[2] | 1 | <?php |
---|
| 2 | /**********************************************************************************\ |
---|
| 3 | * Expresso Administração * |
---|
| 4 | * by Joao Alfredo Knopik Junior (joao.alfredo@gmail.com, jakjr@celepar.pr.gov.br) * |
---|
| 5 | * --------------------------------------------------------------------------------* |
---|
| 6 | * This program is free software; you can redistribute it and/or modify it * |
---|
| 7 | * under the terms of the GNU General Public License as published by the * |
---|
| 8 | * Free Software Foundation; either version 2 of the License, or (at your * |
---|
| 9 | * option) any later version. * |
---|
| 10 | \**********************************************************************************/ |
---|
| 11 | |
---|
| 12 | include_once('class.ldap_functions.inc.php'); |
---|
| 13 | include_once('class.db_functions.inc.php'); |
---|
| 14 | include_once('class.imap_functions.inc.php'); |
---|
| 15 | include_once('class.functions.inc.php'); |
---|
| 16 | |
---|
| 17 | class group |
---|
| 18 | { |
---|
| 19 | var $ldap_functions; |
---|
| 20 | var $db_functions; |
---|
| 21 | var $imap_functions; |
---|
| 22 | var $functions; |
---|
| 23 | var $current_config; |
---|
| 24 | |
---|
| 25 | |
---|
| 26 | function group() |
---|
| 27 | { |
---|
| 28 | $this->ldap_functions = new ldap_functions; |
---|
| 29 | $this->db_functions = new db_functions; |
---|
| 30 | $this->imap_functions = new imap_functions; |
---|
| 31 | $this->functions = new functions; |
---|
| 32 | $this->current_config = $_SESSION['phpgw_info']['expresso']['expressoAdmin']; |
---|
| 33 | } |
---|
| 34 | |
---|
| 35 | function validate_fields($params) |
---|
| 36 | { |
---|
| 37 | return $this->ldap_functions->validate_fields_group($params); |
---|
| 38 | } |
---|
| 39 | |
---|
| 40 | function create($params) |
---|
| 41 | { |
---|
| 42 | // Verifica o acesso do gerente |
---|
| 43 | if (!$this->functions->check_acl($_SESSION['phpgw_session']['session_lid'], 'add_groups')) |
---|
| 44 | { |
---|
| 45 | $return['status'] = false; |
---|
| 46 | $return['msg'] = 'Você não tem acesso para criar novos grupos.'; |
---|
| 47 | return $return; |
---|
| 48 | } |
---|
| 49 | |
---|
| 50 | $return['status'] = true; |
---|
| 51 | |
---|
| 52 | //Retira os uids duplicados se existir |
---|
| 53 | $array_tmp = array(); |
---|
[317] | 54 | $array_tmp = @array_unique($params['members']); |
---|
[2] | 55 | $params['members'] = $array_tmp; |
---|
[64] | 56 | |
---|
| 57 | // Leio o ID a ser usado na criação do objecto. |
---|
| 58 | $next_id = ($this->db_functions->get_next_id('groups')); |
---|
| 59 | if ((!is_numeric($next_id['id'])) || (!$next_id['status'])) |
---|
| 60 | { |
---|
| 61 | $return['status'] = false; |
---|
| 62 | $return['msg'] = "Problemas obtendo ID do usuário.\n" . $id['msg']; |
---|
| 63 | return $return; |
---|
| 64 | } |
---|
| 65 | else |
---|
| 66 | { |
---|
| 67 | $id = $next_id['id']; |
---|
| 68 | } |
---|
[2] | 69 | |
---|
| 70 | // Cria array para incluir no LDAP |
---|
| 71 | $dn = 'cn=' . $params['cn'] . ',' . $params['context']; |
---|
| 72 | |
---|
| 73 | $group_info = array(); |
---|
| 74 | $group_info['cn'] = $params['cn']; |
---|
| 75 | $group_info['description'] = $params['description']; |
---|
| 76 | $group_info['gidNumber'] = $id; |
---|
| 77 | $group_info['objectClass'][] = 'top'; |
---|
| 78 | $group_info['objectClass'][] = 'posixGroup'; |
---|
| 79 | $group_info['objectClass'][] = 'phpgwAccount'; |
---|
| 80 | $group_info['phpgwAccountExpires'] = '-1'; |
---|
| 81 | $group_info['phpgwAccountType'] = 'g'; |
---|
| 82 | $group_info['userPassword'] = ''; |
---|
| 83 | |
---|
[46] | 84 | // E-mail for groups |
---|
| 85 | if ($params['email'] != '') |
---|
| 86 | $group_info['mail'] = $params['email']; |
---|
| 87 | |
---|
[317] | 88 | if ( (count($params['members'])) && (is_array($params['members'])) ) |
---|
[2] | 89 | { |
---|
| 90 | foreach ($params['members'] as $index => $uidnumber) |
---|
| 91 | { |
---|
| 92 | $uid = $this->ldap_functions->uidnumber2uid($uidnumber); |
---|
| 93 | $group_info['memberuid'][] = $uid; |
---|
| 94 | |
---|
| 95 | // Chama funcao para incluir os uidnumbers dos usuarios no grupo |
---|
| 96 | $result = $this->db_functions->add_user2group($id, $uidnumber); |
---|
| 97 | |
---|
| 98 | $this->db_functions->write_log("Adicionado usuario $uid ao grupo ".$group_info['cn']." no momento da criação",$dn,$uidnumber,'',''); |
---|
| 99 | } |
---|
| 100 | } |
---|
| 101 | |
---|
| 102 | // Suporte ao SAMBA |
---|
| 103 | if (($this->current_config['expressoAdmin_samba_support'] == 'true') && ($params['use_attrs_samba'] == 'on')) |
---|
| 104 | { |
---|
| 105 | $group_info['objectClass'][] = 'sambaGroupMapping'; |
---|
[46] | 106 | $group_info['sambaSID'] = $params['sambasid'] . '-' . (($id * 2) + 1001); |
---|
[2] | 107 | $group_info['sambaGroupType'] = '2'; |
---|
| 108 | } |
---|
| 109 | |
---|
[23] | 110 | // ADD ATTRIBUTES |
---|
| 111 | if ($params['phpgwaccountvisible'] == 'on') |
---|
| 112 | { |
---|
| 113 | $group_info['phpgwaccountvisible'] = '-1'; |
---|
| 114 | } |
---|
| 115 | |
---|
[2] | 116 | $result = $this->ldap_functions->ldap_add_entry($dn, $group_info); |
---|
| 117 | if (!$result['status']) |
---|
| 118 | { |
---|
| 119 | $return['status'] = false; |
---|
[317] | 120 | if ($result['error_number'] == '65') |
---|
| 121 | $return['msg'] .= "Não foi possível criar este grupo pois os schemas do servidor LDAP estão desatualizados.\n" . |
---|
| 122 | "O Administrador deve atualizar o diretório /etc/ldap/schema/ e re-inicializar o ldap.\n". |
---|
| 123 | "Uma versão atualizada deste arquivo pode ser encontrada no site:\n" . |
---|
| 124 | "www.expressolivre.org -> Downloads -> schema.tgz"; |
---|
| 125 | else |
---|
| 126 | $return['msg'] .= $result['msg']; |
---|
[2] | 127 | } |
---|
| 128 | |
---|
| 129 | // Chama funcao para incluir os aplicativos ao grupo |
---|
| 130 | $result = $this->db_functions->add_id2apps($id, $params['apps']); |
---|
| 131 | if (!$result['status']) |
---|
| 132 | { |
---|
| 133 | $return['status'] = false; |
---|
| 134 | $return['msg'] .= $result['msg']; |
---|
| 135 | } |
---|
| 136 | |
---|
| 137 | if ($return['status'] == true) |
---|
| 138 | { |
---|
| 139 | $this->db_functions->write_log("Criado grupo de usuários $dn",'',$dn,'',''); |
---|
| 140 | } |
---|
| 141 | |
---|
| 142 | return $return; |
---|
| 143 | } |
---|
| 144 | |
---|
| 145 | function save($new_values) |
---|
| 146 | { |
---|
| 147 | // Verifica o acesso do gerente |
---|
| 148 | if (!$this->functions->check_acl($_SESSION['phpgw_session']['session_lid'], 'edit_groups')) |
---|
| 149 | { |
---|
| 150 | $return['status'] = false; |
---|
| 151 | $return['msg'] = 'Você não tem acesso para editar grupos.'; |
---|
| 152 | return $return; |
---|
| 153 | } |
---|
| 154 | |
---|
| 155 | $return['status'] = true; |
---|
| 156 | |
---|
| 157 | //Retira os uids duplicados se existir |
---|
| 158 | $array_tmp = array(); |
---|
| 159 | $array_tmp = array_unique($new_values['members']); |
---|
| 160 | $new_values['members'] = $array_tmp; |
---|
| 161 | |
---|
| 162 | $old_values = $this->get_info($new_values['gidnumber'], $new_values['manager_context']); |
---|
| 163 | $diff = array_diff($new_values, $old_values); |
---|
| 164 | |
---|
| 165 | $dn = 'cn=' . $old_values['cn'] . ',' . $old_values['context']; |
---|
| 166 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
---|
| 167 | // RENAME |
---|
| 168 | if ($diff['context'] || $diff['cn']) |
---|
| 169 | { |
---|
[355] | 170 | if ( (strcasecmp($old_values['cn'], $new_values['cn']) != 0) || (strcasecmp($old_values['context'], $new_values['context']) != 0) ) |
---|
[2] | 171 | { |
---|
[355] | 172 | $newrdn = 'cn=' . $new_values['cn']; |
---|
| 173 | $newparent = $new_values['context']; |
---|
| 174 | $result = $this->ldap_functions->change_user_context($dn, $newrdn, $newparent); |
---|
| 175 | if (!$result['status']) |
---|
| 176 | { |
---|
| 177 | $return['status'] = false; |
---|
| 178 | $return['msg'] .= $result['msg']; |
---|
| 179 | } |
---|
| 180 | else |
---|
| 181 | { |
---|
| 182 | $dn = $newrdn . ',' . $newparent; |
---|
| 183 | $this->db_functions->write_log('Renomeado grupo de usuários de '.$old_values['cn']." para $dn.",'',$dn,$old_values['cn'],''); |
---|
| 184 | } |
---|
[2] | 185 | } |
---|
| 186 | } |
---|
| 187 | |
---|
[46] | 188 | $ldap_mod_replace = array(); |
---|
[2] | 189 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
---|
[33] | 190 | // REPLACE SAMBASID OF SAMBA |
---|
[46] | 191 | if ( ($this->current_config['expressoAdmin_samba_support'] == 'true') && ($diff['sambasid']) && ($old_values['sambasid'])) |
---|
[33] | 192 | { |
---|
[46] | 193 | $ldap_mod_replace['sambasid'] = $new_values['sambasid'] . '-' . ((2 * $new_values['gidnumber'])+1001); |
---|
| 194 | $this->db_functions->write_log("Alterado dominio samba do grupo $dn para " . $new_values['sambasid'],'',$dn,'',''); |
---|
[33] | 195 | } |
---|
| 196 | |
---|
| 197 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
---|
[2] | 198 | // REPLACE DESCRIPTION |
---|
| 199 | if ($new_values['description'] != $old_values['description']) |
---|
| 200 | { |
---|
| 201 | $ldap_mod_replace['description'] = $new_values['description']; |
---|
[33] | 202 | $this->db_functions->write_log("Modificado descrição do grupo $dn",'',$dn,'',''); |
---|
| 203 | } |
---|
| 204 | |
---|
| 205 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
---|
[46] | 206 | // REPLACE E-Mail |
---|
| 207 | if ((($old_values['email']) && ($diff['email'])) && |
---|
| 208 | $this->functions->check_acl($_SESSION['phpgw_session']['session_lid'],'edit_email_groups')) |
---|
| 209 | { |
---|
| 210 | $ldap_mod_replace['mail'] = $new_values['email']; |
---|
| 211 | $this->db_functions->write_log("Modificado E-Mail do grupo $dn",'',$dn,'',''); |
---|
| 212 | } |
---|
| 213 | |
---|
| 214 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
---|
| 215 | // CALL LDAP_REPLACE FUNCTION |
---|
[33] | 216 | if (count($ldap_mod_replace)) |
---|
| 217 | { |
---|
[2] | 218 | $result = $this->ldap_functions->replace_user_attributes($dn, $ldap_mod_replace); |
---|
| 219 | if (!$result['status']) |
---|
| 220 | { |
---|
| 221 | $return['status'] = false; |
---|
[317] | 222 | if ($result['error_number'] == '65') |
---|
| 223 | $return['msg'] .= "Não foi possível salvar alguns atributos deste grupo pois os schemas do servidor LDAP estão desatualizados.\n" . |
---|
| 224 | "O Administrador deve atualizar o diretório /etc/ldap/schema/ e re-inicializar o ldap.\n". |
---|
| 225 | "Uma versão atualizada deste arquivo pode ser encontrada no site:\n" . |
---|
| 226 | "www.expressolivre.org -> Downloads -> schema.tgz"; |
---|
| 227 | else |
---|
| 228 | $return['msg'] .= $result['msg']; |
---|
[2] | 229 | } |
---|
[33] | 230 | } |
---|
[2] | 231 | |
---|
| 232 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
---|
| 233 | // REMOVE ATTRS OF SAMBA |
---|
| 234 | if (($this->current_config['expressoAdmin_samba_support'] == 'true') && ($old_values['sambaGroup']) && ($new_values['use_attrs_samba'] != 'on')) |
---|
| 235 | { |
---|
| 236 | $ldap_remove['objectclass'] = 'sambaGroupMapping'; |
---|
| 237 | $ldap_remove['sambagrouptype'] = array(); |
---|
| 238 | $ldap_remove['sambaSID'] = array(); |
---|
| 239 | |
---|
| 240 | $result = $this->ldap_functions->remove_user_attributes($dn, $ldap_remove); |
---|
| 241 | if (!$result['status']) |
---|
| 242 | { |
---|
| 243 | $return['status'] = false; |
---|
| 244 | $return['msg'] .= $result['msg']; |
---|
| 245 | } |
---|
| 246 | else |
---|
| 247 | $this->db_functions->write_log("Removido atributos samba do grupo $dn",'',$dn,'',''); |
---|
| 248 | } |
---|
| 249 | |
---|
| 250 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
---|
| 251 | // ADD ATTRS OF SAMBA |
---|
| 252 | if (($this->current_config['expressoAdmin_samba_support'] == 'true') && (!$old_values['sambaGroup']) && ($new_values['use_attrs_samba'] == 'on')) |
---|
| 253 | { |
---|
| 254 | //Verifica se o binario para criar as senhas do samba exite. |
---|
| 255 | if (!is_file('/home/expressolivre/mkntpwd')) |
---|
| 256 | { |
---|
| 257 | $return['status'] = false; |
---|
| 258 | $return['msg'] .= "O arquivo binário /home/expressolivre/mkntpwd não exite.\\nEle é necessário para a criação das senhas usadas pelo SAMBA.\\nInforme o administrador ExpressoLivre sobre isto.\\n"; |
---|
| 259 | } |
---|
| 260 | else |
---|
| 261 | { |
---|
| 262 | $ldap_add['objectClass'][] = 'sambaGroupMapping'; |
---|
| 263 | $ldap_add['sambagrouptype'] = '2'; |
---|
[46] | 264 | $ldap_add['sambasid'] = $new_values['sambasid'] . '-' . ((2 * $new_values['gidnumber'])+1001); |
---|
[2] | 265 | |
---|
| 266 | $result = $this->ldap_functions->add_user_attributes($dn, $ldap_add); |
---|
| 267 | if (!$result['status']) |
---|
| 268 | { |
---|
| 269 | $return['status'] = false; |
---|
| 270 | $return['msg'] .= $result['msg']; |
---|
| 271 | } |
---|
| 272 | else |
---|
[23] | 273 | $this->db_functions->write_log("Adicionado atributos samba ao grupo $dn",'','','',''); |
---|
[2] | 274 | } |
---|
| 275 | } |
---|
[33] | 276 | |
---|
[2] | 277 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
---|
[23] | 278 | // ADD ATTRIBUTES |
---|
[46] | 279 | $ldap_add = array(); |
---|
[23] | 280 | if (($new_values['phpgwaccountvisible'] == 'on') && ($old_values['phpgwaccountvisible'] != '-1')) |
---|
| 281 | { |
---|
| 282 | $ldap_add['phpgwaccountvisible'] = '-1'; |
---|
[46] | 283 | $this->db_functions->write_log("Adicionado atributo phpgwaccountvisible ao grupo $dn",'','','',''); |
---|
| 284 | } |
---|
| 285 | if ((($new_values['email']) && (!$old_values['email'])) && |
---|
| 286 | $this->functions->check_acl($_SESSION['phpgw_session']['session_lid'],'edit_email_groups')) |
---|
| 287 | { |
---|
| 288 | $ldap_add['mail'] = $new_values['email']; |
---|
| 289 | $this->db_functions->write_log("Adicionado atributo mail ao grupo $dn",'','','',''); |
---|
| 290 | } |
---|
| 291 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
---|
| 292 | // CALL LDAP_ADD FUNCTION |
---|
| 293 | if (count($ldap_add)) |
---|
| 294 | { |
---|
[23] | 295 | $result = $this->ldap_functions->add_user_attributes($dn, $ldap_add); |
---|
[317] | 296 | |
---|
[23] | 297 | if (!$result['status']) |
---|
| 298 | { |
---|
| 299 | $return['status'] = false; |
---|
[317] | 300 | if ($result['error_number'] == '65') |
---|
| 301 | $return['msg'] .= "Não foi possível adicionar alguns atributos deste gruupo pois os schemas do servidor LDAP estão desatualizados.\n" . |
---|
| 302 | "O Administrador deve atualizar o diretório /etc/ldap/schema/ e re-inicializar o ldap.\n". |
---|
| 303 | "Uma versão atualizada deste arquivo pode ser encontrada no site:\n" . |
---|
| 304 | "www.expressolivre.org -> Downloads -> schema.tgz"; |
---|
| 305 | else |
---|
| 306 | $return['msg'] .= $result['msg']; |
---|
[23] | 307 | } |
---|
| 308 | } |
---|
[46] | 309 | |
---|
| 310 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
---|
[23] | 311 | // REMOVE ATTRIBUTES |
---|
[46] | 312 | $ldap_remove = array(); |
---|
[23] | 313 | if (($new_values['phpgwaccountvisible'] != 'on') && ($old_values['phpgwaccountvisible'] == '-1')) |
---|
| 314 | { |
---|
| 315 | $ldap_remove['phpgwaccountvisible'] = array(); |
---|
[46] | 316 | $this->db_functions->write_log("Removido atributo phpgwaccountvisible do grupo $dn",'','','',''); |
---|
| 317 | } |
---|
| 318 | if (((!$new_values['email']) && ($old_values['email'])) && |
---|
| 319 | $this->functions->check_acl($_SESSION['phpgw_session']['session_lid'],'edit_email_groups')) |
---|
| 320 | { |
---|
| 321 | $ldap_remove['mail'] = array(); |
---|
| 322 | $this->db_functions->write_log("Removido atributo mail do grupo $dn",'','','',''); |
---|
| 323 | } |
---|
| 324 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
---|
| 325 | // CALL LDAP_REMOVED FUNCTION |
---|
| 326 | if (count($ldap_remove)) |
---|
| 327 | { |
---|
[23] | 328 | $result = $this->ldap_functions->remove_user_attributes($dn, $ldap_remove); |
---|
| 329 | if (!$result['status']) |
---|
| 330 | { |
---|
| 331 | $return['status'] = false; |
---|
| 332 | $return['msg'] .= $result['msg']; |
---|
| 333 | } |
---|
| 334 | } |
---|
| 335 | |
---|
| 336 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
---|
[2] | 337 | // USERS |
---|
| 338 | |
---|
| 339 | if (!$new_values['members']) |
---|
| 340 | $new_values['members'] = array(); |
---|
| 341 | if (!$old_values['members']) |
---|
| 342 | $old_values['members'] = array(); |
---|
| 343 | |
---|
| 344 | $add_users = array_diff($new_values['members'], $old_values['members']); |
---|
| 345 | $remove_users = array_diff($old_values['members'], $new_values['members']); |
---|
| 346 | |
---|
| 347 | if (count($add_users)>0) |
---|
| 348 | { |
---|
| 349 | $array_memberUids_add = array(); |
---|
| 350 | foreach($add_users as $uidnumber) |
---|
| 351 | { |
---|
[86] | 352 | if (is_numeric($uidnumber) && ($uidnumber != -1)) |
---|
[2] | 353 | { |
---|
| 354 | $this->db_functions->add_user2group($new_values['gidnumber'], $uidnumber); |
---|
| 355 | $user = $this->ldap_functions->uidnumber2uid($uidnumber); |
---|
| 356 | $array_memberUids_add[] = $user; |
---|
| 357 | $this->db_functions->write_log("Adicionado usuário $user ao grupo $dn.",$dn,'','',''); |
---|
| 358 | } |
---|
| 359 | else |
---|
| 360 | { |
---|
| 361 | // O memberUID existe no grupo, mas o usuário não existe no ldap |
---|
| 362 | $this->ldap_functions->remove_user2group($new_values['gidnumber'], $uidnumber); |
---|
| 363 | } |
---|
| 364 | } |
---|
| 365 | $this->ldap_functions->add_user2group($new_values['gidnumber'], $array_memberUids_add); |
---|
| 366 | } |
---|
| 367 | if (count($remove_users)>0) |
---|
| 368 | { |
---|
| 369 | $array_memberUids_remove = array(); |
---|
| 370 | foreach($remove_users as $uidnumber) |
---|
| 371 | { |
---|
[86] | 372 | if ($uidnumber != -1) |
---|
| 373 | { |
---|
| 374 | $this->db_functions->remove_user2group($new_values['gidnumber'], $uidnumber); |
---|
| 375 | $user = $this->ldap_functions->uidnumber2uid($uidnumber); |
---|
| 376 | $array_memberUids_remove[] = $user; |
---|
| 377 | $this->db_functions->write_log("Removido usuário $user do grupo $dn.",$dn,'','',''); |
---|
| 378 | } |
---|
[2] | 379 | } |
---|
| 380 | $this->ldap_functions->remove_user2group($new_values['gidnumber'], $array_memberUids_remove); |
---|
| 381 | } |
---|
| 382 | |
---|
| 383 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
---|
| 384 | // APPS |
---|
| 385 | $new_values2 = array(); |
---|
| 386 | $old_values2 = array(); |
---|
| 387 | if (count($new_values['apps'])>0) |
---|
| 388 | { |
---|
| 389 | foreach ($new_values['apps'] as $app=>$tmp) |
---|
| 390 | { |
---|
| 391 | $new_values2[] = $app; |
---|
| 392 | } |
---|
| 393 | } |
---|
| 394 | if (count($old_values['apps'])>0) |
---|
| 395 | { |
---|
| 396 | foreach ($old_values['apps'] as $app=>$tmp) |
---|
| 397 | { |
---|
| 398 | $old_values2[] = $app; |
---|
| 399 | } |
---|
| 400 | } |
---|
[9] | 401 | |
---|
| 402 | $add_apps = array_flip(array_diff($new_values2, $old_values2)); |
---|
| 403 | $remove_apps = array_flip(array_diff($old_values2, $new_values2)); |
---|
[2] | 404 | |
---|
| 405 | if (count($add_apps)>0) |
---|
| 406 | { |
---|
[9] | 407 | $this->db_functions->add_id2apps($new_values['gidnumber'], $add_apps); |
---|
| 408 | |
---|
| 409 | foreach ($add_apps as $app => $index) |
---|
| 410 | $this->db_functions->write_log("Adicionado aplicativo $app ao grupo $dn",'',$dn,'',''); |
---|
[2] | 411 | } |
---|
[9] | 412 | |
---|
[2] | 413 | if (count($remove_apps)>0) |
---|
| 414 | { |
---|
[9] | 415 | //Verifica se o gerente tem acesso a aplicação antes de remove-la do usuario. |
---|
| 416 | $manager_apps = $this->db_functions->get_apps($_SESSION['phpgw_session']['session_lid']); |
---|
| 417 | |
---|
| 418 | foreach ($remove_apps as $app => $app_index) |
---|
| 419 | { |
---|
| 420 | if ($manager_apps[$app] == 'run') |
---|
| 421 | $remove_apps2[$app] = $app_index; |
---|
| 422 | } |
---|
| 423 | $this->db_functions->remove_id2apps($new_values['gidnumber'], $remove_apps2); |
---|
| 424 | |
---|
| 425 | foreach ($remove_apps2 as $app => $access) |
---|
| 426 | $this->db_functions->write_log("Removido aplicativo $app do grupo $dn",'',$dn,'',''); |
---|
[2] | 427 | } |
---|
| 428 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
---|
| 429 | |
---|
| 430 | return $return; |
---|
| 431 | } |
---|
| 432 | |
---|
| 433 | |
---|
[64] | 434 | function get_info($gidnumber) |
---|
[2] | 435 | { |
---|
[64] | 436 | $group_info_ldap = $this->ldap_functions->get_group_info($gidnumber); |
---|
[2] | 437 | $group_info_db = $this->db_functions->get_group_info($gidnumber); |
---|
| 438 | |
---|
| 439 | $group_info = array_merge($group_info_ldap, $group_info_db); |
---|
| 440 | return $group_info; |
---|
| 441 | } |
---|
| 442 | |
---|
| 443 | function delete($params) |
---|
| 444 | { |
---|
| 445 | // Verifica o acesso do gerente |
---|
| 446 | if (!$this->functions->check_acl($_SESSION['phpgw_session']['session_lid'], 'delete_groups')) |
---|
| 447 | { |
---|
| 448 | $return['status'] = false; |
---|
| 449 | $return['msg'] = 'Você não tem acesso para excluir grupos.'; |
---|
| 450 | return $return; |
---|
| 451 | } |
---|
| 452 | |
---|
| 453 | $return['status'] = true; |
---|
| 454 | |
---|
| 455 | $gidnumber = $params['gidnumber']; |
---|
| 456 | $cn = $params['cn']; |
---|
| 457 | |
---|
| 458 | //LDAP |
---|
| 459 | $result_ldap = $this->ldap_functions->delete_group($gidnumber); |
---|
| 460 | if (!$result_ldap['status']) |
---|
| 461 | { |
---|
| 462 | $return['status'] = false; |
---|
| 463 | $return['msg'] .= $result_ldap['msg']; |
---|
| 464 | } |
---|
| 465 | |
---|
| 466 | //DB |
---|
| 467 | $result_db = $this->db_functions->delete_group($gidnumber); |
---|
| 468 | if (!$result_db['status']) |
---|
| 469 | { |
---|
| 470 | $return['status'] = false; |
---|
| 471 | $return['msg'] .= $result_ldap['msg']; |
---|
| 472 | } |
---|
| 473 | |
---|
| 474 | if ($return['status'] == true) |
---|
| 475 | { |
---|
| 476 | $this->db_functions->write_log("Deletado grupo de usuários $cn",'',$cn,'',''); |
---|
| 477 | } |
---|
| 478 | |
---|
| 479 | return $return; |
---|
| 480 | } |
---|
| 481 | |
---|
| 482 | } |
---|
| 483 | ?> |
---|