ultimix
set_field.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 $Database = false;
39  var $Security = false;
40  var $PermitAlgorithms = false;
41 
56  function __construct()
57  {
58  try
59  {
60  $this->Database = get_package( 'database' , 'last' , __FILE__ );
61  $this->Security = get_package( 'security' , 'last' , __FILE__ );
62  $this->PermitAlgorithms = get_package( 'permit::permit_algorithms' , 'last' , __FILE__ );
63  }
64  catch( Exception $e )
65  {
66  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
67  }
68  }
69 
88  private function set_field( &$Options )
89  {
90  try
91  {
92  $PackageName = $Options->get_setting( 'access_package_name' );
93  $PackageVersion = $Options->get_setting( 'access_package_version' , 'last' );
94  $Accessor = get_package( $PackageName , $PackageVersion , __FILE__ );
95  $FunctionName = $Options->get_setting( 'update_func' );
96 
97  $Func = array( $Accessor , $FunctionName );
98 
99  $Ids = $this->Security->get_gp( 'ids' , '' );
100 
101  $UpdateRecord = array();
102  $UpdateRecord[ $Options->get_setting( 'field' ) ] = $Options->get_setting( 'value' );
103 
104  call_user_func( $Func , implode( ',' , $Ids ) , $UpdateRecord , $Options );
105  }
106  catch( Exception $e )
107  {
108  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
109  }
110  }
111 
130  function controller( &$Options )
131  {
132  try
133  {
134  $NotDirectControllerCall = $this->Security->get_s( 'direct_controller' , 'integer' , 0 ) == 0;
135  $HasPermits = $this->PermitAlgorithms->object_has_permit( false , 'user' , $Permit );
136  $GetPostParamsPassed = $this->Security->get_gp( 'set_field' , 'integer' , 1 );
137  $Permit = $Options->get_setting( 'permit' , 'admin' );
138 
139  if( $NotDirectControllerCall && $HasPermits && $GetPostParamsPassed )
140  {
141  $this->set_field( $Options );
142  }
143  }
144  catch( Exception $e )
145  {
146  $Args = func_get_args();_throw_exception_object( __METHOD__ , $Args , $e );
147  }
148  }
149  }
150 
151 ?>