| [ Index ] |
|
Code source de vtiger CRM 5.0.2 |
1 <?php 2 /********************************************************************************* 3 ** The contents of this file are subject to the vtiger CRM Public License Version 1.0 4 * ("License"); You may not use this file except in compliance with the License 5 * The Original Code is: vtiger CRM Open Source 6 * The Initial Developer of the Original Code is vtiger. 7 * Portions created by vtiger are Copyright (C) vtiger. 8 * All Rights Reserved. 9 * 10 ********************************************************************************/ 11 12 require_once ('include/database/PearDatabase.php'); 13 require_once ('include/utils/UserInfoUtil.php'); 14 require_once ('include/utils/utils.php'); 15 global $adb; 16 $profileid = $_REQUEST['profileid']; 17 $def_module = $_REQUEST['selected_module']; 18 $def_tab = $_REQUEST['selected_tab']; 19 20 if(isset($_REQUEST['return_action']) && $_REQUEST['return_action']!= '') 21 $return_action =$_REQUEST['return_action']; 22 else 23 $return_action = 'ListProfiles'; 24 25 //Retreiving the vtiger_tabs permission array 26 $tab_perr_result = $adb->query("select * from vtiger_profile2tab where profileid=".$profileid); 27 $act_perr_result = $adb->query("select * from vtiger_profile2standardpermissions where profileid=".$profileid); 28 $act_utility_result = $adb->query("select * from vtiger_profile2utility where profileid=".$profileid); 29 $num_tab_per = $adb->num_rows($tab_perr_result); 30 $num_act_per = $adb->num_rows($act_perr_result); 31 $num_act_util_per = $adb->num_rows($act_utility_result); 32 33 //Updating vtiger_profile2global permissons vtiger_table 34 $view_all_req=$_REQUEST['view_all']; 35 $view_all = getPermissionValue($view_all_req); 36 37 $edit_all_req=$_REQUEST['edit_all']; 38 $edit_all = getPermissionValue($edit_all_req); 39 40 $update_query = "update vtiger_profile2globalpermissions set globalactionpermission=".$view_all." where globalactionid=1 and profileid=".$profileid; 41 $adb->query($update_query); 42 $update_query = "update vtiger_profile2globalpermissions set globalactionpermission=".$edit_all." where globalactionid=2 and profileid=".$profileid; 43 $adb->query($update_query); 44 45 46 //profile2tab permissions 47 for($i=0; $i<$num_tab_per; $i++) 48 { 49 $tab_id = $adb->query_result($tab_perr_result,$i,"tabid"); 50 $request_var = $tab_id.'_tab'; 51 if($tab_id != 3 && $tab_id != 16) 52 { 53 $permission = $_REQUEST[$request_var]; 54 if($permission == 'on') 55 { 56 $permission_value = 0; 57 } 58 else 59 { 60 $permission_value = 1; 61 } 62 $update_query = "update vtiger_profile2tab set permissions=".$permission_value." where tabid=".$tab_id." and profileid=".$profileid; 63 $adb->query($update_query); 64 if($tab_id ==9) 65 { 66 $update_query = "update vtiger_profile2tab set permissions=".$permission_value." where tabid=16 and profileid=".$profileid; 67 $adb->query($update_query); 68 } 69 } 70 } 71 72 //profile2standard permissions 73 for($i=0; $i<$num_act_per; $i++) 74 { 75 $tab_id = $adb->query_result($act_perr_result,$i,"tabid"); 76 if($tab_id != 16) 77 { 78 $action_id = $adb->query_result($act_perr_result,$i,"operation"); 79 $action_name = getActionname($action_id); 80 if($action_name == 'EditView' || $action_name == 'Delete' || $action_name == 'DetailView') 81 { 82 $request_var = $tab_id.'_'.$action_name; 83 } 84 elseif($action_name == 'Save') 85 { 86 $request_var = $tab_id.'_EditView'; 87 } 88 elseif($action_name == 'index') 89 { 90 $request_var = $tab_id.'_DetailView'; 91 } 92 93 $permission = $_REQUEST[$request_var]; 94 if($permission == 'on') 95 { 96 $permission_value = 0; 97 } 98 else 99 { 100 $permission_value = 1; 101 } 102 $update_query = "update vtiger_profile2standardpermissions set permissions=".$permission_value." where tabid=".$tab_id." and Operation=".$action_id." and profileid=".$profileid; 103 $adb->query($update_query); 104 if($tab_id ==9) 105 { 106 $update_query = "update vtiger_profile2standardpermissions set permissions=".$permission_value." where tabid=16 and Operation=".$action_id." and profileid=".$profileid; 107 $adb->query($update_query); 108 } 109 110 111 112 } 113 } 114 115 //Update Profile 2 utility 116 for($i=0; $i<$num_act_util_per; $i++) 117 { 118 $tab_id = $adb->query_result($act_utility_result,$i,"tabid"); 119 120 $action_id = $adb->query_result($act_utility_result,$i,"activityid"); 121 $action_name = getActionname($action_id); 122 $request_var = $tab_id.'_'.$action_name; 123 124 125 $permission = $_REQUEST[$request_var]; 126 if($permission == 'on') 127 { 128 $permission_value = 0; 129 } 130 else 131 { 132 $permission_value = 1; 133 } 134 135 $update_query = "update vtiger_profile2utility set permission=".$permission_value." where tabid=".$tab_id." and activityid=".$action_id." and profileid=".$profileid; 136 137 $adb->query($update_query); 138 139 140 } 141 142 143 144 $modArr=getFieldModuleAccessArray(); 145 146 foreach($modArr as $fld_module => $fld_label) 147 { 148 $fieldListResult = getProfile2FieldList($fld_module, $profileid); 149 $noofrows = $adb->num_rows($fieldListResult); 150 $tab_id = getTabid($fld_module); 151 for($i=0; $i<$noofrows; $i++) 152 { 153 $fieldid = $adb->query_result($fieldListResult,$i,"fieldid"); 154 $visible = $_REQUEST[$fieldid]; 155 if($visible == 'on') 156 { 157 $visible_value = 0; 158 } 159 else 160 { 161 $visible_value = 1; 162 } 163 //Updating the Mandatory vtiger_fields 164 $uitype = $adb->query_result($fieldListResult,$i,"uitype"); 165 if($uitype == 2 || $uitype == 6 || $uitype == 22 || $uitype == 73 || $uitype == 24 || $uitype == 81 || $uitype == 50 || $uitype == 23 || $uitype == 16) 166 { 167 $visible_value = 0; 168 } 169 //Updating the database 170 $update_query = "update vtiger_profile2field set visible=".$visible_value." where fieldid='".$fieldid."' and profileid=".$profileid." and tabid=".$tab_id; 171 $adb->query($update_query); 172 173 } 174 } 175 $loc = "Location: index.php?action=".$return_action."&module=Users&mode=view&parenttab=Settings&profileid=".$profileid."&selected_tab=".$def_tab."&selected_module=".$def_module; 176 header($loc); 177 178 /** returns value 0 if request permission is on else returns value 1 179 * @param $req_per -- Request Permission:: Type varchar 180 * @returns $permission - can have value 0 or 1:: Type integer 181 * 182 */ 183 function getPermissionValue($req_per) 184 { 185 if($req_per == 'on') 186 { 187 $permission_value = 0; 188 } 189 else 190 { 191 $permission_value = 1; 192 } 193 return $permission_value; 194 } 195 196 ?>
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 |