Extension talk:AWCmod
Contents
New preference tab
- Add a new preference sheet
- Store new items as new user-attributes in users existing table
The InitPreferencesForm hook is called at the end of the form constructor and is passed with the PreferencesForm and Request objects
The main form rendering is done from the mainPrefsForm method
- PreferencesUserInformationPanel( $this, &$userInformationHtml )
Saving new preferences
the savePreferences method calls the SavePreferences hook which passes the PreferencesForm, User and an error message string.
- It should return false for no error condition.
- It then calls $wgUser->saveSettings() so its up to that hook to add the prefs to the User object's mOptions array using setOption
- getOption, getBoolOption, getIntOption, setOption
- encodeOptions - returns a string of k=v\n from the User::mOptions array
- decodeOptions - puts the passed options string into the User::mOptions array
- saveSettings - save the options and other state into the database (runs UserSaveSettings hook after db update)
- loadDefaults - calls the UserLoadDefaults passing the user object
Reset Preferences
There is also a ResetPreferences hook called with the PreferencesForm and User objects.
Account creation form
Rather than a redirect to the preferences page, the form of extra prefs would be best supplied in the login form as well.
All add account methods call the addNewAccountInternal method, then calls the AbortNewAccount hook, and then calls User::saveSettings, and then calls the AddNewAccount hook is called with the User object passed.
Adding fields to the form
For form rendering, the mainLoginForm method calls the UserCreateForm hook passing the form template. templates/Userlogin.php defines the UsercreateTemplate which extends QuickTemplate. The form can be adjusted via the template's data['header'] property.
Save new preferences
The best hook to use for this is the AbortNewAccount because it occurs before the user options are saved to the database