mirror of
https://github.com/moodle/moodle.git
synced 2025-08-08 10:26:40 +02:00
MDL-39956 cohort: Event clean up and made ready for integration
* Added more PHP Documentation * Localised strings for get_name() * get_legacy_eventname() is now static * get_legacy_eventdata() is now protected * Testing legacy event data * Added missing defined('MOODLE_INTERNAL') checks * Added missing call to add_record_snapshot()
This commit is contained in:
parent
4fece33d9a
commit
25a66af722
8 changed files with 160 additions and 75 deletions
|
@ -14,19 +14,34 @@
|
|||
// 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
|
||||
* User added to a cohort event.
|
||||
*
|
||||
* @package core
|
||||
* @copyright 2013 Dan Poltawski <dan@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace core\event;
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* User added to a cohort event class.
|
||||
*
|
||||
* @package core
|
||||
* @copyright 2013 Dan Poltawski <dan@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class cohort_member_added extends base {
|
||||
|
||||
/**
|
||||
* Init method.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function init() {
|
||||
$this->data['crud'] = 'c';
|
||||
// TODO MDL-41040.
|
||||
$this->data['level'] = 50;
|
||||
$this->data['objecttable'] = 'cohort';
|
||||
}
|
||||
|
@ -34,25 +49,24 @@ class cohort_member_added extends base {
|
|||
/**
|
||||
* Returns localised general event name.
|
||||
*
|
||||
* @return string|\lang_string
|
||||
* @return string
|
||||
*/
|
||||
public static function get_name() {
|
||||
//TODO: localise
|
||||
return 'User added to a cohort';
|
||||
return get_string('event_cohort_member_added', 'core_cohort');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns localised description of what happened.
|
||||
* Returns description of what happened.
|
||||
*
|
||||
* @return string|\lang_string
|
||||
* @return string
|
||||
*/
|
||||
public function get_description() {
|
||||
//TODO: localise
|
||||
return 'User '.$this->relateduserid.' was added to cohort '.$this->objectid.' by:'.$this->userid;
|
||||
return 'User '.$this->relateduserid.' was added to cohort '.$this->objectid.' by user '.$this->userid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns relevant URL.
|
||||
*
|
||||
* @return \moodle_url
|
||||
*/
|
||||
public function get_url() {
|
||||
|
@ -60,20 +74,20 @@ class cohort_member_added extends base {
|
|||
}
|
||||
|
||||
/**
|
||||
* Does this event replace legacy event?
|
||||
* Return legacy event name.
|
||||
*
|
||||
* @return null|string legacy event name
|
||||
* @return string legacy event name.
|
||||
*/
|
||||
public function get_legacy_eventname() {
|
||||
public static function get_legacy_eventname() {
|
||||
return 'cohort_member_added';
|
||||
}
|
||||
|
||||
/**
|
||||
* Legacy event data if get_legacy_eventname() is not empty.
|
||||
* Return legacy event data.
|
||||
*
|
||||
* @return mixed
|
||||
* @return stdClass
|
||||
*/
|
||||
public function get_legacy_eventdata() {
|
||||
protected function get_legacy_eventdata() {
|
||||
$data = new \stdClass();
|
||||
$data->cohortid = $this->objectid;
|
||||
$data->userid = $this->relateduserid;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue