Example #1
0
 /**
  * Remove a file
  *
  * @param \thebuggenie\core\entities\File $file The file to be removed
  *
  * @return boolean
  */
 public function detachFile(File $file)
 {
     tables\ArticleFiles::getTable()->removeByArticleIDandFileID($this->getID(), $file->getID());
     if (is_array($this->_files) && array_key_exists($file->getID(), $this->_files)) {
         unset($this->_files[$file->getID()]);
     }
     $file->delete();
 }
Example #2
0
 public function listen_fileHasAccess(framework\Event $event)
 {
     $article_ids = \thebuggenie\modules\publish\entities\tables\ArticleFiles::getTable()->getArticlesByFileID($event->getSubject()->getID());
     foreach ($article_ids as $article_id) {
         $article = new Article($article_id);
         if ($article->canRead()) {
             $event->setProcessed();
             $event->setReturnValue(true);
             break;
         }
     }
 }
Example #3
0
 /**
  * Removes an article from the list of flagged articles
  *
  * @param framework\Event $event
  */
 public function Files__getUnattachedFiles(framework\Event $event)
 {
     $event->setProcessed();
     $event->addToReturnList(ArticleFiles::getTable()->getLinkedFileIds());
 }
Example #4
0
 public static function getByArticleID($article_id)
 {
     return ArticleFiles::getTable()->getByArticleID($article_id);
 }