From adbabb118dd10dec59532da1e31ee5a1923b9a68 Mon Sep 17 00:00:00 2001 From: Nils Haagen Date: Tue, 20 Feb 2024 09:48:44 +0100 Subject: [PATCH] StudyProgramme: fix/amend 'AutomembershipSource Orgu recursive' --- ...rogrammeAutoMembershipTableUpdateSteps.php | 18 ++++++++- .../class.ilStudyProgrammeSetupAgent.php | 9 +++++ .../classes/class.ilObjStudyProgramme.php | 4 -- ....ilObjStudyProgrammeAutoMembershipsGUI.php | 27 ++++--------- ...lStudyProgrammeAutoMembershipsTableGUI.php | 10 +---- ...s.ilStudyProgrammeAutoMembershipSource.php | 39 +++++-------------- ...dyProgrammeAutoMembershipsDBRepository.php | 4 +- ...ProgrammeMembershipSourceReaderFactory.php | 4 +- ...udyProgrammeMembershipSourceReaderOrgu.php | 3 +- ...tudyProgrammeAutoMembershipsSourceTest.php | 7 ++-- lang/ilias_de.lang | 1 + lang/ilias_en.lang | 1 + 12 files changed, 55 insertions(+), 72 deletions(-) diff --git a/Modules/StudyProgramme/classes/Setup/ilStudyProgrammeAutoMembershipTableUpdateSteps.php b/Modules/StudyProgramme/classes/Setup/ilStudyProgrammeAutoMembershipTableUpdateSteps.php index 79c809eb551f..c5eb76367343 100644 --- a/Modules/StudyProgramme/classes/Setup/ilStudyProgrammeAutoMembershipTableUpdateSteps.php +++ b/Modules/StudyProgramme/classes/Setup/ilStudyProgrammeAutoMembershipTableUpdateSteps.php @@ -1,5 +1,21 @@ 'integer', 'length' => 1, 'default' => 0, - 'notnull' => false + 'notnull' => true ] ); } diff --git a/components/ILIAS/StudyProgramme/classes/Setup/class.ilStudyProgrammeSetupAgent.php b/components/ILIAS/StudyProgramme/classes/Setup/class.ilStudyProgrammeSetupAgent.php index b5ad70a27d0f..ee1294dbff1d 100644 --- a/components/ILIAS/StudyProgramme/classes/Setup/class.ilStudyProgrammeSetupAgent.php +++ b/components/ILIAS/StudyProgramme/classes/Setup/class.ilStudyProgrammeSetupAgent.php @@ -36,9 +36,13 @@ public function getUpdateObjective(Config $config = null): Objective return new ObjectiveCollection( 'Database is updated for component/ILIAS/StudyProgramme', false, + // ILIAS 10 new ilDatabaseUpdateStepsExecutedObjective( new ilMigrateStudyProgrammeCertificateProviderDBUpdateSteps() ), + new ilDatabaseUpdateStepsExecutedObjective( + new ilStudyProgrammeAutoMembershipTableUpdateSteps() + ), ); } @@ -47,10 +51,15 @@ public function getStatusObjective(Metrics\Storage $storage): Objective return new ObjectiveCollection( 'Database is updated for component/ILIAS/StudyProgramme', true, + // ILIAS 10 new ilDatabaseUpdateStepsMetricsCollectedObjective( $storage, new ilMigrateStudyProgrammeCertificateProviderDBUpdateSteps() ), + new ilDatabaseUpdateStepsMetricsCollectedObjective( + $storage, + new ilStudyProgrammeAutoMembershipTableUpdateSteps() + ), ); } diff --git a/components/ILIAS/StudyProgramme/classes/class.ilObjStudyProgramme.php b/components/ILIAS/StudyProgramme/classes/class.ilObjStudyProgramme.php index 3b4c40fab590..4c39e4054c74 100755 --- a/components/ILIAS/StudyProgramme/classes/class.ilObjStudyProgramme.php +++ b/components/ILIAS/StudyProgramme/classes/class.ilObjStudyProgramme.php @@ -1351,7 +1351,6 @@ public function getAutomaticMembershipSources(): array /** * Store a source to be monitored for automatic memberships. */ - // cat-tms-patch start #8290 public function storeAutomaticMembershipSource(string $type, int $src_id, bool $search_recursive): void { $ams = $this->auto_memberships_repository->create( @@ -1365,7 +1364,6 @@ public function storeAutomaticMembershipSource(string $type, int $src_id, bool $ ); $this->auto_memberships_repository->update($ams); } - // cat-tms-patch end #8290 /** * Delete a membership source. @@ -1386,7 +1384,6 @@ public function deleteAllAutomaticMembershipSources(): void /** * Disable a membership source. */ - // cat-tms-patch start #8290 public function disableAutomaticMembershipSource(string $type, int $src_id, bool $search_recursive): void { $ams = $this->auto_memberships_repository->create( @@ -1438,7 +1435,6 @@ protected function getMembersOfMembershipSource(ilStudyProgrammeAutoMembershipSo $source_reader = $this->membersourcereader_factory->getReaderFor($ams); return $source_reader->getMemberIds(); } - // cat-tms-patch end #8290 /** * Get all StudyProgrammes monitoring this membership-source. diff --git a/components/ILIAS/StudyProgramme/classes/class.ilObjStudyProgrammeAutoMembershipsGUI.php b/components/ILIAS/StudyProgramme/classes/class.ilObjStudyProgrammeAutoMembershipsGUI.php index 00519a4ebdc8..3df7c3a2a19e 100755 --- a/components/ILIAS/StudyProgramme/classes/class.ilObjStudyProgrammeAutoMembershipsGUI.php +++ b/components/ILIAS/StudyProgramme/classes/class.ilObjStudyProgrammeAutoMembershipsGUI.php @@ -43,10 +43,7 @@ class ilObjStudyProgrammeAutoMembershipsGUI private const F_SOURCE_ID = 'f_sid'; private const F_ORIGINAL_SOURCE_TYPE = 'f_st_org'; private const F_ORIGINAL_SOURCE_ID = 'f_sid_org'; - // cat-tms-patch start #8290 private const F_SEARCH_RECURSIVE = "f_search_recursive"; - // cat-tms-patch end #8290 - private const CMD_VIEW = 'view'; private const CMD_SAVE = 'save'; private const CMD_DELETE = 'delete'; @@ -205,8 +202,8 @@ protected function save(): void $post = $this->request->getParsedBody(); $form->setValuesByArray($post); $src_type = $post[self::F_SOURCE_TYPE]; - $src_id = $post[self::F_SOURCE_ID . $src_type]; - $search_recursive = (bool) $post[self::F_SEARCH_RECURSIVE]; + $src_id = $post[self::F_SOURCE_ID . $src_type] ?? null; + $search_recursive = (bool) ($post[self::F_SEARCH_RECURSIVE] ?? false); if ( (is_null($src_type) || $src_type === "") || @@ -311,10 +308,8 @@ protected function enable(): void $get = $this->request->getQueryParams(); $field = self::CHECKBOX_SOURCE_IDS; if (array_key_exists($field, $get)) { - // cat-tms-patch start #8290 [$type, $id, $search_recursive] = explode('-', $get[$field]); $this->getObject()->enableAutomaticMembershipSource((string) $type, (int) $id, (bool) $search_recursive); - // cat-tms-patch end #8290 } $this->ctrl->redirect($this, self::CMD_VIEW); } @@ -394,16 +389,12 @@ protected function getAsynchModalOutput(): void $current_src_id = null; if ($this->request_wrapper->has(self::F_ORIGINAL_SOURCE_ID)) { - $current_src_id = $this->request_wrapper->retrieve(self::F_ORIGINAL_SOURCE_ID, $this->refinery->to()->string()); + $current_src_id = $this->request_wrapper->retrieve(self::F_ORIGINAL_SOURCE_ID, $this->refinery->kindlyTo()->int()); } - $form = $this->getForm($current_src_type, $current_src_id); $search_recursive = false; - if ( - array_key_exists(self::F_SEARCH_RECURSIVE, $_GET) && - !is_null($_GET[self::F_SEARCH_RECURSIVE]) - ) { - $search_recursive = (bool) $_GET[self::F_SEARCH_RECURSIVE]; + if ($this->request_wrapper->has(self::F_SEARCH_RECURSIVE)) { + $search_recursive = $this->request_wrapper->retrieve(self::F_SEARCH_RECURSIVE, $this->refinery->kindlyTo()->bool()); } $form = $this->getForm($current_src_type, $current_src_id, $search_recursive); $form_id = "form_" . $form->getId(); @@ -474,9 +465,7 @@ function ($id) use ($form) { protected function getForm( string $source_type = null, int $source_id = null, - // cat-tms-patch start #8290 bool $search_recursive = false - // cat-tms-patch end #8290 ): ilPropertyFormGUI { $form = new ilPropertyFormGUI(); @@ -541,12 +530,10 @@ protected function getForm( $orgu->getExplorerGUI()->setAjax(false); $radio_orgu->addSubItem($orgu); - // cat-tms-patch start #8290 $recurse = new ilCheckboxInputGUI($this->txt('search_for_orgu_members_recursive'), self::F_SEARCH_RECURSIVE); - $recurse->setValue(1); + $recurse->setValue('1'); $recurse->setChecked($search_recursive); $radio_orgu->addSubItem($recurse); - // cat-tms-patch end #8290 $rgroup->addOption($radio_orgu); if ( !is_null($source_type) && @@ -576,7 +563,7 @@ protected function getForm( $form->addItem($hi); $hi = new ilHiddenInputGUI(self::F_ORIGINAL_SOURCE_ID); - $hi->setValue($source_id ?? ''); + $hi->setValue((string) $source_id ?? ''); $form->addItem($hi); return $form; diff --git a/components/ILIAS/StudyProgramme/classes/class.ilStudyProgrammeAutoMembershipsTableGUI.php b/components/ILIAS/StudyProgramme/classes/class.ilStudyProgrammeAutoMembershipsTableGUI.php index 5fd3ff01da65..001941b36080 100755 --- a/components/ILIAS/StudyProgramme/classes/class.ilStudyProgrammeAutoMembershipsTableGUI.php +++ b/components/ILIAS/StudyProgramme/classes/class.ilStudyProgrammeAutoMembershipsTableGUI.php @@ -1,7 +1,5 @@ addColumn($this->lng->txt('last_edited_by'), 'editor'); $this->addColumn($this->lng->txt('last_edited'), 'last'); $this->addColumn($this->lng->txt('status'), 'status'); - // cat-tms-patch start #8290 $this->addColumn($this->lng->txt('search_for_orgu_members_recursive'), 'search_recursive'); - // cat-tms-patch end #8290 $this->addColumn($this->lng->txt('actions'), 'actions'); $this->setSelectAllCheckbox(ilObjStudyProgrammeAutoMembershipsGUI::CHECKBOX_SOURCE_IDS . '[]'); $this->setEnableAllCommand(true); @@ -74,12 +72,10 @@ protected function fillRow(array $a_set): void $status = $ams->isEnabled() ? $this->lng->txt('active') : $this->lng->txt('inactive'); $date = $this->getDatePresentation($ams->getLastEdited()->getTimestamp()); - // cat-tms-patch start #8290 $search_recursive = $this->lng->txt("no"); if ($ams->isSearchRecursive()) { $search_recursive = $this->lng->txt("yes"); } - // cat-tms-patch end #8290 $this->tpl->setVariable("ID", $id); $this->tpl->setVariable("TYPE", $this->lng->txt($ams->getSourceType())); @@ -87,9 +83,7 @@ protected function fillRow(array $a_set): void $this->tpl->setVariable("EDITOR", $usr); $this->tpl->setVariable("LAST_EDITED", $date); $this->tpl->setVariable("STATUS", $status); - // cat-tms-patch start #8290 $this->tpl->setVariable("SEARCH_RECURSIVE", $search_recursive); - // cat-tms-patch end #8290 $this->tpl->setVariable("ACTIONS", $actions); } diff --git a/components/ILIAS/StudyProgramme/classes/model/AutoMemberships/class.ilStudyProgrammeAutoMembershipSource.php b/components/ILIAS/StudyProgramme/classes/model/AutoMemberships/class.ilStudyProgrammeAutoMembershipSource.php index 775b54f0ee82..828980af7483 100755 --- a/components/ILIAS/StudyProgramme/classes/model/AutoMemberships/class.ilStudyProgrammeAutoMembershipSource.php +++ b/components/ILIAS/StudyProgramme/classes/model/AutoMemberships/class.ilStudyProgrammeAutoMembershipSource.php @@ -1,7 +1,5 @@ ilPRGAssignment::AUTO_ASSIGNED_BY_ORGU ]; - protected int $prg_obj_id; - protected string $source_type; - protected int $source_id; - protected bool $enabled; - protected int $last_edited_usr_id; - protected DateTimeImmutable $last_edited; - - // cat-tms-patch start #8290 - protected bool $search_recursive; - public function __construct( - int $prg_obj_id, - string $source_type, - int $source_id, - bool $enabled, - int $last_edited_usr_id, - DateTimeImmutable $last_edited, - bool $search_recursive + protected int $prg_obj_id, + protected string $source_type, + protected int $source_id, + protected bool $enabled, + protected int $last_edited_usr_id, + protected DateTimeImmutable $last_edited, + protected bool $search_recursive ) { if (!in_array($source_type, [ self::TYPE_ROLE, @@ -64,16 +54,7 @@ public function __construct( ])) { throw new InvalidArgumentException("Invalid source-type: " . $source_type, 1); } - - $this->prg_obj_id = $prg_obj_id; - $this->source_type = $source_type; - $this->source_id = $source_id; - $this->enabled = $enabled; - $this->last_edited_usr_id = $last_edited_usr_id; - $this->last_edited = $last_edited; - $this->search_recursive = $search_recursive; } - // cat-tms-patch end #8290 public function getPrgObjId(): int { @@ -105,10 +86,8 @@ public function getLastEdited(): DateTimeImmutable return $this->last_edited; } - // cat-tms-patch start #8290 public function isSearchRecursive(): bool { return $this->search_recursive; } - // cat-tms-patch end #8290 } diff --git a/components/ILIAS/StudyProgramme/classes/model/AutoMemberships/class.ilStudyProgrammeAutoMembershipsDBRepository.php b/components/ILIAS/StudyProgramme/classes/model/AutoMemberships/class.ilStudyProgrammeAutoMembershipsDBRepository.php index b8dc6aa40bc2..4c0c910023c3 100755 --- a/components/ILIAS/StudyProgramme/classes/model/AutoMemberships/class.ilStudyProgrammeAutoMembershipsDBRepository.php +++ b/components/ILIAS/StudyProgramme/classes/model/AutoMemberships/class.ilStudyProgrammeAutoMembershipsDBRepository.php @@ -1,7 +1,5 @@ source_id, $this->enbl, $this->usr_id, - $this->dat + $this->dat, + false ); $this->assertInstanceOf( ilStudyProgrammeAutoMembershipSource::class, diff --git a/lang/ilias_de.lang b/lang/ilias_de.lang index 7c716ff55b62..6c66718c7001 100755 --- a/lang/ilias_de.lang +++ b/lang/ilias_de.lang @@ -15245,6 +15245,7 @@ search#:#search_filter_cd#:#Filter nach Erstellungsdatum search#:#search_for_crs_members#:#Nach Kursen suchen search#:#search_for_grp_members#:#Nach Gruppen suchen search#:#search_for_orgu_members#:#Nach Organisationseinheiten suchen +search#:#search_for_orgu_members_recursive#:#Darunterliegende einbeziehen? search#:#search_for_role_members#:#Nach Rollen suchen search#:#search_for_users#:#Nach Benutzern suchen search#:#search_grp_title#:#Gruppenname diff --git a/lang/ilias_en.lang b/lang/ilias_en.lang index 4dc63965fe88..49b59ba3109c 100755 --- a/lang/ilias_en.lang +++ b/lang/ilias_en.lang @@ -15176,6 +15176,7 @@ search#:#search_filter_cd#:#Filter by Creation Date search#:#search_for_crs_members#:#Search for Courses search#:#search_for_grp_members#:#Search for Groups search#:#search_for_orgu_members#:#Search for Organisational Units +search#:#search_for_orgu_members_recursive#:#Include Subunits? search#:#search_for_role_members#:#Search for Roles search#:#search_for_users#:#Search for Users search#:#search_grp_title#:#Group Name