array( 'name' => t('USER-FRIENDLY-NAME'), 'module' => 'hook', 'description' => "CREATE-CONTENT-DESCRIPTION", ) ); } /** * Implementation of hook_perm(). */ function hook_perm() { return array('create hook', 'edit own hook'); } /** * Implementation of hook_access(). */ function hook_access($op, $node) { global $user; if ($op == 'create') { // Only users with permission to do so may create this node type. return user_access('create hook'); } // Users who create a node may edit or delete it later, assuming they have the // necessary permissions. if ($op == 'update' || $op == 'delete') { if (user_access('edit own hook') && ($user->uid == $node->uid)) { return TRUE; } } } /** * Implementation of hook_form(). */ function hook_form(&$node) { $type = node_get_types('type', $node); // We need to define form elements for the node's title and body. $form['title'] = array( '#type' => 'textfield', '#title' => check_plain($type->title_label), '#required' => TRUE, '#default_value' => $node->title, '#weight' => -5 ); // We want the body and filter elements to be adjacent. We could try doing // this by setting their weights, but another module might add elements to the // form with the same weights and end up between ours. By putting them into a // sub-array together, we're able force them to be rendered together. $form['body_filter']['body'] = array( '#type' => 'textarea', '#title' => check_plain($type->body_label), '#default_value' => $node->body, '#required' => FALSE ); $form['body_filter']['filter'] = filter_form($node->format); // NOTE in node_example there is some addition code here not needed for this simple node-type return $form; } /** * Implementation of hook_help(). */ function hook_help($path, $arg) { switch ($path) { case 'admin/help#hook': return t('ADMIN-HELP-TEXT'); break; } } ?>