diff --git a/block_profile_redirect.php b/block_profile_redirect.php index f7e9550..4379643 100644 --- a/block_profile_redirect.php +++ b/block_profile_redirect.php @@ -23,8 +23,7 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class block_profile_redirect extends block_base { - - function init() { + public function init() { $this->title = get_string('blockname', 'block_profile_redirect'); } @@ -39,9 +38,8 @@ function get_content() { } $context = context_system::instance(); - if (has_capability('moodle/site:config', $context)) { // 'moodle/site:doanything' no longer exists. - $content = get_string('sysadmin','block_profile_redirect'); + $content = get_string('sysadmin', 'block_profile_redirect'); } else { $config = get_config('blocks/profile_redirect'); if (isset($config->profilefield)) { @@ -66,11 +64,11 @@ function get_content() { } // $courefieldvalue must not be empty (if it's empty it redirects infinitly). // It also MUST return 1 record. - $course = $DB->get_record('course',array($config->coursefield => $coursefieldvalue)); + $course = $DB->get_record('course', array($config->coursefield => $coursefieldvalue)); - if (!empty($coursefieldvalue) and !empty($course)) { + if (!empty($coursefieldvalue) && !empty($course)) { // Since M2 doesn't output any code we can redirect cleanly. - redirect($CFG->wwwroot.'/course/view.php?id='.$course->id,'',0); + redirect($CFG->wwwroot.'/course/view.php?id='.$course->id, '', 0); $content = ''; // Moodle complains if this isn't set. } else { $content = ''; @@ -85,11 +83,9 @@ function get_content() { return $this->content; } - function hide_header() { return true; } - function has_config() { return true; } diff --git a/classes/privacy/provider.php b/classes/privacy/provider.php index e7dab74..d76b4e1 100644 --- a/classes/privacy/provider.php +++ b/classes/privacy/provider.php @@ -43,4 +43,4 @@ class provider implements \core_privacy\local\metadata\null_provider { public static function get_reason() : string { return 'privacy:metadata'; } -} \ No newline at end of file +} diff --git a/db/access.php b/db/access.php index 157e16f..cacd207 100644 --- a/db/access.php +++ b/db/access.php @@ -32,19 +32,19 @@ 'contextlevel' => CONTEXT_BLOCK, 'archetypes' => array( 'editingteacher' => CAP_ALLOW, - 'manager' => CAP_ALLOW + 'manager' => CAP_ALLOW, ), - 'clonepermissionsfrom' => 'moodle/site:manageblocks' + 'clonepermissionsfrom' => 'moodle/site:manageblocks', ), 'block/profile_redirect:myaddinstance' => array( 'captype' => 'write', 'contextlevel' => CONTEXT_SYSTEM, 'archetypes' => array( - 'user' => CAP_ALLOW + 'user' => CAP_ALLOW, ), - 'clonepermissionsfrom' => 'moodle/my:manageblocks' - ) + 'clonepermissionsfrom' => 'moodle/my:manageblocks', + ), ); diff --git a/lang/en/block_profile_redirect.php b/lang/en/block_profile_redirect.php index 943bffd..387955a 100644 --- a/lang/en/block_profile_redirect.php +++ b/lang/en/block_profile_redirect.php @@ -23,9 +23,9 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -$string['pluginname'] = 'Profile Redirect'; +$string['pluginname'] = 'Profile Redirect'; $string['blockname'] = 'Profile Redirect'; -$string['description'] ='Description'; +$string['description'] = 'Description'; $string['descriptiontxt'] = '
The Profile Redirect block is designed to redirect a user from the site front page or My Moodle page containing the block to a new course. The new course the user is redirected to is based on a value in a profile field matching a value in the course fullname, shortname, or id number based on the site configurations below.
diff --git a/lib.php b/lib.php index 1ca278e..1b28394 100644 --- a/lib.php +++ b/lib.php @@ -25,8 +25,8 @@ /** * Return user fields and custom fields - * - * @return array of userfields without the id fields + * + * @return array of userfields without the id fields */ function block_profile_redirect_profile_fields() { global $CFG, $DB; @@ -37,7 +37,7 @@ function block_profile_redirect_profile_fields() { require_once($CFG->dirroot.'/user/profile/lib.php'); // Only grab the custom profile fields that can contain a course's full name. - if ($fields = $DB->get_records_select('user_info_field','')) { + if ($fields = $DB->get_records_select('user_info_field', '')) { foreach ($fields as $field) { require_once($CFG->dirroot.'/user/profile/field/'.$field->datatype.'/field.class.php'); $newfield = 'profile_field_'.$field->datatype;