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

Revision 2866, 8.8 KB checked in by fpcorrea, 14 years ago (diff)

Ticket #1088 - Limite de anexos agora trata casos descritos no ticket

  • 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                        if ($GLOBALS['phpgw']->acl->check('site_config_access',1,'admin'))
21                        {
22                                $GLOBALS['phpgw']->redirect_link('/#');
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':
37                                case 'jabberit_messenger':
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/');
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/');
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);
81
82                                foreach($_POST['newsettings'] as $key => $config)
83                                {
84                                        if ($config)
85                                        {
86                                                if($GLOBALS['phpgw_info']['server']['found_validation_hook'] && function_exists($key))
87                                                {
88                                                        call_user_func($key,$config);
89                                                        if($GLOBALS['config_error'])
90                                                        {
91                                                                $errors .= lang($GLOBALS['config_error']) . '&nbsp;';
92                                                                $GLOBALS['config_error'] = False;
93                                                        }
94                                                        else
95                                                        {
96                                                                $c->config_data[$key] = $config;
97                                                        }
98                                                }
99                                                else
100                                                {
101                                                        $c->config_data[$key] = $config;
102                                                }
103                                        }
104                                        else
105                                        {
106                                                /* don't erase passwords, since we also don't print them */
107                                                if(!ereg('passwd',$key) && !ereg('password',$key) && !ereg('root_pw',$key))
108                                                {
109                                                        unset($c->config_data[$key]);
110                                                }
111                                        }
112                                }
113                                if($GLOBALS['phpgw_info']['server']['found_validation_hook'] && function_exists('final_validation'))
114                                {
115                                        final_validation($newsettings);
116                                        if($GLOBALS['config_error'])
117                                        {
118                                                $errors .= lang($GLOBALS['config_error']) . '&nbsp;';
119                                                $GLOBALS['config_error'] = False;
120                                        }
121                                        unset($GLOBALS['phpgw_info']['server']['found_validation_hook']);
122                                }
123
124                                $c->save_repository();
125
126                                if(!$errors)
127                                {
128                                        $GLOBALS[ 'phpgw_info' ][ 'flags' ][ 'java_script' ] .= "<script>ExpressoLivre.link( '{$GLOBALS[ 'phpgw' ] -> link('/admin/')}' );</script>";
129                                        exit;
130                                }
131                        }
132
133                        if($errors)
134                        {
135                                $t->set_var('error',lang('Error') . ': ' . $errors);
136                                $t->set_var('th_err','#FF8888');
137                                unset($errors);
138                                unset($GLOBALS['config_error']);
139                        }
140                        else
141                        {
142                                $t->set_var('error','');
143                                $t->set_var('th_err',$GLOBALS['phpgw_info']['theme']['th_bg']);
144                        }
145
146                        if(!@is_object($GLOBALS['phpgw']->js))
147                        {
148                                $GLOBALS['phpgw']->js = CreateObject('phpgwapi.javascript');
149                        }
150                        $GLOBALS['phpgw']->js->validate_file('jscode','openwindow','admin');
151
152                        //$GLOBALS['phpgw']->common->phpgw_header();
153                        //echo parse_navbar();
154
155                        if($appname=="expressoAdmin1_2") {
156                                /* Varre a pasta inc do admin do expresso procurando scripts de geração de login automático
157                                   (classes com nomes iniciados pela string 'login', procedida da string '_' mais o nome
158                                   do algoritmo.
159                                */
160                               
161                                $dir = $GLOBALS['phpgw']->common->get_app_dir($appname) . "/inc";
162                                $options = ' ';
163                                if (is_dir($dir))
164                                {
165                                        if ($dh = opendir($dir))
166                                        {
167                                                while (($file = readdir($dh)) !== false)
168                                                {
169                                                        $temp = explode(".",$file);
170                                                        if( (substr($temp[1],0,5) =='login') && ($temp[0] == 'class') )
171                                                        {
172                                                                $options .= "<option value='".$temp[1]."'";
173                                                                if($current_config['expressoAdmin_loginGenScript'] == $temp[1])
174                                                                        $options .= " selected";
175                                                                $options .= ">" . ucwords(str_replace("_"," ",substr($temp[1],6))) . "</option>";
176                                                        }                               
177                                                }
178                                                closedir($dh);
179                                        }
180                                }
181                               
182                                $t->set_var('rows_login_generator',$options);
183                        }
184                       
185                       
186                        if($appname=="admin") {                                                 
187                                /*
188                                 * FCK editor to agree term
189                                 */
190                                include_once("news_admin/inc/fckeditor.php");
191                                $oFCKeditor = new FCKeditor('newsettings[agree_term]');//CreateObject('news_admin.fckeditor','newsettings[agree_term]');
192
193                                $webserver_url = $GLOBALS['phpgw_info']['server']['webserver_url'];
194                                $webserver_url = ( !empty($webserver_url) ) ? $webserver_url : '/';
195
196                                if(strrpos($webserver_url,'/') === false || strrpos($webserver_url,'/') != (strlen($webserver_url)-1))
197                                        $webserver_url .= '/';
198
199                                $oFCKeditor->BasePath = $webserver_url . 'news_admin/templates/default/fckeditor/';
200                                $oFCKeditor->ToolbarSet = 'Basic';
201                                $oFCKeditor->Value = isset($GLOBALS['phpgw_info']['server']['agree_term']) ? $GLOBALS['phpgw_info']['server']['agree_term'] : '';
202                                $t->set_var('agree_term_input',$oFCKeditor->Create());                 
203                        }
204                        $t->set_var('title',lang('Site Configuration'));
205                        $t->set_var('action_url',$GLOBALS['phpgw']->link('/index.php','menuaction=admin.uiconfig.index&appname=' . $appname));
206                        $t->set_var('th_bg',     $GLOBALS['phpgw_info']['theme']['th_bg']);
207                        $t->set_var('th_text',   $GLOBALS['phpgw_info']['theme']['th_text']);
208                        $t->set_var('row_on',    $GLOBALS['phpgw_info']['theme']['row_on']);
209                        $t->set_var('row_off',   $GLOBALS['phpgw_info']['theme']['row_off']);
210                        $t->set_var('php_upload_limit',str_replace('M','',ini_get('upload_max_filesize')));
211                        $t->pparse('out','header');
212
213                        $vars = $t->get_undefined('body');
214
215                        $GLOBALS['phpgw']->hooks->single('config',$appname);
216
217                        foreach($vars as $value)
218                        {
219                                $valarray = explode('_',$value);
220                                $type = array_shift($valarray);
221                                $newval = implode(' ',$valarray);
222                                switch ($type)
223                                {
224                                        case 'lang':
225                                                $t->set_var($value,lang($newval));
226                                                break;
227                                        case 'value':
228                                                $newval = str_replace(' ','_',$newval);
229                                                /* Don't show passwords in the form */
230                                                if(ereg('passwd',$value) || ereg('password',$value) || ereg('root_pw',$value))
231                                                {
232                                                        $t->set_var($value,'');
233                                                }
234                                                else
235                                                {
236                                                        $t->set_var($value,htmlspecialchars($current_config[$newval]));
237                                                }
238                                                break;
239                                        /*
240                                        case 'checked':
241                                                $newval = str_replace(' ','_',$newval);
242                                                if ($current_config[$newval])
243                                                {
244                                                        $t->set_var($value,' checked');
245                                                }
246                                                else
247                                                {
248                                                        $t->set_var($value,'');
249                                                }
250                                                break;
251                                        */
252                                        case 'selected':
253                                                $configs = array();
254                                                $config  = '';
255                                                $newvals = explode(' ',$newval);
256                                                $setting = end($newvals);
257                                                for ($i=0;$i<(count($newvals) - 1); $i++)
258                                                {
259                                                        $configs[] = $newvals[$i];
260                                                }
261                                                $config = implode('_',$configs);
262                                                /* echo $config . '=' . $current_config[$config]; */
263                                                if ($current_config[$config] == $setting)
264                                                {
265                                                        $t->set_var($value,' selected');
266                                                }
267                                                else
268                                                {
269                                                        $t->set_var($value,'');
270                                                }
271                                                break;
272                                        case 'hook':
273                                                $newval = str_replace(' ','_',$newval);
274                                                if(function_exists($newval))
275                                                {
276                                                        $t->set_var($value,$newval($current_config));
277                                                }
278                                                else
279                                                {
280                                                        $t->set_var($value,'');
281                                                }
282                                                break;
283                                        default:
284                                        $t->set_var($value,'');
285                                        break;
286                                }
287                        }
288
289                        $t->pfp('out','body');
290
291                        $t->set_var('lang_submit', $GLOBALS['phpgw']->acl->check('site_config_access',2,'admin') ? lang('Cancel') : lang('Save'));
292
293                        $t->set_var('lang_cancel', lang('Cancel'));
294                        $t->set_var( 'cancel_button', $GLOBALS[ 'phpgw' ] -> link( '/admin/' ) );
295
296                        $t->pfp('out','footer');
297                }
298        }
299?>
Note: See TracBrowser for help on using the repository browser.