------------------------------------------------------------
revno: 889
committer: Roger Martin <[email protected]>
branch nick: aikiframework
timestamp: Tue 2011-07-19 23:03:09 +0200
message:
  added membership->have_permission and is_systemgod
modified:
  src/libs/membership.php
  src/libs/widgets.php


--
lp:aikiframework
https://code.launchpad.net/~aikiframework-devel/aikiframework/trunk

Your team Aiki Framework Developers is subscribed to branch lp:aikiframework.
To unsubscribe from this branch go to 
https://code.launchpad.net/~aikiframework-devel/aikiframework/trunk/+edit-subscription
=== modified file 'src/libs/membership.php'
--- src/libs/membership.php	2011-07-19 20:24:25 +0000
+++ src/libs/membership.php	2011-07-19 21:03:09 +0000
@@ -267,6 +267,37 @@
 
 
     /**
+     * check is user is systemgod
+     *  
+     * @return boolean 
+     */
+    
+    public function is_systemgod(){
+        return $this->permissions=="SystemGod";
+    }
+
+    /**
+     * check permissions (permission or group_level)
+	 * 
+     * @return boolean 
+     */
+        
+    public function have_permission( $permission="SystemGOD"){
+        global $db;
+        if ( $permission=="SystemGOD" ){
+            return $this->permissions== "SystemGOD";
+        } elseif ( $permission== $this->permissions ){
+            return true;
+        }
+        
+        // permissions don't match. Try group level.
+        $get_group_level = 	$db->get_var(
+			"SELECT group_level from aiki_users_groups where group_permissions='$permission'");
+        
+        return ( !is_null($get_group_level) && $this->group_level < $get_group_level);
+    }
+
+    /**
      * Attempt to get a user's ip address.
 	 *
      * @return string

=== modified file 'src/libs/widgets.php'
--- src/libs/widgets.php	2011-07-14 19:40:12 +0000
+++ src/libs/widgets.php	2011-07-19 21:03:09 +0000
@@ -336,17 +336,13 @@
 		}
 
 		// Security check to determine which widget content to display.		
-		if ($widget->is_admin) {
-			if ($membership->permissions and $widget->if_authorized) {
-				$get_group_level = 	$db->get_var(
-					"SELECT group_level from aiki_users_groups where group_permissions='$widget->permissions'");
-				if ($widget->permissions == $membership->permissions or 
-					$membership->group_level < $get_group_level) {
-					$widget->widget = $widget->if_authorized;
-					$widget->normal_select = $widget->authorized_select;
-					$stopcaching = true;
-				}
-			}
+		if ($widget->is_admin 
+			&& $membership->permissions 
+            && $widget->if_authorized 
+            && $membership->have_permission($widget->permissions) ) {
+                $widget->widget = $widget->if_authorized;
+				$widget->normal_select = $widget->authorized_select;
+				$stopcaching = true;			
 		}
 
 		if ( !$stopcaching and 

_______________________________________________
Mailing list: https://launchpad.net/~aikiframework-devel
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~aikiframework-devel
More help   : https://help.launchpad.net/ListHelp

Reply via email to