DataObjects/Core_person_signup.php
[Pman.Core] / DataObjects / Group_rights.php
index e049fdc..b3877d3 100755 (executable)
@@ -34,28 +34,30 @@ class Pman_Core_DataObjects_Group_rights extends DB_DataObject
     
     var $fullRights = "ADESPIM";
     
-    function listPermsFromGroupIds($grps, $isAdmin=false) {
+    
+    function groupsWithRights($rightname, $right)
+    {
+        $t = clone($this);
+        $t->rightname = $rightname;
+        $t->whereAdd("accessmask like '{$this->escape($right)}'");
+        $t->selectAdd();
+        $t->selectAdd('distinct(group_id) as group_id');
+        return $t->fetchAll('group_id');
+         
+    }
+    
+    
+    function listPermsFromGroupIds($grps, $isAdmin=false, $isOwner = false) {
         
         $t = clone($this);
         $t->whereAdd('group_id IN ('. implode(',', $grps).')');
         $t->autoJoin();
         $t->find();
         
-        $only_public = -1;
-        $ret = array();
+         $ret = array();
         while($t->fetch()) {
             
-            switch($only_public) {
-                case -1:
-                    $only_public  = $t->group_id_type == 2 ? 1 : 0;
-                    break;
-                case 1:
-                    $only_public  = $t->group_id_type == 2 ? $only_public : 0;
-                    break;
-                case 0:
-                    break;
-                    
-            }
+           
             
             
             if (isset($ret[$t->rightname])) {
@@ -67,13 +69,13 @@ class Pman_Core_DataObjects_Group_rights extends DB_DataObject
         // blank out rights that are disabled by the system..
         $defs = $this->defaultPermData();
         
+        
+        
         //echo "<PRE>";print_r($defs);
         $r = array();
         foreach($defs as $k=>$v) {
             
-            if ($only_public) {
-                $v = '';
-            }
+            
             
             if (empty($v[0])) { // delete right if not there..
                 $r[$k] = '';
@@ -83,14 +85,18 @@ class Pman_Core_DataObjects_Group_rights extends DB_DataObject
             
             if (isset($ret[$k])) {
                 if (empty($ret[$k]) && $isAdmin) {
-                    $r[$k] = $only_public ? '' :  $v[0]; // if it's public, the get no default rights
+                    $r[$k] = $v[0] ; // -- it's admin they get rights... can not be disabled..
                     continue;
                 }
-                
+                // in theory non-owners could sneak in rights here..??
                 $r[$k] = $ret[$k];
                 continue;
             }
             // not set contition...
+            if (!$isOwner) {
+                $r[$k] = '';
+                continue;
+            }
             
             $r[$k] = $isAdmin ? $v[0] : $v[1];