Exemple #1
0
 /**
  * Set the state on an item to "deleted" (4)
  *
  * @param      integer $id Resource ID
  * @return     boolean False if errors, True on success
  */
 private function _markRemovedContribution($id)
 {
     // Make sure we have a record to pull
     if (!$id) {
         $this->setError(Lang::txt('COM_CONTRIBUTE_NO_ID'));
         return false;
     }
     // Load resource info
     $row = new Resource($this->database);
     $row->load($id);
     // Mark resource as deleted
     $row->published = 4;
     if (!$row->store()) {
         $this->setError($row->getError());
         return false;
     }
     // Return success
     return true;
 }
Exemple #2
0
 /**
  * Sets the access level of a resource
  * Redirects to main listing
  *
  * @return     void
  */
 public function accessTask()
 {
     // Check for request forgeries
     Request::checkToken(['get', 'post']);
     // Incoming
     $id = Request::getInt('id', 0);
     $pid = Request::getInt('pid', 0);
     // Ensure we have an ID to work with
     if (!$id) {
         $this->setMessage(Lang::txt('COM_RESOURCES_ERROR_MISSING_ID'));
         return $this->cancelTask();
     }
     // Choose access level
     switch ($this->_task) {
         case 'accesspublic':
             $access = 0;
             break;
         case 'accessregistered':
             $access = 1;
             break;
         case 'accessspecial':
             $access = 2;
             break;
         case 'accessprotected':
             $access = 3;
             break;
         case 'accessprivate':
             $access = 4;
             break;
         default:
             $access = 0;
             break;
     }
     // Load resource info
     $row = new Resource($this->database);
     $row->load($id);
     $row->access = $access;
     // Check and store changes
     if (!$row->check()) {
         $this->setMessage($row->getError());
         return $this->cancelTask();
     }
     if (!$row->store()) {
         $this->setMessage($row->getError());
         return $this->cancelTask();
     }
     // Redirect
     App::redirect($this->buildRedirectURL($pid));
 }
 /**
  * Change access on an entry
  *
  * @return  void
  */
 public function accessTask()
 {
     // Incoming parent ID
     $pid = Request::getInt('pid', 0);
     if (!$pid) {
         $this->setError(Lang::txt('CONTRIBUTE_NO_ID'));
         $this->displayTask($pid);
         return;
     }
     // Incoming child ID
     $id = Request::getInt('id', 0);
     if (!$id) {
         $this->setError(Lang::txt('CONTRIBUTE_NO_CHILD_ID'));
         $this->displayTask($pid);
         return;
     }
     // Load resource info
     $row = new Resource($this->database);
     $row->load($id);
     if (!$row) {
         $this->setError(Lang::txt('CONTRIBUTE_NO_CHILD_ID'));
         $this->displayTask($pid);
         return;
     }
     $access = Request::getInt('access', 0);
     if (!in_array($access, array(0, 1))) {
         $access = 0;
     }
     $row->access = $access;
     // Store new content
     if (!$row->store()) {
         $this->setError($row->getError());
         $this->displayTask($pid);
         return;
     }
     // Push through to the attachments view
     $this->displayTask($pid);
 }