| 1 |
<?php
|
| 2 |
// $Id: assignment.module,v 1.4 2006/11/15 02:05:14 rwohleb Exp $
|
| 3 |
|
| 4 |
// hook_help
|
| 5 |
function assignment_help($section) {
|
| 6 |
$output = "";
|
| 7 |
|
| 8 |
switch ($section) {
|
| 9 |
case 'admin/modules#description':
|
| 10 |
$output = t('A simple assignment node.');
|
| 11 |
break;
|
| 12 |
|
| 13 |
case 'node/add#assignment':
|
| 14 |
$output = t('An assignment is a node that you wish to add to a gradebook.');
|
| 15 |
break;
|
| 16 |
}
|
| 17 |
|
| 18 |
return $output;
|
| 19 |
}
|
| 20 |
|
| 21 |
// hook_node_info
|
| 22 |
function assignment_node_info() {
|
| 23 |
return array('assignment' => array('name' => t('assignment'), 'base' => 'assignment'));
|
| 24 |
}
|
| 25 |
|
| 26 |
// hook_perm
|
| 27 |
function assignment_perm() {
|
| 28 |
return array('create assignments', 'edit own assignments');
|
| 29 |
}
|
| 30 |
|
| 31 |
// hook_access
|
| 32 |
function assignment_access($op, $node) {
|
| 33 |
global $user;
|
| 34 |
switch($op) {
|
| 35 |
case 'create':
|
| 36 |
return user_access('create assignments');
|
| 37 |
break;
|
| 38 |
case 'update':
|
| 39 |
case 'delete':
|
| 40 |
if (user_access('edit own assignments') && ($user->uid == $node->uid)) {
|
| 41 |
return TRUE;
|
| 42 |
}
|
| 43 |
break;
|
| 44 |
}
|
| 45 |
return FALSE;
|
| 46 |
}
|
| 47 |
|
| 48 |
// hook_menu
|
| 49 |
function assignment_menu($may_cache) {
|
| 50 |
$items = array();
|
| 51 |
|
| 52 |
if ($may_cache) {
|
| 53 |
$items[] = array('path' => 'node/add/assignment', 'title' => t('assignment'),
|
| 54 |
'access' => user_access('create assignments'));
|
| 55 |
}
|
| 56 |
|
| 57 |
return $items;
|
| 58 |
}
|
| 59 |
|
| 60 |
// hook_settings
|
| 61 |
/*
|
| 62 |
function assignment_settings() {
|
| 63 |
$form = array();
|
| 64 |
|
| 65 |
return $form;
|
| 66 |
}
|
| 67 |
*/
|
| 68 |
|
| 69 |
// hook_form
|
| 70 |
function assignment_form(&$node) {
|
| 71 |
// We need to define form elements for the node's title and body.
|
| 72 |
$form['title'] = array(
|
| 73 |
'#type' => 'textfield',
|
| 74 |
'#title' => t('Title'),
|
| 75 |
'#required' => TRUE,
|
| 76 |
'#default_value' => $node->title,
|
| 77 |
'#weight' => -5
|
| 78 |
);
|
| 79 |
// We want the body and filter elements to be adjacent. We could try doing
|
| 80 |
// this by setting their weights, but another module might add elements to the
|
| 81 |
// form with the same weights and end up between ours. By putting them into a
|
| 82 |
// sub-array together, we're able force them to be rendered together.
|
| 83 |
$form['body_filter']['body'] = array(
|
| 84 |
'#type' => 'textarea',
|
| 85 |
'#title' => t('Body'),
|
| 86 |
'#default_value' => $node->body,
|
| 87 |
'#required' => FALSE
|
| 88 |
);
|
| 89 |
$form['body_filter']['filter'] = filter_form($node->format);
|
| 90 |
|
| 91 |
// Get base form elements.
|
| 92 |
$form = array_merge($form, gradebookapi_assignment_form_elements($node));
|
| 93 |
|
| 94 |
return $form;
|
| 95 |
}
|
| 96 |
|
| 97 |
// This code is already executed in gradebookapi_nodeapi
|
| 98 |
// See bug report: http://drupal.org/node/97406
|
| 99 |
/*
|
| 100 |
function assignment_validate(&$node) {
|
| 101 |
gradebookapi_assignment_validate($node);
|
| 102 |
}
|
| 103 |
|
| 104 |
function assignment_submit(&$node) {
|
| 105 |
//gradebookapi_assignment_submit($node);
|
| 106 |
}
|
| 107 |
|
| 108 |
function assignment_load($node) {
|
| 109 |
return gradebookapi_assignment_load($node);
|
| 110 |
}
|
| 111 |
|
| 112 |
function assignment_insert($node) {
|
| 113 |
gradebookapi_assignment_insert($node);
|
| 114 |
}
|
| 115 |
|
| 116 |
function assignment_update($node) {
|
| 117 |
gradebookapi_assignment_update($node);
|
| 118 |
}
|
| 119 |
|
| 120 |
function assignment_delete($node) {
|
| 121 |
gradebookapi_assignment_delete($node);
|
| 122 |
}
|
| 123 |
*/
|
| 124 |
|
| 125 |
function assignment_form_submit() {
|
| 126 |
}
|