85 'gui::context_set::context_set_utilities' ,
'last' , __FILE__
87 $this->GUI =
get_package(
'gui' ,
'last' , __FILE__ );
88 $this->SecurityParser =
get_package(
'security::security_parser' ,
'last' , __FILE__ );
122 $this->Prefix = $ContextSet->Prefix;
123 $this->Provider = $ContextSet->Provider;
125 catch( Exception $e )
149 function delete( &$Options )
153 $Provider = $this->ContextSetUtilities->get_data_provider( $Options , $this->Provider );
154 $FunctionName = $Options->get_setting(
'delete_func' ,
'delete' );
155 $Ids = $this->ContextSetUtilities->get_posted_ids( $this->Prefix );
157 if( method_exists(
$Provider , $FunctionName ) ===
true )
159 call_user_func( array(
$Provider , $FunctionName ) , implode(
',' , $Ids ) , $Options );
164 throw(
new Exception(
"Method \"$FunctionName\" was not found in the class \"$ClassName.\"" ) );
167 catch( Exception $e )
195 $Ids = $this->ContextSetUtilities->get_posted_ids( $this->Prefix );
196 $Provider = $this->ContextSetUtilities->get_data_provider( $Options , $this->Provider );
198 if( $Options->get_setting(
'id_list_accept' , 1 ) ==
'1' )
201 array(
$Provider , $Options->get_setting(
'func_name' ) ) , implode( $Ids ) , $Options
206 foreach( $Ids as $id )
208 call_user_func( array(
$Provider , $Options->get_setting(
'func_name' ) ) , $id , $Options );
212 catch( Exception $e )
240 private function get_creation_data( &$Options )
244 $ExtractionScript = $Options->get_setting(
'get_post_extraction_script' );
245 $Record = $this->SecurityParser->parse_http_parameters( $ExtractionScript );
247 $FunctionName = $Options->get_setting(
'create_func' ,
'create' );
248 $Provider = $this->ContextSetUtilities->get_data_provider( $Options , $this->Provider );
250 return( array( $Record , $FunctionName ,
$Provider ) );
252 catch( Exception $e )
280 list( $Record , $FunctionName ,
$Provider ) = $this->get_creation_data( $Options );
282 if( method_exists(
$Provider , $FunctionName ) ===
true )
284 $id = call_user_func( array(
$Provider , $FunctionName ) , $Record , $Options );
285 $this->GUI->set_var(
'record_id' , $id );
290 throw(
new Exception(
"Method \"$FunctionName\" was not found in the class \"$ClassName.\"" ) );
293 catch( Exception $e )
325 private function compile_update_record( $RecordNew , $RecordOriginal )
329 $UpdateRecord = array();
331 foreach( $RecordNew as $Field => $NewValue )
333 $Field = str_replace( $this->Prefix.
'_' ,
'' , $Field );
335 if( @$RecordOriginal->$Field != $NewValue )
337 @$UpdateRecord[ $Field ] = $NewValue;
341 return( $UpdateRecord );
343 catch( Exception $e )
383 $GetPostValidation = $Options->get_setting(
'get_post_validation' ,
false );
384 $ValidationScript = $Options->get_setting(
'custom_get_post_validation' , $GetPostValidation );
386 if( $ValidationScript ===
false )
388 throw(
new Exception(
'There is no script to extract data from http headers' ) );
391 $RecordNew = $this->SecurityParser->parse_http_parameters( $ValidationScript );
393 return( $this->compile_update_record( $RecordNew , $RecordOriginal ) );
395 catch( Exception $e )
423 private function get_update_data( &$Options )
427 $Ids = $this->ContextSetUtilities->get_posted_ids( $this->Prefix );
431 $RecordOriginal = $this->ContextSetUtilities->get_data_record( $Options , $Ids );
435 return( array( $Ids , $UpdateRecord ) );
437 catch( Exception $e )
465 list( $Ids , $UpdateRecord ) = $this->get_update_data( $Options );
467 $Provider = $this->ContextSetUtilities->get_data_provider( $Options , $this->Provider );
469 $FunctionName = $Options->get_setting(
'update_func' ,
'update' );
471 if( method_exists(
$Provider , $FunctionName ) ===
true )
473 $Func = array(
$Provider , $FunctionName );
475 call_user_func( $Func , implode(
',' , $Ids ) , $UpdateRecord , $Options );
481 throw(
new Exception(
"Method \"$FunctionName\" was not found in the class \"$ClassName.\"" ) );
484 catch( Exception $e )
512 $Options->set_setting(
'create_func' , $Options->get_setting(
'copy_func' ) );
513 $this->
create( $Options );
515 catch( Exception $e )