Changeset 3255
- Timestamp:
- 09/15/10 17:06:46 (14 years ago)
- Location:
- branches/2.2/workflow
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2/workflow/inc/class.WorkflowLDAP.inc.php
r3221 r3255 562 562 ); 563 563 564 $result = array_merge($result, ldap_get_entries($this->dataSource, $resourceIdentifier)); 564 $entries = ldap_get_entries($this->dataSource, $resourceIdentifier); 565 if (is_array($entries)) { 566 $result = array_merge($result, $entries); 567 } 568 565 569 unset($result['count']); 566 570 } -
branches/2.2/workflow/inc/class.bo_adminaccess.inc.php
r3167 r3255 85 85 return $this->so->getUserNames($admins_id); 86 86 } 87 88 /** 89 * Retorna o nivel administrativo do organograma do processo 90 * 91 * @param array $p processo 92 * @return array o nivel administrativo do monitor do processo 93 * @access public 94 */ 95 function get_organogram_admin_level($p) 96 { 97 return $this->so->getUserAdminLevel('ORG', $p['uid'], $p['pid']); 98 } 87 99 88 100 /** … … 221 233 return null; 222 234 } 235 236 /** 237 * Seta o nivel administrativo do organograma 238 * 239 * @param array $p processo 240 * @return arraym 241 * @access public 242 */ 243 function set_organogram_admin_level($p) 244 { 245 $np = explode('_', $p['np']); 246 $levels = array(); 247 foreach ($np as $pair) 248 { 249 list($key, $value) = explode('=', $pair, 2); 250 $levels[$key] = ($value == '1') ? true : false; 251 } 252 253 254 $result = $this->so->setAdminLevel('ORG', $p['uid'], $p['pid'], $levels); 255 256 if (!$result) { 257 return "Não atualizou as permissões."; 258 } 259 260 } 223 261 224 262 /** -
branches/2.2/workflow/inc/class.so_adminaccess.inc.php
r3167 r3255 184 184 function get_granted_organograms($user_id) 185 185 { 186 return $this->getUserPermissions('ORG', $user_id );186 return $this->getUserPermissions('ORG', $user_id, 0); 187 187 } 188 188 … … 311 311 * @param string $type type of resource 312 312 * @param integer $uid user id 313 * @param requiredLevel Level Required to Access. 313 314 * @return bool 314 315 * @access public 315 316 */ 316 function getUserPermissions($type, $uid )317 function getUserPermissions($type, $uid, $requiredLevel = null) 317 318 { 318 319 $query = " 319 320 SELECT 320 numvalue 321 numvalue, 322 nivel 321 323 FROM 322 324 egw_wf_admin_access … … 329 331 $output = array(); 330 332 if ($result) 331 while ($row = $result->fetchRow()) 332 $output[] = $row['numvalue']; 333 while ($row = $result->fetchRow()) { 334 $authorized = $this->_checkLevelNumber($row['nivel'], $requiredLevel); 335 if (isset($requiredLevel)) { 336 $authorized = $this->checkUserAccessToResource($type,$uid,$row['numvalue'],$requiredLevel); 337 if ($authorized) { 338 $output[] = $row['numvalue']; 339 } 340 } else { 341 $output[] = $row['numvalue']; 342 } 343 } 333 344 334 345 return $output; … … 342 353 * @return array 343 354 */ 344 function getUserGroupPermissions($type, $uid )355 function getUserGroupPermissions($type, $uid, $requiredLevel = null) 345 356 { 346 357 $groups = galaxia_retrieve_user_groups($uid); … … 361 372 $output = array(); 362 373 if ($result) 363 while ($row = $result->fetchRow()) 364 $output[] = $row['numvalue']; 374 while ($row = $result->fetchRow()) { 375 if (isset($requiredLevel)) { 376 //$authorized = $this->_checkLevelNumber($row['nivel'], $requiredLevel); 377 $authorized = $this->checkUserAccessToResource($type,$uid,$row['numvalue'],$requiredLevel); 378 if ($authorized) { 379 $output[] = $row['numvalue']; 380 } 381 } else { 382 $output[] = $row['numvalue']; 383 } 384 } 365 385 366 386 return $output; … … 376 396 function checkUserAccessToType($type, $uid) 377 397 { 378 return (count($this->getUserPermissions($type, $uid )) > 0);398 return (count($this->getUserPermissions($type, $uid,0)) > 0); 379 399 } 380 400 /** … … 414 434 415 435 $result = $this->db->query($query, array($type, $uid, $numvalue)); 436 416 437 $row = $result->fetchRow(); 417 438 418 if (isset($row['nivel'])) 419 return $this->_checkLevelNumber($row['nivel'], $requiredLevel); 439 if (isset($row['nivel'])) { 440 $res = $this->_checkLevelNumber($row['nivel'], $requiredLevel); 441 return $res; 442 } 420 443 else 421 444 return false; … … 491 514 } 492 515 /** 493 * Seta ao nivel de administracao516 * Seta o nivel de administracao 494 517 * 495 518 * @param string $type tipo de recurso … … 505 528 $level = $this->_permissionListToNumber($level); 506 529 507 $query = " 508 UPDATE egw_wf_admin_access 530 $query = "UPDATE egw_wf_admin_access 509 531 SET 510 532 nivel = ? … … 513 535 (tipo = ?) AND 514 536 (numvalue = ?)"; 515 $this->db->query($query, array($level, $uid, $type, $numvalue)); 537 $result = $this->db->query($query, array($level, $uid, $type, $numvalue)); 538 539 return $result; 516 540 } 517 541 -
branches/2.2/workflow/inc/class.so_orgchart.inc.php
r3225 r3255 145 145 else 146 146 { 147 $organizations = $this->acl->getUserPermissions("ORG", $this->userID );147 $organizations = $this->acl->getUserPermissions("ORG", $this->userID, 0); 148 148 $organizations[] = -1; 149 149 $query = "SELECT organizacao_id, nome, descricao, ativa, url_imagem, sitio FROM organizacao WHERE (organizacao_id IN (" . implode(',', $organizations) . ")) ORDER BY nome"; … … 1126 1126 $mobile = ''; 1127 1127 $homePhone = ''; 1128 1128 1129 1129 /* 1130 1130 * Check if the current user can view the mobile and homePhone of the employee … … 1132 1132 * that's being retrieved 1133 1133 */ 1134 if (in_array($account_id,$arr_supervisores) || ($account_id == $employeeID)) { 1134 $authorized = $this->acl->checkUserAccessToResource('ORG', $account_id, (int) $organizationID, 1); 1135 if ((in_array($account_id,$arr_supervisores) || ($account_id == $employeeID)) || ($authorized)) { 1135 1136 $mobile = $employeeEntry['mobile']; 1136 1137 $homePhone = $employeeEntry['homephone']; -
branches/2.2/workflow/inc/class.ui_orgchart.inc.php
r3167 r3255 50 50 51 51 $isAdmin = $this->workflow_acl->checkWorkflowAdmin($GLOBALS['phpgw_info']['user']['account_id']); 52 $isOrgchartManager = $this->workflow_acl->checkUserGroupAccessToType('ORG', $GLOBALS['phpgw_info']['user']['account_id'] );52 $isOrgchartManager = $this->workflow_acl->checkUserGroupAccessToType('ORG', $GLOBALS['phpgw_info']['user']['account_id'],0); 53 53 54 54 if (!($isAdmin || $isOrgchartManager)) -
branches/2.2/workflow/inc/hook_sidebox_menu.inc.php
r3167 r3255 38 38 39 39 /* check if the user can administrate the orgchart */ 40 if ($workflowACL->checkUserGroupAccessToType('ORG', $userID ) || $isWorkflowAdmin)40 if ($workflowACL->checkUserGroupAccessToType('ORG', $userID,0) || $isWorkflowAdmin) 41 41 $file['Organization Chart'] = $GLOBALS['phpgw']->link('/index.php','menuaction=workflow.ui_orgchart.draw'); 42 42 -
branches/2.2/workflow/js/adminaccess/control_folder.js
r795 r3255 357 357 se.setAttribute('size','10'); 358 358 se.setAttribute('id','sel_org_admin'); 359 se.onchange = function() { loadLevelORG(); }; 359 360 se.style.width = input_width; 360 361 se.style.height = input_height; … … 426 427 tr.appendChild(td); 427 428 429 to.appendChild(tr); 430 tb.appendChild(to); 431 432 /* include the cell that will hold the user level interface */ 433 tr = document.createElement("TR"); 434 td = document.createElement("TD"); 435 td.setAttribute("id", "userLevelORG"); 436 td.setAttribute("colSpan", 3); 437 tr.appendChild(td); 428 438 to.appendChild(tr); 429 439 tb.appendChild(to); … … 1026 1036 } 1027 1037 1038 /* construct the user level interface */ 1039 function loadLevelORG() 1040 { 1041 /* required parameters */ 1042 var pid = document.getElementById('sel_org').value; 1043 var uid = document.getElementById('sel_org_admin').value; 1044 1045 var loadLevelHandler = function(data) 1046 { 1047 var userLevelContainer = document.getElementById("userLevelORG"); 1048 userLevelContainer.innerHTML = ""; 1049 1050 /* checkboxes creation */ 1051 var checkBoxesPerRow = 2; 1052 var tb_out = document.createElement("TABLE"); 1053 var to_out = document.createElement("TBODY"); 1054 var tr = document.createElement("TR"); 1055 var td = document.createElement("TD"); 1056 td.innerHTML = "Permissões de Acesso:"; 1057 tr.appendChild(td); 1058 to_out.appendChild(tr); 1059 var table = document.createElement("TABLE"); 1060 var tbody = document.createElement("TBODY"); 1061 table.style.border='1px solid gray'; 1062 tr = null; 1063 td = null; 1064 for (var i = 0; i < permissionListORG.length; i++) 1065 { 1066 /* create the checkbox and the label */ 1067 var checkBox = document.createElement("INPUT"); 1068 checkBox.setAttribute("id", "cb_" + permissionListORG[i]['value']); 1069 checkBox.setAttribute("type", "checkbox"); 1070 if (data['bits'][permissionListORG[i]['value']]) 1071 checkBox.defaultChecked = true; 1072 1073 var label = "<label for=\"cb_" + permissionListORG[i]['value'] + "\">" + permissionListORG[i]['name'] + "</label>"; 1074 /* if necessary, start a new row */ 1075 if (!tr || (tr.childNodes.length == 2*checkBoxesPerRow)) 1076 tr = document.createElement("TR"); 1077 td = document.createElement("TD"); 1078 td.innerHTML = label; 1079 tr.appendChild(td); 1080 td = document.createElement("TD"); 1081 td.appendChild(checkBox); 1082 tr.appendChild(td); 1083 1084 /* check if the row is "complete" */ 1085 if (tr.childNodes.length == 2*checkBoxesPerRow) 1086 { 1087 tbody.appendChild(tr); 1088 } 1089 else 1090 { 1091 if (i == (permissionListORG.length - 1)) 1092 { 1093 tr.appendChild(document.createElement("TD")); 1094 tr.appendChild(document.createElement("TD")); 1095 tbody.appendChild(tr); 1096 } 1097 } 1098 } 1099 tr = document.createElement("TR"); 1100 td = document.createElement("TD"); 1101 td.colSpan = 4; 1102 td.align = 'center'; 1103 var toggleButton = document.createElement("BUTTON"); 1104 toggleButton.onclick = toggleCheckboxesORG; 1105 toggleButton.innerHTML = 'Marcar/Desmarcar Tudo'; 1106 1107 td.appendChild(toggleButton); 1108 tr.appendChild(td); 1109 tbody.appendChild(tr); 1110 table.appendChild(tbody); 1111 1112 /* submit button */ 1113 var button = document.createElement("BUTTON"); 1114 button.onclick = function() { changeUserLevelORG(); }; 1115 button.innerHTML = "Salvar"; 1116 1117 tr = document.createElement("TR"); 1118 td = document.createElement("TD"); 1119 td.appendChild(table); 1120 tr.appendChild(td); 1121 to_out.appendChild(tr); 1122 1123 tr = document.createElement("TR"); 1124 td = document.createElement("TD"); 1125 td.setAttribute("align", "right"); 1126 td.appendChild(button); 1127 tr.appendChild(td); 1128 to_out.appendChild(tr); 1129 1130 tb_out.appendChild(to_out); 1131 userLevelContainer.appendChild(tb_out); 1132 }; 1133 1134 cExecute ("$this.bo_adminaccess.get_organogram_admin_level", loadLevelHandler, "pid=" + pid + "&uid=" + uid); 1135 } 1136 1028 1137 /* change the user level */ 1029 1138 function changeUserLevel() … … 1055 1164 } 1056 1165 1166 /* change the user level */ 1167 function changeUserLevelORG() 1168 { 1169 /* required parameters */ 1170 var pid = document.getElementById('sel_org').value; 1171 var uid = document.getElementById('sel_org_admin').value; 1172 1173 /* check for error (ajax callback) */ 1174 var changeUserLevelHandler = function(data) 1175 { 1176 if (typeof(data) == "string") 1177 write_errors(data); 1178 else 1179 write_msg('As permissões foram salvas'); 1180 }; 1181 1182 /* generate the new permission string */ 1183 var newPermission = ""; 1184 for (var i = 0; i < permissionListORG.length; i++) 1185 { 1186 var cb = document.getElementById("cb_" + permissionListORG[i]['value']); 1187 newPermission += permissionListORG[i]['value'] + "=" + ((cb.checked) ? "1" : "0") + "_"; 1188 } 1189 newPermission = newPermission.substring(0, newPermission.length-1); 1190 1191 /* call ajax */ 1192 cExecute ("$this.bo_adminaccess.set_organogram_admin_level", changeUserLevelHandler, "pid=" + pid + "&uid=" + uid + "&np=" + newPermission); 1193 } 1194 1057 1195 function toggleCheckboxes() 1058 1196 { … … 1060 1198 for (var i = 0; i < permissionList.length; i++) 1061 1199 document.getElementById('cb_' + permissionList[i]['value']).checked = value; 1200 } 1201 1202 function toggleCheckboxesORG() 1203 { 1204 var value = !document.getElementById('cb_' + permissionListORG[0]['value']).checked; 1205 for (var i = 0; i < permissionListORG.length; i++) 1206 document.getElementById('cb_' + permissionListORG[i]['value']).checked = value; 1062 1207 } 1063 1208 -
branches/2.2/workflow/js/adminaccess/main.js
r795 r3255 28 28 permissionList[10]['name'] = "Disparar e-mails"; 29 29 permissionList[10]['value'] = 10; 30 31 var permissionListORG = new Array(); 32 for (var i = 0; i < 2; i++) 33 permissionListORG[i] = new Array(); 34 permissionListORG[0]['name'] = "Administrar Organograma"; 35 permissionListORG[0]['value'] = 0; 36 permissionListORG[1]['name'] = "Visualizar Telefones Pessoais"; 37 permissionListORG[1]['value'] = 1; 30 38 31 39 function show_window(titulo,div,width,height) -
branches/2.2/workflow/setup/tables_update.inc.php
r3167 r3255 194 194 /* adding primary key without the column removed */ 195 195 $GLOBALS['phpgw']->ADOdb->query('ALTER TABLE egw_wf_interinstance_relations ADD CONSTRAINT egw_wf_interinstance_relations_pkey PRIMARY KEY (wf_parent_instance_id, wf_child_instance_id)'); 196 197 /* Update the organogram level of administration off all users from 0 to 1. */ 198 $GLOBALS['phpgw']->ADOdb->query('UPDATE egw_wf_admin_access set nivel = 1 WHERE tipo = \'ORG\' and nivel = 0'); 196 199 } 197 200
Note: See TracChangeset
for help on using the changeset viewer.