source: trunk/admin/inc/class.uiconfig.inc.php @ 5804

Revision 5804, 15.5 KB checked in by acoutinho, 12 years ago (diff)

Ticket #2434 - Implementada funcionalidade de criacao de agenda para contas compartilhadas e imposicao de agendas

  • Property svn:eol-style set to native
  • Property svn:executable set to *
Line 
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               
21                                ob_start();
22                        print_r("teste :D :D :D");
23       
24                        $output = ob_get_clean();
25                        file_put_contents( "/tmp/acoutinho.log",  $output , FILE_APPEND);
26               
27                        if ($GLOBALS['phpgw']->acl->check('site_config_access',1,'admin'))
28                        {
29                                $GLOBALS['phpgw']->redirect_link('/index.php');
30                        }
31
32                        if(get_magic_quotes_gpc() && is_array($_POST['newsettings']))
33                        {
34                                $_POST['newsettings'] = array_map("stripslashes", $_POST['newsettings']);
35                        }
36                       
37                        switch($_GET['appname'])
38                        {
39                                case 'admin':
40                                case 'addressbook':
41                                case 'calendar':
42                                case 'email':
43                                case 'instant_messenger':
44                                case 'jabberit_messenger':
45                                case 'nntp':
46                                        /*
47                                        Other special apps can go here for now, e.g.:
48                                        case 'bogusappname':
49                                        */
50                                        $appname = $_GET['appname'];
51                                        $config_appname = 'phpgwapi';
52                                        break;
53                                case 'phpgwapi':
54                                case '':
55                                        /* This keeps the admin from getting into what is a setup-only config */
56                                        $GLOBALS['phpgw']->redirect_link('/admin/index.php');
57                                        break;
58                                default:
59                                        $appname = $_GET['appname'];
60                                        $config_appname = $appname;
61                                        break;
62                        }
63
64                        $t = CreateObject('phpgwapi.Template',$GLOBALS['phpgw']->common->get_tpl_dir($appname));
65                        $t->set_unknowns('keep');
66                        $t->set_file(array('config' => 'config.tpl'));
67                        $t->set_block('config','header','header');
68                        $t->set_block('config','body','body');
69                        $t->set_block('config','footer','footer');
70
71                        $c = CreateObject('phpgwapi.config',$config_appname);
72                        $c->read_repository();
73
74                        if ($c->config_data)
75                        {
76                                $current_config = $c->config_data;
77                        }
78       
79                if($appname === "expressoCalendar"){                                           
80                        if (isset($_POST['migration']) && ($_POST['migration']  == "true")){
81                       
82                                require_once dirname(__FILE__ )."/../../expressoCalendar/inc/class.ui_migration.inc.php";
83
84                                $migratrion = new Migra();
85                                $migratrion->calendar();
86                        }
87                }
88
89                        if ($_POST['cancel'] || $_POST['submit'] && $GLOBALS['phpgw']->acl->check('site_config_access',2,'admin'))
90                        {
91                                $GLOBALS['phpgw']->redirect_link('/admin/index.php');
92                        }
93
94                        if ($_POST['submit'])
95                        {
96                                /* Load hook file with functions to validate each config (one/none/all) */
97                                $GLOBALS['phpgw']->hooks->single('config_validate',$appname);
98                               
99                                if (!isset($_POST['newsettings']['cc_allow_details'])) {
100                                        $_POST['newsettings']['cc_allow_details'] = "false";
101                                }
102
103                                foreach($_POST['newsettings'] as $key => $config)
104                                {
105                                       
106                                        if ($config) 
107                                        {                                                                                                                                                                                 // Código adicionado 
108                                                if($GLOBALS['phpgw_info']['server']['found_validation_hook'] && (function_exists($key) || function_exists(substr($key,0,strrpos($key,'_')))) )
109                                                {
110                                                        if(function_exists(substr($key,0,strrpos($key,'_'))))
111                                {
112                                call_user_func(substr($key,0,strrpos($key,'_')),&$config);
113                                }
114                                else
115                                {
116                                call_user_func($key,&$config);
117                                }
118
119                                if($GLOBALS['config_error'])
120                                                        {
121                                                                $errors .= lang($GLOBALS['config_error']) . '&nbsp;';
122                                                                $GLOBALS['config_error'] = False;
123                                                        }
124                                                        else
125                                                        {
126                                                                $c->config_data[$key] = $config;
127                                                        }
128                                                }
129                                                else
130                                                {
131                                                        $c->config_data[$key] = $config;
132                                                }
133                                        }
134                                        else
135                                        {
136                                                /* don't erase passwords, since we also don't print them */
137                                                if(!preg_match('/passwd/',$key) && !preg_match('/password/',$key) && !preg_match('/root_pw/',$key) && !preg_match('/pw/',$key))
138                                                {
139                                                        unset($c->config_data[$key]);
140                                                }
141                                        }
142                                }
143                                if($GLOBALS['phpgw_info']['server']['found_validation_hook'] && function_exists('final_validation'))
144                                {
145                                        final_validation($c->config_data);
146                                        if($GLOBALS['config_error'])
147                                        {
148                                                $errors .= lang($GLOBALS['config_error']) . '&nbsp;';
149                                                $GLOBALS['config_error'] = False;
150                                        }
151                                        unset($GLOBALS['phpgw_info']['server']['found_validation_hook']);
152                                }
153
154                                $c->save_repository();
155
156                                if(!$errors)
157                                {
158                                        $GLOBALS['phpgw']->redirect_link('/admin/index.php');
159                                }
160                        }
161
162                        if($errors)
163                        {
164                                $t->set_var('error',lang('Error') . ': ' . $errors);
165                                $t->set_var('th_err','#FF8888');
166                                unset($errors);
167                                unset($GLOBALS['config_error']);
168                        }
169                        else
170                        {
171                                $t->set_var('error','');
172                                $t->set_var('th_err',$GLOBALS['phpgw_info']['theme']['th_bg']);
173                        }
174
175                        if(!@is_object($GLOBALS['phpgw']->js))
176                        {
177                                $GLOBALS['phpgw']->js = CreateObject('phpgwapi.javascript');
178                        }
179                        $GLOBALS['phpgw']->js->validate_file('jscode','openwindow','admin');
180
181                        $GLOBALS['phpgw']->common->phpgw_header();
182                        echo parse_navbar();
183
184                       
185                        $campos = '';
186                        $checked_box = array();
187                        $i = 0;
188                       
189                        if($appname=="contactcenter")
190                        {
191                               
192                                foreach ($c->config_data as $key => $config)
193                                {               
194                                        $parts = explode('_', $key);
195                        if (is_numeric($parts[3]) && $parts[1]=='attribute')
196                        {
197                        $fields[$parts[3]][$key] = $config;
198                        }
199                       
200                       
201                        if($key == 'cc_allow_details') {
202                                $checkedCoisa = 'value="details"';
203                                if ($config=='true') {
204                                        $checkedCoisa = 'value="details" checked="checked"';
205                                }
206                        }                       
207                                }
208       
209                                $campos_vazio = true;
210                                $campos = "
211                                                <input type=\"hidden\" id=\"textHidden\" value=\"".lang('Text')."\" />
212                                                <input type=\"hidden\" id=\"multitextHidden\" value=\"".lang('Multivalued')."\" />
213                                                <input type=\"hidden\" id=\"yesHidden\" value=\"".lang('Yes')."\" />
214                                                <input type=\"hidden\" id=\"noHidden\" value=\"".lang('No')."\" />
215                                                <input type=\"hidden\" id=\"deleteHidden\" value=\"".lang('Delete')."\" />
216                                                <table id=\"cc_newconf\" name=\"cc_newconf\" class=\"cc_attribute\">
217                                                   <tbody id=\"cc_newconftable\" name=\"cc_newconftable\">
218                                                        <tr>
219                                                                <td align=\"center\" style=\"width:170px;\">" . lang('Name')               . "</td>
220                                                                <td align=\"center\" style=\"width:170px;\">" . lang('Corresponding LDAP') . "</td>
221                                                                <td align=\"center\" style=\"width:100px; margin: 0px 0px 0px 8px;\">" . lang('Type')               . "</td>
222                                                                <td align=\"center\" style=\"width:80px; margin: 0px 16px;\">" . lang('Searchable')         . "</td>
223                                                                <td align=\"center\" style=\"width: 15px;\">
224                                                        </tr>";
225               
226                        foreach ($fields as $i => $line)
227                        {
228                                        if ($line["cc_attribute_name_$i"] != '' && $line["cc_attribute_ldapname_$i"] != '') {
229                                                $campos_vazio  = false;
230                        $selectedText  = $line["cc_attribute_type_$i"] == 'text' ? 'selected="selected"' : '';
231                        $selectedTMult = $line["cc_attribute_type_$i"] == 'multivalues' ? 'selected="selected"' : '';
232                                                $selectedYes   = $line["cc_attribute_searchable_$i"] == 'true'  ? 'selected="selected"' : '';
233                                                $selectedNo    = $line["cc_attribute_searchable_$i"] == 'false' ? 'selected="selected"' : '';
234
235                                               
236                                $campos = $campos . "
237                                                                <tr>
238                                                                        <td><input type=\"text\" name=\"newsettings[cc_attribute_name_" . $i . "]\" value=\"".$line["cc_attribute_name_$i"]."\" style=\"width:170px;\"></input></td>
239                                                                        <td><input type=\"text\" name=\"newsettings[cc_attribute_ldapname_" . $i . "]\" value=\"".$line["cc_attribute_ldapname_$i"]."\" style=\"width:170px;\"></input></td>
240                                                                        <td><select name=\"newsettings[cc_attribute_type_" . $i . "]\" style=\"width:86px; margin: 0px 0px 0px 8px;\">
241                                                                                        <option value=\"text\" $selectedText>" . lang('Text') . "</option>
242                                                                                        <option value=\"multivalues\" $selectedTMult>" . lang('Multivalued') ."</option>
243                                                                        </select></td>
244                                                                        <td><select name=\"newsettings[cc_attribute_searchable_$i]\" style=\"margin: 0px 16px;\">
245                                                                                        <option value=\"true\" $selectedYes>" . lang('Yes') . "</option>
246                                                                                        <option value=\"false\" $selectedNo>" . lang('No') . "</option>
247                                                                        </select></td>
248                                                                        <td><img src=\"contactcenter/templates/default/images/cc_x.png\" alt=\"". lang('Delete') . "\" title=\"". lang('Delete') ."\" style=\"width: 15px; height: 14px; cursor: pointer; position: relative; top: 3px;\" onclick=\"javascript:cc_attribute_delete(this)\"></img></td> 
249                                                                </tr>";
250                        }
251                        }
252               
253                            if ($campos_vazio)
254                        {
255                                        $campos .= "<tr>
256                                                                        <td><input type=\"text\" name=\"newsettings[cc_attribute_name_0]\" value=\"\" style=\"width:170px;\"/> </td>
257                                                                        <td><input type=\"text\" name=\"newsettings[cc_attribute_ldapname_0]\" value=\"\" style=\"width:170px;\"/> </td>
258                                                                        <td><select name=\"newsettings[cc_attribute_type_0]\" style=\"width:86px; margin: 0px 0px 0px 8px;\">
259                                        <option value=\"text\">" . lang('Text') . "</option>
260                                        <option value=\"multivalues\">" . lang('Multivalued') . "</option>
261                                                                        </select></td>
262                                                                        <td><select name=\"newsettings[cc_attribute_searchable_0]\" style=\"margin: 0px 16px;\">
263                                        <option value=\"true\">" . lang('Yes') . "</option>
264                                        <option value=\"false\" selected=\"selected\">" . lang('No') . "</option>
265                                                                        </select></td>
266                                                                        <td><img src=\"contactcenter/templates/default/images/cc_x.png\" alt=\"". lang('Delete') ."\" title=\"". lang('Delete') ."\" style=\"width: 15px; height: 14px; cursor: pointer; position: relative; top: 3px;\" onclick=\"javascript:cc_attribute_delete(this)\"/></td>
267                                                                </tr>";                         
268                        }
269                        $campos = $campos . "</tbody></table>";
270                       
271                        $t->set_var('lang_add_button', lang('Add'));
272                                $t->set_var('lang_cc_Set_details_attributes',   lang('Details on the Global Catalog Address'));
273                        $t->set_var('lang_cc_Allow_view_details_label', lang('Enable display of contact details for the Global Catalog'));                             
274                        $t->set_var('attribute_fields', $campos);               
275                        $t->set_var('cc_config_js', $GLOBALS['phpgw_info']['server']['webserver_url'] . '/contactcenter/js/cc_config.js');
276                        $t->set_var('cc_allow_view_details_value', $checkedCoisa);
277                        }
278               
279                       
280                        if($appname=="expressoAdmin1_2") {
281                                /* Varre a pasta inc do admin do expresso procurando scripts de geração de login automático
282                                   (classes com nomes iniciados pela string 'login', procedida da string '_' mais o nome
283                                   do algoritmo.
284                                */
285                               
286                                $dir = $GLOBALS['phpgw']->common->get_app_dir($appname) . "/inc";
287                                $options = ' ';
288                                if (is_dir($dir))
289                                {
290                                        if ($dh = opendir($dir))
291                                        {
292                                                while (($file = readdir($dh)) !== false)
293                                                {
294                                                        $temp = explode(".",$file);
295                                                        if( (substr($temp[1],0,5) =='login') && ($temp[0] == 'class') )
296                                                        {
297                                                                $options .= "<option value='".$temp[1]."'";
298                                                                if($current_config['expressoAdmin_loginGenScript'] == $temp[1])
299                                                                        $options .= " selected";
300                                                                $options .= ">" . ucwords(str_replace("_"," ",substr($temp[1],6))) . "</option>";
301                                                        }                               
302                                                }
303                                                closedir($dh);
304                                        }
305                                }
306                               
307                                $t->set_var('rows_login_generator',$options);
308                        }               
309                       
310                        if($appname=="admin") {                                                 
311                                /*
312                                 * New CKEditor to agree term
313                                 */
314                                $content = isset($GLOBALS['phpgw_info']['server']['agree_term']) ? $GLOBALS['phpgw_info']['server']['agree_term'] : '';
315                                $ckeditor = '<script type="text/javascript" src="./library/ckeditor/ckeditor.js"></script>
316                                                        <textarea cols="80" id="newsettings[agree_term]" name="newsettings[agree_term]" rows="10">' . $content . '</textarea>
317                                                        <script type="text/javascript"> CKEDITOR.replace( \'newsettings[agree_term]\',{
318                                                                removePlugins : \'elementspath\',
319                                                                skin : \'office2003\',
320                                                                toolbar : [["Source","Preview","-","Cut","Copy","Paste","-","Print",
321                                                                "Undo","Redo","-","Find","Replace","-","SelectAll" ],
322                                                                ["Table","HorizontalRule","SpecialChar","PageBreak","-","Bold",
323                                                                "Italic","Underline","Strike","-","Subscript","Superscript",
324                                                                "NumberedList","BulletedList","-","Outdent","Indent","Blockquote",
325                                                                "JustifyLeft","JustifyCenter","JustifyRight","JustifyBlock",
326                                                                "Link", "TextColor","BGColor","Maximize"],
327                                                                ["Styles","Format","Font","FontSize"]]
328                                                        });</script>';
329                                $t->set_var('agree_term_input',$ckeditor);
330                        }
331                        $t->set_var('title',lang('Site Configuration'));
332                        $t->set_var('action_url',$GLOBALS['phpgw']->link('/index.php','menuaction=admin.uiconfig.index&appname=' . $appname));
333                        $t->set_var('th_bg',     $GLOBALS['phpgw_info']['theme']['th_bg']);
334                        $t->set_var('th_text',   $GLOBALS['phpgw_info']['theme']['th_text']);
335                        $t->set_var('row_on',    $GLOBALS['phpgw_info']['theme']['row_on']);
336                        $t->set_var('row_off',   $GLOBALS['phpgw_info']['theme']['row_off']);
337                        $t->set_var('php_upload_limit',str_replace('M','',ini_get('upload_max_filesize')));
338                        $t->pparse('out','header');
339
340                        $vars = $t->get_undefined('body');
341
342                        $GLOBALS['phpgw']->hooks->single('config',$appname);
343
344                        foreach($vars as $value)
345                        {
346                                $valarray = explode('_',$value);
347                                $type = array_shift($valarray);
348                                $newval = implode(' ',$valarray);
349                                switch ($type)
350                                {
351                                        case 'lang':
352                                                $t->set_var($value,lang($newval));
353                                                break;
354                                        case 'value':
355                                                $newval = str_replace(' ','_',$newval);
356                                                /* Don't show passwords in the form */
357                                                if(preg_match('/passwd/',$value) || preg_match('/password/',$value) || preg_match('/root_pw/',$value))
358                                                {
359                                                        $t->set_var($value,'');
360                                                }
361                                                else
362                                                {
363                                                        $t->set_var($value,htmlspecialchars($current_config[$newval]));
364                                                }
365                                                break;
366                                        /*
367                                        case 'checked':
368                                                $newval = str_replace(' ','_',$newval);
369                                                if ($current_config[$newval])
370                                                {
371                                                        $t->set_var($value,' checked');
372                                                }
373                                                else
374                                                {
375                                                        $t->set_var($value,'');
376                                                }
377                                                break;
378                                        */
379                                        case 'selected':
380                                                $configs = array();
381                                                $config  = '';
382                                                $newvals = explode(' ',$newval);
383                                                $setting = end($newvals);
384                                                for ($i=0;$i<(count($newvals) - 1); $i++)
385                                                {
386                                                        $configs[] = $newvals[$i];
387                                                }
388                                                $config = implode('_',$configs);
389                                                /* echo $config . '=' . $current_config[$config]; */
390                                                if ($current_config[$config] == $setting)
391                                                {
392                                                        $t->set_var($value,' selected');
393                                                }
394                                                else
395                                                {
396                                                        $t->set_var($value,'');
397                                                }
398                                                break;
399                                        case 'hook':
400                                                $newval = str_replace(' ','_',$newval);
401                                                if(function_exists($newval))
402                                                {
403                                                        $t->set_var($value,$newval($current_config));
404                                                }
405                                                else
406                                                {
407                                                        $t->set_var($value,'');
408                                                }
409                                                break;
410                                        default:
411                                        $t->set_var($value,'');
412                                        break;
413                                }
414                        }
415
416                        $t->pfp('out','body');
417
418                        $t->set_var('lang_submit', $GLOBALS['phpgw']->acl->check('site_config_access',2,'admin') ? lang('Cancel') : lang('Save'));
419                        $t->set_var('lang_cancel', lang('Cancel'));
420                        $t->pfp('out','footer');
421                }
422        }
423?>
Note: See TracBrowser for help on using the repository browser.