59 $this->Database =
get_package(
'database' ,
'last' , __FILE__ );
60 $this->Security =
get_package(
'security' ,
'last' , __FILE__ );
94 $MasterId = $this->Security->get( $MasterId ,
'integer' );
98 $this->Database->update(
99 $DataAccess->NativeTable ,
100 array(
'date_from' ,
'date_to' ,
'group_id' ) ,
101 array( $Time , $Time + 100 * 365 * 24 * 60 * 60 , $MasterId ) ,
105 $this->Database->commit();
107 catch( Exception $e )
139 private function close_old_version( $MasterId , $Changes , $DataAccess )
143 $MasterId = $this->Security->get( $MasterId ,
'integer' );
146 $Records = $this->Database->select(
'MIN( id ) AS min_id' , $DataAccess->NativeTable );
147 $MinId =
get_field( $Records[ 0 ] ,
'min_id' , 0 ) - 1;
148 $this->Database->update(
149 $DataAccess->NativeTable , array(
'id' ,
'date_to' ) ,
150 array( $MinId , $Time - 1 ) ,
"id = $MasterId"
152 $this->Database->commit();
154 catch( Exception $e )
186 private function create_new_version( $MasterId , $Changes , $DataAccess )
190 $OriginalRecord = $DataAccess->unsafe_select(
"id = $MasterId" );
191 $ChangedRecord =
extend( $OriginalRecord[ 0 ] , $Changes );
192 $NewId = $DataAccess->create( $ChangedRecord );
193 $this->Database->update(
194 $DataAccess->NativeTable , array(
'id' ,
'date_from' ,
'date_to' ,
'group_id' ) ,
195 array( $MasterId , $Time , $Time + 100 * 365 * 24 * 60 * 60 , $MasterId ) ,
"id = $NewId"
197 $this->Database->commit();
199 catch( Exception $e )
235 $this->Database->lock( array( $DataAccess->NativeTable ) , array(
'WRITE' ) );
237 $this->close_old_version( $MasterId , $Changes , $DataAccess );
239 $this->create_new_version( $MasterId , $Changes , $DataAccess );
241 $this->Database->unlock();
243 catch( Exception $e )
275 $MasterId = $this->Security->get( $MasterId ,
'integer_list' );
277 $this->Database->update(
278 $DataAccess->NativeTable , array(
'date_to' ) , array( time() ) ,
279 "id IN ( $MasterId ) AND ( ".$DataAccess->AddLimitations.
" )"
282 $this->Database->commit();
284 catch( Exception $e )