| [3] | 1 | <?php | 
|---|
 | 2 | # -- BEGIN LICENSE BLOCK --------------------------------------- | 
|---|
 | 3 | # | 
|---|
 | 4 | # This file is part of Dotclear 2. | 
|---|
 | 5 | # | 
|---|
| [270] | 6 | # Copyright (c) 2003-2011 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), | 
|---|
 | 74 |           array(__('yes') => 1, __('no') => 0),$s['value']); | 
|---|
 | 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 | 
|---|
 | 83 |      '<tr>'. | 
|---|
| [581] | 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); ?> | 
|---|
 | 95 |   <style type="text/css"> | 
|---|
| [581] | 96 |      table.prefs { border: 1px solid #999; margin-bottom: 2em; } | 
|---|
 | 97 |      table.prefs th { background: #f5f5f5; color: #444; padding-top: 0.3em; padding-bottom: 0.3em; } | 
|---|
| [589] | 98 |      p.anchor-nav {float: right; } | 
|---|
| [3] | 99 |   </style> | 
|---|
| [589] | 100 |      <script type="text/javascript"> | 
|---|
 | 101 |      //<![CDATA[ | 
|---|
 | 102 |      $(function() { | 
|---|
 | 103 |           $("#gp_submit").hide(); | 
|---|
 | 104 |           $("#lp_submit").hide(); | 
|---|
 | 105 |           $("#gp_nav").change(function() { | 
|---|
 | 106 |                window.location = $("#gp_nav option:selected").val(); | 
|---|
 | 107 |           }) | 
|---|
 | 108 |           $("#lp_nav").change(function() { | 
|---|
 | 109 |                window.location = $("#lp_nav option:selected").val(); | 
|---|
 | 110 |           }) | 
|---|
 | 111 |      }); | 
|---|
 | 112 |      //]]> | 
|---|
 | 113 |      </script> | 
|---|
| [3] | 114 | </head> | 
|---|
 | 115 |  | 
|---|
 | 116 | <body> | 
|---|
 | 117 | <?php | 
|---|
 | 118 | if (!empty($_GET['upd'])) { | 
|---|
| [907] | 119 |      dcPage::message(__('Preferences successfully updated')); | 
|---|
| [3] | 120 | } | 
|---|
 | 121 |  | 
|---|
 | 122 | if (!empty($_GET['upda'])) { | 
|---|
| [907] | 123 |      dcPage::message(__('Preferences definition successfully updated')); | 
|---|
| [3] | 124 | } | 
|---|
 | 125 | ?> | 
|---|
| [500] | 126 | <h2><?php echo html::escapeHTML($core->auth->userID()); ?> › <span class="page-title">user:preferences</span></h2> | 
|---|
| [3] | 127 |  | 
|---|
 | 128 | <div id="local" class="multi-part" title="<?php echo __('user preferences'); ?>"> | 
|---|
| [581] | 129 |  | 
|---|
 | 130 | <?php  | 
|---|
| [589] | 131 | $table_header = '<table class="prefs" id="%s"><caption>%s</caption>'. | 
|---|
| [581] | 132 | '<thead>'. | 
|---|
 | 133 | '<tr>'."\n". | 
|---|
 | 134 | '  <th class="nowrap">Setting ID</th>'."\n". | 
|---|
 | 135 | '  <th>'.__('Value').'</th>'."\n". | 
|---|
 | 136 | '  <th>'.__('Type').'</th>'."\n". | 
|---|
 | 137 | '  <th class="maximalx">'.__('Description').'</th>'."\n". | 
|---|
 | 138 | '</tr>'."\n". | 
|---|
 | 139 | '</thead>'."\n". | 
|---|
 | 140 | '<tbody>'; | 
|---|
 | 141 | $table_footer = '</tbody></table>'; | 
|---|
 | 142 |  | 
|---|
| [3] | 143 | $prefs = array(); | 
|---|
 | 144 | foreach ($core->auth->user_prefs->dumpWorkspaces() as $ws => $workspace) { | 
|---|
 | 145 |      foreach ($workspace->dumpPrefs() as $k => $v) { | 
|---|
 | 146 |           $prefs[$ws][$k] = $v; | 
|---|
 | 147 |      } | 
|---|
 | 148 | } | 
|---|
| [589] | 149 | ksort($prefs); | 
|---|
 | 150 | if (count($prefs) > 0) { | 
|---|
 | 151 |      $ws_combo = array(); | 
|---|
 | 152 |      foreach ($prefs as $ws => $s) { | 
|---|
 | 153 |           $ws_combo[$ws] = '#l_'.$ws; | 
|---|
 | 154 |      } | 
|---|
 | 155 |      echo  | 
|---|
 | 156 |           '<form action="plugin.php" method="post">'. | 
|---|
 | 157 |           '<p class="anchor-nav">'. | 
|---|
 | 158 |           '<label for="lp_nav" class="classic">'.__('Goto:').'</label> '.form::combo('lp_nav',$ws_combo). | 
|---|
 | 159 |           ' <input type="submit" value="'.__('Ok').'" id="lp_submit" />'. | 
|---|
 | 160 |           '<input type="hidden" name="p" value="aboutConfig" />'. | 
|---|
 | 161 |           $core->formNonce().'</p></form>'; | 
|---|
 | 162 | } | 
|---|
 | 163 | ?> | 
|---|
| [3] | 164 |  | 
|---|
| [589] | 165 | <form action="plugin.php" method="post"> | 
|---|
| [3] | 166 |  | 
|---|
| [589] | 167 | <?php | 
|---|
| [3] | 168 | foreach ($prefs as $ws => $s) | 
|---|
 | 169 | { | 
|---|
 | 170 |      ksort($s); | 
|---|
| [589] | 171 |      echo sprintf($table_header,'l_'.$ws,$ws); | 
|---|
| [3] | 172 |      foreach ($s as $k => $v) | 
|---|
 | 173 |      { | 
|---|
 | 174 |           echo prefLine($k,$v,$ws,'s',!$v['global']); | 
|---|
 | 175 |      } | 
|---|
| [581] | 176 |      echo $table_footer; | 
|---|
| [3] | 177 | } | 
|---|
 | 178 | ?> | 
|---|
| [581] | 179 |  | 
|---|
| [220] | 180 | <p><input type="submit" value="<?php echo __('Save'); ?>" /> | 
|---|
| [3] | 181 | <input type="hidden" name="p" value="userPref" /> | 
|---|
 | 182 | <?php echo $core->formNonce(); ?></p> | 
|---|
 | 183 | </form> | 
|---|
 | 184 | </div> | 
|---|
 | 185 |  | 
|---|
 | 186 | <div id="global" class="multi-part" title="<?php echo __('global preferences'); ?>"> | 
|---|
| [581] | 187 |  | 
|---|
| [3] | 188 | <?php | 
|---|
 | 189 | $prefs = array(); | 
|---|
 | 190 |  | 
|---|
 | 191 | foreach ($core->auth->user_prefs->dumpWorkspaces() as $ws => $workspace) { | 
|---|
 | 192 |      foreach ($workspace->dumpGlobalPrefs() as $k => $v) { | 
|---|
 | 193 |           $prefs[$ws][$k] = $v; | 
|---|
 | 194 |      } | 
|---|
 | 195 | } | 
|---|
 | 196 |  | 
|---|
 | 197 | ksort($prefs); | 
|---|
 | 198 |  | 
|---|
| [582] | 199 | if (count($prefs) > 0) { | 
|---|
| [589] | 200 |      $ws_combo = array(); | 
|---|
| [582] | 201 |      foreach ($prefs as $ws => $s) { | 
|---|
| [589] | 202 |           $ws_combo[$ws] = '#g_'.$ws; | 
|---|
| [582] | 203 |      } | 
|---|
| [589] | 204 |      echo  | 
|---|
 | 205 |           '<form action="plugin.php" method="post">'. | 
|---|
 | 206 |           '<p class="anchor-nav">'. | 
|---|
 | 207 |           '<label for="gp_nav" class="classic">'.__('Goto:').'</label> '.form::combo('gp_nav',$ws_combo). | 
|---|
 | 208 |           ' <input type="submit" value="'.__('Ok').'" id="gp_submit" />'. | 
|---|
 | 209 |           '<input type="hidden" name="p" value="aboutConfig" />'. | 
|---|
 | 210 |           $core->formNonce().'</p></form>'; | 
|---|
| [582] | 211 | } | 
|---|
| [589] | 212 | ?> | 
|---|
| [582] | 213 |  | 
|---|
| [589] | 214 | <form action="plugin.php" method="post"> | 
|---|
 | 215 |  | 
|---|
 | 216 | <?php | 
|---|
| [3] | 217 | foreach ($prefs as $ws => $s) | 
|---|
 | 218 | { | 
|---|
 | 219 |      ksort($s); | 
|---|
| [589] | 220 |      echo sprintf($table_header,'g_'.$ws,$ws); | 
|---|
| [3] | 221 |      foreach ($s as $k => $v) | 
|---|
 | 222 |      { | 
|---|
 | 223 |           echo prefLine($k,$v,$ws,'gs',false); | 
|---|
 | 224 |      } | 
|---|
| [581] | 225 |      echo $table_footer; | 
|---|
| [3] | 226 | } | 
|---|
 | 227 | ?> | 
|---|
| [581] | 228 |  | 
|---|
| [220] | 229 | <p><input type="submit" value="<?php echo __('Save'); ?>" /> | 
|---|
| [3] | 230 | <input type="hidden" name="p" value="userPref" /> | 
|---|
 | 231 | <?php echo $core->formNonce(); ?></p> | 
|---|
 | 232 | </form> | 
|---|
 | 233 | </div> | 
|---|
 | 234 |  | 
|---|
 | 235 | </body> | 
|---|
 | 236 | </html> | 
|---|