From 12cef11959eb48747007e45318e15378fafa2163 Mon Sep 17 00:00:00 2001 From: Riedler Date: Thu, 20 Feb 2025 17:46:38 +0100 Subject: [PATCH] chore: rename internal stuff to eduplanner user-facing stuff got renamed to LB Planer with one n internal stuff that would need a major version bump got left alone for the next major release --- lbplanner/classes/helpers/config_helper.php | 4 ++-- lbplanner/classes/helpers/course_helper.php | 22 +++++++++---------- .../classes/helpers/notifications_helper.php | 4 ++-- lbplanner/classes/helpers/slot_helper.php | 4 +--- lbplanner/classes/helpers/user_helper.php | 20 ++++++++--------- lbplanner/classes/model/user.php | 2 +- lbplanner/db/services.php | 4 ++-- lbplanner/lang/en/local_lbplanner.php | 2 +- lbplanner/services/config/get_version.php | 2 +- .../services/courses/get_all_courses.php | 2 +- lbplanner/services/courses/get_my_courses.php | 2 +- lbplanner/services/courses/update_course.php | 4 ++-- .../services/modules/get_all_modules.php | 2 +- .../notifications/get_all_notifications.php | 2 +- .../notifications/update_notification.php | 6 ++--- lbplanner/services/user/delete_user.php | 14 ++++++------ lbplanner/services/user/update_user.php | 6 ++--- lbplanner/settings.php | 2 +- 18 files changed, 51 insertions(+), 53 deletions(-) diff --git a/lbplanner/classes/helpers/config_helper.php b/lbplanner/classes/helpers/config_helper.php index 1fe4d370..b52d3ec1 100644 --- a/lbplanner/classes/helpers/config_helper.php +++ b/lbplanner/classes/helpers/config_helper.php @@ -42,7 +42,7 @@ public static function add_customfield(): void { if (array_key_exists('modcustomfields', core_component::get_plugin_list('local'))) { $handler = mod_handler::create(); - $categoryid = $handler->create_category('LB Planner'); + $categoryid = $handler->create_category('LB Planer'); set_config('categoryid', $categoryid, 'local_lbplanner'); $categorycontroller = category_controller::create($categoryid, null, $handler); @@ -64,7 +64,7 @@ public static function add_customfield(): void { '{"required":"0","uniquevalues":"0","options":"GK\r\nEK\r\nTEST\r\nM", "defaultvalue":"","locked":"0","visibility":"2"}' ); - $fieldcontroller->set('shortname', 'lb_planner_gk_ek'); + $fieldcontroller->set('shortname', 'lb_planer_gk_ek'); $fieldcontroller->save(); } } diff --git a/lbplanner/classes/helpers/course_helper.php b/lbplanner/classes/helpers/course_helper.php index e4a74da3..dc822929 100644 --- a/lbplanner/classes/helpers/course_helper.php +++ b/lbplanner/classes/helpers/course_helper.php @@ -34,7 +34,7 @@ class course_helper { /** * The course table used by the LP */ - const LBPLANNER_COURSE_TABLE = 'local_lbplanner_courses'; + const EDUPLANNER_COURSE_TABLE = 'local_lbplanner_courses'; /** * A list of nice colors to choose from :) @@ -61,15 +61,15 @@ class course_helper { /** * Get course from lbpanner DB * - * @param int $courseid id of the course in lbplanner + * @param int $courseid id of the course in Eduplanner * @param int $userid id of the user * - * @return course course from lbplanner + * @return course course from Eduplanner * @throws dml_exception */ - public static function get_lbplanner_course(int $courseid, int $userid): course { + public static function get_eduplanner_course(int $courseid, int $userid): course { global $DB; - return course::from_db($DB->get_record(self::LBPLANNER_COURSE_TABLE, ['courseid' => $courseid, 'userid' => $userid])); + return course::from_db($DB->get_record(self::EDUPLANNER_COURSE_TABLE, ['courseid' => $courseid, 'userid' => $userid])); } /** @@ -77,7 +77,7 @@ public static function get_lbplanner_course(int $courseid, int $userid): course * @param bool $onlyenrolled whether to include only courses in which the current user is enrolled in * @return course[] all courses of the current year */ - public static function get_all_lbplanner_courses(bool $onlyenrolled=true): array { + public static function get_all_eduplanner_courses(bool $onlyenrolled=true): array { global $DB, $USER; $userid = $USER->id; @@ -96,11 +96,11 @@ public static function get_all_lbplanner_courses(bool $onlyenrolled=true): array if (!course::check_year($mdlcourse)) { continue; } - // Check if the course is already in the LB Planner database. - if ($DB->record_exists(self::LBPLANNER_COURSE_TABLE, ['courseid' => $courseid, 'userid' => $userid])) { - $fetchedcourse = self::get_lbplanner_course($courseid, $userid); + // Check if the course is already in the Eduplanner database. + if ($DB->record_exists(self::EDUPLANNER_COURSE_TABLE, ['courseid' => $courseid, 'userid' => $userid])) { + $fetchedcourse = self::get_eduplanner_course($courseid, $userid); } else { - // IF not create an Object to be put into the LB Planner database. + // IF not create an Object to be put into the Eduplanner database. $fetchedcourse = new course( 0, $courseid, $userid, course::prepare_shortname($mdlcourse->shortname), @@ -110,7 +110,7 @@ public static function get_all_lbplanner_courses(bool $onlyenrolled=true): array try { $fetchedcourse->set_fresh( $DB->insert_record( - self::LBPLANNER_COURSE_TABLE, + self::EDUPLANNER_COURSE_TABLE, $fetchedcourse->prepare_for_db() ) ); diff --git a/lbplanner/classes/helpers/notifications_helper.php b/lbplanner/classes/helpers/notifications_helper.php index ac768511..1315ae66 100644 --- a/lbplanner/classes/helpers/notifications_helper.php +++ b/lbplanner/classes/helpers/notifications_helper.php @@ -35,7 +35,7 @@ class notifications_helper { /** * Name of the notifications table. */ - const LBPLANNER_NOTIFICATION_TABLE = 'local_lbplanner_notification'; + const EDUPLANNER_NOTIFICATION_TABLE = 'local_lbplanner_notification'; /** * Returns the data structure of a notification @@ -75,7 +75,7 @@ public static function notify_user(int $userid, int $info, int $type): int { $notification->timestamp = time(); $notification->timestamp_read = null; - $id = $DB->insert_record(self::LBPLANNER_NOTIFICATION_TABLE, $notification); + $id = $DB->insert_record(self::EDUPLANNER_NOTIFICATION_TABLE, $notification); return $id; } diff --git a/lbplanner/classes/helpers/slot_helper.php b/lbplanner/classes/helpers/slot_helper.php index e85c5dba..24985f8d 100644 --- a/lbplanner/classes/helpers/slot_helper.php +++ b/lbplanner/classes/helpers/slot_helper.php @@ -27,8 +27,6 @@ use core\context\system as context_system; -use DateInterval; -use DateTime; use DateTimeImmutable; use DateTimeInterface; use DateTimeZone; @@ -280,7 +278,7 @@ public static function get_filters_for_slot(int $slotid): array { * @return slot[] the filtered slot array */ public static function filter_slots_for_user(array $allslots, \stdClass $user): array { - $mycourses = course_helper::get_all_lbplanner_courses(); + $mycourses = course_helper::get_all_eduplanner_courses(); $mycourseids = []; foreach ($mycourses as $course) { array_push($mycourseids, $course->courseid); diff --git a/lbplanner/classes/helpers/user_helper.php b/lbplanner/classes/helpers/user_helper.php index ff419249..23f7c2b4 100644 --- a/lbplanner/classes/helpers/user_helper.php +++ b/lbplanner/classes/helpers/user_helper.php @@ -37,7 +37,7 @@ class user_helper { /** * Name of the user database */ - const LB_PLANNER_USER_TABLE = 'local_lbplanner_users'; + const EDUPLANNER_USER_TABLE = 'local_lbplanner_users'; /** * Name of the moodle's database @@ -46,7 +46,7 @@ class user_helper { const MOODLE_USER_TABLE = 'user'; /** - * Checks if the given user exists in the LB_PLANNER_USER database. + * Checks if the given user exists in the EDUPLANNER_USER database. * * @param int $userid The id of the user to check. * @@ -55,7 +55,7 @@ class user_helper { */ public static function check_user_exists(int $userid): bool { global $DB; - return $DB->record_exists(self::LB_PLANNER_USER_TABLE, ['userid' => $userid]); + return $DB->record_exists(self::EDUPLANNER_USER_TABLE, ['userid' => $userid]); } /** @@ -69,22 +69,22 @@ public static function check_user_exists(int $userid): bool { */ public static function get_user(int $userid): user { global $DB; - $dbuser = $DB->get_record(self::LB_PLANNER_USER_TABLE, ['userid' => $userid]); + $dbuser = $DB->get_record(self::EDUPLANNER_USER_TABLE, ['userid' => $userid]); if ($dbuser !== false) { return user::from_db($dbuser); } // Register user if not found. - $lbplanneruser = new user(0, $userid, 'default', 'none', 1, false); - $lbpid = $DB->insert_record(self::LB_PLANNER_USER_TABLE, $lbplanneruser->prepare_for_db()); - $lbplanneruser->set_fresh($lbpid); + $eduplanneruser = new user(0, $userid, 'default', 'none', 1, false); + $epid = $DB->insert_record(self::EDUPLANNER_USER_TABLE, $eduplanneruser->prepare_for_db()); + $eduplanneruser->set_fresh($epid); // Create empty plan for newly registered user. $plan = new \stdClass(); - $plan->name = 'Plan for ' . ($lbplanneruser->get_mdluser()->username); + $plan->name = 'Plan for ' . ($eduplanneruser->get_mdluser()->username); $planid = $DB->insert_record(plan_helper::TABLE, $plan); - $lbplanneruser->set_planid($planid); + $eduplanneruser->set_planid($planid); // Set user as owner of new plan. $planaccess = new \stdClass(); @@ -96,7 +96,7 @@ public static function get_user(int $userid): user { // Notify the FE that this user likely hasn't used LBP before. notifications_helper::notify_user($userid, -1, NOTIF_TRIGGER::USER_REGISTERED); - return $lbplanneruser; + return $eduplanneruser; } /** diff --git a/lbplanner/classes/model/user.php b/lbplanner/classes/model/user.php index 59afafc0..0621a4c7 100644 --- a/lbplanner/classes/model/user.php +++ b/lbplanner/classes/model/user.php @@ -90,7 +90,7 @@ class user { /** * Constructs a new course - * @param int $lbpid ID of the lb planner user + * @param int $lbpid ID of the Eduplanner user * @param int $mdlid ID of the moodle user * @param string $theme user-chosen theme * @param string $colorblindness user's colorblindness diff --git a/lbplanner/db/services.php b/lbplanner/db/services.php index c4e1c2cc..3433ee50 100644 --- a/lbplanner/db/services.php +++ b/lbplanner/db/services.php @@ -1,5 +1,5 @@ [ + 'LB Planer API' => [ 'functions' => [ 'local_lbplanner_user_get_user', 'local_lbplanner_user_get_all_users', diff --git a/lbplanner/lang/en/local_lbplanner.php b/lbplanner/lang/en/local_lbplanner.php index eeae8888..0d4017fc 100644 --- a/lbplanner/lang/en/local_lbplanner.php +++ b/lbplanner/lang/en/local_lbplanner.php @@ -1,5 +1,5 @@ new external_value(PARAM_TEXT, 'the current LBPlanner version'), + 'release' => new external_value(PARAM_TEXT, 'the current Eduplanner version'), ] ); } diff --git a/lbplanner/services/courses/get_all_courses.php b/lbplanner/services/courses/get_all_courses.php index 45a638b9..eba53182 100644 --- a/lbplanner/services/courses/get_all_courses.php +++ b/lbplanner/services/courses/get_all_courses.php @@ -50,7 +50,7 @@ public static function get_all_courses(): array { throw new \moodle_exception('access denied: must be slotmaster'); } - $courses = course_helper::get_all_lbplanner_courses(false); + $courses = course_helper::get_all_eduplanner_courses(false); $results = []; foreach ($courses as $course) { array_push($results, $course->prepare_for_api()); diff --git a/lbplanner/services/courses/get_my_courses.php b/lbplanner/services/courses/get_my_courses.php index a053db25..707608d7 100644 --- a/lbplanner/services/courses/get_my_courses.php +++ b/lbplanner/services/courses/get_my_courses.php @@ -43,7 +43,7 @@ public static function get_my_courses_parameters(): external_function_parameters * Get all the courses of the current year. */ public static function get_my_courses(): array { - $courses = course_helper::get_all_lbplanner_courses(true); + $courses = course_helper::get_all_eduplanner_courses(true); $results = []; foreach ($courses as $course) { array_push($results, $course->prepare_for_api()); diff --git a/lbplanner/services/courses/update_course.php b/lbplanner/services/courses/update_course.php index 31645963..0463fa6a 100644 --- a/lbplanner/services/courses/update_course.php +++ b/lbplanner/services/courses/update_course.php @@ -73,7 +73,7 @@ public static function update_course(int $courseid, string $color, string $short throw new moodle_exception('Shortname is too long'); } - $course = course_helper::get_lbplanner_course($courseid, $USER->id); + $course = course_helper::get_eduplanner_course($courseid, $USER->id); if ($color !== null) { $course->set_color($color); @@ -85,7 +85,7 @@ public static function update_course(int $courseid, string $color, string $short $course->set_enabled((bool) $enabled); } - $DB->update_record(course_helper::LBPLANNER_COURSE_TABLE, $course->prepare_for_db()); + $DB->update_record(course_helper::EDUPLANNER_COURSE_TABLE, $course->prepare_for_db()); } /** diff --git a/lbplanner/services/modules/get_all_modules.php b/lbplanner/services/modules/get_all_modules.php index 789a7d98..c54b553c 100644 --- a/lbplanner/services/modules/get_all_modules.php +++ b/lbplanner/services/modules/get_all_modules.php @@ -59,7 +59,7 @@ public static function get_all_modules(bool $ekenabled): array { $modules = []; - $courses = course_helper::get_all_lbplanner_courses(); + $courses = course_helper::get_all_eduplanner_courses(); $planid = plan_helper::get_plan_id($USER->id); foreach ($courses as $course) { diff --git a/lbplanner/services/notifications/get_all_notifications.php b/lbplanner/services/notifications/get_all_notifications.php index f5e1fecf..0426cd2f 100644 --- a/lbplanner/services/notifications/get_all_notifications.php +++ b/lbplanner/services/notifications/get_all_notifications.php @@ -44,7 +44,7 @@ public static function get_all_notifications_parameters(): external_function_par public static function get_all_notifications(): array { global $DB, $USER; - $dbnotifications = $DB->get_records(notifications_helper::LBPLANNER_NOTIFICATION_TABLE, ['userid' => $USER->id]); + $dbnotifications = $DB->get_records(notifications_helper::EDUPLANNER_NOTIFICATION_TABLE, ['userid' => $USER->id]); $notifications = []; diff --git a/lbplanner/services/notifications/update_notification.php b/lbplanner/services/notifications/update_notification.php index 0dbc281c..9e8944a0 100644 --- a/lbplanner/services/notifications/update_notification.php +++ b/lbplanner/services/notifications/update_notification.php @@ -64,12 +64,12 @@ public static function update_notification(int $status, int $notificationid) { ['status' => $status, 'notificationid' => $notificationid] ); - if (!$DB->record_exists(notifications_helper::LBPLANNER_NOTIFICATION_TABLE, ['id' => $notificationid])) { + if (!$DB->record_exists(notifications_helper::EDUPLANNER_NOTIFICATION_TABLE, ['id' => $notificationid])) { throw new \moodle_exception('Notification does not exist'); } $notification = $DB->get_record( - notifications_helper::LBPLANNER_NOTIFICATION_TABLE, + notifications_helper::EDUPLANNER_NOTIFICATION_TABLE, ['id' => $notificationid], '*', MUST_EXIST @@ -77,7 +77,7 @@ public static function update_notification(int $status, int $notificationid) { $notification->status = $status; $notification->timestamp_read = time(); - $DB->update_record(notifications_helper::LBPLANNER_NOTIFICATION_TABLE, $notification); + $DB->update_record(notifications_helper::EDUPLANNER_NOTIFICATION_TABLE, $notification); } /** diff --git a/lbplanner/services/user/delete_user.php b/lbplanner/services/user/delete_user.php index 95756909..a1c5108d 100644 --- a/lbplanner/services/user/delete_user.php +++ b/lbplanner/services/user/delete_user.php @@ -17,7 +17,7 @@ namespace local_lbplanner_services; use dml_exception; -use core_external\{external_api, external_function_parameters, external_value}; +use core_external\{external_api, external_function_parameters}; use local_lbplanner\helpers\{user_helper, plan_helper, course_helper, notifications_helper}; use local_lbplanner\enums\{PLAN_INVITE_STATE, PLAN_ACCESS_TYPE}; use moodle_exception; @@ -51,8 +51,8 @@ public static function delete_user() { $userid = $USER->id; // Check if User is in user table. - if (!$DB->record_exists(user_helper::LB_PLANNER_USER_TABLE, ['userid' => $userid])) { - throw new moodle_exception('User is not registered in LB Planner'); + if (!$DB->record_exists(user_helper::EDUPLANNER_USER_TABLE, ['userid' => $userid])) { + throw new moodle_exception('User is not registered in Eduplanner'); } $planid = plan_helper::get_plan_id($userid); @@ -68,8 +68,8 @@ public static function delete_user() { $DB->delete_records(plan_helper::TABLE, ['id' => $planid]); // Delete all Notifications. - if ($DB->record_exists(notifications_helper::LBPLANNER_NOTIFICATION_TABLE, ['userid' => $userid])) { - $DB->delete_records(notifications_helper::LBPLANNER_NOTIFICATION_TABLE, ['userid' => $userid]); + if ($DB->record_exists(notifications_helper::EDUPLANNER_NOTIFICATION_TABLE, ['userid' => $userid])) { + $DB->delete_records(notifications_helper::EDUPLANNER_NOTIFICATION_TABLE, ['userid' => $userid]); } $invites = plan_helper::get_invites_send($userid); @@ -83,9 +83,9 @@ public static function delete_user() { $DB->delete_records(plan_helper::ACCESS_TABLE, ['userid' => $userid]); // Deleting all Courses associated with the User. - $DB->delete_records(course_helper::LBPLANNER_COURSE_TABLE, ['userid' => $userid]); + $DB->delete_records(course_helper::EDUPLANNER_COURSE_TABLE, ['userid' => $userid]); // Deleting User from User table. - $DB->delete_records(user_helper::LB_PLANNER_USER_TABLE, ['userid' => $userid]); + $DB->delete_records(user_helper::EDUPLANNER_USER_TABLE, ['userid' => $userid]); } /** diff --git a/lbplanner/services/user/update_user.php b/lbplanner/services/user/update_user.php index ce0f545c..81dbd286 100644 --- a/lbplanner/services/user/update_user.php +++ b/lbplanner/services/user/update_user.php @@ -21,7 +21,7 @@ use invalid_parameter_exception; use moodle_exception; -use local_lbplanner\helpers\{plan_helper, user_helper}; +use local_lbplanner\helpers\user_helper; use local_lbplanner\model\user; /** @@ -59,7 +59,7 @@ public static function update_user_parameters(): external_function_parameters { } /** - * Updates the given user in the lbplanner DB + * Updates the given user in the eduplanner DB * @param ?string $theme The theme the user has selected * @param ?string $colorblindness The colorblindness the user has selected * @param ?bool $displaytaskcount The displaytaskcount the user has selected @@ -100,7 +100,7 @@ public static function update_user(?string $theme, ?string $colorblindness, ?boo $user->ekenabled = $ekenabled; } - $DB->update_record(user_helper::LB_PLANNER_USER_TABLE, $user->prepare_for_db()); + $DB->update_record(user_helper::EDUPLANNER_USER_TABLE, $user->prepare_for_db()); return $user->prepare_for_api(); } diff --git a/lbplanner/settings.php b/lbplanner/settings.php index e831d11e..c9b50f27 100644 --- a/lbplanner/settings.php +++ b/lbplanner/settings.php @@ -25,7 +25,7 @@ defined('MOODLE_INTERNAL') || die; if ($hassiteconfig) { - $settings = new admin_settingpage('local_lbplanner', 'LB Planner'); + $settings = new admin_settingpage('local_lbplanner', 'LB Planer'); $ADMIN->add('localplugins', $settings); $settings->add(new admin_setting_configtext('local_lbplanner/activeyear',