Пример #1
0
 /** 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;
 }