ultimix

- Main Page
- Data Structures
- Files
- Examples

- Data Structures
- Data Structure Index
- Data Fields

Public Member Functions | Data Fields
change_history_access_1_0_0 Class Reference

## Public Member Functions
| __construct ()
| get_last_field_vlue ($id, $ObjectType, $Name)
| need_save_field ($id, $ObjectType, $Name, $NewValue)
| get_author ()
| add_to_history ($id, $ObjectType, $Record)
| get_history ($id, $ObjectType)

## Data Fields
| $NativeTable = '`umx_change_history`'
| $Database = false
| $Link = false
| $LinkDictionary = false
| $Security = false
| $UserAlgorithms = false

## Detailed Description

Class provides records change history manupulation routine.

Author
  Dodonov A.A.

Definition at line 26 of file change_history_access.php.

## Constructor & Destructor Documentation

__construct | ( |  | ) |

Constructor.

Exceptions

  Exception | An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 70 of file change_history_access.php.

{
try
{
$this->Database = get_package( 'database' , 'last' , __FILE__ );
$this->Link = get_package( 'link' , 'last' , __FILE__ );
$this->LinkDictionary = get_package( 'link::link_dictionary' , 'last' , __FILE__ );
$this->Security = get_package( 'security' , 'last' , __FILE__ );
$this->UserAlgorithms = get_package( 'user::user_algorithms' , 'last' , __FILE__ );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

## Member Function Documentation

add_to_history | ( |  | $id,
|  |  | $ObjectType,
|  |  | $Record
| ) |  |

Function saves changes history.

Parameters

  $id | - Id of the saving record.
  $ObjectType | - Object type.
  $Record | - Fields to save.

Exceptions

  Exception | An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 296 of file change_history_access.php.

{
try
{
$id = $this->Security->get( $id , 'integer' );
$Record = $this->Security->get( $Record , 'string' );
$ObjectType = $this->LinkDictionary->get_link_type( 'history' , $ObjectType );
$Author = $this->get_author();
foreach( $Record as $Name => $Value )
{
if( $this->need_save_field( $id , $ObjectType , $Name , $Value ) )
{
$this->Database->insert( $this->NativeTable ,
'object_id , object_type , field_name , field_value , creation_date , author' ,
"$id , $ObjectType , '$Name' , '$Value' , NOW() , $Author"
);
$this->Database->commit();
}
}
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

get_author | ( |  | ) |

Method returns action's author.

Returns
  Action's author.

Exceptions

  Exception | An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 256 of file change_history_access.php.

{
try
{
$User = $this->UserAlgorithms->get_user();
return( get_field( $User , 'id' ) );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

get_history | ( |  | $id,
|  |  | $ObjectType
| ) |  |

Function retrives changes history.

Parameters

  $id | - Id of the saving record.
  $ObjectType | - Object type.

Returns
  Changes history.

Exceptions

  Exception | An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 350 of file change_history_access.php.

{
try
{
$id = $this->Security->get( $id , 'integer' );
$ObjectType = $this->LinkDictionary->get_link_type( 'history' , $ObjectType );
$this->Database->query_as( DB_OBJECT );
return(
$this->Database->select(
$this->NativeTable.'.* , umx_user.login AS author_name' ,
$this->NativeTable.' , umx_user' ,
$this->NativeTable.".author = umx_user.id AND ".$this->NativeTable.".object_id = $id AND ".
$this->NativeTable.".object_type = $ObjectType ORDER BY id ASC"
)
);
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

get_last_field_vlue | ( |  | $id,
|  |  | $ObjectType,
|  |  | $Name
| ) |  |

Function retrives last field value.

Parameters

  $id | - Id of the saving record.
  $ObjectType | - Numeric object type.
  $Name | - Field name.

Returns
  Changes history.

Exceptions

  Exception | An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 167 of file change_history_access.php.

{
try
{
$id = $this->Security->get( $id , 'integer' );
$ObjectType = $this->Security->get( $ObjectType , 'integer' );;
$Name = $this->Security->get( $Name , 'command' );
$Entry = $this->get_entry( $id , $ObjectType , $Name );
if( isset( $Entry[ 0 ] ) )
{
return( get_field( $Entry[ 0 ] , 'field_value' ) );
}
return( false );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

need_save_field | ( |  | $id,
|  |  | $ObjectType,
|  |  | $Name,
|  |  | $NewValue
| ) |  |

Should the field be saved.

Parameters

  $id | - Id of the saving record.
  $ObjectType | - Numeric object type.
  $Name | - Field name.
  $NewValue | - Field value.

Returns
  true/false.

Exceptions

  Exception | An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 224 of file change_history_access.php.

{
try
{
$Value = $this->get_last_field_vlue( $id , $ObjectType , $Name );
return( $Value === false || ( $Value == $NewValue ? false : true ) );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

## Field Documentation

$Database = false

Cached packages.

Author
  Dodonov A.A.

Definition at line 50 of file change_history_access.php.

$Link = false

Definition at line 51 of file change_history_access.php.

$LinkDictionary = false

Definition at line 52 of file change_history_access.php.

$NativeTable = '`umx_change_history`'

Table name in wich objects of this entity are stored.

Author
  Dodonov A.A.

Definition at line 38 of file change_history_access.php.

$Security = false

Definition at line 53 of file change_history_access.php.

$UserAlgorithms = false

Definition at line 54 of file change_history_access.php.

The documentation for this class was generated from the following file:

- packages/database/packages/change_history/packages/change_history_access/change_history_access.php