Events

Plugins are the powerful way of extending the functionality of NorrCompetition and allow other extensions to respond to NorrCompetition actions.

You can read more about the plugins in Joomla! CMS here.

The plugin group for all events in NorrCompetition is 'competition'.

Below is the list of available events.

Appform

onAppformDisplay

Description
This event is triggered in CompetitionViewAppform::display (site).

public function onAppformDisplay($context, $item)
{
    // Do something
}

Arguments
$context - the context of the event, ‘com_competition.appform’.
$item - the appform object.

onAppformBeforeFieldsAjaxDisplay

Description
This event is triggered in CompetitionControllerAppform::ajaxGetCustomFields (site).

public function onAppformBeforeFieldsAjaxDisplay($context, &$fields, $competition)
{
    // Do something
}

Arguments
$context - the context of the event, ‘com_competition.appform’.
&$fields - the fields array.
$item - the competition object.

onAppformBeforeSave

onAppformAfterSave

Description
These events are triggered in CompetitionModelAppform::save (site) and in CompetitionModelParticipant::saveAppform (admin). If the plugin returns false for onAppformBeforeSave event then the application form / participant is not being saved to the database and transaction is rolled back.

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

Arguments
$context - the context of the event: ‘com_competition.appform’ or ‘com_competition.participant’.
$table - a reference to CompetitionTableAppform object.
$isNew - true for new application form, false otherwise.

onAppformBeforeSaveTransactionCommit

onAppformAfterSaveTransactionCommit

Description
These plugins are triggered in CompetitionModelAppform::save (site). If the plugin returns false for onAppformBeforeSaveTransactionCommit event then the application form is not being saved and transaction is rolled back.

Please note that onAppformAfterSave event is triggered inside the transaction that can be rolled back. To make sure that all the data is saved use the *AfterSaveTransactionCommit event.

public function onAppformBeforeSaveTransactionCommit($context, $data, $isNew)
{
    // Abort save
    return false;
}

Arguments
$context - the context of the event, ‘com_competition.appform’.
$data - an array of validated application form data.
$isNew - true for new application form, false otherwise.

Competition

onCompetitionDisplay

Description
This event is triggered in CompetitionViewCompetition::display (site).

public function onCompetitionDisplay($context, $item)
{
    // Do something
}

Arguments
$context - the context of the event, ‘com_competition.competition’.
$item - the competition object.

onCompetitionBeforeDelete

onCompetitionAfterDelete

Description
These plugins are triggered in CompetitionModelCompetition::delete (admin). If the plugin returns false for onCompetitionBeforeDelete event then the competition is not being deleted.

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

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

onCompetitionBeforeSave

onCompetitionAfterSave

Description
These events are triggered in CompetitionModelCompetition::save (admin). If the plugin returns false for onCompetitionBeforeSave event then the competition is not being saved to the database.

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

Arguments
$context - the context of the event, ‘com_competition.competition’.
$table - a reference to CompetitionTableCompetition object.
$isNew - true for new competition, false otherwise./

onCompetitionChangeState

Description
Is triggered in CompetitionModelCompetition::publish (admin) after field has its state changed.

public function onCompetitionChangeState($context, $pks, $value)
{
    // Do something
    return;
}

Arguments
$context - the context of the event, ‘com_competition.competition’.
$pks - a list of the primary keys to change.
$value - the value of the state: -2 - deleted; 0 - unpublished; 1 - published.

Content

onContentPrepareForm

Description
This event is triggered in loadForm method of all form models.

public function onContentPrepareForm(JForm $form, $data)
{
    // Do something
    return;
}

Arguments
$form - a JForm object.
$data - the data that should be bind to the form.

To check the context of the event you can use the name of the form like com_competition.appform, com_competition.filed etc.

onContentPrepare

onContentAfterTitle

onContentBeforeDisplay

onContentAfterDisplay

Description
These events are triggered in participant’s view. Read more about the practical usage in Using content plugins on participant's page document.

public function onContentAfterDisplay($context, $item, $params, $page = 0)
{
    // Do something
    return;
}

Arguments
$context - the context of the event, ‘com_competition.participant’
$item - a reference to the participant’s object that is being rendered by the view..
$params - a Joomla\Registry\Registry object containg parametres.
$page - not used and is passed for consistency. Always 0.

$item->text property contains the tags of plugins that are specified in General parameters of NorrCompetition.

Field

onFieldBeforeDelete

onFieldAfterDelete

Description
These events are triggered in CompetitionModelField::delete (admin). If the plugin returns false for onFieldBeforeDelete event then the field is not being deleted.

public function onFieldBeforeDelete($context, $table)
{
    // Do something and abort delete
    return false;
}

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

onFieldBeforeSave

onFieldAfterSave

Description
These events are triggered in CompetitionModelField::save (admin). If the plugin returns false for onFieldBeforeSave event then the filed is not being saved to the database.

public function onFieldAfterSave($context, $table, $isNew)
{
    // Do something
    return;
}

Arguments
$context - the context of the event, ‘com_competition.field’.
$table - a reference to CompetitionTableField object.
$isNew - true for new field, false otherwise.

onFieldChangeState

Description
This evenr is triggered in CompetitionModeField::publish (admin) after field has its state changed.

public function onFieldChangeState($context, $pks, $value)
{
    // Do something
    return;
}

Arguments
$context - the context of the event, ‘com_competition.field’.
$pks - a list of the primary keys to change.
$value - the value of the state.

Participant

onParticipantDisplay

Description
This event is triggered in CompetitionViewParticipant::display (site).

public function onParticipantDisplay($context, $item)
{
    // Do something
}

Arguments
$context - the context of the event, ‘com_competition.participant’.
$item - the participant object.

onParticipantBeforeDelete

onParticipantAfterDelete

Description
These events are triggered in CompetitionModelParticipant::delete (admin). If the plugin returns false for onParticipantBeforeDelete event then the participant is not being deleted.

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

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

onParticipantBeforeSave

onParticipantAfterSave

Description
These plugins are triggered in CompetitionModelAppform::saveParticipant (site) and CompetitionModelParticipant::save (admin). If the plugin returns false for onParticipantBeforeSave event then the participant is not being saved to the database and transaction is rolled back.

Please note that onParticipantAfterSave event is triggered inside the transaction that can be rolled back. To make sure that all the data is saved use the *AfterSaveTransactionCommit event.

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

Arguments
$context - the context of the event: ‘com_competition.participant’ or ‘com_competition.appform’.
$table - a reference to CompetitionTableParticipant object.
$isNew - true for new participant, false otherwise.

onParticipantBeforeSaveTransactionCommit

onParticipantAfterSaveTransactionCommit

Description
These plugins are triggered in CompetitionModeParticipant::save (admin). If the plugin returns false for onParticipantBeforeSaveTransactionCommit event then the participant is not being saved to the database and transaction is rolled back.

public function onParticipantBeforeSaveTransactionCommit($context, $data, $isNew)
{
    // Abort save and all transaction
    return false;
}

Arguments
$context - the context of the event, ‘com_competition.participant’.
$data - the validated participant form data.
$isNew - true for new participant, false otherwise.

onParticipantAllowedCompetitionVotes

Description
This event is triggered in CompetitionModelParticipant::getVoteData (site) and allows to modify the maximum allowed votes for competition. For example to provide additional votes for a user.

public function onParticipantAllowedCompetitionVotes($context, $participantId, $competition, &$allowedVotes)
{
    // Set the allowed votes
    $allowedVotes = 2;

    return true;
}

Arguments
$context - the context of the event, ‘com_competition.participant’.
$participantId - the participant id.
$competition - a competition object.
&$allowedVotes - allowed competition votes.

onParticipantAllowedParticipantVotes

Description
This event is triggered in CompetitionModelParticipant::getVoteData (site) and allows to modify the maximum allowed votes per participant. For example to provide additional votes for a user.

public function onParticipantAllowedParticipantVotes($context, $participantId, $competition, &$allowedVotes)
{
    // Set the allowed votes
    $allowedVotes = 2;

    return true;
}

Arguments
$context - the context of the event, ‘com_competition.participant’.
$participantId - the participant id.
$competition - a reference to competition object.
&$allowedVotes - allowed participant votes.

onParticipantCheckVoteFrequency

Description
This event is triggered in CompetitionModelParticipant::getVoteData (site). If the plugin returns false then vote frequency check is being skipped. This allows to provide an immediate vote for a user.

public function onParticipantCheckVoteFrequency($context, $participantId, $competition)
{
    // Skip this check and allow to vote immediately
    return false;
}

Arguments
$context - the context of the event, ‘com_competition.participant’.
$participantId - the participant id.
$competition - a reference to competition object.

onParticipantBeforeVoteSave

onParticipantAfterVoteSave

Description
These events are triggered in CompetitionModelParticipant::vote (site). If the plugin returns false for onParticipantBeforeVoteSave event then the vote is not being saved to the database and error is being retruned to a user.

public function onParticipantBeforeVoteSave($context, $table, Registry $competitionParams)
{
    // Abort vote saving
    return false;
}

Arguments
$context - the context of the event, ‘com_competition.participant’.
$table - a reference to CompetitionTableVote object. $competitionParams - the parameters of competition in which a vote was taken.

onParticipantBeforeChangeState

Description
This event is triggered in CompetitionModelParticipant::publish (admin) before participant has its state changed.

public function onParticipantBeforeChangeState($context, $pk, $value)
{
    // Abort vote saving
    return false;
}

Arguments
$context - the context of the event, ‘com_competition.participant’.
$pk - the id of participant.
$value - the value of the state: -2 - deleted; 0 - unpublished; 1 - published.

onParticipantChangeState

Description
This event is triggered in CompetitionModelParticipant::publish (admin) after participant has its state changed.

public function onParticipantChangeState($context, $pks, $value)
{
    // Abort vote saving
    return false;
}

Arguments
$context - the context of the event, ‘com_competition.participant’.
$pks - a list of the primary keys to change.
$value - the value of the state: -2 - deleted; 0 - unpublished; 1 - published.

onParticipantBeforeApprove

Description
This event is triggered in CompetitionModelParticipant::approve (admin) before participant has its approval state changed.

public function onParticipantBeforeApprove($context, $table, $value)
{
    // Do something
}

Arguments
$context - the context of the event, ‘com_competition.participant’.
$table - the participant table object.
$value - the value of the state: 0 - unapproved; 1 - approved.

onParticipantApprove

Description
This event is triggered in CompetitionModelParticipant::approve (admin) after participant has its approval state changed.

public function onParticipantApprove($context, $pks, $value)
{
    // Do something
    return;
}

Arguments
$context - the context of the event, ‘com_competition.participant’.
$item - a list of the primary keys to change.
$params - the value of the state: 0 - unapproved; 1 - approved.

User

onUserAuthorise

Description
This event can be triggered anyway in the component and allows the plugins to override JUser::authorise result in case it is not true. If the plugin returns true then action is allowed. Currently plugins can override only core.vote action.

public function onUserAuthorise(JUser $user, $action, $assetname)
{
    // Allow action
    return;
}

Arguments
$user - a reference to JUser object.
$action - the name of the action to check for permission.
$assetname - the name of the asset on which to perform the action.

Vote

onVoteBeforeDelete

onVoteAfterDelete

Description
These events are triggered in CompetitionModelVote::delete (admin). 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.