'schedule/display', 'callback' => 'scheduler_display', 'type' => MENU_CALLBACK, 'access' => user_access('display Schedule'), ); } return $items; } /** * Called by jQuery. */ function scheduler_display() { global $user; $nodelist = scheduler_get_list(); watchdog('scheduler', t('list run by @user accepted', array('@user' => $user->name))); // This print statement will return results to jQuery's request. print drupal_to_js(array('nodeList' => $nodelist)); exit(); } function scheduler_get_list() { $result = db_query('SELECT nid,title FROM {node}'); $rows=array(); while($node = db_fetch_object($result)) { $rows = array($node->nid, $node->title); $rows[]=$row; $output .= $rows[1]; $output .= '
'; }; return $output; } function scheduler_jquery_widget() { // Load the JavaScript and CSS files. drupal_add_js(drupal_get_path('module', 'scheduler') .'/jquery.scheduler.js'); drupal_add_css(drupal_get_path('module', 'scheduler') .'/scheduler.css'); global $user; $nodeTitles = scheduler_get_list(); return theme('scheduler_widget', $nodeTitles); } function theme_scheduler_widget($nodeTitles) { $output = '
'; $output .= '
'; $output .= l(t('Show List'), "schedule/display", array('class' => 'scheduler-link')); $output .= '
'; $output .= '
'; $output .= $nodeTitles; $output .= '
'; $output .= '
'; return $output; } /** * Implementation of hook_nodeapi(). */ function scheduler_nodeapi(&$node, $op, $teaser, $page) { switch ($op) { case 'view': $node->content['scheduler_widget'] = array( '#value' => scheduler_get_list(), '#weight' => 100, ); break; case 'delete': db_query('DELETE FROM {scheduler} WHERE nid = %d', $node->nid); break; } }