Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge of Ilias8 with eduid #6

Open
wants to merge 25 commits into
base: ilias8
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
49c8852
Convert to Short Array Syntax
kergomard Dec 4, 2023
0a0c067
Some Boyscouting
kergomard Dec 4, 2023
42d2230
Add EduID Info To EventoUser
kergomard Dec 4, 2023
4072a2d
Update for EduID
kergomard Dec 6, 2023
e5bcc5f
Remove User from Follow-up Role
kergomard Dec 13, 2023
39cc9ff
Add Function To Save Role Removal Date To Custom Field
kergomard Dec 13, 2023
7b59916
Fixes After Tests
kergomard Dec 15, 2023
dc45e5a
Fix Access to Undeclared Class Constant
kergomard Jan 16, 2024
54c2bd4
RoleId Might be String
kergomard Jan 17, 2024
0afda92
Add Changing External Account
kergomard Jan 17, 2024
ed70fcf
Fix Role and External Account Assignment
kergomard Jan 18, 2024
d3c10e1
Fix Misspelled Variablename
kergomard Jan 19, 2024
fd21dba
Fix Role Removal and Move to Consts for Defaults
kergomard Jan 20, 2024
0023532
Fix Removal of Date Tracking
kergomard Feb 1, 2024
6989c1b
Fix Namespacing of PHP-Constants
kergomard Feb 1, 2024
2696152
Fix Wrong Solution for Constants
kergomard Feb 5, 2024
b992ea4
Change Design & Kunst to Design Film
fajaeggi Mar 26, 2024
7b7240e
PATCH HSLU: Fix for Evento Event Import with members
msalterhslu Apr 2, 2024
0fe4753
PATCH HSLU: Fix for Evento Event Import with members - typo
msalterhslu Apr 3, 2024
83a0a3c
PATCH HSLU: Fix for Evento User Import not creating new users
msalterhslu Apr 3, 2024
ebbfbae
Typo id_by_external_account instead of id_external_account
msalterhslu Jun 18, 2024
8e15738
Merge branch 'ilias8' into ilias8_with_eduid
msalterhslu Jul 4, 2024
3862c16
Insert crevento_evnto_usrs record if missing
msalterhslu Jul 25, 2024
7af89d5
Insert crevento_evnto_usrs record if missing - typo corrected
msalterhslu Jul 25, 2024
b55dabd
Truncate evento_description to 128 AND update crevento_parent_events …
msalterhslu Dec 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions classes/administration/AdminScriptPageGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,9 @@ public function __construct(\ilEventoImportPlugin $plugin_object, \ilGlobalPageT
$this->user = $user;
$this->error = $error;

$this->ref_id = 31;
if (isset($query_params['ref_id'])) {
$this->ref_id = (int) $query_params['ref_id'];
} else {
$this->ref_id = 31;
}

$this->scripts = [
Expand Down Expand Up @@ -126,7 +125,7 @@ public function executeCommandAndRenderGUI()
$f->legacy($script->getParameterFormUI()->getHTML())
);

if(!is_null($executed_script) && $script->getScriptId() == $executed_script) {
if (!is_null($executed_script) && $script->getScriptId() == $executed_script) {
try {
$modal = $script->getResultModalFromRequest(
$this->ctrl->getCmd(),
Expand Down
3 changes: 2 additions & 1 deletion classes/administration/EventLocationsAdminGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace EventoImport\administration;

use EventoImport\config\locations\EventLocationsRepository;
use EventoImport\config\locations\BaseLocationConfiguration;
use ILIAS\DI\UIServices;

class EventLocationsAdminGUI
Expand All @@ -29,7 +30,7 @@ public function getEventLocationsPanelHTML() : string
$ui_components = [];

// Show Location settings from the cron-job
$json_settings = $this->settings->get('crevento_location_settings');
$json_settings = $this->settings->get(BaseLocationConfiguration::CONF_LOCATIONS);
$locations_settings = $json_settings ? json_decode($json_settings, true) : [];
if (!is_array($locations_settings)) {
$locations_settings = [];
Expand Down
70 changes: 37 additions & 33 deletions classes/administration/EventLocationsBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function __construct(EventLocationsRepository $locations_repository, \ilT

$this->hard_coded_department_mapping = [
"Hochschule Luzern" => "HSLU",
"Design & Kunst" => "DK",
"Design Film Kunst" => "DK",
"Informatik" => "I",
"Musik" => "M",
"Soziale Arbeit" => "SA",
Expand Down Expand Up @@ -47,13 +47,15 @@ public function buildCategoryObjectsForConfiguredKinds(array $locations_settings

foreach ($locations_settings['departments'] as $department) {
$department_ref_id = $this->fetchRefIdForObjTitle($repository_root_ref_id, $department);
if ($department_ref_id) {
foreach ($locations_settings['kinds'] as $kind) {
$kind_ref_id = $this->fetchRefIdForObjTitle($department_ref_id, $kind);
if (is_null($kind_ref_id)) {
$this->createCategoryObject($department_ref_id, $kind);
$newly_created_locations[] = strip_tags("$department/$kind");
}
if ($department_ref_id === null) {
continue;
}

foreach ($locations_settings['kinds'] as $kind) {
$kind_ref_id = $this->fetchRefIdForObjTitle($department_ref_id, $kind);
if (is_null($kind_ref_id)) {
$this->createCategoryObject($department_ref_id, $kind);
$newly_created_locations[] = strip_tags("$department/$kind");
}
}
}
Expand All @@ -68,16 +70,16 @@ public function getListOfMissingKindCategories(array $locations_settings) : arra
$missing_locations = [];
foreach ($locations_settings['departments'] as $department) {
$department_ref_id = $this->fetchRefIdForObjTitle($repository_root_ref_id, $department);
if (!is_null($department_ref_id)) {
foreach ($locations_settings['kinds'] as $kind) {
$kind_ref_id = $this->fetchRefIdForObjTitle($department_ref_id, $kind);
if (is_null($kind_ref_id)) {
$missing_locations[] = strip_tags("/$department/$kind/*");
}
}
} else {
if (is_null($department_ref_id)) {
$missing_locations[] = strip_tags("/$department/*");
}

foreach ($locations_settings['kinds'] as $kind) {
$kind_ref_id = $this->fetchRefIdForObjTitle($department_ref_id, $kind);
if (is_null($kind_ref_id)) {
$missing_locations[] = strip_tags("/$department/$kind/*");
}
}
}

return $missing_locations;
Expand All @@ -104,15 +106,13 @@ private function createCategoryObject(int $parent_ref_id, string $category_title
$new_category->setPermissions($parent_ref_id);

// default: sort by title
include_once('Services/Container/classes/class.ilContainerSortingSettings.php');
$settings = new \ilContainerSortingSettings($new_category->getId());
$settings->setSortMode(\ilContainer::SORT_TITLE);
$settings->save();

try {
// inherit parents content style, if not individual
$parent_id = \ilObject::_lookupObjId($parent_ref_id);
include_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php");
$style_id = \ilObjStyleSheet::lookupObjectStyle($parent_id);
if ($style_id > 0) {
if (\ilObjStyleSheet::_lookupStandard($style_id)) {
Expand All @@ -129,7 +129,7 @@ private function fetchRefIdForObjTitle(int $root_ref_id, string $searched_obj_ti
{
foreach ($this->tree->getChildsByType($root_ref_id, 'cat') as $child_node) {
$child_ref = $child_node['child'];
$obj_id = \ilObject::_lookupObjectId($child_ref);
$obj_id = \ilObject::_lookupObjectId((int) $child_ref);
if (\ilObject::_lookupTitle($obj_id) == $searched_obj_title) {
return (int) $child_ref;
}
Expand All @@ -152,20 +152,24 @@ private function fillRepositoryLocationsTable(array $locations_settings) : void
$repository_root_ref_id = 1;
foreach ($locations_settings['departments'] as $department) {
$department_ref_id = $this->fetchRefIdForObjTitle($repository_root_ref_id, $department);
if ($department_ref_id) {
foreach ($locations_settings['kinds'] as $kind) {
$kind_ref_id = $this->fetchRefIdForObjTitle($department_ref_id, $kind);
if ($kind_ref_id) {
foreach ($this->tree->getChildsByType($kind_ref_id, 'cat') as $child_node) {
if ($this->isPossibleYearCategory($child_node)) {
$this->locations_repository->addNewLocation(
$this->getMappedDepartmentName($department),
$kind,
(int) $child_node['title'],
(int) $child_node['ref_id']
);
}
}
if ($department_ref_id === null) {
continue;
}

foreach ($locations_settings['kinds'] as $kind) {
$kind_ref_id = $this->fetchRefIdForObjTitle($department_ref_id, $kind);
if ($kind_ref_id === null) {
continue;
}

foreach ($this->tree->getChildsByType($kind_ref_id, 'cat') as $child_node) {
if ($this->isPossibleYearCategory($child_node)) {
$this->locations_repository->addNewLocation(
$this->getMappedDepartmentName($department),
$kind,
(int) $child_node['title'],
(int) $child_node['ref_id']
);
}
}
}
Expand Down
90 changes: 47 additions & 43 deletions classes/administration/EventoImportApiTester.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,38 +39,40 @@ public function fetchDataRecord(string $cmd, int $id) : ?ApiDataModelBase
$api_importer_settings->getMaxRetries()
);
return $importer->fetchUserDataRecordById($id);
} else {
if ($cmd == 'event') {
$importer = new EventoEventImporter(
$request_client,
$iterator,
$logger,
$api_importer_settings->getTimeoutAfterRequest(),
$api_importer_settings->getMaxRetries()
);
return $importer->fetchEventDataRecordById($id);
} else {
if ($cmd == 'photo') {
$importer = new EventoUserPhotoImporter(
$request_client,
$api_importer_settings->getTimeoutAfterRequest(),
$api_importer_settings->getMaxRetries(),
$logger
);
return $importer->fetchUserPhotoDataById($id);
} else {
if ($cmd == 'admin') {
$importer = new EventoAdminImporter(
$request_client,
$logger,
$api_importer_settings->getTimeoutAfterRequest(),
$api_importer_settings->getMaxRetries()
);
return $importer->fetchEventAdminDataRecordById($id);
}
}
}
}

if ($cmd == 'event') {
$importer = new EventoEventImporter(
$request_client,
$iterator,
$logger,
$api_importer_settings->getTimeoutAfterRequest(),
$api_importer_settings->getMaxRetries()
);
return $importer->fetchEventDataRecordById($id);
}

if ($cmd == 'photo') {
$importer = new EventoUserPhotoImporter(
$request_client,
$api_importer_settings->getTimeoutAfterRequest(),
$api_importer_settings->getMaxRetries(),
$logger
);
return $importer->fetchUserPhotoDataById($id);
}

if ($cmd == 'admin') {
$importer = new EventoAdminImporter(
$request_client,
$logger,
$api_importer_settings->getTimeoutAfterRequest(),
$api_importer_settings->getMaxRetries()
);
return $importer->fetchEventAdminDataRecordById($id);
}

return null;
}

public function fetchDataSet(string $cmd, int $skip, int $take) : array
Expand All @@ -90,18 +92,20 @@ public function fetchDataSet(string $cmd, int $skip, int $take) : array
$api_importer_settings->getMaxRetries()
);
return $importer->fetchSpecificUserDataSet($skip, $take);
} else {
if ($cmd == 'event') {
$importer = new EventoEventImporter(
$request_client,
$iterator,
$logger,
$api_importer_settings->getTimeoutAfterRequest(),
$api_importer_settings->getMaxRetries()
);
return $importer->fetchSpecificEventDataSet($skip, $take);
}
}

if ($cmd == 'event') {
$importer = new EventoEventImporter(
$request_client,
$iterator,
$logger,
$api_importer_settings->getTimeoutAfterRequest(),
$api_importer_settings->getMaxRetries()
);
return $importer->fetchSpecificEventDataSet($skip, $take);
}

return [];
}

public function fetchParameterlessDataset() : array
Expand All @@ -125,7 +129,7 @@ private function buildDataSource(ImporterApiSettings $api_importer_settings) : R
return new RestClientService(
$api_importer_settings->getUrl(),
$api_importer_settings->getTimeoutAfterRequest(),
$api_importer_settings->getApikey(),
$api_importer_settings->getApiKey(),
$api_importer_settings->getApiSecret()
);
}
Expand Down
18 changes: 11 additions & 7 deletions classes/administration/EventoImportApiTesterGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,25 +185,29 @@ private function buildMessageForNextPage(string $infos, string $output) : string

public function getApiDataAsString($cmd) : string
{
if ($cmd == 'by_id') {
if ($cmd === 'by_id') {
$form = $this->initDataRecordForm()->withRequest($this->request);
$data = $form->getData();

if ($data) {
return $this->fetchDataRecordFromFormInput(...$data[0]);
} else {
return "Form data Invalid";
}
} else if ($cmd == 'data_set') {

return "Form data Invalid";
}

if ($cmd === 'data_set') {
$form = $this->initDataSetForm()->withRequest($this->request);
$data = $form->getData();

if ($data) {
return $this->fetchDataSetFromFormInput(...$data[0]);
} else {
return "Form data Invalid";
}
} else if ($cmd == 'parameterless') {

return "Form data Invalid";
}

if ($cmd === 'parameterless') {
return $this->fetchParameterlessDataset();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ private function buildEventImporter($db)
new RestClientService(
$api_settings->getUrl(),
$api_settings->getTimeoutFailedRequest(),
$api_settings->getApikey(),
$api_settings->getApiKey(),
$api_settings->getApiSecret()
),
new ImporterIterator($api_settings->getPageSize()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function getParameterFormUI() : \ilPropertyFormGUI
public function getResultModalFromRequest(string $cmd, Factory $f) : Modal
{
$form = $this->getParameterFormUI();
if(!$form->checkInput()) {
if (!$form->checkInput()) {
throw new \InvalidArgumentException("Invalid Form Input!");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ private function listParticipantsInModal(Factory $f) : Modal
$repo = new IliasEventoEventObjectRepository($this->db);

$form = $this->getParameterFormUI();
if(!$form->checkInput()) {
if (!$form->checkInput()) {
throw new \InvalidArgumentException('Invalid form input');
}

Expand Down Expand Up @@ -136,13 +136,13 @@ private function listParticipantsInModal(Factory $f) : Modal
private function reAddParticipants($f) : Modal
{
$query_params = $this->request->getQueryParams();
if(!isset($query_params['readd_to_event'])) {
if (!isset($query_params['readd_to_event'])) {
throw new \InvalidArgumentException('No Event ID to readd participants');
}
$event = $this->repo->getEventByEventoId((int) $query_params['readd_to_event']);

$readd_form = $this->getFormWithRemovedUsers($event);
if(!$readd_form->checkInput()) {
if (!$readd_form->checkInput()) {
throw new \InvalidArgumentException('Invalid form input');
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function getParameterFormUI() : \ilPropertyFormGUI
public function getResultModalFromRequest(string $cmd, Factory $f) : Modal
{
$form = $this->getParameterFormUI();
if(!$form->checkInput() || $cmd != self::CMD_SET_PERMISSION) {
if (!$form->checkInput() || $cmd != self::CMD_SET_PERMISSION) {
throw new \InvalidArgumentException("Invalid Form Input!");
}

Expand All @@ -68,9 +68,9 @@ public function getResultModalFromRequest(string $cmd, Factory $f) : Modal
$obj_ref_id = (int) $row[HiddenAdminsTableDef::COL_OBJECT_REF_ID];
if (!\ilObject::_exists($role_id)) {
$errors[] = "Role with role_id $role_id does not exist";
} else if (!\ilObject::_exists($obj_ref_id, true)) {
} elseif (!\ilObject::_exists($obj_ref_id, true)) {
$errors[] = "Object with ref_id $obj_ref_id does not exist";
} else if (!$this->tree->isInTree($obj_ref_id)) {
} elseif (!$this->tree->isInTree($obj_ref_id)) {
$errors[] = "Object with ref_id $obj_ref_id is not in tree";
} else {
$this->resetPermissionsForRole(
Expand Down
Loading