ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilMailSearchCoursesGUI Class Reference
+ Collaboration diagram for ilMailSearchCoursesGUI:

Public Member Functions

 __construct ($wsp_access_handler=null, $wsp_node_id=null)
 
 executeCommand ()
 
 mail ()
 
 mailCourses ()
 
 mailMembers ()
 
 cancel ()
 Cancel action. More...
 
 showMembers ()
 Show course members. More...
 
 share ()
 

Protected Member Functions

 addPermission ($a_obj_ids)
 

Protected Attributes

 $tpl
 
 $ctrl
 
 $lng
 
 $user
 
 $error
 
 $rbacsystem
 
 $rbacreview
 
 $tree
 
 $cache
 
 $umail
 
 $mailing_allowed
 

Detailed Description

Author
Jens Conze
Version
$Id$ ilMailSearchCoursesGUI: ilBuddySystemGUI

Definition at line 16 of file class.ilMailSearchCoursesGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilMailSearchCoursesGUI::__construct (   $wsp_access_handler = null,
  $wsp_node_id = null 
)

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

References $DIC, and user().

74  {
75  global $DIC;
76 
77  $this->tpl = $DIC['tpl'];
78  $this->ctrl = $DIC['ilCtrl'];
79  $this->lng = $DIC['lng'];
80  $this->user = $DIC['ilUser'];
81  $this->error = $DIC['ilErr'];
82  $this->rbacsystem = $DIC['rbacsystem'];
83  $this->rbacreview = $DIC['rbacreview'];
84  $this->tree = $DIC['tree'];
85  $this->cache = $DIC['ilObjDataCache'];
86 
87  // personal workspace
88  $this->wsp_access_handler = $wsp_access_handler;
89  $this->wsp_node_id = $wsp_node_id;
90 
91  // check if current user may send mails
92  include_once "Services/Mail/classes/class.ilMail.php";
93  $mail = new ilMail($this->user->getId());
94  $this->mailing_allowed = $this->rbacsystem->checkAccess('internal_mail', $mail->getMailObjectReferenceId());
95 
96  $this->ctrl->saveParameter($this, "mobj_id");
97  $this->ctrl->saveParameter($this, "ref");
98 
99  $this->umail = new ilFormatMail($this->user->getId());
100  }
global $DIC
Definition: saml.php:7
user()
Definition: user.php:4
Class UserMail this class handles user mails.
+ Here is the call graph for this function:

Member Function Documentation

◆ addPermission()

ilMailSearchCoursesGUI::addPermission (   $a_obj_ids)
protected

Definition at line 536 of file class.ilMailSearchCoursesGUI.php.

Referenced by share().

537  {
538  if (!is_array($a_obj_ids)) {
539  $a_obj_ids = array($a_obj_ids);
540  }
541 
542  $existing = $this->wsp_access_handler->getPermissions($this->wsp_node_id);
543  $added = false;
544  foreach ($a_obj_ids as $object_id) {
545  if (!in_array($object_id, $existing)) {
546  $added = $this->wsp_access_handler->addPermission($this->wsp_node_id, $object_id);
547  }
548  }
549 
550  if ($added) {
551  ilUtil::sendSuccess($this->lng->txt("wsp_share_success"), true);
552  }
553  $this->ctrl->redirectByClass("ilworkspaceaccessgui", "share");
554  }
+ Here is the caller graph for this function:

◆ cancel()

ilMailSearchCoursesGUI::cancel ( )

Cancel action.

Definition at line 272 of file class.ilMailSearchCoursesGUI.php.

References $_GET, $data, $key, $path, $table, ilObject\_getAllReferences(), ilCourseParticipants\_getInstanceByObjId(), ilParticipants\_getMembershipByType(), ilObject\_hasUntrashedReference(), ilObjectFactory\getInstanceByObjId(), and user().

273  {
274  if ($_GET["view"] == "mycourses" &&
275  $_GET["ref"] == "mail") {
276  $this->ctrl->returnToParent($this);
277  } else {
278  $this->showMyCourses();
279  }
280  }
$_GET["client_id"]
+ Here is the call graph for this function:

◆ executeCommand()

ilMailSearchCoursesGUI::executeCommand ( )

Definition at line 102 of file class.ilMailSearchCoursesGUI.php.

References ilBuddySystem\getInstance().

103  {
104  $forward_class = $this->ctrl->getNextClass($this);
105  switch ($forward_class) {
106  case 'ilbuddysystemgui':
107  if (!ilBuddySystem::getInstance()->isEnabled()) {
108  $this->error->raiseError($this->lng->txt('msg_no_perm_read'), $this->error->MESSAGE);
109  }
110 
111  require_once 'Services/Contact/BuddySystem/classes/class.ilBuddySystemGUI.php';
112  $this->ctrl->saveParameter($this, 'search_crs');
113  $this->ctrl->setReturn($this, 'showMembers');
114  $this->ctrl->forwardCommand(new ilBuddySystemGUI());
115  break;
116 
117  default:
118  if (!($cmd = $this->ctrl->getCmd())) {
119  $cmd = "showMyCourses";
120  }
121 
122  $this->$cmd();
123  break;
124  }
125  return true;
126  }
Class ilBuddySystemGUI.
+ Here is the call graph for this function:

◆ mail()

ilMailSearchCoursesGUI::mail ( )

Definition at line 128 of file class.ilMailSearchCoursesGUI.php.

References $_GET, $_POST, mailCourses(), mailMembers(), ilUtil\sendInfo(), and showMembers().

129  {
130  if ($_GET["view"] == "mycourses") {
131  $ids = ((int) $_GET['search_crs']) ? array((int) $_GET['search_crs']) : $_POST['search_crs'];
132 
133  if ($ids) {
134  $this->mailCourses();
135  } else {
136  ilUtil::sendInfo($this->lng->txt("mail_select_course"));
137  $this->showMyCourses();
138  }
139  } elseif ($_GET["view"] == "crs_members") {
140  $ids = ((int) $_GET['search_members']) ? array((int) $_GET['search_members']) : $_POST['search_members'];
141  if ($ids) {
142  $this->mailMembers();
143  } else {
144  ilUtil::sendInfo($this->lng->txt("mail_select_one_entry"));
145  $this->showMembers();
146  }
147  } else {
148  $this->showMyCourses();
149  }
150  }
$_GET["client_id"]
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
$_POST["username"]
+ Here is the call graph for this function:

◆ mailCourses()

ilMailSearchCoursesGUI::mailCourses ( )

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

References $_GET, $_POST, ilObject\_getAllReferences(), ilUtil\redirect(), and user().

Referenced by mail().

153  {
154  $members = array();
155 
156  if (!is_array($old_mail_data = $this->umail->getSavedData())) {
157  $this->umail->savePostData(
158  $this->user->getId(),
159  array(),
160  "",
161  "",
162  "",
163  "",
164  "",
165  "",
166  "",
167  ""
168  );
169  }
170 
171  require_once './Services/Object/classes/class.ilObject.php';
172  require_once 'Services/Mail/classes/Address/Type/class.ilMailRoleAddressType.php';
173  $ids = ((int) $_GET['search_crs']) ? array((int) $_GET['search_crs']) : $_POST['search_crs'];
174 
175  foreach ($ids as $crs_id) {
176  $ref_ids = ilObject::_getAllReferences($crs_id);
177 
178  foreach ($ref_ids as $ref_id) {
179  $roles = $this->rbacreview->getAssignableChildRoles($ref_id);
180  foreach ($roles as $role) {
181  if (substr($role['title'], 0, 14) == 'il_crs_member_' ||
182  substr($role['title'], 0, 13) == 'il_crs_tutor_' ||
183  substr($role['title'], 0, 13) == 'il_crs_admin_') {
184  if (isset($old_mail_data['rcp_to']) &&
185  trim($old_mail_data['rcp_to']) != '') {
186  $rcpt = (new \ilRoleMailboxAddress($role['obj_id']))->value();
187  if (!$this->umail->existsRecipient($rcpt, (string) $old_mail_data['rcp_to'])) {
188  array_push($members, $rcpt);
189  }
190  } else {
191  array_push($members, (new \ilRoleMailboxAddress($role['obj_id']))->value());
192  }
193  }
194  }
195  }
196  }
197 
198  if (count($members)) {
199  $mail_data = $this->umail->appendSearchResult($members, 'to');
200  } else {
201  $mail_data = $this->umail->getSavedData();
202  }
203 
204  $this->umail->savePostData(
205  $mail_data["user_id"],
206  $mail_data["attachments"],
207  $mail_data["rcp_to"],
208  $mail_data["rcp_cc"],
209  $mail_data["rcp_bcc"],
210  $mail_data["m_type"],
211  $mail_data["m_email"],
212  $mail_data["m_subject"],
213  $mail_data["m_message"],
214  $mail_data["use_placeholders"],
215  $mail_data['tpl_ctx_id'],
216  $mail_data['tpl_ctx_params']
217  );
218 
219  #$this->ctrl->returnToParent($this);
220  ilUtil::redirect("ilias.php?baseClass=ilMailGUI&type=search_res");
221  }
$_GET["client_id"]
Class ilRoleMailboxAddress.
user()
Definition: user.php:4
static _getAllReferences($a_id)
get all reference ids of object
static redirect($a_script)
$_POST["username"]
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mailMembers()

ilMailSearchCoursesGUI::mailMembers ( )

Definition at line 223 of file class.ilMailSearchCoursesGUI.php.

References $_GET, $_POST, $login, ilObjUser\_lookupLogin(), ilUtil\redirect(), and user().

Referenced by mail().

224  {
225  $members = array();
226 
227  if (!is_array($this->umail->getSavedData())) {
228  $this->umail->savePostData(
229  $this->user->getId(),
230  array(),
231  "",
232  "",
233  "",
234  "",
235  "",
236  "",
237  "",
238  ""
239  );
240  }
241 
242  $ids = ((int) $_GET['search_members']) ? array((int) $_GET['search_members']) : $_POST['search_members'];
243 
244  foreach ($ids as $member) {
245  $login = ilObjUser::_lookupLogin($member);
246  array_push($members, $login);
247  }
248  $mail_data = $this->umail->appendSearchResult($members, "to");
249 
250  $this->umail->savePostData(
251  $mail_data["user_id"],
252  $mail_data["attachments"],
253  $mail_data["rcp_to"],
254  $mail_data["rcp_cc"],
255  $mail_data["rcp_bcc"],
256  $mail_data["m_type"],
257  $mail_data["m_email"],
258  $mail_data["m_subject"],
259  $mail_data["m_message"],
260  $mail_data["use_placeholders"],
261  $mail_data['tpl_ctx_id'],
262  $mail_data['tpl_ctx_params']
263  );
264 
265  #$this->ctrl->returnToParent($this);
266  ilUtil::redirect("ilias.php?baseClass=ilMailGUI&type=search_res");
267  }
static _lookupLogin($a_user_id)
lookup login
$_GET["client_id"]
user()
Definition: user.php:4
$login
Definition: cron.php:13
static redirect($a_script)
$_POST["username"]
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ share()

ilMailSearchCoursesGUI::share ( )

Definition at line 513 of file class.ilMailSearchCoursesGUI.php.

References $_GET, addPermission(), ilUtil\sendInfo(), and showMembers().

514  {
515  if ($_GET["view"] == "mycourses") {
516  $ids = $_REQUEST["search_crs"];
517  if (is_array($ids) && sizeof($ids)) {
518  $this->addPermission($ids);
519  } else {
520  ilUtil::sendInfo($this->lng->txt("mail_select_course"));
521  $this->showMyCourses();
522  }
523  } elseif ($_GET["view"] == "crs_members") {
524  $ids = $_REQUEST["search_members"];
525  if (is_array($ids) && sizeof($ids)) {
526  $this->addPermission($ids);
527  } else {
528  ilUtil::sendInfo($this->lng->txt("mail_select_one_entry"));
529  $this->showMembers();
530  }
531  } else {
532  $this->showMyCourses();
533  }
534  }
$_GET["client_id"]
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
+ Here is the call graph for this function:

◆ showMembers()

ilMailSearchCoursesGUI::showMembers ( )

Show course members.

Definition at line 406 of file class.ilMailSearchCoursesGUI.php.

References $_GET, $_POST, $_SESSION, $context, $login, $name, $table, ilObjUser\_lookupLogin(), ilObjUser\_lookupName(), ilObjUser\_lookupPref(), ilUtil\_sortIds(), ilStr\convertUpperCamelCaseToUnderscoreCase(), ilBuddySystem\getInstance(), ilBuddyList\getInstanceByGlobalUser(), ilObjectFactory\getInstanceByObjId(), ilUtil\sendInfo(), and user().

Referenced by mail(), and share().

407  {
408  include_once 'Modules/Course/classes/class.ilCourseParticipants.php';
409 
410  if ($_GET["search_crs"] != "") {
411  $_POST["search_crs"] = explode(",", $_GET["search_crs"]);
412  $_GET["search_crs"] = "";
413  } elseif ($_SESSION["search_crs"] != "") {
414  $_POST["search_crs"] = explode(",", $_SESSION["search_crs"]);
415  $_SESSION["search_crs"] = "";
416  }
417 
418  if (is_array($_POST['search_crs'])) {
419  $_POST['search_crs'] = array_filter(array_map('intval', $_POST['search_crs']));
420  }
421 
422  if (!is_array($_POST["search_crs"]) ||
423  count($_POST["search_crs"]) == 0) {
424  ilUtil::sendInfo($this->lng->txt("mail_select_course"));
425  $this->showMyCourses();
426  } else {
427  foreach ($_POST['search_crs'] as $crs_id) {
428  $oTmpCrs = ilObjectFactory::getInstanceByObjId($crs_id);
429  if ($oTmpCrs->getShowMembers() == $oTmpCrs->SHOW_MEMBERS_DISABLED) {
430  unset($_POST['search_crs']);
431  ilUtil::sendInfo($this->lng->txt('mail_crs_list_members_not_available_for_at_least_one_crs'));
432  return $this->showMyCourses();
433  }
434  unset($oTmpCrs);
435  }
436 
437  $this->tpl->setTitle($this->lng->txt("mail_addressbook"));
438 
439  $this->ctrl->setParameter($this, "view", "crs_members");
440  if ($_GET["ref"] != "") {
441  $this->ctrl->setParameter($this, "ref", $_GET["ref"]);
442  }
443  if (is_array($_POST["search_crs"])) {
444  $this->ctrl->setParameter($this, "search_crs", implode(",", $_POST["search_crs"]));
445  }
446  $this->tpl->setVariable("ACTION", $this->ctrl->getFormAction($this));
447  $this->ctrl->clearParameters($this);
448 
449  $this->lng->loadLanguageModule('crs');
450  include_once 'Services/Contact/classes/class.ilMailSearchCoursesMembersTableGUI.php';
451  $context = $_GET["ref"] ? $_GET["ref"] : "mail";
452  $table = new ilMailSearchCoursesMembersTableGUI($this, 'crs', $context, $_POST["search_crs"]);
453  $tableData = array();
454  $searchTpl = new ilTemplate('tpl.mail_search_template.html', true, true, 'Services/Contact');
455  foreach ($_POST["search_crs"] as $crs_id) {
456  $members_obj = ilCourseParticipants::_getinstanceByObjId($crs_id);
457  $tmp_members = $members_obj->getParticipants();
458  $course_members = ilUtil::_sortIds($tmp_members, 'usr_data', 'lastname', 'usr_id');
459 
460  foreach ($course_members as $member) {
461  $tmp_usr = new ilObjUser($member);
462  if (!$tmp_usr->getActive()) {
463  continue;
464  }
465 
466  $name = ilObjUser::_lookupName($member);
467  $login = ilObjUser::_lookupLogin($member);
468 
469  $fullname = "";
470  if (in_array(ilObjUser::_lookupPref($member, 'public_profile'), array("g", 'y'))) {
471  $fullname = $name['lastname'] . ', ' . $name['firstname'];
472  }
473 
474  $rowData = array(
475  'members_id' => $member,
476  'members_login' => $login,
477  'members_name' => $fullname,
478  'members_crs_grp' => $this->cache->lookupTitle($crs_id),
479  'search_crs' => $crs_id
480  );
481 
482  if ('mail' == $context && ilBuddySystem::getInstance()->isEnabled()) {
483  $relation = ilBuddyList::getInstanceByGlobalUser()->getRelationByUserId($member);
484  $state_name = ilStr::convertUpperCamelCaseToUnderscoreCase($relation->getState()->getName());
485  $rowData['status'] = '';
486  if ($member != $this->user->getId()) {
487  if ($relation->isOwnedByRequest()) {
488  $rowData['status'] = $this->lng->txt('buddy_bs_state_' . $state_name . '_a');
489  } else {
490  $rowData['status'] = $this->lng->txt('buddy_bs_state_' . $state_name . '_p');
491  }
492  }
493  }
494 
495  $tableData[] = $rowData;
496  }
497  }
498  $table->setData($tableData);
499 
500  if (count($tableData)) {
501  $searchTpl->setVariable("TXT_MARKED_ENTRIES", $this->lng->txt("marked_entries"));
502  }
503 
504  $searchTpl->setVariable('TABLE', $table->getHtml());
505  $this->tpl->setContent($searchTpl->get());
506 
507  if ($_GET["ref"] != "wsp") {
508  $this->tpl->show();
509  }
510  }
511  }
static _lookupLogin($a_user_id)
lookup login
static _lookupName($a_user_id)
lookup user name
static convertUpperCamelCaseToUnderscoreCase($value)
Convert a value given in camel case conversion to underscore case conversion (e.g.
$context
Definition: webdav.php:25
static getInstanceByGlobalUser()
$_SESSION["AccountId"]
$_GET["client_id"]
user()
Definition: user.php:4
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
static _sortIds($a_ids, $a_table, $a_field, $a_id_name)
Function that sorts ids by a given table field using WHERE IN E.g: __sort(array(6,7),'usr_data','lastname','usr_id') => sorts by lastname.
special template class to simplify handling of ITX/PEAR
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
static _lookupPref($a_usr_id, $a_keyword)
$login
Definition: cron.php:13
if(empty($password)) $table
Definition: pwgen.php:24
$_POST["username"]
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $cache

ilMailSearchCoursesGUI::$cache
protected

Definition at line 61 of file class.ilMailSearchCoursesGUI.php.

◆ $ctrl

ilMailSearchCoursesGUI::$ctrl
protected

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

◆ $error

ilMailSearchCoursesGUI::$error
protected

Definition at line 41 of file class.ilMailSearchCoursesGUI.php.

◆ $lng

ilMailSearchCoursesGUI::$lng
protected

Definition at line 31 of file class.ilMailSearchCoursesGUI.php.

◆ $mailing_allowed

ilMailSearchCoursesGUI::$mailing_allowed
protected

Definition at line 71 of file class.ilMailSearchCoursesGUI.php.

◆ $rbacreview

ilMailSearchCoursesGUI::$rbacreview
protected

Definition at line 51 of file class.ilMailSearchCoursesGUI.php.

◆ $rbacsystem

ilMailSearchCoursesGUI::$rbacsystem
protected

Definition at line 46 of file class.ilMailSearchCoursesGUI.php.

◆ $tpl

ilMailSearchCoursesGUI::$tpl
protected

Definition at line 21 of file class.ilMailSearchCoursesGUI.php.

◆ $tree

ilMailSearchCoursesGUI::$tree
protected

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

◆ $umail

ilMailSearchCoursesGUI::$umail
protected

Definition at line 66 of file class.ilMailSearchCoursesGUI.php.

◆ $user

ilMailSearchCoursesGUI::$user
protected

Definition at line 36 of file class.ilMailSearchCoursesGUI.php.


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