]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - classes/Profile.php
Merge branch 'admin-sections/4' into 0.9.x
[quix0rs-gnu-social.git] / classes / Profile.php
index e3b35533ad5224fb6f0d6d80fc126bde9a47aa26..4b2e0900647b29a20204ed63345a6665e2df69c5 100644 (file)
@@ -310,10 +310,12 @@ class Profile extends Memcached_DataObject
           'AND subscription.subscribed != subscription.subscriber ' .
           'ORDER BY subscription.created DESC ';
 
-        if (common_config('db','type') == 'pgsql') {
-            $qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset;
-        } else {
-            $qry .= ' LIMIT ' . $offset . ', ' . $limit;
+        if ($offset>0 && !is_null($limit)){
+            if (common_config('db','type') == 'pgsql') {
+                $qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset;
+            } else {
+                $qry .= ' LIMIT ' . $offset . ', ' . $limit;
+            }
         }
 
         $profile = new Profile();
@@ -333,11 +335,13 @@ class Profile extends Memcached_DataObject
           'AND subscription.subscribed != subscription.subscriber ' .
           'ORDER BY subscription.created DESC ';
 
-        if ($offset) {
-            if (common_config('db','type') == 'pgsql') {
-                $qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset;
-            } else {
-                $qry .= ' LIMIT ' . $offset . ', ' . $limit;
+        if ($offset>0 && !is_null($limit)){
+            if ($offset) {
+                if (common_config('db','type') == 'pgsql') {
+                    $qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset;
+                } else {
+                    $qry .= ' LIMIT ' . $offset . ', ' . $limit;
+                }
             }
         }
 
@@ -590,9 +594,14 @@ class Profile extends Memcached_DataObject
 
     function hasRole($name)
     {
-        $role = Profile_role::pkeyGet(array('profile_id' => $this->id,
-                                            'role' => $name));
-        return (!empty($role));
+        $has_role = false;
+        if (Event::handle('StartHasRole', array($this, $name, &$has_role))) {
+            $role = Profile_role::pkeyGet(array('profile_id' => $this->id,
+                                                'role' => $name));
+            $has_role = !empty($role);
+            Event::handle('EndHasRole', array($this, $name, $has_role));
+        }
+        return $has_role;
     }
 
     function grantRole($name)
@@ -690,8 +699,16 @@ class Profile extends Memcached_DataObject
                 $result = $this->hasRole(Profile_role::ADMINISTRATOR);
                 break;
             case Right::NEWNOTICE:
+            case Right::NEWMESSAGE:
+            case Right::SUBSCRIBE:
                 $result = !$this->isSilenced();
                 break;
+            case Right::PUBLICNOTICE:
+            case Right::EMAILONREPLY:
+            case Right::EMAILONSUBSCRIBE:
+            case Right::EMAILONFAVE:
+                $result = !$this->isSandboxed();
+                break;
             default:
                 $result = false;
                 break;