[ Index ] |
|
Code source de vtiger CRM 5.0.2 |
1 <?php 2 3 /********************************************************************************* 4 ** The contents of this file are subject to the vtiger CRM Public License Version 1.0 5 * ("License"); You may not use this file except in compliance with the License 6 * The Original Code is: vtiger CRM Open Source 7 * The Initial Developer of the Original Code is vtiger. 8 * Portions created by vtiger are Copyright (C) vtiger. 9 * All Rights Reserved. 10 * 11 ********************************************************************************/ 12 13 14 require_once ('include/utils/UserInfoUtil.php'); 15 require_once ('Smarty_setup.php'); 16 $smarty = new vtigerCRM_Smarty; 17 18 global $mod_strings; 19 global $app_strings; 20 global $app_list_strings; 21 22 23 24 global $adb; 25 global $theme; 26 $theme_path="themes/".$theme."/"; 27 $image_path=$theme_path."images/"; 28 29 30 //Retreiving the hierarchy 31 $hquery = "select * from vtiger_role order by parentrole asc"; 32 $hr_res = $adb->query($hquery); 33 $num_rows = $adb->num_rows($hr_res); 34 $hrarray= Array(); 35 36 for($l=0; $l<$num_rows; $l++) 37 { 38 $roleid = $adb->query_result($hr_res,$l,'roleid'); 39 $parent = $adb->query_result($hr_res,$l,'parentrole'); 40 $temp_list = explode('::',$parent); 41 $size = sizeof($temp_list); 42 $i=0; 43 $k= Array(); 44 $y=$hrarray; 45 if(sizeof($hrarray) == 0) 46 { 47 $hrarray[$temp_list[0]]= Array(); 48 } 49 else 50 { 51 while($i<$size-1) 52 { 53 $y=$y[$temp_list[$i]]; 54 $k[$temp_list[$i]] = $y; 55 $i++; 56 57 } 58 $y[$roleid] = Array(); 59 $k[$roleid] = Array(); 60 61 //Reversing the Array 62 $rev_temp_list=array_reverse($temp_list); 63 $j=0; 64 //Now adding this into the main array 65 foreach($rev_temp_list as $value) 66 { 67 if($j == $size-1) 68 { 69 $hrarray[$value]=$k[$value]; 70 } 71 else 72 { 73 $k[$rev_temp_list[$j+1]][$value]=$k[$value]; 74 } 75 $j++; 76 } 77 } 78 79 } 80 //Constructing the Roledetails array 81 $role_det = getAllRoleDetails(); 82 $query = "select * from vtiger_role"; 83 $result = $adb->query($query); 84 $num_rows=$adb->num_rows($result); 85 86 $roleout =''; 87 $roleout .= indent($hrarray,$roleout,$role_det); 88 89 /** recursive function to construct the role tree ui 90 * @param $hrarray -- Hierarchial role tree array with only the roleid:: Type array 91 * @param $roleout -- html string ouput of the constucted role tree ui:: Type varchar 92 * @param $role_det -- Roledetails array got from calling getAllRoleDetails():: Type array 93 * @returns $role_out -- html string ouput of the constucted role tree ui:: Type string 94 * 95 */ 96 97 function indent($hrarray,$roleout,$role_det) 98 { 99 global $theme; 100 $theme_path="themes/".$theme."/"; 101 $image_path=$theme_path."images/"; 102 foreach($hrarray as $roleid => $value) 103 { 104 105 //retreiving the vtiger_role details 106 $role_det_arr=$role_det[$roleid]; 107 $roleid_arr=$role_det_arr[2]; 108 $rolename = $role_det_arr[0]; 109 $roledepth = $role_det_arr[1]; 110 $roleout .= '<ul class="uil" id="'.$roleid.'" style="display:block;list-style-type:none;">'; 111 $roleout .= '<li ><table border="0" cellpadding="0" cellspacing="0" onMouseOver="fnVisible(\'layer_'.$roleid.'\')" onMouseOut="fnInVisible(\'layer_'.$roleid.'\')">'; 112 $roleout.= '<tr><td nowrap>'; 113 if(sizeof($value) >0 && $roledepth != 0) 114 { 115 $roleout.='<b style="font-weight:bold;margin:0;padding:0;cursor:pointer;">'; 116 $roleout .= '<img src="'.$image_path.'/minus.gif" id="img_'.$roleid.'" border="0" alt="Expand/Collapse" title="Expand/Collapse" align="absmiddle" onClick="showhide(\''.$roleid_arr.'\',\'img_'.$roleid.'\')" style="cursor:pointer;">'; 117 } 118 else if($roledepth != 0){ 119 $roleout .= '<img src="'.$image_path.'/vtigerDevDocs.gif" id="img_'.$roleid.'" border="0" alt="Expand/Collapse" title="Expand/Collapse" align="absmiddle">'; 120 } 121 else{ 122 $roleout .= '<img src="'.$image_path.'/menu_root.gif" id="img_'.$roleid.'" border="0" alt="Root" title="Root" align="absmiddle">'; 123 } 124 if($roledepth == 0 ){ 125 $roleout .= ' <b class="genHeaderGray">'.$rolename.'</b></td>'; 126 $roleout .= '<td nowrap><div id="layer_'.$roleid.'" class="drag_Element"><a href="index.php?module=Users&action=createrole&parenttab=Settings&parent='.$roleid.'"><img src="'.$image_path.'/Rolesadd.gif" align="absmiddle" border="0" alt="Add Role" title="Add Role"></a></div></td></tr></table>'; 127 } 128 else{ 129 $roleout .= ' <a href="javascript:put_child_ID(\'user_'.$roleid.'\');" class="x" id="user_'.$roleid.'">'.$rolename.'</a></td>'; 130 131 $roleout.='<td nowrap><div id="layer_'.$roleid.'" class="drag_Element"> 132 <a href="index.php?module=Users&action=createrole&parenttab=Settings&parent='.$roleid.'"><img src="'.$image_path.'/Rolesadd.gif" align="absmiddle" border="0" alt="Add Role" title="Add Role"></a> 133 <a href="index.php?module=Users&action=createrole&roleid='.$roleid.'&parenttab=Settings&mode=edit"><img src="'.$image_path.'/RolesEdit.gif" align="absmiddle" border="0" alt="Edit Role" title="Edit Role"></a>'; 134 135 if($roleid != 'H1' && $roleid != 'H2' && $roleid != 'H3' && $roleid != 'H4' && $roleid != 'H5') 136 { 137 138 $roleout .= '<a href="index.php?module=Users&action=RoleDeleteStep1&roleid='.$roleid.'&parenttab=Settings"><img src="'.$image_path.'/RolesDelete.gif" align="absmiddle" border="0" alt="Delete Role" title="Delete Role"></a>'; 139 } 140 141 $roleout .='<a href="#" class="small" onClick="get_parent_ID(this,\'user_'.$roleid.'\')"><img src="'.$image_path.'/RolesMove.gif" align="absmiddle" border="0" alt="Move Role" title="Move Role"></a> 142 </div></td></tr></table>'; 143 // $roleout .= ' <a href="index.php?module=Users&action=createrole&parenttab=Settings&parent='.$roleid.'">Add</a> | <a href="index.php?module=Users&action=createrole&roleid='.$roleid.'&parenttab=Settings&mode=edit">Edit</a> | <a href="index.php?module=Users&action=RoleDeleteStep1&roleid='.$roleid.'&parenttab=Settings">Delete</a> | <a href="index.php?module=Users&action=RoleDetailView&parenttab=Settings&roleid='.$roleid.'">View</a>'; 144 145 146 } 147 $roleout .= '</li>'; 148 if(sizeof($value) > 0 ) 149 { 150 $roleout = indent($value,$roleout,$role_det); 151 } 152 153 $roleout .= '</ul>'; 154 155 } 156 157 return $roleout; 158 } 159 $smarty->assign("THEME",$theme_path); 160 $smarty->assign("IMAGE_PATH",$image_path); 161 $smarty->assign("APP", $app_strings); 162 $smarty->assign("MOD", return_module_language($current_language,'Settings')); 163 $smarty->assign("CMOD", $mod_strings); 164 $smarty->assign("ROLETREE", $roleout); 165 166 if($_REQUEST['ajax'] == 'true') 167 { 168 $smarty->display("RoleTree.tpl"); 169 } 170 else 171 { 172 $smarty->display("ListRoles.tpl"); 173 } 174 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Feb 25 10:22:19 2007 | par Balluche grâce à PHPXref 0.7 |