本文整理汇总了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;
}