| [ Index ] |
PHP Cross Reference of Moodle 1.9.3 [Build 15-Oct-2008] |
[Source view] [Print] [Project Stats]
deprecatedlib.php - Old functions retained only for backward compatibility Old functions retained only for backward compatibility. New code should not use any of these functions.
| Author: | Martin Dougiamas |
| License: | http://www.gnu.org/copyleft/gpl.html GNU Public License |
| Version: | $Id: deprecatedlib.php,v 1.41.2.8 2008/06/01 13:21:17 skodak Exp $ |
| File Size: | 1679 lines (57 kb) |
| Included or required: | 0 times |
| Referenced: | 0 times |
| Includes or requires: | 0 files |
| require_variable($var) X-Ref |
| Ensure that a variable is set If $var is undefined throw an error, otherwise return $var. param: mixed $var the variable which may be unset param: mixed $default the value to return if $var is unset |
| optional_variable(&$var, $default=0) X-Ref |
| Ensure that a variable is set If $var is undefined set it (by reference), otherwise return $var. param: mixed $var the variable which may be unset param: mixed $default the value to return if $var is unset |
| nvl(&$var, $default='') X-Ref |
| Ensure that a variable is set Return $var if it is defined, otherwise return $default, This function is very similar to {@link optional_variable()} param: mixed $var the variable which may be unset param: mixed $default the value to return if $var is unset return: mixed |
| isadmin($userid=0) X-Ref |
| Determines if a user an admin param: int $userid The id of the user as is found in the 'user' table return: bool |
| isteacher($courseid=0, $userid=0, $obsolete_includeadmin=true) X-Ref |
| Determines if a user is a teacher (or better) param: int $courseid The id of the course that is being viewed, if any param: int $userid The id of the user that is being tested against. Set this to 0 if you would just like to test against the currently logged in user. param: bool $obsolete_includeadmin Not used any more return: bool |
| isteacherinanycourse($userid=0, $includeadmin=true) X-Ref |
| Determines if a user is a teacher in any course, or an admin param: int $userid The id of the user that is being tested against. Set this to 0 if you would just like to test against the currently logged in user. param: bool $includeadmin Include anyone wo is an admin as well return: bool |
| isteacheredit($courseid, $userid=0, $obsolete_ignorestudentview=false) X-Ref |
| Determines if a user is allowed to edit a given course param: int $courseid The id of the course that is being edited param: int $userid The id of the user that is being tested against. Set this to 0 if you would just like to test against the currently logged in user. return: bool |
| iscreator($userid=0) X-Ref |
| Determines if a user can create new courses param: int $userid The user being tested. You can set this to 0 or leave it blank to test the currently logged in user. return: bool |
| isstudent($courseid=0, $userid=0) X-Ref |
| Determines if a user is a student in the specified course If the course id specifies the site then this determines if the user is a confirmed and valid user of this site. param: int $courseid The id of the course being tested param: int $userid The user being tested. You can set this to 0 or leave it blank to test the currently logged in user. return: bool |
| isguest($userid=0) X-Ref |
| Determines if the specified user is logged in as guest. param: int $userid The user being tested. You can set this to 0 or leave it blank to test the currently logged in user. return: bool |
| enrol_student($userid, $courseid, $timestart=0, $timeend=0, $enrol='manual') X-Ref |
| Enrols (or re-enrols) a student in a given course NOTE: Defaults to 'manual' enrolment - enrolment plugins must set it explicitly. param: int $userid The id of the user that is being tested against. Set this to 0 if you would just like to test against the currently logged in user. param: int $courseid The id of the course that is being viewed param: int $timestart ? param: int $timeend ? param: string $enrol ? return: bool |
| unenrol_student($userid, $courseid=0) X-Ref |
| Unenrols a student from a given course param: int $courseid The id of the course that is being viewed, if any param: int $userid The id of the user that is being tested against. return: bool |
| add_teacher($userid, $courseid, $editall=1, $role='', $timestart=0, $timeend=0, $enrol='manual') X-Ref |
| Add a teacher to a given course param: int $userid The id of the user that is being tested against. Set this to 0 if you would just like to test against the currently logged in user. param: int $courseid The id of the course that is being viewed, if any param: int $editall Can edit the course param: string $role Obsolete param: int $timestart The time they start param: int $timeend The time they end in this role param: string $enrol The type of enrolment this is return: bool |
| remove_teacher($userid, $courseid=0) X-Ref |
| Removes a teacher from a given course (or ALL courses) Does not delete the user account param: int $courseid The id of the course that is being viewed, if any param: int $userid The id of the user that is being tested against. return: bool |
| add_admin($userid) X-Ref |
| Add an admin to a site param: int $userid The id of the user that is being tested against. return: bool |
| get_user_info_from_db($field, $value) X-Ref |
| No description |
| get_guest() X-Ref |
| Get the guest user information from the database return: object(user) An associative array with the details of the guest user account. |
| get_teacher($courseid) X-Ref |
| Returns $user object of the main teacher for a course param: int $courseid The course in question. return: user|false A {@link $USER} record of the main teacher for the specified course or false if error. |
| get_recent_enrolments($courseid, $timestart) X-Ref |
| Searches logs to find all enrolments since a certain date used to print recent activity param: int $courseid The course in question. return: object|false {@link $USER} records or false if error. |
| get_course_students($courseid, $sort='ul.timeaccess', $dir='', $page='', $recordsperpage='',$firstinitial='', $lastinitial='', $group=NULL, $search='', $fields='', $exceptions='') X-Ref |
| Returns array of userinfo of all students in this course or on this site if courseid is id of site param: int $courseid The course in question. param: string $sort ? param: string $dir ? param: int $page ? param: int $recordsperpage ? param: string $firstinitial ? param: string $lastinitial ? param: ? $group ? param: string $search ? param: string $fields A comma separated list of fields to be returned from the chosen table. param: string $exceptions ? return: object |
| count_course_students($course, $search='', $firstinitial='', $lastinitial='', $group=NULL, $exceptions='') X-Ref |
| Counts the students in a given course (or site), or a subset of them param: object $course The course in question as a course object. param: string $search ? param: string $firstinitial ? param: string $lastinitial ? param: ? $group ? param: string $exceptions ? return: int |
| get_course_teachers($courseid, $sort='t.authority ASC', $exceptions='') X-Ref |
| Returns list of all teachers in this course If $courseid matches the site id then this function returns a list of all teachers for the site. param: int $courseid The course in question. param: string $sort ? param: string $exceptions ? return: object |
| get_course_users($courseid, $sort='ul.timeaccess DESC', $exceptions='', $fields='u.*, ul.timeaccess as lastaccess') X-Ref |
| Returns all the users of a course: students and teachers param: int $courseid The course in question. param: string $sort ? param: string $exceptions ? param: string $fields A comma separated list of fields to be returned from the chosen table. return: object |
| get_group_students($groupids, $sort='ul.timeaccess DESC') X-Ref |
| Returns an array of user objects param: int $groupid The group(s) in question. param: string $sort How to sort the results return: object (changed to groupids) |
| get_group_teachers($courseid, $groupid) X-Ref |
| Returns list of all the teachers who can access a group param: int $courseid The course in question. param: int $groupid The group in question. return: object |
| make_table($table) X-Ref |
| Creates a nicely formatted table and returns it. param: array $table is an object with several properties. return: string |
| print_simple_box($message, $align='', $width='', $color='', $padding=5, $class='generalbox', $id='', $return=false) X-Ref |
| Print a message in a standard themed box. This old function used to implement boxes using tables. Now it uses a DIV, but the old parameters remain. If possible, $align, $width and $color should not be defined at all. Preferably just use print_box() in weblib.php param: string $align, alignment of the box, not the text (default center, left, right). param: string $width, width of the box, including units %, for example '100%'. param: string $color, background colour of the box, for example '#eee'. param: int $padding, padding in pixels, specified without units. param: string $class, space-separated class names. param: string $id, space-separated id names. param: boolean $return, return as string or just print it |
| print_simple_box_start($align='', $width='', $color='', $padding=5, $class='generalbox', $id='', $return=false) X-Ref |
| This old function used to implement boxes using tables. Now it uses a DIV, but the old parameters remain. If possible, $align, $width and $color should not be defined at all. Even better, please use print_box_start() in weblib.php param: string $align, alignment of the box, not the text (default center, left, right). DEPRECATED param: string $width, width of the box, including % units, for example '100%'. DEPRECATED param: string $color, background colour of the box, for example '#eee'. DEPRECATED param: int $padding, padding in pixels, specified without units. OBSOLETE param: string $class, space-separated class names. param: string $id, space-separated id names. param: boolean $return, return as string or just print it |
| print_simple_box_end($return=false) X-Ref |
| Print the end portion of a standard themed box. Preferably just use print_box_end() in weblib.php |
| detect_munged_arguments($string, $allowdots=1) X-Ref |
| deprecated - use clean_param($string, PARAM_FILE); instead Check for bad characters ? param: string $string ? param: int $allowdots ? |
| current_charset($ignorecache = false) X-Ref |
| No description |
| read_template($filename, &$var) X-Ref |
| Load a template from file - this function dates back to Moodle 1 :-) not used anymore Returns a (big) string containing the contents of a template file with all the variables interpolated. all the variables must be in the $var[] array or object (whatever you decide to use). <b>WARNING: do not use this on big files!!</b> param: string $filename Location on the server's filesystem where template can be found. param: mixed $var Passed in by reference. An array or object which will be loaded with data from the template file. |
| checked(&$var, $set_value = 1, $unset_value = 0) X-Ref |
| deprecated - relies on register globals; use new formslib instead Set a variable's value depending on whether or not it already has a value. If variable is set, set it to the set_value otherwise set it to the unset_value. used to handle checkboxes when you are expecting them from a form param: mixed $var Passed in by reference. The variable to check. param: mixed $set_value The value to set $var to if $var already has a value. param: mixed $unset_value The value to set $var to if $var does not already have a value. |
| frmchecked(&$var, $true_value = 'checked', $false_value = '') X-Ref |
| deprecated - use new formslib instead Prints the word "checked" if a variable is true, otherwise prints nothing, used for printing the word "checked" in a checkbox form element. param: boolean $var Variable to be checked for true value param: string $true_value Value to be printed if $var is true param: string $false_value Value to be printed if $var is false |
| print_richedit_javascript($form, $name, $source='no') X-Ref |
| Legacy function, provided for backward compatability. This method now simply calls {@link use_html_editor()} param: string $name Form element to replace with HTMl editor by name |
| groups_members_from_sql() X-Ref |
| Returns the table in which group members are stored, with a prefix 'gm'. return: SQL string. |
| groups_members_join_sql($groupid=false) X-Ref |
| Returns a join testing user.id against member's user ID. Relies on 'user' table being included as 'user u'. Used in Quiz module reports. param: group ID, optional to include a test for this in the SQL. return: SQL string. |
| groups_members_where_sql($groupid, $userid_sql=false) X-Ref |
| Returns SQL for a WHERE clause testing the group ID. Optionally test the member's ID against another table's user ID column. param: groupid param: userid_sql Optional user ID column selector, example "mdl_user.id", or false. return: SQL string. |
| get_groups($courseid, $userid=0) X-Ref |
| Returns an array of group objects that the user is a member of in the given course. If userid isn't specified, then return a list of all groups in the course. param: int $courseid The id of the course in question. param: int $userid The id of the user in question as found in the 'user' table 'id' field. return: object |
| user_group($courseid, $userid) X-Ref |
| Returns the user's groups in a particular course note: this function originally returned only one group param: int $courseid The course in question. param: int $userid The id of the user as found in the 'user' table. param: int $groupid The id of the group the user is in. return: aray of groups |
| ismember($groupid, $userid = null) X-Ref |
| Determines if the user is a member of the given group. param: int $groupid The group to check for membership. param: int $userid The user to check against the group. return: boolean True if the user is a member, false otherwise. |
| mygroupid($courseid) X-Ref |
| Get the IDs for the user's groups in the given course. param: int $courseid The course being examined - the 'course' table id field. return: array An _array_ of groupids. |
| add_user_to_group($groupid, $userid) X-Ref |
| Add a user to a group, return true upon success or if user already a group member param: int $groupid The group id to add user to param: int $userid The user id to add to the group return: bool |
| get_group_users($groupid, $sort='u.lastaccess DESC', $exceptions='',$fields='u.*') X-Ref |
| Returns an array of user objects param: int $groupid The group in question. param: string $sort ? param: string $exceptions ? return: object |
| groupmode($course, $cm=null) X-Ref |
| Returns the current group mode for a given course or activity module Could be false, SEPARATEGROUPS or VISIBLEGROUPS (<-- Martin) |
| set_current_group($courseid, $groupid) X-Ref |
| Sets the current group in the session variable When $SESSION->currentgroup[$courseid] is set to 0 it means, show all groups. Sets currentgroup[$courseid] in the session variable appropriately. Does not do any permission checking. param: int $courseid The course being examined - relates to id field in param: int $groupid The group being examined. return: int Current group id which was set by this function |
| get_current_group($courseid, $full = false) X-Ref |
| Gets the current group - either from the session variable or from the database. param: int $courseid The course being examined - relates to id field in param: bool $full If true, the return value is a full record object. |
| get_and_set_current_group($course, $groupmode, $groupid=-1) X-Ref |
| A combination function to make it easier for modules to set up groups. It will use a given "groupid" parameter and try to use that to reset the current group for the user. param: course $course A {@link $COURSE} object param: int $groupmode Either NOGROUPS, SEPARATEGROUPS or VISIBLEGROUPS param: int $groupid Will try to use this optional parameter to return: int|false Returns the current group id or false if error. |
| setup_and_print_groups($course, $groupmode, $urlroot) X-Ref |
| A big combination function to make it easier for modules to set up groups. Terminates if the current user shouldn't be looking at this group Otherwise returns the current group if there is one Otherwise returns false if groups aren't relevant param: course $course A {@link $COURSE} object param: int $groupmode Either NOGROUPS, SEPARATEGROUPS or VISIBLEGROUPS param: string $urlroot ? return: int|false |
| print_group_menu($groups, $groupmode, $currentgroup, $urlroot, $showall=1, $return=false) X-Ref |
| Prints an appropriate group selection menu param: array $groups ? param: int $groupmode ? param: string $currentgroup ? param: string $urlroot ? param: boolean $showall: if set to 0, it is a student in separate groups, do not display all participants |
| get_users_longtimenosee($cutofftime) X-Ref |
| All users that we have not seen for a really long time (ie dead accounts) TODO: Delete this for Moodle 2.0 param: string $cutofftime ? return: object {@link $USER} records |
| get_users_unconfirmed($cutofftime=2000000000) X-Ref |
| Full list of users that have not yet confirmed their accounts. TODO: Delete this for Moodle 2.0 param: string $cutofftime ? return: object {@link $USER} records |
| get_users_not_fully_set_up($cutofftime=2000000000) X-Ref |
| Full list of bogus accounts that are probably not ever going to be used TODO: Delete this for Moodle 2.0 param: string $cutofftime ? return: object {@link $USER} records |
| sql_primary_role_subselect() X-Ref |
| Returns SQL to be used as a subselect to find the primary role of users. Geoff Cant <geoff@catalyst.net.nz> (the author) is very keen for this to be implemented as a view in future versions. eg if this function returns a string called $primaryroles, then you could: $sql = 'SELECT COUNT(DISTINCT prs.userid) FROM ('.$primary_roles.') prs WHERE prs.primary_roleid='.$role->id.' AND prs.courseid='.$course->id. ' AND prs.contextlevel = '.CONTEXT_COURSE; return: string the piece of SQL code to be used in your FROM( ) statement. |
| document_file($file, $include=true) X-Ref |
| Can include a given document file (depends on second parameter) or just return info about it. param: string $file ? param: bool $include ? return: ? |
| error($message, $link='') X-Ref |
| Print an error page displaying an error message. Old method, don't call directly in new code - use print_error instead. param: string $message The message to display to the user about the error. param: string $link The url where the user will be prompted to continue. If no url is provided the user will be directed to the site index page. |
| Generated: Wed Jan 14 11:33:29 2009 | Cross-referenced by PHPXref 0.7 |