public function prepare(array $events) { $objectIDs = array(); foreach ($events as $event) { $objectIDs[] = $event->objectID; } // comments $commentList = new CommentList(); $commentList->getConditionBuilder()->add("comment.commentID IN (?)", array($objectIDs)); $commentList->readObjects(); $comments = $commentList->getObjects(); // get news $newsIDs = array(); foreach ($comments as $comment) { $newsIDs[] = $comment->objectID; } $list = new NewsList(); $list->getConditionBuilder()->add("news.newsID IN (?)", array($newsIDs)); $list->readObjects(); $newss = $list->getObjects(); foreach ($events as $event) { if (isset($comments[$event->objectID])) { $comment = $comments[$event->objectID]; if (isset($newss[$comment->objectID])) { $news = $newss[$comment->objectID]; $text = WCF::getLanguage()->getDynamicVariable('wcf.user.profile.recentActivity.newsComment', array('news' => $news)); $event->setTitle($text); $event->setDescription($comment->getFormattedMessage()); $event->setIsAccessible(); } } else { $event->setIsOrphaned(); } } }
public function execute(Cronjob $cronjob) { parent::execute($cronjob); $list = new NewsList(); $list->getConditionBuilder()->add('isDisabled = ?', array(1)); $list->getConditionBuilder()->add('time <= ?', array(TIME_NOW)); $list->readObjects(); $list = $list->getObjects(); $action = new NewsAction($list, 'publish'); $action->executeAction(); }
/** * Returns the file with the given id. * * @param integer $fileID * @return \array<\filebase\data\file\File> */ public function getEntry($entryID) { if (!empty($this->entryIDs)) { $this->entryIDs = array_diff($this->entryIDs, array_keys($this->entrys)); if (!empty($this->entryIDs)) { $entryList = new NewsList(); $entryList->enableCategoryLoading(false); $entryList->setObjectIDs($this->entryIDs); $entryList->readObjects(); $this->entrys += $entryList->getObjects(); $this->entryIDs = array(); } } if (isset($this->entrys[$entryID])) { return $this->entrys[$entryID]; } return null; }
$folder = substr($fileHash, 0, 2); //get size $size = filesize(CMS_DIR . 'images/news/' . $image->filename); //mime type $mime = FileUtil::getMimeType(CMS_DIR . 'images/news/' . $image->filename); //create db entry $action = new FileAction(array(), 'create', array('data' => array('title' => $image->getTitle(), 'filesize' => $size, 'fileType' => $mime, 'fileHash' => $fileHash, 'uploadTime' => TIME_NOW))); $action->executeAction(); $returnValues = $action->getReturnValues(); //set old IDs $oldIDs[$image->imageID] = $returnValues['returnValues']->fileID; if (!is_dir(CMS_DIR . 'files/' . $folder)) { FileUtil::makePath(CMS_DIR . 'files/' . $folder); } copy(CMS_DIR . 'images/news/' . $image->filename, CMS_DIR . 'files/' . $folder . '/' . $returnValues['returnValues']->fileID . '-' . $fileHash); @unlink(CMS_DIR . 'images/news/' . $image->filename); //insert into news image category $sql = "INSERT INTO cms" . WCF_N . "_file_to_category VALUES (?, ?)"; $statement = WCF::getDB()->prepareStatement($sql); $statement->execute(array($returnValues['returnValues']->fileID, $categoryID)); } //loop through news $list = new NewsList(); $list->readObjects(); foreach ($list->getObjects() as $news) { //check if image is set ( no foreign key is given :( ) if ($news->imageID !== 0 && isset($oldIDs[$news->imageID])) { $editor = new NewsEditor($news); $editor->update(array('imageID' => $oldIDs[$news->imageID])); } }