ultimix
group_controller.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 
27 
38  var $PermitAccess = false;
39  var $PermitAlgorithms = false;
40  var $Security = false;
41 
52  function __construct()
53  {
54  try
55  {
56  $this->PermitAccess = get_package( 'permit::permit_access' , 'last' , __FILE__ );
57  $this->PermitAlgorithms = get_package( 'permit::permit_algorithms' , 'last' , __FILE__ );
58  $this->Security = get_package( 'security' , 'last' , __FILE__ );
59  }
60  catch( Exception $e )
61  {
62  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
63  }
64  }
65 
84  function set_group( $Options )
85  {
86  try
87  {
88  $Permit = $this->Security->get_gp( 'permit' , 'command' );
89  $MasterType = $this->Security->get_gp( 'master_type' , 'command' );
90 
91  if( $this->Security->get_gp( 'ids' , 'set' ) )
92  {
93  $MasterId = explode( ',' , $this->Security->get_gp( 'ids' , 'string' ) );
94  }
95  else
96  {
97  $MasterId = array( $this->Security->get_gp( 'master_id' , 'integer' ) );
98  }
99 
100  $this->PermitAccess->set_group_for_object( $Permit , $MasterId , $MasterType );
101  }
102  catch( Exception $e )
103  {
104  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
105  }
106  }
107 
126  function delete_group( $Options )
127  {
128  try
129  {
130  $Permit = $this->Security->get_gp( 'permit' , 'command' );
131  $MasterType = $this->Security->get_gp( 'master_type' , 'command' );
132 
133  if( $this->Security->get_gp( 'ids' , 'set' ) )
134  {
135  $MasterId = explode( ',' , $this->Security->get_gp( 'ids' , 'string' ) );
136  }
137  else
138  {
139  $MasterId = array( $this->Security->get_gp( 'master_id' , 'integer' ) );
140  }
141 
142  $this->PermitAccess->delete_group_for_object( $Permit , $MasterId , $MasterType );
143  }
144  catch( Exception $e )
145  {
146  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
147  }
148  }
149 
168  function toggle_group( $Options )
169  {
170  try
171  {
172  $Permit = $this->Security->get_gp( 'permit' , 'command' );
173  $MasterType = $this->Security->get_gp( 'master_type' , 'command' );
174 
175  if( $this->Security->get_gp( 'ids' , 'set' ) )
176  {
177  $MasterId = explode( ',' , $this->Security->get_gp( 'ids' , 'string' ) );
178  }
179  else
180  {
181  $MasterId = array( $this->Security->get_gp( 'master_id' , 'integer' ) );
182  }
183 
184  $this->PermitAccess->toggle_group_for_object( $Permit , $MasterId , $MasterType );
185  }
186  catch( Exception $e )
187  {
188  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
189  }
190  }
191 
214  private function clear_groups_for_object( $MasterId , $MasterType )
215  {
216  try
217  {
218  $GroupList = $this->Security->get_gp( 'group_list' , 'string' );
219  $GroupList = explode( ',' , $GroupList );
220 
221  foreach( $GroupList as $i => $Title )
222  {
223  $GroupAccess->delete_group_for_object( $Title , $MasterId , $MasterType );
224  }
225  }
226  catch( Exception $e )
227  {
228  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
229  }
230  }
231 
250  function on_set_single_group_for_object( $Parameters )
251  {
252  try
253  {
254  if( $this->Security->get_gp( 'group_name' , 'set' , false ) &&
255  $this->PermitAlgorithms->object_has_permit( false , 'user' , 'permit_manager' ) )
256  {
257  $GroupAccess = get_package( 'permit::group_access' , 'last' , __FILE__ );
258 
259  $MasterId = get_field( $Parameters , 'master_id' );
260  $MasterType = get_field( $Parameters , 'master_type' );
261 
262  $this->clear_groups_for_object( $MasterId , $MasterType );
263 
264  $GroupName = $this->Security->get_gp( 'group_name' , 'command' );
265 
266  $GroupAccess->add_group_for_object( $GroupName , $MasterId , $MasterType );
267  }
268  }
269  catch( Exception $e )
270  {
271  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
272  }
273  }
274 
293  function controller( $Options )
294  {
295  try
296  {
297  $ContextSet = get_package_object( 'gui::context_set' , 'last' , __FILE__ );
298 
299  $ContextSet->add_context( dirname( __FILE__ ).'/conf/cfcx_set_group' );
300 
301  $ContextSet->add_context( dirname( __FILE__ ).'/conf/cfcx_delete_group' );
302 
303  $ContextSet->add_context( dirname( __FILE__ ).'/conf/cfcx_toggle_group' );
304 
305  $ContextSet->execute( $Options , $this , __FILE__ );
306  }
307  catch( Exception $e )
308  {
309  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
310  }
311  }
312  }
313 
314 ?>