Example #1
0
 protected function processCommentActions(\fpcm\model\comments\commentList $commentList)
 {
     $action = $this->getRequestVar('commentAction', array(9));
     $ids = $this->getRequestVar('ids', array(9));
     if (!$action || !is_array($ids) || !count($ids)) {
         $this->view->addErrorMessage('SELECT_ITEMS_MSG');
         return true;
     }
     switch ($action) {
         case $this->actions['COMMENTLIST_ACTION_DELETE']:
             if ($commentList->deleteComments($ids)) {
                 $this->view->addNoticeMessage('DELETE_SUCCESS_COMMENTS');
             } else {
                 $this->view->addErrorMessage('DELETE_FAILED_COMMENTS');
             }
             break;
         case $this->actions['COMMENTLIST_ACTION_APPROVE']:
             if ($commentList->toggleApprovement($ids)) {
                 $this->view->addNoticeMessage('SAVE_SUCCESS_APPROVEMENT');
             } else {
                 $this->view->addErrorMessage('SAVE_FAILED_APPROVEMENT');
             }
             break;
         case $this->actions['COMMENTLIST_ACTION_PRIVATE']:
             if ($commentList->togglePrivate($ids)) {
                 $this->view->addNoticeMessage('SAVE_SUCCESS_PRIVATE');
             } else {
                 $this->view->addErrorMessage('SAVE_FAILED_PRIVATE');
             }
             break;
         case $this->actions['COMMENTLIST_ACTION_SPAM']:
             if ($commentList->toggleSpammer($ids)) {
                 $this->view->addNoticeMessage('SAVE_SUCCESS_SPAMMER');
             } else {
                 $this->view->addErrorMessage('SAVE_FAILED_SPAMMER');
             }
             break;
     }
     return true;
 }