array('name' => t('bookmark'), 'base' => 'bookmark')); } /** * Implementation of hook_perm(). */ function bookmark_perm() { return array('create bookmark', 'edit own bookmarks'); } /** * Implementation of hook_access(). */ function bookmark_access($op, $node) { global $user; print_r($node); if ($op == 'create') { return user_access('create bookmark'); } if ($op == 'update' || $op == 'delete') { if (user_access('edit own bookmarks') && ($user->uid == $node->uid)) { return TRUE; } } } /** * Implementation of hook_menu(). */ function bookmark_menu($may_cache) { $items = array(); if ($may_cache) { $items[] = array('path' => 'node/add/bookmark', 'title' => t('bookmark'), 'access' => user_access('create bookmark')); } return $items; } /** * Implementation of hook_form(). */ function bookmark_form(&$node) { $form['title'] = array( '#type' => 'textfield', '#title' => t('Name'), '#required' => TRUE, '#default_value' => $node->title, '#weight' => -10); $form['link'] = array( '#type' => 'textfield', '#title' => t('Address (URL)'), '#required' => TRUE, '#default_value' => $node->link, '#weight' => -9); $form['description'] = array( '#type' => 'textarea', '#title' => t('Description'), '#required' => FALSE, '#default_value' => $node->description, '#weight' => -8); return $form; } /* * Implementation of hook_insert() */ function bookmark_insert($node) { db_query("INSERT INTO {bookmark} (nid, title, link, description) VALUES (%d, '%s', '%s', '%s')", $node->nid, $node->title, $node->link, $node->description); } /* * Implementation of hook_delete */ function bookmark_delete($node) { db_query("DELETE FROM {bookmark} WHERE nid = %d", $node->nid); } /* * Implementation of hook_update() */ function bookmark_update($node) { db_query("UPDATE {bookmark} SET title = '%s', link = '%s', description = '%s' WHERE nid = %d", $node->title, $node->link, $node->description, $node->nid); } /* * Implementation of hook_load() */ function bookmark_load($node) { $additions = db_fetch_object(db_query('SELECT title, link, description FROM {bookmark} WHERE nid = %d', $node->nid)); return $additions; } /* * Implementation of hook_view() */ function bookmark_view(&$node, $teaser = FALSE, $page = FALSE) { $node = node_prepare($node, $teaser); $order_info = theme('bookmark_order_info', $node); $node->body .= $order_info; $node->teaser .= $order_info; } function theme_bookmark_order_info($node) { $output = '
'; $output .= t('Link: %link
', array('%link' => check_plain($node->link))); $output .= t('Description: %description', array('%description' => check_plain($node->description))); $output .= '
'; return $output; }