[2] | 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 | |
---|
[2876] | 25 | //$html = createObject('phpgwapi.html'); |
---|
[2802] | 26 | $section = addslashes($_REQUEST['section']); |
---|
| 27 | $select_lang = addslashes($_REQUEST['select_lang']); |
---|
[2] | 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 | } |
---|
[1117] | 39 | if (!$GLOBALS['phpgw']->acl->check('mainscreen_message_access',3,'admin')) |
---|
| 40 | { |
---|
| 41 | $acl_ok['loginhelp'] = True; |
---|
| 42 | } |
---|
[2802] | 43 | |
---|
| 44 | if ($_POST['cancel'] && !isset($_POST['message']) || !count($acl_ok) || $_POST['submit'] && !isset($acl_ok[$section])) |
---|
[2] | 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__); |
---|
[2802] | 58 | |
---|
[2] | 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__); |
---|
[2802] | 61 | |
---|
| 62 | $GLOBALS[ 'phpgw_info' ][ 'flags' ][ 'java_script' ] .= "<script>ExpressoLivre.link( '{$GLOBALS[ 'phpgw' ] -> link( '/index.php','menuaction=admin.uimainscreen.index' ) }§ion={$section}&saved=true' );</script>"; |
---|
| 63 | exit; |
---|
[2] | 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; |
---|
[1117] | 77 | case 'loginhelp': |
---|
| 78 | $GLOBALS['phpgw_info']['flags']['app_header'] = lang('Admin').' - '.lang('Edit login help message') . ': '.strtoupper($select_lang); |
---|
| 79 | break; |
---|
[2] | 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 | |
---|
[2802] | 89 | if ( array_key_exists( 'saved', $_GET ) && $_GET[ 'saved' ] == 'true' ) |
---|
| 90 | { |
---|
| 91 | $feedback_message = '<center>'.lang('message has been updated').'</center>'; |
---|
| 92 | $section = ''; |
---|
| 93 | } |
---|
[2] | 94 | |
---|
| 95 | if (empty($section)) |
---|
| 96 | { |
---|
[2876] | 97 | $GLOBALS['phpgw']->js->validate_file('jscode','openwindow','admin'); |
---|
| 98 | //$GLOBALS['phpgw']->common->phpgw_header(); |
---|
| 99 | //echo parse_navbar(); |
---|
[2] | 100 | |
---|
[2876] | 101 | $GLOBALS['phpgw']->template->set_var('form_action',$GLOBALS['phpgw']->link('/index.php','menuaction=admin.uimainscreen.index')); |
---|
[2] | 102 | $GLOBALS['phpgw']->template->set_var('tr_color',$GLOBALS['phpgw_info']['theme']['th_bg']); |
---|
| 103 | $GLOBALS['phpgw']->template->set_var('value',' '); |
---|
| 104 | $GLOBALS['phpgw']->template->fp('rows','row_2',True); |
---|
| 105 | |
---|
| 106 | $tr_color = $GLOBALS['phpgw']->nextmatchs->alternate_row_color($tr_color); |
---|
| 107 | $GLOBALS['phpgw']->template->set_var('tr_color',$tr_color); |
---|
| 108 | |
---|
| 109 | $lang_select = '<select name="select_lang">'; |
---|
| 110 | $GLOBALS['phpgw']->db->query("SELECT lang,phpgw_languages.lang_name,phpgw_languages.lang_id FROM phpgw_lang,phpgw_languages WHERE " |
---|
| 111 | . "phpgw_lang.lang=phpgw_languages.lang_id GROUP BY lang,phpgw_languages.lang_name," |
---|
| 112 | . "phpgw_languages.lang_id ORDER BY lang",__LINE__,__FILE__); |
---|
| 113 | while ($GLOBALS['phpgw']->db->next_record()) |
---|
| 114 | { |
---|
| 115 | $lang = $GLOBALS['phpgw']->db->f('lang'); |
---|
| 116 | $lang_select .= '<option value="' . $lang . '"'.($lang == $select_lang ? ' selected' : '').'>' . |
---|
| 117 | $lang . ' - ' . $GLOBALS['phpgw']->db->f('lang_name') . "</option>\n"; |
---|
| 118 | } |
---|
| 119 | $lang_select .= '</select>'; |
---|
| 120 | $GLOBALS['phpgw']->template->set_var('label',lang('Language')); |
---|
| 121 | $GLOBALS['phpgw']->template->set_var('value',$lang_select); |
---|
| 122 | $GLOBALS['phpgw']->template->fp('rows','row',True); |
---|
| 123 | |
---|
| 124 | $tr_color = $GLOBALS['phpgw']->nextmatchs->alternate_row_color($tr_color); |
---|
| 125 | $GLOBALS['phpgw']->template->set_var('tr_color',$tr_color); |
---|
| 126 | $select_section = '<select name="section">'."\n"; |
---|
| 127 | foreach($acl_ok as $key => $val) |
---|
| 128 | { |
---|
| 129 | $select_section .= ' <option value="'.$key.'"'. |
---|
[2802] | 130 | ($key == $_REQUEST['section'] ? ' selected' : '') . '>' . |
---|
[1362] | 131 | ($key == 'mainscreen' ? lang('Main screen') : lang($key)) . "</option>\n"; |
---|
[2] | 132 | } |
---|
| 133 | $select_section .= '</select>'; |
---|
| 134 | $GLOBALS['phpgw']->template->set_var('label',lang('Section')); |
---|
| 135 | $GLOBALS['phpgw']->template->set_var('value',$select_section); |
---|
| 136 | $GLOBALS['phpgw']->template->fp('rows','row',True); |
---|
| 137 | |
---|
| 138 | $tr_color = $GLOBALS['phpgw']->nextmatchs->alternate_row_color($tr_color); |
---|
| 139 | $GLOBALS['phpgw']->template->set_var('tr_color',$tr_color); |
---|
[2876] | 140 | $GLOBALS['phpgw']->template->set_var('value', |
---|
| 141 | '<input type="button" value="' |
---|
| 142 | . lang('Edit') . '" onclick="ExpressoLivre.link( \'' |
---|
| 143 | . $GLOBALS[ 'phpgw' ] -> link( '/index.php','menuaction=admin.uimainscreen.index' ) |
---|
| 144 | . '\' + \'§ion=\' + escape( this.form.section.item( 1 ).value )' |
---|
| 145 | . ' + \'&select_lang=\' + escape( this.form.select_lang.item( 1 ).value ) )' |
---|
| 146 | . '">' |
---|
| 147 | . '<input type="button" name="cancel" value="' |
---|
| 148 | . lang('cancel') . '" onclick="ExpressoLivre.link( \'' |
---|
| 149 | . $GLOBALS[ 'phpgw' ] -> link( '/admin/index.php' ) |
---|
| 150 | . '\' )">' |
---|
| 151 | ); |
---|
[2] | 152 | $GLOBALS['phpgw']->template->fp('rows','row_2',True); |
---|
| 153 | } |
---|
| 154 | else |
---|
| 155 | { |
---|
[2876] | 156 | $GLOBALS['phpgw']->template->set_block('message','edit','edit'); |
---|
| 157 | $GLOBALS['phpgw']->template->set_block('message','edit_script','edit_script'); |
---|
[2802] | 158 | |
---|
[2] | 159 | $GLOBALS['phpgw']->js->validate_file('jscode','openwindow','admin'); |
---|
[2802] | 160 | |
---|
[2876] | 161 | $GLOBALS['phpgw']->db->query("SELECT content FROM phpgw_lang WHERE lang='$select_lang' AND message_id='$section" |
---|
| 162 | . "_message'",__LINE__,__FILE__); |
---|
| 163 | $GLOBALS['phpgw']->db->next_record(); |
---|
| 164 | |
---|
[2] | 165 | $GLOBALS['phpgw']->template->set_var('form_action',$GLOBALS['phpgw']->link('/index.php','menuaction=admin.uimainscreen.index')); |
---|
| 166 | $GLOBALS['phpgw']->template->set_var('select_lang',$select_lang); |
---|
| 167 | $GLOBALS['phpgw']->template->set_var('section',$section); |
---|
[2876] | 168 | $GLOBALS['phpgw']->template->set_var('message', '<textarea name="message"></textarea>'); |
---|
[2] | 169 | |
---|
[2876] | 170 | $GLOBALS['phpgw']->template->fp('scripts','edit_script',True); |
---|
| 171 | $GLOBALS['phpgw']->template->fp('rows','edit',True); |
---|
[2] | 172 | |
---|
[2876] | 173 | $GLOBALS['phpgw']->template->set_var( 'value', |
---|
| 174 | '<input type="submit" name="submit" value="' |
---|
| 175 | . lang('Save') . '">' |
---|
| 176 | . '<input type="button" name="cancel" value="'. lang('cancel') |
---|
| 177 | .'" onclick="ExpressoLivre.link( \'' |
---|
| 178 | . $GLOBALS[ 'phpgw' ] -> link( '/index.php','menuaction=admin.uimainscreen.index' ) |
---|
| 179 | . '\' )">' |
---|
| 180 | ); |
---|
[2] | 181 | |
---|
| 182 | $GLOBALS['phpgw']->template->fp('rows','row_2',True); |
---|
| 183 | } |
---|
| 184 | |
---|
| 185 | $GLOBALS['phpgw']->template->set_var('lang_cancel',lang('Cancel')); |
---|
| 186 | $GLOBALS['phpgw']->template->set_var('error_message',$feedback_message); |
---|
| 187 | $GLOBALS['phpgw']->template->pfp('out','form'); |
---|
| 188 | } |
---|
| 189 | } |
---|
| 190 | ?> |
---|