Beispiel #1
0
 /**
  * Vote for a wish
  *
  * @return     void
  */
 public function rateitemTask()
 {
     $wish = new Wish(Request::getInt('refid', 1));
     if (!$wish->exists()) {
         // cannot proceed
         return;
     }
     // Load the wishlist
     $wishlist = Wishlist::getInstance($wish->get('wishlist'));
     // Login required
     if (User::isGuest()) {
         // Get List Title
         $this->_list_title = ($wishlist->isPublic() or !$wishlist->isPublic() && $wishlist->access('manage')) ? $wishlist->get('title') : '';
         $this->_buildTitle();
         // Set the pathway
         $this->_buildPathway($wishlist);
         $this->_msg = Lang::txt('COM_WISHLIST_WARNING_WISHLIST_LOGIN_TO_RATE');
         $this->loginTask();
         return;
     }
     // Incoming
     $page = Request::getVar('page', 'wishlist');
     $vote = Request::getWord('vote', '');
     // assuming text only vote. Fix for sql injection ticket 1182
     //$this->authorize_admin($listid);
     $filters = self::getFilters($wishlist->access('manage'));
     if ($wish->vote($vote)) {
         $wishlist->rank();
     }
     // update display
     if (Request::getInt('ajax', 0)) {
         $this->view->setLayout('_vote');
         $this->view->item = $wish;
         $this->view->item->set('vote', $vote);
         $this->view->option = $this->_option;
         $this->view->page = 'wishlist';
         $this->view->filters = $filters;
         $this->view->display();
         return;
     }
     if ($page == 'wishlist') {
         App::redirect(str_replace('&', '&', Route::url($wishlist->link() . '&filterby=' . $filters['filterby'] . '&sortby=' . $filters['sortby'] . '&limitstart=' . $filters['start'] . '&limit=' . $filters['limit'] . '&tags=' . $filters['tag'])));
     } else {
         App::redirect(str_replace('&', '&', Route::url($wish->link() . '&filterby=' . $filters['filterby'] . '&sortby=' . $filters['sortby'] . '&limitstart=' . $filters['start'] . '&limit=' . $filters['limit'] . '&tags=' . $filters['tag'])));
     }
 }
Beispiel #2
0
 /**
  * Create an item entry
  *
  * @param   integer  $id  Optional ID to use
  * @return  boolean
  */
 public function make($id = null)
 {
     if ($this->exists()) {
         return true;
     }
     $id = $id ?: Request::getInt('wishid', 0);
     $this->_tbl->loadType($id, $this->_type);
     if ($this->exists()) {
         return true;
     }
     include_once PATH_CORE . DS . 'components' . DS . 'com_wishlist' . DS . 'models' . DS . 'wishlist.php';
     $wish = new Wish($id);
     if (!$wish->exists()) {
         $this->setError(Lang::txt('Wish not found.'));
         return false;
     }
     $this->set('type', $this->_type)->set('object_id', $wish->get('id'))->set('created', $wish->get('proposed'))->set('created_by', $wish->get('proposed_by'))->set('title', $wish->get('subject'))->set('description', $wish->content('clean', 200))->set('url', Route::url($wish->link()));
     if (!$this->store()) {
         return false;
     }
     return true;
 }