Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes undefined variable $cm #134

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions externallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@

defined('MOODLE_INTERNAL') || die();

require_once("$CFG->libdir/externallib.php");
use core_external\external_api;
use core_external\external_function_parameters;
use core_external\external_multiple_structure;
use core_external\external_single_structure;
use core_external\external_value;

require_once("$CFG->dirroot/mod/oublog/locallib.php");

class mod_oublog_external extends external_api {
Expand All @@ -50,7 +55,7 @@ protected static function get_identifier_parameter(): external_single_structure
return \local_oudataload\users::get_webservice_identifier_parameter();
} else {
return new external_single_structure([
'username' => new \external_value(PARAM_ALPHANUM, 'Moodle username'),
'username' => new external_value(PARAM_ALPHANUM, 'Moodle username'),
]);
}
}
Expand Down
9 changes: 4 additions & 5 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,14 +164,13 @@ function oublog_delete_instance($oublogid) {
// instances
$DB->delete_records('oublog_instances', array('oublogid'=>$oublog->id));

if (!$cm = get_coursemodule_from_instance('oublog', $oublog->id)) {
throw new moodle_exception('invalidcoursemodule');
}

// Fulltext search data
require_once(dirname(__FILE__).'/locallib.php');
if (oublog_search_installed()) {
$moduleid=$DB->get_field('modules', 'id', array('name'=>'oublog'));
$cm=$DB->get_record('course_modules', array('module'=>$moduleid, 'instance'=>$oublog->id));
if (!$cm) {
throw new moodle_exception('invalidcoursemodule');
}
local_ousearch_document::delete_module_instance_data($cm);
}

Expand Down