diff --git a/lbplanner/classes/helpers/config_helper.php b/lbplanner/classes/helpers/config_helper.php index 37a1ff96..2e0e9f5f 100644 --- a/lbplanner/classes/helpers/config_helper.php +++ b/lbplanner/classes/helpers/config_helper.php @@ -20,7 +20,6 @@ use core_customfield\category_controller; use customfield_select\field_controller; use local_modcustomfields\customfield\mod_handler; - use local_lbplanner\enums\SETTINGS; /** @@ -40,9 +39,7 @@ public static function add_customfield(): void { // Check if the category is already created and only create it if it doesn't exist. // Check if plugin "modcustomfields" is installed and create the category and the custom field. if (self::get_category_id() === -1) { - if (array_key_exists('modcustomfields', core_component::get_plugin_list('local'))) { - $handler = mod_handler::create(); $categoryid = $handler->create_category('LB Planer'); diff --git a/lbplanner/classes/helpers/course_helper.php b/lbplanner/classes/helpers/course_helper.php index 0ddff628..177d4cd1 100644 --- a/lbplanner/classes/helpers/course_helper.php +++ b/lbplanner/classes/helpers/course_helper.php @@ -22,7 +22,6 @@ use DateTimeImmutable; use dml_exception; use dml_write_exception; - use local_lbplanner\model\course; /** @@ -34,7 +33,6 @@ * @license https://creativecommons.org/licenses/by-nc-sa/4.0/ CC-BY-NC-SA 4.0 International or later */ class course_helper { - /** * The course table used by the LP */ @@ -99,8 +97,8 @@ public static function get_eduplanner_courses(bool $onlyenrolled): array { But their perf is so abysmal that we have to roll our own function. The code is largely leaned on how these functions work internally, optimized for our purposes. */ if ($onlyenrolled) { - $mdlcourses = $DB->get_records_sql(" - SELECT c.* FROM {course} c + $mdlcourses = $DB->get_records_sql( + "SELECT c.* FROM {course} c INNER JOIN {enrol} e ON e.courseid = c.id INNER JOIN {user_enrolments} ue ON (ue.enrolid = e.id AND ue.userid = :userid) INNER JOIN {tag_instance} ti ON (ti.itemid = c.id) @@ -129,8 +127,8 @@ public static function get_eduplanner_courses(bool $onlyenrolled): array { ] ); } else { - $mdlcourses = $DB->get_records_sql(" - SELECT c.* FROM {course} c + $mdlcourses = $DB->get_records_sql( + "SELECT c.* FROM {course} c INNER JOIN {tag_instance} ti ON (ti.itemid = c.id) WHERE ( c.enddate > :courseexpiredate @@ -156,7 +154,9 @@ public static function get_eduplanner_courses(bool $onlyenrolled): array { } else { // IF not create an Object to be put into the Eduplanner database. $fetchedcourse = new course( - 0, $courseid, $userid, + 0, + $courseid, + $userid, course::prepare_shortname($mdlcourse->shortname), self::COLORS[array_rand(self::COLORS)], false, diff --git a/lbplanner/classes/helpers/invite_helper.php b/lbplanner/classes/helpers/invite_helper.php index abb50b80..2800d6ae 100644 --- a/lbplanner/classes/helpers/invite_helper.php +++ b/lbplanner/classes/helpers/invite_helper.php @@ -28,7 +28,6 @@ * @license https://creativecommons.org/licenses/by-nc-sa/4.0/ CC-BY-NC-SA 4.0 International or later */ class invite_helper { - /** * Returns the data structure of an invite. * @@ -55,7 +54,7 @@ public static function structure(): external_single_structure { public static function assert_invite_pending(int $status) { if ($status !== PLAN_INVITE_STATE::PENDING) { $name = PLAN_INVITE_STATE::name_from($status); - throw new \moodle_exception('Invite already '.$name); + throw new \moodle_exception("Invite already {$name}"); } } } diff --git a/lbplanner/classes/helpers/kanban_helper.php b/lbplanner/classes/helpers/kanban_helper.php index 4e7a4af6..969355a7 100644 --- a/lbplanner/classes/helpers/kanban_helper.php +++ b/lbplanner/classes/helpers/kanban_helper.php @@ -28,7 +28,6 @@ * @license https://creativecommons.org/licenses/by-nc-sa/4.0/ CC-BY-NC-SA 4.0 International or later */ class kanban_helper { - /** * Table for storing kanban board entries. */ @@ -76,7 +75,10 @@ public static function set_entry(kanbanentry $entry): void { $DB->delete_records(self::TABLE, ['userid' => $entry->userid, 'cmid' => $entry->cmid]); } catch (\dml_exception $e) { // Needed for low-reporting contexts such as a prod server. - echo 'error while trying to delete preexisting kanban entries: '.$e->getMessage()."\nFurther info:\n".$e->debuginfo; + echo 'error while trying to delete preexisting kanban entries: ' + . $e->getMessage() + . "\nFurther info:\n" + . $e->debuginfo; var_dump($entry); throw $e; } diff --git a/lbplanner/classes/helpers/modules_helper.php b/lbplanner/classes/helpers/modules_helper.php index d5b4768f..bfa1743a 100644 --- a/lbplanner/classes/helpers/modules_helper.php +++ b/lbplanner/classes/helpers/modules_helper.php @@ -36,7 +36,6 @@ * Contains helper functions for working with modules. */ class modules_helper { - /** * Table where modules are stored. */ diff --git a/lbplanner/classes/helpers/plan_helper.php b/lbplanner/classes/helpers/plan_helper.php index 3fb991f4..6e0fdd30 100644 --- a/lbplanner/classes/helpers/plan_helper.php +++ b/lbplanner/classes/helpers/plan_helper.php @@ -79,7 +79,8 @@ public static function get_owner(int $planid): int { $owner = $DB->get_field( self::ACCESS_TABLE, - 'userid', ['planid' => $planid, 'accesstype' => PLAN_ACCESS_TYPE::OWNER] + 'userid', + ['planid' => $planid, 'accesstype' => PLAN_ACCESS_TYPE::OWNER] ); return intval($owner); @@ -277,7 +278,9 @@ public static function remove_user(int $planid, int $userid, int $removeuserid): $oldaccess = $DB->get_record( self::ACCESS_TABLE, - ['planid' => $planid, 'userid' => $removeuserid], '*', MUST_EXIST + ['planid' => $planid, 'userid' => $removeuserid], + '*', + MUST_EXIST ); $oldaccess->planid = $newplanid; @@ -342,4 +345,3 @@ public static function timestamp_localtime_to_utc(int $localts) { ->getTimestamp(); } } - diff --git a/lbplanner/classes/helpers/slot_helper.php b/lbplanner/classes/helpers/slot_helper.php index 73be7c93..16a146d2 100644 --- a/lbplanner/classes/helpers/slot_helper.php +++ b/lbplanner/classes/helpers/slot_helper.php @@ -26,12 +26,10 @@ namespace local_lbplanner\helpers; use core\context\system as context_system; - use DateTimeImmutable; use DateTimeInterface; use DateTimeZone; -use local_lbplanner\enums\CAPABILITY; -use local_lbplanner\enums\WEEKDAY; +use local_lbplanner\enums\{CAPABILITY, WEEKDAY}; use local_lbplanner\model\{slot, reservation, slot_filter}; /** @@ -62,8 +60,8 @@ class slot_helper { '14:10', '15:10', '16:00', - '17:00', // All units after this point are 45min long instead of the usual 50. - '17:45', // We will assume 50min anyway because it's easier that way. + '17:00', // All units after this point are 45min long instead of the usual 50. + '17:45', // We will assume 50min anyway because it's easier that way. '18:45', '19:30', '20:15', @@ -119,8 +117,8 @@ public static function get_supervisor_slots(int $supervisorid): array { global $DB; $slots = $DB->get_records_sql( - 'SELECT slot.* FROM {'.self::TABLE_SLOTS.'} as slot '. - 'INNER JOIN {'.self::TABLE_SUPERVISORS.'} as supervisor ON supervisor.slotid=slot.id '. + 'SELECT slot.* FROM {' . self::TABLE_SLOTS . '} as slot ' . + 'INNER JOIN {' . self::TABLE_SUPERVISORS . '} as supervisor ON supervisor.slotid=slot.id ' . 'WHERE supervisor.userid=?', [$supervisorid] ); @@ -332,7 +330,7 @@ public static function filter_slots_for_time(array $allslots, int $range): array public static function calculate_slot_datetime(slot $slot, DateTimeImmutable $now): DateTimeImmutable { $slotdaytime = self::SCHOOL_UNITS[$slot->startunit]; // Move to next day this weekday occurs (doesn't move if it's the same as today). - $slotdatetime = $now->modify('this '.WEEKDAY::name_from($slot->weekday)." {$slotdaytime}"); + $slotdatetime = $now->modify('this ' . WEEKDAY::name_from($slot->weekday) . " {$slotdaytime}"); if ($slotdatetime === false) { throw new \coding_exception('error while calculating slot datetime'); } @@ -357,7 +355,7 @@ public static function amend_date_with_unit_time(int $unit, DateTimeInterface $d $utctz = new DateTimeZone('UTC'); $daytime = self::SCHOOL_UNITS[$unit]; - return DateTimeImmutable::createFromFormat('Y-m-d G:i', $date->format('Y-m-d ').$daytime, $utctz); + return DateTimeImmutable::createFromFormat('Y-m-d G:i', $date->format('Y-m-d ') . $daytime, $utctz); } /** diff --git a/lbplanner/classes/helpers/user_helper.php b/lbplanner/classes/helpers/user_helper.php index ca10e824..6dc662f2 100644 --- a/lbplanner/classes/helpers/user_helper.php +++ b/lbplanner/classes/helpers/user_helper.php @@ -19,9 +19,7 @@ use dml_exception; use stdClass; use core_user; - -use local_lbplanner\enums\NOTIF_TRIGGER; -use local_lbplanner\enums\PLAN_ACCESS_TYPE; +use local_lbplanner\enums\{NOTIF_TRIGGER, PLAN_ACCESS_TYPE}; use local_lbplanner\model\user; /** @@ -33,7 +31,6 @@ * @license https://creativecommons.org/licenses/by-nc-sa/4.0/ CC-BY-NC-SA 4.0 International or later */ class user_helper { - /** * Name of the user database */ diff --git a/lbplanner/classes/model/kanbanentry.php b/lbplanner/classes/model/kanbanentry.php index 1f4d7417..e4289d11 100644 --- a/lbplanner/classes/model/kanbanentry.php +++ b/lbplanner/classes/model/kanbanentry.php @@ -127,7 +127,7 @@ public static function api_structure(): external_single_structure { 'id' => new external_value(PARAM_INT, 'kanban board ID'), 'userid' => new external_value(PARAM_INT, 'ID of the owner of this entry'), 'cmid' => new external_value(PARAM_INT, 'ID of the course-module'), - 'column' => new external_value(PARAM_TEXT, 'which column this module is in '.KANBANCOL_TYPE::format()), + 'column' => new external_value(PARAM_TEXT, 'which column this module is in ' . KANBANCOL_TYPE::format()), ] ); } diff --git a/lbplanner/classes/model/module.php b/lbplanner/classes/model/module.php index 98dd6a18..f534d46e 100644 --- a/lbplanner/classes/model/module.php +++ b/lbplanner/classes/model/module.php @@ -303,7 +303,6 @@ public function get_grade(int $userid): ?int { $mdlgrade = end($mdlgrades); if ($mdlgrade->grade > 0) { - $grade = modules_helper::determine_uinified_grade( $mdlgrade->grade, $moduleboundaries->grademax, @@ -349,9 +348,9 @@ public static function api_structure_personal(): external_single_structure { 'cmid' => new external_value(PARAM_INT, 'Course module ID'), 'name' => new external_value(PARAM_TEXT, 'Shortened module name (max. 5 chars)'), 'courseid' => new external_value(PARAM_INT, 'Course ID'), - 'status' => new external_value(PARAM_INT, 'Module status '.MODULE_STATUS::format()), - 'type' => new external_value(PARAM_INT, 'Module type '.MODULE_TYPE::format()), - 'grade' => new external_value(PARAM_INT, 'The grade of the module '.MODULE_GRADE::format()), + 'status' => new external_value(PARAM_INT, 'Module status ' . MODULE_STATUS::format()), + 'type' => new external_value(PARAM_INT, 'Module type ' . MODULE_TYPE::format()), + 'grade' => new external_value(PARAM_INT, 'The grade of the module ' . MODULE_GRADE::format()), 'duedate' => new external_value(PARAM_INT, 'The deadline of the module set by the teacher'), ] ); diff --git a/lbplanner/classes/model/reservation.php b/lbplanner/classes/model/reservation.php index 599f50b3..d89b2f5b 100644 --- a/lbplanner/classes/model/reservation.php +++ b/lbplanner/classes/model/reservation.php @@ -26,9 +26,8 @@ namespace local_lbplanner\model; use DateTimeImmutable; - -use core_external\{external_single_structure, external_value}; use DateTimeZone; +use core_external\{external_single_structure, external_value}; use local_lbplanner\model\slot; use local_lbplanner\helpers\slot_helper; diff --git a/lbplanner/classes/model/slot.php b/lbplanner/classes/model/slot.php index a09370ae..534e33dd 100644 --- a/lbplanner/classes/model/slot.php +++ b/lbplanner/classes/model/slot.php @@ -27,7 +27,6 @@ use local_lbplanner\enums\WEEKDAY; use local_lbplanner\helpers\slot_helper; - use core_external\{external_multiple_structure, external_single_structure, external_value}; use moodle_exception; @@ -90,11 +89,17 @@ class slot { public function __construct(int $id, int $startunit, int $duration, int $weekday, string $room, int $size) { $this->id = $id; if ($startunit <= 0 || $startunit > slot_helper::SCHOOL_UNIT_MAX) { - throw new \moodle_exception("slot's startunit must be >0 and <=".slot_helper::SCHOOL_UNIT_MAX.", but is {$startunit}"); + throw new \moodle_exception( + "slot's startunit must be >0 and <=" + . slot_helper::SCHOOL_UNIT_MAX + . ", but is {$startunit}" + ); } if ($duration <= 0 || ($startunit + $duration - 1) > slot_helper::SCHOOL_UNIT_MAX) { throw new \moodle_exception( - "slot's duration must be >0 and can't exceed ".slot_helper::SCHOOL_UNIT_MAX." with startunit, but is {$duration}" + "slot's duration must be >0 and can't exceed " + . slot_helper::SCHOOL_UNIT_MAX + . " with startunit, but is {$duration}" ); } $this->startunit = $startunit; @@ -102,7 +107,10 @@ public function __construct(int $id, int $startunit, int $duration, int $weekday $this->weekday = WEEKDAY::from($weekday); if (strlen($room) <= 0 && strlen($room) > slot_helper::ROOM_MAXLENGTH) { throw new \moodle_exception( - "room name's length must be >0 and <=".slot_helper::ROOM_MAXLENGTH.", but is ".strlen($room) + "room name's length must be >0 and <=" + . slot_helper::ROOM_MAXLENGTH + . ", but is " + . strlen($room) ); } $this->room = $room; @@ -169,7 +177,7 @@ public function validate(): void { if (strlen($this->room) <= 1) { throw new moodle_exception('room name has to be at least 2 characters long'); } else if (strlen($this->room) > slot_helper::ROOM_MAXLENGTH) { - throw new moodle_exception('room name has a maximum of '.slot_helper::ROOM_MAXLENGTH.' characters'); + throw new moodle_exception('room name has a maximum of ' . slot_helper::ROOM_MAXLENGTH . ' characters'); } // Validating size. if ($this->size < 0) { @@ -313,7 +321,7 @@ public static function api_structure(): external_single_structure { 'id' => new external_value(PARAM_INT, 'slot ID'), 'startunit' => new external_value(PARAM_INT, 'unit this slot starts in (8:00 is unit 1)'), 'duration' => new external_value(PARAM_INT, 'duration of the slot in units'), - 'weekday' => new external_value(PARAM_INT, 'The day this unit repeats weekly: '.WEEKDAY::format()), + 'weekday' => new external_value(PARAM_INT, 'The day this unit repeats weekly: ' . WEEKDAY::format()), 'room' => new external_value(PARAM_TEXT, 'The room this slot is for'), 'size' => new external_value(PARAM_INT, 'total capacity of the slot'), 'fullness' => new external_value(PARAM_INT, 'how many people have already reserved this slot'), diff --git a/lbplanner/classes/model/user.php b/lbplanner/classes/model/user.php index 7bedd26b..3cbfe855 100644 --- a/lbplanner/classes/model/user.php +++ b/lbplanner/classes/model/user.php @@ -28,10 +28,8 @@ use core\context\system as context_system; use core_external\{external_single_structure, external_value}; use user_picture; - -use local_lbplanner\enums\{CAPABILITY, CAPABILITY_FLAG, KANBANCOL_TYPE, KANBANCOL_TYPE_ORNONE}; -use local_lbplanner\helpers\plan_helper; -use local_lbplanner\helpers\user_helper; +use local_lbplanner\enums\{CAPABILITY, CAPABILITY_FLAG, KANBANCOL_TYPE_ORNONE}; +use local_lbplanner\helpers\{plan_helper, user_helper}; /** * Model class for model @@ -419,15 +417,15 @@ public static function api_structure(): external_single_structure { 'showcolumncolors' => new external_value(PARAM_BOOL, 'Whether column colors should show in kanban board'), 'automovecompletedtasks' => new external_value( PARAM_TEXT, - 'The kanban column to move a task to if completed '.KANBANCOL_TYPE_ORNONE::format() + 'The kanban column to move a task to if completed ' . KANBANCOL_TYPE_ORNONE::format() ), 'automovesubmittedtasks' => new external_value( PARAM_TEXT, - 'The kanban column to move a task to if submitted '.KANBANCOL_TYPE_ORNONE::format() + 'The kanban column to move a task to if submitted ' . KANBANCOL_TYPE_ORNONE::format() ), 'automoveoverduetasks' => new external_value( PARAM_TEXT, - 'The kanban column to move a task to if overdue '.KANBANCOL_TYPE_ORNONE::format() + 'The kanban column to move a task to if overdue ' . KANBANCOL_TYPE_ORNONE::format() ), 'capabilities' => new external_value(PARAM_INT, 'The capabilities of the user represented as a bitmask value'), 'vintage' => new external_value(PARAM_TEXT, 'The vintage of the user', VALUE_DEFAULT), diff --git a/lbplanner/classes/polyfill/Enum.php b/lbplanner/classes/polyfill/Enum.php index 82a5d244..0620c828 100644 --- a/lbplanner/classes/polyfill/Enum.php +++ b/lbplanner/classes/polyfill/Enum.php @@ -50,7 +50,7 @@ private static function find($value, bool $try): ?EnumCase { if ($try) { return null; } else { - throw new \moodle_exception("value {$value} cannot be represented as a value in enum ".static::class); + throw new \moodle_exception("value {$value} cannot be represented as a value in enum " . static::class); } } /** @@ -70,7 +70,7 @@ private static function find_from_name(string $name, bool $try): ?EnumCase { if ($try) { return null; } else { - throw new \moodle_exception("name {$name} doesn't exist in ".static::class); + throw new \moodle_exception("name {$name} doesn't exist in " . static::class); } } /** diff --git a/lbplanner/classes/polyfill/EnumCase.php b/lbplanner/classes/polyfill/EnumCase.php index fdfd3bff..8ee536e9 100644 --- a/lbplanner/classes/polyfill/EnumCase.php +++ b/lbplanner/classes/polyfill/EnumCase.php @@ -25,8 +25,6 @@ namespace local_lbplanner\polyfill; -defined('MOODLE_INTERNAL') || die(); - // TODO: revert to native enums once we migrate to php8. /** @@ -47,4 +45,4 @@ public function __construct(string $name, $value) { $this->name = $name; $this->value = $value; } -}; +} diff --git a/lbplanner/db/uninstall.php b/lbplanner/db/uninstall.php index 6f2c06a2..9e28ea3f 100644 --- a/lbplanner/db/uninstall.php +++ b/lbplanner/db/uninstall.php @@ -35,4 +35,3 @@ function xmldb_local_lbplanner_uninstall() { $tag = core_tag_tag::get_by_name(core_tag_collection::get_default(), course_helper::EDUPLANNER_TAG, strictness:MUST_EXIST); core_tag_tag::delete_tags($tag->id); } - diff --git a/lbplanner/db/upgrade.php b/lbplanner/db/upgrade.php index 5c41670c..4192888c 100644 --- a/lbplanner/db/upgrade.php +++ b/lbplanner/db/upgrade.php @@ -24,7 +24,6 @@ */ use core\context\course as context_course; - use local_lbplanner\helpers\{config_helper, course_helper}; /** diff --git a/lbplanner/services/courses/get_all_courses.php b/lbplanner/services/courses/get_all_courses.php index 4f71caea..dd3eda50 100644 --- a/lbplanner/services/courses/get_all_courses.php +++ b/lbplanner/services/courses/get_all_courses.php @@ -31,7 +31,6 @@ * @license https://creativecommons.org/licenses/by-nc-sa/4.0/ CC-BY-NC-SA 4.0 International or later */ class courses_get_all_courses extends \core_external\external_api { - /** * Has no Parameters * @return external_function_parameters diff --git a/lbplanner/services/courses/get_my_courses.php b/lbplanner/services/courses/get_my_courses.php index 8263c7dd..fb14ac5f 100644 --- a/lbplanner/services/courses/get_my_courses.php +++ b/lbplanner/services/courses/get_my_courses.php @@ -17,7 +17,6 @@ namespace local_lbplanner_services; use core_external\{external_function_parameters, external_multiple_structure}; - use local_lbplanner\helpers\course_helper; use local_lbplanner\model\course; @@ -30,7 +29,6 @@ * @license https://creativecommons.org/licenses/by-nc-sa/4.0/ CC-BY-NC-SA 4.0 International or later */ class courses_get_my_courses extends \core_external\external_api { - /** * Has no Parameters * @return external_function_parameters diff --git a/lbplanner/services/plan/accept_invite.php b/lbplanner/services/plan/accept_invite.php index 2e28c200..fdf69399 100644 --- a/lbplanner/services/plan/accept_invite.php +++ b/lbplanner/services/plan/accept_invite.php @@ -75,7 +75,6 @@ public static function accept_invite(int $inviteid) { // Deletes the old plan if the user is the owner of it. $oldplanid = plan_helper::get_plan_id($USER->id); if (plan_helper::get_owner($oldplanid) == $USER->id) { - foreach (plan_helper::get_plan_members($oldplanid) as $member) { if ($member->userid != $USER->id) { self::call_external_function('local_lbplanner_plan_remove_user', [ diff --git a/lbplanner/services/plan/invite_user.php b/lbplanner/services/plan/invite_user.php index 53714f6e..26d977e4 100644 --- a/lbplanner/services/plan/invite_user.php +++ b/lbplanner/services/plan/invite_user.php @@ -75,10 +75,12 @@ public static function invite_user(int $inviteeid): mixed { throw new \moodle_exception('Cannot invite user who is already a member'); } - if ($DB->record_exists( + if ( + $DB->record_exists( plan_helper::INVITES_TABLE, ['inviteeid' => $inviteeid, 'planid' => $planid, 'status' => PLAN_INVITE_STATE::PENDING] - )) { + ) + ) { throw new \moodle_exception('User is already invited'); } diff --git a/lbplanner/services/plan/leave_plan.php b/lbplanner/services/plan/leave_plan.php index 2a77868f..fa007552 100644 --- a/lbplanner/services/plan/leave_plan.php +++ b/lbplanner/services/plan/leave_plan.php @@ -75,13 +75,15 @@ public static function leave_plan() { $allmembers[] = $member; } if (count($writemembers) > 0) { - $newowner = $writemembers[rand( 0, count($writemembers) - 1)]->userid; + $newowner = $writemembers[rand(0, count($writemembers) - 1)]->userid; } else { - $newowner = $allmembers[rand( 0, count($allmembers) - 1)]->userid; + $newowner = $allmembers[rand(0, count($allmembers) - 1)]->userid; } $newowneraccess = $DB->get_record( plan_helper::ACCESS_TABLE, - ['planid' => $planid, 'userid' => $newowner], '*', MUST_EXIST + ['planid' => $planid, 'userid' => $newowner], + '*', + MUST_EXIST ); $newowneraccess->accesstype = PLAN_ACCESS_TYPE::OWNER; $DB->update_record(plan_helper::ACCESS_TABLE, $newowneraccess); @@ -91,7 +93,9 @@ public static function leave_plan() { $oldaccess = $DB->get_record( plan_helper::ACCESS_TABLE, - ['planid' => $planid, 'userid' => $USER->id], '*', MUST_EXIST + ['planid' => $planid, 'userid' => $USER->id], + '*', + MUST_EXIST ); $oldaccess->planid = $newplanid; diff --git a/lbplanner/services/plan/update_access.php b/lbplanner/services/plan/update_access.php index 901e5c59..4ac83084 100644 --- a/lbplanner/services/plan/update_access.php +++ b/lbplanner/services/plan/update_access.php @@ -37,7 +37,7 @@ public static function update_access_parameters(): external_function_parameters return new external_function_parameters([ 'accesstype' => new external_value( PARAM_INT, - 'New access type '.PLAN_ACCESS_TYPE::format(), + 'New access type ' . PLAN_ACCESS_TYPE::format(), VALUE_REQUIRED, null, NULL_NOT_ALLOWED diff --git a/lbplanner/services/slots/add_slot_filter.php b/lbplanner/services/slots/add_slot_filter.php index 133001b8..d89828f1 100644 --- a/lbplanner/services/slots/add_slot_filter.php +++ b/lbplanner/services/slots/add_slot_filter.php @@ -17,7 +17,6 @@ namespace local_lbplanner_services; use core_external\{external_api, external_function_parameters, external_single_structure, external_value}; - use local_lbplanner\helpers\slot_helper; use local_lbplanner\model\slot_filter; diff --git a/lbplanner/services/slots/add_slot_supervisor.php b/lbplanner/services/slots/add_slot_supervisor.php index 38c056e2..7b147f5c 100644 --- a/lbplanner/services/slots/add_slot_supervisor.php +++ b/lbplanner/services/slots/add_slot_supervisor.php @@ -17,7 +17,6 @@ namespace local_lbplanner_services; use core_external\{external_api, external_function_parameters, external_value}; - use local_lbplanner\helpers\slot_helper; use local_lbplanner\model\supervisor; diff --git a/lbplanner/services/slots/book_reservation.php b/lbplanner/services/slots/book_reservation.php index 9fb08199..82afa4cc 100644 --- a/lbplanner/services/slots/book_reservation.php +++ b/lbplanner/services/slots/book_reservation.php @@ -17,14 +17,11 @@ namespace local_lbplanner_services; use DateTimeImmutable; - +use DateTimeZone; use core_user; use core_external\{external_api, external_function_parameters, external_single_structure, external_value}; -use DateTimeZone; use local_lbplanner\enums\NOTIF_TRIGGER; -use local_lbplanner\helpers\config_helper; -use local_lbplanner\helpers\notifications_helper; -use local_lbplanner\helpers\slot_helper; +use local_lbplanner\helpers\{config_helper, notifications_helper, slot_helper}; use local_lbplanner\model\reservation; /** diff --git a/lbplanner/services/slots/create_slot.php b/lbplanner/services/slots/create_slot.php index 5800ff8f..b295c102 100644 --- a/lbplanner/services/slots/create_slot.php +++ b/lbplanner/services/slots/create_slot.php @@ -18,7 +18,6 @@ use core_external\{external_api, external_function_parameters, external_single_structure, external_value}; use core\context\system as context_system; - use local_lbplanner\enums\{CAPABILITY, WEEKDAY}; use local_lbplanner\helpers\slot_helper; use local_lbplanner\model\{slot, supervisor}; @@ -55,7 +54,7 @@ public static function create_slot_parameters(): external_function_parameters { ), 'weekday' => new external_value( PARAM_INT, - 'The weekday this slot happens on. '.WEEKDAY::format(), + 'The weekday this slot happens on. ' . WEEKDAY::format(), VALUE_REQUIRED, null, NULL_NOT_ALLOWED diff --git a/lbplanner/services/slots/delete_slot.php b/lbplanner/services/slots/delete_slot.php index f9dbee45..f7d16918 100644 --- a/lbplanner/services/slots/delete_slot.php +++ b/lbplanner/services/slots/delete_slot.php @@ -17,7 +17,6 @@ namespace local_lbplanner_services; use core_external\{external_api, external_function_parameters, external_value}; - use local_lbplanner\helpers\slot_helper; /** diff --git a/lbplanner/services/slots/get_slot_filters.php b/lbplanner/services/slots/get_slot_filters.php index 42bb9102..6f95b1f1 100644 --- a/lbplanner/services/slots/get_slot_filters.php +++ b/lbplanner/services/slots/get_slot_filters.php @@ -17,7 +17,6 @@ namespace local_lbplanner_services; use core_external\{external_api, external_function_parameters, external_multiple_structure, external_value}; - use local_lbplanner\helpers\slot_helper; use local_lbplanner\model\slot_filter; diff --git a/lbplanner/services/slots/get_slot_reservations.php b/lbplanner/services/slots/get_slot_reservations.php index 9aad48f5..d18943d9 100644 --- a/lbplanner/services/slots/get_slot_reservations.php +++ b/lbplanner/services/slots/get_slot_reservations.php @@ -17,7 +17,6 @@ namespace local_lbplanner_services; use core_external\{external_api, external_function_parameters, external_multiple_structure, external_value}; - use local_lbplanner\helpers\slot_helper; use local_lbplanner\model\reservation; diff --git a/lbplanner/services/slots/get_student_slots.php b/lbplanner/services/slots/get_student_slots.php index 1d5c55b9..d605df4c 100644 --- a/lbplanner/services/slots/get_student_slots.php +++ b/lbplanner/services/slots/get_student_slots.php @@ -17,9 +17,7 @@ namespace local_lbplanner_services; use core_external\{external_api, external_function_parameters, external_multiple_structure, external_value}; - -use local_lbplanner\helpers\slot_helper; -use local_lbplanner\helpers\user_helper; +use local_lbplanner\helpers\{slot_helper, user_helper}; use local_lbplanner\model\slot; /** diff --git a/lbplanner/services/slots/remove_slot_supervisor.php b/lbplanner/services/slots/remove_slot_supervisor.php index 82427f67..e6af6049 100644 --- a/lbplanner/services/slots/remove_slot_supervisor.php +++ b/lbplanner/services/slots/remove_slot_supervisor.php @@ -17,7 +17,6 @@ namespace local_lbplanner_services; use core_external\{external_api, external_function_parameters, external_value}; - use local_lbplanner\helpers\slot_helper; /** diff --git a/lbplanner/services/slots/unbook_reservation.php b/lbplanner/services/slots/unbook_reservation.php index 0184a0d8..7ed222b4 100644 --- a/lbplanner/services/slots/unbook_reservation.php +++ b/lbplanner/services/slots/unbook_reservation.php @@ -17,11 +17,8 @@ namespace local_lbplanner_services; use DateTimeImmutable; - use core_external\{external_api, external_function_parameters, external_value}; - -use local_lbplanner\helpers\slot_helper; -use local_lbplanner\helpers\notifications_helper; +use local_lbplanner\helpers\{slot_helper, notifications_helper}; use local_lbplanner\enums\NOTIF_TRIGGER; /** @@ -91,7 +88,7 @@ public static function unbook_reservation(int $reservationid, bool $nice): void if ($startpast) { throw new \moodle_exception( 'Students can\'t unbook reservations that have already started.' - .' If you want to unbook this reservation regardless, force it.' + . ' If you want to unbook this reservation regardless, force it.' ); } notifications_helper::notify_user($reservation->userid, $reservation->id, NOTIF_TRIGGER::UNBOOK_REQUESTED); diff --git a/lbplanner/services/slots/update_slot.php b/lbplanner/services/slots/update_slot.php index 212109d5..7150dee9 100644 --- a/lbplanner/services/slots/update_slot.php +++ b/lbplanner/services/slots/update_slot.php @@ -17,7 +17,6 @@ namespace local_lbplanner_services; use core_external\{external_api, external_function_parameters, external_value}; - use local_lbplanner\enums\WEEKDAY; use local_lbplanner\helpers\slot_helper; @@ -60,7 +59,7 @@ public static function update_slot_parameters(): external_function_parameters { ), 'weekday' => new external_value( PARAM_INT, - 'The weekday this slot happens on. '.WEEKDAY::format().' (null to ignore)', + 'The weekday this slot happens on. ' . WEEKDAY::format() . ' (null to ignore)', VALUE_DEFAULT, null, NULL_ALLOWED diff --git a/lbplanner/services/user/delete_user.php b/lbplanner/services/user/delete_user.php index a1c5108d..719e60bb 100644 --- a/lbplanner/services/user/delete_user.php +++ b/lbplanner/services/user/delete_user.php @@ -61,7 +61,8 @@ public static function delete_user() { if ( !(count(plan_helper::get_plan_members($planid)) == 1 ) && - !(plan_helper::get_access_type($planid, $userid) == PLAN_ACCESS_TYPE::OWNER)) { + !(plan_helper::get_access_type($planid, $userid) == PLAN_ACCESS_TYPE::OWNER) + ) { self::call_external_function('local_lbplanner_plan_leave_plan', ['userid' => $userid, 'planid' => $planid]); } $DB->delete_records(plan_helper::DEADLINES_TABLE, ['planid' => $planid]); diff --git a/lbplanner/services/user/get_all_users.php b/lbplanner/services/user/get_all_users.php index 863eecdb..e37ead40 100644 --- a/lbplanner/services/user/get_all_users.php +++ b/lbplanner/services/user/get_all_users.php @@ -16,15 +16,14 @@ namespace local_lbplanner_services; -use dml_exception; use core_external\{external_api, external_function_parameters, external_multiple_structure, external_value}; use invalid_parameter_exception; -use local_lbplanner\enums\CAPABILITY; use moodle_exception; +use dml_exception; use core\context\system as context_system; - use local_lbplanner\helpers\user_helper; use local_lbplanner\model\user; +use local_lbplanner\enums\CAPABILITY; /** * Gets all users with one or several LBP capabilities. diff --git a/lbplanner/services/user/get_user.php b/lbplanner/services/user/get_user.php index d7cc827b..129f13f9 100644 --- a/lbplanner/services/user/get_user.php +++ b/lbplanner/services/user/get_user.php @@ -18,9 +18,8 @@ use coding_exception; use dml_exception; -use core_external\{external_function_parameters, external_single_structure}; use moodle_exception; - +use core_external\{external_function_parameters, external_single_structure}; use local_lbplanner\helpers\user_helper; use local_lbplanner\model\user; diff --git a/lbplanner/services/user/update_user.php b/lbplanner/services/user/update_user.php index 89eb5750..9a1a3a81 100644 --- a/lbplanner/services/user/update_user.php +++ b/lbplanner/services/user/update_user.php @@ -16,11 +16,10 @@ namespace local_lbplanner_services; -use dml_exception; use core_external\{external_api, external_function_parameters, external_single_structure, external_value}; use invalid_parameter_exception; use moodle_exception; - +use dml_exception; use local_lbplanner\helpers\user_helper; use local_lbplanner\model\user; use local_lbplanner\enums\KANBANCOL_TYPE_ORNONE; @@ -40,42 +39,54 @@ class user_update_user extends external_api { */ public static function update_user_parameters(): external_function_parameters { return new external_function_parameters([ - 'theme' => new external_value(PARAM_TEXT, 'The theme the user has selected', VALUE_DEFAULT, null), + 'theme' => new external_value( + PARAM_TEXT, + 'The theme the user has selected', + VALUE_DEFAULT, + null + ), 'colorblindness' => new external_value( PARAM_TEXT, 'The colorblindness the user has selected', VALUE_DEFAULT, - null), + null + ), 'displaytaskcount' => new external_value( PARAM_BOOL, 'Whether the user has the taskcount enabled', VALUE_DEFAULT, - null), + null + ), 'ekenabled' => new external_value( PARAM_BOOL, 'Whether the user wants to see EK modules', VALUE_DEFAULT, - null), + null + ), 'showcolumncolors' => new external_value( PARAM_BOOL, 'Whether column colors should show in kanban board', VALUE_DEFAULT, - null), + null + ), 'automovecompletedtasks' => new external_value( PARAM_TEXT, - 'The kanban column to move a task to if completed '.KANBANCOL_TYPE_ORNONE::format(), + 'The kanban column to move a task to if completed ' . KANBANCOL_TYPE_ORNONE::format(), VALUE_DEFAULT, - null), + null + ), 'automovesubmittedtasks' => new external_value( PARAM_TEXT, - 'The kanban column to move a task to if submitted '.KANBANCOL_TYPE_ORNONE::format(), + 'The kanban column to move a task to if submitted ' . KANBANCOL_TYPE_ORNONE::format(), VALUE_DEFAULT, - null), + null + ), 'automoveoverduetasks' => new external_value( PARAM_TEXT, - 'The kanban column to move a task to if overdue '.KANBANCOL_TYPE_ORNONE::format(), + 'The kanban column to move a task to if overdue ' . KANBANCOL_TYPE_ORNONE::format(), VALUE_DEFAULT, - null), + null + ), ]); } diff --git a/lbplanner/settings.php b/lbplanner/settings.php index 65a84832..543faf02 100644 --- a/lbplanner/settings.php +++ b/lbplanner/settings.php @@ -31,7 +31,7 @@ $ADMIN->add('localplugins', $settings); $futuresightsett = new admin_setting_configselect( - 'local_lbplanner/'.SETTINGS::SLOT_FUTURESIGHT, + 'local_lbplanner/' . SETTINGS::SLOT_FUTURESIGHT, 'Advance reservation limit', 'Maximum number of days in advance students can reserve slots (0 = same day only).', 3, @@ -49,7 +49,7 @@ $settings->add($futuresightsett); $outdaterangesett = new admin_setting_configduration( - 'local_lbplanner/'.SETTINGS::COURSE_OUTDATERANGE, + 'local_lbplanner/' . SETTINGS::COURSE_OUTDATERANGE, 'Mark courses as outdated after', 'The maximum duration a course remains visible in EduPlanner after it ends.', 31536000, // 1 non-leap year.