本文整理匯總了PHP中vB_Api::InstanceInternal方法的典型用法代碼示例。如果您正苦於以下問題:PHP vB_Api::InstanceInternal方法的具體用法?PHP vB_Api::InstanceInternal怎麽用?PHP vB_Api::InstanceInternal使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類vB_Api
的用法示例。
在下文中一共展示了vB_Api::InstanceInternal方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: addAttachment
/**
* Adds one or more attachments
*
* @param int
* @param mixed array of attachment info
*
* @return int an attachid
*
**/
public function addAttachment($nodeid, $data)
{
/* data must include a filedataid, and possibly
any combination of visible,counter,posthash,filename,caption, reportthreadid, settings
*/
if (empty($nodeid) or empty($data['filedataid'])) {
throw new Exception('incorrect_attach_data');
}
//we need the current node data.
$node = $this->getNode($nodeid);
if (empty($node)) {
throw new Exception('incorrect_attach_data');
}
$maxattachments = vB::getUserContext()->getChannelLimitPermission('forumpermissions', 'maxattachments', $nodeid);
//check the permission.
$canAdd = false;
if ($node['userid'] == vB::getCurrentSession()->get('userid') and vB::getUserContext()->getChannelPermission('forumpermissions', 'canpostattachment', $nodeid)) {
$canAdd = true;
}
if (!$canAdd and vB::getUserContext()->getChannelPermission('moderatorpermissions', 'canmoderateattachments', $nodeid)) {
$canAdd = true;
}
if (!$canAdd) {
throw new Exception('no_permission');
}
if (isset($node['attachments']) and $maxattachments > 0 and count($node['attachments']) >= $maxattachments) {
throw new Exception('max_attachments_reached');
}
$attachApi = vB_Api::InstanceInternal('content_attach');
$data['parentid'] = $nodeid;
$attachid = $attachApi->add($data);
//updating the refcount in filedata happens in attach library's add() now.
return is_array($attachid) ? $attachid[0] : $attachid;
}