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('ContactCenter').' - '.lang('Preferences'); |
---|
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 | $actual = $this->get_preferences(); |
---|
33 | |
---|
34 | /* Get the catalog options */ |
---|
35 | $pCatalog = CreateObject('contactcenter.bo_people_catalog'); |
---|
36 | $types = $pCatalog->get_all_connections_types(); |
---|
37 | |
---|
38 | if (is_array($types)) |
---|
39 | { |
---|
40 | $options_email = ''; |
---|
41 | foreach($types as $id => $name) |
---|
42 | { |
---|
43 | $options_email .= '<option value="'.$id.'"'; |
---|
44 | |
---|
45 | if ($actual['personCardEmail'] == $id) |
---|
46 | { |
---|
47 | $options_email .= ' selected '; |
---|
48 | } |
---|
49 | |
---|
50 | $options_email .= '>'.$name."</option>\n"; |
---|
51 | } |
---|
52 | |
---|
53 | $options_phone = ''; |
---|
54 | foreach($types as $id => $name) |
---|
55 | { |
---|
56 | $options_phone .= '<option value="'.$id.'"'; |
---|
57 | |
---|
58 | if ($actual['personCardPhone'] == $id) |
---|
59 | { |
---|
60 | $options_phone .= ' selected '; |
---|
61 | } |
---|
62 | |
---|
63 | $options_phone .= '>'.$name."</option>\n"; |
---|
64 | } |
---|
65 | } |
---|
66 | else |
---|
67 | { |
---|
68 | $options_email = ''; |
---|
69 | $options_phone = ''; |
---|
70 | } |
---|
71 | |
---|
72 | if ($actual['displayConnector'] or !$actual['displayConnectorDefault']) |
---|
73 | { |
---|
74 | $GLOBALS['phpgw']->template->set_var('displayConnector', 'checked'); |
---|
75 | } |
---|
76 | else |
---|
77 | { |
---|
78 | $GLOBALS['phpgw']->template->set_var('displayConnector', ''); |
---|
79 | } |
---|
80 | |
---|
81 | $GLOBALS['phpgw']->template->set_var('personCardEmail', $options_email); |
---|
82 | $GLOBALS['phpgw']->template->set_var('personCardPhone', $options_phone); |
---|
83 | |
---|
84 | /* Translate the fields */ |
---|
85 | $this->translate('pref'); |
---|
86 | |
---|
87 | $GLOBALS['phpgw']->template->set_var('form_action', $GLOBALS['phpgw']->link('/index.php', 'menuaction=contactcenter.ui_preferences.set_preferences')); |
---|
88 | |
---|
89 | $GLOBALS['phpgw']->template->pparse('out', 'pref'); |
---|
90 | } |
---|
91 | |
---|
92 | function translate($handle) |
---|
93 | { |
---|
94 | $vars = $GLOBALS['phpgw']->template->get_undefined($handle); |
---|
95 | foreach($vars as $name => $value) |
---|
96 | { |
---|
97 | if (ereg('^lang_', $name) !== false) |
---|
98 | { |
---|
99 | $GLOBALS['phpgw']->template->set_var($name, lang(str_replace('_',' ',substr($name, 5)))); |
---|
100 | } |
---|
101 | } |
---|
102 | } |
---|
103 | |
---|
104 | function set_preferences() |
---|
105 | { |
---|
106 | if ($_POST['save']) |
---|
107 | { |
---|
108 | $GLOBALS['phpgw']->preferences->read(); |
---|
109 | /* |
---|
110 | $GLOBALS['phpgw']->preferences->delete('contactcenter', 'personCardEmail'); |
---|
111 | $GLOBALS['phpgw']->preferences->delete('contactcenter', 'personCardPhone'); |
---|
112 | */ |
---|
113 | $GLOBALS['phpgw']->preferences->delete('contactcenter', 'displayConnector'); |
---|
114 | $GLOBALS['phpgw']->preferences->delete('contactcenter', 'displayConnectorDefault'); |
---|
115 | |
---|
116 | /* |
---|
117 | $GLOBALS['phpgw']->preferences->add('contactcenter', 'personCardEmail', $_POST['personCardEmail'], 'forced'); |
---|
118 | $GLOBALS['phpgw']->preferences->add('contactcenter', 'personCardPhone', $_POST['personCardPhone'], 'forced'); |
---|
119 | */ |
---|
120 | |
---|
121 | $GLOBALS['phpgw']->preferences->add('contactcenter', 'displayConnectorDefault', '1'); |
---|
122 | |
---|
123 | if($_POST['displayConnector']) |
---|
124 | { |
---|
125 | $GLOBALS['phpgw']->preferences->add('contactcenter', 'displayConnector', '1'); |
---|
126 | } |
---|
127 | else |
---|
128 | { |
---|
129 | $GLOBALS['phpgw']->preferences->add('contactcenter', 'displayConnector', '0'); |
---|
130 | } |
---|
131 | |
---|
132 | $GLOBALS['phpgw']->preferences->save_repository(); |
---|
133 | } |
---|
134 | |
---|
135 | header('Location: '.$GLOBALS['phpgw']->link('/preferences/index.php')); |
---|
136 | } |
---|
137 | |
---|
138 | function get_preferences() |
---|
139 | { |
---|
140 | $prefs = $GLOBALS['phpgw']->preferences->read(); |
---|
141 | |
---|
142 | if (!$prefs['contactcenter']['displayConnectorDefault'] and !$prefs['contactcenter']['displayConnector']) |
---|
143 | { |
---|
144 | $prefs['contactcenter']['displayConnector'] = true; |
---|
145 | } |
---|
146 | |
---|
147 | $prefs['contactcenter']['personCardEmail'] = 1; |
---|
148 | $prefs['contactcenter']['personCardPhone'] = 2; |
---|
149 | |
---|
150 | return $prefs['contactcenter']; |
---|
151 | } |
---|
152 | } |
---|
153 | ?> |
---|