source: trunk/phpgwapi/inc/class.preferences.inc.php @ 2

Revision 2, 45.3 KB checked in by niltonneto, 17 years ago (diff)

Removida todas as tags usadas pelo CVS ($Id, $Source).
Primeira versão no CVS externo.

  • Property svn:eol-style set to native
  • Property svn:executable set to *
Line 
1<?php
2        /**************************************************************************\
3        * eGroupWare API - Preferences                                             *
4        * This file written by Joseph Engo <jengo@phpgroupware.org>                *
5        * and Mark Peters <skeeter@phpgroupware.org>                               *
6        * Manages user preferences                                                 *
7        * Copyright (C) 2000, 2001 Joseph Engo                                     *
8        * -------------------------------------------------------------------------*
9        * This library is part of the eGroupWare API                               *
10        * http://www.egroupware.org/api                                            *
11        * ------------------------------------------------------------------------ *
12        * This library is free software; you can redistribute it and/or modify it  *
13        * under the terms of the GNU Lesser General Public License as published by *
14        * the Free Software Foundation; either version 2.1 of the License,         *
15        * or any later version.                                                    *
16        * This library is distributed in the hope that it will be useful, but      *
17        * WITHOUT ANY WARRANTY; without even the implied warranty of               *
18        * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                     *
19        * See the GNU Lesser General Public License for more details.              *
20        * You should have received a copy of the GNU Lesser General Public License *
21        * along with this library; if not, write to the Free Software Foundation,  *
22        * Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA            *
23        \**************************************************************************/
24
25
26        /*!
27        @class preferences
28        @abstract preferences class used for setting application preferences
29        @discussion the prefs are read into 4 arrays: \
30                $data the effective prefs used everywhere in phpgw, they are merged from the other 3 arrays \
31                $user the stored user prefs, only used for manipulating and storeing the user prefs \
32                $default the default preferences, always used when the user has no own preference set \
33                $forced forced preferences set by the admin, they take precedence over user or default prefs
34        */
35        class preferences
36        {
37                /*! @var account_id */
38                var $account_id;
39                /*! @var account_type */
40                var $account_type;
41                /*! @var data effectiv user prefs, used by all apps */
42                var $data = array();
43                /*! @var user set user prefs for saveing (no defaults/forced prefs merged) */
44                var $user = array();
45                /*! @var default default prefs */
46                var $default = array();
47                /*! @var forced forced prefs */
48                var $forced = array();
49                /*! @var session session / tempory prefs */
50                var $session = array();
51                /*! @var db */
52                var $db;
53
54                var $values,$vars;      // standard notify substitues, will be set by standard_substitues()
55
56                /**************************************************************************\
57                * Standard constructor for setting $this->account_id                       *
58                \**************************************************************************/
59                /*!
60                @function preferences
61                @abstract Standard constructor for setting $this->account_id
62                @discussion Author:
63                */
64                function preferences($account_id = '')
65                {
66                        $this->db         = is_object($GLOBALS['phpgw']->db) ? $GLOBALS['phpgw']->db : $GLOBALS['phpgw_setup']->db;
67                        $this->account_id = get_account_id($account_id);
68                }
69
70                /**************************************************************************\
71                * These are the standard $this->account_id specific functions              *
72                \**************************************************************************/
73
74                /*!
75                @function parse_notify
76                @abstract parses a notify and replaces the substitutes
77                @syntax parse_notify($msg,$values='',$use_standard_values=True)
78                @param $msg message to parse / substitute
79                @param $values extra vars to replace in addition to $this->values, vars are in an array with \
80                        $key => $value pairs, $key does not include the $'s and is the *untranslated* name
81                @param $use_standard_values should the standard values are used
82                @returns the parsed notify-msg
83                */
84                function parse_notify($msg,$values='',$use_standard_values=True)
85                {
86                        $vals = $values ? $values : array();
87
88                        if ($use_standard_values && is_array($this->values))
89                        {
90                                $vals += $this->values;
91                        }
92                        foreach($vals as $key => $val)
93                        {
94                                $replace[] = '$$'.$key.'$$';
95                                $with[]    = $val;
96                        }
97                        return str_replace($replace,$with,$msg);
98                }
99               
100                /*!
101                @function lang_notify
102                @abstract replaces the english key's with translated ones, or if $un_lang the opposite
103                @syntax lang_notify($msg,$values='',$un_lang=False)
104                @param $msg message to translate
105                @param $values extra vars to replace in addition to $this->values, vars are in an array with \
106                        $key => $value pairs, $key does not include the $'s and is the *untranslated* name
107                @param $un_lang if true translate back
108                @returns the result
109                */
110                function lang_notify($msg,$vals=array(),$un_lang=False)
111                {
112                        foreach($vals as $key => $val)
113                        {
114                                $lname = ($lname = lang($key)) == $key.'*' ? $key : $lname;
115                                if ($un_lang)
116                                {
117                                        $langs[$lname] = '$$'.$key.'$$';
118                                }
119                                else
120                                {
121                                        $langs[$key] = '$$'.$lname.'$$';
122                                }
123                        }
124                        return $this->parse_notify($msg,$langs,False);
125                }
126
127                /*!
128                @function standard_substitues
129                @abstract define some standard substitues-values and use them on the prefs, if needed
130                */
131                function standard_substitutes()
132                {
133                        if (!is_array(@$GLOBALS['phpgw_info']['user']['preferences']))
134                        {
135                                $GLOBALS['phpgw_info']['user']['preferences'] = $this->data;    // else no lang()
136                        }
137                        // we cant use phpgw_info/user/fullname, as it's not set when we run
138                        $GLOBALS['phpgw']->accounts->get_account_name($this->account_id,$lid,$fname,$lname);
139
140                        $this->values = array(  // standard notify replacements
141                                'fullname'  => $GLOBALS['phpgw']->common->display_fullname('',$fname,$lname),
142                                'firstname' => $fname,
143                                'lastname'  => $lname,
144                                'domain'    => $GLOBALS['phpgw_info']['server']['mail_suffix'],
145                                'email'     => $this->email_address($this->account_id),
146                                'date'      => $GLOBALS['phpgw']->common->show_date('',$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']),
147                        );
148                        // do this first, as it might be already contain some substitues
149                        //
150                        $this->values['email'] = $this->parse_notify($this->values['email']);
151
152                        $this->vars = array(    // langs have to be in common !!!
153                                'fullname'  => lang('name of the user, eg. "%1"',$this->values['fullname']),
154                                'firstname' => lang('first name of the user, eg. "%1"',$this->values['firstname']),
155                                'lastname'  => lang('last name of the user, eg. "%1"',$this->values['lastname']),
156                                'domain'    => lang('domain name for mail-address, eg. "%1"',$this->values['domain']),
157                                'email'     => lang('email-address of the user, eg. "%1"',$this->values['email']),
158                                'date'      => lang('todays date, eg. "%1"',$this->values['date']),
159                        );
160                        // do the substituetion in the effective prefs (data)
161                        //
162                        foreach($this->data as $app => $data)
163                        {
164                                foreach($data as $key => $val)
165                                {
166                                        if (!is_array($val) && strstr($val,'$$') !== False)
167                                        {
168                                                $this->data[$app][$key] = $this->parse_notify($val);
169                                        }
170                                        elseif (is_array($val))
171                                        {
172                                                foreach($val as $k => $v)
173                                                {
174                                                        if (!is_array($v) && strstr($val,'$$') !== False)
175                                                        {
176                                                                $this->data[$app][$key][$k] = $this->parse_notify($v);
177                                                        }
178                                                }
179                                        }
180                                }
181                        }
182                }
183
184                /*!
185                @function unquote
186                @abstract unquote (stripslashes) recursivly the whole array
187                @param $arr array to unquote (var-param!)
188                */
189                function unquote(&$arr)
190                {
191                        if (!is_array($arr))
192                        {
193                                $arr = stripslashes($arr);
194                                return;
195                        }
196                        foreach($arr as $key => $value)
197                        {
198                                if (is_array($value))
199                                {
200                                        $this->unquote($arr[$key]);
201                                }
202                                else
203                                {
204                                        $arr[$key] = stripslashes($value);
205                                }
206                        }
207                }
208
209                /*!
210                @function read_repository
211                @abstract private - read preferences from the repository
212                @note the function ready all 3 prefs user/default/forced and merges them to the effective ones
213                @discussion private function should only be called from within this class
214                */
215                function read_repository()
216                {
217                        $this->session = $GLOBALS['phpgw']->session->appsession('preferences','preferences');
218                        if (!is_array($this->session))
219                        {
220                                $this->session = array();
221                        }
222                        $this->db->query("SELECT * FROM phpgw_preferences"
223                                . " WHERE preference_owner IN (-1,-2," . (int)$this->account_id . ')',__LINE__,__FILE__);
224
225                        $this->forced = $this->default = $this->user = array();
226                        while($this->db->next_record())
227                        {
228                                // The following replacement is required for PostgreSQL to work
229                                $app = str_replace(' ','',$this->db->f('preference_app'));
230                                $value = unserialize($this->db->f('preference_value'));
231                                $this->unquote($value);
232                                if (!is_array($value))
233                                {
234                                        continue;
235                                }
236                                switch($this->db->f('preference_owner'))
237                                {
238                                        case -1:        // forced
239                                                $this->forced[$app] = $value;
240                                                break;
241                                        case -2:        // default
242                                                $this->default[$app] = $value;
243                                                break;
244                                        default:        // user
245                                                $this->user[$app] = $value;
246                                                break;
247                                }
248                        }
249                        $this->data = $this->user;
250
251                        // let the (temp.) session prefs. override the user prefs.
252                        //
253                        foreach($this->session as $app => $values)
254                        {
255                                foreach($values as $var => $value)
256                                {
257                                        $this->data[$app][$var] = $value;
258                                }
259                        }
260
261                        // now use defaults if needed (user-value unset or empty)
262                        //
263                        foreach($this->default as $app => $values)
264                        {
265                                foreach($values as $var => $value)
266                                {
267                                        if (!isset($this->data[$app][$var]) || $this->data[$app][$var] === '')
268                                        {
269                                                $this->data[$app][$var] = $value;
270                                        }
271                                }
272                        }
273                        // now set/force forced values
274                        //
275                        foreach($this->forced as $app => $values)
276                        {
277                                foreach($values as $var => $value)
278                                {
279                                        $this->data[$app][$var] = $value;
280                                }
281                        }
282                        // setup the standard substitutes and substitutes the data in $this->data
283                        //
284                        $this->standard_substitutes();
285
286                        // This is to supress warnings during login
287                        if (is_array($this->data))
288                        {
289                                reset($this->data);
290                        }
291                        if (isset($this->debug) && substr($GLOBALS['phpgw_info']['flags']['currentapp'],0,3) != 'log')
292                        {
293                                echo 'user<pre>';     print_r($this->user); echo "</pre>\n";
294                                echo 'forced<pre>';   print_r($this->forced); echo "</pre>\n";
295                                echo 'default<pre>';  print_r($this->default); echo "</pre>\n";
296                                echo 'effectiv<pre>'; print_r($this->data); echo "</pre>\n";
297                        }
298                        return $this->data;
299                }
300
301                /*!
302                @function read
303                @abstract public - read preferences from repository and stores in an array
304                @discussion Syntax array read(); <>
305                Example1: preferences->read();
306                @result $data array containing user preferences
307                */
308                function read()
309                {
310                        if (count($this->data) == 0)
311                        {
312                                $this->read_repository();
313                        }
314                        reset ($this->data);
315                        return $this->data;
316                }
317
318                /*!
319                @function add
320                @abstract add preference to $app_name a particular app
321                @discussion
322                @param $app_name name of the app
323                @param $var name of preference to be stored
324                @param $value value of the preference
325                @param $type of preference to set: forced, default, user
326                @note the effective prefs ($this->data) are updated to reflect the change
327                @returns the new effective prefs (even when forced or default prefs are set !)
328                */
329                function add($app_name,$var,$value = '##undef##',$type='user')
330                {
331                        //echo "<p>add('$app_name','$var','$value')</p>\n";
332                        if ($value === '##undef##')
333                        {
334                                global $$var;
335                                $value = $$var;
336                        }
337 
338                        switch ($type)
339                        {
340                                case 'session':
341                                        if (!isset($this->forced[$app_name][$var]) || $this->forced[$app_name][$var] === '')
342                                        {
343                                                $this->session[$app_name][$var] = $this->data[$app_name][$var] = $value;
344                                                $GLOBALS['phpgw']->session->appsession('preferences','preferences',$this->session);
345                                        }
346                                        break;
347
348                                case 'forced':
349                                        $this->data[$app_name][$var] = $this->forced[$app_name][$var] = $value;
350                                        break;
351
352                                case 'default':
353                                        $this->default[$app_name][$var] = $value;
354                                        if ((!isset($this->forced[$app_name][$var]) || $this->forced[$app_name][$var] === '') &&
355                                                (!isset($this->user[$app_name][$var]) || $this->user[$app_name][$var] === ''))
356                                        {
357                                                $this->data[$app_name][$var] = $value;
358                                        }
359                                        break;
360
361                                case user:
362                                default:
363                                        $this->user[$app_name][$var] = $value;
364                                        if (!isset($this->forced[$app_name][$var]) || $this->forced[$app_name][$var] === '')
365                                        {
366                                                $this->data[$app_name][$var] = $value;
367                                        }
368                                        break;
369                        }
370                        reset($this->data);
371                        return $this->data;
372                }
373
374                /*!
375                @function delete
376                @abstract delete preference from $app_name
377                @discussion
378                @param $app_name name of app
379                @param $var variable to be deleted
380                @param $type of preference to set: forced, default, user
381                @note the effektive prefs ($this->data) are updated to reflect the change
382                @returns the new effective prefs (even when forced or default prefs are deleted!)
383                */
384                function delete($app_name, $var = False,$type = 'user')
385                {
386                        //echo "<p>delete('$app_name','$var','$type')</p>\n";
387                        $set_via = array(
388                                'forced'  => array('user','default'),
389                                'default' => array('forced','user'),
390                                'user'    => array('forced','default')
391                        );
392                        if (!isset($set_via[$type]))
393                        {
394                                $type = 'user';
395                        }
396                        $pref = &$this->$type;
397
398                        if ($all = (is_string($var) && $var == ''))
399                        {
400                                unset($pref[$app_name]);
401                                unset($this->data[$app_name]);
402                        }
403                        else
404                        {
405                                unset($pref[$app_name][$var]);
406                                unset($this->data[$app_name][$var]);
407                        }
408                        // set the effectiv pref again if needed
409                        //
410                        foreach ($set_via[$type] as $set_from)
411                        {
412                                if ($all)
413                                {
414                                        if (isset($this->$set_from[$app_name]))
415                                        {
416                                                $this->data[$app_name] = $this->$set_from[$app_name];
417                                                break;
418                                        }
419                                }
420                                else
421                                {
422                                        $arr = $this->$set_from;
423                                        if($var && @isset($arr[$app_name][$var]) && $arr[$app_name][$var] !== '')
424                                        {
425                                                $this->data[$app_name][$var] = $this->$set_from[$app_name][$var];
426                                                break;
427                                        }
428                                        unset($arr);
429                                }
430                        }
431                        reset ($this->data);
432                        return $this->data;
433                }
434
435                /*!
436                @function add_struct
437                @abstract add complex array data preference to $app_name a particular app
438                @discussion Use for sublevels of prefs, such as email app's extra accounts preferences
439                @param $app_name name of the app
440                @param $var array keys separated by '/', eg. 'ex_accounts/1'
441                @param $value value of the preference
442                @note the function works on user and data, to be able to save the pref and to have imediate effect
443                */
444                function add_struct($app_name,$var,$value = '')
445                {
446                        /* eval is slow and dangerous
447                        $code = '$this->data[$app_name]'.$var.' = $value;';
448                        print_debug('class.preferences: add_struct: $code: ', $code,'api');
449                        eval($code);
450                        */
451                        $parts = explode('/',str_replace(array('][','[',']','"',"'"),array('/','','','',''),$var));
452                        $data = &$this->data[$app_name];
453                        $user = &$this->user[$app_name];
454                        foreach($parts as $name)
455                        {
456                                $data = &$data[$name];
457                                $user = &$user[$name];
458                        }
459                        $data = $user = $value;
460                        print_debug('class.preferences: add_struct: $this->data[$app_name] dump:', $this->data[$app_name],'api');
461                        reset($this->data);
462                        return $this->data;
463                }
464
465                /*!
466                @function delete_struct
467                @abstract delete complex array data preference from $app_name
468                @discussion Use for sublevels of prefs, such as email app's extra accounts preferences
469                @param $app_name name of app
470                @param $var array keys separated by '/', eg. 'ex_accounts/1'
471                @note the function works on user and data, to be able to save the pref and to have immediate effect
472                */
473                function delete_struct($app_name, $var = '')
474                {
475                        /* eval is slow and dangerous
476                        $code_1 = '$this->data[$app_name]'.$var.' = "";';
477                        print_debug('class.preferences: delete_struct: $code_1:', $code_1,'api');
478                        eval($code_1);
479                        $code_2 = 'unset($this->data[$app_name]'.$var.');' ;
480                        print_debug('class.preferences: delete_struct:  $code_2: ', $code_2,'api');
481                        eval($code_2);
482                        */
483                        $parts = explode('/',str_replace(array('][','[',']','"',"'"),array('/','','','',''),$var));
484                        $last = array_pop($parts);
485                        $data = &$this->data[$app_name];
486                        $user = &$this->user[$app_name];
487                        foreach($parts as $name)
488                        {
489                                $data = &$data[$name];
490                                $user = &$user[$name];
491                        }
492                        unset($data[$last]);
493                        unset($user[$last]);
494                        print_debug('* $this->data[$app_name] dump:', $this->data[$app_name],'api');
495                        reset ($this->data);
496                        return $this->data;
497                }
498
499                /*!
500                @function quote
501                @abstract quote (addslashes) recursivly the whole array
502                @param $arr array to unquote (var-param!)
503                */
504                function quote(&$arr)
505                {
506                        if (!is_array($arr))
507                        {
508                                $arr = addslashes($arr);
509                                return;
510                        }
511                        foreach($arr as $key => $value)
512                        {
513                                if (is_array($value))
514                                {
515                                        $this->quote($arr[$key]);
516                                }
517                                else
518                                {
519                                        $arr[$key] = addslashes($value);
520                                }
521                        }
522                }
523
524                /*!
525                @function save_repository
526                @abstract save the the preferences to the repository
527                @syntax save_repository($update_session_info = False,$type='')
528                @param $update_session_info old param, seems not to be used
529                @param $type which prefs to update: user/default/forced
530                @note the user prefs for saveing are in $this->user not in $this->data, which are the effectiv prefs only
531                */
532                function save_repository($update_session_info = False,$type='user')
533                {
534                        switch($type)
535                        {
536                                case 'forced':
537                                        $account_id = -1;
538                                        $prefs = &$this->forced;
539                                        break;
540                                case 'default':
541                                        $account_id = -2;
542                                        $prefs = &$this->default;
543                                        break;
544                                default:
545                                        $account_id = (int)$this->account_id;
546                                        $prefs = &$this->user;  // we use the user-array as data contains default values too
547                                        break;
548                        }
549                        //echo "<p>preferences::save_repository(,$type): account_id=$account_id, prefs="; print_r($prefs); echo "</p>\n";
550
551                        if (! $GLOBALS['phpgw']->acl->check('session_only_preferences',1,'preferences'))
552                        {
553                                $this->db->transaction_begin();
554                                $this->db->query("DELETE FROM phpgw_preferences WHERE preference_owner='$account_id'",
555                                        __LINE__,__FILE__
556                                );
557
558                                foreach($prefs as $app => $value)
559                                {
560                                        if (!is_array($value))
561                                        {
562                                                continue;
563                                        }
564                                        $this->quote($value);
565                                        $value = $this->db->db_addslashes(serialize($value));   // this addslashes is for the database
566                                        $app = $this->db->db_addslashes($app);
567
568                                        $this->db->query($sql = "INSERT INTO phpgw_preferences"
569                                                . " (preference_owner,preference_app,preference_value)"
570                                                . " VALUES ($account_id,'$app','$value')",__LINE__,__FILE__);
571                                }
572                                $this->db->transaction_commit();
573                        }
574                        else
575                        {
576                                $GLOBALS['phpgw_info']['user']['preferences'] = $this->data;
577                                $GLOBALS['phpgw']->session->save_repositories();
578                        }
579
580                        if (($type == 'user' || !$type) && $GLOBALS['phpgw_info']['server']['cache_phpgw_info'] && $this->account_id == $GLOBALS['phpgw_info']['user']['account_id'])
581                        {
582                                $GLOBALS['phpgw']->session->delete_cache($this->account_id);
583                                $GLOBALS['phpgw']->session->read_repositories(False);
584                        }
585
586                        return $this->data;
587                }
588
589                /*!
590                @function create_defaults
591                @abstract insert a copy of the default preferences for use by real account_id
592                @discussion
593                @param $account_id numerical id of account for which to create the prefs
594                */
595                function create_defaults($account_id)
596                {
597                        return; // not longer needed, as the defaults are merged in on runtime
598                        $this->db->query("select * from phpgw_preferences where preference_owner='-2'",__LINE__,__FILE__);
599                        $this->db->next_record();
600
601                        if($this->db->f('preference_value'))
602                        {
603                                $this->db->query("insert into phpgw_preferences values ('$account_id','"
604                                        . $this->db->f('preference_value') . "')",__LINE__,__FILE__);
605                        }
606
607                        if ($GLOBALS['phpgw_info']['server']['cache_phpgw_info'] && $account_id == $GLOBALS['phpgw_info']['user']['account_id'])
608                        {
609                                $GLOBALS['phpgw']->session->read_repositories(False);
610                        }
611                }
612
613                /*!
614                @function update_data
615                @abstract update the preferences array
616                @discussion
617                @param $data array of preferences
618                */
619                function update_data($data)
620                {
621                        reset($data);
622                        $this->data = Array();
623                        $this->data = $data;
624                        reset($this->data);
625                        return $this->data;
626                }
627
628                /* legacy support */
629                function change($app_name,$var,$value = "")
630                {
631                        return $this->add($app_name,$var,$value);
632                }
633                function commit($update_session_info = True)
634                {
635                        //return $this->save_repository($update_session_info);
636                }
637
638                /**************************************************************************\
639                * These are the non-standard $this->account_id specific functions          *
640                \**************************************************************************/
641
642                /*!
643                @function verify_basic_settings
644                @abstract verify basic settings
645                @discussion
646                */
647                function verify_basic_settings()
648                {
649                        if (!@is_array($GLOBALS['phpgw_info']['user']['preferences']))
650                        {
651                                $GLOBALS['phpgw_info']['user']['preferences'] = array();
652                        }
653                        /* This takes care of new users who don't have proper default prefs setup */
654                        if (!isset($GLOBALS['phpgw_info']['flags']['nocommon_preferences']) ||
655                                !$GLOBALS['phpgw_info']['flags']['nocommon_preferences'])
656                        {
657                                $preferences_update = False;
658                                if (!isset($GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs']) ||
659                                        !$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'])
660                                {
661                                        $this->add('common','maxmatchs',15);
662                                        $preferences_update = True;
663                                }
664                                if (!isset($GLOBALS['phpgw_info']['user']['preferences']['common']['theme']) ||
665                                        !$GLOBALS['phpgw_info']['user']['preferences']['common']['theme'])
666                                {
667                                        $this->add('common','theme','default');
668                                        $preferences_update = True;
669                                }
670                                if (!isset($GLOBALS['phpgw_info']['user']['preferences']['common']['template_set']) ||
671                                        !$GLOBALS['phpgw_info']['user']['preferences']['common']['template_set'])
672                                {
673                                        $this->add('common','template_set','default');
674                                        $preferences_update = True;
675                                }
676                                if (!isset($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']) ||
677                                        !$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'])
678                                {
679                                        $this->add('common','dateformat','m/d/Y');
680                                        $preferences_update = True;
681                                }
682                                if (!isset($GLOBALS['phpgw_info']['user']['preferences']['common']['timeformat']) ||
683                                        !$GLOBALS['phpgw_info']['user']['preferences']['common']['timeformat'])
684                                {
685                                        $this->add('common','timeformat',12);
686                                        $preferences_update = True;
687                                }
688                                if (!isset($GLOBALS['phpgw_info']['user']['preferences']['common']['lang']) ||
689                                        !$GLOBALS['phpgw_info']['user']['preferences']['common']['lang'])
690                                {
691                                        $this->add('common','lang',$GLOBALS['phpgw']->common->getPreferredLanguage());
692                                        $preferences_update = True;
693                                }
694                                if ($preferences_update)
695                                {
696                                        $this->save_repository();
697                                }
698                                unset($preferences_update);
699                        }
700                }
701
702                /****************************************************\
703                * Email Preferences and Private Support Functions   *
704                \****************************************************/
705
706                /*!
707                @function sub_get_mailsvr_port
708                @abstract Helper function for create_email_preferences, gets mail server port number.
709                @discussion This will generate the appropriate port number to access a
710                mail server of type pop3, pop3s, imap, imaps users value from
711                $phpgw_info['user']['preferences']['email']['mail_port'].
712                if that value is not set, it generates a default port for the given $server_type.
713                Someday, this *MAY* be
714                (a) a se4rver wide admin setting, or
715                (b)user custom preference
716                Until then, simply set the port number based on the mail_server_type, thereof
717                ONLY call this function AFTER ['email']['mail_server_type'] has been set.
718                @param $prefs - user preferences array based on element ['email'][]
719                @author  Angles
720                @access Private
721                */
722                function sub_get_mailsvr_port($prefs, $acctnum=0)
723                {
724                        // first we try the port number supplied in preferences
725                        if((isset($prefs['email']['accounts'][$acctnum]['mail_port'])) &&
726                                ($prefs['email']['accounts'][$acctnum]['mail_port'] != ''))
727                        {
728                                $port_number = $prefs['email']['accounts'][$acctnum]['mail_port'];
729                        }
730                        // preferences does not have a port number, generate a default value
731                        else
732                        {
733                                if (!isset($prefs['email']['accounts'][$acctnum]['mail_server_type']))
734                                {
735                                        $prefs['email']['accounts'][$acctnum]['mail_server_type'] = $prefs['email']['mail_server_type'];
736                                }
737
738                                switch($prefs['email']['accounts'][$acctnum]['mail_server_type'])
739                                {
740                                        case 'pop3s':
741                                                // POP3 over SSL
742                                                $port_number = 995;
743                                                break;
744                                        case 'pop3':
745                                                // POP3 normal connection, No SSL
746                                                // ( same string as normal imap above)
747                                                $port_number = 110;
748                                                break;
749                                        case 'nntp':
750                                                // NNTP news server port
751                                                $port_number = 119;
752                                                break;
753                                        case 'imaps':
754                                                // IMAP over SSL
755                                                $port_number = 993;
756                                                break;
757                                        case 'imap':
758                                                // IMAP normal connection, No SSL
759                                        default:
760                                                // UNKNOWN SERVER in Preferences, return a
761                                                // default value that is likely to work
762                                                // probably should raise some kind of error here
763                                                $port_number = 143;
764                                                break;
765                                }
766                        }
767                        return $port_number;
768                }
769
770                /*!
771                @function sub_default_userid
772                @abstract Helper function for create_email_preferences, gets default userid for email
773                @discussion This will generate the appropriate userid for accessing an email server.
774                In the absence of a custom ['email']['userid'], this function should be used to set it.
775                @param $accountid - as determined in and/or passed to "create_email_preferences"
776                @access Private
777                */
778                function sub_default_userid($account_id='')
779                {
780                        if ($GLOBALS['phpgw_info']['server']['mail_login_type'] == 'vmailmgr')
781                        {
782                                $prefs_email_userid = $GLOBALS['phpgw']->accounts->id2name($account_id)
783                                        . '@' . $GLOBALS['phpgw_info']['server']['mail_suffix'];
784                        }
785                        else
786                        {
787                                $prefs_email_userid = $GLOBALS['phpgw']->accounts->id2name($account_id);
788                        }
789                        return $prefs_email_userid;
790                }
791
792                /*!
793                @function email_address
794                @abstract returns the custom email-address (if set) or generates a default one
795                @discussion This will generate the appropriate email address used as the "From:"
796                email address when the user sends email, the localpert@domain part. The "personal"
797                part is generated elsewhere.
798                In the absence of a custom ['email']['address'], this function should be used to set it.
799                @param $accountid - as determined in and/or passed to "create_email_preferences"
800                @access Public now
801                */
802                function email_address($account_id='')
803                {
804                        if (isset($this->data['email']['address']))
805                        {
806                                return $this->data['email']['address'];
807                        }
808                        // if email-address is set in the account, return it
809                        if ($email = $GLOBALS['phpgw']->accounts->id2name($account_id,'account_email'))
810                        {
811                                return $email;
812                        }
813                        $prefs_email_address = $GLOBALS['phpgw']->accounts->id2name($account_id);
814                        if (strstr($prefs_email_address,'@') === False)
815                        {
816                                $prefs_email_address .= '@' . $GLOBALS['phpgw_info']['server']['mail_suffix'];
817                        }
818                        return $prefs_email_address;
819                }
820
821                function sub_default_address($account_id='')
822                {
823                        return $this->email_address($account_id);
824                }
825
826                /*!
827                @function create_email_preferences
828                @abstract create email preferences
829                @param $account_id -optional defaults to : get_account_id()
830                @discussion fills a local copy of ['email'][] prefs array which is then returned to the calling
831                function, which the calling function generally tacks onto the $GLOBALS['phpgw_info'] array as such:
832                        $GLOBALS['phpgw_info']['user']['preferences'] = $GLOBALS['phpgw']->preferences->create_email_preferences();
833                which fills an array based at:
834                        $GLOBALS['phpgw_info']['user']['preferences']['email'][prefs_are_elements_here]
835                Reading the raw preference DB data and comparing to the email preference schema defined in
836                /email/class.bopreferences.inc.php (see discussion there and below) to create default preference values
837                for the  in the ['email'][] pref data array in cases where the user has not supplied
838                a preference value for any particular preference item available to the user.
839                @access Public
840                */
841                function create_email_preferences($accountid='', $acctnum=0)
842                {
843                        print_debug('class.preferences: create_email_preferences: ENTERING<br>', 'messageonly','api');
844                        // we may need function "html_quotes_decode" from the mail_msg class
845                        $email_base = CreateObject("email.mail_msg");
846
847                        $account_id = get_account_id($accountid);
848                        // If the current user is not the request user, grab the preferences
849                        // and reset back to current user.
850                        if($account_id != $this->account_id)
851                        {
852                                // Temporarily store the values to a temp, so when the
853                                // read_repository() is called, it doesn't destory the
854                                // current users settings.
855                                $temp_account_id = $this->account_id;
856                                $temp_data = $this->data;
857
858                                // Grab the new users settings, only if they are not the
859                                // current users settings.
860                                $this->account_id = $account_id;
861                                $prefs = $this->read_repository();
862
863                                // Reset the data to what it was prior to this call
864                                $this->account_id = $temp_account_id;
865                                $this->data = $temp_data;
866                        }
867                        else
868                        {
869                                $prefs = $this->data;
870                        }
871                        // are we dealing with the default email account or an extra email account?
872                        if ($acctnum != 0)
873                        {
874                                // prefs are actually a sub-element of the main email prefs
875                                // at location [email][ex_accounts][X][...pref names] => pref values
876                                // make this look like "prefs[email] so the code below code below will do its job transparently
877                               
878                                // store original prefs
879                                $orig_prefs = array();
880                                $orig_prefs = $prefs;
881                                // obtain the desired sub-array of extra account prefs
882                                $sub_prefs = array();
883                                $sub_prefs['email'] = $prefs['email']['ex_accounts'][$acctnum];
884                                // make the switch, make it seem like top level email prefs
885                                $prefs = array();
886                                $prefs['email'] = $sub_prefs['email'];
887                                // since we return just $prefs, it's up to the calling program to put the sub prefs in the right place
888                        }
889                        print_debug('class.preferences: create_email_preferences: $acctnum: ['.$acctnum.'] ; raw $this->data dump', $this->data,'api');
890
891                        // = = = =  NOT-SIMPLE  PREFS  = = = =
892                        // Default Preferences info that is:
893                        // (a) not controlled by email prefs itself (mostly api and/or server level stuff)
894                        // (b) too complicated to be described in the email prefs data array instructions
895                       
896                        // ---  [server][mail_server_type]  ---
897                        // Set API Level Server Mail Type if not defined
898                        // if for some reason the API didnot have a mail server type set during initialization
899                        if (empty($GLOBALS['phpgw_info']['server']['mail_server_type']))
900                        {
901                                $GLOBALS['phpgw_info']['server']['mail_server_type'] = 'imap';
902                        }
903
904                        // ---  [server][mail_folder]  ---
905                        // ====  UWash Mail Folder Location used to be "mail", now it's changeable, but keep the
906                        // ====  default to "mail" so upgrades happen transparently
907                        // ---  TEMP MAKE DEFAULT UWASH MAIL FOLDER ~/mail (a.k.a. $HOME/mail)
908                        $GLOBALS['phpgw_info']['server']['mail_folder'] = 'mail';
909                        // ---  DELETE THE ABOVE WHEN THIS OPTION GETS INTO THE SYSTEM SETUP
910                        // pick up custom "mail_folder" if it exists (used for UWash and UWash Maildir servers)
911                        // else use the system default (which we temporarily hard coded to "mail" just above here)
912
913                        //---  [email][mail_port]  ---
914                        // These sets the mail_port server variable
915                        // someday (not currently) this may be a site-wide property set during site setup
916                        // additionally, someday (not currently) the user may be able to override this with
917                        // a custom email preference. Currently, we simply use standard port numbers
918                        // for the service in question.
919                        $prefs['email']['mail_port'] = $this->sub_get_mailsvr_port($prefs);
920
921                        //---  [email][fullname]  ---
922                        // we pick this up from phpgw api for the default account
923                        // the user does not directly manipulate this pref for the default email account
924                        if ((string)$acctnum == '0')
925                        {
926                                $prefs['email']['fullname'] = $GLOBALS['phpgw_info']['user']['fullname'];
927                        }
928
929                        // = = = =  SIMPLER PREFS  = = = =
930
931                        // Default Preferences info that is articulated in the email prefs schema array itself
932                        // such email prefs schema array is described and established in /email/class.bopreferences
933                        // by function "init_available_prefs", see the discussion there.
934
935                        // --- create the objectified /email/class.bopreferences.inc.php ---
936                        //Begin Jakjr
937                        #$bo_mail_prefs = CreateObject('email.bopreferences');
938
939                        // --- bo_mail_prefs->init_available_prefs() ---
940                        // this fills object_email_bopreferences->std_prefs and ->cust_prefs
941                        // we will initialize the users preferences according to the rules and instructions
942                        // embodied in those prefs arrays, applying those rules to the unprocessed
943                        // data read from the preferences DB. By taking the raw data and applying those rules,
944                        // we will construct valid and known email preference data for this user.
945                        #$bo_mail_prefs->init_available_prefs();
946
947                        // --- combine the two array (std and cust) for 1 pass handling ---
948                        // when this preference DB was submitted and saved, it was hopefully so well structured
949                        // that we can simply combine the two arrays, std_prefs and cust_prefs, and do a one
950                        // pass analysis and preparation of this users preferences.
951                        #$avail_pref_array = $bo_mail_prefs->std_prefs;
952                        #$c_cust_prefs = count($bo_mail_prefs->cust_prefs);
953                        #for($i=0;$i<$c_cust_prefs;$i++)
954                        #{
955                        #       // add each custom prefs to the std prefs array
956                        #       $next_idx = count($avail_pref_array);
957                        #       $avail_pref_array[$next_idx] = $bo_mail_prefs->cust_prefs[$i];
958                        #}
959                        print_debug('class.preferences: create_email_preferences: std AND cust arrays combined:', $avail_pref_array,'api');
960
961                        // --- make the schema-based pref data for this user ---
962                        // user defined values and/or user specified custom email prefs are read from the
963                        // prefs DB with mininal manipulation of the data. Currently the only change to
964                        // users raw data is related to reversing the encoding of "database un-friendly" chars
965                        // which itself may become unnecessary if and when the database handlers can reliably
966                        // take care of this for us. Of course, password data requires special decoding,
967                        // but the password in the array [email][paswd] should be left in encrypted form
968                        // and only decrypted seperately when used to login in to an email server.
969
970                        // --- generating a default value if necessary ---
971                        // in the absence of a user defined custom email preference for a particular item, we can
972                        // determine the desired default value for that pref as such:
973                        // $this_avail_pref['init_default']  is a comma seperated seperated string which should
974                        // be exploded into an array containing 2 elements that are:
975                        // exploded[0] : an description of how to handle the next string element to get a default value.
976                        // Possible "instructional tokens" for exploded[0] (called $set_proc[0] below) are:
977                        //      string
978                        //      set_or_not
979                        //      function
980                        //      init_no_fill
981                        //      varEVAL
982                        // tells you how to handle the string in exploded[1] (called $set_proc[1] below) to get a valid
983                        // default value for a particular preference if one is needed (i.e. if no user custom
984                        // email preference exists that should override that default value, in which case we
985                        // do not even need to obtain such a default value as described in ['init_default'] anyway).
986                       
987                        // --- loop thru $avail_pref_array and process each pref item ---
988                        $c_prefs = count($avail_pref_array);
989                        for($i=0;$i<$c_prefs;$i++)
990                        {
991                                $this_avail_pref = $avail_pref_array[$i];
992                                print_debug('class.preferences: create_email_preferences: value from DB for $prefs[email]['.$this_avail_pref['id'].'] = ['.$prefs['email'][$this_avail_pref['id']].']', 'messageonly','api');
993                                print_debug('class.preferences: create_email_preferences: std/cust_prefs $this_avail_pref['.$i.'] dump:', $this_avail_pref,'api');
994
995                                // --- is there a value in the DB for this preference item ---
996                                // if the prefs DB has no value for this defined available preference, we must make one.
997                                // This occurs if (a) this is user's first login, or (b) this is a custom pref which the user
998                                // has not overriden, do a default (non-custom) value is needed.
999                                if (!isset($prefs['email'][$this_avail_pref['id']]))
1000                                {
1001                                        // now we are analizing an individual pref that is available to the user
1002                                        // AND the user had no existing value in the prefs DB for this.
1003
1004                                        // --- get instructions on how to generate a default value ---
1005                                        $set_proc = explode(',', $this_avail_pref['init_default']);
1006                                        print_debug(' * set_proc=['.serialize($set_proc).']', 'messageonly','api');
1007
1008                                        // --- use "instructional token" in $set_proc[0] to take appropriate action ---
1009                                        // STRING
1010                                        if ($set_proc[0] == 'string')
1011                                        {
1012                                                // means this pref item's value type is string
1013                                                // which defined string default value is in $set_proc[1]
1014                                                print_debug('* handle "string" set_proc: ', serialize($set_proc),'api');
1015                                                if (trim($set_proc[1]) == '')
1016                                                {
1017                                                        // this happens when $this_avail_pref['init_default'] = "string, "
1018                                                        $this_string = '';
1019                                                }
1020                                                else
1021                                                {
1022                                                        $this_string = $set_proc[1];
1023                                                }
1024                                                $prefs['email'][$this_avail_pref['id']] = $this_string;
1025                                        }
1026                                        // SET_OR_NOT
1027                                        elseif ($set_proc[0] == 'set_or_not')
1028                                        {
1029                                                // typical with boolean options, True = "set/exists" and False = unset
1030                                                print_debug('* handle "set_or_not" set_proc: ', serialize($set_proc),'api');
1031                                                if ($set_proc[1] == 'not_set')
1032                                                {
1033                                                        // leave it NOT SET
1034                                                }
1035                                                else
1036                                                {
1037                                                        // opposite of boolean not_set  = string "True" which simply sets a
1038                                                        // value it exists in the users session [email][] preference array
1039                                                        $prefs['email'][$this_avail_pref['id']] = 'True';
1040                                                }
1041                                        }
1042                                        // FUNCTION
1043                                        elseif ($set_proc[0] == 'function')
1044                                        {
1045                                                // string in $set_proc[1] should be "eval"uated as code, calling a function
1046                                                // which will give us a default value to put in users session [email][] prefs array
1047                                                print_debug(' * handle "function" set_proc: ', serialize($set_proc),'api');
1048                                                $evaled = '';
1049                                                //eval('$evaled = $this->'.$set_proc[1].'('.$account_id.');');
1050
1051                                                $code = '$evaled = $this->'.$set_proc[1].'('.$account_id.');';
1052                                                print_debug(' * $code: ', $code,'api');
1053                                                eval($code);
1054
1055                                                print_debug('* $evaled:', $evaled,'api');
1056                                                $prefs['email'][$this_avail_pref['id']] = $evaled;
1057                                        }
1058                                        // INIT_NO_FILL
1059                                        elseif ($set_proc[0] == 'init_no_fill')
1060                                        {
1061                                                // we have an available preference item that we may NOT fill with a default
1062                                                // value. Only the user may supply a value for this pref item.
1063                                                print_debug('* handle "init_no_fill" set_proc:', serialize($set_proc),'api');
1064                                                // we are FORBADE from filling this at this time!
1065                                        }
1066                                        // varEVAL
1067                                        elseif ($set_proc[0] == 'varEVAL')
1068                                        {
1069                                                // similar to "function" but used for array references, the string in $set_proc[1]
1070                                                // represents code which typically is an array referencing a system/api property
1071                                                print_debug('* handle "GLOBALS" set_proc:', serialize($set_proc),'api');
1072                                                $evaled = '';
1073                                                $code = '$evaled = '.$set_proc[1];
1074                                                print_debug(' * $code:', $code,'api');
1075                                                eval($code);
1076                                                print_debug('* $evaled:', $evaled,'api');
1077                                                $prefs['email'][$this_avail_pref['id']] = $evaled;
1078                                        }
1079                                        else
1080                                        {
1081                                                // error, no instructions on how to handle this element's default value creation
1082                                                echo 'class.preferences: create_email_preferences: set_proc ERROR: '.serialize($set_proc).'<br>';
1083                                        }
1084                                }
1085                                else
1086                                {
1087                                        // we have a value in the database, do we need to prepare it in any way?
1088                                        // (the following discussion is unconfirmed:)
1089                                        // DO NOT ALTER the data in the prefs array!!!! or the next time we call
1090                                        // save_repository withOUT undoing what we might do here, the
1091                                        // prefs will permenantly LOOSE the very thing(s) we are un-doing
1092                                        /// here until the next OFFICIAL submit email prefs function, where it
1093                                        // will again get this preparation before being written to the database.
1094
1095                                        // NOTE: if database de-fanging is eventually handled deeper in the
1096                                        // preferences class, then the following code would become depreciated
1097                                        // and should be removed in that case.
1098                                        if (($this_avail_pref['type'] == 'user_string') &&
1099                                                (stristr($this_avail_pref['write_props'], 'no_db_defang') == False))
1100                                        {
1101                                                // this value was "de-fanged" before putting it in the database
1102                                                // undo that defanging now
1103                                                $db_unfriendly = $email_base->html_quotes_decode($prefs['email'][$this_avail_pref['id']]);
1104                                                $prefs['email'][$this_avail_pref['id']] = $db_unfriendly;
1105                                        }
1106                                }
1107                        }
1108                        // users preferences are now established to known structured values...
1109
1110                        // SANITY CHECK
1111                        // ---  [email][use_trash_folder]  ---
1112                        // ---  [email][use_sent_folder]  ---
1113                        // is it possible to use Trash and Sent folders - i.e. using IMAP server
1114                        // if not - force settings to false
1115                        if (stristr($prefs['email']['mail_server_type'], 'imap') == False)
1116                        {
1117                                if (isset($prefs['email']['use_trash_folder']))
1118                                {
1119                                        unset($prefs['email']['use_trash_folder']);
1120                                }
1121
1122                                if (isset($prefs['email']['use_sent_folder']))
1123                                {
1124                                        unset($prefs['email']['use_sent_folder']);
1125                                }
1126                        }
1127
1128                        // DEBUG : force some settings to test stuff
1129                        //$prefs['email']['p_persistent'] = 'True';
1130                       
1131                        print_debug('class.preferences: $acctnum: ['.$acctnum.'] ; create_email_preferences: $prefs[email]', $prefs['email'],'api');
1132                        print_debug('class.preferences: create_email_preferences: LEAVING', 'messageonly','api');
1133                        return $prefs;
1134                }
1135
1136                        /*
1137                        // ==== DEPRECATED - ARCHIVAL CODE ====
1138                        // used to be part of function this->create_email_preferences()
1139                        // = = = =  SIMPLER PREFS  = = = =
1140                        // Default Preferences info that is:
1141                        // described in the email prefs array itself
1142
1143                        $default_trash_folder = 'Trash';
1144                        $default_sent_folder = 'Sent';
1145
1146                        // ---  userid  ---
1147                        if (!isset($prefs['email']['userid']))
1148                        {
1149                                $prefs['email']['userid'] = $this->sub_default_userid($accountid);
1150                        }
1151                        // ---  address  ---
1152                        if (!isset($prefs['email']['address']))
1153                        {
1154                                $prefs['email']['address'] = $this->email_address($accountid);
1155                        }
1156                        // ---  mail_server  ---
1157                        if (!isset($prefs['email']['mail_server']))
1158                        {
1159                                $prefs['email']['mail_server'] = $GLOBALS['phpgw_info']['server']['mail_server'];
1160                        }
1161                        // ---  mail_server_type  ---
1162                        if (!isset($prefs['email']['mail_server_type']))
1163                        {
1164                                $prefs['email']['mail_server_type'] = $GLOBALS['phpgw_info']['server']['mail_server_type'];
1165                        }
1166                        // ---  imap_server_type  ---
1167                        if (!isset($prefs['email']['imap_server_type']))
1168                        {
1169                                $prefs['email']['imap_server_type'] = $GLOBALS['phpgw_info']['server']['imap_server_type'];
1170                        }
1171                        // ---  mail_folder  ---
1172                        // because of the way this option works, an empty string IS ACTUALLY a valid value
1173                        // which represents the $HOME/* as the UWash mail files location
1174                        // THERFOR we must check the "Use_custom_setting" option to help us figure out what to do
1175                        if (!isset($prefs['email']['use_custom_settings']))
1176                        {
1177                                // we are NOT using custom settings so this MUST be the server default
1178                                $prefs['email']['mail_folder'] = $GLOBALS['phpgw_info']['server']['mail_folder'];
1179                        }
1180                        else
1181                        {
1182                                // we ARE using custom settings AND a BLANK STRING is a valid option, so...
1183                                if ((isset($prefs['email']['mail_folder']))
1184                                && ($prefs['email']['mail_folder'] != ''))
1185                                {
1186                                        // using custom AND a string exists, so "mail_folder" is that string stored in the custom prefs by the user
1187                                        // DO NOTING - VALID OPTION VALUE for $prefs['email']['mail_folder']
1188                                }
1189                                else
1190                                {
1191                                        // using Custom Prefs BUT this text box was left empty by the user on submit, so no value stored
1192                                        // BUT since we are using custom prefs, "mail_folder" MUST BE AN EMPTY STRING
1193                                        // which is an acceptable, valid preference, overriding any value which
1194                                        // may have been set in ["server"]["mail_folder"]
1195                                        // This is one of the few instances in the preference class where an empty, unspecified value
1196                                        // actually does NOT get deleted from the repository.
1197                                        $prefs['email']['mail_folder'] = '';
1198                                }
1199                        }
1200
1201                        // ---  use_trash_folder  ---
1202                        // ---  trash_folder_name  ---
1203                        // if the option to use the Trash folder is ON, make sure a proper name is specified
1204                        if (isset($prefs['email']['use_trash_folder']))
1205                        {
1206                                if ((!isset($prefs['email']['trash_folder_name']))
1207                                || ($prefs['email']['trash_folder_name'] == ''))
1208                                {
1209                                        $prefs['email']['trash_folder_name'] = $default_trash_folder;
1210                                }
1211                        }
1212
1213                        // ---  use_sent_folder  ---
1214                        // ---  sent_folder_name  ---
1215                        // if the option to use the sent folder is ON, make sure a proper name is specified
1216                        if (isset($prefs['email']['use_sent_folder']))
1217                        {
1218                                if ((!isset($prefs['email']['sent_folder_name']))
1219                                || ($prefs['email']['sent_folder_name'] == ''))
1220                                {
1221                                        $prefs['email']['sent_folder_name'] = $default_sent_folder;
1222                                }
1223                        }
1224
1225                        // ---  layout  ---
1226                        // Layout Template Preference
1227                        // layout 1 = default ; others are prefs
1228                        if (!isset($prefs['email']['layout']))
1229                        {
1230                                $prefs['email']['layout'] = 1;
1231                        }
1232
1233                        //// ---  font_size_offset  ---
1234                        //// Email Index Page Font Size Preference
1235                        //// layout 1 = default ; others are prefs
1236                        //if (!isset($prefs['email']['font_size_offset']))
1237                        //{
1238                        //      $prefs['email']['font_size_offset'] = 'normal';
1239                        //}
1240
1241                        // SANITY CHECK
1242                        // ---  use_trash_folder  ---
1243                        // ---  use_sent_folder  ---
1244                        // is it possible to use Trash and Sent folders - i.e. using IMAP server
1245                        // if not - force settings to false
1246                        if (stristr($prefs['email']['mail_server_type'], 'imap') == False)
1247                        {
1248                                if (isset($prefs['email']['use_trash_folder']))
1249                                {
1250                                        unset($prefs['email']['use_trash_folder']);
1251                                }
1252                               
1253                                if (isset($prefs['email']['use_sent_folder']))
1254                                {
1255                                        unset($prefs['email']['use_sent_folder']);
1256                                }
1257                        }
1258
1259                        // DEBUG : force some settings to test stuff
1260                        //$prefs['email']['layout'] = 1;
1261                        //$prefs['email']['layout'] = 2;
1262                        //$prefs['email']['font_size_offset'] = (-1);
1263
1264                        // DEBUG
1265                        //echo "<br>prefs['email']: <br>"
1266                        //      .'<pre>'.serialize($prefs['email']) .'</pre><br>';
1267                        return $prefs;
1268                        */
1269        } /* end of preferences class */
1270?>
Note: See TracBrowser for help on using the repository browser.