/**
  * @see	\wcf\system\moderation\queue\IModerationQueueHandler::assignQueues()
  */
 public function assignQueues(array $queues)
 {
     $assignments = array();
     // read comments and responses
     $responseIDs = array();
     foreach ($queues as $queue) {
         $responseIDs[] = $queue->objectID;
     }
     $conditions = new PreparedStatementConditionBuilder();
     $conditions->add("comment_response.responseID IN (?)", array($responseIDs));
     $sql = "SELECT\t\tcomment_response.responseID, comment.commentID, comment.objectTypeID, comment.objectID\n\t\t\tFROM\t\twcf" . WCF_N . "_comment_response comment_response\n\t\t\tLEFT JOIN\twcf" . WCF_N . "_comment comment\n\t\t\tON\t\t(comment.commentID = comment_response.commentID)\n\t\t\t" . $conditions;
     $statement = WCF::getDB()->prepareStatement($sql);
     $statement->execute($conditions->getParameters());
     $comments = $responses = array();
     while ($row = $statement->fetchArray()) {
         $comments[$row['commentID']] = new Comment(null, $row);
         $responses[$row['responseID']] = new CommentResponse(null, $row);
     }
     $orphanedQueueIDs = array();
     foreach ($queues as $queue) {
         $assignUser = false;
         if (!isset($responses[$queue->objectID]) || !isset($comments[$responses[$queue->objectID]->commentID])) {
             $orphanedQueueIDs[] = $queue->queueID;
             continue;
         }
         $comment = $comments[$responses[$queue->objectID]->commentID];
         if ($this->getCommentManager($comment)->canModerate($comment->objectTypeID, $comment->objectID)) {
             $assignUser = true;
         }
         $assignments[$queue->queueID] = $assignUser;
     }
     ModerationQueueManager::getInstance()->removeOrphans($orphanedQueueIDs);
     ModerationQueueManager::getInstance()->setAssignment($assignments);
 }
 /**
  * @see	\wcf\page\IPage::readParameters()
  */
 public function readParameters()
 {
     parent::readParameters();
     $processor = ModerationQueueManager::getInstance()->getProcessor(null, null, $this->queue->objectTypeID);
     if (!$processor instanceof IModerationQueueReportHandler) {
         throw new IllegalLinkException();
     }
 }
 /**
  * @see	\wcf\system\moderation\queue\IModerationQueueHandler::assignQueues()
  */
 public function assignQueues(array $queues)
 {
     $assignments = array();
     foreach ($queues as $queue) {
         $assignUser = false;
         if (WCF::getSession()->getPermission('mod.general.canUseModeration')) {
             $assignUser = true;
         }
         $assignments[$queue->queueID] = $assignUser;
     }
     ModerationQueueManager::getInstance()->setAssignment($assignments);
 }
 /**
  * @see	\wcf\data\DatabaseObjectList::readObjects()
  */
 public function readObjects()
 {
     parent::readObjects();
     if (!empty($this->objects)) {
         $objects = array();
         foreach ($this->objects as &$object) {
             $object = new ViewableModerationQueue($object);
             if (!isset($objects[$object->objectTypeID])) {
                 $objects[$object->objectTypeID] = array();
             }
             $objects[$object->objectTypeID][] = $object;
         }
         unset($object);
         foreach ($objects as $objectTypeID => $queueItems) {
             ModerationQueueManager::getInstance()->populate($objectTypeID, $queueItems);
         }
         // check for non-existant items
         $queueIDs = array();
         foreach ($this->objects as $index => $object) {
             if ($object->isOrphaned()) {
                 $queueIDs[] = $object->queueID;
                 unset($this->objects[$index]);
             }
         }
         // remove orphaned queues
         if (!empty($queueIDs)) {
             $this->indexToObject = array_keys($this->objects);
             ModerationQueueManager::getInstance()->removeOrphans($queueIDs);
         }
         if ($this->loadUserProfiles) {
             $userIDs = array();
             foreach ($this->objects as $object) {
                 $userIDs[] = $object->getAffectedObject()->getUserID();
             }
             $userProfiles = UserProfile::getUserProfiles($userIDs);
             foreach ($this->objects as $object) {
                 if (isset($userProfiles[$object->getAffectedObject()->getUserID()])) {
                     $object->setUserProfile($userProfiles[$object->getAffectedObject()->getUserID()]);
                 }
             }
         }
     }
 }
 /**
  * @see	\wcf\system\cronjob\ICronjob::execute()
  */
 public function execute(Cronjob $cronjob)
 {
     parent::execute($cronjob);
     $sql = "SELECT\tqueueID\n\t\t\tFROM\twcf" . WCF_N . "_moderation_queue\n\t\t\tWHERE\tstatus = ?\n\t\t\t\tAND lastChangeTime < ?";
     $statement = WCF::getDB()->prepareStatement($sql);
     $statement->execute(array(ModerationQueue::STATUS_DONE, TIME_NOW - 86400 * 30));
     $queueIDs = array();
     while ($row = $statement->fetchArray()) {
         $queueIDs[] = $row['queueID'];
     }
     if (!empty($queueIDs)) {
         $conditions = new PreparedStatementConditionBuilder();
         $conditions->add("queueID IN (?)", array($queueIDs));
         $sql = "DELETE FROM\twcf" . WCF_N . "_moderation_queue\n\t\t\t\t" . $conditions;
         $statement = WCF::getDB()->prepareStatement($sql);
         $statement->execute($conditions->getParameters());
         // reset moderation count for all users
         ModerationQueueManager::getInstance()->resetModerationCount();
     }
 }
 /**
  * @see	\wcf\system\moderation\queue\IModerationQueueHandler::removeQueues()
  */
 public function removeQueues(array $objectIDs)
 {
     $objectTypeID = ModerationQueueManager::getInstance()->getObjectTypeID($this->definitionName, $this->objectType);
     if ($objectTypeID === null) {
         throw new SystemException("Object type '" . $this->objectType . "' is not valid for definition '" . $this->definitionName . "'");
     }
     $conditions = new PreparedStatementConditionBuilder();
     $conditions->add("objectTypeID = ?", array($objectTypeID));
     $conditions->add("objectID IN (?)", array($objectIDs));
     $sql = "SELECT\tqueueID\n\t\t\tFROM\twcf" . WCF_N . "_moderation_queue\n\t\t\t" . $conditions;
     $statement = WCF::getDB()->prepareStatement($sql);
     $statement->execute($conditions->getParameters());
     $queueIDs = array();
     while ($row = $statement->fetchArray()) {
         $queueIDs[] = $row['queueID'];
     }
     if (!empty($queueIDs)) {
         $queueAction = new ModerationQueueAction($queueIDs, 'delete');
         $queueAction->executeAction();
     }
 }
 /**
  * Marks this entry as rejected, e.g. report was unjustified or content approval was denied.
  */
 public function markAsRejected()
 {
     $this->update(array('status' => ModerationQueue::STATUS_REJECTED));
     // reset moderation count
     ModerationQueueManager::getInstance()->resetModerationCount();
 }
Пример #8
0
 /**
  * @see	\wcf\page\IPage::assignVariables()
  */
 public function assignVariables()
 {
     parent::assignVariables();
     WCF::getTPL()->assign(array('assignedUserID' => $this->assignedUserID, 'availableDefinitions' => $this->availableDefinitions, 'definitionID' => $this->definitionID, 'definitionNames' => ModerationQueueManager::getInstance()->getDefinitionNamesByObjectTypeIDs(), 'status' => $this->status));
 }
Пример #9
0
 /**
  * @see	\wcf\form\IForm::save()
  */
 public function save()
 {
     AbstractForm::save();
     // handle avatar
     if ($this->avatarType != 'custom') {
         // delete custom avatar
         if ($this->user->avatarID) {
             $action = new UserAvatarAction(array($this->user->avatarID), 'delete');
             $action->executeAction();
         }
     }
     switch ($this->avatarType) {
         case 'none':
             $avatarData = array('avatarID' => null, 'enableGravatar' => 0);
             break;
         case 'custom':
             $avatarData = array('enableGravatar' => 0);
             break;
         case 'gravatar':
             $avatarData = array('avatarID' => null, 'enableGravatar' => 1);
             break;
     }
     $this->additionalFields = array_merge($this->additionalFields, $avatarData);
     // add default groups
     $defaultGroups = UserGroup::getAccessibleGroups(array(UserGroup::GUESTS, UserGroup::EVERYONE, UserGroup::USERS));
     $oldGroupIDs = $this->user->getGroupIDs();
     foreach ($oldGroupIDs as $oldGroupID) {
         if (isset($defaultGroups[$oldGroupID])) {
             $this->groupIDs[] = $oldGroupID;
         }
     }
     $this->groupIDs = array_unique($this->groupIDs);
     // save user
     $saveOptions = $this->optionHandler->save();
     $data = array('data' => array_merge($this->additionalFields, array('username' => $this->username, 'email' => $this->email, 'password' => $this->password, 'languageID' => $this->languageID, 'userTitle' => $this->userTitle, 'signature' => $this->signature, 'signatureEnableBBCodes' => $this->signatureEnableBBCodes, 'signatureEnableSmilies' => $this->signatureEnableSmilies, 'signatureEnableHtml' => $this->signatureEnableHtml)), 'groups' => $this->groupIDs, 'languageIDs' => $this->visibleLanguages, 'options' => $saveOptions);
     // handle ban
     if (WCF::getSession()->getPermission('admin.user.canBanUser')) {
         if ($this->banExpires) {
             $this->banExpires = strtotime($this->banExpires);
         } else {
             $this->banExpires = 0;
         }
         $data['data']['banned'] = $this->banned;
         $data['data']['banReason'] = $this->banReason;
         $data['data']['banExpires'] = $this->banExpires;
     }
     // handle disabled signature
     if (WCF::getSession()->getPermission('admin.user.canDisableSignature')) {
         if ($this->disableSignatureExpires) {
             $this->disableSignatureExpires = strtotime($this->disableSignatureExpires);
         } else {
             $this->disableSignatureExpires = 0;
         }
         $data['data']['disableSignature'] = $this->disableSignature;
         $data['data']['disableSignatureReason'] = $this->disableSignatureReason;
         $data['data']['disableSignatureExpires'] = $this->disableSignatureExpires;
     }
     // handle disabled avatar
     if (WCF::getSession()->getPermission('admin.user.canDisableAvatar')) {
         if ($this->disableAvatarExpires) {
             $this->disableAvatarExpires = strtotime($this->disableAvatarExpires);
         } else {
             $this->disableAvatarExpires = 0;
         }
         $data['data']['disableAvatar'] = $this->disableAvatar;
         $data['data']['disableAvatarReason'] = $this->disableAvatarReason;
         $data['data']['disableAvatarExpires'] = $this->disableAvatarExpires;
     }
     $this->objectAction = new UserAction(array($this->userID), 'update', $data);
     $this->objectAction->executeAction();
     // update user rank
     $editor = new UserEditor(new User($this->userID));
     if (MODULE_USER_RANK) {
         $action = new UserProfileAction(array($editor), 'updateUserRank');
         $action->executeAction();
     }
     if (MODULE_USERS_ONLINE) {
         $action = new UserProfileAction(array($editor), 'updateUserOnlineMarking');
         $action->executeAction();
     }
     // remove assignments
     $sql = "DELETE FROM\twcf" . WCF_N . "_moderation_queue_to_user\n\t\t\tWHERE\t\tuserID = ?";
     $statement = WCF::getDB()->prepareStatement($sql);
     $statement->execute(array($this->user->userID));
     // reset moderation count
     ModerationQueueManager::getInstance()->resetModerationCount($this->user->userID);
     $this->saved();
     // reset password
     $this->password = $this->confirmPassword = '';
     // show success message
     WCF::getTPL()->assign('success', true);
 }
 /**
  * @see	\wcf\system\moderation\queue\AbstractModerationQueueManager::addEntry()
  */
 protected function addEntry($objectTypeID, $objectID, $containerID = 0, array $additionalData = array())
 {
     $sql = "SELECT\tqueueID\n\t\t\tFROM\twcf" . WCF_N . "_moderation_queue\n\t\t\tWHERE\tobjectTypeID = ?\n\t\t\t\tAND objectID = ?\n\t\t\t\tAND status <> ?";
     $statement = WCF::getDB()->prepareStatement($sql);
     $statement->execute(array($objectTypeID, $objectID, ModerationQueue::STATUS_DONE));
     $row = $statement->fetchArray();
     if ($row === false) {
         $objectAction = new ModerationQueueAction(array(), 'create', array('data' => array('objectTypeID' => $objectTypeID, 'objectID' => $objectID, 'containerID' => $containerID, 'userID' => WCF::getUser()->userID ?: null, 'time' => TIME_NOW, 'additionalData' => serialize($additionalData))));
         $objectAction->executeAction();
     } else {
         $objectAction = new ModerationQueueAction(array($row['queueID']), 'update', array('data' => array('status' => ModerationQueue::STATUS_OUTSTANDING, 'containerID' => $containerID, 'userID' => WCF::getUser()->userID ?: null, 'time' => TIME_NOW, 'additionalData' => serialize($additionalData))));
         $objectAction->executeAction();
     }
     ModerationQueueManager::getInstance()->resetModerationCount();
 }
 /**
  * @see	\wcf\data\AbstractDatabaseObjectAction::delete()
  */
 public function delete()
 {
     $count = parent::delete();
     $attachmentMessageIDs = $conversationIDs = array();
     foreach ($this->objects as $message) {
         if (!in_array($message->conversationID, $conversationIDs)) {
             $conversationIDs[] = $message->conversationID;
         }
         if ($message->attachments) {
             $attachmentMessageIDs[] = $message->messageID;
         }
     }
     // rebuild conversations
     if (!empty($conversationIDs)) {
         $conversationAction = new ConversationAction($conversationIDs, 'rebuild');
         $conversationAction->executeAction();
     }
     if (!empty($this->objectIDs)) {
         // delete notifications
         UserNotificationHandler::getInstance()->deleteNotifications('conversationMessage', 'com.woltlab.wcf.conversation.message.notification', array(), $this->objectIDs);
         // update search index
         SearchIndexManager::getInstance()->delete('com.woltlab.wcf.conversation.message', $this->objectIDs);
         // update embedded objects
         MessageEmbeddedObjectManager::getInstance()->removeObjects('com.woltlab.wcf.conversation.message', $this->objectIDs);
         // remove moderation queues
         ModerationQueueManager::getInstance()->removeQueues('com.woltlab.wcf.conversation.message', $this->objectIDs);
     }
     // remove attachments
     if (!empty($attachmentMessageIDs)) {
         AttachmentHandler::removeAttachments('com.woltlab.wcf.conversation.message', $attachmentMessageIDs);
     }
     return $count;
 }
 /**
  * Marks queue entries as read.
  */
 public function markAsRead()
 {
     if (empty($this->parameters['visitTime'])) {
         $this->parameters['visitTime'] = TIME_NOW;
     }
     if (empty($this->objects)) {
         $this->readObjects();
     }
     foreach ($this->objects as $queue) {
         VisitTracker::getInstance()->trackObjectVisit('com.woltlab.wcf.moderation.queue', $queue->queueID, $this->parameters['visitTime']);
     }
     // reset storage
     UserStorageHandler::getInstance()->reset(array(WCF::getUser()->userID), 'unreadModerationCount');
     if (count($this->objects) == 1) {
         $queue = reset($this->objects);
         return array('markAsRead' => $queue->queueID, 'totalCount' => ModerationQueueManager::getInstance()->getUnreadModerationCount(true));
     }
 }
 /**
  * Returns the link for viewing/editing this object.
  * 
  * @return	string
  */
 public function getLink()
 {
     return ModerationQueueManager::getInstance()->getLink($this->objectTypeID, $this->queueID);
 }