forked from moodle/moodle
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MDL-40058 Events: Replaced add_to_log for page comments to event
- Loading branch information
1 parent
8b43cf2
commit 86b0e3b
Showing
10 changed files
with
468 additions
and
2 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
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
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,81 @@ | ||
<?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/>. | ||
|
||
/** | ||
* Abstract comment created event. | ||
* | ||
* @package core | ||
* @copyright 2013 Rajesh Taneja <[email protected]> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
|
||
namespace core\event; | ||
|
||
defined('MOODLE_INTERNAL') || die(); | ||
|
||
/** | ||
* Abstract comment created event class. | ||
* | ||
* This class has to be extended by any event which is triggred while creating new comment. | ||
* | ||
* @package core | ||
* @copyright 2013 Rajesh Taneja <[email protected]> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
abstract class comment_created extends \core\event\base { | ||
|
||
/** | ||
* Init method. | ||
* | ||
* @return void | ||
*/ | ||
protected function init() { | ||
$this->data['crud'] = 'c'; | ||
$this->data['level'] = self::LEVEL_PARTICIPATING; | ||
$this->data['objecttable'] = 'comments'; | ||
} | ||
|
||
/** | ||
* Return localised event name. | ||
* | ||
* @return string | ||
*/ | ||
public static function get_name() { | ||
return get_string('eventcommentcreated', 'moodle'); | ||
} | ||
|
||
/** | ||
* Returns description of what happened. | ||
* | ||
* @return string | ||
*/ | ||
public function get_description() { | ||
return 'User with id '. $this->userid . ' added comment for ' . $this->component . ' with instance id ' . | ||
$this->contextinstanceid; | ||
} | ||
|
||
/** | ||
* Custom validation. | ||
* | ||
* @throws \coding_exception | ||
* @return void | ||
*/ | ||
protected function validate_data() { | ||
if (!isset($this->other['itemid'])) { | ||
throw new \coding_exception('The itemid needs to be set in $other'); | ||
} | ||
} | ||
} |
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,81 @@ | ||
<?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/>. | ||
|
||
/** | ||
* Abstract comment deleted event. | ||
* | ||
* @package core | ||
* @copyright 2013 Rajesh Taneja <[email protected]> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
|
||
namespace core\event; | ||
|
||
defined('MOODLE_INTERNAL') || die(); | ||
|
||
/** | ||
* Abstract comment deleted event class. | ||
* | ||
* This class has to be extended by any event which is triggred while deleting comment. | ||
* | ||
* @package core | ||
* @copyright 2013 Rajesh Taneja <[email protected]> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
abstract class comment_deleted extends \core\event\base { | ||
|
||
/** | ||
* Init method. | ||
* | ||
* @return void | ||
*/ | ||
protected function init() { | ||
$this->data['crud'] = 'd'; | ||
$this->data['level'] = self::LEVEL_PARTICIPATING; | ||
$this->data['objecttable'] = 'comments'; | ||
} | ||
|
||
/** | ||
* Return localised event name. | ||
* | ||
* @return string | ||
*/ | ||
public static function get_name() { | ||
return get_string('eventcommentdeleted', 'moodle'); | ||
} | ||
|
||
/** | ||
* Returns description of what happened. | ||
* | ||
* @return string | ||
*/ | ||
public function get_description() { | ||
return 'User with id '. $this->userid . ' deleted comment for ' . $this->component . ' with instance id ' . | ||
$this->contextinstanceid; | ||
} | ||
|
||
/** | ||
* Custom validation. | ||
* | ||
* @throws \coding_exception | ||
* @return void | ||
*/ | ||
protected function validate_data() { | ||
if (!isset($this->other['itemid'])) { | ||
throw new \coding_exception('The itemid needs to be set in $other'); | ||
} | ||
} | ||
} |
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,68 @@ | ||
<?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/>. | ||
|
||
/** | ||
* Abstract comments viewed event. | ||
* | ||
* @package core | ||
* @copyright 2013 Rajesh Taneja <[email protected]> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
|
||
namespace core\event; | ||
|
||
defined('MOODLE_INTERNAL') || die(); | ||
|
||
/** | ||
* Abstract comments viewed event class. | ||
* | ||
* This class has to be extended by any event which is triggred while viewing comment. | ||
* | ||
* @package core | ||
* @copyright 2013 Rajesh Taneja <[email protected]> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
abstract class comments_viewed extends \core\event\base { | ||
|
||
/** | ||
* Init method. | ||
* | ||
* @return void | ||
*/ | ||
protected function init() { | ||
$this->data['crud'] = 'r'; | ||
$this->data['level'] = self::LEVEL_PARTICIPATING; | ||
} | ||
|
||
/** | ||
* Return localised event name. | ||
* | ||
* @return string | ||
*/ | ||
public static function get_name() { | ||
return get_string('eventcommentsviewed', 'moodle'); | ||
} | ||
|
||
/** | ||
* Returns description of what happened. | ||
* | ||
* @return string | ||
*/ | ||
public function get_description() { | ||
return 'User with id '. $this->userid . ' viewed comments for ' . $this->component . ' with instance id ' . | ||
$this->objectid; | ||
} | ||
} |
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,55 @@ | ||
<?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/>. | ||
|
||
/** | ||
* mod_wiki comment created event. | ||
* | ||
* @package mod_wiki | ||
* @copyright 2013 Rajesh Taneja <[email protected]> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
|
||
namespace mod_wiki\event; | ||
defined('MOODLE_INTERNAL') || die(); | ||
|
||
/** | ||
* mod_wiki comment created event. | ||
* | ||
* @package mod_wiki | ||
* @copyright 2013 Rajesh Taneja <[email protected]> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
class comment_created extends \core\event\comment_created { | ||
|
||
/** | ||
* Get URL related to the action. | ||
* | ||
* @return \moodle_url | ||
*/ | ||
public function get_url() { | ||
return new \moodle_url('/mod/wiki/comments.php', array('pageid' => $this->other['itemid'])); | ||
} | ||
|
||
/** | ||
* Returns description of what happened. | ||
* | ||
* @return string | ||
*/ | ||
public function get_description() { | ||
return 'User with id '. $this->userid . ' added comment for ' . $this->component . ' with page id ' . | ||
$this->other['itemid']; | ||
} | ||
} |
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,55 @@ | ||
<?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/>. | ||
|
||
/** | ||
* mod_wiki comment deleted event. | ||
* | ||
* @package mod_wiki | ||
* @copyright 2013 Rajesh Taneja <[email protected]> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
|
||
namespace mod_wiki\event; | ||
defined('MOODLE_INTERNAL') || die(); | ||
|
||
/** | ||
* mod_wiki comment deleted event. | ||
* | ||
* @package mod_wiki | ||
* @copyright 2013 Rajesh Taneja <[email protected]> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
class comment_deleted extends \core\event\comment_deleted { | ||
|
||
/** | ||
* Get URL related to the action. | ||
* | ||
* @return \moodle_url | ||
*/ | ||
public function get_url() { | ||
return new \moodle_url('/mod/wiki/comments.php', array('pageid' => $this->other['itemid'])); | ||
} | ||
|
||
/** | ||
* Returns description of what happened. | ||
* | ||
* @return string | ||
*/ | ||
public function get_description() { | ||
return 'User with id '. $this->userid . ' deleted comment for ' . $this->component . ' with page id ' . | ||
$this->other['itemid']; | ||
} | ||
} |
Oops, something went wrong.