/** * Implementation of hook_menu(). */ function identity_menu() { // This is the minimum information you can provide for a menu item. $items['TODO: Enter path'] = array( 'title' => 'TODO: Enter menu item title', 'page callback' => 'TODO: Enter callback function', 'access arguments' => array('TODO: Enter user permissions'), ); // more complex menu item $items['TODO: Enter path'] = array( 'title' => 'TODO: Enter menu item title', 'description' => 'TODO: Enter description', 'page callback' => 'TODO: Enter callback function', 'page arguments' => '', // An array of arguments to pass to the page callback function. Integer values pass the corresponding URL component. 'access callback' => '', // defaults to user_access() 'access arguments' => array('TODO: Enter user permissions'), 'weight' => 0, 'type' => MENU_NORMAL_ITEM, // One of MENU_NORMAL_ITEM / MENU_CALLBACK / MENU_SUGGESTED_ITEM / MENU_LOCAL_TASK / MENU_DEFAULT_LOCAL_TASK 'menu_name' => '', // Menu to place this item in. 'title callback' => '', // Function to generate the title, defaults to t(). 'title arguments' => '', // Arguments to send to t() or your custom callback. ); // OPTIONAL: Fill in additional static menu items return $items; } /** * Implementation of hook_perm(). */ function identity_perm() { return array('create Identity', 'edit own Identity'); } /** * Implementation of hook_elements(). */ function identity_elements() { $type['example'] = array('#property' => t('TODO: Fill in appropriate properties and values for element type.')); // OPTIONAL: Define additional element types. return $type; } /** * Implementation of hook_node_info(). */ function identity_node_info() { ############## WORK: add INFO to these!!!! return array( 'identity' => array( 'name' => '', /* INFO: the human-readable name of the node type. Required. */ 'module' => '', /* INFO: a string telling Drupal how a module's functions map to hooks (i.e. if module is defined as example_foo, then example_foo_insert will be called when inserting a node of that type). This string is usually the name of the module in question, but not always. Required. */ 'description' => '', 'help' => '', 'has_title' => '', 'title_label' => '', 'has_body' => '', 'body_label' => '', 'min_word_count' => '', 'locked' => '', /* INFO: boolean indicating whether the machine-readable name of this content type can (FALSE) or cannot (TRUE) be edited by a site administrator. Optional (defaults to TRUE). */ ), // add further types as needed ); } /** * Implementation of hook_access(). */ function identity_access($op, $node, $account) { global $user; if ($op == 'create') { return user_access('create Identity'); } if ($op == 'update' || $op == 'delete') { if (user_access('edit own Identity') && ($user->uid == $node->uid)) { return TRUE; } } } /** * Implementation of hook_form(). */ function identity_form(&$node, $form_state) { // The site admin can decide if this node type has a title and body, and how // the fields should be labeled. We need to load these settings so we can // build the node form correctly. $type = node_get_types('type', $node); if ($type->has_title) { $form['title'] = array( '#type' => 'textfield', '#title' => check_plain($type->title_label), '#required' => TRUE, '#default_value' => $node->title, '#weight' => -5 ); } if ($type->has_body) { // In Drupal 6, we can use node_body_field() to get the body and filter // elements. This replaces the old textarea + filter_form() method of // setting this up. It will also ensure the teaser splitter gets set up // properly. $form['body_field'] = node_body_field($node, $type->body_label, $type->min_word_count); } // TODO: Enter additional form elements return $form; } /** * Implementation of hook_validate(). */ function identity_validate($node, &$form) { // TODO: Enter form validation code here if (0) { // if bad stuff form_set_error('FORM ELEMENT NAME', t('TODO: Write an error message.')); } } /** * Implementation of hook_insert(). */ function identity_insert($node) { // TODO: Enter database insertion query here, for example: // db_query("INSERT INTO {node_example} (vid, nid, color, quantity) VALUES (%d, %d, '%s', %d)", $node->vid, $node->nid, $node->color, $node->quantity); } /** * Implementation of hook_update(). */ function identity_update($node) { // if this is a new node or we're adding a new revision, if ($node->revision) { identity_insert($node); } else { // TODO: Enter database update query here, for example: // db_query("UPDATE {node_example} SET color = '%s', quantity = %d WHERE vid = %d", $node->color, $node->quantity, $node->vid); } } /** * Implementation of hook_delete(). */ function identity_delete(&$node) { // TODO: Enter database deletion query here, for example: // db_query('DELETE FROM {node_example} WHERE nid = %d', $node->nid); } /** * Implementation of hook_load(). */ function identity_load($node) { // TODO: Obtain and return additional fields added to the node type, for example: // $additions = db_fetch_object(db_query('SELECT color, quantity FROM {node_example} WHERE vid = %d', $node->vid)); // return $additions; } /** * Implementation of hook_view(). */ function identity_view($node, $teaser = FALSE, $page = FALSE) { // TODO: Insert additional code (call to theme functions, etc.) to execute when viewing a node, for example: // $node = node_prepare($node, $teaser); // $node->content['myfield'] = array( // '#value' => theme('node_example_order_info', $node), // '#weight' => 1, // ); return $node; } /** * Implementation of hook_footer(). */ function identity_footer($main = 0) { } /** * Implementation of hook_form_alter(). */ function identity_form_alter(&$form, &$form_state, $form_id) { }