source: trunk/mobile/inc/class.ui_preferences.inc.php @ 691

Revision 691, 3.1 KB checked in by eduardoalex, 15 years ago (diff)

Ticket #449.

Line 
1<?php
2  /***************************************************************************\
3  * eGroupWare - Contacts Center                                              *
4  * http://www.egroupware.org                                                 *
5  * Written by:                                                               *
6  *  - Raphael Derosso Pereira <raphaelpereira@users.sourceforge.net>         *
7  *  sponsored by Thyamad - http://www.thyamad.com
8  * ------------------------------------------------------------------------- *
9  *  This program is free software; you can redistribute it and/or modify it  *
10  *  under the terms of the GNU General Public License as published by the    *
11  *  Free Software Foundation; either version 2 of the License, or (at your   *
12  *  option) any later version.                                               *
13  \***************************************************************************/
14
15
16        class ui_preferences
17        {
18                var $public_functions = array(
19                        'index'           => true,
20                        'set_preferences' => true,
21                );
22               
23                function index()
24                {
25                        $GLOBALS['phpgw_info']['flags']['app_header'] = lang('Preferences').' - '.lang('Mobile');
26                        $GLOBALS['phpgw']->common->phpgw_header();
27                        echo parse_navbar();
28
29                        $GLOBALS['phpgw']->template->set_file(array('pref' => 'preferences.tpl'));
30
31                        /* Get Saved Preferences */
32                        $prefs = $GLOBALS['phpgw']->preferences->read();
33                       
34                        if($prefs['mobile']['download_attach']==1)
35                                $GLOBALS['phpgw']->template->set_var('download_attach_option_Yes_selected', 'selected');
36                        else
37                                $GLOBALS['phpgw']->template->set_var('download_attach_option_No_selected', 'selected');
38                       
39                        $max_page = isset($prefs['mobile']['max_message_per_page'])?
40                                        $prefs['mobile']['max_message_per_page']:10;
41                       
42                        $max_page = "max_message_per_page_".$max_page."_selected";
43
44                       
45                        $GLOBALS['phpgw']->template->set_var($max_page,"selected");
46                       
47                        /* Translate the fields */
48                        $this->translate('pref');
49
50                        $GLOBALS['phpgw']->template->set_var('form_action', $GLOBALS['phpgw']->link('/index.php', 'menuaction=mobile.ui_preferences.set_preferences'));
51
52                        $GLOBALS['phpgw']->template->pparse('out', 'pref');
53                }
54                       
55                function translate($handle)
56                {
57                        $vars = $GLOBALS['phpgw']->template->get_undefined($handle);
58                        foreach($vars as $name => $value)
59                        {
60                                if (ereg('^lang_', $name) !== false)
61                                {
62                                        $GLOBALS['phpgw']->template->set_var($name, lang(str_replace('_',' ',substr($name, 5))));
63                                }
64                                else {
65                                        $GLOBALS['phpgw']->template->set_var($name, " ");
66                                }
67                        }
68                }
69               
70                function set_preferences()
71                {
72                        if ($_POST['save'])
73                        {
74                                $GLOBALS['phpgw']->preferences->read();
75                               
76                                if($_POST['download_attach']==0)
77                                        $GLOBALS['phpgw']->preferences->delete('mobile', 'download_attach');
78                                else
79                                        $GLOBALS['phpgw']->preferences->add('mobile', 'download_attach', '1');
80                               
81                                $GLOBALS['phpgw']->preferences->add('mobile', 'max_message_per_page', $_POST['max_message_per_page']);
82                               
83                                $GLOBALS['phpgw']->preferences->save_repository();
84                        }
85
86                        header('Location: '.$GLOBALS['phpgw']->link('/preferences/index.php'));
87                }
88
89        }
90?>
Note: See TracBrowser for help on using the repository browser.