Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

groupedit.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: groupedit.php 9537 2002-05-15 16:02:04Z bf $
5 //
6 // Created on: <20-Sep-2000 13:32:11 ce>
7 //
8 // This source file is part of Exponential Basic, publishing software.
9 //
10 // Copyright (C) 1999-2001 eZ Systems. All rights reserved.
11 //
12 // This program is free software; you can redistribute it and/or
13 // modify it under the terms of the GNU General Public License
14 // as published by the Free Software Foundation; either version 2
15 // of the License, or (at your option) any later version.
16 //
17 // This program is distributed in the hope that it will be useful,
18 // but WITHOUT ANY WARRANTY; without even the implied warranty of
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 // GNU General Public License for more details.
21 //
22 // You should have received a copy of the GNU General Public License
23 // along with this program; if not, write to the Free Software
24 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, US
25 //
26
27 // include_once( "classes/INIFile.php" );
28 // include_once( "classes/eztemplate.php" );
29 // include_once( "classes/ezhttptool.php" );
30
31 $ini =& eZINI::instance( 'site.ini' );
32
33 $Language = $ini->variable( "eZUserMain", "Language" );
34
35 // include_once( "ezuser/classes/ezuser.php" );
36 // include_once( "ezuser/classes/ezusergroup.php" );
37 // include_once( "ezuser/classes/ezmodule.php" );
38 // include_once( "ezuser/classes/ezpermission.php" );
39
40 require( "kernel/ezuser/admin/admincheck.php" );
41
42 $user =& eZUser::currentUser();
43
44 if ( isset( $DeleteGroups ) and isset( $GroupArrayID ) )
45 {
46 $hasRoot = $user->hasRootAccess();
47 foreach ( $GroupArrayID as $groupid )
48 {
49 if( $hasRoot )
50 {
51 (new eZUserGroup())->delete( $groupid );
52 }
53 else
54 {
55 $group = new eZUserGroup( $groupid );
56 if( !$group->isRoot() )
57 (new eZUserGroup())->delete( $groupid );
58 }
59 }
60 eZHTTPTool::header( "Location: /user/grouplist" );
61 exit();
62 }
63
64 if ( isset( $Back ) )
65 {
66 eZHTTPTool::header( "Location: /user/grouplist/" );
67 exit();
68 }
69
70
71
72 // do not allow editing users with root access while you do not.
73 if( isset( $GroupID ) )
74 {
75 $editGroup = new eZUserGroup( $GroupID );
76 if( !$user->hasRootAccess() && $editGroup->isRoot() )
77 {
78 $info = urlencode( "Can't edit a group with root priveliges." );
79 eZHTTPTool::header( "Location: /error/403?Info=$info" );
80 exit();
81 }
82 }
83
84 if ( isset( $Action ) && $Action == "insert" )
85 {
86 if ( eZPermission::checkPermission( $user, "eZUser", "GroupAdd" ) )
87 {
88 if ( $Name == "" || $Description == "" )
89 {
90 $error = new eZINI( "kernel/ezuser/admin/intl/" . $Language . "/groupedit.php.ini", false );
91 $error_msg = $error->variable( "strings", "error_msg" );
92 }
93 else
94 {
95 $group = new eZUserGroup();
96 $group->setName( $Name );
97 $group->setDescription( $Description );
98 $group->setSessionTimeout( $SessionTimeout );
99 $group->setGroupURL( $GroupURL );
100
101 if ( isset( $IsRoot ) && $user->hasRootAccess() )
102 $group->setIsRoot( 1 );
103 else
104 $group->setIsRoot( 0 );
105 $permission = new eZPermission();
106
107 $group->store();
108
109 $group->get( $group->id() );
110
111 $permissionList = $permission->getAll();
112
113 foreach ( $permissionList as $permissionItem )
114 {
115 $permissionItem->setEnabled( $group, false );
116 }
117
118 if ( isset( $PermissionArray ) && count ( $PermissionArray ) > 0 )
119 {
120 foreach ( $PermissionArray as $PermissionID )
121 {
122 $permission->get( $PermissionID );
123 $permission->setEnabled( $group, true );
124 }
125 }
126
127 eZHTTPTool::header( "Location: /user/grouplist/" );
128 exit();
129 }
130 }
131 else
132 {
133 eZHTTPTool::header( "Location: /error/403/" );
134 exit();
135 }
136 }
137
138 if ( isset( $Action ) && $Action == "delete" )
139 {
140 if ( eZPermission::checkPermission( $user, "eZUser", "GroupDelete" ) )
141 {
142
143 $group = new eZUserGroup();
144 $group->get( $GroupID );
145
146 $group->delete();
147
148 eZHTTPTool::header( "Location: /user/grouplist/" );
149 exit();
150 }
151 else
152 {
153 print( "No rights.");
154 }
155 }
156
157 if ( isset( $Action ) && $Action == "update" )
158 {
159 if ( eZPermission::checkPermission( $user, "eZUser", "GroupModify" ) )
160 {
161 $permission = new eZPermission();
162 $group = new eZUserGroup();
163 $group->get( $GroupID );
164 $group->setName( $Name );
165 $group->setGroupURL( $GroupURL );
166 $group->setDescription( $Description );
167 $group->setSessionTimeout( $SessionTimeout );
168
169 if ( isset( $IsRoot ) && $user->hasRootAccess() )
170 $group->setIsRoot( true );
171 else
172 $group->setIsRoot( false );
173
174 $permissionList = $permission->getAll();
175
176 foreach ( $permissionList as $permissionItem )
177 {
178 $permissionItem->setEnabled( $group, false );
179 }
180
181 foreach ( $PermissionArray as $PermissionID )
182 {
183 $permission->get( $PermissionID );
184 $permission->setEnabled( $group, true );
185 }
186
187 $group->store();
188
189 eZHTTPTool::header( "Location: /user/grouplist/" );
190 exit();
191 }
192 else
193 {
194 eZHTTPTool::header( "Location: /error/403/" );
195 exit();
196 }
197 }
198
199 // Template
200 $t = new eZTemplate( "kernel/ezuser/admin/" . $ini->variable( "eZUserMain", "AdminTemplateDir" ),
201 "kernel/ezuser/admin/" . "/intl", $Language, "groupedit.php" );
202 $t->setAllStrings();
203
204 $t->set_file( "group_edit", "groupedit.tpl" );
205
206 $t->set_block( "group_edit", "module_list_header_tpl", "module_header" );
207 $t->set_block( "module_list_header_tpl", "permission_list_tpl", "permission_item" );
208 $t->set_block( "permission_list_tpl", "permission_enabled_tpl", "is_enabled_item" );
209
210 $headline = new eZINI( "kernel/ezuser/admin/intl/" . $Language . "/groupedit.php.ini", false );
211 $t->set_var( "head_line", $headline->variable( "strings", "head_line_insert" ) );
212
213 if ( isset( $Action ) && $Action == "new" )
214 {
215 $Name = "";
216 $Description = "";
217 $GroupURL = "";
218 }
219 $ActionValue = "insert";
220
221 // Edit
222 if ( isset( $Action ) && $Action == "edit" )
223 {
224 $group = new eZUserGroup();
225 $group->get( $GroupID );
226
227 $Name = $group->name();
228 $Description = $group->description();
229 $GroupURL = $group->groupURL();
230 $SessionTimeout = $group->sessionTimeout();
231 $IsRoot = $group->isRoot();
232 $ActionValue = "update";
233
234 $headline = new eZINI( "kernel/ezuser/admin/intl/" . $Language . "/groupedit.php.ini", false );
235 $t->set_var( "head_line", $headline->variable( "strings", "head_line_edit" ) );
236 }
237
238 // List over all modules.
239 $module = new eZModule();
240 $moduleList = $module->getAll( true );
241
242 foreach ( $moduleList as $moduleItem )
243 {
244 $t->set_var( "module_name", $moduleItem->name() );
245 $t->set_var( "module_id", $moduleItem->id() );
246
247 $permission = new eZPermission();
248 $permissionList = $permission->getAllByModule( $moduleItem );
249
250 $t->set_var( "permission_item", "" );
251
252 foreach ( $permissionList as $permissionItem )
253 {
254 $t->set_var( "permission_name", $permissionItem->name() );
255 $t->set_var( "permission_id", $permissionItem->id() );
256
257 if ( isset( $group ) && get_class ( $group ) == "eZUserGroup" && $permissionItem->isEnabled( $group ) )
258 {
259 $t->set_var( "is_enabled", "checked" );
260 }
261 else
262 {
263 $t->set_var( "is_enabled", "" );
264 }
265
266 $t->parse( "permission_item", "permission_list_tpl", true );
267 }
268
269 if ( count( $permissionList ) > 0 )
270 $t->parse( "module_header", "module_list_header_tpl", true );
271 else
272 $t->set_var( "module_header", "" );
273 }
274
275 $t->set_var( "error_msg", isset( $error_msg ) ? $error_msg : false );
276 $t->set_var( "name_value", isset( $Name ) ? $Name : false );
277 $t->set_var( "description_value", isset( $Description ) ? $Description : false );
278 $t->set_var( "group_url_value", isset( $GroupURL ) ? $GroupURL : false );
279 $t->set_var( "session_timeout_value", isset( $SessionTimeout ) ? $SessionTimeout : false );
280 $t->set_var( "action_value", isset( $ActionValue ) ? $ActionValue : false );
281
282 ( isset( $IsRoot ) && $IsRoot == true ) ? $t->set_var( "root_checked", "checked" ) : $t->set_var( "root_checked", "" );
283
284 $t->set_var( "group_id", isset( $GroupID ) ? $GroupID : false );
285
286 $t->pparse( "output", "group_edit" );
287
288 ?>
$group
$group
Definition: admin/articleedit.php:799
$Description
$Description
Definition: articlelistrss.php:38
eZHTTPTool\header
static header( $string)
Definition: ezhttptool.php:96
eZINI
Reads and writes .ini style configuration files.
eZModule
Definition: ezmodule.php:54
eZPermission
Definition: ezpermission.php:97
eZPermission\checkPermission
static checkPermission( $user, $moduleName, $permissionName)
Definition: ezpermission.php:430
eZTemplate
Definition: eztemplate.php:107
eZUserGroup
Definition: ezusergroup.php:66
eZUser\currentUser
static & currentUser()
Definition: ezuser.php:896
$Action
$Action
Definition: companysearch.php:80
$permission
$permission
Definition: eventedit.php:315
$error
$error
Definition: ezarticle/admin/categoryedit.php:51
$error_msg
$error_msg
Definition: ezlink/admin/categoryedit.php:33
exit
exit
Definition: folder.php:81
$ActionValue
if(isset( $Action) && $Action=="new") $ActionValue
Definition: groupedit.php:219
$module
if(isset( $Action) && $Action=="edit") $module
Definition: groupedit.php:239
$user
$user
Definition: groupedit.php:42
$headline
$headline
Definition: groupedit.php:210
$Language
$Language
Definition: groupedit.php:33
$ini
$ini
Definition: groupedit.php:31
$moduleList
$moduleList
Definition: groupedit.php:240
$t
if(isset( $DeleteGroups) and isset( $GroupArrayID)) if(isset( $Back)) if(isset( $GroupID)) if(isset( $Action) && $Action=="insert") if(isset( $Action) && $Action=="delete") if(isset( $Action) && $Action=="update") $t
Definition: groupedit.php:200
$Name
$Name
Definition: polledit.php:250
$GroupID
$GroupID
Definition: rssheadlines.php:51
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.