[Vtigercrm-commits] [vtiger-commits] r7663 - in /vtigercrm/trunk/modules/Users: DetailView.php EditView.php ListView.php LoginHistory.php ShowHistory.php User.php UserGroups.php
vtigercrm-commits at vtiger.fosslabs.com
vtigercrm-commits at vtiger.fosslabs.com
Thu Jun 29 08:31:44 EDT 2006
Author: richie
Date: Thu Jun 29 06:30:44 2006
New Revision: 7663
Log:
New UI for Users has been integrated
Added:
vtigercrm/trunk/modules/Users/UserGroups.php
Modified:
vtigercrm/trunk/modules/Users/DetailView.php
vtigercrm/trunk/modules/Users/EditView.php
vtigercrm/trunk/modules/Users/ListView.php
vtigercrm/trunk/modules/Users/LoginHistory.php
vtigercrm/trunk/modules/Users/ShowHistory.php
vtigercrm/trunk/modules/Users/User.php
Modified: vtigercrm/trunk/modules/Users/DetailView.php
==============================================================================
--- vtigercrm/trunk/modules/Users/DetailView.php (original)
+++ vtigercrm/trunk/modules/Users/DetailView.php Thu Jun 29 06:30:44 2006
@@ -83,10 +83,6 @@
require_once($theme_path.'layout_utils.php');
//the user might belong to multiple groups
-if($focus->id != 1)
-{
- $groupids = fetchUserGroupids($focus->id);
-}
$log->info("User detail view");
$category = getParenttab();
@@ -99,7 +95,7 @@
$smarty->assign("MOD", $smod_strings);
$smarty->assign("APP", $app_strings);
-
+$smarty->assign("GROUP_COUNT",count(getGroupDetails($focus->id)));
$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);
@@ -139,16 +135,9 @@
$buttons = "<input title='".$app_strings['LBL_EDIT_BUTTON_TITLE']."' accessKey='".$app_strings['LBL_EDIT_BUTTON_KEY']."' class='crmButton small edit' 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);
- $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']."'>";
+ $buttons = "<input title='".$mod_strings['LBL_CHANGE_PASSWORD_BUTTON_TITLE']."' accessKey='".$mod_strings['LBL_CHANGE_PASSWORD_BUTTON_KEY']."' class='crmButton password small' 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=200, top=226, 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);
- $buttons = "<input title='".$mod_strings['LBL_LIST_MAILSERVER_BUTTON_TITLE']."' accessKey='".$mod_strings['LBL_LIST_MAILSERVER_BUTTON_KEY']."' class='classBtn' onclick=\"this.form.return_module.value='Users'; this.form.return_action.value='ListMailAccount'; this.form.return_id.value='$focus->id'; this.form.module.value='Settings' ;this.form.action.value='ListMailAccount'\" type='submit' name='ListMailServerAccount' value=' ".$mod_strings['LBL_LIST_MAILSERVER_BUTTON_LABEL']." '>";
- $smarty->assign('LIST_MAILSERVER_BUTTON',$buttons);
- $buttons = "<input title='".$mod_strings['LBL_CHANGE_HOMEPAGE_TITLE']."' class='classBtn' align='center' onclick=\"this.form.return_module.value='Users'; this.form.return_action.value='DetailView'; this.form.action.value='EditHomeOrder'; this.form.record.value='$focus->id';\" type='submit' name='EditHomeOrder' value=' ".$mod_strings['LBL_CHANGE_HOMEPAGE_LABEL']." '>";
- $smarty->assign('CHANGE_HOMEPAGE_BUTTON',$buttons);
-
}
if (is_admin($current_user))
@@ -184,7 +173,7 @@
$smarty->assign("CURRENT_USERID", $current_user->id);
$smarty->assign("HOMEORDER",$focus->getHomeOrder($focus->id));
$smarty->assign("BLOCKS", getBlocks($currentModule,"detail_view",'',$focus->column_fields));
-
+$smarty->assign("USERNAME",$focus->last_name.' '.$focus->first_name);
$smarty->display("UserDetailView.tpl");
Modified: vtigercrm/trunk/modules/Users/EditView.php
==============================================================================
--- vtigercrm/trunk/modules/Users/EditView.php (original)
+++ vtigercrm/trunk/modules/Users/EditView.php Thu Jun 29 06:30:44 2006
@@ -43,6 +43,7 @@
$mode='edit';
if (!is_admin($current_user) && $_REQUEST['record'] != $current_user->id) die ("Unauthorized access to user administration.");
$focus->retrieve_entity_info($_REQUEST['record'],'Users');
+ $smarty->assign("USERNAME",$focus->last_name.' '.$focus->first_name);
}else
{
$mode='create';
@@ -110,6 +111,6 @@
$smarty->assign('PARENTTAB',$_REQUEST['parenttab']);
- $smarty->display('UserEditView.tpl');
+$smarty->display('UserEditView.tpl');
?>
Modified: vtigercrm/trunk/modules/Users/ListView.php
==============================================================================
--- vtigercrm/trunk/modules/Users/ListView.php (original)
+++ vtigercrm/trunk/modules/Users/ListView.php Thu Jun 29 06:30:44 2006
@@ -59,10 +59,7 @@
$list_query .= ' ORDER BY '.$order_by.' '.$sorder;
$list_result = $adb->query($list_query);
//Retreive the Navigation array
-$navigation_array = getNavigationValues($start, $no_of_users['user'], '10');
-$start_rec = $navigation_array['start'];
-$end_rec = $navigation_array['end_val'];
-$record_string= $app_strings[LBL_SHOWING]." " .$start_rec." - ".$end_rec." " .$app_strings[LBL_LIST_OF] ." ".$no_of_users['user'];
+$navigation_array = getNavigationValues($start, $adb->num_rows($list_result), $no_of_users['user']);
$navigationOutput = getTableHeaderNavigation($navigation_array, $url_string,"Administration","index",'');
$smarty->assign("MOD", return_module_language($current_language,'Settings'));
Modified: vtigercrm/trunk/modules/Users/LoginHistory.php
==============================================================================
--- vtigercrm/trunk/modules/Users/LoginHistory.php (original)
+++ vtigercrm/trunk/modules/Users/LoginHistory.php Thu Jun 29 06:30:44 2006
@@ -18,7 +18,7 @@
require_once('include/database/PearDatabase.php');
// Contact is used to store customer information.
-class LoginHistory extends SugarBean {
+class LoginHistory {
var $log;
var $db;
@@ -51,11 +51,77 @@
$this->db = new PearDatabase();
}
+ var $sortby_fields = Array('user_name', 'user_ip', 'login_time', 'logout_time', 'status');
+
// This is the list of vtiger_fields that are in the lists.
- var $list_fields = Array('login_id', 'user_name', 'user_ip', 'login_time', 'logout_time', 'status');
+ var $list_fields = Array(
+ 'User Name'=>Array('vtiger_loginhistory'=>'user_name'),
+ 'User IP'=>Array('vtiger_loginhistory'=>'user_ip'),
+ 'Signin Time'=>Array('vtiger_loginhistory'=>'login_time'),
+ 'Signout Time'=>Array('vtiger_loginhistory'=>'logout_time'),
+ 'Status'=>Array('vtiger_loginhistory'=>'status'),
+ );
+
+ var $list_fields_name = Array(
+ 'User Name'=>'user_name',
+ 'User IP'=>'user_ip',
+ 'Signin Time'=>'login_time',
+ 'Signout Time'=>'logout_time',
+ 'Status'=>'status'
+ );
+ var $default_order_by = "login_time";
+ var $default_sort_order = 'DESC';
+
+
+ function getHistoryListViewHeader()
+ {
+ global $app_strings;
- var $default_order_by = "login_id";
+ $header_array = array($app_strings['LBL_LIST_USER_NAME'], $app_strings['LBL_LIST_USERIP'], $app_strings['LBL_LIST_SIGNIN'], $app_strings['LBL_LIST_SIGNOUT'], $app_strings['LBL_LIST_STATUS']);
+ return $header_array;
+
+ }
+
+ function getHistoryListViewEntries($navigation_array, $sorder='', $orderby='')
+ {
+ global $adb, $current_user;
+
+ if($sorder != '' && $order_by != '')
+ {
+ if(is_admin($current_user))
+ $list_query = "Select * from vtiger_loginhistory order by ".$order_by." ".$sorder;
+ else
+ $list_query = "Select * from vtiger_loginhistory where user_name=".$current_user->user_name." order by ".$order_by." ".$sorder;
+
+ }
+ else
+ {
+ if(is_admin($current_user))
+ $list_query = "Select * from vtiger_loginhistory order by ".$this->default_order_by." ".$this->default_sort_order;
+ else
+ $list_query = "Select * from vtiger_loginhistory where user_name='".$current_user->user_name."' order by ".$this->default_order_by." ".$this->default_sort_order;
+
+ }
+ $result = $adb->query($list_query);
+ $entries_list = array();
+
+ for($i = $navigation_array['start']; $i <= $navigation_array['end_val']; $i++)
+ {
+ $entries = array();
+ $loginid = $adb->query_result($result, $i-1, 'login_id');
+
+ $entries[] = $adb->query_result($result, $i-1, 'user_name');
+ $entries[] = $adb->query_result($result, $i-1, 'user_ip');
+ $entries[] = $adb->query_result($result, $i-1, 'login_time');
+ $entries[] = $adb->query_result($result, $i-1, 'logout_time');
+ $entries[] = $adb->query_result($result, $i-1, 'status');
+
+ $entries_list[] = $entries;
+ }
+ return $entries_list;
+
+ }
/** Records the Login info */
function user_login(&$usname,&$usip,&$intime)
Modified: vtigercrm/trunk/modules/Users/ShowHistory.php
==============================================================================
--- vtigercrm/trunk/modules/Users/ShowHistory.php (original)
+++ vtigercrm/trunk/modules/Users/ShowHistory.php Thu Jun 29 06:30:44 2006
@@ -9,13 +9,12 @@
* All Rights Reserved.
********************************************************************************/
-require_once('XTemplate/xtpl.php');
+require_once('Smarty_setup.php');
require_once('data/Tracker.php');
require_once('modules/Users/LoginHistory.php');
require_once('modules/Users/User.php');
require_once('themes/'.$theme.'/layout_utils.php');
require_once('include/logging.php');
-require_once('include/ListView/ListView.php');
require_once('include/database/PearDatabase.php');
#require_once('modules/Users/User.php');
require_once('include/utils/utils.php');
@@ -23,7 +22,7 @@
global $app_strings;
global $mod_strings;
global $app_list_strings;
-global $current_language;
+global $current_language, $current_user, $adb;
$current_module_strings = return_module_language($current_language, 'Users');
global $list_max_entries_per_page;
@@ -34,28 +33,54 @@
global $currentModule;
global $theme;
+$theme_path="themes/".$theme."/";
+$image_path=$theme_path."images/";
-$focus = new User();
+$focus = new LoginHistory();
-if(isset($_REQUEST['record'])) {
- $focus->retrieve_entity_info($_REQUEST['record'],"Users");
+$smarty = new vtigerCRM_Smarty;
+
+$category = getParenttab();
+
+if(is_admin($current_user))
+{
+ $qry = "Select * from vtiger_loginhistory";
+ $qry_result = $adb->query($qry);
+ $no_of_rows = $adb->num_rows($qry_result);
}
-if(isset($_REQUEST['isDuplicate']) && $_REQUEST['isDuplicate'] == 'true') {
- $focus->id = "";
+else
+{
+ $qry = "Select * from vtiger_loginhistory where user_name='".$current_user->user_name."'";
+ $qry_result = $adb->query($qry);
+ $no_of_rows = $adb->num_rows($qry_result);
}
-// focus_list is the means of passing data to a ListView.
-global $focus_list;
+//Retreiving the start value from request
+if(isset($_REQUEST['start']) && $_REQUEST['start'] != '')
+{
+ $start = $_REQUEST['start'];
+}
+else
+ $start=1;
-if (!isset($where)) $where = "";
+//Retreive the Navigation array
+$navigation_array = getNavigationValues($start, $no_of_rows, '10');
-$seedLogin = new LoginHistory();
-$ListView = new ListView();
-$ListView->initNewXTemplate('modules/Users/ShowHistory.html',$current_module_strings);
-$ListView->setHeaderTitle($current_module_strings['LBL_LOGIN_HISTORY_BUTTON_LABEL']);
-$ListView->setHeaderText($button);
-$ListView->setQuery($where, "", "login_id", "LOGIN");
-$ListView->processListView($seedLogin, "main", "LOGIN");
+$start_rec = $navigation_array['start'];
+$end_rec = $navigation_array['end_val'];
+$record_string= $app_strings[LBL_SHOWING]." " .$start_rec." - ".$end_rec." " .$app_strings[LBL_LIST_OF] ." ".$no_of_rows;
+$navigationOutput = getTableHeaderNavigation($navigation_array, $url_string,"Users","ShowHistory",'');
+
+$smarty->assign("MOD", $current_module_strings);
+$smarty->assign("APP", $app_strings);
+$smarty->assign("IMAGE_PATH",$image_path);
+$smarty->assign("LIST_HEADER",$focus->getHistoryListViewHeader());
+$smarty->assign("LIST_ENTRIES",$focus->getHistoryListViewEntries($navigation_array, $sorder, $sortby));
+$smarty->assign("RECORD_COUNTS", $record_string);
+$smarty->assign("NAVIGATION", $navigationOutput);
+$smarty->assign("CATEGORY",$category);
+
+$smarty->display("ShowHistoryContents.tpl");
?>
Modified: vtigercrm/trunk/modules/Users/User.php
==============================================================================
--- vtigercrm/trunk/modules/Users/User.php (original)
+++ vtigercrm/trunk/modules/Users/User.php Thu Jun 29 06:30:44 2006
@@ -861,19 +861,6 @@
return GetRelatedList('Users','Activities',$focus,$query,$button,$returnset);
}
-function get_user_groups($id)
-{
- global $log;
- $log->debug("Entering get_contacts(".$id.") method ...");
- global $app_strings;
- $button = '';
- $query = 'select vtiger_users.*,vtiger_groups.* from vtiger_users inner join vtiger_users2group on vtiger_users.id=vtiger_users2group.userid left join vtiger_groups on vtiger_groups.groupid=vtiger_users2group.groupid where vtiger_users.id='.$id;
- $log->debug("Exiting get_contacts method ...");
- return getAllGroupInfo($query);
- }
-
-
-
function save($module_name)
{
global $log;
More information about the vtigercrm-commits
mailing list