Exemple #1
0
 /**
  * Mark a wish as deleted
  *
  * @return  void
  */
 public function deletewishTask()
 {
     // Check if wish exists on this list
     $wishlist = new Wishlist(Request::getInt('rid', 0), Request::getCmd('category', ''));
     if (!$wishlist->exists()) {
         throw new Exception(Lang::txt('COM_WISHLIST_ERROR_WISH_NOT_FOUND_ON_LIST'), 404);
     }
     $wish = new Wish(Request::getInt('wishid', 0));
     if (!$wish->exists()) {
         throw new Exception(Lang::txt('COM_WISHLIST_ERROR_WISH_NOT_FOUND'), 404);
     }
     // Login required
     if (User::isGuest()) {
         // Set page title
         if (!$wishlist->isPublic() && !$wishlist->access('manage')) {
             $this->_list_title = '';
         }
         $this->_buildTitle();
         // Set the pathway
         $this->_buildPathway($wishlist);
         $this->loginTask();
         return;
     }
     // get admin priviliges
     //$this->authorize_admin($wishlist->id);
     //$objWish->load($wishid);
     if (!$wishlist->access('manage') && $wish->get('proposed_by') != User::get('id')) {
         throw new Exception(Lang::txt('COM_WISHLIST_ALERTNOTAUTH'), 403);
     }
     //$withdraw = 0; //$this->_task=='withdraw' ? 1 : 0; /* [!] zooley - Mark as deleted instead of withdrawn? Seems to cause confusion if wish still appears in lists. */
     $wish->set('status', 2);
     if ($wish->store()) {
         // also delete all votes for this wish
         /*$objR = new WishRank($this->database);
         
         			if ($objR->remove_vote($wishid))
         			{
         				// re-calculate rankings of remaining wishes
         				$this->listid = $wishlist->id;
         				$wishlist->rank();
         			}*/
         // return bonuses
         if ($this->banking) {
             $WE = new Economy($this->database);
             $WE->cleanupBonus($wish->get('id'));
         }
     } else {
         $this->setError(Lang::txt('COM_WISHLIST_ERROR_WISH_DELETE_FAILED'));
     }
     // Log activity
     Event::trigger('system.logActivity', ['activity' => ['action' => 'deleted', 'scope' => 'wishlist.wish', 'scope_id' => $wish->get('id'), 'description' => Lang::txt('COM_WISHLIST_ACTIVITY_WISH_DELETED', '<a href="' . Route::url($wish->link('permalink')) . '">' . $wish->get('subject') . '</a>'), 'details' => array('subject' => $wish->get('subject'), 'url' => Route::url($wish->link('permalink')))], 'recipients' => array(['wishlist.' . $wishlist->get('category'), $wishlist->get('referenceid')], ['user', $wish->get('proposed_by')])]);
     // go back to the wishlist
     App::redirect($wishlist->link(), $this->getError(), $this->getError() ? 'error' : null);
 }
 /**
  * Mark a wish as deleted
  *
  * @return     void
  */
 public function deletewishTask()
 {
     // Check if wish exists on this list
     $wishlist = new Wishlist(Request::getInt('rid', 0), Request::getVar('category', ''));
     if (!$wishlist->exists()) {
         throw new Exception(Lang::txt('COM_WISHLIST_ERROR_WISH_NOT_FOUND_ON_LIST'), 404);
     }
     $wish = new Wish(Request::getInt('wishid', 0));
     if (!$wish->exists()) {
         throw new Exception(Lang::txt('COM_WISHLIST_ERROR_WISH_NOT_FOUND'), 404);
     }
     // Login required
     if (User::isGuest()) {
         // Set page title
         if (!$wishlist->isPublic() && !$wishlist->access('manage')) {
             $this->_list_title = '';
         }
         $this->_buildTitle();
         // Set the pathway
         $this->_buildPathway($wishlist);
         $this->loginTask();
         return;
     }
     // get admin priviliges
     //$this->authorize_admin($wishlist->id);
     //$objWish->load($wishid);
     if (!$wishlist->access('manage') && $wish->get('proposed_by') != User::get('id')) {
         throw new Exception(Lang::txt('COM_WISHLIST_ALERTNOTAUTH'), 403);
     }
     //$withdraw = 0; //$this->_task=='withdraw' ? 1 : 0; /* [!] zooley - Mark as deleted instead of withdrawn? Seems to cause confusion if wish still appears in lists. */
     $wish->set('status', 2);
     if ($wish->store()) {
         // also delete all votes for this wish
         /*$objR = new WishRank($this->database);
         
         			if ($objR->remove_vote($wishid))
         			{
         				// re-calculate rankings of remaining wishes
         				$this->listid = $wishlist->id;
         				$wishlist->rank();
         			}*/
         // return bonuses
         if ($this->banking) {
             $WE = new Economy($this->database);
             $WE->cleanupBonus($wish->get('id'));
         }
     } else {
         $this->setError(Lang::txt('COM_WISHLIST_ERROR_WISH_DELETE_FAILED'));
     }
     // go back to the wishlist
     App::redirect($wishlist->link(), $this->getError(), $this->getError() ? 'error' : null);
 }