[3] | 1 | <?php |
---|
| 2 | # -- BEGIN LICENSE BLOCK --------------------------------------- |
---|
| 3 | # |
---|
| 4 | # This file is part of Dotclear 2. |
---|
| 5 | # |
---|
[1179] | 6 | # Copyright (c) 2003-2013 Olivier Meunier & Association Dotclear |
---|
[3] | 7 | # Licensed under the GPL version 2.0 license. |
---|
| 8 | # See LICENSE file or |
---|
| 9 | # http://www.gnu.org/licenses/old-licenses/gpl-2.0.html |
---|
| 10 | # |
---|
| 11 | # -- END LICENSE BLOCK ----------------------------------------- |
---|
| 12 | if (!defined('DC_CONTEXT_ADMIN')) { return; } |
---|
| 13 | |
---|
[589] | 14 | # Local navigation |
---|
| 15 | if (!empty($_POST['gp_nav'])) { |
---|
| 16 | http::redirect($p_url.$_POST['gp_nav']); |
---|
| 17 | exit; |
---|
| 18 | } |
---|
| 19 | if (!empty($_POST['lp_nav'])) { |
---|
| 20 | http::redirect($p_url.$_POST['lp_nav']); |
---|
| 21 | exit; |
---|
| 22 | } |
---|
| 23 | |
---|
[3] | 24 | # Local prefs update |
---|
| 25 | if (!empty($_POST['s']) && is_array($_POST['s'])) |
---|
| 26 | { |
---|
| 27 | try |
---|
| 28 | { |
---|
| 29 | foreach ($_POST['s'] as $ws => $s) |
---|
| 30 | { |
---|
| 31 | $core->auth->user_prefs->addWorkspace($ws); |
---|
| 32 | |
---|
| 33 | foreach ($s as $k => $v) { |
---|
| 34 | $core->auth->user_prefs->$ws->put($k,$v); |
---|
| 35 | } |
---|
| 36 | } |
---|
| 37 | |
---|
| 38 | http::redirect($p_url.'&upd=1'); |
---|
| 39 | } |
---|
| 40 | catch (Exception $e) |
---|
| 41 | { |
---|
| 42 | $core->error->add($e->getMessage()); |
---|
| 43 | } |
---|
| 44 | } |
---|
| 45 | |
---|
| 46 | # Global prefs update |
---|
| 47 | if (!empty($_POST['gs']) && is_array($_POST['gs'])) |
---|
| 48 | { |
---|
| 49 | try |
---|
| 50 | { |
---|
| 51 | foreach ($_POST['gs'] as $ws => $s) |
---|
| 52 | { |
---|
| 53 | $core->auth->user_prefs->addWorkspace($ws); |
---|
| 54 | |
---|
| 55 | foreach ($s as $k => $v) { |
---|
| 56 | $core->auth->user_prefs->$ws->put($k,$v,null,null,true,true); |
---|
| 57 | } |
---|
| 58 | } |
---|
| 59 | |
---|
| 60 | http::redirect($p_url.'&upd=1&part=global'); |
---|
| 61 | } |
---|
| 62 | catch (Exception $e) |
---|
| 63 | { |
---|
| 64 | $core->error->add($e->getMessage()); |
---|
| 65 | } |
---|
| 66 | } |
---|
| 67 | |
---|
| 68 | $part = !empty($_GET['part']) && $_GET['part'] == 'global' ? 'global' : 'local'; |
---|
| 69 | |
---|
| 70 | function prefLine($id,$s,$ws,$field_name,$strong_label) |
---|
| 71 | { |
---|
| 72 | if ($s['type'] == 'boolean') { |
---|
| 73 | $field = form::combo(array($field_name.'['.$ws.']['.$id.']',$field_name.'_'.$id), |
---|
[1109] | 74 | array(__('yes') => 1, __('no') => 0),$s['value'] ? 1 : 0); |
---|
[3] | 75 | } else { |
---|
| 76 | $field = form::field(array($field_name.'['.$ws.']['.$id.']',$field_name.'_'.$id),40,null, |
---|
| 77 | html::escapeHTML($s['value'])); |
---|
| 78 | } |
---|
| 79 | |
---|
| 80 | $slabel = $strong_label ? '<strong>%s</strong>' : '%s'; |
---|
| 81 | |
---|
| 82 | return |
---|
[1348] | 83 | '<tr class="line">'. |
---|
[1280] | 84 | '<td scope="raw"><label for="s_'.$id.'">'.sprintf($slabel,html::escapeHTML($id)).'</label></td>'. |
---|
[3] | 85 | '<td>'.$field.'</td>'. |
---|
| 86 | '<td>'.$s['type'].'</td>'. |
---|
| 87 | '<td>'.html::escapeHTML($s['label']).'</td>'. |
---|
| 88 | '</tr>'; |
---|
| 89 | } |
---|
| 90 | ?> |
---|
| 91 | <html> |
---|
| 92 | <head> |
---|
| 93 | <title>user:preferences</title> |
---|
| 94 | <?php echo dcPage::jsPageTabs($part); ?> |
---|
[589] | 95 | <script type="text/javascript"> |
---|
| 96 | //<![CDATA[ |
---|
| 97 | $(function() { |
---|
| 98 | $("#gp_submit").hide(); |
---|
| 99 | $("#lp_submit").hide(); |
---|
| 100 | $("#gp_nav").change(function() { |
---|
| 101 | window.location = $("#gp_nav option:selected").val(); |
---|
| 102 | }) |
---|
| 103 | $("#lp_nav").change(function() { |
---|
| 104 | window.location = $("#lp_nav option:selected").val(); |
---|
| 105 | }) |
---|
| 106 | }); |
---|
| 107 | //]]> |
---|
| 108 | </script> |
---|
[3] | 109 | </head> |
---|
| 110 | |
---|
| 111 | <body> |
---|
| 112 | <?php |
---|
[1358] | 113 | echo dcPage::breadcrumb( |
---|
| 114 | array( |
---|
| 115 | __('System') => '', |
---|
| 116 | html::escapeHTML($core->auth->userID()) => '', |
---|
| 117 | '<span class="page-title">'.__('user:preferences').'</span>' => '' |
---|
| 118 | )); |
---|
| 119 | |
---|
[3] | 120 | if (!empty($_GET['upd'])) { |
---|
[907] | 121 | dcPage::message(__('Preferences successfully updated')); |
---|
[3] | 122 | } |
---|
| 123 | |
---|
| 124 | if (!empty($_GET['upda'])) { |
---|
[907] | 125 | dcPage::message(__('Preferences definition successfully updated')); |
---|
[3] | 126 | } |
---|
| 127 | ?> |
---|
| 128 | |
---|
[1338] | 129 | <div id="local" class="multi-part" title="<?php echo __('User preferences'); ?>"> |
---|
[581] | 130 | |
---|
| 131 | <?php |
---|
[1341] | 132 | $table_header = '<table class="prefs" id="%s"><caption class="as_h3">%s</caption>'. |
---|
[581] | 133 | '<thead>'. |
---|
| 134 | '<tr>'."\n". |
---|
| 135 | ' <th class="nowrap">Setting ID</th>'."\n". |
---|
| 136 | ' <th>'.__('Value').'</th>'."\n". |
---|
| 137 | ' <th>'.__('Type').'</th>'."\n". |
---|
| 138 | ' <th class="maximalx">'.__('Description').'</th>'."\n". |
---|
| 139 | '</tr>'."\n". |
---|
| 140 | '</thead>'."\n". |
---|
| 141 | '<tbody>'; |
---|
| 142 | $table_footer = '</tbody></table>'; |
---|
| 143 | |
---|
[3] | 144 | $prefs = array(); |
---|
| 145 | foreach ($core->auth->user_prefs->dumpWorkspaces() as $ws => $workspace) { |
---|
| 146 | foreach ($workspace->dumpPrefs() as $k => $v) { |
---|
| 147 | $prefs[$ws][$k] = $v; |
---|
| 148 | } |
---|
| 149 | } |
---|
[589] | 150 | ksort($prefs); |
---|
| 151 | if (count($prefs) > 0) { |
---|
| 152 | $ws_combo = array(); |
---|
| 153 | foreach ($prefs as $ws => $s) { |
---|
| 154 | $ws_combo[$ws] = '#l_'.$ws; |
---|
| 155 | } |
---|
| 156 | echo |
---|
| 157 | '<form action="plugin.php" method="post">'. |
---|
| 158 | '<p class="anchor-nav">'. |
---|
| 159 | '<label for="lp_nav" class="classic">'.__('Goto:').'</label> '.form::combo('lp_nav',$ws_combo). |
---|
| 160 | ' <input type="submit" value="'.__('Ok').'" id="lp_submit" />'. |
---|
| 161 | '<input type="hidden" name="p" value="aboutConfig" />'. |
---|
| 162 | $core->formNonce().'</p></form>'; |
---|
| 163 | } |
---|
| 164 | ?> |
---|
[3] | 165 | |
---|
[589] | 166 | <form action="plugin.php" method="post"> |
---|
[3] | 167 | |
---|
[589] | 168 | <?php |
---|
[3] | 169 | foreach ($prefs as $ws => $s) |
---|
| 170 | { |
---|
| 171 | ksort($s); |
---|
[589] | 172 | echo sprintf($table_header,'l_'.$ws,$ws); |
---|
[3] | 173 | foreach ($s as $k => $v) |
---|
| 174 | { |
---|
| 175 | echo prefLine($k,$v,$ws,'s',!$v['global']); |
---|
| 176 | } |
---|
[581] | 177 | echo $table_footer; |
---|
[3] | 178 | } |
---|
| 179 | ?> |
---|
[581] | 180 | |
---|
[220] | 181 | <p><input type="submit" value="<?php echo __('Save'); ?>" /> |
---|
[3] | 182 | <input type="hidden" name="p" value="userPref" /> |
---|
| 183 | <?php echo $core->formNonce(); ?></p> |
---|
| 184 | </form> |
---|
| 185 | </div> |
---|
| 186 | |
---|
[1338] | 187 | <div id="global" class="multi-part" title="<?php echo __('Global preferences'); ?>"> |
---|
[581] | 188 | |
---|
[3] | 189 | <?php |
---|
| 190 | $prefs = array(); |
---|
| 191 | |
---|
| 192 | foreach ($core->auth->user_prefs->dumpWorkspaces() as $ws => $workspace) { |
---|
| 193 | foreach ($workspace->dumpGlobalPrefs() as $k => $v) { |
---|
| 194 | $prefs[$ws][$k] = $v; |
---|
| 195 | } |
---|
| 196 | } |
---|
| 197 | |
---|
| 198 | ksort($prefs); |
---|
| 199 | |
---|
[582] | 200 | if (count($prefs) > 0) { |
---|
[589] | 201 | $ws_combo = array(); |
---|
[582] | 202 | foreach ($prefs as $ws => $s) { |
---|
[589] | 203 | $ws_combo[$ws] = '#g_'.$ws; |
---|
[582] | 204 | } |
---|
[589] | 205 | echo |
---|
| 206 | '<form action="plugin.php" method="post">'. |
---|
| 207 | '<p class="anchor-nav">'. |
---|
| 208 | '<label for="gp_nav" class="classic">'.__('Goto:').'</label> '.form::combo('gp_nav',$ws_combo). |
---|
| 209 | ' <input type="submit" value="'.__('Ok').'" id="gp_submit" />'. |
---|
| 210 | '<input type="hidden" name="p" value="aboutConfig" />'. |
---|
| 211 | $core->formNonce().'</p></form>'; |
---|
[582] | 212 | } |
---|
[589] | 213 | ?> |
---|
[582] | 214 | |
---|
[589] | 215 | <form action="plugin.php" method="post"> |
---|
| 216 | |
---|
| 217 | <?php |
---|
[3] | 218 | foreach ($prefs as $ws => $s) |
---|
| 219 | { |
---|
| 220 | ksort($s); |
---|
[589] | 221 | echo sprintf($table_header,'g_'.$ws,$ws); |
---|
[3] | 222 | foreach ($s as $k => $v) |
---|
| 223 | { |
---|
| 224 | echo prefLine($k,$v,$ws,'gs',false); |
---|
| 225 | } |
---|
[581] | 226 | echo $table_footer; |
---|
[3] | 227 | } |
---|
| 228 | ?> |
---|
[581] | 229 | |
---|
[220] | 230 | <p><input type="submit" value="<?php echo __('Save'); ?>" /> |
---|
[3] | 231 | <input type="hidden" name="p" value="userPref" /> |
---|
| 232 | <?php echo $core->formNonce(); ?></p> |
---|
| 233 | </form> |
---|
| 234 | </div> |
---|
| 235 | |
---|
| 236 | </body> |
---|
[1339] | 237 | </html> |
---|