source: sandbox/2.2.0.2/admin/inc/class.uiconfig.inc.php @ 4548

Revision 4548, 13.7 KB checked in by airton, 13 years ago (diff)

Ticket #1954 - Implementacao de busca avançada no contactcenter - Padronizacao da tela de busca avancada

  • Property svn:eol-style set to native
  • Property svn:executable set to *
RevLine 
[2]1<?php
2  /**************************************************************************\
3  * eGroupWare - Admin config                                                *
4  * Written by Miles Lott <milosch@phpwhere.org>                             *
5  * http://www.egroupware.org                                                *
6  * --------------------------------------------                             *
7  *  This program is free software; you can redistribute it and/or modify it *
8  *  under the terms of the GNU General Public License as published by the   *
9  *  Free Software Foundation; either version 2 of the License, or (at your  *
10  *  option) any later version.                                              *
11  \**************************************************************************/
12
13
14        class uiconfig
15        {
16                var $public_functions = array('index' => True);
17
18                function index()
19                {
20                        if ($GLOBALS['phpgw']->acl->check('site_config_access',1,'admin'))
21                        {
22                                $GLOBALS['phpgw']->redirect_link('/index.php');
23                        }
24
25                        if(get_magic_quotes_gpc() && is_array($_POST['newsettings']))
26                        {
27                                $_POST['newsettings'] = array_map("stripslashes", $_POST['newsettings']);
28                        }
29                       
30                        switch($_GET['appname'])
31                        {
32                                case 'admin':
33                                case 'addressbook':
34                                case 'calendar':
35                                case 'email':
36                                case 'instant_messenger':
[382]37                                case 'jabberit_messenger':
[2]38                                case 'nntp':
39                                        /*
40                                        Other special apps can go here for now, e.g.:
41                                        case 'bogusappname':
42                                        */
43                                        $appname = $_GET['appname'];
44                                        $config_appname = 'phpgwapi';
45                                        break;
46                                case 'phpgwapi':
47                                case '':
48                                        /* This keeps the admin from getting into what is a setup-only config */
49                                        $GLOBALS['phpgw']->redirect_link('/admin/index.php');
50                                        break;
51                                default:
52                                        $appname = $_GET['appname'];
53                                        $config_appname = $appname;
54                                        break;
55                        }
56
57                        $t = CreateObject('phpgwapi.Template',$GLOBALS['phpgw']->common->get_tpl_dir($appname));
58                        $t->set_unknowns('keep');
59                        $t->set_file(array('config' => 'config.tpl'));
60                        $t->set_block('config','header','header');
61                        $t->set_block('config','body','body');
62                        $t->set_block('config','footer','footer');
63
64                        $c = CreateObject('phpgwapi.config',$config_appname);
65                        $c->read_repository();
66
67                        if ($c->config_data)
68                        {
69                                $current_config = $c->config_data;
70                        }
71
72                        if ($_POST['cancel'] || $_POST['submit'] && $GLOBALS['phpgw']->acl->check('site_config_access',2,'admin'))
73                        {
74                                $GLOBALS['phpgw']->redirect_link('/admin/index.php');
75                        }
76
77                        if ($_POST['submit'])
78                        {
79                                /* Load hook file with functions to validate each config (one/none/all) */
80                                $GLOBALS['phpgw']->hooks->single('config_validate',$appname);
[4500]81                               
82                                if (!isset($_POST['newsettings']['cc_allow_details'])) {
83                                        $_POST['newsettings']['cc_allow_details'] = "false";
84                                }
[2]85
86                                foreach($_POST['newsettings'] as $key => $config)
87                                {
[4500]88                                       
89                                        if ($config) 
90                                        {                                                                                                                                                                                 // Código adicionado 
91                                                if($GLOBALS['phpgw_info']['server']['found_validation_hook'] && (function_exists($key) || function_exists(substr($key,0,strrpos($key,'_')))) )
[2]92                                                {
[4500]93                                                        if(function_exists(substr($key,0,strrpos($key,'_'))))
94                                {
95                                call_user_func(substr($key,0,strrpos($key,'_')),&$config);
96                                }
97                                else
98                                {
99                                call_user_func($key,&$config);
100                                }
101
102                                if($GLOBALS['config_error'])
[2]103                                                        {
104                                                                $errors .= lang($GLOBALS['config_error']) . '&nbsp;';
105                                                                $GLOBALS['config_error'] = False;
106                                                        }
107                                                        else
108                                                        {
109                                                                $c->config_data[$key] = $config;
110                                                        }
111                                                }
112                                                else
113                                                {
114                                                        $c->config_data[$key] = $config;
115                                                }
116                                        }
117                                        else
118                                        {
119                                                /* don't erase passwords, since we also don't print them */
[4548]120                                                if(!ereg('passwd',$key) && !ereg('password',$key) && !ereg('root_pw',$key) && !ereg('pw',$key))
[2]121                                                {
122                                                        unset($c->config_data[$key]);
123                                                }
124                                        }
125                                }
126                                if($GLOBALS['phpgw_info']['server']['found_validation_hook'] && function_exists('final_validation'))
127                                {
[4548]128                                        final_validation($c->config_data);
[2]129                                        if($GLOBALS['config_error'])
130                                        {
131                                                $errors .= lang($GLOBALS['config_error']) . '&nbsp;';
132                                                $GLOBALS['config_error'] = False;
133                                        }
134                                        unset($GLOBALS['phpgw_info']['server']['found_validation_hook']);
135                                }
136
137                                $c->save_repository();
138
139                                if(!$errors)
140                                {
141                                        $GLOBALS['phpgw']->redirect_link('/admin/index.php');
142                                }
143                        }
144
145                        if($errors)
146                        {
147                                $t->set_var('error',lang('Error') . ': ' . $errors);
148                                $t->set_var('th_err','#FF8888');
149                                unset($errors);
150                                unset($GLOBALS['config_error']);
151                        }
152                        else
153                        {
154                                $t->set_var('error','');
155                                $t->set_var('th_err',$GLOBALS['phpgw_info']['theme']['th_bg']);
156                        }
157
158                        if(!@is_object($GLOBALS['phpgw']->js))
159                        {
160                                $GLOBALS['phpgw']->js = CreateObject('phpgwapi.javascript');
161                        }
162                        $GLOBALS['phpgw']->js->validate_file('jscode','openwindow','admin');
163
164                        $GLOBALS['phpgw']->common->phpgw_header();
165                        echo parse_navbar();
166
[4500]167                       
168                        $campos = '';
[4548]169                        $checked_box = array();
170                        $i = 0;
[4500]171                       
172                        if($appname=="contactcenter")
173                        {
174                               
175                                foreach ($c->config_data as $key => $config)
176                                {               
177                                        $parts = explode('_', $key);
178                        if (is_numeric($parts[3]) && $parts[1]=='attribute')
179                        {
180                        $fields[$parts[3]][$key] = $config;
181                        }
182                       
183                       
184                        if($key == 'cc_allow_details') {
185                                $checkedCoisa = 'value="details"';
186                                if ($config=='true') {
187                                        $checkedCoisa = 'value="details" checked="checked"';
188                                }
[4548]189                        }                       
190                                }
191       
192                                $campos_vazio = true;
193                                $campos = "<div>
194                                                                <label style=\"margin:46px;\">" . lang('Name')               . "</label>
195                                                                <label style=\"margin:50px;\">" . lang('Corresponding LDAP') . "</label>
196                                                                <label style=\"margin:25px;\">" . lang('Type')               . "</label>
197                                                                <label style=\"margin:10px;\">" . lang('Searchable')         . "</label>
198                                                        </div>";
[4500]199               
200                        foreach ($fields as $i => $line)
201                        {
[4548]202                                        if ($line["cc_attribute_name_$i"] != '' && $line["cc_attribute_ldapname_$i"] != '') {
203                                                $campos_vazio  = false;
[4500]204                        $selectedText  = $line["cc_attribute_type_$i"] == 'text' ? 'selected="selected"' : '';
205                        $selectedTMult = $line["cc_attribute_type_$i"] == 'multivalues' ? 'selected="selected"' : '';
[4548]206                                                $selectedYes   = $line["cc_attribute_searchable_$i"] == 'true'  ? 'selected="selected"' : '';
207                                                $selectedNo    = $line["cc_attribute_searchable_$i"] == 'false' ? 'selected="selected"' : '';
208
209                                               
[4500]210                                $campos = $campos . "<div class=\"cc_attribute\">
[4548]211                                                                        <input type=\"text\" name=\"newsettings[cc_attribute_name_" . $i . "]\" value=\"".$line["cc_attribute_name_$i"]."\" style=\"width:170px;\"/>
212                                                                        <input type=\"text\" name=\"newsettings[cc_attribute_ldapname_" . $i . "]\" value=\"".$line["cc_attribute_ldapname_$i"]."\" style=\"width:170px;\"/>
213                                                                        <select name=\"newsettings[cc_attribute_type_" . $i . "]\" style=\"width:86px; margin: 0px 0px 0px 8px;\">
214                                                                                        <option value=\"text\" $selectedText>" . lang('Text') . "</option>
215                                                                                        <option value=\"multivalues\" $selectedTMult>" . lang('Multivalued') ."</option>
216                                                                        </select>
217                                                                        <select name=\"newsettings[cc_attribute_searchable_$i]\" style=\"margin: 0px 16px;\">
218                                                                                        <option value=\"true\" $selectedYes>" . lang('Yes') . "</option>
219                                                                                        <option value=\"false\" $selectedNo>" . lang('No') . "</option>
220                                                                        </select>
221                                                                        <img src=\"contactcenter/templates/default/images/cc_x.png\" alt=\"". lang('Delete') . "\" style=\"width: 15px; height: 14px; cursor: pointer; position: relative; top: 3px;\" onclick=\"javascript:cc_attribute_delete(this)\"/> 
222                                                                </div>";
[4500]223                        }
224                        }
225               
[4548]226                            if ($campos_vazio)
[4500]227                        {
[4548]228                                $campos .= "<div class=\"cc_attribute\">
229                                <input type=\"text\" name=\"newsettings[cc_attribute_name_0]\" value=\"\" style=\"width:170px;\"/>
230                                <input type=\"text\" name=\"newsettings[cc_attribute_ldapname_0]\" value=\"\" style=\"width:170px;\"/>
231                                <select name=\"newsettings[cc_attribute_type_0]\" style=\"width:86px; margin: 0px 0px 0px 8px;\">
[4500]232                                        <option value=\"text\">" . lang('Text') . "</option>
233                                        <option value=\"multivalues\">" . lang('Multivalued') . "</option>
234                                </select>
[4548]235                                                                <select name=\"newsettings[cc_attribute_searchable_0]\" style=\"margin: 0px 16px;\">
236                                        <option value=\"true\">" . lang('Yes') . "</option>
237                                        <option value=\"false\" selected=\"selected\">" . lang('No') . "</option>
238                                </select>
[4500]239                                <img src=\"contactcenter/templates/default/images/cc_x.png\" alt=\"". lang('Delete') ."\" style=\"width: 15px; height: 14px; cursor: pointer; position: relative; top: 3px;\" onclick=\"javascript:cc_attribute_delete(this)\"/>
240                        </div>";
241                        }
242                       
243                        $t->set_var('lang_add_button', lang('Add'));
244                                $t->set_var('lang_cc_Set_details_attributes',   lang('Details on the Global Catalog Address'));
245                        $t->set_var('lang_cc_Allow_view_details_label', lang('Enable display of contact details for the Global Catalog'));                             
246                        $t->set_var('attribute_fields', $campos);               
247                        $t->set_var('cc_config_js', $GLOBALS['phpgw_info']['server']['webserver_url'] . '/contactcenter/js/cc_config.js');
248                        $t->set_var('cc_allow_view_details_value', $checkedCoisa);
249                        }
250               
251                       
[540]252                        if($appname=="expressoAdmin1_2") {
253                                /* Varre a pasta inc do admin do expresso procurando scripts de geração de login automático
254                                   (classes com nomes iniciados pela string 'login', procedida da string '_' mais o nome
255                                   do algoritmo.
256                                */
[597]257                               
[540]258                                $dir = $GLOBALS['phpgw']->common->get_app_dir($appname) . "/inc";
259                                $options = ' ';
[608]260                                if (is_dir($dir))
261                                {
262                                        if ($dh = opendir($dir))
263                                        {
264                                                while (($file = readdir($dh)) !== false)
265                                                {
[540]266                                                        $temp = explode(".",$file);
[608]267                                                        if( (substr($temp[1],0,5) =='login') && ($temp[0] == 'class') )
268                                                        {
[540]269                                                                $options .= "<option value='".$temp[1]."'";
270                                                                if($current_config['expressoAdmin_loginGenScript'] == $temp[1])
271                                                                        $options .= " selected";
272                                                                $options .= ">" . ucwords(str_replace("_"," ",substr($temp[1],6))) . "</option>";
273                                                        }                               
274                                                }
275                                                closedir($dh);
276                                        }
277                                }
278                               
279                                $t->set_var('rows_login_generator',$options);
280                        }
[547]281                       
282                       
[597]283                        if($appname=="admin") {                                                 
284                                /*
[608]285                                 * FCK editor to agree term
[597]286                                 */
287                                include_once("news_admin/inc/fckeditor.php");
288                                $oFCKeditor = new FCKeditor('newsettings[agree_term]');//CreateObject('news_admin.fckeditor','newsettings[agree_term]');
[1325]289                                $oFCKeditor->BasePath = 'news_admin/templates/default/fckeditor/';
[597]290                                $oFCKeditor->ToolbarSet = 'Basic';
[608]291                                $oFCKeditor->Value = isset($GLOBALS['phpgw_info']['server']['agree_term']) ? $GLOBALS['phpgw_info']['server']['agree_term'] : '';
[597]292                                $t->set_var('agree_term_input',$oFCKeditor->Create());                 
293                        }
[2]294                        $t->set_var('title',lang('Site Configuration'));
295                        $t->set_var('action_url',$GLOBALS['phpgw']->link('/index.php','menuaction=admin.uiconfig.index&appname=' . $appname));
296                        $t->set_var('th_bg',     $GLOBALS['phpgw_info']['theme']['th_bg']);
297                        $t->set_var('th_text',   $GLOBALS['phpgw_info']['theme']['th_text']);
298                        $t->set_var('row_on',    $GLOBALS['phpgw_info']['theme']['row_on']);
299                        $t->set_var('row_off',   $GLOBALS['phpgw_info']['theme']['row_off']);
[3018]300                        $t->set_var('php_upload_limit',str_replace('M','',ini_get('upload_max_filesize')));
[2]301                        $t->pparse('out','header');
302
303                        $vars = $t->get_undefined('body');
304
305                        $GLOBALS['phpgw']->hooks->single('config',$appname);
306
307                        foreach($vars as $value)
308                        {
309                                $valarray = explode('_',$value);
310                                $type = array_shift($valarray);
311                                $newval = implode(' ',$valarray);
312                                switch ($type)
313                                {
314                                        case 'lang':
315                                                $t->set_var($value,lang($newval));
316                                                break;
317                                        case 'value':
318                                                $newval = str_replace(' ','_',$newval);
319                                                /* Don't show passwords in the form */
320                                                if(ereg('passwd',$value) || ereg('password',$value) || ereg('root_pw',$value))
321                                                {
322                                                        $t->set_var($value,'');
323                                                }
324                                                else
325                                                {
[1085]326                                                        $t->set_var($value,htmlspecialchars($current_config[$newval]));
[2]327                                                }
328                                                break;
329                                        /*
330                                        case 'checked':
331                                                $newval = str_replace(' ','_',$newval);
332                                                if ($current_config[$newval])
333                                                {
334                                                        $t->set_var($value,' checked');
335                                                }
336                                                else
337                                                {
338                                                        $t->set_var($value,'');
339                                                }
340                                                break;
341                                        */
342                                        case 'selected':
343                                                $configs = array();
344                                                $config  = '';
345                                                $newvals = explode(' ',$newval);
346                                                $setting = end($newvals);
347                                                for ($i=0;$i<(count($newvals) - 1); $i++)
348                                                {
349                                                        $configs[] = $newvals[$i];
350                                                }
351                                                $config = implode('_',$configs);
352                                                /* echo $config . '=' . $current_config[$config]; */
353                                                if ($current_config[$config] == $setting)
354                                                {
355                                                        $t->set_var($value,' selected');
356                                                }
357                                                else
358                                                {
359                                                        $t->set_var($value,'');
360                                                }
361                                                break;
362                                        case 'hook':
363                                                $newval = str_replace(' ','_',$newval);
364                                                if(function_exists($newval))
365                                                {
366                                                        $t->set_var($value,$newval($current_config));
367                                                }
368                                                else
369                                                {
370                                                        $t->set_var($value,'');
371                                                }
372                                                break;
373                                        default:
374                                        $t->set_var($value,'');
375                                        break;
376                                }
377                        }
378
379                        $t->pfp('out','body');
380
381                        $t->set_var('lang_submit', $GLOBALS['phpgw']->acl->check('site_config_access',2,'admin') ? lang('Cancel') : lang('Save'));
382                        $t->set_var('lang_cancel', lang('Cancel'));
383                        $t->pfp('out','footer');
384                }
385        }
386?>
Note: See TracBrowser for help on using the repository browser.