Changeset 9960
- Timestamp:
- 11/17/08 09:11:37 (2 months ago)
- Files:
-
- branches/0.8/jaws/html/gadgets/Poll/AdminModel.php (modified) (11 diffs)
- branches/0.8/jaws/html/gadgets/Poll/HTML.php (modified) (3 diffs)
- branches/0.8/jaws/html/gadgets/Poll/Info.php (modified) (1 diff)
- branches/0.8/jaws/html/gadgets/Poll/LayoutHTML.php (modified) (4 diffs)
- branches/0.8/jaws/html/gadgets/Poll/templates/Poll.html (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/0.8/jaws/html/gadgets/Poll/AdminModel.php
r9935 r9960 75 75 function UpdateGadget($old, $new) 76 76 { 77 if (version_compare($old, '0.8.0', '<')) { 78 $result = $this->installSchema('schema.xml', '', "$old.xml"); 79 if (Jaws_Error::IsError($result)) { 80 return $result; 81 } 82 83 $result = $this->installSchema('insert.xml', '', 'schema.xml', true); 84 if (Jaws_Error::IsError($result)) { 85 return $result; 86 } 87 88 // ACL keys 89 $GLOBALS['app']->ACL->NewKey('/ACL/gadgets/Poll/ManagePolls', 'true'); 90 $GLOBALS['app']->ACL->NewKey('/ACL/gadgets/Poll/ManageGroups', 'true'); 91 $GLOBALS['app']->ACL->NewKey('/ACL/gadgets/Poll/ViewReports', 'true'); 92 $GLOBALS['app']->ACL->DeleteKey('/ACL/gadgets/Poll/AddPoll'); 93 $GLOBALS['app']->ACL->DeleteKey('/ACL/gadgets/Poll/EditPoll'); 94 $GLOBALS['app']->ACL->DeleteKey('/ACL/gadgets/Poll/DeletePoll'); 95 $GLOBALS['app']->ACL->DeleteKey('/ACL/gadgets/Poll/UpdateProperties'); 96 97 // Registry keys. 98 $GLOBALS['app']->Registry->NewKey('/gadgets/Poll/cookie_period', '150'); 99 } 100 101 //rename layout action 102 $layoutModel = $GLOBALS['app']->LoadGadget('Layout', 'AdminModel'); 103 $result = $layoutModel->ChangeGadgetActionName('Poll', 'Display', 'ViewPoll'); 77 $result = $this->installSchema('schema.xml', '', "$old.xml"); 104 78 if (Jaws_Error::IsError($result)) { 105 79 return $result; 106 80 } 81 82 $result = $this->installSchema('insert.xml', '', 'schema.xml', true); 83 if (Jaws_Error::IsError($result)) { 84 return $result; 85 } 86 87 // ACL keys 88 $GLOBALS['app']->ACL->NewKey('/ACL/gadgets/Poll/ManagePolls', 'true'); 89 $GLOBALS['app']->ACL->NewKey('/ACL/gadgets/Poll/ManageGroups', 'true'); 90 $GLOBALS['app']->ACL->NewKey('/ACL/gadgets/Poll/ViewReports', 'true'); 91 $GLOBALS['app']->ACL->DeleteKey('/ACL/gadgets/Poll/AddPoll'); 92 $GLOBALS['app']->ACL->DeleteKey('/ACL/gadgets/Poll/EditPoll'); 93 $GLOBALS['app']->ACL->DeleteKey('/ACL/gadgets/Poll/DeletePoll'); 94 $GLOBALS['app']->ACL->DeleteKey('/ACL/gadgets/Poll/UpdateProperties'); 95 96 // Registry keys. 97 $GLOBALS['app']->Registry->NewKey('/gadgets/Poll/cookie_period', '150'); 107 98 108 99 return true; … … 143 134 return new Jaws_Error(_t('POLL_ERROR_POLL_NOT_ADDED'), _t('POLL_NAME')); 144 135 } 145 146 //remove cached files147 $GLOBALS['app']->Cache->delete('Poll', 'LastPoll');148 $GLOBALS['app']->Cache->delete('Poll', 'ListOfPolls');149 $GLOBALS['app']->Cache->delete('Poll', 'DefaultAction');150 136 151 137 $GLOBALS['app']->Session->PushLastResponse(_t('POLL_POLLS_ADDED'), RESPONSE_NOTICE); … … 196 182 } 197 183 198 //remove cached files199 $GLOBALS['app']->Cache->delete('Poll', 'LastPoll');200 $GLOBALS['app']->Cache->delete('Poll', 'ListOfPolls');201 $GLOBALS['app']->Cache->delete('Poll', 'DefaultAction');202 $GLOBALS['app']->Cache->delete('Poll', 'ViewPoll', $pid);203 $GLOBALS['app']->Cache->delete('Poll', 'ViewResult', $pid);204 205 184 $GLOBALS['app']->Session->PushLastResponse(_t('POLL_POLLS_UPDATED'), RESPONSE_NOTICE); 206 185 return true; … … 222 201 return new Jaws_Error(_t('POLL_ERROR_POLL_NOT_DELETED'), _t('POLL_NAME')); 223 202 } 224 225 //remove cached files226 $GLOBALS['app']->Cache->delete('Poll', 'LastPoll');227 $GLOBALS['app']->Cache->delete('Poll', 'ListOfPolls');228 $GLOBALS['app']->Cache->delete('Poll', 'DefaultAction');229 $GLOBALS['app']->Cache->delete('Poll', 'ViewPoll', $pid);230 $GLOBALS['app']->Cache->delete('Poll', 'ViewResult', $pid);231 203 232 204 $sql = 'DELETE FROM [[poll_answers]] WHERE [pid] = {pid}'; … … 264 236 } 265 237 if (!$found) { 266 $this->DeleteAnswer($ pid, $oldAnswer['id']);238 $this->DeleteAnswer($oldAnswer['id']); 267 239 } 268 240 } … … 278 250 } 279 251 if ($found) { 280 $res = $this->UpdateAnswer($ pid, $newAnswer['id'], $newAnswer['answer'], $index);252 $res = $this->UpdateAnswer($newAnswer['id'], $newAnswer['answer'], $index); 281 253 if (Jaws_Error::IsError($res)) { 282 254 $GLOBALS['app']->Session->PushLastResponse(_t('POLL_ERROR_ANSWER_NOT_UPDATED'), RESPONSE_ERROR); … … 323 295 } 324 296 325 //remove cached files326 $GLOBALS['app']->Cache->delete('Poll', 'LastPoll');327 $GLOBALS['app']->Cache->delete('Poll', 'ViewPoll', $pid);328 $GLOBALS['app']->Cache->delete('Poll', 'ViewResult', $pid);329 330 297 return true; 331 298 } … … 339 306 * @return boolean True if the answer was updated and false on error 340 307 */ 341 function UpdateAnswer($ pid, $aid, $answer, $rank)308 function UpdateAnswer($aid, $answer, $rank) 342 309 { 343 310 $sql = ' … … 358 325 } 359 326 360 //remove cached files361 $GLOBALS['app']->Cache->delete('Poll', 'LastPoll');362 $GLOBALS['app']->Cache->delete('Poll', 'ViewPoll', $pid);363 $GLOBALS['app']->Cache->delete('Poll', 'ViewResult', $pid);364 365 327 return true; 366 328 } … … 373 335 * @return boolean True if the answer was deleted and false on error 374 336 */ 375 function DeleteAnswer($ pid, $aid)337 function DeleteAnswer($aid) 376 338 { 377 339 $sql = 'DELETE FROM [[poll_answers]] WHERE [id] = {aid}'; … … 381 343 return new Jaws_Error(_t('POLL_ERROR_ANSWER_NOT_DELETED'), _t('POLL_NAME')); 382 344 } 383 384 //remove cached files385 $GLOBALS['app']->Cache->delete('Poll', 'LastPoll');386 $GLOBALS['app']->Cache->delete('Poll', 'ViewPoll', $pid);387 $GLOBALS['app']->Cache->delete('Poll', 'ViewResult', $pid);388 345 389 346 return true; branches/0.8/jaws/html/gadgets/Poll/HTML.php
r9926 r9960 56 56 $model->AddAnswerVote($post['pid'], $aid); 57 57 } 58 59 //remove cached files60 $GLOBALS['app']->Cache->delete('Poll', 'ViewResult', $post['pid']);61 58 } 62 59 } … … 107 104 $request =& Jaws_Request::getInstance(); 108 105 $pid = $request->get('id', 'get'); 109 return $layoutGadget-> ViewPoll($pid);106 return $layoutGadget->Display($pid); 110 107 } 111 108 … … 118 115 function ViewResult() 119 116 { 120 //cache output of this action121 $GLOBALS['app']->Layout->SetCurrentActionCacheable();122 123 117 $request =& Jaws_Request::getInstance(); 124 118 $pid = $request->get('id', 'get'); branches/0.8/jaws/html/gadgets/Poll/Info.php
r9930 r9960 17 17 $this->GadgetName(_t('POLL_NAME')); 18 18 $this->GadgetDescription(_t('POLL_DESCRIPTION')); 19 $this->GadgetVersion('0.8. 1');19 $this->GadgetVersion('0.8.0'); 20 20 $this->Doc('gadget/Poll'); 21 21 branches/0.8/jaws/html/gadgets/Poll/LayoutHTML.php
r9926 r9960 36 36 if (!Jaws_Error::isError($polls)) { 37 37 foreach ($polls as $poll) { 38 $actions[' ViewPoll(' . $poll['id'] . ')'] = array(38 $actions['Display(' . $poll['id'] . ')'] = array( 39 39 'mode' => 'LayoutAction', 40 40 'name' => $poll['question'], … … 56 56 function LastPoll() 57 57 { 58 return $this-> ViewPoll(0);58 return $this->Display(0); 59 59 } 60 60 … … 67 67 function ListOfPolls() 68 68 { 69 //cache output of this action70 $GLOBALS['app']->Layout->SetCurrentActionCacheable();71 72 69 $tpl = new Jaws_Template('gadgets/Poll/templates/'); 73 70 $tpl->Load('Polls.html'); … … 96 93 * @access public 97 94 */ 98 function ViewPoll($pid = 0)95 function Display($pid = 0) 99 96 { 100 //cache output of this action101 $GLOBALS['app']->Layout->SetCurrentActionCacheable();102 103 97 $model = $GLOBALS['app']->LoadGadget('Poll', 'Model'); 104 98 if (empty($pid)) { branches/0.8/jaws/html/gadgets/Poll/templates/Poll.html
r9942 r9960 2 2 <div class="gadget poll"> 3 3 <h2>{title}</h2> 4 <form action="{base_script}" name="poll_form_{pid}"method="post">4 <form action="{base_script}" method="post"> 5 5 <input type="hidden" name="gadget" value="Poll" /> 6 6 <input type="hidden" name="action" value="Vote" /> … … 15 15 </div> 16 16 <div class="actions">{result_link} {btn_vote}</div> 17 <!-- BEGIN cookie -->18 <script type="text/javascript">19 if (-1 != document.cookie.indexOf('poll_' + {pid})) {20 document.poll_form_{pid}.onsubmit = function() {21 return false;22 }23 }24 </script>25 <!-- END cookie -->26 17 </form> 27 18 </div>
