source: trunk/admin/inc/class.uimainscreen.inc.php @ 2802

Revision 2802, 9.9 KB checked in by rodsouza, 14 years ago (diff)

Ticket #1058 - Permitindo o envio de formulário por requisição background

  • Property svn:eol-style set to native
  • Property svn:executable set to *
Line 
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($_REQUEST['section']);
27                        $select_lang = addslashes($_REQUEST['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 (!$GLOBALS['phpgw']->acl->check('mainscreen_message_access',3,'admin'))
40                        {
41                                $acl_ok['loginhelp'] = True;
42                        }
43
44                        if ($_POST['cancel'] && !isset($_POST['message']) || !count($acl_ok) || $_POST['submit'] && !isset($acl_ok[$section]))
45                        {
46                                $GLOBALS['phpgw']->redirect_link('/admin/index.php');
47                        }
48
49                        $GLOBALS['phpgw']->template->set_file(array('message' => 'mainscreen_message.tpl'));
50                        $GLOBALS['phpgw']->template->set_block('message','form','form');
51                        $GLOBALS['phpgw']->template->set_block('message','row','row');
52                        $GLOBALS['phpgw']->template->set_block('message','row_2','row_2');
53
54                        if ($_POST['submit'])
55                        {
56                                $GLOBALS['phpgw']->db->query("DELETE FROM phpgw_lang WHERE message_id='$section" . "_message' AND app_name='"
57                                        . "$section' AND lang='$select_lang'",__LINE__,__FILE__);
58
59                                $GLOBALS['phpgw']->db->query("INSERT INTO phpgw_lang (message_id,app_name,lang,content)VALUES ('$section" . "_message','$section','$select_lang','"
60                                        . $message . "')",__LINE__,__FILE__);
61
62                                $GLOBALS[ 'phpgw_info' ][ 'flags' ][ 'java_script' ] .= "<script>ExpressoLivre.link( '{$GLOBALS[ 'phpgw' ] -> link( '/index.php','menuaction=admin.uimainscreen.index' ) }&section={$section}&saved=true' );</script>";
63                                exit;
64                        }
65                        if ($_POST['cancel'])   // back to section/lang-selection
66                        {
67                                $message = $section = '';
68                        }
69                        switch ($section)
70                        {
71                                case 'mainscreen':
72                                        $GLOBALS['phpgw_info']['flags']['app_header'] = lang('Admin').' - '.lang('Edit main screen message') . ': '.strtoupper($select_lang);
73                                        break;
74                                case 'loginscreen':
75                                        $GLOBALS['phpgw_info']['flags']['app_header'] = lang('Admin').' - '.lang('Edit login screen message') . ': '.strtoupper($select_lang);
76                                        break;
77                                case 'loginhelp':
78                                        $GLOBALS['phpgw_info']['flags']['app_header'] = lang('Admin').' - '.lang('Edit login help message') . ': '.strtoupper($select_lang);
79                                        break;
80                                default:
81                                        $GLOBALS['phpgw_info']['flags']['app_header'] = lang('Admin').' - '.lang('Main screen message');
82                                        break;
83                        }
84                        if(!@is_object($GLOBALS['phpgw']->js))
85                        {
86                                $GLOBALS['phpgw']->js = CreateObject('phpgwapi.javascript');
87                        }
88
89                        if ( array_key_exists( 'saved', $_GET ) && $_GET[ 'saved' ] == 'true' )
90                        {
91                                $feedback_message = '<center>'.lang('message has been updated').'</center>';
92                                $section = '';
93                        }
94
95                        if (empty($section))
96                        {
97
98                           $GLOBALS['phpgw']->js->validate_file('jscode','openwindow','admin');
99                           //$GLOBALS['phpgw']->common->phpgw_header();
100                           //echo parse_navbar();
101                                 
102                           
103                           $GLOBALS['phpgw']->template->set_var('form_action',$GLOBALS['phpgw']->link('/index.php','menuaction=admin.uimainscreen.index'));
104                                $GLOBALS['phpgw']->template->set_var('tr_color',$GLOBALS['phpgw_info']['theme']['th_bg']);
105                                $GLOBALS['phpgw']->template->set_var('value','&nbsp;');
106                                $GLOBALS['phpgw']->template->fp('rows','row_2',True);
107
108                                $tr_color = $GLOBALS['phpgw']->nextmatchs->alternate_row_color($tr_color);
109                                $GLOBALS['phpgw']->template->set_var('tr_color',$tr_color);
110
111                                $lang_select = '<select name="select_lang">';
112                                $GLOBALS['phpgw']->db->query("SELECT lang,phpgw_languages.lang_name,phpgw_languages.lang_id FROM phpgw_lang,phpgw_languages WHERE "
113                                        . "phpgw_lang.lang=phpgw_languages.lang_id GROUP BY lang,phpgw_languages.lang_name,"
114                                        . "phpgw_languages.lang_id ORDER BY lang",__LINE__,__FILE__);
115                                while ($GLOBALS['phpgw']->db->next_record())
116                                {
117                                        $lang = $GLOBALS['phpgw']->db->f('lang');
118                                        $lang_select .= '<option value="' . $lang . '"'.($lang == $select_lang ? ' selected' : '').'>' .
119                                                $lang . ' - ' . $GLOBALS['phpgw']->db->f('lang_name') . "</option>\n";
120                                }
121                                $lang_select .= '</select>';
122                                $GLOBALS['phpgw']->template->set_var('label',lang('Language'));
123                                $GLOBALS['phpgw']->template->set_var('value',$lang_select);
124                                $GLOBALS['phpgw']->template->fp('rows','row',True);
125
126                                $tr_color = $GLOBALS['phpgw']->nextmatchs->alternate_row_color($tr_color);
127                                $GLOBALS['phpgw']->template->set_var('tr_color',$tr_color);
128                                $select_section = '<select name="section">'."\n";
129                                foreach($acl_ok as $key => $val)
130                                {
131                                        $select_section .= ' <option value="'.$key.'"'.
132                                                ($key == $_REQUEST['section'] ? ' selected' : '') . '>' .
133                                                ($key == 'mainscreen' ? lang('Main screen') : lang($key)) . "</option>\n";
134                                }
135                                $select_section .= '</select>';
136                                $GLOBALS['phpgw']->template->set_var('label',lang('Section'));
137                                $GLOBALS['phpgw']->template->set_var('value',$select_section);
138                                $GLOBALS['phpgw']->template->fp('rows','row',True);
139
140                                $tr_color = $GLOBALS['phpgw']->nextmatchs->alternate_row_color($tr_color);
141                                $GLOBALS['phpgw']->template->set_var('tr_color',$tr_color);
142                                $GLOBALS['phpgw']->template->set_var('value','<input type="button" value="' . lang('Edit')
143                                        . '" onclick="ExpressoLivre.link( \'' . $GLOBALS[ 'phpgw' ] -> link( '/index.php','menuaction=admin.uimainscreen.index' )
144                                        . '\' + \'&section=\' + escape( this.form.section.item( 1 ).value ) + \'&select_lang=\' + escape( this.form.select_lang.item( 1 ).value ) )'
145                                        . '"><input type="button" name="cancel" value="'. lang('cancel') .'" onclick="ExpressoLivre.link( \'' . $GLOBALS[ 'phpgw' ] -> link( '/admin/index.php' ) . '\' )">');
146                                $GLOBALS['phpgw']->template->fp('rows','row_2',True);
147                        }
148                        else
149                        {
150                           $GLOBALS['phpgw']->db->query("SELECT content FROM phpgw_lang WHERE lang='$select_lang' AND message_id='$section"
151                                . "_message'",__LINE__,__FILE__);
152                                $GLOBALS['phpgw']->db->next_record();
153                               
154                                $current_message = $GLOBALS['phpgw']->db->f('content');
155                               
156                                if($_REQUEST['htmlarea'])
157                                {
158                                        //$text_or_htmlarea=$html->htmlarea('message',stripslashes($current_message));
159
160                                        include_once("news_admin/inc/fckeditor.php");
161                                        $oFCKeditor = new FCKeditor( 'message' );
162
163                                        $webserver_url = $GLOBALS['phpgw_info']['server']['webserver_url'];
164                                        $webserver_url = ( !empty($webserver_url) ) ? $webserver_url : '/';
165
166                                        if(strrpos($webserver_url,'/') === false || strrpos($webserver_url,'/') != (strlen($webserver_url)-1))
167                                                $webserver_url .= '/';
168
169                                        $oFCKeditor->BasePath = $webserver_url . 'news_admin/templates/default/fckeditor/';
170                                        $oFCKeditor->ToolbarSet = 'Basic';
171                                        $oFCKeditor->Value = $current_message;
172
173                                        $text_or_htmlarea = $oFCKeditor->Create( );
174
175                                        $htmlarea_button='<input type="button" name="no-htmlarea" onclick="ExpressoLivre.link( \''.$GLOBALS['phpgw']->link('/index.php','menuaction=admin.uimainscreen.index&htmlarea=true&section=' . $section ) . '\');" value="'.lang('disable WYSIWYG-editor').'">';       
176                                }
177                                else
178                                {
179                                        $text_or_htmlarea='<textarea name="message" style="width:100%; min-width:350px; height:300px;" wrap="virtual">' . stripslashes($current_message) . '</textarea>';
180                                        $htmlarea_button='<input type="button" name="htmlarea" onclick="ExpressoLivre.link( \''.$GLOBALS['phpgw']->link('/index.php','menuaction=admin.uimainscreen.index&htmlarea=true&section=' . $section ) . '\' );" value="'.lang('activate WYSIWYG-editor').'">';
181
182                                }                         
183
184                                $GLOBALS['phpgw']->js->validate_file('jscode','openwindow','admin');
185                                //$GLOBALS['phpgw']->common->phpgw_header();
186                                //echo parse_navbar();
187
188                                $GLOBALS['phpgw']->template->set_var('form_action',$GLOBALS['phpgw']->link('/index.php','menuaction=admin.uimainscreen.index'));
189                                $GLOBALS['phpgw']->template->set_var('select_lang',$select_lang);
190                                $GLOBALS['phpgw']->template->set_var('section',$section);
191                                $GLOBALS['phpgw']->template->set_var('tr_color',$GLOBALS['phpgw_info']['theme']['th_bg']);
192                                $GLOBALS['phpgw']->template->set_var('value','&nbsp;');
193                                $GLOBALS['phpgw']->template->fp('rows','row_2',True);
194
195                                $tr_color = $GLOBALS['phpgw']->nextmatchs->alternate_row_color($tr_color);
196                                $GLOBALS['phpgw']->template->set_var('tr_color',$tr_color);
197
198                               
199                                $GLOBALS['phpgw']->template->set_var('value',$text_or_htmlarea);
200                               
201                               
202                               
203                                $GLOBALS['phpgw']->template->fp('rows','row_2',True);
204
205                                $tr_color = $GLOBALS['phpgw']->nextmatchs->alternate_row_color($tr_color);
206                                $GLOBALS['phpgw']->template->set_var('tr_color',$tr_color);
207                                $GLOBALS['phpgw']->template->set_var('value','<input type="submit" name="submit" value="' . lang('Save')
208                                . '"><input type="button" name="cancel" value="'. lang('cancel') .'" onclick="ExpressoLivre.link( \'' . $GLOBALS[ 'phpgw' ] -> link( '/index.php','menuaction=admin.uimainscreen.index' ) . '\' )">'.$htmlarea_button);
209                                $GLOBALS['phpgw']->template->fp('rows','row_2',True);
210                        }
211
212                        $GLOBALS['phpgw']->template->set_var('lang_cancel',lang('Cancel'));
213                        $GLOBALS['phpgw']->template->set_var('error_message',$feedback_message);
214                        $GLOBALS['phpgw']->template->pfp('out','form');
215                }
216        }
217?>
Note: See TracBrowser for help on using the repository browser.