id int32 0 241k | repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1
value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 |
|---|---|---|---|---|---|---|---|---|---|---|---|
216,800 | moodle/moodle | course/classes/category.php | core_course_category.get | public static function get($id, $strictness = MUST_EXIST, $alwaysreturnhidden = false, $user = null) {
if (!$id) {
// Top-level category.
if ($alwaysreturnhidden || self::top()->is_uservisible()) {
return self::top();
}
if ($strictness == MUST_EXIS... | php | public static function get($id, $strictness = MUST_EXIST, $alwaysreturnhidden = false, $user = null) {
if (!$id) {
// Top-level category.
if ($alwaysreturnhidden || self::top()->is_uservisible()) {
return self::top();
}
if ($strictness == MUST_EXIS... | [
"public",
"static",
"function",
"get",
"(",
"$",
"id",
",",
"$",
"strictness",
"=",
"MUST_EXIST",
",",
"$",
"alwaysreturnhidden",
"=",
"false",
",",
"$",
"user",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"id",
")",
"{",
"// Top-level category.",
"if"... | Returns coursecat object for requested category
If category is not visible to the given user, it is treated as non existing
unless $alwaysreturnhidden is set to true
If id is 0, the pseudo object for root category is returned (convenient
for calling other functions such as get_children())
@param int $id category id
... | [
"Returns",
"coursecat",
"object",
"for",
"requested",
"category"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/classes/category.php#L230-L268 |
216,801 | moodle/moodle | course/classes/category.php | core_course_category.user_top | public static function user_top() {
$children = self::top()->get_children();
if (count($children) == 1) {
// User has access to only one category on the top level. Return this category as "user top category".
return reset($children);
}
if (count($children) > 1) {
... | php | public static function user_top() {
$children = self::top()->get_children();
if (count($children) == 1) {
// User has access to only one category on the top level. Return this category as "user top category".
return reset($children);
}
if (count($children) > 1) {
... | [
"public",
"static",
"function",
"user_top",
"(",
")",
"{",
"$",
"children",
"=",
"self",
"::",
"top",
"(",
")",
"->",
"get_children",
"(",
")",
";",
"if",
"(",
"count",
"(",
"$",
"children",
")",
"==",
"1",
")",
"{",
"// User has access to only one categ... | Returns the top-most category for the current user
Examples:
1. User can browse courses everywhere - return self::top() - pseudo-category with id=0
2. User does not have capability to browse courses on the system level but
has it in ONE course category - return this course category
3. User has capability to browse cou... | [
"Returns",
"the",
"top",
"-",
"most",
"category",
"for",
"the",
"current",
"user"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/classes/category.php#L299-L313 |
216,802 | moodle/moodle | course/classes/category.php | core_course_category.get_many | public static function get_many(array $ids) {
global $DB;
$coursecatrecordcache = cache::make('core', 'coursecatrecords');
$categories = $coursecatrecordcache->get_many($ids);
$toload = array();
foreach ($categories as $id => $result) {
if ($result === false) {
... | php | public static function get_many(array $ids) {
global $DB;
$coursecatrecordcache = cache::make('core', 'coursecatrecords');
$categories = $coursecatrecordcache->get_many($ids);
$toload = array();
foreach ($categories as $id => $result) {
if ($result === false) {
... | [
"public",
"static",
"function",
"get_many",
"(",
"array",
"$",
"ids",
")",
"{",
"global",
"$",
"DB",
";",
"$",
"coursecatrecordcache",
"=",
"cache",
"::",
"make",
"(",
"'core'",
",",
"'coursecatrecords'",
")",
";",
"$",
"categories",
"=",
"$",
"coursecatre... | Load many core_course_category objects.
@param array $ids An array of category ID's to load.
@return core_course_category[] | [
"Load",
"many",
"core_course_category",
"objects",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/classes/category.php#L321-L342 |
216,803 | moodle/moodle | course/classes/category.php | core_course_category.get_all | public static function get_all($options = []) {
global $DB;
$coursecatrecordcache = cache::make('core', 'coursecatrecords');
$catcontextsql = \context_helper::get_preload_record_columns_sql('ctx');
$catsql = "SELECT cc.*, {$catcontextsql}
FROM {course_categories} c... | php | public static function get_all($options = []) {
global $DB;
$coursecatrecordcache = cache::make('core', 'coursecatrecords');
$catcontextsql = \context_helper::get_preload_record_columns_sql('ctx');
$catsql = "SELECT cc.*, {$catcontextsql}
FROM {course_categories} c... | [
"public",
"static",
"function",
"get_all",
"(",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"global",
"$",
"DB",
";",
"$",
"coursecatrecordcache",
"=",
"cache",
"::",
"make",
"(",
"'core'",
",",
"'coursecatrecords'",
")",
";",
"$",
"catcontextsql",
"=",
"\\... | Load all core_course_category objects.
@param array $options Options:
- returnhidden Return categories even if they are hidden
@return core_course_category[] | [
"Load",
"all",
"core_course_category",
"objects",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/classes/category.php#L351-L384 |
216,804 | moodle/moodle | course/classes/category.php | core_course_category.get_default | public static function get_default() {
if ($visiblechildren = self::top()->get_children()) {
$defcategory = reset($visiblechildren);
} else {
$toplevelcategories = self::get_tree(0);
$defcategoryid = $toplevelcategories[0];
$defcategory = self::get($defcat... | php | public static function get_default() {
if ($visiblechildren = self::top()->get_children()) {
$defcategory = reset($visiblechildren);
} else {
$toplevelcategories = self::get_tree(0);
$defcategoryid = $toplevelcategories[0];
$defcategory = self::get($defcat... | [
"public",
"static",
"function",
"get_default",
"(",
")",
"{",
"if",
"(",
"$",
"visiblechildren",
"=",
"self",
"::",
"top",
"(",
")",
"->",
"get_children",
"(",
")",
")",
"{",
"$",
"defcategory",
"=",
"reset",
"(",
"$",
"visiblechildren",
")",
";",
"}",... | Returns the first found category
Note that if there are no categories visible to the current user on the first level,
the invisible category may be returned
@return core_course_category | [
"Returns",
"the",
"first",
"found",
"category"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/classes/category.php#L394-L403 |
216,805 | moodle/moodle | course/classes/category.php | core_course_category.can_view_category | public static function can_view_category($category, $user = null) {
if (!$category->id) {
return has_capability('moodle/category:viewcourselist', context_system::instance(), $user);
}
$context = context_coursecat::instance($category->id);
if (!$category->visible && !has_capab... | php | public static function can_view_category($category, $user = null) {
if (!$category->id) {
return has_capability('moodle/category:viewcourselist', context_system::instance(), $user);
}
$context = context_coursecat::instance($category->id);
if (!$category->visible && !has_capab... | [
"public",
"static",
"function",
"can_view_category",
"(",
"$",
"category",
",",
"$",
"user",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"category",
"->",
"id",
")",
"{",
"return",
"has_capability",
"(",
"'moodle/category:viewcourselist'",
",",
"context_system... | Checks if current user has access to the category
@param stdClass|core_course_category $category
@param int|stdClass $user The user id or object. By default (null) checks access for the current user.
@return bool | [
"Checks",
"if",
"current",
"user",
"has",
"access",
"to",
"the",
"category"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/classes/category.php#L654-L663 |
216,806 | moodle/moodle | course/classes/category.php | core_course_category.can_view_course_info | public static function can_view_course_info($course, $user = null) {
if ($course->id == SITEID) {
return true;
}
if (!$course->visible) {
$coursecontext = context_course::instance($course->id);
if (!has_capability('moodle/course:viewhiddencourses', $coursecont... | php | public static function can_view_course_info($course, $user = null) {
if ($course->id == SITEID) {
return true;
}
if (!$course->visible) {
$coursecontext = context_course::instance($course->id);
if (!has_capability('moodle/course:viewhiddencourses', $coursecont... | [
"public",
"static",
"function",
"can_view_course_info",
"(",
"$",
"course",
",",
"$",
"user",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"course",
"->",
"id",
"==",
"SITEID",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"!",
"$",
"course",
"->",
"v... | Checks if current user can view course information or enrolment page.
This method does not check if user is already enrolled in the course
@param stdClass $course course object (must have 'id', 'visible' and 'category' fields)
@param null|stdClass $user The user id or object. By default (null) checks access for the c... | [
"Checks",
"if",
"current",
"user",
"can",
"view",
"course",
"information",
"or",
"enrolment",
"page",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/classes/category.php#L673-L686 |
216,807 | moodle/moodle | course/classes/category.php | core_course_category.get_db_record | public function get_db_record() {
global $DB;
if ($record = $DB->get_record('course_categories', array('id' => $this->id))) {
return $record;
} else {
return (object)convert_to_array($this);
}
} | php | public function get_db_record() {
global $DB;
if ($record = $DB->get_record('course_categories', array('id' => $this->id))) {
return $record;
} else {
return (object)convert_to_array($this);
}
} | [
"public",
"function",
"get_db_record",
"(",
")",
"{",
"global",
"$",
"DB",
";",
"if",
"(",
"$",
"record",
"=",
"$",
"DB",
"->",
"get_record",
"(",
"'course_categories'",
",",
"array",
"(",
"'id'",
"=>",
"$",
"this",
"->",
"id",
")",
")",
")",
"{",
... | Returns the complete corresponding record from DB table course_categories
Mostly used in deprecated functions
@return stdClass | [
"Returns",
"the",
"complete",
"corresponding",
"record",
"from",
"DB",
"table",
"course_categories"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/classes/category.php#L695-L702 |
216,808 | moodle/moodle | course/classes/category.php | core_course_category.get_tree | protected static function get_tree($id) {
global $DB;
$coursecattreecache = cache::make('core', 'coursecattree');
$rv = $coursecattreecache->get($id);
if ($rv !== false) {
return $rv;
}
// Re-build the tree.
$sql = "SELECT cc.id, cc.parent, cc.visible
... | php | protected static function get_tree($id) {
global $DB;
$coursecattreecache = cache::make('core', 'coursecattree');
$rv = $coursecattreecache->get($id);
if ($rv !== false) {
return $rv;
}
// Re-build the tree.
$sql = "SELECT cc.id, cc.parent, cc.visible
... | [
"protected",
"static",
"function",
"get_tree",
"(",
"$",
"id",
")",
"{",
"global",
"$",
"DB",
";",
"$",
"coursecattreecache",
"=",
"cache",
"::",
"make",
"(",
"'core'",
",",
"'coursecattree'",
")",
";",
"$",
"rv",
"=",
"$",
"coursecattreecache",
"->",
"g... | Returns the entry from categories tree and makes sure the application-level tree cache is built
The following keys can be requested:
'countall' - total number of categories in the system (always present)
0 - array of ids of top-level categories (always present)
'0i' - array of ids of top-level categories that have vi... | [
"Returns",
"the",
"entry",
"from",
"categories",
"tree",
"and",
"makes",
"sure",
"the",
"application",
"-",
"level",
"tree",
"cache",
"is",
"built"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/classes/category.php#L719-L769 |
216,809 | moodle/moodle | course/classes/category.php | core_course_category.get_records | protected static function get_records($whereclause, $params) {
global $DB;
// Retrieve from DB only the fields that need to be stored in cache.
$fields = array_keys(array_filter(self::$coursecatfields));
$ctxselect = context_helper::get_preload_record_columns_sql('ctx');
$sql = "... | php | protected static function get_records($whereclause, $params) {
global $DB;
// Retrieve from DB only the fields that need to be stored in cache.
$fields = array_keys(array_filter(self::$coursecatfields));
$ctxselect = context_helper::get_preload_record_columns_sql('ctx');
$sql = "... | [
"protected",
"static",
"function",
"get_records",
"(",
"$",
"whereclause",
",",
"$",
"params",
")",
"{",
"global",
"$",
"DB",
";",
"// Retrieve from DB only the fields that need to be stored in cache.",
"$",
"fields",
"=",
"array_keys",
"(",
"array_filter",
"(",
"self... | Retrieves number of records from course_categories table
Only cached fields are retrieved. Records are ready for preloading context
@param string $whereclause
@param array $params
@return array array of stdClass objects | [
"Retrieves",
"number",
"of",
"records",
"from",
"course_categories",
"table"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/classes/category.php#L807-L818 |
216,810 | moodle/moodle | course/classes/category.php | core_course_category.role_assignment_changed | public static function role_assignment_changed($roleid, $context) {
global $CFG, $DB;
if ($context->contextlevel > CONTEXT_COURSE) {
// No changes to course contacts if role was assigned on the module/block level.
return;
}
// Trigger a purge for all caches list... | php | public static function role_assignment_changed($roleid, $context) {
global $CFG, $DB;
if ($context->contextlevel > CONTEXT_COURSE) {
// No changes to course contacts if role was assigned on the module/block level.
return;
}
// Trigger a purge for all caches list... | [
"public",
"static",
"function",
"role_assignment_changed",
"(",
"$",
"roleid",
",",
"$",
"context",
")",
"{",
"global",
"$",
"CFG",
",",
"$",
"DB",
";",
"if",
"(",
"$",
"context",
"->",
"contextlevel",
">",
"CONTEXT_COURSE",
")",
"{",
"// No changes to cours... | Resets course contact caches when role assignments were changed
@param int $roleid role id that was given or taken away
@param context $context context where role assignment has been changed | [
"Resets",
"course",
"contact",
"caches",
"when",
"role",
"assignments",
"were",
"changed"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/classes/category.php#L826-L857 |
216,811 | moodle/moodle | course/classes/category.php | core_course_category.user_enrolment_changed | public static function user_enrolment_changed($courseid, $userid,
$status, $timestart = null, $timeend = null) {
$cache = cache::make('core', 'coursecontacts');
$contacts = $cache->get($courseid);
if ($contacts === false) {
// The contacts for the affected course were not... | php | public static function user_enrolment_changed($courseid, $userid,
$status, $timestart = null, $timeend = null) {
$cache = cache::make('core', 'coursecontacts');
$contacts = $cache->get($courseid);
if ($contacts === false) {
// The contacts for the affected course were not... | [
"public",
"static",
"function",
"user_enrolment_changed",
"(",
"$",
"courseid",
",",
"$",
"userid",
",",
"$",
"status",
",",
"$",
"timestart",
"=",
"null",
",",
"$",
"timeend",
"=",
"null",
")",
"{",
"$",
"cache",
"=",
"cache",
"::",
"make",
"(",
"'cor... | Executed when user enrolment was changed to check if course
contacts cache needs to be cleared
@param int $courseid course id
@param int $userid user id
@param int $status new enrolment status (0 - active, 1 - suspended)
@param int $timestart new enrolment time start
@param int $timeend new enrolment time end | [
"Executed",
"when",
"user",
"enrolment",
"was",
"changed",
"to",
"check",
"if",
"course",
"contacts",
"cache",
"needs",
"to",
"be",
"cleared"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/classes/category.php#L869-L900 |
216,812 | moodle/moodle | course/classes/category.php | core_course_category.preload_custom_fields | public static function preload_custom_fields(array &$records) {
$customfields = \core_course\customfield\course_handler::create()->get_instances_data(array_keys($records));
foreach ($customfields as $courseid => $data) {
$records[$courseid]->customfields = $data;
}
} | php | public static function preload_custom_fields(array &$records) {
$customfields = \core_course\customfield\course_handler::create()->get_instances_data(array_keys($records));
foreach ($customfields as $courseid => $data) {
$records[$courseid]->customfields = $data;
}
} | [
"public",
"static",
"function",
"preload_custom_fields",
"(",
"array",
"&",
"$",
"records",
")",
"{",
"$",
"customfields",
"=",
"\\",
"core_course",
"\\",
"customfield",
"\\",
"course_handler",
"::",
"create",
"(",
")",
"->",
"get_instances_data",
"(",
"array_ke... | Preloads the custom fields values in bulk
@param array $records | [
"Preloads",
"the",
"custom",
"fields",
"values",
"in",
"bulk"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/classes/category.php#L1020-L1025 |
216,813 | moodle/moodle | course/classes/category.php | core_course_category.ensure_users_enrolled | protected static function ensure_users_enrolled($courseusers) {
global $DB;
// If the input array is too big, split it into chunks.
$maxcoursesinquery = 20;
if (count($courseusers) > $maxcoursesinquery) {
$rv = array();
for ($offset = 0; $offset < count($courseuse... | php | protected static function ensure_users_enrolled($courseusers) {
global $DB;
// If the input array is too big, split it into chunks.
$maxcoursesinquery = 20;
if (count($courseusers) > $maxcoursesinquery) {
$rv = array();
for ($offset = 0; $offset < count($courseuse... | [
"protected",
"static",
"function",
"ensure_users_enrolled",
"(",
"$",
"courseusers",
")",
"{",
"global",
"$",
"DB",
";",
"// If the input array is too big, split it into chunks.",
"$",
"maxcoursesinquery",
"=",
"20",
";",
"if",
"(",
"count",
"(",
"$",
"courseusers",
... | Verify user enrollments for multiple course-user combinations
@param array $courseusers array where keys are course ids and values are array
of users in this course whose enrolment we wish to verify
@return array same structure as input array but values list only users from input
who are enrolled in the course | [
"Verify",
"user",
"enrollments",
"for",
"multiple",
"course",
"-",
"user",
"combinations"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/classes/category.php#L1035-L1080 |
216,814 | moodle/moodle | course/classes/category.php | core_course_category.get_course_records | protected static function get_course_records($whereclause, $params, $options, $checkvisibility = false) {
global $DB;
$ctxselect = context_helper::get_preload_record_columns_sql('ctx');
$fields = array('c.id', 'c.category', 'c.sortorder',
'c.shortname', 'c.fullname', 'c.i... | php | protected static function get_course_records($whereclause, $params, $options, $checkvisibility = false) {
global $DB;
$ctxselect = context_helper::get_preload_record_columns_sql('ctx');
$fields = array('c.id', 'c.category', 'c.sortorder',
'c.shortname', 'c.fullname', 'c.i... | [
"protected",
"static",
"function",
"get_course_records",
"(",
"$",
"whereclause",
",",
"$",
"params",
",",
"$",
"options",
",",
"$",
"checkvisibility",
"=",
"false",
")",
"{",
"global",
"$",
"DB",
";",
"$",
"ctxselect",
"=",
"context_helper",
"::",
"get_prel... | Retrieves number of records from course table
Not all fields are retrieved. Records are ready for preloading context
@param string $whereclause
@param array $params
@param array $options may indicate that summary needs to be retrieved
@param bool $checkvisibility if true, capability 'moodle/course:viewhiddencourses' ... | [
"Retrieves",
"number",
"of",
"records",
"from",
"course",
"table"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/classes/category.php#L1094-L1130 |
216,815 | moodle/moodle | course/classes/category.php | core_course_category.get_not_visible_children_ids | protected function get_not_visible_children_ids() {
global $DB;
$coursecatcache = cache::make('core', 'coursecat');
if (($invisibleids = $coursecatcache->get('ic'. $this->id)) === false) {
// We never checked visible children before.
$hidden = self::get_tree($this->id.'i'... | php | protected function get_not_visible_children_ids() {
global $DB;
$coursecatcache = cache::make('core', 'coursecat');
if (($invisibleids = $coursecatcache->get('ic'. $this->id)) === false) {
// We never checked visible children before.
$hidden = self::get_tree($this->id.'i'... | [
"protected",
"function",
"get_not_visible_children_ids",
"(",
")",
"{",
"global",
"$",
"DB",
";",
"$",
"coursecatcache",
"=",
"cache",
"::",
"make",
"(",
"'core'",
",",
"'coursecat'",
")",
";",
"if",
"(",
"(",
"$",
"invisibleids",
"=",
"$",
"coursecatcache",... | Returns array of ids of children categories that current user can not see
This data is cached in user session cache
@return array | [
"Returns",
"array",
"of",
"ids",
"of",
"children",
"categories",
"that",
"current",
"user",
"can",
"not",
"see"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/classes/category.php#L1139-L1168 |
216,816 | moodle/moodle | course/classes/category.php | core_course_category.sort_records | protected static function sort_records(&$records, $sortfields) {
if (empty($records)) {
return;
}
// If sorting by course display name, calculate it (it may be fullname or shortname+fullname).
if (array_key_exists('displayname', $sortfields)) {
foreach ($records a... | php | protected static function sort_records(&$records, $sortfields) {
if (empty($records)) {
return;
}
// If sorting by course display name, calculate it (it may be fullname or shortname+fullname).
if (array_key_exists('displayname', $sortfields)) {
foreach ($records a... | [
"protected",
"static",
"function",
"sort_records",
"(",
"&",
"$",
"records",
",",
"$",
"sortfields",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"records",
")",
")",
"{",
"return",
";",
"}",
"// If sorting by course display name, calculate it (it may be fullname or shor... | Sorts list of records by several fields
@param array $records array of stdClass objects
@param array $sortfields assoc array where key is the field to sort and value is 1 for asc or -1 for desc
@return int | [
"Sorts",
"list",
"of",
"records",
"by",
"several",
"fields"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/classes/category.php#L1177-L1234 |
216,817 | moodle/moodle | course/classes/category.php | core_course_category.has_capability_on_any | public static function has_capability_on_any($capabilities) {
global $DB;
if (!isloggedin() || isguestuser()) {
return false;
}
if (!is_array($capabilities)) {
$capabilities = array($capabilities);
}
$keys = array();
foreach ($capabilities... | php | public static function has_capability_on_any($capabilities) {
global $DB;
if (!isloggedin() || isguestuser()) {
return false;
}
if (!is_array($capabilities)) {
$capabilities = array($capabilities);
}
$keys = array();
foreach ($capabilities... | [
"public",
"static",
"function",
"has_capability_on_any",
"(",
"$",
"capabilities",
")",
"{",
"global",
"$",
"DB",
";",
"if",
"(",
"!",
"isloggedin",
"(",
")",
"||",
"isguestuser",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"is_arr... | Checks if the user has at least one of the given capabilities on any category.
@param array|string $capabilities One or more capabilities to check. Check made is an OR.
@return bool | [
"Checks",
"if",
"the",
"user",
"has",
"at",
"least",
"one",
"of",
"the",
"given",
"capabilities",
"on",
"any",
"category",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/classes/category.php#L1363-L1423 |
216,818 | moodle/moodle | course/classes/category.php | core_course_category.get_children_count | public function get_children_count() {
$sortedids = self::get_tree($this->id);
$invisibleids = $this->get_not_visible_children_ids();
return count($sortedids) - count($invisibleids);
} | php | public function get_children_count() {
$sortedids = self::get_tree($this->id);
$invisibleids = $this->get_not_visible_children_ids();
return count($sortedids) - count($invisibleids);
} | [
"public",
"function",
"get_children_count",
"(",
")",
"{",
"$",
"sortedids",
"=",
"self",
"::",
"get_tree",
"(",
"$",
"this",
"->",
"id",
")",
";",
"$",
"invisibleids",
"=",
"$",
"this",
"->",
"get_not_visible_children_ids",
"(",
")",
";",
"return",
"count... | Returns number of subcategories visible to the current user
@return int | [
"Returns",
"number",
"of",
"subcategories",
"visible",
"to",
"the",
"current",
"user"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/classes/category.php#L1446-L1450 |
216,819 | moodle/moodle | course/classes/category.php | core_course_category.search_courses_count | public static function search_courses_count($search, $options = array(), $requiredcapabilities = array()) {
$coursecatcache = cache::make('core', 'coursecat');
$cntcachekey = 'scnt-'. serialize($search) . serialize($requiredcapabilities);
if (($cnt = $coursecatcache->get($cntcachekey)) === false... | php | public static function search_courses_count($search, $options = array(), $requiredcapabilities = array()) {
$coursecatcache = cache::make('core', 'coursecat');
$cntcachekey = 'scnt-'. serialize($search) . serialize($requiredcapabilities);
if (($cnt = $coursecatcache->get($cntcachekey)) === false... | [
"public",
"static",
"function",
"search_courses_count",
"(",
"$",
"search",
",",
"$",
"options",
"=",
"array",
"(",
")",
",",
"$",
"requiredcapabilities",
"=",
"array",
"(",
")",
")",
"{",
"$",
"coursecatcache",
"=",
"cache",
"::",
"make",
"(",
"'core'",
... | Returns number of courses in the search results
It is recommended to call this function after {@link core_course_category::search_courses()}
and not before because only course ids are cached. Otherwise search_courses() may
perform extra DB queries.
@param array $search search criteria, see method search_courses() for... | [
"Returns",
"number",
"of",
"courses",
"in",
"the",
"search",
"results"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/classes/category.php#L1654-L1668 |
216,820 | moodle/moodle | course/classes/category.php | core_course_category.get_courses_count | public function get_courses_count($options = array()) {
$cntcachekey = 'lcnt-'. $this->id. '-'. (!empty($options['recursive']) ? 'r' : '');
$coursecatcache = cache::make('core', 'coursecat');
if (($cnt = $coursecatcache->get($cntcachekey)) === false) {
// Cached value not found. Retr... | php | public function get_courses_count($options = array()) {
$cntcachekey = 'lcnt-'. $this->id. '-'. (!empty($options['recursive']) ? 'r' : '');
$coursecatcache = cache::make('core', 'coursecat');
if (($cnt = $coursecatcache->get($cntcachekey)) === false) {
// Cached value not found. Retr... | [
"public",
"function",
"get_courses_count",
"(",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"$",
"cntcachekey",
"=",
"'lcnt-'",
".",
"$",
"this",
"->",
"id",
".",
"'-'",
".",
"(",
"!",
"empty",
"(",
"$",
"options",
"[",
"'recursive'",
"]",
")",... | Returns number of courses visible to the user
@param array $options similar to get_courses() except some options do not affect
number of courses (i.e. sort, summary, offset, limit etc.)
@return int | [
"Returns",
"number",
"of",
"courses",
"visible",
"to",
"the",
"user"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/classes/category.php#L1807-L1821 |
216,821 | moodle/moodle | course/classes/category.php | core_course_category.can_delete_full | public function can_delete_full() {
global $DB;
if (!$this->id) {
// Fool-proof.
return false;
}
$context = $this->get_context();
if (!$this->is_uservisible() ||
!has_capability('moodle/category:manage', $context)) {
return fal... | php | public function can_delete_full() {
global $DB;
if (!$this->id) {
// Fool-proof.
return false;
}
$context = $this->get_context();
if (!$this->is_uservisible() ||
!has_capability('moodle/category:manage', $context)) {
return fal... | [
"public",
"function",
"can_delete_full",
"(",
")",
"{",
"global",
"$",
"DB",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"id",
")",
"{",
"// Fool-proof.",
"return",
"false",
";",
"}",
"$",
"context",
"=",
"$",
"this",
"->",
"get_context",
"(",
")",
";",
... | Returns true if user can delete current category and all its contents
To be able to delete course category the user must have permission
'moodle/category:manage' in ALL child course categories AND
be able to delete all courses
@return bool | [
"Returns",
"true",
"if",
"user",
"can",
"delete",
"current",
"category",
"and",
"all",
"its",
"contents"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/classes/category.php#L1848-L1892 |
216,822 | moodle/moodle | course/classes/category.php | core_course_category.delete_full | public function delete_full($showfeedback = true) {
global $CFG, $DB;
require_once($CFG->libdir.'/gradelib.php');
require_once($CFG->libdir.'/questionlib.php');
require_once($CFG->dirroot.'/cohort/lib.php');
// Make sure we won't timeout when deleting a lot of courses.
... | php | public function delete_full($showfeedback = true) {
global $CFG, $DB;
require_once($CFG->libdir.'/gradelib.php');
require_once($CFG->libdir.'/questionlib.php');
require_once($CFG->dirroot.'/cohort/lib.php');
// Make sure we won't timeout when deleting a lot of courses.
... | [
"public",
"function",
"delete_full",
"(",
"$",
"showfeedback",
"=",
"true",
")",
"{",
"global",
"$",
"CFG",
",",
"$",
"DB",
";",
"require_once",
"(",
"$",
"CFG",
"->",
"libdir",
".",
"'/gradelib.php'",
")",
";",
"require_once",
"(",
"$",
"CFG",
"->",
"... | Recursively delete category including all subcategories and courses
Function {@link core_course_category::can_delete_full()} MUST be called prior
to calling this function because there is no capability check
inside this function
@param boolean $showfeedback display some notices
@return array return deleted courses
@t... | [
"Recursively",
"delete",
"category",
"including",
"all",
"subcategories",
"and",
"courses"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/classes/category.php#L1905-L1978 |
216,823 | moodle/moodle | course/classes/category.php | core_course_category.can_move_content_to | public function can_move_content_to($newcatid) {
global $CFG;
require_once($CFG->libdir . '/questionlib.php');
$context = $this->get_context();
if (!$this->is_uservisible() ||
!has_capability('moodle/category:manage', $context)) {
return false;
}
... | php | public function can_move_content_to($newcatid) {
global $CFG;
require_once($CFG->libdir . '/questionlib.php');
$context = $this->get_context();
if (!$this->is_uservisible() ||
!has_capability('moodle/category:manage', $context)) {
return false;
}
... | [
"public",
"function",
"can_move_content_to",
"(",
"$",
"newcatid",
")",
"{",
"global",
"$",
"CFG",
";",
"require_once",
"(",
"$",
"CFG",
"->",
"libdir",
".",
"'/questionlib.php'",
")",
";",
"$",
"context",
"=",
"$",
"this",
"->",
"get_context",
"(",
")",
... | Checks if user has capability to move all category content to the new parent before
removing this category
@param int $newcatid
@return bool | [
"Checks",
"if",
"user",
"has",
"capability",
"to",
"move",
"all",
"category",
"content",
"to",
"the",
"new",
"parent",
"before",
"removing",
"this",
"category"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/classes/category.php#L2024-L2047 |
216,824 | moodle/moodle | course/classes/category.php | core_course_category.can_change_parent | public function can_change_parent($newparentcat) {
if (!has_capability('moodle/category:manage', $this->get_context())) {
return false;
}
if (is_object($newparentcat)) {
$newparentcat = self::get($newparentcat->id, IGNORE_MISSING);
} else {
$newparentc... | php | public function can_change_parent($newparentcat) {
if (!has_capability('moodle/category:manage', $this->get_context())) {
return false;
}
if (is_object($newparentcat)) {
$newparentcat = self::get($newparentcat->id, IGNORE_MISSING);
} else {
$newparentc... | [
"public",
"function",
"can_change_parent",
"(",
"$",
"newparentcat",
")",
"{",
"if",
"(",
"!",
"has_capability",
"(",
"'moodle/category:manage'",
",",
"$",
"this",
"->",
"get_context",
"(",
")",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"is_ob... | Checks if user can move current category to the new parent
This checks if new parent category exists, user has manage cap there
and new parent is not a child of this category
@param int|stdClass|core_course_category $newparentcat
@return bool | [
"Checks",
"if",
"user",
"can",
"move",
"current",
"category",
"to",
"the",
"new",
"parent"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/classes/category.php#L2151-L2172 |
216,825 | moodle/moodle | course/classes/category.php | core_course_category.change_parent_raw | protected function change_parent_raw(core_course_category $newparentcat) {
global $DB;
$context = $this->get_context();
$hidecat = false;
if (empty($newparentcat->id)) {
$DB->set_field('course_categories', 'parent', 0, array('id' => $this->id));
$newparent = con... | php | protected function change_parent_raw(core_course_category $newparentcat) {
global $DB;
$context = $this->get_context();
$hidecat = false;
if (empty($newparentcat->id)) {
$DB->set_field('course_categories', 'parent', 0, array('id' => $this->id));
$newparent = con... | [
"protected",
"function",
"change_parent_raw",
"(",
"core_course_category",
"$",
"newparentcat",
")",
"{",
"global",
"$",
"DB",
";",
"$",
"context",
"=",
"$",
"this",
"->",
"get_context",
"(",
")",
";",
"$",
"hidecat",
"=",
"false",
";",
"if",
"(",
"empty",... | Moves the category under another parent category. All associated contexts are moved as well
This is protected function, use change_parent() or update() from outside of this class
@see core_course_category::change_parent()
@see core_course_category::update()
@param core_course_category $newparentcat
@throws moodle_ex... | [
"Moves",
"the",
"category",
"under",
"another",
"parent",
"category",
".",
"All",
"associated",
"contexts",
"are",
"moved",
"as",
"well"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/classes/category.php#L2185-L2222 |
216,826 | moodle/moodle | course/classes/category.php | core_course_category.change_parent | public function change_parent($newparentcat) {
// Make sure parent category exists but do not check capabilities here that it is visible to current user.
if (is_object($newparentcat)) {
$newparentcat = self::get($newparentcat->id, MUST_EXIST, true);
} else {
$newparentcat... | php | public function change_parent($newparentcat) {
// Make sure parent category exists but do not check capabilities here that it is visible to current user.
if (is_object($newparentcat)) {
$newparentcat = self::get($newparentcat->id, MUST_EXIST, true);
} else {
$newparentcat... | [
"public",
"function",
"change_parent",
"(",
"$",
"newparentcat",
")",
"{",
"// Make sure parent category exists but do not check capabilities here that it is visible to current user.",
"if",
"(",
"is_object",
"(",
"$",
"newparentcat",
")",
")",
"{",
"$",
"newparentcat",
"=",
... | Efficiently moves a category - NOTE that this can have
a huge impact access-control-wise...
Note that this function does not check capabilities.
Example of usage:
$coursecat = core_course_category::get($categoryid);
if ($coursecat->can_change_parent($newparentcatid)) {
$coursecat->change_parent($newparentcatid);
}
T... | [
"Efficiently",
"moves",
"a",
"category",
"-",
"NOTE",
"that",
"this",
"can",
"have",
"a",
"huge",
"impact",
"access",
"-",
"control",
"-",
"wise",
"..."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/classes/category.php#L2242-L2262 |
216,827 | moodle/moodle | course/classes/category.php | core_course_category.get_formatted_name | public function get_formatted_name($options = array()) {
if ($this->id) {
$context = $this->get_context();
return format_string($this->name, true, array('context' => $context) + $options);
} else {
return get_string('top');
}
} | php | public function get_formatted_name($options = array()) {
if ($this->id) {
$context = $this->get_context();
return format_string($this->name, true, array('context' => $context) + $options);
} else {
return get_string('top');
}
} | [
"public",
"function",
"get_formatted_name",
"(",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"id",
")",
"{",
"$",
"context",
"=",
"$",
"this",
"->",
"get_context",
"(",
")",
";",
"return",
"format_string",
"(",
"$"... | Returns name of the category formatted as a string
@param array $options formatting options other than context
@return string | [
"Returns",
"name",
"of",
"the",
"category",
"formatted",
"as",
"a",
"string"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/classes/category.php#L2401-L2408 |
216,828 | moodle/moodle | course/classes/category.php | core_course_category.get_nested_name | public function get_nested_name($includelinks = true, $separator = ' / ', $options = []) {
// Get the name of hierarchical name of this category.
$parents = $this->get_parents();
$categories = static::get_many($parents);
$categories[] = $this;
$names = array_map(function($catego... | php | public function get_nested_name($includelinks = true, $separator = ' / ', $options = []) {
// Get the name of hierarchical name of this category.
$parents = $this->get_parents();
$categories = static::get_many($parents);
$categories[] = $this;
$names = array_map(function($catego... | [
"public",
"function",
"get_nested_name",
"(",
"$",
"includelinks",
"=",
"true",
",",
"$",
"separator",
"=",
"' / '",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"// Get the name of hierarchical name of this category.",
"$",
"parents",
"=",
"$",
"this",
"->",
... | Get the nested name of this category, with all of it's parents.
@param bool $includelinks Whether to wrap each name in the view link for that category.
@param string $separator The string between each name.
@param array $options Formatting options.
@return string | [
"Get",
"the",
"nested",
"name",
"of",
"this",
"category",
"with",
"all",
"of",
"it",
"s",
"parents",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/classes/category.php#L2418-L2434 |
216,829 | moodle/moodle | course/classes/category.php | core_course_category.wake_from_cache | public static function wake_from_cache($a) {
$record = new stdClass;
foreach (self::$coursecatfields as $property => $cachedirectives) {
if ($cachedirectives !== null) {
list($shortname, $defaultvalue) = $cachedirectives;
if (array_key_exists($shortname, $a)) ... | php | public static function wake_from_cache($a) {
$record = new stdClass;
foreach (self::$coursecatfields as $property => $cachedirectives) {
if ($cachedirectives !== null) {
list($shortname, $defaultvalue) = $cachedirectives;
if (array_key_exists($shortname, $a)) ... | [
"public",
"static",
"function",
"wake_from_cache",
"(",
"$",
"a",
")",
"{",
"$",
"record",
"=",
"new",
"stdClass",
";",
"foreach",
"(",
"self",
"::",
"$",
"coursecatfields",
"as",
"$",
"property",
"=>",
"$",
"cachedirectives",
")",
"{",
"if",
"(",
"$",
... | Takes the data provided by prepare_to_cache and reinitialises an instance of the associated from it.
implementing method from interface cacheable_object
@param array $a
@return core_course_category | [
"Takes",
"the",
"data",
"provided",
"by",
"prepare_to_cache",
"and",
"reinitialises",
"an",
"instance",
"of",
"the",
"associated",
"from",
"it",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/classes/category.php#L2614-L2633 |
216,830 | moodle/moodle | course/classes/category.php | core_course_category.can_review_filters | public function can_review_filters() {
return $this->is_uservisible() &&
has_capability('moodle/filter:manage', $this->get_context()) &&
count(filter_get_available_in_context($this->get_context())) > 0;
} | php | public function can_review_filters() {
return $this->is_uservisible() &&
has_capability('moodle/filter:manage', $this->get_context()) &&
count(filter_get_available_in_context($this->get_context())) > 0;
} | [
"public",
"function",
"can_review_filters",
"(",
")",
"{",
"return",
"$",
"this",
"->",
"is_uservisible",
"(",
")",
"&&",
"has_capability",
"(",
"'moodle/filter:manage'",
",",
"$",
"this",
"->",
"get_context",
"(",
")",
")",
"&&",
"count",
"(",
"filter_get_ava... | Returns true if the current user can review filter settings for this category.
@return bool | [
"Returns",
"true",
"if",
"the",
"current",
"user",
"can",
"review",
"filter",
"settings",
"for",
"this",
"category",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/classes/category.php#L2760-L2764 |
216,831 | moodle/moodle | course/classes/category.php | core_course_category.resort_subcategories | public function resort_subcategories($field, $cleanup = true) {
global $DB;
$desc = false;
if (substr($field, -4) === "desc") {
$desc = true;
$field = substr($field, 0, -4); // Remove "desc" from field name.
}
if ($field !== 'name' && $field !== 'idnumber... | php | public function resort_subcategories($field, $cleanup = true) {
global $DB;
$desc = false;
if (substr($field, -4) === "desc") {
$desc = true;
$field = substr($field, 0, -4); // Remove "desc" from field name.
}
if ($field !== 'name' && $field !== 'idnumber... | [
"public",
"function",
"resort_subcategories",
"(",
"$",
"field",
",",
"$",
"cleanup",
"=",
"true",
")",
"{",
"global",
"$",
"DB",
";",
"$",
"desc",
"=",
"false",
";",
"if",
"(",
"substr",
"(",
"$",
"field",
",",
"-",
"4",
")",
"===",
"\"desc\"",
")... | Resorts the sub categories of this category by the given field.
@param string $field One of name, idnumber or descending values of each (appended desc)
@param bool $cleanup If true cleanup will be done, if false you will need to do it manually later.
@return bool True on success.
@throws coding_exception | [
"Resorts",
"the",
"sub",
"categories",
"of",
"this",
"category",
"by",
"the",
"given",
"field",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/classes/category.php#L2806-L2831 |
216,832 | moodle/moodle | course/classes/category.php | core_course_category.resort_courses | public function resort_courses($field, $cleanup = true) {
global $DB;
$desc = false;
if (substr($field, -4) === "desc") {
$desc = true;
$field = substr($field, 0, -4); // Remove "desc" from field name.
}
if ($field !== 'fullname' && $field !== 'shortname'... | php | public function resort_courses($field, $cleanup = true) {
global $DB;
$desc = false;
if (substr($field, -4) === "desc") {
$desc = true;
$field = substr($field, 0, -4); // Remove "desc" from field name.
}
if ($field !== 'fullname' && $field !== 'shortname'... | [
"public",
"function",
"resort_courses",
"(",
"$",
"field",
",",
"$",
"cleanup",
"=",
"true",
")",
"{",
"global",
"$",
"DB",
";",
"$",
"desc",
"=",
"false",
";",
"if",
"(",
"substr",
"(",
"$",
"field",
",",
"-",
"4",
")",
"===",
"\"desc\"",
")",
"... | Resort the courses within this category by the given field.
@param string $field One of fullname, shortname, idnumber or descending values of each (appended desc)
@param bool $cleanup
@return bool True for success.
@throws coding_exception | [
"Resort",
"the",
"courses",
"within",
"this",
"category",
"by",
"the",
"given",
"field",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/classes/category.php#L2854-L2914 |
216,833 | moodle/moodle | course/classes/category.php | core_course_category.change_sortorder_by_one | public function change_sortorder_by_one($up) {
global $DB;
$params = array($this->sortorder, $this->parent);
if ($up) {
$select = 'sortorder < ? AND parent = ?';
$sort = 'sortorder DESC';
} else {
$select = 'sortorder > ? AND parent = ?';
$... | php | public function change_sortorder_by_one($up) {
global $DB;
$params = array($this->sortorder, $this->parent);
if ($up) {
$select = 'sortorder < ? AND parent = ?';
$sort = 'sortorder DESC';
} else {
$select = 'sortorder > ? AND parent = ?';
$... | [
"public",
"function",
"change_sortorder_by_one",
"(",
"$",
"up",
")",
"{",
"global",
"$",
"DB",
";",
"$",
"params",
"=",
"array",
"(",
"$",
"this",
"->",
"sortorder",
",",
"$",
"this",
"->",
"parent",
")",
";",
"if",
"(",
"$",
"up",
")",
"{",
"$",
... | Changes the sort order of this categories parent shifting this category up or down one.
@param bool $up If set to true the category is shifted up one spot, else its moved down.
@return bool True on success, false otherwise. | [
"Changes",
"the",
"sort",
"order",
"of",
"this",
"categories",
"parent",
"shifting",
"this",
"category",
"up",
"or",
"down",
"one",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/classes/category.php#L2922-L2954 |
216,834 | moodle/moodle | course/classes/category.php | core_course_category.can_request_course | public function can_request_course() {
global $CFG;
if (empty($CFG->enablecourserequests) || $this->id != $CFG->defaultrequestcategory) {
return false;
}
return !$this->can_create_course() && has_capability('moodle/course:request', $this->get_context());
} | php | public function can_request_course() {
global $CFG;
if (empty($CFG->enablecourserequests) || $this->id != $CFG->defaultrequestcategory) {
return false;
}
return !$this->can_create_course() && has_capability('moodle/course:request', $this->get_context());
} | [
"public",
"function",
"can_request_course",
"(",
")",
"{",
"global",
"$",
"CFG",
";",
"if",
"(",
"empty",
"(",
"$",
"CFG",
"->",
"enablecourserequests",
")",
"||",
"$",
"this",
"->",
"id",
"!=",
"$",
"CFG",
"->",
"defaultrequestcategory",
")",
"{",
"retu... | Returns true if the user is able to request a new course be created.
@return bool | [
"Returns",
"true",
"if",
"the",
"user",
"is",
"able",
"to",
"request",
"a",
"new",
"course",
"be",
"created",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/classes/category.php#L2975-L2981 |
216,835 | moodle/moodle | course/classes/category.php | core_course_category.can_approve_course_requests | public static function can_approve_course_requests() {
global $CFG, $DB;
if (empty($CFG->enablecourserequests)) {
return false;
}
$context = context_system::instance();
if (!has_capability('moodle/site:approvecourse', $context)) {
return false;
}
... | php | public static function can_approve_course_requests() {
global $CFG, $DB;
if (empty($CFG->enablecourserequests)) {
return false;
}
$context = context_system::instance();
if (!has_capability('moodle/site:approvecourse', $context)) {
return false;
}
... | [
"public",
"static",
"function",
"can_approve_course_requests",
"(",
")",
"{",
"global",
"$",
"CFG",
",",
"$",
"DB",
";",
"if",
"(",
"empty",
"(",
"$",
"CFG",
"->",
"enablecourserequests",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"context",
"=",
... | Returns true if the user can approve course requests.
@return bool | [
"Returns",
"true",
"if",
"the",
"user",
"can",
"approve",
"course",
"requests",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/classes/category.php#L2987-L3000 |
216,836 | moodle/moodle | lib/oauthlib.php | oauth_helper.sign | public function sign($http_method, $url, $params, $secret) {
$sig = array(
strtoupper($http_method),
preg_replace('/%7E/', '~', rawurlencode($url)),
rawurlencode($this->get_signable_parameters($params)),
);
$base_string = implode('&', $sig);
$sig = ba... | php | public function sign($http_method, $url, $params, $secret) {
$sig = array(
strtoupper($http_method),
preg_replace('/%7E/', '~', rawurlencode($url)),
rawurlencode($this->get_signable_parameters($params)),
);
$base_string = implode('&', $sig);
$sig = ba... | [
"public",
"function",
"sign",
"(",
"$",
"http_method",
",",
"$",
"url",
",",
"$",
"params",
",",
"$",
"secret",
")",
"{",
"$",
"sig",
"=",
"array",
"(",
"strtoupper",
"(",
"$",
"http_method",
")",
",",
"preg_replace",
"(",
"'/%7E/'",
",",
"'~'",
",",... | Create signature for oauth request
@param string $url
@param string $secret
@param array $params
@return string | [
"Create",
"signature",
"for",
"oauth",
"request"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/oauthlib.php#L149-L159 |
216,837 | moodle/moodle | lib/oauthlib.php | oauth_helper.request_token | public function request_token() {
$this->sign_secret = $this->consumer_secret.'&';
if (empty($this->oauth_callback)) {
$params = [];
} else {
$params = ['oauth_callback' => $this->oauth_callback->out(false)];
}
$params = $this->prepare_oauth_parameters($... | php | public function request_token() {
$this->sign_secret = $this->consumer_secret.'&';
if (empty($this->oauth_callback)) {
$params = [];
} else {
$params = ['oauth_callback' => $this->oauth_callback->out(false)];
}
$params = $this->prepare_oauth_parameters($... | [
"public",
"function",
"request_token",
"(",
")",
"{",
"$",
"this",
"->",
"sign_secret",
"=",
"$",
"this",
"->",
"consumer_secret",
".",
"'&'",
";",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"oauth_callback",
")",
")",
"{",
"$",
"params",
"=",
"[",
... | Request token for authentication
This is the first step to use OAuth, it will return oauth_token and oauth_token_secret
@return array | [
"Request",
"token",
"for",
"authentication",
"This",
"is",
"the",
"first",
"step",
"to",
"use",
"OAuth",
"it",
"will",
"return",
"oauth_token",
"and",
"oauth_token_secret"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/oauthlib.php#L219-L241 |
216,838 | moodle/moodle | lib/oauthlib.php | oauth_helper.get_access_token | public function get_access_token($token, $secret, $verifier='') {
$this->sign_secret = $this->consumer_secret.'&'.$secret;
$params = $this->prepare_oauth_parameters($this->access_token_api, array('oauth_token'=>$token, 'oauth_verifier'=>$verifier), 'POST');
$this->setup_oauth_http_header($params... | php | public function get_access_token($token, $secret, $verifier='') {
$this->sign_secret = $this->consumer_secret.'&'.$secret;
$params = $this->prepare_oauth_parameters($this->access_token_api, array('oauth_token'=>$token, 'oauth_verifier'=>$verifier), 'POST');
$this->setup_oauth_http_header($params... | [
"public",
"function",
"get_access_token",
"(",
"$",
"token",
",",
"$",
"secret",
",",
"$",
"verifier",
"=",
"''",
")",
"{",
"$",
"this",
"->",
"sign_secret",
"=",
"$",
"this",
"->",
"consumer_secret",
".",
"'&'",
".",
"$",
"secret",
";",
"$",
"params",... | Request oauth access token from server
@param string $method
@param string $url
@param string $token
@param string $secret | [
"Request",
"oauth",
"access",
"token",
"from",
"server"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/oauthlib.php#L260-L275 |
216,839 | moodle/moodle | lib/oauthlib.php | oauth_helper.request | public function request($method, $url, $params=array(), $token='', $secret='') {
if (empty($token)) {
$token = $this->access_token;
}
if (empty($secret)) {
$secret = $this->access_token_secret;
}
// to access protected resource, sign_secret will alwasy be ... | php | public function request($method, $url, $params=array(), $token='', $secret='') {
if (empty($token)) {
$token = $this->access_token;
}
if (empty($secret)) {
$secret = $this->access_token_secret;
}
// to access protected resource, sign_secret will alwasy be ... | [
"public",
"function",
"request",
"(",
"$",
"method",
",",
"$",
"url",
",",
"$",
"params",
"=",
"array",
"(",
")",
",",
"$",
"token",
"=",
"''",
",",
"$",
"secret",
"=",
"''",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"token",
")",
")",
"{",
"$"... | Request oauth protected resources
@param string $method
@param string $url
@param string $token
@param string $secret | [
"Request",
"oauth",
"protected",
"resources"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/oauthlib.php#L284-L304 |
216,840 | moodle/moodle | lib/oauthlib.php | oauth_helper.get | public function get($url, $params=array(), $token='', $secret='') {
return $this->request('GET', $url, $params, $token, $secret);
} | php | public function get($url, $params=array(), $token='', $secret='') {
return $this->request('GET', $url, $params, $token, $secret);
} | [
"public",
"function",
"get",
"(",
"$",
"url",
",",
"$",
"params",
"=",
"array",
"(",
")",
",",
"$",
"token",
"=",
"''",
",",
"$",
"secret",
"=",
"''",
")",
"{",
"return",
"$",
"this",
"->",
"request",
"(",
"'GET'",
",",
"$",
"url",
",",
"$",
... | shortcut to start http get request | [
"shortcut",
"to",
"start",
"http",
"get",
"request"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/oauthlib.php#L309-L311 |
216,841 | moodle/moodle | lib/oauthlib.php | oauth_helper.post | public function post($url, $params=array(), $token='', $secret='') {
return $this->request('POST', $url, $params, $token, $secret);
} | php | public function post($url, $params=array(), $token='', $secret='') {
return $this->request('POST', $url, $params, $token, $secret);
} | [
"public",
"function",
"post",
"(",
"$",
"url",
",",
"$",
"params",
"=",
"array",
"(",
")",
",",
"$",
"token",
"=",
"''",
",",
"$",
"secret",
"=",
"''",
")",
"{",
"return",
"$",
"this",
"->",
"request",
"(",
"'POST'",
",",
"$",
"url",
",",
"$",
... | shortcut to start http post request | [
"shortcut",
"to",
"start",
"http",
"post",
"request"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/oauthlib.php#L316-L318 |
216,842 | moodle/moodle | lib/oauthlib.php | oauth_helper.parse_result | public function parse_result($str) {
if (empty($str)) {
throw new moodle_exception('error');
}
$parts = explode('&', $str);
$result = array();
foreach ($parts as $part){
list($k, $v) = explode('=', $part, 2);
$result[urldecode($k)] = urldecode(... | php | public function parse_result($str) {
if (empty($str)) {
throw new moodle_exception('error');
}
$parts = explode('&', $str);
$result = array();
foreach ($parts as $part){
list($k, $v) = explode('=', $part, 2);
$result[urldecode($k)] = urldecode(... | [
"public",
"function",
"parse_result",
"(",
"$",
"str",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"str",
")",
")",
"{",
"throw",
"new",
"moodle_exception",
"(",
"'error'",
")",
";",
"}",
"$",
"parts",
"=",
"explode",
"(",
"'&'",
",",
"$",
"str",
")",
... | A method to parse oauth response to get oauth_token and oauth_token_secret
@param string $str
@return array | [
"A",
"method",
"to",
"parse",
"oauth",
"response",
"to",
"get",
"oauth_token",
"and",
"oauth_token_secret"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/oauthlib.php#L325-L339 |
216,843 | moodle/moodle | lib/oauthlib.php | oauth_helper.get_nonce | function get_nonce() {
if (!empty($this->nonce)) {
$nonce = $this->nonce;
unset($this->nonce);
return $nonce;
}
$mt = microtime();
$rand = mt_rand();
return md5($mt . $rand);
} | php | function get_nonce() {
if (!empty($this->nonce)) {
$nonce = $this->nonce;
unset($this->nonce);
return $nonce;
}
$mt = microtime();
$rand = mt_rand();
return md5($mt . $rand);
} | [
"function",
"get_nonce",
"(",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"nonce",
")",
")",
"{",
"$",
"nonce",
"=",
"$",
"this",
"->",
"nonce",
";",
"unset",
"(",
"$",
"this",
"->",
"nonce",
")",
";",
"return",
"$",
"nonce",
";"... | Generate nonce for oauth request | [
"Generate",
"nonce",
"for",
"oauth",
"request"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/oauthlib.php#L367-L377 |
216,844 | moodle/moodle | lib/oauthlib.php | oauth2_client.is_logged_in | public function is_logged_in() {
// Has the token expired?
if (isset($this->accesstoken->expires) && time() >= $this->accesstoken->expires) {
$this->log_out();
return false;
}
// We have a token so we are logged in.
if (isset($this->accesstoken->token)) {... | php | public function is_logged_in() {
// Has the token expired?
if (isset($this->accesstoken->expires) && time() >= $this->accesstoken->expires) {
$this->log_out();
return false;
}
// We have a token so we are logged in.
if (isset($this->accesstoken->token)) {... | [
"public",
"function",
"is_logged_in",
"(",
")",
"{",
"// Has the token expired?",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"accesstoken",
"->",
"expires",
")",
"&&",
"time",
"(",
")",
">=",
"$",
"this",
"->",
"accesstoken",
"->",
"expires",
")",
"{",
... | Is the user logged in? Note that if this is called
after the first part of the authorisation flow the token
is upgraded to an accesstoken.
@return boolean true if logged in | [
"Is",
"the",
"user",
"logged",
"in?",
"Note",
"that",
"if",
"this",
"is",
"called",
"after",
"the",
"first",
"part",
"of",
"the",
"authorisation",
"flow",
"the",
"token",
"is",
"upgraded",
"to",
"an",
"accesstoken",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/oauthlib.php#L445-L480 |
216,845 | moodle/moodle | lib/oauthlib.php | oauth2_client.get_login_url | public function get_login_url() {
$callbackurl = self::callback_url();
$params = array_merge(
[
'client_id' => $this->clientid,
'response_type' => 'code',
'redirect_uri' => $callbackurl->out(false),
'state' => $this->returnurl-... | php | public function get_login_url() {
$callbackurl = self::callback_url();
$params = array_merge(
[
'client_id' => $this->clientid,
'response_type' => 'code',
'redirect_uri' => $callbackurl->out(false),
'state' => $this->returnurl-... | [
"public",
"function",
"get_login_url",
"(",
")",
"{",
"$",
"callbackurl",
"=",
"self",
"::",
"callback_url",
"(",
")",
";",
"$",
"params",
"=",
"array_merge",
"(",
"[",
"'client_id'",
"=>",
"$",
"this",
"->",
"clientid",
",",
"'response_type'",
"=>",
"'cod... | Returns the login link for this oauth request
@return moodle_url login url | [
"Returns",
"the",
"login",
"link",
"for",
"this",
"oauth",
"request"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/oauthlib.php#L507-L522 |
216,846 | moodle/moodle | lib/oauthlib.php | oauth2_client.upgrade_token | public function upgrade_token($code) {
$callbackurl = self::callback_url();
$params = array('code' => $code,
'grant_type' => 'authorization_code',
'redirect_uri' => $callbackurl->out(false),
);
if ($this->basicauth) {
$idsecret = urlencode($this->clie... | php | public function upgrade_token($code) {
$callbackurl = self::callback_url();
$params = array('code' => $code,
'grant_type' => 'authorization_code',
'redirect_uri' => $callbackurl->out(false),
);
if ($this->basicauth) {
$idsecret = urlencode($this->clie... | [
"public",
"function",
"upgrade_token",
"(",
"$",
"code",
")",
"{",
"$",
"callbackurl",
"=",
"self",
"::",
"callback_url",
"(",
")",
";",
"$",
"params",
"=",
"array",
"(",
"'code'",
"=>",
"$",
"code",
",",
"'grant_type'",
"=>",
"'authorization_code'",
",",
... | Upgrade a authorization token from oauth 2.0 to an access token
@param string $code the code returned from the oauth authenticaiton
@return boolean true if token is upgraded succesfully | [
"Upgrade",
"a",
"authorization",
"token",
"from",
"oauth",
"2",
".",
"0",
"to",
"an",
"access",
"token"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/oauthlib.php#L544-L601 |
216,847 | moodle/moodle | lib/oauthlib.php | oauth2_client.request | protected function request($url, $options = array(), $acceptheader = 'application/json') {
$murl = new moodle_url($url);
if ($this->accesstoken) {
if ($this->use_http_get()) {
// If using HTTP GET add as a parameter.
$murl->param('access_token', $this->access... | php | protected function request($url, $options = array(), $acceptheader = 'application/json') {
$murl = new moodle_url($url);
if ($this->accesstoken) {
if ($this->use_http_get()) {
// If using HTTP GET add as a parameter.
$murl->param('access_token', $this->access... | [
"protected",
"function",
"request",
"(",
"$",
"url",
",",
"$",
"options",
"=",
"array",
"(",
")",
",",
"$",
"acceptheader",
"=",
"'application/json'",
")",
"{",
"$",
"murl",
"=",
"new",
"moodle_url",
"(",
"$",
"url",
")",
";",
"if",
"(",
"$",
"this",... | Make a HTTP request, adding the access token we have
@param string $url The URL to request
@param array $options
@param mixed $acceptheader mimetype (as string) or false to skip sending an accept header.
@return bool | [
"Make",
"a",
"HTTP",
"request",
"adding",
"the",
"access",
"token",
"we",
"have"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/oauthlib.php#L618-L639 |
216,848 | moodle/moodle | lib/oauthlib.php | oauth2_client.multi | protected function multi($requests, $options = array()) {
if ($this->accesstoken) {
$this->setHeader('Authorization: Bearer '.$this->accesstoken->token);
}
return parent::multi($requests, $options);
} | php | protected function multi($requests, $options = array()) {
if ($this->accesstoken) {
$this->setHeader('Authorization: Bearer '.$this->accesstoken->token);
}
return parent::multi($requests, $options);
} | [
"protected",
"function",
"multi",
"(",
"$",
"requests",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"accesstoken",
")",
"{",
"$",
"this",
"->",
"setHeader",
"(",
"'Authorization: Bearer '",
".",
"$",
"this",
"->... | Multiple HTTP Requests
This function could run multi-requests in parallel.
@param array $requests An array of files to request
@param array $options An array of options to set
@return array An array of results | [
"Multiple",
"HTTP",
"Requests",
"This",
"function",
"could",
"run",
"multi",
"-",
"requests",
"in",
"parallel",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/oauthlib.php#L649-L654 |
216,849 | moodle/moodle | lib/oauthlib.php | oauth2_client.store_token | protected function store_token($token) {
global $SESSION;
$this->accesstoken = $token;
$name = $this->get_tokenname();
if ($token !== null) {
$SESSION->{$name} = $token;
} else {
unset($SESSION->{$name});
}
} | php | protected function store_token($token) {
global $SESSION;
$this->accesstoken = $token;
$name = $this->get_tokenname();
if ($token !== null) {
$SESSION->{$name} = $token;
} else {
unset($SESSION->{$name});
}
} | [
"protected",
"function",
"store_token",
"(",
"$",
"token",
")",
"{",
"global",
"$",
"SESSION",
";",
"$",
"this",
"->",
"accesstoken",
"=",
"$",
"token",
";",
"$",
"name",
"=",
"$",
"this",
"->",
"get_tokenname",
"(",
")",
";",
"if",
"(",
"$",
"token"... | Store a token between requests. Currently uses
session named by get_tokenname
@param stdClass|null $token token object to store or null to clear | [
"Store",
"a",
"token",
"between",
"requests",
".",
"Currently",
"uses",
"session",
"named",
"by",
"get_tokenname"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/oauthlib.php#L676-L687 |
216,850 | moodle/moodle | lib/oauthlib.php | oauth2_client.get_stored_token | protected function get_stored_token() {
global $SESSION;
$name = $this->get_tokenname();
if (isset($SESSION->{$name})) {
return $SESSION->{$name};
}
return null;
} | php | protected function get_stored_token() {
global $SESSION;
$name = $this->get_tokenname();
if (isset($SESSION->{$name})) {
return $SESSION->{$name};
}
return null;
} | [
"protected",
"function",
"get_stored_token",
"(",
")",
"{",
"global",
"$",
"SESSION",
";",
"$",
"name",
"=",
"$",
"this",
"->",
"get_tokenname",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"SESSION",
"->",
"{",
"$",
"name",
"}",
")",
")",
"{",
"re... | Retrieve a token stored.
@return stdClass|null token object | [
"Retrieve",
"a",
"token",
"stored",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/oauthlib.php#L703-L713 |
216,851 | moodle/moodle | lib/horde/framework/Horde/Mail/Transport/Smtp.php | Horde_Mail_Transport_Smtp.disconnect | public function disconnect()
{
/* If we have an SMTP object, disconnect and destroy it. */
if (is_object($this->_smtp) && $this->_smtp->disconnect()) {
$this->_smtp = null;
}
/* We are disconnected if we no longer have an SMTP object. */
return ($this->_smtp === ... | php | public function disconnect()
{
/* If we have an SMTP object, disconnect and destroy it. */
if (is_object($this->_smtp) && $this->_smtp->disconnect()) {
$this->_smtp = null;
}
/* We are disconnected if we no longer have an SMTP object. */
return ($this->_smtp === ... | [
"public",
"function",
"disconnect",
"(",
")",
"{",
"/* If we have an SMTP object, disconnect and destroy it. */",
"if",
"(",
"is_object",
"(",
"$",
"this",
"->",
"_smtp",
")",
"&&",
"$",
"this",
"->",
"_smtp",
"->",
"disconnect",
"(",
")",
")",
"{",
"$",
"this... | Disconnect and destroy the current SMTP connection.
@return boolean True if the SMTP connection no longer exists. | [
"Disconnect",
"and",
"destroy",
"the",
"current",
"SMTP",
"connection",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Mail/Transport/Smtp.php#L318-L327 |
216,852 | moodle/moodle | repository/onedrive/lib.php | repository_onedrive.print_login | public function print_login() {
$client = $this->get_user_oauth_client();
$url = $client->get_login_url();
if ($this->options['ajax']) {
$popup = new stdClass();
$popup->type = 'popup';
$popup->url = $url->out(false);
return array('login' => array... | php | public function print_login() {
$client = $this->get_user_oauth_client();
$url = $client->get_login_url();
if ($this->options['ajax']) {
$popup = new stdClass();
$popup->type = 'popup';
$popup->url = $url->out(false);
return array('login' => array... | [
"public",
"function",
"print_login",
"(",
")",
"{",
"$",
"client",
"=",
"$",
"this",
"->",
"get_user_oauth_client",
"(",
")",
";",
"$",
"url",
"=",
"$",
"client",
"->",
"get_login_url",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"options",
"[",
"'a... | Print or return the login form.
@return void|array for ajax. | [
"Print",
"or",
"return",
"the",
"login",
"form",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/repository/onedrive/lib.php#L116-L128 |
216,853 | moodle/moodle | repository/onedrive/lib.php | repository_onedrive.print_login_popup | public function print_login_popup($attr = null) {
global $OUTPUT, $PAGE;
$client = $this->get_user_oauth_client(false);
$url = new moodle_url($client->get_login_url());
$state = $url->get_param('state') . '&reloadparent=true';
$url->param('state', $state);
$PAGE->set_pa... | php | public function print_login_popup($attr = null) {
global $OUTPUT, $PAGE;
$client = $this->get_user_oauth_client(false);
$url = new moodle_url($client->get_login_url());
$state = $url->get_param('state') . '&reloadparent=true';
$url->param('state', $state);
$PAGE->set_pa... | [
"public",
"function",
"print_login_popup",
"(",
"$",
"attr",
"=",
"null",
")",
"{",
"global",
"$",
"OUTPUT",
",",
"$",
"PAGE",
";",
"$",
"client",
"=",
"$",
"this",
"->",
"get_user_oauth_client",
"(",
"false",
")",
";",
"$",
"url",
"=",
"new",
"moodle_... | Print the login in a popup.
@param array|null $attr Custom attributes to be applied to popup div. | [
"Print",
"the",
"login",
"in",
"a",
"popup",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/repository/onedrive/lib.php#L135-L155 |
216,854 | moodle/moodle | repository/onedrive/lib.php | repository_onedrive.build_breadcrumb | protected function build_breadcrumb($path) {
$bread = explode('/', $path);
$crumbtrail = '';
foreach ($bread as $crumb) {
list($id, $name) = $this->explode_node_path($crumb);
$name = empty($name) ? $id : $name;
$breadcrumb[] = array(
'name' => ... | php | protected function build_breadcrumb($path) {
$bread = explode('/', $path);
$crumbtrail = '';
foreach ($bread as $crumb) {
list($id, $name) = $this->explode_node_path($crumb);
$name = empty($name) ? $id : $name;
$breadcrumb[] = array(
'name' => ... | [
"protected",
"function",
"build_breadcrumb",
"(",
"$",
"path",
")",
"{",
"$",
"bread",
"=",
"explode",
"(",
"'/'",
",",
"$",
"path",
")",
";",
"$",
"crumbtrail",
"=",
"''",
";",
"foreach",
"(",
"$",
"bread",
"as",
"$",
"crumb",
")",
"{",
"list",
"(... | Build the breadcrumb from a path.
@param string $path to create a breadcrumb from.
@return array containing name and path of each crumb. | [
"Build",
"the",
"breadcrumb",
"from",
"a",
"path",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/repository/onedrive/lib.php#L163-L177 |
216,855 | moodle/moodle | repository/onedrive/lib.php | repository_onedrive.build_node_path | protected function build_node_path($id, $name = '', $root = '') {
$path = $id;
if (!empty($name)) {
$path .= '|' . urlencode($name);
}
if (!empty($root)) {
$path = trim($root, '/') . '/' . $path;
}
return $path;
} | php | protected function build_node_path($id, $name = '', $root = '') {
$path = $id;
if (!empty($name)) {
$path .= '|' . urlencode($name);
}
if (!empty($root)) {
$path = trim($root, '/') . '/' . $path;
}
return $path;
} | [
"protected",
"function",
"build_node_path",
"(",
"$",
"id",
",",
"$",
"name",
"=",
"''",
",",
"$",
"root",
"=",
"''",
")",
"{",
"$",
"path",
"=",
"$",
"id",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"name",
")",
")",
"{",
"$",
"path",
".=",
"'|... | Generates a safe path to a node.
Typically, a node will be id|Name of the node.
@param string $id of the node.
@param string $name of the node, will be URL encoded.
@param string $root to append the node on, must be a result of this function.
@return string path to the node. | [
"Generates",
"a",
"safe",
"path",
"to",
"a",
"node",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/repository/onedrive/lib.php#L189-L198 |
216,856 | moodle/moodle | repository/onedrive/lib.php | repository_onedrive.explode_node_path | protected function explode_node_path($node) {
if (strpos($node, '|') !== false) {
list($id, $name) = explode('|', $node, 2);
$name = urldecode($name);
} else {
$id = $node;
$name = '';
}
$id = urldecode($id);
return array(
... | php | protected function explode_node_path($node) {
if (strpos($node, '|') !== false) {
list($id, $name) = explode('|', $node, 2);
$name = urldecode($name);
} else {
$id = $node;
$name = '';
}
$id = urldecode($id);
return array(
... | [
"protected",
"function",
"explode_node_path",
"(",
"$",
"node",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"node",
",",
"'|'",
")",
"!==",
"false",
")",
"{",
"list",
"(",
"$",
"id",
",",
"$",
"name",
")",
"=",
"explode",
"(",
"'|'",
",",
"$",
"node... | Returns information about a node in a path.
@see self::build_node_path()
@param string $node to extrat information from.
@return array about the node. | [
"Returns",
"information",
"about",
"a",
"node",
"in",
"a",
"path",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/repository/onedrive/lib.php#L207-L222 |
216,857 | moodle/moodle | repository/onedrive/lib.php | repository_onedrive.delete_file_by_path | protected function delete_file_by_path(\repository_onedrive\rest $client, $fullpath) {
try {
$response = $client->call('delete_file_by_path', ['fullpath' => $fullpath]);
} catch (\core\oauth2\rest_exception $re) {
return false;
}
return true;
} | php | protected function delete_file_by_path(\repository_onedrive\rest $client, $fullpath) {
try {
$response = $client->call('delete_file_by_path', ['fullpath' => $fullpath]);
} catch (\core\oauth2\rest_exception $re) {
return false;
}
return true;
} | [
"protected",
"function",
"delete_file_by_path",
"(",
"\\",
"repository_onedrive",
"\\",
"rest",
"$",
"client",
",",
"$",
"fullpath",
")",
"{",
"try",
"{",
"$",
"response",
"=",
"$",
"client",
"->",
"call",
"(",
"'delete_file_by_path'",
",",
"[",
"'fullpath'",
... | Delete a file by full path.
@param \repository_onedrive\rest $client Authenticated client.
@param string $fullpath
@return boolean | [
"Delete",
"a",
"file",
"by",
"full",
"path",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/repository/onedrive/lib.php#L653-L660 |
216,858 | moodle/moodle | repository/onedrive/lib.php | repository_onedrive.create_folder_in_folder | protected function create_folder_in_folder(\repository_onedrive\rest $client, $foldername, $parentid) {
$params = ['parentid' => $parentid];
$folder = [ 'name' => $foldername, 'folder' => [ 'childCount' => 0 ]];
$created = $client->call('create_folder', $params, json_encode($folder));
if... | php | protected function create_folder_in_folder(\repository_onedrive\rest $client, $foldername, $parentid) {
$params = ['parentid' => $parentid];
$folder = [ 'name' => $foldername, 'folder' => [ 'childCount' => 0 ]];
$created = $client->call('create_folder', $params, json_encode($folder));
if... | [
"protected",
"function",
"create_folder_in_folder",
"(",
"\\",
"repository_onedrive",
"\\",
"rest",
"$",
"client",
",",
"$",
"foldername",
",",
"$",
"parentid",
")",
"{",
"$",
"params",
"=",
"[",
"'parentid'",
"=>",
"$",
"parentid",
"]",
";",
"$",
"folder",
... | Create a folder within a folder
@param \repository_onedrive\rest $client Authenticated client.
@param string $foldername The folder we are creating.
@param string $parentid The parent folder we are creating in.
@return string The file id of the new folder. | [
"Create",
"a",
"folder",
"within",
"a",
"folder"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/repository/onedrive/lib.php#L671-L680 |
216,859 | moodle/moodle | repository/onedrive/lib.php | repository_onedrive.get_mimetype_from_filename | protected function get_mimetype_from_filename($filename) {
$mimetype = 'application/unknown';
$types = core_filetypes::get_types();
$fileextension = '.bin';
if (strpos($filename, '.') !== false) {
$fileextension = substr($filename, strrpos($filename, '.') + 1);
}
... | php | protected function get_mimetype_from_filename($filename) {
$mimetype = 'application/unknown';
$types = core_filetypes::get_types();
$fileextension = '.bin';
if (strpos($filename, '.') !== false) {
$fileextension = substr($filename, strrpos($filename, '.') + 1);
}
... | [
"protected",
"function",
"get_mimetype_from_filename",
"(",
"$",
"filename",
")",
"{",
"$",
"mimetype",
"=",
"'application/unknown'",
";",
"$",
"types",
"=",
"core_filetypes",
"::",
"get_types",
"(",
")",
";",
"$",
"fileextension",
"=",
"'.bin'",
";",
"if",
"(... | Given a filename, use the core_filetypes registered types to guess a mimetype.
If no mimetype is known, return 'application/unknown';
@param string $filename
@return string $mimetype | [
"Given",
"a",
"filename",
"use",
"the",
"core_filetypes",
"registered",
"types",
"to",
"guess",
"a",
"mimetype",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/repository/onedrive/lib.php#L764-L776 |
216,860 | moodle/moodle | repository/onedrive/lib.php | repository_onedrive.upload_file | protected function upload_file(\repository_onedrive\rest $service, \curl $curl, \curl $authcurl,
$filepath, $mimetype, $parentid, $filename) {
// Start an upload session.
// Docs https://developer.microsoft.com/en-us/graph/docs/api-reference/v1.0/api/item_createuploads... | php | protected function upload_file(\repository_onedrive\rest $service, \curl $curl, \curl $authcurl,
$filepath, $mimetype, $parentid, $filename) {
// Start an upload session.
// Docs https://developer.microsoft.com/en-us/graph/docs/api-reference/v1.0/api/item_createuploads... | [
"protected",
"function",
"upload_file",
"(",
"\\",
"repository_onedrive",
"\\",
"rest",
"$",
"service",
",",
"\\",
"curl",
"$",
"curl",
",",
"\\",
"curl",
"$",
"authcurl",
",",
"$",
"filepath",
",",
"$",
"mimetype",
",",
"$",
"parentid",
",",
"$",
"filen... | Upload a file to onedrive.
@param \repository_onedrive\rest $service Authenticated client.
@param \curl $curl Curl client to perform the put operation (with no auth headers).
@param \curl $authcurl Curl client that will send authentication headers
@param string $filepath The local path to the file to upload
@param str... | [
"Upload",
"a",
"file",
"to",
"onedrive",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/repository/onedrive/lib.php#L790-L830 |
216,861 | moodle/moodle | repository/onedrive/lib.php | repository_onedrive.get_reference_details | public function get_reference_details($reference, $filestatus = 0) {
if (empty($reference)) {
return get_string('unknownsource', 'repository');
}
$source = json_decode($reference);
if (empty($source->usesystem)) {
return '';
}
$systemauth = \core\o... | php | public function get_reference_details($reference, $filestatus = 0) {
if (empty($reference)) {
return get_string('unknownsource', 'repository');
}
$source = json_decode($reference);
if (empty($source->usesystem)) {
return '';
}
$systemauth = \core\o... | [
"public",
"function",
"get_reference_details",
"(",
"$",
"reference",
",",
"$",
"filestatus",
"=",
"0",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"reference",
")",
")",
"{",
"return",
"get_string",
"(",
"'unknownsource'",
",",
"'repository'",
")",
";",
"}",
... | Get human readable file info from the reference.
@param string $reference
@param int $filestatus | [
"Get",
"human",
"readable",
"file",
"info",
"from",
"the",
"reference",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/repository/onedrive/lib.php#L980-L1005 |
216,862 | moodle/moodle | repository/onedrive/lib.php | repository_onedrive.can_import_skydrive_files | public static function can_import_skydrive_files() {
global $DB;
$skydrive = $DB->get_record('repository', ['type' => 'skydrive'], 'id', IGNORE_MISSING);
$onedrive = $DB->get_record('repository', ['type' => 'onedrive'], 'id', IGNORE_MISSING);
if (empty($skydrive) || empty($onedrive)) {... | php | public static function can_import_skydrive_files() {
global $DB;
$skydrive = $DB->get_record('repository', ['type' => 'skydrive'], 'id', IGNORE_MISSING);
$onedrive = $DB->get_record('repository', ['type' => 'onedrive'], 'id', IGNORE_MISSING);
if (empty($skydrive) || empty($onedrive)) {... | [
"public",
"static",
"function",
"can_import_skydrive_files",
"(",
")",
"{",
"global",
"$",
"DB",
";",
"$",
"skydrive",
"=",
"$",
"DB",
"->",
"get_record",
"(",
"'repository'",
",",
"[",
"'type'",
"=>",
"'skydrive'",
"]",
",",
"'id'",
",",
"IGNORE_MISSING",
... | Return true if any instances of the skydrive repo exist - and we can import them.
@return bool | [
"Return",
"true",
"if",
"any",
"instances",
"of",
"the",
"skydrive",
"repo",
"exist",
"-",
"and",
"we",
"can",
"import",
"them",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/repository/onedrive/lib.php#L1012-L1043 |
216,863 | moodle/moodle | repository/onedrive/lib.php | repository_onedrive.import_skydrive_files | public static function import_skydrive_files() {
global $DB;
if (!self::can_import_skydrive_files()) {
return false;
}
// Should only be one of each.
$skydrivetype = repository::get_type_by_typename('skydrive');
$skydriveinstances = repository::get_instances... | php | public static function import_skydrive_files() {
global $DB;
if (!self::can_import_skydrive_files()) {
return false;
}
// Should only be one of each.
$skydrivetype = repository::get_type_by_typename('skydrive');
$skydriveinstances = repository::get_instances... | [
"public",
"static",
"function",
"import_skydrive_files",
"(",
")",
"{",
"global",
"$",
"DB",
";",
"if",
"(",
"!",
"self",
"::",
"can_import_skydrive_files",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"// Should only be one of each.",
"$",
"skydrivetype",
... | Import all the files that were created with the skydrive repo to this repo.
@return bool | [
"Import",
"all",
"the",
"files",
"that",
"were",
"created",
"with",
"the",
"skydrive",
"repo",
"to",
"this",
"repo",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/repository/onedrive/lib.php#L1050-L1076 |
216,864 | moodle/moodle | blocks/activity_results/backup/moodle2/restore_activity_results_block_task.class.php | restore_activity_results_block_task.after_restore | public function after_restore() {
global $DB;
// Get the blockid.
$blockid = $this->get_blockid();
if ($configdata = $DB->get_field('block_instances', 'configdata', array('id' => $blockid))) {
$config = unserialize(base64_decode($configdata));
if (!empty($config... | php | public function after_restore() {
global $DB;
// Get the blockid.
$blockid = $this->get_blockid();
if ($configdata = $DB->get_field('block_instances', 'configdata', array('id' => $blockid))) {
$config = unserialize(base64_decode($configdata));
if (!empty($config... | [
"public",
"function",
"after_restore",
"(",
")",
"{",
"global",
"$",
"DB",
";",
"// Get the blockid.",
"$",
"blockid",
"=",
"$",
"this",
"->",
"get_blockid",
"(",
")",
";",
"if",
"(",
"$",
"configdata",
"=",
"$",
"DB",
"->",
"get_field",
"(",
"'block_ins... | This function, executed after all the tasks in the plan
have been executed, will perform the recode of the
target activity for the block. This must be done here
and not in normal execution steps because the activity
can be restored after the block. | [
"This",
"function",
"executed",
"after",
"all",
"the",
"tasks",
"in",
"the",
"plan",
"have",
"been",
"executed",
"will",
"perform",
"the",
"recode",
"of",
"the",
"target",
"activity",
"for",
"the",
"block",
".",
"This",
"must",
"be",
"done",
"here",
"and",... | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/blocks/activity_results/backup/moodle2/restore_activity_results_block_task.class.php#L69-L98 |
216,865 | moodle/moodle | admin/tool/usertours/classes/local/filter/base.php | base.save_filter_values_from_form | public static function save_filter_values_from_form(tour $tour, \stdClass $data) {
$filtername = static::get_filter_name();
$key = "filter_{$filtername}";
$newvalue = $data->$key;
foreach ($data->$key as $value) {
if ($value === static::ANYVALUE) {
$newvalue... | php | public static function save_filter_values_from_form(tour $tour, \stdClass $data) {
$filtername = static::get_filter_name();
$key = "filter_{$filtername}";
$newvalue = $data->$key;
foreach ($data->$key as $value) {
if ($value === static::ANYVALUE) {
$newvalue... | [
"public",
"static",
"function",
"save_filter_values_from_form",
"(",
"tour",
"$",
"tour",
",",
"\\",
"stdClass",
"$",
"data",
")",
"{",
"$",
"filtername",
"=",
"static",
"::",
"get_filter_name",
"(",
")",
";",
"$",
"key",
"=",
"\"filter_{$filtername}\"",
";",
... | Save the filter values from the form to the tour.
@param tour $tour The tour to save values to
@param stdClass $data The data submitted in the form | [
"Save",
"the",
"filter",
"values",
"from",
"the",
"form",
"to",
"the",
"tour",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/admin/tool/usertours/classes/local/filter/base.php#L120-L134 |
216,866 | moodle/moodle | customfield/classes/handler.php | handler.get_field_config_form | public function get_field_config_form(field_controller $field) : field_config_form {
$form = new field_config_form(null, ['field' => $field]);
$form->set_data(api::prepare_field_for_config_form($field));
return $form;
} | php | public function get_field_config_form(field_controller $field) : field_config_form {
$form = new field_config_form(null, ['field' => $field]);
$form->set_data(api::prepare_field_for_config_form($field));
return $form;
} | [
"public",
"function",
"get_field_config_form",
"(",
"field_controller",
"$",
"field",
")",
":",
"field_config_form",
"{",
"$",
"form",
"=",
"new",
"field_config_form",
"(",
"null",
",",
"[",
"'field'",
"=>",
"$",
"field",
"]",
")",
";",
"$",
"form",
"->",
... | The form to create or edit a field
@param field_controller $field
@return field_config_form | [
"The",
"form",
"to",
"create",
"or",
"edit",
"a",
"field"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/customfield/classes/handler.php#L187-L191 |
216,867 | moodle/moodle | customfield/classes/handler.php | handler.create_category | public function create_category(string $name = null) : int {
global $DB;
$params = ['component' => $this->get_component(), 'area' => $this->get_area(), 'itemid' => $this->get_itemid()];
if (empty($name)) {
for ($suffix = 0; $suffix < 100; $suffix++) {
$name = $this->... | php | public function create_category(string $name = null) : int {
global $DB;
$params = ['component' => $this->get_component(), 'area' => $this->get_area(), 'itemid' => $this->get_itemid()];
if (empty($name)) {
for ($suffix = 0; $suffix < 100; $suffix++) {
$name = $this->... | [
"public",
"function",
"create_category",
"(",
"string",
"$",
"name",
"=",
"null",
")",
":",
"int",
"{",
"global",
"$",
"DB",
";",
"$",
"params",
"=",
"[",
"'component'",
"=>",
"$",
"this",
"->",
"get_component",
"(",
")",
",",
"'area'",
"=>",
"$",
"t... | Creates a new category and inserts it to the database
@param string $name name of the category, null to generate automatically
@return int id of the new category | [
"Creates",
"a",
"new",
"category",
"and",
"inserts",
"it",
"to",
"the",
"database"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/customfield/classes/handler.php#L213-L230 |
216,868 | moodle/moodle | customfield/classes/handler.php | handler.validate_category | protected function validate_category(category_controller $category) : category_controller {
$categories = $this->get_categories_with_fields();
if (!array_key_exists($category->get('id'), $categories)) {
throw new \moodle_exception('categorynotfound', 'core_customfield');
}
re... | php | protected function validate_category(category_controller $category) : category_controller {
$categories = $this->get_categories_with_fields();
if (!array_key_exists($category->get('id'), $categories)) {
throw new \moodle_exception('categorynotfound', 'core_customfield');
}
re... | [
"protected",
"function",
"validate_category",
"(",
"category_controller",
"$",
"category",
")",
":",
"category_controller",
"{",
"$",
"categories",
"=",
"$",
"this",
"->",
"get_categories_with_fields",
"(",
")",
";",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
... | Validate that the given category belongs to this handler
@param category_controller $category
@return category_controller
@throws \moodle_exception | [
"Validate",
"that",
"the",
"given",
"category",
"belongs",
"to",
"this",
"handler"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/customfield/classes/handler.php#L239-L245 |
216,869 | moodle/moodle | customfield/classes/handler.php | handler.validate_field | protected function validate_field(field_controller $field) : field_controller {
if (!array_key_exists($field->get('categoryid'), $this->get_categories_with_fields())) {
throw new \moodle_exception('fieldnotfound', 'core_customfield');
}
$category = $this->get_categories_with_fields()... | php | protected function validate_field(field_controller $field) : field_controller {
if (!array_key_exists($field->get('categoryid'), $this->get_categories_with_fields())) {
throw new \moodle_exception('fieldnotfound', 'core_customfield');
}
$category = $this->get_categories_with_fields()... | [
"protected",
"function",
"validate_field",
"(",
"field_controller",
"$",
"field",
")",
":",
"field_controller",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"field",
"->",
"get",
"(",
"'categoryid'",
")",
",",
"$",
"this",
"->",
"get_categories_with_fields... | Validate that the given field belongs to this handler
@param field_controller $field
@return field_controller
@throws \moodle_exception | [
"Validate",
"that",
"the",
"given",
"field",
"belongs",
"to",
"this",
"handler"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/customfield/classes/handler.php#L254-L263 |
216,870 | moodle/moodle | customfield/classes/handler.php | handler.rename_category | public function rename_category(category_controller $category, string $name) {
$this->validate_category($category);
$category->set('name', $name);
api::save_category($category);
$this->clear_configuration_cache();
} | php | public function rename_category(category_controller $category, string $name) {
$this->validate_category($category);
$category->set('name', $name);
api::save_category($category);
$this->clear_configuration_cache();
} | [
"public",
"function",
"rename_category",
"(",
"category_controller",
"$",
"category",
",",
"string",
"$",
"name",
")",
"{",
"$",
"this",
"->",
"validate_category",
"(",
"$",
"category",
")",
";",
"$",
"category",
"->",
"set",
"(",
"'name'",
",",
"$",
"name... | Change name for a field category
@param category_controller $category
@param string $name | [
"Change",
"name",
"for",
"a",
"field",
"category"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/customfield/classes/handler.php#L271-L276 |
216,871 | moodle/moodle | customfield/classes/handler.php | handler.move_category | public function move_category(category_controller $category, int $beforeid = 0) {
$category = $this->validate_category($category);
api::move_category($category, $beforeid);
$this->clear_configuration_cache();
} | php | public function move_category(category_controller $category, int $beforeid = 0) {
$category = $this->validate_category($category);
api::move_category($category, $beforeid);
$this->clear_configuration_cache();
} | [
"public",
"function",
"move_category",
"(",
"category_controller",
"$",
"category",
",",
"int",
"$",
"beforeid",
"=",
"0",
")",
"{",
"$",
"category",
"=",
"$",
"this",
"->",
"validate_category",
"(",
"$",
"category",
")",
";",
"api",
"::",
"move_category",
... | Change sort order of the categories
@param category_controller $category category that needs to be moved
@param int $beforeid id of the category this category needs to be moved before, 0 to move to the end | [
"Change",
"sort",
"order",
"of",
"the",
"categories"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/customfield/classes/handler.php#L284-L288 |
216,872 | moodle/moodle | customfield/classes/handler.php | handler.delete_category | public function delete_category(category_controller $category) : bool {
$category = $this->validate_category($category);
$result = api::delete_category($category);
$this->clear_configuration_cache();
return $result;
} | php | public function delete_category(category_controller $category) : bool {
$category = $this->validate_category($category);
$result = api::delete_category($category);
$this->clear_configuration_cache();
return $result;
} | [
"public",
"function",
"delete_category",
"(",
"category_controller",
"$",
"category",
")",
":",
"bool",
"{",
"$",
"category",
"=",
"$",
"this",
"->",
"validate_category",
"(",
"$",
"category",
")",
";",
"$",
"result",
"=",
"api",
"::",
"delete_category",
"("... | Permanently delete category, all fields in it and all associated data
@param category_controller $category
@return bool | [
"Permanently",
"delete",
"category",
"all",
"fields",
"in",
"it",
"and",
"all",
"associated",
"data"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/customfield/classes/handler.php#L296-L301 |
216,873 | moodle/moodle | customfield/classes/handler.php | handler.delete_all | public function delete_all() {
$categories = $this->get_categories_with_fields();
foreach ($categories as $category) {
api::delete_category($category);
}
$this->clear_configuration_cache();
} | php | public function delete_all() {
$categories = $this->get_categories_with_fields();
foreach ($categories as $category) {
api::delete_category($category);
}
$this->clear_configuration_cache();
} | [
"public",
"function",
"delete_all",
"(",
")",
"{",
"$",
"categories",
"=",
"$",
"this",
"->",
"get_categories_with_fields",
"(",
")",
";",
"foreach",
"(",
"$",
"categories",
"as",
"$",
"category",
")",
"{",
"api",
"::",
"delete_category",
"(",
"$",
"catego... | Deletes all data and all fields and categories defined in this handler | [
"Deletes",
"all",
"data",
"and",
"all",
"fields",
"and",
"categories",
"defined",
"in",
"this",
"handler"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/customfield/classes/handler.php#L306-L312 |
216,874 | moodle/moodle | customfield/classes/handler.php | handler.delete_field_configuration | public function delete_field_configuration(field_controller $field) : bool {
$field = $this->validate_field($field);
$result = api::delete_field_configuration($field);
$this->clear_configuration_cache();
return $result;
} | php | public function delete_field_configuration(field_controller $field) : bool {
$field = $this->validate_field($field);
$result = api::delete_field_configuration($field);
$this->clear_configuration_cache();
return $result;
} | [
"public",
"function",
"delete_field_configuration",
"(",
"field_controller",
"$",
"field",
")",
":",
"bool",
"{",
"$",
"field",
"=",
"$",
"this",
"->",
"validate_field",
"(",
"$",
"field",
")",
";",
"$",
"result",
"=",
"api",
"::",
"delete_field_configuration"... | Permanently delete a custom field configuration and all associated data
@param field_controller $field
@return bool | [
"Permanently",
"delete",
"a",
"custom",
"field",
"configuration",
"and",
"all",
"associated",
"data"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/customfield/classes/handler.php#L320-L325 |
216,875 | moodle/moodle | customfield/classes/handler.php | handler.get_instance_data | public function get_instance_data(int $instanceid, bool $returnall = false) : array {
$fields = $returnall ? $this->get_fields() : $this->get_visible_fields($instanceid);
return api::get_instance_fields_data($fields, $instanceid);
} | php | public function get_instance_data(int $instanceid, bool $returnall = false) : array {
$fields = $returnall ? $this->get_fields() : $this->get_visible_fields($instanceid);
return api::get_instance_fields_data($fields, $instanceid);
} | [
"public",
"function",
"get_instance_data",
"(",
"int",
"$",
"instanceid",
",",
"bool",
"$",
"returnall",
"=",
"false",
")",
":",
"array",
"{",
"$",
"fields",
"=",
"$",
"returnall",
"?",
"$",
"this",
"->",
"get_fields",
"(",
")",
":",
"$",
"this",
"->",... | Returns the custom field values for an individual instance
The caller must check access to the instance itself before invoking this method
The result is an array of data_controller objects
@param int $instanceid
@param bool $returnall return data for all fields (by default only visible fields)
@return data_controlle... | [
"Returns",
"the",
"custom",
"field",
"values",
"for",
"an",
"individual",
"instance"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/customfield/classes/handler.php#L387-L390 |
216,876 | moodle/moodle | customfield/classes/handler.php | handler.get_instances_data | public function get_instances_data(array $instanceids, bool $returnall = false) : array {
$result = api::get_instances_fields_data($this->get_fields(), $instanceids);
if (!$returnall) {
// Filter only by visible fields (list of visible fields may be different for each instance).
... | php | public function get_instances_data(array $instanceids, bool $returnall = false) : array {
$result = api::get_instances_fields_data($this->get_fields(), $instanceids);
if (!$returnall) {
// Filter only by visible fields (list of visible fields may be different for each instance).
... | [
"public",
"function",
"get_instances_data",
"(",
"array",
"$",
"instanceids",
",",
"bool",
"$",
"returnall",
"=",
"false",
")",
":",
"array",
"{",
"$",
"result",
"=",
"api",
"::",
"get_instances_fields_data",
"(",
"$",
"this",
"->",
"get_fields",
"(",
")",
... | Returns the custom fields values for multiple instances
The caller must check access to the instance itself before invoking this method
The result is an array of data_controller objects
@param int[] $instanceids
@param bool $returnall return data for all fields (by default only visible fields)
@return data_controlle... | [
"Returns",
"the",
"custom",
"fields",
"values",
"for",
"multiple",
"instances"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/customfield/classes/handler.php#L405-L418 |
216,877 | moodle/moodle | customfield/classes/handler.php | handler.display_custom_fields_data | public function display_custom_fields_data(array $fieldsdata) : string {
global $PAGE;
$output = $PAGE->get_renderer('core_customfield');
$content = '';
foreach ($fieldsdata as $data) {
$fd = new field_data($data);
$content .= $output->render($fd);
}
... | php | public function display_custom_fields_data(array $fieldsdata) : string {
global $PAGE;
$output = $PAGE->get_renderer('core_customfield');
$content = '';
foreach ($fieldsdata as $data) {
$fd = new field_data($data);
$content .= $output->render($fd);
}
... | [
"public",
"function",
"display_custom_fields_data",
"(",
"array",
"$",
"fieldsdata",
")",
":",
"string",
"{",
"global",
"$",
"PAGE",
";",
"$",
"output",
"=",
"$",
"PAGE",
"->",
"get_renderer",
"(",
"'core_customfield'",
")",
";",
"$",
"content",
"=",
"''",
... | Display visible custom fields.
This is a sample implementation that can be overridden in each handler.
@param data_controller[] $fieldsdata
@return string | [
"Display",
"visible",
"custom",
"fields",
".",
"This",
"is",
"a",
"sample",
"implementation",
"that",
"can",
"be",
"overridden",
"in",
"each",
"handler",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/customfield/classes/handler.php#L463-L473 |
216,878 | moodle/moodle | customfield/classes/handler.php | handler.get_categories_with_fields | public function get_categories_with_fields() : array {
if ($this->categories === null) {
$this->categories = api::get_categories_with_fields($this->get_component(), $this->get_area(), $this->get_itemid());
}
$handler = $this;
array_walk($this->categories, function(category_co... | php | public function get_categories_with_fields() : array {
if ($this->categories === null) {
$this->categories = api::get_categories_with_fields($this->get_component(), $this->get_area(), $this->get_itemid());
}
$handler = $this;
array_walk($this->categories, function(category_co... | [
"public",
"function",
"get_categories_with_fields",
"(",
")",
":",
"array",
"{",
"if",
"(",
"$",
"this",
"->",
"categories",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"categories",
"=",
"api",
"::",
"get_categories_with_fields",
"(",
"$",
"this",
"->",
"... | Returns array of categories, each of them contains a list of fields definitions.
@return category_controller[] | [
"Returns",
"array",
"of",
"categories",
"each",
"of",
"them",
"contains",
"a",
"list",
"of",
"fields",
"definitions",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/customfield/classes/handler.php#L480-L489 |
216,879 | moodle/moodle | customfield/classes/handler.php | handler.can_backup | protected function can_backup(field_controller $field, int $instanceid) : bool {
return $this->can_view($field, $instanceid) || $this->can_edit($field, $instanceid);
} | php | protected function can_backup(field_controller $field, int $instanceid) : bool {
return $this->can_view($field, $instanceid) || $this->can_edit($field, $instanceid);
} | [
"protected",
"function",
"can_backup",
"(",
"field_controller",
"$",
"field",
",",
"int",
"$",
"instanceid",
")",
":",
"bool",
"{",
"return",
"$",
"this",
"->",
"can_view",
"(",
"$",
"field",
",",
"$",
"instanceid",
")",
"||",
"$",
"this",
"->",
"can_edi... | Checks if current user can backup a given field
Capability to backup the instance does not need to be checked here
@param field_controller $field
@param int $instanceid
@return bool | [
"Checks",
"if",
"current",
"user",
"can",
"backup",
"a",
"given",
"field"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/customfield/classes/handler.php#L507-L509 |
216,880 | moodle/moodle | customfield/classes/handler.php | handler.get_instance_data_for_backup | public function get_instance_data_for_backup(int $instanceid) : array {
$finalfields = [];
$data = $this->get_instance_data($instanceid, true);
foreach ($data as $d) {
if ($d->get('id') && $this->can_backup($d->get_field(), $instanceid)) {
$finalfields[] = [
... | php | public function get_instance_data_for_backup(int $instanceid) : array {
$finalfields = [];
$data = $this->get_instance_data($instanceid, true);
foreach ($data as $d) {
if ($d->get('id') && $this->can_backup($d->get_field(), $instanceid)) {
$finalfields[] = [
... | [
"public",
"function",
"get_instance_data_for_backup",
"(",
"int",
"$",
"instanceid",
")",
":",
"array",
"{",
"$",
"finalfields",
"=",
"[",
"]",
";",
"$",
"data",
"=",
"$",
"this",
"->",
"get_instance_data",
"(",
"$",
"instanceid",
",",
"true",
")",
";",
... | Get raw data associated with all fields current user can view or edit
@param int $instanceid
@return array | [
"Get",
"raw",
"data",
"associated",
"with",
"all",
"fields",
"current",
"user",
"can",
"view",
"or",
"edit"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/customfield/classes/handler.php#L517-L531 |
216,881 | moodle/moodle | customfield/classes/handler.php | handler.instance_form_definition_after_data | public function instance_form_definition_after_data(\MoodleQuickForm $mform, int $instanceid = 0) {
$editablefields = $this->get_editable_fields($instanceid);
$fields = api::get_instance_fields_data($editablefields, $instanceid);
foreach ($fields as $formfield) {
$formfield->instanc... | php | public function instance_form_definition_after_data(\MoodleQuickForm $mform, int $instanceid = 0) {
$editablefields = $this->get_editable_fields($instanceid);
$fields = api::get_instance_fields_data($editablefields, $instanceid);
foreach ($fields as $formfield) {
$formfield->instanc... | [
"public",
"function",
"instance_form_definition_after_data",
"(",
"\\",
"MoodleQuickForm",
"$",
"mform",
",",
"int",
"$",
"instanceid",
"=",
"0",
")",
"{",
"$",
"editablefields",
"=",
"$",
"this",
"->",
"get_editable_fields",
"(",
"$",
"instanceid",
")",
";",
... | Form data definition callback.
This method is called from moodleform::definition_after_data and allows to tweak
mform with some data coming directly from the field plugin data controller.
@param \MoodleQuickForm $mform
@param int $instanceid | [
"Form",
"data",
"definition",
"callback",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/customfield/classes/handler.php#L542-L549 |
216,882 | moodle/moodle | customfield/classes/handler.php | handler.instance_form_save | public function instance_form_save(stdClass $instance, bool $isnewinstance = false) {
if (empty($instance->id)) {
throw new \coding_exception('Caller must ensure that id is already set in data before calling this method');
}
if (!preg_grep('/^customfield_/', array_keys((array)$instan... | php | public function instance_form_save(stdClass $instance, bool $isnewinstance = false) {
if (empty($instance->id)) {
throw new \coding_exception('Caller must ensure that id is already set in data before calling this method');
}
if (!preg_grep('/^customfield_/', array_keys((array)$instan... | [
"public",
"function",
"instance_form_save",
"(",
"stdClass",
"$",
"instance",
",",
"bool",
"$",
"isnewinstance",
"=",
"false",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"instance",
"->",
"id",
")",
")",
"{",
"throw",
"new",
"\\",
"coding_exception",
"(",
"... | Saves the given data for custom fields, must be called after the instance is saved and id is present
Example:
if ($data = $form->get_data()) {
// ... save main instance, set $data->id if instance was created.
$handler->instance_form_save($data);
redirect(...);
}
@param stdClass $instance data received from a form
@pa... | [
"Saves",
"the",
"given",
"data",
"for",
"custom",
"fields",
"must",
"be",
"called",
"after",
"the",
"instance",
"is",
"saved",
"and",
"id",
"is",
"present"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/customfield/classes/handler.php#L585-L601 |
216,883 | moodle/moodle | customfield/classes/handler.php | handler.instance_form_definition | public function instance_form_definition(\MoodleQuickForm $mform, int $instanceid = 0) {
$editablefields = $this->get_editable_fields($instanceid);
$fieldswithdata = api::get_instance_fields_data($editablefields, $instanceid);
$lastcategoryid = null;
foreach ($fieldswithdata as $data) {... | php | public function instance_form_definition(\MoodleQuickForm $mform, int $instanceid = 0) {
$editablefields = $this->get_editable_fields($instanceid);
$fieldswithdata = api::get_instance_fields_data($editablefields, $instanceid);
$lastcategoryid = null;
foreach ($fieldswithdata as $data) {... | [
"public",
"function",
"instance_form_definition",
"(",
"\\",
"MoodleQuickForm",
"$",
"mform",
",",
"int",
"$",
"instanceid",
"=",
"0",
")",
"{",
"$",
"editablefields",
"=",
"$",
"this",
"->",
"get_editable_fields",
"(",
"$",
"instanceid",
")",
";",
"$",
"fie... | Adds custom fields to instance editing form
Example:
public function definition() {
// ... normal instance definition, including hidden 'id' field.
$handler->instance_form_definition($this->_form, $instanceid);
$this->add_action_buttons();
}
@param \MoodleQuickForm $mform
@param int $instanceid id of the instance, ca... | [
"Adds",
"custom",
"fields",
"to",
"instance",
"editing",
"form"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/customfield/classes/handler.php#L642-L665 |
216,884 | moodle/moodle | customfield/classes/handler.php | handler.save_field_configuration | public function save_field_configuration(field_controller $field, stdClass $data) {
if ($field->get('id')) {
$field = $this->validate_field($field);
} else {
$this->validate_category($field->get_category());
}
api::save_field_configuration($field, $data);
... | php | public function save_field_configuration(field_controller $field, stdClass $data) {
if ($field->get('id')) {
$field = $this->validate_field($field);
} else {
$this->validate_category($field->get_category());
}
api::save_field_configuration($field, $data);
... | [
"public",
"function",
"save_field_configuration",
"(",
"field_controller",
"$",
"field",
",",
"stdClass",
"$",
"data",
")",
"{",
"if",
"(",
"$",
"field",
"->",
"get",
"(",
"'id'",
")",
")",
"{",
"$",
"field",
"=",
"$",
"this",
"->",
"validate_field",
"("... | Save the field configuration with the data from the form
@param field_controller $field
@param stdClass $data data from the form | [
"Save",
"the",
"field",
"configuration",
"with",
"the",
"data",
"from",
"the",
"form"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/customfield/classes/handler.php#L700-L708 |
216,885 | moodle/moodle | customfield/classes/handler.php | handler.get_visible_fields | protected function get_visible_fields(int $instanceid) : array {
$handler = $this;
return array_filter($this->get_fields(),
function($field) use($handler, $instanceid) {
return $handler->can_view($field, $instanceid);
}
);
} | php | protected function get_visible_fields(int $instanceid) : array {
$handler = $this;
return array_filter($this->get_fields(),
function($field) use($handler, $instanceid) {
return $handler->can_view($field, $instanceid);
}
);
} | [
"protected",
"function",
"get_visible_fields",
"(",
"int",
"$",
"instanceid",
")",
":",
"array",
"{",
"$",
"handler",
"=",
"$",
"this",
";",
"return",
"array_filter",
"(",
"$",
"this",
"->",
"get_fields",
"(",
")",
",",
"function",
"(",
"$",
"field",
")"... | Get visible fields
@param int $instanceid
@return field_controller[] | [
"Get",
"visible",
"fields"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/customfield/classes/handler.php#L749-L756 |
216,886 | moodle/moodle | customfield/classes/handler.php | handler.get_editable_fields | public function get_editable_fields(int $instanceid) : array {
$handler = $this;
return array_filter($this->get_fields(),
function($field) use($handler, $instanceid) {
return $handler->can_edit($field, $instanceid);
}
);
} | php | public function get_editable_fields(int $instanceid) : array {
$handler = $this;
return array_filter($this->get_fields(),
function($field) use($handler, $instanceid) {
return $handler->can_edit($field, $instanceid);
}
);
} | [
"public",
"function",
"get_editable_fields",
"(",
"int",
"$",
"instanceid",
")",
":",
"array",
"{",
"$",
"handler",
"=",
"$",
"this",
";",
"return",
"array_filter",
"(",
"$",
"this",
"->",
"get_fields",
"(",
")",
",",
"function",
"(",
"$",
"field",
")",
... | Get editable fields
@param int $instanceid
@return field_controller[] | [
"Get",
"editable",
"fields"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/customfield/classes/handler.php#L764-L771 |
216,887 | moodle/moodle | customfield/classes/handler.php | handler.delete_instance | public function delete_instance(int $instanceid) {
$fielddata = api::get_instance_fields_data($this->get_fields(), $instanceid, false);
foreach ($fielddata as $data) {
$data->delete();
}
} | php | public function delete_instance(int $instanceid) {
$fielddata = api::get_instance_fields_data($this->get_fields(), $instanceid, false);
foreach ($fielddata as $data) {
$data->delete();
}
} | [
"public",
"function",
"delete_instance",
"(",
"int",
"$",
"instanceid",
")",
"{",
"$",
"fielddata",
"=",
"api",
"::",
"get_instance_fields_data",
"(",
"$",
"this",
"->",
"get_fields",
"(",
")",
",",
"$",
"instanceid",
",",
"false",
")",
";",
"foreach",
"("... | Deletes all data related to all fields of an instance.
@param int $instanceid | [
"Deletes",
"all",
"data",
"related",
"to",
"all",
"fields",
"of",
"an",
"instance",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/customfield/classes/handler.php#L786-L791 |
216,888 | moodle/moodle | customfield/classes/output/field_data.php | field_data.export_for_template | public function export_for_template(\renderer_base $output) {
$value = $this->get_value();
return (object)[
'value' => $value,
'type' => $this->get_type(),
'shortname' => $this->get_shortname(),
'name' => $this->get_name(),
'hasvalue' => ($valu... | php | public function export_for_template(\renderer_base $output) {
$value = $this->get_value();
return (object)[
'value' => $value,
'type' => $this->get_type(),
'shortname' => $this->get_shortname(),
'name' => $this->get_name(),
'hasvalue' => ($valu... | [
"public",
"function",
"export_for_template",
"(",
"\\",
"renderer_base",
"$",
"output",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"get_value",
"(",
")",
";",
"return",
"(",
"object",
")",
"[",
"'value'",
"=>",
"$",
"value",
",",
"'type'",
"=>",
"... | Export data for using as template context.
@param \renderer_base $output
@return \stdClass | [
"Export",
"data",
"for",
"using",
"as",
"template",
"context",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/customfield/classes/output/field_data.php#L103-L113 |
216,889 | moodle/moodle | auth/mnet/classes/privacy/provider.php | provider.export_user_data | public static function export_user_data(approved_contextlist $contextlist) {
global $DB;
$context = \context_user::instance($contextlist->get_user()->id);
$sql = "SELECT ml.id, mh.wwwroot, mh.name, ml.remoteid, ml.time, ml.userid, ml.ip, ml.course,
ml.coursename, ml.modu... | php | public static function export_user_data(approved_contextlist $contextlist) {
global $DB;
$context = \context_user::instance($contextlist->get_user()->id);
$sql = "SELECT ml.id, mh.wwwroot, mh.name, ml.remoteid, ml.time, ml.userid, ml.ip, ml.course,
ml.coursename, ml.modu... | [
"public",
"static",
"function",
"export_user_data",
"(",
"approved_contextlist",
"$",
"contextlist",
")",
"{",
"global",
"$",
"DB",
";",
"$",
"context",
"=",
"\\",
"context_user",
"::",
"instance",
"(",
"$",
"contextlist",
"->",
"get_user",
"(",
")",
"->",
"... | Export all user data for the specified user, in the specified contexts, using the supplied exporter instance.
@param approved_contextlist $contextlist The approved contexts to export information for. | [
"Export",
"all",
"user",
"data",
"for",
"the",
"specified",
"user",
"in",
"the",
"specified",
"contexts",
"using",
"the",
"supplied",
"exporter",
"instance",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/auth/mnet/classes/privacy/provider.php#L176-L224 |
216,890 | moodle/moodle | user/externallib.php | core_user_external.update_user_preferences | public static function update_user_preferences($userid = 0, $emailstop = null, $preferences = array()) {
global $USER, $CFG;
require_once($CFG->dirroot . '/user/lib.php');
require_once($CFG->dirroot . '/user/editlib.php');
require_once($CFG->dirroot . '/message/lib.php');
if (e... | php | public static function update_user_preferences($userid = 0, $emailstop = null, $preferences = array()) {
global $USER, $CFG;
require_once($CFG->dirroot . '/user/lib.php');
require_once($CFG->dirroot . '/user/editlib.php');
require_once($CFG->dirroot . '/message/lib.php');
if (e... | [
"public",
"static",
"function",
"update_user_preferences",
"(",
"$",
"userid",
"=",
"0",
",",
"$",
"emailstop",
"=",
"null",
",",
"$",
"preferences",
"=",
"array",
"(",
")",
")",
"{",
"global",
"$",
"USER",
",",
"$",
"CFG",
";",
"require_once",
"(",
"$... | Update the user's preferences.
@param int $userid
@param bool|null $emailstop
@param array $preferences
@return null
@since Moodle 3.2 | [
"Update",
"the",
"user",
"s",
"preferences",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/user/externallib.php#L399-L447 |
216,891 | moodle/moodle | user/externallib.php | core_user_external.get_users_by_field | public static function get_users_by_field($field, $values) {
global $CFG, $USER, $DB;
require_once($CFG->dirroot . "/user/lib.php");
$params = self::validate_parameters(self::get_users_by_field_parameters(),
array('field' => $field, 'values' => $values));
// This array ... | php | public static function get_users_by_field($field, $values) {
global $CFG, $USER, $DB;
require_once($CFG->dirroot . "/user/lib.php");
$params = self::validate_parameters(self::get_users_by_field_parameters(),
array('field' => $field, 'values' => $values));
// This array ... | [
"public",
"static",
"function",
"get_users_by_field",
"(",
"$",
"field",
",",
"$",
"values",
")",
"{",
"global",
"$",
"CFG",
",",
"$",
"USER",
",",
"$",
"DB",
";",
"require_once",
"(",
"$",
"CFG",
"->",
"dirroot",
".",
"\"/user/lib.php\"",
")",
";",
"$... | Get user information for a unique field.
@throws coding_exception
@throws invalid_parameter_exception
@param string $field
@param array $values
@return array An array of arrays containg user profiles.
@since Moodle 2.4 | [
"Get",
"user",
"information",
"for",
"a",
"unique",
"field",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/user/externallib.php#L708-L766 |
216,892 | moodle/moodle | user/externallib.php | core_user_external.get_course_user_profiles | public static function get_course_user_profiles($userlist) {
global $CFG, $USER, $DB;
require_once($CFG->dirroot . "/user/lib.php");
$params = self::validate_parameters(self::get_course_user_profiles_parameters(), array('userlist' => $userlist));
$userids = array();
$courseids =... | php | public static function get_course_user_profiles($userlist) {
global $CFG, $USER, $DB;
require_once($CFG->dirroot . "/user/lib.php");
$params = self::validate_parameters(self::get_course_user_profiles_parameters(), array('userlist' => $userlist));
$userids = array();
$courseids =... | [
"public",
"static",
"function",
"get_course_user_profiles",
"(",
"$",
"userlist",
")",
"{",
"global",
"$",
"CFG",
",",
"$",
"USER",
",",
"$",
"DB",
";",
"require_once",
"(",
"$",
"CFG",
"->",
"dirroot",
".",
"\"/user/lib.php\"",
")",
";",
"$",
"params",
... | Get course participant's details
@param array $userlist array of user ids and according course ids
@return array An array of arrays describing course participants
@since Moodle 2.2 | [
"Get",
"course",
"participant",
"s",
"details"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/user/externallib.php#L983-L1038 |
216,893 | moodle/moodle | user/externallib.php | core_user_external.add_user_private_files | public static function add_user_private_files($draftid) {
global $CFG, $USER;
require_once($CFG->libdir . "/filelib.php");
$params = self::validate_parameters(self::add_user_private_files_parameters(), array('draftid' => $draftid));
if (isguestuser()) {
throw new invalid_pa... | php | public static function add_user_private_files($draftid) {
global $CFG, $USER;
require_once($CFG->libdir . "/filelib.php");
$params = self::validate_parameters(self::add_user_private_files_parameters(), array('draftid' => $draftid));
if (isguestuser()) {
throw new invalid_pa... | [
"public",
"static",
"function",
"add_user_private_files",
"(",
"$",
"draftid",
")",
"{",
"global",
"$",
"CFG",
",",
"$",
"USER",
";",
"require_once",
"(",
"$",
"CFG",
"->",
"libdir",
".",
"\"/filelib.php\"",
")",
";",
"$",
"params",
"=",
"self",
"::",
"v... | Copy files from a draft area to users private files area.
@throws invalid_parameter_exception
@param int $draftid Id of a draft area containing files.
@return array An array of warnings
@since Moodle 2.6 | [
"Copy",
"files",
"from",
"a",
"draft",
"area",
"to",
"users",
"private",
"files",
"area",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/user/externallib.php#L1167-L1195 |
216,894 | moodle/moodle | user/externallib.php | core_user_external.view_user_list | public static function view_user_list($courseid) {
global $CFG;
require_once($CFG->dirroot . "/user/lib.php");
require_once($CFG->dirroot . '/course/lib.php');
$params = self::validate_parameters(self::view_user_list_parameters(),
array(
... | php | public static function view_user_list($courseid) {
global $CFG;
require_once($CFG->dirroot . "/user/lib.php");
require_once($CFG->dirroot . '/course/lib.php');
$params = self::validate_parameters(self::view_user_list_parameters(),
array(
... | [
"public",
"static",
"function",
"view_user_list",
"(",
"$",
"courseid",
")",
"{",
"global",
"$",
"CFG",
";",
"require_once",
"(",
"$",
"CFG",
"->",
"dirroot",
".",
"\"/user/lib.php\"",
")",
";",
"require_once",
"(",
"$",
"CFG",
"->",
"dirroot",
".",
"'/cou... | Trigger the user_list_viewed event.
@param int $courseid id of course
@return array of warnings and status result
@since Moodle 2.9
@throws moodle_exception | [
"Trigger",
"the",
"user_list_viewed",
"event",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/user/externallib.php#L1404-L1437 |
216,895 | moodle/moodle | user/externallib.php | core_user_external.view_user_profile | public static function view_user_profile($userid, $courseid = 0) {
global $CFG, $USER;
require_once($CFG->dirroot . "/user/profile/lib.php");
$params = self::validate_parameters(self::view_user_profile_parameters(),
array(
... | php | public static function view_user_profile($userid, $courseid = 0) {
global $CFG, $USER;
require_once($CFG->dirroot . "/user/profile/lib.php");
$params = self::validate_parameters(self::view_user_profile_parameters(),
array(
... | [
"public",
"static",
"function",
"view_user_profile",
"(",
"$",
"userid",
",",
"$",
"courseid",
"=",
"0",
")",
"{",
"global",
"$",
"CFG",
",",
"$",
"USER",
";",
"require_once",
"(",
"$",
"CFG",
"->",
"dirroot",
".",
"\"/user/profile/lib.php\"",
")",
";",
... | Trigger the user profile viewed event.
@param int $userid id of user
@param int $courseid id of course
@return array of warnings and status result
@since Moodle 2.9
@throws moodle_exception | [
"Trigger",
"the",
"user",
"profile",
"viewed",
"event",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/user/externallib.php#L1478-L1534 |
216,896 | moodle/moodle | user/externallib.php | core_user_external.get_user_preferences | public static function get_user_preferences($name = '', $userid = 0) {
global $USER;
$params = self::validate_parameters(self::get_user_preferences_parameters(),
array(
'name' => $name,
... | php | public static function get_user_preferences($name = '', $userid = 0) {
global $USER;
$params = self::validate_parameters(self::get_user_preferences_parameters(),
array(
'name' => $name,
... | [
"public",
"static",
"function",
"get_user_preferences",
"(",
"$",
"name",
"=",
"''",
",",
"$",
"userid",
"=",
"0",
")",
"{",
"global",
"$",
"USER",
";",
"$",
"params",
"=",
"self",
"::",
"validate_parameters",
"(",
"self",
"::",
"get_user_preferences_paramet... | Return user preferences.
@param string $name preference name, empty for all
@param int $userid id of the user, 0 for current user
@return array of warnings and preferences
@since Moodle 3.2
@throws moodle_exception | [
"Return",
"user",
"preferences",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/user/externallib.php#L1575-L1620 |
216,897 | moodle/moodle | user/externallib.php | core_user_external.update_picture | public static function update_picture($draftitemid, $delete = false, $userid = 0) {
global $CFG, $USER, $PAGE;
$params = self::validate_parameters(
self::update_picture_parameters(),
array(
'draftitemid' => $draftitemid,
'delete' => $delete,
... | php | public static function update_picture($draftitemid, $delete = false, $userid = 0) {
global $CFG, $USER, $PAGE;
$params = self::validate_parameters(
self::update_picture_parameters(),
array(
'draftitemid' => $draftitemid,
'delete' => $delete,
... | [
"public",
"static",
"function",
"update_picture",
"(",
"$",
"draftitemid",
",",
"$",
"delete",
"=",
"false",
",",
"$",
"userid",
"=",
"0",
")",
"{",
"global",
"$",
"CFG",
",",
"$",
"USER",
",",
"$",
"PAGE",
";",
"$",
"params",
"=",
"self",
"::",
"v... | Update or delete the user picture in the site
@param int $draftitemid id of the user draft file to use as image
@param bool $delete if we should delete the user picture
@param int $userid id of the user, 0 for current user
@return array warnings and success status
@since Moodle 3.2
@throws moodle_except... | [
"Update",
"or",
"delete",
"the",
"user",
"picture",
"in",
"the",
"site"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/user/externallib.php#L1671-L1725 |
216,898 | moodle/moodle | user/externallib.php | core_user_external.set_user_preferences | public static function set_user_preferences($preferences) {
global $USER;
$params = self::validate_parameters(self::set_user_preferences_parameters(), array('preferences' => $preferences));
$warnings = array();
$saved = array();
$context = context_system::instance();
se... | php | public static function set_user_preferences($preferences) {
global $USER;
$params = self::validate_parameters(self::set_user_preferences_parameters(), array('preferences' => $preferences));
$warnings = array();
$saved = array();
$context = context_system::instance();
se... | [
"public",
"static",
"function",
"set_user_preferences",
"(",
"$",
"preferences",
")",
"{",
"global",
"$",
"USER",
";",
"$",
"params",
"=",
"self",
"::",
"validate_parameters",
"(",
"self",
"::",
"set_user_preferences_parameters",
"(",
")",
",",
"array",
"(",
"... | Set user preferences.
@param array $preferences list of preferences including name, value and userid
@return array of warnings and preferences saved
@since Moodle 3.2
@throws moodle_exception | [
"Set",
"user",
"preferences",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/user/externallib.php#L1773-L1834 |
216,899 | moodle/moodle | user/externallib.php | core_user_external.agree_site_policy | public static function agree_site_policy() {
global $CFG, $DB, $USER;
$warnings = array();
$context = context_system::instance();
try {
// We expect an exception here since the user didn't agree the site policy yet.
self::validate_context($context);
} ca... | php | public static function agree_site_policy() {
global $CFG, $DB, $USER;
$warnings = array();
$context = context_system::instance();
try {
// We expect an exception here since the user didn't agree the site policy yet.
self::validate_context($context);
} ca... | [
"public",
"static",
"function",
"agree_site_policy",
"(",
")",
"{",
"global",
"$",
"CFG",
",",
"$",
"DB",
",",
"$",
"USER",
";",
"$",
"warnings",
"=",
"array",
"(",
")",
";",
"$",
"context",
"=",
"context_system",
"::",
"instance",
"(",
")",
";",
"tr... | Agree the site policy for the current user.
@return array of warnings and status result
@since Moodle 3.2
@throws moodle_exception | [
"Agree",
"the",
"site",
"policy",
"for",
"the",
"current",
"user",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/user/externallib.php#L1875-L1917 |
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.