/** Check for attachment limits/permissions for a given extension. * Note: This is only constrained to the attachmenttype and attachmentpermission tables. The create permissions * for all attachments are handled in the channels. * TODO: Make this part of the channel permissions * * @param string the extension to check for * @param int node id. in case of groupInTopic * * @return mixed false if the extension is not allowed or the user doesn't have permission to use it. Otherwise an array of limits. */ public function getAttachmentPermissions($extension, $nodeid = false) { $usergroups = $this->usergroups; $returnValue = false; if ($nodeid !== false and !empty($this->groupInTopic)) { //groupintopic is set at the channel level. So let's get this node's channel. $gitNodeid = $this->getChannelIdOfNode($nodeid); //see if we have at the node level if (array_key_exists($gitNodeid, $this->groupInTopic)) { foreach ($this->groupInTopic[$gitNodeid] as $usergroupid) { if (!in_array($usergroupid, $usergroups)) { $usergroups[] = $usergroupid; } } } } foreach ($usergroups as $usergroupid) { $permission = $this->permissionContext->getAttachmentPermissions($usergroupid, $extension); if ($returnValue === false) { $returnValue = $permission; } else { if ($permission === false) { // Don't need to do anything here... } else { // Get the max values for all the fields. 0 = no limit. foreach (array_keys($permission) as $dimension) { if ($returnValue[$dimension] == 0 or $permission[$dimension] == 0) { $returnValue[$dimension] = 0; } else { $returnValue[$dimension] = max($returnValue[$dimension], $permission[$dimension]); } } } } } return $returnValue; }
/** * This implements vB_PermissionContext::getAdminUser(). * return int User id from a user that can administer the admincp */ public function fetchAdminUser() { return vB_PermissionContext::getAdminUser(); }
/** * Checks usergroupid and membergroupids to see if the user has super moderator privileges * * @param integer Usergroupid * @param string Membergroupids (comma separated) * * @return boolean Returns true if user has super moderator privileges */ function is_supermod($usergroupid, $membergroupids) { $datastore = vB::getDatastore(); if (!empty($membergroupids)) { $membergroupids = explode(',', $membergroupids); } $bf_ugp_adminpermissions = $datastore->get_value('bf_ugp_adminpermissions'); $permissionContext = new vB_PermissionContext($datastore, $usergroupid, $membergroupids); $admin_permissions = $permissionContext->getPermission('adminpermissions'); return $admin_permissions & $bf_ugp_adminpermissions['ismoderator']; }