ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilMailMemberSearchGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2015 ILIAS open source, Extended GPL, see docs/LICENSE */
3
10{
14 protected $mail_roles;
15
19 protected $gui;
20
28 protected $objParticipants = NULL;
29
33 protected $ctrl;
34
38 protected $tpl;
39
43 protected $lng;
44
48 protected $access;
49
57 {
58 global $DIC;
59
60 $this->ctrl = $DIC['ilCtrl'];
61 $this->tpl = $DIC['tpl'];
62 $this->lng = $DIC['lng'];
63 $this->access = $DIC['ilAccess'];
64
65 $this->lng->loadLanguageModule('mail');
66 $this->lng->loadLanguageModule('search');
67
68 $this->gui = $gui;
69 $this->ref_id = $ref_id;
70
71 $this->objMailMemberRoles = $objMailMemberRoles;
72 $this->mail_roles = $objMailMemberRoles->getMailRoles($ref_id);
73 }
74
78 public function executeCommand()
79 {
80 $next_class = $this->ctrl->getNextClass($this);
81 $cmd = $this->ctrl->getCmd();
82
83 $this->ctrl->setReturn($this,'');
84
85 switch($next_class)
86 {
87 default:
88 switch($cmd)
89 {
90 case 'sendMailToSelectedUsers':
92 break;
93
94 case 'showSelectableUsers':
95 $this->showSelectableUsers();
96 break;
97
98 case 'nextMailForm':
99 $this->nextMailForm();
100 break;
101
102 case 'cancel':
104 break;
105
106 default:
107 if(isset($_GET['returned_from_mail']) && $_GET['returned_from_mail'] == '1')
108 {
110 }
111 $this->showSearchForm();
112 break;
113 }
114 break;
115 }
116 return true;
117 }
118
119 private function redirectToParentReferer()
120 {
121 $redirect_target = $this->getStoredReferer();
122 $this->unsetStoredReferer();
123 ilUtil::redirect($redirect_target);
124 }
125
129 public function storeReferer()
130 {
131 $referer = ilSession::get('referer');
132 ilSession::set('ilMailMemberSearchGUIReferer', $referer);
133 }
134
138 private function getStoredReferer()
139 {
140 $stored_referer = ilSession::get('ilMailMemberSearchGUIReferer');
141 return (strlen($stored_referer) ? $stored_referer : false);
142 }
143
147 private function unsetStoredReferer()
148 {
149 ilSession::set('ilMailMemberSearchGUIReferer','');
150 }
151
155 protected function nextMailForm()
156 {
157 $form = $this->initMailToMembersForm();
158 if($form->checkInput())
159 {
160 if($form->getInput('mail_member_type') == 'mail_member_roles')
161 {
162 if(count($form->getInput('roles')) > 0)
163 {
164 $role_mail_boxes = array();
165 $roles = $form->getInput('roles');
166 foreach($roles as $role_id)
167 {
168 $mailbox = $this->objMailMemberRoles->getMailboxRoleAddress($role_id);
169 $role_mail_boxes[] = $mailbox;
170 }
171
172 require_once 'Services/Mail/classes/class.ilMailFormCall.php';
173 $_SESSION['mail_roles'] = $role_mail_boxes;
174
176 $this, 'showSearchForm',
177 array('type' => 'role'),
178 array(
179 'type' => 'role',
180 'rcp_to' => implode(',', $role_mail_boxes),
181 'sig' => $this->gui->createMailSignature()
182 ),
183 $this->generateContextArray()
184 ));
185 }
186 else
187 {
188 $form->setValuesByPost();
189 ilUtil::sendFailure($this->lng->txt('no_checkbox'));
190 $this->showSearchForm();
191 return;
192 }
193 }
194 else
195 {
196 $this->showSelectableUsers();
197 return;
198 }
199 }
200
201 $form->setValuesByPost();
202 $this->showSearchForm();
203 }
204
208 protected function generateContextArray()
209 {
210 $context_array = array();
211 require_once 'Modules/Course/classes/class.ilCourseMailTemplateTutorContext.php';
212 if($this->access->checkAccess('write',"",$this->ref_id) )
213 {
214 $context_array = array(
216 'ref_id' => $this->ref_id,
217 'ts' => time()
218 );
219 }
220
221 return $context_array;
222 }
223
227 protected function showSelectableUsers()
228 {
229 include_once './Services/Contact/classes/class.ilMailMemberSearchTableGUI.php';
230 include_once './Services/Contact/classes/class.ilMailMemberSearchDataProvider.php';
231
232 $this->tpl->getStandardTemplate();
233 $tbl = new ilMailMemberSearchTableGUI($this, 'showSelectableUsers');
235 $tbl->setData($provider->getData());
236
237 $this->tpl->setContent($tbl->getHTML());
238 }
239
243 protected function sendMailToSelectedUsers()
244 {
245 if(!count($_POST['user_ids']))
246 {
247 ilUtil::sendFailure($this->lng->txt("no_checkbox"));
248 $this->showSelectableUsers();
249 return false;
250 }
251
252 $rcps = array();
253 foreach($_POST['user_ids'] as $usr_id)
254 {
255 $rcps[] = ilObjUser::_lookupLogin($usr_id);
256 }
257
258 if(!count(array_filter($rcps)))
259 {
260 ilUtil::sendFailure($this->lng->txt("no_checkbox"));
261 $this->showSelectableUsers();
262 return false;
263 }
264
265 require_once 'Services/Mail/classes/class.ilMailFormCall.php';
267
269 $this, 'members',
270 array(),
271 array(
272 'type' => 'new',
273 'sig' => $this->gui->createMailSignature()
274 ),
275 $this->generateContextArray()
276 ));
277
278 return true;
279 }
280
284 protected function showSearchForm()
285 {
286 $this->storeReferer();
287
288 $form = $this->initMailToMembersForm();
289 $this->tpl->setContent($form->getHTML());
290 }
291
295 protected function getObjParticipants()
296 {
298 }
299
304 {
305 $this->objParticipants = $objParticipants;
306 }
307
311 protected function initMailToMembersForm()
312 {
313 $this->lng->loadLanguageModule('mail');
314
315 include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
316 $form = new ilPropertyFormGUI();
317 $form->setTitle($this->lng->txt('mail_members'));
318
319 $form->setFormAction($this->ctrl->getFormAction($this, 'nextMailForm'));
320
321 $radio_grp = $this->getMailRadioGroup();
322
323 $form->addItem($radio_grp);
324 $form->addCommandButton('nextMailForm', $this->lng->txt('mail_members_search_continue'));
325 $form->addCommandButton('cancel', $this->lng->txt('cancel'));
326
327 return $form;
328 }
329
333 private function getMailRoles()
334 {
335 return $this->mail_roles;
336 }
337
341 protected function getMailRadioGroup()
342 {
343 $mail_roles = $this->getMailRoles();
344
345 $radio_grp = new ilRadioGroupInputGUI('', 'mail_member_type');
346
347 $radio_sel_users = new ilRadioOption($this->lng->txt('mail_sel_users'), 'mail_sel_users');
348
349 $radio_roles = new ilRadioOption($this->objMailMemberRoles->getRadioOptionTitle(), 'mail_member_roles');
350 foreach($mail_roles as $role)
351 {
352 $chk_role = new ilCheckboxInputGUI($role['form_option_title'], 'roles[]');
353 $chk_role->setValue($role['role_id']);
354 $chk_role->setInfo($role['mailbox']);
355 $radio_roles->addSubItem($chk_role);
356 }
357
358 $radio_grp->setValue('mail_member_roles');
359
360 $radio_grp->addOption($radio_sel_users);
361 $radio_grp->addOption($radio_roles);
362
363 return $radio_grp;
364 }
365}
$_GET["client_id"]
$_POST["username"]
$_SESSION["AccountId"]
An exception for terminatinating execution or to throw for unit testing.
Class ilAbstractMailMemberRoles.
This class represents a checkbox property in a property form.
static getRedirectTarget($gui, $cmd, array $gui_params=array(), array $mail_params=array(), array $context_params=array())
static setRecipients(array $recipients)
const CONTEXT_KEY
Session parameter for the context.
Class ilMailMemberSearchDataProvider.
Class ilMailMemberSearchGUI.
__construct($gui, $ref_id, ilAbstractMailMemberRoles $objMailMemberRoles)
ilMailMemberSearchGUI constructor.
static _lookupLogin($a_user_id)
lookup login
This class represents a property form user interface.
This class represents a property in a property form.
This class represents an option in a radio group.
static set($a_var, $a_val)
Set a value.
static get($a_var)
Get a value.
static redirect($a_script)
http redirect to other script
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
$tbl
Definition: example_048.php:81
$cmd
Definition: sahs_server.php:35
$ref_id
Definition: sahs_server.php:39
global $DIC