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
218,700
moodle/moodle
competency/classes/external.php
external.count_templates
public static function count_templates($context, $includes) { $params = self::validate_parameters(self::count_templates_parameters(), array( 'context' => $context, 'includes' => $includes )); $context = self::get_context_from_params($params['context']); self::validate_context($context); return api::count_templates($context, $includes); }
php
public static function count_templates($context, $includes) { $params = self::validate_parameters(self::count_templates_parameters(), array( 'context' => $context, 'includes' => $includes )); $context = self::get_context_from_params($params['context']); self::validate_context($context); return api::count_templates($context, $includes); }
[ "public", "static", "function", "count_templates", "(", "$", "context", ",", "$", "includes", ")", "{", "$", "params", "=", "self", "::", "validate_parameters", "(", "self", "::", "count_templates_parameters", "(", ")", ",", "array", "(", "'context'", "=>", "$", "context", ",", "'includes'", "=>", "$", "includes", ")", ")", ";", "$", "context", "=", "self", "::", "get_context_from_params", "(", "$", "params", "[", "'context'", "]", ")", ";", "self", "::", "validate_context", "(", "$", "context", ")", ";", "return", "api", "::", "count_templates", "(", "$", "context", ",", "$", "includes", ")", ";", "}" ]
Count the existing learning plan templates @param array $context @param string $includes @return int
[ "Count", "the", "existing", "learning", "plan", "templates" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/competency/classes/external.php#L1954-L1963
218,701
moodle/moodle
competency/classes/external.php
external.add_competency_to_plan
public static function add_competency_to_plan($planid, $competencyid) { $params = self::validate_parameters(self::add_competency_to_plan_parameters(), array( 'planid' => $planid, 'competencyid' => $competencyid, )); $plan = api::read_plan($params['planid']); self::validate_context($plan->get_context()); return api::add_competency_to_plan($params['planid'], $params['competencyid']); }
php
public static function add_competency_to_plan($planid, $competencyid) { $params = self::validate_parameters(self::add_competency_to_plan_parameters(), array( 'planid' => $planid, 'competencyid' => $competencyid, )); $plan = api::read_plan($params['planid']); self::validate_context($plan->get_context()); return api::add_competency_to_plan($params['planid'], $params['competencyid']); }
[ "public", "static", "function", "add_competency_to_plan", "(", "$", "planid", ",", "$", "competencyid", ")", "{", "$", "params", "=", "self", "::", "validate_parameters", "(", "self", "::", "add_competency_to_plan_parameters", "(", ")", ",", "array", "(", "'planid'", "=>", "$", "planid", ",", "'competencyid'", "=>", "$", "competencyid", ",", ")", ")", ";", "$", "plan", "=", "api", "::", "read_plan", "(", "$", "params", "[", "'planid'", "]", ")", ";", "self", "::", "validate_context", "(", "$", "plan", "->", "get_context", "(", ")", ")", ";", "return", "api", "::", "add_competency_to_plan", "(", "$", "params", "[", "'planid'", "]", ",", "$", "params", "[", "'competencyid'", "]", ")", ";", "}" ]
add competency to a learning plan. @param int $planid Plan id. @param int $competencyid Competency id. @return int
[ "add", "competency", "to", "a", "learning", "plan", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/competency/classes/external.php#L2252-L2262
218,702
moodle/moodle
competency/classes/external.php
external.remove_competency_from_plan
public static function remove_competency_from_plan($planid, $competencyid) { $params = self::validate_parameters(self::remove_competency_from_plan_parameters(), array( 'planid' => $planid, 'competencyid' => $competencyid, )); $plan = api::read_plan($params['planid']); self::validate_context($plan->get_context()); return api::remove_competency_from_plan($params['planid'], $params['competencyid']); }
php
public static function remove_competency_from_plan($planid, $competencyid) { $params = self::validate_parameters(self::remove_competency_from_plan_parameters(), array( 'planid' => $planid, 'competencyid' => $competencyid, )); $plan = api::read_plan($params['planid']); self::validate_context($plan->get_context()); return api::remove_competency_from_plan($params['planid'], $params['competencyid']); }
[ "public", "static", "function", "remove_competency_from_plan", "(", "$", "planid", ",", "$", "competencyid", ")", "{", "$", "params", "=", "self", "::", "validate_parameters", "(", "self", "::", "remove_competency_from_plan_parameters", "(", ")", ",", "array", "(", "'planid'", "=>", "$", "planid", ",", "'competencyid'", "=>", "$", "competencyid", ",", ")", ")", ";", "$", "plan", "=", "api", "::", "read_plan", "(", "$", "params", "[", "'planid'", "]", ")", ";", "self", "::", "validate_context", "(", "$", "plan", "->", "get_context", "(", ")", ")", ";", "return", "api", "::", "remove_competency_from_plan", "(", "$", "params", "[", "'planid'", "]", ",", "$", "params", "[", "'competencyid'", "]", ")", ";", "}" ]
Remove a competency from plan. @param int $planid Plan id. @param int $competencyid Competency id. @return int
[ "Remove", "a", "competency", "from", "plan", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/competency/classes/external.php#L2303-L2312
218,703
moodle/moodle
competency/classes/external.php
external.reorder_plan_competency
public static function reorder_plan_competency($planid, $competencyidfrom, $competencyidto) { $params = self::validate_parameters(self::reorder_plan_competency_parameters(), array( 'planid' => $planid, 'competencyidfrom' => $competencyidfrom, 'competencyidto' => $competencyidto, )); $plan = api::read_plan($params['planid']); self::validate_context($plan->get_context()); return api::reorder_plan_competency($params['planid'], $params['competencyidfrom'], $params['competencyidto']); }
php
public static function reorder_plan_competency($planid, $competencyidfrom, $competencyidto) { $params = self::validate_parameters(self::reorder_plan_competency_parameters(), array( 'planid' => $planid, 'competencyidfrom' => $competencyidfrom, 'competencyidto' => $competencyidto, )); $plan = api::read_plan($params['planid']); self::validate_context($plan->get_context()); return api::reorder_plan_competency($params['planid'], $params['competencyidfrom'], $params['competencyidto']); }
[ "public", "static", "function", "reorder_plan_competency", "(", "$", "planid", ",", "$", "competencyidfrom", ",", "$", "competencyidto", ")", "{", "$", "params", "=", "self", "::", "validate_parameters", "(", "self", "::", "reorder_plan_competency_parameters", "(", ")", ",", "array", "(", "'planid'", "=>", "$", "planid", ",", "'competencyidfrom'", "=>", "$", "competencyidfrom", ",", "'competencyidto'", "=>", "$", "competencyidto", ",", ")", ")", ";", "$", "plan", "=", "api", "::", "read_plan", "(", "$", "params", "[", "'planid'", "]", ")", ";", "self", "::", "validate_context", "(", "$", "plan", "->", "get_context", "(", ")", ")", ";", "return", "api", "::", "reorder_plan_competency", "(", "$", "params", "[", "'planid'", "]", ",", "$", "params", "[", "'competencyidfrom'", "]", ",", "$", "params", "[", "'competencyidto'", "]", ")", ";", "}" ]
Change the order of plan competencies. @param int $planid The plan id @param int $competencyidfrom The competency to move. @param int $competencyidto The competency to move to. @return bool
[ "Change", "the", "order", "of", "plan", "competencies", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/competency/classes/external.php#L2383-L2394
218,704
moodle/moodle
competency/classes/external.php
external.user_competency_cancel_review_request
public static function user_competency_cancel_review_request($userid, $competencyid) { $params = self::validate_parameters(self::user_competency_cancel_review_request_parameters(), array( 'userid' => $userid, 'competencyid' => $competencyid )); $context = context_user::instance($params['userid']); self::validate_context($context); return api::user_competency_cancel_review_request($userid, $competencyid); }
php
public static function user_competency_cancel_review_request($userid, $competencyid) { $params = self::validate_parameters(self::user_competency_cancel_review_request_parameters(), array( 'userid' => $userid, 'competencyid' => $competencyid )); $context = context_user::instance($params['userid']); self::validate_context($context); return api::user_competency_cancel_review_request($userid, $competencyid); }
[ "public", "static", "function", "user_competency_cancel_review_request", "(", "$", "userid", ",", "$", "competencyid", ")", "{", "$", "params", "=", "self", "::", "validate_parameters", "(", "self", "::", "user_competency_cancel_review_request_parameters", "(", ")", ",", "array", "(", "'userid'", "=>", "$", "userid", ",", "'competencyid'", "=>", "$", "competencyid", ")", ")", ";", "$", "context", "=", "context_user", "::", "instance", "(", "$", "params", "[", "'userid'", "]", ")", ";", "self", "::", "validate_context", "(", "$", "context", ")", ";", "return", "api", "::", "user_competency_cancel_review_request", "(", "$", "userid", ",", "$", "competencyid", ")", ";", "}" ]
External function user_competency_cancel_review_request. @param int $userid The user ID. @param int $competencyid The competency ID. @return boolean
[ "External", "function", "user_competency_cancel_review_request", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/competency/classes/external.php#L2424-L2434
218,705
moodle/moodle
competency/classes/external.php
external.user_competency_request_review
public static function user_competency_request_review($userid, $competencyid) { $params = self::validate_parameters(self::user_competency_request_review_parameters(), array( 'userid' => $userid, 'competencyid' => $competencyid, )); $context = context_user::instance($params['userid']); self::validate_context($context); return api::user_competency_request_review($userid, $competencyid); }
php
public static function user_competency_request_review($userid, $competencyid) { $params = self::validate_parameters(self::user_competency_request_review_parameters(), array( 'userid' => $userid, 'competencyid' => $competencyid, )); $context = context_user::instance($params['userid']); self::validate_context($context); return api::user_competency_request_review($userid, $competencyid); }
[ "public", "static", "function", "user_competency_request_review", "(", "$", "userid", ",", "$", "competencyid", ")", "{", "$", "params", "=", "self", "::", "validate_parameters", "(", "self", "::", "user_competency_request_review_parameters", "(", ")", ",", "array", "(", "'userid'", "=>", "$", "userid", ",", "'competencyid'", "=>", "$", "competencyid", ",", ")", ")", ";", "$", "context", "=", "context_user", "::", "instance", "(", "$", "params", "[", "'userid'", "]", ")", ";", "self", "::", "validate_context", "(", "$", "context", ")", ";", "return", "api", "::", "user_competency_request_review", "(", "$", "userid", ",", "$", "competencyid", ")", ";", "}" ]
External function user_competency_request_review. @param int $userid The user ID. @param int $competencyid The competency ID. @return boolean
[ "External", "function", "user_competency_request_review", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/competency/classes/external.php#L2464-L2474
218,706
moodle/moodle
competency/classes/external.php
external.user_competency_start_review
public static function user_competency_start_review($userid, $competencyid) { $params = self::validate_parameters(self::user_competency_start_review_parameters(), array( 'userid' => $userid, 'competencyid' => $competencyid )); $context = context_user::instance($params['userid']); self::validate_context($context); return api::user_competency_start_review($userid, $competencyid); }
php
public static function user_competency_start_review($userid, $competencyid) { $params = self::validate_parameters(self::user_competency_start_review_parameters(), array( 'userid' => $userid, 'competencyid' => $competencyid )); $context = context_user::instance($params['userid']); self::validate_context($context); return api::user_competency_start_review($userid, $competencyid); }
[ "public", "static", "function", "user_competency_start_review", "(", "$", "userid", ",", "$", "competencyid", ")", "{", "$", "params", "=", "self", "::", "validate_parameters", "(", "self", "::", "user_competency_start_review_parameters", "(", ")", ",", "array", "(", "'userid'", "=>", "$", "userid", ",", "'competencyid'", "=>", "$", "competencyid", ")", ")", ";", "$", "context", "=", "context_user", "::", "instance", "(", "$", "params", "[", "'userid'", "]", ")", ";", "self", "::", "validate_context", "(", "$", "context", ")", ";", "return", "api", "::", "user_competency_start_review", "(", "$", "userid", ",", "$", "competencyid", ")", ";", "}" ]
External function user_competency_start_review. @param int $userid The user ID. @param int $competencyid The competency ID. @return boolean
[ "External", "function", "user_competency_start_review", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/competency/classes/external.php#L2504-L2514
218,707
moodle/moodle
competency/classes/external.php
external.user_competency_stop_review
public static function user_competency_stop_review($userid, $competencyid) { $params = self::validate_parameters(self::user_competency_stop_review_parameters(), array( 'userid' => $userid, 'competencyid' => $competencyid )); $context = context_user::instance($params['userid']); self::validate_context($context); return api::user_competency_stop_review($userid, $competencyid); }
php
public static function user_competency_stop_review($userid, $competencyid) { $params = self::validate_parameters(self::user_competency_stop_review_parameters(), array( 'userid' => $userid, 'competencyid' => $competencyid )); $context = context_user::instance($params['userid']); self::validate_context($context); return api::user_competency_stop_review($userid, $competencyid); }
[ "public", "static", "function", "user_competency_stop_review", "(", "$", "userid", ",", "$", "competencyid", ")", "{", "$", "params", "=", "self", "::", "validate_parameters", "(", "self", "::", "user_competency_stop_review_parameters", "(", ")", ",", "array", "(", "'userid'", "=>", "$", "userid", ",", "'competencyid'", "=>", "$", "competencyid", ")", ")", ";", "$", "context", "=", "context_user", "::", "instance", "(", "$", "params", "[", "'userid'", "]", ")", ";", "self", "::", "validate_context", "(", "$", "context", ")", ";", "return", "api", "::", "user_competency_stop_review", "(", "$", "userid", ",", "$", "competencyid", ")", ";", "}" ]
External function user_competency_stop_review. @param int $userid The user ID. @param int $competencyid The competency ID. @return boolean
[ "External", "function", "user_competency_stop_review", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/competency/classes/external.php#L2544-L2554
218,708
moodle/moodle
competency/classes/external.php
external.create_plan
public static function create_plan($plan) { global $PAGE; $params = self::validate_parameters(self::create_plan_parameters(), array('plan' => $plan)); $params = $params['plan']; $context = context_user::instance($params['userid']); self::validate_context($context); $output = $PAGE->get_renderer('core'); $params = (object) $params; $result = api::create_plan($params); $exporter = new plan_exporter($result, array('template' => null)); return $exporter->export($output); }
php
public static function create_plan($plan) { global $PAGE; $params = self::validate_parameters(self::create_plan_parameters(), array('plan' => $plan)); $params = $params['plan']; $context = context_user::instance($params['userid']); self::validate_context($context); $output = $PAGE->get_renderer('core'); $params = (object) $params; $result = api::create_plan($params); $exporter = new plan_exporter($result, array('template' => null)); return $exporter->export($output); }
[ "public", "static", "function", "create_plan", "(", "$", "plan", ")", "{", "global", "$", "PAGE", ";", "$", "params", "=", "self", "::", "validate_parameters", "(", "self", "::", "create_plan_parameters", "(", ")", ",", "array", "(", "'plan'", "=>", "$", "plan", ")", ")", ";", "$", "params", "=", "$", "params", "[", "'plan'", "]", ";", "$", "context", "=", "context_user", "::", "instance", "(", "$", "params", "[", "'userid'", "]", ")", ";", "self", "::", "validate_context", "(", "$", "context", ")", ";", "$", "output", "=", "$", "PAGE", "->", "get_renderer", "(", "'core'", ")", ";", "$", "params", "=", "(", "object", ")", "$", "params", ";", "$", "result", "=", "api", "::", "create_plan", "(", "$", "params", ")", ";", "$", "exporter", "=", "new", "plan_exporter", "(", "$", "result", ",", "array", "(", "'template'", "=>", "null", ")", ")", ";", "return", "$", "exporter", "->", "export", "(", "$", "output", ")", ";", "}" ]
Create a new learning plan. @param array $plan List of fields for the plan. @return array New plan record.
[ "Create", "a", "new", "learning", "plan", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/competency/classes/external.php#L2652-L2667
218,709
moodle/moodle
competency/classes/external.php
external.update_plan
public static function update_plan($plan) { global $PAGE; $params = self::validate_parameters(self::update_plan_parameters(), array('plan' => $plan)); $params = $params['plan']; $plan = api::read_plan($params['id']); self::validate_context($plan->get_context()); $output = $PAGE->get_renderer('core'); $params = (object) $params; $result = api::update_plan($params); $exporter = new plan_exporter($result, ['template' => $plan->get_template()]); return $exporter->export($output); }
php
public static function update_plan($plan) { global $PAGE; $params = self::validate_parameters(self::update_plan_parameters(), array('plan' => $plan)); $params = $params['plan']; $plan = api::read_plan($params['id']); self::validate_context($plan->get_context()); $output = $PAGE->get_renderer('core'); $params = (object) $params; $result = api::update_plan($params); $exporter = new plan_exporter($result, ['template' => $plan->get_template()]); return $exporter->export($output); }
[ "public", "static", "function", "update_plan", "(", "$", "plan", ")", "{", "global", "$", "PAGE", ";", "$", "params", "=", "self", "::", "validate_parameters", "(", "self", "::", "update_plan_parameters", "(", ")", ",", "array", "(", "'plan'", "=>", "$", "plan", ")", ")", ";", "$", "params", "=", "$", "params", "[", "'plan'", "]", ";", "$", "plan", "=", "api", "::", "read_plan", "(", "$", "params", "[", "'id'", "]", ")", ";", "self", "::", "validate_context", "(", "$", "plan", "->", "get_context", "(", ")", ")", ";", "$", "output", "=", "$", "PAGE", "->", "get_renderer", "(", "'core'", ")", ";", "$", "params", "=", "(", "object", ")", "$", "params", ";", "$", "result", "=", "api", "::", "update_plan", "(", "$", "params", ")", ";", "$", "exporter", "=", "new", "plan_exporter", "(", "$", "result", ",", "[", "'template'", "=>", "$", "plan", "->", "get_template", "(", ")", "]", ")", ";", "return", "$", "exporter", "->", "export", "(", "$", "output", ")", ";", "}" ]
Updates a new learning plan. @param array $plan Fields for the plan (id is required) @return mixed
[ "Updates", "a", "new", "learning", "plan", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/competency/classes/external.php#L2695-L2710
218,710
moodle/moodle
competency/classes/external.php
external.complete_plan
public static function complete_plan($planid) { $params = self::validate_parameters(self::complete_plan_parameters(), array( 'planid' => $planid )); return api::complete_plan($params['planid']); }
php
public static function complete_plan($planid) { $params = self::validate_parameters(self::complete_plan_parameters(), array( 'planid' => $planid )); return api::complete_plan($params['planid']); }
[ "public", "static", "function", "complete_plan", "(", "$", "planid", ")", "{", "$", "params", "=", "self", "::", "validate_parameters", "(", "self", "::", "complete_plan_parameters", "(", ")", ",", "array", "(", "'planid'", "=>", "$", "planid", ")", ")", ";", "return", "api", "::", "complete_plan", "(", "$", "params", "[", "'planid'", "]", ")", ";", "}" ]
Complete Learning plan. @param int $planid plan id (id is required) @return boolean
[ "Complete", "Learning", "plan", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/competency/classes/external.php#L2742-L2748
218,711
moodle/moodle
competency/classes/external.php
external.reopen_plan
public static function reopen_plan($planid) { $params = self::validate_parameters(self::reopen_plan_parameters(), array( 'planid' => $planid )); return api::reopen_plan($params['planid']); }
php
public static function reopen_plan($planid) { $params = self::validate_parameters(self::reopen_plan_parameters(), array( 'planid' => $planid )); return api::reopen_plan($params['planid']); }
[ "public", "static", "function", "reopen_plan", "(", "$", "planid", ")", "{", "$", "params", "=", "self", "::", "validate_parameters", "(", "self", "::", "reopen_plan_parameters", "(", ")", ",", "array", "(", "'planid'", "=>", "$", "planid", ")", ")", ";", "return", "api", "::", "reopen_plan", "(", "$", "params", "[", "'planid'", "]", ")", ";", "}" ]
Reopen Learning plan. @param int $planid plan id (id is required) @return boolean
[ "Reopen", "Learning", "plan", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/competency/classes/external.php#L2780-L2786
218,712
moodle/moodle
competency/classes/external.php
external.read_plan
public static function read_plan($id) { global $PAGE; $params = self::validate_parameters(self::read_plan_parameters(), array( 'id' => $id, )); $plan = api::read_plan($params['id']); self::validate_context($plan->get_context()); $output = $PAGE->get_renderer('core'); $exporter = new plan_exporter($plan, array('template' => $plan->get_template())); $record = $exporter->export($output); return external_api::clean_returnvalue(self::read_plan_returns(), $record); }
php
public static function read_plan($id) { global $PAGE; $params = self::validate_parameters(self::read_plan_parameters(), array( 'id' => $id, )); $plan = api::read_plan($params['id']); self::validate_context($plan->get_context()); $output = $PAGE->get_renderer('core'); $exporter = new plan_exporter($plan, array('template' => $plan->get_template())); $record = $exporter->export($output); return external_api::clean_returnvalue(self::read_plan_returns(), $record); }
[ "public", "static", "function", "read_plan", "(", "$", "id", ")", "{", "global", "$", "PAGE", ";", "$", "params", "=", "self", "::", "validate_parameters", "(", "self", "::", "read_plan_parameters", "(", ")", ",", "array", "(", "'id'", "=>", "$", "id", ",", ")", ")", ";", "$", "plan", "=", "api", "::", "read_plan", "(", "$", "params", "[", "'id'", "]", ")", ";", "self", "::", "validate_context", "(", "$", "plan", "->", "get_context", "(", ")", ")", ";", "$", "output", "=", "$", "PAGE", "->", "get_renderer", "(", "'core'", ")", ";", "$", "exporter", "=", "new", "plan_exporter", "(", "$", "plan", ",", "array", "(", "'template'", "=>", "$", "plan", "->", "get_template", "(", ")", ")", ")", ";", "$", "record", "=", "$", "exporter", "->", "export", "(", "$", "output", ")", ";", "return", "external_api", "::", "clean_returnvalue", "(", "self", "::", "read_plan_returns", "(", ")", ",", "$", "record", ")", ";", "}" ]
Read a plan by id. @param int $id The id of the plan. @return \stdClass
[ "Read", "a", "plan", "by", "id", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/competency/classes/external.php#L2817-L2831
218,713
moodle/moodle
competency/classes/external.php
external.delete_plan
public static function delete_plan($id) { $params = self::validate_parameters(self::delete_plan_parameters(), array( 'id' => $id, )); $plan = api::read_plan($params['id']); self::validate_context($plan->get_context()); return external_api::clean_returnvalue(self::delete_plan_returns(), api::delete_plan($params['id'])); }
php
public static function delete_plan($id) { $params = self::validate_parameters(self::delete_plan_parameters(), array( 'id' => $id, )); $plan = api::read_plan($params['id']); self::validate_context($plan->get_context()); return external_api::clean_returnvalue(self::delete_plan_returns(), api::delete_plan($params['id'])); }
[ "public", "static", "function", "delete_plan", "(", "$", "id", ")", "{", "$", "params", "=", "self", "::", "validate_parameters", "(", "self", "::", "delete_plan_parameters", "(", ")", ",", "array", "(", "'id'", "=>", "$", "id", ",", ")", ")", ";", "$", "plan", "=", "api", "::", "read_plan", "(", "$", "params", "[", "'id'", "]", ")", ";", "self", "::", "validate_context", "(", "$", "plan", "->", "get_context", "(", ")", ")", ";", "return", "external_api", "::", "clean_returnvalue", "(", "self", "::", "delete_plan_returns", "(", ")", ",", "api", "::", "delete_plan", "(", "$", "params", "[", "'id'", "]", ")", ")", ";", "}" ]
Delete a plan. @param int $id The plan id @return boolean
[ "Delete", "a", "plan", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/competency/classes/external.php#L2866-L2875
218,714
moodle/moodle
competency/classes/external.php
external.plan_cancel_review_request
public static function plan_cancel_review_request($id) { $params = self::validate_parameters(self::plan_cancel_review_request_parameters(), array( 'id' => $id )); $plan = api::read_plan($id); self::validate_context($plan->get_context()); return api::plan_cancel_review_request($plan); }
php
public static function plan_cancel_review_request($id) { $params = self::validate_parameters(self::plan_cancel_review_request_parameters(), array( 'id' => $id )); $plan = api::read_plan($id); self::validate_context($plan->get_context()); return api::plan_cancel_review_request($plan); }
[ "public", "static", "function", "plan_cancel_review_request", "(", "$", "id", ")", "{", "$", "params", "=", "self", "::", "validate_parameters", "(", "self", "::", "plan_cancel_review_request_parameters", "(", ")", ",", "array", "(", "'id'", "=>", "$", "id", ")", ")", ";", "$", "plan", "=", "api", "::", "read_plan", "(", "$", "id", ")", ";", "self", "::", "validate_context", "(", "$", "plan", "->", "get_context", "(", ")", ")", ";", "return", "api", "::", "plan_cancel_review_request", "(", "$", "plan", ")", ";", "}" ]
External function plan_cancel_review_request. @param int $id The plan ID. @return boolean
[ "External", "function", "plan_cancel_review_request", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/competency/classes/external.php#L2903-L2912
218,715
moodle/moodle
competency/classes/external.php
external.plan_request_review
public static function plan_request_review($id) { $params = self::validate_parameters(self::plan_request_review_parameters(), array( 'id' => $id )); $plan = api::read_plan($id); self::validate_context($plan->get_context()); return api::plan_request_review($plan); }
php
public static function plan_request_review($id) { $params = self::validate_parameters(self::plan_request_review_parameters(), array( 'id' => $id )); $plan = api::read_plan($id); self::validate_context($plan->get_context()); return api::plan_request_review($plan); }
[ "public", "static", "function", "plan_request_review", "(", "$", "id", ")", "{", "$", "params", "=", "self", "::", "validate_parameters", "(", "self", "::", "plan_request_review_parameters", "(", ")", ",", "array", "(", "'id'", "=>", "$", "id", ")", ")", ";", "$", "plan", "=", "api", "::", "read_plan", "(", "$", "id", ")", ";", "self", "::", "validate_context", "(", "$", "plan", "->", "get_context", "(", ")", ")", ";", "return", "api", "::", "plan_request_review", "(", "$", "plan", ")", ";", "}" ]
External function plan_request_review. @param int $id The plan ID. @return boolean
[ "External", "function", "plan_request_review", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/competency/classes/external.php#L2940-L2949
218,716
moodle/moodle
competency/classes/external.php
external.plan_start_review
public static function plan_start_review($id) { $params = self::validate_parameters(self::plan_start_review_parameters(), array( 'id' => $id )); $plan = api::read_plan($id); self::validate_context($plan->get_context()); return api::plan_start_review($plan); }
php
public static function plan_start_review($id) { $params = self::validate_parameters(self::plan_start_review_parameters(), array( 'id' => $id )); $plan = api::read_plan($id); self::validate_context($plan->get_context()); return api::plan_start_review($plan); }
[ "public", "static", "function", "plan_start_review", "(", "$", "id", ")", "{", "$", "params", "=", "self", "::", "validate_parameters", "(", "self", "::", "plan_start_review_parameters", "(", ")", ",", "array", "(", "'id'", "=>", "$", "id", ")", ")", ";", "$", "plan", "=", "api", "::", "read_plan", "(", "$", "id", ")", ";", "self", "::", "validate_context", "(", "$", "plan", "->", "get_context", "(", ")", ")", ";", "return", "api", "::", "plan_start_review", "(", "$", "plan", ")", ";", "}" ]
External function plan_start_review. @param int $id The plan ID. @return boolean
[ "External", "function", "plan_start_review", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/competency/classes/external.php#L2977-L2986
218,717
moodle/moodle
competency/classes/external.php
external.plan_stop_review
public static function plan_stop_review($id) { $params = self::validate_parameters(self::plan_stop_review_parameters(), array( 'id' => $id )); $plan = api::read_plan($id); self::validate_context($plan->get_context()); return api::plan_stop_review($plan); }
php
public static function plan_stop_review($id) { $params = self::validate_parameters(self::plan_stop_review_parameters(), array( 'id' => $id )); $plan = api::read_plan($id); self::validate_context($plan->get_context()); return api::plan_stop_review($plan); }
[ "public", "static", "function", "plan_stop_review", "(", "$", "id", ")", "{", "$", "params", "=", "self", "::", "validate_parameters", "(", "self", "::", "plan_stop_review_parameters", "(", ")", ",", "array", "(", "'id'", "=>", "$", "id", ")", ")", ";", "$", "plan", "=", "api", "::", "read_plan", "(", "$", "id", ")", ";", "self", "::", "validate_context", "(", "$", "plan", "->", "get_context", "(", ")", ")", ";", "return", "api", "::", "plan_stop_review", "(", "$", "plan", ")", ";", "}" ]
External function plan_stop_review. @param int $id The plan ID. @return boolean
[ "External", "function", "plan_stop_review", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/competency/classes/external.php#L3014-L3023
218,718
moodle/moodle
competency/classes/external.php
external.approve_plan
public static function approve_plan($id) { $params = self::validate_parameters(self::approve_plan_parameters(), array( 'id' => $id, )); $plan = api::read_plan($id); self::validate_context($plan->get_context()); return api::approve_plan($plan); }
php
public static function approve_plan($id) { $params = self::validate_parameters(self::approve_plan_parameters(), array( 'id' => $id, )); $plan = api::read_plan($id); self::validate_context($plan->get_context()); return api::approve_plan($plan); }
[ "public", "static", "function", "approve_plan", "(", "$", "id", ")", "{", "$", "params", "=", "self", "::", "validate_parameters", "(", "self", "::", "approve_plan_parameters", "(", ")", ",", "array", "(", "'id'", "=>", "$", "id", ",", ")", ")", ";", "$", "plan", "=", "api", "::", "read_plan", "(", "$", "id", ")", ";", "self", "::", "validate_context", "(", "$", "plan", "->", "get_context", "(", ")", ")", ";", "return", "api", "::", "approve_plan", "(", "$", "plan", ")", ";", "}" ]
External function approve_plan. @param int $id The plan ID. @return boolean
[ "External", "function", "approve_plan", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/competency/classes/external.php#L3051-L3060
218,719
moodle/moodle
competency/classes/external.php
external.unapprove_plan
public static function unapprove_plan($id) { $params = self::validate_parameters(self::unapprove_plan_parameters(), array( 'id' => $id, )); $plan = api::read_plan($id); self::validate_context($plan->get_context()); return api::unapprove_plan($plan); }
php
public static function unapprove_plan($id) { $params = self::validate_parameters(self::unapprove_plan_parameters(), array( 'id' => $id, )); $plan = api::read_plan($id); self::validate_context($plan->get_context()); return api::unapprove_plan($plan); }
[ "public", "static", "function", "unapprove_plan", "(", "$", "id", ")", "{", "$", "params", "=", "self", "::", "validate_parameters", "(", "self", "::", "unapprove_plan_parameters", "(", ")", ",", "array", "(", "'id'", "=>", "$", "id", ",", ")", ")", ";", "$", "plan", "=", "api", "::", "read_plan", "(", "$", "id", ")", ";", "self", "::", "validate_context", "(", "$", "plan", "->", "get_context", "(", ")", ")", ";", "return", "api", "::", "unapprove_plan", "(", "$", "plan", ")", ";", "}" ]
External function unapprove_plan. @param int $id The plan ID. @return boolean
[ "External", "function", "unapprove_plan", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/competency/classes/external.php#L3088-L3097
218,720
moodle/moodle
competency/classes/external.php
external.list_plan_competencies
public static function list_plan_competencies($id) { global $PAGE; $params = self::validate_parameters(self::list_plan_competencies_parameters(), array('id' => $id)); $id = $params['id']; $plan = api::read_plan($id); $usercontext = $plan->get_context(); self::validate_context($usercontext); $output = $PAGE->get_renderer('core'); $result = api::list_plan_competencies($plan); if ($plan->get('status') == plan::STATUS_COMPLETE) { $ucproperty = 'usercompetencyplan'; } else { $ucproperty = 'usercompetency'; } $helper = new performance_helper(); foreach ($result as $key => $r) { $context = $helper->get_context_from_competency($r->competency); $scale = $helper->get_scale_from_competency($r->competency); $exporter = new competency_exporter($r->competency, array('context' => $context)); $r->competency = $exporter->export($output); if ($r->usercompetency) { $exporter = new user_competency_exporter($r->usercompetency, array('scale' => $scale)); $r->usercompetency = $exporter->export($output); unset($r->usercompetencyplan); } else { $exporter = new user_competency_plan_exporter($r->usercompetencyplan, array('scale' => $scale)); $r->usercompetencyplan = $exporter->export($output); unset($r->usercompetency); } } return $result; }
php
public static function list_plan_competencies($id) { global $PAGE; $params = self::validate_parameters(self::list_plan_competencies_parameters(), array('id' => $id)); $id = $params['id']; $plan = api::read_plan($id); $usercontext = $plan->get_context(); self::validate_context($usercontext); $output = $PAGE->get_renderer('core'); $result = api::list_plan_competencies($plan); if ($plan->get('status') == plan::STATUS_COMPLETE) { $ucproperty = 'usercompetencyplan'; } else { $ucproperty = 'usercompetency'; } $helper = new performance_helper(); foreach ($result as $key => $r) { $context = $helper->get_context_from_competency($r->competency); $scale = $helper->get_scale_from_competency($r->competency); $exporter = new competency_exporter($r->competency, array('context' => $context)); $r->competency = $exporter->export($output); if ($r->usercompetency) { $exporter = new user_competency_exporter($r->usercompetency, array('scale' => $scale)); $r->usercompetency = $exporter->export($output); unset($r->usercompetencyplan); } else { $exporter = new user_competency_plan_exporter($r->usercompetencyplan, array('scale' => $scale)); $r->usercompetencyplan = $exporter->export($output); unset($r->usercompetency); } } return $result; }
[ "public", "static", "function", "list_plan_competencies", "(", "$", "id", ")", "{", "global", "$", "PAGE", ";", "$", "params", "=", "self", "::", "validate_parameters", "(", "self", "::", "list_plan_competencies_parameters", "(", ")", ",", "array", "(", "'id'", "=>", "$", "id", ")", ")", ";", "$", "id", "=", "$", "params", "[", "'id'", "]", ";", "$", "plan", "=", "api", "::", "read_plan", "(", "$", "id", ")", ";", "$", "usercontext", "=", "$", "plan", "->", "get_context", "(", ")", ";", "self", "::", "validate_context", "(", "$", "usercontext", ")", ";", "$", "output", "=", "$", "PAGE", "->", "get_renderer", "(", "'core'", ")", ";", "$", "result", "=", "api", "::", "list_plan_competencies", "(", "$", "plan", ")", ";", "if", "(", "$", "plan", "->", "get", "(", "'status'", ")", "==", "plan", "::", "STATUS_COMPLETE", ")", "{", "$", "ucproperty", "=", "'usercompetencyplan'", ";", "}", "else", "{", "$", "ucproperty", "=", "'usercompetency'", ";", "}", "$", "helper", "=", "new", "performance_helper", "(", ")", ";", "foreach", "(", "$", "result", "as", "$", "key", "=>", "$", "r", ")", "{", "$", "context", "=", "$", "helper", "->", "get_context_from_competency", "(", "$", "r", "->", "competency", ")", ";", "$", "scale", "=", "$", "helper", "->", "get_scale_from_competency", "(", "$", "r", "->", "competency", ")", ";", "$", "exporter", "=", "new", "competency_exporter", "(", "$", "r", "->", "competency", ",", "array", "(", "'context'", "=>", "$", "context", ")", ")", ";", "$", "r", "->", "competency", "=", "$", "exporter", "->", "export", "(", "$", "output", ")", ";", "if", "(", "$", "r", "->", "usercompetency", ")", "{", "$", "exporter", "=", "new", "user_competency_exporter", "(", "$", "r", "->", "usercompetency", ",", "array", "(", "'scale'", "=>", "$", "scale", ")", ")", ";", "$", "r", "->", "usercompetency", "=", "$", "exporter", "->", "export", "(", "$", "output", ")", ";", "unset", "(", "$", "r", "->", "usercompetencyplan", ")", ";", "}", "else", "{", "$", "exporter", "=", "new", "user_competency_plan_exporter", "(", "$", "r", "->", "usercompetencyplan", ",", "array", "(", "'scale'", "=>", "$", "scale", ")", ")", ";", "$", "r", "->", "usercompetencyplan", "=", "$", "exporter", "->", "export", "(", "$", "output", ")", ";", "unset", "(", "$", "r", "->", "usercompetency", ")", ";", "}", "}", "return", "$", "result", ";", "}" ]
List plan competencies. @param int $id The plan ID. @return array
[ "List", "plan", "competencies", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/competency/classes/external.php#L3124-L3161
218,721
moodle/moodle
competency/classes/external.php
external.list_plan_competencies_returns
public static function list_plan_competencies_returns() { $uc = user_competency_exporter::get_read_structure(); $ucp = user_competency_plan_exporter::get_read_structure(); $uc->required = VALUE_OPTIONAL; $ucp->required = VALUE_OPTIONAL; return new external_multiple_structure( new external_single_structure(array( 'competency' => competency_exporter::get_read_structure(), 'usercompetency' => $uc, 'usercompetencyplan' => $ucp )) ); }
php
public static function list_plan_competencies_returns() { $uc = user_competency_exporter::get_read_structure(); $ucp = user_competency_plan_exporter::get_read_structure(); $uc->required = VALUE_OPTIONAL; $ucp->required = VALUE_OPTIONAL; return new external_multiple_structure( new external_single_structure(array( 'competency' => competency_exporter::get_read_structure(), 'usercompetency' => $uc, 'usercompetencyplan' => $ucp )) ); }
[ "public", "static", "function", "list_plan_competencies_returns", "(", ")", "{", "$", "uc", "=", "user_competency_exporter", "::", "get_read_structure", "(", ")", ";", "$", "ucp", "=", "user_competency_plan_exporter", "::", "get_read_structure", "(", ")", ";", "$", "uc", "->", "required", "=", "VALUE_OPTIONAL", ";", "$", "ucp", "->", "required", "=", "VALUE_OPTIONAL", ";", "return", "new", "external_multiple_structure", "(", "new", "external_single_structure", "(", "array", "(", "'competency'", "=>", "competency_exporter", "::", "get_read_structure", "(", ")", ",", "'usercompetency'", "=>", "$", "uc", ",", "'usercompetencyplan'", "=>", "$", "ucp", ")", ")", ")", ";", "}" ]
External function return structure. @return \external_description
[ "External", "function", "return", "structure", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/competency/classes/external.php#L3168-L3182
218,722
moodle/moodle
competency/classes/external.php
external.list_user_plans
public static function list_user_plans($userid) { global $PAGE; $params = self::validate_parameters(self::list_user_plans_parameters(), array( 'userid' => $userid )); $context = context_user::instance($params['userid']); self::validate_context($context); $output = $PAGE->get_renderer('core'); $response = array(); $plans = api::list_user_plans($params['userid']); foreach ($plans as $plan) { $exporter = new plan_exporter($plan, array('template' => $plan->get_template())); $response[] = $exporter->export($output); } return $response; }
php
public static function list_user_plans($userid) { global $PAGE; $params = self::validate_parameters(self::list_user_plans_parameters(), array( 'userid' => $userid )); $context = context_user::instance($params['userid']); self::validate_context($context); $output = $PAGE->get_renderer('core'); $response = array(); $plans = api::list_user_plans($params['userid']); foreach ($plans as $plan) { $exporter = new plan_exporter($plan, array('template' => $plan->get_template())); $response[] = $exporter->export($output); } return $response; }
[ "public", "static", "function", "list_user_plans", "(", "$", "userid", ")", "{", "global", "$", "PAGE", ";", "$", "params", "=", "self", "::", "validate_parameters", "(", "self", "::", "list_user_plans_parameters", "(", ")", ",", "array", "(", "'userid'", "=>", "$", "userid", ")", ")", ";", "$", "context", "=", "context_user", "::", "instance", "(", "$", "params", "[", "'userid'", "]", ")", ";", "self", "::", "validate_context", "(", "$", "context", ")", ";", "$", "output", "=", "$", "PAGE", "->", "get_renderer", "(", "'core'", ")", ";", "$", "response", "=", "array", "(", ")", ";", "$", "plans", "=", "api", "::", "list_user_plans", "(", "$", "params", "[", "'userid'", "]", ")", ";", "foreach", "(", "$", "plans", "as", "$", "plan", ")", "{", "$", "exporter", "=", "new", "plan_exporter", "(", "$", "plan", ",", "array", "(", "'template'", "=>", "$", "plan", "->", "get_template", "(", ")", ")", ")", ";", "$", "response", "[", "]", "=", "$", "exporter", "->", "export", "(", "$", "output", ")", ";", "}", "return", "$", "response", ";", "}" ]
External function list_user_plans. @param int $userid The user ID. @return boolean
[ "External", "function", "list_user_plans", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/competency/classes/external.php#L3201-L3219
218,723
moodle/moodle
competency/classes/external.php
external.request_review_of_user_evidence_linked_competencies
public static function request_review_of_user_evidence_linked_competencies($id) { $params = self::validate_parameters(self::request_review_of_user_evidence_linked_competencies_parameters(), array( 'id' => $id )); $userevidence = api::read_user_evidence($id); self::validate_context($userevidence->get_context()); return api::request_review_of_user_evidence_linked_competencies($id); }
php
public static function request_review_of_user_evidence_linked_competencies($id) { $params = self::validate_parameters(self::request_review_of_user_evidence_linked_competencies_parameters(), array( 'id' => $id )); $userevidence = api::read_user_evidence($id); self::validate_context($userevidence->get_context()); return api::request_review_of_user_evidence_linked_competencies($id); }
[ "public", "static", "function", "request_review_of_user_evidence_linked_competencies", "(", "$", "id", ")", "{", "$", "params", "=", "self", "::", "validate_parameters", "(", "self", "::", "request_review_of_user_evidence_linked_competencies_parameters", "(", ")", ",", "array", "(", "'id'", "=>", "$", "id", ")", ")", ";", "$", "userevidence", "=", "api", "::", "read_user_evidence", "(", "$", "id", ")", ";", "self", "::", "validate_context", "(", "$", "userevidence", "->", "get_context", "(", ")", ")", ";", "return", "api", "::", "request_review_of_user_evidence_linked_competencies", "(", "$", "id", ")", ";", "}" ]
Send user evidence competencies to review. @param int $id The user evidence id. @return boolean
[ "Send", "user", "evidence", "competencies", "to", "review", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/competency/classes/external.php#L3407-L3416
218,724
moodle/moodle
competency/classes/external.php
external.get_scale_values
public static function get_scale_values($scaleid) { global $DB; $params = self::validate_parameters(self::get_scale_values_parameters(), array( 'scaleid' => $scaleid, ) ); $context = context_system::instance(); self::validate_context($context); // The following section is not learning plan specific and so has not been moved to the api. // Retrieve the scale value from the database. $scale = grade_scale::fetch(array('id' => $scaleid)); $scalevalues = $scale->load_items(); foreach ($scalevalues as $key => $value) { // Add a key (make the first value 1). $scalevalues[$key] = array( 'id' => $key + 1, 'name' => external_format_string($value, $context->id) ); } return $scalevalues; }
php
public static function get_scale_values($scaleid) { global $DB; $params = self::validate_parameters(self::get_scale_values_parameters(), array( 'scaleid' => $scaleid, ) ); $context = context_system::instance(); self::validate_context($context); // The following section is not learning plan specific and so has not been moved to the api. // Retrieve the scale value from the database. $scale = grade_scale::fetch(array('id' => $scaleid)); $scalevalues = $scale->load_items(); foreach ($scalevalues as $key => $value) { // Add a key (make the first value 1). $scalevalues[$key] = array( 'id' => $key + 1, 'name' => external_format_string($value, $context->id) ); } return $scalevalues; }
[ "public", "static", "function", "get_scale_values", "(", "$", "scaleid", ")", "{", "global", "$", "DB", ";", "$", "params", "=", "self", "::", "validate_parameters", "(", "self", "::", "get_scale_values_parameters", "(", ")", ",", "array", "(", "'scaleid'", "=>", "$", "scaleid", ",", ")", ")", ";", "$", "context", "=", "context_system", "::", "instance", "(", ")", ";", "self", "::", "validate_context", "(", "$", "context", ")", ";", "// The following section is not learning plan specific and so has not been moved to the api.", "// Retrieve the scale value from the database.", "$", "scale", "=", "grade_scale", "::", "fetch", "(", "array", "(", "'id'", "=>", "$", "scaleid", ")", ")", ";", "$", "scalevalues", "=", "$", "scale", "->", "load_items", "(", ")", ";", "foreach", "(", "$", "scalevalues", "as", "$", "key", "=>", "$", "value", ")", "{", "// Add a key (make the first value 1).", "$", "scalevalues", "[", "$", "key", "]", "=", "array", "(", "'id'", "=>", "$", "key", "+", "1", ",", "'name'", "=>", "external_format_string", "(", "$", "value", ",", "$", "context", "->", "id", ")", ")", ";", "}", "return", "$", "scalevalues", ";", "}" ]
Get the values associated with a scale. @param int $scaleid Scale ID @return array Values for a scale.
[ "Get", "the", "values", "associated", "with", "a", "scale", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/competency/classes/external.php#L3449-L3470
218,725
moodle/moodle
competency/classes/external.php
external.add_related_competency
public static function add_related_competency($competencyid, $relatedcompetencyid) { $params = self::validate_parameters(self::add_related_competency_parameters(), array( 'competencyid' => $competencyid, 'relatedcompetencyid' => $relatedcompetencyid )); $competency = api::read_competency($params['competencyid']); self::validate_context($competency->get_context()); return api::add_related_competency($params['competencyid'], $params['relatedcompetencyid']); }
php
public static function add_related_competency($competencyid, $relatedcompetencyid) { $params = self::validate_parameters(self::add_related_competency_parameters(), array( 'competencyid' => $competencyid, 'relatedcompetencyid' => $relatedcompetencyid )); $competency = api::read_competency($params['competencyid']); self::validate_context($competency->get_context()); return api::add_related_competency($params['competencyid'], $params['relatedcompetencyid']); }
[ "public", "static", "function", "add_related_competency", "(", "$", "competencyid", ",", "$", "relatedcompetencyid", ")", "{", "$", "params", "=", "self", "::", "validate_parameters", "(", "self", "::", "add_related_competency_parameters", "(", ")", ",", "array", "(", "'competencyid'", "=>", "$", "competencyid", ",", "'relatedcompetencyid'", "=>", "$", "relatedcompetencyid", ")", ")", ";", "$", "competency", "=", "api", "::", "read_competency", "(", "$", "params", "[", "'competencyid'", "]", ")", ";", "self", "::", "validate_context", "(", "$", "competency", "->", "get_context", "(", ")", ")", ";", "return", "api", "::", "add_related_competency", "(", "$", "params", "[", "'competencyid'", "]", ",", "$", "params", "[", "'relatedcompetencyid'", "]", ")", ";", "}" ]
Adds a related competency. @param int $competencyid @param int $relatedcompetencyid @return bool
[ "Adds", "a", "related", "competency", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/competency/classes/external.php#L3517-L3526
218,726
moodle/moodle
competency/classes/external.php
external.remove_related_competency
public static function remove_related_competency($competencyid, $relatedcompetencyid) { $params = self::validate_parameters(self::remove_related_competency_parameters(), array( 'competencyid' => $competencyid, 'relatedcompetencyid' => $relatedcompetencyid )); $competency = api::read_competency($params['competencyid']); self::validate_context($competency->get_context()); return api::remove_related_competency($params['competencyid'], $params['relatedcompetencyid']); }
php
public static function remove_related_competency($competencyid, $relatedcompetencyid) { $params = self::validate_parameters(self::remove_related_competency_parameters(), array( 'competencyid' => $competencyid, 'relatedcompetencyid' => $relatedcompetencyid )); $competency = api::read_competency($params['competencyid']); self::validate_context($competency->get_context()); return api::remove_related_competency($params['competencyid'], $params['relatedcompetencyid']); }
[ "public", "static", "function", "remove_related_competency", "(", "$", "competencyid", ",", "$", "relatedcompetencyid", ")", "{", "$", "params", "=", "self", "::", "validate_parameters", "(", "self", "::", "remove_related_competency_parameters", "(", ")", ",", "array", "(", "'competencyid'", "=>", "$", "competencyid", ",", "'relatedcompetencyid'", "=>", "$", "relatedcompetencyid", ")", ")", ";", "$", "competency", "=", "api", "::", "read_competency", "(", "$", "params", "[", "'competencyid'", "]", ")", ";", "self", "::", "validate_context", "(", "$", "competency", "->", "get_context", "(", ")", ")", ";", "return", "api", "::", "remove_related_competency", "(", "$", "params", "[", "'competencyid'", "]", ",", "$", "params", "[", "'relatedcompetencyid'", "]", ")", ";", "}" ]
Removes a related competency. @param int $competencyid @param int $relatedcompetencyid @return bool
[ "Removes", "a", "related", "competency", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/competency/classes/external.php#L3567-L3576
218,727
moodle/moodle
competency/classes/external.php
external.set_course_competency_ruleoutcome
public static function set_course_competency_ruleoutcome($coursecompetencyid, $ruleoutcome) { $params = self::validate_parameters(self::set_course_competency_ruleoutcome_parameters(), array( 'coursecompetencyid' => $coursecompetencyid, 'ruleoutcome' => $ruleoutcome, )); $coursecompetency = new course_competency($params['coursecompetencyid']); self::validate_context(context_course::instance($coursecompetency->get('courseid'))); return api::set_course_competency_ruleoutcome($coursecompetency, $params['ruleoutcome']); }
php
public static function set_course_competency_ruleoutcome($coursecompetencyid, $ruleoutcome) { $params = self::validate_parameters(self::set_course_competency_ruleoutcome_parameters(), array( 'coursecompetencyid' => $coursecompetencyid, 'ruleoutcome' => $ruleoutcome, )); $coursecompetency = new course_competency($params['coursecompetencyid']); self::validate_context(context_course::instance($coursecompetency->get('courseid'))); return api::set_course_competency_ruleoutcome($coursecompetency, $params['ruleoutcome']); }
[ "public", "static", "function", "set_course_competency_ruleoutcome", "(", "$", "coursecompetencyid", ",", "$", "ruleoutcome", ")", "{", "$", "params", "=", "self", "::", "validate_parameters", "(", "self", "::", "set_course_competency_ruleoutcome_parameters", "(", ")", ",", "array", "(", "'coursecompetencyid'", "=>", "$", "coursecompetencyid", ",", "'ruleoutcome'", "=>", "$", "ruleoutcome", ",", ")", ")", ";", "$", "coursecompetency", "=", "new", "course_competency", "(", "$", "params", "[", "'coursecompetencyid'", "]", ")", ";", "self", "::", "validate_context", "(", "context_course", "::", "instance", "(", "$", "coursecompetency", "->", "get", "(", "'courseid'", ")", ")", ")", ";", "return", "api", "::", "set_course_competency_ruleoutcome", "(", "$", "coursecompetency", ",", "$", "params", "[", "'ruleoutcome'", "]", ")", ";", "}" ]
Change the ruleoutcome of a course competency. @param int $coursecompetencyid The course competency id @param int $ruleoutcome The ruleoutcome value @return bool
[ "Change", "the", "ruleoutcome", "of", "a", "course", "competency", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/competency/classes/external.php#L3619-L3629
218,728
moodle/moodle
competency/classes/external.php
external.grade_competency_parameters
public static function grade_competency_parameters() { $userid = new external_value( PARAM_INT, 'User ID', VALUE_REQUIRED ); $competencyid = new external_value( PARAM_INT, 'Competency ID', VALUE_REQUIRED ); $grade = new external_value( PARAM_INT, 'New grade', VALUE_REQUIRED ); $note = new external_value( PARAM_NOTAGS, 'A note to attach to the evidence', VALUE_DEFAULT ); $params = array( 'userid' => $userid, 'competencyid' => $competencyid, 'grade' => $grade, 'note' => $note, ); return new external_function_parameters($params); }
php
public static function grade_competency_parameters() { $userid = new external_value( PARAM_INT, 'User ID', VALUE_REQUIRED ); $competencyid = new external_value( PARAM_INT, 'Competency ID', VALUE_REQUIRED ); $grade = new external_value( PARAM_INT, 'New grade', VALUE_REQUIRED ); $note = new external_value( PARAM_NOTAGS, 'A note to attach to the evidence', VALUE_DEFAULT ); $params = array( 'userid' => $userid, 'competencyid' => $competencyid, 'grade' => $grade, 'note' => $note, ); return new external_function_parameters($params); }
[ "public", "static", "function", "grade_competency_parameters", "(", ")", "{", "$", "userid", "=", "new", "external_value", "(", "PARAM_INT", ",", "'User ID'", ",", "VALUE_REQUIRED", ")", ";", "$", "competencyid", "=", "new", "external_value", "(", "PARAM_INT", ",", "'Competency ID'", ",", "VALUE_REQUIRED", ")", ";", "$", "grade", "=", "new", "external_value", "(", "PARAM_INT", ",", "'New grade'", ",", "VALUE_REQUIRED", ")", ";", "$", "note", "=", "new", "external_value", "(", "PARAM_NOTAGS", ",", "'A note to attach to the evidence'", ",", "VALUE_DEFAULT", ")", ";", "$", "params", "=", "array", "(", "'userid'", "=>", "$", "userid", ",", "'competencyid'", "=>", "$", "competencyid", ",", "'grade'", "=>", "$", "grade", ",", "'note'", "=>", "$", "note", ",", ")", ";", "return", "new", "external_function_parameters", "(", "$", "params", ")", ";", "}" ]
Returns description of external function parameters. @return \external_function_parameters
[ "Returns", "description", "of", "external", "function", "parameters", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/competency/classes/external.php#L3646-L3675
218,729
moodle/moodle
competency/classes/external.php
external.grade_competency
public static function grade_competency($userid, $competencyid, $grade, $note = null) { global $USER, $PAGE; $params = self::validate_parameters(self::grade_competency_parameters(), array( 'userid' => $userid, 'competencyid' => $competencyid, 'grade' => $grade, 'note' => $note )); $uc = api::get_user_competency($params['userid'], $params['competencyid']); self::validate_context($uc->get_context()); $output = $PAGE->get_renderer('core'); $evidence = api::grade_competency( $uc->get('userid'), $uc->get('competencyid'), $params['grade'], $params['note'] ); $scale = $uc->get_competency()->get_scale(); $exporter = new evidence_exporter($evidence, [ 'actionuser' => $USER, 'scale' => $scale, 'usercompetency' => $uc, 'usercompetencyplan' => null, 'context' => $evidence->get_context() ]); return $exporter->export($output); }
php
public static function grade_competency($userid, $competencyid, $grade, $note = null) { global $USER, $PAGE; $params = self::validate_parameters(self::grade_competency_parameters(), array( 'userid' => $userid, 'competencyid' => $competencyid, 'grade' => $grade, 'note' => $note )); $uc = api::get_user_competency($params['userid'], $params['competencyid']); self::validate_context($uc->get_context()); $output = $PAGE->get_renderer('core'); $evidence = api::grade_competency( $uc->get('userid'), $uc->get('competencyid'), $params['grade'], $params['note'] ); $scale = $uc->get_competency()->get_scale(); $exporter = new evidence_exporter($evidence, [ 'actionuser' => $USER, 'scale' => $scale, 'usercompetency' => $uc, 'usercompetencyplan' => null, 'context' => $evidence->get_context() ]); return $exporter->export($output); }
[ "public", "static", "function", "grade_competency", "(", "$", "userid", ",", "$", "competencyid", ",", "$", "grade", ",", "$", "note", "=", "null", ")", "{", "global", "$", "USER", ",", "$", "PAGE", ";", "$", "params", "=", "self", "::", "validate_parameters", "(", "self", "::", "grade_competency_parameters", "(", ")", ",", "array", "(", "'userid'", "=>", "$", "userid", ",", "'competencyid'", "=>", "$", "competencyid", ",", "'grade'", "=>", "$", "grade", ",", "'note'", "=>", "$", "note", ")", ")", ";", "$", "uc", "=", "api", "::", "get_user_competency", "(", "$", "params", "[", "'userid'", "]", ",", "$", "params", "[", "'competencyid'", "]", ")", ";", "self", "::", "validate_context", "(", "$", "uc", "->", "get_context", "(", ")", ")", ";", "$", "output", "=", "$", "PAGE", "->", "get_renderer", "(", "'core'", ")", ";", "$", "evidence", "=", "api", "::", "grade_competency", "(", "$", "uc", "->", "get", "(", "'userid'", ")", ",", "$", "uc", "->", "get", "(", "'competencyid'", ")", ",", "$", "params", "[", "'grade'", "]", ",", "$", "params", "[", "'note'", "]", ")", ";", "$", "scale", "=", "$", "uc", "->", "get_competency", "(", ")", "->", "get_scale", "(", ")", ";", "$", "exporter", "=", "new", "evidence_exporter", "(", "$", "evidence", ",", "[", "'actionuser'", "=>", "$", "USER", ",", "'scale'", "=>", "$", "scale", ",", "'usercompetency'", "=>", "$", "uc", ",", "'usercompetencyplan'", "=>", "null", ",", "'context'", "=>", "$", "evidence", "->", "get_context", "(", ")", "]", ")", ";", "return", "$", "exporter", "->", "export", "(", "$", "output", ")", ";", "}" ]
Grade a competency. @param int $userid The user ID. @param int $competencyid The competency id @param int $grade The new grade value @param string $note A note to attach to the evidence @return bool
[ "Grade", "a", "competency", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/competency/classes/external.php#L3686-L3715
218,730
moodle/moodle
competency/classes/external.php
external.grade_competency_in_plan
public static function grade_competency_in_plan($planid, $competencyid, $grade, $note = null) { global $USER, $PAGE; $params = self::validate_parameters(self::grade_competency_in_plan_parameters(), array( 'planid' => $planid, 'competencyid' => $competencyid, 'grade' => $grade, 'note' => $note )); $plan = new plan($params['planid']); $context = $plan->get_context(); self::validate_context($context); $output = $PAGE->get_renderer('core'); $evidence = api::grade_competency_in_plan( $plan->get('id'), $params['competencyid'], $params['grade'], $params['note'] ); $competency = api::read_competency($params['competencyid']); $scale = $competency->get_scale(); $exporter = new evidence_exporter($evidence, [ 'actionuser' => $USER, 'scale' => $scale, 'usercompetency' => null, 'usercompetencyplan' => null, 'context' => $evidence->get_context() ]); return $exporter->export($output); }
php
public static function grade_competency_in_plan($planid, $competencyid, $grade, $note = null) { global $USER, $PAGE; $params = self::validate_parameters(self::grade_competency_in_plan_parameters(), array( 'planid' => $planid, 'competencyid' => $competencyid, 'grade' => $grade, 'note' => $note )); $plan = new plan($params['planid']); $context = $plan->get_context(); self::validate_context($context); $output = $PAGE->get_renderer('core'); $evidence = api::grade_competency_in_plan( $plan->get('id'), $params['competencyid'], $params['grade'], $params['note'] ); $competency = api::read_competency($params['competencyid']); $scale = $competency->get_scale(); $exporter = new evidence_exporter($evidence, [ 'actionuser' => $USER, 'scale' => $scale, 'usercompetency' => null, 'usercompetencyplan' => null, 'context' => $evidence->get_context() ]); return $exporter->export($output); }
[ "public", "static", "function", "grade_competency_in_plan", "(", "$", "planid", ",", "$", "competencyid", ",", "$", "grade", ",", "$", "note", "=", "null", ")", "{", "global", "$", "USER", ",", "$", "PAGE", ";", "$", "params", "=", "self", "::", "validate_parameters", "(", "self", "::", "grade_competency_in_plan_parameters", "(", ")", ",", "array", "(", "'planid'", "=>", "$", "planid", ",", "'competencyid'", "=>", "$", "competencyid", ",", "'grade'", "=>", "$", "grade", ",", "'note'", "=>", "$", "note", ")", ")", ";", "$", "plan", "=", "new", "plan", "(", "$", "params", "[", "'planid'", "]", ")", ";", "$", "context", "=", "$", "plan", "->", "get_context", "(", ")", ";", "self", "::", "validate_context", "(", "$", "context", ")", ";", "$", "output", "=", "$", "PAGE", "->", "get_renderer", "(", "'core'", ")", ";", "$", "evidence", "=", "api", "::", "grade_competency_in_plan", "(", "$", "plan", "->", "get", "(", "'id'", ")", ",", "$", "params", "[", "'competencyid'", "]", ",", "$", "params", "[", "'grade'", "]", ",", "$", "params", "[", "'note'", "]", ")", ";", "$", "competency", "=", "api", "::", "read_competency", "(", "$", "params", "[", "'competencyid'", "]", ")", ";", "$", "scale", "=", "$", "competency", "->", "get_scale", "(", ")", ";", "$", "exporter", "=", "new", "evidence_exporter", "(", "$", "evidence", ",", "[", "'actionuser'", "=>", "$", "USER", ",", "'scale'", "=>", "$", "scale", ",", "'usercompetency'", "=>", "null", ",", "'usercompetencyplan'", "=>", "null", ",", "'context'", "=>", "$", "evidence", "->", "get_context", "(", ")", "]", ")", ";", "return", "$", "exporter", "->", "export", "(", "$", "output", ")", ";", "}" ]
Grade a competency in a plan. @param int $planid The plan id @param int $competencyid The competency id @param int $grade The new grade value @param string $note A note to add to the evidence @return bool
[ "Grade", "a", "competency", "in", "a", "plan", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/competency/classes/external.php#L3771-L3802
218,731
moodle/moodle
competency/classes/external.php
external.grade_competency_in_course
public static function grade_competency_in_course($courseid, $userid, $competencyid, $grade, $note = null) { global $USER, $PAGE, $DB; $params = self::validate_parameters(self::grade_competency_in_course_parameters(), array( 'courseid' => $courseid, 'userid' => $userid, 'competencyid' => $competencyid, 'grade' => $grade, 'note' => $note )); $course = $DB->get_record('course', array('id' => $params['courseid'])); $context = context_course::instance($course->id); self::validate_context($context); $output = $PAGE->get_renderer('core'); $evidence = api::grade_competency_in_course( $params['courseid'], $params['userid'], $params['competencyid'], $params['grade'], $params['note'] ); $competency = api::read_competency($params['competencyid']); $scale = $competency->get_scale(); $exporter = new evidence_exporter($evidence, array( 'actionuser' => $USER, 'scale' => $scale, 'usercompetency' => null, 'usercompetencyplan' => null, 'context' => $evidence->get_context(), )); return $exporter->export($output); }
php
public static function grade_competency_in_course($courseid, $userid, $competencyid, $grade, $note = null) { global $USER, $PAGE, $DB; $params = self::validate_parameters(self::grade_competency_in_course_parameters(), array( 'courseid' => $courseid, 'userid' => $userid, 'competencyid' => $competencyid, 'grade' => $grade, 'note' => $note )); $course = $DB->get_record('course', array('id' => $params['courseid'])); $context = context_course::instance($course->id); self::validate_context($context); $output = $PAGE->get_renderer('core'); $evidence = api::grade_competency_in_course( $params['courseid'], $params['userid'], $params['competencyid'], $params['grade'], $params['note'] ); $competency = api::read_competency($params['competencyid']); $scale = $competency->get_scale(); $exporter = new evidence_exporter($evidence, array( 'actionuser' => $USER, 'scale' => $scale, 'usercompetency' => null, 'usercompetencyplan' => null, 'context' => $evidence->get_context(), )); return $exporter->export($output); }
[ "public", "static", "function", "grade_competency_in_course", "(", "$", "courseid", ",", "$", "userid", ",", "$", "competencyid", ",", "$", "grade", ",", "$", "note", "=", "null", ")", "{", "global", "$", "USER", ",", "$", "PAGE", ",", "$", "DB", ";", "$", "params", "=", "self", "::", "validate_parameters", "(", "self", "::", "grade_competency_in_course_parameters", "(", ")", ",", "array", "(", "'courseid'", "=>", "$", "courseid", ",", "'userid'", "=>", "$", "userid", ",", "'competencyid'", "=>", "$", "competencyid", ",", "'grade'", "=>", "$", "grade", ",", "'note'", "=>", "$", "note", ")", ")", ";", "$", "course", "=", "$", "DB", "->", "get_record", "(", "'course'", ",", "array", "(", "'id'", "=>", "$", "params", "[", "'courseid'", "]", ")", ")", ";", "$", "context", "=", "context_course", "::", "instance", "(", "$", "course", "->", "id", ")", ";", "self", "::", "validate_context", "(", "$", "context", ")", ";", "$", "output", "=", "$", "PAGE", "->", "get_renderer", "(", "'core'", ")", ";", "$", "evidence", "=", "api", "::", "grade_competency_in_course", "(", "$", "params", "[", "'courseid'", "]", ",", "$", "params", "[", "'userid'", "]", ",", "$", "params", "[", "'competencyid'", "]", ",", "$", "params", "[", "'grade'", "]", ",", "$", "params", "[", "'note'", "]", ")", ";", "$", "competency", "=", "api", "::", "read_competency", "(", "$", "params", "[", "'competencyid'", "]", ")", ";", "$", "scale", "=", "$", "competency", "->", "get_scale", "(", ")", ";", "$", "exporter", "=", "new", "evidence_exporter", "(", "$", "evidence", ",", "array", "(", "'actionuser'", "=>", "$", "USER", ",", "'scale'", "=>", "$", "scale", ",", "'usercompetency'", "=>", "null", ",", "'usercompetencyplan'", "=>", "null", ",", "'context'", "=>", "$", "evidence", "->", "get_context", "(", ")", ",", ")", ")", ";", "return", "$", "exporter", "->", "export", "(", "$", "output", ")", ";", "}" ]
Grade a competency in a course. @param int $courseid The course id @param int $userid The user id @param int $competencyid The competency id @param int $grade The new grade value @param string $note A note to add to the evidence @return bool
[ "Grade", "a", "competency", "in", "a", "course", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/competency/classes/external.php#L4082-L4115
218,732
moodle/moodle
competency/classes/external.php
external.unlink_plan_from_template
public static function unlink_plan_from_template($planid) { $params = self::validate_parameters(self::unlink_plan_from_template_parameters(), array( 'planid' => $planid, )); $plan = new plan($params['planid']); self::validate_context($plan->get_context()); return api::unlink_plan_from_template($plan); }
php
public static function unlink_plan_from_template($planid) { $params = self::validate_parameters(self::unlink_plan_from_template_parameters(), array( 'planid' => $planid, )); $plan = new plan($params['planid']); self::validate_context($plan->get_context()); return api::unlink_plan_from_template($plan); }
[ "public", "static", "function", "unlink_plan_from_template", "(", "$", "planid", ")", "{", "$", "params", "=", "self", "::", "validate_parameters", "(", "self", "::", "unlink_plan_from_template_parameters", "(", ")", ",", "array", "(", "'planid'", "=>", "$", "planid", ",", ")", ")", ";", "$", "plan", "=", "new", "plan", "(", "$", "params", "[", "'planid'", "]", ")", ";", "self", "::", "validate_context", "(", "$", "plan", "->", "get_context", "(", ")", ")", ";", "return", "api", "::", "unlink_plan_from_template", "(", "$", "plan", ")", ";", "}" ]
Unlink the plan from the template. @param int $planid The plan id @return bool
[ "Unlink", "the", "plan", "from", "the", "template", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/competency/classes/external.php#L4150-L4159
218,733
moodle/moodle
competency/classes/external.php
external.template_viewed
public static function template_viewed($id) { $params = self::validate_parameters(self::view_book_parameters(), array( 'id' => $id )); $template = api::read_template($params['id']); self::validate_context($template->get_context()); return api::template_viewed($params['id']); }
php
public static function template_viewed($id) { $params = self::validate_parameters(self::view_book_parameters(), array( 'id' => $id )); $template = api::read_template($params['id']); self::validate_context($template->get_context()); return api::template_viewed($params['id']); }
[ "public", "static", "function", "template_viewed", "(", "$", "id", ")", "{", "$", "params", "=", "self", "::", "validate_parameters", "(", "self", "::", "view_book_parameters", "(", ")", ",", "array", "(", "'id'", "=>", "$", "id", ")", ")", ";", "$", "template", "=", "api", "::", "read_template", "(", "$", "params", "[", "'id'", "]", ")", ";", "self", "::", "validate_context", "(", "$", "template", "->", "get_context", "(", ")", ")", ";", "return", "api", "::", "template_viewed", "(", "$", "params", "[", "'id'", "]", ")", ";", "}" ]
Log the template viewed event. @param int $id the template id @return array of warnings and status result @throws moodle_exception
[ "Log", "the", "template", "viewed", "event", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/competency/classes/external.php#L4195-L4204
218,734
moodle/moodle
competency/classes/external.php
external.update_course_competency_settings
public static function update_course_competency_settings($courseid, $settings) { $params = self::validate_parameters(self::update_course_competency_settings_parameters(), array( 'courseid' => $courseid, 'settings' => $settings )); $context = context_course::instance($params['courseid']); self::validate_context($context); $result = api::update_course_competency_settings($params['courseid'], $params['settings']); return $result; }
php
public static function update_course_competency_settings($courseid, $settings) { $params = self::validate_parameters(self::update_course_competency_settings_parameters(), array( 'courseid' => $courseid, 'settings' => $settings )); $context = context_course::instance($params['courseid']); self::validate_context($context); $result = api::update_course_competency_settings($params['courseid'], $params['settings']); return $result; }
[ "public", "static", "function", "update_course_competency_settings", "(", "$", "courseid", ",", "$", "settings", ")", "{", "$", "params", "=", "self", "::", "validate_parameters", "(", "self", "::", "update_course_competency_settings_parameters", "(", ")", ",", "array", "(", "'courseid'", "=>", "$", "courseid", ",", "'settings'", "=>", "$", "settings", ")", ")", ";", "$", "context", "=", "context_course", "::", "instance", "(", "$", "params", "[", "'courseid'", "]", ")", ";", "self", "::", "validate_context", "(", "$", "context", ")", ";", "$", "result", "=", "api", "::", "update_course_competency_settings", "(", "$", "params", "[", "'courseid'", "]", ",", "$", "params", "[", "'settings'", "]", ")", ";", "return", "$", "result", ";", "}" ]
Update the course competency settings @param int $courseid the course id @param stdClass $settings The list of settings (currently only pushratingstouserplans). @throws moodle_exception
[ "Update", "the", "course", "competency", "settings" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/competency/classes/external.php#L4248-L4259
218,735
moodle/moodle
competency/classes/external.php
external.delete_evidence
public static function delete_evidence($id) { $params = self::validate_parameters(self::delete_evidence_parameters(), array( 'id' => $id )); $evidence = api::read_evidence($params['id']); $uc = api::get_user_competency_by_id($evidence->get('usercompetencyid')); self::validate_context($uc->get_context()); return api::delete_evidence($evidence); }
php
public static function delete_evidence($id) { $params = self::validate_parameters(self::delete_evidence_parameters(), array( 'id' => $id )); $evidence = api::read_evidence($params['id']); $uc = api::get_user_competency_by_id($evidence->get('usercompetencyid')); self::validate_context($uc->get_context()); return api::delete_evidence($evidence); }
[ "public", "static", "function", "delete_evidence", "(", "$", "id", ")", "{", "$", "params", "=", "self", "::", "validate_parameters", "(", "self", "::", "delete_evidence_parameters", "(", ")", ",", "array", "(", "'id'", "=>", "$", "id", ")", ")", ";", "$", "evidence", "=", "api", "::", "read_evidence", "(", "$", "params", "[", "'id'", "]", ")", ";", "$", "uc", "=", "api", "::", "get_user_competency_by_id", "(", "$", "evidence", "->", "get", "(", "'usercompetencyid'", ")", ")", ";", "self", "::", "validate_context", "(", "$", "uc", "->", "get_context", "(", ")", ")", ";", "return", "api", "::", "delete_evidence", "(", "$", "evidence", ")", ";", "}" ]
External function delete_evidence. @param int $id The evidence ID. @return boolean
[ "External", "function", "delete_evidence", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/competency/classes/external.php#L4287-L4297
218,736
moodle/moodle
lib/horde/framework/Horde/Imap/Client/Socket/Connection/Socket.php
Horde_Imap_Client_Socket_Connection_Socket.write
public function write($data, $eol = false) { if ($eol) { $buffer = $this->_buffer; $debug = $this->client_debug; $this->_buffer = ''; $this->client_debug = true; if (fwrite($this->_stream, $buffer . $data . ($eol ? "\r\n" : '')) === false) { throw new Horde_Imap_Client_Exception( Horde_Imap_Client_Translation::r("Server write error."), Horde_Imap_Client_Exception::SERVER_WRITEERROR ); } if ($debug) { $this->_params['debug']->client($buffer . $data); } } else { $this->_buffer .= $data; } }
php
public function write($data, $eol = false) { if ($eol) { $buffer = $this->_buffer; $debug = $this->client_debug; $this->_buffer = ''; $this->client_debug = true; if (fwrite($this->_stream, $buffer . $data . ($eol ? "\r\n" : '')) === false) { throw new Horde_Imap_Client_Exception( Horde_Imap_Client_Translation::r("Server write error."), Horde_Imap_Client_Exception::SERVER_WRITEERROR ); } if ($debug) { $this->_params['debug']->client($buffer . $data); } } else { $this->_buffer .= $data; } }
[ "public", "function", "write", "(", "$", "data", ",", "$", "eol", "=", "false", ")", "{", "if", "(", "$", "eol", ")", "{", "$", "buffer", "=", "$", "this", "->", "_buffer", ";", "$", "debug", "=", "$", "this", "->", "client_debug", ";", "$", "this", "->", "_buffer", "=", "''", ";", "$", "this", "->", "client_debug", "=", "true", ";", "if", "(", "fwrite", "(", "$", "this", "->", "_stream", ",", "$", "buffer", ".", "$", "data", ".", "(", "$", "eol", "?", "\"\\r\\n\"", ":", "''", ")", ")", "===", "false", ")", "{", "throw", "new", "Horde_Imap_Client_Exception", "(", "Horde_Imap_Client_Translation", "::", "r", "(", "\"Server write error.\"", ")", ",", "Horde_Imap_Client_Exception", "::", "SERVER_WRITEERROR", ")", ";", "}", "if", "(", "$", "debug", ")", "{", "$", "this", "->", "_params", "[", "'debug'", "]", "->", "client", "(", "$", "buffer", ".", "$", "data", ")", ";", "}", "}", "else", "{", "$", "this", "->", "_buffer", ".=", "$", "data", ";", "}", "}" ]
Writes data to the IMAP output stream. @param string $data String data. @param boolean $eol Append EOL? @throws Horde_Imap_Client_Exception
[ "Writes", "data", "to", "the", "IMAP", "output", "stream", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Imap/Client/Socket/Connection/Socket.php#L53-L75
218,737
moodle/moodle
lib/horde/framework/Horde/Imap/Client/Socket/Connection/Socket.php
Horde_Imap_Client_Socket_Connection_Socket.writeLiteral
public function writeLiteral($data, $length, $binary = false) { $this->_buffer = ''; $success = false; if ($data instanceof Horde_Stream) { $data = $data->stream; } if (rewind($data)) { $success = true; while (!feof($data)) { if ((($read_data = fread($data, 8192)) === false) || (fwrite($this->_stream, $read_data) === false)) { $success = false; break; } } } if (!$success) { $this->client_debug = true; throw new Horde_Imap_Client_Exception( Horde_Imap_Client_Translation::r("Server write error."), Horde_Imap_Client_Exception::SERVER_WRITEERROR ); } if ($this->client_debug && !empty($this->_params['debugliteral'])) { rewind($data); while (!feof($data)) { $this->_params['debug']->raw(fread($data, 8192)); } } else { $this->_params['debug']->client('[' . ($binary ? 'BINARY' : 'LITERAL') . ' DATA: ' . $length . ' bytes]'); } }
php
public function writeLiteral($data, $length, $binary = false) { $this->_buffer = ''; $success = false; if ($data instanceof Horde_Stream) { $data = $data->stream; } if (rewind($data)) { $success = true; while (!feof($data)) { if ((($read_data = fread($data, 8192)) === false) || (fwrite($this->_stream, $read_data) === false)) { $success = false; break; } } } if (!$success) { $this->client_debug = true; throw new Horde_Imap_Client_Exception( Horde_Imap_Client_Translation::r("Server write error."), Horde_Imap_Client_Exception::SERVER_WRITEERROR ); } if ($this->client_debug && !empty($this->_params['debugliteral'])) { rewind($data); while (!feof($data)) { $this->_params['debug']->raw(fread($data, 8192)); } } else { $this->_params['debug']->client('[' . ($binary ? 'BINARY' : 'LITERAL') . ' DATA: ' . $length . ' bytes]'); } }
[ "public", "function", "writeLiteral", "(", "$", "data", ",", "$", "length", ",", "$", "binary", "=", "false", ")", "{", "$", "this", "->", "_buffer", "=", "''", ";", "$", "success", "=", "false", ";", "if", "(", "$", "data", "instanceof", "Horde_Stream", ")", "{", "$", "data", "=", "$", "data", "->", "stream", ";", "}", "if", "(", "rewind", "(", "$", "data", ")", ")", "{", "$", "success", "=", "true", ";", "while", "(", "!", "feof", "(", "$", "data", ")", ")", "{", "if", "(", "(", "(", "$", "read_data", "=", "fread", "(", "$", "data", ",", "8192", ")", ")", "===", "false", ")", "||", "(", "fwrite", "(", "$", "this", "->", "_stream", ",", "$", "read_data", ")", "===", "false", ")", ")", "{", "$", "success", "=", "false", ";", "break", ";", "}", "}", "}", "if", "(", "!", "$", "success", ")", "{", "$", "this", "->", "client_debug", "=", "true", ";", "throw", "new", "Horde_Imap_Client_Exception", "(", "Horde_Imap_Client_Translation", "::", "r", "(", "\"Server write error.\"", ")", ",", "Horde_Imap_Client_Exception", "::", "SERVER_WRITEERROR", ")", ";", "}", "if", "(", "$", "this", "->", "client_debug", "&&", "!", "empty", "(", "$", "this", "->", "_params", "[", "'debugliteral'", "]", ")", ")", "{", "rewind", "(", "$", "data", ")", ";", "while", "(", "!", "feof", "(", "$", "data", ")", ")", "{", "$", "this", "->", "_params", "[", "'debug'", "]", "->", "raw", "(", "fread", "(", "$", "data", ",", "8192", ")", ")", ";", "}", "}", "else", "{", "$", "this", "->", "_params", "[", "'debug'", "]", "->", "client", "(", "'['", ".", "(", "$", "binary", "?", "'BINARY'", ":", "'LITERAL'", ")", ".", "' DATA: '", ".", "$", "length", ".", "' bytes]'", ")", ";", "}", "}" ]
Writes literal data to the IMAP output stream. @param mixed $data Either a stream resource, or Horde_Stream object. @param integer $length The literal length. @param boolean $binary If true, this is binary data. @throws Horde_Imap_Client_Exception
[ "Writes", "literal", "data", "to", "the", "IMAP", "output", "stream", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Imap/Client/Socket/Connection/Socket.php#L87-L123
218,738
moodle/moodle
lib/horde/framework/Horde/Imap/Client/Socket/Connection/Socket.php
Horde_Imap_Client_Socket_Connection_Socket.read
public function read($size = null) { $got_data = false; $literal_len = null; $token = new Horde_Imap_Client_Tokenize(); do { if (feof($this->_stream)) { $this->close(); $this->_params['debug']->info( 'ERROR: Server closed the connection.' ); throw new Horde_Imap_Client_Exception( Horde_Imap_Client_Translation::r("Mail server closed the connection unexpectedly."), Horde_Imap_Client_Exception::DISCONNECT ); } if (is_null($literal_len)) { $buffer = ''; while (($in = fgets($this->_stream)) !== false) { $got_data = true; if (substr($in, -1) === "\n") { $in = rtrim($in); $this->_params['debug']->server($buffer . $in); $token->add($in); break; } $buffer .= $in; $token->add($in); } /* Check for literal data. */ if (is_null($len = $token->getLiteralLength())) { break; } // Skip 0-length literal data. if ($len['length']) { $binary = $len['binary']; $literal_len = $len['length']; } continue; } $old_len = $literal_len; while (($literal_len > 0) && !feof($this->_stream)) { $in = fread($this->_stream, min($literal_len, 8192)); /* Only store in stream if this is something more than a * nominal number of bytes. */ if ($old_len > 256) { $token->addLiteralStream($in); } else { $token->add($in); } if (!empty($this->_params['debugliteral'])) { $this->_params['debug']->raw($in); } $got_data = true; $literal_len -= strlen($in); } $literal_len = null; if (empty($this->_params['debugliteral'])) { $this->_params['debug']->server('[' . ($binary ? 'BINARY' : 'LITERAL') . ' DATA: ' . $old_len . ' bytes]'); } } while (true); if (!$got_data) { $this->_params['debug']->info('ERROR: read/timeout error.'); throw new Horde_Imap_Client_Exception( Horde_Imap_Client_Translation::r("Error when communicating with the mail server."), Horde_Imap_Client_Exception::SERVER_READERROR ); } return $token; }
php
public function read($size = null) { $got_data = false; $literal_len = null; $token = new Horde_Imap_Client_Tokenize(); do { if (feof($this->_stream)) { $this->close(); $this->_params['debug']->info( 'ERROR: Server closed the connection.' ); throw new Horde_Imap_Client_Exception( Horde_Imap_Client_Translation::r("Mail server closed the connection unexpectedly."), Horde_Imap_Client_Exception::DISCONNECT ); } if (is_null($literal_len)) { $buffer = ''; while (($in = fgets($this->_stream)) !== false) { $got_data = true; if (substr($in, -1) === "\n") { $in = rtrim($in); $this->_params['debug']->server($buffer . $in); $token->add($in); break; } $buffer .= $in; $token->add($in); } /* Check for literal data. */ if (is_null($len = $token->getLiteralLength())) { break; } // Skip 0-length literal data. if ($len['length']) { $binary = $len['binary']; $literal_len = $len['length']; } continue; } $old_len = $literal_len; while (($literal_len > 0) && !feof($this->_stream)) { $in = fread($this->_stream, min($literal_len, 8192)); /* Only store in stream if this is something more than a * nominal number of bytes. */ if ($old_len > 256) { $token->addLiteralStream($in); } else { $token->add($in); } if (!empty($this->_params['debugliteral'])) { $this->_params['debug']->raw($in); } $got_data = true; $literal_len -= strlen($in); } $literal_len = null; if (empty($this->_params['debugliteral'])) { $this->_params['debug']->server('[' . ($binary ? 'BINARY' : 'LITERAL') . ' DATA: ' . $old_len . ' bytes]'); } } while (true); if (!$got_data) { $this->_params['debug']->info('ERROR: read/timeout error.'); throw new Horde_Imap_Client_Exception( Horde_Imap_Client_Translation::r("Error when communicating with the mail server."), Horde_Imap_Client_Exception::SERVER_READERROR ); } return $token; }
[ "public", "function", "read", "(", "$", "size", "=", "null", ")", "{", "$", "got_data", "=", "false", ";", "$", "literal_len", "=", "null", ";", "$", "token", "=", "new", "Horde_Imap_Client_Tokenize", "(", ")", ";", "do", "{", "if", "(", "feof", "(", "$", "this", "->", "_stream", ")", ")", "{", "$", "this", "->", "close", "(", ")", ";", "$", "this", "->", "_params", "[", "'debug'", "]", "->", "info", "(", "'ERROR: Server closed the connection.'", ")", ";", "throw", "new", "Horde_Imap_Client_Exception", "(", "Horde_Imap_Client_Translation", "::", "r", "(", "\"Mail server closed the connection unexpectedly.\"", ")", ",", "Horde_Imap_Client_Exception", "::", "DISCONNECT", ")", ";", "}", "if", "(", "is_null", "(", "$", "literal_len", ")", ")", "{", "$", "buffer", "=", "''", ";", "while", "(", "(", "$", "in", "=", "fgets", "(", "$", "this", "->", "_stream", ")", ")", "!==", "false", ")", "{", "$", "got_data", "=", "true", ";", "if", "(", "substr", "(", "$", "in", ",", "-", "1", ")", "===", "\"\\n\"", ")", "{", "$", "in", "=", "rtrim", "(", "$", "in", ")", ";", "$", "this", "->", "_params", "[", "'debug'", "]", "->", "server", "(", "$", "buffer", ".", "$", "in", ")", ";", "$", "token", "->", "add", "(", "$", "in", ")", ";", "break", ";", "}", "$", "buffer", ".=", "$", "in", ";", "$", "token", "->", "add", "(", "$", "in", ")", ";", "}", "/* Check for literal data. */", "if", "(", "is_null", "(", "$", "len", "=", "$", "token", "->", "getLiteralLength", "(", ")", ")", ")", "{", "break", ";", "}", "// Skip 0-length literal data.", "if", "(", "$", "len", "[", "'length'", "]", ")", "{", "$", "binary", "=", "$", "len", "[", "'binary'", "]", ";", "$", "literal_len", "=", "$", "len", "[", "'length'", "]", ";", "}", "continue", ";", "}", "$", "old_len", "=", "$", "literal_len", ";", "while", "(", "(", "$", "literal_len", ">", "0", ")", "&&", "!", "feof", "(", "$", "this", "->", "_stream", ")", ")", "{", "$", "in", "=", "fread", "(", "$", "this", "->", "_stream", ",", "min", "(", "$", "literal_len", ",", "8192", ")", ")", ";", "/* Only store in stream if this is something more than a\n * nominal number of bytes. */", "if", "(", "$", "old_len", ">", "256", ")", "{", "$", "token", "->", "addLiteralStream", "(", "$", "in", ")", ";", "}", "else", "{", "$", "token", "->", "add", "(", "$", "in", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "this", "->", "_params", "[", "'debugliteral'", "]", ")", ")", "{", "$", "this", "->", "_params", "[", "'debug'", "]", "->", "raw", "(", "$", "in", ")", ";", "}", "$", "got_data", "=", "true", ";", "$", "literal_len", "-=", "strlen", "(", "$", "in", ")", ";", "}", "$", "literal_len", "=", "null", ";", "if", "(", "empty", "(", "$", "this", "->", "_params", "[", "'debugliteral'", "]", ")", ")", "{", "$", "this", "->", "_params", "[", "'debug'", "]", "->", "server", "(", "'['", ".", "(", "$", "binary", "?", "'BINARY'", ":", "'LITERAL'", ")", ".", "' DATA: '", ".", "$", "old_len", ".", "' bytes]'", ")", ";", "}", "}", "while", "(", "true", ")", ";", "if", "(", "!", "$", "got_data", ")", "{", "$", "this", "->", "_params", "[", "'debug'", "]", "->", "info", "(", "'ERROR: read/timeout error.'", ")", ";", "throw", "new", "Horde_Imap_Client_Exception", "(", "Horde_Imap_Client_Translation", "::", "r", "(", "\"Error when communicating with the mail server.\"", ")", ",", "Horde_Imap_Client_Exception", "::", "SERVER_READERROR", ")", ";", "}", "return", "$", "token", ";", "}" ]
Read data from incoming IMAP stream. @param integer $size UNUSED: The number of bytes to read from the socket. @return Horde_Imap_Client_Tokenize The tokenized data. @throws Horde_Imap_Client_Exception
[ "Read", "data", "from", "incoming", "IMAP", "stream", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Imap/Client/Socket/Connection/Socket.php#L135-L220
218,739
moodle/moodle
user/files_form.php
user_files_form.definition
public function definition() { $mform = $this->_form; $data = $this->_customdata['data']; $options = $this->_customdata['options']; $mform->addElement('filemanager', 'files_filemanager', get_string('files'), null, $options); $mform->addElement('hidden', 'returnurl', $data->returnurl); if (isset($data->emaillink)) { $emaillink = html_writer::link(new moodle_url('mailto:' . $data->emaillink), $data->emaillink); $mform->addElement('static', 'emailaddress', '', get_string('emailtoprivatefiles', 'moodle', $emaillink)); } $mform->setType('returnurl', PARAM_LOCALURL); $this->add_action_buttons(true, get_string('savechanges')); $this->set_data($data); }
php
public function definition() { $mform = $this->_form; $data = $this->_customdata['data']; $options = $this->_customdata['options']; $mform->addElement('filemanager', 'files_filemanager', get_string('files'), null, $options); $mform->addElement('hidden', 'returnurl', $data->returnurl); if (isset($data->emaillink)) { $emaillink = html_writer::link(new moodle_url('mailto:' . $data->emaillink), $data->emaillink); $mform->addElement('static', 'emailaddress', '', get_string('emailtoprivatefiles', 'moodle', $emaillink)); } $mform->setType('returnurl', PARAM_LOCALURL); $this->add_action_buttons(true, get_string('savechanges')); $this->set_data($data); }
[ "public", "function", "definition", "(", ")", "{", "$", "mform", "=", "$", "this", "->", "_form", ";", "$", "data", "=", "$", "this", "->", "_customdata", "[", "'data'", "]", ";", "$", "options", "=", "$", "this", "->", "_customdata", "[", "'options'", "]", ";", "$", "mform", "->", "addElement", "(", "'filemanager'", ",", "'files_filemanager'", ",", "get_string", "(", "'files'", ")", ",", "null", ",", "$", "options", ")", ";", "$", "mform", "->", "addElement", "(", "'hidden'", ",", "'returnurl'", ",", "$", "data", "->", "returnurl", ")", ";", "if", "(", "isset", "(", "$", "data", "->", "emaillink", ")", ")", "{", "$", "emaillink", "=", "html_writer", "::", "link", "(", "new", "moodle_url", "(", "'mailto:'", ".", "$", "data", "->", "emaillink", ")", ",", "$", "data", "->", "emaillink", ")", ";", "$", "mform", "->", "addElement", "(", "'static'", ",", "'emailaddress'", ",", "''", ",", "get_string", "(", "'emailtoprivatefiles'", ",", "'moodle'", ",", "$", "emaillink", ")", ")", ";", "}", "$", "mform", "->", "setType", "(", "'returnurl'", ",", "PARAM_LOCALURL", ")", ";", "$", "this", "->", "add_action_buttons", "(", "true", ",", "get_string", "(", "'savechanges'", ")", ")", ";", "$", "this", "->", "set_data", "(", "$", "data", ")", ";", "}" ]
Add elements to this form.
[ "Add", "elements", "to", "this", "form", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/user/files_form.php#L40-L58
218,740
moodle/moodle
user/files_form.php
user_files_form.validation
public function validation($data, $files) { $errors = array(); $draftitemid = $data['files_filemanager']; if (file_is_draft_area_limit_reached($draftitemid, $this->_customdata['options']['areamaxbytes'])) { $errors['files_filemanager'] = get_string('userquotalimit', 'error'); } return $errors; }
php
public function validation($data, $files) { $errors = array(); $draftitemid = $data['files_filemanager']; if (file_is_draft_area_limit_reached($draftitemid, $this->_customdata['options']['areamaxbytes'])) { $errors['files_filemanager'] = get_string('userquotalimit', 'error'); } return $errors; }
[ "public", "function", "validation", "(", "$", "data", ",", "$", "files", ")", "{", "$", "errors", "=", "array", "(", ")", ";", "$", "draftitemid", "=", "$", "data", "[", "'files_filemanager'", "]", ";", "if", "(", "file_is_draft_area_limit_reached", "(", "$", "draftitemid", ",", "$", "this", "->", "_customdata", "[", "'options'", "]", "[", "'areamaxbytes'", "]", ")", ")", "{", "$", "errors", "[", "'files_filemanager'", "]", "=", "get_string", "(", "'userquotalimit'", ",", "'error'", ")", ";", "}", "return", "$", "errors", ";", "}" ]
Validate incoming data. @param array $data @param array $files @return array
[ "Validate", "incoming", "data", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/user/files_form.php#L67-L75
218,741
moodle/moodle
lib/horde/framework/Horde/Imap/Client/Base.php
Horde_Imap_Client_Base._initOb
protected function _initOb() { register_shutdown_function(array($this, 'shutdown')); $this->_alerts = new Horde_Imap_Client_Base_Alerts(); // @todo: Remove (BC) $this->_alerts->attach($this); $this->_debug = ($debug = $this->getParam('debug')) ? new Horde_Imap_Client_Base_Debug($debug) : new Horde_Support_Stub(); // @todo: Remove (BC purposes) if (isset($this->_init['capability']) && !is_object($this->_init['capability'])) { $this->_setInit('capability'); } foreach (array('capability', 'search_charset') as $val) { if (isset($this->_init[$val])) { $this->_init[$val]->attach($this); } } }
php
protected function _initOb() { register_shutdown_function(array($this, 'shutdown')); $this->_alerts = new Horde_Imap_Client_Base_Alerts(); // @todo: Remove (BC) $this->_alerts->attach($this); $this->_debug = ($debug = $this->getParam('debug')) ? new Horde_Imap_Client_Base_Debug($debug) : new Horde_Support_Stub(); // @todo: Remove (BC purposes) if (isset($this->_init['capability']) && !is_object($this->_init['capability'])) { $this->_setInit('capability'); } foreach (array('capability', 'search_charset') as $val) { if (isset($this->_init[$val])) { $this->_init[$val]->attach($this); } } }
[ "protected", "function", "_initOb", "(", ")", "{", "register_shutdown_function", "(", "array", "(", "$", "this", ",", "'shutdown'", ")", ")", ";", "$", "this", "->", "_alerts", "=", "new", "Horde_Imap_Client_Base_Alerts", "(", ")", ";", "// @todo: Remove (BC)", "$", "this", "->", "_alerts", "->", "attach", "(", "$", "this", ")", ";", "$", "this", "->", "_debug", "=", "(", "$", "debug", "=", "$", "this", "->", "getParam", "(", "'debug'", ")", ")", "?", "new", "Horde_Imap_Client_Base_Debug", "(", "$", "debug", ")", ":", "new", "Horde_Support_Stub", "(", ")", ";", "// @todo: Remove (BC purposes)", "if", "(", "isset", "(", "$", "this", "->", "_init", "[", "'capability'", "]", ")", "&&", "!", "is_object", "(", "$", "this", "->", "_init", "[", "'capability'", "]", ")", ")", "{", "$", "this", "->", "_setInit", "(", "'capability'", ")", ";", "}", "foreach", "(", "array", "(", "'capability'", ",", "'search_charset'", ")", "as", "$", "val", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "_init", "[", "$", "val", "]", ")", ")", "{", "$", "this", "->", "_init", "[", "$", "val", "]", "->", "attach", "(", "$", "this", ")", ";", "}", "}", "}" ]
Do initialization tasks.
[ "Do", "initialization", "tasks", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Imap/Client/Base.php#L298-L321
218,742
moodle/moodle
lib/horde/framework/Horde/Imap/Client/Base.php
Horde_Imap_Client_Base._setInit
public function _setInit($key = null, $val = null) { if (is_null($key)) { $this->_init = array(); } elseif (is_null($val)) { unset($this->_init[$key]); } else { switch ($key) { case 'capability': if ($ci = $this->getParam('capability_ignore')) { $ignored = array(); foreach ($ci as $val2) { $c = explode('=', $val2); if ($val->query($c[0], isset($c[1]) ? $c[1] : null)) { $ignored[] = $val2; $val->remove($c[0], isset($c[1]) ? $c[1] : null); } } if ($this->_debug->debug && !empty($ignored)) { $this->_debug->info(sprintf( 'CONFIG: IGNORING these IMAP capabilities: %s', implode(', ', $ignored) )); } } $val->attach($this); break; } /* Nothing has changed. */ if (isset($this->_init[$key]) && ($this->_init[$key] === $val)) { return; } $this->_init[$key] = $val; } $this->changed = true; }
php
public function _setInit($key = null, $val = null) { if (is_null($key)) { $this->_init = array(); } elseif (is_null($val)) { unset($this->_init[$key]); } else { switch ($key) { case 'capability': if ($ci = $this->getParam('capability_ignore')) { $ignored = array(); foreach ($ci as $val2) { $c = explode('=', $val2); if ($val->query($c[0], isset($c[1]) ? $c[1] : null)) { $ignored[] = $val2; $val->remove($c[0], isset($c[1]) ? $c[1] : null); } } if ($this->_debug->debug && !empty($ignored)) { $this->_debug->info(sprintf( 'CONFIG: IGNORING these IMAP capabilities: %s', implode(', ', $ignored) )); } } $val->attach($this); break; } /* Nothing has changed. */ if (isset($this->_init[$key]) && ($this->_init[$key] === $val)) { return; } $this->_init[$key] = $val; } $this->changed = true; }
[ "public", "function", "_setInit", "(", "$", "key", "=", "null", ",", "$", "val", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "key", ")", ")", "{", "$", "this", "->", "_init", "=", "array", "(", ")", ";", "}", "elseif", "(", "is_null", "(", "$", "val", ")", ")", "{", "unset", "(", "$", "this", "->", "_init", "[", "$", "key", "]", ")", ";", "}", "else", "{", "switch", "(", "$", "key", ")", "{", "case", "'capability'", ":", "if", "(", "$", "ci", "=", "$", "this", "->", "getParam", "(", "'capability_ignore'", ")", ")", "{", "$", "ignored", "=", "array", "(", ")", ";", "foreach", "(", "$", "ci", "as", "$", "val2", ")", "{", "$", "c", "=", "explode", "(", "'='", ",", "$", "val2", ")", ";", "if", "(", "$", "val", "->", "query", "(", "$", "c", "[", "0", "]", ",", "isset", "(", "$", "c", "[", "1", "]", ")", "?", "$", "c", "[", "1", "]", ":", "null", ")", ")", "{", "$", "ignored", "[", "]", "=", "$", "val2", ";", "$", "val", "->", "remove", "(", "$", "c", "[", "0", "]", ",", "isset", "(", "$", "c", "[", "1", "]", ")", "?", "$", "c", "[", "1", "]", ":", "null", ")", ";", "}", "}", "if", "(", "$", "this", "->", "_debug", "->", "debug", "&&", "!", "empty", "(", "$", "ignored", ")", ")", "{", "$", "this", "->", "_debug", "->", "info", "(", "sprintf", "(", "'CONFIG: IGNORING these IMAP capabilities: %s'", ",", "implode", "(", "', '", ",", "$", "ignored", ")", ")", ")", ";", "}", "}", "$", "val", "->", "attach", "(", "$", "this", ")", ";", "break", ";", "}", "/* Nothing has changed. */", "if", "(", "isset", "(", "$", "this", "->", "_init", "[", "$", "key", "]", ")", "&&", "(", "$", "this", "->", "_init", "[", "$", "key", "]", "===", "$", "val", ")", ")", "{", "return", ";", "}", "$", "this", "->", "_init", "[", "$", "key", "]", "=", "$", "val", ";", "}", "$", "this", "->", "changed", "=", "true", ";", "}" ]
Set an initialization value. @param string $key The initialization key. If null, resets all keys. @param mixed $val The cached value. If null, removes the key.
[ "Set", "an", "initialization", "value", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Imap/Client/Base.php#L419-L461
218,743
moodle/moodle
lib/horde/framework/Horde/Imap/Client/Base.php
Horde_Imap_Client_Base._initCache
protected function _initCache($current = false) { $c = $this->getParam('cache'); if (empty($c['fields'])) { return false; } if (is_null($this->_cache)) { if (isset($c['backend'])) { $backend = $c['backend']; } elseif (isset($c['cacheob'])) { /* Deprecated */ $backend = new Horde_Imap_Client_Cache_Backend_Cache($c); } else { return false; } $this->_cache = new Horde_Imap_Client_Cache(array( 'backend' => $backend, 'baseob' => $this, 'debug' => $this->_debug )); } return $current /* If UIDs are labeled as not sticky, don't cache since UIDs will * change on every access. */ ? !($this->_mailboxOb()->getStatus(Horde_Imap_Client::STATUS_UIDNOTSTICKY)) : true; }
php
protected function _initCache($current = false) { $c = $this->getParam('cache'); if (empty($c['fields'])) { return false; } if (is_null($this->_cache)) { if (isset($c['backend'])) { $backend = $c['backend']; } elseif (isset($c['cacheob'])) { /* Deprecated */ $backend = new Horde_Imap_Client_Cache_Backend_Cache($c); } else { return false; } $this->_cache = new Horde_Imap_Client_Cache(array( 'backend' => $backend, 'baseob' => $this, 'debug' => $this->_debug )); } return $current /* If UIDs are labeled as not sticky, don't cache since UIDs will * change on every access. */ ? !($this->_mailboxOb()->getStatus(Horde_Imap_Client::STATUS_UIDNOTSTICKY)) : true; }
[ "protected", "function", "_initCache", "(", "$", "current", "=", "false", ")", "{", "$", "c", "=", "$", "this", "->", "getParam", "(", "'cache'", ")", ";", "if", "(", "empty", "(", "$", "c", "[", "'fields'", "]", ")", ")", "{", "return", "false", ";", "}", "if", "(", "is_null", "(", "$", "this", "->", "_cache", ")", ")", "{", "if", "(", "isset", "(", "$", "c", "[", "'backend'", "]", ")", ")", "{", "$", "backend", "=", "$", "c", "[", "'backend'", "]", ";", "}", "elseif", "(", "isset", "(", "$", "c", "[", "'cacheob'", "]", ")", ")", "{", "/* Deprecated */", "$", "backend", "=", "new", "Horde_Imap_Client_Cache_Backend_Cache", "(", "$", "c", ")", ";", "}", "else", "{", "return", "false", ";", "}", "$", "this", "->", "_cache", "=", "new", "Horde_Imap_Client_Cache", "(", "array", "(", "'backend'", "=>", "$", "backend", ",", "'baseob'", "=>", "$", "this", ",", "'debug'", "=>", "$", "this", "->", "_debug", ")", ")", ";", "}", "return", "$", "current", "/* If UIDs are labeled as not sticky, don't cache since UIDs will\n * change on every access. */", "?", "!", "(", "$", "this", "->", "_mailboxOb", "(", ")", "->", "getStatus", "(", "Horde_Imap_Client", "::", "STATUS_UIDNOTSTICKY", ")", ")", ":", "true", ";", "}" ]
Initialize the Horde_Imap_Client_Cache object, if necessary. @param boolean $current If true, we are going to update the currently selected mailbox. Add an additional check to see if caching is available in current mailbox. @return boolean Returns true if caching is enabled.
[ "Initialize", "the", "Horde_Imap_Client_Cache", "object", "if", "necessary", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Imap/Client/Base.php#L473-L503
218,744
moodle/moodle
lib/horde/framework/Horde/Imap/Client/Base.php
Horde_Imap_Client_Base.getParam
public function getParam($key) { /* Passwords may be stored encrypted. */ switch ($key) { case 'password': if (isset($this->_params[$key]) && ($this->_params[$key] instanceof Horde_Imap_Client_Base_Password)) { return $this->_params[$key]->getPassword(); } // DEPRECATED if (!empty($this->_params['_passencrypt'])) { try { $secret = new Horde_Secret(); return $secret->read($this->_getEncryptKey(), $this->_params['password']); } catch (Exception $e) { return null; } } break; } return isset($this->_params[$key]) ? $this->_params[$key] : null; }
php
public function getParam($key) { /* Passwords may be stored encrypted. */ switch ($key) { case 'password': if (isset($this->_params[$key]) && ($this->_params[$key] instanceof Horde_Imap_Client_Base_Password)) { return $this->_params[$key]->getPassword(); } // DEPRECATED if (!empty($this->_params['_passencrypt'])) { try { $secret = new Horde_Secret(); return $secret->read($this->_getEncryptKey(), $this->_params['password']); } catch (Exception $e) { return null; } } break; } return isset($this->_params[$key]) ? $this->_params[$key] : null; }
[ "public", "function", "getParam", "(", "$", "key", ")", "{", "/* Passwords may be stored encrypted. */", "switch", "(", "$", "key", ")", "{", "case", "'password'", ":", "if", "(", "isset", "(", "$", "this", "->", "_params", "[", "$", "key", "]", ")", "&&", "(", "$", "this", "->", "_params", "[", "$", "key", "]", "instanceof", "Horde_Imap_Client_Base_Password", ")", ")", "{", "return", "$", "this", "->", "_params", "[", "$", "key", "]", "->", "getPassword", "(", ")", ";", "}", "// DEPRECATED", "if", "(", "!", "empty", "(", "$", "this", "->", "_params", "[", "'_passencrypt'", "]", ")", ")", "{", "try", "{", "$", "secret", "=", "new", "Horde_Secret", "(", ")", ";", "return", "$", "secret", "->", "read", "(", "$", "this", "->", "_getEncryptKey", "(", ")", ",", "$", "this", "->", "_params", "[", "'password'", "]", ")", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "return", "null", ";", "}", "}", "break", ";", "}", "return", "isset", "(", "$", "this", "->", "_params", "[", "$", "key", "]", ")", "?", "$", "this", "->", "_params", "[", "$", "key", "]", ":", "null", ";", "}" ]
Returns a value from the internal params array. @param string $key The param key. @return mixed The param value, or null if not found.
[ "Returns", "a", "value", "from", "the", "internal", "params", "array", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Imap/Client/Base.php#L512-L537
218,745
moodle/moodle
lib/horde/framework/Horde/Imap/Client/Base.php
Horde_Imap_Client_Base.setParam
public function setParam($key, $val) { switch ($key) { case 'password': if ($val instanceof Horde_Imap_Client_Base_Password) { break; } // DEPRECATED: Encrypt password. try { $encrypt_key = $this->_getEncryptKey(); if (strlen($encrypt_key)) { $secret = new Horde_Secret(); $val = $secret->write($encrypt_key, $val); $this->_params['_passencrypt'] = true; } } catch (Exception $e) {} break; } $this->_params[$key] = $val; $this->changed = true; }
php
public function setParam($key, $val) { switch ($key) { case 'password': if ($val instanceof Horde_Imap_Client_Base_Password) { break; } // DEPRECATED: Encrypt password. try { $encrypt_key = $this->_getEncryptKey(); if (strlen($encrypt_key)) { $secret = new Horde_Secret(); $val = $secret->write($encrypt_key, $val); $this->_params['_passencrypt'] = true; } } catch (Exception $e) {} break; } $this->_params[$key] = $val; $this->changed = true; }
[ "public", "function", "setParam", "(", "$", "key", ",", "$", "val", ")", "{", "switch", "(", "$", "key", ")", "{", "case", "'password'", ":", "if", "(", "$", "val", "instanceof", "Horde_Imap_Client_Base_Password", ")", "{", "break", ";", "}", "// DEPRECATED: Encrypt password.", "try", "{", "$", "encrypt_key", "=", "$", "this", "->", "_getEncryptKey", "(", ")", ";", "if", "(", "strlen", "(", "$", "encrypt_key", ")", ")", "{", "$", "secret", "=", "new", "Horde_Secret", "(", ")", ";", "$", "val", "=", "$", "secret", "->", "write", "(", "$", "encrypt_key", ",", "$", "val", ")", ";", "$", "this", "->", "_params", "[", "'_passencrypt'", "]", "=", "true", ";", "}", "}", "catch", "(", "Exception", "$", "e", ")", "{", "}", "break", ";", "}", "$", "this", "->", "_params", "[", "$", "key", "]", "=", "$", "val", ";", "$", "this", "->", "changed", "=", "true", ";", "}" ]
Sets a configuration parameter value. @param string $key The param key. @param mixed $val The param value.
[ "Sets", "a", "configuration", "parameter", "value", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Imap/Client/Base.php#L545-L567
218,746
moodle/moodle
lib/horde/framework/Horde/Imap/Client/Base.php
Horde_Imap_Client_Base._capability
protected function _capability() { if (!isset($this->_init['capability'])) { $this->_initCapability(); } return ($args = func_num_args()) ? $this->_init['capability']->query(func_get_arg(0), ($args > 1) ? func_get_arg(1) : null) : $this->_init['capability']; }
php
protected function _capability() { if (!isset($this->_init['capability'])) { $this->_initCapability(); } return ($args = func_num_args()) ? $this->_init['capability']->query(func_get_arg(0), ($args > 1) ? func_get_arg(1) : null) : $this->_init['capability']; }
[ "protected", "function", "_capability", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "_init", "[", "'capability'", "]", ")", ")", "{", "$", "this", "->", "_initCapability", "(", ")", ";", "}", "return", "(", "$", "args", "=", "func_num_args", "(", ")", ")", "?", "$", "this", "->", "_init", "[", "'capability'", "]", "->", "query", "(", "func_get_arg", "(", "0", ")", ",", "(", "$", "args", ">", "1", ")", "?", "func_get_arg", "(", "1", ")", ":", "null", ")", ":", "$", "this", "->", "_init", "[", "'capability'", "]", ";", "}" ]
Query server capability. Required because internal code can't call capability via magic method directly - it may not exist yet, the creation code may call capability recursively, and __get() doesn't allow recursive calls to the same property (chicken/egg issue). @return mixed The capability object if no arguments provided. If arguments are provided, they are passed to the query() method and this value is returned. @throws Horde_Imap_Client_Exception
[ "Query", "server", "capability", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Imap/Client/Base.php#L646-L655
218,747
moodle/moodle
lib/horde/framework/Horde/Imap/Client/Base.php
Horde_Imap_Client_Base.login
public function login() { if (!$this->_isAuthenticated && $this->_login()) { if ($this->getParam('id')) { try { $this->sendID(); /* ID is queued - force sending the queued command. */ $this->_sendCmd($this->_pipeline()); } catch (Horde_Imap_Client_Exception_NoSupportExtension $e) { // Ignore if server doesn't support ID extension. } } if ($this->getParam('comparator')) { try { $this->setComparator(); } catch (Horde_Imap_Client_Exception_NoSupportExtension $e) { // Ignore if server doesn't support I18NLEVEL=2 } } } $this->_isAuthenticated = true; }
php
public function login() { if (!$this->_isAuthenticated && $this->_login()) { if ($this->getParam('id')) { try { $this->sendID(); /* ID is queued - force sending the queued command. */ $this->_sendCmd($this->_pipeline()); } catch (Horde_Imap_Client_Exception_NoSupportExtension $e) { // Ignore if server doesn't support ID extension. } } if ($this->getParam('comparator')) { try { $this->setComparator(); } catch (Horde_Imap_Client_Exception_NoSupportExtension $e) { // Ignore if server doesn't support I18NLEVEL=2 } } } $this->_isAuthenticated = true; }
[ "public", "function", "login", "(", ")", "{", "if", "(", "!", "$", "this", "->", "_isAuthenticated", "&&", "$", "this", "->", "_login", "(", ")", ")", "{", "if", "(", "$", "this", "->", "getParam", "(", "'id'", ")", ")", "{", "try", "{", "$", "this", "->", "sendID", "(", ")", ";", "/* ID is queued - force sending the queued command. */", "$", "this", "->", "_sendCmd", "(", "$", "this", "->", "_pipeline", "(", ")", ")", ";", "}", "catch", "(", "Horde_Imap_Client_Exception_NoSupportExtension", "$", "e", ")", "{", "// Ignore if server doesn't support ID extension.", "}", "}", "if", "(", "$", "this", "->", "getParam", "(", "'comparator'", ")", ")", "{", "try", "{", "$", "this", "->", "setComparator", "(", ")", ";", "}", "catch", "(", "Horde_Imap_Client_Exception_NoSupportExtension", "$", "e", ")", "{", "// Ignore if server doesn't support I18NLEVEL=2", "}", "}", "}", "$", "this", "->", "_isAuthenticated", "=", "true", ";", "}" ]
Login to the IMAP server. @throws Horde_Imap_Client_Exception
[ "Login", "to", "the", "IMAP", "server", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Imap/Client/Base.php#L831-L854
218,748
moodle/moodle
lib/horde/framework/Horde/Imap/Client/Base.php
Horde_Imap_Client_Base.openMailbox
public function openMailbox($mailbox, $mode = Horde_Imap_Client::OPEN_AUTO) { $this->login(); $change = false; $mailbox = Horde_Imap_Client_Mailbox::get($mailbox); if ($mode == Horde_Imap_Client::OPEN_AUTO) { if (is_null($this->_selected) || !$mailbox->equals($this->_selected)) { $mode = Horde_Imap_Client::OPEN_READONLY; $change = true; } } else { $change = (is_null($this->_selected) || !$mailbox->equals($this->_selected) || ($mode != $this->_mode)); } if ($change) { $this->_openMailbox($mailbox, $mode); $this->_mailboxOb()->open = true; if ($this->_initCache(true)) { $this->_condstoreSync(); } } }
php
public function openMailbox($mailbox, $mode = Horde_Imap_Client::OPEN_AUTO) { $this->login(); $change = false; $mailbox = Horde_Imap_Client_Mailbox::get($mailbox); if ($mode == Horde_Imap_Client::OPEN_AUTO) { if (is_null($this->_selected) || !$mailbox->equals($this->_selected)) { $mode = Horde_Imap_Client::OPEN_READONLY; $change = true; } } else { $change = (is_null($this->_selected) || !$mailbox->equals($this->_selected) || ($mode != $this->_mode)); } if ($change) { $this->_openMailbox($mailbox, $mode); $this->_mailboxOb()->open = true; if ($this->_initCache(true)) { $this->_condstoreSync(); } } }
[ "public", "function", "openMailbox", "(", "$", "mailbox", ",", "$", "mode", "=", "Horde_Imap_Client", "::", "OPEN_AUTO", ")", "{", "$", "this", "->", "login", "(", ")", ";", "$", "change", "=", "false", ";", "$", "mailbox", "=", "Horde_Imap_Client_Mailbox", "::", "get", "(", "$", "mailbox", ")", ";", "if", "(", "$", "mode", "==", "Horde_Imap_Client", "::", "OPEN_AUTO", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "_selected", ")", "||", "!", "$", "mailbox", "->", "equals", "(", "$", "this", "->", "_selected", ")", ")", "{", "$", "mode", "=", "Horde_Imap_Client", "::", "OPEN_READONLY", ";", "$", "change", "=", "true", ";", "}", "}", "else", "{", "$", "change", "=", "(", "is_null", "(", "$", "this", "->", "_selected", ")", "||", "!", "$", "mailbox", "->", "equals", "(", "$", "this", "->", "_selected", ")", "||", "(", "$", "mode", "!=", "$", "this", "->", "_mode", ")", ")", ";", "}", "if", "(", "$", "change", ")", "{", "$", "this", "->", "_openMailbox", "(", "$", "mailbox", ",", "$", "mode", ")", ";", "$", "this", "->", "_mailboxOb", "(", ")", "->", "open", "=", "true", ";", "if", "(", "$", "this", "->", "_initCache", "(", "true", ")", ")", "{", "$", "this", "->", "_condstoreSync", "(", ")", ";", "}", "}", "}" ]
Open a mailbox. @param mixed $mailbox The mailbox to open. Either a Horde_Imap_Client_Mailbox object or a string (UTF-8). @param integer $mode The access mode. Either - Horde_Imap_Client::OPEN_READONLY - Horde_Imap_Client::OPEN_READWRITE - Horde_Imap_Client::OPEN_AUTO @throws Horde_Imap_Client_Exception
[ "Open", "a", "mailbox", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Imap/Client/Base.php#L1026-L1052
218,749
moodle/moodle
lib/horde/framework/Horde/Imap/Client/Base.php
Horde_Imap_Client_Base._changeSelected
protected function _changeSelected($mailbox = null, $mode = null) { $this->_mode = $mode; if (is_null($mailbox)) { $this->_selected = null; } else { $this->_selected = clone $mailbox; $this->_mailboxOb()->reset(); } }
php
protected function _changeSelected($mailbox = null, $mode = null) { $this->_mode = $mode; if (is_null($mailbox)) { $this->_selected = null; } else { $this->_selected = clone $mailbox; $this->_mailboxOb()->reset(); } }
[ "protected", "function", "_changeSelected", "(", "$", "mailbox", "=", "null", ",", "$", "mode", "=", "null", ")", "{", "$", "this", "->", "_mode", "=", "$", "mode", ";", "if", "(", "is_null", "(", "$", "mailbox", ")", ")", "{", "$", "this", "->", "_selected", "=", "null", ";", "}", "else", "{", "$", "this", "->", "_selected", "=", "clone", "$", "mailbox", ";", "$", "this", "->", "_mailboxOb", "(", ")", "->", "reset", "(", ")", ";", "}", "}" ]
Called when the selected mailbox is changed. @param mixed $mailbox The selected mailbox or null. @param integer $mode The access mode.
[ "Called", "when", "the", "selected", "mailbox", "is", "changed", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Imap/Client/Base.php#L1071-L1080
218,750
moodle/moodle
lib/horde/framework/Horde/Imap/Client/Base.php
Horde_Imap_Client_Base._mailboxOb
protected function _mailboxOb($mailbox = null) { $name = is_null($mailbox) ? strval($this->_selected) : strval($mailbox); if (!isset($this->_temp['mailbox_ob'][$name])) { $this->_temp['mailbox_ob'][$name] = new Horde_Imap_Client_Base_Mailbox(); } return $this->_temp['mailbox_ob'][$name]; }
php
protected function _mailboxOb($mailbox = null) { $name = is_null($mailbox) ? strval($this->_selected) : strval($mailbox); if (!isset($this->_temp['mailbox_ob'][$name])) { $this->_temp['mailbox_ob'][$name] = new Horde_Imap_Client_Base_Mailbox(); } return $this->_temp['mailbox_ob'][$name]; }
[ "protected", "function", "_mailboxOb", "(", "$", "mailbox", "=", "null", ")", "{", "$", "name", "=", "is_null", "(", "$", "mailbox", ")", "?", "strval", "(", "$", "this", "->", "_selected", ")", ":", "strval", "(", "$", "mailbox", ")", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "_temp", "[", "'mailbox_ob'", "]", "[", "$", "name", "]", ")", ")", "{", "$", "this", "->", "_temp", "[", "'mailbox_ob'", "]", "[", "$", "name", "]", "=", "new", "Horde_Imap_Client_Base_Mailbox", "(", ")", ";", "}", "return", "$", "this", "->", "_temp", "[", "'mailbox_ob'", "]", "[", "$", "name", "]", ";", "}" ]
Return the Horde_Imap_Client_Base_Mailbox object. @param string $mailbox The mailbox name. Defaults to currently selected mailbox. @return Horde_Imap_Client_Base_Mailbox Mailbox object.
[ "Return", "the", "Horde_Imap_Client_Base_Mailbox", "object", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Imap/Client/Base.php#L1090-L1101
218,751
moodle/moodle
lib/horde/framework/Horde/Imap/Client/Base.php
Horde_Imap_Client_Base.createMailbox
public function createMailbox($mailbox, array $opts = array()) { $this->login(); if (!$this->_capability('CREATE-SPECIAL-USE')) { unset($opts['special_use']); } $this->_createMailbox(Horde_Imap_Client_Mailbox::get($mailbox), $opts); }
php
public function createMailbox($mailbox, array $opts = array()) { $this->login(); if (!$this->_capability('CREATE-SPECIAL-USE')) { unset($opts['special_use']); } $this->_createMailbox(Horde_Imap_Client_Mailbox::get($mailbox), $opts); }
[ "public", "function", "createMailbox", "(", "$", "mailbox", ",", "array", "$", "opts", "=", "array", "(", ")", ")", "{", "$", "this", "->", "login", "(", ")", ";", "if", "(", "!", "$", "this", "->", "_capability", "(", "'CREATE-SPECIAL-USE'", ")", ")", "{", "unset", "(", "$", "opts", "[", "'special_use'", "]", ")", ";", "}", "$", "this", "->", "_createMailbox", "(", "Horde_Imap_Client_Mailbox", "::", "get", "(", "$", "mailbox", ")", ",", "$", "opts", ")", ";", "}" ]
Create a mailbox. @param mixed $mailbox The mailbox to create. Either a Horde_Imap_Client_Mailbox object or a string (UTF-8). @param array $opts Additional options: - special_use: (array) An array of special-use flags to mark the mailbox with. The server MUST support RFC 6154. @throws Horde_Imap_Client_Exception
[ "Create", "a", "mailbox", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Imap/Client/Base.php#L1135-L1144
218,752
moodle/moodle
lib/horde/framework/Horde/Imap/Client/Base.php
Horde_Imap_Client_Base.deleteMailbox
public function deleteMailbox($mailbox) { $this->login(); $mailbox = Horde_Imap_Client_Mailbox::get($mailbox); $this->_deleteMailbox($mailbox); $this->_deleteMailboxPost($mailbox); }
php
public function deleteMailbox($mailbox) { $this->login(); $mailbox = Horde_Imap_Client_Mailbox::get($mailbox); $this->_deleteMailbox($mailbox); $this->_deleteMailboxPost($mailbox); }
[ "public", "function", "deleteMailbox", "(", "$", "mailbox", ")", "{", "$", "this", "->", "login", "(", ")", ";", "$", "mailbox", "=", "Horde_Imap_Client_Mailbox", "::", "get", "(", "$", "mailbox", ")", ";", "$", "this", "->", "_deleteMailbox", "(", "$", "mailbox", ")", ";", "$", "this", "->", "_deleteMailboxPost", "(", "$", "mailbox", ")", ";", "}" ]
Delete a mailbox. @param mixed $mailbox The mailbox to delete. Either a Horde_Imap_Client_Mailbox object or a string (UTF-8). @throws Horde_Imap_Client_Exception
[ "Delete", "a", "mailbox", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Imap/Client/Base.php#L1167-L1175
218,753
moodle/moodle
lib/horde/framework/Horde/Imap/Client/Base.php
Horde_Imap_Client_Base._deleteMailboxPost
protected function _deleteMailboxPost(Horde_Imap_Client_Mailbox $mailbox) { /* Delete mailbox caches. */ if ($this->_initCache()) { $this->_cache->deleteMailbox($mailbox); } unset($this->_temp['mailbox_ob'][strval($mailbox)]); /* Unsubscribe from mailbox. */ try { $this->subscribeMailbox($mailbox, false); } catch (Horde_Imap_Client_Exception $e) { // Ignore failed unsubscribe request } }
php
protected function _deleteMailboxPost(Horde_Imap_Client_Mailbox $mailbox) { /* Delete mailbox caches. */ if ($this->_initCache()) { $this->_cache->deleteMailbox($mailbox); } unset($this->_temp['mailbox_ob'][strval($mailbox)]); /* Unsubscribe from mailbox. */ try { $this->subscribeMailbox($mailbox, false); } catch (Horde_Imap_Client_Exception $e) { // Ignore failed unsubscribe request } }
[ "protected", "function", "_deleteMailboxPost", "(", "Horde_Imap_Client_Mailbox", "$", "mailbox", ")", "{", "/* Delete mailbox caches. */", "if", "(", "$", "this", "->", "_initCache", "(", ")", ")", "{", "$", "this", "->", "_cache", "->", "deleteMailbox", "(", "$", "mailbox", ")", ";", "}", "unset", "(", "$", "this", "->", "_temp", "[", "'mailbox_ob'", "]", "[", "strval", "(", "$", "mailbox", ")", "]", ")", ";", "/* Unsubscribe from mailbox. */", "try", "{", "$", "this", "->", "subscribeMailbox", "(", "$", "mailbox", ",", "false", ")", ";", "}", "catch", "(", "Horde_Imap_Client_Exception", "$", "e", ")", "{", "// Ignore failed unsubscribe request", "}", "}" ]
Actions to perform after a mailbox delete. @param Horde_Imap_Client_Mailbox $mailbox The deleted mailbox.
[ "Actions", "to", "perform", "after", "a", "mailbox", "delete", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Imap/Client/Base.php#L1191-L1205
218,754
moodle/moodle
lib/horde/framework/Horde/Imap/Client/Base.php
Horde_Imap_Client_Base.renameMailbox
public function renameMailbox($old, $new) { // Login will be handled by first listMailboxes() call. $old = Horde_Imap_Client_Mailbox::get($old); $new = Horde_Imap_Client_Mailbox::get($new); /* Check if old mailbox(es) were subscribed to. */ $base = $this->listMailboxes($old, Horde_Imap_Client::MBOX_SUBSCRIBED, array('delimiter' => true)); if (empty($base)) { $base = $this->listMailboxes($old, Horde_Imap_Client::MBOX_ALL, array('delimiter' => true)); $base = reset($base); $subscribed = array(); } else { $base = reset($base); $subscribed = array($base['mailbox']); } $all_mboxes = array($base['mailbox']); if (strlen($base['delimiter'])) { $search = $old->list_escape . $base['delimiter'] . '*'; $all_mboxes = array_merge($all_mboxes, $this->listMailboxes($search, Horde_Imap_Client::MBOX_ALL, array('flat' => true))); $subscribed = array_merge($subscribed, $this->listMailboxes($search, Horde_Imap_Client::MBOX_SUBSCRIBED, array('flat' => true))); } $this->_renameMailbox($old, $new); /* Delete mailbox actions. */ foreach ($all_mboxes as $val) { $this->_deleteMailboxPost($val); } foreach ($subscribed as $val) { try { $this->subscribeMailbox(new Horde_Imap_Client_Mailbox(substr_replace($val, $new, 0, strlen($old)))); } catch (Horde_Imap_Client_Exception $e) { // Ignore failed subscription requests } } }
php
public function renameMailbox($old, $new) { // Login will be handled by first listMailboxes() call. $old = Horde_Imap_Client_Mailbox::get($old); $new = Horde_Imap_Client_Mailbox::get($new); /* Check if old mailbox(es) were subscribed to. */ $base = $this->listMailboxes($old, Horde_Imap_Client::MBOX_SUBSCRIBED, array('delimiter' => true)); if (empty($base)) { $base = $this->listMailboxes($old, Horde_Imap_Client::MBOX_ALL, array('delimiter' => true)); $base = reset($base); $subscribed = array(); } else { $base = reset($base); $subscribed = array($base['mailbox']); } $all_mboxes = array($base['mailbox']); if (strlen($base['delimiter'])) { $search = $old->list_escape . $base['delimiter'] . '*'; $all_mboxes = array_merge($all_mboxes, $this->listMailboxes($search, Horde_Imap_Client::MBOX_ALL, array('flat' => true))); $subscribed = array_merge($subscribed, $this->listMailboxes($search, Horde_Imap_Client::MBOX_SUBSCRIBED, array('flat' => true))); } $this->_renameMailbox($old, $new); /* Delete mailbox actions. */ foreach ($all_mboxes as $val) { $this->_deleteMailboxPost($val); } foreach ($subscribed as $val) { try { $this->subscribeMailbox(new Horde_Imap_Client_Mailbox(substr_replace($val, $new, 0, strlen($old)))); } catch (Horde_Imap_Client_Exception $e) { // Ignore failed subscription requests } } }
[ "public", "function", "renameMailbox", "(", "$", "old", ",", "$", "new", ")", "{", "// Login will be handled by first listMailboxes() call.", "$", "old", "=", "Horde_Imap_Client_Mailbox", "::", "get", "(", "$", "old", ")", ";", "$", "new", "=", "Horde_Imap_Client_Mailbox", "::", "get", "(", "$", "new", ")", ";", "/* Check if old mailbox(es) were subscribed to. */", "$", "base", "=", "$", "this", "->", "listMailboxes", "(", "$", "old", ",", "Horde_Imap_Client", "::", "MBOX_SUBSCRIBED", ",", "array", "(", "'delimiter'", "=>", "true", ")", ")", ";", "if", "(", "empty", "(", "$", "base", ")", ")", "{", "$", "base", "=", "$", "this", "->", "listMailboxes", "(", "$", "old", ",", "Horde_Imap_Client", "::", "MBOX_ALL", ",", "array", "(", "'delimiter'", "=>", "true", ")", ")", ";", "$", "base", "=", "reset", "(", "$", "base", ")", ";", "$", "subscribed", "=", "array", "(", ")", ";", "}", "else", "{", "$", "base", "=", "reset", "(", "$", "base", ")", ";", "$", "subscribed", "=", "array", "(", "$", "base", "[", "'mailbox'", "]", ")", ";", "}", "$", "all_mboxes", "=", "array", "(", "$", "base", "[", "'mailbox'", "]", ")", ";", "if", "(", "strlen", "(", "$", "base", "[", "'delimiter'", "]", ")", ")", "{", "$", "search", "=", "$", "old", "->", "list_escape", ".", "$", "base", "[", "'delimiter'", "]", ".", "'*'", ";", "$", "all_mboxes", "=", "array_merge", "(", "$", "all_mboxes", ",", "$", "this", "->", "listMailboxes", "(", "$", "search", ",", "Horde_Imap_Client", "::", "MBOX_ALL", ",", "array", "(", "'flat'", "=>", "true", ")", ")", ")", ";", "$", "subscribed", "=", "array_merge", "(", "$", "subscribed", ",", "$", "this", "->", "listMailboxes", "(", "$", "search", ",", "Horde_Imap_Client", "::", "MBOX_SUBSCRIBED", ",", "array", "(", "'flat'", "=>", "true", ")", ")", ")", ";", "}", "$", "this", "->", "_renameMailbox", "(", "$", "old", ",", "$", "new", ")", ";", "/* Delete mailbox actions. */", "foreach", "(", "$", "all_mboxes", "as", "$", "val", ")", "{", "$", "this", "->", "_deleteMailboxPost", "(", "$", "val", ")", ";", "}", "foreach", "(", "$", "subscribed", "as", "$", "val", ")", "{", "try", "{", "$", "this", "->", "subscribeMailbox", "(", "new", "Horde_Imap_Client_Mailbox", "(", "substr_replace", "(", "$", "val", ",", "$", "new", ",", "0", ",", "strlen", "(", "$", "old", ")", ")", ")", ")", ";", "}", "catch", "(", "Horde_Imap_Client_Exception", "$", "e", ")", "{", "// Ignore failed subscription requests", "}", "}", "}" ]
Rename a mailbox. @param mixed $old The old mailbox name. Either a Horde_Imap_Client_Mailbox object or a string (UTF-8). @param mixed $new The new mailbox name. Either a Horde_Imap_Client_Mailbox object or a string (UTF-8). @throws Horde_Imap_Client_Exception
[ "Rename", "a", "mailbox", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Imap/Client/Base.php#L1217-L1256
218,755
moodle/moodle
lib/horde/framework/Horde/Imap/Client/Base.php
Horde_Imap_Client_Base.subscribeMailbox
public function subscribeMailbox($mailbox, $subscribe = true) { $this->login(); $this->_subscribeMailbox(Horde_Imap_Client_Mailbox::get($mailbox), (bool)$subscribe); }
php
public function subscribeMailbox($mailbox, $subscribe = true) { $this->login(); $this->_subscribeMailbox(Horde_Imap_Client_Mailbox::get($mailbox), (bool)$subscribe); }
[ "public", "function", "subscribeMailbox", "(", "$", "mailbox", ",", "$", "subscribe", "=", "true", ")", "{", "$", "this", "->", "login", "(", ")", ";", "$", "this", "->", "_subscribeMailbox", "(", "Horde_Imap_Client_Mailbox", "::", "get", "(", "$", "mailbox", ")", ",", "(", "bool", ")", "$", "subscribe", ")", ";", "}" ]
Manage subscription status for a mailbox. @param mixed $mailbox The mailbox to [un]subscribe to. Either a Horde_Imap_Client_Mailbox object or a string (UTF-8). @param boolean $subscribe True to subscribe, false to unsubscribe. @throws Horde_Imap_Client_Exception
[ "Manage", "subscription", "status", "for", "a", "mailbox", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Imap/Client/Base.php#L1279-L1283
218,756
moodle/moodle
lib/horde/framework/Horde/Imap/Client/Base.php
Horde_Imap_Client_Base.listMailboxes
public function listMailboxes($pattern, $mode = Horde_Imap_Client::MBOX_ALL, array $options = array()) { $this->login(); $pattern = is_array($pattern) ? array_unique($pattern) : array($pattern); /* Prepare patterns. */ $plist = array(); foreach ($pattern as $val) { if ($val instanceof Horde_Imap_Client_Mailbox) { $val = $val->list_escape; } $plist[] = Horde_Imap_Client_Mailbox::get(preg_replace( array("/\*{2,}/", "/\%{2,}/"), array('*', '%'), Horde_Imap_Client_Utf7imap::Utf8ToUtf7Imap($val) ), true); } if (isset($options['special_use']) && !$this->_capability('SPECIAL-USE')) { unset($options['special_use']); } $ret = $this->_listMailboxes($plist, $mode, $options); if (!empty($options['status']) && !$this->_capability('LIST-STATUS')) { foreach ($this->status(array_keys($ret), $options['status']) as $key => $val) { $ret[$key]['status'] = $val; } } if (empty($options['sort'])) { return $ret; } $list_ob = new Horde_Imap_Client_Mailbox_List(empty($options['flat']) ? array_keys($ret) : $ret); $sorted = $list_ob->sort(array( 'delimiter' => empty($options['sort_delimiter']) ? '.' : $options['sort_delimiter'] )); if (!empty($options['flat'])) { return $sorted; } $out = array(); foreach ($sorted as $val) { $out[$val] = $ret[$val]; } return $out; }
php
public function listMailboxes($pattern, $mode = Horde_Imap_Client::MBOX_ALL, array $options = array()) { $this->login(); $pattern = is_array($pattern) ? array_unique($pattern) : array($pattern); /* Prepare patterns. */ $plist = array(); foreach ($pattern as $val) { if ($val instanceof Horde_Imap_Client_Mailbox) { $val = $val->list_escape; } $plist[] = Horde_Imap_Client_Mailbox::get(preg_replace( array("/\*{2,}/", "/\%{2,}/"), array('*', '%'), Horde_Imap_Client_Utf7imap::Utf8ToUtf7Imap($val) ), true); } if (isset($options['special_use']) && !$this->_capability('SPECIAL-USE')) { unset($options['special_use']); } $ret = $this->_listMailboxes($plist, $mode, $options); if (!empty($options['status']) && !$this->_capability('LIST-STATUS')) { foreach ($this->status(array_keys($ret), $options['status']) as $key => $val) { $ret[$key]['status'] = $val; } } if (empty($options['sort'])) { return $ret; } $list_ob = new Horde_Imap_Client_Mailbox_List(empty($options['flat']) ? array_keys($ret) : $ret); $sorted = $list_ob->sort(array( 'delimiter' => empty($options['sort_delimiter']) ? '.' : $options['sort_delimiter'] )); if (!empty($options['flat'])) { return $sorted; } $out = array(); foreach ($sorted as $val) { $out[$val] = $ret[$val]; } return $out; }
[ "public", "function", "listMailboxes", "(", "$", "pattern", ",", "$", "mode", "=", "Horde_Imap_Client", "::", "MBOX_ALL", ",", "array", "$", "options", "=", "array", "(", ")", ")", "{", "$", "this", "->", "login", "(", ")", ";", "$", "pattern", "=", "is_array", "(", "$", "pattern", ")", "?", "array_unique", "(", "$", "pattern", ")", ":", "array", "(", "$", "pattern", ")", ";", "/* Prepare patterns. */", "$", "plist", "=", "array", "(", ")", ";", "foreach", "(", "$", "pattern", "as", "$", "val", ")", "{", "if", "(", "$", "val", "instanceof", "Horde_Imap_Client_Mailbox", ")", "{", "$", "val", "=", "$", "val", "->", "list_escape", ";", "}", "$", "plist", "[", "]", "=", "Horde_Imap_Client_Mailbox", "::", "get", "(", "preg_replace", "(", "array", "(", "\"/\\*{2,}/\"", ",", "\"/\\%{2,}/\"", ")", ",", "array", "(", "'*'", ",", "'%'", ")", ",", "Horde_Imap_Client_Utf7imap", "::", "Utf8ToUtf7Imap", "(", "$", "val", ")", ")", ",", "true", ")", ";", "}", "if", "(", "isset", "(", "$", "options", "[", "'special_use'", "]", ")", "&&", "!", "$", "this", "->", "_capability", "(", "'SPECIAL-USE'", ")", ")", "{", "unset", "(", "$", "options", "[", "'special_use'", "]", ")", ";", "}", "$", "ret", "=", "$", "this", "->", "_listMailboxes", "(", "$", "plist", ",", "$", "mode", ",", "$", "options", ")", ";", "if", "(", "!", "empty", "(", "$", "options", "[", "'status'", "]", ")", "&&", "!", "$", "this", "->", "_capability", "(", "'LIST-STATUS'", ")", ")", "{", "foreach", "(", "$", "this", "->", "status", "(", "array_keys", "(", "$", "ret", ")", ",", "$", "options", "[", "'status'", "]", ")", "as", "$", "key", "=>", "$", "val", ")", "{", "$", "ret", "[", "$", "key", "]", "[", "'status'", "]", "=", "$", "val", ";", "}", "}", "if", "(", "empty", "(", "$", "options", "[", "'sort'", "]", ")", ")", "{", "return", "$", "ret", ";", "}", "$", "list_ob", "=", "new", "Horde_Imap_Client_Mailbox_List", "(", "empty", "(", "$", "options", "[", "'flat'", "]", ")", "?", "array_keys", "(", "$", "ret", ")", ":", "$", "ret", ")", ";", "$", "sorted", "=", "$", "list_ob", "->", "sort", "(", "array", "(", "'delimiter'", "=>", "empty", "(", "$", "options", "[", "'sort_delimiter'", "]", ")", "?", "'.'", ":", "$", "options", "[", "'sort_delimiter'", "]", ")", ")", ";", "if", "(", "!", "empty", "(", "$", "options", "[", "'flat'", "]", ")", ")", "{", "return", "$", "sorted", ";", "}", "$", "out", "=", "array", "(", ")", ";", "foreach", "(", "$", "sorted", "as", "$", "val", ")", "{", "$", "out", "[", "$", "val", "]", "=", "$", "ret", "[", "$", "val", "]", ";", "}", "return", "$", "out", ";", "}" ]
Obtain a list of mailboxes matching a pattern. @param mixed $pattern The mailbox search pattern(s) (see RFC 3501 [6.3.8] for the format). A UTF-8 string or an array of strings. If a Horde_Imap_Client_Mailbox object is given, it is escaped (i.e. wildcard patterns are converted to return the miminal number of matches possible). @param integer $mode Which mailboxes to return. Either: - Horde_Imap_Client::MBOX_SUBSCRIBED Return subscribed mailboxes. - Horde_Imap_Client::MBOX_SUBSCRIBED_EXISTS Return subscribed mailboxes that exist on the server. - Horde_Imap_Client::MBOX_UNSUBSCRIBED Return unsubscribed mailboxes. - Horde_Imap_Client::MBOX_ALL Return all mailboxes regardless of subscription status. - Horde_Imap_Client::MBOX_ALL_SUBSCRIBED (@since 2.23.0) Return all mailboxes regardless of subscription status, and ensure the '\subscribed' attribute is set if mailbox is subscribed (implies 'attributes' option is true). @param array $options Additional options: <pre> - attributes: (boolean) If true, return attribute information under the 'attributes' key. DEFAULT: Do not return this information. - children: (boolean) Tell server to return children attribute information (\HasChildren, \HasNoChildren). Requires the LIST-EXTENDED extension to guarantee this information is returned. Server MAY return this attribute without this option, or if the CHILDREN extension is available, but it is not guaranteed. DEFAULT: false - flat: (boolean) If true, return a flat list of mailbox names only. Overrides the 'attributes' option. DEFAULT: Do not return flat list. - recursivematch: (boolean) Force the server to return information about parent mailboxes that don't match other selection options, but have some sub-mailboxes that do. Information about children is returned in the CHILDINFO extended data item ('extended'). Requires the LIST-EXTENDED extension. DEFAULT: false - remote: (boolean) Tell server to return mailboxes that reside on another server. Requires the LIST-EXTENDED extension. DEFAULT: false - special_use: (boolean) Tell server to return special-use attribute information (see Horde_Imap_Client SPECIALUSE_* constants). Server must support the SPECIAL-USE return option for this setting to have any effect. DEFAULT: false - status: (integer) Tell server to return status information. The value is a bitmask that may contain any of: - Horde_Imap_Client::STATUS_MESSAGES - Horde_Imap_Client::STATUS_RECENT - Horde_Imap_Client::STATUS_UIDNEXT - Horde_Imap_Client::STATUS_UIDVALIDITY - Horde_Imap_Client::STATUS_UNSEEN - Horde_Imap_Client::STATUS_HIGHESTMODSEQ DEFAULT: 0 - sort: (boolean) If true, return a sorted list of mailboxes? DEFAULT: Do not sort the list. - sort_delimiter: (string) If 'sort' is true, this is the delimiter used to sort the mailboxes. DEFAULT: '.' </pre> @return array If 'flat' option is true, the array values are a list of Horde_Imap_Client_Mailbox objects. Otherwise, the keys are UTF-8 mailbox names and the values are arrays with these keys: - attributes: (array) List of lower-cased attributes [only if 'attributes' option is true]. - delimiter: (string) The delimiter for the mailbox. - extended: (TODO) TODO [only if 'recursivematch' option is true and LIST-EXTENDED extension is supported on the server]. - mailbox: (Horde_Imap_Client_Mailbox) The mailbox object. - status: (array) See status() [only if 'status' option is true]. @throws Horde_Imap_Client_Exception
[ "Obtain", "a", "list", "of", "mailboxes", "matching", "a", "pattern", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Imap/Client/Base.php#L1380-L1436
218,757
moodle/moodle
lib/horde/framework/Horde/Imap/Client/Base.php
Horde_Imap_Client_Base.statusMultiple
public function statusMultiple($mailboxes, $flags = Horde_Imap_Client::STATUS_ALL, array $opts = array()) { return $this->status($mailboxes, $flags, $opts); }
php
public function statusMultiple($mailboxes, $flags = Horde_Imap_Client::STATUS_ALL, array $opts = array()) { return $this->status($mailboxes, $flags, $opts); }
[ "public", "function", "statusMultiple", "(", "$", "mailboxes", ",", "$", "flags", "=", "Horde_Imap_Client", "::", "STATUS_ALL", ",", "array", "$", "opts", "=", "array", "(", ")", ")", "{", "return", "$", "this", "->", "status", "(", "$", "mailboxes", ",", "$", "flags", ",", "$", "opts", ")", ";", "}" ]
Perform a STATUS call on multiple mailboxes at the same time. This method leverages the LIST-EXTENDED and LIST-STATUS extensions on the IMAP server to improve the efficiency of this operation. @deprecated Use status() instead. @param array $mailboxes The mailboxes to query. Either Horde_Imap_Client_Mailbox objects, strings (UTF-8), or a combination of the two. @param integer $flags See status(). @param array $opts Additional options: - sort: (boolean) If true, sort the list of mailboxes? DEFAULT: Do not sort the list. - sort_delimiter: (string) If 'sort' is true, this is the delimiter used to sort the mailboxes. DEFAULT: '.' @return array An array with the keys as the mailbox names (UTF-8) and the values as arrays with the requested keys (from the mask given in $flags).
[ "Perform", "a", "STATUS", "call", "on", "multiple", "mailboxes", "at", "the", "same", "time", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Imap/Client/Base.php#L1789-L1794
218,758
moodle/moodle
lib/horde/framework/Horde/Imap/Client/Base.php
Horde_Imap_Client_Base.expunge
public function expunge($mailbox, array $options = array()) { // Open mailbox call will handle the login. $this->openMailbox($mailbox, Horde_Imap_Client::OPEN_READWRITE); /* Don't expunge if the mailbox is readonly. */ if ($this->_mode == Horde_Imap_Client::OPEN_READONLY) { throw new Horde_Imap_Client_Exception( Horde_Imap_Client_Translation::r("Cannot expunge read-only mailbox."), Horde_Imap_Client_Exception::MAILBOX_READONLY ); } if (empty($options['ids'])) { $options['ids'] = $this->getIdsOb(Horde_Imap_Client_Ids::ALL); } elseif ($options['ids']->isEmpty()) { return $this->getIdsOb(); } return $this->_expunge($options); }
php
public function expunge($mailbox, array $options = array()) { // Open mailbox call will handle the login. $this->openMailbox($mailbox, Horde_Imap_Client::OPEN_READWRITE); /* Don't expunge if the mailbox is readonly. */ if ($this->_mode == Horde_Imap_Client::OPEN_READONLY) { throw new Horde_Imap_Client_Exception( Horde_Imap_Client_Translation::r("Cannot expunge read-only mailbox."), Horde_Imap_Client_Exception::MAILBOX_READONLY ); } if (empty($options['ids'])) { $options['ids'] = $this->getIdsOb(Horde_Imap_Client_Ids::ALL); } elseif ($options['ids']->isEmpty()) { return $this->getIdsOb(); } return $this->_expunge($options); }
[ "public", "function", "expunge", "(", "$", "mailbox", ",", "array", "$", "options", "=", "array", "(", ")", ")", "{", "// Open mailbox call will handle the login.", "$", "this", "->", "openMailbox", "(", "$", "mailbox", ",", "Horde_Imap_Client", "::", "OPEN_READWRITE", ")", ";", "/* Don't expunge if the mailbox is readonly. */", "if", "(", "$", "this", "->", "_mode", "==", "Horde_Imap_Client", "::", "OPEN_READONLY", ")", "{", "throw", "new", "Horde_Imap_Client_Exception", "(", "Horde_Imap_Client_Translation", "::", "r", "(", "\"Cannot expunge read-only mailbox.\"", ")", ",", "Horde_Imap_Client_Exception", "::", "MAILBOX_READONLY", ")", ";", "}", "if", "(", "empty", "(", "$", "options", "[", "'ids'", "]", ")", ")", "{", "$", "options", "[", "'ids'", "]", "=", "$", "this", "->", "getIdsOb", "(", "Horde_Imap_Client_Ids", "::", "ALL", ")", ";", "}", "elseif", "(", "$", "options", "[", "'ids'", "]", "->", "isEmpty", "(", ")", ")", "{", "return", "$", "this", "->", "getIdsOb", "(", ")", ";", "}", "return", "$", "this", "->", "_expunge", "(", "$", "options", ")", ";", "}" ]
Expunge deleted messages from the given mailbox. @param mixed $mailbox The mailbox to expunge. Either a Horde_Imap_Client_Mailbox object or a string (UTF-8). @param array $options Additional options: - delete: (boolean) If true, will flag all messages in 'ids' as deleted (since 2.10.0). DEFAULT: false - ids: (Horde_Imap_Client_Ids) A list of messages to expunge. These messages must already be flagged as deleted (unless 'delete' is true). DEFAULT: All messages marked as deleted will be expunged. - list: (boolean) If true, returns the list of expunged messages (UIDs only). DEFAULT: false @return Horde_Imap_Client_Ids If 'list' option is true, returns the UID list of expunged messages. @throws Horde_Imap_Client_Exception
[ "Expunge", "deleted", "messages", "from", "the", "given", "mailbox", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Imap/Client/Base.php#L1979-L1999
218,759
moodle/moodle
lib/horde/framework/Horde/Imap/Client/Base.php
Horde_Imap_Client_Base.copy
public function copy($source, $dest, array $options = array()) { // Open mailbox call will handle the login. $this->openMailbox($source, empty($options['move']) ? Horde_Imap_Client::OPEN_AUTO : Horde_Imap_Client::OPEN_READWRITE); /* SEARCHRES requires server support. */ if (empty($options['ids'])) { $options['ids'] = $this->getIdsOb(Horde_Imap_Client_Ids::ALL); } elseif ($options['ids']->isEmpty()) { return array(); } elseif ($options['ids']->search_res && !$this->_capability('SEARCHRES')) { throw new Horde_Imap_Client_Exception_NoSupportExtension('SEARCHRES'); } $dest = Horde_Imap_Client_Mailbox::get($dest); $res = $this->_copy($dest, $options); if (($res === true) && !empty($options['force_map'])) { /* Need to manually create mapping from Message-ID data. */ $query = new Horde_Imap_Client_Fetch_Query(); $query->envelope(); $fetch = $this->fetch($source, $query, array( 'ids' => $options['ids'] )); $res = array(); foreach ($fetch as $val) { if ($uid = $this->_getUidByMessageId($dest, $val->getEnvelope()->message_id)) { $res[$val->getUid()] = $uid; } } } return $res; }
php
public function copy($source, $dest, array $options = array()) { // Open mailbox call will handle the login. $this->openMailbox($source, empty($options['move']) ? Horde_Imap_Client::OPEN_AUTO : Horde_Imap_Client::OPEN_READWRITE); /* SEARCHRES requires server support. */ if (empty($options['ids'])) { $options['ids'] = $this->getIdsOb(Horde_Imap_Client_Ids::ALL); } elseif ($options['ids']->isEmpty()) { return array(); } elseif ($options['ids']->search_res && !$this->_capability('SEARCHRES')) { throw new Horde_Imap_Client_Exception_NoSupportExtension('SEARCHRES'); } $dest = Horde_Imap_Client_Mailbox::get($dest); $res = $this->_copy($dest, $options); if (($res === true) && !empty($options['force_map'])) { /* Need to manually create mapping from Message-ID data. */ $query = new Horde_Imap_Client_Fetch_Query(); $query->envelope(); $fetch = $this->fetch($source, $query, array( 'ids' => $options['ids'] )); $res = array(); foreach ($fetch as $val) { if ($uid = $this->_getUidByMessageId($dest, $val->getEnvelope()->message_id)) { $res[$val->getUid()] = $uid; } } } return $res; }
[ "public", "function", "copy", "(", "$", "source", ",", "$", "dest", ",", "array", "$", "options", "=", "array", "(", ")", ")", "{", "// Open mailbox call will handle the login.", "$", "this", "->", "openMailbox", "(", "$", "source", ",", "empty", "(", "$", "options", "[", "'move'", "]", ")", "?", "Horde_Imap_Client", "::", "OPEN_AUTO", ":", "Horde_Imap_Client", "::", "OPEN_READWRITE", ")", ";", "/* SEARCHRES requires server support. */", "if", "(", "empty", "(", "$", "options", "[", "'ids'", "]", ")", ")", "{", "$", "options", "[", "'ids'", "]", "=", "$", "this", "->", "getIdsOb", "(", "Horde_Imap_Client_Ids", "::", "ALL", ")", ";", "}", "elseif", "(", "$", "options", "[", "'ids'", "]", "->", "isEmpty", "(", ")", ")", "{", "return", "array", "(", ")", ";", "}", "elseif", "(", "$", "options", "[", "'ids'", "]", "->", "search_res", "&&", "!", "$", "this", "->", "_capability", "(", "'SEARCHRES'", ")", ")", "{", "throw", "new", "Horde_Imap_Client_Exception_NoSupportExtension", "(", "'SEARCHRES'", ")", ";", "}", "$", "dest", "=", "Horde_Imap_Client_Mailbox", "::", "get", "(", "$", "dest", ")", ";", "$", "res", "=", "$", "this", "->", "_copy", "(", "$", "dest", ",", "$", "options", ")", ";", "if", "(", "(", "$", "res", "===", "true", ")", "&&", "!", "empty", "(", "$", "options", "[", "'force_map'", "]", ")", ")", "{", "/* Need to manually create mapping from Message-ID data. */", "$", "query", "=", "new", "Horde_Imap_Client_Fetch_Query", "(", ")", ";", "$", "query", "->", "envelope", "(", ")", ";", "$", "fetch", "=", "$", "this", "->", "fetch", "(", "$", "source", ",", "$", "query", ",", "array", "(", "'ids'", "=>", "$", "options", "[", "'ids'", "]", ")", ")", ";", "$", "res", "=", "array", "(", ")", ";", "foreach", "(", "$", "fetch", "as", "$", "val", ")", "{", "if", "(", "$", "uid", "=", "$", "this", "->", "_getUidByMessageId", "(", "$", "dest", ",", "$", "val", "->", "getEnvelope", "(", ")", "->", "message_id", ")", ")", "{", "$", "res", "[", "$", "val", "->", "getUid", "(", ")", "]", "=", "$", "uid", ";", "}", "}", "}", "return", "$", "res", ";", "}" ]
Copy messages to another mailbox. @param mixed $source The source mailbox. Either a Horde_Imap_Client_Mailbox object or a string (UTF-8). @param mixed $dest The destination mailbox. Either a Horde_Imap_Client_Mailbox object or a string (UTF-8). @param array $options Additional options: - create: (boolean) Try to create $dest if it does not exist? DEFAULT: No. - force_map: (boolean) Forces the array mapping to always be returned. [@since 2.19.0] - ids: (Horde_Imap_Client_Ids) The list of messages to copy. DEFAULT: All messages in $mailbox will be copied. - move: (boolean) If true, delete the original messages. DEFAULT: Original messages are not deleted. @return mixed An array mapping old UIDs (keys) to new UIDs (values) on success (only guaranteed if 'force_map' is true) or true. @throws Horde_Imap_Client_Exception @throws Horde_Imap_Client_Exception_NoSupportExtension
[ "Copy", "messages", "to", "another", "mailbox", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Imap/Client/Base.php#L2941-L2976
218,760
moodle/moodle
lib/horde/framework/Horde/Imap/Client/Base.php
Horde_Imap_Client_Base.allAclRights
public function allAclRights() { $this->login(); $rights = array( Horde_Imap_Client::ACL_LOOKUP, Horde_Imap_Client::ACL_READ, Horde_Imap_Client::ACL_SEEN, Horde_Imap_Client::ACL_WRITE, Horde_Imap_Client::ACL_INSERT, Horde_Imap_Client::ACL_POST, Horde_Imap_Client::ACL_ADMINISTER ); if ($capability = $this->_capability()->getParams('RIGHTS')) { // Add rights defined in CAPABILITY string (RFC 4314). return array_merge($rights, str_split(reset($capability))); } // Add RFC 2086 rights (deprecated by RFC 4314, but need to keep for // compatibility with old servers). return array_merge($rights, array( Horde_Imap_Client::ACL_CREATE, Horde_Imap_Client::ACL_DELETE )); }
php
public function allAclRights() { $this->login(); $rights = array( Horde_Imap_Client::ACL_LOOKUP, Horde_Imap_Client::ACL_READ, Horde_Imap_Client::ACL_SEEN, Horde_Imap_Client::ACL_WRITE, Horde_Imap_Client::ACL_INSERT, Horde_Imap_Client::ACL_POST, Horde_Imap_Client::ACL_ADMINISTER ); if ($capability = $this->_capability()->getParams('RIGHTS')) { // Add rights defined in CAPABILITY string (RFC 4314). return array_merge($rights, str_split(reset($capability))); } // Add RFC 2086 rights (deprecated by RFC 4314, but need to keep for // compatibility with old servers). return array_merge($rights, array( Horde_Imap_Client::ACL_CREATE, Horde_Imap_Client::ACL_DELETE )); }
[ "public", "function", "allAclRights", "(", ")", "{", "$", "this", "->", "login", "(", ")", ";", "$", "rights", "=", "array", "(", "Horde_Imap_Client", "::", "ACL_LOOKUP", ",", "Horde_Imap_Client", "::", "ACL_READ", ",", "Horde_Imap_Client", "::", "ACL_SEEN", ",", "Horde_Imap_Client", "::", "ACL_WRITE", ",", "Horde_Imap_Client", "::", "ACL_INSERT", ",", "Horde_Imap_Client", "::", "ACL_POST", ",", "Horde_Imap_Client", "::", "ACL_ADMINISTER", ")", ";", "if", "(", "$", "capability", "=", "$", "this", "->", "_capability", "(", ")", "->", "getParams", "(", "'RIGHTS'", ")", ")", "{", "// Add rights defined in CAPABILITY string (RFC 4314).", "return", "array_merge", "(", "$", "rights", ",", "str_split", "(", "reset", "(", "$", "capability", ")", ")", ")", ";", "}", "// Add RFC 2086 rights (deprecated by RFC 4314, but need to keep for", "// compatibility with old servers).", "return", "array_merge", "(", "$", "rights", ",", "array", "(", "Horde_Imap_Client", "::", "ACL_CREATE", ",", "Horde_Imap_Client", "::", "ACL_DELETE", ")", ")", ";", "}" ]
Return master list of ACL rights available on the server. @return array A list of ACL rights.
[ "Return", "master", "list", "of", "ACL", "rights", "available", "on", "the", "server", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Imap/Client/Base.php#L3329-L3354
218,761
moodle/moodle
lib/horde/framework/Horde/Imap/Client/Base.php
Horde_Imap_Client_Base.resolveIds
public function resolveIds(Horde_Imap_Client_Mailbox $mailbox, Horde_Imap_Client_Ids $ids, $convert = 0) { $map = $this->_mailboxOb($mailbox)->map; if ($ids->special) { /* Optimization for ALL sequence searches. */ if (!$convert && $ids->all && $ids->sequence) { $res = $this->status($mailbox, Horde_Imap_Client::STATUS_MESSAGES); return $this->getIdsOb($res['messages'] ? ('1:' . $res['messages']) : array(), true); } $convert = 2; } elseif (!$convert || (!$ids->sequence && ($convert == 1)) || $ids->isEmpty()) { return clone $ids; } else { /* Do an all or nothing: either we have all the numbers/UIDs in * memory and can return, or just send the whole ID query to the * server. Any advantage we would get by a partial search are * outweighed by the complexities needed to make the search and * then merge back into the original results. */ $lookup = $map->lookup($ids); if (count($lookup) === count($ids)) { return $this->getIdsOb(array_values($lookup)); } } $query = new Horde_Imap_Client_Search_Query(); $query->ids($ids); $res = $this->search($mailbox, $query, array( 'results' => array( Horde_Imap_Client::SEARCH_RESULTS_MATCH, Horde_Imap_Client::SEARCH_RESULTS_SAVE ), 'sequence' => (!$convert && $ids->sequence), 'sort' => array(Horde_Imap_Client::SORT_SEQUENCE) )); /* Update mapping. */ if ($convert) { if ($ids->all) { $ids = $this->getIdsOb('1:' . count($res['match'])); } elseif ($ids->special) { return $res['match']; } /* Sanity checking (Bug #12911). */ $list1 = array_slice($ids->ids, 0, count($res['match'])); $list2 = $res['match']->ids; if (!empty($list1) && !empty($list2) && (count($list1) === count($list2))) { $map->update(array_combine($list1, $list2)); } } return $res['match']; }
php
public function resolveIds(Horde_Imap_Client_Mailbox $mailbox, Horde_Imap_Client_Ids $ids, $convert = 0) { $map = $this->_mailboxOb($mailbox)->map; if ($ids->special) { /* Optimization for ALL sequence searches. */ if (!$convert && $ids->all && $ids->sequence) { $res = $this->status($mailbox, Horde_Imap_Client::STATUS_MESSAGES); return $this->getIdsOb($res['messages'] ? ('1:' . $res['messages']) : array(), true); } $convert = 2; } elseif (!$convert || (!$ids->sequence && ($convert == 1)) || $ids->isEmpty()) { return clone $ids; } else { /* Do an all or nothing: either we have all the numbers/UIDs in * memory and can return, or just send the whole ID query to the * server. Any advantage we would get by a partial search are * outweighed by the complexities needed to make the search and * then merge back into the original results. */ $lookup = $map->lookup($ids); if (count($lookup) === count($ids)) { return $this->getIdsOb(array_values($lookup)); } } $query = new Horde_Imap_Client_Search_Query(); $query->ids($ids); $res = $this->search($mailbox, $query, array( 'results' => array( Horde_Imap_Client::SEARCH_RESULTS_MATCH, Horde_Imap_Client::SEARCH_RESULTS_SAVE ), 'sequence' => (!$convert && $ids->sequence), 'sort' => array(Horde_Imap_Client::SORT_SEQUENCE) )); /* Update mapping. */ if ($convert) { if ($ids->all) { $ids = $this->getIdsOb('1:' . count($res['match'])); } elseif ($ids->special) { return $res['match']; } /* Sanity checking (Bug #12911). */ $list1 = array_slice($ids->ids, 0, count($res['match'])); $list2 = $res['match']->ids; if (!empty($list1) && !empty($list2) && (count($list1) === count($list2))) { $map->update(array_combine($list1, $list2)); } } return $res['match']; }
[ "public", "function", "resolveIds", "(", "Horde_Imap_Client_Mailbox", "$", "mailbox", ",", "Horde_Imap_Client_Ids", "$", "ids", ",", "$", "convert", "=", "0", ")", "{", "$", "map", "=", "$", "this", "->", "_mailboxOb", "(", "$", "mailbox", ")", "->", "map", ";", "if", "(", "$", "ids", "->", "special", ")", "{", "/* Optimization for ALL sequence searches. */", "if", "(", "!", "$", "convert", "&&", "$", "ids", "->", "all", "&&", "$", "ids", "->", "sequence", ")", "{", "$", "res", "=", "$", "this", "->", "status", "(", "$", "mailbox", ",", "Horde_Imap_Client", "::", "STATUS_MESSAGES", ")", ";", "return", "$", "this", "->", "getIdsOb", "(", "$", "res", "[", "'messages'", "]", "?", "(", "'1:'", ".", "$", "res", "[", "'messages'", "]", ")", ":", "array", "(", ")", ",", "true", ")", ";", "}", "$", "convert", "=", "2", ";", "}", "elseif", "(", "!", "$", "convert", "||", "(", "!", "$", "ids", "->", "sequence", "&&", "(", "$", "convert", "==", "1", ")", ")", "||", "$", "ids", "->", "isEmpty", "(", ")", ")", "{", "return", "clone", "$", "ids", ";", "}", "else", "{", "/* Do an all or nothing: either we have all the numbers/UIDs in\n * memory and can return, or just send the whole ID query to the\n * server. Any advantage we would get by a partial search are\n * outweighed by the complexities needed to make the search and\n * then merge back into the original results. */", "$", "lookup", "=", "$", "map", "->", "lookup", "(", "$", "ids", ")", ";", "if", "(", "count", "(", "$", "lookup", ")", "===", "count", "(", "$", "ids", ")", ")", "{", "return", "$", "this", "->", "getIdsOb", "(", "array_values", "(", "$", "lookup", ")", ")", ";", "}", "}", "$", "query", "=", "new", "Horde_Imap_Client_Search_Query", "(", ")", ";", "$", "query", "->", "ids", "(", "$", "ids", ")", ";", "$", "res", "=", "$", "this", "->", "search", "(", "$", "mailbox", ",", "$", "query", ",", "array", "(", "'results'", "=>", "array", "(", "Horde_Imap_Client", "::", "SEARCH_RESULTS_MATCH", ",", "Horde_Imap_Client", "::", "SEARCH_RESULTS_SAVE", ")", ",", "'sequence'", "=>", "(", "!", "$", "convert", "&&", "$", "ids", "->", "sequence", ")", ",", "'sort'", "=>", "array", "(", "Horde_Imap_Client", "::", "SORT_SEQUENCE", ")", ")", ")", ";", "/* Update mapping. */", "if", "(", "$", "convert", ")", "{", "if", "(", "$", "ids", "->", "all", ")", "{", "$", "ids", "=", "$", "this", "->", "getIdsOb", "(", "'1:'", ".", "count", "(", "$", "res", "[", "'match'", "]", ")", ")", ";", "}", "elseif", "(", "$", "ids", "->", "special", ")", "{", "return", "$", "res", "[", "'match'", "]", ";", "}", "/* Sanity checking (Bug #12911). */", "$", "list1", "=", "array_slice", "(", "$", "ids", "->", "ids", ",", "0", ",", "count", "(", "$", "res", "[", "'match'", "]", ")", ")", ";", "$", "list2", "=", "$", "res", "[", "'match'", "]", "->", "ids", ";", "if", "(", "!", "empty", "(", "$", "list1", ")", "&&", "!", "empty", "(", "$", "list2", ")", "&&", "(", "count", "(", "$", "list1", ")", "===", "count", "(", "$", "list2", ")", ")", ")", "{", "$", "map", "->", "update", "(", "array_combine", "(", "$", "list1", ",", "$", "list2", ")", ")", ";", "}", "}", "return", "$", "res", "[", "'match'", "]", ";", "}" ]
Resolves an IDs object into a list of IDs. @param Horde_Imap_Client_Mailbox $mailbox The mailbox. @param Horde_Imap_Client_Ids $ids The Ids object. @param integer $convert Convert to UIDs? - 0: No - 1: Only if $ids is not already a UIDs object - 2: Always @return Horde_Imap_Client_Ids The list of IDs.
[ "Resolves", "an", "IDs", "object", "into", "a", "list", "of", "IDs", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Imap/Client/Base.php#L3490-L3550
218,762
moodle/moodle
lib/horde/framework/Horde/Imap/Client/Base.php
Horde_Imap_Client_Base.getSyncToken
public function getSyncToken($mailbox) { $out = array(); foreach ($this->_syncStatus($mailbox) as $key => $val) { $out[] = $key . $val; } return base64_encode(implode(',', $out)); }
php
public function getSyncToken($mailbox) { $out = array(); foreach ($this->_syncStatus($mailbox) as $key => $val) { $out[] = $key . $val; } return base64_encode(implode(',', $out)); }
[ "public", "function", "getSyncToken", "(", "$", "mailbox", ")", "{", "$", "out", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "_syncStatus", "(", "$", "mailbox", ")", "as", "$", "key", "=>", "$", "val", ")", "{", "$", "out", "[", "]", "=", "$", "key", ".", "$", "val", ";", "}", "return", "base64_encode", "(", "implode", "(", "','", ",", "$", "out", ")", ")", ";", "}" ]
Returns a unique token for the current mailbox synchronization status. @since 2.2.0 @param mixed $mailbox A mailbox. Either a Horde_Imap_Client_Mailbox object or a string (UTF-8). @return string The sync token. @throws Horde_Imap_Client_Exception
[ "Returns", "a", "unique", "token", "for", "the", "current", "mailbox", "synchronization", "status", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Imap/Client/Base.php#L3581-L3590
218,763
moodle/moodle
lib/horde/framework/Horde/Imap/Client/Base.php
Horde_Imap_Client_Base.sync
public function sync($mailbox, $token, array $opts = array()) { if (($token = base64_decode($token, true)) === false) { throw new Horde_Imap_Client_Exception_Sync('Bad token.', Horde_Imap_Client_Exception_Sync::BAD_TOKEN); } $sync = array(); foreach (explode(',', $token) as $val) { $sync[substr($val, 0, 1)] = substr($val, 1); } return new Horde_Imap_Client_Data_Sync( $this, $mailbox, $sync, $this->_syncStatus($mailbox), (isset($opts['criteria']) ? $opts['criteria'] : Horde_Imap_Client::SYNC_ALL), (isset($opts['ids']) ? $opts['ids'] : null) ); }
php
public function sync($mailbox, $token, array $opts = array()) { if (($token = base64_decode($token, true)) === false) { throw new Horde_Imap_Client_Exception_Sync('Bad token.', Horde_Imap_Client_Exception_Sync::BAD_TOKEN); } $sync = array(); foreach (explode(',', $token) as $val) { $sync[substr($val, 0, 1)] = substr($val, 1); } return new Horde_Imap_Client_Data_Sync( $this, $mailbox, $sync, $this->_syncStatus($mailbox), (isset($opts['criteria']) ? $opts['criteria'] : Horde_Imap_Client::SYNC_ALL), (isset($opts['ids']) ? $opts['ids'] : null) ); }
[ "public", "function", "sync", "(", "$", "mailbox", ",", "$", "token", ",", "array", "$", "opts", "=", "array", "(", ")", ")", "{", "if", "(", "(", "$", "token", "=", "base64_decode", "(", "$", "token", ",", "true", ")", ")", "===", "false", ")", "{", "throw", "new", "Horde_Imap_Client_Exception_Sync", "(", "'Bad token.'", ",", "Horde_Imap_Client_Exception_Sync", "::", "BAD_TOKEN", ")", ";", "}", "$", "sync", "=", "array", "(", ")", ";", "foreach", "(", "explode", "(", "','", ",", "$", "token", ")", "as", "$", "val", ")", "{", "$", "sync", "[", "substr", "(", "$", "val", ",", "0", ",", "1", ")", "]", "=", "substr", "(", "$", "val", ",", "1", ")", ";", "}", "return", "new", "Horde_Imap_Client_Data_Sync", "(", "$", "this", ",", "$", "mailbox", ",", "$", "sync", ",", "$", "this", "->", "_syncStatus", "(", "$", "mailbox", ")", ",", "(", "isset", "(", "$", "opts", "[", "'criteria'", "]", ")", "?", "$", "opts", "[", "'criteria'", "]", ":", "Horde_Imap_Client", "::", "SYNC_ALL", ")", ",", "(", "isset", "(", "$", "opts", "[", "'ids'", "]", ")", "?", "$", "opts", "[", "'ids'", "]", ":", "null", ")", ")", ";", "}" ]
Synchronize a mailbox from a sync token. @since 2.2.0 @param mixed $mailbox A mailbox. Either a Horde_Imap_Client_Mailbox object or a string (UTF-8). @param string $token A sync token generated by getSyncToken(). @param array $opts Additional options: - criteria: (integer) Mask of Horde_Imap_Client::SYNC_* criteria to return. Defaults to SYNC_ALL. - ids: (Horde_Imap_Client_Ids) A cached list of UIDs. Unless QRESYNC is available on the server, failure to specify this option means SYNC_VANISHEDUIDS information cannot be returned. @return Horde_Imap_Client_Data_Sync A sync object. @throws Horde_Imap_Client_Exception @throws Horde_Imap_Client_Exception_Sync
[ "Synchronize", "a", "mailbox", "from", "a", "sync", "token", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Imap/Client/Base.php#L3612-L3631
218,764
moodle/moodle
lib/horde/framework/Horde/Imap/Client/Base.php
Horde_Imap_Client_Base._moveCache
protected function _moveCache(Horde_Imap_Client_Mailbox $to, $map, $uidvalid) { if (!$this->_initCache()) { return; } $c = $this->getParam('cache'); if (in_array(strval($to), $c['fetch_ignore'])) { $this->_debug->info(sprintf( 'CACHE: Ignoring moving FETCH data (%s => %s)', $this->_selected, $to )); return; } $old = $this->_cache->get($this->_selected, array_keys($map), null); $new = array(); foreach ($map as $key => $val) { if (!empty($old[$key])) { $new[$val] = $old[$key]; } } if (!empty($new)) { $this->_cache->set($to, $new, $uidvalid); } }
php
protected function _moveCache(Horde_Imap_Client_Mailbox $to, $map, $uidvalid) { if (!$this->_initCache()) { return; } $c = $this->getParam('cache'); if (in_array(strval($to), $c['fetch_ignore'])) { $this->_debug->info(sprintf( 'CACHE: Ignoring moving FETCH data (%s => %s)', $this->_selected, $to )); return; } $old = $this->_cache->get($this->_selected, array_keys($map), null); $new = array(); foreach ($map as $key => $val) { if (!empty($old[$key])) { $new[$val] = $old[$key]; } } if (!empty($new)) { $this->_cache->set($to, $new, $uidvalid); } }
[ "protected", "function", "_moveCache", "(", "Horde_Imap_Client_Mailbox", "$", "to", ",", "$", "map", ",", "$", "uidvalid", ")", "{", "if", "(", "!", "$", "this", "->", "_initCache", "(", ")", ")", "{", "return", ";", "}", "$", "c", "=", "$", "this", "->", "getParam", "(", "'cache'", ")", ";", "if", "(", "in_array", "(", "strval", "(", "$", "to", ")", ",", "$", "c", "[", "'fetch_ignore'", "]", ")", ")", "{", "$", "this", "->", "_debug", "->", "info", "(", "sprintf", "(", "'CACHE: Ignoring moving FETCH data (%s => %s)'", ",", "$", "this", "->", "_selected", ",", "$", "to", ")", ")", ";", "return", ";", "}", "$", "old", "=", "$", "this", "->", "_cache", "->", "get", "(", "$", "this", "->", "_selected", ",", "array_keys", "(", "$", "map", ")", ",", "null", ")", ";", "$", "new", "=", "array", "(", ")", ";", "foreach", "(", "$", "map", "as", "$", "key", "=>", "$", "val", ")", "{", "if", "(", "!", "empty", "(", "$", "old", "[", "$", "key", "]", ")", ")", "{", "$", "new", "[", "$", "val", "]", "=", "$", "old", "[", "$", "key", "]", ";", "}", "}", "if", "(", "!", "empty", "(", "$", "new", ")", ")", "{", "$", "this", "->", "_cache", "->", "set", "(", "$", "to", ",", "$", "new", ",", "$", "uidvalid", ")", ";", "}", "}" ]
Moves cache entries from the current mailbox to another mailbox. @param Horde_Imap_Client_Mailbox $to The destination mailbox. @param array $map Mapping of source UIDs (keys) to destination UIDs (values). @param string $uidvalid UIDVALIDITY of destination mailbox. @throws Horde_Imap_Client_Exception
[ "Moves", "cache", "entries", "from", "the", "current", "mailbox", "to", "another", "mailbox", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Imap/Client/Base.php#L3753-L3782
218,765
moodle/moodle
lib/horde/framework/Horde/Imap/Client/Base.php
Horde_Imap_Client_Base._getSearchCache
protected function _getSearchCache($type, $options) { $status = $this->status($this->_selected, Horde_Imap_Client::STATUS_HIGHESTMODSEQ | Horde_Imap_Client::STATUS_UIDVALIDITY); /* Search caching requires MODSEQ, which may not be active for a * mailbox. */ if (empty($status['highestmodseq'])) { return null; } ksort($options); $cache = hash('md5', $type . serialize($options)); $cacheid = $this->getSyncToken($this->_selected); $ret = array(); $md = $this->_cache->getMetaData( $this->_selected, $status['uidvalidity'], array(self::CACHE_SEARCH, self::CACHE_SEARCHID) ); if (!isset($md[self::CACHE_SEARCHID]) || ($md[self::CACHE_SEARCHID] != $cacheid)) { $md[self::CACHE_SEARCH] = array(); $md[self::CACHE_SEARCHID] = $cacheid; if ($this->_debug->debug && !isset($this->_temp['searchcacheexpire'][strval($this->_selected)])) { $this->_debug->info(sprintf( 'SEARCH: Expired from cache [%s]', $this->_selected )); $this->_temp['searchcacheexpire'][strval($this->_selected)] = true; } } elseif (isset($md[self::CACHE_SEARCH][$cache])) { $this->_debug->info(sprintf( 'SEARCH: Retrieved %s from cache (%s [%s])', $type, $cache, $this->_selected )); $ret['data'] = $md[self::CACHE_SEARCH][$cache]; unset($md[self::CACHE_SEARCHID]); } return array_merge($ret, array( 'id' => $cache, 'metadata' => $md, 'type' => $type )); }
php
protected function _getSearchCache($type, $options) { $status = $this->status($this->_selected, Horde_Imap_Client::STATUS_HIGHESTMODSEQ | Horde_Imap_Client::STATUS_UIDVALIDITY); /* Search caching requires MODSEQ, which may not be active for a * mailbox. */ if (empty($status['highestmodseq'])) { return null; } ksort($options); $cache = hash('md5', $type . serialize($options)); $cacheid = $this->getSyncToken($this->_selected); $ret = array(); $md = $this->_cache->getMetaData( $this->_selected, $status['uidvalidity'], array(self::CACHE_SEARCH, self::CACHE_SEARCHID) ); if (!isset($md[self::CACHE_SEARCHID]) || ($md[self::CACHE_SEARCHID] != $cacheid)) { $md[self::CACHE_SEARCH] = array(); $md[self::CACHE_SEARCHID] = $cacheid; if ($this->_debug->debug && !isset($this->_temp['searchcacheexpire'][strval($this->_selected)])) { $this->_debug->info(sprintf( 'SEARCH: Expired from cache [%s]', $this->_selected )); $this->_temp['searchcacheexpire'][strval($this->_selected)] = true; } } elseif (isset($md[self::CACHE_SEARCH][$cache])) { $this->_debug->info(sprintf( 'SEARCH: Retrieved %s from cache (%s [%s])', $type, $cache, $this->_selected )); $ret['data'] = $md[self::CACHE_SEARCH][$cache]; unset($md[self::CACHE_SEARCHID]); } return array_merge($ret, array( 'id' => $cache, 'metadata' => $md, 'type' => $type )); }
[ "protected", "function", "_getSearchCache", "(", "$", "type", ",", "$", "options", ")", "{", "$", "status", "=", "$", "this", "->", "status", "(", "$", "this", "->", "_selected", ",", "Horde_Imap_Client", "::", "STATUS_HIGHESTMODSEQ", "|", "Horde_Imap_Client", "::", "STATUS_UIDVALIDITY", ")", ";", "/* Search caching requires MODSEQ, which may not be active for a\n * mailbox. */", "if", "(", "empty", "(", "$", "status", "[", "'highestmodseq'", "]", ")", ")", "{", "return", "null", ";", "}", "ksort", "(", "$", "options", ")", ";", "$", "cache", "=", "hash", "(", "'md5'", ",", "$", "type", ".", "serialize", "(", "$", "options", ")", ")", ";", "$", "cacheid", "=", "$", "this", "->", "getSyncToken", "(", "$", "this", "->", "_selected", ")", ";", "$", "ret", "=", "array", "(", ")", ";", "$", "md", "=", "$", "this", "->", "_cache", "->", "getMetaData", "(", "$", "this", "->", "_selected", ",", "$", "status", "[", "'uidvalidity'", "]", ",", "array", "(", "self", "::", "CACHE_SEARCH", ",", "self", "::", "CACHE_SEARCHID", ")", ")", ";", "if", "(", "!", "isset", "(", "$", "md", "[", "self", "::", "CACHE_SEARCHID", "]", ")", "||", "(", "$", "md", "[", "self", "::", "CACHE_SEARCHID", "]", "!=", "$", "cacheid", ")", ")", "{", "$", "md", "[", "self", "::", "CACHE_SEARCH", "]", "=", "array", "(", ")", ";", "$", "md", "[", "self", "::", "CACHE_SEARCHID", "]", "=", "$", "cacheid", ";", "if", "(", "$", "this", "->", "_debug", "->", "debug", "&&", "!", "isset", "(", "$", "this", "->", "_temp", "[", "'searchcacheexpire'", "]", "[", "strval", "(", "$", "this", "->", "_selected", ")", "]", ")", ")", "{", "$", "this", "->", "_debug", "->", "info", "(", "sprintf", "(", "'SEARCH: Expired from cache [%s]'", ",", "$", "this", "->", "_selected", ")", ")", ";", "$", "this", "->", "_temp", "[", "'searchcacheexpire'", "]", "[", "strval", "(", "$", "this", "->", "_selected", ")", "]", "=", "true", ";", "}", "}", "elseif", "(", "isset", "(", "$", "md", "[", "self", "::", "CACHE_SEARCH", "]", "[", "$", "cache", "]", ")", ")", "{", "$", "this", "->", "_debug", "->", "info", "(", "sprintf", "(", "'SEARCH: Retrieved %s from cache (%s [%s])'", ",", "$", "type", ",", "$", "cache", ",", "$", "this", "->", "_selected", ")", ")", ";", "$", "ret", "[", "'data'", "]", "=", "$", "md", "[", "self", "::", "CACHE_SEARCH", "]", "[", "$", "cache", "]", ";", "unset", "(", "$", "md", "[", "self", "::", "CACHE_SEARCHID", "]", ")", ";", "}", "return", "array_merge", "(", "$", "ret", ",", "array", "(", "'id'", "=>", "$", "cache", ",", "'metadata'", "=>", "$", "md", ",", "'type'", "=>", "$", "type", ")", ")", ";", "}" ]
Retrieve data from the search cache. @param string $type The cache type ('search' or 'thread'). @param array $options The options array of the calling function. @return mixed Returns search cache metadata. If search was retrieved, data is in key 'data'. Returns null if caching is not available.
[ "Retrieve", "data", "from", "the", "search", "cache", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Imap/Client/Base.php#L3826-L3875
218,766
moodle/moodle
lib/horde/framework/Horde/Imap/Client/Base.php
Horde_Imap_Client_Base._setSearchCache
protected function _setSearchCache($data, $sdata) { $sdata['metadata'][self::CACHE_SEARCH][$sdata['id']] = $data; $this->_cache->setMetaData($this->_selected, null, $sdata['metadata']); if ($this->_debug->debug) { $this->_debug->info(sprintf( 'SEARCH: Saved %s to cache (%s [%s])', $sdata['type'], $sdata['id'], $this->_selected )); unset($this->_temp['searchcacheexpire'][strval($this->_selected)]); } }
php
protected function _setSearchCache($data, $sdata) { $sdata['metadata'][self::CACHE_SEARCH][$sdata['id']] = $data; $this->_cache->setMetaData($this->_selected, null, $sdata['metadata']); if ($this->_debug->debug) { $this->_debug->info(sprintf( 'SEARCH: Saved %s to cache (%s [%s])', $sdata['type'], $sdata['id'], $this->_selected )); unset($this->_temp['searchcacheexpire'][strval($this->_selected)]); } }
[ "protected", "function", "_setSearchCache", "(", "$", "data", ",", "$", "sdata", ")", "{", "$", "sdata", "[", "'metadata'", "]", "[", "self", "::", "CACHE_SEARCH", "]", "[", "$", "sdata", "[", "'id'", "]", "]", "=", "$", "data", ";", "$", "this", "->", "_cache", "->", "setMetaData", "(", "$", "this", "->", "_selected", ",", "null", ",", "$", "sdata", "[", "'metadata'", "]", ")", ";", "if", "(", "$", "this", "->", "_debug", "->", "debug", ")", "{", "$", "this", "->", "_debug", "->", "info", "(", "sprintf", "(", "'SEARCH: Saved %s to cache (%s [%s])'", ",", "$", "sdata", "[", "'type'", "]", ",", "$", "sdata", "[", "'id'", "]", ",", "$", "this", "->", "_selected", ")", ")", ";", "unset", "(", "$", "this", "->", "_temp", "[", "'searchcacheexpire'", "]", "[", "strval", "(", "$", "this", "->", "_selected", ")", "]", ")", ";", "}", "}" ]
Set data in the search cache. @param mixed $data The cache data to store. @param string $sdata The search data returned from _getSearchCache().
[ "Set", "data", "in", "the", "search", "cache", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Imap/Client/Base.php#L3883-L3898
218,767
moodle/moodle
lib/horde/framework/Horde/Imap/Client/Base.php
Horde_Imap_Client_Base._updateModSeq
protected function _updateModSeq($modseq) { if (!$this->_initCache(true)) { return false; } $mbox_ob = $this->_mailboxOb(); $uidvalid = $mbox_ob->getStatus(Horde_Imap_Client::STATUS_UIDVALIDITY); $md = $this->_cache->getMetaData($this->_selected, $uidvalid, array(self::CACHE_MODSEQ)); if (isset($md[self::CACHE_MODSEQ])) { if ($md[self::CACHE_MODSEQ] < $modseq) { $set = true; $sync = $md[self::CACHE_MODSEQ]; } else { $set = false; $sync = 0; } $mbox_ob->setStatus(Horde_Imap_Client::STATUS_SYNCMODSEQ, $md[self::CACHE_MODSEQ]); } else { $set = true; $sync = 0; } /* $modseq can be 0 - NOMODSEQ - so don't store in that case. */ if ($set && $modseq) { $this->_cache->setMetaData($this->_selected, $uidvalid, array( self::CACHE_MODSEQ => $modseq )); } return $sync; }
php
protected function _updateModSeq($modseq) { if (!$this->_initCache(true)) { return false; } $mbox_ob = $this->_mailboxOb(); $uidvalid = $mbox_ob->getStatus(Horde_Imap_Client::STATUS_UIDVALIDITY); $md = $this->_cache->getMetaData($this->_selected, $uidvalid, array(self::CACHE_MODSEQ)); if (isset($md[self::CACHE_MODSEQ])) { if ($md[self::CACHE_MODSEQ] < $modseq) { $set = true; $sync = $md[self::CACHE_MODSEQ]; } else { $set = false; $sync = 0; } $mbox_ob->setStatus(Horde_Imap_Client::STATUS_SYNCMODSEQ, $md[self::CACHE_MODSEQ]); } else { $set = true; $sync = 0; } /* $modseq can be 0 - NOMODSEQ - so don't store in that case. */ if ($set && $modseq) { $this->_cache->setMetaData($this->_selected, $uidvalid, array( self::CACHE_MODSEQ => $modseq )); } return $sync; }
[ "protected", "function", "_updateModSeq", "(", "$", "modseq", ")", "{", "if", "(", "!", "$", "this", "->", "_initCache", "(", "true", ")", ")", "{", "return", "false", ";", "}", "$", "mbox_ob", "=", "$", "this", "->", "_mailboxOb", "(", ")", ";", "$", "uidvalid", "=", "$", "mbox_ob", "->", "getStatus", "(", "Horde_Imap_Client", "::", "STATUS_UIDVALIDITY", ")", ";", "$", "md", "=", "$", "this", "->", "_cache", "->", "getMetaData", "(", "$", "this", "->", "_selected", ",", "$", "uidvalid", ",", "array", "(", "self", "::", "CACHE_MODSEQ", ")", ")", ";", "if", "(", "isset", "(", "$", "md", "[", "self", "::", "CACHE_MODSEQ", "]", ")", ")", "{", "if", "(", "$", "md", "[", "self", "::", "CACHE_MODSEQ", "]", "<", "$", "modseq", ")", "{", "$", "set", "=", "true", ";", "$", "sync", "=", "$", "md", "[", "self", "::", "CACHE_MODSEQ", "]", ";", "}", "else", "{", "$", "set", "=", "false", ";", "$", "sync", "=", "0", ";", "}", "$", "mbox_ob", "->", "setStatus", "(", "Horde_Imap_Client", "::", "STATUS_SYNCMODSEQ", ",", "$", "md", "[", "self", "::", "CACHE_MODSEQ", "]", ")", ";", "}", "else", "{", "$", "set", "=", "true", ";", "$", "sync", "=", "0", ";", "}", "/* $modseq can be 0 - NOMODSEQ - so don't store in that case. */", "if", "(", "$", "set", "&&", "$", "modseq", ")", "{", "$", "this", "->", "_cache", "->", "setMetaData", "(", "$", "this", "->", "_selected", ",", "$", "uidvalid", ",", "array", "(", "self", "::", "CACHE_MODSEQ", "=>", "$", "modseq", ")", ")", ";", "}", "return", "$", "sync", ";", "}" ]
Updates the cached MODSEQ value. @param integer $modseq MODSEQ value to store. @return mixed The MODSEQ of the old value if it was replaced (or false if it didn't exist or is the same).
[ "Updates", "the", "cached", "MODSEQ", "value", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Imap/Client/Base.php#L3908-L3940
218,768
moodle/moodle
lib/horde/framework/Horde/Imap/Client/Base.php
Horde_Imap_Client_Base._cacheFields
protected function _cacheFields() { $c = $this->getParam('cache'); $out = $c['fields']; if (!$this->_capability()->isEnabled('CONDSTORE')) { unset($out[Horde_Imap_Client::FETCH_FLAGS]); } return $out; }
php
protected function _cacheFields() { $c = $this->getParam('cache'); $out = $c['fields']; if (!$this->_capability()->isEnabled('CONDSTORE')) { unset($out[Horde_Imap_Client::FETCH_FLAGS]); } return $out; }
[ "protected", "function", "_cacheFields", "(", ")", "{", "$", "c", "=", "$", "this", "->", "getParam", "(", "'cache'", ")", ";", "$", "out", "=", "$", "c", "[", "'fields'", "]", ";", "if", "(", "!", "$", "this", "->", "_capability", "(", ")", "->", "isEnabled", "(", "'CONDSTORE'", ")", ")", "{", "unset", "(", "$", "out", "[", "Horde_Imap_Client", "::", "FETCH_FLAGS", "]", ")", ";", "}", "return", "$", "out", ";", "}" ]
Provide the list of available caching fields. @return array The list of available caching fields (fields are in the key).
[ "Provide", "the", "list", "of", "available", "caching", "fields", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Imap/Client/Base.php#L4005-L4015
218,769
moodle/moodle
lib/horde/framework/Horde/Imap/Client/Base.php
Horde_Imap_Client_Base._syncStatus
protected function _syncStatus($mailbox) { $status = $this->status( $mailbox, Horde_Imap_Client::STATUS_HIGHESTMODSEQ | Horde_Imap_Client::STATUS_MESSAGES | Horde_Imap_Client::STATUS_UIDNEXT_FORCE | Horde_Imap_Client::STATUS_UIDVALIDITY ); $fields = array('uidnext', 'uidvalidity'); if (empty($status['highestmodseq'])) { $fields[] = 'messages'; } else { $fields[] = 'highestmodseq'; } $out = array(); $sync_map = array_flip(Horde_Imap_Client_Data_Sync::$map); foreach ($fields as $val) { $out[$sync_map[$val]] = $status[$val]; } return array_filter($out); }
php
protected function _syncStatus($mailbox) { $status = $this->status( $mailbox, Horde_Imap_Client::STATUS_HIGHESTMODSEQ | Horde_Imap_Client::STATUS_MESSAGES | Horde_Imap_Client::STATUS_UIDNEXT_FORCE | Horde_Imap_Client::STATUS_UIDVALIDITY ); $fields = array('uidnext', 'uidvalidity'); if (empty($status['highestmodseq'])) { $fields[] = 'messages'; } else { $fields[] = 'highestmodseq'; } $out = array(); $sync_map = array_flip(Horde_Imap_Client_Data_Sync::$map); foreach ($fields as $val) { $out[$sync_map[$val]] = $status[$val]; } return array_filter($out); }
[ "protected", "function", "_syncStatus", "(", "$", "mailbox", ")", "{", "$", "status", "=", "$", "this", "->", "status", "(", "$", "mailbox", ",", "Horde_Imap_Client", "::", "STATUS_HIGHESTMODSEQ", "|", "Horde_Imap_Client", "::", "STATUS_MESSAGES", "|", "Horde_Imap_Client", "::", "STATUS_UIDNEXT_FORCE", "|", "Horde_Imap_Client", "::", "STATUS_UIDVALIDITY", ")", ";", "$", "fields", "=", "array", "(", "'uidnext'", ",", "'uidvalidity'", ")", ";", "if", "(", "empty", "(", "$", "status", "[", "'highestmodseq'", "]", ")", ")", "{", "$", "fields", "[", "]", "=", "'messages'", ";", "}", "else", "{", "$", "fields", "[", "]", "=", "'highestmodseq'", ";", "}", "$", "out", "=", "array", "(", ")", ";", "$", "sync_map", "=", "array_flip", "(", "Horde_Imap_Client_Data_Sync", "::", "$", "map", ")", ";", "foreach", "(", "$", "fields", "as", "$", "val", ")", "{", "$", "out", "[", "$", "sync_map", "[", "$", "val", "]", "]", "=", "$", "status", "[", "$", "val", "]", ";", "}", "return", "array_filter", "(", "$", "out", ")", ";", "}" ]
Return the current mailbox synchronization status. @param mixed $mailbox A mailbox. Either a Horde_Imap_Client_Mailbox object or a string (UTF-8). @return array An array with status data. (This data is not guaranteed to have any specific format).
[ "Return", "the", "current", "mailbox", "synchronization", "status", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Imap/Client/Base.php#L4026-L4051
218,770
moodle/moodle
lib/horde/framework/Horde/Imap/Client/Base.php
Horde_Imap_Client_Base._getUidByMessageId
protected function _getUidByMessageId($mailbox, $msgid) { if (!$msgid) { return null; } $query = new Horde_Imap_Client_Search_Query(); $query->headerText('Message-ID', $msgid); $res = $this->search($mailbox, $query, array( 'results' => array(Horde_Imap_Client::SEARCH_RESULTS_MAX) )); return $res['max']; }
php
protected function _getUidByMessageId($mailbox, $msgid) { if (!$msgid) { return null; } $query = new Horde_Imap_Client_Search_Query(); $query->headerText('Message-ID', $msgid); $res = $this->search($mailbox, $query, array( 'results' => array(Horde_Imap_Client::SEARCH_RESULTS_MAX) )); return $res['max']; }
[ "protected", "function", "_getUidByMessageId", "(", "$", "mailbox", ",", "$", "msgid", ")", "{", "if", "(", "!", "$", "msgid", ")", "{", "return", "null", ";", "}", "$", "query", "=", "new", "Horde_Imap_Client_Search_Query", "(", ")", ";", "$", "query", "->", "headerText", "(", "'Message-ID'", ",", "$", "msgid", ")", ";", "$", "res", "=", "$", "this", "->", "search", "(", "$", "mailbox", ",", "$", "query", ",", "array", "(", "'results'", "=>", "array", "(", "Horde_Imap_Client", "::", "SEARCH_RESULTS_MAX", ")", ")", ")", ";", "return", "$", "res", "[", "'max'", "]", ";", "}" ]
Get a message UID by the Message-ID. Returns the last message in a mailbox that matches. @param Horde_Imap_Client_Mailbox $mailbox The mailbox to search @param string $msgid Message-ID. @return string UID (null if not found).
[ "Get", "a", "message", "UID", "by", "the", "Message", "-", "ID", ".", "Returns", "the", "last", "message", "in", "a", "mailbox", "that", "matches", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Imap/Client/Base.php#L4062-L4075
218,771
moodle/moodle
lib/horde/framework/Horde/Exception/Pear.php
Horde_Exception_Pear._getPearTrace
private function _getPearTrace(PEAR_Error $error) { $pear_error = ''; $backtrace = $error->getBacktrace(); if (!empty($backtrace)) { $pear_error .= 'PEAR backtrace:' . "\n\n"; foreach ($backtrace as $frame) { $pear_error .= (isset($frame['class']) ? $frame['class'] : '') . (isset($frame['type']) ? $frame['type'] : '') . (isset($frame['function']) ? $frame['function'] : 'unkown') . ' ' . (isset($frame['file']) ? $frame['file'] : 'unkown') . ':' . (isset($frame['line']) ? $frame['line'] : 'unkown') . "\n"; } } $userinfo = $error->getUserInfo(); if (!empty($userinfo)) { $pear_error .= "\n" . 'PEAR user info:' . "\n\n"; if (is_string($userinfo)) { $pear_error .= $userinfo; } else { $pear_error .= print_r($userinfo, true); } } return $pear_error; }
php
private function _getPearTrace(PEAR_Error $error) { $pear_error = ''; $backtrace = $error->getBacktrace(); if (!empty($backtrace)) { $pear_error .= 'PEAR backtrace:' . "\n\n"; foreach ($backtrace as $frame) { $pear_error .= (isset($frame['class']) ? $frame['class'] : '') . (isset($frame['type']) ? $frame['type'] : '') . (isset($frame['function']) ? $frame['function'] : 'unkown') . ' ' . (isset($frame['file']) ? $frame['file'] : 'unkown') . ':' . (isset($frame['line']) ? $frame['line'] : 'unkown') . "\n"; } } $userinfo = $error->getUserInfo(); if (!empty($userinfo)) { $pear_error .= "\n" . 'PEAR user info:' . "\n\n"; if (is_string($userinfo)) { $pear_error .= $userinfo; } else { $pear_error .= print_r($userinfo, true); } } return $pear_error; }
[ "private", "function", "_getPearTrace", "(", "PEAR_Error", "$", "error", ")", "{", "$", "pear_error", "=", "''", ";", "$", "backtrace", "=", "$", "error", "->", "getBacktrace", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "backtrace", ")", ")", "{", "$", "pear_error", ".=", "'PEAR backtrace:'", ".", "\"\\n\\n\"", ";", "foreach", "(", "$", "backtrace", "as", "$", "frame", ")", "{", "$", "pear_error", ".=", "(", "isset", "(", "$", "frame", "[", "'class'", "]", ")", "?", "$", "frame", "[", "'class'", "]", ":", "''", ")", ".", "(", "isset", "(", "$", "frame", "[", "'type'", "]", ")", "?", "$", "frame", "[", "'type'", "]", ":", "''", ")", ".", "(", "isset", "(", "$", "frame", "[", "'function'", "]", ")", "?", "$", "frame", "[", "'function'", "]", ":", "'unkown'", ")", ".", "' '", ".", "(", "isset", "(", "$", "frame", "[", "'file'", "]", ")", "?", "$", "frame", "[", "'file'", "]", ":", "'unkown'", ")", ".", "':'", ".", "(", "isset", "(", "$", "frame", "[", "'line'", "]", ")", "?", "$", "frame", "[", "'line'", "]", ":", "'unkown'", ")", ".", "\"\\n\"", ";", "}", "}", "$", "userinfo", "=", "$", "error", "->", "getUserInfo", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "userinfo", ")", ")", "{", "$", "pear_error", ".=", "\"\\n\"", ".", "'PEAR user info:'", ".", "\"\\n\\n\"", ";", "if", "(", "is_string", "(", "$", "userinfo", ")", ")", "{", "$", "pear_error", ".=", "$", "userinfo", ";", "}", "else", "{", "$", "pear_error", ".=", "print_r", "(", "$", "userinfo", ",", "true", ")", ";", "}", "}", "return", "$", "pear_error", ";", "}" ]
Return a trace for the PEAR error. @param PEAR_Error $error The PEAR error. @return string The backtrace as a string.
[ "Return", "a", "trace", "for", "the", "PEAR", "error", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Exception/Pear.php#L50-L75
218,772
moodle/moodle
favourites/classes/privacy/provider.php
provider.add_userids_for_context
public static function add_userids_for_context(\core_privacy\local\request\userlist $userlist, string $itemtype = null) { if (empty($userlist)) { return; } $params = [ 'contextid' => $userlist->get_context()->id, 'component' => $userlist->get_component() ]; $sql = "SELECT userid FROM {favourite} WHERE contextid = :contextid AND component = :component"; if (!is_null($itemtype)) { $sql .= " AND itemtype = :itemtype"; $params['itemtype'] = $itemtype; } $userlist->add_from_sql('userid', $sql, $params); }
php
public static function add_userids_for_context(\core_privacy\local\request\userlist $userlist, string $itemtype = null) { if (empty($userlist)) { return; } $params = [ 'contextid' => $userlist->get_context()->id, 'component' => $userlist->get_component() ]; $sql = "SELECT userid FROM {favourite} WHERE contextid = :contextid AND component = :component"; if (!is_null($itemtype)) { $sql .= " AND itemtype = :itemtype"; $params['itemtype'] = $itemtype; } $userlist->add_from_sql('userid', $sql, $params); }
[ "public", "static", "function", "add_userids_for_context", "(", "\\", "core_privacy", "\\", "local", "\\", "request", "\\", "userlist", "$", "userlist", ",", "string", "$", "itemtype", "=", "null", ")", "{", "if", "(", "empty", "(", "$", "userlist", ")", ")", "{", "return", ";", "}", "$", "params", "=", "[", "'contextid'", "=>", "$", "userlist", "->", "get_context", "(", ")", "->", "id", ",", "'component'", "=>", "$", "userlist", "->", "get_component", "(", ")", "]", ";", "$", "sql", "=", "\"SELECT userid\n FROM {favourite}\n WHERE contextid = :contextid\n AND component = :component\"", ";", "if", "(", "!", "is_null", "(", "$", "itemtype", ")", ")", "{", "$", "sql", ".=", "\" AND itemtype = :itemtype\"", ";", "$", "params", "[", "'itemtype'", "]", "=", "$", "itemtype", ";", "}", "$", "userlist", "->", "add_from_sql", "(", "'userid'", ",", "$", "sql", ",", "$", "params", ")", ";", "}" ]
Add users to a userlist who have favourites within the specified context. @param \core_privacy\local\request\userlist $userlist The userlist to add the users to. @param string $itemtype the type of the favourited items. @return void
[ "Add", "users", "to", "a", "userlist", "who", "have", "favourites", "within", "the", "specified", "context", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/favourites/classes/privacy/provider.php#L111-L133
218,773
moodle/moodle
favourites/classes/privacy/provider.php
provider.get_favourites_info_for_user
public static function get_favourites_info_for_user(int $userid, \context $context, string $component, string $itemtype, int $itemid) { global $DB; $params = [ 'userid' => $userid, 'component' => $component, 'itemtype' => $itemtype, 'itemid' => $itemid, 'contextid' => $context->id ]; if (!$favourited = $DB->get_record('favourite', $params)) { return; } return [ 'starred' => transform::yesno(true), 'ordering' => $favourited->ordering, 'timecreated' => transform::datetime($favourited->timecreated), 'timemodified' => transform::datetime($favourited->timemodified) ]; }
php
public static function get_favourites_info_for_user(int $userid, \context $context, string $component, string $itemtype, int $itemid) { global $DB; $params = [ 'userid' => $userid, 'component' => $component, 'itemtype' => $itemtype, 'itemid' => $itemid, 'contextid' => $context->id ]; if (!$favourited = $DB->get_record('favourite', $params)) { return; } return [ 'starred' => transform::yesno(true), 'ordering' => $favourited->ordering, 'timecreated' => transform::datetime($favourited->timecreated), 'timemodified' => transform::datetime($favourited->timemodified) ]; }
[ "public", "static", "function", "get_favourites_info_for_user", "(", "int", "$", "userid", ",", "\\", "context", "$", "context", ",", "string", "$", "component", ",", "string", "$", "itemtype", ",", "int", "$", "itemid", ")", "{", "global", "$", "DB", ";", "$", "params", "=", "[", "'userid'", "=>", "$", "userid", ",", "'component'", "=>", "$", "component", ",", "'itemtype'", "=>", "$", "itemtype", ",", "'itemid'", "=>", "$", "itemid", ",", "'contextid'", "=>", "$", "context", "->", "id", "]", ";", "if", "(", "!", "$", "favourited", "=", "$", "DB", "->", "get_record", "(", "'favourite'", ",", "$", "params", ")", ")", "{", "return", ";", "}", "return", "[", "'starred'", "=>", "transform", "::", "yesno", "(", "true", ")", ",", "'ordering'", "=>", "$", "favourited", "->", "ordering", ",", "'timecreated'", "=>", "transform", "::", "datetime", "(", "$", "favourited", "->", "timecreated", ")", ",", "'timemodified'", "=>", "transform", "::", "datetime", "(", "$", "favourited", "->", "timemodified", ")", "]", ";", "}" ]
Get favourites data for the specified user in the specified component, item type and item ID. @param int $userid The id of the user in scope. @param \context $context The context to which data is scoped. @param string $component The favourite's component name. @param string $itemtype The favourite's item type. @param int $itemid The favourite's item ID. @return array|null
[ "Get", "favourites", "data", "for", "the", "specified", "user", "in", "the", "specified", "component", "item", "type", "and", "item", "ID", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/favourites/classes/privacy/provider.php#L145-L167
218,774
moodle/moodle
favourites/classes/privacy/provider.php
provider.delete_favourites_for_all_users
public static function delete_favourites_for_all_users(\context $context, string $component, string $itemtype, int $itemid = 0) { global $DB; $params = [ 'component' => $component, 'itemtype' => $itemtype, 'contextid' => $context->id ]; $select = "component = :component AND itemtype =:itemtype AND contextid = :contextid"; if (!empty($itemid)) { $select .= " AND itemid = :itemid"; $params['itemid'] = $itemid; } $DB->delete_records_select('favourite', $select, $params); }
php
public static function delete_favourites_for_all_users(\context $context, string $component, string $itemtype, int $itemid = 0) { global $DB; $params = [ 'component' => $component, 'itemtype' => $itemtype, 'contextid' => $context->id ]; $select = "component = :component AND itemtype =:itemtype AND contextid = :contextid"; if (!empty($itemid)) { $select .= " AND itemid = :itemid"; $params['itemid'] = $itemid; } $DB->delete_records_select('favourite', $select, $params); }
[ "public", "static", "function", "delete_favourites_for_all_users", "(", "\\", "context", "$", "context", ",", "string", "$", "component", ",", "string", "$", "itemtype", ",", "int", "$", "itemid", "=", "0", ")", "{", "global", "$", "DB", ";", "$", "params", "=", "[", "'component'", "=>", "$", "component", ",", "'itemtype'", "=>", "$", "itemtype", ",", "'contextid'", "=>", "$", "context", "->", "id", "]", ";", "$", "select", "=", "\"component = :component AND itemtype =:itemtype AND contextid = :contextid\"", ";", "if", "(", "!", "empty", "(", "$", "itemid", ")", ")", "{", "$", "select", ".=", "\" AND itemid = :itemid\"", ";", "$", "params", "[", "'itemid'", "]", "=", "$", "itemid", ";", "}", "$", "DB", "->", "delete_records_select", "(", "'favourite'", ",", "$", "select", ",", "$", "params", ")", ";", "}" ]
Delete all favourites for all users in the specified contexts, and component area. @param \context $context The context to which deletion is scoped. @param string $component The favourite's component name. @param string $itemtype The favourite's itemtype. @param int $itemid Optional itemid associated with component. @throws \dml_exception if any errors are encountered during deletion.
[ "Delete", "all", "favourites", "for", "all", "users", "in", "the", "specified", "contexts", "and", "component", "area", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/favourites/classes/privacy/provider.php#L178-L195
218,775
moodle/moodle
favourites/classes/privacy/provider.php
provider.delete_favourites_for_userlist
public static function delete_favourites_for_userlist(\core_privacy\local\request\approved_userlist $userlist, string $itemtype, int $itemid = 0) { global $DB; $userids = $userlist->get_userids(); if (empty($userids)) { return; } $context = $userlist->get_context(); list($usersql, $userparams) = $DB->get_in_or_equal($userids, SQL_PARAMS_NAMED); $params = [ 'component' => $userlist->get_component(), 'itemtype' => $itemtype, 'contextid' => $context->id ]; $params += $userparams; $select = "component = :component AND itemtype = :itemtype AND contextid = :contextid AND userid $usersql"; if (!empty($itemid)) { $select .= " AND itemid = :itemid"; $params['itemid'] = $itemid; } $DB->delete_records_select('favourite', $select, $params); }
php
public static function delete_favourites_for_userlist(\core_privacy\local\request\approved_userlist $userlist, string $itemtype, int $itemid = 0) { global $DB; $userids = $userlist->get_userids(); if (empty($userids)) { return; } $context = $userlist->get_context(); list($usersql, $userparams) = $DB->get_in_or_equal($userids, SQL_PARAMS_NAMED); $params = [ 'component' => $userlist->get_component(), 'itemtype' => $itemtype, 'contextid' => $context->id ]; $params += $userparams; $select = "component = :component AND itemtype = :itemtype AND contextid = :contextid AND userid $usersql"; if (!empty($itemid)) { $select .= " AND itemid = :itemid"; $params['itemid'] = $itemid; } $DB->delete_records_select('favourite', $select, $params); }
[ "public", "static", "function", "delete_favourites_for_userlist", "(", "\\", "core_privacy", "\\", "local", "\\", "request", "\\", "approved_userlist", "$", "userlist", ",", "string", "$", "itemtype", ",", "int", "$", "itemid", "=", "0", ")", "{", "global", "$", "DB", ";", "$", "userids", "=", "$", "userlist", "->", "get_userids", "(", ")", ";", "if", "(", "empty", "(", "$", "userids", ")", ")", "{", "return", ";", "}", "$", "context", "=", "$", "userlist", "->", "get_context", "(", ")", ";", "list", "(", "$", "usersql", ",", "$", "userparams", ")", "=", "$", "DB", "->", "get_in_or_equal", "(", "$", "userids", ",", "SQL_PARAMS_NAMED", ")", ";", "$", "params", "=", "[", "'component'", "=>", "$", "userlist", "->", "get_component", "(", ")", ",", "'itemtype'", "=>", "$", "itemtype", ",", "'contextid'", "=>", "$", "context", "->", "id", "]", ";", "$", "params", "+=", "$", "userparams", ";", "$", "select", "=", "\"component = :component AND itemtype = :itemtype AND contextid = :contextid AND userid $usersql\"", ";", "if", "(", "!", "empty", "(", "$", "itemid", ")", ")", "{", "$", "select", ".=", "\" AND itemid = :itemid\"", ";", "$", "params", "[", "'itemid'", "]", "=", "$", "itemid", ";", "}", "$", "DB", "->", "delete_records_select", "(", "'favourite'", ",", "$", "select", ",", "$", "params", ")", ";", "}" ]
Delete all favourites for the specified users in the specified context, component area and item type. @param \core_privacy\local\request\approved_userlist $userlist The approved contexts and user information to delete information for. @param string $itemtype The favourite's itemtype. @param int $itemid Optional itemid associated with component. @throws \dml_exception if any errors are encountered during deletion.
[ "Delete", "all", "favourites", "for", "the", "specified", "users", "in", "the", "specified", "context", "component", "area", "and", "item", "type", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/favourites/classes/privacy/provider.php#L206-L234
218,776
moodle/moodle
favourites/classes/privacy/provider.php
provider.delete_favourites_for_user
public static function delete_favourites_for_user(approved_contextlist $contextlist, string $component, string $itemtype, int $itemid = 0) { global $DB; $userid = $contextlist->get_user()->id; list($insql, $inparams) = $DB->get_in_or_equal($contextlist->get_contextids(), SQL_PARAMS_NAMED); $params = [ 'userid' => $userid, 'component' => $component, 'itemtype' => $itemtype, ]; $params += $inparams; $select = "userid = :userid AND component = :component AND itemtype =:itemtype AND contextid $insql"; if (!empty($itemid)) { $select .= " AND itemid = :itemid"; $params['itemid'] = $itemid; } $DB->delete_records_select('favourite', $select, $params); }
php
public static function delete_favourites_for_user(approved_contextlist $contextlist, string $component, string $itemtype, int $itemid = 0) { global $DB; $userid = $contextlist->get_user()->id; list($insql, $inparams) = $DB->get_in_or_equal($contextlist->get_contextids(), SQL_PARAMS_NAMED); $params = [ 'userid' => $userid, 'component' => $component, 'itemtype' => $itemtype, ]; $params += $inparams; $select = "userid = :userid AND component = :component AND itemtype =:itemtype AND contextid $insql"; if (!empty($itemid)) { $select .= " AND itemid = :itemid"; $params['itemid'] = $itemid; } $DB->delete_records_select('favourite', $select, $params); }
[ "public", "static", "function", "delete_favourites_for_user", "(", "approved_contextlist", "$", "contextlist", ",", "string", "$", "component", ",", "string", "$", "itemtype", ",", "int", "$", "itemid", "=", "0", ")", "{", "global", "$", "DB", ";", "$", "userid", "=", "$", "contextlist", "->", "get_user", "(", ")", "->", "id", ";", "list", "(", "$", "insql", ",", "$", "inparams", ")", "=", "$", "DB", "->", "get_in_or_equal", "(", "$", "contextlist", "->", "get_contextids", "(", ")", ",", "SQL_PARAMS_NAMED", ")", ";", "$", "params", "=", "[", "'userid'", "=>", "$", "userid", ",", "'component'", "=>", "$", "component", ",", "'itemtype'", "=>", "$", "itemtype", ",", "]", ";", "$", "params", "+=", "$", "inparams", ";", "$", "select", "=", "\"userid = :userid AND component = :component AND itemtype =:itemtype AND contextid $insql\"", ";", "if", "(", "!", "empty", "(", "$", "itemid", ")", ")", "{", "$", "select", ".=", "\" AND itemid = :itemid\"", ";", "$", "params", "[", "'itemid'", "]", "=", "$", "itemid", ";", "}", "$", "DB", "->", "delete_records_select", "(", "'favourite'", ",", "$", "select", ",", "$", "params", ")", ";", "}" ]
Delete all favourites for the specified user, in the specified contexts. @param approved_contextlist $contextlist The approved contexts and user information to delete information for. @param string $component The favourite's component name. @param string $itemtype The favourite's itemtype. @param int $itemid Optional itemid associated with component. @throws \coding_exception @throws \dml_exception
[ "Delete", "all", "favourites", "for", "the", "specified", "user", "in", "the", "specified", "contexts", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/favourites/classes/privacy/provider.php#L246-L269
218,777
moodle/moodle
privacy/classes/output/exported_navigation_page.php
exported_navigation_page.create_navigation
protected function create_navigation(\stdClass $tree) { if ($this->firstelement) { $html = \html_writer::start_tag('ul', ['class' => 'treeview parent block_tree list', 'id' => 'my-tree']); $this->firstelement = false; } else { $html = \html_writer::start_tag('ul', ['class' => 'parent', 'role' => 'group']); } foreach ($tree->children as $child) { if (isset($child->children)) { $html .= \html_writer::start_tag('li', ['class' => 'menu-item', 'role' => 'treeitem', 'aria-expanded' => 'false']); $html .= $child->name; $html .= $this->create_navigation($child); } else { $html .= \html_writer::start_tag('li', ['class' => 'item', 'role' => 'treeitem', 'aria-expanded' => 'false']); // Normal display. if (isset($child->datavar)) { $html .= \html_writer::link('#', $child->name, ['data-var' => $child->datavar]); } else { $html .= \html_writer::link($child->url, $child->name, ['target' => '_blank']); } } $html .= \html_writer::end_tag('li'); } $html .= \html_writer::end_tag('ul'); return $html; }
php
protected function create_navigation(\stdClass $tree) { if ($this->firstelement) { $html = \html_writer::start_tag('ul', ['class' => 'treeview parent block_tree list', 'id' => 'my-tree']); $this->firstelement = false; } else { $html = \html_writer::start_tag('ul', ['class' => 'parent', 'role' => 'group']); } foreach ($tree->children as $child) { if (isset($child->children)) { $html .= \html_writer::start_tag('li', ['class' => 'menu-item', 'role' => 'treeitem', 'aria-expanded' => 'false']); $html .= $child->name; $html .= $this->create_navigation($child); } else { $html .= \html_writer::start_tag('li', ['class' => 'item', 'role' => 'treeitem', 'aria-expanded' => 'false']); // Normal display. if (isset($child->datavar)) { $html .= \html_writer::link('#', $child->name, ['data-var' => $child->datavar]); } else { $html .= \html_writer::link($child->url, $child->name, ['target' => '_blank']); } } $html .= \html_writer::end_tag('li'); } $html .= \html_writer::end_tag('ul'); return $html; }
[ "protected", "function", "create_navigation", "(", "\\", "stdClass", "$", "tree", ")", "{", "if", "(", "$", "this", "->", "firstelement", ")", "{", "$", "html", "=", "\\", "html_writer", "::", "start_tag", "(", "'ul'", ",", "[", "'class'", "=>", "'treeview parent block_tree list'", ",", "'id'", "=>", "'my-tree'", "]", ")", ";", "$", "this", "->", "firstelement", "=", "false", ";", "}", "else", "{", "$", "html", "=", "\\", "html_writer", "::", "start_tag", "(", "'ul'", ",", "[", "'class'", "=>", "'parent'", ",", "'role'", "=>", "'group'", "]", ")", ";", "}", "foreach", "(", "$", "tree", "->", "children", "as", "$", "child", ")", "{", "if", "(", "isset", "(", "$", "child", "->", "children", ")", ")", "{", "$", "html", ".=", "\\", "html_writer", "::", "start_tag", "(", "'li'", ",", "[", "'class'", "=>", "'menu-item'", ",", "'role'", "=>", "'treeitem'", ",", "'aria-expanded'", "=>", "'false'", "]", ")", ";", "$", "html", ".=", "$", "child", "->", "name", ";", "$", "html", ".=", "$", "this", "->", "create_navigation", "(", "$", "child", ")", ";", "}", "else", "{", "$", "html", ".=", "\\", "html_writer", "::", "start_tag", "(", "'li'", ",", "[", "'class'", "=>", "'item'", ",", "'role'", "=>", "'treeitem'", ",", "'aria-expanded'", "=>", "'false'", "]", ")", ";", "// Normal display.", "if", "(", "isset", "(", "$", "child", "->", "datavar", ")", ")", "{", "$", "html", ".=", "\\", "html_writer", "::", "link", "(", "'#'", ",", "$", "child", "->", "name", ",", "[", "'data-var'", "=>", "$", "child", "->", "datavar", "]", ")", ";", "}", "else", "{", "$", "html", ".=", "\\", "html_writer", "::", "link", "(", "$", "child", "->", "url", ",", "$", "child", "->", "name", ",", "[", "'target'", "=>", "'_blank'", "]", ")", ";", "}", "}", "$", "html", ".=", "\\", "html_writer", "::", "end_tag", "(", "'li'", ")", ";", "}", "$", "html", ".=", "\\", "html_writer", "::", "end_tag", "(", "'ul'", ")", ";", "return", "$", "html", ";", "}" ]
Creates the navigation list html. Why this and not a template? My attempts at trying to get a recursive template working failed. @param \stdClass $tree Full tree to create navigation out of. @return string navigation html.
[ "Creates", "the", "navigation", "list", "html", ".", "Why", "this", "and", "not", "a", "template?", "My", "attempts", "at", "trying", "to", "get", "a", "recursive", "template", "working", "failed", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/privacy/classes/output/exported_navigation_page.php#L61-L86
218,778
moodle/moodle
mod/quiz/backup/moodle2/restore_quiz_stepslib.php
restore_quiz_activity_structure_step.process_quiz_slot_tags
protected function process_quiz_slot_tags($data) { global $DB; $data = (object)$data; $data->slotid = $this->get_new_parentid('quiz_question_instance'); if ($this->task->is_samesite() && $tag = core_tag_tag::get($data->tagid, 'id, name')) { $data->tagname = $tag->name; } else if ($tag = core_tag_tag::get_by_name(0, $data->tagname, 'id, name')) { $data->tagid = $tag->id; } else { $data->tagid = null; $data->tagname = $tag->name; } $DB->insert_record('quiz_slot_tags', $data); }
php
protected function process_quiz_slot_tags($data) { global $DB; $data = (object)$data; $data->slotid = $this->get_new_parentid('quiz_question_instance'); if ($this->task->is_samesite() && $tag = core_tag_tag::get($data->tagid, 'id, name')) { $data->tagname = $tag->name; } else if ($tag = core_tag_tag::get_by_name(0, $data->tagname, 'id, name')) { $data->tagid = $tag->id; } else { $data->tagid = null; $data->tagname = $tag->name; } $DB->insert_record('quiz_slot_tags', $data); }
[ "protected", "function", "process_quiz_slot_tags", "(", "$", "data", ")", "{", "global", "$", "DB", ";", "$", "data", "=", "(", "object", ")", "$", "data", ";", "$", "data", "->", "slotid", "=", "$", "this", "->", "get_new_parentid", "(", "'quiz_question_instance'", ")", ";", "if", "(", "$", "this", "->", "task", "->", "is_samesite", "(", ")", "&&", "$", "tag", "=", "core_tag_tag", "::", "get", "(", "$", "data", "->", "tagid", ",", "'id, name'", ")", ")", "{", "$", "data", "->", "tagname", "=", "$", "tag", "->", "name", ";", "}", "else", "if", "(", "$", "tag", "=", "core_tag_tag", "::", "get_by_name", "(", "0", ",", "$", "data", "->", "tagname", ",", "'id, name'", ")", ")", "{", "$", "data", "->", "tagid", "=", "$", "tag", "->", "id", ";", "}", "else", "{", "$", "data", "->", "tagid", "=", "null", ";", "$", "data", "->", "tagname", "=", "$", "tag", "->", "name", ";", "}", "$", "DB", "->", "insert_record", "(", "'quiz_slot_tags'", ",", "$", "data", ")", ";", "}" ]
Process a quiz_slot_tags restore @param stdClass|array $data The quiz_slot_tags data
[ "Process", "a", "quiz_slot_tags", "restore" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/quiz/backup/moodle2/restore_quiz_stepslib.php#L317-L333
218,779
moodle/moodle
lib/adodb/drivers/adodb-borland_ibase.inc.php
ADODB_borland_ibase.SelectLimit
function SelectLimit($sql,$nrows=-1,$offset=-1,$inputarr=false,$secs2cache=0) { if ($nrows > 0) { if ($offset <= 0) $str = " ROWS $nrows "; else { $a = $offset+1; $b = $offset+$nrows; $str = " ROWS $a TO $b"; } } else { // ok, skip $a = $offset + 1; $str = " ROWS $a TO 999999999"; // 999 million } $sql .= $str; return ($secs2cache) ? $this->CacheExecute($secs2cache,$sql,$inputarr) : $this->Execute($sql,$inputarr); }
php
function SelectLimit($sql,$nrows=-1,$offset=-1,$inputarr=false,$secs2cache=0) { if ($nrows > 0) { if ($offset <= 0) $str = " ROWS $nrows "; else { $a = $offset+1; $b = $offset+$nrows; $str = " ROWS $a TO $b"; } } else { // ok, skip $a = $offset + 1; $str = " ROWS $a TO 999999999"; // 999 million } $sql .= $str; return ($secs2cache) ? $this->CacheExecute($secs2cache,$sql,$inputarr) : $this->Execute($sql,$inputarr); }
[ "function", "SelectLimit", "(", "$", "sql", ",", "$", "nrows", "=", "-", "1", ",", "$", "offset", "=", "-", "1", ",", "$", "inputarr", "=", "false", ",", "$", "secs2cache", "=", "0", ")", "{", "if", "(", "$", "nrows", ">", "0", ")", "{", "if", "(", "$", "offset", "<=", "0", ")", "$", "str", "=", "\" ROWS $nrows \"", ";", "else", "{", "$", "a", "=", "$", "offset", "+", "1", ";", "$", "b", "=", "$", "offset", "+", "$", "nrows", ";", "$", "str", "=", "\" ROWS $a TO $b\"", ";", "}", "}", "else", "{", "// ok, skip", "$", "a", "=", "$", "offset", "+", "1", ";", "$", "str", "=", "\" ROWS $a TO 999999999\"", ";", "// 999 million", "}", "$", "sql", ".=", "$", "str", ";", "return", "(", "$", "secs2cache", ")", "?", "$", "this", "->", "CacheExecute", "(", "$", "secs2cache", ",", "$", "sql", ",", "$", "inputarr", ")", ":", "$", "this", "->", "Execute", "(", "$", "sql", ",", "$", "inputarr", ")", ";", "}" ]
SELECT FIRST 5 SKIP 2 col1, col2 FROM TABLE
[ "SELECT", "FIRST", "5", "SKIP", "2", "col1", "col2", "FROM", "TABLE" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/adodb/drivers/adodb-borland_ibase.inc.php#L54-L74
218,780
moodle/moodle
message/output/airnotifier/externallib.php
message_airnotifier_external.get_user_devices
public static function get_user_devices($appid, $userid = 0) { global $USER; $params = self::validate_parameters( self::get_user_devices_parameters(), array( 'appid' => $appid, 'userid' => $userid, ) ); $context = context_system::instance(); self::validate_context($context); if (empty($params['userid'])) { $user = $USER; } else { $user = core_user::get_user($params['userid'], '*', MUST_EXIST); core_user::require_active_user($user); // Allow only admins to retrieve other users devices. if ($user->id != $USER->id) { require_capability('moodle/site:config', $context); } } $warnings = array(); $devices = array(); // Check if mobile notifications are enabled. if (!self::is_system_configured()) { $warnings[] = array( 'item' => 'user', 'itemid' => $user->id, 'warningcode' => 'systemnotconfigured', 'message' => 'Mobile notifications are not configured' ); } else { // We catch exceptions here because get_user_devices may try to connect to Airnotifier. try { $manager = new message_airnotifier_manager(); $devices = $manager->get_user_devices($appid, $user->id); } catch (Exception $e) { $warnings[] = array( 'item' => 'user', 'itemid' => $user->id, 'warningcode' => 'errorgettingdevices', 'message' => $e->getMessage() ); } } return array( 'devices' => $devices, 'warnings' => $warnings ); }
php
public static function get_user_devices($appid, $userid = 0) { global $USER; $params = self::validate_parameters( self::get_user_devices_parameters(), array( 'appid' => $appid, 'userid' => $userid, ) ); $context = context_system::instance(); self::validate_context($context); if (empty($params['userid'])) { $user = $USER; } else { $user = core_user::get_user($params['userid'], '*', MUST_EXIST); core_user::require_active_user($user); // Allow only admins to retrieve other users devices. if ($user->id != $USER->id) { require_capability('moodle/site:config', $context); } } $warnings = array(); $devices = array(); // Check if mobile notifications are enabled. if (!self::is_system_configured()) { $warnings[] = array( 'item' => 'user', 'itemid' => $user->id, 'warningcode' => 'systemnotconfigured', 'message' => 'Mobile notifications are not configured' ); } else { // We catch exceptions here because get_user_devices may try to connect to Airnotifier. try { $manager = new message_airnotifier_manager(); $devices = $manager->get_user_devices($appid, $user->id); } catch (Exception $e) { $warnings[] = array( 'item' => 'user', 'itemid' => $user->id, 'warningcode' => 'errorgettingdevices', 'message' => $e->getMessage() ); } } return array( 'devices' => $devices, 'warnings' => $warnings ); }
[ "public", "static", "function", "get_user_devices", "(", "$", "appid", ",", "$", "userid", "=", "0", ")", "{", "global", "$", "USER", ";", "$", "params", "=", "self", "::", "validate_parameters", "(", "self", "::", "get_user_devices_parameters", "(", ")", ",", "array", "(", "'appid'", "=>", "$", "appid", ",", "'userid'", "=>", "$", "userid", ",", ")", ")", ";", "$", "context", "=", "context_system", "::", "instance", "(", ")", ";", "self", "::", "validate_context", "(", "$", "context", ")", ";", "if", "(", "empty", "(", "$", "params", "[", "'userid'", "]", ")", ")", "{", "$", "user", "=", "$", "USER", ";", "}", "else", "{", "$", "user", "=", "core_user", "::", "get_user", "(", "$", "params", "[", "'userid'", "]", ",", "'*'", ",", "MUST_EXIST", ")", ";", "core_user", "::", "require_active_user", "(", "$", "user", ")", ";", "// Allow only admins to retrieve other users devices.", "if", "(", "$", "user", "->", "id", "!=", "$", "USER", "->", "id", ")", "{", "require_capability", "(", "'moodle/site:config'", ",", "$", "context", ")", ";", "}", "}", "$", "warnings", "=", "array", "(", ")", ";", "$", "devices", "=", "array", "(", ")", ";", "// Check if mobile notifications are enabled.", "if", "(", "!", "self", "::", "is_system_configured", "(", ")", ")", "{", "$", "warnings", "[", "]", "=", "array", "(", "'item'", "=>", "'user'", ",", "'itemid'", "=>", "$", "user", "->", "id", ",", "'warningcode'", "=>", "'systemnotconfigured'", ",", "'message'", "=>", "'Mobile notifications are not configured'", ")", ";", "}", "else", "{", "// We catch exceptions here because get_user_devices may try to connect to Airnotifier.", "try", "{", "$", "manager", "=", "new", "message_airnotifier_manager", "(", ")", ";", "$", "devices", "=", "$", "manager", "->", "get_user_devices", "(", "$", "appid", ",", "$", "user", "->", "id", ")", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "$", "warnings", "[", "]", "=", "array", "(", "'item'", "=>", "'user'", ",", "'itemid'", "=>", "$", "user", "->", "id", ",", "'warningcode'", "=>", "'errorgettingdevices'", ",", "'message'", "=>", "$", "e", "->", "getMessage", "(", ")", ")", ";", "}", "}", "return", "array", "(", "'devices'", "=>", "$", "devices", ",", "'warnings'", "=>", "$", "warnings", ")", ";", "}" ]
Return the list of mobile devices that are registered in Moodle for the given user. @param string $appid app unique id (usually a reversed domain) @param integer $userid the user id, 0 for current user @return array warnings and devices @throws moodle_exception @since Moodle 3.2
[ "Return", "the", "list", "of", "mobile", "devices", "that", "are", "registered", "in", "Moodle", "for", "the", "given", "user", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/message/output/airnotifier/externallib.php#L238-L292
218,781
moodle/moodle
lib/adodb/adodb-pear.inc.php
DB.factory
function factory($type) { include_once(ADODB_DIR."/drivers/adodb-$type.inc.php"); $obj = NewADOConnection($type); if (!is_object($obj)) $obj = new PEAR_Error('Unknown Database Driver: '.$dsninfo['phptype'],-1); return $obj; }
php
function factory($type) { include_once(ADODB_DIR."/drivers/adodb-$type.inc.php"); $obj = NewADOConnection($type); if (!is_object($obj)) $obj = new PEAR_Error('Unknown Database Driver: '.$dsninfo['phptype'],-1); return $obj; }
[ "function", "factory", "(", "$", "type", ")", "{", "include_once", "(", "ADODB_DIR", ".", "\"/drivers/adodb-$type.inc.php\"", ")", ";", "$", "obj", "=", "NewADOConnection", "(", "$", "type", ")", ";", "if", "(", "!", "is_object", "(", "$", "obj", ")", ")", "$", "obj", "=", "new", "PEAR_Error", "(", "'Unknown Database Driver: '", ".", "$", "dsninfo", "[", "'phptype'", "]", ",", "-", "1", ")", ";", "return", "$", "obj", ";", "}" ]
Create a new DB object for the specified database type @param $type string database type, for example "mysql" @return object a newly created DB object, or a DB error code on error
[ "Create", "a", "new", "DB", "object", "for", "the", "specified", "database", "type" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/adodb/adodb-pear.inc.php#L110-L116
218,782
moodle/moodle
lib/adodb/adodb-pear.inc.php
DB.connect
function connect($dsn, $options = false) { if (is_array($dsn)) { $dsninfo = $dsn; } else { $dsninfo = DB::parseDSN($dsn); } switch ($dsninfo["phptype"]) { case 'pgsql': $type = 'postgres7'; break; case 'ifx': $type = 'informix9'; break; default: $type = $dsninfo["phptype"]; break; } if (is_array($options) && isset($options["debug"]) && $options["debug"] >= 2) { // expose php errors with sufficient debug level @include_once("adodb-$type.inc.php"); } else { @include_once("adodb-$type.inc.php"); } @$obj = NewADOConnection($type); if (!is_object($obj)) { $obj = new PEAR_Error('Unknown Database Driver: '.$dsninfo['phptype'],-1); return $obj; } if (is_array($options)) { foreach($options as $k => $v) { switch(strtolower($k)) { case 'persist': case 'persistent': $persist = $v; break; #ibase case 'dialect': $obj->dialect = $v; break; case 'charset': $obj->charset = $v; break; case 'buffers': $obj->buffers = $v; break; #ado case 'charpage': $obj->charPage = $v; break; #mysql case 'clientflags': $obj->clientFlags = $v; break; } } } else { $persist = false; } if (isset($dsninfo['socket'])) $dsninfo['hostspec'] .= ':'.$dsninfo['socket']; else if (isset($dsninfo['port'])) $dsninfo['hostspec'] .= ':'.$dsninfo['port']; if($persist) $ok = $obj->PConnect($dsninfo['hostspec'], $dsninfo['username'],$dsninfo['password'],$dsninfo['database']); else $ok = $obj->Connect($dsninfo['hostspec'], $dsninfo['username'],$dsninfo['password'],$dsninfo['database']); if (!$ok) $obj = ADODB_PEAR_Error(); return $obj; }
php
function connect($dsn, $options = false) { if (is_array($dsn)) { $dsninfo = $dsn; } else { $dsninfo = DB::parseDSN($dsn); } switch ($dsninfo["phptype"]) { case 'pgsql': $type = 'postgres7'; break; case 'ifx': $type = 'informix9'; break; default: $type = $dsninfo["phptype"]; break; } if (is_array($options) && isset($options["debug"]) && $options["debug"] >= 2) { // expose php errors with sufficient debug level @include_once("adodb-$type.inc.php"); } else { @include_once("adodb-$type.inc.php"); } @$obj = NewADOConnection($type); if (!is_object($obj)) { $obj = new PEAR_Error('Unknown Database Driver: '.$dsninfo['phptype'],-1); return $obj; } if (is_array($options)) { foreach($options as $k => $v) { switch(strtolower($k)) { case 'persist': case 'persistent': $persist = $v; break; #ibase case 'dialect': $obj->dialect = $v; break; case 'charset': $obj->charset = $v; break; case 'buffers': $obj->buffers = $v; break; #ado case 'charpage': $obj->charPage = $v; break; #mysql case 'clientflags': $obj->clientFlags = $v; break; } } } else { $persist = false; } if (isset($dsninfo['socket'])) $dsninfo['hostspec'] .= ':'.$dsninfo['socket']; else if (isset($dsninfo['port'])) $dsninfo['hostspec'] .= ':'.$dsninfo['port']; if($persist) $ok = $obj->PConnect($dsninfo['hostspec'], $dsninfo['username'],$dsninfo['password'],$dsninfo['database']); else $ok = $obj->Connect($dsninfo['hostspec'], $dsninfo['username'],$dsninfo['password'],$dsninfo['database']); if (!$ok) $obj = ADODB_PEAR_Error(); return $obj; }
[ "function", "connect", "(", "$", "dsn", ",", "$", "options", "=", "false", ")", "{", "if", "(", "is_array", "(", "$", "dsn", ")", ")", "{", "$", "dsninfo", "=", "$", "dsn", ";", "}", "else", "{", "$", "dsninfo", "=", "DB", "::", "parseDSN", "(", "$", "dsn", ")", ";", "}", "switch", "(", "$", "dsninfo", "[", "\"phptype\"", "]", ")", "{", "case", "'pgsql'", ":", "$", "type", "=", "'postgres7'", ";", "break", ";", "case", "'ifx'", ":", "$", "type", "=", "'informix9'", ";", "break", ";", "default", ":", "$", "type", "=", "$", "dsninfo", "[", "\"phptype\"", "]", ";", "break", ";", "}", "if", "(", "is_array", "(", "$", "options", ")", "&&", "isset", "(", "$", "options", "[", "\"debug\"", "]", ")", "&&", "$", "options", "[", "\"debug\"", "]", ">=", "2", ")", "{", "// expose php errors with sufficient debug level", "@", "include_once", "(", "\"adodb-$type.inc.php\"", ")", ";", "}", "else", "{", "@", "include_once", "(", "\"adodb-$type.inc.php\"", ")", ";", "}", "@", "$", "obj", "=", "NewADOConnection", "(", "$", "type", ")", ";", "if", "(", "!", "is_object", "(", "$", "obj", ")", ")", "{", "$", "obj", "=", "new", "PEAR_Error", "(", "'Unknown Database Driver: '", ".", "$", "dsninfo", "[", "'phptype'", "]", ",", "-", "1", ")", ";", "return", "$", "obj", ";", "}", "if", "(", "is_array", "(", "$", "options", ")", ")", "{", "foreach", "(", "$", "options", "as", "$", "k", "=>", "$", "v", ")", "{", "switch", "(", "strtolower", "(", "$", "k", ")", ")", "{", "case", "'persist'", ":", "case", "'persistent'", ":", "$", "persist", "=", "$", "v", ";", "break", ";", "#ibase", "case", "'dialect'", ":", "$", "obj", "->", "dialect", "=", "$", "v", ";", "break", ";", "case", "'charset'", ":", "$", "obj", "->", "charset", "=", "$", "v", ";", "break", ";", "case", "'buffers'", ":", "$", "obj", "->", "buffers", "=", "$", "v", ";", "break", ";", "#ado", "case", "'charpage'", ":", "$", "obj", "->", "charPage", "=", "$", "v", ";", "break", ";", "#mysql", "case", "'clientflags'", ":", "$", "obj", "->", "clientFlags", "=", "$", "v", ";", "break", ";", "}", "}", "}", "else", "{", "$", "persist", "=", "false", ";", "}", "if", "(", "isset", "(", "$", "dsninfo", "[", "'socket'", "]", ")", ")", "$", "dsninfo", "[", "'hostspec'", "]", ".=", "':'", ".", "$", "dsninfo", "[", "'socket'", "]", ";", "else", "if", "(", "isset", "(", "$", "dsninfo", "[", "'port'", "]", ")", ")", "$", "dsninfo", "[", "'hostspec'", "]", ".=", "':'", ".", "$", "dsninfo", "[", "'port'", "]", ";", "if", "(", "$", "persist", ")", "$", "ok", "=", "$", "obj", "->", "PConnect", "(", "$", "dsninfo", "[", "'hostspec'", "]", ",", "$", "dsninfo", "[", "'username'", "]", ",", "$", "dsninfo", "[", "'password'", "]", ",", "$", "dsninfo", "[", "'database'", "]", ")", ";", "else", "$", "ok", "=", "$", "obj", "->", "Connect", "(", "$", "dsninfo", "[", "'hostspec'", "]", ",", "$", "dsninfo", "[", "'username'", "]", ",", "$", "dsninfo", "[", "'password'", "]", ",", "$", "dsninfo", "[", "'database'", "]", ")", ";", "if", "(", "!", "$", "ok", ")", "$", "obj", "=", "ADODB_PEAR_Error", "(", ")", ";", "return", "$", "obj", ";", "}" ]
Create a new DB object and connect to the specified database @param $dsn mixed "data source name", see the DB::parseDSN method for a description of the dsn format. Can also be specified as an array of the format returned by DB::parseDSN. @param $options mixed if boolean (or scalar), tells whether this connection should be persistent (for backends that support this). This parameter can also be an array of options, see DB_common::setOption for more information on connection options. @return object a newly created DB connection object, or a DB error object on error @see DB::parseDSN @see DB::isError
[ "Create", "a", "new", "DB", "object", "and", "connect", "to", "the", "specified", "database" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/adodb/adodb-pear.inc.php#L137-L190
218,783
moodle/moodle
lib/adodb/adodb-pear.inc.php
DB.isError
function isError($value) { if (!is_object($value)) return false; $class = strtolower(get_class($value)); return $class == 'pear_error' || is_subclass_of($value, 'pear_error') || $class == 'db_error' || is_subclass_of($value, 'db_error'); }
php
function isError($value) { if (!is_object($value)) return false; $class = strtolower(get_class($value)); return $class == 'pear_error' || is_subclass_of($value, 'pear_error') || $class == 'db_error' || is_subclass_of($value, 'db_error'); }
[ "function", "isError", "(", "$", "value", ")", "{", "if", "(", "!", "is_object", "(", "$", "value", ")", ")", "return", "false", ";", "$", "class", "=", "strtolower", "(", "get_class", "(", "$", "value", ")", ")", ";", "return", "$", "class", "==", "'pear_error'", "||", "is_subclass_of", "(", "$", "value", ",", "'pear_error'", ")", "||", "$", "class", "==", "'db_error'", "||", "is_subclass_of", "(", "$", "value", ",", "'db_error'", ")", ";", "}" ]
Tell whether a result code from a DB method is an error @param $value int result code @return bool whether $value is an error
[ "Tell", "whether", "a", "result", "code", "from", "a", "DB", "method", "is", "an", "error" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/adodb/adodb-pear.inc.php#L209-L215
218,784
moodle/moodle
lib/adodb/adodb-pear.inc.php
DB.parseDSN
function parseDSN($dsn) { if (is_array($dsn)) { return $dsn; } $parsed = array( 'phptype' => false, 'dbsyntax' => false, 'protocol' => false, 'hostspec' => false, 'database' => false, 'username' => false, 'password' => false ); // Find phptype and dbsyntax if (($pos = strpos($dsn, '://')) !== false) { $str = substr($dsn, 0, $pos); $dsn = substr($dsn, $pos + 3); } else { $str = $dsn; $dsn = NULL; } // Get phptype and dbsyntax // $str => phptype(dbsyntax) if (preg_match('|^(.+?)\((.*?)\)$|', $str, $arr)) { $parsed['phptype'] = $arr[1]; $parsed['dbsyntax'] = (empty($arr[2])) ? $arr[1] : $arr[2]; } else { $parsed['phptype'] = $str; $parsed['dbsyntax'] = $str; } if (empty($dsn)) { return $parsed; } // Get (if found): username and password // $dsn => username:password@protocol+hostspec/database if (($at = strpos($dsn,'@')) !== false) { $str = substr($dsn, 0, $at); $dsn = substr($dsn, $at + 1); if (($pos = strpos($str, ':')) !== false) { $parsed['username'] = urldecode(substr($str, 0, $pos)); $parsed['password'] = urldecode(substr($str, $pos + 1)); } else { $parsed['username'] = urldecode($str); } } // Find protocol and hostspec // $dsn => protocol+hostspec/database if (($pos=strpos($dsn, '/')) !== false) { $str = substr($dsn, 0, $pos); $dsn = substr($dsn, $pos + 1); } else { $str = $dsn; $dsn = NULL; } // Get protocol + hostspec // $str => protocol+hostspec if (($pos=strpos($str, '+')) !== false) { $parsed['protocol'] = substr($str, 0, $pos); $parsed['hostspec'] = urldecode(substr($str, $pos + 1)); } else { $parsed['hostspec'] = urldecode($str); } // Get dabase if any // $dsn => database if (!empty($dsn)) { $parsed['database'] = $dsn; } return $parsed; }
php
function parseDSN($dsn) { if (is_array($dsn)) { return $dsn; } $parsed = array( 'phptype' => false, 'dbsyntax' => false, 'protocol' => false, 'hostspec' => false, 'database' => false, 'username' => false, 'password' => false ); // Find phptype and dbsyntax if (($pos = strpos($dsn, '://')) !== false) { $str = substr($dsn, 0, $pos); $dsn = substr($dsn, $pos + 3); } else { $str = $dsn; $dsn = NULL; } // Get phptype and dbsyntax // $str => phptype(dbsyntax) if (preg_match('|^(.+?)\((.*?)\)$|', $str, $arr)) { $parsed['phptype'] = $arr[1]; $parsed['dbsyntax'] = (empty($arr[2])) ? $arr[1] : $arr[2]; } else { $parsed['phptype'] = $str; $parsed['dbsyntax'] = $str; } if (empty($dsn)) { return $parsed; } // Get (if found): username and password // $dsn => username:password@protocol+hostspec/database if (($at = strpos($dsn,'@')) !== false) { $str = substr($dsn, 0, $at); $dsn = substr($dsn, $at + 1); if (($pos = strpos($str, ':')) !== false) { $parsed['username'] = urldecode(substr($str, 0, $pos)); $parsed['password'] = urldecode(substr($str, $pos + 1)); } else { $parsed['username'] = urldecode($str); } } // Find protocol and hostspec // $dsn => protocol+hostspec/database if (($pos=strpos($dsn, '/')) !== false) { $str = substr($dsn, 0, $pos); $dsn = substr($dsn, $pos + 1); } else { $str = $dsn; $dsn = NULL; } // Get protocol + hostspec // $str => protocol+hostspec if (($pos=strpos($str, '+')) !== false) { $parsed['protocol'] = substr($str, 0, $pos); $parsed['hostspec'] = urldecode(substr($str, $pos + 1)); } else { $parsed['hostspec'] = urldecode($str); } // Get dabase if any // $dsn => database if (!empty($dsn)) { $parsed['database'] = $dsn; } return $parsed; }
[ "function", "parseDSN", "(", "$", "dsn", ")", "{", "if", "(", "is_array", "(", "$", "dsn", ")", ")", "{", "return", "$", "dsn", ";", "}", "$", "parsed", "=", "array", "(", "'phptype'", "=>", "false", ",", "'dbsyntax'", "=>", "false", ",", "'protocol'", "=>", "false", ",", "'hostspec'", "=>", "false", ",", "'database'", "=>", "false", ",", "'username'", "=>", "false", ",", "'password'", "=>", "false", ")", ";", "// Find phptype and dbsyntax", "if", "(", "(", "$", "pos", "=", "strpos", "(", "$", "dsn", ",", "'://'", ")", ")", "!==", "false", ")", "{", "$", "str", "=", "substr", "(", "$", "dsn", ",", "0", ",", "$", "pos", ")", ";", "$", "dsn", "=", "substr", "(", "$", "dsn", ",", "$", "pos", "+", "3", ")", ";", "}", "else", "{", "$", "str", "=", "$", "dsn", ";", "$", "dsn", "=", "NULL", ";", "}", "// Get phptype and dbsyntax", "// $str => phptype(dbsyntax)", "if", "(", "preg_match", "(", "'|^(.+?)\\((.*?)\\)$|'", ",", "$", "str", ",", "$", "arr", ")", ")", "{", "$", "parsed", "[", "'phptype'", "]", "=", "$", "arr", "[", "1", "]", ";", "$", "parsed", "[", "'dbsyntax'", "]", "=", "(", "empty", "(", "$", "arr", "[", "2", "]", ")", ")", "?", "$", "arr", "[", "1", "]", ":", "$", "arr", "[", "2", "]", ";", "}", "else", "{", "$", "parsed", "[", "'phptype'", "]", "=", "$", "str", ";", "$", "parsed", "[", "'dbsyntax'", "]", "=", "$", "str", ";", "}", "if", "(", "empty", "(", "$", "dsn", ")", ")", "{", "return", "$", "parsed", ";", "}", "// Get (if found): username and password", "// $dsn => username:password@protocol+hostspec/database", "if", "(", "(", "$", "at", "=", "strpos", "(", "$", "dsn", ",", "'@'", ")", ")", "!==", "false", ")", "{", "$", "str", "=", "substr", "(", "$", "dsn", ",", "0", ",", "$", "at", ")", ";", "$", "dsn", "=", "substr", "(", "$", "dsn", ",", "$", "at", "+", "1", ")", ";", "if", "(", "(", "$", "pos", "=", "strpos", "(", "$", "str", ",", "':'", ")", ")", "!==", "false", ")", "{", "$", "parsed", "[", "'username'", "]", "=", "urldecode", "(", "substr", "(", "$", "str", ",", "0", ",", "$", "pos", ")", ")", ";", "$", "parsed", "[", "'password'", "]", "=", "urldecode", "(", "substr", "(", "$", "str", ",", "$", "pos", "+", "1", ")", ")", ";", "}", "else", "{", "$", "parsed", "[", "'username'", "]", "=", "urldecode", "(", "$", "str", ")", ";", "}", "}", "// Find protocol and hostspec", "// $dsn => protocol+hostspec/database", "if", "(", "(", "$", "pos", "=", "strpos", "(", "$", "dsn", ",", "'/'", ")", ")", "!==", "false", ")", "{", "$", "str", "=", "substr", "(", "$", "dsn", ",", "0", ",", "$", "pos", ")", ";", "$", "dsn", "=", "substr", "(", "$", "dsn", ",", "$", "pos", "+", "1", ")", ";", "}", "else", "{", "$", "str", "=", "$", "dsn", ";", "$", "dsn", "=", "NULL", ";", "}", "// Get protocol + hostspec", "// $str => protocol+hostspec", "if", "(", "(", "$", "pos", "=", "strpos", "(", "$", "str", ",", "'+'", ")", ")", "!==", "false", ")", "{", "$", "parsed", "[", "'protocol'", "]", "=", "substr", "(", "$", "str", ",", "0", ",", "$", "pos", ")", ";", "$", "parsed", "[", "'hostspec'", "]", "=", "urldecode", "(", "substr", "(", "$", "str", ",", "$", "pos", "+", "1", ")", ")", ";", "}", "else", "{", "$", "parsed", "[", "'hostspec'", "]", "=", "urldecode", "(", "$", "str", ")", ";", "}", "// Get dabase if any", "// $dsn => database", "if", "(", "!", "empty", "(", "$", "dsn", ")", ")", "{", "$", "parsed", "[", "'database'", "]", "=", "$", "dsn", ";", "}", "return", "$", "parsed", ";", "}" ]
Parse a data source name @param $dsn string Data Source Name to be parsed @return array an associative array with the following keys: phptype: Database backend used in PHP (mysql, odbc etc.) dbsyntax: Database used with regards to SQL syntax etc. protocol: Communication protocol to use (tcp, unix etc.) hostspec: Host specification (hostname[:port]) database: Database to use on the DBMS server username: User name for login password: Password for login The format of the supplied DSN is in its fullest form: phptype(dbsyntax)://username:password@protocol+hostspec/database Most variations are allowed: phptype://username:password@protocol+hostspec:110//usr/db_file.db phptype://username:password@hostspec/database_name phptype://username:password@hostspec phptype://username@hostspec phptype://hostspec/database phptype://hostspec phptype(dbsyntax) phptype @author Tomas V.V.Cox <cox@idecnet.com>
[ "Parse", "a", "data", "source", "name" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/adodb/adodb-pear.inc.php#L268-L346
218,785
moodle/moodle
lib/adodb/adodb-pear.inc.php
DB.assertExtension
function assertExtension($name) { if (!extension_loaded($name)) { $dlext = (strncmp(PHP_OS,'WIN',3) === 0) ? '.dll' : '.so'; @dl($name . $dlext); } if (!extension_loaded($name)) { return false; } return true; }
php
function assertExtension($name) { if (!extension_loaded($name)) { $dlext = (strncmp(PHP_OS,'WIN',3) === 0) ? '.dll' : '.so'; @dl($name . $dlext); } if (!extension_loaded($name)) { return false; } return true; }
[ "function", "assertExtension", "(", "$", "name", ")", "{", "if", "(", "!", "extension_loaded", "(", "$", "name", ")", ")", "{", "$", "dlext", "=", "(", "strncmp", "(", "PHP_OS", ",", "'WIN'", ",", "3", ")", "===", "0", ")", "?", "'.dll'", ":", "'.so'", ";", "@", "dl", "(", "$", "name", ".", "$", "dlext", ")", ";", "}", "if", "(", "!", "extension_loaded", "(", "$", "name", ")", ")", "{", "return", "false", ";", "}", "return", "true", ";", "}" ]
Load a PHP database extension if it is not loaded already. @access public @param $name the base name of the extension (without the .so or .dll suffix) @return bool true if the extension was already or successfully loaded, false if it could not be loaded
[ "Load", "a", "PHP", "database", "extension", "if", "it", "is", "not", "loaded", "already", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/adodb/adodb-pear.inc.php#L359-L369
218,786
moodle/moodle
files/externallib.php
core_files_external.get_files_parameters
public static function get_files_parameters() { return new external_function_parameters( array( 'contextid' => new external_value(PARAM_INT, 'context id Set to -1 to use contextlevel and instanceid.'), 'component' => new external_value(PARAM_TEXT, 'component'), 'filearea' => new external_value(PARAM_TEXT, 'file area'), 'itemid' => new external_value(PARAM_INT, 'associated id'), 'filepath' => new external_value(PARAM_PATH, 'file path'), 'filename' => new external_value(PARAM_TEXT, 'file name'), 'modified' => new external_value(PARAM_INT, 'timestamp to return files changed after this time.', VALUE_DEFAULT, null), 'contextlevel' => new external_value(PARAM_ALPHA, 'The context level for the file location.', VALUE_DEFAULT, null), 'instanceid' => new external_value(PARAM_INT, 'The instance id for where the file is located.', VALUE_DEFAULT, null) ) ); }
php
public static function get_files_parameters() { return new external_function_parameters( array( 'contextid' => new external_value(PARAM_INT, 'context id Set to -1 to use contextlevel and instanceid.'), 'component' => new external_value(PARAM_TEXT, 'component'), 'filearea' => new external_value(PARAM_TEXT, 'file area'), 'itemid' => new external_value(PARAM_INT, 'associated id'), 'filepath' => new external_value(PARAM_PATH, 'file path'), 'filename' => new external_value(PARAM_TEXT, 'file name'), 'modified' => new external_value(PARAM_INT, 'timestamp to return files changed after this time.', VALUE_DEFAULT, null), 'contextlevel' => new external_value(PARAM_ALPHA, 'The context level for the file location.', VALUE_DEFAULT, null), 'instanceid' => new external_value(PARAM_INT, 'The instance id for where the file is located.', VALUE_DEFAULT, null) ) ); }
[ "public", "static", "function", "get_files_parameters", "(", ")", "{", "return", "new", "external_function_parameters", "(", "array", "(", "'contextid'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'context id Set to -1 to use contextlevel and instanceid.'", ")", ",", "'component'", "=>", "new", "external_value", "(", "PARAM_TEXT", ",", "'component'", ")", ",", "'filearea'", "=>", "new", "external_value", "(", "PARAM_TEXT", ",", "'file area'", ")", ",", "'itemid'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'associated id'", ")", ",", "'filepath'", "=>", "new", "external_value", "(", "PARAM_PATH", ",", "'file path'", ")", ",", "'filename'", "=>", "new", "external_value", "(", "PARAM_TEXT", ",", "'file name'", ")", ",", "'modified'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'timestamp to return files changed after this time.'", ",", "VALUE_DEFAULT", ",", "null", ")", ",", "'contextlevel'", "=>", "new", "external_value", "(", "PARAM_ALPHA", ",", "'The context level for the file location.'", ",", "VALUE_DEFAULT", ",", "null", ")", ",", "'instanceid'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'The instance id for where the file is located.'", ",", "VALUE_DEFAULT", ",", "null", ")", ")", ")", ";", "}" ]
Returns description of get_files parameters @return external_function_parameters @since Moodle 2.2
[ "Returns", "description", "of", "get_files", "parameters" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/files/externallib.php#L49-L64
218,787
moodle/moodle
files/externallib.php
core_files_external.get_files_returns
public static function get_files_returns() { return new external_single_structure( array( 'parents' => new external_multiple_structure( new external_single_structure( array( 'contextid' => new external_value(PARAM_INT, ''), 'component' => new external_value(PARAM_COMPONENT, ''), 'filearea' => new external_value(PARAM_AREA, ''), 'itemid' => new external_value(PARAM_INT, ''), 'filepath' => new external_value(PARAM_TEXT, ''), 'filename' => new external_value(PARAM_TEXT, ''), ) ) ), 'files' => new external_multiple_structure( new external_single_structure( array( 'contextid' => new external_value(PARAM_INT, ''), 'component' => new external_value(PARAM_COMPONENT, ''), 'filearea' => new external_value(PARAM_AREA, ''), 'itemid' => new external_value(PARAM_INT, ''), 'filepath' => new external_value(PARAM_TEXT, ''), 'filename' => new external_value(PARAM_TEXT, ''), 'isdir' => new external_value(PARAM_BOOL, ''), 'url' => new external_value(PARAM_TEXT, ''), 'timemodified' => new external_value(PARAM_INT, ''), 'timecreated' => new external_value(PARAM_INT, 'Time created', VALUE_OPTIONAL), 'filesize' => new external_value(PARAM_INT, 'File size', VALUE_OPTIONAL), 'author' => new external_value(PARAM_TEXT, 'File owner', VALUE_OPTIONAL), 'license' => new external_value(PARAM_TEXT, 'File license', VALUE_OPTIONAL), ) ) ) ) ); }
php
public static function get_files_returns() { return new external_single_structure( array( 'parents' => new external_multiple_structure( new external_single_structure( array( 'contextid' => new external_value(PARAM_INT, ''), 'component' => new external_value(PARAM_COMPONENT, ''), 'filearea' => new external_value(PARAM_AREA, ''), 'itemid' => new external_value(PARAM_INT, ''), 'filepath' => new external_value(PARAM_TEXT, ''), 'filename' => new external_value(PARAM_TEXT, ''), ) ) ), 'files' => new external_multiple_structure( new external_single_structure( array( 'contextid' => new external_value(PARAM_INT, ''), 'component' => new external_value(PARAM_COMPONENT, ''), 'filearea' => new external_value(PARAM_AREA, ''), 'itemid' => new external_value(PARAM_INT, ''), 'filepath' => new external_value(PARAM_TEXT, ''), 'filename' => new external_value(PARAM_TEXT, ''), 'isdir' => new external_value(PARAM_BOOL, ''), 'url' => new external_value(PARAM_TEXT, ''), 'timemodified' => new external_value(PARAM_INT, ''), 'timecreated' => new external_value(PARAM_INT, 'Time created', VALUE_OPTIONAL), 'filesize' => new external_value(PARAM_INT, 'File size', VALUE_OPTIONAL), 'author' => new external_value(PARAM_TEXT, 'File owner', VALUE_OPTIONAL), 'license' => new external_value(PARAM_TEXT, 'File license', VALUE_OPTIONAL), ) ) ) ) ); }
[ "public", "static", "function", "get_files_returns", "(", ")", "{", "return", "new", "external_single_structure", "(", "array", "(", "'parents'", "=>", "new", "external_multiple_structure", "(", "new", "external_single_structure", "(", "array", "(", "'contextid'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "''", ")", ",", "'component'", "=>", "new", "external_value", "(", "PARAM_COMPONENT", ",", "''", ")", ",", "'filearea'", "=>", "new", "external_value", "(", "PARAM_AREA", ",", "''", ")", ",", "'itemid'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "''", ")", ",", "'filepath'", "=>", "new", "external_value", "(", "PARAM_TEXT", ",", "''", ")", ",", "'filename'", "=>", "new", "external_value", "(", "PARAM_TEXT", ",", "''", ")", ",", ")", ")", ")", ",", "'files'", "=>", "new", "external_multiple_structure", "(", "new", "external_single_structure", "(", "array", "(", "'contextid'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "''", ")", ",", "'component'", "=>", "new", "external_value", "(", "PARAM_COMPONENT", ",", "''", ")", ",", "'filearea'", "=>", "new", "external_value", "(", "PARAM_AREA", ",", "''", ")", ",", "'itemid'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "''", ")", ",", "'filepath'", "=>", "new", "external_value", "(", "PARAM_TEXT", ",", "''", ")", ",", "'filename'", "=>", "new", "external_value", "(", "PARAM_TEXT", ",", "''", ")", ",", "'isdir'", "=>", "new", "external_value", "(", "PARAM_BOOL", ",", "''", ")", ",", "'url'", "=>", "new", "external_value", "(", "PARAM_TEXT", ",", "''", ")", ",", "'timemodified'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "''", ")", ",", "'timecreated'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'Time created'", ",", "VALUE_OPTIONAL", ")", ",", "'filesize'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'File size'", ",", "VALUE_OPTIONAL", ")", ",", "'author'", "=>", "new", "external_value", "(", "PARAM_TEXT", ",", "'File owner'", ",", "VALUE_OPTIONAL", ")", ",", "'license'", "=>", "new", "external_value", "(", "PARAM_TEXT", ",", "'File license'", ",", "VALUE_OPTIONAL", ")", ",", ")", ")", ")", ")", ")", ";", "}" ]
Returns description of get_files returns @return external_single_structure @since Moodle 2.9 Returns additional fields for files (timecreated, filesize, author, license) @since Moodle 2.2
[ "Returns", "description", "of", "get_files", "returns" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/files/externallib.php#L199-L235
218,788
moodle/moodle
files/externallib.php
core_files_external.upload_parameters
public static function upload_parameters() { return new external_function_parameters( array( 'contextid' => new external_value(PARAM_INT, 'context id', VALUE_DEFAULT, null), 'component' => new external_value(PARAM_COMPONENT, 'component'), 'filearea' => new external_value(PARAM_AREA, 'file area'), 'itemid' => new external_value(PARAM_INT, 'associated id'), 'filepath' => new external_value(PARAM_PATH, 'file path'), 'filename' => new external_value(PARAM_FILE, 'file name'), 'filecontent' => new external_value(PARAM_TEXT, 'file content'), 'contextlevel' => new external_value(PARAM_ALPHA, 'The context level to put the file in, (block, course, coursecat, system, user, module)', VALUE_DEFAULT, null), 'instanceid' => new external_value(PARAM_INT, 'The Instance id of item associated with the context level', VALUE_DEFAULT, null) ) ); }
php
public static function upload_parameters() { return new external_function_parameters( array( 'contextid' => new external_value(PARAM_INT, 'context id', VALUE_DEFAULT, null), 'component' => new external_value(PARAM_COMPONENT, 'component'), 'filearea' => new external_value(PARAM_AREA, 'file area'), 'itemid' => new external_value(PARAM_INT, 'associated id'), 'filepath' => new external_value(PARAM_PATH, 'file path'), 'filename' => new external_value(PARAM_FILE, 'file name'), 'filecontent' => new external_value(PARAM_TEXT, 'file content'), 'contextlevel' => new external_value(PARAM_ALPHA, 'The context level to put the file in, (block, course, coursecat, system, user, module)', VALUE_DEFAULT, null), 'instanceid' => new external_value(PARAM_INT, 'The Instance id of item associated with the context level', VALUE_DEFAULT, null) ) ); }
[ "public", "static", "function", "upload_parameters", "(", ")", "{", "return", "new", "external_function_parameters", "(", "array", "(", "'contextid'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'context id'", ",", "VALUE_DEFAULT", ",", "null", ")", ",", "'component'", "=>", "new", "external_value", "(", "PARAM_COMPONENT", ",", "'component'", ")", ",", "'filearea'", "=>", "new", "external_value", "(", "PARAM_AREA", ",", "'file area'", ")", ",", "'itemid'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'associated id'", ")", ",", "'filepath'", "=>", "new", "external_value", "(", "PARAM_PATH", ",", "'file path'", ")", ",", "'filename'", "=>", "new", "external_value", "(", "PARAM_FILE", ",", "'file name'", ")", ",", "'filecontent'", "=>", "new", "external_value", "(", "PARAM_TEXT", ",", "'file content'", ")", ",", "'contextlevel'", "=>", "new", "external_value", "(", "PARAM_ALPHA", ",", "'The context level to put the file in,\n (block, course, coursecat, system, user, module)'", ",", "VALUE_DEFAULT", ",", "null", ")", ",", "'instanceid'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'The Instance id of item associated\n with the context level'", ",", "VALUE_DEFAULT", ",", "null", ")", ")", ")", ";", "}" ]
Returns description of upload parameters @return external_function_parameters @since Moodle 2.2
[ "Returns", "description", "of", "upload", "parameters" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/files/externallib.php#L243-L259
218,789
moodle/moodle
files/externallib.php
core_files_external.upload_returns
public static function upload_returns() { return new external_single_structure( array( 'contextid' => new external_value(PARAM_INT, ''), 'component' => new external_value(PARAM_COMPONENT, ''), 'filearea' => new external_value(PARAM_AREA, ''), 'itemid' => new external_value(PARAM_INT, ''), 'filepath' => new external_value(PARAM_TEXT, ''), 'filename' => new external_value(PARAM_FILE, ''), 'url' => new external_value(PARAM_TEXT, ''), ) ); }
php
public static function upload_returns() { return new external_single_structure( array( 'contextid' => new external_value(PARAM_INT, ''), 'component' => new external_value(PARAM_COMPONENT, ''), 'filearea' => new external_value(PARAM_AREA, ''), 'itemid' => new external_value(PARAM_INT, ''), 'filepath' => new external_value(PARAM_TEXT, ''), 'filename' => new external_value(PARAM_FILE, ''), 'url' => new external_value(PARAM_TEXT, ''), ) ); }
[ "public", "static", "function", "upload_returns", "(", ")", "{", "return", "new", "external_single_structure", "(", "array", "(", "'contextid'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "''", ")", ",", "'component'", "=>", "new", "external_value", "(", "PARAM_COMPONENT", ",", "''", ")", ",", "'filearea'", "=>", "new", "external_value", "(", "PARAM_AREA", ",", "''", ")", ",", "'itemid'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "''", ")", ",", "'filepath'", "=>", "new", "external_value", "(", "PARAM_TEXT", ",", "''", ")", ",", "'filename'", "=>", "new", "external_value", "(", "PARAM_FILE", ",", "''", ")", ",", "'url'", "=>", "new", "external_value", "(", "PARAM_TEXT", ",", "''", ")", ",", ")", ")", ";", "}" ]
Returns description of upload returns @return external_single_structure @since Moodle 2.2
[ "Returns", "description", "of", "upload", "returns" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/files/externallib.php#L376-L388
218,790
moodle/moodle
user/profile/field/checkbox/classes/privacy/provider.php
provider.get_records
protected static function get_records($userid) { global $DB; $sql = "SELECT * FROM {user_info_data} uda JOIN {user_info_field} uif ON uda.fieldid = uif.id WHERE uda.userid = :userid AND uif.datatype = :datatype"; $params = [ 'userid' => $userid, 'datatype' => 'checkbox' ]; return $DB->get_records_sql($sql, $params); }
php
protected static function get_records($userid) { global $DB; $sql = "SELECT * FROM {user_info_data} uda JOIN {user_info_field} uif ON uda.fieldid = uif.id WHERE uda.userid = :userid AND uif.datatype = :datatype"; $params = [ 'userid' => $userid, 'datatype' => 'checkbox' ]; return $DB->get_records_sql($sql, $params); }
[ "protected", "static", "function", "get_records", "(", "$", "userid", ")", "{", "global", "$", "DB", ";", "$", "sql", "=", "\"SELECT *\n FROM {user_info_data} uda\n JOIN {user_info_field} uif ON uda.fieldid = uif.id\n WHERE uda.userid = :userid\n AND uif.datatype = :datatype\"", ";", "$", "params", "=", "[", "'userid'", "=>", "$", "userid", ",", "'datatype'", "=>", "'checkbox'", "]", ";", "return", "$", "DB", "->", "get_records_sql", "(", "$", "sql", ",", "$", "params", ")", ";", "}" ]
Get records related to this plugin and user. @param int $userid The user ID @return array An array of records.
[ "Get", "records", "related", "to", "this", "plugin", "and", "user", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/user/profile/field/checkbox/classes/privacy/provider.php#L201-L215
218,791
moodle/moodle
mod/lesson/mod_form.php
mod_lesson_mod_form.data_preprocessing
public function data_preprocessing(&$defaultvalues) { if (isset($defaultvalues['conditions'])) { $conditions = unserialize($defaultvalues['conditions']); $defaultvalues['timespent'] = $conditions->timespent; $defaultvalues['completed'] = $conditions->completed; $defaultvalues['gradebetterthan'] = $conditions->gradebetterthan; } // Set up the completion checkbox which is not part of standard data. $defaultvalues['completiontimespentenabled'] = !empty($defaultvalues['completiontimespent']) ? 1 : 0; if ($this->current->instance) { // Editing existing instance - copy existing files into draft area. $draftitemid = file_get_submitted_draft_itemid('mediafile'); file_prepare_draft_area($draftitemid, $this->context->id, 'mod_lesson', 'mediafile', 0, array('subdirs'=>0, 'maxbytes' => $this->course->maxbytes, 'maxfiles' => 1)); $defaultvalues['mediafile'] = $draftitemid; } }
php
public function data_preprocessing(&$defaultvalues) { if (isset($defaultvalues['conditions'])) { $conditions = unserialize($defaultvalues['conditions']); $defaultvalues['timespent'] = $conditions->timespent; $defaultvalues['completed'] = $conditions->completed; $defaultvalues['gradebetterthan'] = $conditions->gradebetterthan; } // Set up the completion checkbox which is not part of standard data. $defaultvalues['completiontimespentenabled'] = !empty($defaultvalues['completiontimespent']) ? 1 : 0; if ($this->current->instance) { // Editing existing instance - copy existing files into draft area. $draftitemid = file_get_submitted_draft_itemid('mediafile'); file_prepare_draft_area($draftitemid, $this->context->id, 'mod_lesson', 'mediafile', 0, array('subdirs'=>0, 'maxbytes' => $this->course->maxbytes, 'maxfiles' => 1)); $defaultvalues['mediafile'] = $draftitemid; } }
[ "public", "function", "data_preprocessing", "(", "&", "$", "defaultvalues", ")", "{", "if", "(", "isset", "(", "$", "defaultvalues", "[", "'conditions'", "]", ")", ")", "{", "$", "conditions", "=", "unserialize", "(", "$", "defaultvalues", "[", "'conditions'", "]", ")", ";", "$", "defaultvalues", "[", "'timespent'", "]", "=", "$", "conditions", "->", "timespent", ";", "$", "defaultvalues", "[", "'completed'", "]", "=", "$", "conditions", "->", "completed", ";", "$", "defaultvalues", "[", "'gradebetterthan'", "]", "=", "$", "conditions", "->", "gradebetterthan", ";", "}", "// Set up the completion checkbox which is not part of standard data.", "$", "defaultvalues", "[", "'completiontimespentenabled'", "]", "=", "!", "empty", "(", "$", "defaultvalues", "[", "'completiontimespent'", "]", ")", "?", "1", ":", "0", ";", "if", "(", "$", "this", "->", "current", "->", "instance", ")", "{", "// Editing existing instance - copy existing files into draft area.", "$", "draftitemid", "=", "file_get_submitted_draft_itemid", "(", "'mediafile'", ")", ";", "file_prepare_draft_area", "(", "$", "draftitemid", ",", "$", "this", "->", "context", "->", "id", ",", "'mod_lesson'", ",", "'mediafile'", ",", "0", ",", "array", "(", "'subdirs'", "=>", "0", ",", "'maxbytes'", "=>", "$", "this", "->", "course", "->", "maxbytes", ",", "'maxfiles'", "=>", "1", ")", ")", ";", "$", "defaultvalues", "[", "'mediafile'", "]", "=", "$", "draftitemid", ";", "}", "}" ]
Enforce defaults here @param array $defaultvalues Form defaults @return void
[ "Enforce", "defaults", "here" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/lesson/mod_form.php#L359-L377
218,792
moodle/moodle
mod/lesson/renderer.php
mod_lesson_renderer.header
public function header($lesson, $cm, $currenttab = '', $extraeditbuttons = false, $lessonpageid = null, $extrapagetitle = null) { global $CFG; $activityname = format_string($lesson->name, true, $lesson->course); if (empty($extrapagetitle)) { $title = $this->page->course->shortname.": ".$activityname; } else { $title = $this->page->course->shortname.": ".$activityname.": ".$extrapagetitle; } // Build the buttons $context = context_module::instance($cm->id); /// Header setup $this->page->set_title($title); $this->page->set_heading($this->page->course->fullname); lesson_add_header_buttons($cm, $context, $extraeditbuttons, $lessonpageid); $output = $this->output->header(); if (has_capability('mod/lesson:manage', $context)) { $output .= $this->output->heading_with_help($activityname, 'overview', 'lesson'); if (!empty($currenttab)) { ob_start(); include($CFG->dirroot.'/mod/lesson/tabs.php'); $output .= ob_get_contents(); ob_end_clean(); } } else { $output .= $this->output->heading($activityname); } foreach ($lesson->messages as $message) { $output .= $this->output->notification($message[0], $message[1], $message[2]); } return $output; }
php
public function header($lesson, $cm, $currenttab = '', $extraeditbuttons = false, $lessonpageid = null, $extrapagetitle = null) { global $CFG; $activityname = format_string($lesson->name, true, $lesson->course); if (empty($extrapagetitle)) { $title = $this->page->course->shortname.": ".$activityname; } else { $title = $this->page->course->shortname.": ".$activityname.": ".$extrapagetitle; } // Build the buttons $context = context_module::instance($cm->id); /// Header setup $this->page->set_title($title); $this->page->set_heading($this->page->course->fullname); lesson_add_header_buttons($cm, $context, $extraeditbuttons, $lessonpageid); $output = $this->output->header(); if (has_capability('mod/lesson:manage', $context)) { $output .= $this->output->heading_with_help($activityname, 'overview', 'lesson'); if (!empty($currenttab)) { ob_start(); include($CFG->dirroot.'/mod/lesson/tabs.php'); $output .= ob_get_contents(); ob_end_clean(); } } else { $output .= $this->output->heading($activityname); } foreach ($lesson->messages as $message) { $output .= $this->output->notification($message[0], $message[1], $message[2]); } return $output; }
[ "public", "function", "header", "(", "$", "lesson", ",", "$", "cm", ",", "$", "currenttab", "=", "''", ",", "$", "extraeditbuttons", "=", "false", ",", "$", "lessonpageid", "=", "null", ",", "$", "extrapagetitle", "=", "null", ")", "{", "global", "$", "CFG", ";", "$", "activityname", "=", "format_string", "(", "$", "lesson", "->", "name", ",", "true", ",", "$", "lesson", "->", "course", ")", ";", "if", "(", "empty", "(", "$", "extrapagetitle", ")", ")", "{", "$", "title", "=", "$", "this", "->", "page", "->", "course", "->", "shortname", ".", "\": \"", ".", "$", "activityname", ";", "}", "else", "{", "$", "title", "=", "$", "this", "->", "page", "->", "course", "->", "shortname", ".", "\": \"", ".", "$", "activityname", ".", "\": \"", ".", "$", "extrapagetitle", ";", "}", "// Build the buttons", "$", "context", "=", "context_module", "::", "instance", "(", "$", "cm", "->", "id", ")", ";", "/// Header setup", "$", "this", "->", "page", "->", "set_title", "(", "$", "title", ")", ";", "$", "this", "->", "page", "->", "set_heading", "(", "$", "this", "->", "page", "->", "course", "->", "fullname", ")", ";", "lesson_add_header_buttons", "(", "$", "cm", ",", "$", "context", ",", "$", "extraeditbuttons", ",", "$", "lessonpageid", ")", ";", "$", "output", "=", "$", "this", "->", "output", "->", "header", "(", ")", ";", "if", "(", "has_capability", "(", "'mod/lesson:manage'", ",", "$", "context", ")", ")", "{", "$", "output", ".=", "$", "this", "->", "output", "->", "heading_with_help", "(", "$", "activityname", ",", "'overview'", ",", "'lesson'", ")", ";", "if", "(", "!", "empty", "(", "$", "currenttab", ")", ")", "{", "ob_start", "(", ")", ";", "include", "(", "$", "CFG", "->", "dirroot", ".", "'/mod/lesson/tabs.php'", ")", ";", "$", "output", ".=", "ob_get_contents", "(", ")", ";", "ob_end_clean", "(", ")", ";", "}", "}", "else", "{", "$", "output", ".=", "$", "this", "->", "output", "->", "heading", "(", "$", "activityname", ")", ";", "}", "foreach", "(", "$", "lesson", "->", "messages", "as", "$", "message", ")", "{", "$", "output", ".=", "$", "this", "->", "output", "->", "notification", "(", "$", "message", "[", "0", "]", ",", "$", "message", "[", "1", "]", ",", "$", "message", "[", "2", "]", ")", ";", "}", "return", "$", "output", ";", "}" ]
Returns the header for the lesson module @param lesson $lesson a lesson object. @param string $currenttab current tab that is shown. @param bool $extraeditbuttons if extra edit buttons should be displayed. @param int $lessonpageid id of the lesson page that needs to be displayed. @param string $extrapagetitle String to appent to the page title. @return string
[ "Returns", "the", "header", "for", "the", "lesson", "module" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/lesson/renderer.php#L39-L76
218,793
moodle/moodle
mod/lesson/renderer.php
mod_lesson_renderer.lesson_inaccessible
public function lesson_inaccessible($message) { global $CFG; $output = $this->output->box_start('generalbox boxaligncenter'); $output .= $this->output->box_start('center'); $output .= $message; $output .= $this->output->box('<a href="'.$CFG->wwwroot.'/course/view.php?id='. $this->page->course->id .'">'. get_string('returnto', 'lesson', format_string($this->page->course->fullname, true)) .'</a>', 'lessonbutton standardbutton'); $output .= $this->output->box_end(); $output .= $this->output->box_end(); return $output; }
php
public function lesson_inaccessible($message) { global $CFG; $output = $this->output->box_start('generalbox boxaligncenter'); $output .= $this->output->box_start('center'); $output .= $message; $output .= $this->output->box('<a href="'.$CFG->wwwroot.'/course/view.php?id='. $this->page->course->id .'">'. get_string('returnto', 'lesson', format_string($this->page->course->fullname, true)) .'</a>', 'lessonbutton standardbutton'); $output .= $this->output->box_end(); $output .= $this->output->box_end(); return $output; }
[ "public", "function", "lesson_inaccessible", "(", "$", "message", ")", "{", "global", "$", "CFG", ";", "$", "output", "=", "$", "this", "->", "output", "->", "box_start", "(", "'generalbox boxaligncenter'", ")", ";", "$", "output", ".=", "$", "this", "->", "output", "->", "box_start", "(", "'center'", ")", ";", "$", "output", ".=", "$", "message", ";", "$", "output", ".=", "$", "this", "->", "output", "->", "box", "(", "'<a href=\"'", ".", "$", "CFG", "->", "wwwroot", ".", "'/course/view.php?id='", ".", "$", "this", "->", "page", "->", "course", "->", "id", ".", "'\">'", ".", "get_string", "(", "'returnto'", ",", "'lesson'", ",", "format_string", "(", "$", "this", "->", "page", "->", "course", "->", "fullname", ",", "true", ")", ")", ".", "'</a>'", ",", "'lessonbutton standardbutton'", ")", ";", "$", "output", ".=", "$", "this", "->", "output", "->", "box_end", "(", ")", ";", "$", "output", ".=", "$", "this", "->", "output", "->", "box_end", "(", ")", ";", "return", "$", "output", ";", "}" ]
Returns HTML for a lesson inaccessible message @param string $message @return <type>
[ "Returns", "HTML", "for", "a", "lesson", "inaccessible", "message" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/lesson/renderer.php#L92-L101
218,794
moodle/moodle
mod/lesson/renderer.php
mod_lesson_renderer.login_prompt
public function login_prompt(lesson $lesson, $failedattempt = false) { global $CFG; $output = $this->output->box_start('password-form'); $output .= $this->output->box_start('generalbox boxaligncenter'); $output .= '<form id="password" method="post" action="'.$CFG->wwwroot.'/mod/lesson/view.php" autocomplete="off">'; $output .= '<fieldset class="invisiblefieldset center">'; $output .= '<input type="hidden" name="id" value="'. $this->page->cm->id .'" />'; $output .= '<input type="hidden" name="sesskey" value="'.sesskey().'" />'; if ($failedattempt) { $output .= $this->output->notification(get_string('loginfail', 'lesson')); } $output .= get_string('passwordprotectedlesson', 'lesson', format_string($lesson->name)).'<br /><br />'; $output .= get_string('enterpassword', 'lesson')." <input type=\"password\" name=\"userpassword\" /><br /><br />"; $output .= "<div class='lessonbutton standardbutton submitbutton'><input type='submit' value='".get_string('continue', 'lesson')."' /></div>"; $output .= " <div class='lessonbutton standardbutton submitbutton'><input type='submit' name='backtocourse' value='".get_string('cancel', 'lesson')."' /></div>"; $output .= '</fieldset></form>'; $output .= $this->output->box_end(); $output .= $this->output->box_end(); return $output; }
php
public function login_prompt(lesson $lesson, $failedattempt = false) { global $CFG; $output = $this->output->box_start('password-form'); $output .= $this->output->box_start('generalbox boxaligncenter'); $output .= '<form id="password" method="post" action="'.$CFG->wwwroot.'/mod/lesson/view.php" autocomplete="off">'; $output .= '<fieldset class="invisiblefieldset center">'; $output .= '<input type="hidden" name="id" value="'. $this->page->cm->id .'" />'; $output .= '<input type="hidden" name="sesskey" value="'.sesskey().'" />'; if ($failedattempt) { $output .= $this->output->notification(get_string('loginfail', 'lesson')); } $output .= get_string('passwordprotectedlesson', 'lesson', format_string($lesson->name)).'<br /><br />'; $output .= get_string('enterpassword', 'lesson')." <input type=\"password\" name=\"userpassword\" /><br /><br />"; $output .= "<div class='lessonbutton standardbutton submitbutton'><input type='submit' value='".get_string('continue', 'lesson')."' /></div>"; $output .= " <div class='lessonbutton standardbutton submitbutton'><input type='submit' name='backtocourse' value='".get_string('cancel', 'lesson')."' /></div>"; $output .= '</fieldset></form>'; $output .= $this->output->box_end(); $output .= $this->output->box_end(); return $output; }
[ "public", "function", "login_prompt", "(", "lesson", "$", "lesson", ",", "$", "failedattempt", "=", "false", ")", "{", "global", "$", "CFG", ";", "$", "output", "=", "$", "this", "->", "output", "->", "box_start", "(", "'password-form'", ")", ";", "$", "output", ".=", "$", "this", "->", "output", "->", "box_start", "(", "'generalbox boxaligncenter'", ")", ";", "$", "output", ".=", "'<form id=\"password\" method=\"post\" action=\"'", ".", "$", "CFG", "->", "wwwroot", ".", "'/mod/lesson/view.php\" autocomplete=\"off\">'", ";", "$", "output", ".=", "'<fieldset class=\"invisiblefieldset center\">'", ";", "$", "output", ".=", "'<input type=\"hidden\" name=\"id\" value=\"'", ".", "$", "this", "->", "page", "->", "cm", "->", "id", ".", "'\" />'", ";", "$", "output", ".=", "'<input type=\"hidden\" name=\"sesskey\" value=\"'", ".", "sesskey", "(", ")", ".", "'\" />'", ";", "if", "(", "$", "failedattempt", ")", "{", "$", "output", ".=", "$", "this", "->", "output", "->", "notification", "(", "get_string", "(", "'loginfail'", ",", "'lesson'", ")", ")", ";", "}", "$", "output", ".=", "get_string", "(", "'passwordprotectedlesson'", ",", "'lesson'", ",", "format_string", "(", "$", "lesson", "->", "name", ")", ")", ".", "'<br /><br />'", ";", "$", "output", ".=", "get_string", "(", "'enterpassword'", ",", "'lesson'", ")", ".", "\" <input type=\\\"password\\\" name=\\\"userpassword\\\" /><br /><br />\"", ";", "$", "output", ".=", "\"<div class='lessonbutton standardbutton submitbutton'><input type='submit' value='\"", ".", "get_string", "(", "'continue'", ",", "'lesson'", ")", ".", "\"' /></div>\"", ";", "$", "output", ".=", "\" <div class='lessonbutton standardbutton submitbutton'><input type='submit' name='backtocourse' value='\"", ".", "get_string", "(", "'cancel'", ",", "'lesson'", ")", ".", "\"' /></div>\"", ";", "$", "output", ".=", "'</fieldset></form>'", ";", "$", "output", ".=", "$", "this", "->", "output", "->", "box_end", "(", ")", ";", "$", "output", ".=", "$", "this", "->", "output", "->", "box_end", "(", ")", ";", "return", "$", "output", ";", "}" ]
Returns HTML to prompt the user to log in @param lesson $lesson @param bool $failedattempt @return string
[ "Returns", "HTML", "to", "prompt", "the", "user", "to", "log", "in" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/lesson/renderer.php#L109-L128
218,795
moodle/moodle
mod/lesson/renderer.php
mod_lesson_renderer.dependancy_errors
public function dependancy_errors($dependentlesson, $errors) { $output = $this->output->box_start('generalbox boxaligncenter'); $output .= get_string('completethefollowingconditions', 'lesson', $dependentlesson->name); $output .= $this->output->box(implode('<br />'.get_string('and', 'lesson').'<br />', $errors),'center'); $output .= $this->output->box_end(); return $output; }
php
public function dependancy_errors($dependentlesson, $errors) { $output = $this->output->box_start('generalbox boxaligncenter'); $output .= get_string('completethefollowingconditions', 'lesson', $dependentlesson->name); $output .= $this->output->box(implode('<br />'.get_string('and', 'lesson').'<br />', $errors),'center'); $output .= $this->output->box_end(); return $output; }
[ "public", "function", "dependancy_errors", "(", "$", "dependentlesson", ",", "$", "errors", ")", "{", "$", "output", "=", "$", "this", "->", "output", "->", "box_start", "(", "'generalbox boxaligncenter'", ")", ";", "$", "output", ".=", "get_string", "(", "'completethefollowingconditions'", ",", "'lesson'", ",", "$", "dependentlesson", "->", "name", ")", ";", "$", "output", ".=", "$", "this", "->", "output", "->", "box", "(", "implode", "(", "'<br />'", ".", "get_string", "(", "'and'", ",", "'lesson'", ")", ".", "'<br />'", ",", "$", "errors", ")", ",", "'center'", ")", ";", "$", "output", ".=", "$", "this", "->", "output", "->", "box_end", "(", ")", ";", "return", "$", "output", ";", "}" ]
Returns HTML to display dependancy errors @param object $dependentlesson @param array $errors @return string
[ "Returns", "HTML", "to", "display", "dependancy", "errors" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/lesson/renderer.php#L137-L143
218,796
moodle/moodle
mod/lesson/renderer.php
mod_lesson_renderer.message
public function message($message, single_button $button = null) { $output = $this->output->box_start('generalbox boxaligncenter'); $output .= $message; if ($button !== null) { $output .= $this->output->box($this->output->render($button), 'lessonbutton standardbutton'); } $output .= $this->output->box_end(); return $output; }
php
public function message($message, single_button $button = null) { $output = $this->output->box_start('generalbox boxaligncenter'); $output .= $message; if ($button !== null) { $output .= $this->output->box($this->output->render($button), 'lessonbutton standardbutton'); } $output .= $this->output->box_end(); return $output; }
[ "public", "function", "message", "(", "$", "message", ",", "single_button", "$", "button", "=", "null", ")", "{", "$", "output", "=", "$", "this", "->", "output", "->", "box_start", "(", "'generalbox boxaligncenter'", ")", ";", "$", "output", ".=", "$", "message", ";", "if", "(", "$", "button", "!==", "null", ")", "{", "$", "output", ".=", "$", "this", "->", "output", "->", "box", "(", "$", "this", "->", "output", "->", "render", "(", "$", "button", ")", ",", "'lessonbutton standardbutton'", ")", ";", "}", "$", "output", ".=", "$", "this", "->", "output", "->", "box_end", "(", ")", ";", "return", "$", "output", ";", "}" ]
Returns HTML to display a message @param string $message @param single_button $button @return string
[ "Returns", "HTML", "to", "display", "a", "message" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/lesson/renderer.php#L151-L159
218,797
moodle/moodle
mod/lesson/renderer.php
mod_lesson_renderer.continue_links
public function continue_links(lesson $lesson, $lastpageseenid) { global $CFG; $output = $this->output->box(get_string('youhaveseen','lesson'), 'generalbox boxaligncenter'); $output .= $this->output->box_start('center'); $yeslink = html_writer::link(new moodle_url('/mod/lesson/view.php', array('id' => $this->page->cm->id, 'pageid' => $lastpageseenid, 'startlastseen' => 'yes')), get_string('yes'), array('class' => 'btn btn-primary')); $output .= html_writer::tag('span', $yeslink, array('class'=>'lessonbutton standardbutton')); $output .= '&nbsp;'; $nolink = html_writer::link(new moodle_url('/mod/lesson/view.php', array('id' => $this->page->cm->id, 'pageid' => $lesson->firstpageid, 'startlastseen' => 'no')), get_string('no'), array('class' => 'btn btn-secondary')); $output .= html_writer::tag('span', $nolink, array('class'=>'lessonbutton standardbutton')); $output .= $this->output->box_end(); return $output; }
php
public function continue_links(lesson $lesson, $lastpageseenid) { global $CFG; $output = $this->output->box(get_string('youhaveseen','lesson'), 'generalbox boxaligncenter'); $output .= $this->output->box_start('center'); $yeslink = html_writer::link(new moodle_url('/mod/lesson/view.php', array('id' => $this->page->cm->id, 'pageid' => $lastpageseenid, 'startlastseen' => 'yes')), get_string('yes'), array('class' => 'btn btn-primary')); $output .= html_writer::tag('span', $yeslink, array('class'=>'lessonbutton standardbutton')); $output .= '&nbsp;'; $nolink = html_writer::link(new moodle_url('/mod/lesson/view.php', array('id' => $this->page->cm->id, 'pageid' => $lesson->firstpageid, 'startlastseen' => 'no')), get_string('no'), array('class' => 'btn btn-secondary')); $output .= html_writer::tag('span', $nolink, array('class'=>'lessonbutton standardbutton')); $output .= $this->output->box_end(); return $output; }
[ "public", "function", "continue_links", "(", "lesson", "$", "lesson", ",", "$", "lastpageseenid", ")", "{", "global", "$", "CFG", ";", "$", "output", "=", "$", "this", "->", "output", "->", "box", "(", "get_string", "(", "'youhaveseen'", ",", "'lesson'", ")", ",", "'generalbox boxaligncenter'", ")", ";", "$", "output", ".=", "$", "this", "->", "output", "->", "box_start", "(", "'center'", ")", ";", "$", "yeslink", "=", "html_writer", "::", "link", "(", "new", "moodle_url", "(", "'/mod/lesson/view.php'", ",", "array", "(", "'id'", "=>", "$", "this", "->", "page", "->", "cm", "->", "id", ",", "'pageid'", "=>", "$", "lastpageseenid", ",", "'startlastseen'", "=>", "'yes'", ")", ")", ",", "get_string", "(", "'yes'", ")", ",", "array", "(", "'class'", "=>", "'btn btn-primary'", ")", ")", ";", "$", "output", ".=", "html_writer", "::", "tag", "(", "'span'", ",", "$", "yeslink", ",", "array", "(", "'class'", "=>", "'lessonbutton standardbutton'", ")", ")", ";", "$", "output", ".=", "'&nbsp;'", ";", "$", "nolink", "=", "html_writer", "::", "link", "(", "new", "moodle_url", "(", "'/mod/lesson/view.php'", ",", "array", "(", "'id'", "=>", "$", "this", "->", "page", "->", "cm", "->", "id", ",", "'pageid'", "=>", "$", "lesson", "->", "firstpageid", ",", "'startlastseen'", "=>", "'no'", ")", ")", ",", "get_string", "(", "'no'", ")", ",", "array", "(", "'class'", "=>", "'btn btn-secondary'", ")", ")", ";", "$", "output", ".=", "html_writer", "::", "tag", "(", "'span'", ",", "$", "nolink", ",", "array", "(", "'class'", "=>", "'lessonbutton standardbutton'", ")", ")", ";", "$", "output", ".=", "$", "this", "->", "output", "->", "box_end", "(", ")", ";", "return", "$", "output", ";", "}" ]
Returns HTML to display a continue button @param lesson $lesson @param int $lastpageseen @return string
[ "Returns", "HTML", "to", "display", "a", "continue", "button" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/lesson/renderer.php#L167-L183
218,798
moodle/moodle
mod/lesson/renderer.php
mod_lesson_renderer.display_page
public function display_page(lesson $lesson, lesson_page $page, $attempt) { // We need to buffer here as there is an mforms display call ob_start(); echo $page->display($this, $attempt); $output = ob_get_contents(); ob_end_clean(); return $output; }
php
public function display_page(lesson $lesson, lesson_page $page, $attempt) { // We need to buffer here as there is an mforms display call ob_start(); echo $page->display($this, $attempt); $output = ob_get_contents(); ob_end_clean(); return $output; }
[ "public", "function", "display_page", "(", "lesson", "$", "lesson", ",", "lesson_page", "$", "page", ",", "$", "attempt", ")", "{", "// We need to buffer here as there is an mforms display call", "ob_start", "(", ")", ";", "echo", "$", "page", "->", "display", "(", "$", "this", ",", "$", "attempt", ")", ";", "$", "output", "=", "ob_get_contents", "(", ")", ";", "ob_end_clean", "(", ")", ";", "return", "$", "output", ";", "}" ]
Returns HTML to display a page to the user @param lesson $lesson @param lesson_page $page @param object $attempt @return string
[ "Returns", "HTML", "to", "display", "a", "page", "to", "the", "user" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/lesson/renderer.php#L192-L199
218,799
moodle/moodle
mod/lesson/renderer.php
mod_lesson_renderer.display_edit_collapsed
public function display_edit_collapsed(lesson $lesson, $pageid) { global $DB, $CFG; $manager = lesson_page_type_manager::get($lesson); $qtypes = $manager->get_page_type_strings(); $npages = count($lesson->load_all_pages()); $table = new html_table(); $table->head = array(get_string('pagetitle', 'lesson'), get_string('qtype', 'lesson'), get_string('jumps', 'lesson'), get_string('actions', 'lesson')); $table->align = array('left', 'left', 'left', 'center'); $table->wrap = array('', 'nowrap', '', 'nowrap'); $table->tablealign = 'center'; $table->cellspacing = 0; $table->cellpadding = '2px'; $table->width = '80%'; $table->data = array(); $canedit = has_capability('mod/lesson:edit', context_module::instance($this->page->cm->id)); while ($pageid != 0) { $page = $lesson->load_page($pageid); $data = array(); $url = new moodle_url('/mod/lesson/edit.php', array( 'id' => $this->page->cm->id, 'mode' => 'single', 'pageid' => $page->id )); $data[] = html_writer::link($url, format_string($page->title, true), array('id' => 'lesson-' . $page->id)); $data[] = $qtypes[$page->qtype]; $data[] = implode("<br />\n", $page->jumps); if ($canedit) { $data[] = $this->page_action_links($page, $npages, true); } else { $data[] = ''; } $table->data[] = $data; $pageid = $page->nextpageid; } return html_writer::table($table); }
php
public function display_edit_collapsed(lesson $lesson, $pageid) { global $DB, $CFG; $manager = lesson_page_type_manager::get($lesson); $qtypes = $manager->get_page_type_strings(); $npages = count($lesson->load_all_pages()); $table = new html_table(); $table->head = array(get_string('pagetitle', 'lesson'), get_string('qtype', 'lesson'), get_string('jumps', 'lesson'), get_string('actions', 'lesson')); $table->align = array('left', 'left', 'left', 'center'); $table->wrap = array('', 'nowrap', '', 'nowrap'); $table->tablealign = 'center'; $table->cellspacing = 0; $table->cellpadding = '2px'; $table->width = '80%'; $table->data = array(); $canedit = has_capability('mod/lesson:edit', context_module::instance($this->page->cm->id)); while ($pageid != 0) { $page = $lesson->load_page($pageid); $data = array(); $url = new moodle_url('/mod/lesson/edit.php', array( 'id' => $this->page->cm->id, 'mode' => 'single', 'pageid' => $page->id )); $data[] = html_writer::link($url, format_string($page->title, true), array('id' => 'lesson-' . $page->id)); $data[] = $qtypes[$page->qtype]; $data[] = implode("<br />\n", $page->jumps); if ($canedit) { $data[] = $this->page_action_links($page, $npages, true); } else { $data[] = ''; } $table->data[] = $data; $pageid = $page->nextpageid; } return html_writer::table($table); }
[ "public", "function", "display_edit_collapsed", "(", "lesson", "$", "lesson", ",", "$", "pageid", ")", "{", "global", "$", "DB", ",", "$", "CFG", ";", "$", "manager", "=", "lesson_page_type_manager", "::", "get", "(", "$", "lesson", ")", ";", "$", "qtypes", "=", "$", "manager", "->", "get_page_type_strings", "(", ")", ";", "$", "npages", "=", "count", "(", "$", "lesson", "->", "load_all_pages", "(", ")", ")", ";", "$", "table", "=", "new", "html_table", "(", ")", ";", "$", "table", "->", "head", "=", "array", "(", "get_string", "(", "'pagetitle'", ",", "'lesson'", ")", ",", "get_string", "(", "'qtype'", ",", "'lesson'", ")", ",", "get_string", "(", "'jumps'", ",", "'lesson'", ")", ",", "get_string", "(", "'actions'", ",", "'lesson'", ")", ")", ";", "$", "table", "->", "align", "=", "array", "(", "'left'", ",", "'left'", ",", "'left'", ",", "'center'", ")", ";", "$", "table", "->", "wrap", "=", "array", "(", "''", ",", "'nowrap'", ",", "''", ",", "'nowrap'", ")", ";", "$", "table", "->", "tablealign", "=", "'center'", ";", "$", "table", "->", "cellspacing", "=", "0", ";", "$", "table", "->", "cellpadding", "=", "'2px'", ";", "$", "table", "->", "width", "=", "'80%'", ";", "$", "table", "->", "data", "=", "array", "(", ")", ";", "$", "canedit", "=", "has_capability", "(", "'mod/lesson:edit'", ",", "context_module", "::", "instance", "(", "$", "this", "->", "page", "->", "cm", "->", "id", ")", ")", ";", "while", "(", "$", "pageid", "!=", "0", ")", "{", "$", "page", "=", "$", "lesson", "->", "load_page", "(", "$", "pageid", ")", ";", "$", "data", "=", "array", "(", ")", ";", "$", "url", "=", "new", "moodle_url", "(", "'/mod/lesson/edit.php'", ",", "array", "(", "'id'", "=>", "$", "this", "->", "page", "->", "cm", "->", "id", ",", "'mode'", "=>", "'single'", ",", "'pageid'", "=>", "$", "page", "->", "id", ")", ")", ";", "$", "data", "[", "]", "=", "html_writer", "::", "link", "(", "$", "url", ",", "format_string", "(", "$", "page", "->", "title", ",", "true", ")", ",", "array", "(", "'id'", "=>", "'lesson-'", ".", "$", "page", "->", "id", ")", ")", ";", "$", "data", "[", "]", "=", "$", "qtypes", "[", "$", "page", "->", "qtype", "]", ";", "$", "data", "[", "]", "=", "implode", "(", "\"<br />\\n\"", ",", "$", "page", "->", "jumps", ")", ";", "if", "(", "$", "canedit", ")", "{", "$", "data", "[", "]", "=", "$", "this", "->", "page_action_links", "(", "$", "page", ",", "$", "npages", ",", "true", ")", ";", "}", "else", "{", "$", "data", "[", "]", "=", "''", ";", "}", "$", "table", "->", "data", "[", "]", "=", "$", "data", ";", "$", "pageid", "=", "$", "page", "->", "nextpageid", ";", "}", "return", "html_writer", "::", "table", "(", "$", "table", ")", ";", "}" ]
Returns HTML to display a collapsed edit form @param lesson $lesson @param int $pageid @return string
[ "Returns", "HTML", "to", "display", "a", "collapsed", "edit", "form" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/lesson/renderer.php#L208-L248