[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 | class uisectors |
---|
| 13 | { |
---|
| 14 | var $public_functions = array |
---|
| 15 | ( |
---|
| 16 | 'list_sectors' => True, |
---|
| 17 | 'add_sector' => True, |
---|
| 18 | 'validate_data_sectors_add' => True, |
---|
[32] | 19 | 'edit_sector' => True, |
---|
| 20 | 'validate_data_sectors_edit' => True, |
---|
[2] | 21 | 'delete_sector' => True, |
---|
[6553] | 22 | 'css' => True, |
---|
| 23 | 'view_cota' => True |
---|
[2] | 24 | ); |
---|
| 25 | |
---|
| 26 | var $bo; |
---|
| 27 | var $nextmatchs; |
---|
| 28 | var $functions; |
---|
| 29 | |
---|
| 30 | function uisectors() |
---|
| 31 | { |
---|
| 32 | $this->bo = CreateObject('expressoAdmin1_2.bosectors'); |
---|
| 33 | $this->so = $this->bo->so; |
---|
| 34 | $this->functions = $this->bo->functions; |
---|
| 35 | $this->nextmatchs = createobject('phpgwapi.nextmatchs'); |
---|
| 36 | } |
---|
| 37 | |
---|
| 38 | function list_sectors() |
---|
| 39 | { |
---|
[64] | 40 | $manager_lid = $GLOBALS['phpgw']->accounts->data['account_lid']; |
---|
| 41 | $acl = $this->functions->read_acl($manager_lid); |
---|
| 42 | $contexts = $acl['contexts']; |
---|
| 43 | foreach ($acl['contexts_display'] as $index=>$tmp_context) |
---|
| 44 | { |
---|
| 45 | $context_display .= '<br>'.$tmp_context; |
---|
| 46 | } |
---|
| 47 | |
---|
[2] | 48 | // Verifica se o administrador tem acesso. |
---|
[5133] | 49 | if (!$this->functions->check_acl($manager_lid,'list_sectors')) |
---|
| 50 | { |
---|
| 51 | $GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/expressoAdmin1_2/inc/access_denied.php')); |
---|
| 52 | } |
---|
[2] | 53 | |
---|
| 54 | unset($GLOBALS['phpgw_info']['flags']['noheader']); |
---|
| 55 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']); |
---|
| 56 | |
---|
| 57 | $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['expressoAdmin1_2']['title'].' - '.lang('Sectors'); |
---|
| 58 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
| 59 | |
---|
| 60 | $p = CreateObject('phpgwapi.Template',PHPGW_APP_TPL); |
---|
| 61 | $p->set_file(array('sectors' => 'sectors.tpl')); |
---|
| 62 | $p->set_block('sectors','list','list'); |
---|
| 63 | $p->set_block('sectors','row','row'); |
---|
| 64 | $p->set_block('sectors','row_empty','row_empty'); |
---|
| 65 | |
---|
[6553] | 66 | //$sectors_info = $this->functions->get_sectors_list($contexts); |
---|
| 67 | $sectors_info = $this->functions->get_organizations2($contexts); |
---|
[2] | 68 | |
---|
| 69 | $var = Array( |
---|
| 70 | 'th_bg' => $GLOBALS['phpgw_info']['theme']['th_bg'], |
---|
| 71 | 'back_url' => $GLOBALS['phpgw']->link('/expressoAdmin1_2/index.php'), |
---|
[548] | 72 | 'context_display' => $context_display, |
---|
[6553] | 73 | 'lang_inactives' => lang('list inactives'), |
---|
| 74 | 'lang_ver_cota' => lang('view cota') |
---|
[2] | 75 | ); |
---|
[5133] | 76 | |
---|
[2] | 77 | $p->set_var($var); |
---|
[414] | 78 | $p->set_var($this->functions->make_dinamic_lang($p, 'list')); |
---|
[2] | 79 | |
---|
| 80 | if (!count($sectors_info)) |
---|
| 81 | { |
---|
| 82 | $p->set_var('message',lang('No matches found')); |
---|
| 83 | $p->parse('rows','row_empty',True); |
---|
| 84 | } |
---|
| 85 | else |
---|
| 86 | { |
---|
[64] | 87 | if ($this->functions->check_acl($manager_lid,'edit_sectors')) |
---|
[2] | 88 | { |
---|
| 89 | $can_edit = True; |
---|
| 90 | } |
---|
| 91 | |
---|
[64] | 92 | if ($this->functions->check_acl($manager_lid,'delete_sectors')) |
---|
[2] | 93 | { |
---|
| 94 | $can_delete = True; |
---|
| 95 | } |
---|
| 96 | |
---|
[46] | 97 | foreach($sectors_info as $context=>$sector) |
---|
[2] | 98 | { |
---|
| 99 | $tr_color = $this->nextmatchs->alternate_row_color($tr_color); |
---|
| 100 | $var = Array( |
---|
| 101 | 'tr_color' => $tr_color, |
---|
[6553] | 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']) |
---|
[3359] | 105 | ); |
---|
| 106 | |
---|
[6697] | 107 | $var['sector_name'] = utf8_decode($var['sector_name']); |
---|
[5133] | 108 | |
---|
[3359] | 109 | |
---|
[548] | 110 | if(isset($GLOBALS['phpgw_info']['server']['time_to_account_expires'])) |
---|
[6553] | 111 | $var['inactives_link'] = $this->row_action('list_inactive','users',$sector['dn'],'uiaccounts'); |
---|
[548] | 112 | else |
---|
[597] | 113 | $var['inactives_link'] = lang('disabled'); |
---|
[548] | 114 | |
---|
[2] | 115 | $p->set_var($var); |
---|
| 116 | |
---|
[32] | 117 | if ($can_edit) |
---|
| 118 | { |
---|
[6553] | 119 | $p->set_var('edit_link',$this->row_action('edit','sector',$sector['dn'])); |
---|
[32] | 120 | } |
---|
| 121 | else |
---|
| 122 | { |
---|
| 123 | $p->set_var('edit_link',' '); |
---|
| 124 | } |
---|
| 125 | |
---|
[2] | 126 | if ($can_delete) |
---|
| 127 | { |
---|
[6553] | 128 | $p->set_var('delete_link',$this->row_action('delete','sector',$sector['dn'])); |
---|
[2] | 129 | } |
---|
| 130 | else |
---|
| 131 | { |
---|
| 132 | $p->set_var('delete_link',' '); |
---|
| 133 | } |
---|
| 134 | |
---|
| 135 | $p->fp('rows','row',True); |
---|
| 136 | } |
---|
| 137 | } |
---|
| 138 | $var = Array( |
---|
| 139 | 'action' => $GLOBALS['phpgw']->link('/index.php','menuaction=expressoAdmin1_2.uisectors.add_sector') |
---|
| 140 | ); |
---|
| 141 | $p->set_var($var); |
---|
| 142 | |
---|
[3359] | 143 | $p->set_var('input_add','<input type="submit" value="' . lang('Add Sectors') . '">'); |
---|
| 144 | |
---|
[2] | 145 | $p->parse('rows','row_empty',True); |
---|
| 146 | $p->pfp('out','list'); |
---|
| 147 | } |
---|
| 148 | |
---|
| 149 | |
---|
| 150 | function add_sector($context='') |
---|
| 151 | { |
---|
[64] | 152 | $manager_lid = $GLOBALS['phpgw']->accounts->data['account_lid']; |
---|
| 153 | $acl = $this->functions->read_acl($manager_lid); |
---|
[1145] | 154 | |
---|
| 155 | $manager_contexts = $acl['contexts']; |
---|
| 156 | $combo_manager_org = ''; |
---|
| 157 | |
---|
[1394] | 158 | if ( array_key_exists( 'context', $_GET ) ) |
---|
| 159 | { |
---|
| 160 | $context = $_GET['context']; |
---|
| 161 | $combo_manager_org = $this->functions->get_organizations( $context, '', true, true, true ); |
---|
[5133] | 162 | $combo_manager_org = preg_replace("/\\\([0-9A-Fa-f]{2})/e", "''.chr(hexdec('\\1')).''",$combo_manager_org); |
---|
| 163 | $combo_manager_org = utf8_decode($combo_manager_org); |
---|
[1394] | 164 | } |
---|
| 165 | else |
---|
| 166 | { |
---|
| 167 | foreach ($manager_contexts as $index=>$context) |
---|
| 168 | $combo_manager_org .= $this->functions->get_organizations( $context ); |
---|
| 169 | } |
---|
| 170 | |
---|
[2] | 171 | // Verifica se tem acesso a este modulo |
---|
[64] | 172 | if (!$this->functions->check_acl($manager_lid,'create_sectors')) |
---|
[2] | 173 | { |
---|
| 174 | $GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/expressoAdmin1_2/inc/access_denied.php')); |
---|
| 175 | } |
---|
| 176 | |
---|
| 177 | unset($GLOBALS['phpgw_info']['flags']['noheader']); |
---|
| 178 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']); |
---|
[309] | 179 | $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['expressoAdmin1_2']['title'].' - '.lang('Create Sector'); |
---|
[2] | 180 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
| 181 | |
---|
| 182 | // Set o template |
---|
| 183 | $p = CreateObject('phpgwapi.Template',PHPGW_APP_TPL); |
---|
| 184 | $p->set_file(Array('create_sector' => 'sectors_form.tpl')); |
---|
[414] | 185 | $p->set_block('create_sector','list','list'); |
---|
[396] | 186 | |
---|
[2] | 187 | // Seta variaveis utilizadas pelo tpl. |
---|
| 188 | $var = Array( |
---|
[32] | 189 | 'action' => $GLOBALS['phpgw']->link('/index.php','menuaction=expressoAdmin1_2.uisectors.validate_data_sectors_add'), |
---|
| 190 | 'back_url' => $GLOBALS['phpgw']->link('/index.php','menuaction=expressoAdmin1_2.uisectors.list_sectors'), |
---|
| 191 | 'th_bg' => $GLOBALS['phpgw_info']['theme']['th_bg'], |
---|
[64] | 192 | 'context' => $context == '' ? $GLOBALS['phpgw_info']['server']['ldap_context'] : $context, |
---|
[32] | 193 | 'sector' => $_POST['sector'], |
---|
[6917] | 194 | 'associated_domain' => $_POST['associated_domain'], |
---|
[6553] | 195 | 'disk_quota' => $_POST['disk_quota'], |
---|
[6917] | 196 | 'users_quota' => $_POST['users_quota'], |
---|
[1145] | 197 | 'manager_org' => $combo_manager_org, |
---|
[309] | 198 | 'sector_visible_checked'=> $_POST['sector_visible'] ? 'checked' : '', |
---|
[32] | 199 | 'error_messages' => $_POST['error_messages'] == '' ? '' : "<script type='text/javascript'>alert('".$_POST['error_messages']."')</script>", |
---|
[2] | 200 | ); |
---|
[6553] | 201 | |
---|
| 202 | if($this->functions->db_functions->use_cota_control()) { |
---|
| 203 | $var["open_comment_cotas"] = ""; |
---|
| 204 | $var["close_comment_cotas"] =""; |
---|
| 205 | } |
---|
| 206 | else { |
---|
| 207 | $var["open_comment_cotas"] = "<!--"; |
---|
| 208 | $var["close_comment_cotas"] ="-->"; |
---|
| 209 | } |
---|
| 210 | |
---|
[5133] | 211 | $var['sector'] = preg_replace("/\\\([0-9A-Fa-f]{2})/e", "''.chr(hexdec('\\1')).''",$var['sector']); |
---|
| 212 | $var['sector'] = utf8_decode($var['sector']); |
---|
[1516] | 213 | |
---|
[2] | 214 | $p->set_var($var); |
---|
[414] | 215 | $p->set_var($this->functions->make_dinamic_lang($p, 'list')); |
---|
[2] | 216 | |
---|
| 217 | $p->pfp('out','create_sector'); |
---|
| 218 | } |
---|
| 219 | |
---|
[32] | 220 | function edit_sector() |
---|
| 221 | { |
---|
| 222 | $account_lid = $GLOBALS['phpgw']->accounts->data['account_lid']; |
---|
| 223 | $acl = $this->functions->read_acl($account_lid); |
---|
| 224 | $manager_context = $acl[0]['context']; |
---|
| 225 | |
---|
| 226 | $context = $_GET['context']; |
---|
[1145] | 227 | |
---|
[5133] | 228 | $context = utf8_encode($context); |
---|
| 229 | $context = preg_replace("/\\\([0-9A-Fa-f]{2})/e", "''.chr(hexdec('\\1')).''",$context); |
---|
| 230 | |
---|
| 231 | $combo_manager_org = $this->functions->get_organizations($context, '', true, true, true); |
---|
| 232 | |
---|
| 233 | $combo_manager_org = utf8_decode(preg_replace("/\\\([0-9A-Fa-f]{2})/e", "''.chr(hexdec('\\1')).''",$combo_manager_org)); |
---|
| 234 | |
---|
[1145] | 235 | $combo_manager_org = substr( $combo_manager_org, 0, ( strpos($combo_manager_org, '</option>') + 9 ) ); |
---|
[6697] | 236 | $combo_manager_org =utf8_decode($combo_manager_org); |
---|
| 237 | $a_tmp = explode(",", $context); |
---|
| 238 | $sector_name = utf8_decode( str_replace('ou=' , '' ,$a_tmp[0])); |
---|
[32] | 239 | |
---|
| 240 | // Verifica se tem acesso a este modulo |
---|
| 241 | if (!$this->functions->check_acl($account_lid,'edit_sectors')) |
---|
| 242 | { |
---|
| 243 | $GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/expressoAdmin1_2/inc/access_denied.php')); |
---|
| 244 | } |
---|
| 245 | |
---|
| 246 | unset($GLOBALS['phpgw_info']['flags']['noheader']); |
---|
| 247 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']); |
---|
[309] | 248 | $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['expressoAdmin1_2']['title'].' - '.lang('Edit Sector'); |
---|
[32] | 249 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
| 250 | |
---|
| 251 | // Set o template |
---|
| 252 | $p = CreateObject('phpgwapi.Template',PHPGW_APP_TPL); |
---|
| 253 | $p->set_file(Array('edit_sector' => 'sectors_form.tpl')); |
---|
[414] | 254 | $p->set_block('edit_sector','list','list'); |
---|
[32] | 255 | |
---|
| 256 | if (!$_POST) |
---|
| 257 | { |
---|
[6697] | 258 | $sector_info = $this->so->get_info($_GET['context']); |
---|
[6917] | 259 | $sector_disk_quota = $sector_info[0]['diskquota'][0]; |
---|
| 260 | $sector_users_quota = $sector_info[0]['usersquota'][0]; |
---|
| 261 | $sector_associated_domain = $sector_info[0]['associateddomain'][0]; |
---|
[32] | 262 | $_POST['sector_visible'] = $sector_info[0]['phpgwaccountvisible'][0]; |
---|
| 263 | } |
---|
| 264 | |
---|
| 265 | // Seta variaveis utilizadas pelo tpl. |
---|
| 266 | $var = Array( |
---|
| 267 | 'action' => $GLOBALS['phpgw']->link('/index.php','menuaction=expressoAdmin1_2.bosectors.save_sector'), |
---|
| 268 | 'back_url' => $GLOBALS['phpgw']->link('/index.php','menuaction=expressoAdmin1_2.uisectors.list_sectors'), |
---|
| 269 | 'th_bg' => $GLOBALS['phpgw_info']['theme']['th_bg'], |
---|
| 270 | 'context' => $context == '' ? $manager_context : $context, |
---|
[1145] | 271 | 'sector' => $_POST['sector'] == '' ? $sector_name : $_POST['sector'], |
---|
| 272 | 'manager_org' => $combo_manager_org, |
---|
[309] | 273 | 'sector_visible_checked'=> $_POST['sector_visible'] ? 'checked' : '', |
---|
[6917] | 274 | 'disk_quota' => $_POST['disk_quota'] == '' ? $sector_disk_quota : $_POST['disk_quota'], |
---|
| 275 | 'users_quota' => $_POST['users_quota'] == '' ? $sector_users_quota : $_POST['users_quota'], |
---|
| 276 | 'associated_domain' => $_POST['associated_domain'] == '' ? $sector_associated_domain : $_POST['associated_domain'], |
---|
[32] | 277 | 'lang_add' => lang('Add'), |
---|
| 278 | 'disable' => 'disabled', |
---|
| 279 | 'error_messages' => $_POST['error_messages'] == '' ? '' : "<script type='text/javascript'>alert('".$_POST['error_messages']."')</script>", |
---|
[6553] | 280 | 'lang_disk_quota' => lang('disk quota'), |
---|
| 281 | 'lang_users_quota' => lang('users quota') |
---|
| 282 | ); |
---|
| 283 | if($this->functions->db_functions->use_cota_control()) { |
---|
| 284 | $var["open_comment_cotas"] = ""; |
---|
| 285 | $var["close_comment_cotas"] =""; |
---|
| 286 | } |
---|
| 287 | else { |
---|
| 288 | $var["open_comment_cotas"] = "<!--"; |
---|
| 289 | $var["close_comment_cotas"] ="-->"; |
---|
| 290 | } |
---|
[1516] | 291 | |
---|
[5133] | 292 | $var['sector'] = preg_replace("/\\\([0-9A-Fa-f]{2})/e", "''.chr(hexdec('\\1')).''",$var['sector']); |
---|
| 293 | $var['sector'] = utf8_decode($var['sector']); |
---|
[1516] | 294 | |
---|
| 295 | $p->set_var($var); |
---|
[5133] | 296 | $p->set_var($this->functions->make_dinamic_lang($p, 'list')); |
---|
[1516] | 297 | |
---|
[5133] | 298 | $p->pfp('out','edit_sector'); |
---|
[6553] | 299 | } |
---|
| 300 | |
---|
| 301 | function view_cota() |
---|
| 302 | { |
---|
[6697] | 303 | $context = utf8_decode($_GET['context']); |
---|
| 304 | $a_tmp = explode(",", $context); |
---|
[6553] | 305 | |
---|
[6697] | 306 | $sector_name = str_replace('ou=' , '' ,$a_tmp[0]); |
---|
[6553] | 307 | if($this->functions->db_functions->use_cota_control()) { |
---|
[6697] | 308 | $sector_info = $this->so->get_info($_GET['context']); |
---|
[6553] | 309 | $sector_disk_cota = $sector_info[0]['diskquota'][0]; |
---|
| 310 | $sector_users_cota = $sector_info[0]['usersquota'][0]; |
---|
| 311 | } |
---|
| 312 | else { |
---|
| 313 | $sector_disk_cota = lang('cotas control disabled'); |
---|
| 314 | $sector_users_cota = lang('cotas control disabled'); |
---|
| 315 | } |
---|
| 316 | |
---|
| 317 | |
---|
| 318 | unset($GLOBALS['phpgw_info']['flags']['noheader']); |
---|
| 319 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']); |
---|
| 320 | $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['expressoAdmin1_2']['title'].' - '.lang('Edit Sector'); |
---|
| 321 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
| 322 | |
---|
| 323 | // Set o template |
---|
| 324 | $p = CreateObject('phpgwapi.Template',PHPGW_APP_TPL); |
---|
| 325 | $p->set_file(Array('ver_cota' => 'sectors_cota.tpl')); |
---|
| 326 | |
---|
| 327 | |
---|
| 328 | // Seta variaveis utilizadas pelo tpl. |
---|
| 329 | $var = Array( |
---|
| 330 | 'back_url' => $GLOBALS['phpgw']->link('/index.php','menuaction=expressoAdmin1_2.uisectors.list_sectors'), |
---|
| 331 | 'th_bg' => $GLOBALS['phpgw_info']['theme']['th_bg'], |
---|
| 332 | 'context' => $context, |
---|
| 333 | 'sector' => $sector_name, |
---|
| 334 | 'disk_cota' => $sector_disk_cota, |
---|
| 335 | 'users_cota' => $sector_users_cota, |
---|
| 336 | 'actual_users' => $this->functions->get_num_users($context), |
---|
| 337 | 'actual_disk' => round($this->functions->get_actual_disk_usage($context),2), |
---|
| 338 | |
---|
| 339 | 'lang_back' => lang('Back'), |
---|
| 340 | 'lang_context' => lang('Context'), |
---|
| 341 | 'lang_sector_name' => lang('Sector name'), |
---|
| 342 | 'lang_disk_cota' => lang('disk usage cota'), |
---|
| 343 | 'lang_users_cota' => lang('user number cota'), |
---|
| 344 | 'lang_user_number' => lang('user number'), |
---|
| 345 | 'lang_disk_used' => lang('disk usage'), |
---|
| 346 | 'error_messages' => $_POST['error_messages'] == '' ? '' : "<script type='text/javascript'>alert('".$_POST['error_messages']."')</script>", |
---|
| 347 | ); |
---|
| 348 | $p->set_var($var); |
---|
| 349 | |
---|
| 350 | $p->pfp('out','ver_cota'); |
---|
| 351 | } |
---|
[1516] | 352 | |
---|
[2] | 353 | function validate_data_sectors_add() |
---|
| 354 | { |
---|
| 355 | $sector_name = $_POST['sector']; |
---|
[396] | 356 | $context = $_POST['context']; |
---|
[2] | 357 | |
---|
| 358 | // Verifica se o nome do sector nao esta vazio. |
---|
| 359 | if ($sector_name == '') |
---|
| 360 | { |
---|
[309] | 361 | $_POST['error_messages'] = lang('Sector name is empty.'); |
---|
[2] | 362 | ExecMethod('expressoAdmin1_2.uisectors.add_sector'); |
---|
| 363 | return; |
---|
| 364 | } |
---|
| 365 | |
---|
| 366 | // Verifica se o nome do setor existe no contexto atual. |
---|
| 367 | if ($this->so->exist_sector_name($sector_name, $context)) |
---|
| 368 | { |
---|
| 369 | $_POST['error_messages'] = lang('Sector name already exist.'); |
---|
| 370 | ExecMethod('expressoAdmin1_2.uisectors.add_sector'); |
---|
| 371 | return; |
---|
| 372 | } |
---|
| 373 | |
---|
| 374 | ExecMethod('expressoAdmin1_2.bosectors.create_sector'); |
---|
| 375 | } |
---|
[32] | 376 | |
---|
[2] | 377 | function delete_sector() |
---|
| 378 | { |
---|
| 379 | $account_lid = $GLOBALS['phpgw']->accounts->data['account_lid']; |
---|
| 380 | $acl = $this->functions->read_acl($account_lid); |
---|
| 381 | $manager_context = $acl[0]['context']; |
---|
| 382 | |
---|
[5133] | 383 | $manager_context = utf8_encode($manager_context); |
---|
| 384 | $manager_context = preg_replace("/\\\([0-9A-Fa-f]{2})/e", "''.chr(hexdec('\\1')).''",$manager_context); |
---|
| 385 | |
---|
[2] | 386 | // Verifica se tem acesso a este modulo |
---|
| 387 | if (!$this->functions->check_acl($account_lid,'delete_sectors')) |
---|
| 388 | { |
---|
| 389 | $GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/expressoAdmin1_2/inc/access_denied.php')); |
---|
| 390 | } |
---|
| 391 | |
---|
| 392 | unset($GLOBALS['phpgw_info']['flags']['noheader']); |
---|
| 393 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']); |
---|
[309] | 394 | $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['expressoAdmin1_2']['title'].' - '.lang('Delete Sectors'); |
---|
[2] | 395 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
| 396 | |
---|
| 397 | // Set o template |
---|
| 398 | $p = CreateObject('phpgwapi.Template',PHPGW_APP_TPL); |
---|
| 399 | $p->set_file(Array('delete_sector' => 'sectors_delete.tpl')); |
---|
[414] | 400 | $p->set_block('delete_sector','list','list'); |
---|
[2] | 401 | |
---|
| 402 | $tmp_sector_name = $_GET['context']; |
---|
| 403 | $tmp_sector_name = explode(",",$tmp_sector_name); |
---|
| 404 | $tmp_sector_name = $tmp_sector_name[0]; |
---|
| 405 | $tmp_sector_name = explode("=", $tmp_sector_name); |
---|
| 406 | $sector_name = $tmp_sector_name[1]; |
---|
| 407 | |
---|
[5133] | 408 | |
---|
[2] | 409 | // Get users of sector |
---|
[5133] | 410 | $sector_users = $this->so->get_sector_users(utf8_encode($_GET['context'])); |
---|
| 411 | $sector_groups = $this->so->get_sector_groups(utf8_encode($_GET['context'])); |
---|
| 412 | $sector_subsectors = $this->so->get_sector_subsectors(utf8_encode($_GET['context'])); |
---|
[2] | 413 | |
---|
| 414 | $users_list = ''; |
---|
| 415 | foreach ($sector_users as $user) |
---|
| 416 | { |
---|
| 417 | $users_list .= $user['cn'][0] . '<br>'; |
---|
| 418 | } |
---|
| 419 | |
---|
| 420 | $groups_list = ''; |
---|
| 421 | foreach ($sector_groups as $group) |
---|
| 422 | { |
---|
| 423 | $groups_list .= $group['cn'][0] . '<br>'; |
---|
| 424 | } |
---|
| 425 | |
---|
| 426 | $subsectors_list = ''; |
---|
| 427 | foreach ($sector_subsectors as $subsector) |
---|
| 428 | { |
---|
| 429 | if ($subsector['dn'] != $_GET['context']) |
---|
[5133] | 430 | $subsectors_list .= utf8_decode($subsector['ou'][0] . '<br>'); |
---|
[2] | 431 | } |
---|
| 432 | |
---|
| 433 | // Seta variaveis utilizadas pelo tpl. |
---|
| 434 | $var = Array( |
---|
| 435 | 'color_bg1' => "#E8F0F0", |
---|
| 436 | 'manager_context' => $manager_context, |
---|
| 437 | 'dn' => $_GET['context'], |
---|
| 438 | 'back_url' => $GLOBALS['phpgw']->link('/index.php','menuaction=expressoAdmin1_2.uisectors.list_sectors'), |
---|
| 439 | 'action' => $GLOBALS['phpgw']->link('/index.php','menuaction=expressoAdmin1_2.bosectors.delete_sector'), |
---|
| 440 | |
---|
| 441 | 'sector_name' => $sector_name, |
---|
| 442 | 'users_list' => $users_list, |
---|
| 443 | 'groups_list' => $groups_list, |
---|
| 444 | 'sectors_list' => $subsectors_list |
---|
| 445 | ); |
---|
[6697] | 446 | $var['sector_name'] =utf8_decode( preg_replace("/\\\([0-9A-Fa-f]{2})/e", "''.chr(hexdec('\\1')).''",$var['sector_name'])); |
---|
[5133] | 447 | |
---|
[2] | 448 | $p->set_var($var); |
---|
[414] | 449 | $p->set_var($this->functions->make_dinamic_lang($p, 'list')); |
---|
[2] | 450 | $p->pfp('out','delete_sector'); |
---|
| 451 | } |
---|
| 452 | |
---|
[548] | 453 | function row_action($action,$type,$context,$class='uisectors') |
---|
[2] | 454 | { |
---|
| 455 | return '<a href="'.$GLOBALS['phpgw']->link('/index.php',Array( |
---|
[548] | 456 | 'menuaction' => 'expressoAdmin1_2.'.$class.'.'.$action.'_'.$type, |
---|
[2] | 457 | 'context' => $context |
---|
| 458 | )).'"> '.lang($action).' </a>'; |
---|
| 459 | } |
---|
| 460 | |
---|
| 461 | function css() |
---|
| 462 | { |
---|
| 463 | $appCSS = ''; |
---|
| 464 | return $appCSS; |
---|
| 465 | } |
---|
| 466 | |
---|
| 467 | } |
---|
[548] | 468 | ?> |
---|