/** * @see \wcf\system\message\embedded\object\IMessageEmbeddedObjectHandler::parseMessage() */ public function parseMessage($message) { $parsedAttachmentIDs = array_unique(ArrayUtil::toIntegerArray(array_merge(self::getFirstParameters($message, 'attach'), self::getTextParameters($message, 'attach')))); if (!empty($parsedAttachmentIDs)) { $attachmentIDs = array(); foreach ($parsedAttachmentIDs as $parsedAttachmentID) { if ($parsedAttachmentID) { $attachmentIDs[] = $parsedAttachmentID; } } if (!empty($attachmentIDs)) { $attachmentList = new AttachmentList(); $attachmentList->getConditionBuilder()->add("attachment.attachmentID IN (?)", array($attachmentIDs)); $attachmentList->readObjectIDs(); return $attachmentList->getObjectIDs(); } } return false; }
/** * @see \wcf\system\message\embedded\object\IMessageEmbeddedObjectHandler::parseMessage() */ public function parseMessage($message) { // yes i know... but what i can do diffrent to the parent class? ;) I am only need xattach... Stupid! $return = false; $parsedIDs = array_unique(ArrayUtil::toIntegerArray(self::getFirstParameters($message, 'xattach'))); if (!empty($parsedIDs)) { $attachmentIDs = array(); foreach ($parsedIDs as $attachmentID) { if ($attachmentID) { $attachmentIDs[] = $attachmentID; } } if (!empty($attachmentIDs)) { $attachmentList = new AttachmentList(); $attachmentList->getConditionBuilder()->add("attachment.attachmentID IN (?)", array($attachmentIDs)); $attachmentList->readObjectIDs(); $return = $attachmentList->getObjectIDs(); } } return $return; }
/** * Removes all attachments for given object ids by type. * * @param string $objectType * @param array<integer> $objectIDs */ public static function removeAttachments($objectType, array $objectIDs) { $attachmentList = new AttachmentList(); $attachmentList->getConditionBuilder()->add("objectTypeID = ?", array(ObjectTypeCache::getInstance()->getObjectTypeByName('com.woltlab.wcf.attachment.objectType', $objectType)->objectTypeID)); $attachmentList->getConditionBuilder()->add("objectID IN (?)", array($objectIDs)); $attachmentList->readObjects(); if (count($attachmentList)) { $attachmentAction = new AttachmentAction($attachmentList->getObjects(), 'delete'); $attachmentAction->executeAction(); } }
/** * Copies attachments from one object id to another. */ public function copy() { $sourceObjectType = ObjectTypeCache::getInstance()->getObjectTypeByName('com.woltlab.wcf.attachment.objectType', $this->parameters['sourceObjectType']); $targetObjectType = ObjectTypeCache::getInstance()->getObjectTypeByName('com.woltlab.wcf.attachment.objectType', $this->parameters['targetObjectType']); $attachmentList = new AttachmentList(); $attachmentList->getConditionBuilder()->add("attachment.objectTypeID = ?", array($sourceObjectType->objectTypeID)); $attachmentList->getConditionBuilder()->add("attachment.objectID = ?", array($this->parameters['sourceObjectID'])); $attachmentList->readObjects(); $newAttachmentIDs = array(); foreach ($attachmentList as $attachment) { $newAttachment = AttachmentEditor::create(array('objectTypeID' => $targetObjectType->objectTypeID, 'objectID' => $this->parameters['targetObjectID'], 'userID' => $attachment->userID, 'filename' => $attachment->filename, 'filesize' => $attachment->filesize, 'fileType' => $attachment->fileType, 'fileHash' => $attachment->fileHash, 'isImage' => $attachment->isImage, 'width' => $attachment->width, 'height' => $attachment->height, 'tinyThumbnailType' => $attachment->tinyThumbnailType, 'tinyThumbnailSize' => $attachment->tinyThumbnailSize, 'tinyThumbnailWidth' => $attachment->tinyThumbnailWidth, 'tinyThumbnailHeight' => $attachment->tinyThumbnailHeight, 'thumbnailType' => $attachment->thumbnailType, 'thumbnailSize' => $attachment->thumbnailSize, 'thumbnailWidth' => $attachment->thumbnailWidth, 'thumbnailHeight' => $attachment->thumbnailHeight, 'downloads' => $attachment->downloads, 'lastDownloadTime' => $attachment->lastDownloadTime, 'uploadTime' => $attachment->uploadTime, 'showOrder' => $attachment->showOrder)); // copy attachment @copy($attachment->getLocation(), $newAttachment->getLocation()); if ($attachment->tinyThumbnailSize) { @copy($attachment->getTinyThumbnailLocation(), $newAttachment->getTinyThumbnailLocation()); } if ($attachment->thumbnailSize) { @copy($attachment->getThumbnailLocation(), $newAttachment->getThumbnailLocation()); } $newAttachmentIDs[$attachment->attachmentID] = $newAttachment->attachmentID; } return array('attachmentIDs' => $newAttachmentIDs); }