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 uimanagers |
---|
13 | { |
---|
14 | var $public_functions = array |
---|
15 | ( |
---|
16 | 'list_managers' => True, |
---|
17 | 'add_managers' => True, |
---|
18 | 'delete_managers' => True, |
---|
19 | 'edit_managers' => True, |
---|
20 | 'validate' => True |
---|
21 | ); |
---|
22 | |
---|
23 | var $functions; |
---|
24 | var $config; |
---|
25 | |
---|
26 | function uimanagers() |
---|
27 | { |
---|
28 | $this->functions = CreateObject('expressoAdmin1_2.functions'); |
---|
29 | $c = CreateObject('phpgwapi.config','expressoAdmin1_2'); |
---|
30 | $c->read_repository(); |
---|
31 | $this->config = $c->config_data; |
---|
32 | |
---|
33 | if(!@is_object($GLOBALS['phpgw']->js)) |
---|
34 | { |
---|
35 | $GLOBALS['phpgw']->js = CreateObject('phpgwapi.javascript'); |
---|
36 | } |
---|
37 | $GLOBALS['phpgw']->js->validate_file('jscode','connector','expressoAdmin1_2');#diretorio, arquivo.js, aplicacao |
---|
38 | $GLOBALS['phpgw']->js->validate_file('jscode','managers','expressoAdmin1_2'); |
---|
39 | } |
---|
40 | |
---|
41 | function row_action($lang,$link,$manager_lid,$context) |
---|
42 | { |
---|
43 | return '<a href="'.$GLOBALS['phpgw']->link('/index.php',Array( |
---|
44 | 'menuaction' => 'expressoAdmin1_2.uimanagers.'.$link, |
---|
45 | 'action' => $lang, |
---|
46 | 'manager_lid' => $manager_lid, |
---|
47 | 'context' => $context |
---|
48 | )).'" onmouseover="window.status=\''.lang($lang).' Manager\'; return true;" onmouseout="window.status=\'\';" >'.lang($lang).' </a>'; |
---|
49 | } |
---|
50 | |
---|
51 | function list_managers() |
---|
52 | { |
---|
53 | // Caso nao seja admin, sai. |
---|
54 | if ($GLOBALS['phpgw']->acl->check('group_access',1,'admin')) |
---|
55 | { |
---|
56 | $GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/admin/index.php')); |
---|
57 | } |
---|
58 | // Imprime o NavBar |
---|
59 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']); |
---|
60 | $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['expressoAdmin1_2']['title'].' - '.lang('List Managers'); |
---|
61 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
62 | |
---|
63 | // Seta o template |
---|
64 | $p = CreateObject('phpgwapi.Template',PHPGW_APP_TPL); |
---|
65 | $p->set_file(array('managers' => 'managers.tpl')); |
---|
66 | $p->set_block('managers','body','body'); |
---|
67 | $p->set_block('managers','row','row'); |
---|
68 | $p->set_block('managers','row_empty','row_empty'); |
---|
69 | $tpl_vars = $p->get_undefined('body'); |
---|
70 | |
---|
71 | $var = Array( |
---|
72 | 'action' => $GLOBALS['phpgw']->link('/index.php','menuaction=expressoAdmin1_2.uimanagers.add_managers'), |
---|
73 | 'tr_color' => '#DDDDDD', |
---|
74 | 'th_bg' => $GLOBALS['phpgw_info']['theme']['th_bg'] |
---|
75 | ); |
---|
76 | |
---|
77 | // Cria dinamicamente os langs |
---|
78 | foreach ($tpl_vars as $atribute) |
---|
79 | { |
---|
80 | $lang = strstr($atribute, 'lang_'); |
---|
81 | if($lang !== false) |
---|
82 | { |
---|
83 | $p->set_var($atribute, $this->make_lang($atribute)); |
---|
84 | } |
---|
85 | } |
---|
86 | |
---|
87 | // Le BD para pegar os administradors. |
---|
88 | $query = 'SELECT manager_lid,context FROM phpgw_expressoadmin ORDER by manager_lid'; |
---|
89 | $GLOBALS['phpgw']->db->query($query); |
---|
90 | while($GLOBALS['phpgw']->db->next_record()) |
---|
91 | { |
---|
92 | $managers[] = $GLOBALS['phpgw']->db->row(); |
---|
93 | } |
---|
94 | $ldap_conn = $GLOBALS['phpgw']->common->ldapConnect(); |
---|
95 | $justthese = array("cn"); |
---|
96 | // Loop para listar os administradores |
---|
97 | if (count($managers)) |
---|
98 | { |
---|
99 | foreach($managers as $array_managers) |
---|
100 | { |
---|
101 | $managers_context = ""; |
---|
102 | $a_managers_context = split("%", $array_managers['context']); |
---|
103 | |
---|
104 | foreach ($a_managers_context as $context) |
---|
105 | { |
---|
106 | $managers_context .= "$context<br>"; |
---|
107 | } |
---|
108 | |
---|
109 | $filter="(&(phpgwAccountType=u)(uid=".$array_managers['manager_lid']."))"; |
---|
110 | $ldap_search = ldap_search($ldap_conn, $GLOBALS['phpgw_info']['server']['ldap_context'], $filter, $justthese); |
---|
111 | $ldap_result = ldap_get_entries($ldap_conn, $ldap_search); |
---|
112 | $p->set_var('manager_lid', $array_managers[manager_lid]); |
---|
113 | $p->set_var('manager_cn', $ldap_result[0]['cn'][0] == '' ? '<font color=red>NAO ENCONTRADO NO LDAP</font>' : $ldap_result[0]['cn'][0]); |
---|
114 | $p->set_var('context', $managers_context); |
---|
115 | $p->set_var('link_edit',$this->row_action('edit','edit_managers',$array_managers[manager_lid],$array_managers[context])); |
---|
116 | $p->set_var('link_delete',$this->row_action('delete','delete_managers',$array_managers[manager_lid],$array_managers[context])); |
---|
117 | $p->set_var('link_copy',"<a href='#' onClick='javascript:copy_manager(\"".$array_managers['manager_lid']."\");'>Copiar</a>"); |
---|
118 | $p->fp('rows','row',True); |
---|
119 | } |
---|
120 | } |
---|
121 | $p->set_var($var); |
---|
122 | $p->pfp('out','body'); |
---|
123 | ldap_close($ldap_conn); |
---|
124 | } |
---|
125 | |
---|
126 | |
---|
127 | function add_managers() |
---|
128 | { |
---|
129 | // Caso nao seja admin, sai. |
---|
130 | if ($GLOBALS['phpgw']->acl->check('group_access',1,'admin')) |
---|
131 | { |
---|
132 | $GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/admin/index.php')); |
---|
133 | } |
---|
134 | |
---|
135 | // Seta o template |
---|
136 | $p = CreateObject('phpgwapi.Template',PHPGW_APP_TPL); |
---|
137 | $p->set_file(array('managers' => 'managers_form.tpl')); |
---|
138 | $p->set_block('managers','form','form'); |
---|
139 | $tpl_vars = $p->get_undefined('form'); |
---|
140 | |
---|
141 | // Imprime o NavBar |
---|
142 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']); |
---|
143 | $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['expressoAdmin1_2']['title'].' - '.lang('Add Managers'); |
---|
144 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
145 | |
---|
146 | // Seta variaveis javascript necessárias |
---|
147 | $webserver_url = $GLOBALS['phpgw_info']['server']['webserver_url']; |
---|
148 | $scripts_java = '<script type="text/javascript" src="'.$webserver_url.'/expressoAdmin1_2/js/jscode/expressoadmin.js"></script>'; |
---|
149 | |
---|
150 | // App, create list of available apps |
---|
151 | $applications_list = $this->make_app_list(''); |
---|
152 | |
---|
153 | /* |
---|
154 | if ($_POST['context']) |
---|
155 | { |
---|
156 | $contexts = split("%", $_POST['context']); |
---|
157 | foreach ($contexts as $manager_context) |
---|
158 | $input_context_fields .= "<input type='text' size=60 value=$manager_context></input><br>"; |
---|
159 | } |
---|
160 | else |
---|
161 | $input_context_fields = '<input type="text" size=60></input><br>'; |
---|
162 | */ |
---|
163 | |
---|
164 | $options_context = $this->functions->get_organizations($GLOBALS['phpgw_info']['server']['ldap_context'], '', false, true, false); |
---|
165 | |
---|
166 | // Seta variaveis que estao no TPL |
---|
167 | $var = Array( |
---|
168 | 'scripts_java' => $scripts_java, |
---|
169 | //'action' => $GLOBALS['phpgw']->link('/index.php','menuaction=expressoAdmin1_2.uimanagers.validate'), |
---|
170 | //'action' => $GLOBALS['phpgw']->link('/index.php','menuaction=expressoAdmin1_2.bomanagers.add_managers'), |
---|
171 | 'display_samba_suport' => $this->config['expressoAdmin_samba_support'] == 'true' ? '' : 'display:none', |
---|
172 | 'type' => "add", |
---|
173 | 'color_bg1' => "#E8F0F0", |
---|
174 | 'color_bg2' => "#D3DCE3", |
---|
175 | 'color_font1' => "#DDDDDD", |
---|
176 | 'color_font2' => "#EEEEEE", |
---|
177 | 'input_context_fields' => $input_context_fields, |
---|
178 | 'error_messages' => $_POST['error_messages'] == '' ? '' : '<script language="JavaScript">alert("'.$_POST['error_messages'].'");</script>', |
---|
179 | 'manager_lid' => $_POST['manager_lid'], |
---|
180 | 'context' => $_POST['context'], |
---|
181 | 'app_list' => $applications_list, |
---|
182 | 'options_contexts' => $options_context |
---|
183 | ); |
---|
184 | $p->set_var($var); |
---|
185 | |
---|
186 | // Cria dinamicamente os langs e seta acls |
---|
187 | foreach ($tpl_vars as $atribute) |
---|
188 | { |
---|
189 | $acl = strstr($atribute, 'acl_'); |
---|
190 | $lang = strstr($atribute, 'lang_'); |
---|
191 | // Recuperar os valores das ACLS |
---|
192 | if ($acl !== false) |
---|
193 | { |
---|
194 | $p->set_var($atribute, $_POST[$atribute] != '' ? 'checked' : ''); |
---|
195 | } |
---|
196 | // Setar os langs do tpl. |
---|
197 | elseif($lang !== false) |
---|
198 | { |
---|
199 | $p->set_var($atribute, $this->make_lang($atribute)); |
---|
200 | } |
---|
201 | } |
---|
202 | |
---|
203 | echo $p->fp('out','form'); |
---|
204 | } |
---|
205 | |
---|
206 | function delete_managers() |
---|
207 | { |
---|
208 | // Criar uma verificação e jogar a query para o BO. |
---|
209 | $context = $_GET['context']; |
---|
210 | $manager_lid = $_GET['manager_lid']; |
---|
211 | |
---|
212 | $query = "DELETE FROM phpgw_expressoadmin WHERE manager_lid = '".$manager_lid."' AND context = '" . $context ."'"; |
---|
213 | $GLOBALS['phpgw']->db->query($query); |
---|
214 | |
---|
215 | // Remove Gerente da tabela dos apps |
---|
216 | $query = "DELETE FROM phpgw_expressoadmin_apps WHERE " |
---|
217 | . "manager_lid = '".$manager_lid."' AND " |
---|
218 | . "context = '".$context."'"; |
---|
219 | $GLOBALS['phpgw']->db->query($query); |
---|
220 | |
---|
221 | // Remove Gerente na ACL do expressoadmin |
---|
222 | $accounts = CreateObject('phpgwapi.accounts'); |
---|
223 | $manager_id = $accounts->name2id($_GET['manager_lid']); |
---|
224 | $sql = "DELETE FROM phpgw_acl WHERE acl_appname = 'expressoadmin' AND acl_account = '" . $manager_id . "'"; |
---|
225 | $GLOBALS['phpgw']->db->query($sql); |
---|
226 | |
---|
227 | ExecMethod('expressoAdmin1_2.uimanagers.list_managers'); |
---|
228 | } |
---|
229 | |
---|
230 | function edit_managers() |
---|
231 | { |
---|
232 | // Caso nao seja admin, sai. |
---|
233 | if ($GLOBALS['phpgw']->acl->check('group_access',1,'admin')) |
---|
234 | { |
---|
235 | $GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/admin/index.php')); |
---|
236 | } |
---|
237 | |
---|
238 | // Verifica se eh a primeira entrada, ai eu tenho o get, senao pego o post. |
---|
239 | if ($_GET['manager_lid'] != '') |
---|
240 | { |
---|
241 | $first_time = true; |
---|
242 | $_POST['manager_lid'] = $_GET['manager_lid']; |
---|
243 | $_POST['context'] = $_GET['context']; |
---|
244 | $hidden_manager_lid = $_GET['manager_lid']; |
---|
245 | } |
---|
246 | elseif ($_POST['manager_lid'] != '') |
---|
247 | { |
---|
248 | $first_time = false; |
---|
249 | $hidden_manager_lid = $_POST['old_manager_lid']; |
---|
250 | } |
---|
251 | |
---|
252 | if ($first_time) |
---|
253 | { |
---|
254 | //Pego ACL do gerente |
---|
255 | $manager = $this->functions->read_acl($_GET['manager_lid']); |
---|
256 | //Cria vetor da ACL |
---|
257 | $manager_acl = $this->functions->make_array_acl($manager['acl']); |
---|
258 | |
---|
259 | //Pesquisa no Banco e pega os valores dos apps. |
---|
260 | $query = "SELECT * FROM phpgw_expressoadmin_apps WHERE manager_lid = '" . $_GET['manager_lid'] . "' AND context = '" . $_GET['context'] . "'"; |
---|
261 | $GLOBALS['phpgw']->db->query($query); |
---|
262 | $i=0; |
---|
263 | $manager[0]['apps'] = array(); |
---|
264 | while($GLOBALS['phpgw']->db->next_record()) |
---|
265 | { |
---|
266 | $tmp[$i] = $GLOBALS['phpgw']->db->row(); |
---|
267 | $_POST['applications_list'][$tmp[$i]['app']] = 1; |
---|
268 | $manager[0]['apps'][$tmp[$i]['app']] = 1; |
---|
269 | $i++; |
---|
270 | } |
---|
271 | } |
---|
272 | |
---|
273 | // Seta o template |
---|
274 | $p = CreateObject('phpgwapi.Template',PHPGW_APP_TPL); |
---|
275 | $p->set_file(array('managers' => 'managers_form.tpl')); |
---|
276 | $p->set_block('managers','form','form'); |
---|
277 | $tpl_vars = $p->get_undefined('form'); |
---|
278 | |
---|
279 | // Imprime o NavBar |
---|
280 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']); |
---|
281 | $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['expressoAdmin1_2']['title'].' - '.lang('Edit Managers'); |
---|
282 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
283 | |
---|
284 | // Seta variaveis javas necessárias |
---|
285 | $webserver_url = $GLOBALS['phpgw_info']['server']['webserver_url']; |
---|
286 | $scripts_java = '<script type="text/javascript" src="'.$webserver_url.'/expressoAdmin1_2/js/jscode/expressoadmin.js"></script>'; |
---|
287 | |
---|
288 | // App, create list of available apps |
---|
289 | $applications_list = $this->make_app_list($manager[0]['apps']); |
---|
290 | |
---|
291 | $a_context = split("%", $_POST['context']); |
---|
292 | foreach ($a_context as $context) |
---|
293 | $input_context_fields .= '<div><input disabled type="text" value="'.$context.'" size=60></input><span onclick="this.parentNode.parentNode.removeChild(this.parentNode);" style="cursor:pointer"> -</span></div>'; |
---|
294 | $options_context = $this->functions->get_organizations($GLOBALS['phpgw_info']['server']['ldap_context'], '', false, true, false); |
---|
295 | |
---|
296 | $var = Array( |
---|
297 | 'scripts_java' => $scripts_java, |
---|
298 | 'action' => $GLOBALS['phpgw']->link('/index.php','menuaction=expressoAdmin1_2.uimanagers.validate'), |
---|
299 | 'display_samba_suport' => $this->config['expressoAdmin_samba_support'] == 'true' ? '' : 'display:none', |
---|
300 | 'color_bg1' => "#E8F0F0", |
---|
301 | 'color_bg2' => "#D3DCE3", |
---|
302 | 'color_font1' => "#DDDDDD", |
---|
303 | 'color_font2' => "#EEEEEE", |
---|
304 | 'type' => "edit", |
---|
305 | 'display_manager_select' => 'none', |
---|
306 | 'input_manager_lid_disabled'=> 'disabled', |
---|
307 | 'error_messages' => $_POST['error_messages'] == '' ? '' : '<script language="JavaScript1.3">alert("'.$_POST['error_messages'].'");</script>', |
---|
308 | 'manager_lid' => $_POST['manager_lid'], |
---|
309 | 'hidden_manager_lid' => $_POST['manager_lid'], |
---|
310 | 'context' => $_POST['context'], |
---|
311 | |
---|
312 | 'input_context_fields' => $input_context_fields, |
---|
313 | 'options_contexts' => $options_context, |
---|
314 | |
---|
315 | 'hidden_manager_lid' => $hidden_manager_lid, |
---|
316 | 'app_list' => $applications_list |
---|
317 | ); |
---|
318 | $p->set_var($var); |
---|
319 | |
---|
320 | // Cria dinamicamente os langs e seta acls |
---|
321 | foreach ($tpl_vars as $atribute) |
---|
322 | { |
---|
323 | $acl = strstr($atribute, 'acl_'); |
---|
324 | $lang = strstr($atribute, 'lang_'); |
---|
325 | // Recuperar os valores das ACLS |
---|
326 | if ($acl !== false) |
---|
327 | { |
---|
328 | if ($first_time) |
---|
329 | $p->set_var($atribute, $manager_acl[$atribute] != '' ? 'checked' : ''); |
---|
330 | else |
---|
331 | $p->set_var($atribute, $_POST[$atribute] != '' ? 'checked' : ''); |
---|
332 | } |
---|
333 | // Setar os langs do tpl. |
---|
334 | elseif($lang !== false) |
---|
335 | { |
---|
336 | $p->set_var($atribute, $this->make_lang($atribute)); |
---|
337 | } |
---|
338 | } |
---|
339 | |
---|
340 | echo $p->fp('out','form'); |
---|
341 | } |
---|
342 | |
---|
343 | /* |
---|
344 | function validate() |
---|
345 | { |
---|
346 | return 'OK'; |
---|
347 | |
---|
348 | $accounts = CreateObject('phpgwapi.accounts'); |
---|
349 | $errors = array(); |
---|
350 | |
---|
351 | |
---|
352 | // verifica se o manager existe. caso retorne 1 existe e eh uma conta de usuario. |
---|
353 | $manager_lid_exists = $accounts->exists($_POST['ea_select_managers']); |
---|
354 | if ($manager_lid_exists != 1) |
---|
355 | { |
---|
356 | $_POST['error_messages'] = lang("Manager LID don't exist."); |
---|
357 | if ($_POST['type'] == 'add') |
---|
358 | $this->add_managers(); |
---|
359 | elseif ($_POST['type'] == 'edit') |
---|
360 | $this->edit_managers(); |
---|
361 | return; |
---|
362 | } |
---|
363 | |
---|
364 | |
---|
365 | // Verifica se o contexto existe. |
---|
366 | $dn = $GLOBALS['phpgw_info']['server']['ldap_root_dn']; |
---|
367 | $passwd = $GLOBALS['phpgw_info']['server']['ldap_root_pw']; |
---|
368 | $ldap_conn = ldap_connect($GLOBALS['phpgw_info']['server']['ldap_host']); |
---|
369 | ldap_set_option($ldap_conn, LDAP_OPT_PROTOCOL_VERSION, 3); |
---|
370 | ldap_set_option($ldap_conn, LDAP_OPT_REFERRALS, 0); |
---|
371 | ldap_bind($ldap_conn,$dn,$passwd); |
---|
372 | |
---|
373 | $contexts = split("%", $_POST['context']); |
---|
374 | |
---|
375 | foreach ($contexts as $index=>$context) |
---|
376 | { |
---|
377 | $sr=@ldap_list($ldap_conn, $context, "cn=*"); |
---|
378 | if (!$sr) |
---|
379 | { |
---|
380 | $_POST['error_messages'] = lang("Context don't exist") . ": $context"; |
---|
381 | ldap_close($ldap_conn); |
---|
382 | if ($_POST['type'] == 'add') |
---|
383 | $this->add_managers(); |
---|
384 | elseif ($_POST['type'] == 'edit') |
---|
385 | $this->edit_managers(); |
---|
386 | return; |
---|
387 | } |
---|
388 | } |
---|
389 | |
---|
390 | if ($_POST['type'] == 'add') |
---|
391 | { |
---|
392 | //Verifica se ja existe o manager com aquele contexto cadastrado |
---|
393 | $query = "SELECT manager_lid FROM phpgw_expressoadmin WHERE manager_lid = '" . $_POST['ea_select_manager'] . "' AND context = '" . $_POST['context'] . "'"; |
---|
394 | $GLOBALS['phpgw']->db->query($query); |
---|
395 | $num_registros = 0; |
---|
396 | while($GLOBALS['phpgw']->db->next_record()) |
---|
397 | { |
---|
398 | $tmp[] = $GLOBALS['phpgw']->db->row(); |
---|
399 | $num_registros++; |
---|
400 | } |
---|
401 | if ($num_registros != 0) |
---|
402 | { |
---|
403 | $_POST['error_messages'] = lang('Este Gerente, neste contexto já exite !!'); |
---|
404 | $this->add_managers(); |
---|
405 | return; |
---|
406 | } |
---|
407 | } |
---|
408 | |
---|
409 | if ($_POST['type'] == 'add') |
---|
410 | ExecMethod('expressoAdmin1_2.bomanagers.add_managers'); |
---|
411 | elseif ($_POST['type'] == 'edit') |
---|
412 | ExecMethod('expressoAdmin1_2.bomanagers.edit_managers'); |
---|
413 | |
---|
414 | return true; |
---|
415 | } |
---|
416 | */ |
---|
417 | |
---|
418 | function make_lang($ram_lang) |
---|
419 | { |
---|
420 | $a_lang = split("_", $ram_lang); |
---|
421 | $a_lang_reverse = array_reverse ( $a_lang, true ); |
---|
422 | //Retira o lang do array. |
---|
423 | array_pop ( $a_lang_reverse ); |
---|
424 | $a_lang = array_reverse ( $a_lang_reverse, true ); |
---|
425 | $a_new_lang = implode ( " ", $a_lang ); |
---|
426 | return lang($a_new_lang); |
---|
427 | } |
---|
428 | |
---|
429 | function make_app_list($manager_app_list) |
---|
430 | { |
---|
431 | $this->nextmatchs = createobject('phpgwapi.nextmatchs'); |
---|
432 | $apps = CreateObject('phpgwapi.applications',$_account_id); |
---|
433 | $db_perms = $apps->read_account_specific(); |
---|
434 | $availableApps = $GLOBALS['phpgw_info']['apps']; |
---|
435 | |
---|
436 | uasort($availableApps,create_function('$a,$b','return strcasecmp($a["title"],$b["title"]);')); |
---|
437 | |
---|
438 | // Loop para criar dinamicamente uma tabela com 3 colunas, cada coluna com um aplicativo e um check box. |
---|
439 | $applications_list = ''; |
---|
440 | $app_col1 = ''; |
---|
441 | $app_col2 = ''; |
---|
442 | $app_col3 = ''; |
---|
443 | $total_apps = count($availableApps); |
---|
444 | $i = 0; |
---|
445 | |
---|
446 | foreach($availableApps as $app => $data) |
---|
447 | { |
---|
448 | // 1 coluna |
---|
449 | if (($i +1) % 3 == 1) |
---|
450 | { |
---|
451 | if ($manager_app_list[$app] == 1) |
---|
452 | $checked = 'checked'; |
---|
453 | else |
---|
454 | $checked = ''; |
---|
455 | $app_col1 = sprintf("<td>%s</td><td width='10'><input type='checkbox' name='applications_list[%s]' value='1' %s %s></td>\n", |
---|
456 | $data['title'],$app,$checked, $disabled); |
---|
457 | |
---|
458 | if ($i == ($total_apps-1)) |
---|
459 | $applications_list .= sprintf('<tr bgcolor="%s">%s</tr>',$this->nextmatchs->alternate_row_color(), $app_col1); |
---|
460 | } |
---|
461 | // 2 coluna |
---|
462 | if (($i +1) % 3 == 2) |
---|
463 | { |
---|
464 | if ($manager_app_list[$app] == 1) |
---|
465 | $checked = 'checked'; |
---|
466 | else |
---|
467 | $checked = ''; |
---|
468 | $app_col2 = sprintf("<td>%s</td><td width='10'><input type='checkbox' name='applications_list[%s]' value='1' %s %s></td>\n", |
---|
469 | $data['title'],$app,$checked, $disabled); |
---|
470 | |
---|
471 | if ($i == ($total_apps-1)) |
---|
472 | $applications_list .= sprintf('<tr bgcolor="%s">%s%s</tr>',$this->nextmatchs->alternate_row_color(), $app_col1,$app_col2); |
---|
473 | } |
---|
474 | // 3 coluna |
---|
475 | if (($i +1) % 3 == 0) |
---|
476 | { |
---|
477 | if ($manager_app_list[$app] == 1) |
---|
478 | $checked = 'checked'; |
---|
479 | else |
---|
480 | $checked = ''; |
---|
481 | $app_col3 = sprintf("<td>%s</td><td width='10'><input type='checkbox' name='applications_list[%s]' value='1' %s %s></td>\n", |
---|
482 | $data['title'],$app,$checked, $disabled); |
---|
483 | |
---|
484 | // Cria nova linha |
---|
485 | $applications_list .= sprintf('<tr bgcolor="%s">%s%s%s</tr>',$this->nextmatchs->alternate_row_color(), $app_col1, $app_col2, $app_col3); |
---|
486 | } |
---|
487 | $i++; |
---|
488 | } |
---|
489 | return $applications_list; |
---|
490 | } |
---|
491 | } |
---|
492 | ?> |
---|