ultimix

- Main Page
- Data Structures
- Files
- Examples

- Data Structures
- Data Structure Index
- Data Fields

Public Member Functions | Data Fields
rating_algorithms_1_0_0 Class Reference

## Public Member Functions
| __construct ()
| increase_rating ($MasterId, $MasterType, $Value)
| get_rating_object ($MasterId=false, $MasterType= 'user')
| get_rating ($MasterId=false, $MasterType= 'user')
| set_rating ($Value, $MasterId=false, $MasterType= 'user')
| change_rating ($Delta, $MasterId=false, $MasterType= 'user')

## Data Fields
| $Database = false
| $DatabaseAlgorithms = false
| $LinkUtilities = false
| $RatingAccess = false

## Detailed Description

Class provides data access routine.

Author
  Dodonov A.A.

Definition at line 26 of file rating_algorithms.php.

## Constructor & Destructor Documentation

__construct | ( |  | ) |

Constructor.

Author
  Dodonov A.A.

Definition at line 53 of file rating_algorithms.php.

{
try
{
$this->Database = get_package( 'database' , 'last' , __FILE__ );
$this->DatabaseAlgorithms = get_package( 'database::database_algorithms' , 'last' , __FILE__ );
$this->LinkUtilities = get_package( 'link::link_utilities' , 'last' , __FILE__ );
$this->RatingAccess = get_package( 'rating::rating_access' , 'last' , __FILE__ );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

## Member Function Documentation

change_rating | ( |  | $Delta,
|  |  | $MasterId = `false`,
|  |  | $MasterType = `'user'`
| ) |  |

Function changes rating.

Parameters

  $Delta | - Rating value delta.
  $MasterId | - Master object's id.
  $MasterType | - Master object's type.

Exceptions

  Exception | An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 269 of file rating_algorithms.php.

{
try
{
$this->Database->lock( array( 'umx_rating' ) , array( 'WRITE' ) );
$Delta = $this->Security->get( $Delta , 'float' );
/* just create rating record in the DB in case is does not exist */
$Record = $this->get_rating_object( $MasterId , $MasterType );
$Value = get_field( $Record , 'value' );
$this->RatingAcces->update( get_field( $Rating , 'id' ) , array( 'value' => $Value + $Delta ) );
$this->Database->unlock();
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

get_rating | ( |  | $MasterId = `false`,
|  |  | $MasterType = `'user'`
| ) |  |

Function fetches object's rating.

Parameters

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

Returns
  Rating.

Exceptions

  Exception | An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 186 of file rating_algorithms.php.

{
try
{
$Record = $this->get_rating_object( $MasterId , $MasterType );
return( get_field( $Record , 'value' ) );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

get_rating_object | ( |  | $MasterId = `false`,
|  |  | $MasterType = `'user'`
| ) |  |

Function fetches object's rating.

Parameters

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

Returns
  Rating object.

Exceptions

  Exception | An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 130 of file rating_algorithms.php.

{
try
{
list( $MasterId , $MasterType ) = $this->LinkUtilities->trasform_master_parameters(
$MasterId , $MasterType
);
if( $this->LinkUtilities->dependent_objects_exist( $MasterId , $MasterType , 'rating' ) )
{
$Records = $this->LinkUtilities->get_dependent_objects(
$MasterId , $MasterType , 'rating' , $this->RatingAccess
);
}
else
{
$id = $this->RatingAccess->create(
array( 'master_id' => $MasterId , 'master_type' => $MasterType )
);
$Records = $this->RatingAccess->select_list( $id );
}
return( $Records[ 0 ] );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

increase_rating | ( |  | $MasterId,
|  |  | $MasterType,
|  |  | $Value
| ) |  |

Function increases rating for the specified object.

Parameters

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

Exceptions

  Exception | An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 90 of file rating_algorithms.php.

{
try
{
$Rating = $this->LinkUtilities->get_dependent_objects(
$MasterId , $MasterType , $this->RatingAccess
);
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

set_rating | ( |  | $Value,
|  |  | $MasterId = `false`,
|  |  | $MasterType = `'user'`
| ) |  |

Function sets rating.

Parameters

  $Value | - New value of the rating.
  $MasterId | - Master object's id.
  $MasterType | - Master object's type.

Exceptions

  Exception | An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 226 of file rating_algorithms.php.

{
try
{
$Value = $this->Security->get( $Value , 'float' );
/* just create rating record in the DB in case is does not exist */
$Record = $this->get_rating_object( $MasterId , $MasterType );
$this->RatingAcces->update( get_field( $Rating , 'id' ) , array( 'value' => $Value ) );
}
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 rating_algorithms.php.

$DatabaseAlgorithms = false

Definition at line 39 of file rating_algorithms.php.

$LinkUtilities = false

Definition at line 40 of file rating_algorithms.php.

$RatingAccess = false

Definition at line 41 of file rating_algorithms.php.

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

- packages/rating/packages/rating_algorithms/rating_algorithms.php