| [ Index ] |
PHP Cross Reference of Drupal 6 (gatewave) |
[Summary view] [Print] [Text view]
1 <?php 2 // $Id: station_program.module,v 1.22 2010/01/12 07:22:37 drewish Exp $ 3 4 /** 5 * Implementation of hook_help(). 6 */ 7 function station_program_help($path, $arg) { 8 switch ($path) { 9 case 'admin/settings/station/program': 10 return t("These settings allow you to configure the station's program node."); 11 } 12 } 13 14 /** 15 * Implementation of hook_menu(). 16 */ 17 function station_program_menu() { 18 $items['station/autocomplete/program'] = array( 19 'title' => 'program autocomplete', 20 'page callback' => 'station_program_autocomplete', 21 'access arguments' => array('access content'), 22 'type' => MENU_CALLBACK, 23 ); 24 return $items; 25 } 26 27 /** 28 * Implementation of hook_node_info(). 29 */ 30 function station_program_node_info() { 31 return array( 32 'station_program' => array( 33 'name' => t('Program'), 34 'module' => 'station_program', 35 'description' => t('A radio program that you can schedule.'), 36 'has_title' => TRUE, 37 'title_label' => t('Title'), 38 'has_body' => TRUE, 39 'body_label' => t('Description'), 40 ) 41 ); 42 } 43 44 /** 45 * Implementation of hook_perm(). 46 */ 47 function station_program_perm() { 48 return array( 49 'administer station programs', 50 'view station program content', 51 'create station program content', 52 'edit any station program content', 53 'edit own station program content', 54 'delete any station program content', 55 ); 56 } 57 58 /** 59 * Implementation of hook_access(). 60 */ 61 function station_program_access($op, $node, $account) { 62 if (user_access('administer station programs', $account)) { 63 return TRUE; 64 } 65 66 switch ($op) { 67 case 'view': 68 return user_access('view station program content', $account); 69 70 case 'create': 71 return user_access('create station program content', $account); 72 73 case 'update': 74 if (user_access('edit any station program content', $account)) { 75 return TRUE; 76 } 77 78 // The node owner can edit the program. 79 if (user_access('edit own station program content', $account)) { 80 if ($node->uid == $account->uid) { 81 return TRUE; 82 } 83 84 // If the schedule is enabled, let DJs edit the program. 85 if (module_exists('station_schedule')) { 86 if (!empty($node->field_station_program_dj)) { 87 foreach ($node->field_station_program_dj as $delta => $user) { 88 if ($user['uid'] == $account->uid) { 89 return TRUE; 90 } 91 } 92 } 93 } 94 } 95 return FALSE; 96 97 case 'delete': 98 return user_access('delete any station program content', $account); 99 } 100 } 101 102 /** 103 * Implementation of hook_form(). 104 */ 105 function station_program_form(&$node) { 106 $type = node_get_types('type', $node); 107 108 $form['title'] = array( 109 '#type' => 'textfield', 110 '#title' => check_plain($type->title_label), 111 '#default_value' => $node->title, 112 '#required' => TRUE, 113 '#maxlength' => 128, 114 '#description' => t('The name of the program. You should avoid making major changes to this without telling the programming director.'), 115 ); 116 // $form['genre'] = array( 117 // '#type' => 'textfield', 118 // '#title' => t('Text genre'), 119 // '#description' => t('A free-form description of the musical genres played on the program.'), 120 // '#default_value' => $node->genre, 121 // '#required' => true, 122 // '#maxlength' => 200, 123 // '#weight' => -2, 124 // ); 125 // $form['url'] = array( 126 // '#type' => 'textfield', 127 // '#title' => t('Homepage URL'), 128 // '#description' => t("Link to the program's website."), 129 // '#default_value' => $node->url, 130 // '#maxlength' => 255, 131 // '#weight' => -1, 132 // ); 133 if ($type->has_body) { 134 $form['body_filter']['body'] = array( 135 '#type' => 'textarea', 136 '#title' => check_plain($type->body_label), 137 '#default_value' => $node->body, 138 '#rows' => 10, 139 '#required' => ($type->min_word_count > 0), 140 '#description' => t("Free form description of the show."), 141 ); 142 $form['body_filter']['format'] = filter_form($node->format); 143 } 144 145 return $form; 146 } 147 148 /** 149 * Retrieve a pipe delimited string of autocomplete suggestions for existing programs 150 */ 151 function station_program_autocomplete($string = '') { 152 $matches = array(); 153 $result = db_query_range("SELECT DISTINCT title FROM {node} WHERE type = 'station_program' AND LOWER(title) LIKE LOWER('%s%%') AND status = 1 ORDER BY title", $string, 0, 10); 154 while ($program = db_fetch_object($result)) { 155 $matches[$program->title] = check_plain($program->title); 156 } 157 print drupal_to_js($matches); 158 exit(); 159 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Thu Mar 24 11:18:33 2011 | Cross-referenced by PHPXref 0.7 |