/** * Gets the "public" attachment information for a node. Which may be empty. * @param int|int[] $nodeids nodeid or array of nodeids * @return array Array( * {nodeid1} => array( * {attachmentid1} => array(attachment information), * {attachmentid2} => array(attachment information) * ), * {nodeid2} => array( * {attachmentid3} => array(attachment information), * {attachmentid4} => array(attachment information) * ), * ) * Where attachment information contains * - nodeid * - parentid * - filedataid * - filename * - filesize * - settings * - counter * - dateline * - resize_dateline * - extension */ function getNodeAttachmentsPublicInfo($nodeids) { if (empty($nodeids)) { return array(); } if (!is_array($nodeids)) { $nodeids = array($nodeids); } $getnodeids = array(); $perms = array(); foreach ($nodeids as $nodeid) { $node = $this->library->getNodeBare($nodeid); $contentApi = vB_Api_Content::getContentApi($node['contenttypeid']); if (!$contentApi->validate($node, vB_Api_Content::ACTION_VIEW, $node['nodeid'], array($node['nodeid'] => $node))) { continue; } $getnodeids[] = $nodeid; /* We don't care about attachment permissions. This is used for getting enough attachment data to create the attachment link for a user who DOES NOT have enough permission to view an image outright. $perms[$nodeid] = array( 'cangetattachment' => vB::getUserContext()->getChannelPermission('forumpermissions', 'cangetattachment', $nodeid), 'cangetimgattachment' => vB::getUserContext()->getChannelPermission('forumpermissions2', 'cangetimgattachment', $nodeid), ); */ } if (empty($getnodeids)) { return array(); } $attachments = array(); $rawAttach = $this->library->fetchNodeAttachments($getnodeids); $publicFields = array("nodeid", "contenttypeid", "parentid", "filedataid", "filename", "filesize", "settings", "resize_filesize", "hasthumbnail", "counter", "dateline", "resize_dateline", "extension"); foreach ($rawAttach as $attach) { foreach ($publicFields as $fieldname) { if (isset($attach[$fieldname])) { $attachments[$attach['parentid']][$attach['nodeid']][$fieldname] = $attach[$fieldname]; } } } return $attachments; }