Cheetah
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | List of all members
ChWsbVoting Class Reference
Inheritance diagram for ChWsbVoting:
ChBaseVotingView ChTemplVotingView ChEventsVoting ChGroupsVoting ChSitesVoting ChStoreVoting ChWallVoting ChWsbTextVoting ChArlVoting ChFdbVoting ChNewsVoting

Public Member Functions

 __construct ( $sSystem, $iId, $iInit=1)
 
 init ($iId)
 
 initVotes ()
 
 makeVote ($iVote)
 
 checkAction ($bPerformAction=false)
 
 isDublicateVote ()
 
 getId ()
 
 isEnabled ()
 
 getMaxVote ()
 
 getVoteCount ()
 
 getVoteRate ()
 
 getSystemName ()
 
 setId ($iId)
 
 getSqlParts ($sMailTable, $sMailField)
 
 isValidSystem ($sSystem)
 
 deleteVotings ($iId)
 
 getTopVotedItem ($iDays, $sJoinTable='', $sJoinField='', $sWhere='')
 
 getVotedItems ($sIp)
 
 maintenance ()
 
 actionVote ()
 

Static Public Member Functions

static getObjectInstance ($sSys, $iId, $iInit=true)
 
static & getSystems ()
 

Public Attributes

 $_iId = 0
 
 $_iCount = 0
 
 $_fRate = 0
 
 $_sSystem = 'profile'
 
 $_aSystem = array ()
 
 $_oQuery = null
 

Protected Member Functions

 _getVoteResult ()
 
 _triggerVote ()
 

Detailed Description

Votings for any content

Related classes: ChWsbVotingQuery - votings database queries ChBaseVotingView - votings base representation ChTemplVotingView - custom template representation

AJAX votings for any content. Big and small votings stars are supported

To add votings section to your site you need to add a record to 'sys_objects_vote' table:

ID - autoincremented id for internal usage ObjectName - your unique module name, with vendor prefix, lowercase and spaces are underscored TableRating - table name where sumarry votigs are stored TableTrack - table name where each vote is stored RowPrefix - row prefix for TableRating MaxVotes - max vote number, 5 by default PostName - post variable name with rating IsDuplicate - number of seconds to not allow duplicate vote (for some bad reason it is define here) IsOn - is this vote object enabled ClassName - custom class name for HotOrNot

See also
ChWsbRate ClassFile - custom class path for HotOrNot TriggerTable - table to be updated upon each vote TriggerFieldRate - TriggerTable table field with average rate TriggerFieldRateCount - TriggerTable table field with votes count TriggerFieldId - TriggerTable table field with unique record id, primary key OverrideClassName - your custom class name, if you overrride default class OverrideClassFile - your custom class path

You can refer to Cheetah modules for sample record in this table.

Example of usage: After filling in the table you can show big votings in any place, using the following code:

ch_import('ChTemplVotingView'); $o = new ChTemplVotingView ('value of ObjectName field', $iYourEntryId); if (!$o->isEnabled()) return ''; echo $o->getBigVoting (1); // 1 - rate is allowed

And small votings, using the following code:

$o = new ChTemplVotingView ('value of ObjectName field', $iYourEntryId); if (!$o->isEnabled()) return ''; echo $o->getSmallVoting (0); // 0 - rate is not allowed, like readony votings

In some cases votes are already in database and there is no need to execute additional query to get ratings, so you can use the following code:

$o = new ChTemplVotingView ('value of ObjectName field', 0); foreach ($aRecords as $aData) echo $o->getJustVotingElement(0, $aData['ID'], $aData['voting_rate']);

Please note that you never need to use ChWsbVoting class directly, use ChTemplVotingView instead. Also if you override votings class with your own then make it child of ChTemplVotingView class.

Memberships/ACL: vote - ACTION_ID_VOTE

Alerts: Alerts type/unit - every module has own type/unit, it equals to ObjectName The following alerts are rised

rate - comment was posted $iObjectId - entry id $iSenderId - rater user id $aExtra['rate'] - rate

Definition at line 89 of file ChWsbVoting.php.

Constructor & Destructor Documentation

◆ __construct()

ChWsbVoting::__construct (   $sSystem,
  $iId,
  $iInit = 1 
)

Member Function Documentation

◆ _getVoteResult()

ChWsbVoting::_getVoteResult ( )
protected

Definition at line 359 of file ChWsbVoting.php.

◆ _triggerVote()

ChWsbVoting::_triggerVote ( )
protected

Definition at line 377 of file ChWsbVoting.php.

◆ actionVote()

ChWsbVoting::actionVote ( )

Definition at line 343 of file ChWsbVoting.php.

◆ checkAction()

ChWsbVoting::checkAction (   $bPerformAction = false)

Reimplemented in ChStoreVoting, ChGroupsVoting, and ChEventsVoting.

Definition at line 239 of file ChWsbVoting.php.

◆ deleteVotings()

ChWsbVoting::deleteVotings (   $iId)

Definition at line 310 of file ChWsbVoting.php.

◆ getId()

ChWsbVoting::getId ( )

Definition at line 257 of file ChWsbVoting.php.

◆ getMaxVote()

ChWsbVoting::getMaxVote ( )

Definition at line 267 of file ChWsbVoting.php.

◆ getObjectInstance()

static ChWsbVoting::getObjectInstance (   $sSys,
  $iId,
  $iInit = true 
)
static

get voting object instanse

Parameters
$sSysvoting object name
$iIdassociated content id
$iInitperform initialization
Returns
null on error, or ready to use class instance

Definition at line 126 of file ChWsbVoting.php.

◆ getSqlParts()

ChWsbVoting::getSqlParts (   $sMailTable,
  $sMailField 
)

Definition at line 297 of file ChWsbVoting.php.

◆ getSystemName()

ChWsbVoting::getSystemName ( )

Definition at line 282 of file ChWsbVoting.php.

◆ getSystems()

static& ChWsbVoting::getSystems ( )
static

Definition at line 142 of file ChWsbVoting.php.

◆ getTopVotedItem()

ChWsbVoting::getTopVotedItem (   $iDays,
  $sJoinTable = '',
  $sJoinField = '',
  $sWhere = '' 
)

Definition at line 317 of file ChWsbVoting.php.

◆ getVoteCount()

ChWsbVoting::getVoteCount ( )

Definition at line 272 of file ChWsbVoting.php.

◆ getVotedItems()

ChWsbVoting::getVotedItems (   $sIp)

Definition at line 322 of file ChWsbVoting.php.

◆ getVoteRate()

ChWsbVoting::getVoteRate ( )

Definition at line 277 of file ChWsbVoting.php.

◆ init()

ChWsbVoting::init (   $iId)

Definition at line 193 of file ChWsbVoting.php.

◆ initVotes()

ChWsbVoting::initVotes ( )

Definition at line 205 of file ChWsbVoting.php.

◆ isDublicateVote()

ChWsbVoting::isDublicateVote ( )

Definition at line 249 of file ChWsbVoting.php.

◆ isEnabled()

ChWsbVoting::isEnabled ( )

Definition at line 262 of file ChWsbVoting.php.

◆ isValidSystem()

ChWsbVoting::isValidSystem (   $sSystem)

Definition at line 305 of file ChWsbVoting.php.

◆ maintenance()

ChWsbVoting::maintenance ( )

it is called on cron every day or similar period to clean old votes

Definition at line 330 of file ChWsbVoting.php.

◆ makeVote()

ChWsbVoting::makeVote (   $iVote)

Definition at line 218 of file ChWsbVoting.php.

◆ setId()

ChWsbVoting::setId (   $iId)

set id to operate with votes

Definition at line 290 of file ChWsbVoting.php.

Member Data Documentation

◆ $_aSystem

ChWsbVoting::$_aSystem = array ()

Definition at line 96 of file ChWsbVoting.php.

◆ $_fRate

ChWsbVoting::$_fRate = 0

Definition at line 93 of file ChWsbVoting.php.

◆ $_iCount

ChWsbVoting::$_iCount = 0

Definition at line 92 of file ChWsbVoting.php.

◆ $_iId

ChWsbVoting::$_iId = 0

Definition at line 91 of file ChWsbVoting.php.

◆ $_oQuery

ChWsbVoting::$_oQuery = null

Definition at line 98 of file ChWsbVoting.php.

◆ $_sSystem

ChWsbVoting::$_sSystem = 'profile'

Definition at line 94 of file ChWsbVoting.php.


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