/** * Creates a new ViewableNewsList object. */ public function __construct() { parent::__construct(); // get author avatar if (!empty($this->sqlSelects)) { $this->sqlSelects .= ', '; } $this->sqlSelects .= "user_avatar.*, user_avatar.width as avatarWidth, user_avatar.height as avatarHeight, user_avatar.fileHash as avatarFileHash, user_table.*"; $this->sqlJoins .= " LEFT JOIN wcf" . WCF_N . "_user user_table ON (user_table.userID = news.userID)"; $this->sqlJoins .= " LEFT JOIN wcf" . WCF_N . "_user_avatar user_avatar ON (user_avatar.avatarID = user_table.avatarID)"; // get news picture $this->sqlSelects .= ", news_picture.categoryID, news_picture.fileHash, news_picture.fileExtension"; $this->sqlJoins .= " LEFT JOIN news" . WCF_N . "_news_picture news_picture ON (news.pictureID = news_picture.pictureID)"; // get the news like status $this->sqlSelects .= ", like_object.likes, like_object.dislikes"; $this->sqlJoins .= " LEFT JOIN wcf" . WCF_N . "_like_object like_object ON (like_object.objectTypeID = " . LikeHandler::getInstance()->getObjectType('de.voolia.news.likeableNews')->objectTypeID . " AND like_object.objectID = news.newsID)"; if (WCF::getUser()->userID != 0) { // last news visit time if (!empty($this->sqlSelects)) { $this->sqlSelects .= ','; } $this->sqlSelects .= 'tracked_visit.visitTime'; $this->sqlJoins .= " LEFT JOIN wcf" . WCF_N . "_tracked_visit tracked_visit ON (tracked_visit.objectTypeID = " . VisitTracker::getInstance()->getObjectTypeID('de.voolia.news.entry') . " AND tracked_visit.objectID = news.newsID AND tracked_visit.userID = " . WCF::getUser()->userID . ")"; } }
/** * Creates a new ViewableEntryList object. */ public function __construct() { parent::__construct(); // get last file if (!empty($this->sqlSelects)) { $this->sqlSelects .= ','; } $this->sqlSelects .= 'file.*'; $this->sqlJoins .= " LEFT JOIN filebase" . WCF_N . "_file file ON (file.fileID = entry.lastFileID)"; if (WCF::getUser()->userID != 0) { // last visit time if (!empty($this->sqlSelects)) { $this->sqlSelects .= ','; } $this->sqlSelects .= 'tracked_visit.visitTime'; $this->sqlJoins .= " LEFT JOIN wcf" . WCF_N . "_tracked_visit tracked_visit ON (tracked_visit.objectTypeID = " . VisitTracker::getInstance()->getObjectTypeID('de.incendium.filebase.entry') . " AND tracked_visit.objectID = entry.entryID AND tracked_visit.userID = " . WCF::getUser()->userID . ")"; // subscriptions if (!empty($this->sqlSelects)) { $this->sqlSelects .= ','; } $this->sqlSelects .= 'user_object_watch.watchID, user_object_watch.notification'; $this->sqlJoins .= " LEFT JOIN wcf" . WCF_N . "_user_object_watch user_object_watch ON (user_object_watch.objectTypeID = " . ObjectTypeCache::getInstance()->getObjectTypeByName('com.woltlab.wcf.user.objectWatch', 'de.incendium.filebase.entry')->objectTypeID . " AND user_object_watch.userID = " . WCF::getUser()->userID . " AND user_object_watch.objectID = entry.entryID)"; } // get avatars if (!empty($this->sqlSelects)) { $this->sqlSelects .= ','; } $this->sqlSelects .= "user_avatar.*, user_table.*"; $this->sqlJoins .= " LEFT JOIN wcf" . WCF_N . "_user user_table ON (user_table.userID = entry.userID)"; $this->sqlJoins .= " LEFT JOIN wcf" . WCF_N . "_user_avatar user_avatar ON (user_avatar.avatarID = user_table.avatarID)"; // get like status if (!empty($this->sqlSelects)) { $this->sqlSelects .= ','; } $this->sqlSelects .= "like_object.likes, like_object.dislikes"; $this->sqlJoins .= " LEFT JOIN wcf" . WCF_N . "_like_object like_object ON (like_object.objectTypeID = " . LikeHandler::getInstance()->getObjectType('de.incendium.filebase.likeableEntry')->objectTypeID . " AND like_object.objectID = entry.entryID)"; // get report status if (WCF::getSession()->getPermission('mod.general.canUseModeration')) { if (!empty($this->sqlSelects)) { $this->sqlSelects .= ','; } $this->sqlSelects .= "moderation_queue.queueID AS reportQueueID"; $this->sqlJoins .= " LEFT JOIN wcf" . WCF_N . "_moderation_queue moderation_queue ON (moderation_queue.objectTypeID = " . ObjectTypeCache::getInstance()->getObjectTypeIDByName('com.woltlab.wcf.moderation.report', 'de.incendium.filebase.entry') . " AND moderation_queue.objectID = entry.entryID AND moderation_queue.status <> " . ModerationQueue::STATUS_DONE . " AND moderation_queue.status <> " . ModerationQueue::STATUS_REJECTED . " AND moderation_queue.status <> " . ModerationQueue::STATUS_CONFIRMED . ")"; } if (!WCF::getSession()->getPermission('mod.filebase.canViewDeletedEntry')) { $this->loadDeleteNote = false; } }
public function __construct() { parent::__construct(); if (WCF::getUser()->userID != 0) { // last visit time if (!empty($this->sqlSelects)) { $this->sqlSelects .= ','; } $this->sqlSelects .= 'tracked_visit.visitTime'; $this->sqlJoins .= " LEFT JOIN wcf" . WCF_N . "_tracked_visit tracked_visit ON (tracked_visit.objectTypeID = " . VisitTracker::getInstance()->getObjectTypeID('de.codequake.cms.news') . " AND tracked_visit.objectID = news.newsID AND tracked_visit.userID = " . WCF::getUser()->userID . ")"; } // get like status if (!empty($this->sqlSelects)) { $this->sqlSelects .= ','; } $this->sqlSelects .= "like_object.likes, like_object.dislikes"; $this->sqlJoins .= " LEFT JOIN wcf" . WCF_N . "_like_object like_object ON (like_object.objectTypeID = " . LikeHandler::getInstance()->getObjectType('de.codequake.cms.likeableNews')->objectTypeID . " AND like_object.objectID = news.newsID)"; }
/** * judge can like post * * @param Object $oMbqEtForumPost * @return Boolean */ public function canAclLikePost($oMbqEtForumPost = null) { if (empty($oMbqEtForumPost) || !MbqMain::hasLogin()) { return false; } $objectType = LikeHandler::getInstance()->getObjectType('com.woltlab.wbb.likeablePost'); if ($objectType === null) { return false; } $objectTypeProvider = $objectType->getProcessor(); $likeableObject = $objectTypeProvider->getObjectByID($oMbqEtForumPost->postId->oriValue); $likeableObject->setObjectType($objectType); return $objectTypeProvider->checkPermissions($likeableObject); }
/** * Deletes given entries. * * @return array<array> */ public function delete() { if (empty($this->objects)) { $this->readObjects(); } $entryIDs = $entyData = $attachmentEntryIDs = $userCounters = array(); foreach ($this->objects as $entry) { $entryData[$entry->entryID] = $entry->userID; $entryIDs[] = $entry->entryID; if ($entry->attachments) { $attachmentEntryIDs[] = $entry->entryID; } if (!$entry->isDisabled) { if (!isset($userToItems[$entry->userID])) { $userToItems[$entry->userID] = 0; } $userToItems[$entry->userID]++; } } // remove user activity events $this->removeActivityEvents($entryData); // remove files $fileList = new EntryFileList(); $fileList->getConditionBuilder()->add("file.entryID IN (?)", array(array_keys($entryData))); $fileList->readObjects(); $fileAction = new EntryFileAction($fileList->getObjects(), 'delete', array('ignoreEntries' => true)); $fileAction->executeAction(); // remove entries foreach ($this->objects as $entry) { $entry->delete(); $this->addEntryData($entry->getDecoratedObject(), 'deleted', LinkHandler::getInstance()->getLink('FilebaseOverview', array('application' => 'filebase'))); EntryModificationLogHandler::getInstance()->delete($entry->getDecoratedObject()); } if (!empty($entryIDs)) { // delete like data LikeHandler::getInstance()->removeLikes('de.incendium.filebase.likeableEntry', $entryIDs); // delete comments CommentHandler::getInstance()->deleteObjects('de.incendium.filebase.entryComment', $entryIDs); // delete tag to object entries TagEngine::getInstance()->deleteObjects('de.incendium.filebase.entry', $entryIDs); // delete entry from search index SearchIndexManager::getInstance()->delete('de.incendium.filebase.entry', $entryIDs); } // decrease user entry counter if (!empty($userCounters)) { EntryEditor::updateEntryCounter($userCounters); } // delete attachments if (!empty($attachmentEntryIDs)) { AttachmentHandler::removeAttachments('de.incendium.filebase.entry', $attachmentEntryIDs); } // delete subscriptions UserObjectWatchHandler::getInstance()->deleteObjects('de.incendium.filebase.entry', $entryIDs); $this->unmarkItems(); return $this->getEntryData(); }
public function readData() { parent::readData(); VisitCountHandler::getInstance()->count(); WCF::getBreadcrumbs()->add(new Breadcrumb(WCF::getLanguage()->get('cms.page.news'), LinkHandler::getInstance()->getLink('NewsCategoryList', array('application' => 'cms')))); $this->commentObjectTypeID = CommentHandler::getInstance()->getObjectTypeID('de.codequake.cms.news.comment'); $this->commentManager = CommentHandler::getInstance()->getObjectType($this->commentObjectTypeID)->getProcessor(); $this->commentList = CommentHandler::getInstance()->getCommentList($this->commentManager, $this->commentObjectTypeID, $this->newsID); $newsEditor = new NewsEditor($this->news->getDecoratedObject()); $newsEditor->update(array('clicks' => $this->news->clicks + 1)); // get Tags if (MODULE_TAGGING) { $this->tags = $this->news->getTags(); } if ($this->news->teaser != '') { MetaTagHandler::getInstance()->addTag('description', 'description', $this->news->teaser); } else { MetaTagHandler::getInstance()->addTag('description', 'description', StringUtil::decodeHTML(StringUtil::stripHTML($this->news->getExcerpt()))); } if (!empty($this->tags)) { MetaTagHandler::getInstance()->addTag('keywords', 'keywords', implode(',', $this->tags)); } MetaTagHandler::getInstance()->addTag('og:title', 'og:title', $this->news->subject . ' - ' . WCF::getLanguage()->get(PAGE_TITLE), true); MetaTagHandler::getInstance()->addTag('og:url', 'og:url', LinkHandler::getInstance()->getLink('News', array('application' => 'cms', 'object' => $this->news->getDecoratedObject())), true); MetaTagHandler::getInstance()->addTag('og:type', 'og:type', 'article', true); if ($this->news->getImage() != null) { MetaTagHandler::getInstance()->addTag('og:image', 'og:image', $this->news->getImage()->getLink(), true); } if ($this->news->getUserProfile()->facebook != '') { MetaTagHandler::getInstance()->addTag('article:author', 'article:author', 'https://facebook.com/' . $this->news->getUserProfile()->facebook, true); } if (FACEBOOK_PUBLIC_KEY != '') { MetaTagHandler::getInstance()->addTag('fb:app_id', 'fb:app_id', FACEBOOK_PUBLIC_KEY, true); } MetaTagHandler::getInstance()->addTag('og:description', 'og:description', StringUtil::decodeHTML(StringUtil::stripHTML($this->news->getExcerpt())), true); if ($this->news->isNew()) { $newsAction = new NewsAction(array($this->news->getDecoratedObject()), 'markAsRead', array('viewableNews' => $this->news)); $newsAction->executeAction(); } // fetch likes if (MODULE_LIKE) { $objectType = LikeHandler::getInstance()->getObjectType('de.codequake.cms.likeableNews'); LikeHandler::getInstance()->loadLikeObjects($objectType, array($this->newsID)); $this->likeData = LikeHandler::getInstance()->getLikeObjects($objectType); } }
/** * @see \wcf\data\IDeleteAction::delete() */ public function delete() { if (empty($this->objects)) { $this->readObjects(); } $entryIDs = $entyData = $attachmentEntryIDs = $userCounters = array(); foreach ($this->objects as $entry) { $entryData[$entry->entryID] = $entry->userID; $entryIDs[] = $entry->entryID; if ($entry->attachments) { $attachmentEntryIDs[] = $entry->entryID; } if (!$entry->isDisabled) { if (!isset($userToItems[$entry->userID])) { $userToItems[$entry->userID] = 0; } $userToItems[$entry->userID]++; } } // remove user activity events $this->removeActivityEvents($entryData); // remove entries foreach ($this->objects as $entry) { $entry->delete(); $this->addEntryData($entry->getDecoratedObject(), 'deleted', LinkHandler::getInstance()->getLink('LinklistOverview', array('application' => 'linklist'))); EntryModificationLogHandler::getInstance()->delete($entry->getDecoratedObject()); } if (!empty($entryIDs)) { // delete like data LikeHandler::getInstance()->removeLikes('de.incendium.linklist.likeableEntry', $entryIDs); // delete comments CommentHandler::getInstance()->deleteObjects('de.incendium.linklist.entryComment', $entryIDs); // delete tag to object entries TagEngine::getInstance()->deleteObjects('de.incendium.linklist.entry', $entryIDs); // delete entry from search index SearchIndexManager::getInstance()->delete('de.incendium.linklist.entry', $entryIDs); } // decrease user entry counter if (!empty($userCounters)) { EntryEditor::updateEntryCounter($userCounters); } // delete attachments if (!empty($attachmentEntryIDs)) { AttachmentHandler::removeAttachments('de.incendium.linklist.entry', $attachmentEntryIDs); } $this->unmarkItems(); return $this->getEntryData(); }
/** * Fetches the like data. * * @return array */ public function getLikeData() { if (empty($this->objectIDs)) { return array(); } $objectType = LikeHandler::getInstance()->getObjectType('com.woltlab.wcf.comment.response'); LikeHandler::getInstance()->loadLikeObjects($objectType, $this->objectIDs); $likeData = array('response' => LikeHandler::getInstance()->getLikeObjects($objectType)); return $likeData; }
/** * @see \wcf\data\AbstractDatabaseObjectAction::delete() */ public function delete() { if (empty($this->objects)) { $this->readObjects(); } if (empty($this->objects)) { return 0; } $ignoreCounters = !empty($this->parameters['ignoreCounters']); // read object type ids for comments $commentIDs = array(); foreach ($this->objects as $response) { $commentIDs[] = $response->commentID; } $commentList = new CommentList(); $commentList->getConditionBuilder()->add("comment.commentID IN (?)", array($commentIDs)); $commentList->readObjects(); $comments = $commentList->getObjects(); // update counters $processors = $responseIDs = $updateComments = array(); foreach ($this->objects as $response) { $objectTypeID = $comments[$response->commentID]->objectTypeID; if (!isset($processors[$objectTypeID])) { $objectType = ObjectTypeCache::getInstance()->getObjectType($objectTypeID); $processors[$objectTypeID] = $objectType->getProcessor(); $responseIDs[$objectTypeID] = array(); } $responseIDs[$objectTypeID][] = $response->responseID; if (!$ignoreCounters) { $processors[$objectTypeID]->updateCounter($comments[$response->commentID]->objectID, -1); if (!isset($updateComments[$response->commentID])) { $updateComments[$response->commentID] = 0; } $updateComments[$response->commentID]++; } } // remove responses $count = parent::delete(); // update comment responses and cached response ids if (!$ignoreCounters) { foreach ($comments as $comment) { $commentEditor = new CommentEditor($comment); $commentEditor->updateResponseIDs(); $commentEditor->updateCounters(array('responses' => -1 * $updateComments[$comment->commentID])); } } $likeObjectIDs = array(); $notificationObjectTypes = array(); foreach ($responseIDs as $objectTypeID => $objectIDs) { // remove activity events $objectType = ObjectTypeCache::getInstance()->getObjectType($objectTypeID); if (UserActivityEventHandler::getInstance()->getObjectTypeID($objectType->objectType . '.response.recentActivityEvent')) { UserActivityEventHandler::getInstance()->removeEvents($objectType->objectType . '.response.recentActivityEvent', $objectIDs); } // delete notifications if (UserNotificationHandler::getInstance()->getObjectTypeID($objectType->objectType . '.response.notification')) { UserNotificationHandler::getInstance()->removeNotifications($objectType->objectType . '.response.notification', $objectIDs); } $likeObjectIDs = array_merge($likeObjectIDs, $objectIDs); if (UserNotificationHandler::getInstance()->getObjectTypeID($objectType->objectType . '.response.like.notification')) { $notificationObjectTypes[] = $objectType->objectType . '.response.like.notification'; } } // remove likes if (!empty($likeObjectIDs)) { LikeHandler::getInstance()->removeLikes('com.woltlab.wcf.comment.response', $likeObjectIDs, $notificationObjectTypes); } return $count; }
/** * @see \wcf\page\IPage::readData() */ public function readData() { parent::readData(); // add breadcrumbs WCF::getBreadcrumbs()->add(new Breadcrumb(WCF::getLanguage()->get('cms.header.menu.news'), LinkHandler::getInstance()->getLink('NewsOverview', array('application' => 'cms')))); if ($this->entry->isArchived) { WCF::getBreadcrumbs()->add(new Breadcrumb(WCF::getLanguage()->get('cms.header.menu.news.archive'), LinkHandler::getInstance()->getLink('NewsArchive', array('application' => 'cms')))); } $categories = array(); $leafCategories = $this->entry->getLeafCategories(); $category = reset($leafCategories); while ($category !== null) { $categories[] = $category; $category = $category->getParentCategory(); } foreach (array_reverse($categories) as $parentCategory) { WCF::getBreadcrumbs()->add($parentCategory->getBreadcrumb()); } // update news view count $this->entry->updateVisits(); // update news visit if ($this->entry->isNew()) { $entryAction = new EntryAction(array($this->entry->getDecoratedObject()), 'markAsRead', array('viewableEntry' => $this->entry)); $entryAction->executeAction(); } // fetch news likes if (MODULE_LIKE) { $objectType = LikeHandler::getInstance()->getObjectType('de.incendium.cms.like.likeableNews'); LikeHandler::getInstance()->loadLikeObjects($objectType, array($this->entryID)); $this->entryLikeData = LikeHandler::getInstance()->getLikeObjects($objectType); } // get news tags if (MODULE_TAGGING) { $this->tags = TagEngine::getInstance()->getObjectTags('de.incendium.cms.news.entry', $this->entry->entryID, array($this->entry->languageID === null ? LanguageFactory::getInstance()->getDefaultLanguageID() : "")); } // get news comments if ($this->commentManager === null) { $this->objectTypeID = CommentHandler::getInstance()->getObjectTypeID('de.incendium.cms.news.comment'); $objectType = CommentHandler::getInstance()->getObjectType($this->objectTypeID); $this->commentManager = $objectType->getProcessor(); } $this->commentList = CommentHandler::getInstance()->getCommentList($this->commentManager, $this->objectTypeID, $this->entryID); // more news from this category $this->moreEntryList = new AccessibleEntryList(); $this->moreEntryList->getConditionBuilder()->add("news_entry.entryID IN (SELECT entryID FROM cms" . WCF_N . "_news_entry_to_category WHERE entryID != ? AND categoryID IN (?))", array($this->entryID, $this->entry->getCategoryIDs())); $this->moreEntryList->sqlLimit = CMS_DASHBOARD_SIDEBAR_NEWSENTRIES; $this->moreEntryList->readObjects(); // meta tags MetaTagHandler::getInstance()->addTag('og:title', 'og:title', $this->entry->subject . ' - ' . WCF::getLanguage()->get(PAGE_TITLE), true); MetaTagHandler::getInstance()->addTag('og:url', 'og:url', LinkHandler::getInstance()->getLink('NewsEntry', array('application' => 'cms', 'object' => $this->entry)), true); MetaTagHandler::getInstance()->addTag('og:type', 'og:type', 'article', true); MetaTagHandler::getInstance()->addTag('og:description', 'og:description', StringUtil::decodeHTML(StringUtil::stripHTML($this->entry->getExcerpt())), true); // add tags as keywords if (!empty($this->tags)) { $keywords = ''; foreach ($this->tags as $tag) { if (!empty($keywords)) { $keywords .= ', '; } $keywords .= $tag->name; } MetaTagHandler::getInstance()->addTag('keywords', 'keywords', $keywords); } // quotes MessageQuoteManager::getInstance()->initObjects('de.incendium.cms.news.entry', array($this->entry->entryID)); }
public function updateLike($oMbqEtForumPost) { if (is_array($oMbqEtForumPost)) { MbqError::alert('', __METHOD__ . ',line:' . __LINE__ . '.' . MBQ_ERR_INFO_NOT_ACHIEVE); } $oPost = $oMbqEtForumPost->mbqBind['oViewablePost']->getDecoratedObject(); //ref wcf\data\like\LikeAction\Like $objectType = LikeHandler::getInstance()->getObjectType('com.woltlab.wbb.likeablePost'); if ($objectType === null) { MbqError::alert('', '', '', MBQ_ERR_APP); } $objectTypeProvider = $objectType->getProcessor(); $likeableObject = $objectTypeProvider->getObjectByID($oMbqEtForumPost->postId->oriValue); $likeableObject->setObjectType($objectType); $likeData = LikeHandler::getInstance()->like($likeableObject, WCF::getUser(), Like::LIKE); // handle activity event if (UserActivityEventHandler::getInstance()->getObjectTypeID($objectType->objectType . '.recentActivityEvent')) { if ($likeData['data']['liked'] == 1) { UserActivityEventHandler::getInstance()->fireEvent($objectType->objectType . '.recentActivityEvent', $oMbqEtForumPost->postId->oriValue); } else { UserActivityEventHandler::getInstance()->removeEvents($objectType->objectType . '.recentActivityEvent', array($oMbqEtForumPost->postId->oriValue)); } } // change post data $user = WCF::getUser(); if ($likeData['data']['liked'] == 1) { $oMbqEtForumPost->isLiked->setOriValue(MbqBaseFdt::getFdt('MbqFdtForum.MbqEtForumPost.isLiked.range.yes')); $oMbqEtLike = MbqMain::$oClk->newObj('MbqEtLike'); $oMbqEtLike->key->setOriValue($oMbqEtForumPost->postId->oriValue); $oMbqEtLike->userId->setOriValue($user->__get('userID')); $oMbqEtLike->type->setOriValue(MbqBaseFdt::getFdt('MbqFdtLike.MbqEtLike.type.range.likeForumPost')); $oMbqEtLike->postTime->setOriValue($oPost->time); $oMbqRdEtUser = MbqMain::$oClk->newObj('MbqRdEtUser'); $oMbqEtLike->oMbqEtUser = $oMbqRdEtUser->initOMbqEtUser($user->__get('userID'), array('case' => 'byUserId')); $oMbqEtForumPost->objsMbqEtLike[$user->__get('userID')] = $oMbqEtLike; } else { $oMbqEtForumPost->isLiked->setOriValue(MbqBaseFdt::getFdt('MbqFdtForum.MbqEtForumPost.isLiked.range.no')); unset($oMbqEtForumPost->objsMbqEtLike[$user->__get('userID')]); } return $oMbqEtForumPost; }
/** * @see \wcf\system\faker\IFaker::fake() */ public function fake() { $likeableObjectID = $this->getLikeableObjectID(); $likeableObject = $this->objectTypeProvider->getObjectByID($likeableObjectID); $likeableObject->setObjectType($this->objectType); $sql = "SELECT\t\tuserID, username\n\t\t\tFROM\t\twcf" . WCF_N . "_user\n\t\t\tORDER BY\tuserID ASC"; $statement = WCF::getDB()->prepareStatement($sql, 1, $this->generator->numberBetween(0, $this->userCount - 1)); $statement->execute(); $liker = $statement->fetchObject('\\wcf\\data\\user\\User'); if (isset($this->parameters['likeValue'])) { switch ($this->parameters['likeValue']) { case '+': $value = \wcf\data\like\Like::LIKE; break; case '-': $value = \wcf\data\like\Like::DISLIKE; break; case '+-': if ($this->generator->boolean) { $value = \wcf\data\like\Like::LIKE; } else { $value = \wcf\data\like\Like::DISLIKE; } } } else { $value = \wcf\data\like\Like::LIKE; } \wcf\system\like\LikeHandler::getInstance()->like($likeableObject, $liker, $value); }
/** * @see \wcf\data\IDeleteAction::delete() */ public function delete() { // delete news entries parent::delete(); // collect data $newsIDs = $perUserCount = $pollIDs = array(); foreach ($this->objects as $news) { $newsIDs[] = $news->newsID; if ($news->pollID) { $pollIDs[] = $news->pollID; } if (!$news->isDisabled) { if (!isset($perUserCount[$news->userID])) { $perUserCount[$news->userID] = 0; } $perUserCount[$news->userID]++; } } if (!empty($newsIDs)) { // delete like data LikeHandler::getInstance()->removeLikes('de.voolia.news.likeableNews', $newsIDs); // delete comments CommentHandler::getInstance()->deleteObjects('de.voolia.news.comment', $newsIDs); // delete tag to object entries TagEngine::getInstance()->deleteObjects('de.voolia.news.entry', $newsIDs); // delete entry activity events UserActivityEventHandler::getInstance()->removeEvents('de.voolia.news.recentActivityEvent.news', $newsIDs); UserActivityPointHandler::getInstance()->removeEvents('de.voolia.news.activityPointEvent.news', $perUserCount); // delete entry from search index SearchIndexManager::getInstance()->delete('de.voolia.news.entry', $newsIDs); // remove object from moderation queue ModerationQueueActivationManager::getInstance()->removeModeratedContent('de.voolia.news.entry', $newsIDs); } // delete a poll if (!empty($pollIDs)) { PollManager::getInstance()->removePolls($pollIDs); } // reset the user storage data UserStorageHandler::getInstance()->resetAll('newsUnreadEntries'); UserStorageHandler::getInstance()->resetAll('newsUnreadWatchedEntries'); // reset the news cache NewsEditor::resetNewsStatsCache(); }
/** * Fetches the like data. * * @return array */ public function getLikeData() { if (empty($this->objectIDs)) { return array(); } $likeData = array(); $commentObjectType = LikeHandler::getInstance()->getObjectType('com.woltlab.wcf.comment'); LikeHandler::getInstance()->loadLikeObjects($commentObjectType, $this->getObjectIDs()); $likeData['comment'] = LikeHandler::getInstance()->getLikeObjects($commentObjectType); if (!empty($this->responseIDs)) { $responseObjectType = LikeHandler::getInstance()->getObjectType('com.woltlab.wcf.comment.response'); LikeHandler::getInstance()->loadLikeObjects($responseObjectType, $this->responseIDs); $likeData['response'] = LikeHandler::getInstance()->getLikeObjects($responseObjectType); } return $likeData; }
/** * @see \wcf\data\IDeleteAction::delete() */ public function delete() { if (empty($this->objects)) { $this->readObjects(); } // collect data $entryIDs = $entyData = $attachmentEntryIDs = $perUserCount = $pollIDs = array(); foreach ($this->objects as $entry) { $entryIDs[] = $entry->entryID; $entryData[$entry->entryID] = $entry->userID; if ($entry->pollID) { $pollIDs[] = $entry->pollID; } if ($entry->attachments) { $attachmentEntryIDs[] = $entry->entryID; } if (!$entry->isDisabled) { if (!isset($perUserCount[$entry->userID])) { $perUserCount[$entry->userID] = 0; } $perUserCount[$entry->userID]++; } } // remove user activity events $this->removeActivityEvents($entryData); // remove entries foreach ($this->objects as $entry) { $entry->delete(); $this->addEntryData($entry->getDecoratedObject(), 'deleted', LinkHandler::getInstance()->getLink('NewsOverview', array('application' => 'cms'))); NewsEntryModificationLogHandler::getInstance()->delete($entry->getDecoratedObject()); } if (!empty($entryIDs)) { // delete like data LikeHandler::getInstance()->removeLikes('de.incendium.cms.like.likeableNews', $entryIDs); // delete comments CommentHandler::getInstance()->deleteObjects('de.incendium.cms.news.comment', $entryIDs); // delete tag to object entries TagEngine::getInstance()->deleteObjects('de.incendium.cms.news.entry', $entryIDs); // delete entry activity events UserActivityEventHandler::getInstance()->removeEvents('de.incendium.cms.news.recentActivityEvent.entry', $entryIDs); UserActivityPointHandler::getInstance()->removeEvents('de.incendium.cms.news.activityPointEvent.entry', $perUserCount); // delete entry from search index SearchIndexManager::getInstance()->delete('de.incendium.cms.news.entry', $entryIDs); // remove object from moderation queue ModerationQueueActivationManager::getInstance()->removeModeratedContent('de.incendium.cms.news.entry', $entryIDs); } // delete a poll if (!empty($pollIDs)) { PollManager::getInstance()->removePolls($pollIDs); } // delete attachments if (!empty($attachmentEntryIDs)) { AttachmentHandler::removeAttachments('de.incendium.cms.news.entry', $attachmentEntryIDs); } // reset the user storage data UserStorageHandler::getInstance()->resetAll('cmsUnreadNewsEntries'); $this->unmarkItems(); return $this->getEntryData(); }
/** * Validates permissions for given object. */ protected function validateObjectParameters() { if (!MODULE_LIKE) { throw new PermissionDeniedException(); } $this->readString('containerID', false, 'data'); $this->readInteger('objectID', false, 'data'); $this->readString('objectType', false, 'data'); $this->objectType = LikeHandler::getInstance()->getObjectType($this->parameters['data']['objectType']); if ($this->objectType === null) { throw new UserInputException('objectType'); } $this->objectTypeProvider = $this->objectType->getProcessor(); $this->likeableObject = $this->objectTypeProvider->getObjectByID($this->parameters['data']['objectID']); $this->likeableObject->setObjectType($this->objectType); if (!$this->objectTypeProvider->checkPermissions($this->likeableObject)) { throw new PermissionDeniedException(); } }
/** * init one forum post by condition * * @param Mixed $var * @param Array $mbqOpt * $mbqOpt['case'] = 'oViewablePost' means init forum post by oViewablePost * $mbqOpt['case'] = 'byPostId' means init forum post by post id * @return Mixed */ public function initOMbqEtForumPost($var = null, $mbqOpt = array()) { if ($mbqOpt['case'] == 'oViewablePost') { $user = WCF::getUser(); $oPost = $var->getDecoratedObject(); $oMbqEtForumPost = MbqMain::$oClk->newObj('MbqEtForumPost'); $oMbqEtForumPost->postId->setOriValue($oPost->postID); $oMbqEtForumPost->forumId->setOriValue($oPost->getThread()->boardID); $oMbqEtForumPost->topicId->setOriValue($oPost->threadID); $oMbqEtForumPost->postTitle->setOriValue($oPost->subject); $oMbqEtForumPost->postContent->setOriValue($this->customReplacement($oPost->getMessage())); $oMbqEtForumPost->postContent->setAppDisplayValue($this->customReplacement($oPost->getFormattedMessage())); $oMbqEtForumPost->postContent->setTmlDisplayValue($this->processContentForDisplay($var, true)); $oMbqEtForumPost->postContent->setTmlDisplayValueNoHtml($this->processContentForDisplay($var, false)); $oMbqEtForumPost->shortContent->setOriValue(MbqMain::$oMbqCm->getShortContent($oMbqEtForumPost->postContent->tmlDisplayValue)); $oMbqEtForumPost->postAuthorId->setOriValue($oPost->userID); if ($oPost->isDisabled) { $oMbqEtForumPost->state->setOriValue(MbqBaseFdt::getFdt('MbqFdtForum.MbqEtForumPost.state.range.postOkNeedModeration')); } else { $oMbqEtForumPost->state->setOriValue(MbqBaseFdt::getFdt('MbqFdtForum.MbqEtForumPost.state.range.postOk')); } $oMbqAclEtForumPost = MbqMain::$oClk->newObj('MbqAclEtForumPost'); if (MODULE_LIKE && (LIKE_ALLOW_FOR_OWN_CONTENT && $oPost->userID == $user->userID || $oPost->userID != $user->userID) && $oMbqAclEtForumPost->canAclLikePost($oMbqEtForumPost)) { $oMbqEtForumPost->canLike->setOriValue(MbqBaseFdt::getFdt('MbqFdtForum.MbqEtForumPost.canLike.range.yes')); } else { $oMbqEtForumPost->canLike->setOriValue(MbqBaseFdt::getFdt('MbqFdtForum.MbqEtForumPost.canLike.range.no')); } if (isset($oPost->cumulativeLikes)) { $oMbqEtForumPost->likeCount->setOriValue($oPost->cumulativeLikes); } $objectType = LikeHandler::getInstance()->getObjectType('com.woltlab.wbb.likeablePost'); LikeHandler::getInstance()->loadLikeObjects($objectType, array($oPost->postID)); $likeData = LikeHandler::getInstance()->getLikeObjects($objectType); $likeObject = isset($likeData[$oPost->postID]) ? $likeData[$oPost->postID] : null; if (isset($likeObject) && !empty($likeObject)) { $likes = $likeObject->getUsers(); foreach ($likes as $like) { $oMbqEtLike = MbqMain::$oClk->newObj('MbqEtLike'); $oMbqEtLike->key->setOriValue($oPost->postID); $oMbqEtLike->userId->setOriValue($like->__get('userID')); $oMbqEtLike->type->setOriValue(MbqBaseFdt::getFdt('MbqFdtLike.MbqEtLike.type.range.likeForumPost')); $oMbqEtLike->postTime->setOriValue($oPost->time); $oMbqRdEtUser = MbqMain::$oClk->newObj('MbqRdEtUser'); $oMbqEtLike->oMbqEtUser = $oMbqRdEtUser->initOMbqEtUser($like->__get('userID'), array('case' => 'byUserId')); $oMbqEtForumPost->objsMbqEtLike[$like->__get('userID')] = $oMbqEtLike; } if (array_key_exists($user->__get('userID'), $oMbqEtForumPost->objsMbqEtLike)) { $oMbqEtForumPost->isLiked->setOriValue(MbqBaseFdt::getFdt('MbqFdtForum.MbqEtForumPost.isLiked.range.yes')); } else { $oMbqEtForumPost->isLiked->setOriValue(MbqBaseFdt::getFdt('MbqFdtForum.MbqEtForumPost.isLiked.range.no')); } } else { $oMbqEtForumPost->isLiked->setOriValue(MbqBaseFdt::getFdt('MbqFdtForum.MbqEtForumPost.isLiked.range.no')); } $oMbqEtForumPost->postTime->setOriValue($oPost->time); $oMbqEtForumPost->mbqBind['oViewablePost'] = $var; return $oMbqEtForumPost; } elseif ($mbqOpt['case'] == 'byPostId') { $objsMbqEtForumPost = $this->getObjsMbqEtForumPost(array($var), array('case' => 'byPostIds')); if ($objsMbqEtForumPost) { return $objsMbqEtForumPost[0]; } else { return false; } } MbqError::alert('', __METHOD__ . ',line:' . __LINE__ . '.' . MBQ_ERR_INFO_UNKNOWN_CASE); }
/** * Removes all comments for given objects. * * @param string $objectType * @param array<integer> $objectIDs */ public function deleteObjects($objectType, array $objectIDs) { $objectTypeID = $this->getObjectTypeID($objectType); $objectTypeObj = $this->getObjectType($objectTypeID); // get comment ids $commentList = new CommentList(); $commentList->getConditionBuilder()->add('comment.objectTypeID = ?', array($objectTypeID)); $commentList->getConditionBuilder()->add('comment.objectID IN (?)', array($objectIDs)); $commentList->readObjectIDs(); $commentIDs = $commentList->getObjectIDs(); // no comments -> skip if (empty($commentIDs)) { return; } // get response ids $responseList = new CommentResponseList(); $responseList->getConditionBuilder()->add('comment_response.commentID IN (?)', array($commentIDs)); $responseList->readObjectIDs(); $responseIDs = $responseList->getObjectIDs(); // delete likes $notificationObjectTypes = array(); if (UserNotificationHandler::getInstance()->getObjectTypeID($objectTypeObj->objectType . '.like.notification')) { $notificationObjectTypes[] = $objectTypeObj->objectType . '.like.notification'; } LikeHandler::getInstance()->removeLikes('com.woltlab.wcf.comment', $commentIDs, $notificationObjectTypes); // delete activity events if (UserActivityEventHandler::getInstance()->getObjectTypeID($objectTypeObj->objectType . '.recentActivityEvent')) { UserActivityEventHandler::getInstance()->removeEvents($objectTypeObj->objectType . '.recentActivityEvent', $commentIDs); } // delete notifications if (UserNotificationHandler::getInstance()->getObjectTypeID($objectTypeObj->objectType . '.notification')) { UserNotificationHandler::getInstance()->removeNotifications($objectTypeObj->objectType . '.notification', $commentIDs); } if (!empty($responseIDs)) { // delete likes (for responses) $notificationObjectTypes = array(); if (UserNotificationHandler::getInstance()->getObjectTypeID($objectTypeObj->objectType . '.response.like.notification')) { $notificationObjectTypes[] = $objectTypeObj->objectType . '.response.like.notification'; } LikeHandler::getInstance()->removeLikes('com.woltlab.wcf.comment.response', $responseIDs, $notificationObjectTypes); // delete activity events (for responses) if (UserActivityEventHandler::getInstance()->getObjectTypeID($objectTypeObj->objectType . '.response.recentActivityEvent')) { UserActivityEventHandler::getInstance()->removeEvents($objectTypeObj->objectType . '.response.recentActivityEvent', $responseIDs); } // delete notifications (for responses) if (UserNotificationHandler::getInstance()->getObjectTypeID($objectTypeObj->objectType . '.response.notification')) { UserNotificationHandler::getInstance()->removeNotifications($objectTypeObj->objectType . '.response.notification', $responseIDs); } } // delete comments / responses CommentEditor::deleteAll($commentIDs); }
public function readData() { parent::readData(); // update entry visit if ($this->entry->isNew()) { $entryAction = new EntryAction(array($this->entry->getDecoratedObject()), 'markAsRead', array('viewableEntry' => $this->entry)); $entryAction->executeAction(); } // get author's user profile $this->userProfile = $this->entry->getUserProfile(); // get comments $this->commentObjectTypeID = CommentHandler::getInstance()->getObjectTypeID('de.incendium.linklist.entryComment'); $this->commentManager = CommentHandler::getInstance()->getObjectType($this->commentObjectTypeID)->getProcessor(); $this->commentList = CommentHandler::getInstance()->getCommentList($this->commentManager, $this->commentObjectTypeID, $this->entryID); // get other entries by this author $this->userEntryList = new AccessibleEntryList(); $this->userEntryList->enableCategoryLoading(false); $this->userEntryList->getConditionBuilder()->add('entry.userID = ?', array($this->entry->userID)); $this->userEntryList->getConditionBuilder()->add('entry.entryID <> ?', array($this->entry->entryID)); $this->userEntryList->sqlLimit = 5; $this->userEntryList->readObjects(); // get tags if (MODULE_TAGGING) { $this->tags = TagEngine::getInstance()->getObjectTags('de.incendium.linklist.entry', $this->entry->entryID, array($this->entry->languageID === null ? LanguageFactory::getInstance()->getDefaultLanguageID() : "")); } // fetch likes if (MODULE_LIKE) { $objectType = LikeHandler::getInstance()->getObjectType('de.incendium.linklist.likeableEntry'); LikeHandler::getInstance()->loadLikeObjects($objectType, array($this->entryID)); $this->entryLikeData = LikeHandler::getInstance()->getLikeObjects($objectType); } // add breadcrumbs $leafCategories = $this->entry->getLeafCategories(); $category = reset($leafCategories); LINKLISTCore::getInstance()->setLocation($category->getParentCategories(), $category); MetaTagHandler::getInstance()->addTag('og:title', 'og:title', $this->entry->subject . ' - ' . WCF::getLanguage()->get(PAGE_TITLE), true); MetaTagHandler::getInstance()->addTag('og:url', 'og:url', LinkHandler::getInstance()->getLink('Entry', array('application' => 'linklist', 'object' => $this->entry)), true); MetaTagHandler::getInstance()->addTag('og:type', 'og:type', 'article', true); MetaTagHandler::getInstance()->addTag('og:description', 'og:description', $this->entry->teaser, true); // add tags as keywords if (!empty($this->tags)) { $keywords = ''; foreach ($this->tags as $tag) { if (!empty($keywords)) { $keywords .= ', '; } $keywords .= $tag->name; } MetaTagHandler::getInstance()->addTag('keywords', 'keywords', $keywords); } }
/** * @see \wcf\data\AbstractDatabaseObjectAction::delete() */ public function delete() { if (empty($this->objects)) { $this->readObjects(); } // update counters $processors = array(); $groupCommentIDs = $commentIDs = array(); foreach ($this->objects as $comment) { if (!isset($processors[$comment->objectTypeID])) { $objectType = ObjectTypeCache::getInstance()->getObjectType($comment->objectTypeID); $processors[$comment->objectTypeID] = $objectType->getProcessor(); $groupCommentIDs[$comment->objectTypeID] = array(); } $processors[$comment->objectTypeID]->updateCounter($comment->objectID, -1 * ($comment->responses + 1)); $groupCommentIDs[$comment->objectTypeID][] = $comment->commentID; $commentIDs[] = $comment->commentID; } if (!empty($groupCommentIDs)) { $likeObjectIDs = array(); $notificationObjectTypes = array(); foreach ($groupCommentIDs as $objectTypeID => $objectIDs) { // remove activity events $objectType = ObjectTypeCache::getInstance()->getObjectType($objectTypeID); if (UserActivityEventHandler::getInstance()->getObjectTypeID($objectType->objectType . '.recentActivityEvent')) { UserActivityEventHandler::getInstance()->removeEvents($objectType->objectType . '.recentActivityEvent', $objectIDs); } $likeObjectIDs = array_merge($likeObjectIDs, $objectIDs); // delete notifications $objectType = ObjectTypeCache::getInstance()->getObjectType($comment->objectTypeID); if (UserNotificationHandler::getInstance()->getObjectTypeID($objectType->objectType . '.notification')) { UserNotificationHandler::getInstance()->removeNotifications($objectType->objectType . '.notification', $objectIDs); } if (UserNotificationHandler::getInstance()->getObjectTypeID($objectType->objectType . '.like.notification')) { $notificationObjectTypes[] = $objectType->objectType . '.like.notification'; } } // remove likes LikeHandler::getInstance()->removeLikes('com.woltlab.wcf.comment', $likeObjectIDs, $notificationObjectTypes); } // delete responses if (!empty($commentIDs)) { $commentResponseList = new CommentResponseList(); $commentResponseList->getConditionBuilder()->add('comment_response.commentID IN (?)', array($commentIDs)); $commentResponseList->readObjectIDs(); if (count($commentResponseList->getObjectIDs())) { $action = new CommentResponseAction($commentResponseList->getObjectIDs(), 'delete', array('ignoreCounters' => true)); $action->executeAction(); } } return parent::delete(); }