Skip to content

Commit 5d498eb

Browse files
committed
Merge branch 'trunk' of https://github.com/ILIAS-eLearning/ILIAS into trunk
2 parents f8a0199 + c82d95e commit 5d498eb

31 files changed

Lines changed: 394 additions & 173 deletions

File tree

components/ILIAS/Administration/classes/SystemSupport/class.ilSystemSupportContactsGUI.php

Lines changed: 66 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -89,59 +89,90 @@ public function showContacts()
8989
$this->tpl->loadStandardTemplate();
9090
$this->tpl->setTitle($this->lng->txt("adm_support_contacts"));
9191

92-
$html = "";
93-
foreach (ilSystemSupportContacts::getValidSupportContactIds() as $c) {
94-
$pgui = new PublicProfileGUI($c);
95-
//$pgui->setBackUrl($this->ctrl->getLinkTargetByClass("ilinfoscreengui"));
96-
$pgui->setEmbedded(true);
97-
$html .= $pgui->getHTML();
92+
$content = [];
93+
if (self::isAnonymous() && !self::globalProfilesEnabled()) {
94+
$mails = [];
95+
foreach (ilSystemSupportContacts::getValidSupportContactIds() as $user_id) {
96+
$mail = ilObjUser::_lookupEmail($user_id);
97+
if ($mail) {
98+
$mails[] = $mail;
99+
}
100+
}
101+
$content[] = $this->ui->factory()->listing()->unordered(array_unique($mails));
102+
} else {
103+
foreach (ilSystemSupportContacts::getValidSupportContactIds() as $user_id) {
104+
if (self::isProfileVisible($user_id)) {
105+
$pgui = new PublicProfileGUI($user_id);
106+
$pgui->setEmbedded(true);
107+
$content[] = $this->ui->factory()->legacy()->content($pgui->getHTML());
108+
}
109+
}
98110
}
99111

100-
$f = $this->ui->factory();
101-
$r = $this->ui->renderer();
102-
$p = $f->panel()->standard(
112+
$panel = $this->ui->factory()->panel()->standard(
103113
$this->lng->txt("adm_support_contacts"),
104-
$f->legacy()->content($html)
114+
$content
105115
);
106116

107-
$this->tpl->setContent($r->render($p));
117+
$this->tpl->setContent($this->ui->renderer()->render($panel));
108118
$this->tpl->printToStdout();
109119
}
110120

111-
public static function getFooterLink(): null|URI|string
121+
122+
/**
123+
* Get a contact link to be shown in the footer
124+
*/
125+
public static function getFooterLink(): ?string
112126
{
113127
global $DIC;
114-
115-
$ilCtrl = $DIC->ctrl();
116-
$ilUser = $DIC->user();
117-
$uri = $DIC->http()->request()->getUri();
118-
119-
$users = ilSystemSupportContacts::getValidSupportContactIds();
120-
if (count($users) > 0) {
121-
// #17847 - we cannot use a proper GUI on the login screen
122-
if (!$ilUser->getId() || $ilUser->getId() == ANONYMOUS_USER_ID) {
123-
return "mailto:" . ilLegacyFormElementsUtil::prepareFormOutput(
124-
ilSystemSupportContacts::getMailsToAddress()
125-
);
126-
} else {
127-
$path = $ilCtrl->getLinkTargetByClass("ilsystemsupportcontactsgui", "", "", false, false);
128-
return new URI($uri->getScheme() . '://' . $uri->getHost() . '/' . $path);
129-
}
128+
if (!empty(ilSystemSupportContacts::getValidSupportContactIds())) {
129+
return $DIC->ctrl()->getLinkTargetByClass(self::class);
130130
}
131-
132131
return null;
133132
}
134133

135134
/**
136-
* Get footer text
137-
*
138-
* @return string footer text
135+
* Get the text for a contact link to be shown in the footer
139136
*/
140-
public static function getFooterText()
137+
public static function getFooterText(): string
141138
{
142139
global $DIC;
140+
return $DIC->language()->txt("contact_sysadmin");
141+
}
143142

144-
$lng = $DIC->language();
145-
return $lng->txt("contact_sysadmin");
143+
/**
144+
* Check if the profile of a user can be shown
145+
* - if it is published for www
146+
* - OR if it is published for users and the current user is logged in
147+
*/
148+
public static function isProfileVisible(int $user_id): bool
149+
{
150+
$user = new ilObjUser($user_id);
151+
$public = $user->getPref('public_profile');
152+
153+
if (self::isAnonymous()) {
154+
return $public === 'g' && self::globalProfilesEnabled();
155+
} else {
156+
return $public === 'g' || $public === 'y';
157+
}
158+
}
159+
160+
/**
161+
* Check if the current user is anonymous
162+
*/
163+
private static function isAnonymous(): bool
164+
{
165+
global $DIC;
166+
$current_user_id = $DIC->user()->getId();
167+
return $current_user_id === 0 || $current_user_id === ANONYMOUS_USER_ID;
168+
}
169+
170+
/**
171+
* Check if user profiles can be shown to anonymous users
172+
*/
173+
private static function globalProfilesEnabled(): bool
174+
{
175+
global $DIC;
176+
return $DIC->settings()->get('enable_global_profiles') ?? false;
146177
}
147178
}

components/ILIAS/COPage/COPage.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,18 @@ public function getTarget(): string
110110
return "assets/js/ilIntLink.js";
111111
}
112112
};
113+
// this is just a dummy to make the html export to the same
114+
// target assets/content_style/style.css work
115+
$contribute[Component\Resource\PublicAsset::class] = static fn() => new class () implements Component\Resource\PublicAsset {
116+
public function getSource(): string
117+
{
118+
return "components/ILIAS/COPage/css/content_base.css";
119+
}
120+
public function getTarget(): string
121+
{
122+
return "assets/content_style/style.css";
123+
}
124+
};
113125

114126
}
115127
}

components/ILIAS/COPage/classes/class.ilCOPageHTMLExport.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ public function exportStyles(): void
140140
} else {
141141
$this->export_collector->addDirectory(
142142
ilObjStyleSheet::getBasicImageDir(),
143-
"/basic_style/images"
143+
"/assets/basic_style/images"
144144
);
145145
$this->export_collector->addFile(
146146
"../components/ILIAS/COPage/css/content.css",
@@ -161,7 +161,7 @@ public function exportStyles(): void
161161
$this->export_collector->addContainerDirectory(
162162
$res_id->serialize(),
163163
"",
164-
"content_style"
164+
"assets/content_style"
165165
);
166166
}
167167
}
@@ -493,8 +493,12 @@ protected function initResourceTemplate(
493493
$this->global_screen->layout()->meta()->reset();
494494
$tpl = new ilGlobalTemplate($template_file, true, true, "components/ILIAS/COPage");
495495
$this->getPreparedMainTemplate($tpl);
496-
$tpl->addCss(\ilUtil::getStyleSheetLocation());
497-
$tpl->addCss(ilObjStyleSheet::getContentStylePath($this->getContentStyleId()));
496+
$this->global_screen->layout()->meta()->addCss(
497+
\ilUtil::getStyleSheetLocation()
498+
);
499+
$this->global_screen->layout()->meta()->addCss(
500+
\ilObjStyleSheet::getExportContentStylePath()
501+
);
498502
$tpl->addCss(ilObjStyleSheet::getSyntaxStylePath());
499503
return $tpl;
500504
}

components/ILIAS/Exercise/Assignment/class.ilExAssignment.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1476,6 +1476,8 @@ public static function sendFeedbackNotifications(
14761476
global $DIC;
14771477

14781478
$ilDB = $DIC->database();
1479+
$gui = $DIC->exercise()->internal()->gui();
1480+
$domain = $DIC->exercise()->internal()->domain();
14791481
$log = ilLoggerFactory::getLogger("exc");
14801482

14811483
$ass = new self($a_ass_id);
@@ -1504,6 +1506,24 @@ public static function sendFeedbackNotifications(
15041506
$ntf->setSubjectLangId("exc_feedback_notification_subject");
15051507
$ntf->setIntroductionLangId("exc_feedback_notification_body");
15061508
$ntf->addAdditionalInfo("exc_assignment", $ass->getTitle());
1509+
$ref_id = 0;
1510+
if ($a_user_id) { // link to assignment
1511+
$ref_id = $domain->permission()->getFirstRefIdWithPermission(
1512+
"read",
1513+
$ass->getExerciseId(),
1514+
$a_user_id
1515+
);
1516+
} else {
1517+
$ref_ids = ilObject::_getAllReferences($ass->getExerciseId());
1518+
if (count($ref_ids) === 1) {
1519+
$ref_id = current($ref_ids);
1520+
}
1521+
}
1522+
if ($ref_id > 0) {
1523+
$perm_link = $gui->permanentLink()->getPermanentLink($ref_id, $ass->getId());
1524+
$ntf->addAdditionalInfo("exc_link_to_assignment", $perm_link);
1525+
}
1526+
15071527
$ntf->setGotoLangId("exc_feedback_notification_link");
15081528
$ntf->setReasonLangId("exc_feedback_notification_reason");
15091529

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?php
2+
3+
/**
4+
* This file is part of ILIAS, a powerful learning management system
5+
* published by ILIAS open source e-Learning e.V.
6+
*
7+
* ILIAS is licensed with the GPL-3.0,
8+
* see https://www.gnu.org/licenses/gpl-3.0.en.html
9+
* You should have received a copy of said license along with the
10+
* source code, too.
11+
*
12+
* If this is not the case or you just want to try ILIAS, you'll find
13+
* us at:
14+
* https://www.ilias.de
15+
* https://github.com/ILIAS-eLearning
16+
*
17+
*********************************************************************/
18+
19+
declare(strict_types=1);
20+
21+
namespace ILIAS\Exercise\Permission;
22+
23+
use ILIAS\ResourceStorage\Stakeholder\ResourceStakeholder;
24+
use ILIAS\Exercise\InternalDomainService;
25+
26+
class PermissionManager
27+
{
28+
public function __construct(
29+
protected InternalDomainService $domain
30+
) {
31+
}
32+
33+
public function getFirstRefIdWithPermission(
34+
string $perm,
35+
int $obj_id,
36+
int $user_id
37+
): int {
38+
$access = $this->domain->access();
39+
40+
foreach (\ilObject::_getAllReferences($obj_id) as $ref_id) {
41+
if ($access->checkAccessOfUser($user_id, $perm, "", $ref_id)) {
42+
return $ref_id;
43+
}
44+
}
45+
return 0;
46+
}
47+
48+
}

components/ILIAS/Exercise/Service/classes/class.InternalDomainService.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
use ILIAS\Exercise\PeerReview\DomainService;
3131
use ILIAS\Exercise\Settings\SettingsManager;
3232
use ILIAS\Exercise\User\UserEvent;
33+
use ILIAS\Exercise\Permission\PermissionManager;
3334

3435
class InternalDomainService
3536
{
@@ -136,4 +137,11 @@ public function userEvent(): UserEvent
136137
);
137138
}
138139

140+
public function permission(): PermissionManager
141+
{
142+
return $this->instance["perm"] ??= new PermissionManager(
143+
$this
144+
);
145+
}
146+
139147
}

components/ILIAS/Export/HTML/class.Util.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,10 @@ public function exportResourceFiles(): void
152152
$target_dir = $this->target_dir;
153153
$css = $global_screen->layout()->meta()->getCss();
154154
foreach ($css->getItemsInOrderOfDelivery() as $item) {
155+
// skip dummy "assets/content_style/style.css"
156+
if (str_contains($item->getContent(), "assets/content_style")) {
157+
continue;
158+
}
155159
$this->exportResourceFile($target_dir, $item->getContent());
156160
}
157161
$js = $global_screen->layout()->meta()->getJs();

components/ILIAS/Export/Print/class.PrintProcessGUI.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -157,12 +157,7 @@ public function renderPrintView(int $content_style_id = 0): string
157157

158158
$tpl->setBodyClass($this->body_class);
159159
$tpl->addCss(\ilUtil::getStyleSheetLocation("filesystem"));
160-
$tpl->addCss(
161-
\ilObjStyleSheet::getContentStylePath(
162-
$content_style_id,
163-
false
164-
)
165-
);
160+
$tpl->addCss(\ilObjStyleSheet::getExportContentStylePath());
166161
$tpl->addCss(\ilObjStyleSheet::getContentPrintStyle());
167162
$tpl->addCss(\ilObjStyleSheet::getSyntaxStylePath());
168163

components/ILIAS/GlobalScreen/classes/UI/Footer/Entries/EntriesTable.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,15 @@ public function getRows(OrderingRowBuilder $row_builder, array $visible_column_i
6767
$nok = $this->pons->out()->nok();
6868

6969
foreach ($this->repository->allForParent($this->group->getId()) as $entry) {
70-
$title = $this->translations_repository->get($entry)->getDefault()?->getTranslation() ?? $entry->getTitle();
70+
if ($entry->isCore()) {
71+
$title = $this->collector->getSingleItemFromRaw(
72+
$this->identification->fromSerializedIdentification($entry->getId()),
73+
)?->getTitle() ?? 'Unknown';
74+
} else {
75+
$title = $this->translations_repository->get($entry)->getDefault()?->getTranslation(
76+
) ?? $entry->getTitle();
77+
}
78+
7179
$row = $row_builder->buildOrderingRow(
7280
$this->hash($entry->getId()),
7381
[

components/ILIAS/GlobalScreen/classes/UI/Footer/Groups/GroupsTable.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public function getRows(OrderingRowBuilder $row_builder, array $visible_column_i
7878
if ($group->isCore()) {
7979
$title = $this->collector->getSingleItemFromRaw(
8080
$this->identification->fromSerializedIdentification($group->getId()),
81-
)?->getTitle()??'';
81+
)?->getTitle() ?? 'Unknown';
8282
} else {
8383
$title = $this->translations_repository->get($group)->getDefault()?->getTranslation(
8484
) ?? $group->getTitle();

0 commit comments

Comments
 (0)