Vote

onVoteBeforeDelete

onVoteAfterDelete

Description These events are triggered in CompetitionModelVote::delete (site - on unvote; admin - on vote delete). If the plugin returns false for onVoteBeforeDelete event then the vote is not being deleted.

public function onVoteBeforeDelete($context, $table)
{
    // Do something
    return true;
}

Arguments $context - the context of the event, ‘com_competition.vote’. $table - a reference to CompetitionTableVote object.

onVoteSetScore

Description These event is triggered in CompetitionModelVote::setScore (site). It allows to provide own analytics and change the score and information for vote.

public function onVoteSetScore($context, $entryId, $trackingData, $params, $score)
{
    // Do some analytics
    $score['score']  = 1;
    $score['info'][] = 'I do not like you';
    
    // Do more analytics
    $score['score']  = 1;
    $score['info'][] = 'I am still do not like you :)';
    
    return;
}

Arguments $context - the context of the event, ‘com_competition.vote’. $entryId - ID of entry for which the vote is being processed. $trackingData - additional browser tracking data. $params - parameters of the contest. $score - array containing the score and info about the score.

onVoteSetValid

Description These event is triggered in CompetitionModelVote::setValid (site). It allows to provide own analytics and change the validity for vote: 0 - not valid, 1 - valid.

public function onVoteSetValid($context, $entryId, $trackingData, $params, &$valid)
{
    // Do some analytics
    $valid = 0;
    
    return;
}

Arguments $context - the context of the event, ‘com_competition.vote’. $entryId - ID of entry for which the vote is being processed. $trackingData - additional browser tracking data. $params - parameters of the contest. &$valid - the validity of the score.

onVoteBeforeSaveDetails

onVoteAfterSaveDetails

Description These events are triggered in CompetitionModelVote::saveDetails (site). It allows to provide own analytics and set own vote details. Also it is possible to set additional data: country and city (does not set by component).

public function onVoteBeforeSaveDetails($context, $table, $params)
{
    // Set city to London
    $table->country = 'UK';
    $table->city    = 'London';

    return;
}

Arguments $context - the context of the event, 'com_competition.vote'. $table - a reference to CompetitionTableVoteDetails object. $params - parameters of the contest.

Below is the list of vote details class properties:

/**
 * Vote details table class
 *
 * @property   integer  $id          Primary key
 * @property   integer  $vote_id     Vote ID
 * @property   string   $user_agent  User agent string
 * @property   string   $language    Browser language
 * @property   string   $timezone    User timezone
 * @property   string   $platform    User platform
 * @property   string   $scr_res     Screen resolution
 * @property   string   $canvas      Passed canvas or not
 * @property   string   $referrer    Referrer URL
 * @property   integer  $timediff    Time difference in milliseconds between entering the site and vote
 * @property   string   $country     Country of voter
 * @property   string   $city        City of voter
 */

onVoteResponse

Description These event is triggered in CompetitionControllerParticipant::ajaxVote (site). It allows to change the response data send back to user. For example, you can change a message that is displayed to a user.

public function onVoteResponse($context, $response)
{
	if ($context != 'com_competition.vote'
		|| !\Joomla\CMS\Factory::getApplication()->app->isClient('site'))
	{
		return;
	}

	$response->message = 'onVoteResponse is working fine';
}

Arguments $context - the context of the event, ‘com_competition.vote’. $response - response object holding vote data, response status and response message.

onUnvoteResponse

Description These event is triggered in CompetitionControllerParticipant::ajaxUnvote (site). It allows to change the response data send back to user. For example, you can change a message that is displayed to a user.

public function onUnvoteResponse($context, $response)
{
	if ($context != 'com_competition.vote'
		|| !\Joomla\CMS\Factory::getApplication()->app->isClient('site'))
	{
		return;
	}

	$response->message = 'onUnvoteResponse is working fine';
}

Arguments $context - the context of the event, ‘com_competition.vote’. $response - response object holding vote data, response status and response message.

Last updated