1 | <?php |
---|
2 | /**************************************************************************\ |
---|
3 | * eGroupWare - administration * |
---|
4 | * http://www.egroupware.org * |
---|
5 | * -------------------------------------------- * |
---|
6 | * This program is free software; you can redistribute it and/or modify it * |
---|
7 | * under the terms of the GNU General Public License as published by the * |
---|
8 | * Free Software Foundation; either version 2 of the License, or (at your * |
---|
9 | * option) any later version. * |
---|
10 | \**************************************************************************/ |
---|
11 | |
---|
12 | |
---|
13 | class uimainscreen |
---|
14 | { |
---|
15 | var $public_functions = array('index' => True); |
---|
16 | |
---|
17 | function uimainscreen() |
---|
18 | { |
---|
19 | $GLOBALS['phpgw']->nextmatchs = CreateObject('phpgwapi.nextmatchs'); |
---|
20 | } |
---|
21 | |
---|
22 | function index() |
---|
23 | { |
---|
24 | |
---|
25 | $html = createObject('phpgwapi.html'); |
---|
26 | $section = addslashes($_POST['section']); |
---|
27 | $select_lang = addslashes($_POST['select_lang']); |
---|
28 | $message = addslashes($_POST['message']); |
---|
29 | |
---|
30 | $acl_ok = array(); |
---|
31 | if (!$GLOBALS['phpgw']->acl->check('mainscreen_message_access',1,'admin')) |
---|
32 | { |
---|
33 | $acl_ok['mainscreen'] = True; |
---|
34 | } |
---|
35 | if (!$GLOBALS['phpgw']->acl->check('mainscreen_message_access',2,'admin')) |
---|
36 | { |
---|
37 | $acl_ok['loginscreen'] = True; |
---|
38 | } |
---|
39 | if ($_POST['cancel'] && !isset($_POST['message']) || |
---|
40 | !count($acl_ok) || $_POST['submit'] && !isset($acl_ok[$section])) |
---|
41 | { |
---|
42 | $GLOBALS['phpgw']->redirect_link('/admin/index.php'); |
---|
43 | } |
---|
44 | |
---|
45 | $GLOBALS['phpgw']->template->set_file(array('message' => 'mainscreen_message.tpl')); |
---|
46 | $GLOBALS['phpgw']->template->set_block('message','form','form'); |
---|
47 | $GLOBALS['phpgw']->template->set_block('message','row','row'); |
---|
48 | $GLOBALS['phpgw']->template->set_block('message','row_2','row_2'); |
---|
49 | |
---|
50 | if ($_POST['submit']) |
---|
51 | { |
---|
52 | $GLOBALS['phpgw']->db->query("DELETE FROM phpgw_lang WHERE message_id='$section" . "_message' AND app_name='" |
---|
53 | . "$section' AND lang='$select_lang'",__LINE__,__FILE__); |
---|
54 | $GLOBALS['phpgw']->db->query("INSERT INTO phpgw_lang (message_id,app_name,lang,content)VALUES ('$section" . "_message','$section','$select_lang','" |
---|
55 | . $message . "')",__LINE__,__FILE__); |
---|
56 | $feedback_message = '<center>'.lang('message has been updated').'</center>'; |
---|
57 | |
---|
58 | $section = ''; |
---|
59 | } |
---|
60 | if ($_POST['cancel']) // back to section/lang-selection |
---|
61 | { |
---|
62 | $message = $section = ''; |
---|
63 | } |
---|
64 | switch ($section) |
---|
65 | { |
---|
66 | case 'mainscreen': |
---|
67 | $GLOBALS['phpgw_info']['flags']['app_header'] = lang('Admin').' - '.lang('Edit main screen message') . ': '.strtoupper($select_lang); |
---|
68 | break; |
---|
69 | case 'loginscreen': |
---|
70 | $GLOBALS['phpgw_info']['flags']['app_header'] = lang('Admin').' - '.lang('Edit login screen message') . ': '.strtoupper($select_lang); |
---|
71 | break; |
---|
72 | default: |
---|
73 | $GLOBALS['phpgw_info']['flags']['app_header'] = lang('Admin').' - '.lang('Main screen message'); |
---|
74 | break; |
---|
75 | } |
---|
76 | if(!@is_object($GLOBALS['phpgw']->js)) |
---|
77 | { |
---|
78 | $GLOBALS['phpgw']->js = CreateObject('phpgwapi.javascript'); |
---|
79 | } |
---|
80 | |
---|
81 | |
---|
82 | |
---|
83 | |
---|
84 | if (empty($section)) |
---|
85 | { |
---|
86 | |
---|
87 | $GLOBALS['phpgw']->js->validate_file('jscode','openwindow','admin'); |
---|
88 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
89 | echo parse_navbar(); |
---|
90 | |
---|
91 | |
---|
92 | $GLOBALS['phpgw']->template->set_var('form_action',$GLOBALS['phpgw']->link('/index.php','menuaction=admin.uimainscreen.index')); |
---|
93 | $GLOBALS['phpgw']->template->set_var('tr_color',$GLOBALS['phpgw_info']['theme']['th_bg']); |
---|
94 | $GLOBALS['phpgw']->template->set_var('value',' '); |
---|
95 | $GLOBALS['phpgw']->template->fp('rows','row_2',True); |
---|
96 | |
---|
97 | $tr_color = $GLOBALS['phpgw']->nextmatchs->alternate_row_color($tr_color); |
---|
98 | $GLOBALS['phpgw']->template->set_var('tr_color',$tr_color); |
---|
99 | |
---|
100 | $lang_select = '<select name="select_lang">'; |
---|
101 | $GLOBALS['phpgw']->db->query("SELECT lang,phpgw_languages.lang_name,phpgw_languages.lang_id FROM phpgw_lang,phpgw_languages WHERE " |
---|
102 | . "phpgw_lang.lang=phpgw_languages.lang_id GROUP BY lang,phpgw_languages.lang_name," |
---|
103 | . "phpgw_languages.lang_id ORDER BY lang",__LINE__,__FILE__); |
---|
104 | while ($GLOBALS['phpgw']->db->next_record()) |
---|
105 | { |
---|
106 | $lang = $GLOBALS['phpgw']->db->f('lang'); |
---|
107 | $lang_select .= '<option value="' . $lang . '"'.($lang == $select_lang ? ' selected' : '').'>' . |
---|
108 | $lang . ' - ' . $GLOBALS['phpgw']->db->f('lang_name') . "</option>\n"; |
---|
109 | } |
---|
110 | $lang_select .= '</select>'; |
---|
111 | $GLOBALS['phpgw']->template->set_var('label',lang('Language')); |
---|
112 | $GLOBALS['phpgw']->template->set_var('value',$lang_select); |
---|
113 | $GLOBALS['phpgw']->template->fp('rows','row',True); |
---|
114 | |
---|
115 | $tr_color = $GLOBALS['phpgw']->nextmatchs->alternate_row_color($tr_color); |
---|
116 | $GLOBALS['phpgw']->template->set_var('tr_color',$tr_color); |
---|
117 | $select_section = '<select name="section">'."\n"; |
---|
118 | foreach($acl_ok as $key => $val) |
---|
119 | { |
---|
120 | $select_section .= ' <option value="'.$key.'"'. |
---|
121 | ($key == $_POST['section'] ? ' selected' : '') . '>' . |
---|
122 | ($key == 'mainscreen' ? lang('Main screen') : lang("Login screen")) . "</option>\n"; |
---|
123 | } |
---|
124 | $select_section .= '</select>'; |
---|
125 | $GLOBALS['phpgw']->template->set_var('label',lang('Section')); |
---|
126 | $GLOBALS['phpgw']->template->set_var('value',$select_section); |
---|
127 | $GLOBALS['phpgw']->template->fp('rows','row',True); |
---|
128 | |
---|
129 | $tr_color = $GLOBALS['phpgw']->nextmatchs->alternate_row_color($tr_color); |
---|
130 | $GLOBALS['phpgw']->template->set_var('tr_color',$tr_color); |
---|
131 | $GLOBALS['phpgw']->template->set_var('value','<input type="submit" value="' . lang('Edit') |
---|
132 | . '"><input type="submit" name="cancel" value="'. lang('cancel') .'">'); |
---|
133 | $GLOBALS['phpgw']->template->fp('rows','row_2',True); |
---|
134 | } |
---|
135 | else |
---|
136 | { |
---|
137 | $GLOBALS['phpgw']->db->query("SELECT content FROM phpgw_lang WHERE lang='$select_lang' AND message_id='$section" |
---|
138 | . "_message'",__LINE__,__FILE__); |
---|
139 | $GLOBALS['phpgw']->db->next_record(); |
---|
140 | |
---|
141 | $current_message = $GLOBALS['phpgw']->db->f('content'); |
---|
142 | |
---|
143 | if($_POST['htmlarea']) |
---|
144 | { |
---|
145 | $text_or_htmlarea=$html->htmlarea('message',stripslashes($current_message)); |
---|
146 | $htmlarea_button='<input type="submit" name="no-htmlarea" onclick="self.location.href=\''.$GLOBALS['phpgw']->link('/index.php','menuaction=admin.uimainscreen.index&htmlarea=true').'\'" value="'.lang('disable WYSIWYG-editor').'">'; |
---|
147 | } |
---|
148 | else |
---|
149 | { |
---|
150 | $text_or_htmlarea='<textarea name="message" style="width:100%; min-width:350px; height:300px;" wrap="virtual">' . stripslashes($current_message) . '</textarea>'; |
---|
151 | $htmlarea_button='<input type="submit" name="htmlarea" onclick="self.location.href=\''.$GLOBALS['phpgw']->link('/index.php','menuaction=admin.uimainscreen.index&htmlarea=true').'\'" value="'.lang('activate WYSIWYG-editor').'">'; |
---|
152 | |
---|
153 | } |
---|
154 | |
---|
155 | $GLOBALS['phpgw']->js->validate_file('jscode','openwindow','admin'); |
---|
156 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
157 | echo parse_navbar(); |
---|
158 | |
---|
159 | $GLOBALS['phpgw']->template->set_var('form_action',$GLOBALS['phpgw']->link('/index.php','menuaction=admin.uimainscreen.index')); |
---|
160 | $GLOBALS['phpgw']->template->set_var('select_lang',$select_lang); |
---|
161 | $GLOBALS['phpgw']->template->set_var('section',$section); |
---|
162 | $GLOBALS['phpgw']->template->set_var('tr_color',$GLOBALS['phpgw_info']['theme']['th_bg']); |
---|
163 | $GLOBALS['phpgw']->template->set_var('value',' '); |
---|
164 | $GLOBALS['phpgw']->template->fp('rows','row_2',True); |
---|
165 | |
---|
166 | $tr_color = $GLOBALS['phpgw']->nextmatchs->alternate_row_color($tr_color); |
---|
167 | $GLOBALS['phpgw']->template->set_var('tr_color',$tr_color); |
---|
168 | |
---|
169 | |
---|
170 | $GLOBALS['phpgw']->template->set_var('value',$text_or_htmlarea); |
---|
171 | |
---|
172 | |
---|
173 | |
---|
174 | $GLOBALS['phpgw']->template->fp('rows','row_2',True); |
---|
175 | |
---|
176 | $tr_color = $GLOBALS['phpgw']->nextmatchs->alternate_row_color($tr_color); |
---|
177 | $GLOBALS['phpgw']->template->set_var('tr_color',$tr_color); |
---|
178 | $GLOBALS['phpgw']->template->set_var('value','<input type="submit" name="submit" value="' . lang('Save') |
---|
179 | . '"><input type="submit" name="cancel" value="'. lang('cancel') .'">'.$htmlarea_button); |
---|
180 | $GLOBALS['phpgw']->template->fp('rows','row_2',True); |
---|
181 | } |
---|
182 | |
---|
183 | $GLOBALS['phpgw']->template->set_var('lang_cancel',lang('Cancel')); |
---|
184 | $GLOBALS['phpgw']->template->set_var('error_message',$feedback_message); |
---|
185 | $GLOBALS['phpgw']->template->pfp('out','form'); |
---|
186 | } |
---|
187 | } |
---|
188 | ?> |
---|