ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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$ @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 73 of file class.ilMailSearchCoursesGUI.php.

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 }
user()
Definition: user.php:4
error($a_errmsg)
set error message @access public
Class UserMail this class handles user mails.
This class handles base functions for mail handling.
global $DIC

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

602 {
603 if(!is_array($a_obj_ids))
604 {
605 $a_obj_ids = array($a_obj_ids);
606 }
607
608 $existing = $this->wsp_access_handler->getPermissions($this->wsp_node_id);
609 $added = false;
610 foreach($a_obj_ids as $object_id)
611 {
612 if(!in_array($object_id, $existing))
613 {
614 $added = $this->wsp_access_handler->addPermission($this->wsp_node_id, $object_id);
615 }
616 }
617
618 if($added)
619 {
620 ilUtil::sendSuccess($this->lng->txt("wsp_share_success"), true);
621 }
622 $this->ctrl->redirectByClass("ilworkspaceaccessgui", "share");
623 }
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 296 of file class.ilMailSearchCoursesGUI.php.

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

References $_GET.

◆ executeCommand()

ilMailSearchCoursesGUI::executeCommand ( )

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

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

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

+ Here is the call graph for this function:

◆ mail()

ilMailSearchCoursesGUI::mail ( )

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

132 {
133 if ($_GET["view"] == "mycourses")
134 {
135 $ids = ((int)$_GET['search_crs']) ? array((int)$_GET['search_crs']) : $_POST['search_crs'];
136
137 if ($ids)
138 {
139 $this->mailCourses();
140 }
141 else
142 {
143 ilUtil::sendInfo($this->lng->txt("mail_select_course"));
144 $this->showMyCourses();
145 }
146 }
147 else if ($_GET["view"] == "crs_members")
148 {
149 $ids = ((int)$_GET['search_members']) ? array((int)$_GET['search_members']) : $_POST['search_members'];
150 if ($ids)
151 {
152 $this->mailMembers();
153 }
154 else
155 {
156 ilUtil::sendInfo($this->lng->txt("mail_select_one_entry"));
157 $this->showMembers();
158 }
159 }
160 else
161 {
162 $this->showMyCourses();
163 }
164 }
$_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 166 of file class.ilMailSearchCoursesGUI.php.

167 {
168 $members = array();
169
170 if (!is_array($old_mail_data = $this->umail->getSavedData()))
171 {
172 $this->umail->savePostData(
173 $this->user->getId(),
174 array(),
175 "",
176 "",
177 "",
178 "",
179 "",
180 "",
181 "",
182 ""
183 );
184 }
185
186 require_once './Services/Object/classes/class.ilObject.php';
187 require_once 'Services/Mail/classes/Address/Type/class.ilMailRoleAddressType.php';
188 $ids = ((int)$_GET['search_crs']) ? array((int)$_GET['search_crs']) : $_POST['search_crs'];
189
190 foreach ($ids as $crs_id)
191 {
192 $ref_ids = ilObject::_getAllReferences($crs_id);
193
194 foreach ($ref_ids as $ref_id)
195 {
196 $roles = $this->rbacreview->getAssignableChildRoles($ref_id);
197 foreach ($roles as $role)
198 {
199 if (substr($role['title'], 0, 14) == 'il_crs_member_' ||
200 substr($role['title'], 0, 13) == 'il_crs_tutor_' ||
201 substr($role['title'], 0, 13) == 'il_crs_admin_')
202 {
203 if(isset($old_mail_data['rcp_to']) &&
204 trim($old_mail_data['rcp_to']) != '')
205 {
206 $rcpt = ilMailRoleAddressType::getRoleMailboxAddress($role['obj_id']);
207 if(!$this->umail->existsRecipient($rcpt, $old_mail_data['rcp_to']))
208 {
209 array_push($members, $rcpt);
210 }
211 }
212 else
213 {
214 array_push($members, ilMailRoleAddressType::getRoleMailboxAddress($role['obj_id']));
215 }
216 }
217 }
218 }
219 }
220
221 if(count($members))
222 $mail_data = $this->umail->appendSearchResult($members, 'to');
223 else
224 $mail_data = $this->umail->getSavedData();
225
226 $this->umail->savePostData(
227 $mail_data["user_id"],
228 $mail_data["attachments"],
229 $mail_data["rcp_to"],
230 $mail_data["rcp_cc"],
231 $mail_data["rcp_bcc"],
232 $mail_data["m_type"],
233 $mail_data["m_email"],
234 $mail_data["m_subject"],
235 $mail_data["m_message"],
236 $mail_data["use_placeholders"],
237 $mail_data['tpl_ctx_id'],
238 $mail_data['tpl_ctx_params']
239 );
240
241 #$this->ctrl->returnToParent($this);
242 ilUtil::redirect("ilias.php?baseClass=ilMailGUI&type=search_res");
243 }
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, $ref_id, ilObject\_getAllReferences(), 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 245 of file class.ilMailSearchCoursesGUI.php.

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

References $_GET, $_POST, 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 567 of file class.ilMailSearchCoursesGUI.php.

568 {
569 if ($_GET["view"] == "mycourses")
570 {
571 $ids = $_REQUEST["search_crs"];
572 if (sizeof($ids))
573 {
574 $this->addPermission($ids);
575 }
576 else
577 {
578 ilUtil::sendInfo($this->lng->txt("mail_select_course"));
579 $this->showMyCourses();
580 }
581 }
582 else if ($_GET["view"] == "crs_members")
583 {
584 $ids = $_REQUEST["search_members"];
585 if (sizeof($ids))
586 {
587 $this->addPermission($ids);
588 }
589 else
590 {
591 ilUtil::sendInfo($this->lng->txt("mail_select_one_entry"));
592 $this->showMembers();
593 }
594 }
595 else
596 {
597 $this->showMyCourses();
598 }
599 }

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

+ Here is the call graph for this function:

◆ showMembers()

ilMailSearchCoursesGUI::showMembers ( )

Show course members.

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

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

References $_GET, $_POST, $_SESSION, 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.

◆ $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: