Changeset 73
- Timestamp:
- Jan 7, 2007 4:13:31 AM (6 years ago)
- Location:
- trunk/jpdd
- Files:
-
- 2 edited
-
class.jpdd.workshop.php (modified) (6 diffs)
-
sql/db.sql (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/jpdd/class.jpdd.workshop.php
r72 r73 14 14 return array('Update Workshops'); 15 15 } 16 17 16 function getEditPrivilege() { 18 17 return array('Update Workshops'); 18 } 19 20 function getNonAttendees($flavor) { 21 global $jpdd; 22 $jpdd->prepClass('person'); 23 return $jpdd->getSeriesFromSQL('SELECT person.* FROM person LEFT JOIN (SELECT * FROM attendance WHERE workshop_id = '.$this->getID().' AND flavor = '.$jpdd->escStr($flavor).') AS attendance ON (person.id = attendance.person_id) WHERE workshop_id IS NULL', 'JPDD_Person'); 19 24 } 20 25 … … 25 30 } 26 31 32 function addAttendees($ids, $flavor) { 33 global $jpdd; 34 if (!is_array($ids)) { 35 if ($jpdd->isEmpty($ids)) 36 return; 37 $ids = array($ids); 38 } 39 reset($ids); 40 while(list(,$id) = each($ids)) { 41 if (!$jpdd->isEmpty($id)) { 42 $jpdd->executeSQL('INSERT INTO attendance (person_id, workshop_id, flavor) VALUES ('.(int)$id.', '.$this->getID().', '.$jpdd->escStr($flavor).')'); 43 } 44 } 45 } 46 function dropAttendees($ids, $flavor) { 47 global $jpdd; 48 if (!is_array($ids)) { 49 if ($jpdd->isEmpty($ids)) 50 return; 51 $ids = array($ids); 52 } 53 $jpdd->executeSQL('DELETE FROM attendance WHERE workshop_id = '.$this->getID().' AND flavor = '.$jpdd->escStr($flavor).' AND person_id IN ('.join(',', array_map('intval', $ids)).')'); 54 } 55 56 27 57 function getFormInnards() { 28 58 global $jpdd; 59 $nonpresenters = $this->getNonAttendees('presenter'); 60 $presenters = $this->getAttendees('presenter'); 61 29 62 return '<div> 30 63 <label>Title<br/><input type="text" size="72" name="title" value="'.$this->getTitle(true).'"/></label><br/> … … 34 67 <label>Min. Attendees: <input type="text" size="2" maxlength="2" name="min_attendees" value="'.($jpdd->isEmpty($this->_min_attendees) ? '' : (int)$this->_min_attendees).'"/></label><br/> 35 68 <label>Max. Attendees: <input type="text" size="2" maxlength="2" name="max_attendees" value="'.($jpdd->isEmpty($this->_max_attendees) ? '' : (int)$this->_max_attendees).'"/></label> 69 </div> 70 <div> 71 '.(0 == count($presenters)?'':'Presented by:<br/><ul>'. 72 join("\n", array_map(create_function('$h', 'return "<li>".$h->getLinkedTitle()." <label>[<input type=\"checkbox\" name=\"remove_presenters[]\" value=\"".$h->getID()."\"/>remove]</label>";'), $presenters)).'</ul>').' 73 <label>Add Presenter:<br/><select name="new_presenters[]"> 74 <option value=""></option> 75 '.join("\n", array_map(create_function('$h', "return '<option value=\"'.\$h->getID().'\">'.\$h->getTitle().'</option>';"), $nonpresenters)).' 76 </select></label> 36 77 </div> 37 78 </div>'; … … 60 101 } else { 61 102 $this->JPDD_Workshop(array('id' => $this->getID())); 103 $this->addAttendees($_POST['new_presenters'], 'presenter'); 104 $this->dropAttendees($_POST['remove_presenters'], 'presenter'); 62 105 return true; 63 106 } … … 79 122 } else { 80 123 $this->JPDD_Workshop(array('data' => $jpdd->getSingletonFromSQL('SELECT * from workshop WHERE id = currval(\'workshop_id_seq\')'))); 124 $this->addAttendees($_POST['new_presenters'], 'presenter'); 81 125 return true; 82 126 } … … 91 135 } 92 136 93 $ret .= '<div class="workshop-blurb">'.$this->getDescription().'</div>'; 137 // silly debugging: 138 // $nonpresenters = $this->getNonAttendees('presenter'); 139 // $ret .= 'Non-presenters: <ul>'.join("\n", array_map(create_function('$xx', 'return "<li>".$xx->getLinkedTitle();'), $nonpresenters)).'</ul>'; 94 140 95 141 $ret .= '<div class="attendance">Min. Attendees: '.(int)($this->_min_attendees).'<br/>'. -
trunk/jpdd/sql/db.sql
r72 r73 302 302 REVOKE ALL ON TABLE attendance FROM dkg; 303 303 GRANT ALL ON TABLE attendance TO dkg; 304 GRANT SELECT ON TABLE attendance TO "www-data"; 304 GRANT INSERT,SELECT,DELETE ON TABLE attendance TO "www-data"; 305 306 307 -- 308 -- Name: attendance_id_seq; Type: ACL; Schema: public; Owner: dkg 309 -- 310 311 REVOKE ALL ON TABLE attendance_id_seq FROM PUBLIC; 312 REVOKE ALL ON TABLE attendance_id_seq FROM dkg; 313 GRANT ALL ON TABLE attendance_id_seq TO dkg; 314 GRANT SELECT,UPDATE ON TABLE attendance_id_seq TO "www-data"; 305 315 306 316
Note: See TracChangeset
for help on using the changeset viewer.

