|
Moodle
2.2.1
http://www.collinsharper.com
|

Public Member Functions | |
| __construct ($name, $options=array()) | |
| exclude ($arrayofuserids) | |
| clear_exclusions () | |
| get_exclusions () | |
| get_selected_users () | |
| get_selected_user () | |
| invalidate_selected_users () | |
| display ($return=false) | |
| set_rows ($numrows) | |
| get_rows () | |
| set_multiselect ($multiselect) | |
| is_multiselect () | |
| get_name () | |
| set_extra_fields ($fields) | |
| find_users ($search) | |
| output_user ($user) | |
Protected Member Functions | |
| get_options () | |
| is_validating () | |
| load_selected_users () | |
| required_fields_sql ($u) | |
| search_sql ($search, $u) | |
| too_many_results ($search, $count) | |
| output_options ($groupedusers, $search) | |
| output_optgroup ($groupname, $users, $select) | |
| search_button_caption () | |
| initialise_javascript ($search) | |
Protected Attributes | |
| $name | |
| $extrafields | |
| $accesscontext | |
| $multiselect = true | |
| $rows = USER_SELECTOR_DEFAULT_ROWS | |
| $exclude = array() | |
| $selected = null | |
| $preserveselected = false | |
| $autoselectunique = false | |
| $searchanywhere = false | |
| $validatinguserids = null | |
Static Protected Attributes | |
| static | $jsmodule |
Base class for user selectors.
In your theme, you must give each user-selector a defined width. If the user selector has name="myid", then the div myid_wrapper must have a width specified.
| __construct | ( | $ | name, |
| $ | options = array() |
||
| ) |
Constructor. Each subclass must have a constructor with this signature.
| string | $name | the control name/id for use in the HTML. |
| array | $options | other options needed to construct this selector. You must be able to clone a userselector by doing new get_class($us)($us->get_name(), $us->get_options()); |
Reimplemented in forum_potential_subscriber_selector, forum_subscriber_selector_base, existing_role_holders, role_assign_user_selector_base, groups_user_selector_base, mnetservice_enrol_potential_users_selector, mnetservice_enrol_existing_users_selector, cohort_existing_selector, cohort_candidate_selector, enrol_manual_current_participant, service_user_selector, and enrol_manual_potential_participant.
Definition at line 90 of file lib.php.

| clear_exclusions | ( | ) |
| display | ( | $ | return = false | ) |
Output this user_selector as HTML.
| boolean | $return | if true, return the HTML as a string instead of outputting it. |
Definition at line 196 of file lib.php.


| exclude | ( | $ | arrayofuserids | ) |
All to the list of user ids that this control will not select. For example, on the role assign page, we do not list the users who already have the role in question.
| array | $arrayofuserids | the user ids to exclude. |
Definition at line 132 of file lib.php.

| find_users | ( | $ | search | ) | [abstract] |
Search the database for users matching the $search string, and any other conditions that apply. The SQL for testing whether a user matches the search string should be obtained by calling the search_sql method.
This method is used both when getting the list of choices to display to the user, and also when validating a list of users that was selected.
When preparing a list of users to choose from ($this->is_validating() return false) you should probably have an maximum number of users you will return, and if more users than this match your search, you should instead return a message generated by the too_many_results() method. However, you should not do this when validating.
If you are writing a new user_selector subclass, I strongly recommend you look at some of the subclasses later in this file and in admin/roles/lib.php. They should help you see exactly what you have to do.
| string | $search | the search string. |
Reimplemented in forum_existing_subscriber_selector, forum_potential_subscriber_selector, admins_existing_selector, admins_potential_selector, existing_role_holders, potential_assignees_course_and_above, potential_assignees_below_course, group_non_members_selector, group_members_selector, mnetservice_enrol_potential_users_selector, mnetservice_enrol_existing_users_selector, cohort_existing_selector, cohort_candidate_selector, enrol_manual_current_participant, service_user_selector, and enrol_manual_potential_participant.

| get_exclusions | ( | ) |
| get_name | ( | ) |
| get_options | ( | ) | [protected] |
Note: this function must be implemented if you use the search ajax field (e.g. set $options['file'] = '/admin/filecontainingyourclass.php';)
Reimplemented in forum_potential_subscriber_selector, forum_subscriber_selector_base, admins_existing_selector, admins_potential_selector, role_assign_user_selector_base, groups_user_selector_base, mnetservice_enrol_potential_users_selector, mnetservice_enrol_existing_users_selector, cohort_existing_selector, cohort_candidate_selector, enrol_manual_current_participant, service_user_selector, and enrol_manual_potential_participant.
Definition at line 341 of file lib.php.

| get_rows | ( | ) |
Definition at line 155 of file lib.php.


| initialise_javascript | ( | $ | search | ) | [protected] |
If you update the database in such a way that it is likely to change the list of users that this component is allowed to select from, then you must call this method. For example, on the role assign page, after you have assigned some roles to some users, you should call this.
| is_multiselect | ( | ) |
| is_validating | ( | ) | [protected] |
| load_selected_users | ( | ) | [protected] |
| output_optgroup | ( | $ | groupname, |
| $ | users, | ||
| $ | select | ||
| ) | [protected] |
Output one particular optgroup. Used by the preceding function output_options.
| string | $groupname | the label for this optgroup. |
| array | $users | the users to put in this optgroup. |
| boolean | $select | if true, select the users in this group. |
Definition at line 568 of file lib.php.


| output_options | ( | $ | groupedusers, |
| $ | search | ||
| ) | [protected] |
Output the list of <optgroup>s and <options>s that go inside the select. This method should do the same as the JavaScript method user_selector.prototype.handle_response.
| array | $groupedusers | an array, as returned by find_users. |
Definition at line 520 of file lib.php.


| output_user | ( | $ | user | ) |
Convert a user object to a string suitable for displaying as an option in the list box.
| object | $user | the user to display. |
Reimplemented in group_non_members_selector.
Definition at line 596 of file lib.php.

| required_fields_sql | ( | $ | u | ) | [protected] |
| search_button_caption | ( | ) | [protected] |
| search_sql | ( | $ | search, |
| $ | u | ||
| ) | [protected] |
| string | $search | the text to search for. |
| string | $u | the table alias for the user table in the query being built. May be ''. |
Definition at line 430 of file lib.php.


| set_extra_fields | ( | $ | fields | ) |
| set_multiselect | ( | $ | multiselect | ) |
| set_rows | ( | $ | numrows | ) |
| too_many_results | ( | $ | search, |
| $ | count | ||
| ) | [protected] |
Used to generate a nice message when there are too many users to show. The message includes the number of users that currently match, and the text of the message depends on whether the search term is non-blank.
| string | $search | the search term, as passed in to the find users method. |
| int | $count | the number of users that currently match. |
Definition at line 499 of file lib.php.

$jsmodule [static, protected] |
array( 'name' => 'user_selector', 'fullpath' => '/user/selector/module.js', 'requires' => array('node', 'event-custom', 'datasource', 'json'), 'strings' => array( array('previouslyselectedusers', 'moodle', '%%SEARCHTERM%%'), array('nomatchingusers', 'moodle', '%%SEARCHTERM%%'), array('none', 'moodle') ))
$rows = USER_SELECTOR_DEFAULT_ROWS [protected] |