[ Index ] |
|
Code source de Dotclear 2.0-beta6 |
1 <?php 2 # ***** BEGIN LICENSE BLOCK ***** 3 # This file is part of DotClear. 4 # Copyright (c) 2005 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 23 require dirname(__FILE__).'/../inc/admin/prepend.php'; 24 25 dcPage::checkSuper(); 26 27 $page_title = __('new user'); 28 29 $user_id = ''; 30 $user_super = ''; 31 $user_pwd = ''; 32 $user_name = ''; 33 $user_firstname = ''; 34 $user_displayname = ''; 35 $user_email = ''; 36 $user_url = ''; 37 $user_lang = $core->auth->getInfo('user_lang'); 38 $user_tz = $core->auth->getInfo('user_tz'); 39 $user_post_status = ''; 40 41 $user_options = $core->userDefaults(); 42 43 foreach ($core->getFormaters() as $v) { 44 $formaters_combo[$v] = $v; 45 } 46 47 foreach ($core->blog->getAllPostStatus() as $k => $v) { 48 $status_combo[$v] = $k; 49 } 50 51 # Language codes 52 foreach (l10n::getISOcodes(1) as $k => $v) { 53 $lang_combo[] = new formSelectOption($k,$v,$v == 'en' || is_dir(DC_L10N_ROOT.'/'.$v) ? 'avail10n' : ''); 54 } 55 56 # Get user if we have an ID 57 if (!empty($_REQUEST['id'])) 58 { 59 try { 60 $rs = $core->getUser($_REQUEST['id']); 61 62 $user_id = $rs->user_id; 63 $user_super = $rs->user_super; 64 $user_pwd = $rs->user_pwd; 65 $user_name = $rs->user_name; 66 $user_firstname = $rs->user_firstname; 67 $user_displayname = $rs->user_displayname; 68 $user_email = $rs->user_email; 69 $user_url = $rs->user_url; 70 $user_lang = $rs->user_lang; 71 $user_tz = $rs->user_tz; 72 $user_post_status = $rs->user_post_status; 73 74 $user_options = array_merge($user_options,$rs->options()); 75 76 $page_title = $user_id; 77 } catch (Exception $e) { 78 $core->error->add($e->getMessage()); 79 } 80 } 81 82 # Add or update user 83 if (isset($_POST['user_name'])) 84 { 85 $cur = $core->con->openCursor($core->prefix.'user'); 86 87 $cur->user_id = $_POST['user_id']; 88 $cur->user_super = $user_super = !empty($_POST['user_super']) ? 1 : 0; 89 $cur->user_name = $user_name = $_POST['user_name']; 90 $cur->user_firstname = $user_firstname = $_POST['user_firstname']; 91 $cur->user_displayname = $user_displayname = $_POST['user_displayname']; 92 $cur->user_email = $user_email = $_POST['user_email']; 93 $cur->user_url = $user_url = $_POST['user_url']; 94 $cur->user_lang = $user_lang = $_POST['user_lang']; 95 $cur->user_tz = $user_tz = $_POST['user_tz']; 96 $cur->user_post_status = $user_post_status = $_POST['user_post_status']; 97 98 if (!empty($_POST['new_pwd'])) { 99 if ($_POST['new_pwd'] != $_POST['new_pwd_c']) { 100 $core->error->add(__("Passwords don't match")); 101 } else { 102 $cur->user_pwd = $_POST['new_pwd']; 103 } 104 } 105 106 $user_options['post_format'] = $_POST['user_post_format']; 107 $user_options['edit_size'] = (integer) $_POST['user_edit_size']; 108 109 if ($user_options['edit_size'] < 1) { 110 $user_options['edit_size'] = 10; 111 } 112 113 $cur->user_options = new ArrayObject($user_options); 114 115 # Udate user 116 if ($user_id) 117 { 118 if (!$core->error->flag()) 119 { 120 try 121 { 122 # --BEHAVIOR-- adminBeforeUserUpdate 123 $core->callBehavior('adminBeforeUserUpdate',$cur,$user_id); 124 125 $new_id = $core->updUser($user_id,$cur); 126 127 # --BEHAVIOR-- adminAfterUserUpdate 128 $core->callBehavior('adminAfterUserUpdate',$cur,$new_id); 129 130 if ($user_id == $core->auth->userID() && 131 $user_id != $new_id) { 132 $core->session->destroy(); 133 } 134 135 http::redirect('user.php?id='.$new_id.'&upd=1'); 136 } 137 catch (Exception $e) 138 { 139 $core->error->add($e->getMessage()); 140 } 141 } 142 } 143 # Add user 144 else 145 { 146 if (!$core->error->flag()) 147 { 148 try 149 { 150 # --BEHAVIOR-- adminBeforeUserCreate 151 $core->callBehavior('adminBeforeUserCreate',$cur); 152 153 $new_id = $core->addUser($cur); 154 155 # --BEHAVIOR-- adminAfterUserCreate 156 $core->callBehavior('adminAfterUserCreate',$cur,$new_id); 157 158 http::redirect('user.php?id='.$new_id.'&add=1'); 159 } 160 catch (Exception $e) 161 { 162 $core->error->add($e->getMessage()); 163 } 164 } 165 } 166 } 167 168 169 /* DISPLAY 170 -------------------------------------------------------- */ 171 dcPage::open($page_title, 172 dcPage::jsConfirmClose('user-form'). 173 174 # --BEHAVIOR-- adminUserHeaders 175 $core->callBehavior('adminUserHeaders') 176 ); 177 178 if (!empty($_GET['upd'])) { 179 echo '<p class="message">'.__('User has been successfully updated.').'</p>'; 180 } 181 182 if (!empty($_GET['add'])) { 183 echo '<p class="message">'.__('User has been successfully created.').'</p>'; 184 } 185 186 echo '<h2><a href="users.php">'.__('Users').'</a> > '.$page_title.'</h2>'; 187 188 if ($user_id == $core->auth->userID()) { 189 echo 190 '<p class="warning">'.__('Warning:').' '. 191 __('If you change your login, you will have to log in again.').'</p>'; 192 } 193 194 echo 195 '<form action="user.php" method="post"id="user-form">'. 196 '<fieldset><legend>'.__('User information').'</legend>'. 197 '<div class="two-cols">'. 198 '<div class="col">'. 199 '<p><label class="required" title="'.__('Required field').'">'.__('Login:').' '. 200 form::field('user_id',20,255,html::escapeHTML($user_id),'',2). 201 '</label></p>'. 202 '<p class="form-note">'.__('At least 2 characters using letters, numbers or symbols.').'</p>'. 203 204 '<p><label>'.($user_id!='' ? __('New password:') : __('Password:')).' '. 205 form::password('new_pwd',20,255,'','',3). 206 '</label></p>'. 207 208 '<p><label>'.__('Confirm password:').' '. 209 form::password('new_pwd_c',20,255,'','',4). 210 '</label></p>'. 211 212 '<p><label>'.__('Name:').' '. 213 form::field('user_name',20,255,html::escapeHTML($user_name),'',5). 214 '</label></p>'. 215 216 '<p><label>'.__('Firstname:').' '. 217 form::field('user_firstname',20,255,html::escapeHTML($user_firstname),'',6). 218 '</label></p>'. 219 220 '<p><label>'.__('Display name:').' '. 221 form::field('user_displayname',20,255,html::escapeHTML($user_displayname),'',7). 222 '</label></p>'. 223 224 '<p><label>'.__('Email:').' '. 225 form::field('user_email',20,255,html::escapeHTML($user_email),'',8). 226 '</label></p>'. 227 '</div>'. 228 229 '<div class="col">'. 230 '<p><label>'.__('URL:').' '. 231 form::field('user_url',30,255,html::escapeHTML($user_url),'',8). 232 '</label></p>'. 233 '<p><label>'.__('Preferred format:').' '. 234 form::combo('user_post_format',$formaters_combo,$user_options['post_format'],'',9). 235 '</label></p>'. 236 237 '<p><label>'.__('Default entry status:').' '. 238 form::combo('user_post_status',$status_combo,$user_post_status,'',10). 239 '</label></p>'. 240 241 '<p><label>'.__('Entry edit field height:').' '. 242 form::field('user_edit_size',5,4,(integer) $user_options['edit_size'],'',11). 243 '</label></p>'. 244 245 '<p><label>'.__('User language:').' '. 246 form::combo('user_lang',$lang_combo,$user_lang,'l10n',12). 247 '</label></p>'. 248 249 '<p><label>'.__('User timezone:').' '. 250 form::combo('user_tz',dt::getZones(true,true),$user_tz,'',13). 251 '</label></p>'. 252 253 '<p><label class="classic">'.form::checkbox('user_super','1',$user_super,'',14).' '. 254 __('Super administrator').'</label></p>'. 255 '</div>'. 256 '</div>'. 257 '</fieldset>'; 258 259 # --BEHAVIOR-- adminUserForm 260 $core->callBehavior('adminUserForm',isset($rs) ? $rs : null); 261 262 echo 263 '<p class="clear"><input type="submit" accesskey="s" value="'.__('Save').'" tabindex="15" />'. 264 ($user_id != '' ? form::hidden('id',$user_id) : ''). 265 '</p>'. 266 267 '</form>'; 268 269 if ($user_id) 270 { 271 echo '<fieldset class="clear"><legend>'.__('Permissions').'</legend>'; 272 273 $permissions = $core->getUserPermissions($user_id); 274 $perm_types = $core->auth->getPermissionsTypes(); 275 276 if (count($permissions) == 0) 277 { 278 echo '<p>'.__('No permissions.').'</p>'; 279 } 280 else 281 { 282 foreach ($permissions as $k => $v) 283 { 284 if (count($v['p']) > 0) 285 { 286 echo '<h4><a href="blog.php?id='.html::escapeHTML($k).'">'. 287 html::escapeHTML($v['name']).'</a> ('.html::escapeHTML($k).') - '. 288 '<a href="permissions.php?blog_id[]='.$k.'&user_id[]='.$user_id.'">' 289 .__('change permissions').'</a></h4>'; 290 291 echo '<ul>'; 292 foreach ($v['p'] as $p => $V) { 293 echo '<li>'.__($perm_types[$p]).'</li>'; 294 } 295 echo '</ul>'; 296 } 297 } 298 } 299 300 echo 301 '<p><a href="permissions_blog.php?user_id[]='.$user_id.'">'. 302 __('Add new permissions').'</a></p>'. 303 '</fieldset>'; 304 } 305 306 dcPage::close(); 307 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Fri Feb 23 22:16:06 2007 | par Balluche grâce à PHPXref 0.7 |