Changeset 6553
- Timestamp:
- 06/20/12 12:31:51 (11 years ago)
- Location:
- trunk/expressoAdmin1_2
- Files:
-
- 1 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/expressoAdmin1_2/inc/class.bosectors.inc.php
r5133 r6553 47 47 $sector_info['objectClass'][0] = 'top'; 48 48 $sector_info['objectClass'][1] = 'organizationalUnit'; 49 50 /*Insere as informações sobre quota total por usuários e por gigabytes de espaço em disco 51 Se não vierem os dados, ele coloca 0 (Caso não exista controle de cota). 52 */ 53 $sector_info['diskQuota'] = isset($_POST['disk_quota']) ? $_POST['disk_quota'] : "0"; 54 $sector_info['usersQuota'] = isset($_POST['users_quota']) ? $_POST['users_quota'] : "0"; 55 49 56 50 57 $systemName = $GLOBALS['phpgw_info']['server']['system_name']; … … 98 105 $this->so->add_attribute($sector_info[0]['dn'], $ldap_mod_add); 99 106 } 100 else 107 elseif($sector_info['phpgwaccountvisible'] == '-1') 101 108 { 102 109 $ldap_mod_del['objectClass'] = 'phpgwAccount'; 103 110 $ldap_mod_del['phpgwaccountvisible'] = array(); 104 111 $this->so->remove_attribute($sector_info[0]['dn'], $ldap_mod_del); 112 } 113 114 //Modifica o conteúdo das cotas. 115 if( (isset($_POST['disk_quota']) ) && (isset($_POST['users_quota']) ) ) { //se for passado alguma coisa, lógico 116 $ldap_mod_replace = array(); 117 $ldap_mod_replace['diskQuota'] = $_POST['disk_quota']; 118 $ldap_mod_replace['usersQuota'] = $_POST['users_quota']; 119 $this->so->replace_attribute($sector_info[0]['dn'], $ldap_mod_replace); 105 120 } 106 121 -
trunk/expressoAdmin1_2/inc/class.db_functions.inc.php
r6517 r6553 65 65 return $acls; 66 66 } 67 68 //returns true if cotas control property is set. 69 function use_cota_control() { 70 $query = "select * from phpgw_config where config_name='expressoAdmin_cotasOu' and config_value='true'"; 71 $this->db->query($query); 72 if($this->db->next_record()) 73 return true; 74 return false; 75 } 76 67 77 /* 68 78 * Reativa os usuários desabilitados por tempo inativo modificando o seu ultimo acesso para o dia atual. -
trunk/expressoAdmin1_2/inc/class.functions.inc.php
r5934 r6553 464 464 $sectors_info = $s->get_organizations($context, $selected, $referral, $show_invisible_ou, $master); 465 465 return $sectors_info; 466 } 467 466 } 467 468 /* 469 Funciona de maneira similar ao get_sectors_list, porém retorna a propria OU do contexto 470 e monta o array de retorno de forma diferente, necessário para algumas mudanças implementadas 471 no método admin.uisectors.list_sectors. 472 */ 473 function get_organizations2($contexts, $selected='', $referral=false, $show_invisible_ou=true) { 474 475 $dn = $GLOBALS['phpgw_info']['server']['ldap_root_dn']; 476 $passwd = $GLOBALS['phpgw_info']['server']['ldap_root_pw']; 477 $ldap_conn = ldap_connect($GLOBALS['phpgw_info']['server']['ldap_host']); 478 479 ldap_set_option($ldap_conn, LDAP_OPT_PROTOCOL_VERSION, 3); 480 481 if ($referral) 482 ldap_set_option($ldap_conn, LDAP_OPT_REFERRALS, 1); 483 else 484 ldap_set_option($ldap_conn, LDAP_OPT_REFERRALS, 0); 485 486 ldap_bind($ldap_conn,$dn,$passwd); 487 488 $justthese = array("dn","diskQuota","usersQuota","actualDiskQuota"); 489 $filter = "(ou=*)"; 490 foreach ($contexts as $context) { 491 $search=ldap_search($ldap_conn, $context, $filter, $justthese); 492 493 ldap_sort($ldap_conn, $search, "ou"); 494 $info = ldap_get_entries($ldap_conn, $search); 495 ldap_close($ldap_conn); 496 497 // Retiro o count do array info e inverto o array para ordenaçãoo. 498 for ($i=0; $i<$info["count"]; $i++) 499 { 500 $dn = $info[$i]["dn"]; 501 502 // Necessário, pq em uma busca com ldapsearch ou=*, traz tb o próprio ou. 503 //if (strtolower($dn) == $context) 504 //continue; 505 506 $array_dn = ldap_explode_dn ( $dn, 1 ); 507 508 $array_dn_reverse = array_reverse ( $array_dn, true ); 509 510 // Retirar o indice count do array. 511 array_pop ( $array_dn_reverse ); 512 513 $inverted_dn[implode ( "#", $array_dn_reverse )] = $info[$i]; 514 } 515 } 516 // Ordenação por chave 517 ksort($inverted_dn); 518 519 // Construção do select 520 $level = 0; 521 $options = array(); 522 foreach ($inverted_dn as $dn=>$info_ou) 523 { 524 $display = ''; 525 $info_retorno = array(); 526 $array_dn_reverse = explode ( "#", $dn ); 527 $array_dn = array_reverse ( $array_dn_reverse, true ); 528 529 $level = count( $array_dn ) - (int)(count(explode(",", $GLOBALS['phpgw_info']['server']['ldap_context'])) + 1); 530 531 if ($level == 0) 532 $display .= '+'; 533 else 534 { 535 for ($i=0; $i<$level; $i++) 536 $display .= '---'; 537 } 538 539 reset ( $array_dn ); 540 $display .= ' ' . (current ( $array_dn ) ); 541 542 $info_retorno['display'] = $display; 543 $info_retorno['dn'] = $info_ou['dn']; 544 $info_retorno['diskquota'] = $info_ou['diskquota'][0]; 545 $info_retorno['usersquota'] = $info_ou['usersquota'][0]; 546 // $info_retorno['actualdiskquota'] = round($this->get_actual_disk_usage($info_ou['dn']),2);//$info_ou['actualdiskquota'][0]; 547 // $info_retorno['actualnumusers'] = $this->get_num_users($info_ou['dn']); 548 549 array_push($options,$info_retorno); 550 551 } 552 return $options; 553 } 554 555 function get_info($context, $referral = false) { 556 $dn = $GLOBALS['phpgw_info']['server']['ldap_root_dn']; 557 $passwd = $GLOBALS['phpgw_info']['server']['ldap_root_pw']; 558 $ldap_conn = ldap_connect($GLOBALS['phpgw_info']['server']['ldap_host']); 559 560 ldap_set_option($ldap_conn, LDAP_OPT_PROTOCOL_VERSION, 3); 561 562 if ($referral) 563 ldap_set_option($ldap_conn, LDAP_OPT_REFERRALS, 1); 564 else 565 ldap_set_option($ldap_conn, LDAP_OPT_REFERRALS, 0); 566 567 ldap_bind($ldap_conn,$dn,$passwd); 568 569 $filter="(objectClass=organizationalUnit)"; 570 $search=ldap_search($ldap_conn, $context, $filter); 571 $result = ldap_get_entries($ldap_conn, $search); 572 return $result; 573 574 } 575 576 function get_num_users($context,$selected='', $referral=false, $show_invisible_ou=true) { 577 $dn = $GLOBALS['phpgw_info']['server']['ldap_root_dn']; 578 $passwd = $GLOBALS['phpgw_info']['server']['ldap_root_pw']; 579 $ldap_conn = ldap_connect($GLOBALS['phpgw_info']['server']['ldap_host']); 580 581 ldap_set_option($ldap_conn, LDAP_OPT_PROTOCOL_VERSION, 3); 582 583 if ($referral) 584 ldap_set_option($ldap_conn, LDAP_OPT_REFERRALS, 1); 585 else 586 ldap_set_option($ldap_conn, LDAP_OPT_REFERRALS, 0); 587 588 ldap_bind($ldap_conn,$dn,$passwd); 589 590 $justthese = array("dn"); 591 $filter = "(objectClass=inetOrgPerson)"; 592 $search=ldap_search($ldap_conn, $context, $filter, $justthese); 593 594 $retorno = ldap_count_entries($ldap_conn, $search); 595 ldap_close($ldap_conn); 596 597 return $retorno; 598 } 599 600 //Checa se existe quota para mais um usuᅵrio no setor... se existir retorna true, senᅵo false. 601 function existe_quota_usuario($setor) { 602 $num_users = $this->get_num_users($setor['dn']); 603 //return $num_users . " --- " . $setor['usersquota'][0] 604 if(($num_users>=$setor['usersquota'][0]) && ($setor['usersquota'][0]!=-1)) { 605 return false; 606 } 607 return true; 608 } 609 610 //Checa se existe quota em disco para mais um usuᅵrio no setor... se existir retorna true, senᅵo false. 611 function existe_quota_disco($setor,$quota_novo_usuario) { 612 settype($quota_novo_usuario,"float"); 613 $quota_novo_usuario /= 1024; //A quota vᅵm da interface em megabytes, deve se tornar gigabyte. 614 615 $nova_quota = $this->get_actual_disk_usage($setor['dn']) + $quota_novo_usuario; 616 if(( $nova_quota >= $setor['diskquota'][0] ) && ($setor['diskquota'][0] != -1)) { 617 return false; 618 } 619 return true; 620 } 621 622 // Soma as quotas de todos os usuᅵrios daquele contexto. 623 function get_actual_disk_usage($context) { 624 $quota_usada=0; 625 $contexts = array($context); 626 $usuarios = $this->get_list('accounts', '', $contexts); 627 628 $imap_functions = new imap_functions(); 629 foreach($usuarios as $usuario) { 630 $temp = $imap_functions->get_user_info($usuario['account_lid']); 631 if($temp['mailquota'] != -1) //Usuᅵrio sem cota nᅵo conta... 632 $quota_usada += ($temp['mailquota'] / 1024); 633 } 634 return $quota_usada; 635 } 636 637 468 638 function get_sectors($selected='', $referral=false, $show_invisible_ou=true) 469 639 { -
trunk/expressoAdmin1_2/inc/class.sosectors.inc.php
r5133 r6553 133 133 } 134 134 135 function replace_attribute($dn, $info) 136 { 137 $connection = $GLOBALS['phpgw']->common->ldapConnect(); 138 139 if (ldap_mod_replace($connection, $dn, $info)) 140 { 141 ldap_close($connection); 142 return true; 143 } 144 else 145 { 146 echo 'Erro na escrita no LDAP, funcao replace_attribute: ' . ldap_error($connection); 147 ldap_close($connection); 148 return false; 149 } 150 } 151 135 152 function remove_attribute($dn, $info) 136 153 { -
trunk/expressoAdmin1_2/inc/class.uisectors.inc.php
r5133 r6553 20 20 'validate_data_sectors_edit' => True, 21 21 'delete_sector' => True, 22 'css' => True 22 'css' => True, 23 'view_cota' => True 23 24 ); 24 25 … … 63 64 $p->set_block('sectors','row_empty','row_empty'); 64 65 65 $sectors_info = $this->functions->get_sectors_list($contexts); 66 //$sectors_info = $this->functions->get_sectors_list($contexts); 67 $sectors_info = $this->functions->get_organizations2($contexts); 66 68 67 69 $var = Array( … … 69 71 'back_url' => $GLOBALS['phpgw']->link('/expressoAdmin1_2/index.php'), 70 72 'context_display' => $context_display, 71 'lang_inactives' => lang('list inactives') 73 'lang_inactives' => lang('list inactives'), 74 'lang_ver_cota' => lang('view cota') 72 75 ); 73 76 … … 95 98 { 96 99 $tr_color = $this->nextmatchs->alternate_row_color($tr_color); 97 98 100 $var = Array( 99 101 'tr_color' => $tr_color, 100 'sector_name' => $sector, 101 'add_link' => $this->row_action('add','sector',$context) 102 'sector_name' => $sector['display'], 103 'cota_link' => $this->row_action('view','cota',$sector['dn']), 104 'add_link' => $this->row_action('add','sector',$sector['dn']) 102 105 ); 103 106 … … 106 109 107 110 if(isset($GLOBALS['phpgw_info']['server']['time_to_account_expires'])) 108 $var['inactives_link'] = $this->row_action('list_inactive','users',$ context,'uiaccounts');111 $var['inactives_link'] = $this->row_action('list_inactive','users',$sector['dn'],'uiaccounts'); 109 112 else 110 113 $var['inactives_link'] = lang('disabled'); … … 114 117 if ($can_edit) 115 118 { 116 $p->set_var('edit_link',$this->row_action('edit','sector', utf8_decode($context)));119 $p->set_var('edit_link',$this->row_action('edit','sector',$sector['dn'])); 117 120 } 118 121 else … … 123 126 if ($can_delete) 124 127 { 125 $p->set_var('delete_link',$this->row_action('delete','sector', utf8_decode($context)));128 $p->set_var('delete_link',$this->row_action('delete','sector',$sector['dn'])); 126 129 } 127 130 else … … 189 192 'context' => $context == '' ? $GLOBALS['phpgw_info']['server']['ldap_context'] : $context, 190 193 'sector' => $_POST['sector'], 194 'disk_quota' => $_POST['disk_quota'], 195 'users_quota' => $_POST['users_quota'], 191 196 'manager_org' => $combo_manager_org, 192 197 'sector_visible_checked'=> $_POST['sector_visible'] ? 'checked' : '', 193 198 'error_messages' => $_POST['error_messages'] == '' ? '' : "<script type='text/javascript'>alert('".$_POST['error_messages']."')</script>", 194 199 ); 195 200 201 if($this->functions->db_functions->use_cota_control()) { 202 $var["open_comment_cotas"] = ""; 203 $var["close_comment_cotas"] =""; 204 } 205 else { 206 $var["open_comment_cotas"] = "<!--"; 207 $var["close_comment_cotas"] ="-->"; 208 } 209 196 210 $var['sector'] = preg_replace("/\\\([0-9A-Fa-f]{2})/e", "''.chr(hexdec('\\1')).''",$var['sector']); 197 211 $var['sector'] = utf8_decode($var['sector']); … … 242 256 { 243 257 $sector_info = $this->so->get_info($context); 258 $sector_disk_quota = $sector_info[0]['diskquota'][0]; 259 $sector_users_quota = $sector_info[0]['usersquota'][0]; 244 260 $_POST['sector_visible'] = $sector_info[0]['phpgwaccountvisible'][0]; 245 261 } … … 254 270 'manager_org' => $combo_manager_org, 255 271 'sector_visible_checked'=> $_POST['sector_visible'] ? 'checked' : '', 272 'disk_quota' => $_POST['disk_quota'] == '' ? $sector_disk_quota : $_POST['disk_quota'], 273 'users_quota' => $_POST['users_quota'] == '' ? $sector_users_quota : $_POST['users_quota'], 256 274 257 275 'lang_add' => lang('Add'), 258 276 'disable' => 'disabled', 259 277 'error_messages' => $_POST['error_messages'] == '' ? '' : "<script type='text/javascript'>alert('".$_POST['error_messages']."')</script>", 260 ); 278 'lang_disk_quota' => lang('disk quota'), 279 'lang_users_quota' => lang('users quota') 280 ); 281 if($this->functions->db_functions->use_cota_control()) { 282 $var["open_comment_cotas"] = ""; 283 $var["close_comment_cotas"] =""; 284 } 285 else { 286 $var["open_comment_cotas"] = "<!--"; 287 $var["close_comment_cotas"] ="-->"; 288 } 261 289 262 290 $var['sector'] = preg_replace("/\\\([0-9A-Fa-f]{2})/e", "''.chr(hexdec('\\1')).''",$var['sector']); … … 267 295 268 296 $p->pfp('out','edit_sector'); 269 } 297 } 298 299 function view_cota() 300 { 301 $context = $_GET['context']; 302 $a_tmp = explode(",", ldap_dn2ufn($context)); 303 304 $sector_name = $a_tmp[0]; 305 if($this->functions->db_functions->use_cota_control()) { 306 $sector_info = $this->so->get_info($context); 307 $sector_disk_cota = $sector_info[0]['diskquota'][0]; 308 $sector_users_cota = $sector_info[0]['usersquota'][0]; 309 } 310 else { 311 $sector_disk_cota = lang('cotas control disabled'); 312 $sector_users_cota = lang('cotas control disabled'); 313 } 314 315 316 unset($GLOBALS['phpgw_info']['flags']['noheader']); 317 unset($GLOBALS['phpgw_info']['flags']['nonavbar']); 318 $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['expressoAdmin1_2']['title'].' - '.lang('Edit Sector'); 319 $GLOBALS['phpgw']->common->phpgw_header(); 320 321 // Set o template 322 $p = CreateObject('phpgwapi.Template',PHPGW_APP_TPL); 323 $p->set_file(Array('ver_cota' => 'sectors_cota.tpl')); 324 325 326 // Seta variaveis utilizadas pelo tpl. 327 $var = Array( 328 'back_url' => $GLOBALS['phpgw']->link('/index.php','menuaction=expressoAdmin1_2.uisectors.list_sectors'), 329 'th_bg' => $GLOBALS['phpgw_info']['theme']['th_bg'], 330 'context' => $context, 331 'sector' => $sector_name, 332 'disk_cota' => $sector_disk_cota, 333 'users_cota' => $sector_users_cota, 334 'actual_users' => $this->functions->get_num_users($context), 335 'actual_disk' => round($this->functions->get_actual_disk_usage($context),2), 336 337 'lang_back' => lang('Back'), 338 'lang_context' => lang('Context'), 339 'lang_sector_name' => lang('Sector name'), 340 'lang_disk_cota' => lang('disk usage cota'), 341 'lang_users_cota' => lang('user number cota'), 342 'lang_user_number' => lang('user number'), 343 'lang_disk_used' => lang('disk usage'), 344 'error_messages' => $_POST['error_messages'] == '' ? '' : "<script type='text/javascript'>alert('".$_POST['error_messages']."')</script>", 345 ); 346 $p->set_var($var); 347 348 $p->pfp('out','ver_cota'); 349 } 270 350 271 351 function validate_data_sectors_add() -
trunk/expressoAdmin1_2/inc/class.user.inc.php
r6186 r6553 36 36 $return['status'] = true; 37 37 38 if($this->db_functions->use_cota_control()) { 39 //Verifica quota de usuários e disco 40 $setor = $this->functions->get_info($params['context']); 41 if (!$this->functions->existe_quota_usuario($setor[0])) { 42 $return['status'] = false; 43 $return['msg'] = $this->functions->lang("user cota exceeded");//TODO colocar valor de acordo com tabela de traduções. 44 return $return; 45 } 46 if (!$this->functions->existe_quota_disco($setor[0],$params['mailquota'])) { 47 $return['status'] = false; 48 $return['msg'] = $this->functions->lang("disk cota exceeded");//TODO colocar valor de acordo com tabela de traduções. 49 return $return; 50 } 51 } 52 38 53 // Verifica o acesso do gerente 39 54 if ($this->functions->check_acl($_SESSION['phpgw_session']['session_lid'], 'add_users')) … … 303 318 */ 304 319 320 //Verifica quota de disco, como estou alterando, não preciso checar quota de usuários. 321 if($this->db_functions->use_cota_control()) { 322 $setor = $this->functions->get_info($new_values['context']); 323 if (!$this->functions->existe_quota_disco($setor[0],$new_values['mailquota'])) { 324 $return['status'] = false; 325 $return['msg'] = "Quota em disco excedida...";//TODO colocar valor de acordo com tabela de traduções. 326 return $return; 327 } 328 } 329 305 330 $manager_account_lid = $_SESSION['phpgw_session']['session_lid']; 306 331 if ((!$this->functions->check_acl($manager_account_lid,'edit_users')) && -
trunk/expressoAdmin1_2/setup/phpgw_pt-br.lang
r5870 r6553 458 458 user login expressoAdmin1_2 pt-br Login do usuário 459 459 last login expressoAdmin1_2 pt-br Último acesso 460 user number cota expressoAdmin1_2 pt-br Cota de usuários 461 disk usage cota expressoAdmin1_2 pt-br Cota de disco 462 user number expressoAdmin1_2 pt-br Nº de usuários 463 disk usage expressoAdmin1_2 pt-br Espaço utilizado 464 view cota expressoAdmin1_2 pt-br Cotas 465 users quota expressoAdmin1_2 pt-br Cota de Usuários 466 disk quota expressoAdmin1_2 pt-br Cota em Disco 460 467 shared accounts expressoAdmin1_2 pt-br Contas compartilhadas 461 468 create shared account expressoAdmin1_2 pt-br Criar conta compartilhada -
trunk/expressoAdmin1_2/templates/default/config.tpl
r5133 r6553 166 166 <td><span>{lang_Result}: </span><span id="nextid_db_result"></span></td> 167 167 </tr> 168 <tr class="row_off"> 169 <td>{lang_use_quotas_control_for_ou}</td> 170 <td> 171 <select name="newsettings[expressoAdmin_cotasOu]"> 172 <option value="">{lang_No}</option> 173 <option value="true"{selected_expressoAdmin_cotasOu_true}>{lang_Yes}</option> 174 </select> 175 </td> 176 </tr> 168 177 <tr class="row_on"> 169 178 <td>{lang_use_login_generator}</td> -
trunk/expressoAdmin1_2/templates/default/sectors.tpl
r5133 r6553 17 17 </table> 18 18 19 <table border="0" width=" 65%" align="center">19 <table border="0" width="70%" align="center"> 20 20 <tr bgcolor="{th_bg}"> 21 21 <td>{lang_name}</td> 22 22 <td>{lang_inactives}</td> 23 <td>{lang_ver_cota}</td> 23 24 <td>{lang_add_sub_sectors}</td> 24 25 <td>{lang_edit}</td> … … 32 33 <tr bgcolor="{tr_color}"> 33 34 <td>{sector_name}</td> 34 <td width="13%">{inactives_link}</td> 35 <td width="25%">{add_link}</td> 35 <td width="13%">{inactives_link}</td> 36 <td width="13%">{cota_link}</td> 37 <td width="12%">{add_link}</td> 36 38 <td width="5%">{edit_link}</td> 37 39 <td width="5%">{delete_link}</td> -
trunk/expressoAdmin1_2/templates/default/sectors_form.tpl
r6159 r6553 23 23 </td> 24 24 </tr> 25 {open_comment_cotas} 26 <tr> 27 <td> 28 {lang_users_quota}: 29 </td> 30 <td> 31 <input type="text" autocomplete="off" name="users_quota" value={users_quota}> 32 </td> 33 </tr> 34 35 <tr> 36 <td> 37 {lang_disk_quota}: 38 </td> 39 <td> 40 <input type="text" autocomplete="off" name="disk_quota" value={disk_quota}> 41 </td> 42 </tr> 43 {close_comment_cotas} 25 44 <tr> 26 45 <td>
Note: See TracChangeset
for help on using the changeset viewer.