UNA
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

 isUndo ()
 
 actionVote ()
 
 isAllowedVote ($isPerformAction=false)
 
- Public Member Functions inherited from BxDolObject
 getConditions ($sMainTable, $sMainField)
 
 getQueryObject ()
 
 checkAction ($sAction, $isPerformAction=false)
 
 onObjectDelete ($iObjectId=0)
 

Static Public Member Functions

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

Protected Member Functions

 _isDuplicate ($iObjectId, $iAuthorId, $iAuthorIp, $bVoted)
 
- Protected Member Functions inherited from BxDolObject
 _getAuthorId ()
 
 _trigger ()
 
 _triggerValue ($iValue)
 
 _replaceMarkers ($mixed)
 

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();

Memberships/ACL:

  • vote

Alerts(hooks)

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

Member Function Documentation

◆ _isDuplicate()

BxDolVote::_isDuplicate (   $iObjectId,
  $iAuthorId,
  $iAuthorIp,
  $bVoted 
)
protected

Internal functions

◆ actionVote()

BxDolVote::actionVote ( )

Actions functions

◆ getObjectInstance()

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

get votes object instanse

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

◆ isAllowedVote()

BxDolVote::isAllowedVote (   $isPerformAction = false)

Permissions functions

◆ isUndo()

BxDolVote::isUndo ( )

Interface functions for outer usage


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