コード例 #1
0
ファイル: articles.php プロジェクト: mined-gatech/hubzero-cms
 /**
  * Records the vote (like/dislike) of either an article or comment
  * AJAX call - Displays updated vote links
  * Standard link - falls through to the article view
  *
  * @return  void
  */
 public function voteTask()
 {
     if (User::isGuest()) {
         $return = Request::getVar('REQUEST_URI', Route::url('index.php?option=' . $this->_option), 'server');
         App::redirect(Route::url('index.php?option=com_users&view=login&return=' . base64_encode($return)));
         return;
     }
     // Incoming
     $type = strtolower(Request::getVar('type', ''));
     $vote = strtolower(Request::getVar('vote', ''));
     $id = Request::getInt('id', 0);
     // Did they vote?
     if (!$vote) {
         $this->setError(Lang::txt('COM_KB_USER_DIDNT_VOTE'));
         return $this->articleTask();
     }
     if (!in_array($type, array('article', 'comment'))) {
         App::abort(404, Lang::txt('COM_KB_WRONG_VOTE_TYPE'));
     }
     // Load the article
     switch ($type) {
         case 'article':
             $row = Article::oneOrFail($id);
             break;
         case 'comment':
             $row = Comment::oneOrFail($id);
             break;
     }
     if (!$row->vote($vote, User::get('id'))) {
         $this->setError($row->getError());
     }
     if (Request::getInt('no_html', 0)) {
         $this->view->item = $row;
         $this->view->type = $type;
         $this->view->vote = $vote;
         $this->view->id = '';
         //$id;
         if ($this->getError()) {
             $this->view->setError($this->getError());
         }
         $this->view->setLayout('_vote')->display();
     } else {
         if ($type == 'article') {
             App::redirect(Route::url($row->link()));
             return;
         }
         $this->articleTask();
     }
 }
コード例 #2
0
ファイル: kb.php プロジェクト: mined-gatech/hubzero-cms
 /**
  * Retrieves a row from the database
  *
  * @param      string $refid    ID of the database table row
  * @param      string $parent   If the element has a parent element
  * @param      string $category Element type (determines table to look in)
  * @param      string $message  If the element has a parent element
  * @return     array
  */
 public function deleteReportedItem($refid, $parent, $category, $message)
 {
     if ($category != 'kb') {
         return null;
     }
     require_once PATH_CORE . DS . 'components' . DS . 'com_kb' . DS . 'models' . DS . 'comment.php';
     $comment = \Components\Kb\Models\Comment::oneOrFail($refid);
     $comment->set('state', 2);
     $comment->save();
     return '';
 }