ultimix

- Main Page
- Data Structures
- Files
- Examples

- Data Structures
- Data Structure Index
- Data Fields

Public Member Functions | Data Fields
link_utilities_1_0_0 Class Reference

## Public Member Functions
| __construct ()
| get_dependent_objects ($MasterId, $MasterType, $ObjectType, &$Access=false)
| dependent_objects_exist ($MasterId, $MasterType, $ObjectType)
| get_master_objects ($ObjectId, $MasterType, $ObjectType, $Access=false)
| master_objects_exists ($ObjectId, $MasterType, $ObjectType)
| trasform_master_parameters ($MasterId, $MasterType)
| get_sub_records ($Object1Type, $Object2Type, &$Records, $FieldName1, $JoiningTableName, $FieldName2, $Fields= '*')
| get_joining_records (&$Records, $FieldName1, $FieldName2, $JoiningTableName, $ExtendingFields, $Condition= '1=1')
| join_data (&$Records, $Object1Type, $Object2Type, $FieldName1, $FieldName2, $JoiningTableName, $JoinName, $Fields= '*')
| join_single_to_single_data (&$Records, $FieldName1, $FieldName2, $JoiningTableName, $JoinName, $Fields= '*', $Condition= '1=1')
| join_single_to_many_data (&$Records, $FieldName1, $FieldName2, $JoiningTableName, $JoinName, $Fields= '*', $Condition= '1=1')
| extend_records (&$Records, $FieldName1, $FieldName2, $JoiningTableName, $ExtendingFields, $Condition= '1=1')

## Data Fields
| $Database = false
| $Link = false
| $Security = false
| $String = false
| $UserAlgorithms = false

## Detailed Description

Link utilities.

Author
  Dodonov A.A.

Definition at line 26 of file link_utilities.php.

## Constructor & Destructor Documentation

__construct | ( |  | ) |

Constructor.

Exceptions

  Exception | An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 58 of file link_utilities.php.

{
try
{
$this->Database = get_package( 'database' , 'last' , __FILE__ );
$this->Link = get_package( 'link' , 'last' , __FILE__ );
$this->Security = get_package( 'security' , 'last' , __FILE__ );
$this->String = get_package( 'string' , '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

dependent_objects_exist | ( |  | $MasterId,
|  |  | $MasterType,
|  |  | $ObjectType
| ) |  |

Do dependent objects exist.

Parameters

  $MasterId | - Id of the master-object.
  $MasterType | - Type of the master-object.
  $ObjectType | - Type of the dependent object.

Returns
  true/false.

Exceptions

  Exception | An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 169 of file link_utilities.php.

{
try
{
$MasterId = $this->Security->get( $MasterId , 'integer' );
$MasterType = $this->Security->get( $MasterType , 'command' );
$ids = $this->get_dependent_objects( $MasterId , $MasterType , $ObjectType );
return( isset( $ids[ 0 ] ) && $ids[ 0 ] );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

extend_records | ( | & | $Records,
|  |  | $FieldName1,
|  |  | $FieldName2,
|  |  | $JoiningTableName,
|  |  | $ExtendingFields,
|  |  | $Condition = `'1 = 1'`
| ) |  |

Function joins data.

Parameters

  $Records | - Array of records to be extended.
  $FieldName1 | - First field name.
  $FieldName2 | - Second field name.
  $JoiningTableName | - Joining table.
  $ExtendingFields | - Fields to add.
  $Condition | - Additional conditions.

Returns
  List of records.

Exceptions

  Exception | An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 756 of file link_utilities.php.

{
try
{
$SubRecords = $this->get_joining_records(
$Records , $FieldName1 , $FieldName2 , $JoiningTableName ,
implode( ' , ' , $ExtendingFields ) , $Condition
);
foreach( $Records as $k1 => $v1 )
{
foreach( $SubRecords as $k2 => $v2 )
{
if( get_field( $v1 , $FieldName1 ) == get_field( $v2 , '_joining_field' ) )
{
extend( $Records[ $k1 ] , remove_fields( $v2 , '_joining_field' ) );
}
}
}
return( $Records );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

get_dependent_objects | ( |  | $MasterId,
|  |  | $MasterType,
|  |  | $ObjectType,
|  | & | $Access = `false`
| ) |  |

Function returns dependent objects.

Parameters

  $MasterId | - Id of the master-object.
  $MasterType | - Type of the master-object.
  $ObjectType | - Type of the dependent object.
  $Access | - Data acces object.

Returns
  Array of identificators or objects.

Note
  If no objects were found array(0) may be returned.

Exceptions

  Exception | An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 112 of file link_utilities.php.

{
try
{
$MasterId = $this->Security->get( $MasterId , 'integer' );
$MasterType = $this->Security->get( $MasterType , 'command' );
$ids = array( 0 );
$Links = $this->Link->get_links( $MasterId , false , $MasterType , $ObjectType );
if( isset( $Links[ 0 ] ) )
{
$ids = get_field_ex( $Links , 'object2_id' );
}
if( $Access === false )
{
return( $ids );
}
else
{
return( $Access->select_list( implode( ',' , $ids ) ) );
}
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

get_joining_records | ( | & | $Records,
|  |  | $FieldName1,
|  |  | $FieldName2,
|  |  | $JoiningTableName,
|  |  | $ExtendingFields,
|  |  | $Condition = `'1 = 1'`
| ) |  |

Function fetches additional data.

Parameters

  $Records | - Array of records to be extended.
  $FieldName1 | - First field name.
  $FieldName2 | - Second field name.
  $JoiningTableName | - Joining table.
  $ExtendingFields | - Fields to add.
  $Condition | - Additional conditions.

Returns
  List of records.

Exceptions

  Exception | An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 462 of file link_utilities.php.

{
try
{
if( isset( $Records[ 0 ] ) )
{
$Values = implode( ' , ' , array_unique( get_field_ex( $Records , $FieldName1 ) ) );
$SubRecords = $this->Database->select(
"$FieldName2 AS _joining_field , $ExtendingFields" , "$JoiningTableName" ,
"$FieldName2 IN ( $Values ) AND ( $Condition )"
);
return( $SubRecords );
}
return( array() );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

get_master_objects | ( |  | $ObjectId,
|  |  | $MasterType,
|  |  | $ObjectType,
|  |  | $Access = `false`
| ) |  |

Function returns parent objects.

Parameters

  $ObjectId | - Id of the dependent object.
  $MasterType | - Type of the master-object.
  $ObjectType | - Type of the dependent object.
  $Access | - Data acces object.

Returns
  Array of identificators or objects, or objects themselves.

Note
  If no objects were found array(0) may be returned.

Exceptions

  Exception | An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 224 of file link_utilities.php.

{
try
{
$ObjectId = $this->Security->get( $ObjectId , 'integer' );
$MasterType = $this->Security->get( $MasterType , 'command' );
$ids = array( 0 );
$Links = $this->Link->get_links( false , $ObjectId , $MasterType , $ObjectType );
if( isset( $Links[ 0 ] ) )
{
$ids = get_field_ex( $Links , 'object1_id' );
}
if( $Access === false )
{
return( $ids );
}
else
{
return( $Access->select_list( implode( ',' , $ids ) ) );
}
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

get_sub_records | ( |  | $Object1Type,
|  |  | $Object2Type,
|  | & | $Records,
|  |  | $FieldName1,
|  |  | $JoiningTableName,
|  |  | $FieldName2,
|  |  | $Fields = `'*'`
| ) |  |

Function returns joind data.

Parameters

  $Object1Type | - Type of the first object.
  $Object2Type | - Type of the second object.
  $Records | - Array of records.
  $FieldName1 | - Field's name.
  $JoiningTableName | - Joining table name.
  $FieldName2 | - Field's name.
  $Fields | - List of the joining fields.

Returns
  true List of records.

Exceptions

  Exception | An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 394 of file link_utilities.php.

{
try
{
if( isset( $Records[ 0 ] ) )
{
$LinkType = $this->LinkDictionary->get_link_type( $Object1Type , $Object2Type );
$Ids = implode_ex( ',' , $Records , $FieldName1 );
$Fields = "$Fields , umx_link.object1_id AS _record_original_id";
$Tables = "$JoiningTableName , umx_link";
$JoinConditions = "umx_link.type $LinkType AND umx_link.object1_id IN ( $Ids ) AND
umx_link.object2_id = $JoiningTableName".".$FieldName2";
return( $this->Database->select( $Fields , $Tables , $JoinConditions ) );
}
else
{
return( array() );
}
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

join_data | ( | & | $Records,
|  |  | $Object1Type,
|  |  | $Object2Type,
|  |  | $FieldName1,
|  |  | $FieldName2,
|  |  | $JoiningTableName,
|  |  | $JoinName,
|  |  | $Fields = `'*'`
| ) |  |

Function joins data.

Parameters

  $Records | - Array of records.
  $Object1Type | - Type of the first object.
  $Object2Type | - Type of the second object.
  $FieldName1 | - Field's name.
  $FieldName2 | - Field's name.
  $JoiningTableName | - Joining table name.
  $JoinName | - Name of he join.
  $Fields | - List of the joining fields.

Returns
  List of records.

Exceptions

  Exception | An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 535 of file link_utilities.php.

{
try
{
$SubRecords = $this->get_sub_records( $Object1Type , $Object2Type , $Records , $FieldName1 ,
$JoiningTableName , $FieldName2 );
foreach( $Records as $k1 => $v1 )
{
set_field( $Records[ $k1 ] , $JoinName , array() );
foreach( $SubRecords as $k2 => $v2 )
{
if( get_field( $v1 , $FieldName1 ) == get_field( $v2 , $FieldName2 ) )
{
append_to_field( $Records[ $k1 ] , $JoinName , $v2 );
}
}
}
return( $Records );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

join_single_to_many_data | ( | & | $Records,
|  |  | $FieldName1,
|  |  | $FieldName2,
|  |  | $JoiningTableName,
|  |  | $JoinName,
|  |  | $Fields = `'*'`,
|  |  | $Condition = `'1 = 1'`
| ) |  |

Function joins data.

Parameters

  $Records | - Array of records to be extended.
  $FieldName1 | - First field name.
  $FieldName2 | - Second field name.
  $JoiningTableName | - Joining table.
  $JoinName | - Name of he join.
  $Fields | - List of the joining fields.
  $Condition | - Additional conditions.

Returns
  List of records.

Exceptions

  Exception | An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 685 of file link_utilities.php.

{
try
{
$SubRecords = $this->get_joining_records(
$Records , $FieldName1 , $FieldName2 , $JoiningTableName , $Fields , $Condition
);
foreach( $Records as $k1 => $v1 )
{
set_field( $Records[ $k1 ] , $JoinName , array() );
foreach( $SubRecords as $k2 => $v2 )
{
if( get_field( $v1 , $FieldName1 ) == get_field( $v2 , '_joining_field' ) )
{
append_to_field( $Records[ $k1 ] , $JoinName , remove_fields( $v2 , '_joining_field' ) );
}
}
}
return( $Records );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

join_single_to_single_data | ( | & | $Records,
|  |  | $FieldName1,
|  |  | $FieldName2,
|  |  | $JoiningTableName,
|  |  | $JoinName,
|  |  | $Fields = `'*'`,
|  |  | $Condition = `'1 = 1'`
| ) |  |

Function joins data.

Parameters

  $Records | - Array of records to be extended.
  $FieldName1 | - First field name.
  $FieldName2 | - Second field name.
  $JoiningTableName | - Joining table.
  $JoinName | - Name of he join.
  $Fields | - List of the joining fields.
  $Condition | - Additional conditions.

Returns
  List of records.

Exceptions

  Exception | An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 609 of file link_utilities.php.

{
try
{
$SubRecords = $this->get_joining_records(
$Records , $FieldName1 , $FieldName2 , $JoiningTableName , $Fields , $Condition
);
foreach( $Records as $k1 => $v1 )
{
foreach( $SubRecords as $k2 => $v2 )
{
if( get_field( $v1 , $FieldName1 ) == get_field( $v2 , '_joining_field' ) )
{
if( get_field( $Records[ $k1 ] , $JoinName , false ) !== false )
{
throw( new Exception( "The field \"$JoinName\" was already set" ) );
}
set_field( $Records[ $k1 ] , $JoinName , remove_fields( $v2 , '_joining_field' ) );
}
}
}
return( $Records );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

master_objects_exists | ( |  | $ObjectId,
|  |  | $MasterType,
|  |  | $ObjectType
| ) |  |

Do dependent objects exist.

Parameters

  $ObjectId | - Id of the dependent-object.
  $MasterType | - Type of the master-object.
  $ObjectType | - Type of the dependent object.

Returns
  true/false.

Exceptions

  Exception | An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 284 of file link_utilities.php.

{
try
{
$ObjectId = $this->Security->get( $ObjectId , 'integer' );
$MasterType = $this->Security->get( $MasterType , 'command' );
$ids = $this->get_master_objects( $ObjectId , $MasterType , $ObjectType );
return( isset( $ids[ 0 ] ) && $ids[ 0 ] );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

trasform_master_parameters | ( |  | $MasterId,
|  |  | $MasterType
| ) |  |

Function transforms master object's parameters.

Parameters

  $MasterId | - Master object's id.
  $MasterType | - Master object's type.

Returns
  Transforned parameters.

Exceptions

  Exception | An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 327 of file link_utilities.php.

{
try
{
$MasterType = $this->Security->get( $MasterType , 'command' );
if( $MasterId === false && $MasterType == 'user' )
{
$MasterId = $this->UserAlgorithms->get_id();
}
$MasterId = $this->Security->get( $MasterId , 'integer' );
return( array( $MasterId , $MasterType ) );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

## Field Documentation

$Database = false

Cached objects.

Author
  Dodonov A.A.

Definition at line 38 of file link_utilities.php.

$Link = false

Definition at line 39 of file link_utilities.php.

$Security = false

Definition at line 40 of file link_utilities.php.

$String = false

Definition at line 41 of file link_utilities.php.

$UserAlgorithms = false

Definition at line 42 of file link_utilities.php.

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

- packages/link/packages/link_utilities/link_utilities.php