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.
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.
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.
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/entry 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.
Description
These plugins are triggered in CompetitionModelAppform::save
(site). If the plugin returns false
for onAppformBeforeSaveTransactionCommit
event then the entry 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 entry form, false otherwise.
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 contest object.
Description
These plugins are triggered in CompetitionModelCompetition::delete
(admin). If the plugin returns false
for onCompetitionBeforeDelete
event then the contest 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.
Description
These events are triggered in CompetitionModelCompetition::save
(admin). If the plugin returns false
for onCompetitionBeforeSave
event then the contest 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 contest, false otherwise./
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.
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.
Description
These events are triggered in entry's view. Read more about the practical usage in Using content plugins on entry 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 entry'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.
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.
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.
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.
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 entry object.
Description
These events are triggered in CompetitionModelParticipant::delete
(admin). If the plugin returns false
for onParticipantBeforeDelete
event then the entry 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.
Description
These plugins are triggered in CompetitionModelAppform::saveParticipant
(site) and CompetitionModelParticipant::save
(admin). If the plugin returns false
for onParticipantBeforeSave
event then the entry 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 entry, false otherwise.
Description
These plugins are triggered in CompetitionModeParticipant::save
(admin). If the plugin returns false
for onParticipantBeforeSaveTransactionCommit
event then the entry 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 entry form data.
$isNew
- true for new entry, false otherwise.
Description
This event is triggered in CompetitionModelParticipant::getVoteData
(site) and allows to modify the maximum allowed votes for contest. 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 entry ID.
$competition
- a contest object.
&$allowedVotes
- allowed contest votes.
Description
This event is triggered in CompetitionModelParticipant::getVoteData
(site) and allows to modify the maximum allowed votes per entry. 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 entry ID.
$competition
- a reference to contest object.
&$allowedVotes
- allowed entry votes.
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 entry ID.
$competition
- a reference to contest object.
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.
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 entry.
$value
- the value of the state: -2 - deleted; 0 - unpublished; 1 - published.
Description
This event is triggered in CompetitionModelParticipant::publish
(admin) after entry 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.
Description
This event is triggered in CompetitionModelParticipant::approve
(admin) before entry 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 entry table object.
$value
- the value of the state: 0 - unapproved; 1 - approved.
Description
This event is triggered in CompetitionModelParticipant::approve
(admin) after the entry 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.
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.
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.
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.
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.