/**
  * {@inheritdoc}
  */
 public function delete()
 {
     //get classes
     $baseClass = $this->className;
     $articleClass = $baseClass::getBaseClass();
     $attachedNewsIDs = array();
     foreach ($this->objects as $article) {
         $this->objectIDs[] = $article->{$baseClass::getDatabaseTableIndexName()};
         if ($article->attachments != 0) {
             $attachedObjectIDs[] = $article->{$baseClass::getDatabaseTableIndexName()};
         }
     }
     // remove attachments
     if (0 !== count($attachedObjectIDs)) {
         AttachmentHandler::removeAttachments($articleClass::$objectType, $attachedObjectIDs);
     }
     return parent::delete();
 }
Esempio n. 2
0
 /**
  * init one forum by condition
  *
  * @param  Mixed  $var
  * @param  Array  $mbqOpt
  * $mbqOpt['case'] = 'byForumId' means init forum by forum id
  * $mbqOpt['case'] = 'oDetailedBoardNode' means init forum by oDetailedBoardNode
  * @return  Mixed
  */
 public function initOMbqEtForum($var = null, $mbqOpt = array())
 {
     if ($mbqOpt['case'] == 'byForumId') {
         if (isset(MbqMain::$oMbqAppEnv->exttAllForums[$var])) {
             return MbqMain::$oMbqAppEnv->exttAllForums[$var];
         }
         return false;
     } elseif ($mbqOpt['case'] == 'oDetailedBoardNode') {
         $oBoard = $var->getBoard();
         $oMbqEtForum = MbqMain::$oClk->newObj('MbqEtForum');
         $oMbqEtForum->forumId->setOriValue($oBoard->boardID);
         $oMbqEtForum->forumName->setOriValue($oBoard->getTitle());
         $oMbqEtForum->description->setOriValue($oBoard->description);
         $oMbqEtForum->totalTopicNum->setOriValue($var->getThreads());
         $oMbqEtForum->totalPostNum->setOriValue($var->getPosts());
         $oMbqEtForum->parentId->setOriValue($oBoard->parentID);
         if ($var->getUnreadThreads()) {
             $oMbqEtForum->newPost->setOriValue(MbqBaseFdt::getFdt('MbqFdtForum.MbqEtForum.newPost.range.yes'));
         }
         if ($oBoard->isExternalLink()) {
             $oMbqEtForum->url->setOriValue($oBoard->getLink());
         }
         if ($oBoard->isCategory()) {
             $oMbqEtForum->subOnly->setOriValue(MbqBaseFdt::getFdt('MbqFdtForum.MbqEtForum.subOnly.range.yes'));
         } elseif ($oBoard->isBoard()) {
             $oMbqEtForum->subOnly->setOriValue(MbqBaseFdt::getFdt('MbqFdtForum.MbqEtForum.subOnly.range.no'));
         }
         $oMbqAclEtForumTopic = MbqMain::$oClk->newObj('MbqAclEtForumTopic');
         $oMbqEtForum->mbqBind['oDetailedBoardNode'] = $var;
         if ($oMbqAclEtForumTopic->canAclNewTopic($oMbqEtForum)) {
             $oMbqEtForum->canPost->setOriValue(MbqBaseFdt::getFdt('MbqFdtForum.MbqEtForum.canPost.range.yes'));
         } else {
             $oMbqEtForum->canPost->setOriValue(MbqBaseFdt::getFdt('MbqFdtForum.MbqEtForum.canPost.range.no'));
         }
         $attachmentObjectType = 'com.woltlab.wbb.post';
         $attachmentObjectID = 0;
         $attachmentParentObjectID = $oBoard->boardID;
         $oAttachmentHandler = new AttachmentHandler($attachmentObjectType, $attachmentObjectID, \wcf\util\StringUtil::getRandomID(), $attachmentParentObjectID);
         if ($oAttachmentHandler->canUpload()) {
             $oMbqEtForum->canUpload->setOriValue(MbqBaseFdt::getFdt('MbqFdtForum.MbqEtForum.canUpload.range.yes'));
         } else {
             $oMbqEtForum->canUpload->setOriValue(MbqBaseFdt::getFdt('MbqFdtForum.MbqEtForum.canUpload.range.no'));
         }
         return $oMbqEtForum;
     }
     MbqError::alert('', __METHOD__ . ',line:' . __LINE__ . '.' . MBQ_ERR_INFO_UNKNOWN_CASE);
 }
 /**
  * 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();
 }
 /**
  * @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();
 }
 /**
  * @see	\wcf\data\IMessageInlineEditorAction::beginEdit()
  */
 public function beginEdit()
 {
     BBCodeHandler::getInstance()->setAllowedBBCodes(explode(',', WCF::getSession()->getPermission('user.message.allowedBBCodes')));
     WCF::getTPL()->assign(array('defaultSmilies' => SmileyCache::getInstance()->getCategorySmilies(), 'message' => $this->message, 'permissionCanUseSmilies' => 'user.message.canUseSmilies', 'wysiwygSelector' => 'messageEditor' . $this->message->messageID));
     if (MODULE_ATTACHMENT) {
         $tmpHash = StringUtil::getRandomID();
         $attachmentHandler = new AttachmentHandler('com.woltlab.wcf.conversation.message', $this->message->messageID, $tmpHash);
         $attachmentList = $attachmentHandler->getAttachmentList();
         WCF::getTPL()->assign(array('attachmentHandler' => $attachmentHandler, 'attachmentList' => $attachmentList->getObjects(), 'attachmentObjectID' => $this->message->messageID, 'attachmentObjectType' => 'com.woltlab.wcf.conversation.message', 'attachmentParentObjectID' => 0, 'tmpHash' => $tmpHash));
     }
     return array('actionName' => 'beginEdit', 'template' => WCF::getTPL()->fetch('conversationMessageInlineEditor'));
 }
Esempio n. 6
0
 /**
  * Validates the upload action.
  */
 public function validateUpload()
 {
     // IE<10 fallback
     if (isset($_POST['isFallback'])) {
         $this->parameters['objectType'] = isset($_POST['objectType']) ? $_POST['objectType'] : '';
         $this->parameters['objectID'] = isset($_POST['objectID']) ? $_POST['objectID'] : 0;
         $this->parameters['parentObjectID'] = isset($_POST['parentObjectID']) ? $_POST['parentObjectID'] : 0;
         $this->parameters['tmpHash'] = isset($_POST['tmpHash']) ? $_POST['tmpHash'] : '';
     }
     // read variables
     $this->readString('objectType');
     $this->readInteger('objectID', true);
     $this->readInteger('parentObjectID', true);
     $this->readString('tmpHash');
     // validate object type
     $objectType = ObjectTypeCache::getInstance()->getObjectTypeByName('com.woltlab.wcf.attachment.objectType', $this->parameters['objectType']);
     if ($objectType === null) {
         throw new UserInputException('objectType');
     }
     // get processor
     $processor = $objectType->getProcessor();
     // check upload permissions
     if (!$processor->canUpload(!empty($this->parameters['objectID']) ? intval($this->parameters['objectID']) : 0, !empty($this->parameters['parentObjectID']) ? intval($this->parameters['parentObjectID']) : 0)) {
         throw new PermissionDeniedException();
     }
     // check max count of uploads
     $handler = new AttachmentHandler($this->parameters['objectType'], intval($this->parameters['objectID']), $this->parameters['tmpHash']);
     if ($handler->count() + count($this->parameters['__files']->getFiles()) > $processor->getMaxCount()) {
         throw new UserInputException('files', 'exceededQuota', array('current' => $handler->count(), 'quota' => $processor->getMaxCount()));
     }
     // check max filesize, allowed file extensions etc.
     $this->parameters['__files']->validateFiles(new DefaultUploadFileValidationStrategy($processor->getMaxSize(), $processor->getAllowedExtensions()));
 }
Esempio n. 7
0
 public function delete()
 {
     $newsIDs = array();
     $attachedNewsIDs = array();
     foreach ($this->objects as $news) {
         $newsIDs[] = $news->newsID;
         if ($news->attachments != 0) {
             $attachedNewsIDs[] = $news->newsID;
         }
     }
     // remove activity points
     UserActivityPointHandler::getInstance()->removeEvents('de.codequake.cms.activityPointEvent.news', $newsIDs);
     // remove attaches
     if (!empty($attachedNewsIDs)) {
         AttachmentHandler::removeAttachments('de.codequake.cms.news', $attachedNewsIDs);
     }
     // delete old search index entries
     if (!empty($objectIDs)) {
         SearchIndexManager::getInstance()->delete('de.codequake.cms.news', $newsIDs);
     }
     if (isset($this->parameters['unmarkItems'])) {
         $this->unmarkItems($newsIDs);
     }
     return parent::delete();
 }