ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilMailMemberSearchGUI Class Reference

Class ilMailMemberSearchGUI. More...

+ Collaboration diagram for ilMailMemberSearchGUI:

Public Member Functions

 __construct ($gui, $ref_id, ilAbstractMailMemberRoles $objMailMemberRoles)
 ilMailMemberSearchGUI constructor. More...
 
 executeCommand ()
 
 storeReferer ()
 
 setObjParticipants ($objParticipants)
 

Protected Member Functions

 nextMailForm ()
 
 generateContextArray ()
 
 showSelectableUsers ()
 
 sendMailToSelectedUsers ()
 
 showSearchForm ()
 
 getObjParticipants ()
 
 initMailToMembersForm ()
 
 getMailRadioGroup ()
 

Protected Attributes

 $mail_roles
 
 $gui
 
 $objMailMemberRoles
 
 $objParticipants = null
 
 $ctrl
 
 $tpl
 
 $lng
 
 $access
 

Private Member Functions

 redirectToParentReferer ()
 
 getStoredReferer ()
 
 unsetStoredReferer ()
 
 getMailRoles ()
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilMailMemberSearchGUI::__construct (   $gui,
  $ref_id,
ilAbstractMailMemberRoles  $objMailMemberRoles 
)

ilMailMemberSearchGUI constructor.

Parameters
ilObjGroupGUI | ilObjCourseGUI$gui
$ref_id
ilAbstractMailMemberRoles$objMailMemberRoles

Definition at line 56 of file class.ilMailMemberSearchGUI.php.

References $DIC, $gui, $objMailMemberRoles, and ilAbstractMailMemberRoles\getMailRoles().

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  }
global $DIC
Definition: saml.php:7
+ Here is the call graph for this function:

Member Function Documentation

◆ executeCommand()

ilMailMemberSearchGUI::executeCommand ( )
Returns
bool

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

References $_GET, nextMailForm(), redirectToParentReferer(), sendMailToSelectedUsers(), showSearchForm(), and showSelectableUsers().

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  default:
87  switch ($cmd) {
88  case 'sendMailToSelectedUsers':
89  $this->sendMailToSelectedUsers();
90  break;
91 
92  case 'showSelectableUsers':
93  $this->showSelectableUsers();
94  break;
95 
96  case 'nextMailForm':
97  $this->nextMailForm();
98  break;
99 
100  case 'cancel':
101  $this->redirectToParentReferer();
102  break;
103 
104  default:
105  if (isset($_GET['returned_from_mail']) && $_GET['returned_from_mail'] == '1') {
106  $this->redirectToParentReferer();
107  }
108  $this->showSearchForm();
109  break;
110  }
111  break;
112  }
113  return true;
114  }
$_GET["client_id"]
+ Here is the call graph for this function:

◆ generateContextArray()

ilMailMemberSearchGUI::generateContextArray ( )
protected
Returns
array

Definition at line 198 of file class.ilMailMemberSearchGUI.php.

References $type, ilObject\_lookupType(), ilMailFormCall\CONTEXT_KEY, ilCourseMailTemplateTutorContext\ID, and ilSessionMailTemplateParticipantContext\ID.

Referenced by nextMailForm(), and sendMailToSelectedUsers().

199  {
200  $context_array = [];
201 
202  $type = ilObject::_lookupType($this->ref_id, true);
203  switch ($type) {
204  case 'crs':
205  if ($this->access->checkAccess('write', "", $this->ref_id)) {
206  $context_array = array(
208  'ref_id' => $this->ref_id,
209  'ts' => time()
210  );
211  }
212  break;
213 
214  case 'sess':
215  if ($this->access->checkAccess('write', "", $this->ref_id)) {
216  $context_array = array(
218  'ref_id' => $this->ref_id,
219  'ts' => time()
220  );
221  }
222  break;
223  }
224  return $context_array;
225  }
$type
static _lookupType($a_id, $a_reference=false)
lookup object type
const CONTEXT_KEY
Session parameter for the context.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getMailRadioGroup()

ilMailMemberSearchGUI::getMailRadioGroup ( )
protected
Returns
ilRadioGroupInputGUI

Definition at line 342 of file class.ilMailMemberSearchGUI.php.

References $mail_roles, ilRadioOption\addSubItem(), and getMailRoles().

Referenced by initMailToMembersForm().

343  {
344  $mail_roles = $this->getMailRoles();
345 
346  $radio_grp = new ilRadioGroupInputGUI($this->lng->txt('mail_sel_label'), 'mail_member_type');
347 
348  $radio_sel_users = new ilRadioOption($this->lng->txt('mail_sel_users'), 'mail_sel_users');
349 
350  $radio_roles = new ilRadioOption($this->objMailMemberRoles->getRadioOptionTitle(), 'mail_member_roles');
351  foreach ($mail_roles as $role) {
352  $chk_role = new ilCheckboxInputGUI($role['form_option_title'], 'roles[]');
353 
354  if (array_key_exists('default_checked', $role) && $role['default_checked']) {
355  $chk_role->setChecked(true);
356  }
357  $chk_role->setValue($role['role_id']);
358  $chk_role->setInfo($role['mailbox']);
359  $radio_roles->addSubItem($chk_role);
360  }
361 
362  $radio_grp->setValue('mail_member_roles');
363 
364  $radio_grp->addOption($radio_sel_users);
365  $radio_grp->addOption($radio_roles);
366 
367  return $radio_grp;
368  }
This class represents an option in a radio group.
This class represents a checkbox property in a property form.
This class represents a property in a property form.
addSubItem($a_item)
Add Subitem.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getMailRoles()

ilMailMemberSearchGUI::getMailRoles ( )
private
Returns
mixed

Definition at line 334 of file class.ilMailMemberSearchGUI.php.

References $mail_roles.

Referenced by getMailRadioGroup().

+ Here is the caller graph for this function:

◆ getObjParticipants()

ilMailMemberSearchGUI::getObjParticipants ( )
protected
Returns
null

Definition at line 296 of file class.ilMailMemberSearchGUI.php.

References $objParticipants.

Referenced by showSelectableUsers().

+ Here is the caller graph for this function:

◆ getStoredReferer()

ilMailMemberSearchGUI::getStoredReferer ( )
private
Returns
bool || redirect target

Definition at line 135 of file class.ilMailMemberSearchGUI.php.

References ilSession\get().

Referenced by redirectToParentReferer().

136  {
137  $stored_referer = ilSession::get('ilMailMemberSearchGUIReferer');
138  return (strlen($stored_referer) ? $stored_referer : false);
139  }
static get($a_var)
Get a value.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initMailToMembersForm()

ilMailMemberSearchGUI::initMailToMembersForm ( )
protected
Returns
ilPropertyFormGUI

Definition at line 312 of file class.ilMailMemberSearchGUI.php.

References $form, and getMailRadioGroup().

Referenced by nextMailForm(), and showSearchForm().

313  {
314  $this->lng->loadLanguageModule('mail');
315 
316  include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
317  $form = new ilPropertyFormGUI();
318  $form->setTitle($this->lng->txt('mail_members'));
319 
320  $form->setFormAction($this->ctrl->getFormAction($this, 'nextMailForm'));
321 
322  $radio_grp = $this->getMailRadioGroup();
323 
324  $form->addItem($radio_grp);
325  $form->addCommandButton('nextMailForm', $this->lng->txt('mail_members_search_continue'));
326  $form->addCommandButton('cancel', $this->lng->txt('cancel'));
327 
328  return $form;
329  }
This class represents a property form user interface.
if(isset($_POST['submit'])) $form
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ nextMailForm()

ilMailMemberSearchGUI::nextMailForm ( )
protected

Definition at line 152 of file class.ilMailMemberSearchGUI.php.

References $_SESSION, $form, generateContextArray(), ilMailFormCall\getRedirectTarget(), initMailToMembersForm(), ilUtil\redirect(), ilUtil\sendFailure(), showSearchForm(), and showSelectableUsers().

Referenced by executeCommand().

153  {
154  $form = $this->initMailToMembersForm();
155  if ($form->checkInput()) {
156  if ($form->getInput('mail_member_type') == 'mail_member_roles') {
157  if (is_array($form->getInput('roles')) && count($form->getInput('roles')) > 0) {
158  $role_mail_boxes = array();
159  $roles = $form->getInput('roles');
160  foreach ($roles as $role_id) {
161  $mailbox = $this->objMailMemberRoles->getMailboxRoleAddress($role_id);
162  $role_mail_boxes[] = $mailbox;
163  }
164 
165  require_once 'Services/Mail/classes/class.ilMailFormCall.php';
166  $_SESSION['mail_roles'] = $role_mail_boxes;
167 
169  $this,
170  'showSearchForm',
171  array('type' => 'role'),
172  array(
173  'type' => 'role',
174  'rcp_to' => implode(',', $role_mail_boxes),
175  'sig' => $this->gui->createMailSignature()
176  ),
177  $this->generateContextArray()
178  ));
179  } else {
180  $form->setValuesByPost();
181  ilUtil::sendFailure($this->lng->txt('no_checkbox'));
182  $this->showSearchForm();
183  return;
184  }
185  } else {
186  $this->showSelectableUsers();
187  return;
188  }
189  }
190 
191  $form->setValuesByPost();
192  $this->showSearchForm();
193  }
$_SESSION["AccountId"]
if(isset($_POST['submit'])) $form
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static getRedirectTarget($gui, $cmd, array $gui_params=array(), array $mail_params=array(), array $context_params=array())
static redirect($a_script)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ redirectToParentReferer()

ilMailMemberSearchGUI::redirectToParentReferer ( )
private

Definition at line 116 of file class.ilMailMemberSearchGUI.php.

References getStoredReferer(), ilUtil\redirect(), and unsetStoredReferer().

Referenced by executeCommand().

117  {
118  $redirect_target = $this->getStoredReferer();
119  $this->unsetStoredReferer();
120  ilUtil::redirect($redirect_target);
121  }
static redirect($a_script)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sendMailToSelectedUsers()

ilMailMemberSearchGUI::sendMailToSelectedUsers ( )
protected
Returns
bool

Definition at line 246 of file class.ilMailMemberSearchGUI.php.

References $_POST, ilObjUser\_lookupLogin(), generateContextArray(), ilMailFormCall\getRedirectTarget(), ilUtil\redirect(), ilUtil\sendFailure(), ilMailFormCall\setRecipients(), and showSelectableUsers().

Referenced by executeCommand().

247  {
248  if (!is_array($_POST['user_ids']) || 0 === count($_POST['user_ids'])) {
249  ilUtil::sendFailure($this->lng->txt("no_checkbox"));
250  $this->showSelectableUsers();
251  return false;
252  }
253 
254  $rcps = array();
255  foreach ($_POST['user_ids'] as $usr_id) {
256  $rcps[] = ilObjUser::_lookupLogin($usr_id);
257  }
258 
259  if (!count(array_filter($rcps))) {
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,
270  'members',
271  array(),
272  array(
273  'type' => 'new',
274  'sig' => $this->gui->createMailSignature()
275  ),
276  $this->generateContextArray()
277  ));
278 
279  return true;
280  }
static _lookupLogin($a_user_id)
lookup login
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static getRedirectTarget($gui, $cmd, array $gui_params=array(), array $mail_params=array(), array $context_params=array())
static setRecipients(array $recipients)
static redirect($a_script)
$_POST["username"]
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setObjParticipants()

ilMailMemberSearchGUI::setObjParticipants (   $objParticipants)
Parameters
null$objParticipantsilCourseParticipants || ilGroupParticipants

Definition at line 304 of file class.ilMailMemberSearchGUI.php.

References $objParticipants.

Referenced by ilObjGroupGUI\executeCommand(), and ilObjCourseGUI\executeCommand().

305  {
306  $this->objParticipants = $objParticipants;
307  }
+ Here is the caller graph for this function:

◆ showSearchForm()

ilMailMemberSearchGUI::showSearchForm ( )
protected

Definition at line 285 of file class.ilMailMemberSearchGUI.php.

References $form, initMailToMembersForm(), and storeReferer().

Referenced by executeCommand(), and nextMailForm().

286  {
287  $this->storeReferer();
288 
289  $form = $this->initMailToMembersForm();
290  $this->tpl->setContent($form->getHTML());
291  }
if(isset($_POST['submit'])) $form
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ showSelectableUsers()

ilMailMemberSearchGUI::showSelectableUsers ( )
protected

Definition at line 230 of file class.ilMailMemberSearchGUI.php.

References PHPMailer\PHPMailer\$provider, $tbl, and getObjParticipants().

Referenced by executeCommand(), nextMailForm(), and sendMailToSelectedUsers().

231  {
232  include_once './Services/Contact/classes/class.ilMailMemberSearchTableGUI.php';
233  include_once './Services/Contact/classes/class.ilMailMemberSearchDataProvider.php';
234 
235  $this->tpl->getStandardTemplate();
236  $tbl = new ilMailMemberSearchTableGUI($this, 'showSelectableUsers');
237  $provider = new ilMailMemberSearchDataProvider($this->getObjParticipants(), $this->ref_id);
238  $tbl->setData($provider->getData());
239 
240  $this->tpl->setContent($tbl->getHTML());
241  }
$tbl
Definition: example_048.php:81
Class ilMailMemberSearchDataProvider.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ storeReferer()

ilMailMemberSearchGUI::storeReferer ( )

Definition at line 126 of file class.ilMailMemberSearchGUI.php.

References ilSession\get(), and ilSession\set().

Referenced by showSearchForm().

127  {
128  $referer = ilSession::get('referer');
129  ilSession::set('ilMailMemberSearchGUIReferer', $referer);
130  }
static get($a_var)
Get a value.
static set($a_var, $a_val)
Set a value.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ unsetStoredReferer()

ilMailMemberSearchGUI::unsetStoredReferer ( )
private

Definition at line 144 of file class.ilMailMemberSearchGUI.php.

References ilSession\set().

Referenced by redirectToParentReferer().

145  {
146  ilSession::set('ilMailMemberSearchGUIReferer', '');
147  }
static set($a_var, $a_val)
Set a value.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $access

ilMailMemberSearchGUI::$access
protected

Definition at line 48 of file class.ilMailMemberSearchGUI.php.

◆ $ctrl

ilMailMemberSearchGUI::$ctrl
protected

Definition at line 33 of file class.ilMailMemberSearchGUI.php.

◆ $gui

ilMailMemberSearchGUI::$gui
protected

Definition at line 19 of file class.ilMailMemberSearchGUI.php.

Referenced by __construct().

◆ $lng

ilMailMemberSearchGUI::$lng
protected

Definition at line 43 of file class.ilMailMemberSearchGUI.php.

◆ $mail_roles

ilMailMemberSearchGUI::$mail_roles
protected

Definition at line 14 of file class.ilMailMemberSearchGUI.php.

Referenced by getMailRadioGroup(), and getMailRoles().

◆ $objMailMemberRoles

ilMailMemberSearchGUI::$objMailMemberRoles
protected

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

Referenced by __construct().

◆ $objParticipants

ilMailMemberSearchGUI::$objParticipants = null
protected

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

Referenced by getObjParticipants(), and setObjParticipants().

◆ $tpl

ilMailMemberSearchGUI::$tpl
protected

Definition at line 38 of file class.ilMailMemberSearchGUI.php.


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