UNA
Loading...
Searching...
No Matches
BxDolScore Class Reference
Inheritance diagram for BxDolScore:
BxDolObject BxDolFactory iBxDolReplaceable BxBaseScore BxTemplScore BxDolCmtsScore BxMarketScore BxBaseCmtsScore BxTemplCmtsScore

Public Member Functions

 isPerformed ($iObjectId, $iAuthorId, $iAuthorIp=0)
 
 getObjectAuthorId ($iObjectId=0)
 
 isUndo ()
 
 getStatCounterUp ()
 
 getStatCounterDown ()
 
 getStatScore ()
 
 getSocketName ()
 
 actionVoteUp ()
 
 actionVoteDown ()
 
 actionGetVotedBy ()
 
 vote ($aVoteData=[], $aRequestParamsData=[])
 
 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 ()
 
 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)
 
 _isAllowedVoteByObject ($aObject)
 
 _putVoteData ($iObjectId, $iAuthorId, $iAuthorIp, $aData, $bPerformUndo)
 
 _returnVoteDataForSocket ($aData, $aMask=[])
 
 _getVote ($iObjectId=0, $bForceGet=false)
 
 _isVote ($iObjectId=0, $bForceGet=false)
 
 _isCount ($aScore=[])
 
 _getTrack ($iObjectId, $iAuthorId)
 
 _getImageDo ($sType)
 
 _getIconDo ($sType='')
 
 _getTitleDo ($sType)
 
 _getTitleDoBy ()
 
 _encodeElementParams ($aParams)
 
 _decodeElementParams ($sParams, $bMergeWithDefaults=true)
 
- 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())
 
 _prepareRequestParamsData ($aParams, $aParamsAdd=array())
 
 _getTmplContentElementBlock ()
 
 _getTmplContentElementInline ()
 
 _getTmplContentDoAction ()
 
 _getTmplContentDoActionLabel ()
 
 _getTmplContentCounter ()
 
 _getTmplContentCounterLabel ()
 

Protected Attributes

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

Detailed Description

Score 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 = BxDolScore::getObjectInstance('system object name', $iYourEntryId);
if (!$o->isEnabled()) return '';
echo $o->getElementBlock();
static getObjectInstance($sSys, $iId, $iInit=true, $oTemplate=false)
Definition BxDolScore.php:103

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

Constructor & Destructor Documentation

◆ __construct()

BxDolScore::__construct ( $sSystem,
$iId,
$iInit = true,
$oTemplate = false )
protected

Reimplemented from BxDolObject.

Member Function Documentation

◆ _getImageDo()

BxDolScore::_getImageDo ( $sType)
protected

Note. By default image based controls aren't used. Therefore it can be overwritten in custom template.

◆ _isAllowedVoteByObject()

BxDolScore::_isAllowedVoteByObject ( $aObject)
protected

Internal functions

Reimplemented in BxDolCmtsScore.

◆ actionVoteUp()

BxDolScore::actionVoteUp ( )

Actions functions

◆ getObjectInstance()

static BxDolScore::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

◆ getSystems()

static & BxDolScore::getSystems ( )
static

Reimplemented from BxDolObject.

◆ isAllowedVote()

BxDolScore::isAllowedVote ( $isPerformAction = false)

Permissions functions

Reimplemented in BxMarketScore.

◆ isPerformed()

BxDolScore::isPerformed ( $iObjectId,
$iAuthorId,
$iAuthorIp = 0 )

Reimplemented from BxDolObject.

◆ isUndo()

BxDolScore::isUndo ( )

Interface functions for outer usage

◆ vote()

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

Hooks:

'{object_name}', 'doVoteUp' - hook after score vote

  • $unit_name - score object name
  • $action - equals doVoteUp
  • $object_id - object id which got a vote
  • $sender_id - profile id who voted
  • $extra_params - array of additional params with the following array keys:

Hooks:

'{object_name}', 'doVoteDown' - hook after score vote

It's equivalent to '{object_name}', 'doVoteUp' - hook after score vote

HOOKS
'{object_name}', 'doVoteDown' - hook after score vote

Hooks:

'{object_name}', 'undoVoteUp' - hook after undo score vote

It's equivalent to '{object_name}', 'doVoteUp' - hook after score vote

HOOKS
'{object_name}', 'undoVoteUp' - hook after undo score vote

Hooks:

'{object_name}', 'undoVoteDown' - hook after undo score vote

It's equivalent to '{object_name}', 'doVoteUp' - hook after score vote

HOOKS
'{object_name}', 'undoVoteDown' - hook after undo score vote

Hooks:

'score', 'doUp' - hook after score vote

  • $unit_name - equals score
  • $action - equals doUp
  • $object_id - score vote id
  • $sender_id - profile id who voted
  • $extra_params - array of additional params with the following array keys:

Hooks:

'score', 'doDown' - hook after score vote

It's equivalent to 'score', 'doUp' - hook after score vote

HOOKS
'score', 'doDown' - hook after score vote

Hooks:

'score', 'undoUp' - hook after undo score vote

It's equivalent to 'score', 'doUp' - hook after score vote

HOOKS
'score', 'undoUp' - hook after undo score vote

Hooks:

'score', 'undoDown' - hook after undo score vote

It's equivalent to 'score', 'doUp' - hook after score vote

HOOKS
'score', 'undoDown' - hook after undo score vote

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