user_prefs.php 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. <?php
  2. # ***** BEGIN LICENSE BLOCK *****
  3. # This file is part of DotClear.
  4. # Copyright (c) 2004 Olivier Meunier and contributors. All rights
  5. # reserved.
  6. #
  7. # DotClear is free software; you can redistribute it and/or modify
  8. # it under the terms of the GNU General Public License as published by
  9. # the Free Software Foundation; either version 2 of the License, or
  10. # (at your option) any later version.
  11. #
  12. # DotClear is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU General Public License
  18. # along with DotClear; if not, write to the Free Software
  19. # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  20. #
  21. # ***** END LICENSE BLOCK *****
  22. require dirname(__FILE__).'/inc/prepend.php';
  23. $auth->check(1);
  24. include dirname(__FILE__).'/inc/connexion.php';
  25. $err = '';
  26. # Tableau des formats
  27. $arry_format = array('HTML' => 'html', 'Wiki' => 'wiki');
  28. # Tableau des publication
  29. $arry_post_pub = array(__('Online') => 1, __('Offline') => 0);
  30. # Tableau des décalages
  31. for ($i=-24; $i<=24; $i++) {
  32. $arry_delta_time[(string) $i] = (string) $i;
  33. }
  34. # Récupération des catégories
  35. $rsCat = $blog->getCat();
  36. $arry_cat = array();
  37. if ($rsCat->isEmpty()) {
  38. $arry_cat[''] = 0;
  39. } else {
  40. while ($rsCat->fetch()) {
  41. $arry_cat[$rsCat->f('cat_libelle')] = $rsCat->f('cat_id');
  42. }
  43. }
  44. # Récupération de l'utilisateur
  45. $rs = $blog->getUser($_SESSION['sess_user_id']);
  46. $user_nom = $rs->f('user_nom');
  47. $user_prenom = $rs->f('user_prenom');
  48. $user_pseudo = $rs->f('user_pseudo');
  49. $user_email = $rs->f('user_email');
  50. $user_pwd = '';
  51. $user_post_format = $rs->f('user_post_format');
  52. $user_edit_size = $rs->f('user_edit_size');
  53. $user_pref_cat = $rs->f('user_pref_cat');
  54. $user_lang = $rs->f('user_lang');
  55. $user_delta = $rs->f('user_delta');
  56. $user_post_pub = $rs->f('user_post_pub');
  57. # Mise à jour des préférences
  58. if(!empty($_POST))
  59. {
  60. $user_prenom = $_POST['user_prenom'];
  61. $user_nom = $_POST['user_nom'];
  62. $user_pseudo = $_POST['user_pseudo'];
  63. $user_email = $_POST['user_email'];
  64. $user_pwd = trim($_POST['user_pwd']);
  65. $user_post_format = $_POST['user_post_format'];
  66. $user_edit_size = $_POST['user_edit_size'];
  67. $user_pref_cat = $_POST['user_pref_cat'];
  68. $user_lang = $_POST['user_lang'];
  69. $user_delta = $_POST['user_delta'];
  70. $user_post_pub = $_POST['user_post_pub'];
  71. if($blog->updUser($_SESSION['sess_user_id'],$_SESSION['sess_user_id'],
  72. $rs->f('user_level'),$user_pwd,$user_nom,$user_prenom,$user_pseudo,
  73. $user_email,$user_post_format,$user_edit_size,$user_pref_cat,$user_lang,
  74. $user_delta,$user_post_pub) !== false)
  75. {
  76. # On update la session pour que les modifs soient prises en compte
  77. # tout de suite
  78. $_SESSION['sess_user_nom'] = $user_nom;
  79. $_SESSION['sess_user_prenom'] = $user_prenom;
  80. $_SESSION['sess_user_pseudo'] = $user_pseudo;
  81. $_SESSION['sess_user_email'] = $user_email;
  82. $_SESSION['sess_user_format'] = $user_post_format;
  83. $_SESSION['sess_user_edit_size'] = $user_edit_size;
  84. $_SESSION['sess_user_pref_cat'] = $user_pref_cat;
  85. $_SESSION['sess_user_lang'] = $user_lang;
  86. $_SESSION['sess_user_delta'] = $user_delta;
  87. $_SESSION['sess_user_post_pub'] = $user_post_pub;
  88. if($_SESSION['sess_user_pseudo'] != '')
  89. $_SESSION['sess_user_cn'] = $_SESSION['sess_user_pseudo'];
  90. else
  91. $_SESSION['sess_user_cn'] = trim($_SESSION['sess_user_prenom'].' '.$_SESSION['sess_user_nom']);
  92. $msg = __('Editor updated');
  93. header('Location: user_prefs.php?msg='.rawurlencode($msg));
  94. exit;
  95. } else {
  96. $err = $blog->error(1);
  97. }
  98. }
  99. # Sous menu
  100. openPage(__('User preferences'));
  101. if($err != '')
  102. {
  103. echo '<div class="erreur"><p><strong>'.__('Error(s)').' :</strong></p>'.$err.'</div>';
  104. }
  105. ?>
  106. <h2><?php echo __('User preferences'); ?></h2>
  107. <form action="user_prefs.php" method="post" class="clear">
  108. <p class="field"><label class="float" for="user_prenom"><?php
  109. echo __('Firstname'); ?> (<?php echo __('optional'); ?>)&nbsp;:
  110. <?php echo helpLink('user','user_prenom'); ?></label>
  111. <?php echo form::field('user_prenom',30,255,$user_prenom); ?>
  112. </p>
  113. <p class="field"><label class="float" for="user_nom"><strong><?php
  114. echo __('Name'); ?>&nbsp;:</strong>
  115. <?php echo helpLink('user','user_nom'); ?></label>
  116. <?php echo form::field('user_nom',30,255,$user_nom); ?>
  117. </p>
  118. <p class="field"><label class="float" for="user_pseudo"><?php
  119. echo __('Nickname'); ?> (<?php echo __('optional'); ?>)&nbsp;:
  120. <?php echo helpLink('user','user_pseudo'); ?></label>
  121. <?php echo form::field('user_pseudo',30,255,$user_pseudo); ?>
  122. </p>
  123. <p class="field"><label class="float" for="user_email"><?php
  124. echo __('Email'); ?> (<?php echo __('optional'); ?>)&nbsp;:
  125. <?php echo helpLink('user','user_email'); ?></label>
  126. <?php echo form::field('user_email',30,255,$user_email); ?>
  127. </p>
  128. <p class="field"><label class="float" for="user_pwd"><?php
  129. echo __('Password'); ?>&nbsp;:
  130. <?php echo helpLink('user','user_pwd'); ?></label>
  131. <?php echo form::field('user_pwd',30,255); ?>
  132. <br />(<?php echo __('Leave empty to keep password intact'); ?>)</p>
  133. <p class="field"><label class="float" for="user_post_format"><strong><?php
  134. echo __('Prefered edit format'); ?>&nbsp;:</strong>
  135. <?php echo helpLink('user','user_post_format'); ?></label>
  136. <?php echo form::combo('user_post_format',$arry_format,$user_post_format); ?>
  137. </p>
  138. <p class="field"><label class="float" for="user_post_pub"><strong><?php
  139. echo __('Default publication status'); ?>&nbsp;:</strong>
  140. <?php echo helpLink('user','user_post_pub'); ?></label>
  141. <?php echo form::combo('user_post_pub',$arry_post_pub,$user_post_pub); ?>
  142. </p>
  143. <p class="field"><label class="float" for="user_pref_cat"><strong><?php
  144. echo __('Prefered category'); ?>&nbsp;:</strong>
  145. <?php echo helpLink('user','user_pref_cat'); ?></label>
  146. <?php echo form::combo('user_pref_cat',$arry_cat,$user_pref_cat); ?>
  147. </p>
  148. <p class="field"><label class="float" for="user_edit_size"><strong><?php
  149. echo __('Entry edit field height'); ?>&nbsp;:</strong>
  150. <?php echo helpLink('user','user_edit_size'); ?></label>
  151. <?php echo form::field('user_edit_size',2,3,$user_edit_size); ?>
  152. </p>
  153. <p class="field"><label class="float" for="user_lang"><strong><?php
  154. echo __('Language'); ?>&nbsp;:</strong>
  155. <?php echo helpLink('user','user_lang'); ?></label>
  156. <?php echo form::combo('user_lang',l10n::getISOcodes(1),$user_lang); ?></p>
  157. <p class="field"><label class="float" for="user_delta"><strong><?php
  158. echo __('Number of hours between user\'s local time and the server time'); ?>&nbsp;:</strong>
  159. <?php echo helpLink('user','user_delta'); ?></label>
  160. <?php echo form::combo('user_delta',$arry_delta_time,$user_delta); ?>
  161. (<?php echo sprintf(__('Server time is %s'),date('Y-m-d H:i')); ?>)</p>
  162. <p class="field"><input class="submit" type="submit" value="<?php echo __('save'); ?>" /></p>
  163. </form>
  164. <?php closePage(); ?>