Пример #1
0
 function executeCmd()
 {
     global $mainframe;
     $cmd = strtolower(JCommentsInput::getVar('cmd', ''));
     $hash = JCommentsInput::getVar('hash', '');
     $id = (int) JCommentsInput::getVar('id', 0);
     $error = '';
     $link = $mainframe->getCfg('live_site') . '/index.php';
     $checkHash = JCommentsFactory::getCmdHash($cmd, $id);
     if ($hash == $checkHash) {
         $config =& JCommentsFactory::getConfig();
         if ($config->getInt('enable_quick_moderation') == 1) {
             $dbo =& JCommentsFactory::getDBO();
             $comment = new JCommentsDB($dbo);
             if ($comment->load($id)) {
                 $link = JCommentsObjectHelper::getLink($comment->object_id, $comment->object_group);
                 $link = str_replace('&', '&', $link);
                 switch ($cmd) {
                     case 'publish':
                         $comment->published = 1;
                         $comment->store();
                         $link .= '#comment-' . $comment->id;
                         break;
                     case 'unpublish':
                         $comment->published = 0;
                         $comment->store();
                         $acl =& JCommentsFactory::getACL();
                         if ($acl->canPublish()) {
                             $link .= '#comment-' . $comment->id;
                         } else {
                             $link .= '#comments';
                         }
                         break;
                     case 'delete':
                         $comment->delete();
                         $link .= '#comments';
                         break;
                 }
             }
         } else {
             $error = JText::_('Quick moderation function is disabled by administrator!');
         }
     } else {
         $error = JText::_('Incorrect hash for this operation!');
     }
     JCommentsRedirect($link, $error);
 }