Changeset 120
- Timestamp:
- 13/10/07 02:59:34 (5 years ago)
- Location:
- roster/trunk
- Files:
-
- 2 edited
-
roster.install (modified) (1 diff)
-
roster.module (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
roster/trunk/roster.install
r115 r120 14 14 PRIMARY KEY (bid))"); 15 15 16 db_query("CREATE TABLE {roster_assignment} ( 17 bid int unsigned NOT NULL default '0', 18 person int unsigned NOT NULL default '0', 19 period int unsigned NOT NULL default '0', 20 notes text, 21 PRIMARY KEY (bid, person, period))"); 16 db_query("CREATE TABLE IF NOT EXISTS {roster_assignment} ( 17 `aid` int(11) NOT NULL auto_increment, 18 `bid` int(10) unsigned NOT NULL default '0', 19 `person` int(10) unsigned NOT NULL default '0', 20 `period` int(10) unsigned NOT NULL default '0', 21 `notes` text, 22 PRIMARY KEY (`aid`) 23 )"); 22 24 23 25 break; -
roster/trunk/roster.module
r119 r120 67 67 } 68 68 69 /** 70 * Rewrite the form callbacks so that roster_assignment_form* 71 * use the roster_assignment_form method 72 */ 69 73 function roster_forms() { 70 71 74 # get the form id 72 75 $args = func_get_args(); … … 84 87 } 85 88 89 /** 90 * Get the booth information 91 */ 86 92 function roster_get_booth($bid){ 87 93 $results = db_query("SELECT bid, name, last_votes, last_votes_total FROM {roster_booths} WHERE bid = %d", $bid); … … 89 95 } 90 96 97 /** 98 * Get all the booths for an election 99 */ 91 100 function roster_get_booths($nid){ 92 101 $res = array(); … … 99 108 } 100 109 110 /** 111 * Get the roster for an election, and use the booth_id then period as the key 112 */ 101 113 function roster_get_roster($nid){ 102 114 $res = array(); … … 108 120 else 109 121 $booth = array(); 110 $booth[$row->period] = $row; 122 if ($booth[$row->period] == NULL) 123 $booth[$row->period] = array($row); 124 else 125 $booth[$row->period][] = $row; 111 126 $res[$row->bid] = $booth; 112 127 } … … 114 129 } 115 130 131 /** 132 * Intercept load and save calls so we can use the body to store the extra details 133 */ 116 134 function roster_nodeapi(&$node, $op){ 117 135 switch($op){ … … 216 234 '#weight' => 1, 217 235 ); 236 237 // Get roster data 218 238 $booths = roster_get_booths($node->nid); 219 239 $roster = roster_get_roster($node->nid); … … 224 244 } 225 245 246 // Init unique form ID 226 247 $rosterFormId = 0; 227 248 249 // Format roster table for display 228 250 $table = "<table><tr><th>Booth</th><th>Morning</th><th>Afternoon</th></tr>"; 229 251 foreach ($booths as $booth){ 230 252 $table .= "<tr><td>".l($booth->name,'node/'.arg(1).'/booth/'.$booth->bid)."</td>"; 231 $person = ($roster[$booth->bid] != NULL)?$roster[$booth->bid][0]:NULL; 232 $table .= "<td>".drupal_get_form('roster_assignment_form'.$rosterFormId++, $users, $person, $booth->bid, 0)."</td>"; 233 $person = ($roster[$booth->bid] != NULL)?$roster[$booth->bid][1]:NULL; 234 $table .= "<td>".drupal_get_form('roster_assignment_form'.$rosterFormId++, $users, $person, $booth->bid, 1)."</td>"; 253 $people = ($roster[$booth->bid] != NULL)?$roster[$booth->bid][0]:NULL; 254 $table .= "<td>"; 255 foreach ($people as $person) 256 drupal_get_form('roster_assignment_form'.$rosterFormId++, $users, $person, $booth->bid, 0); 257 // A new one too 258 drupal_get_form('roster_assignment_form'.$rosterFormId++, $users, NULL, $booth->bid, 0); 259 $table .= "</td>"; 260 $people = ($roster[$booth->bid] != NULL)?$roster[$booth->bid][1]:NULL; 261 $table .= "<td>"; 262 foreach ($people as $person) 263 drupal_get_form('roster_assignment_form'.$rosterFormId++, $users, $person, $booth->bid, 1) 264 // A new one too 265 drupal_get_form('roster_assignment_form'.$rosterFormId++, $users, NULL, $booth->bid, 1) 266 $table .= "</td>"; 235 267 $table .= "</tr>"; 236 268 } … … 241 273 ); 242 274 275 // Set body to null to hide on the view 243 276 $node->content['body'] = NULL; 244 277 return $node; … … 268 301 } 269 302 303 /** 304 * Get the CiviCRM group members by group id 305 */ 270 306 function roster_get_group_members($group_id) { 271 307 // Check if CiviCRM is installed here. … … 278 314 $groups =& crm_get_groups(array('id' => $group_id)); 279 315 280 // Pass 'group' => group.id into search API to find members of that group281 // Only one group with that title, so we can reference282 // first object in returned array from get_groups.283 316 $params = array('group' => array($groups[0]->id => 1)); 284 317 … … 294 327 } 295 328 329 /** 330 * Get a list of the CiviCRM groups 331 */ 296 332 function roster_get_groups() { 297 333 // Check if CiviCRM is installed here.
Note: See TracChangeset
for help on using the changeset viewer.
