ILIAS  release_4-4 Revision
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.

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

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  }
< 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']
Mail Box class Base class for creating and handling mail boxes.
global $ilCtrl
Definition: ilias.php:18
Class UserMail this class handles user mails.
Class Mail this class handles base functions for mail handling.
global $ilUser
Definition: imgupload.php:15

Member Function Documentation

◆ addPermission()

ilMailSearchCoursesGUI::addPermission (   $a_obj_ids)
protected

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

References ilUtil\sendSuccess().

Referenced by share().

588  {
589  if(!is_array($a_obj_ids))
590  {
591  $a_obj_ids = array($a_obj_ids);
592  }
593 
594  $existing = $this->wsp_access_handler->getPermissions($this->wsp_node_id);
595  $added = false;
596  foreach($a_obj_ids as $object_id)
597  {
598  if(!in_array($object_id, $existing))
599  {
600  $added = $this->wsp_access_handler->addPermission($this->wsp_node_id, $object_id);
601  }
602  }
603 
604  if($added)
605  {
606  ilUtil::sendSuccess($this->lng->txt("wsp_share_success"), true);
607  }
608  $this->ctrl->redirectByClass("ilworkspaceaccessgui", "share");
609  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
+ 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 241 of file class.ilMailSearchCoursesGUI.php.

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

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

◆ cancel()

ilMailSearchCoursesGUI::cancel ( )

Cancel action.

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

References $_GET, $data, $ilUser, $lng, $path, $ref_id, $tpl, ilObject\_getAllReferences(), ilCourseParticipants\_getInstanceByObjId(), ilParticipants\_getMembershipByType(), ilObject\_hasUntrashedReference(), and ilObjectFactory\getInstanceByObjId().

287  {
288  if ($_GET["view"] == "mycourses" &&
289  $_GET["ref"] == "mail")
290  {
291  $this->ctrl->returnToParent($this);
292  }
293  else
294  {
295  $this->showMyCourses();
296  }
297  }
$_GET["client_id"]
+ Here is the call graph for this function:

◆ executeCommand()

ilMailSearchCoursesGUI::executeCommand ( )

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

References $cmd.

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

◆ mail()

ilMailSearchCoursesGUI::mail ( )

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

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

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  }
$_POST['username']
Definition: cron.php:12
$_GET["client_id"]
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
global $ilUser
Definition: imgupload.php:15
+ Here is the call graph for this function:

◆ mailCourses()

ilMailSearchCoursesGUI::mailCourses ( )

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

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

Referenced by mail().

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 
148  if(!$this->umail->doesRecipientStillExists($rcpt, $old_mail_data['rcp_to']))
149  // does not work if Pear is enabled and Mailbox Address contain special chars!!
150 // array_push($members, $rcpt);
151  // FIX for Mantis: 7523, 8061
152  array_push($members, '#'.$role['title']);
153 
154  unset($rcpt);
155  }
156  else
157  {
158  // does not work if Pear is enabled and Mailbox Address contain special chars!!
159 // array_push($members, $rbacreview->getRoleMailboxAddress($role['obj_id']));
160  // FIX for Mantis: 7523, 8061
161  array_push($members, '#'.$role['title']);
162  }
163  }
164  }
165  }
166  }
167 
168  if(count($members))
169  $mail_data = $this->umail->appendSearchResult($members, 'to');
170  else
171  $mail_data = $this->umail->getSavedData();
172 
173  $this->umail->savePostData(
174  $mail_data["user_id"],
175  $mail_data["attachments"],
176  $mail_data["rcp_to"],
177  $mail_data["rcp_cc"],
178  $mail_data["rcp_bcc"],
179  $mail_data["m_type"],
180  $mail_data["m_email"],
181  $mail_data["m_subject"],
182  $mail_data["m_message"],
183  $mail_data["use_placeholders"]
184  );
185 
186  #$this->ctrl->returnToParent($this);
187  ilUtil::redirect("ilias.php?baseClass=ilMailGUI&type=search_res");
188  }
$_POST['username']
Definition: cron.php:12
$_GET["client_id"]
static _getAllReferences($a_id)
get all reference ids of object
global $ilUser
Definition: imgupload.php:15
$ref_id
Definition: sahs_server.php:39
static redirect($a_script)
http redirect to other script
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mailMembers()

ilMailSearchCoursesGUI::mailMembers ( )

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

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

Referenced by mail().

191  {
192  global $ilUser;
193 
194  $members = array();
195 
196  if (!is_array($this->umail->getSavedData()))
197  {
198  $this->umail->savePostData(
199  $ilUser->getId(),
200  array(),
201  "",
202  "",
203  "",
204  "",
205  "",
206  "",
207  "",
208  ""
209  );
210  }
211 
212  $ids = ((int)$_GET['search_members']) ? array((int)$_GET['search_members']) : $_POST['search_members'];
213 
214  foreach ($ids as $member)
215  {
216  $login = ilObjUser::_lookupLogin($member);
217  array_push($members, $login);
218  }
219  $mail_data = $this->umail->appendSearchResult($members,"to");
220 
221  $this->umail->savePostData(
222  $mail_data["user_id"],
223  $mail_data["attachments"],
224  $mail_data["rcp_to"],
225  $mail_data["rcp_cc"],
226  $mail_data["rcp_bcc"],
227  $mail_data["m_type"],
228  $mail_data["m_email"],
229  $mail_data["m_subject"],
230  $mail_data["m_message"],
231  $mail_data["use_placeholders"]
232  );
233 
234  #$this->ctrl->returnToParent($this);
235  ilUtil::redirect("ilias.php?baseClass=ilMailGUI&type=search_res");
236  }
$_POST['username']
Definition: cron.php:12
$_GET["client_id"]
_lookupLogin($a_user_id)
lookup login
global $ilUser
Definition: imgupload.php:15
static redirect($a_script)
http redirect to other script
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ share()

ilMailSearchCoursesGUI::share ( )

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

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

552  {
553  global $lng;
554 
555  if ($_GET["view"] == "mycourses")
556  {
557  $ids = $_REQUEST["search_crs"];
558  if (sizeof($ids))
559  {
560  $this->addPermission($ids);
561  }
562  else
563  {
564  ilUtil::sendInfo($lng->txt("mail_select_course"));
565  $this->showMyCourses();
566  }
567  }
568  else if ($_GET["view"] == "crs_members")
569  {
570  $ids = $_REQUEST["search_members"];
571  if (sizeof($ids))
572  {
573  $this->addPermission($ids);
574  }
575  else
576  {
577  ilUtil::sendInfo($lng->txt("mail_select_one_entry"));
578  $this->showMembers();
579  }
580  }
581  else
582  {
583  $this->showMyCourses();
584  }
585  }
$_GET["client_id"]
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
if($_REQUEST['ilias_path']) define('ILIAS_HTTP_PATH' $_REQUEST['ilias_path']
Definition: index.php:7
+ Here is the call graph for this function:

◆ showMembers()

ilMailSearchCoursesGUI::showMembers ( )

Show course members.

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

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().

444  {
445  global $lng, $ilUser, $ilObjDataCache;
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($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($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  $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  $table->setId('show_crs_mmbrs_tbl');
498  $tableData = array();
499  $searchTpl = new ilTemplate('tpl.mail_search_template.html', true, true, 'Services/Contact');
500  foreach($_POST["search_crs"] as $crs_id)
501  {
502  $members_obj = ilCourseParticipants::_getinstanceByObjId($crs_id);
503  $tmp_members = $members_obj->getParticipants();
504  $course_members = ilUtil::_sortIds($tmp_members, 'usr_data', 'lastname', 'usr_id');
505 
506  foreach ($course_members as $member)
507  {
508  $tmp_usr = new ilObjUser($member);
509  if($tmp_usr->checkTimeLimit()== false || $tmp_usr->getActive() == false )
510  {
511  unset($tmp_usr);
512  continue;
513  }
514  unset($tmp_usr);
515 
516  $name = ilObjUser::_lookupName($member);
517  $login = ilObjUser::_lookupLogin($member);
518 
519  $fullname = "";
520  if(in_array(ilObjUser::_lookupPref($member, 'public_profile'), array("g", 'y')))
521  $fullname = $name['lastname'].', '.$name['firstname'];
522 
523  $rowData = array(
524  'members_id' => $member,
525  'members_login' => $login,
526  'members_name' => $fullname,
527  'members_crs_grp' => $ilObjDataCache->lookupTitle($crs_id),
528  'members_in_addressbook' => $this->abook->checkEntryByLogin($login) ? $lng->txt("yes") : $lng->txt("no"),
529  'search_crs' => $crs_id
530  );
531 
532  $tableData[] = $rowData;
533  }
534  }
535  $table->setData($tableData);
536  if (count($tableData))
537  {
538  $searchTpl->setVariable("TXT_MARKED_ENTRIES",$lng->txt("marked_entries"));
539  }
540 
541  $searchTpl->setVariable('TABLE', $table->getHtml());
542  $this->tpl->setContent($searchTpl->get());
543 
544  if($_GET["ref"] != "wsp")
545  {
546  $this->tpl->show();
547  }
548  }
549  }
< 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']
static _lookupName($a_user_id)
lookup user name
$_POST['username']
Definition: cron.php:12
$_GET["client_id"]
_lookupPref($a_usr_id, $a_keyword)
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),&#39;usr_data&#39;,&#39;lastname&#39;,&#39;usr_id&#39;) => sorts by lastname.
special template class to simplify handling of ITX/PEAR
_lookupLogin($a_user_id)
lookup login
getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
global $ilUser
Definition: imgupload.php:15
+ 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(), and cancel().

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