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-39956 cohort: Convert to new events
* \core\event\cohort_created * \core\event\cohort_updated * \core\event\cohort_deleted * \core\event\cohort_member_added * \core\event\cohort_member_removed
- Loading branch information
1 parent
50ff861
commit 04aee04
Showing
6 changed files
with
436 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
<?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/>. | ||
|
||
namespace core\event; | ||
|
||
/** | ||
* Cohort created event. | ||
* | ||
* @package core | ||
* @copyright 2013 Dan Poltawski <[email protected]> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
|
||
class cohort_created extends base { | ||
protected function init() { | ||
$this->data['crud'] = 'c'; | ||
$this->data['level'] = 50; | ||
$this->data['objecttable'] = 'cohort'; | ||
} | ||
|
||
/** | ||
* Returns localised general event name. | ||
* | ||
* @return string|\lang_string | ||
*/ | ||
public static function get_name() { | ||
//TODO: localise | ||
return 'Cohort created'; | ||
} | ||
|
||
/** | ||
* Returns localised description of what happened. | ||
* | ||
* @return string|\lang_string | ||
*/ | ||
public function get_description() { | ||
//TODO: localise | ||
return 'Cohort '.$this->objectid.' was created by '.$this->userid.' at context '.$this->contextid; | ||
} | ||
|
||
/** | ||
* Returns relevant URL. | ||
* @return \moodle_url | ||
*/ | ||
public function get_url() { | ||
return new \moodle_url('/cohort/index.php', array('contextid' => $this->contextid)); | ||
} | ||
|
||
/** | ||
* Does this event replace legacy event? | ||
* | ||
* @return null|string legacy event name | ||
*/ | ||
public function get_legacy_eventname() { | ||
return 'cohort_added'; | ||
} | ||
|
||
/** | ||
* Legacy event data if get_legacy_eventname() is not empty. | ||
* | ||
* @return mixed | ||
*/ | ||
public function get_legacy_eventdata() { | ||
return $this->get_record_snapshot('cohort', $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,79 @@ | ||
<?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/>. | ||
|
||
namespace core\event; | ||
|
||
/** | ||
* Cohort deleted event. | ||
* | ||
* @package core | ||
* @copyright 2013 Dan Poltawski <[email protected]> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
|
||
class cohort_deleted extends base { | ||
protected function init() { | ||
$this->data['crud'] = 'd'; | ||
$this->data['level'] = 50; | ||
$this->data['objecttable'] = 'cohort'; | ||
} | ||
|
||
/** | ||
* Returns localised general event name. | ||
* | ||
* @return string|\lang_string | ||
*/ | ||
public static function get_name() { | ||
//TODO: localise | ||
return 'Cohort deleted'; | ||
} | ||
|
||
/** | ||
* Returns localised description of what happened. | ||
* | ||
* @return string|\lang_string | ||
*/ | ||
public function get_description() { | ||
//TODO: localise | ||
return 'Cohort '.$this->objectid.' was deleted by '.$this->userid.' from context '.$this->contextid; | ||
} | ||
|
||
/** | ||
* Returns relevant URL. | ||
* @return \moodle_url | ||
*/ | ||
public function get_url() { | ||
return new \moodle_url('/cohort/index.php', array('contextid' => $this->contextid)); | ||
} | ||
|
||
/** | ||
* Does this event replace legacy event? | ||
* | ||
* @return null|string legacy event name | ||
*/ | ||
public function get_legacy_eventname() { | ||
return 'cohort_deleted'; | ||
} | ||
|
||
/** | ||
* Legacy event data if get_legacy_eventname() is not empty. | ||
* | ||
* @return mixed | ||
*/ | ||
public function get_legacy_eventdata() { | ||
return $this->get_record_snapshot('cohort', $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,82 @@ | ||
<?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/>. | ||
|
||
namespace core\event; | ||
|
||
/** | ||
* User added to a cohort | ||
* | ||
* @package core | ||
* @copyright 2013 Dan Poltawski <[email protected]> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
|
||
class cohort_member_added extends base { | ||
protected function init() { | ||
$this->data['crud'] = 'c'; | ||
$this->data['level'] = 50; | ||
$this->data['objecttable'] = 'cohort'; | ||
} | ||
|
||
/** | ||
* Returns localised general event name. | ||
* | ||
* @return string|\lang_string | ||
*/ | ||
public static function get_name() { | ||
//TODO: localise | ||
return 'User added to a cohort'; | ||
} | ||
|
||
/** | ||
* Returns localised description of what happened. | ||
* | ||
* @return string|\lang_string | ||
*/ | ||
public function get_description() { | ||
//TODO: localise | ||
return 'User '.$this->relateduserid.' was added to cohort '.$this->objectid.' by:'.$this->userid; | ||
} | ||
|
||
/** | ||
* Returns relevant URL. | ||
* @return \moodle_url | ||
*/ | ||
public function get_url() { | ||
return new \moodle_url('/cohort/assign.php', array('id' => $this->objectid)); | ||
} | ||
|
||
/** | ||
* Does this event replace legacy event? | ||
* | ||
* @return null|string legacy event name | ||
*/ | ||
public function get_legacy_eventname() { | ||
return 'cohort_member_added'; | ||
} | ||
|
||
/** | ||
* Legacy event data if get_legacy_eventname() is not empty. | ||
* | ||
* @return mixed | ||
*/ | ||
public function get_legacy_eventdata() { | ||
$data = new \stdClass(); | ||
$data->cohortid = $this->objectid; | ||
$data->userid = $this->relateduserid; | ||
return $data; | ||
} | ||
} |
Oops, something went wrong.