[Vtigercrm-commits] [vtiger-commits] r4858 - in /vtigercrm/trunk: Smarty/templates/Settings/ModuleOwnersContents.tpl modules/Settings/ListModuleOwners.php modules/Settings/SettingsAjax.php

vtigercrm-commits at vtiger.fosslabs.com vtigercrm-commits at vtiger.fosslabs.com
Tue Apr 4 00:55:54 EDT 2006


Author: don
Date: Mon Apr  3 22:55:41 2006
New Revision: 4858

Log:
* files added to integrate new UI for module OwnersSmarty/templates/Settings/ModuleOwners.tpl

Added:
    vtigercrm/trunk/Smarty/templates/Settings/ModuleOwnersContents.tpl   (with props)
    vtigercrm/trunk/modules/Settings/SettingsAjax.php
Modified:
    vtigercrm/trunk/modules/Settings/ListModuleOwners.php

Modified: vtigercrm/trunk/modules/Settings/ListModuleOwners.php
==============================================================================
--- vtigercrm/trunk/modules/Settings/ListModuleOwners.php (original)
+++ vtigercrm/trunk/modules/Settings/ListModuleOwners.php Mon Apr  3 22:55:41 2006
@@ -9,63 +9,75 @@
 * 
  ********************************************************************************/
 
-require_once('XTemplate/xtpl.php');
 
-echo get_module_title($mod_strings['LBL_MODULE_NAME'], $mod_strings['LBL_MODULE_NAME'].' : Assign Module Owners', true);
-
+require_once('Smarty_setup.php');
+require_once('include/utils/utils.php');
 global $mod_strings, $app_strings;
 global $theme;
 $theme_path="themes/".$theme."/";
 $image_path=$theme_path."images/";
 
+$module_array = getModuleNameList();
+if($_REQUEST['list_module_mode'] != '' && $_REQUEST['list_module_mode'] == 'save')
+{
+	foreach($module_array as $val)
+	{
+		$req_name = 'user_'.strtolower($val);
+		$userid = $_REQUEST[$req_name];
+		$tabid = getTabid($val);
+		if($tabid != '' && $userid != '')
+		{
+			$sql = 'update moduleowners set user_id = '.$userid.' where tabid = '.$tabid;
+			$adb->query($sql);
+		}
+	}
+	
+}
+elseif($_REQUEST['list_module_mode'] != '' && $_REQUEST['list_module_mode'] == 'edit')
+{
+	$user_array = get_user_array(false);
+	foreach($module_array as $val)
+	{
+		$user_combo = getUserCombo($user_array,$val);
 
-$module_array = getModuleNameList();
-$user_array = get_user_array();
+		$user_list []= $val;
+		$user_list []= $user_combo;
 
-$row = 1;
-foreach($module_array as $val)
-{
-	if ($row%2==0)
-        {
-		$trowclass = 'evenListRow';
 	}
-	else
-	{
-		$trowclass = 'oddListRow';
-	}
-	$row ++;
-	$user_list .= '<tr class="'.$trowclass.'"><td nowrap width="20%" height="21" style="padding:0px 3px 0px 3px;">'.$val.' : </td>';
-
-	//get the user array as a combo list
-	$user_id = getModuleOwner(getTabid($val));
-	$user_name = getUserName($user_id);
-
-	$user_list .= '<td width="20%" style="padding:0px 3px 0px 3px;"><a href="index.php?module=Users&action=DetailView&record='.$user_id.'">'.$user_name.'</a></td></tr>';
-
-	//To add the modules as single string to pass as hidden value
-	$modules .= $val.'&&&';
+	$user_list = array_chunk($user_list,2);
 }
 
+$smarty = new vtigerCRM_Smarty;
+if($_REQUEST['list_module_mode'] != 'edit')
+{
+	foreach($module_array as $val)
+	{
+		$user_list []= $val;
 
-require_once($theme_path.'layout_utils.php');
+		//get the user array as a combo list
+		$user_id = getModuleOwner(getTabid($val));
+		$user_name = getUserName($user_id);
 
+		$user_list []= $user_id;
+		$user_list []= $user_name;
+	}
+
+	$user_list = array_chunk($user_list,3);
+}
 $log->info("Settings Module Owners view");
 
-$xtpl=new XTemplate ('modules/Settings/ListModuleOwners.html');
-$xtpl->assign("MOD", $mod_strings);
-$xtpl->assign("APP", $app_strings);
-$xtpl->assign("THEME", $theme);
-$xtpl->assign("IMAGE_PATH", $image_path);
-$xtpl->assign("MODULE", "Settings");
+$smarty->assign("MODULE_MODE",$_REQUEST['list_module_mode']);
+$smarty->assign("USER_LIST", $user_list);
+$smarty->assign("MOD", return_module_language($current_language,'Settings'));
+$smarty->assign("IMAGE_PATH",$image_path);
+$smarty->assign("APP", $app_strings);
+$smarty->assign("CMOD", $mod_strings);
 
-$xtpl->assign("MODULES_LIST", $modules);
-
-$xtpl->assign("USER_LIST", $user_list);
-
-$xtpl->parse("main");
-
-$xtpl->out("main");
-
+if($_REQUEST['file_mode'] != 'ajax')
+	$smarty->display("Settings/ModuleOwners.tpl");
+else
+	$smarty->display("Settings/ModuleOwnersContents.tpl");
+	
 function getModuleOwner($tabid)
 {
 	global $adb;
@@ -87,9 +99,31 @@
 	{
 		array_push($mod_array,$row['name']);
 	}
-	//echo '<pre>';print_r($mod_array);echo '</pre>';
-
 	return $mod_array;
 }
+function getUserCombo($user_array,$name)
+{
+	global $adb;
 
+	$tabid = getTabid($name);
+	$sql = "select * from moduleowners where tabid=".$tabid;
+	$res = $adb->query($sql);
+	$db_userid = $adb->query_result($res,0,'user_id');
+	
+	//Form the user combo list for each module
+	$combo_name = "user_".strtolower($name);
+	$user_combo = '<select name="'.$combo_name.'">';
+	foreach($user_array as $user_id => $user_name)
+	{
+		$selected = '';
+		if($user_id == $db_userid)
+		{	
+			$selected = 'selected';
+		}
+		$user_combo .= '<OPTION value="'.$user_id.'" '.$selected.'>'.$user_name.'</OPTION>';
+	}
+	$user_combo .= '</select>';
+
+	return $user_combo;
+}
 ?>





More information about the vtigercrm-commits mailing list