Skip to content

Commit

Permalink
MDL-57273 persistent: Some more magic __call conversions
Browse files Browse the repository at this point in the history
I missed all the entry pages when converting from set_abc() and get_abc() to set('abc', ) and get('abc').

Also fixed a wrong namespace for core_competency\external\performance_helper
  • Loading branch information
Damyon Wiese committed Jan 24, 2017
1 parent e97e961 commit 0ce135f
Show file tree
Hide file tree
Showing 19 changed files with 32 additions and 32 deletions.
6 changes: 3 additions & 3 deletions admin/tool/lp/competencies.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,18 @@
}

$title = get_string('competencies', 'core_competency');
$pagetitle = get_string('competenciesforframework', 'tool_lp', $framework->get_shortname());
$pagetitle = get_string('competenciesforframework', 'tool_lp', $framework->get('shortname'));

// Set up the page.
$url = new moodle_url("/admin/tool/lp/competencies.php", array('competencyframeworkid' => $framework->get_id(),
$url = new moodle_url("/admin/tool/lp/competencies.php", array('competencyframeworkid' => $framework->get('id'),
'pagecontextid' => $pagecontextid));
$frameworksurl = new moodle_url('/admin/tool/lp/competencyframeworks.php', array('pagecontextid' => $pagecontextid));

$PAGE->navigation->override_active_url($frameworksurl);
$PAGE->set_context($pagecontext);
$PAGE->set_pagelayout('admin');
$PAGE->set_url($url);
$PAGE->navbar->add($framework->get_shortname(), $url);
$PAGE->navbar->add($framework->get('shortname'), $url);
$PAGE->set_title($title);
$PAGE->set_heading($title);
$output = $PAGE->get_renderer('tool_lp');
Expand Down
2 changes: 1 addition & 1 deletion admin/tool/lp/editcompetency.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
// Get page URL.
$urloptions = [
'id' => $id,
'competencyframeworkid' => $competencyframework->get_id(),
'competencyframeworkid' => $competencyframework->get('id'),
'parentid' => $parentid,
'pagecontextid' => $pagecontextid
];
Expand Down
2 changes: 1 addition & 1 deletion admin/tool/lp/editcompetencyframework.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
$framework = \core_competency\api::create_framework($data);
$frameworkmanageurl = new moodle_url('/admin/tool/lp/competencies.php', array(
'pagecontextid' => $pagecontextid,
'competencyframeworkid' => $framework->get_id()
'competencyframeworkid' => $framework->get('id')
));
$messagesuccess = get_string('competencyframeworkcreated', 'tool_lp');
redirect($frameworkmanageurl, $messagesuccess, 0, \core\output\notification::NOTIFY_SUCCESS);
Expand Down
4 changes: 2 additions & 2 deletions admin/tool/lp/editplan.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
$plan = \core_competency\api::read_plan($id);

// The userid parameter must be the same as the owner of the plan.
if ($userid != $plan->get_userid()) {
if ($userid != $plan->get('userid')) {
throw new coding_exception('Inconsistency between the userid parameter and the userid of the plan');
}

Expand Down Expand Up @@ -81,7 +81,7 @@
if ($data) {
if (empty($data->id)) {
$plan = \core_competency\api::create_plan($data);
$returnurl = new moodle_url('/admin/tool/lp/plan.php', ['id' => $plan->get_id()]);
$returnurl = new moodle_url('/admin/tool/lp/plan.php', ['id' => $plan->get('id')]);
$returnmsg = get_string('plancreated', 'tool_lp');
} else {
\core_competency\api::update_plan($data);
Expand Down
2 changes: 1 addition & 1 deletion admin/tool/lp/edittemplate.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
if (empty($data->id)) {
$template = \core_competency\api::create_template($data);
$returnurl = new moodle_url('/admin/tool/lp/templatecompetencies.php', [
'templateid' => $template->get_id(),
'templateid' => $template->get('id'),
'pagecontextid' => $pagecontextid
]);
$returnmsg = get_string('templatecreated', 'tool_lp');
Expand Down
2 changes: 1 addition & 1 deletion admin/tool/lp/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ function tool_lp_coursemodule_edit_post_actions($data, $course) {

$existingids = array();
foreach ($existing as $cmc) {
array_push($existingids, $cmc->get_competencyid());
array_push($existingids, $cmc->get('competencyid'));
}

$newids = isset($data->competencies) ? $data->competencies : array();
Expand Down
2 changes: 1 addition & 1 deletion admin/tool/lp/plan.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
$plan = \core_competency\api::read_plan($id);
$url = new moodle_url('/admin/tool/lp/plan.php', array('id' => $id));

list($title, $subtitle) = \tool_lp\page_helper::setup_for_plan($plan->get_userid(), $url, $plan);
list($title, $subtitle) = \tool_lp\page_helper::setup_for_plan($plan->get('userid'), $url, $plan);

$output = $PAGE->get_renderer('tool_lp');
echo $output->header();
Expand Down
8 changes: 4 additions & 4 deletions admin/tool/lp/template_cohorts.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
$context = $template->get_context();
$canreadtemplate = $template->can_read();
$canmanagetemplate = $template->can_manage();
$duedatereached = $template->get_duedate() > 0 && $template->get_duedate() < time();
$duedatereached = $template->get('duedate') > 0 && $template->get('duedate') < time();

if (!$canreadtemplate) {
throw new required_capability_exception($context, 'moodle/competency:templateview', 'nopermissions', '');
Expand Down Expand Up @@ -65,10 +65,10 @@
$relation = \core_competency\api::create_template_cohort($template, $cohortid);

// Create a plan for each member if template visible, and the due date is not reached, and we didn't reach our limit yet.
if ($template->get_visible() && $i < $maxtocreate && !$duedatereached) {
if ($template->get('visible') && $i < $maxtocreate && !$duedatereached) {

// Only create a few plans right now.
$tocreate = \core_competency\template_cohort::get_missing_plans($template->get_id(), $cohortid);
$tocreate = \core_competency\template_cohort::get_missing_plans($template->get('id'), $cohortid);
if ($i + count($tocreate) <= $maxtocreate) {
$i += \core_competency\api::create_plans_from_template_cohort($template, $cohortid);
} else {
Expand All @@ -94,7 +94,7 @@
echo $output->heading($title);
echo $output->heading($subtitle, 3);
if ($canmanagetemplate) {
if ($template->get_visible() == false) {
if ($template->get('visible') == false) {
// Display message to prevent that cohort will not be synchronzed if the template is hidden.
echo $output->notify_message(get_string('templatecohortnotsyncedwhilehidden', 'tool_lp'));
} else if ($duedatereached) {
Expand Down
6 changes: 3 additions & 3 deletions admin/tool/lp/template_plans.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
if ($canmanagetemplate && ($data = $form->get_data()) && !empty($data->users)) {
$i = 0;
foreach ($data->users as $userid) {
$result = \core_competency\api::create_plan_from_template($template->get_id(), $userid);
$result = \core_competency\api::create_plan_from_template($template->get('id'), $userid);
if ($result) {
$i++;
}
Expand All @@ -74,10 +74,10 @@

// Do not display form when the template is hidden.
if ($canmanagetemplate) {
if (!$template->get_visible()) {
if (!$template->get('visible')) {
// Display message that plan can not be created if the template is hidden.
echo $output->notify_message(get_string('cannotcreateuserplanswhentemplatehidden', 'tool_lp'));
} else if ($template->get_duedate() > 0 && $template->get_duedate() < time() + 900) {
} else if ($template->get('duedate') > 0 && $template->get('duedate') < time() + 900) {
// Prevent the user from creating plans when the due date is passed, or in less than 15 minutes.
echo $output->notify_message(get_string('cannotcreateuserplanswhentemplateduedateispassed', 'tool_lp'));
} else {
Expand Down
2 changes: 1 addition & 1 deletion admin/tool/lp/templatecompetencies.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
\core_competency\api::template_viewed($template);

// Set up the page.
$url = new moodle_url('/admin/tool/lp/templatecompetencies.php', array('templateid' => $template->get_id(),
$url = new moodle_url('/admin/tool/lp/templatecompetencies.php', array('templateid' => $template->get('id'),
'pagecontextid' => $pagecontextid));
list($title, $subtitle) = \tool_lp\page_helper::setup_for_template($pagecontextid, $url, $template);

Expand Down
4 changes: 2 additions & 2 deletions admin/tool/lp/user_competency.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
$params = array('id' => $id);
$url = new moodle_url('/admin/tool/lp/user_competency.php', $params);

$user = core_user::get_user($uc->get_userid());
$user = core_user::get_user($uc->get('userid'));
if (!$user || !core_user::is_real_user($user->id)) {
throw new moodle_exception('invaliduser', 'error');
}
Expand All @@ -47,7 +47,7 @@

$PAGE->set_pagelayout('standard');
$PAGE->set_url($url);
$PAGE->navigation->override_active_url(new moodle_url('/admin/tool/lp/plans.php', array('userid' => $uc->get_userid())));
$PAGE->navigation->override_active_url(new moodle_url('/admin/tool/lp/plans.php', array('userid' => $uc->get('userid'))));
$PAGE->set_context($uc->get_context());
if (!$iscurrentuser) {
$PAGE->navigation->extend_for_user($user);
Expand Down
2 changes: 1 addition & 1 deletion admin/tool/lp/user_competency_in_course.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
if ($userid > 0) {
$usercompetencycourses = \core_competency\api::list_user_competencies_in_course($courseid, $userid);
}
$subtitle = $competency->get_shortname() . ' <em>' . $competency->get_idnumber() . '</em>';
$subtitle = $competency->get('shortname') . ' <em>' . $competency->get('idnumber') . '</em>';

list($title, $subtitle) = \tool_lp\page_helper::setup_for_course($url, $course, $subtitle);

Expand Down
6 changes: 3 additions & 3 deletions admin/tool/lp/user_competency_in_plan.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@
$page = new \tool_lp\output\user_competency_summary_in_plan($competencyid, $planid);
echo $output->render($page);
// Trigger the viewed event.
$pc = \core_competency\api::get_plan_competency($plan, $competency->get_id());
if ($plan->get_status() == \core_competency\plan::STATUS_COMPLETE) {
$pc = \core_competency\api::get_plan_competency($plan, $competency->get('id'));
if ($plan->get('status') == \core_competency\plan::STATUS_COMPLETE) {
$usercompetencyplan = $pc->usercompetencyplan;
\core_competency\api::user_competency_plan_viewed($usercompetencyplan);
} else {
$usercompetency = $pc->usercompetency;
\core_competency\api::user_competency_viewed_in_plan($usercompetency, $plan->get_id());
\core_competency\api::user_competency_viewed_in_plan($usercompetency, $plan->get('id'));
}

echo $output->footer();
2 changes: 1 addition & 1 deletion admin/tool/lp/user_evidence.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

$userevidence = \core_competency\api::read_user_evidence($id);
$url = new moodle_url('/admin/tool/lp/user_evidence.php', array('id' => $id));
list($title, $subtitle) = \tool_lp\page_helper::setup_for_user_evidence($userevidence->get_userid(), $url, $userevidence);
list($title, $subtitle) = \tool_lp\page_helper::setup_for_user_evidence($userevidence->get('userid'), $url, $userevidence);

$output = $PAGE->get_renderer('tool_lp');
echo $output->header();
Expand Down
6 changes: 3 additions & 3 deletions admin/tool/lp/user_evidence_edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
$userevidence = \core_competency\api::read_user_evidence($id);

// The userid parameter must be the same as the owner of the evidence.
if ($userid != $userevidence->get_userid()) {
if ($userid != $userevidence->get('userid')) {
throw new coding_exception('Inconsistency between the userid parameter and the userid of the plan.');
}

Expand Down Expand Up @@ -84,7 +84,7 @@
// Load existing user evidence.
$itemid = null;
if ($userevidence) {
$itemid = $userevidence->get_id();
$itemid = $userevidence->get('id');
}

// Massaging the file API.
Expand All @@ -100,7 +100,7 @@

if (empty($userevidence)) {
$userevidence = \core_competency\api::create_user_evidence($data, $draftitemid);
$returnurl = new moodle_url('/admin/tool/lp/user_evidence.php', ['id' => $userevidence->get_id()]);
$returnurl = new moodle_url('/admin/tool/lp/user_evidence.php', ['id' => $userevidence->get('id')]);
$returnmsg = get_string('userevidencecreated', 'tool_lp');
} else {
\core_competency\api::update_user_evidence($data, $draftitemid);
Expand Down
2 changes: 1 addition & 1 deletion admin/tool/lpimportcsv/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
$form->set_import_error($error);
} else {
$framework = $importer->import();
$urlparams = ['competencyframeworkid' => $framework->get_id(), 'pagecontextid' => $context->id];
$urlparams = ['competencyframeworkid' => $framework->get('id'), 'pagecontextid' => $context->id];
$frameworksurl = new moodle_url('/admin/tool/lp/competencies.php', $urlparams);
echo $OUTPUT->notification(get_string('competencyframeworkcreated', 'tool_lp'), 'notifysuccess');
echo $OUTPUT->continue_button($frameworksurl);
Expand Down
2 changes: 1 addition & 1 deletion blocks/lp/classes/output/summary.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function export_for_template(renderer_base $output) {
if (count($plans) >= 3) {
break;
}
if ($plan->get_status() == plan::STATUS_ACTIVE) {
if ($plan->get('status') == plan::STATUS_ACTIVE) {
$plans[] = $plan;
}
}
Expand Down
2 changes: 1 addition & 1 deletion competency/classes/external/user_evidence_exporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

use moodle_url;
use renderer_base;
use core_competency\performance_helper;
use core_competency\external\performance_helper;
use core_files\external\stored_file_exporter;

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/classes/form/persistent.php
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ public function get_data() {
$data = static::convert_fields($data);

// Ensure that the ID is set.
$data->id = $this->persistent->get_id();
$data->id = $this->persistent->get('id');
}
return $data;
}
Expand Down

0 comments on commit 0ce135f

Please sign in to comment.