ultimix

- Main Page
- Data Structures
- Files
- Examples

- File List
- Globals

user_permit_manager.php
Go to the documentation of this file.
1 <?php
2
3 /*
4 * This source code is a part of the Ultimix Project.
5 * It is distributed under BSD license. All other third side source code (like tinyMCE) is distributed under
6 * it's own license wich could be found from the corresponding files or sources.
7 * This source code is provided "as is" without any warranties or garanties.
8 *
9 * Have a nice day!
10 *
11 * @url http://ultimix.sorceforge.net
12 *
13 * @author Alexey "gdever" Dodonov
14 */
15
26 class user_permit_manager_1_0_0{
27
38 var $CachedMultyFS = false;
39 var $GroupAccess = false;
40 var $Link = false;
41 var $PermitAccess = false;
42 var $PermitAlgorithms = false;
43 var $Security = false;
44 var $UserAccess = false;
45 var $UserAlgorithms = false;
46
57 function __construct()
58 {
59 try
60 {
61 $this->CachedMultyFS = get_package( 'cached_multy_fs' , 'last' , __FILE__ );
62 $this->GroupAccess = get_package( 'permit::group_access' , 'last' , __FILE__ );
63 $this->Link = get_package( 'link' , 'last' , __FILE__ );
64 $this->PermitAccess = get_package( 'permit::permit_access' , 'last' , __FILE__ );
65 $this->PermitAlgorithms = get_package( 'permit::permit_algorithms' , 'last' , __FILE__ );
66 $this->Security = get_package( 'security' , 'last' , __FILE__ );
67 $this->UserAccess = get_package( 'user::user_access' , 'last' , __FILE__ );
68 $this->UserAlgorithms = get_package( 'user::user_algorithms' , 'last' , __FILE__ );
69 }
70 catch( Exception $e )
71 {
72 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
73 }
74 }
75
94 function change_permits_controller( $Options )
95 {
96 try
97 {
98 $UserId = $this->Security->get_p( 'record_id' , 'integer' );
99 $Permits = $this->Security->get_p( 'permits' , 'command' , array() );
100
101 $HasPermits = $this->PermitAlgorithms->get_permits_for_object( $UserId , 'user' , false );
102 foreach( $HasPermits as $p )
103 {
104 if( in_array( $p , $Permits ) === false )
105 {
106 $p = $this->PermitAccess->get_permit_by_name( $p );
107 $this->Link->delete_link( $UserId , $p->id , 'user' , 'permit' );
108 }
109 }
110
111 foreach( $Permits as $p )
112 {
113 $this->PermitAccess->add_permit_for_object( $p , $UserId , 'user' );
114 }
115 }
116 catch( Exception $e )
117 {
118 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
119 }
120 }
121
140 function change_groups_controller( $Options )
141 {
142 try
143 {
144 $UserId = $this->Security->get_p( 'record_id' , 'integer' );
145 $Groups = $this->Security->get_p( 'groups' , 'command' , array() );
146
147 $HasGroups = $this->GroupAccess->get_groups_for_object( $UserId , 'user' );
148 foreach( $HasGroups as $g )
149 {
150 if( in_array( $g , $Groups ) === false )
151 {
152 $g = $this->GroupAccess->get_group_by_name( $g );
153 $this->Link->delete_link( $UserId , $g->id , 'user' , 'group' );
154 }
155 }
156
157 foreach( $Groups as $p )
158 {
159 $this->GroupAccess->add_group_for_object( $p , $UserId , 'user' );
160 }
161 }
162 catch( Exception $e )
163 {
164 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
165 }
166 }
167
186 function change_permits_view( $Options )
187 {
188 try
189 {
190 $User = $this->UserAlgorithms->get_by_id(
191 $this->Security->get_p( 'user_permit_record_id' , 'integer' )
192 );
193 $this->Output = $this->CachedMultyFS->get_template( __FILE__ , 'permits_view.tpl' );
194 $this->Output = str_replace( '{path}' , dirname( __FILE__ ) , $this->Output );
195 $this->Output = str_replace( '{login}' , $User->login , $this->Output );
196 }
197 catch( Exception $e )
198 {
199 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
200 }
201 }
202
221 function change_groups_view( $Options )
222 {
223 try
224 {
225 $User = $this->UserAlgorithms->get_by_id(
226 $this->Security->get_p( 'user_permit_record_id' , 'integer' )
227 );
228 $this->Output = $this->CachedMultyFS->get_template( __FILE__ , 'groups_view.tpl' );
229 $this->Output = str_replace( '{path}' , dirname( __FILE__ ) , $this->Output );
230 $this->Output = str_replace( '{login}' , $User->login , $this->Output );
231 }
232 catch( Exception $e )
233 {
234 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
235 }
236 }
237
260 function controller( $Options )
261 {
262 try
263 {
264 $ContextSet = get_package_object( 'gui::context_set' , 'last' , __FILE__ );
265
266 $ContextSet->add_context( dirname( __FILE__ ).'/conf/cfcx_change_permits_controller' );
267 $ContextSet->add_context( dirname( __FILE__ ).'/conf/cfcx_change_groups_controller' );
268 $ContextSet->execute( $Options , $this , __FILE__ );
269 }
270 catch( Exception $e )
271 {
272 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
273 }
274 }
275
298 function view( $Options )
299 {
300 try
301 {
302 $ContextSet = get_package_object( 'gui::context_set' , 'last' , __FILE__ );
303
304 $ContextSet->add_context( dirname( __FILE__ ).'/conf/cfcx_change_permits_view' );
305 $ContextSet->add_context( dirname( __FILE__ ).'/conf/cfcx_change_groups_view' );
306 $ContextSet->execute( $Options , $this , __FILE__ );
307
308 return( $this->Output );
309 }
310 catch( Exception $e )
311 {
312 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
313 }
314 }
315 }
316
317 ?>