Changeset 3255


Ignore:
Timestamp:
09/15/10 17:06:46 (14 years ago)
Author:
pereira.jair
Message:

Ticket #1186 - Alterado modulo administrativo do organograma p/ definir diferentes niveis de usuarios.

Location:
branches/2.2/workflow
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2/workflow/inc/class.WorkflowLDAP.inc.php

    r3221 r3255  
    562562                        ); 
    563563 
    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                         
    565569                        unset($result['count']); 
    566570                } 
  • branches/2.2/workflow/inc/class.bo_adminaccess.inc.php

    r3167 r3255  
    8585                return $this->so->getUserNames($admins_id); 
    8686        } 
     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        } 
    8799 
    88100        /** 
     
    221233                return null; 
    222234        } 
     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        } 
    223261 
    224262        /** 
  • branches/2.2/workflow/inc/class.so_adminaccess.inc.php

    r3167 r3255  
    184184        function get_granted_organograms($user_id) 
    185185        { 
    186                 return $this->getUserPermissions('ORG', $user_id); 
     186                return $this->getUserPermissions('ORG', $user_id, 0); 
    187187        } 
    188188 
     
    311311        * @param string $type type of resource 
    312312        * @param integer $uid user id 
     313        * @param requiredLevel Level Required to Access. 
    313314        * @return bool 
    314315        * @access public 
    315316        */ 
    316         function getUserPermissions($type, $uid) 
     317        function getUserPermissions($type, $uid, $requiredLevel = null) 
    317318        { 
    318319                $query = " 
    319320                        SELECT 
    320                                 numvalue 
     321                                numvalue, 
     322                                nivel 
    321323                        FROM 
    322324                                egw_wf_admin_access 
     
    329331                $output = array(); 
    330332                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                        } 
    333344 
    334345                return $output; 
     
    342353         * @return array 
    343354         */ 
    344         function getUserGroupPermissions($type, $uid) 
     355        function getUserGroupPermissions($type, $uid, $requiredLevel = null) 
    345356        { 
    346357                $groups = galaxia_retrieve_user_groups($uid); 
     
    361372                $output = array(); 
    362373                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                        } 
    365385 
    366386                return $output; 
     
    376396        function checkUserAccessToType($type, $uid) 
    377397        { 
    378                 return (count($this->getUserPermissions($type, $uid)) > 0); 
     398                return (count($this->getUserPermissions($type, $uid,0)) > 0); 
    379399        } 
    380400        /** 
     
    414434 
    415435                $result = $this->db->query($query, array($type, $uid, $numvalue)); 
     436                 
    416437                $row = $result->fetchRow(); 
    417438 
    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                } 
    420443                else 
    421444                        return false; 
     
    491514        } 
    492515        /** 
    493         * Setaa o nivel de administracao 
     516        * Seta o nivel de administracao 
    494517        * 
    495518        * @param string  $type tipo de recurso 
     
    505528                        $level = $this->_permissionListToNumber($level); 
    506529 
    507                 $query = " 
    508                         UPDATE egw_wf_admin_access 
     530                $query = "UPDATE egw_wf_admin_access 
    509531                        SET 
    510532                                nivel = ? 
     
    513535                                (tipo = ?) AND 
    514536                                (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; 
    516540        } 
    517541 
  • branches/2.2/workflow/inc/class.so_orgchart.inc.php

    r3225 r3255  
    145145                else 
    146146                { 
    147                         $organizations = $this->acl->getUserPermissions("ORG", $this->userID); 
     147                        $organizations = $this->acl->getUserPermissions("ORG", $this->userID, 0); 
    148148                        $organizations[] = -1; 
    149149                        $query = "SELECT organizacao_id, nome, descricao, ativa, url_imagem, sitio FROM organizacao WHERE (organizacao_id IN (" . implode(',', $organizations)  . ")) ORDER BY nome"; 
     
    11261126                $mobile         = ''; 
    11271127                $homePhone  = ''; 
    1128  
     1128                 
    11291129                /* 
    11301130                 * Check if the current user can view the mobile and homePhone of the employee 
     
    11321132                 * that's being retrieved 
    11331133                 */ 
    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)) { 
    11351136                        $mobile         = $employeeEntry['mobile']; 
    11361137                        $homePhone      = $employeeEntry['homephone']; 
  • branches/2.2/workflow/inc/class.ui_orgchart.inc.php

    r3167 r3255  
    5050 
    5151                $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); 
    5353 
    5454                if (!($isAdmin || $isOrgchartManager)) 
  • branches/2.2/workflow/inc/hook_sidebox_menu.inc.php

    r3167 r3255  
    3838 
    3939        /* check if the user can administrate the orgchart */ 
    40         if ($workflowACL->checkUserGroupAccessToType('ORG', $userID) || $isWorkflowAdmin) 
     40        if ($workflowACL->checkUserGroupAccessToType('ORG', $userID,0) || $isWorkflowAdmin) 
    4141                $file['Organization Chart']     = $GLOBALS['phpgw']->link('/index.php','menuaction=workflow.ui_orgchart.draw'); 
    4242 
  • branches/2.2/workflow/js/adminaccess/control_folder.js

    r795 r3255  
    357357        se.setAttribute('size','10'); 
    358358        se.setAttribute('id','sel_org_admin'); 
     359        se.onchange = function() { loadLevelORG();  }; 
    359360        se.style.width = input_width; 
    360361        se.style.height = input_height; 
     
    426427        tr.appendChild(td); 
    427428 
     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); 
    428438        to.appendChild(tr); 
    429439        tb.appendChild(to); 
     
    10261036} 
    10271037 
     1038/* construct the user level interface */ 
     1039function 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 
    10281137/* change the user level */ 
    10291138function changeUserLevel() 
     
    10551164} 
    10561165 
     1166/* change the user level */ 
     1167function 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 
    10571195function toggleCheckboxes() 
    10581196{ 
     
    10601198        for (var i = 0; i < permissionList.length; i++) 
    10611199                document.getElementById('cb_' + permissionList[i]['value']).checked = value; 
     1200} 
     1201 
     1202function 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; 
    10621207} 
    10631208 
  • branches/2.2/workflow/js/adminaccess/main.js

    r795 r3255  
    2828permissionList[10]['name'] = "Disparar e-mails"; 
    2929permissionList[10]['value'] = 10; 
     30 
     31var permissionListORG = new Array(); 
     32for (var i = 0; i < 2; i++) 
     33        permissionListORG[i] = new Array(); 
     34permissionListORG[0]['name'] = "Administrar Organograma"; 
     35permissionListORG[0]['value'] = 0; 
     36permissionListORG[1]['name'] = "Visualizar Telefones Pessoais"; 
     37permissionListORG[1]['value'] = 1; 
    3038 
    3139function show_window(titulo,div,width,height) 
  • branches/2.2/workflow/setup/tables_update.inc.php

    r3167 r3255  
    194194                        /* adding primary key without the column removed */ 
    195195                        $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'); 
    196199                } 
    197200 
Note: See TracChangeset for help on using the changeset viewer.