Skip to content

Commit

Permalink
Fixed an issue where contextid is not saved and retrieved correctly, …
Browse files Browse the repository at this point in the history
…causing links not being shown in block.
  • Loading branch information
nelson-edalex committed Jun 27, 2018
1 parent 5f62df1 commit fb9242b
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions managelinks.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,11 @@
require_capability('block/equella_links:manageanylinks', $context);



if (!empty($action)) {
$link = $DB->get_record('block_equella_links', array('id' => $linkid), '*', MUST_EXIST);
$link = $DB->get_record('block_equella_links', array('id' => $linkid, 'contextid'=>$context->id), '*', MUST_EXIST);
if ($action == 'edit') {
$mform = new equella_links_edit_form($PAGE->url, false);
$mform->set_data(array('title'=>$link->title, 'url'=>$link->url, 'linkid'=>$link->id));
$mform->set_data(array('title'=>$link->title, 'url'=>$link->url, 'linkid'=>$link->id, 'contextid'=>$context->id));
} else if ($action == 'delete') {
$DB->delete_records('block_equella_links', array('id' => $linkid));
// we are done here
Expand All @@ -46,13 +45,15 @@
$editinglink->id = $formdata->linkid;
$editinglink->title = $formdata->title;
$editinglink->url = $formdata->url;
$editinglink->contextid = $context->id;
$DB->update_record('block_equella_links', $editinglink);
} else {
$addinglink = new stdClass;
$addinglink->title = $formdata->title;
$addinglink->url = $formdata->url;
$addinglink->created = time();
$addinglink->tagged = 0;
$addinglink->contextid = $context->id;
$DB->insert_record('block_equella_links', $addinglink);
}
redirect($baseurl);
Expand All @@ -69,7 +70,7 @@
$table->set_attribute('class', 'generaltable generalbox');

$table->setup();
$links = $DB->get_records('block_equella_links');
$links = $DB->get_records('block_equella_links', array('contextid'=>$context->id));
foreach ($links as $link) {
$editurl = new moodle_url('/blocks/equella_links/managelinks.php', array('linkid'=>$link->id, 'action'=>'edit', 'courseid'=>$courseid));
$editaction = $OUTPUT->action_icon($editurl, new pix_icon('t/edit', get_string('edit')));
Expand Down

0 comments on commit fb9242b

Please sign in to comment.