public function getAttachments() { if (MODULE_ATTACHMENT == 1 && $this->attachments) { $attachmentList = new GroupedAttachmentList('de.codequake.cms.news'); $attachmentList->getConditionBuilder()->add('attachment.objectID IN (?)', array($this->newsID)); $attachmentList->readObjects(); $attachmentList->setPermissions(array('canDownload' => WCF::getSession()->getPermission('user.cms.news.canDownloadAttachments'), 'canViewPreview' => WCF::getSession()->getPermission('user.cms.news.canDownloadAttachments'))); AttachmentBBCode::setAttachmentList($attachmentList); return $attachmentList; } return null; }
/** * @return \wcf\data\attachment\GroupedAttachmentList */ public function getAttachments() { if (MODULE_ATTACHMENT && $this->attachments) { $attachmentList = new GroupedAttachmentList(self::$objectType); $attachmentList->getConditionBuilder()->add('attachment.objectID IN (?)', array($this->{static::getDatabaseTableIndexName()})); $attachmentList->readObjects(); //add permissions! $attachmentList->setPermissions(array('canDownload' => '', 'canViewPreview' => '')); AttachmentBBCode::setAttachmentList($attachmentList); return $attachmentList; } return; }
/** * Assigns and returns the embedded attachments. * * @param boolean $ignoreCache * @return \wcf\data\attachment\GroupedAttachmentList */ public function getAttachments($ignoreCache = false) { if (MODULE_ATTACHMENT == 1 && ($this->attachments || $ignoreCache)) { $attachmentList = new GroupedAttachmentList('com.woltlab.wcf.conversation.message'); $attachmentList->getConditionBuilder()->add('attachment.objectID IN (?)', array($this->messageID)); $attachmentList->readObjects(); $attachmentList->setPermissions(array('canDownload' => true, 'canViewPreview' => true)); if ($ignoreCache && !count($attachmentList)) { return null; } return $attachmentList; } return null; }
/** * Reads the list of attachments. */ public function readAttachments() { if (MODULE_ATTACHMENT == 1 && !empty($this->attachmentObjectIDs)) { $this->attachmentList = new GroupedAttachmentList('com.woltlab.wcf.conversation.message'); $this->attachmentList->getConditionBuilder()->add('attachment.objectID IN (?)', array($this->attachmentObjectIDs)); $this->attachmentList->readObjects(); } }
/** * Gets a list of attachments. */ public function readAttachments() { if (MODULE_ATTACHMENT && !empty($this->attachmentObjectIDs)) { $this->attachmentList = new GroupedAttachmentList('de.incendium.cms.news.entry'); $this->attachmentList->getConditionBuilder()->add('attachment.objectID IN (?)', array($this->attachmentObjectIDs)); $this->attachmentList->readObjects(); // set embedded attachments AttachmentBBCode::setAttachmentList($this->attachmentList); } }
/** * Gets and assigns embedded attachments. * * @return \wcf\data\attachment\GroupedAttachmentList */ public function getAttachments() { if (MODULE_ATTACHMENT == 1 && $this->attachments) { $attachmentList = new GroupedAttachmentList('de.voolia.news.entry'); $attachmentList->getConditionBuilder()->add('attachment.objectID IN (?)', array($this->newsID)); $attachmentList->readObjects(); // set embedded attachments AttachmentBBCode::setAttachmentList($attachmentList); return $attachmentList; } return null; }
/** * Returns and assigns embedded attachments. * * @return \wcf\data\attachment\GroupedAttachmentList */ public function getAttachments() { if (MODULE_ATTACHMENT == 1 && $this->attachments) { $attachmentList = new GroupedAttachmentList('de.incendium.filebase.entry'); $attachmentList->getConditionBuilder()->add('attachment.objectID IN (?)', array($this->entryID)); $attachmentList->readObjects(); $attachmentList->setPermissions(array('canDownload' => WCF::getSession()->getPermission('user.filebase.canViewScreenshot'), 'canViewPreview' => WCF::getSession()->getPermission('user.filebase.canViewScreenshot'))); // set embedded attachments AttachmentBBCode::setAttachmentList($attachmentList); return $attachmentList; } return null; }
/** * @see \wcf\system\bbcode\IBBCode::getParsedTag() */ public function getParsedTag(array $openingTag, $content, array $closingTag, BBCodeParser $parser) { // get attachment id $attachmentID = 0; if (isset($openingTag['attributes'][0])) { $attachmentID = $openingTag['attributes'][0]; } // get embedded object $attachment = MessageEmbeddedObjectManager::getInstance()->getObject('com.woltlab.wcf.attachment', $attachmentID); if ($attachment === null) { if (self::$attachmentList !== null) { $attachments = self::$attachmentList->getGroupedObjects(self::$objectID); if (isset($attachments[$attachmentID])) { $attachment = $attachments[$attachmentID]; // mark attachment as embedded $attachment->markAsEmbedded(); } } } if ($attachment !== null) { if ($attachment->showAsImage() && $attachment->canViewPreview() && $parser->getOutputType() == 'text/html') { // image $alignment = isset($openingTag['attributes'][1]) ? $openingTag['attributes'][1] : ''; $width = isset($openingTag['attributes'][2]) ? $openingTag['attributes'][2] : 0; // check if width is valid and the original is accessible by viewer if ($width > 0) { if ($attachment->canDownload()) { // check if width exceeds image width if ($width > $attachment->width) { $width = $attachment->width; } } else { $width = 0; } } $result = ''; if ($width > 0) { $class = ''; if ($alignment == 'left' || $alignment == 'right') { $class = 'messageFloatObject' . ucfirst($alignment); } $source = StringUtil::encodeHTML(LinkHandler::getInstance()->getLink('Attachment', array('object' => $attachment))); $title = StringUtil::encodeHTML($attachment->filename); $result = '<a href="' . $source . '" title="' . $title . '" class="embeddedAttachmentLink jsImageViewer' . ($class ? ' ' . $class : '') . '"><img src="' . $source . '" style="width: ' . $width . 'px" alt="" /></a>'; } else { $linkParameters = array('object' => $attachment); if ($attachment->hasThumbnail()) { $linkParameters['thumbnail'] = 1; } $class = ''; if ($alignment == 'left' || $alignment == 'right') { $class = 'messageFloatObject' . ucfirst($alignment); } $imageClasses = ''; if (!$attachment->hasThumbnail()) { $imageClasses = 'embeddedAttachmentLink jsResizeImage'; } if ($class && (!$attachment->hasThumbnail() || !$attachment->canDownload())) { $imageClasses .= ' ' . $class; } $result = '<img src="' . StringUtil::encodeHTML(LinkHandler::getInstance()->getLink('Attachment', $linkParameters)) . '"' . ($imageClasses ? ' class="' . $imageClasses . '"' : '') . ' style="width: ' . ($attachment->hasThumbnail() ? $attachment->thumbnailWidth : $attachment->width) . 'px; height: ' . ($attachment->hasThumbnail() ? $attachment->thumbnailHeight : $attachment->height) . 'px;" alt="" />'; if ($attachment->hasThumbnail() && $attachment->canDownload()) { $result = '<a href="' . StringUtil::encodeHTML(LinkHandler::getInstance()->getLink('Attachment', array('object' => $attachment))) . '" title="' . StringUtil::encodeHTML($attachment->filename) . '" class="embeddedAttachmentLink jsImageViewer' . ($class ? ' ' . $class : '') . '">' . $result . '</a>'; } } return $result; } else { // file return StringUtil::getAnchorTag(LinkHandler::getInstance()->getLink('Attachment', array('object' => $attachment)), !empty($content) && $content != $attachmentID ? $content : $attachment->filename); } } // fallback return StringUtil::getAnchorTag(LinkHandler::getInstance()->getLink('Attachment', array('id' => $attachmentID))); }