ultimix
category_access_1_0_0 Class Reference

Public Member Functions

 __construct ()
 set_add_limitations ($theAddLimitation)
 create ($Record)
 update ($id, $Record)
 select_list ($id)
 delete ($cid)
 move_up_children_categories ($cid, $NewRootId)
 unsafe_select ($Condition= '1=1')
 select ($Start, $Limit, $Field=false, $Order=false, $Condition= '1=1')
 get_category_id ($Name)
 get_children ($id)
 get_children_count ($id)
 get_siblings ($id)
 get_siblings_ids ($id)
 select_categories_list ($id)

Data Fields

 $NativeTable = '`umx_category`'
 $Database = false
 $DatabaseAlgorithms = false
 $Security = false
 $SecurityParser = false
 $Dictionary = false
 $AddLimitations = '1 = 1'

Detailed Description

Working with categories.

Author
Dodonov A.A.

Definition at line 26 of file category_access.php.

Constructor & Destructor Documentation

__construct ( )

Constructor.

Author
Dodonov A.A.

Definition at line 77 of file category_access.php.

{
try
{
$this->Database = get_package( 'database' , 'last' , __FILE__ );
$this->DatabaseAlgorithms = get_package( 'database::database_algorithms' , 'last' , __FILE__ );
$this->Security = get_package( 'security' , 'last' , __FILE__ );
$this->SecurityParser = get_package( 'security::security_parser' , 'last' , __FILE__ );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

Member Function Documentation

create (   $Record)

Creating record.

Parameters
$RecordExample for creation.
Returns
id of the created record.
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 163 of file category_access.php.

{
try
{
$Script = 'title:string;root_id:integer;direct_category:integer,default_0,allow_not_set;'.
'mask:integer,default_0,allow_not_set';
$Record = $this->SecurityParser->parse_parameters( $Record , $Script );
list( $Fields , $Values ) = $this->DatabaseAlgorithms->compile_fields_values( $Record );
$id = $this->DatabaseAlgorithms->create( $this->NativeTable , $Fields , $Values );
$EventManager = get_package( 'event_manager' , 'last' , __FILE__ );
$EventManager->trigger_event( 'on_after_create_category' , array( 'id' => $id ) );
return( $id );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
delete (   $cid)

Delete records.

Parameters
$cid- Record's id.
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 289 of file category_access.php.

{
try
{
$cid = $this->Security->get( $cid , 'integer_list' );
$EventManager = get_package( 'event_manager' , 'last' , __FILE__ );
$EventManager->trigger_event( 'on_before_delete_category' , array( 'id' => $cid ) );
$this->Database->delete( 'umx_category' , "( $this->AddLimitations ) AND id IN ( $cid )" );
$this->Database->commit();
$EventManager = get_package( 'event_manager' , 'last' , __FILE__ );
$EventManager->trigger_event( 'on_after_delete_category' , array( 'id' => $cid ) );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
get_category_id (   $Name)

Definition at line 507 of file category_access.php.

{
try
{
if( $this->Dictionary === false )
{
$this->Dictionary = $this->unsafe_select( 'category_name IS NOT NULL' );
}
foreach( $this->Dictionary as $k => $v )
{
if( get_field( $v , 'category_name' ) == $Name )
{
return( get_field( $v , 'id' ) );
}
}
throw( new Exception( "Category with name '$Name' was not found" ) );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
get_children (   $id)

Function returns subcategories.

Parameters
$Name- Name of the category.
Returns
Subcategories.
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 554 of file category_access.php.

{
try
{
$id = $this->Security->get( $id , 'integer' );
return( $this->unsafe_select( "root_id = $id ORDER BY title" ) );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
get_children_count (   $id)

Function returns subcategories.

Parameters
$Name- Name of the category.
Returns
Subcategories.
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 590 of file category_access.php.

{
try
{
$id = $this->Security->get( $id , 'integer' );
return( count( $this->unsafe_select( "root_id = $id ORDER BY title" ) ) );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
get_siblings (   $id)

Function returns siblings of the element.

Parameters
$id- Id of the category.
Returns
Siblings.
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 626 of file category_access.php.

{
try
{
$ids = $this->Security->get( $id , 'integer' );
$Siblings = array();
while( true )
{
$Children = $this->unsafe_select( "root_id IN ( $ids ) ORDER BY title" );
if( isset( $Children[ 0 ] ) )
{
$Siblings = array_merge( $Siblings , $Children );
$ids = get_field_ex( $Children , 'id' );
$ids = implode( ',' , $ids );
}
else
{
return( $Siblings );
}
}
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
get_siblings_ids (   $id)

Function returns ids of all siblings.

Parameters
$id- Id of the category.
Returns
Ids of all siblings.
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 680 of file category_access.php.

{
try
{
$ids = $this->Security->get( $id , 'integer' );
$SiblingsIds = array();
while( true )
{
$Children = $this->unsafe_select( "root_id IN ( $ids ) ORDER BY title" );
if( isset( $Children[ 0 ] ) )
{
$ids = get_field_ex( $Children , 'id' );
$SiblingsIds = array_merge( $SiblingsIds , $ids );
$ids = implode( ',' , $ids );
}
else
{
return( $SiblingsIds );
}
}
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
move_up_children_categories (   $cid,
  $NewRootId 
)

Moving children categories.

Parameters
$cid- Record's id.
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 328 of file category_access.php.

{
try
{
$cid = $this->Security->get( $cid , 'integer_list' );
$NewRootId = $this->Security->get( $NewRootId , 'integer' );
$Condition = "( $this->AddLimitations ) AND root_id IN ( $cid )";
$this->Database->update( $this->NativeTable , array( 'root_id' ) , array( $NewRootId ) , $Condition );
$this->Database->commit();
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
select (   $Start,
  $Limit,
  $Field = false,
  $Order = false,
  $Condition = '1 = 1' 
)

Selecting all records.

Parameters
$Start- Cursor of the first record.
$Limit- Count of the selecting records.
$Field- Field to sort by.
$Order- Sorting order.
$Condition- Additional conditions.
Returns
Vector of arrays.
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 465 of file category_access.php.

{
try
{
$Condition = $this->DatabaseAlgorithms->select_condition(
$Start , $Limit , $Field , $Order , $Condition , $this->NativeTable
);
$this->Database->query_as( DB_OBJECT );
list( $Fields , $Tables , $Condition ) = $this->get_fetch_parameters( $Condition );
return( $this->Database->select( $Fields , $Tables , $Condition ) );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
select_categories_list (   $id)

Function returns all subcategories.

Parameters
$id- id of the category.
Returns
Subcategories.
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 734 of file category_access.php.

{
try
{
$id = $this->Security->get( $id , 'integer' );
return( $this->unsafe_select( "direct_category = $id ORDER BY title" ) );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
select_list (   $id)

Function selects list of objects.

Parameters
$id- Comma separated list of record's id.
Returns
Array of records.
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 257 of file category_access.php.

{
try
{
$id = $this->Security->get( $id , 'integer_list' );
return( $this->unsafe_select( $this->NativeTable.".id IN ( $id )" ) );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
set_add_limitations (   $theAddLimitation)

Function sets additional limitations.

Parameters
$theAddLimitation- Additional limitations.
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 122 of file category_access.php.

{
try
{
if( $this->AddLimitations === '1 = 1' )
{
$this->AddLimitations = $theAddLimitation;
}
else
{
throw( new Exception( '"AddLimitations" was already set' ) );
}
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
unsafe_select (   $Condition = '1 = 1')

Selecting records.

Parameters
$Condition- Selection condition.
Returns
Array of objects.
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 370 of file category_access.php.

{
try
{
$this->Database->query_as( DB_OBJECT );
return( $this->Database->select( '*' , 'umx_category' , "( $this->AddLimitations ) AND $Condition" ) );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
update (   $id,
  $Record 
)

Updating record.

Parameters
$id- Comma separated list of record's id.
$Record- Example for update.
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 208 of file category_access.php.

{
try
{
$id = $this->Security->get( $id , 'integer_list' );
$Script = 'title:string;root_id:integer;direct_category:integer;mask:integer';
$Record = $this->SecurityParser->parse_parameters( $Record , $Script , 'allow_not_set' );
list( $Fields , $Values ) = $this->DatabaseAlgorithms->compile_fields_values( $Record );
if( isset( $Fields[ 0 ] ) )
{
$Condition = "( $this->AddLimitations ) AND id IN ( $id )";
$this->Database->update( $this->NativeTable , $Fields , $Values , $Condition );
$this->Database->commit();
}
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

Field Documentation

$AddLimitations = '1 = 1'

Definition at line 102 of file category_access.php.

$Database = false

Cached objects.

Author
Dodonov A.A.

Definition at line 50 of file category_access.php.

$DatabaseAlgorithms = false

Definition at line 51 of file category_access.php.

$Dictionary = false

Categories dictionary.

Author
Dodonov A.A.

Definition at line 65 of file category_access.php.

$NativeTable = '`umx_category`'

Table name in wich objects of this entity are stored.

Author
Dodonov A.A.

Definition at line 38 of file category_access.php.

$Security = false

Definition at line 52 of file category_access.php.

$SecurityParser = false

Definition at line 53 of file category_access.php.


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