From fc9fc9fb306f8a4bae15bb0d886a17ec6fad3ead Mon Sep 17 00:00:00 2001 From: Rajesh Taneja Date: Fri, 2 Aug 2013 13:48:11 +0800 Subject: [PATCH 1/2] MDL-41000 Events: Fixed phpdoc for get_name and get_description in \core\event\base class --- lang/en/error.php | 1 + lib/classes/event/base.php | 12 ++++-------- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/lang/en/error.php b/lang/en/error.php index 6bc3ac12c1c..a2508b4f514 100644 --- a/lang/en/error.php +++ b/lang/en/error.php @@ -503,6 +503,7 @@ $string['unknowncourse'] = 'Unknown course named "{$a}"'; $string['unknowncourseidnumber'] = 'Unknown course ID "{$a}"'; $string['unknowncoursesection'] = 'Unknown course section in course "{$a}"'; $string['unknowncourserequest'] = 'Unknown course request'; +$string['unknownevent'] = 'Unknown event'; $string['unknownfiletype'] = 'Error unknown filtertype'; $string['unknowngroup'] = 'Unknown group "{$a}"'; $string['unknownhelp'] = 'Unknown help topic {$a}'; diff --git a/lib/classes/event/base.php b/lib/classes/event/base.php index fd031d4dbb0..ecd42e3831a 100644 --- a/lib/classes/event/base.php +++ b/lib/classes/event/base.php @@ -234,25 +234,21 @@ abstract class base implements \IteratorAggregate { * * Override in subclass, we can not make it static and abstract at the same time. * - * TODO: MDL-37658 - * - * @return string|\lang_string + * @return string */ public static function get_name() { // Override in subclass with real lang string. $parts = explode('\\', __CLASS__); if (count($parts) !== 3) { - return 'unknown event'; + return get_string('unknownevent', 'error'); } return $parts[0].': '.str_replace('_', ' ', $parts[2]); } /** - * Returns localised description of what happened. + * Returns non-localised event description with id's for admin use only. * - * TODO: MDL-37658 - * - * @return string|\lang_string + * @return string */ public function get_description() { return null; From 91665753df096d10a0a57d768d35fc37821746fb Mon Sep 17 00:00:00 2001 From: Rajesh Taneja Date: Fri, 2 Aug 2013 14:23:50 +0800 Subject: [PATCH 2/2] MDL-41000 Events: Fixed return values for get_name() and get_description() in existing events Changes done for following events: - \core_auth\event\user_loggedin - \core\event\role_assigned - \core\event\role_unassigned --- auth/classes/event/user_loggedin.php | 10 +++++----- lang/en/auth.php | 1 - lang/en/role.php | 2 ++ lib/classes/event/role_assigned.php | 10 ++++------ lib/classes/event/role_unassigned.php | 12 +++++------- 5 files changed, 16 insertions(+), 19 deletions(-) diff --git a/auth/classes/event/user_loggedin.php b/auth/classes/event/user_loggedin.php index 74279756a17..5f133445aa4 100644 --- a/auth/classes/event/user_loggedin.php +++ b/auth/classes/event/user_loggedin.php @@ -36,12 +36,12 @@ defined('MOODLE_INTERNAL') || die(); class user_loggedin extends \core\event\base { /** - * Returns localised description of what happened. + * Returns non-localised event description with id's for admin use only. * - * @return \lang_string. + * @return string */ public function get_description() { - return new \lang_string('event_user_loggedin_desc', '', $this->get_username()); + return 'Userid ' . $this->userid . ' has logged in'; } /** @@ -57,10 +57,10 @@ class user_loggedin extends \core\event\base { /** * Return localised event name. * - * @return \lang_string + * @return string */ public static function get_name() { - return new \lang_string('event_user_loggedin'); + return new get_string('event_user_loggedin', 'auth'); } /** diff --git a/lang/en/auth.php b/lang/en/auth.php index 733a95fdde5..8533af90130 100644 --- a/lang/en/auth.php +++ b/lang/en/auth.php @@ -82,7 +82,6 @@ $string['errorminpasswordnonalphanum'] = 'Passwords must have at least {$a} non- $string['errorminpasswordupper'] = 'Passwords must have at least {$a} upper case letter(s).'; $string['errorpasswordupdate'] = 'Error updating password, password not changed'; $string['event_user_loggedin'] = 'User has logged in'; -$string['event_user_loggedin_desc'] = 'User {$a} has logged in'; $string['forcechangepassword'] = 'Force change password'; $string['forcechangepasswordfirst_help'] = 'Force users to change password on their first login to Moodle.'; $string['forcechangepassword_help'] = 'Force users to change password on their next login to Moodle.'; diff --git a/lang/en/role.php b/lang/en/role.php index 191d0f868a4..0ad7b6a31f9 100644 --- a/lang/en/role.php +++ b/lang/en/role.php @@ -181,6 +181,8 @@ $string['errorbadrolename'] = 'Incorrect role name'; $string['errorbadroleshortname'] = 'Incorrect role short name'; $string['errorexistsrolename'] = 'Role name already exists'; $string['errorexistsroleshortname'] = 'Role name already exists'; +$string['eventroleassigned'] = 'Role assigned'; +$string['eventroleunassigned'] = 'Role unassigned'; $string['existingadmins'] = 'Current site administrators'; $string['existingusers'] = '{$a} existing users'; $string['explanation'] = 'Explanation'; diff --git a/lib/classes/event/role_assigned.php b/lib/classes/event/role_assigned.php index 79c7daa6ec2..6f9e8edb2f8 100644 --- a/lib/classes/event/role_assigned.php +++ b/lib/classes/event/role_assigned.php @@ -35,20 +35,18 @@ class role_assigned extends base { /** * Returns localised general event name. * - * @return string|\lang_string + * @return string */ public static function get_name() { - //TODO: MDL-37658 localise - return 'Role assigned'; + return get_string('eventroleassigned', 'role'); } /** - * Returns localised description of what happened. + * Returns non-localised event description with id's for admin use only. * - * @return string|\lang_string + * @return string */ public function get_description() { - //TODO: MDL-37658 localise return 'Role '.$this->objectid.' was assigned to user '.$this->relateduserid.' in context '.$this->contextid; } diff --git a/lib/classes/event/role_unassigned.php b/lib/classes/event/role_unassigned.php index 75501e8d3be..7dbfc647ec7 100644 --- a/lib/classes/event/role_unassigned.php +++ b/lib/classes/event/role_unassigned.php @@ -35,21 +35,19 @@ class role_unassigned extends base { /** * Returns localised general event name. * - * @return string|\lang_string + * @return string */ public static function get_name() { - //TODO: MDL-37658 localise - return 'Role unassigned'; + return get_string('eventroleunassigned', 'role'); } /** - * Returns localised description of what happened. + * Returns non-localised event description with id's for admin use only. * - * @return string|\lang_string + * @return string */ public function get_description() { - //TODO: MDL-37658 localise - return 'Role '.$this->objectid.'was unassigned from user '.$this->relateduserid.' in context '.$this->contextid; + return 'Role '.$this->objectid.' was unassigned from user '.$this->relateduserid.' in context '.$this->contextid; } /**