ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
ilMailSearchCoursesGUI Class Reference
+ Collaboration diagram for ilMailSearchCoursesGUI:

Public Member Functions

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

Protected Member Functions

 addPermission ($a_obj_ids)
 

Protected Attributes

 $mailing_allowed
 

Private Attributes

 $tpl = null
 
 $ctrl = null
 
 $lng = null
 
 $umail = null
 
 $abook = null
 

Detailed Description

Author
Jens Conze
Version
$Id$ @ilCtrl_Calls 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 27 of file class.ilMailSearchCoursesGUI.php.

28 {
29 global $tpl, $ilCtrl, $lng, $ilUser, $rbacsystem;
30
31 $this->tpl = $tpl;
32 $this->ctrl = $ilCtrl;
33 $this->lng = $lng;
34
35 // personal workspace
36 $this->wsp_access_handler = $wsp_access_handler;
37 $this->wsp_node_id = $wsp_node_id;
38
39 // check if current user may send mails
40 include_once "Services/Mail/classes/class.ilMail.php";
41 $mail = new ilMail($_SESSION["AccountId"]);
42 $this->mailing_allowed = $rbacsystem->checkAccess('internal_mail',$mail->getMailObjectReferenceId());
43
44 $this->ctrl->saveParameter($this, "mobj_id");
45 $this->ctrl->saveParameter($this, "ref");
46
47 $this->umail = new ilFormatMail($ilUser->getId());
48 }
$_SESSION["AccountId"]
Class UserMail this class handles user mails.
Class Mail this class handles base functions for mail handling.
global $ilCtrl
Definition: ilias.php:18
global $ilUser
Definition: imgupload.php:15

References $_SESSION, $ilCtrl, $ilUser, $lng, and $tpl.

Member Function Documentation

◆ addPermission()

ilMailSearchCoursesGUI::addPermission (   $a_obj_ids)
protected

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

572 {
573 if(!is_array($a_obj_ids))
574 {
575 $a_obj_ids = array($a_obj_ids);
576 }
577
578 $existing = $this->wsp_access_handler->getPermissions($this->wsp_node_id);
579 $added = false;
580 foreach($a_obj_ids as $object_id)
581 {
582 if(!in_array($object_id, $existing))
583 {
584 $added = $this->wsp_access_handler->addPermission($this->wsp_node_id, $object_id);
585 }
586 }
587
588 if($added)
589 {
590 ilUtil::sendSuccess($this->lng->txt("wsp_share_success"), true);
591 }
592 $this->ctrl->redirectByClass("ilworkspaceaccessgui", "share");
593 }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.

References ilUtil\sendSuccess().

Referenced by share().

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

◆ cancel()

ilMailSearchCoursesGUI::cancel ( )

Cancel action.

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

255 {
256 if ($_GET["view"] == "mycourses" &&
257 $_GET["ref"] == "mail")
258 {
259 $this->ctrl->returnToParent($this);
260 }
261 else
262 {
263 $this->showMyCourses();
264 }
265 }
$_GET["client_id"]

References $_GET.

◆ mail()

ilMailSearchCoursesGUI::mail ( )

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

85 {
86 global $ilUser, $lng;
87 if ($_GET["view"] == "mycourses")
88 {
89 $ids = ((int)$_GET['search_crs']) ? array((int)$_GET['search_crs']) : $_POST['search_crs'];
90
91 if ($ids)
92 {
93 $this->mailCourses();
94 }
95 else
96 {
97 ilUtil::sendInfo($lng->txt("mail_select_course"));
98 $this->showMyCourses();
99 }
100 }
101 else if ($_GET["view"] == "crs_members")
102 {
103 $ids = ((int)$_GET['search_members']) ? array((int)$_GET['search_members']) : $_POST['search_members'];
104 if ($ids)
105 {
106 $this->mailMembers();
107 }
108 else
109 {
110 ilUtil::sendInfo($lng->txt("mail_select_one_entry"));
111 $this->showMembers();
112 }
113 }
114 else
115 {
116 $this->showMyCourses();
117 }
118 }
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
$_POST['username']
Definition: cron.php:12

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

+ Here is the call graph for this function:

◆ mailCourses()

ilMailSearchCoursesGUI::mailCourses ( )

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

121 {
122 global $ilUser, $lng, $rbacreview;
123
124 $members = array();
125
126 if (!is_array($old_mail_data = $this->umail->getSavedData()))
127 {
128 $this->umail->savePostData(
129 $ilUser->getId(),
130 array(),
131 "",
132 "",
133 "",
134 "",
135 "",
136 "",
137 "",
138 ""
139 );
140 }
141
142 require_once './Services/Object/classes/class.ilObject.php';
143
144 $ids = ((int)$_GET['search_crs']) ? array((int)$_GET['search_crs']) : $_POST['search_crs'];
145
146 foreach ($ids as $crs_id)
147 {
148 $ref_ids = ilObject::_getAllReferences($crs_id);
149
150 foreach ($ref_ids as $ref_id)
151 {
152 $roles = $rbacreview->getAssignableChildRoles($ref_id);
153 foreach ($roles as $role)
154 {
155 if (substr($role['title'], 0, 14) == 'il_crs_member_' ||
156 substr($role['title'], 0, 13) == 'il_crs_tutor_' ||
157 substr($role['title'], 0, 13) == 'il_crs_admin_')
158 {
159 if(isset($old_mail_data['rcp_to']) &&
160 trim($old_mail_data['rcp_to']) != '')
161 {
162 $rcpt = $rbacreview->getRoleMailboxAddress($role['obj_id']);
163 if(!$this->umail->doesRecipientStillExists($rcpt, $old_mail_data['rcp_to']))
164 {
165 array_push($members, $rcpt);
166 }
167 }
168 else
169 {
170 array_push($members, $rbacreview->getRoleMailboxAddress($role['obj_id']));
171 }
172 }
173 }
174 }
175 }
176
177 if(count($members))
178 $mail_data = $this->umail->appendSearchResult($members, 'to');
179 else
180 $mail_data = $this->umail->getSavedData();
181
182 $this->umail->savePostData(
183 $mail_data["user_id"],
184 $mail_data["attachments"],
185 $mail_data["rcp_to"],
186 $mail_data["rcp_cc"],
187 $mail_data["rcp_bcc"],
188 $mail_data["m_type"],
189 $mail_data["m_email"],
190 $mail_data["m_subject"],
191 $mail_data["m_message"],
192 $mail_data["use_placeholders"],
193 $mail_data['tpl_ctx_id'],
194 $mail_data['tpl_ctx_params']
195 );
196
197 #$this->ctrl->returnToParent($this);
198 ilUtil::redirect("ilias.php?baseClass=ilMailGUI&type=search_res");
199 }
static _getAllReferences($a_id)
get all reference ids of object
static redirect($a_script)
http redirect to other script
$ref_id
Definition: sahs_server.php:39

References $_GET, $_POST, $ilUser, $lng, $ref_id, ilObject\_getAllReferences(), and ilUtil\redirect().

Referenced by mail().

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

◆ mailMembers()

ilMailSearchCoursesGUI::mailMembers ( )

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

202 {
203 global $ilUser;
204
205 $members = array();
206
207 if (!is_array($this->umail->getSavedData()))
208 {
209 $this->umail->savePostData(
210 $ilUser->getId(),
211 array(),
212 "",
213 "",
214 "",
215 "",
216 "",
217 "",
218 "",
219 ""
220 );
221 }
222
223 $ids = ((int)$_GET['search_members']) ? array((int)$_GET['search_members']) : $_POST['search_members'];
224
225 foreach ($ids as $member)
226 {
227 $login = ilObjUser::_lookupLogin($member);
228 array_push($members, $login);
229 }
230 $mail_data = $this->umail->appendSearchResult($members,"to");
231
232 $this->umail->savePostData(
233 $mail_data["user_id"],
234 $mail_data["attachments"],
235 $mail_data["rcp_to"],
236 $mail_data["rcp_cc"],
237 $mail_data["rcp_bcc"],
238 $mail_data["m_type"],
239 $mail_data["m_email"],
240 $mail_data["m_subject"],
241 $mail_data["m_message"],
242 $mail_data["use_placeholders"],
243 $mail_data['tpl_ctx_id'],
244 $mail_data['tpl_ctx_params']
245 );
246
247 #$this->ctrl->returnToParent($this);
248 ilUtil::redirect("ilias.php?baseClass=ilMailGUI&type=search_res");
249 }
static _lookupLogin($a_user_id)
lookup login

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

Referenced by mail().

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

◆ share()

ilMailSearchCoursesGUI::share ( )

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

536 {
537 global $lng;
538
539 if ($_GET["view"] == "mycourses")
540 {
541 $ids = $_REQUEST["search_crs"];
542 if (sizeof($ids))
543 {
544 $this->addPermission($ids);
545 }
546 else
547 {
548 ilUtil::sendInfo($lng->txt("mail_select_course"));
549 $this->showMyCourses();
550 }
551 }
552 else if ($_GET["view"] == "crs_members")
553 {
554 $ids = $_REQUEST["search_members"];
555 if (sizeof($ids))
556 {
557 $this->addPermission($ids);
558 }
559 else
560 {
561 ilUtil::sendInfo($lng->txt("mail_select_one_entry"));
562 $this->showMembers();
563 }
564 }
565 else
566 {
567 $this->showMyCourses();
568 }
569 }
if($_REQUEST['ilias_path']) define('ILIAS_HTTP_PATH' $_REQUEST['ilias_path']
Definition: index.php:7

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

+ Here is the call graph for this function:

◆ showMembers()

ilMailSearchCoursesGUI::showMembers ( )

Show course members.

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

412 {
413 global $lng, $ilUser, $ilObjDataCache;
414
415 include_once 'Modules/Course/classes/class.ilCourseParticipants.php';
416
417 if ($_GET["search_crs"] != "")
418 {
419 $_POST["search_crs"] = explode(",", $_GET["search_crs"]);
420 $_GET["search_crs"] = "";
421 }
422 else if ($_SESSION["search_crs"] != "")
423 {
424 $_POST["search_crs"] = explode(",", $_SESSION["search_crs"]);
425 $_SESSION["search_crs"] = "";
426 }
427
428 if(is_array($_POST['search_crs']))
429 {
430 $_POST['search_crs'] = array_filter(array_map('intval', $_POST['search_crs']));
431 }
432
433 if (!is_array($_POST["search_crs"]) ||
434 count($_POST["search_crs"]) == 0)
435 {
436 ilUtil::sendInfo($lng->txt("mail_select_course"));
437 $this->showMyCourses();
438 }
439 else
440 {
441 foreach($_POST['search_crs'] as $crs_id)
442 {
443 $oTmpCrs = ilObjectFactory::getInstanceByObjId($crs_id);
444 if($oTmpCrs->getShowMembers() == $oTmpCrs->SHOW_MEMBERS_DISABLED)
445 {
446 unset($_POST['search_crs']);
447 ilUtil::sendInfo($lng->txt('mail_crs_list_members_not_available_for_at_least_one_crs'));
448 return $this->showMyCourses();
449 }
450 unset($oTmpCrs);
451 }
452
453 $this->tpl->setTitle($this->lng->txt("mail_addressbook"));
454
455 $this->ctrl->setParameter($this, "view", "crs_members");
456 if ($_GET["ref"] != "") $this->ctrl->setParameter($this, "ref", $_GET["ref"]);
457 if (is_array($_POST["search_crs"])) $this->ctrl->setParameter($this, "search_crs", implode(",", $_POST["search_crs"]));
458 $this->tpl->setVariable("ACTION", $this->ctrl->getFormAction($this));
459 $this->ctrl->clearParameters($this);
460
461 $lng->loadLanguageModule('crs');
462 include_once 'Services/Contact/classes/class.ilMailSearchCoursesMembersTableGUI.php';
463 $context = $_GET["ref"] ? $_GET["ref"] : "mail";
464 $table = new ilMailSearchCoursesMembersTableGUI($this, 'crs', $context);
465 $tableData = array();
466 $searchTpl = new ilTemplate('tpl.mail_search_template.html', true, true, 'Services/Contact');
467 foreach($_POST["search_crs"] as $crs_id)
468 {
469 $members_obj = ilCourseParticipants::_getinstanceByObjId($crs_id);
470 $tmp_members = $members_obj->getParticipants();
471 $course_members = ilUtil::_sortIds($tmp_members, 'usr_data', 'lastname', 'usr_id');
472
473 foreach ($course_members as $member)
474 {
475 $tmp_usr = new ilObjUser($member);
476 if($tmp_usr->checkTimeLimit()== false || $tmp_usr->getActive() == false )
477 {
478 unset($tmp_usr);
479 continue;
480 }
481 unset($tmp_usr);
482
483 $name = ilObjUser::_lookupName($member);
484 $login = ilObjUser::_lookupLogin($member);
485
486 $fullname = "";
487 if(in_array(ilObjUser::_lookupPref($member, 'public_profile'), array("g", 'y')))
488 $fullname = $name['lastname'].', '.$name['firstname'];
489
490 $rowData = array(
491 'members_id' => $member,
492 'members_login' => $login,
493 'members_name' => $fullname,
494 'members_crs_grp' => $ilObjDataCache->lookupTitle($crs_id),
495 'search_crs' => $crs_id
496 );
497
498 if('mail' == $context && ilBuddySystem::getInstance()->isEnabled())
499 {
500 $relation = ilBuddyList::getInstanceByGlobalUser()->getRelationByUserId($member);
501 $state_name = ilStr::convertUpperCamelCaseToUnderscoreCase($relation->getState()->getName());
502 $rowData['status'] = '';
503 if($member != $ilUser->getId())
504 {
505 if($relation->isOwnedByRequest())
506 {
507 $rowData['status'] = $this->lng->txt('buddy_bs_state_' . $state_name . '_a');
508 }
509 else
510 {
511 $rowData['status'] = $this->lng->txt('buddy_bs_state_' . $state_name . '_p');
512 }
513 }
514 }
515
516 $tableData[] = $rowData;
517 }
518 }
519 $table->setData($tableData);
520 if (count($tableData))
521 {
522 $searchTpl->setVariable("TXT_MARKED_ENTRIES",$lng->txt("marked_entries"));
523 }
524
525 $searchTpl->setVariable('TABLE', $table->getHtml());
526 $this->tpl->setContent($searchTpl->get());
527
528 if($_GET["ref"] != "wsp")
529 {
530 $this->tpl->show();
531 }
532 }
533 }
static _lookupName($a_user_id)
lookup user name
_lookupPref($a_usr_id, $a_keyword)
getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
static convertUpperCamelCaseToUnderscoreCase($value)
Convert a value given in camel case conversion to underscore case conversion (e.g.
special template class to simplify handling of ITX/PEAR
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,...

References $_GET, $_POST, $_SESSION, $ilUser, $lng, ilObjUser\_lookupLogin(), ilObjUser\_lookupName(), ilObjUser\_lookupPref(), ilUtil\_sortIds(), ilStr\convertUpperCamelCaseToUnderscoreCase(), ilBuddySystem\getInstance(), ilObjectFactory\getInstanceByObjId(), and ilUtil\sendInfo().

Referenced by mail(), and share().

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

Field Documentation

◆ $abook

ilMailSearchCoursesGUI::$abook = null
private

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

◆ $ctrl

ilMailSearchCoursesGUI::$ctrl = null
private

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

◆ $lng

ilMailSearchCoursesGUI::$lng = null
private

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

Referenced by __construct(), mail(), mailCourses(), share(), and showMembers().

◆ $mailing_allowed

ilMailSearchCoursesGUI::$mailing_allowed
protected

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

◆ $tpl

ilMailSearchCoursesGUI::$tpl = null
private

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

Referenced by __construct().

◆ $umail

ilMailSearchCoursesGUI::$umail = null
private

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


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