ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilStudyProgrammeMailMemberSearchGUI Class Reference
+ Collaboration diagram for ilStudyProgrammeMailMemberSearchGUI:

Public Member Functions

 __construct (ilCtrl $ctrl, ilGlobalTemplateInterface $tpl, ilLanguage $lng, ilAccessHandler $access, ILIAS\HTTP\Wrapper\WrapperFactory $http_wrapper, ILIAS\Refinery\Factory $refinery, ilPRGPermissionsHelper $permission_helper, protected int $context_prg_obj_id, protected ilPRGMessagePrinter $messages,)
 
 getAssignments ()
 
 setAssignments (array $assignments)
 
 getBackTarget ()
 
 setBackTarget (string $target)
 
 executeCommand ()
 

Protected Member Functions

 showSelectableUsers ()
 
 getProcessData ()
 
 getPRGMembersGUI ()
 
 retrieveUserIds ()
 
 sendMailToSelectedUsers ()
 
 generateContextArray ()
 
 redirectToParent ()
 
 createMailSignature ()
 
 getRootPrgRefId ()
 
 getRootPrgObjId ()
 

Protected Attributes

ilCtrl $ctrl
 
ilGlobalTemplateInterface $tpl
 
ilLanguage $lng
 
ilAccessHandler $access
 
ILIAS HTTP Wrapper WrapperFactory $http_wrapper
 
ILIAS Refinery Factory $refinery
 
array $assignments = []
 
array $user_ids = []
 
ilPRGPermissionsHelper $permission_helper
 

Private Attributes

string $back_target = null
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilStudyProgrammeMailMemberSearchGUI::__construct ( ilCtrl  $ctrl,
ilGlobalTemplateInterface  $tpl,
ilLanguage  $lng,
ilAccessHandler  $access,
ILIAS\HTTP\Wrapper\WrapperFactory  $http_wrapper,
ILIAS\Refinery\Factory  $refinery,
ilPRGPermissionsHelper  $permission_helper,
protected int  $context_prg_obj_id,
protected ilPRGMessagePrinter  $messages 
)

Definition at line 35 of file class.ilStudyProgrammeMailMemberSearchGUI.php.

45 {
46 $this->ctrl = $ctrl;
47 $this->tpl = $tpl;
48 $this->lng = $lng;
49 $this->access = $access;
50 $this->http_wrapper = $http_wrapper;
51 $this->refinery = $refinery;
52 $this->permission_helper = $permission_helper;
53
54 $this->lng->loadLanguageModule('mail');
55 $this->lng->loadLanguageModule('search');
56 }

References $access, $ctrl, $http_wrapper, $lng, $permission_helper, $refinery, $tpl, ILIAS\Repository\access(), ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), and ILIAS\Repository\refinery().

+ Here is the call graph for this function:

Member Function Documentation

◆ createMailSignature()

ilStudyProgrammeMailMemberSearchGUI::createMailSignature ( )
protected

Definition at line 238 of file class.ilStudyProgrammeMailMemberSearchGUI.php.

238 : string
239 {
240 $link = chr(13) . chr(10) . chr(13) . chr(10);
241 $link .= $this->lng->txt('prg_mail_permanent_link');
242 $link .= chr(13) . chr(10) . chr(13) . chr(10);
243 $link .= ilLink::_getLink($this->getRootPrgRefId());
244 return rawurlencode(base64_encode($link));
245 }

References getRootPrgRefId(), and ILIAS\Repository\lng().

Referenced by sendMailToSelectedUsers().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ executeCommand()

ilStudyProgrammeMailMemberSearchGUI::executeCommand ( )

Definition at line 78 of file class.ilStudyProgrammeMailMemberSearchGUI.php.

78 : void
79 {
80 $cmd = $this->ctrl->getCmd();
81
82 $this->ctrl->setReturn($this, '');
83
84 switch ($cmd) {
85 case 'showSelectableUsers':
86 case 'members':
87 $this->showSelectableUsers();
88 break;
89 case 'sendMailToSelectedUsers':
90 $this->user_ids = $this->retrieveUserIds();
92 break;
93 case 'mailUserMulti':
94 $this->user_ids = array_keys($this->getProcessData());
96 break;
97 case 'cancel':
98 $this->redirectToParent();
99 break;
100 default:
101 throw new Exception('Unknown command ' . $cmd);
102 }
103 }

References ILIAS\Repository\ctrl(), getProcessData(), redirectToParent(), retrieveUserIds(), sendMailToSelectedUsers(), and showSelectableUsers().

+ Here is the call graph for this function:

◆ generateContextArray()

ilStudyProgrammeMailMemberSearchGUI::generateContextArray ( )
protected

Definition at line 209 of file class.ilStudyProgrammeMailMemberSearchGUI.php.

209 : array
210 {
211 $context_array = [];
212 $ref_id = $this->getRootPrgRefId();
213 $type = ilObject::_lookupType($ref_id, true);
214 switch ($type) {
215 case 'prg':
216 if ($this->access->checkAccess('write', "", $ref_id)) {
217 $context_array = array(
219 'ref_id' => $ref_id,
220 'ts' => time()
221 );
222 }
223 break;
224 }
225 return $context_array;
226 }
final const string CONTEXT_KEY
static _lookupType(int $id, bool $reference=false)
$ref_id
Definition: ltiauth.php:66

References $ref_id, ilObject\_lookupType(), ILIAS\Repository\access(), ilMailFormCall\CONTEXT_KEY, getRootPrgRefId(), and ilStudyProgrammeMailTemplateContext\ID.

Referenced by sendMailToSelectedUsers().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAssignments()

ilStudyProgrammeMailMemberSearchGUI::getAssignments ( )

Definition at line 58 of file class.ilStudyProgrammeMailMemberSearchGUI.php.

References $assignments.

Referenced by getProcessData(), getRootPrgObjId(), and getRootPrgRefId().

+ Here is the caller graph for this function:

◆ getBackTarget()

ilStudyProgrammeMailMemberSearchGUI::getBackTarget ( )

Definition at line 68 of file class.ilStudyProgrammeMailMemberSearchGUI.php.

References $back_target.

Referenced by redirectToParent().

+ Here is the caller graph for this function:

◆ getPRGMembersGUI()

ilStudyProgrammeMailMemberSearchGUI::getPRGMembersGUI ( )
protected

Definition at line 156 of file class.ilStudyProgrammeMailMemberSearchGUI.php.

157 {
158 return ilStudyProgrammeDIC::dic()['ilObjStudyProgrammeMembersGUI'];
159 }
@ilCtrl_Calls ilObjStudyProgrammeMembersGUI: ilStudyProgrammeRepositorySearchGUI @ilCtrl_Calls ilObjS...

References ilStudyProgrammeDIC\dic().

Referenced by sendMailToSelectedUsers().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getProcessData()

ilStudyProgrammeMailMemberSearchGUI::getProcessData ( )
protected

Definition at line 114 of file class.ilStudyProgrammeMailMemberSearchGUI.php.

114 : array
115 {
116 $data = [];
117 $usr_ids = [];
118 foreach ($this->getAssignments() as $assignment) {
119 $usr_id = $assignment->getUserId();
120 $name = ilObjUser::_lookupName($usr_id);
121 $login = ilObjUser::_lookupLogin($usr_id);
122 $publicName = $name['lastname'] . ', ' . $name['firstname'];
123 $data[] = [
124 'user_id' => $usr_id,
125 'login' => $login,
126 'name' => $publicName,
127 'root_id' => $assignment->getRootId()
128 ];
129 $usr_ids[] = $usr_id;
130 }
131
132 $allowed_user_ids = $this->permission_helper->filterUserIds(
133 array_unique($usr_ids),
135 );
136
137 $ret = [];
138 $foreign = $this->messages->getMessageCollection('mails_foreign_assignment');
139
140 foreach($data as $entry) {
141 if($entry['root_id'] === $this->context_prg_obj_id) {
142 $ret[$entry['user_id']] = $entry;
143 } else {
144 $foreign->add(false, 'foreign_assignment', $entry['name']);
145 }
146 }
147
148 if($foreign->hasErrors()) {
149 $this->messages->showMessages($foreign);
150 }
151
152
153 return $ret;
154 }
static _lookupName(int $a_user_id)
static _lookupLogin(int $a_user_id)

References $data, ilObjUser\_lookupLogin(), ilObjUser\_lookupName(), getAssignments(), and ilOrgUnitOperation\OP_MANAGE_MEMBERS.

Referenced by executeCommand(), and showSelectableUsers().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getRootPrgObjId()

ilStudyProgrammeMailMemberSearchGUI::getRootPrgObjId ( )
protected

Definition at line 254 of file class.ilStudyProgrammeMailMemberSearchGUI.php.

254 : int
255 {
256 $assignments = $this->getAssignments();
257 $assignment = array_shift($assignments);
258 return (int) $assignment->getRootId();
259 }

References $assignments, and getAssignments().

Referenced by showSelectableUsers().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getRootPrgRefId()

ilStudyProgrammeMailMemberSearchGUI::getRootPrgRefId ( )
protected

Definition at line 247 of file class.ilStudyProgrammeMailMemberSearchGUI.php.

247 : int
248 {
249 $assignments = $this->getAssignments();
250 $assignment = array_shift($assignments);
251 return ilObjStudyProgramme::getRefIdFor($assignment->getRootId());
252 }
static getRefIdFor(int $obj_id)

References $assignments, getAssignments(), and ilObjStudyProgramme\getRefIdFor().

Referenced by createMailSignature(), and generateContextArray().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ redirectToParent()

ilStudyProgrammeMailMemberSearchGUI::redirectToParent ( )
protected

Definition at line 228 of file class.ilStudyProgrammeMailMemberSearchGUI.php.

228 : void
229 {
230 $back_target = $this->getBackTarget();
231 if (is_null($back_target)) {
232 throw new LogicException("Can't redirect. No back target given.");
233 }
234
235 $this->ctrl->redirectToURL($back_target);
236 }

References $back_target, ILIAS\Repository\ctrl(), and getBackTarget().

Referenced by executeCommand().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ retrieveUserIds()

ilStudyProgrammeMailMemberSearchGUI::retrieveUserIds ( )
protected

Definition at line 161 of file class.ilStudyProgrammeMailMemberSearchGUI.php.

161 : array
162 {
163 $user_ids = [];
164 if ($this->http_wrapper->post()->has("user_ids")) {
165 $user_ids = $this->http_wrapper->post()->retrieve(
166 "user_ids",
167 $this->refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->int())
168 );
169 }
170 return $user_ids;
171 }

References $user_ids, and ILIAS\Repository\refinery().

Referenced by executeCommand().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sendMailToSelectedUsers()

ilStudyProgrammeMailMemberSearchGUI::sendMailToSelectedUsers ( )
protected

Definition at line 173 of file class.ilStudyProgrammeMailMemberSearchGUI.php.

173 : bool
174 {
176 if (!count($user_ids)) {
177 $this->tpl->setOnScreenMessage("failure", $this->lng->txt("no_checkbox"));
178 $this->showSelectableUsers();
179 return false;
180 }
181
182 $rcps = array();
183 foreach ($user_ids as $usr_id) {
184 $rcps[] = ilObjUser::_lookupLogin($usr_id);
185 }
186
187 if (!count(array_filter($rcps))) {
188 $this->tpl->setOnScreenMessage("failure", $this->lng->txt("no_checkbox"));
189 $this->showSelectableUsers();
190 return false;
191 }
193
194 $members_gui = $this->getPRGMembersGUI();
195 $this->ctrl->redirectToURL(ilMailFormCall::getRedirectTarget(
196 $members_gui,
197 'view',
198 array(),
199 array(
200 'type' => 'new',
201 'sig' => $this->createMailSignature()
202 ),
203 $this->generateContextArray()
204 ));
205
206 return true;
207 }
static getRedirectTarget( $gui, string $cmd, array $gui_params=[], array $mail_params=[], array $context_params=[])
static setRecipients(array $recipients, string $type='to')

References $user_ids, ilObjUser\_lookupLogin(), createMailSignature(), ILIAS\Repository\ctrl(), generateContextArray(), getPRGMembersGUI(), ilMailFormCall\getRedirectTarget(), ILIAS\Repository\lng(), ilMailFormCall\setRecipients(), and showSelectableUsers().

Referenced by executeCommand().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setAssignments()

ilStudyProgrammeMailMemberSearchGUI::setAssignments ( array  $assignments)

Definition at line 63 of file class.ilStudyProgrammeMailMemberSearchGUI.php.

63 : void
64 {
65 $this->assignments = $assignments;
66 }

References $assignments.

◆ setBackTarget()

ilStudyProgrammeMailMemberSearchGUI::setBackTarget ( string  $target)

Definition at line 73 of file class.ilStudyProgrammeMailMemberSearchGUI.php.

73 : void
74 {
75 $this->back_target = $target;
76 }

◆ showSelectableUsers()

ilStudyProgrammeMailMemberSearchGUI::showSelectableUsers ( )
protected

Definition at line 105 of file class.ilStudyProgrammeMailMemberSearchGUI.php.

105 : void
106 {
107 $this->tpl->loadStandardTemplate();
108 $tbl = new ilStudyProgrammeMailMemberSearchTableGUI($this, $this->getRootPrgObjId(), 'showSelectableUsers');
109 $tbl->setData($this->getProcessData());
110
111 $this->tpl->setContent($tbl->getHTML());
112 }

References getProcessData(), and getRootPrgObjId().

Referenced by executeCommand(), and sendMailToSelectedUsers().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $access

ilAccessHandler ilStudyProgrammeMailMemberSearchGUI::$access
protected

Definition at line 26 of file class.ilStudyProgrammeMailMemberSearchGUI.php.

Referenced by __construct().

◆ $assignments

array ilStudyProgrammeMailMemberSearchGUI::$assignments = []
protected

◆ $back_target

string ilStudyProgrammeMailMemberSearchGUI::$back_target = null
private

◆ $ctrl

ilCtrl ilStudyProgrammeMailMemberSearchGUI::$ctrl
protected

Definition at line 23 of file class.ilStudyProgrammeMailMemberSearchGUI.php.

Referenced by __construct().

◆ $http_wrapper

ILIAS HTTP Wrapper WrapperFactory ilStudyProgrammeMailMemberSearchGUI::$http_wrapper
protected

Definition at line 27 of file class.ilStudyProgrammeMailMemberSearchGUI.php.

Referenced by __construct().

◆ $lng

ilLanguage ilStudyProgrammeMailMemberSearchGUI::$lng
protected

Definition at line 25 of file class.ilStudyProgrammeMailMemberSearchGUI.php.

Referenced by __construct().

◆ $permission_helper

ilPRGPermissionsHelper ilStudyProgrammeMailMemberSearchGUI::$permission_helper
protected

Definition at line 32 of file class.ilStudyProgrammeMailMemberSearchGUI.php.

Referenced by __construct().

◆ $refinery

ILIAS Refinery Factory ilStudyProgrammeMailMemberSearchGUI::$refinery
protected

Definition at line 28 of file class.ilStudyProgrammeMailMemberSearchGUI.php.

Referenced by __construct().

◆ $tpl

ilGlobalTemplateInterface ilStudyProgrammeMailMemberSearchGUI::$tpl
protected

Definition at line 24 of file class.ilStudyProgrammeMailMemberSearchGUI.php.

Referenced by __construct().

◆ $user_ids

array ilStudyProgrammeMailMemberSearchGUI::$user_ids = []
protected

The documentation for this class was generated from the following file: