ILIAS  release_7 Revision v7.30-3-g800a261c036
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
 
 $rerfinery
 

Private Member Functions

 getContext ()
 

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 75 of file class.ilMailSearchCoursesGUI.php.

76 {
77 global $DIC;
78
79 $this->tpl = $DIC['tpl'];
80 $this->ctrl = $DIC['ilCtrl'];
81 $this->lng = $DIC['lng'];
82 $this->user = $DIC['ilUser'];
83 $this->error = $DIC['ilErr'];
84 $this->rbacsystem = $DIC['rbacsystem'];
85 $this->rbacreview = $DIC['rbacreview'];
86 $this->tree = $DIC['tree'];
87 $this->cache = $DIC['ilObjDataCache'];
88 $this->refinery = $DIC->refinery();
89
90 // personal workspace
91 $this->wsp_access_handler = $wsp_access_handler;
92 $this->wsp_node_id = $wsp_node_id;
93
94 // check if current user may send mails
95 include_once "Services/Mail/classes/class.ilMail.php";
96 $mail = new ilMail($this->user->getId());
97 $this->mailing_allowed = $this->rbacsystem->checkAccess('internal_mail', $mail->getMailObjectReferenceId());
98
99 $this->ctrl->saveParameter($this, "mobj_id");
100 $this->ctrl->saveParameter($this, "ref");
101
102 $this->umail = new ilFormatMail($this->user->getId());
103 }
user()
Definition: user.php:4
error($a_errmsg)
set error message @access public
Class UserMail this class handles user mails.
global $DIC
Definition: goto.php:24

References $DIC, error(), and user().

+ Here is the call graph for this function:

Member Function Documentation

◆ addPermission()

ilMailSearchCoursesGUI::addPermission (   $a_obj_ids)
protected

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

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

Referenced by share().

+ Here is the caller graph for this function:

◆ cancel()

ilMailSearchCoursesGUI::cancel ( )

Cancel action.

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

299 {
300 if ($_GET["view"] == "mycourses" &&
301 $_GET["ref"] == "mail") {
302 $this->ctrl->returnToParent($this);
303 } else {
304 $this->showMyCourses();
305 }
306 }
$_GET["client_id"]

References $_GET.

◆ executeCommand()

ilMailSearchCoursesGUI::executeCommand ( )

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

122 {
123 $forward_class = $this->ctrl->getNextClass($this);
124 switch ($forward_class) {
125 case 'ilbuddysystemgui':
126 if (!ilBuddySystem::getInstance()->isEnabled()) {
127 $this->error->raiseError($this->lng->txt('msg_no_perm_read'), $this->error->MESSAGE);
128 }
129
130 require_once 'Services/Contact/BuddySystem/classes/class.ilBuddySystemGUI.php';
131 $this->ctrl->saveParameter($this, 'search_crs');
132 $this->ctrl->setReturn($this, 'showMembers');
133 $this->ctrl->forwardCommand(new ilBuddySystemGUI());
134 break;
135
136 default:
137 if (!($cmd = $this->ctrl->getCmd())) {
138 $cmd = "showMyCourses";
139 }
140
141 $this->$cmd();
142 break;
143 }
144 return true;
145 }
Class ilBuddySystemGUI.

References error(), and ilBuddySystem\getInstance().

+ Here is the call graph for this function:

◆ getContext()

ilMailSearchCoursesGUI::getContext ( )
private

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

105 : string
106 {
107 $context = 'mail';
108 if (isset($_GET['ref'])) {
109 $always = $context;
110 $context = $this->refinery->byTrying([
111 $this->refinery->kindlyTo()->string(),
112 $this->refinery->custom()->transformation(static function ($value) use ($always) {
113 return $always;
114 }),
115 ])->transform($_GET['ref']);
116 }
117
118 return $context;
119 }
$context
Definition: webdav.php:26

References $_GET, and $context.

◆ mail()

ilMailSearchCoursesGUI::mail ( )

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

148 {
149 if ($_GET["view"] == "mycourses") {
150 $ids = ((int) $_GET['search_crs']) ? array((int) $_GET['search_crs']) : $_POST['search_crs'];
151
152 if ($ids) {
153 $this->mailCourses();
154 } else {
155 ilUtil::sendInfo($this->lng->txt("mail_select_course"));
156 $this->showMyCourses();
157 }
158 } elseif ($_GET["view"] == "crs_members") {
159 $ids = ((int) $_GET['search_members']) ? array((int) $_GET['search_members']) : $_POST['search_members'];
160 if ($ids) {
161 $this->mailMembers();
162 } else {
163 ilUtil::sendInfo($this->lng->txt("mail_select_one_entry"));
164 $this->showMembers();
165 }
166 } else {
167 $this->showMyCourses();
168 }
169 }
$_POST["username"]
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.

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

+ Here is the call graph for this function:

◆ mailCourses()

ilMailSearchCoursesGUI::mailCourses ( )

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

172 {
173 $members = array();
174
175 if (!is_array($old_mail_data = $this->umail->getSavedData())) {
176 $this->umail->savePostData(
177 $this->user->getId(),
178 array(),
179 "",
180 "",
181 "",
182 "",
183 "",
184 "",
185 "",
186 ""
187 );
188 }
189
190 require_once './Services/Object/classes/class.ilObject.php';
191 require_once 'Services/Mail/classes/Address/Type/class.ilMailRoleAddressType.php';
192 $ids = ((int) $_GET['search_crs']) ? array((int) $_GET['search_crs']) : $_POST['search_crs'];
193
194 foreach ($ids as $crs_id) {
195 $ref_ids = ilObject::_getAllReferences($crs_id);
196
197 foreach ($ref_ids as $ref_id) {
198 $roles = $this->rbacreview->getAssignableChildRoles($ref_id);
199 $can_send_mails = ilParticipants::canSendMailToMembers(
200 (int) $ref_id,
201 $this->user->getId(),
203 );
204 if (!$can_send_mails) {
205 continue;
206 }
207
208 foreach ($roles as $role) {
209 if (substr($role['title'], 0, 14) == 'il_crs_member_' ||
210 substr($role['title'], 0, 13) == 'il_crs_tutor_' ||
211 substr($role['title'], 0, 13) == 'il_crs_admin_') {
212 if (isset($old_mail_data['rcp_to']) &&
213 trim($old_mail_data['rcp_to']) != '') {
214 $rcpt = (new \ilRoleMailboxAddress($role['obj_id']))->value();
215 if (!$this->umail->existsRecipient($rcpt, (string) $old_mail_data['rcp_to'])) {
216 array_push($members, $rcpt);
217 }
218 } else {
219 array_push($members, (new \ilRoleMailboxAddress($role['obj_id']))->value());
220 }
221 }
222 }
223 }
224 }
225
226 if (count($members)) {
227 $mail_data = $this->umail->appendSearchResult($members, 'to');
228 } else {
229 $mail_data = $this->umail->getSavedData();
230 }
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_email"],
239 $mail_data["m_subject"],
240 $mail_data["m_message"],
241 $mail_data["use_placeholders"],
242 $mail_data['tpl_ctx_id'],
243 $mail_data['tpl_ctx_params']
244 );
245
246 #$this->ctrl->returnToParent($this);
247 ilUtil::redirect("ilias.php?baseClass=ilMailGUI&type=search_res");
248 }
static getMailObjectRefId()
Determines the reference id of the mail object and stores this information in a local cache variable.
static _getAllReferences($a_id)
get all reference ids of object
static canSendMailToMembers( $ref_id_or_instance, ?int $usr_id=null, ?int $mail_obj_ref_id=null)
This method was introduced as a band-aid fix for #22764.
Class ilRoleMailboxAddress.
static redirect($a_script)

References $_GET, $_POST, ilObject\_getAllReferences(), ilParticipants\canSendMailToMembers(), ilMailGlobalServices\getMailObjectRefId(), ilUtil\redirect(), and user().

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 250 of file class.ilMailSearchCoursesGUI.php.

251 {
252 $members = array();
253
254 if (!is_array($this->umail->getSavedData())) {
255 $this->umail->savePostData(
256 $this->user->getId(),
257 array(),
258 "",
259 "",
260 "",
261 "",
262 "",
263 "",
264 "",
265 ""
266 );
267 }
268
269 $ids = ((int) $_GET['search_members']) ? array((int) $_GET['search_members']) : $_POST['search_members'];
270
271 foreach ($ids as $member) {
273 array_push($members, $login);
274 }
275 $mail_data = $this->umail->appendSearchResult($members, "to");
276
277 $this->umail->savePostData(
278 $mail_data["user_id"],
279 $mail_data["attachments"],
280 $mail_data["rcp_to"],
281 $mail_data["rcp_cc"],
282 $mail_data["rcp_bcc"],
283 $mail_data["m_email"],
284 $mail_data["m_subject"],
285 $mail_data["m_message"],
286 $mail_data["use_placeholders"],
287 $mail_data['tpl_ctx_id'],
288 $mail_data['tpl_ctx_params']
289 );
290
291 #$this->ctrl->returnToParent($this);
292 ilUtil::redirect("ilias.php?baseClass=ilMailGUI&type=search_res");
293 }
static _lookupLogin($a_user_id)
lookup login
$login
Definition: cron.php:13

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

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 548 of file class.ilMailSearchCoursesGUI.php.

549 {
550 if ($_GET["view"] == "mycourses") {
551 $ids = $_REQUEST["search_crs"];
552 if (!is_array($ids) && $ids !== "") {
553 $ids = [$ids];
554 }
555 if (is_array($ids) && sizeof($ids)) {
556 $this->addPermission($ids);
557 } else {
558 ilUtil::sendInfo($this->lng->txt("mail_select_course"));
559 $this->showMyCourses();
560 }
561 } elseif ($_GET["view"] == "crs_members") {
562 $ids = $_REQUEST["search_members"];
563 if (is_array($ids) && sizeof($ids)) {
564 $this->addPermission($ids);
565 } else {
566 ilUtil::sendInfo($this->lng->txt("mail_select_one_entry"));
567 $this->showMembers();
568 }
569 } else {
570 $this->showMyCourses();
571 }
572 }

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

+ Here is the call graph for this function:

◆ showMembers()

ilMailSearchCoursesGUI::showMembers ( )

Show course members.

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

442 {
443 include_once 'Modules/Course/classes/class.ilCourseParticipants.php';
444
445 if ($_GET["search_crs"] != "") {
446 $_POST["search_crs"] = explode(",", $_GET["search_crs"]);
447 $_GET["search_crs"] = "";
448 } elseif ($_SESSION["search_crs"] != "") {
449 $_POST["search_crs"] = explode(",", $_SESSION["search_crs"]);
450 $_SESSION["search_crs"] = "";
451 }
452
453 if (is_array($_POST['search_crs'])) {
454 $_POST['search_crs'] = array_filter(array_map('intval', $_POST['search_crs']));
455 }
456
457 if (!is_array($_POST["search_crs"]) ||
458 count($_POST["search_crs"]) == 0) {
459 ilUtil::sendInfo($this->lng->txt("mail_select_course"));
460 $this->showMyCourses();
461 } else {
462 foreach ($_POST['search_crs'] as $crs_id) {
463 $oTmpCrs = ilObjectFactory::getInstanceByObjId($crs_id);
464 if ($oTmpCrs->getShowMembers() == $oTmpCrs->SHOW_MEMBERS_DISABLED) {
465 unset($_POST['search_crs']);
466 ilUtil::sendInfo($this->lng->txt('mail_crs_list_members_not_available_for_at_least_one_crs'));
467 return $this->showMyCourses();
468 }
469 unset($oTmpCrs);
470 }
471
472 $this->tpl->setTitle($this->lng->txt("mail_addressbook"));
473
474 $this->ctrl->setParameter($this, "view", "crs_members");
475 if ($_GET["ref"] != "") {
476 $this->ctrl->setParameter($this, "ref", $_GET["ref"]);
477 }
478 if (is_array($_POST["search_crs"])) {
479 $this->ctrl->setParameter($this, "search_crs", implode(",", $_POST["search_crs"]));
480 }
481 $this->tpl->setVariable("ACTION", $this->ctrl->getFormAction($this));
482 $this->ctrl->clearParameters($this);
483
484 $this->lng->loadLanguageModule('crs');
485 include_once 'Services/Contact/classes/class.ilMailSearchCoursesMembersTableGUI.php';
486 $context = $_GET["ref"] ? $_GET["ref"] : "mail";
487 $table = new ilMailSearchCoursesMembersTableGUI($this, 'crs', $context, $_POST["search_crs"]);
488 $tableData = array();
489 $searchTpl = new ilTemplate('tpl.mail_search_template.html', true, true, 'Services/Contact');
490 foreach ($_POST["search_crs"] as $crs_id) {
491 $members_obj = ilCourseParticipants::_getinstanceByObjId($crs_id);
492 $tmp_members = $members_obj->getParticipants();
493 $course_members = ilUtil::_sortIds($tmp_members, 'usr_data', 'lastname', 'usr_id');
494
495 foreach ($course_members as $member) {
496 $tmp_usr = new ilObjUser($member);
497 if (!$tmp_usr->getActive()) {
498 continue;
499 }
500
501 $name = ilObjUser::_lookupName($member);
503
504 $fullname = "";
505 if (in_array(ilObjUser::_lookupPref($member, 'public_profile'), array("g", 'y'))) {
506 $fullname = $name['lastname'] . ', ' . $name['firstname'];
507 }
508
509 $rowData = array(
510 'members_id' => $member,
511 'members_login' => $login,
512 'members_name' => $fullname,
513 'members_crs_grp' => $this->cache->lookupTitle($crs_id),
514 'search_crs' => $crs_id
515 );
516
517 if ('mail' == $context && ilBuddySystem::getInstance()->isEnabled()) {
518 $relation = ilBuddyList::getInstanceByGlobalUser()->getRelationByUserId($member);
519 $state_name = ilStr::convertUpperCamelCaseToUnderscoreCase($relation->getState()->getName());
520 $rowData['status'] = '';
521 if ($member != $this->user->getId()) {
522 if ($relation->isOwnedByActor()) {
523 $rowData['status'] = $this->lng->txt('buddy_bs_state_' . $state_name . '_a');
524 } else {
525 $rowData['status'] = $this->lng->txt('buddy_bs_state_' . $state_name . '_p');
526 }
527 }
528 }
529
530 $tableData[] = $rowData;
531 }
532 }
533 $table->setData($tableData);
534
535 if (count($tableData)) {
536 $searchTpl->setVariable("TXT_MARKED_ENTRIES", $this->lng->txt("marked_entries"));
537 }
538
539 $searchTpl->setVariable('TABLE', $table->getHtml());
540 $this->tpl->setContent($searchTpl->get());
541
542 if ($_GET["ref"] != "wsp") {
543 $this->tpl->printToStdout();
544 }
545 }
546 }
$_SESSION["AccountId"]
static getInstanceByGlobalUser()
static _lookupPref($a_usr_id, $a_keyword)
static _lookupName($a_user_id)
lookup user name
static 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,...
if($format !==null) $name
Definition: metadata.php:230

References $_GET, $_POST, $_SESSION, $context, $login, $name, 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().

+ 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.

◆ $rerfinery

ilMailSearchCoursesGUI::$rerfinery
protected

Definition at line 73 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: