Extension talk:AWCmod

From Organic Design wiki

Installation

Create a directory in your extensions directory called AWCmod and put both scripts into it (AWCmod.php and states.php), also create a subdirectory in there called images which PHP has permission to create and modify files in (this is where the profile images get uploaded to).

Include the extension the normal way after the include of the AWCforum extension, for example: <php> include("$IP/extensions/awc/forums/awc_forum.php"); include("$IP/extensions/AWCmod/AWCmod.php"); </php>

Add some CSS rules into your MediaWiki:Common.css article for the sortable tables and profile info box, for example: <css> table.sortable { background-color: #f4f4f4; } table.sortable tr.odd { background-color: white; } table.sortable td, table.sortable th { padding: 0 4px; margin: 0; } table.sortable th { text-align: center; } table.sortable td { overflow: hidden; white-space: nowrap; font-size: 8pt; } .userprofile { padding: 5px; background-color: #f0f0f0; border: 1px solid #ccc; } .userprofile th { padding: 0 5px; } </css>

Usage

  • $awcDefaultImage set this to the path of the image to use if no profile image has been uploaded
  • $awcMaxImageSize set this to the maximum size in bytes that a profile image is allowed to be (default 100000)

forum_search tag

The account creation and preferences forms have some of the new fields added for testing. Their new values save into the database and can then be used in AWC forum-post searches.

Here's an example of using the forum_search tag to create a link to a search for all posts from users having the zip code of 123456.

<forum_search zipcode=123456>Posts from zipcode 1234546</forum_search>

The following one refines the search by also requiring the posts to match a search keyword of "foo":

<forum_search zipcode=123456 kw=foo>Foo posts from zipcode 123456</forum_search>

You can add any number of conditions which will be ANDed - ie all the conditions supplied act as filters. Any of the users preferences can be included such as phone or even skin etc. The native AWC conditions which are accepted in the tag are as follows:

profile_search tag

<profile_search expertise=Lawyer state=Iowa>Lawyers in Iowa</profile_search>

Notes for second phase of development (in progress)

General

  • Modify email message language file(s) to indicate functionality above, text to encourage them to A) Confirm Email and B) go to Extended Profile to complete additional information after signup.
  • Dump the extension to the create-account form
  • Require email address confirmation to register (unconfirmed users are treated as unregistered as far as perms go)

Profile extension

  • Resort Extended Profile fields per Client Specification
  • Extended Profile Logo and Values will show up in User Page.
  • Handle image upload (to AWCmod/userid.xxx)
  • Include Client Supplied text for information on top of the extended profile.
  • Rename tab to Extended Profile

User search

  • New tag for creating links to searches
  • Form ("If nobody, nobody in your area has created a profile, refine your search by")
  • Specialpage for searching and rendering results
  • Search parameters via URL or form
  • Sortable table for results

Notes for first phase of development (done)

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