ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
ilMailSearchCoursesGUI Class Reference
+ Collaboration diagram for ilMailSearchCoursesGUI:

Public Member Functions

 __construct ($wsp_access_handler=null, $wsp_node_id=null)
 
 executeCommand ()
 
 mail ()
 
 mailCourses ()
 
 mailMembers ()
 
 adoptMembers ()
 Take over course members to addressbook. More...
 
 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$

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 $this->abook = new ilAddressbook($ilUser->getId());
49 }
Mail Box class Base class for creating and handling mail boxes.
Class UserMail this class handles user mails.
Class Mail this class handles base functions for mail handling.
< a tabindex="-1" style="border-style: none;" href="#" title="Refresh Image" onclick="document.getElementById('siimage').src = './securimage_show.php?sid=' + Math.random(); this.blur(); return false">< img src="./images/refresh.png" alt="Reload Image" height="32" width="32" onclick="this.blur()" align="bottom" border="0"/></a >< br/>< strong > Enter Code *if($_SERVER['REQUEST_METHOD']=='POST' &&@ $_POST['do']=='contact') $_SESSION['ctform']['success']
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 580 of file class.ilMailSearchCoursesGUI.php.

581 {
582 if(!is_array($a_obj_ids))
583 {
584 $a_obj_ids = array($a_obj_ids);
585 }
586
587 $existing = $this->wsp_access_handler->getPermissions($this->wsp_node_id);
588 $added = false;
589 foreach($a_obj_ids as $object_id)
590 {
591 if(!in_array($object_id, $existing))
592 {
593 $added = $this->wsp_access_handler->addPermission($this->wsp_node_id, $object_id);
594 }
595 }
596
597 if($added)
598 {
599 ilUtil::sendSuccess($this->lng->txt("wsp_share_success"), true);
600 }
601 $this->ctrl->redirectByClass("ilworkspaceaccessgui", "share");
602 }
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:

◆ adoptMembers()

ilMailSearchCoursesGUI::adoptMembers ( )

Take over course members to addressbook.

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

235 {
236 global $lng;
237 $ids = ((int)$_GET['search_members']) ? array((int)$_GET['search_members']) : $_POST['search_members'];
238
239 if ((int)$ids && !is_array($ids))
240 $ids = array((int)$ids);
241
242 if ($ids )
243 {
244 $members = array();
245
246 foreach ($ids as $member)
247 {
248 $login = ilObjUser::_lookupLogin($member);
249
250 if (!$this->abook->checkEntry($login))
251 {
252 $name = ilObjUser::_lookupName($member);
253 $email = '';
254 if(ilObjUser::_lookupPref((int)$member, 'public_email') == 'y')
255 {
256 $email = ilObjUser::_lookupEmail($member);
257 }
258 $this->abook->addEntry(
259 $login,
260 $name["firstname"],
261 $name["lastname"],
262 $email
263 );
264 }
265 }
266 ilUtil::sendInfo($lng->txt("mail_members_added_addressbook"));
267 }
268 else
269 {
270 ilUtil::sendInfo($lng->txt("mail_select_one_entry"));
271 }
272
273 $this->showMembers();
274 }
$_GET["client_id"]
_lookupLogin($a_user_id)
lookup login
static _lookupName($a_user_id)
lookup user name
_lookupEmail($a_user_id)
Lookup email.
_lookupPref($a_usr_id, $a_keyword)
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
$_POST['username']
Definition: cron.php:12

References $_GET, $_POST, $lng, ilObjUser\_lookupEmail(), ilObjUser\_lookupLogin(), ilObjUser\_lookupName(), ilObjUser\_lookupPref(), ilUtil\sendInfo(), and showMembers().

+ Here is the call graph for this function:

◆ cancel()

ilMailSearchCoursesGUI::cancel ( )

Cancel action.

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

280 {
281 if ($_GET["view"] == "mycourses" &&
282 $_GET["ref"] == "mail")
283 {
284 $this->ctrl->returnToParent($this);
285 }
286 else
287 {
288 $this->showMyCourses();
289 }
290 }

References $_GET.

◆ executeCommand()

ilMailSearchCoursesGUI::executeCommand ( )

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

52 {
53 $forward_class = $this->ctrl->getNextClass($this);
54 switch($forward_class)
55 {
56 default:
57 if (!($cmd = $this->ctrl->getCmd()))
58 {
59 $cmd = "showMyCourses";
60 }
61
62 $this->$cmd();
63 break;
64 }
65 return true;
66 }
$cmd
Definition: sahs_server.php:35

References $cmd.

◆ mail()

ilMailSearchCoursesGUI::mail ( )

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

69 {
70 global $ilUser, $lng;
71 if ($_GET["view"] == "mycourses")
72 {
73 $ids = ((int)$_GET['search_crs']) ? array((int)$_GET['search_crs']) : $_POST['search_crs'];
74
75 if ($ids)
76 {
77 $this->mailCourses();
78 }
79 else
80 {
81 ilUtil::sendInfo($lng->txt("mail_select_course"));
82 $this->showMyCourses();
83 }
84 }
85 else if ($_GET["view"] == "crs_members")
86 {
87 $ids = ((int)$_GET['search_members']) ? array((int)$_GET['search_members']) : $_POST['search_members'];
88 if ($ids)
89 {
90 $this->mailMembers();
91 }
92 else
93 {
94 ilUtil::sendInfo($lng->txt("mail_select_one_entry"));
95 $this->showMembers();
96 }
97 }
98 else
99 {
100 $this->showMyCourses();
101 }
102 }

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

105 {
106 global $ilUser, $lng, $rbacreview;
107
108 $members = array();
109
110 if (!is_array($old_mail_data = $this->umail->getSavedData()))
111 {
112 $this->umail->savePostData(
113 $ilUser->getId(),
114 array(),
115 "",
116 "",
117 "",
118 "",
119 "",
120 "",
121 "",
122 ""
123 );
124 }
125
126 require_once './Services/Object/classes/class.ilObject.php';
127
128 $ids = ((int)$_GET['search_crs']) ? array((int)$_GET['search_crs']) : $_POST['search_crs'];
129
130 foreach ($ids as $crs_id)
131 {
132 $ref_ids = ilObject::_getAllReferences($crs_id);
133
134 foreach ($ref_ids as $ref_id)
135 {
136 $roles = $rbacreview->getAssignableChildRoles($ref_id);
137 foreach ($roles as $role)
138 {
139 if (substr($role['title'], 0, 14) == 'il_crs_member_' ||
140 substr($role['title'], 0, 13) == 'il_crs_tutor_' ||
141 substr($role['title'], 0, 13) == 'il_crs_admin_')
142 {
143 if(isset($old_mail_data['rcp_to']) &&
144 trim($old_mail_data['rcp_to']) != '')
145 {
146 $rcpt = $rbacreview->getRoleMailboxAddress($role['obj_id']);
147 if(!$this->umail->doesRecipientStillExists($rcpt, $old_mail_data['rcp_to']))
148 {
149 array_push($members, $rcpt);
150 }
151 }
152 else
153 {
154 array_push($members, $rbacreview->getRoleMailboxAddress($role['obj_id']));
155 }
156 }
157 }
158 }
159 }
160
161 if(count($members))
162 $mail_data = $this->umail->appendSearchResult($members, 'to');
163 else
164 $mail_data = $this->umail->getSavedData();
165
166 $this->umail->savePostData(
167 $mail_data["user_id"],
168 $mail_data["attachments"],
169 $mail_data["rcp_to"],
170 $mail_data["rcp_cc"],
171 $mail_data["rcp_bcc"],
172 $mail_data["m_type"],
173 $mail_data["m_email"],
174 $mail_data["m_subject"],
175 $mail_data["m_message"],
176 $mail_data["use_placeholders"]
177 );
178
179 #$this->ctrl->returnToParent($this);
180 ilUtil::redirect("ilias.php?baseClass=ilMailGUI&type=search_res");
181 }
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 183 of file class.ilMailSearchCoursesGUI.php.

184 {
185 global $ilUser;
186
187 $members = array();
188
189 if (!is_array($this->umail->getSavedData()))
190 {
191 $this->umail->savePostData(
192 $ilUser->getId(),
193 array(),
194 "",
195 "",
196 "",
197 "",
198 "",
199 "",
200 "",
201 ""
202 );
203 }
204
205 $ids = ((int)$_GET['search_members']) ? array((int)$_GET['search_members']) : $_POST['search_members'];
206
207 foreach ($ids as $member)
208 {
209 $login = ilObjUser::_lookupLogin($member);
210 array_push($members, $login);
211 }
212 $mail_data = $this->umail->appendSearchResult($members,"to");
213
214 $this->umail->savePostData(
215 $mail_data["user_id"],
216 $mail_data["attachments"],
217 $mail_data["rcp_to"],
218 $mail_data["rcp_cc"],
219 $mail_data["rcp_bcc"],
220 $mail_data["m_type"],
221 $mail_data["m_email"],
222 $mail_data["m_subject"],
223 $mail_data["m_message"],
224 $mail_data["use_placeholders"]
225 );
226
227 #$this->ctrl->returnToParent($this);
228 ilUtil::redirect("ilias.php?baseClass=ilMailGUI&type=search_res");
229 }

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

545 {
546 global $lng;
547
548 if ($_GET["view"] == "mycourses")
549 {
550 $ids = $_REQUEST["search_crs"];
551 if (sizeof($ids))
552 {
553 $this->addPermission($ids);
554 }
555 else
556 {
557 ilUtil::sendInfo($lng->txt("mail_select_course"));
558 $this->showMyCourses();
559 }
560 }
561 else if ($_GET["view"] == "crs_members")
562 {
563 $ids = $_REQUEST["search_members"];
564 if (sizeof($ids))
565 {
566 $this->addPermission($ids);
567 }
568 else
569 {
570 ilUtil::sendInfo($lng->txt("mail_select_one_entry"));
571 $this->showMembers();
572 }
573 }
574 else
575 {
576 $this->showMyCourses();
577 }
578 }
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 436 of file class.ilMailSearchCoursesGUI.php.

437 {
438 global $lng, $ilUser, $ilObjDataCache;
439
440 include_once 'Modules/Course/classes/class.ilCourseParticipants.php';
441
442 if ($_GET["search_crs"] != "")
443 {
444 $_POST["search_crs"] = explode(",", $_GET["search_crs"]);
445 $_GET["search_crs"] = "";
446 }
447 else if ($_SESSION["search_crs"] != "")
448 {
449 $_POST["search_crs"] = explode(",", $_SESSION["search_crs"]);
450 $_SESSION["search_crs"] = "";
451 }
452
453 if(is_array($_POST['search_crs']))
454 {
455 $_POST['search_crs'] = array_filter(array_map('intval', $_POST['search_crs']));
456 }
457
458 if (!is_array($_POST["search_crs"]) ||
459 count($_POST["search_crs"]) == 0)
460 {
461 ilUtil::sendInfo($lng->txt("mail_select_course"));
462 $this->showMyCourses();
463 }
464 else
465 {
466 foreach($_POST['search_crs'] as $crs_id)
467 {
468 $oTmpCrs = ilObjectFactory::getInstanceByObjId($crs_id);
469 if($oTmpCrs->getShowMembers() == $oTmpCrs->SHOW_MEMBERS_DISABLED)
470 {
471 unset($_POST['search_crs']);
472 ilUtil::sendInfo($lng->txt('mail_crs_list_members_not_available_for_at_least_one_crs'));
473 return $this->showMyCourses();
474 }
475 unset($oTmpCrs);
476 }
477
478 $this->tpl->setTitle($this->lng->txt("mail_addressbook"));
479
480 $this->ctrl->setParameter($this, "view", "crs_members");
481 if ($_GET["ref"] != "") $this->ctrl->setParameter($this, "ref", $_GET["ref"]);
482 if (is_array($_POST["search_crs"])) $this->ctrl->setParameter($this, "search_crs", implode(",", $_POST["search_crs"]));
483 $this->tpl->setVariable("ACTION", $this->ctrl->getFormAction($this));
484 $this->ctrl->clearParameters($this);
485
486 $lng->loadLanguageModule('crs');
487 include_once 'Services/Contact/classes/class.ilMailSearchCoursesMembersTableGUI.php';
488 $context = $_GET["ref"] ? $_GET["ref"] : "mail";
489 $table = new ilMailSearchCoursesMembersTableGUI($this, 'crs', $context);
490 $table->setId('show_crs_mmbrs_tbl');
491 $tableData = array();
492 $searchTpl = new ilTemplate('tpl.mail_search_template.html', true, true, 'Services/Contact');
493 foreach($_POST["search_crs"] as $crs_id)
494 {
495 $members_obj = ilCourseParticipants::_getinstanceByObjId($crs_id);
496 $tmp_members = $members_obj->getParticipants();
497 $course_members = ilUtil::_sortIds($tmp_members, 'usr_data', 'lastname', 'usr_id');
498
499 foreach ($course_members as $member)
500 {
501 $tmp_usr = new ilObjUser($member);
502 if($tmp_usr->checkTimeLimit()== false || $tmp_usr->getActive() == false )
503 {
504 unset($tmp_usr);
505 continue;
506 }
507 unset($tmp_usr);
508
509 $name = ilObjUser::_lookupName($member);
510 $login = ilObjUser::_lookupLogin($member);
511
512 $fullname = "";
513 if(in_array(ilObjUser::_lookupPref($member, 'public_profile'), array("g", 'y')))
514 $fullname = $name['lastname'].', '.$name['firstname'];
515
516 $rowData = array(
517 'members_id' => $member,
518 'members_login' => $login,
519 'members_name' => $fullname,
520 'members_crs_grp' => $ilObjDataCache->lookupTitle($crs_id),
521 'members_in_addressbook' => $this->abook->checkEntryByLogin($login) ? $lng->txt("yes") : $lng->txt("no"),
522 'search_crs' => $crs_id
523 );
524
525 $tableData[] = $rowData;
526 }
527 }
528 $table->setData($tableData);
529 if (count($tableData))
530 {
531 $searchTpl->setVariable("TXT_MARKED_ENTRIES",$lng->txt("marked_entries"));
532 }
533
534 $searchTpl->setVariable('TABLE', $table->getHtml());
535 $this->tpl->setContent($searchTpl->get());
536
537 if($_GET["ref"] != "wsp")
538 {
539 $this->tpl->show();
540 }
541 }
542 }
getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
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(), ilObjectFactory\getInstanceByObjId(), and ilUtil\sendInfo().

Referenced by adoptMembers(), 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

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