mirror of
https://github.com/moodle/moodle.git
synced 2025-01-17 21:49:15 +01:00
Merge branch 'wip-MDL-44403-master' of git://github.com/marinaglancy/moodle
This commit is contained in:
commit
d09cfab660
@ -267,7 +267,7 @@ class blog_entry implements renderable {
|
||||
'objectid' => $this->id,
|
||||
'relateduserid' => $this->userid
|
||||
));
|
||||
$event->set_custom_data($this);
|
||||
$event->set_blog_entry($this);
|
||||
$event->trigger();
|
||||
}
|
||||
|
||||
@ -309,7 +309,7 @@ class blog_entry implements renderable {
|
||||
'objectid' => $entry->id,
|
||||
'relateduserid' => $entry->userid
|
||||
));
|
||||
$event->set_custom_data($entry);
|
||||
$event->set_blog_entry($entry);
|
||||
$event->trigger();
|
||||
}
|
||||
|
||||
@ -334,7 +334,7 @@ class blog_entry implements renderable {
|
||||
'relateduserid' => $this->userid
|
||||
));
|
||||
$event->add_record_snapshot("post", $record);
|
||||
$event->set_custom_data($this);
|
||||
$event->set_blog_entry($this);
|
||||
$event->trigger();
|
||||
}
|
||||
|
||||
|
@ -326,7 +326,6 @@ function groups_create_grouping($data, $editoroptions=null) {
|
||||
'objectid' => $id
|
||||
);
|
||||
$event = \core\event\grouping_created::create($params);
|
||||
$event->set_legacy_eventdata($data);
|
||||
$event->trigger();
|
||||
|
||||
return $id;
|
||||
@ -442,7 +441,6 @@ function groups_update_grouping($data, $editoroptions=null) {
|
||||
'objectid' => $data->id
|
||||
);
|
||||
$event = \core\event\grouping_updated::create($params);
|
||||
$event->set_legacy_eventdata($data);
|
||||
$event->trigger();
|
||||
|
||||
return true;
|
||||
|
@ -124,12 +124,6 @@ class core_group_lib_testcase extends advanced_testcase {
|
||||
|
||||
$this->assertInstanceOf('\core\event\grouping_created', $event);
|
||||
|
||||
// 'Repairing' the object for comparison because of type of variables being wrong.
|
||||
$group->id = (int) $group->id;
|
||||
$group->timemodified = (int) $group->timemodified;
|
||||
$group->timecreated = (int) $group->timecreated;
|
||||
unset($group->idnumber);
|
||||
unset($group->configdata);
|
||||
$this->assertEventLegacyData($group, $event);
|
||||
$this->assertSame('groups_grouping_created', $event->get_legacy_eventname());
|
||||
|
||||
@ -187,10 +181,16 @@ class core_group_lib_testcase extends advanced_testcase {
|
||||
|
||||
$this->assertInstanceOf('\core\event\grouping_updated', $event);
|
||||
|
||||
// 'Repairing' the object for comparison because of type of variables being wrong.
|
||||
$data->id = (int) $grouping->id;
|
||||
// Get the timemodified from DB for comparison with snapshot.
|
||||
$data->timemodified = $DB->get_field('groupings', 'timemodified', array('id'=>$grouping->id));
|
||||
$this->assertTimeCurrent($data->timemodified);
|
||||
// Following fields were not updated so the snapshot should have them the same as in original group.
|
||||
$data->description = $grouping->description;
|
||||
$data->descriptionformat = $grouping->descriptionformat;
|
||||
$data->configdata = $grouping->configdata;
|
||||
$data->idnumber = $grouping->idnumber;
|
||||
$data->timecreated = $grouping->timecreated;
|
||||
// Assert legacy event data.
|
||||
$this->assertEventLegacyData($data, $event);
|
||||
$this->assertSame('groups_grouping_updated', $event->get_legacy_eventname());
|
||||
|
||||
|
@ -37,8 +37,8 @@ defined('MOODLE_INTERNAL') || die();
|
||||
*/
|
||||
class blog_entry_created extends \core\event\base {
|
||||
|
||||
/** @var \blog_entry A reference to the active blog_entry object. */
|
||||
protected $customobject;
|
||||
/** @var \blog_entry A reference to the active blog_entry object. */
|
||||
protected $blogentry;
|
||||
|
||||
/**
|
||||
* Set basic properties for the event.
|
||||
@ -51,12 +51,24 @@ class blog_entry_created extends \core\event\base {
|
||||
}
|
||||
|
||||
/**
|
||||
* Set custom data of the event.
|
||||
* Set blog_entry object to be used by observers.
|
||||
*
|
||||
* @param \blog_entry $data A reference to the active blog_entry object.
|
||||
*/
|
||||
public function set_custom_data(\blog_entry $data) {
|
||||
$this->customobject = $data;
|
||||
public function set_blog_entry(\blog_entry $blogentry) {
|
||||
$this->blogentry = $blogentry;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns created blog_entry object for event observers.
|
||||
*
|
||||
* @return \blog_entry
|
||||
*/
|
||||
public function get_blog_entry() {
|
||||
if ($this->is_restored()) {
|
||||
throw new \coding_exception('Function get_blog_entry() can not be used on restored events.');
|
||||
}
|
||||
return $this->blogentry;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -100,7 +112,7 @@ class blog_entry_created extends \core\event\base {
|
||||
* @return \blog_entry
|
||||
*/
|
||||
protected function get_legacy_eventdata() {
|
||||
return $this->customobject;
|
||||
return $this->blogentry;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -110,6 +122,6 @@ class blog_entry_created extends \core\event\base {
|
||||
*/
|
||||
protected function get_legacy_logdata() {
|
||||
return array (SITEID, 'blog', 'add', 'index.php?userid=' . $this->relateduserid . '&entryid=' . $this->objectid,
|
||||
$this->customobject->subject);
|
||||
$this->blogentry->subject);
|
||||
}
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ defined('MOODLE_INTERNAL') || die();
|
||||
class blog_entry_deleted extends \core\event\base {
|
||||
|
||||
/** @var \blog_entry A reference to the active blog_entry object. */
|
||||
protected $customobject;
|
||||
protected $blogentry;
|
||||
|
||||
/**
|
||||
* Set basic event properties.
|
||||
@ -59,12 +59,24 @@ class blog_entry_deleted extends \core\event\base {
|
||||
}
|
||||
|
||||
/**
|
||||
* Set custom data of the event.
|
||||
* Sets blog_entry object to be used by observers.
|
||||
*
|
||||
* @param \blog_entry $data A reference to the active blog_entry object.
|
||||
*/
|
||||
public function set_custom_data(\blog_entry $data) {
|
||||
$this->customobject = $data;
|
||||
public function set_blog_entry(\blog_entry $blogentry) {
|
||||
$this->blogentry = $blogentry;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns deleted blog entry for event observers.
|
||||
*
|
||||
* @return \blog_entry
|
||||
*/
|
||||
public function get_blog_entry() {
|
||||
if ($this->is_restored()) {
|
||||
throw new \coding_exception('Function get_blog_entry() can not be used on restored events.');
|
||||
}
|
||||
return $this->blogentry;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -91,7 +103,7 @@ class blog_entry_deleted extends \core\event\base {
|
||||
* @return \blog_entry
|
||||
*/
|
||||
protected function get_legacy_eventdata() {
|
||||
return $this->customobject;
|
||||
return $this->blogentry;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -36,7 +36,7 @@ defined('MOODLE_INTERNAL') || die();
|
||||
class blog_entry_updated extends base {
|
||||
|
||||
/** @var \blog_entry A reference to the active blog_entry object. */
|
||||
protected $customobject;
|
||||
protected $blogentry;
|
||||
|
||||
/**
|
||||
* Set basic event properties.
|
||||
@ -49,12 +49,24 @@ class blog_entry_updated extends base {
|
||||
}
|
||||
|
||||
/**
|
||||
* Set custom data of the event.
|
||||
* Sets blog_entry object to be used by observers.
|
||||
*
|
||||
* @param \blog_entry $data A reference to the active blog_entry object.
|
||||
*/
|
||||
public function set_custom_data(\blog_entry $data) {
|
||||
$this->customobject = $data;
|
||||
public function set_blog_entry(\blog_entry $blogentry) {
|
||||
$this->blogentry = $blogentry;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns updated blog entry for event observers.
|
||||
*
|
||||
* @return \blog_entry
|
||||
*/
|
||||
public function get_blog_entry() {
|
||||
if ($this->is_restored()) {
|
||||
throw new \coding_exception('Function get_blog_entry() can not be used on restored events.');
|
||||
}
|
||||
return $this->blogentry;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -89,7 +101,7 @@ class blog_entry_updated extends base {
|
||||
* @return \blog_entry
|
||||
*/
|
||||
protected function get_legacy_eventdata() {
|
||||
return $this->customobject;
|
||||
return $this->blogentry;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -108,7 +120,7 @@ class blog_entry_updated extends base {
|
||||
*/
|
||||
protected function get_legacy_logdata() {
|
||||
return array(SITEID, 'blog', 'update', 'index.php?userid=' . $this->relateduserid . '&entryid=' . $this->objectid,
|
||||
$this->customobject->subject);
|
||||
$this->blogentry->subject);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -84,12 +84,24 @@ class course_category_deleted extends base {
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the legacy event data.
|
||||
* Set custom data of the event - deleted coursecat.
|
||||
*
|
||||
* @param coursecat $class instance of the coursecat class
|
||||
* @param \coursecat $coursecat
|
||||
*/
|
||||
public function set_legacy_eventdata($class) {
|
||||
$this->coursecat = $class;
|
||||
public function set_coursecat(\coursecat $coursecat) {
|
||||
$this->coursecat = $coursecat;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns deleted coursecat for event observers.
|
||||
*
|
||||
* @return \coursecat
|
||||
*/
|
||||
public function get_coursecat() {
|
||||
if ($this->is_restored()) {
|
||||
throw new \coding_exception('Function get_coursecat() can not be used on restored events.');
|
||||
}
|
||||
return $this->coursecat;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -34,13 +34,6 @@ defined('MOODLE_INTERNAL') || die();
|
||||
*/
|
||||
class grouping_created extends \core\event\base {
|
||||
|
||||
/**
|
||||
* Legacy data.
|
||||
*
|
||||
* @var mixed
|
||||
*/
|
||||
protected $legacydata;
|
||||
|
||||
/**
|
||||
* Returns description of what happened.
|
||||
*
|
||||
@ -56,7 +49,7 @@ class grouping_created extends \core\event\base {
|
||||
* @return stdClass
|
||||
*/
|
||||
protected function get_legacy_eventdata() {
|
||||
return $this->legacydata;
|
||||
return $this->get_record_snapshot('groupings', $this->objectid);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -97,14 +90,4 @@ class grouping_created extends \core\event\base {
|
||||
$this->data['objecttable'] = 'groupings';
|
||||
}
|
||||
|
||||
/**
|
||||
* Set legacy data.
|
||||
*
|
||||
* @param mixed $legacydata.
|
||||
* @return void
|
||||
*/
|
||||
public function set_legacy_eventdata($legacydata) {
|
||||
$this->legacydata = $legacydata;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -34,13 +34,6 @@ defined('MOODLE_INTERNAL') || die();
|
||||
*/
|
||||
class grouping_updated extends \core\event\base {
|
||||
|
||||
/**
|
||||
* Legacy data.
|
||||
*
|
||||
* @var mixed
|
||||
*/
|
||||
protected $legacydata;
|
||||
|
||||
/**
|
||||
* Returns description of what happened.
|
||||
*
|
||||
@ -56,7 +49,7 @@ class grouping_updated extends \core\event\base {
|
||||
* @return stdClass
|
||||
*/
|
||||
protected function get_legacy_eventdata() {
|
||||
return $this->legacydata;
|
||||
return $this->get_record_snapshot('groupings', $this->objectid);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -97,14 +90,4 @@ class grouping_updated extends \core\event\base {
|
||||
$this->data['objecttable'] = 'groupings';
|
||||
}
|
||||
|
||||
/**
|
||||
* Set legacy data.
|
||||
*
|
||||
* @param mixed $legacydata.
|
||||
* @return void
|
||||
*/
|
||||
public function set_legacy_eventdata($legacydata) {
|
||||
$this->legacydata = $legacydata;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1643,7 +1643,7 @@ class coursecat implements renderable, cacheable_object, IteratorAggregate {
|
||||
'context' => $coursecatcontext,
|
||||
'other' => array('name' => $this->name)
|
||||
));
|
||||
$event->set_legacy_eventdata($this);
|
||||
$event->set_coursecat($this);
|
||||
$event->trigger();
|
||||
|
||||
// If we deleted $CFG->defaultrequestcategory, make it point somewhere else.
|
||||
@ -1798,7 +1798,7 @@ class coursecat implements renderable, cacheable_object, IteratorAggregate {
|
||||
'context' => $context,
|
||||
'other' => array('name' => $this->name)
|
||||
));
|
||||
$event->set_legacy_eventdata($this);
|
||||
$event->set_coursecat($this);
|
||||
$event->trigger();
|
||||
|
||||
cache_helper::purge_by_event('changesincoursecat');
|
||||
|
@ -44,16 +44,28 @@ defined('MOODLE_INTERNAL') || die();
|
||||
*/
|
||||
class unknown_service_api_called extends \core\event\base {
|
||||
|
||||
/** Old data to be used for the legacy event. */
|
||||
protected $legacydata;
|
||||
/** @var \stdClass Data to be used by event observers. */
|
||||
protected $eventdata;
|
||||
|
||||
/**
|
||||
* Set method for legacy data.
|
||||
* Sets custom data used by event observers.
|
||||
*
|
||||
* @param stdClass $data legacy event data.
|
||||
* @param \stdClass $data
|
||||
*/
|
||||
public function set_legacy_data($data) {
|
||||
$this->legacydata = $data;
|
||||
public function set_message_data(\stdClass $data) {
|
||||
$this->eventdata = $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns custom data for event observers.
|
||||
*
|
||||
* @return \stdClass
|
||||
*/
|
||||
public function get_message_data() {
|
||||
if ($this->is_restored()) {
|
||||
throw new \coding_exception('Function get_message_data() can not be used on restored events.');
|
||||
}
|
||||
return $this->eventdata;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -99,7 +111,7 @@ class unknown_service_api_called extends \core\event\base {
|
||||
* @return mixed
|
||||
*/
|
||||
protected function get_legacy_eventdata() {
|
||||
return $this->legacydata;
|
||||
return $this->eventdata;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -146,15 +146,17 @@ switch ($messagetype) {
|
||||
//Fire an event if we get a web service request which we don't support directly.
|
||||
//This will allow others to extend the LTI services, which I expect to be a common
|
||||
//use case, at least until the spec matures.
|
||||
// Please note that you will have to change $eventdata['other']['body'] into an xml
|
||||
// element in an event observer as done above.
|
||||
$data = new stdClass();
|
||||
$data->body = $rawbody;
|
||||
$data->xml = $xml;
|
||||
$data->messagetype = $messagetype;
|
||||
$data->consumerkey = $consumerkey;
|
||||
$data->sharedsecret = $sharedsecret;
|
||||
$eventdata = array();
|
||||
$eventdata['other'] = array();
|
||||
$eventdata['other']['body'] = $rawbody;
|
||||
$eventdata['other']['messageid'] = lti_parse_message_id($xml);
|
||||
$eventdata['other']['messagetype'] = $messagetype;
|
||||
$eventdata['other']['consumerkey'] = $consumerkey;
|
||||
$eventdata['other']['sharedsecret'] = $sharedsecret;
|
||||
|
||||
// Before firing the event, allow subplugins a chance to handle.
|
||||
if (lti_extend_lti_services((object) $eventdata['other'])) {
|
||||
@ -168,7 +170,7 @@ switch ($messagetype) {
|
||||
|
||||
try {
|
||||
$event = \mod_lti\event\unknown_service_api_called::create($eventdata);
|
||||
$event->set_legacy_data($eventdata);
|
||||
$event->set_message_data($data);
|
||||
$event->trigger();
|
||||
} catch (Exception $e) {
|
||||
$lti_web_service_handled = false;
|
||||
|
6
mod/lti/upgrade.txt
Normal file
6
mod/lti/upgrade.txt
Normal file
@ -0,0 +1,6 @@
|
||||
This files describes API changes in the lti code.
|
||||
|
||||
=== 2.7 ===
|
||||
|
||||
* mod_lti\event\unknown_service_api_called now has less data stored in 'other'
|
||||
but everything is still available for event observers via method get_message_data()
|
Loading…
x
Reference in New Issue
Block a user