redacteur.php 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  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(9);
  24. include dirname(__FILE__).'/inc/connexion.php';
  25. $id = (!empty($_REQUEST['id'])) ? $_REQUEST['id'] : NULL;
  26. $page_titre = __('Editor creation');
  27. $err = '';
  28. $alert = '';
  29. $user_id = '';
  30. $user_nom = '';
  31. $user_prenom = '';
  32. $user_pseudo = '';
  33. $user_email = '';
  34. $user_pwd = '';
  35. $user_level = 1;
  36. $user_lang = DC_LANG;
  37. $user_post_format = 'wiki';
  38. $user_edit_size = 10;
  39. $user_pref_cat = '';
  40. $user_delta = 0;
  41. $user_post_pub = 1;
  42. $arry_levels = array(__('inactive') => 0,
  43. __('editor') => 1,
  44. __('advanced editor') => 5,
  45. __('administrator') => 9);
  46. # Tableau des formats
  47. $arry_format = array('HTML' => 'html', 'Wiki' => 'wiki');
  48. # Tableau des publication
  49. $arry_post_pub = array(__('Online') => 1, __('Offline') => 0);
  50. # Tableau des décalages
  51. for ($i=-24; $i<=24; $i++) {
  52. $arry_delta_time[(string) $i] = (string) $i;
  53. }
  54. # Récupération des catégories
  55. $rsCat = $blog->getCat();
  56. $arry_cat = array();
  57. if ($rsCat->isEmpty()) {
  58. $arry_cat[''] = 0;
  59. } else {
  60. while ($rsCat->fetch()) {
  61. $arry_cat[$rsCat->f('cat_libelle')] = $rsCat->f('cat_id');
  62. }
  63. }
  64. if (!empty($id) || !empty($_POST['user_id']))
  65. {
  66. if (!empty($id))
  67. {
  68. $rsUser = $blog->getUser($id);
  69. if (!$rsUser->isEmpty()) {
  70. $user_id = $rsUser->f('user_id');
  71. $user_nom = $rsUser->f('user_nom');
  72. $user_prenom = $rsUser->f('user_prenom');
  73. $user_pseudo = $rsUser->f('user_pseudo');
  74. $user_email = $rsUser->f('user_email');
  75. $user_level = $rsUser->f('user_level');
  76. $user_lang = $rsUser->f('user_lang');
  77. $user_post_format = $rsUser->f('user_post_format');
  78. $user_edit_size = $rsUser->f('user_edit_size');
  79. $user_pref_cat = $rsUser->f('user_pref_cat');
  80. $user_delta = $rsUser->f('user_delta');
  81. $user_post_pub = $rsUser->f('user_post_pub');
  82. $page_titre = sprintf(__('Update of editor %s'),$user_id);
  83. if($user_id == $_SESSION['sess_user_id']) {
  84. $alert = __('You are about to update you own profile. You will be disconnected after changes.');
  85. }
  86. # Suppresion d'un rédacteur
  87. if(!empty($_GET['del']))
  88. {
  89. if ($blog->delUser($user_id) !== false) {
  90. $msg = __('Editor deleted');
  91. header('Location: redac_list.php?msg='.rawurlencode($msg));
  92. exit;
  93. } else {
  94. $err = $blog->error(1);
  95. }
  96. }
  97. # Mise à jour d'un rédacteur
  98. if(!empty($_POST['user_id']))
  99. {
  100. $new_user_id = $_POST['user_id'];
  101. $user_nom = $_POST['user_nom'];
  102. $user_prenom = $_POST['user_prenom'];
  103. $user_email = $_POST['user_email'];
  104. $user_level = $_POST['user_level'];
  105. $user_pwd = $_POST['user_pwd'];
  106. $user_pseudo = $_POST['user_pseudo'];
  107. $user_post_format = $_POST['user_post_format'];
  108. $user_edit_size = $_POST['user_edit_size'];
  109. $user_pref_cat = $_POST['user_pref_cat'];
  110. $user_lang = $_POST['user_lang'];
  111. $user_delta = $_POST['user_delta'];
  112. $user_post_pub = $_POST['user_post_pub'];
  113. if($blog->updUser($user_id,$new_user_id,$user_level,$user_pwd,
  114. $user_nom,$user_prenom,$user_pseudo,$user_email,
  115. $user_post_format,$user_edit_size,$user_pref_cat,$user_lang,
  116. $user_delta,$user_post_pub) !== false)
  117. {
  118. if($user_id == $_SESSION['sess_user_id']) {
  119. header('Location: index.php?logout=1');
  120. exit;
  121. }
  122. $msg = __('Editor updated');
  123. header('Location: redac_list.php?msg='.rawurlencode($msg));
  124. exit;
  125. } else {
  126. $err = $blog->error(1);
  127. }
  128. }
  129. }
  130. }
  131. elseif(!empty($_POST['user_id']))
  132. {
  133. # Création d'un rédacteur
  134. $user_id = $_POST['user_id'];
  135. $user_nom = $_POST['user_nom'];
  136. $user_prenom = $_POST['user_prenom'];
  137. $user_pseudo = $_POST['user_pseudo'];
  138. $user_email = $_POST['user_email'];
  139. $user_level = $_POST['user_level'];
  140. $user_pwd = $_POST['user_pwd'];
  141. $user_lang = $_POST['user_lang'];
  142. $user_post_format = $_POST['user_post_format'];
  143. $user_edit_size = $_POST['user_edit_size'];
  144. $user_pref_cat = $_POST['user_pref_cat'];
  145. $user_delta = $_POST['user_delta'];
  146. $user_post_pub = $_POST['user_post_pub'];
  147. if ($blog->addUser($user_id,$user_level,$user_pwd,$user_nom,$user_prenom,
  148. $user_pseudo,$user_email,$user_post_format,$user_edit_size,
  149. $user_pref_cat,$user_lang,$user_delta,$user_post_pub) !== false ) {
  150. $msg = __('Editor created');
  151. header('Location: redac_list.php?msg='.rawurlencode($msg));
  152. exit;
  153. } else {
  154. $err = $blog->error(1);
  155. }
  156. }
  157. }
  158. openPage($page_titre);
  159. if($err != '')
  160. {
  161. echo '<div class="erreur"><p><strong>'.__('Error(s)').' :</strong></p>'.
  162. $err.'</div>';
  163. }
  164. ?>
  165. <p><strong><a href="redac_list.php"><?php echo __('Back'); ?></a></strong></p>
  166. <h2><?php echo $page_titre; ?></h2>
  167. <?php
  168. if ($alert != '') {
  169. echo '<p class="message">'.$alert.'</p>';
  170. }
  171. ?>
  172. <form action="redacteur.php" method="post">
  173. <p><?php echo __('Note: Login must be letters or numbers.'); ?></p>
  174. <p class="field"><label class="float" for="user_id"><strong><?php
  175. echo __('Login'); ?>&nbsp;:</strong>
  176. <?php echo helpLink('user','user_id'); ?></label>
  177. <?php echo form::field('user_id',30,32,$user_id); ?>
  178. </p>
  179. <p class="field"><label class="float" for="user_prenom"><?php
  180. echo __ ('Firstname'); ?> (<?php echo __('optional'); ?>)&nbsp;:
  181. <?php echo helpLink('user','user_prenom'); ?></label>
  182. <?php echo form::field('user_prenom',30,255,$user_prenom); ?>
  183. </p>
  184. <p class="field"><label class="float" for="user_nom"><strong><?php
  185. echo __('Name'); ?>&nbsp;:</strong>
  186. <?php echo helpLink('user','user_nom'); ?></label>
  187. <?php echo form::field('user_nom',30,255,$user_nom); ?>
  188. </p>
  189. <p class="field"><label class="float" for="user_pseudo"><?php
  190. echo __('Nickname'); ?> (<?php echo __('optional'); ?>)&nbsp;:
  191. <?php echo helpLink('user','user_pseudo'); ?></label>
  192. <?php echo form::field('user_pseudo',30,255,$user_pseudo); ?>
  193. </p>
  194. <p class="field"><label class="float" for="user_email"><?php
  195. echo __('Email'); ?> (<?php echo __('optional'); ?>)&nbsp;:
  196. <?php echo helpLink('user','user_email'); ?></label>
  197. <?php echo form::field('user_email',30,255,$user_email); ?>
  198. </p>
  199. <p class="field"><label class="float" for="user_pwd"><?php
  200. echo __('Password'); ?>&nbsp;:
  201. <?php echo helpLink('user','user_pwd'); ?></label>
  202. <?php echo form::field('user_pwd',30,255,'');
  203. if ($user_id) { echo '<br />('.__('Leave empty to keep password intact').')'; }
  204. ?></p>
  205. <p class="field"><label class="float" for="user_level"><strong><?php
  206. echo __('Level'); ?>&nbsp;:</strong>
  207. <?php echo helpLink('user','user_level'); ?></label>
  208. <?php echo form::combo('user_level',$arry_levels,$user_level); ?>
  209. </p>
  210. <p class="field"><label class="float" for="user_lang"><strong><?php
  211. echo __('Language'); ?>&nbsp;:</strong>
  212. <?php echo helpLink('user','user_lang'); ?></label>
  213. <?php echo form::combo('user_lang',l10n::getISOcodes(1),$user_lang); ?></p>
  214. <p class="field"><label class="float" for="user_post_format"><strong><?php
  215. echo __('Prefered edit format'); ?>&nbsp;:</strong>
  216. <?php echo helpLink('user','user_post_format'); ?></label>
  217. <?php echo form::combo('user_post_format',$arry_format,$user_post_format); ?>
  218. </p>
  219. <p class="field"><label class="float" for="user_post_pub"><strong><?php
  220. echo __('Default publication status'); ?>&nbsp;:</strong>
  221. <?php echo helpLink('user','user_post_pub'); ?></label>
  222. <?php echo form::combo('user_post_pub',$arry_post_pub,$user_post_pub); ?>
  223. </p>
  224. <p class="field"><label class="float" for="user_pref_cat"><strong><?php
  225. echo __('Prefered category'); ?>&nbsp;:</strong>
  226. <?php echo helpLink('user','user_pref_cat'); ?></label>
  227. <?php echo form::combo('user_pref_cat',$arry_cat,$user_pref_cat); ?>
  228. </p>
  229. <p class="field"><label class="float" for="user_edit_size"><strong><?php
  230. echo __('Entry edit field height'); ?>&nbsp;:</strong>
  231. <?php echo helpLink('user','user_edit_size'); ?></label>
  232. <?php echo form::field('user_edit_size',2,3,$user_edit_size); ?>
  233. </p>
  234. <p class="field"><label class="float" for="user_delta"><strong><?php
  235. echo __('Number of hours between user\'s local time and the server time'); ?>&nbsp;:</strong>
  236. <?php echo helpLink('user','user_delta'); ?></label>
  237. <?php echo form::combo('user_delta',$arry_delta_time,$user_delta); ?>
  238. (<?php echo sprintf(__('Server time is %s'),date('Y-m-d H:i')); ?>)</p>
  239. <p class="field"><input class="submit" type="submit" value="<?php echo __('save'); ?>" />
  240. <?php
  241. echo (!empty($id)) ? '<input type="hidden" name="id" value="'.$id.'" />' : '';
  242. ?></p>
  243. </form>
  244. <?php closePage(); ?>