From 29e3d6665751f758f1a84fd92e5c4e42644f3cfc Mon Sep 17 00:00:00 2001 From: Daniel Date: Mon, 2 Oct 2023 15:26:58 +0200 Subject: [PATCH] moved patches --- .../patches/1addActiveStateToProfile.php | 38 ++++++++++++++ .../patches/2addDbTermsConditionsToTeam.php | 19 +++++++ .../patches/3addTermsAcceptedToProfile.php | 38 ++++++++++++++ src/server/patches/4addDbNewUsersInactive.php | 20 ++++++++ .../old/addCategoryIdsJsToAppointments.php | 44 ++++++++++++++++ ...ddDateTimeRejectToExistingAppointments.php | 39 ++++++++++++++ .../old/addGeneralCourseCategoryToTeam.php | 41 +++++++++++++++ .../patches/old/addPublicIdToProfile.php | 51 +++++++++++++++++++ .../old/addTeamCategoriesToAdminProfiles.php | 50 ++++++++++++++++++ ...placeCategoryByCategoryIdInAppointment.php | 51 +++++++++++++++++++ 10 files changed, 391 insertions(+) create mode 100644 src/server/patches/1addActiveStateToProfile.php create mode 100644 src/server/patches/2addDbTermsConditionsToTeam.php create mode 100644 src/server/patches/3addTermsAcceptedToProfile.php create mode 100644 src/server/patches/4addDbNewUsersInactive.php create mode 100644 src/server/patches/old/addCategoryIdsJsToAppointments.php create mode 100644 src/server/patches/old/addDateTimeRejectToExistingAppointments.php create mode 100644 src/server/patches/old/addGeneralCourseCategoryToTeam.php create mode 100644 src/server/patches/old/addPublicIdToProfile.php create mode 100644 src/server/patches/old/addTeamCategoriesToAdminProfiles.php create mode 100644 src/server/patches/old/replaceCategoryByCategoryIdInAppointment.php diff --git a/src/server/patches/1addActiveStateToProfile.php b/src/server/patches/1addActiveStateToProfile.php new file mode 100644 index 0000000..68af861 --- /dev/null +++ b/src/server/patches/1addActiveStateToProfile.php @@ -0,0 +1,38 @@ +query( $sql ); + $res = $stmt->fetchAll(); + + $db->beginTransaction(); + foreach( $res as $row ) + { + if ( is_array( $row ) && isset( $row[ 'id' ] ) ) + { + + $entProfile = TB_Shared_Ent_TeamData_Profile::get( $row[ 'id' ] ); + $resTeam = []; + foreach ($entProfile->teams_js as $team) { + $tmpTeam = $team; + $tmpTeam['status'] = 'active'; + $resTeam[] = $tmpTeam; + } + $entProfile->teams_js = $resTeam; + $entProfile->save(); + unset($team); + unset( $entProfile ); + } + } + $db->commit(); + + echo "DONE..."; +} + +patch_addActiveStateToProfile(); \ No newline at end of file diff --git a/src/server/patches/2addDbTermsConditionsToTeam.php b/src/server/patches/2addDbTermsConditionsToTeam.php new file mode 100644 index 0000000..29fa2a2 --- /dev/null +++ b/src/server/patches/2addDbTermsConditionsToTeam.php @@ -0,0 +1,19 @@ +query( $sql ); + + echo "DONE..."; +} + +patch(); \ No newline at end of file diff --git a/src/server/patches/3addTermsAcceptedToProfile.php b/src/server/patches/3addTermsAcceptedToProfile.php new file mode 100644 index 0000000..f777470 --- /dev/null +++ b/src/server/patches/3addTermsAcceptedToProfile.php @@ -0,0 +1,38 @@ +query( $sql ); + $res = $stmt->fetchAll(); + + $db->beginTransaction(); + foreach( $res as $row ) + { + if ( is_array( $row ) && isset( $row[ 'id' ] ) ) + { + + $entProfile = TB_Shared_Ent_TeamData_Profile::get( $row[ 'id' ] ); + $resTeam = []; + foreach ($entProfile->teams_js as $team) { + $tmpTeam = $team; + $tmpTeam['terms_accepted'] = 0; + $resTeam[] = $tmpTeam; + } + $entProfile->teams_js = $resTeam; + $entProfile->save(); + unset($team); + unset( $entProfile ); + } + } + $db->commit(); + + echo "DONE..."; +} + +patch_addTermsAcceptedToProfile(); \ No newline at end of file diff --git a/src/server/patches/4addDbNewUsersInactive.php b/src/server/patches/4addDbNewUsersInactive.php new file mode 100644 index 0000000..b607718 --- /dev/null +++ b/src/server/patches/4addDbNewUsersInactive.php @@ -0,0 +1,20 @@ +query( $sql ); + + $sql = "UPDATE team SET new_users_inactive = 0 WHERE 1"; + $stmt = $db->query( $sql ); + echo "DONE..."; +} + +patch(); \ No newline at end of file diff --git a/src/server/patches/old/addCategoryIdsJsToAppointments.php b/src/server/patches/old/addCategoryIdsJsToAppointments.php new file mode 100644 index 0000000..f77271a --- /dev/null +++ b/src/server/patches/old/addCategoryIdsJsToAppointments.php @@ -0,0 +1,44 @@ +query( $sql ); + $res = $stmt->fetchAll(); + + foreach( $res as $row ) + { + if ( is_array( $row ) && isset( $row[ 'id' ] ) ) + { + $db->beginTransaction(); + $entApp = TB_Shared_Ent_TeamData_Appointment::get( $row[ 'id' ] ); + if ( $entApp instanceof TB_Shared_Ent_TeamData_Appointment ) + { + if ( !is_null( $entApp->category_id ) ) + { + $entApp->category_ids_js = array( $entApp->category_id ); + $entApp->save(); + } + } + $db->commit(); + } + } + + echo "DONE..."; +} + +patch_addCategoryIdsJsToAppointments(); diff --git a/src/server/patches/old/addDateTimeRejectToExistingAppointments.php b/src/server/patches/old/addDateTimeRejectToExistingAppointments.php new file mode 100644 index 0000000..847546a --- /dev/null +++ b/src/server/patches/old/addDateTimeRejectToExistingAppointments.php @@ -0,0 +1,39 @@ +query( $sql ); + $res = $stmt->fetchAll(); + + foreach( $res as $row ) + { + if ( is_array( $row ) && isset( $row[ 'id' ] ) ) + { + $db->beginTransaction(); + $entAppointment = TB_Shared_Ent_TeamData_Appointment::get( $row[ 'id' ] ); + $entAppointment->deadline_reject_dt = $entAppointment->start_dt; + $entAppointment->save(); + $db->commit(); + unset( $entAppointment ); + } + } + + echo "DONE..."; +} + +patch_addDateTimeRejectToExistingAppointments(); diff --git a/src/server/patches/old/addGeneralCourseCategoryToTeam.php b/src/server/patches/old/addGeneralCourseCategoryToTeam.php new file mode 100644 index 0000000..0b0c167 --- /dev/null +++ b/src/server/patches/old/addGeneralCourseCategoryToTeam.php @@ -0,0 +1,41 @@ +id . '-0'; + $generalCategory = $team->getCourseCategoryDataById( $generalCategoryId ); + if ( is_null( $generalCategory ) ) + { + $team->addCourseCategory( [ 'id' => $generalCategoryId, 'name' => 'Allgemein' ] ); + $team->save(); + } + + unset( $team ); + } + + echo "DONE..."; +} + +patch_addGeneralCourseCategoryToTeam(); diff --git a/src/server/patches/old/addPublicIdToProfile.php b/src/server/patches/old/addPublicIdToProfile.php new file mode 100644 index 0000000..47b6f03 --- /dev/null +++ b/src/server/patches/old/addPublicIdToProfile.php @@ -0,0 +1,51 @@ +query( $sql ); + $res = $stmt->fetchAll(); + + foreach( $res as $row ) + { + if ( is_array( $row ) && isset( $row[ 'id' ] ) ) + { + $db->beginTransaction(); + $entProfile = TB_Shared_Ent_TeamData_Profile::get( $row[ 'id' ] ); + if ( $entProfile instanceof TB_Shared_Ent_TeamData_Profile ) + { + $entProfile->public_id = TB_Server_Utils_Helper::getToken(64); + $entProfile->save(); + } + $db->commit(); + } + } + + echo "DONE..."; +} + +patch_AddPublicIdToProfiles(); diff --git a/src/server/patches/old/addTeamCategoriesToAdminProfiles.php b/src/server/patches/old/addTeamCategoriesToAdminProfiles.php new file mode 100644 index 0000000..c14ddbe --- /dev/null +++ b/src/server/patches/old/addTeamCategoriesToAdminProfiles.php @@ -0,0 +1,50 @@ +getTeamIds(); + foreach( $tIds as $tId ) + { + if ( $ap->isAdminOfTeam( $tId ) ) + { + /** @var TB_Shared_Ent_TeamData_Team $team */ + $team = TB_Shared_Ent_TeamData_Team::get( $tId ); + if ( is_array( $team->course_categories_js ) ) + { + $teamCategoryIds = $ap->getTeamIds(); + foreach( $team->course_categories_js as $courseCategory ) + { + $ap->addToCategoryId( $courseCategory[ 'id' ] ); + } + + $ap->save(); + } + } + } + } + + + echo "DONE..."; +} + +patch_AddTeamCategoriesToAdminProfiles(); diff --git a/src/server/patches/old/replaceCategoryByCategoryIdInAppointment.php b/src/server/patches/old/replaceCategoryByCategoryIdInAppointment.php new file mode 100644 index 0000000..589256f --- /dev/null +++ b/src/server/patches/old/replaceCategoryByCategoryIdInAppointment.php @@ -0,0 +1,51 @@ +team_id ); + if ( $team ) + { + $categoryId = $team->id . '-0'; + foreach( $team->course_categories_js as $category ) + { + if ( $category[ 'name' ] === $a->category ) + { + $categoryId = $category[ 'id' ]; + break; + } + } + if ( $categoryId ) + { + //$a->category = NULL; + $a->category_id = $categoryId; + $a->save(); + } + unset( $team ); + } + } + + echo "DONE..."; +} + +patch_replaceCategoryByCategoryIdInAppointment();