| [ 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 $changes = false; 28 $blogs = array(); 29 $users = array(); 30 31 # Check users 32 if (!empty($_REQUEST['user_id']) && is_array($_REQUEST['user_id'])) 33 { 34 foreach ($_REQUEST['user_id'] as $u) 35 { 36 if ($core->userExists($u)) { 37 $users[] = $u; 38 } 39 } 40 } 41 42 # Check blogs 43 if (!empty($_REQUEST['blog_id']) && is_array($_REQUEST['blog_id'])) 44 { 45 foreach ($_REQUEST['blog_id'] as $b) 46 { 47 if ($core->blogExists($b)) { 48 $blogs[] = $b; 49 } 50 } 51 } 52 53 # Update permissions 54 if (!empty($_POST['upd_perm']) && !empty($users) && !empty($blogs)) 55 { 56 $redir = 'permissions.php?upd=1'; 57 58 foreach ($users as $u) 59 { 60 foreach ($blogs as $b) 61 { 62 if (!$core->error->flag()) 63 { 64 $set_perms = array(); 65 66 if (!empty($_POST['perm'][$b])) 67 { 68 foreach ($_POST['perm'][$b] as $perm_id => $v) 69 { 70 if ($v) { 71 $set_perms[$perm_id] = true; 72 } 73 } 74 } 75 76 try { 77 $core->setUserBlogPermissions($u, $b, $set_perms, true); 78 } catch (Exception $e) { 79 $core->error->add($e->getMessage()); 80 } 81 } 82 } 83 84 $redir .= '&user_id[]='.$u; 85 } 86 87 if (!$core->error->flag()) 88 { 89 foreach ($blogs as $b) { 90 $redir .= '&blog_id[]='.$b; 91 } 92 http::redirect($redir); 93 } 94 } 95 96 97 98 if (empty($blogs) || empty($users)) { 99 $core->error->add(__('No blog or user given.')); 100 } 101 102 103 /* DISPLAY 104 -------------------------------------------------------- */ 105 dcPage::open(__('permissions'), 106 dcPage::jsLoad('js/_permissions.js') 107 ); 108 109 echo '<h2><a href="users.php">'.__('Users').'</a> > '.__('Permissions').'</h2>'; 110 111 if (!empty($_GET['upd'])) { 112 echo '<p class="message">'.__('The permissions have been successfully updated.').'</p>'; 113 } 114 115 if (!empty($blogs) && !empty($users)) 116 { 117 $perm_form = ''; 118 119 if (count($users) == 1) { 120 $user_perm = $core->getUserPermissions($users[0]); 121 } 122 123 foreach ($users as $u) { 124 $user_list[] = '<a href="user.php?id='.$u.'">'.$u.'</a>'; 125 } 126 127 echo '<p>'.sprintf(__('You are about to change permissions on the following blogs for users %s.'), 128 implode(', ',$user_list)); 129 130 echo '<form id="permissions-form" action="permissions.php" method="post">'; 131 132 foreach ($blogs as $b) 133 { 134 echo '<h3><a href="blog.php?id='.html::escapeHTML($b).'">'.html::escapeHTML($b).'</a>'. 135 form::hidden(array('blog_id[]'),$b).'</h3>'; 136 137 foreach ($core->auth->getPermissionsTypes() as $perm_id => $perm) 138 { 139 $checked = false; 140 141 if (count($users) == 1) { 142 $checked = isset($user_perm[$b]['p'][$perm_id]) && $user_perm[$b]['p'][$perm_id]; 143 } 144 145 echo 146 '<p><label class="classic">'. 147 form::checkbox(array('perm['.html::escapeHTML($b).']['.html::escapeHTML($perm_id).']'), 148 1,$checked).' '. 149 __($perm).'</label></p>'; 150 } 151 } 152 153 echo 154 '<p><input type="submit" accesskey="s" value="'.__('save').'" />'; 155 156 foreach ($users as $u) { 157 echo form::hidden(array('user_id[]'),$u); 158 } 159 160 echo form::hidden('upd_perm',1).'</p></form>'; 161 } 162 163 dcPage::close(); 164 ?>
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 |