-
Notifications
You must be signed in to change notification settings - Fork 5
extending_jcommunity
The module is usable without modifying it. However, perhaps you would like to extends forms, to do things during the registration etc.
You should not directly modify files of the module ! Use the features of Jelix which allow to "overload" files. Read the Jelix manual
Here are the details that work at least with jCommunity 0.3.
Perhaps you would like to add additionnal fields in the registration form.
First copy the registration.form.xml file into your var/overloads/jcommunity/forms/ and modify it by adding your specific fields.
If you need to initialize values in this new fields, before the display of the form, create an event handler for the event jcommunity_registration_init_form. With this event, you could access to the form and the template through the event parameters "form" and "tpl".
Many events are sent by jcommunity during many actions. Here are some skeleton of event listeners you can implements.
class mymodulecommunityListener extends jEventListener{
/**
* initialisation of the form before its display or before
* the save.
* event parameter:
* - form jFormsBase
* - tpl jTpl the template; given only before the display
*/
function onjcommunity_registration_init_form ($event) {
}
/**
* opportunity to prepare the user record before its save
* event parameter:
* - form jFormsBase
* - user user record
* event response:
* - errorRegistration: error message if there is an error
*/
function onjcommunity_registration_prepare_save ($event) {
}
/**
* the user has just been saved
* event parameter:
* - user user record
*/
function onAuthNewUser ($event) {
}
/**
* the user is saved now. It is almost the same
* event as AuthNewUser, but you have the form object as
* an additionnal parameter.
* event parameter:
* - form jFormsBase
* - user user record
*/
function onjcommunity_registration_after_save ($event) {
}
/**
* registration has been confirmed automatically or by the user
* you can update the user object (or other things), it will be then
* saved by jCommunity
* event parameter:
* - user user record
*/
function onjcommunity_registration_confirm ($event) {
}
}
class mymoduleaccountcommunityListener extends jEventListener{
/**
* initialisation of the template before the display of details account
* event parameter:
* - login string the login of the user
* - user object the user record
* - tpl jTpl the template used to show details of the account
*/
function onjcommunity_account_show ($event) {
}
/**
* opportunity to prepare the form to edit details of the user account,
* .
* Called:
* - before the load of the user data, during the creation of the form
* - before its display
* - during the save, just before retrieving submitted data
* event parameter:
* - form jFormsBase
* - login string user login
*/
function onjcommunity_init_edit_form_account ($event) {
}
/**
* opportunity to initialize the form to edit details of the user account,
* after the load of the user data into the form
* event parameter:
* - form jFormsBase
* - login string user login
*/
function onjcommunity_prepare_edit_account ($event) {
}
/**
* opportunity to initialize the display of the forme to edit details of the user account,
* event parameter:
* - form jFormsBase
* - login string user login
* - rep: jresponse the html response used to display the page
* - tpl: jTpl the template to display the form
*/
function onjcommunity_edit_account ($event) {
}
/**
* opportunity to check data from the form, before the save of data.
* add error into the form if you want to cancel the save
* event parameter:
* - form jFormsBase
* - login string user login
*/
function onjcommunity_check_before_save_account ($event) {
}
/**
* user data are ok, and will be saved. you can do additional data process
* on the dao object before the save
* event parameter:
* - record: user dao record
* - login: user login
* - form: jFormsBase
* - factory: dao factory
* - to_insert: false if this is an update (always the case in fact)
*/
function onjcommunity_save_account ($event) {
}
/**
* event sent before the deletion of an account.
*event parameter:
* - login: the login of the account to delete
*event response:
* - canremove : true if the account can be deleted
*/
function onAuthCanRemoveUser ($event) {
}
/**
* an account has been deleted.
* event parameter:
* - login: the login of the user
* - user: the dao record (invalid)
*/
function onAuthRemoveUser ($event) {
}
}
class mymodulelogincommunityListener extends jEventListener{
/**
* initialisation of the form before its display or before
* the save.
* event parameter:
* - login
*/
function onAuthBeforeLogin ($event) {
}
/**
*
* event parameter:
* - login
* - user
* event response
* - canlogin true if ok
*/
function onAuthCanLogin ($event) {
}
/**
*
* event parameter:
* - login
* - persistence
*/
function onAuthLogin ($event) {
}
/**
*
* event parameter:
* - login
*/
function onAuthErrorLogin ($event) {
}
/**
*
* event parameter:
* - login
*/
function onAuthLogout ($event) {
}
}