[Vtigercrm-commits] [vtiger-commits] r4845 - in /vtigercrm/trunk/modules/Users: CreateUserPrivilegeFile.php User.php

vtigercrm-commits at vtiger.fosslabs.com vtigercrm-commits at vtiger.fosslabs.com
Mon Apr 3 14:31:12 EDT 2006


Author: don
Date: Mon Apr  3 12:31:07 2006
New Revision: 4845

Log:
Now in index.php querying user table every time is avoided

Modified:
    vtigercrm/trunk/modules/Users/CreateUserPrivilegeFile.php
    vtigercrm/trunk/modules/Users/User.php

Modified: vtigercrm/trunk/modules/Users/CreateUserPrivilegeFile.php
==============================================================================
--- vtigercrm/trunk/modules/Users/CreateUserPrivilegeFile.php (original)
+++ vtigercrm/trunk/modules/Users/CreateUserPrivilegeFile.php Mon Apr  3 12:31:07 2006
@@ -21,9 +21,17 @@
 		$newbuf .= "//This is the access privilege file\n";
 		$user_focus= new User();
 		$user_focus->retrieve($userid);
+		$userInfo=Array();
+		foreach($user_focus->column_fields as $field)
+        	{
+               		$userInfo[$field]= $user_focus->$field;
+        	}
+
 		if($user_focus->is_admin == 'on')
 		{
 			$newbuf .= "\$is_admin=true;\n";
+			$newbuf .="\n";		
+			$newbuf .= "\$user_info=".constructSingleStringKeyValueArray($userInfo).";\n";
 			$newbuf .= "\n";
 			$newbuf .= "?>";
 			fputs($handle, $newbuf);
@@ -48,6 +56,8 @@
 			$subRoleAndUsers=getSubordinateRoleAndUsers($user_role);
 			$def_org_share=getDefaultSharingAction();
 			$parentRoles=getParentRole($user_role);
+
+			
 
 			
 			$newbuf .= "\$current_user_roles='".$user_role."';\n";
@@ -69,6 +79,8 @@
 			$newbuf .= "\$parent_roles=".constructSingleCharArray($parentRoles).";\n";
 			$newbuf .="\n";		
 			$newbuf .= "\$subordinate_roles_users=".constructTwoDimensionalCharIntSingleArray($subRoleAndUsers).";\n";
+			$newbuf .="\n";		
+			$newbuf .= "\$user_info=".constructSingleStringKeyValueArray($userInfo).";\n";
 
 			$newbuf .= "?>";
 			fputs($handle, $newbuf);
@@ -1106,6 +1118,32 @@
         }
 }
 
+function constructSingleStringKeyValueArray($var)
+{
+
+        $size = sizeof($var);
+        $i=1;
+        if (is_array($var))
+        {
+                $code = 'array(';
+                foreach ($var as $key => $value)
+                {
+                        if($i<$size)
+                        {
+                                $code .= "'".$key."'=>'".$value."',";
+                        }
+                        else
+                        {
+                                $code .= "'".$key."'=>'".$value."'";
+                        }
+                        $i++;
+                }
+                $code .= ')';
+                return $code;
+        }
+}
+
+
 
 function constructSingleArray($var)
 {

Modified: vtigercrm/trunk/modules/Users/User.php
==============================================================================
--- vtigercrm/trunk/modules/Users/User.php (original)
+++ vtigercrm/trunk/modules/Users/User.php Mon Apr  3 12:31:07 2006
@@ -552,6 +552,25 @@
 			$this->reports_to_name = '';
 		}		
 	}
+
+	function retrieveCurrentUserInfoFromFile($userid)
+	{
+		require('user_privileges/user_privileges_'.$userid.'.php');
+		foreach($this->column_fields as $field)
+                {
+                        if(isset($user_info[$field]))
+                        {
+                                $this->$field = $user_info[$field];
+                        }
+                }
+		return $this;
+		
+	}
+
+	
 }
 
+	
+
+
 ?>





More information about the vtigercrm-commits mailing list