]> git.mxchange.org Git - friendica.git/blobdiff - src/Model/PermissionSet.php
Shorten "Configuration" to "Config" again, since the Wrapper is gone
[friendica.git] / src / Model / PermissionSet.php
index c9b2b17b67223b0608d0a3fe8eb89b430d5111c3..d0e256d15363c9b71cd218e43afec21b8f658903 100644 (file)
@@ -4,13 +4,12 @@
  */
 namespace Friendica\Model;
 
-use Friendica\BaseObject;
 use Friendica\Database\DBA;
 
 /**
- * @brief functions for interacting with the permission set of an object (item, photo, event, ...)
+ * functions for interacting with the permission set of an object (item, photo, event, ...)
  */
-class PermissionSet extends BaseObject
+class PermissionSet
 {
        /**
         * Fetch the id of a given permission set. Generate a new one when needed
@@ -22,10 +21,10 @@ class PermissionSet extends BaseObject
        public static function fetchIDForPost(&$postarray)
        {
                $condition = ['uid' => $postarray['uid'],
-                       'allow_cid' => self::sortPermissions(defaults($postarray, 'allow_cid', '')),
-                       'allow_gid' => self::sortPermissions(defaults($postarray, 'allow_gid', '')),
-                       'deny_cid' => self::sortPermissions(defaults($postarray, 'deny_cid', '')),
-                       'deny_gid' => self::sortPermissions(defaults($postarray, 'deny_gid', ''))];
+                       'allow_cid' => self::sortPermissions($postarray['allow_cid'] ?? ''),
+                       'allow_gid' => self::sortPermissions($postarray['allow_gid'] ?? ''),
+                       'deny_cid'  => self::sortPermissions($postarray['deny_cid']  ?? ''),
+                       'deny_gid'  => self::sortPermissions($postarray['deny_gid']  ?? '')];
 
                $set = DBA::selectFirst('permissionset', ['id'], $condition);
 
@@ -63,7 +62,7 @@ class PermissionSet extends BaseObject
        }
 
        /**
-        * @brief Returns a permission set for a given contact
+        * Returns a permission set for a given contact
         *
         * @param integer $uid        User id whom the items belong
         * @param integer $contact_id Contact id of the visitor
@@ -89,11 +88,9 @@ class PermissionSet extends BaseObject
 
                $contact_str = '<' . $contact_id . '>';
 
-               $condition = ["`uid` = ? AND (`allow_cid` = '' OR`allow_cid` REGEXP ?)
-                       AND (`deny_cid` = '' OR NOT `deny_cid` REGEXP ?)
-                       AND (`allow_gid` = '' OR `allow_gid` REGEXP ?)
-                       AND (`deny_gid` = '' OR NOT `deny_gid` REGEXP ?)",
-                       $uid, $contact_str, $contact_str, $group_str, $group_str];
+               $condition = ["`uid` = ? AND (NOT (`deny_cid` REGEXP ? OR deny_gid REGEXP ?)
+                       AND (allow_cid REGEXP ? OR allow_gid REGEXP ? OR (allow_cid = '' AND allow_gid = '')))",
+                       $uid, $contact_str, $group_str, $contact_str, $group_str];
 
                $ret = DBA::select('permissionset', ['id'], $condition);
                $set = [];