-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
OUWiki: 2.7 logging to events migration #11298
- Loading branch information
1 parent
1588627
commit 04873c1
Showing
17 changed files
with
960 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
// This file is part of Moodle - http://moodle.org/ | ||
// | ||
// Moodle is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// Moodle is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
/** | ||
* The mod_forumng instance list viewed event. | ||
* | ||
* @package mod_forumng | ||
* @copyright 2014 The Open University | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
|
||
namespace mod_ouwiki\event; | ||
|
||
defined('MOODLE_INTERNAL') || die(); | ||
|
||
/** | ||
* The mod_forumng instance list viewed event class. | ||
* | ||
* @package mod_ouwiki | ||
* @since Moodle 2.7 | ||
* @copyright 2014 The Open University | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
class course_module_instance_list_viewed extends \core\event\course_module_instance_list_viewed { | ||
// No need for any code here as everything is handled by the parent class. | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
<?php | ||
// This file is part of Moodle - http://moodle.org/ | ||
// | ||
// Moodle is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// Moodle is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
/** | ||
* The mod_ouwiki view ouwiki event. | ||
* | ||
* @package mod_ouwiki | ||
* @copyright 2014 The Open University | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
|
||
namespace mod_ouwiki\event; | ||
|
||
defined('MOODLE_INTERNAL') || die(); | ||
|
||
/** | ||
* The mod_ouwiki view ouwiki event class. | ||
* | ||
* @package mod_ouwiki | ||
* @since Moodle 2.7 | ||
* @copyright 2014 The Open University | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
class ouwiki_viewed extends \core\event\base { | ||
|
||
/** | ||
* Init method. | ||
* | ||
* @return void | ||
*/ | ||
protected function init() { | ||
$this->data['crud'] = 'r'; | ||
$this->data['edulevel'] = self::LEVEL_PARTICIPATING; | ||
$this->data['objecttable'] = 'ouwiki'; | ||
} | ||
|
||
/** | ||
* Returns description of what happened. | ||
* | ||
* @return string | ||
*/ | ||
public function get_description() { | ||
$str1 = "The user with id '$this->userid' viewed ouwiki page {$this->other['info']} | ||
with the course module id of '$this->contextinstanceid'."; | ||
$str2 = "Action was {$this->other['action']}"; | ||
return $str1.$str2; | ||
} | ||
|
||
/** | ||
* Return localised event name. | ||
* | ||
* @return string | ||
*/ | ||
public static function get_name() { | ||
return get_string('event:ouwikiviewed', 'mod_ouwiki'); | ||
} | ||
|
||
/** | ||
* Get URL related to the action | ||
* | ||
* @return \moodle_url | ||
*/ | ||
public function get_url() { | ||
return new \moodle_url('\\mod\\ouwiki\\' . $this->other['logurl']); | ||
} | ||
|
||
/** | ||
* Return the legacy event log data. | ||
* | ||
* @return array|null | ||
*/ | ||
protected function get_legacy_logdata() { | ||
return array($this->courseid, 'ouwiki', $this->other['action'], $this->other['logurl'], | ||
$this->other['info'], $this->contextinstanceid); | ||
} | ||
|
||
/** | ||
* Custom validation. | ||
* | ||
* @throws \coding_exception | ||
* @return void | ||
*/ | ||
protected function validate_data() { | ||
parent::validate_data(); | ||
|
||
if (!isset($this->objectid)) { | ||
throw new \coding_exception('The \'ouwikiid\' value must be set in the object.'); | ||
} | ||
|
||
if (!isset($this->other['info'])) { | ||
throw new \coding_exception('The \'info\' value must be set in other.'); | ||
} | ||
|
||
if (!isset($this->other['action'])) { | ||
throw new \coding_exception('The \'action\' value must be set in other.'); | ||
} | ||
|
||
if (!isset($this->other['logurl'])) { | ||
throw new \coding_exception('The \'logurl\' value must be set in other.'); | ||
} | ||
|
||
if ($this->contextlevel != CONTEXT_MODULE) { | ||
throw new \coding_exception('Context level must be CONTEXT_MODULE.'); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
<?php | ||
// This file is part of Moodle - http://moodle.org/ | ||
// | ||
// Moodle is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// Moodle is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
/** | ||
* The mod_ouwiki view ouwiki event. | ||
* | ||
* @package mod_ouwiki | ||
* @copyright 2014 The Open University | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
|
||
namespace mod_ouwiki\event; | ||
|
||
defined('MOODLE_INTERNAL') || die(); | ||
|
||
/** | ||
* The mod_ouwiki view ouwiki event class. | ||
* | ||
* @package mod_ouwiki | ||
* @since Moodle 2.7 | ||
* @copyright 2014 The Open University | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
|
||
class page_created extends \core\event\base { | ||
/** | ||
* Init method. | ||
* | ||
* @return void | ||
*/ | ||
protected function init() { | ||
$this->data['crud'] = 'c'; | ||
$this->data['edulevel'] = self::LEVEL_PARTICIPATING; | ||
$this->data['objecttable'] = 'ouwiki_pages'; | ||
} | ||
|
||
/** | ||
* Return localised event name. | ||
* | ||
* @return string | ||
*/ | ||
public static function get_name() { | ||
return get_string('event:ouwikipagecreated', 'mod_ouwiki'); | ||
} | ||
|
||
/** | ||
* Returns description of what happened. | ||
* | ||
* @return string | ||
*/ | ||
public function get_description() { | ||
return "The user with id '$this->userid' created the page {$this->other['info']} with id '$this->objectid' | ||
for the ouwiki with course module id of '$this->contextinstanceid'."; | ||
} | ||
|
||
/** | ||
* Get URL related to the action | ||
* | ||
* @return \moodle_url | ||
*/ | ||
public function get_url() { | ||
return new \moodle_url($this->other['logurl']); | ||
} | ||
|
||
/** | ||
* Return the legacy event log data. | ||
* | ||
* @return array|null | ||
*/ | ||
protected function get_legacy_logdata() { | ||
$logurl = substr($this->other['logurl'], strlen('/mod/ouwiki/')); | ||
return array($this->courseid, 'ouwiki', 'page created', $logurl, | ||
$this->other['info'], $this->contextinstanceid); | ||
} | ||
|
||
/** | ||
* Custom validation. | ||
* | ||
* @throws \coding_exception | ||
* @return void | ||
*/ | ||
protected function validate_data() { | ||
parent::validate_data(); | ||
|
||
if (!isset($this->objectid)) { | ||
throw new \coding_exception('The \'ouwikiid\' value must be set in the object.'); | ||
} | ||
|
||
if (!isset($this->other['info'])) { | ||
throw new \coding_exception('The \'info\' value must be set in other.'); | ||
} | ||
|
||
if (!isset($this->other['logurl'])) { | ||
throw new \coding_exception('The \'logurl\' value must be set in other.'); | ||
} | ||
|
||
if ($this->contextlevel != CONTEXT_MODULE) { | ||
throw new \coding_exception('Context level must be CONTEXT_MODULE.'); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
<?php | ||
// This file is part of Moodle - http://moodle.org/ | ||
// | ||
// Moodle is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// Moodle is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
/** | ||
* The mod_ouwiki view ouwiki event. | ||
* | ||
* @package mod_ouwiki | ||
* @copyright 2014 The Open University | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
|
||
namespace mod_ouwiki\event; | ||
|
||
defined('MOODLE_INTERNAL') || die(); | ||
|
||
/** | ||
* The mod_ouwiki view ouwiki event class. | ||
* | ||
* @package mod_ouwiki | ||
* @since Moodle 2.7 | ||
* @copyright 2014 The Open University | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
class page_lock extends \core\event\base { | ||
|
||
/** | ||
* Init method. | ||
* | ||
* @return void | ||
*/ | ||
protected function init() { | ||
$this->data['crud'] = 'u'; | ||
$this->data['edulevel'] = self::LEVEL_PARTICIPATING; | ||
$this->data['objecttable'] = 'ouwiki_pages'; | ||
} | ||
|
||
/** | ||
* Returns description of what happened. | ||
* | ||
* @return string | ||
*/ | ||
public function get_description() { | ||
return "The user with id '$this->userid' locked ouwiki page {$this->other['info']} | ||
with the course module id '$this->contextinstanceid' "; | ||
} | ||
|
||
/** | ||
* Return localised event name. | ||
* | ||
* @return string | ||
*/ | ||
public static function get_name() { | ||
return get_string('event:pagelock', 'mod_ouwiki'); | ||
} | ||
|
||
/** | ||
* Get URL related to the action | ||
* | ||
* @return \moodle_url | ||
*/ | ||
public function get_url() { | ||
return new \moodle_url('\\mod\\ouwiki\\' . $this->other['logurl']); | ||
} | ||
|
||
/** | ||
* Return the legacy event log data. | ||
* | ||
* @return array|null | ||
*/ | ||
protected function get_legacy_logdata() { | ||
return array($this->courseid, 'ouwiki', 'lock', $this->other['logurl'], | ||
$this->other['info'], $this->contextinstanceid); | ||
} | ||
|
||
/** | ||
* Custom validation. | ||
* | ||
* @throws \coding_exception | ||
* @return void | ||
*/ | ||
protected function validate_data() { | ||
parent::validate_data(); | ||
|
||
if (!isset($this->objectid)) { | ||
throw new \coding_exception('The \'ouwikiid\' value must be set in the object.'); | ||
} | ||
|
||
if (!isset($this->other['info'])) { | ||
throw new \coding_exception('The \'info\' value must be set in other.'); | ||
} | ||
|
||
if (!isset($this->other['logurl'])) { | ||
throw new \coding_exception('The \'logurl\' value must be set in other.'); | ||
} | ||
|
||
if ($this->contextlevel != CONTEXT_MODULE) { | ||
throw new \coding_exception('Context level must be CONTEXT_MODULE.'); | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.