Пример #1
0
 /**
  * Delete one or more entries
  *
  * @return     void
  */
 public function deleteTask()
 {
     // Check if they're logged in
     if (User::isGuest()) {
         $this->loginTask();
         return;
     }
     // Incoming (we're expecting an array)
     $ids = Request::getVar('id', array());
     if (!is_array($ids)) {
         $ids = array();
     }
     // Make sure we have IDs to work with
     if (count($ids) > 0) {
         // Loop through the IDs and delete the citation
         $citation = new Citation($this->database);
         $assoc = new Association($this->database);
         $author = new Author($this->database);
         foreach ($ids as $id) {
             // Fetch and delete all the associations to this citation
             $isAdmin = User::get("usertype") == "Super Administrator" ? true : false;
             $assocs = $assoc->getRecords(array('cid' => $id), $isAdmin);
             foreach ($assocs as $a) {
                 $assoc->delete($a->id);
             }
             // Fetch and delete all the authors to this citation
             $authors = $author->getRecords(array('cid' => $id), $isAdmin);
             foreach ($authors as $a) {
                 $author->delete($a->id);
             }
             // Delete the citation
             $citation->delete($id);
         }
     }
     // Redirect
     App::redirect(Route::url('index.php?option=' . $this->_option));
 }
Пример #2
0
 /**
  * Get a list of authors
  *
  * @param   integer  $id  Optional citation ID
  * @return  array
  */
 public function authors($id = null)
 {
     require_once __DIR__ . DS . 'author.php';
     if (is_null($id)) {
         $id = $this->id;
     }
     $ca = new Author($this->_db);
     return $ca->getRecords(array('cid' => $id));
 }
Пример #3
0
 /**
  * Remove one or more citations
  *
  * @return	void
  */
 public function removeTask()
 {
     // Incoming (we're expecting an array)
     $ids = Request::getVar('id', array());
     if (!is_array($ids)) {
         $ids = array($ids);
     }
     // Make sure we have IDs to work with
     if (count($ids) > 0) {
         // Loop through the IDs and delete the citation
         $citation = new Citation($this->database);
         $assoc = new Association($this->database);
         $author = new Author($this->database);
         foreach ($ids as $id) {
             // Fetch and delete all the associations to this citation
             $assocs = $assoc->getRecords(array('cid' => $id));
             foreach ($assocs as $a) {
                 $assoc->delete($a->id);
             }
             // Fetch and delete all the authors to this citation
             $authors = $author->getRecords(array('cid' => $id));
             foreach ($authors as $a) {
                 $author->delete($a->id);
             }
             // Delete the citation
             $citation->delete($id);
             //citation tags
             $ct = new Tags($id);
             $ct->removeAll();
         }
         $message = Lang::txt('CITATION_REMOVED');
     } else {
         $message = Lang::txt('NO_SELECTION');
     }
     // Redirect
     App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, true), $message);
 }
Пример #4
0
 /**
  * Remove one or more authors from a citation
  *
  * @return  void
  */
 public function removeTask()
 {
     // Check for request forgeries
     Request::checkToken(['get', 'post']);
     if ($this->getError()) {
         return $this->displayTask();
     }
     $author = new Author($this->database);
     $mbrs = Request::getVar('author', array());
     $mbrs = !is_array($mbrs) ? array($mbrs) : $mbrs;
     $users = array();
     foreach ($mbrs as $mbr) {
         if (!$author->delete(intval($mbr))) {
             $this->setError(Lang::txt('COM_CITATIONS_ERROR_UNABLE_TO_REMOVE') . ' ' . $mbr);
         }
     }
     $this->saveAuthorsList();
     // Push through to the view
     $this->displayTask();
 }