Beispiel #1
0
 /**
  * Remove an author from an item
  *
  * @return     void
  */
 public function removeTask()
 {
     // Incoming
     $id = Request::getInt('id', 0);
     $pid = Request::getInt('pid', 0);
     // Ensure we have a resource ID ($pid) to work with
     if (!$pid) {
         $this->setError(Lang::txt('CONTRIBUTE_NO_ID'));
         $this->displayTask();
         return;
     }
     // Ensure we have the contributor's ID ($id)
     if ($id) {
         $rc = new Contributor($this->database);
         if (!$rc->deleteAssociation($id, $pid, 'resources')) {
             $this->setError($rc->getError());
         }
     }
     // Push through to the authors view
     $this->displayTask($pid);
 }
Beispiel #2
0
 /**
  * Save an entry
  *
  * @return  void
  */
 public function saveTask()
 {
     // Check for request forgeries
     Request::checkToken();
     // Incoming
     $fields = Request::getVar('fields', array(), 'post');
     $authorid = Request::getVar('authorid', 0);
     $id = Request::getVar('id', 0);
     if (!$authorid) {
         App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, false));
         return;
     }
     $rows = array();
     if (is_array($fields)) {
         foreach ($fields as $fieldset) {
             $rc = new Contributor($this->database);
             $rc->subtable = 'resources';
             $rc->subid = trim($fieldset['subid']);
             $rc->authorid = $authorid;
             $rc->name = trim($fieldset['name']);
             $rc->organization = trim($fieldset['organization']);
             $rc->role = $fieldset['role'];
             $rc->ordering = $fieldset['ordering'];
             if ($authorid != $id) {
                 if (!$rc->createAssociation()) {
                     $this->setError($rc->getError());
                 }
                 if (!$rc->deleteAssociation($id, $rc->subid, $rc->subtable)) {
                     $this->setError($rc->getError());
                 }
             } else {
                 if (!$rc->updateAssociation()) {
                     $this->setError($rc->getError());
                 }
             }
             $rows[] = $rc;
         }
     }
     // Instantiate a resource/contributor association object
     $rc = new Contributor($this->database);
     if ($this->_task == 'apply') {
         return $this->editTask($rows);
     }
     App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, false));
 }