ultimix

- Main Page
- Data Structures
- Files
- Examples

- Data Structures
- Data Structure Index
- Data Fields

Public Member Functions | Data Fields
content_access_1_0_0 Class Reference

## Public Member Functions
| __construct ()
| set_add_limitations ($theAddLimitation)
| select ($Start=false, $Limit=false, $Field=false, $Order=false, $Condition= '1=1', $Options=false)
| unsafe_select ($Condition= '1=1 ')
| select_list ($id)
| delete ($id)
| create (&$Record)
| select_content_by_category ($CategoryIds)
| get_publication_structure ($CategoryIds)
| get_content_for_date ($Year, $Month, $CategoryIds)
| update ($id, $Record)
| search ($Start, $SearchString)

## Data Fields
| $NativeTable = '`umx_content`'
| $Database = false
| $DatabaseAlgorithms = false
| $Security = false
| $SecurityParser = false
| $UserAccess = false
| $AddLimitations = '1 = 1'

## Detailed Description

Class provides access to site materials.

Author
  Dodonov A.A.

Definition at line 26 of file content_access.php.

## Constructor & Destructor Documentation

__construct | ( |  | ) |

Constructor.

Author
  Dodonov A.A.

Definition at line 66 of file content_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__ );
$this->UserAccess = get_package( 'user::user_access' , 'last' , __FILE__ );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

## Member Function Documentation

create | ( | & | $Record | ) |

Creating record.

Parameters

  $Record | Example for creation.

Returns
  id of the created record.

Exceptions

  Exception | - An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 456 of file content_access.php.

{
try
{
list( $Fields , $Values ) = $this->fetch_create_data( $Record );
$id = $this->DatabaseAlgorithms->create( $this->NativeTable , $Fields , $Values );
$EventManager = get_package( 'event_manager' , 'last' , __FILE__ );
$EventManager->trigger_event( 'on_after_create_content' , array( 'id' => $id ) );
return( $id );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

delete | ( |  | $id | ) |

Function deletes record.

Parameters

  $id | - Records's id.

Exceptions

  Exception | - An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 376 of file content_access.php.

{
try
{
$id = $this->Security->get( $id , 'integer_list' );
$this->Database->delete( $this->NativeTable , "( $this->AddLimitations ) AND id IN ( $id )" );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

get_content_for_date | ( |  | $Year,
|  |  | $Month,
|  |  | $CategoryIds
| ) |  |

Function returns contents.

Parameters

  $Year | - Year.
  $Month | - Month.
  $CategoryIds | - ids of the categories.

Returns
  Content.

Exceptions

  Exception | - An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 589 of file content_access.php.

{
try
{
$Year = $this->Security->get( $Year , 'integer' );
$Month = $this->Security->get( $Month , 'integer' );
$CategoryIds = $this->Security->get( $CategoryIds , 'integer' );
return(
$this->unsafe_select(
"YEAR( publication_date ) = $Year AND MONTH( publication_date ) = $Month AND ".
'category IN ( '.implode( ',' , $CategoryIds ).' ) ORDER BY publication_date ASC'
)
);
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

get_publication_structure | ( |  | $CategoryIds | ) |

Function returns publication structure.

Parameters

  $CategoryIds | - ids of the categories.

Returns
  Publication structure.

Exceptions

  Exception | - An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 537 of file content_access.php.

{
try
{
$CategoryIds = $this->Security->get( $CategoryIds , 'integer' );
return(
$this->Database->select(
'YEAR( publication_date ) AS publication_year , MONTH( publication_date ) AS publication_month'.
' , COUNT( * ) AS publication_count' ,
$this->NativeTable ,
'category IN ( '.implode( ',' , $CategoryIds ).
' ) GROUP BY publication_year , publication_month ORDER BY publication_date ASC'
)
);
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

search | ( |  | $Start,
|  |  | $SearchString
| ) |  |

Searching records.

Parameters

  $Start | - Search limitations.
  $SearchString | - Search string.

Returns
  Records.

Exceptions

  Exception | - An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 762 of file content_access.php.

{
try
{
$Start = $this->Security->get( $Start , 'integer' );
$this->Database->query_as( DB_OBJECT );
$Records = $this->Database->select(
$this->search_fields( $SearchString ) , $this->NativeTable ,
"( $this->AddLimitations ) ORDER BY relevation DESC LIMIT $Start , 10"
);
return( $Records );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

select | ( |  | $Start = `false`,
|  |  | $Limit = `false`,
|  |  | $Field = `false`,
|  |  | $Order = `false`,
|  |  | $Condition = `'1 = 1'`,
|  |  | $Options = `false`
| ) |  |

Function returns list of records.

Parameters

  $Start | - Number of the first record.
  $Limit | - Count of records limitation.
  $Field | - Field to sort by.
  $Order | - Sorting order.
  $Condition | - Additional conditions.
  $Options | - Additional options.

Returns
  List of records.

Exceptions

  Exception | - An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 173 of file content_access.php.

{
try
{
$AddCondition = '';
if( $Options !== false && $Options->get_setting( 'category_name' , false ) )
{
$Category = get_package( 'category::category_algorithms' , 'last' , __FILE__ );
$AddCondition = 'AND category IN ( '.implode(
',' , $Category->get_category_ids( $Options->get_setting( 'category_name' ) )
).' )';
}
$Condition = $this->DatabaseAlgorithms->select_condition(
$Start , $Limit , $Field , $Order , $Condition , $this->NativeTable
);
return( $this->unsafe_select( $Condition ) );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

select_content_by_category | ( |  | $CategoryIds | ) |

Function returns a list of contents.

Parameters

  $CategoryIds | - ids of the categories.

Returns
  Array of content objects.

Exceptions

  Exception | - An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 497 of file content_access.php.

{
try
{
$CategoryIds = $this->Security->get( $CategoryIds , 'integer' );
return(
$this->unsafe_select(
'category IN ( '.implode( ',' , $CategoryIds ).' ) ORDER BY publication_date ASC'
)
);
}
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

  Exception | - An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 344 of file content_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

  Exception | - An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 112 of file content_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 '` | ) |

Function returns list of records.

Returns
  List of available records.

Exceptions

  Exception | - An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 300 of file content_access.php.

{
try
{
$this->Database->query_as( DB_OBJECT );
$Content = $this->Database->select(
$this->NativeTable.'.* , umx_category.title AS category_title , user.login AS author_name' ,
$this->NativeTable.' , umx_category , '.$this->UserAccess->NativeTable.' AS user' ,
"author = user.id AND ( $this->AddLimitations ) AND umx_category.id = category AND $Condition"
);
$this->compile_selected_content( $Content );
return( $Content );
}
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

  Exception | - An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 666 of file content_access.php.

{
try
{
$id = $this->Security->get( $id , 'integer_list' );
$this->compile_record( $Record );
list( $Fields , $Values ) = $this->DatabaseAlgorithms->compile_fields_values( $Record );
if( isset( $Fields[ 0 ] ) )
{
/* the modification_date will be changed only if the content was changed */
$Fields [] = 'modification_date';
$Values [] = 'now()';
$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 92 of file content_access.php.

$Database = false

Cached objects.

Author
  Dodonov A.A.

Definition at line 50 of file content_access.php.

$DatabaseAlgorithms = false

Definition at line 51 of file content_access.php.

$NativeTable = '`umx_content`'

Table name in wich objects of this entity are stored.

Author
  Dodonov A.A.

Definition at line 38 of file content_access.php.

$Security = false

Definition at line 52 of file content_access.php.

$SecurityParser = false

Definition at line 53 of file content_access.php.

$UserAccess = false

Definition at line 54 of file content_access.php.

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

- packages/content/packages/content_access/content_access.php