'admin/settings/timetracker', 'title' => t('On this date module settings'), 'callback' => 'drupal_get_form', 'callback arguments' => 'timetracker_admin', 'access' => user_access('access administration pages'), 'type' => MENU_NORMAL_ITEM, ); */ /* link to the main punch interface */ $items[] = array( 'path' => 'timetracker', 'title' => t('Timetracker'), 'callback' => 'timetracker_page', 'access' => user_access('timetracking'), 'type' => MENU_NORMAL_ITEM /* note: not a MENU_CALLBACK, since we want this toplevel */ ); return $items; } /** * Generate or list blocks provided by this module * @param op the operation from the URL * @param delta offset * @returns block HTML */ function timetracker_block($op='list', $delta=0) { /* listing of blocks, such as on the admin/block page */ if ($op == "list") { $i = 0; $block[$i++]["info"] = t('Quick punch'); $block[$i++]["info"] = t('Active punches'); $block[$i++]["info"] = t('Punched in users'); $block[$i++]["info"] = t('My last punches'); $block[$i++]["info"] = t('Recent punches'); $block[$i++]["info"] = t('My recent punches'); return $block; } elseif ($op == "view") { switch ($delta) { case 0: default: $content = 'Block not implemented yet'; break; } return $content; } } // end timetracker_block /** * Complete punch interface */ function timetracker_punch_form() { $output = ''; $form = array(); $form['tags'] = array('#type' => 'textfield', '#title' => t('Tags'), '#default_value' => $edit['tags'], '#size' => 60, '#maxlength' => 64, '#description' => t('A comma-separated list of terms describing this content. Example: customerX, role:webdev, tobill, random...'), ); $form['comment'] = array('#type' => 'textfield', '#title' => t('Comment'), '#default_value' => $edit['comment'], '#size' => 60, '#maxlength' => 255, '#description' => t('A comment describing your work in more details.'), ); $form['submit'] = array('#type' => 'submit', '#value' => t('Save'), ); return $form; } /** * Validate the complete punch interface * * @see timetracker_punch_form() */ function timetracker_punch_form_validate($form_id, $form_values) { if ($form_values['tags'] == '') { form_set_error('', t('You must choose tags for your punch.')); } } /** * Input data the complete punch interface * * @see timetracker_punch_form() */ function timetracker_punch_form_submit($form_id, $form_values) { // TODO: enter data in the database here drupal_set_message('tags changed'); } /** * Generate the main interface to the timetracker */ function timetracker_page() { $output .= drupal_get_form('timetracker_punch_form'); print theme('page', $output); }