ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
SharedNotification.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
24{
25 protected array $shared_to_obj_ids = [];
26 protected \ilObjUser $user;
27
28 public function __construct()
29 {
30 global $DIC;
31 $this->user = $DIC->user();
33 }
34
35 public function setSharedToObjectIds(array $a_val): void
36 {
37 $this->shared_to_obj_ids = $a_val;
38 }
39
40 public function send(): bool
41 {
42 $rcp = $this->user->getId();
43
44 $this->initLanguage($rcp);
45 $this->initMail();
46 $this->setSubject(
47 sprintf(
48 $this->getLanguageText('prtf_successfully_shared_prtf'),
49 $this->getObjectTitle(true)
50 )
51 );
52 $this->setBody(\ilMail::getSalutation($rcp, $this->getLanguage()));
53 $this->appendBody("\n\n");
54 $this->appendBody(
55 sprintf(
56 $this->getLanguageText('prtf_successfully_shared_prtf_body'),
57 $this->getObjectTitle(false)
58 )
59 );
61 $this->appendBody("\n\n");
62 $this->appendBody($this->getLanguageText('prtf_permanent_link'));
63 $this->appendBody("\n");
64 $this->appendBody(\ilLink::_getStaticLink($this->getObjId(), "prtf"));
65 $this->getMail()->appendInstallationSignature(true);
66
67 $this->sendMail(array($rcp));
68
69 return true;
70 }
71
72 protected function appendObjectInformation(): void
73 {
74 $users = [];
75 foreach ($this->shared_to_obj_ids as $obj_id) {
77 switch ($type) {
78 case "crs":
79 case "grp":
80 $this->appendBody("\n\n" . $this->getLanguage()->txt("obj_" . $type) . ": " .
82 break;
83 case "usr":
85 break;
86 }
87 }
88 if (count($users) > 1) {
89 $this->appendBody("\n\n" . $this->getLanguage()->txt("users") . ": ");
90 $this->appendBody("\n" . implode("\n", $users));
91 }
92 if (count($users) === 1) {
93 $this->appendBody("\n\n" . $this->getLanguage()->txt("user") . ": " . current($users));
94 }
95 if (in_array(\ilWorkspaceAccessGUI::PERMISSION_REGISTERED, $this->shared_to_obj_ids, true)) {
96 $this->appendBody("\n\n" . $this->getLanguage()->txt("wsp_set_permission_registered"));
97 }
98 if (in_array(\ilWorkspaceAccessGUI::PERMISSION_ALL, $this->shared_to_obj_ids, true)) {
99 $this->appendBody("\n\n" . $this->getLanguage()->txt("wsp_set_permission_all"));
100 }
101 if (in_array(\ilWorkspaceAccessGUI::PERMISSION_ALL_PASSWORD, $this->shared_to_obj_ids, true)) {
102 $this->appendBody("\n\n" . $this->getLanguage()->txt("wsp_set_permission_all_password"));
103 }
104 }
105
106 protected function initLanguage(int $a_usr_id): void
107 {
108 parent::initLanguage($a_usr_id);
109 $this->getLanguage()->loadLanguageModule('prtf');
110 $this->getLanguage()->loadLanguageModule('wsp');
111 }
112}
getObjectTitle(bool $a_shorten=false)
sendMail(array $a_rcp, bool $a_parse_recipients=true)
getLanguageText(string $a_keyword)
setSubject(string $a_subject)
static getSalutation(int $a_usr_id, ?ilLanguage $a_language=null)
static _lookupType(int $id, bool $reference=false)
static _lookupTitle(int $obj_id)
static getNamePresentation( $a_user_id, bool $a_user_image=false, bool $a_profile_link=false, string $a_profile_back_link='', bool $a_force_first_lastname=false, bool $a_omit_login=false, bool $a_sortable=true, bool $a_return_data_array=false, $a_ctrl_path=null)
Default behaviour is:
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26