[Vtigercrm-commits] [vtiger-commits] r7018 - in /vtigercrm/trunk/modules/Users: Authenticate.php CreateUserPrivilegeFile.php DetailView.php EditView.php Forms.php Save.php User.php

vtigercrm-commits at vtiger.fosslabs.com vtigercrm-commits at vtiger.fosslabs.com
Tue Jun 13 06:04:44 EDT 2006


Author: richie
Date: Tue Jun 13 04:04:34 2006
New Revision: 7018

Log:
users module added in CRMEntity

Modified:
    vtigercrm/trunk/modules/Users/Authenticate.php
    vtigercrm/trunk/modules/Users/CreateUserPrivilegeFile.php
    vtigercrm/trunk/modules/Users/DetailView.php
    vtigercrm/trunk/modules/Users/EditView.php
    vtigercrm/trunk/modules/Users/Forms.php
    vtigercrm/trunk/modules/Users/Save.php
    vtigercrm/trunk/modules/Users/User.php

Modified: vtigercrm/trunk/modules/Users/Authenticate.php
==============================================================================
--- vtigercrm/trunk/modules/Users/Authenticate.php (original)
+++ vtigercrm/trunk/modules/Users/Authenticate.php Tue Jun 13 04:04:34 2006
@@ -31,7 +31,7 @@
 $focus = new User();
 
 // Add in defensive code here.
-$focus->user_name = to_html($_REQUEST['user_name']);
+$focus->column_fields["user_name"] = to_html($_REQUEST['user_name']);
 $user_password = $_REQUEST['user_password'];
 
 $focus->load_user($user_password);
@@ -43,33 +43,16 @@
         $intime=date("Y/m/d H:i:s");
         require_once('modules/Users/LoginHistory.php');
         $loghistory=new LoginHistory();
-        $Signin = $loghistory->user_login($focus->user_name,$usip,$intime);
-
-	//Authentication for tutos
-        //include('modules/Calendar/Authenticate.php');
+        $Signin = $loghistory->user_login($focus->column_fields["user_name"],$usip,$intime);
 
 	// save the user information into the session
 	// go to the home screen
 	//Security related entries start
 	require_once('include/utils/UserInfoUtil.php');
-	//$rolename = fetchUserRole($focus->id);
-	//$profilename = fetchUserProfile($focus->id);
 	$profileid = fetchUserProfileId($focus->id);	
-	//setting the vtiger_role into the session
-	//$_SESSION['authenticated_user_roleid'] = $profilename;
-
-	//Setting the Object in Session
-	/*
-	$accessObj = new AccessControl();
-	$accessObj->authenticated_user_profileid = $profileid;
-	$accessObj->tab_permission_set = setPermittedTabs2Session($profileid);
-	
-	$accessObj->action_permission_set = setPermittedActions2Session($profileid);
-	$_SESSION['access_privileges'] = $accessObj; 
-	*/
+	//setting the role into the session
 
 	createUserPrivilegesfile($focus->id);
-        //createUserSharingPrivilegesfile($focus->id);	
 		
 	$_SESSION['authenticated_user_profileid'] = $profileid;
 	setGlobalProfilePermission2Session($profileid);
@@ -128,7 +111,7 @@
         $log->debug("app_unique_key is $application_unique_key");
 
 	
-// Clear all uploaded import vtiger_files for this user if it exists
+// Clear all uploaded import files for this user if it exists
 
 	global $import_dir;
 
@@ -141,7 +124,7 @@
 }
 else
 {
-	$_SESSION['login_user_name'] = $focus->user_name;
+	$_SESSION['login_user_name'] = $focus->column_fields["user_name"];
 	$_SESSION['login_password'] = $user_password;
 	$_SESSION['login_error'] = $mod_strings['ERR_INVALID_PASSWORD'];
 	

Modified: vtigercrm/trunk/modules/Users/CreateUserPrivilegeFile.php
==============================================================================
--- vtigercrm/trunk/modules/Users/CreateUserPrivilegeFile.php (original)
+++ vtigercrm/trunk/modules/Users/CreateUserPrivilegeFile.php Tue Jun 13 04:04:34 2006
@@ -30,9 +30,12 @@
 		$newbuf .="\n";		
 		$newbuf .= "//This is the access privilege file\n";
 		$user_focus= new User();
-		$user_focus->retrieve($userid);
+		$user_focus->retrieve_entity_info($userid,'Users');
+		
 		$userInfo=Array();
-		foreach($user_focus->column_fields as $field)
+		$user_focus->column_fields["id"] = '';
+		$user_focus->id = $userid; 
+		foreach($user_focus->column_fields as $field=>$value_iter)
         	{
                		$userInfo[$field]= $user_focus->$field;
         	}
@@ -113,7 +116,7 @@
 		$newbuf .="\n";		
 		$newbuf .= "//This is the sharing access privilege file\n";
 		$user_focus= new User();
-		$user_focus->retrieve($userid);
+		$user_focus->retrieve_entity_info($userid,'Users');
 		if($user_focus->is_admin == 'on')
 		{
 			$newbuf .= "\n";
@@ -439,7 +442,7 @@
 
 
 
-		//Retreiving from vtiger_role to rs
+		//Retreiving from role to rs
 		$parRoleList = "(";
 		foreach($parent_roles as $par_role_id)
 		{

Modified: vtigercrm/trunk/modules/Users/DetailView.php
==============================================================================
--- vtigercrm/trunk/modules/Users/DetailView.php (original)
+++ vtigercrm/trunk/modules/Users/DetailView.php Tue Jun 13 04:04:34 2006
@@ -32,18 +32,18 @@
 global $theme;
 global $default_language;
 global $adb;
-
+global $currentModule;
 global $app_strings;
 global $mod_strings;
 
 $focus = new User();
 
 if(!empty($_REQUEST['record'])) {
-        $focus->retrieve($_REQUEST['record']);
+	$focus->retrieve_entity_info($_REQUEST['record'],'Users');
+	$focus->id = $_REQUEST['record'];	
 }
 else
 {
- //       header("Location: index.php?module=Users&action=ListView");
 
     echo "
         <script type='text/javascript'>
@@ -82,11 +82,7 @@
 $image_path=$theme_path."images/";
 require_once($theme_path.'layout_utils.php');
 
-$role = fetchUserRole($focus->id);
-$rolename =  getRoleName($role);
-$currencyid=fetchCurrency($focus->id);
-$currency=getCurrencyName($currencyid);
-//the user might belong to multiple vtiger_groups
+//the user might belong to multiple groups
 if($focus->id != 1)
 {
  $groupids = fetchUserGroupids($focus->id);
@@ -107,13 +103,7 @@
 $smarty->assign("THEME", $theme);
 $smarty->assign("IMAGE_PATH", $image_path);$smarty->assign("PRINT_URL", "phprint.php?jt=".session_id().$GLOBALS['request_string']);
 $smarty->assign("ID", $focus->id);
-$smarty->assign("USER_NAME", $focus->user_name);
-$smarty->assign("FIRST_NAME", $focus->first_name);
-$smarty->assign("LAST_NAME", $focus->last_name);
 $smarty->assign("CATEGORY", $category);
-$smarty->assign("STATUS", $focus->status);
-$smarty->assign("YAHOO_ID", $focus->yahoo_id);
-$smarty->assign("DATE_FORMAT", $focus->date_format);
 if(isset($focus->imagename) && $focus->imagename!='')
 {
 	$imagestring="<div id='track1' style='margin: 4px 0pt 0pt 10px; width: 200px; background-image: url(themes/images/scaler_slider_track.gif); background-repeat: repeat-x; background-position: left center; height: 18px;'>
@@ -123,11 +113,9 @@
 
 	<div class='scale-image' style='padding: 10px; float: left; width: 83.415px;'><img src='test/user/".$focus->imagename."' width='100%'</div>
 	<p><script type='text/javascript' src='include/js/scale_demo.js'></script></p>";
-	$smarty->assign("USER_IMAGE",$imagestring);
+	//$smarty->assign("USER_IMAGE",$imagestring);
 }
 				
-if (isset($focus->yahoo_id) && $focus->yahoo_id !== "") $smarty->assign("YAHOO_MESSENGER", "<a href='http://edit.yahoo.com/config/send_webmesg?.target=".$focus->yahoo_id."'><img border=0 src='http://opi.yahoo.com/online?u=".$focus->yahoo_id."'&m=g&t=2'></a>");
-
 if(isset($_REQUEST['modechk']) && $_REQUEST['modechk'] != '' )
 {
 	$modepref = $_REQUEST['modechk'];
@@ -151,11 +139,8 @@
 	$buttons = "<input title='".$app_strings['LBL_EDIT_BUTTON_TITLE']."' accessKey='".$app_strings['LBL_EDIT_BUTTON_KEY']."' class='classBtn' onclick=\"this.form.return_module.value='Users'; this.form.return_action.value='DetailView'; this.form.return_id.value='$focus->id'; this.form.action.value='EditView'; this.form.parenttab.value='$parenttab'\" type='submit' name='Edit' value='  ".$app_strings['LBL_EDIT_BUTTON_LABEL']."  '>";
 	$smarty->assign('EDIT_BUTTON',$buttons);
 	
- //global $AUTHCFG;
- 	//if (strtoupper($AUTHCFG['authType']) == 'SQL') {
 		$buttons = "<input title='".$mod_strings['LBL_CHANGE_PASSWORD_BUTTON_TITLE']."' accessKey='".$mod_strings['LBL_CHANGE_PASSWORD_BUTTON_KEY']."' class='classBtn' LANGUAGE=javascript onclick='return window.open(\"index.php?module=Users&action=ChangePassword&form=DetailView\",\"test\",\"width=320,height=165,resizable=no,scrollbars=0, toolbar=no, titlebar=no, left=100, top=126, screenX=100, screenY=126\");' type='button' name='password' value='".$mod_strings['LBL_CHANGE_PASSWORD_BUTTON_LABEL']."'>";
 		$smarty->assign('CHANGE_PW_BUTTON',$buttons);
-	//}
 	
 	$buttons = "<input title='".$mod_strings['LBL_LOGIN_HISTORY_BUTTON_TITLE']."' accessKey='".$mod_strings['LBL_LOGIN_HISTORY_BUTTON_KEY']."' class='classBtn' onclick=\"this.form.return_module.value='Users'; this.form.return_action.value='ShowHistory'; this.form.return_id.value='$focus->id'; this.form.action.value='ShowHistory'\" type='submit' name='LoginHistory' value=' ".$mod_strings['LBL_LOGIN_HISTORY_BUTTON_LABEL']." '>";	
 	$smarty->assign('LOGIN_HISTORY_BUTTON',$buttons);
@@ -166,33 +151,18 @@
 
 	
 }
-/* Forum Display/Hide Button
-if($_REQUEST['forumDisplay'] == "true" || $displayForums == "true"){
-	$buttons .= "<input title='".$app_strings['LBL_FORUM_HIDE_BUTTON_TITLE']."' accessKey='".$app_strings['LBL_FORUM_HIDE_BUTTON_KEY']."' class='button' onclick=\"this.form.module.value='Users'; this.form.forumDisplay.value='false'; this.form.action.value='DetailView'\" type='submit' name='Display' value=' ".$app_strings['LBL_FORUM_HIDE_BUTTON_LABEL']." '></td>\n";
-}
-else
-{
-	$buttons .= "<input title='".$app_strings['LBL_FORUM_SHOW_BUTTON_TITLE']."' accessKey='".$app_strings['LBL_FORUM_SHOW_BUTTON_KEY']."' class='button' onclick=\"this.form.module.value='Users'; this.form.forumDisplay.value='true'; this.form.action.value='DetailView'\" type='submit' name='Display' value=' ".$app_strings['LBL_FORUM_SHOW_BUTTON_LABEL']." '></td>\n";
-}
-*/
 if (is_admin($current_user)) 
 {
 	$buttons = "<input title='".$app_strings['LBL_DUPLICATE_BUTTON_TITLE']."' accessKey='".$app_strings['LBL_DUPLICATE_BUTTON_KEY']."' class='classBtn' onclick=\"this.form.return_module.value='Users'; this.form.return_action.value='DetailView'; this.form.isDuplicate.value=true; this.form.return_id.value='".$_REQUEST['record']."';this.form.action.value='EditView'\" type='submit' name='Duplicate' value=' ".$app_strings['LBL_DUPLICATE_BUTTON_LABEL']."'   >";
 	$smarty->assign('DUPLICATE_BUTTON',$buttons);
 	
-	//done so that only the admin user can see the customize vtiger_tab button
-	if($_REQUEST['record'] == $current_user->id)
-	{
-		$buttons = "<input title='".$app_strings['LBL_TABCUSTOMISE_BUTTON_TITLE']."' accessKey='".$app_strings['LBL_TABCUSTOMISE_BUTTON_KEY']."' class='classBtn' onclick=\"this.form.return_module.value='Users'; this.form.return_action.value='TabCustomise'; this.form.action.value='TabCustomise'\" type='submit' name='Customise' value=' ".$app_strings['LBL_TABCUSTOMISE_BUTTON_LABEL']." '>";
-		$smarty->assign('TABCUSTOMIZE_BUTTON',$buttons);
-	}
+	//done so that only the admin user can see the customize tab button
 	if($_REQUEST['record'] != $current_user->id)
 	{
 		$buttons = "<input title='".$app_strings['LBL_DELETE_BUTTON_TITLE']."' accessKey='".$app_strings['LBL_DELETE_BUTTON_KEY']."' class='classBtn' onclick=\"deleteUser('$focus->id')\" type='button' name='Delete' value='  ".$app_strings['LBL_DELETE_BUTTON_LABEL']."  '>";
 		$smarty->assign('DELETE_BUTTON',$buttons);
 	}
 
-        //$buttons .= "<input title='".$app_strings['LBL_ROLES_BUTTON_TITLE']."' accessKey='".$app_strings['LBL_ROLES_BUTTON_KEY']."' class='button' onclick=\"this.form.return_module.value='Users'; this.form.return_action.value='TabCustomise'; this.form.action.value='ListPermissions'\" type='submit' name='ListPermissions' value=' ".$app_strings['LBL_ROLES_BUTTON_LABEL']." '></td>\n";
 	if($_SESSION['authenticated_user_roleid'] == 'administrator')
 	{
 		$buttons = "<input title='".$app_strings['LBL_LISTROLES_BUTTON_TITLE']."' accessKey='".$app_strings['LBL_LISTROLES_BUTTON_KEY']."' class='classBtn' onclick=\"this.form.return_module.value='Users'; this.form.return_action.value='TabCustomise'; this.form.action.value='listroles'; this.form.record.value= '". $current_user->id ."'\" type='submit' name='ListRoles' value=' ".$app_strings['LBL_LISTROLES_BUTTON_LABEL']." '>";
@@ -202,99 +172,12 @@
 }
 
 
-if ((is_admin($current_user) || $_REQUEST['record'] == $current_user->id) && $focus->is_admin == 'on') {
-	$smarty->assign("IS_ADMIN", "checked");
-}
 
-$smarty->assign("DESCRIPTION", nl2br($focus->description));
-if(is_admin($current_user))
-{
-	$smarty->assign("ROLEASSIGNED","<a href=index.php?module=Users&action=RoleDetailView&roleid=".$role .">" .$rolename ."</a>");
-}
-else
-{
-	$smarty->assign("ROLEASSIGNED",$rolename);
-}
+$smarty->assign("MODULE", 'Settings');
+$smarty->assign("BLOCKS", getBlocks($currentModule,"detail_view",'',$focus->column_fields));
 
-	$smarty->assign("CURRENCY_NAME",$currency);
-
-//Getting the Group Lists
-$groupids = fetchUserGroupids($focus->id);
-if($groupids) {
-	$query ="select groupid,groupname from vtiger_groups where groupid in (".$groupids.")";
-	$result = $adb->query($query);
-	$num_rows = $adb->num_rows($result);
-} else {
-	$num_rows = 0;
-}
-
-
-
-//Assigning the group lists
-if(is_admin($current_user))
-{
-	for($i=0;$i < $num_rows;$i++)
-	{
-		$groupid = $adb->query_result($result,$i,'groupid');
-		$groupname = $adb->query_result($result,$i,'groupname');
-		$grouplists[$i] ="<a href='index.php?module=Users&action=GroupDetailView&groupId=".$groupid."'>".$groupname."</a>";
-	}
-	if($grouplists != '')
-	{	
-		$group_lists = implode(",",$grouplists);
-	}	
-	$smarty->assign("GROUPASSIGNED",$group_lists);
-}
-else
-{
-	for($i=0;$i < $num_rows;$i++)
-	{
-		$groupname = $adb->query_result($result,$i,'groupname');
-		$grouplists[$i] =$groupname;
-	}
-	if($grouplists != '')
-	{	
-		$group_lists = implode(",",$grouplists);
-	}
-	$smarty->assign("GROUPASSIGNED",$group_lists);
-}
-$smarty->assign("COLORASSIGNED", "<div style='background-color:".$focus->cal_color.";'>".$focus->cal_color."</div>");
-if($focus->hour_format == 'am/pm')
-{
-	$smarty->assign("CAL_HRFORMAT", "11:00pm");
-}
-else
-{
-	$smarty->assign("CAL_HRFORMAT", "23:00");
-}
-$smarty->assign("CAL_HRDURATION", $focus->start_hour."&nbsp;ends at&nbsp;".$focus->end_hour);
-$smarty->assign("ACTIVITY_VIEW", $focus->activity_view);
-$smarty->assign("LEAD_VIEW", $focus->lead_view);
-$smarty->assign("TITLE", $focus->title);
-$smarty->assign("DEPARTMENT", $focus->department);
-$smarty->assign("REPORTS_TO_ID", $focus->reports_to_id);
-$smarty->assign("REPORTS_TO_NAME", $focus->reports_to_name);
-$smarty->assign("PHONE_HOME", $focus->phone_home);
-$smarty->assign("PHONE_MOBILE", $focus->phone_mobile);
-$smarty->assign("PHONE_WORK", $focus->phone_work);
-$smarty->assign("PHONE_OTHER", $focus->phone_other);
-$smarty->assign("PHONE_FAX", $focus->phone_fax);
-$smarty->assign("EMAIL1", $focus->email1);
-$smarty->assign("EMAIL2", $focus->email2);
-$smarty->assign("ADDRESS_STREET", $focus->address_street);
-$smarty->assign("ADDRESS_CITY", $focus->address_city);
-$smarty->assign("ADDRESS_STATE", $focus->address_state);
-$smarty->assign("ADDRESS_POSTALCODE", $focus->address_postalcode);
-$smarty->assign("ADDRESS_COUNTRY", $focus->address_country);
-$smarty->assign("SIGNATURE", nl2br($focus->signature));
-$smarty->assign("MODULE", 'Settings');
-
-
-$mode1 = 'pref';
-$smarty->assign("MODE1", $mode1);
 
         $smarty->display("UserDetailView.tpl");
 
-echo "</td></tr>\n";
 
 ?>

Modified: vtigercrm/trunk/modules/Users/EditView.php
==============================================================================
--- vtigercrm/trunk/modules/Users/EditView.php (original)
+++ vtigercrm/trunk/modules/Users/EditView.php Tue Jun 13 04:04:34 2006
@@ -32,35 +32,26 @@
 global $app_strings;
 global $app_list_strings;
 global $mod_strings;
+global $currentModule;
 
 
+$smarty=new vtigerCRM_Smarty;
 $focus = new User();
 
 if(isset($_REQUEST['record']) && isset($_REQUEST['record'])) {
+	$smarty->assign("ID",$_REQUEST['record']);
 	$mode='edit';
 	if (!is_admin($current_user) && $_REQUEST['record'] != $current_user->id) die ("Unauthorized access to user administration.");
-    $focus->retrieve($_REQUEST['record']);
+    $focus->retrieve_entity_info($_REQUEST['record'],'Users');
 }else
 {
 	$mode='create';
-	$password='<tr>
-	   		   <td width="20%" class="dataLabel"><FONT class="required">*</FONT>Password</td>
-		       <td width="30%"><input name="new_password" type="password" vtiger_tabindex="1" size="25" maxlength="25"></td>
-			   <td width="20%" class="dataLabel"><FONT class="required">*</FONT>Confirm Password</td>
-			   <td width="30%"><input name="confirm_new_password" type="password" vtiger_tabindex="2" size="25" maxlength="75"></td>
-			  </tr>';
 }
 
 if(isset($_REQUEST['isDuplicate']) && $_REQUEST['isDuplicate'] == 'true') {
 	$focus->id = "";
 	$focus->user_name = "";
 	$mode='create';
-	$password='<tr>
-	   		   <td width="20%" class="dataLabel"><FONT class="required">*</FONT>Password</td>
-		       <td width="30%"><input name="new_password" type="password" vtiger_tabindex="1" size="25" maxlength="25"></td>
-			   <td width="20%" class="dataLabel"><FONT class="required">*</FONT>Confirm Password</td>
-			   <td width="30%"><input name="confirm_new_password" type="password" vtiger_tabindex="2" size="25" maxlength="75"></td>
-			  </tr>';
 }
 
 global $theme;
@@ -70,8 +61,8 @@
 
 $log->info("User edit view");
 
-$smarty=new vtigerCRM_Smarty;
 
+$smarty->assign("JAVASCRIPT", get_validate_record_js());
 $smarty->assign("UMOD", $mod_strings);
 global $current_language;
 $smod_strings = return_module_language($current_language,'Settings');
@@ -90,255 +81,18 @@
         $smarty->assign("RETURN_ACTION", $_REQUEST['return_action']);
         $RETURN_ACTION = $_REQUEST['return_action'];
 }
-if(isset($_REQUEST['activity_mode']))
-{
-	$smarty->assign("ACTIVITYMODE",$_REQUEST['activity_mode']);
-}
 if ($_REQUEST['isDuplicate'] != 'true' && isset($_REQUEST['return_id']))
 {
         $smarty->assign("RETURN_ID", $_REQUEST['return_id']);
         $RETURN_ID = $_REQUEST['return_id'];
 }
 
-$smarty->assign("JAVASCRIPT", get_validate_record_js());
-
 $smarty->assign("IMAGE_PATH", $image_path);$smarty->assign("PRINT_URL", "phprint.php?jt=".session_id().$GLOBALS['request_string']);
-$smarty->assign("ID", $focus->id);
-$smarty->assign("USER_NAME", $focus->user_name);
-$smarty->assign("FIRST_NAME", $focus->first_name);
-$smarty->assign("LAST_NAME", $focus->last_name);
-$smarty->assign("TITLE", $focus->title);
-$smarty->assign("DEPARTMENT", $focus->department);
-$smarty->assign("REPORTS_TO_ID", $focus->reports_to_id);
-$smarty->assign("REPORTS_TO_NAME", $focus->reports_to_name);
-$smarty->assign("PHONE_HOME", $focus->phone_home);
-$smarty->assign("PHONE_MOBILE", $focus->phone_mobile);
-$smarty->assign("PHONE_WORK", $focus->phone_work);
-$smarty->assign("PHONE_OTHER", $focus->phone_other);
-$smarty->assign("PHONE_FAX", $focus->phone_fax);
-$smarty->assign("EMAIL1", $focus->email1);
-$smarty->assign("EMAIL2", $focus->email2);
-$smarty->assign("YAHOO_ID", $focus->yahoo_id);
-if (isset($focus->yahoo_id) && $focus->yahoo_id !== "") $smarty->assign("YAHOO_MESSENGER", "<a href='http://edit.yahoo.com/config/send_webmesg?.target=".$focus->yahoo_id."'><img border=0 src='http://opi.yahoo.com/online?u=".$focus->yahoo_id."'&m=g&t=2'></a>");
-$smarty->assign("ADDRESS_STREET", $focus->address_street);
-$smarty->assign("ADDRESS_CITY", $focus->address_city);
-$smarty->assign("ADDRESS_STATE", $focus->address_state);
-$smarty->assign("ADDRESS_POSTALCODE", $focus->address_postalcode);
-$smarty->assign("ADDRESS_COUNTRY", $focus->address_country);
-$smarty->assign("SIGNATURE", $focus->signature);
-$smarty->assign("DESCRIPTION", $focus->description);
-$smarty->assign("USERIMAGE", $focus->imagename);
-$smarty->assign("MODE", $mode);
+$focus->mode = $mode;
+$disp_view = getView($focus->mode);
+$smarty->assign("BLOCKS",getBlocks($currentModule,$disp_view,$mode,$focus->column_fields));	
 $smarty->assign("MODULE", 'Settings');
-
-$DATE_FORMAT_SELECT_OPTION = '<select name="date_format">';
-		
-               
-if($focus->date_format == 'dd-mm-yyyy')
-{
-	$selected1 = 'selected';
-}
-elseif($focus->date_format == 'mm-dd-yyyy')
-{
-	$selected2 = 'selected';
-}
-elseif($focus->date_format == 'yyyy-mm-dd')
-{
-	$selected3 = 'selected';
-}
-$DATE_FORMAT_SELECT_OPTION .= '<option value="dd-mm-yyyy" '.$selected1.'>';
-$DATE_FORMAT_SELECT_OPTION .= 'dd-mm-yyyy';
-$DATE_FORMAT_SELECT_OPTION .= '</option>';
-$DATE_FORMAT_SELECT_OPTION .= '<option value="mm-dd-yyyy" '.$selected2.'>';
-$DATE_FORMAT_SELECT_OPTION .= 'mm-dd-yyyy';
-$DATE_FORMAT_SELECT_OPTION .= '</option>';
-$DATE_FORMAT_SELECT_OPTION .= '<option value="yyyy-mm-dd" '.$selected3.'>';
-$DATE_FORMAT_SELECT_OPTION .= 'yyyy-mm-dd';
-$DATE_FORMAT_SELECT_OPTION .= '</option>';	
-$DATE_FORMAT_SELECT_OPTION .= ' </select>';
-$smarty->assign("DATE_FORMAT", $DATE_FORMAT_SELECT_OPTION);
-
-if (is_admin($current_user)) {
-	$status = "<td width='30%'>&nbsp;&nbsp;<select name='status' vtiger_tabindex='1'";
-	if (isset($default_user_name)
-		&& $default_user_name != ""
-		&& $default_user_name == $focus->user_name
-		&& isset($lock_default_user_name)
-		&& $lock_default_user_name == true ) {
-		$status .= " disabled ";
-	}
-	$status .= ">";
-	$status .= get_select_options_with_id($app_list_strings['user_status_dom'], $focus->status);
-	$status .= "</select></td>\n";
-	$smarty->assign("USER_STATUS_OPTIONS", $status);
-
-}
-else
-{
-		$status = "<td width='30%'>&nbsp;&nbsp;<select name='status' vtiger_tabindex='1' disabled>";
-		$status .= get_select_options_with_id($app_list_strings['user_status_dom'], $focus->status);
-		$status .= "</select></td>\n";
-		$smarty->assign("USER_STATUS_OPTIONS", $status);
-
-}	
-
-if (is_admin($current_user)) {
-     
-               
-		 $opt =	'<a href="javascript:openPopup();"><img src="'.$image_path.'select.gif" border="0" align="absmiddle"></a>';
-                $smarty->assign("ROLEPOPUPBUTTON", $opt);
-	
-	}
-		
-        if($focus->id != '')
-        {
-
-		$roleselectedid=fetchUserRole($focus->id);
-		$roleselected=getRoleName($roleselectedid);
-                $smarty->assign("USERROLE", $roleselectedid);
-                $smarty->assign("ROLENAME", $roleselected);
-
-        }
-               
-		
-		 
-
-
-
-if (is_admin($current_user)) {                   
-        $GROUP_SELECT_OPTION = '<select name="group_name">';
-		$GROUP_SELECT_OPTION .= '<option value="">--None--</option>';
-		if($focus->id) {
-			$sql = "SELECT groupname
-				FROM vtiger_users2group
-				INNER JOIN vtiger_groups
-					ON vtiger_groups.groupid = vtiger_users2group.groupid
-				WHERE userid = '" .$focus->id ."'";
-			$result = $adb->query($sql);
-			$groupnameArray = $adb->fetch_array($result);
-		}
-		$groupselected = $groupnameArray["groupname"];
-		$sql2 = "SELECT groupname FROM vtiger_groups";
-                  $result_name = $adb->query($sql2);
-                  $temprow = $adb->fetch_array($result_name);
-                   do
-                   {
-          		  $selected = '';
-
-                    $groupname=$temprow["groupname"];
-		       if($groupselected != '' && $groupname == $groupselected)
-	        	{
-		                $selected = 'selected';
-        		}
-                    $GROUP_SELECT_OPTION .= '<option value="'.$groupname.'" '.$selected.'>';
-                    $GROUP_SELECT_OPTION .= $temprow["groupname"];
-                    $GROUP_SELECT_OPTION .= '</option>';
-                   }while($temprow = $adb->fetch_array($result_name));
-                                  
-                   $GROUP_SELECT_OPTION .= ' </select>';
-                   
-                   $smarty->assign("GROUP_NAME", $GROUP_SELECT_OPTION);
- }
-
-if (is_admin($current_user)) { 
-	$CURRENCY_SELECT_OPTION = '<select name="currency_id" class="small">';
-	}
-else
-{
-	$CURRENCY_SELECT_OPTION = '<select name="currency_id" class="small" disabled>';
-}
-	
-        if($focus->id != '')
-        {
-                $currencyselectedid=fetchCurrency($focus->id);
-                $currencyselected=getCurrencyName($currencyselectedid);
-        }
-        $allCurrency=getDisplayCurrency();
-        foreach($allCurrency as $id=>$currencyInfoArr)
-        {
-               $currencyname=$currencyInfoArr;
-               $selected = '';
-               if($currencyselected != '' && $currencyname == $currencyselected)
-               {
-                       $selected = 'selected';
-               }
-               $CURRENCY_SELECT_OPTION .= '<option value="'.$id .'" '.$selected .'>';
-               $CURRENCY_SELECT_OPTION .= $currencyname;
-               $CURRENCY_SELECT_OPTION .= '</option>';
-        }
-        $CURRENCY_SELECT_OPTION .= ' </select>';
-        $smarty->assign("CURRENCY_NAME", $CURRENCY_SELECT_OPTION);
-
-
-
-$smarty->assign("ACTIVITY_VIEW", getActivityVIew($focus->activity_view));
-$smarty->assign("CLOUD_TAG", $focus->tagcloud);
-
-$smarty->assign("LEAD_VIEW", getLeadVIew($focus->lead_view));
-
-		if($focus->cal_color == '') $focus->cal_color = '#E6FAD8';
-
- 		$smarty->assign("CAL_COLOR",'<INPUT TYPE="text" readonly NAME="cal_color" SIZE="10" VALUE="'.$focus->cal_color.'" style="background-color:'.$focus->cal_color.';"> <img src="include/images/bgcolor.gif" onClick="cp2.select(document.EditView.cal_color,\'pick2\');return false;" NAME="pick2" ID="pick2" align="middle">');
-		
-		$hrformat = '<select name="hour_format" class="small">';
-		if($focus->hour_format == '24')
-		{
-			$_24selected = 'selected';
-			$_ampmselected = '';
-		}
-		elseif($focus->hour_format == 'am/pm')
-		{
-			$_24selected = '';
-			$_ampmselected = 'selected';
-		}
-		$hrformat .= '<option value="24" '.$_24selected.'>23:00</option>';
-		$hrformat .= '<option value="am/pm" '.$_ampmselected.'>11:00pm</option>';
-		$hrformat .= '</select>';
-		$smarty->assign("CAL_HRFORMAT",$hrformat);
-
-		$stend_hour = '<select name="start_hour" class="small">';
-		for($i=0;$i<=15;$i++)
-		{
-			if($i == $focus->start_hour)
-				$selected = 'selected';
-			else
-				$selected = '';
-			if($i <= 9 && strlen(trim($i)) < 2)
-			{
-				$hrvalue= '0'.$i.':00';
-			}
-			else
-				$hrvalue= $i.':00';
-			$stend_hour .= '<option value="'.$hrvalue.'" '.$selected.'>'.$hrvalue.'</option>';
-		}
-		$stend_hour .= '</select>&nbsp;ends at:';
-		$stend_hour .= '<select name="end_hour" class="small">';
-		for($i=16;$i<=23;$i++)
-		{
-			if($i == $focus->end_hour)
-				$selected = 'selected';
-			else
-				$selected = '';
-			if($i <= 9 && strlen(trim($i)) < 2)
-			{
-				$hrvalue= '0'.$i.':00';
-			}
-			else
-				$hrvalue= $i.':00';
-			$stend_hour .= '<option value="'.$hrvalue.'" '.$selected.'>'.$hrvalue.'</option>';
-		}
-		$stend_hour .= '</select>&nbsp;';
-		$smarty->assign("CAL_HRDURATION",$stend_hour);
-
-if (isset($default_user_name)
-	&& $default_user_name != ""
-	&& $default_user_name == $focus->user_name
-	&& isset($lock_default_user_name)
-	&& $lock_default_user_name == true ) {
-	$status .= " disabled ";
-	$smarty->assign("DISABLED", "disabled");
-}
-
+$smarty->assign("MODE",$focus->mode);
 if ($_REQUEST['Edit'] == ' Edit ')
 {
 	$smarty->assign("READONLY", "readonly");
@@ -352,12 +106,6 @@
 
 
 
-if (is_admin($current_user) && $focus->is_admin == 'on') $smarty->assign("IS_ADMIN", "checked");
-elseif (is_admin($current_user) && $focus->is_admin != 'on') ;
-elseif (!is_admin($current_user) && $focus->is_admin == 'on') $smarty->assign("IS_ADMIN", "disabled checked");
-else $smarty->assign("IS_ADMIN", "disabled");
-
-//$smarty->assign("",$focus->getUserListViewHeader());
 
 $smarty->assign('PARENTTAB',$_REQUEST['parenttab']);
 

Modified: vtigercrm/trunk/modules/Users/Forms.php
==============================================================================
--- vtigercrm/trunk/modules/Users/Forms.php (original)
+++ vtigercrm/trunk/modules/Users/Forms.php Tue Jun 13 04:04:34 2006
@@ -54,7 +54,7 @@
 function verify_data(form) {
 	var isError = false;
 	var errorMessage = "";
-	if (trim(form.email1.value) == "") {
+	if (trim(form.email.value) == "") {
 		isError = true;
 		errorMessage += "\\n$lbl_user_email1";
 		oField_miss = form.email1;
@@ -71,15 +71,15 @@
 	}
 	if(form.mode.value !='edit')
 	{
-		if (trim(form.new_password.value) == "") {
+		if (trim(form.user_password.value) == "") {
 			isError = true;
 			errorMessage += "\\n$lbl_new_password";
-			oField_miss =form.new_password;
+			oField_miss =form.user_password;
 		}
-		if (trim(form.confirm_new_password.value) == "") {
+		if (trim(form.confirm_password.value) == "") {
 			isError = true;
 			errorMessage += "\\n$lbl_confirm_new_password";
-			oField_miss =form.confirm_new_password;
+			oField_miss =form.confirm_password;
 		}
 	}
 	if (trim(form.user_name.value) == "") {
@@ -91,19 +91,19 @@
 	if (isError == true) {
 		set_fieldfocus(errorMessage,oField_miss);
 	}
-	if (trim(form.email1.value) != "" && !/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(form.email1.value)) {
-		errorMessage='"' + form.email1.value + '" is $err_invalid_email_address';
+	if (trim(form.email.value) != "" && !/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(form.email.value)) {
+		errorMessage='"' + form.email.value + '" is $err_invalid_email_address';
 		set_fieldfocus(errorMessage,form.email1);
 	}
 	if (trim(form.email2.value) != "" && !/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(form.email2.value)) {
-		errorMessage='"' + form.email2.value + '" value in other email vtiger_field is $err_invalid_email_address';
+		errorMessage='"' + form.email2.value + '" value in other email field is $err_invalid_email_address';
 		set_fieldfocus(errorMessage,form.email2);
 	}
 	if(form.mode.value != 'edit')
 	{
-		if(trim(form.new_password.value) != trim(form.confirm_new_password.value))
+		if(trim(form.user_password.value) != trim(form.confirm_password.value))
 		{
-			set_fieldfocus("The password does't match",form.form.new_password);
+			set_fieldfocus("The password does't match",form.user_password);
 		}
 		check_duplicate();
 	}else

Modified: vtigercrm/trunk/modules/Users/Save.php
==============================================================================
--- vtigercrm/trunk/modules/Users/Save.php (original)
+++ vtigercrm/trunk/modules/Users/Save.php Tue Jun 13 04:04:34 2006
@@ -46,13 +46,16 @@
 elseif (!isset($_POST['record']) && !is_admin($current_user)) echo ("Unauthorized access to user administration.");
 
 $focus = new User();
-$focus->retrieve($_POST['record']);
-if(isset($focus->id) && $focus->id != '')
-    $mode='edit';
+if(isset($_REQUEST["record"]) && $_REQUEST["record"] != '')
+{
+    $focus->mode='edit';
+	$focus->id = $_REQUEST["record"];
+}
 else
-    $mode='';
+    $focus->mode='';
+	
 //save user Image
-$image_upload_array=SaveImage($_FILES,'user',$focus->id,$mode);
+$image_upload_array=SaveImage($_FILES,'user',$focus->id,$focus->mode);
 $focus->imagename = $image_upload_array['imagename'];
 $image_error = $image_upload_array['imageerror'];
 $errormessage = $image_upload_array['errormessage'];
@@ -69,61 +72,21 @@
 		exit;
 	}
 	
-	foreach($focus->column_fields as $field)
-	{
-		if(isset($_POST[$field]))
-		{
-			$value = $_POST[$field];
-			$focus->$field = $value;
 			
-		}
-	}
+	if (!isset($_POST['is_admin'])) $_REQUEST["is_admin"] = 'off';
+	//Code contributed by mike crowe for rearrange the home page and tab
+	if (!isset($_POST['deleted'])) $_REQUEST["deleted"] = '0';
+	if (!isset($_POST['homeorder']) || $_POST['homeorder'] == "" ) $_REQUEST["homeorder"] = 'ILTI,QLTQ,ALVT,PLVT,CVLVT,HLT,OLV,GRT,OLTSO';
 	
-	foreach($focus->additional_column_fields as $field)
-	{
-		if(isset($_POST[$field]))
-		{
-			$value = $_POST[$field];
-			$focus->$field = $value;
-			
-		}
-	}
-	
-	if (!isset($_POST['is_admin'])) $focus->is_admin = 'off';
-	//Code contributed by mike crowe for rearrange the home page and vtiger_tab
-	if (!isset($_POST['deleted'])) $focus->deleted = '0';
-	if (!isset($_POST['homeorder']) || $_POST['homeorder'] == "" ) $focus->homeorder = 'ILTI,QLTQ,ALVT,PLVT,CVLVT,HLT,OLV,GRT,OLTSO';
-	
-/*	if (!$focus->verify_data()) {
-		header("Location: index.php?action=Error&module=Users&error_string=".urlencode($focus->error_string));
-		exit;
-	}
-	else{	*/
+	setObjectValuesFromRequest(&$focus);
 		$focus->save("Users");
-//		include('modules/Calendar/user_ins.php');
-//		include("modules/Users/forum_register.php");	
 		$return_id = $focus->id;
-//	}
+
 if (isset($_POST['user_name']) && isset($_POST['new_password'])) {
-	/*	
-		//changing fourm password	
-		define('IN_PHPBB', 1);
-		
-		$phpbb_root_path = "modules/MessageBoard/";
-		require($phpbb_root_path . 'extension.inc');
-		include($phpbb_root_path . 'common.php');
-	*/	
 		$new_pass = $_POST['new_password'];
 		$new_passwd = $_POST['new_password'];
 		$new_pass = md5($new_pass);
 		$uname = $_POST['user_name'];
-		//$sql = "UPDATE " . USERS_TABLE . " SET user_password = '$new_pass' WHERE username = '$uname'";
-	/*
-		if (!($result = $db->sql_query($sql)) )
-		{
-			message_die(GENERAL_ERROR, 'Could not update user password', '', __LINE__, __FILE__, $sql);
-		}
-	*/
 		if (!$focus->change_password($_POST['confirm_new_password'], $_POST['new_password'])) {
 		
 			header("Location: index.php?action=Error&module=Users&error_string=".urlencode($focus->error_string));

Modified: vtigercrm/trunk/modules/Users/User.php
==============================================================================
--- vtigercrm/trunk/modules/Users/User.php (original)
+++ vtigercrm/trunk/modules/Users/User.php Tue Jun 13 04:04:34 2006
@@ -30,14 +30,14 @@
 
 require_once('include/logging.php');
 require_once('include/database/PearDatabase.php');
-require_once('data/SugarBean.php');
+require_once('data/CRMEntity.php');
 require_once('include/utils/UserInfoUtil.php');
 
 // User is used to store customer information.
-class User extends SugarBean {
+class User extends CRMEntity {
 	var $log;
 	var $db;
-	// Stored vtiger_fields
+	// Stored fields
 	var $id;
 	var $user_name;
 	var $user_password;
@@ -84,8 +84,22 @@
 	var $reports_to_id;
 
 	var $module_id='id';
-	
-	var $table_name = "vtiger_users";
+	var $tab_name = Array('vtiger_users','vtiger_attachments','vtiger_user2role');	
+	var $tab_name_index = Array('vtiger_users'=>'id','vtiger_attachments'=>'attachmentsid','vtiger_user2role'=>'userid');
+	var $column_fields = Array();
+	var $table_name = "users";
+	var $sortby_fields = Array();		  
+	
+    // This is the list of fields that are in the lists.
+    var $list_fields_name = Array();
+    var $list_link_field= '';
+
+	var $list_mode;
+	var $popup_type;
+
+	var $search_fields = Array();
+    var $search_fields_name = Array();
+	
 	var $module_name = "Users";
 
 	var $object_name = "User";
@@ -96,58 +110,13 @@
 	var $imagename;
 	var $defhomeview;
 	//var $sortby_fields = Array('user_name','email1','last_name','is_admin','status');	
-	var $column_fields = Array("id"
-		,"user_name"
-		,"user_password"
-		,"cal_color"
-		,"hour_format"
-		,"start_hour"
-		,"end_hour"
-		,"first_name"
-		,"last_name"
-		,"description"
-		,"date_entered"
-		,"date_modified"
-		,"modified_user_id"
-		,"title"
-		,"department"
-		,"is_admin"
-		,"currency_id"
-		,"phone_home"
-		,"phone_mobile"
-		,"phone_work"
-		,"phone_other"
-		,"phone_fax"
-		,"email1"
-		,"email2"
-		,"signature"
-		,"yahoo_id"
-		,"address_street"
-		,"address_city"
-		,"address_state"
-		,"address_postalcode"
-		,"address_country"
-		,"reports_to_id"
-		,"tz"
-		,"holidays"
-		,"namedays"
-		,"workdays"
-		,"weekstart"
-		,"status"
-		,"date_format"
-		,"activity_view"
-		,"lead_view"
-		,"tagcloud"
-		,"imagename"
-		,"defhomeview"
-		);
 
 	var $encodeFields = Array("first_name", "last_name", "description");
 
-	// This is used to retrieve related vtiger_fields from form posts.
+	// This is used to retrieve related fields from form posts.
 	var $additional_column_fields = Array('reports_to_name');		
 	
-	// This is the list of vtiger_fields that are in the lists.
+	// This is the list of fields that are in the lists.
 	var $list_fields = Array('id', 'first_name', 'last_name', 'user_name', 'status', 'department', 'yahoo_id', 'is_admin', 'email1', 'phone_work');
 	//commented as we get issues with sugarbean
 	/*
@@ -169,7 +138,10 @@
 
 	function User() {
 		$this->log = LoggerManager::getLogger('user');
+		$this->log->debug("Entering User() method ...");
 		$this->db = new PearDatabase();
+		$this->column_fields = getColumnFields('Users');
+		$this->log->debug("Exiting User() method ...");
 		
 	}
 
@@ -225,19 +197,20 @@
 	function encrypt_password($user_password)
 	{
 		// encrypt the password.
-		$salt = substr($this->user_name, 0, 2);
+		$salt = substr($this->column_fields["user_name"], 0, 2);
 		$encrypted_password = crypt($user_password, $salt);	
 
 		return $encrypted_password;
 	}
 	
 	function authenticate_user($password){
-	
-		$query = "SELECT * from $this->table_name where user_name='$this->user_name' AND user_hash='$password'";
+		$usr_name = $this->column_fields["user_name"];
+	
+		$query = "SELECT * from $this->table_name where user_name='$usr_name' AND user_hash='$password'";
 		$result = $this->db->requireSingleResult($query, false);
 
 		if(empty($result)){
-			$this->log->fatal("SECURITY: failed login by $this->user_name");
+			$this->log->fatal("SECURITY: failed login by $usr_name");
 			return false;
 		}
 
@@ -278,12 +251,13 @@
 	 */
 	function doLogin($user_password) {
 		global $AUTHCFG;
+		$usr_name = $this->column_fields["user_name"];
 	
 		switch (strtoupper($AUTHCFG['authType'])) {
 			case 'LDAP':
 				$this->log->debug("Using LDAP authentication");
 				require_once('modules/Users/authTypes/LDAP.php');
-				$result = ldapAuthenticate($this->user_name, $user_password);
+				$result = ldapAuthenticate($this->column_fields["user_name"], $user_password);
 				if ($result == NULL) {
 					return false;
 				} else {
@@ -295,7 +269,7 @@
 				$this->log->debug("Using Active Directory authentication");
 				require_once('modules/Users/authTypes/adLDAP.php');
 				$adldap = new adLDAP();
-				if ($adldap->authenticate($this->user_name,$user_password)) {
+				if ($adldap->authenticate($this->column_fields["user_name"],$user_password)) {
 					return true;
 				} else {
 					return false;
@@ -305,7 +279,7 @@
 			default:
 				$this->log->debug("Using integrated/SQL authentication");
 				$encrypted_password = $this->encrypt_password($user_password);
-				$query = "SELECT * from $this->table_name where user_name='$this->user_name' AND user_password='$encrypted_password'";
+				$query = "SELECT * from $this->table_name where user_name='$usr_name' AND user_password='$encrypted_password'";
 				$result = $this->db->requireSingleResult($query, false);
 				if (empty($result)) {
 					return false;
@@ -327,18 +301,19 @@
 	 */
 	function load_user($user_password)
 	{
+		$usr_name = $this->column_fields["user_name"];
 		if(isset($_SESSION['loginattempts'])){
 				 $_SESSION['loginattempts'] += 1;
 		}else{
 			$_SESSION['loginattempts'] = 1;	
 		}
 		if($_SESSION['loginattempts'] > 5){
-			$this->log->warn("SECURITY: " . $this->user_name . " has attempted to login ". 	$_SESSION['loginattempts'] . " times.");
-		}
-		$this->log->debug("Starting user load for $this->user_name");
+			$this->log->warn("SECURITY: " . $usr_name . " has attempted to login ". 	$_SESSION['loginattempts'] . " times.");
+		}
+		$this->log->debug("Starting user load for $usr_name");
 		$validation = 0;
 		unset($_SESSION['validation']);
-		if( !isset($this->user_name) || $this->user_name == "" || !isset($user_password) || $user_password == "")
+		if( !isset($this->column_fields["user_name"]) || $this->column_fields["user_name"] == "" || !isset($user_password) || $user_password == "")
 			return null;
 			
 		if($this->validation_check('aW5jbHVkZS9pbWFnZXMvc3VnYXJzYWxlc19tZC5naWY=','1a44d4ab8f2d6e15e0ff6ac1c2c87e6f', '866bba5ae0a15180e8613d33b0acc6bd') == -1)$validation = -1;
@@ -352,19 +327,18 @@
 		
 		if(!$authCheck)
 		{
-			$this->log->warn("User authentication for $this->user_name failed");
+			$this->log->warn("User authentication for $usr_name failed");
 			return null;
 		}
 		
-		$query = "SELECT * from $this->table_name where user_name='$this->user_name'";
+		$query = "SELECT * from $this->table_name where user_name='$usr_name'";
 		$result = $this->db->requireSingleResult($query, false);
 
-		// Get the vtiger_fields for the user
+		// Get the fields for the user
 		$row = $this->db->fetchByAssoc($result);
+		$this->id = $row['id'];	
 
 		$user_hash = strtolower(md5($user_password));
-		
-		
 		
 		
 		// If there is no user_hash is not present or is out of date, then create a new one.
@@ -372,19 +346,6 @@
 		{
 			$query = "UPDATE $this->table_name SET user_hash='$user_hash' where id='{$row['id']}'";
 			$this->db->query($query, true, "Error setting new hash for {$row['user_name']}: ");	
-		}
-		
-		// now fill in the vtiger_fields.
-		foreach($this->column_fields as $field)
-		{
-			//$this->log->info($field);
-			
-			if(isset($row[$field]))
-			{
-				$this->log->debug("=".$row[$field]);
-	
-				$this->$field = $row[$field];
-			}
 		}
 		$this->loadPreferencesFromDB($row['user_preferences']);
 		
@@ -408,9 +369,10 @@
 	*/
 	function change_password($user_password, $new_password)
 	{
+		$usr_name = $this->column_fields["user_name"];
 		global $mod_strings;
 		global $current_user;
-		$this->log->debug("Starting password change for $this->user_name");
+		$this->log->debug("Starting password change for $usr_name");
 		
 		if( !isset($new_password) || $new_password == "") {
 			$this->error_string = $mod_strings['ERR_PASSWORD_CHANGE_FAILED_1'].$user_name.$mod_strings['ERR_PASSWORD_CHANGE_FAILED_2'];
@@ -430,7 +392,7 @@
 	
 			if($row == null)
 			{
-				$this->log->warn("Incorrect old password for $this->user_name");
+				$this->log->warn("Incorrect old password for $usr_name");
 				$this->error_string = $mod_strings['ERR_PASSWORD_INCORRECT_OLD'];
 				return false;
 			}
@@ -441,7 +403,7 @@
 		
 		//set new password
 		$query = "UPDATE $this->table_name SET user_password='$encrypted_new_password', user_hash='$user_hash' where id='$this->id'";
-		$this->db->query($query, true, "Error setting new password for $this->user_name: ");	
+		$this->db->query($query, true, "Error setting new password for $usr_name: ");	
 		return true;
 	}
 	
@@ -460,16 +422,17 @@
 	}
 	
 	/** 
-	 * @return -- returns a list of all vtiger_users in the system.
+	 * @return -- returns a list of all users in the system.
 	 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc..
 	 * All Rights Reserved..
 	 * Contributor(s): ______________________________________..
 	 */
 	function verify_data()
 	{
+		$usr_name = $this->column_fields["user_name"];
 		global $mod_strings;
 		
-		$query = "SELECT user_name from vtiger_users where user_name='$this->user_name' AND id<>'$this->id' AND deleted=0";
+		$query = "SELECT user_name from vtiger_users where user_name='$usr_name' AND id<>'$this->id' AND deleted=0";
 		$result =$this->db->query($query, true, "Error selecting possible duplicate users: ");
 		$dup_users = $this->db->fetchByAssoc($result);
 		
@@ -478,20 +441,20 @@
 		$last_admin = $this->db->fetchByAssoc($result);
 
 		$this->log->debug("last admin length: ".count($last_admin));
-		$this->log->debug($last_admin['user_name']." == ".$this->user_name);
+		$this->log->debug($last_admin['user_name']." == ".$usr_name);
 
 		$verified = true;
 		if($dup_users != null)
 		{
-			$this->error_string .= $mod_strings['ERR_USER_NAME_EXISTS_1'].$this->user_name.$mod_strings['ERR_USER_NAME_EXISTS_2'];
+			$this->error_string .= $mod_strings['ERR_USER_NAME_EXISTS_1'].$usr_name.''.$mod_strings['ERR_USER_NAME_EXISTS_2'];
 			$verified = false;
 		}
 		if(!isset($_REQUEST['is_admin']) &&
 			count($last_admin) == 1 && 
-			$last_admin['user_name'] == $this->user_name) {
+			$last_admin['user_name'] == $usr_name) {
 			$this->log->debug("last admin length: ".count($last_admin));
 
-			$this->error_string .= $mod_strings['ERR_LAST_ADMIN_1'].$this->user_name.$mod_strings['ERR_LAST_ADMIN_2'];
+			$this->error_string .= $mod_strings['ERR_LAST_ADMIN_1'].$usr_name.$mod_strings['ERR_LAST_ADMIN_2'];
 			$verified = false;
 		}
 		
@@ -589,13 +552,14 @@
 	function retrieveCurrentUserInfoFromFile($userid)
 	{
 		require('user_privileges/user_privileges_'.$userid.'.php');
-		foreach($this->column_fields as $field)
+		foreach($this->column_fields as $field=>$value_iter)
                 {
                         if(isset($user_info[$field]))
                         {
                                 $this->$field = $user_info[$field];
                         }
                 }
+		$this->id = $userid;
 		return $this;
 		
 	}





More information about the vtigercrm-commits mailing list