Changeset 9960

Show
Ignore:
Timestamp:
11/17/08 09:11:37 (2 months ago)
Author:
afz
Message:

revert Poll gadget changes to before starting cache stuffs

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/0.8/jaws/html/gadgets/Poll/AdminModel.php

    r9935 r9960  
    7575    function UpdateGadget($old, $new) 
    7676    { 
    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"); 
    10478        if (Jaws_Error::IsError($result)) { 
    10579            return $result; 
    10680        } 
     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'); 
    10798 
    10899        return true; 
     
    143134            return new Jaws_Error(_t('POLL_ERROR_POLL_NOT_ADDED'), _t('POLL_NAME')); 
    144135        } 
    145  
    146         //remove cached files 
    147         $GLOBALS['app']->Cache->delete('Poll', 'LastPoll'); 
    148         $GLOBALS['app']->Cache->delete('Poll', 'ListOfPolls'); 
    149         $GLOBALS['app']->Cache->delete('Poll', 'DefaultAction'); 
    150136 
    151137        $GLOBALS['app']->Session->PushLastResponse(_t('POLL_POLLS_ADDED'), RESPONSE_NOTICE); 
     
    196182        } 
    197183 
    198         //remove cached files 
    199         $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  
    205184        $GLOBALS['app']->Session->PushLastResponse(_t('POLL_POLLS_UPDATED'), RESPONSE_NOTICE); 
    206185        return true; 
     
    222201            return new Jaws_Error(_t('POLL_ERROR_POLL_NOT_DELETED'), _t('POLL_NAME')); 
    223202        } 
    224  
    225         //remove cached files 
    226         $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); 
    231203 
    232204        $sql = 'DELETE FROM [[poll_answers]] WHERE [pid] = {pid}'; 
     
    264236            } 
    265237            if (!$found) { 
    266                 $this->DeleteAnswer($pid, $oldAnswer['id']); 
     238                $this->DeleteAnswer($oldAnswer['id']); 
    267239            } 
    268240        } 
     
    278250            } 
    279251            if ($found) { 
    280                 $res = $this->UpdateAnswer($pid, $newAnswer['id'], $newAnswer['answer'], $index); 
     252                $res = $this->UpdateAnswer($newAnswer['id'], $newAnswer['answer'], $index); 
    281253                if (Jaws_Error::IsError($res)) { 
    282254                    $GLOBALS['app']->Session->PushLastResponse(_t('POLL_ERROR_ANSWER_NOT_UPDATED'), RESPONSE_ERROR); 
     
    323295        } 
    324296 
    325         //remove cached files 
    326         $GLOBALS['app']->Cache->delete('Poll', 'LastPoll'); 
    327         $GLOBALS['app']->Cache->delete('Poll', 'ViewPoll', $pid); 
    328         $GLOBALS['app']->Cache->delete('Poll', 'ViewResult', $pid); 
    329  
    330297        return true; 
    331298    } 
     
    339306     * @return  boolean True if the answer was updated and false on error 
    340307     */ 
    341     function UpdateAnswer($pid, $aid, $answer, $rank) 
     308    function UpdateAnswer($aid, $answer, $rank) 
    342309    { 
    343310        $sql = ' 
     
    358325        } 
    359326 
    360         //remove cached files 
    361         $GLOBALS['app']->Cache->delete('Poll', 'LastPoll'); 
    362         $GLOBALS['app']->Cache->delete('Poll', 'ViewPoll', $pid); 
    363         $GLOBALS['app']->Cache->delete('Poll', 'ViewResult', $pid); 
    364  
    365327        return true; 
    366328    } 
     
    373335     * @return  boolean True if the answer was deleted and false on error 
    374336     */ 
    375     function DeleteAnswer($pid, $aid) 
     337    function DeleteAnswer($aid) 
    376338    { 
    377339        $sql = 'DELETE FROM [[poll_answers]] WHERE [id] = {aid}'; 
     
    381343            return new Jaws_Error(_t('POLL_ERROR_ANSWER_NOT_DELETED'), _t('POLL_NAME')); 
    382344        } 
    383  
    384         //remove cached files 
    385         $GLOBALS['app']->Cache->delete('Poll', 'LastPoll'); 
    386         $GLOBALS['app']->Cache->delete('Poll', 'ViewPoll', $pid); 
    387         $GLOBALS['app']->Cache->delete('Poll', 'ViewResult', $pid); 
    388345 
    389346        return true; 
  • branches/0.8/jaws/html/gadgets/Poll/HTML.php

    r9926 r9960  
    5656                    $model->AddAnswerVote($post['pid'], $aid); 
    5757                } 
    58  
    59                 //remove cached files 
    60                 $GLOBALS['app']->Cache->delete('Poll', 'ViewResult', $post['pid']); 
    6158            } 
    6259        } 
     
    107104        $request =& Jaws_Request::getInstance(); 
    108105        $pid = $request->get('id', 'get'); 
    109         return $layoutGadget->ViewPoll($pid); 
     106        return $layoutGadget->Display($pid); 
    110107    } 
    111108 
     
    118115    function ViewResult() 
    119116    { 
    120         //cache output of this action 
    121         $GLOBALS['app']->Layout->SetCurrentActionCacheable(); 
    122  
    123117        $request =& Jaws_Request::getInstance(); 
    124118        $pid = $request->get('id', 'get'); 
  • branches/0.8/jaws/html/gadgets/Poll/Info.php

    r9930 r9960  
    1717        $this->GadgetName(_t('POLL_NAME')); 
    1818        $this->GadgetDescription(_t('POLL_DESCRIPTION')); 
    19         $this->GadgetVersion('0.8.1'); 
     19        $this->GadgetVersion('0.8.0'); 
    2020        $this->Doc('gadget/Poll'); 
    2121 
  • branches/0.8/jaws/html/gadgets/Poll/LayoutHTML.php

    r9926 r9960  
    3636        if (!Jaws_Error::isError($polls)) { 
    3737            foreach ($polls as $poll) { 
    38                 $actions['ViewPoll(' . $poll['id'] . ')'] = array( 
     38                $actions['Display(' . $poll['id'] . ')'] = array( 
    3939                    'mode' => 'LayoutAction', 
    4040                    'name' => $poll['question'], 
     
    5656    function LastPoll() 
    5757    { 
    58         return $this->ViewPoll(0); 
     58        return $this->Display(0); 
    5959    } 
    6060 
     
    6767    function ListOfPolls() 
    6868    { 
    69         //cache output of this action 
    70         $GLOBALS['app']->Layout->SetCurrentActionCacheable(); 
    71  
    7269        $tpl = new Jaws_Template('gadgets/Poll/templates/'); 
    7370        $tpl->Load('Polls.html'); 
     
    9693     * @access  public 
    9794     */ 
    98     function ViewPoll($pid = 0) 
     95    function Display($pid = 0) 
    9996    { 
    100         //cache output of this action 
    101         $GLOBALS['app']->Layout->SetCurrentActionCacheable(); 
    102  
    10397        $model = $GLOBALS['app']->LoadGadget('Poll', 'Model'); 
    10498        if (empty($pid)) { 
  • branches/0.8/jaws/html/gadgets/Poll/templates/Poll.html

    r9942 r9960  
    22<div class="gadget poll"> 
    33  <h2>{title}</h2> 
    4   <form action="{base_script}" name="poll_form_{pid}" method="post"> 
     4  <form action="{base_script}" method="post"> 
    55  <input type="hidden" name="gadget" value="Poll" /> 
    66  <input type="hidden" name="action" value="Vote" /> 
     
    1515  </div> 
    1616  <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 --> 
    2617  </form> 
    2718</div>