No Matches
BxDolVote Class Reference
Inheritance diagram for BxDolVote:
BxDolObject BxDolFactory iBxDolReplaceable BxBaseVote BxTemplVote BxDolVoteLikes BxDolVoteReactions BxDolVoteStars BxBaseVoteLikes BxBaseVoteReactions BxBaseVoteStars BxTemplVoteLikes BxTemplVoteReactions BxTemplVoteStars BxAlbumsVoteLikesMedia BxBaseModProfileVote BxBaseModTextVotePollAnswers BxDolCmtsVoteLikes BxPollsVoteSubentries BxTimelineVoteLikes BxDolCmtsVoteReactions BxMarketVoteReactions BxMarketVoteStars BxPhotosVoteStars BxReviewsVoteStars

Public Member Functions

 getObjectAuthorId ($iObjectId=0)
 isUndo ()
 getType ()
 getMinValue ()
 getMaxValue ()
 getStatCounter ()
 getStatRate ()
 getSocketName ()
 actionVote ()
 vote ($aVoteData=[], $aRequestParamsData=[])
 actionGetVotedBy ()
 isAllowedVote ($isPerformAction=false)
 msgErrAllowedVote ()
 isAllowedVoteView ($isPerformAction=false)
 msgErrAllowedVoteView ()
 isAllowedVoteViewVoters ($isPerformAction=false)
 msgErrAllowedVoteViewVoters ()
- Public Member Functions inherited from BxDolObject
 init ($iId)
 getSystemId ()
 getSystemName ()
 getSystemInfo ()
 getId ()
 setId ($iId)
 isEnabled ()
 isPerformed ($iObjectId, $iAuthorId, $iAuthorIp=0)
 getVote ($iObjectId=0, $bForceGet=false)
 getTrack ($iObjectId, $iAuthorId)
 getConditions ($sMainTable, $sMainField)
 getConditionsTrack ($sMainTable, $sMainField, $iAuthorId=0)
 getSqlParts ($sMainTable, $sMainField)
 getSqlPartsTrack ($sMainTable, $sMainField, $iAuthorId=0)
 getSqlPartsTrackAuthor ($sMainTable, $sMainField, $iObjectId=0)
 addMarkers ($aMarkers)
 getElementAPI ($aParams=[])
 getCounterAPI ($aParams=[])
 getQueryObject ()
 checkAction ($sAction, $isPerformAction=false)
 checkActionErrorMsg ($sAction)
 onObjectDelete ($iObjectId=0)

Static Public Member Functions

static getObjectInstance ($sSys, $iId, $iInit=true, $oTemplate=false)
static & getSystems ()
static onAuthorDelete ($iAuthorId)
- Static Public Member Functions inherited from BxDolObject
static pruning ()

Protected Member Functions

 __construct ($sSystem, $iId, $iInit=true, $oTemplate=false)
 _isDuplicate ($iObjectId, $iAuthorId, $iAuthorIp, $bVoted)
 _isCount ($aVote=array())
 _isAllowedVoteByObject ($aObject)
 _getVoteData ()
 _putVoteData ($iObjectId, $iAuthorId, $iAuthorIp, $aData, $bPerformUndo)
 _returnVoteData ($iObjectId, $iAuthorId, $iAuthorIp, $aData, $bVoted, $aParams=[])
 _returnVoteDataForSocket ($aData, $aMask=[])
 _prepareRequestParamsData ($aParams, $aParamsAdd=array())
 _getVote ($iObjectId=0, $bForceGet=false)
 _isVote ($iObjectId=0, $bForceGet=false)
 _getTrack ($iObjectId, $iAuthorId)
 _getIconDo ($bVoted)
 _getTitleDo ($bVoted)
 _getTitleDoBy ($aParams=[])
 _useIconAs ($aParams=[])
- Protected Member Functions inherited from BxDolObject
 _getAuthorId ()
 _getAuthorPassword ()
 _getAuthorIp ()
 _getAuthorInfo ($iAuthorId=0)
 _getAuthorObject ($iAuthorId=0)
 _trigger ()
 _triggerValue ($iValue)
 _replaceMarkers ($mixed)
 _prepareParamsData ($aParams)
 _getRequestParamsData ($aKeys=array())
 _getTmplContentElementBlock ()
 _getTmplContentElementInline ()
 _getTmplContentDoAction ()
 _getTmplContentDoActionLabel ()
 _getTmplContentCounter ()
 _getTmplContentCounterLabel ()

Protected Attributes

- Protected Attributes inherited from BxDolObject
 $_oTemplate = null
 $_oQuery = null
 $_bApi = false
 $_iId = 0
 $_sSystem = ''
 $_aSystem = array()
 $_aMarkers = array ()
 $_sTmplContentElementBlock = ''
 $_sTmplContentElementInline = ''
 $_sTmplContentDoActionLabel = ''
 $_sTmplContentCounter = ''
 $_sTmplContentCounterLabel = ''

Detailed Description

Vote for any content

Related classes:

AJAX vote for any content. Stars and Plus based representations are supported.

To add vote section to your feature you need to add a record to 'sys_objects_vote' table:

  • ID - autoincremented id for internal usage
  • Name - your unique module name, with vendor prefix, lowercase and spaces are underscored
  • TableMain - table name where summary votigs are stored
  • TableTrack - table name where each vote is stored
  • PostTimeout - number of seconds to not allow duplicate vote
  • MinValue - min vote value, 1 by default
  • MaxValue - max vote value, 5 by default
  • IsUndo - is Undo enabled for Plus based votes
  • IsOn - is this vote object enabled
  • TriggerTable - table to be updated upon each vote
  • TriggerFieldId - TriggerTable table field with unique record id, primary key
  • TriggerFieldRate - TriggerTable table field with average rate
  • TriggerFieldRateCount - TriggerTable table field with votes count
  • ClassName - your custom class name, if you overrride default class
  • ClassFile - your custom class path

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

Example of usage

To get Star based vote you need to have different values for MinValue and MaxValue (for example 1 and 5) and IsUndo should be equal to 0. To get Plus(Like) based vote you need to have equal values for MinValue and MaxValue (for example 1) and IsUndo should be equal to 1. After filling the other paramenters in the table you can show vote in any place, using the following code:

$o = BxDolVote::getObjectInstance('system object name', $iYourEntryId);
if (!$o->isEnabled()) return '';
echo $o->getElementBlock();
static getObjectInstance($sSys, $iId, $iInit=true, $oTemplate=false)
Definition BxDolVote.php:105


  • vote


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

Constructor & Destructor Documentation

◆ __construct()

BxDolVote::__construct ( $sSystem,
$iInit = true,
$oTemplate = false )

Reimplemented from BxDolObject.

Member Function Documentation

◆ _getIconDo()

BxDolVote::_getIconDo ( $bVoted)

Reimplemented in BxPollsVoteSubentries.

◆ _isAllowedVoteByObject()

BxDolVote::_isAllowedVoteByObject ( $aObject)

Reimplemented in BxBaseModTextVotePollAnswers.

◆ _isDuplicate()

BxDolVote::_isDuplicate ( $iObjectId,
$bVoted )

Internal functions

Reimplemented in BxDolVoteLikes, BxDolVoteReactions, and BxDolVoteStars.

◆ _isVote()

BxDolVote::_isVote ( $iObjectId = 0,
$bForceGet = false )

Reimplemented in BxDolVoteReactions.

◆ _prepareRequestParamsData()

BxDolVote::_prepareRequestParamsData ( $aParams,
$aParamsAdd = array() )

Reimplemented from BxDolObject.

◆ actionVote()

BxDolVote::actionVote ( )

Actions functions

◆ getObjectInstance()

static BxDolVote::getObjectInstance ( $sSys,
$iInit = true,
$oTemplate = false )

get votes object instanse

$sSysvote object name
$iIdassociated content id, where vote is available
$iInitperform initialization
null on error, or ready to use class instance

◆ getSystems()

static & BxDolVote::getSystems ( )

Reimplemented from BxDolObject.

◆ isAllowedVote()

BxDolVote::isAllowedVote ( $isPerformAction = false)

◆ isUndo()

BxDolVote::isUndo ( )

Interface functions for outer usage

◆ vote()

BxDolVote::vote ( $aVoteData = [],
$aRequestParamsData = [] )


'vote', 'undo' - hook on cancel vote

  • $unit_name - equals vote
  • $action - equals undo
  • $object_id - vote id
  • $sender_id - profile_id for vote's author
  • $extra_params - array of additional params with the following array keys:


'vote', 'do' - hook on new vote

  • $unit_name - equals vote
  • $action - equals do
  • $object_id - vote id
  • $sender_id - profile_id for vote's author
  • $extra_params - array of additional params with the following array keys:
    • object_system - [string] system name, ex: bx_posts
    • object_id - [int] reported object id
    • object_author_id - [int] author's profile_id for reported object_id
      'vote', 'do' - hook on new vote

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