5 require_once
'./Services/User/classes/class.ilObjUser.php';
6 require_once
"Services/Mail/classes/class.ilMailbox.php";
7 require_once
"Services/Mail/classes/class.ilFormatMail.php";
8 require_once
'Services/Contact/BuddySystem/classes/class.ilBuddySystem.php';
73 public function __construct($wsp_access_handler = null, $wsp_node_id = null)
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'];
88 $this->wsp_access_handler = $wsp_access_handler;
89 $this->wsp_node_id = $wsp_node_id;
92 include_once
"Services/Mail/classes/class.ilMail.php";
94 $this->mailing_allowed = $this->rbacsystem->checkAccess(
'internal_mail',$mail->getMailObjectReferenceId());
96 $this->ctrl->saveParameter($this,
"mobj_id");
97 $this->ctrl->saveParameter($this,
"ref");
104 $forward_class = $this->ctrl->getNextClass($this);
105 switch($forward_class)
107 case 'ilbuddysystemgui':
110 $this->error->raiseError($this->lng->txt(
'msg_no_perm_read'), $this->error->MESSAGE);
113 require_once
'Services/Contact/BuddySystem/classes/class.ilBuddySystemGUI.php';
114 $this->ctrl->saveParameter($this,
'search_crs');
115 $this->ctrl->setReturn($this,
'showMembers');
120 if (!(
$cmd = $this->ctrl->getCmd()))
122 $cmd =
"showMyCourses";
133 if (
$_GET[
"view"] ==
"mycourses")
144 $this->showMyCourses();
147 else if (
$_GET[
"view"] ==
"crs_members")
149 $ids = ((int)
$_GET[
'search_members']) ?
array((
int)
$_GET[
'search_members']) :
$_POST[
'search_members'];
162 $this->showMyCourses();
170 if (!is_array($old_mail_data = $this->umail->getSavedData()))
172 $this->umail->savePostData(
173 $this->
user->getId(),
186 require_once
'./Services/Object/classes/class.ilObject.php';
187 require_once
'Services/Mail/classes/Address/Type/class.ilMailRoleAddressType.php';
190 foreach ($ids as $crs_id)
196 $roles = $this->rbacreview->getAssignableChildRoles($ref_id);
197 foreach ($roles as $role)
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_')
203 if(isset($old_mail_data[
'rcp_to']) &&
204 trim($old_mail_data[
'rcp_to']) !=
'')
206 $rcpt = ilMailRoleAddressType::getRoleMailboxAddress($role[
'obj_id']);
207 if(!$this->umail->existsRecipient($rcpt, $old_mail_data[
'rcp_to']))
209 array_push($members, $rcpt);
214 array_push($members, ilMailRoleAddressType::getRoleMailboxAddress($role[
'obj_id']));
222 $mail_data = $this->umail->appendSearchResult($members,
'to');
224 $mail_data = $this->umail->getSavedData();
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']
241 #$this->ctrl->returnToParent($this); 249 if (!is_array($this->umail->getSavedData()))
251 $this->umail->savePostData(
252 $this->
user->getId(),
265 $ids = ((int)
$_GET[
'search_members']) ?
array((
int)
$_GET[
'search_members']) :
$_POST[
'search_members'];
267 foreach ($ids as $member)
270 array_push($members, $login);
272 $mail_data = $this->umail->appendSearchResult($members,
"to");
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']
289 #$this->ctrl->returnToParent($this); 298 if (
$_GET[
"view"] ==
"mycourses" &&
299 $_GET[
"ref"] ==
"mail")
301 $this->ctrl->returnToParent($this);
305 $this->showMyCourses();
312 public function showMyCourses()
314 include_once
'Modules/Course/classes/class.ilCourseParticipants.php';
316 $this->tpl->setTitle($this->lng->txt(
'mail_addressbook') );
318 $searchTpl =
new ilTemplate(
'tpl.mail_search_template.html',
true,
true,
'Services/Contact');
320 $_GET[
'view'] =
'mycourses';
322 $this->lng->loadLanguageModule(
'crs');
324 include_once
'Services/Contact/classes/class.ilMailSearchCoursesTableGUI.php';
326 $table->setId(
'search_crs_tbl');
327 include_once
'Modules/Course/classes/class.ilCourseParticipants.php';
330 $tableData =
array();
331 if (is_array($crs_ids) && count($crs_ids) > 0)
333 $num_courses_hidden_members = 0;
334 include_once(
"./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php");
335 foreach($crs_ids as $crs_id)
342 $isOffline = !$oTmpCrs->isActivated();
344 $showMemberListEnabled = (boolean)$oTmpCrs->getShowMembers();
346 $isPrivilegedUser = $this->rbacsystem->checkAccess(
'write', $ref_ids[0]);
348 if($hasUntrashedReferences && ((!$isOffline && $showMemberListEnabled) || $isPrivilegedUser))
351 $crs_members = $oCrsParticipants->getParticipants();
353 foreach($crs_members as $key => $member)
356 if($tmp_usr->checkTimeLimit()==
false || $tmp_usr->getActive() == false )
358 unset($crs_members[$key]);
363 $hiddenMembers =
false;
364 if((
int)$oTmpCrs->getShowMembers() == $oTmpCrs->SHOW_MEMBERS_DISABLED)
366 ++$num_courses_hidden_members;
367 $hiddenMembers =
true;
373 $path_arr = $this->tree->getPathFull(
$ref_id, $this->tree->getRootId());
376 foreach($path_arr as
$data)
382 $path .= $data[
'title'];
387 $current_selection_list->setListTitle($this->lng->txt(
"actions"));
388 $current_selection_list->setId(
"act_".$counter);
390 $this->ctrl->setParameter($this,
'search_crs', $crs_id);
391 $this->ctrl->setParameter($this,
'view',
'mycourses');
393 if(
$_GET[
"ref"] ==
"mail")
395 if ($this->mailing_allowed)
396 $current_selection_list->addItem($this->lng->txt(
"mail_members"),
'', $this->ctrl->getLinkTarget($this,
"mail"));
398 else if(
$_GET[
"ref"] ==
"wsp")
400 $current_selection_list->addItem($this->lng->txt(
"wsp_share_with_members"),
'', $this->ctrl->getLinkTarget($this,
"share"));
402 $current_selection_list->addItem($this->lng->txt(
"mail_list_members"),
'', $this->ctrl->getLinkTarget($this,
"showMembers"));
404 $this->ctrl->clearParameters($this);
409 "CRS_NAME" => $this->cache->lookupTitle($crs_id),
410 "CRS_NO_MEMBERS" => count($crs_members),
412 'COMMAND_SELECTION_LIST' => $current_selection_list->getHTML(),
413 "hidden_members" => $hiddenMembers,
416 $tableData[] = $rowData;
420 if($num_courses_hidden_members > 0)
422 $searchTpl->setCurrentBlock(
'caption_block');
423 $searchTpl->setVariable(
'TXT_LIST_MEMBERS_NOT_AVAILABLE', $this->lng->txt(
'mail_crs_list_members_not_available'));
424 $searchTpl->parseCurrentBlock();
428 $searchTpl->setVariable(
'TXT_MARKED_ENTRIES', $this->lng->txt(
'marked_entries'));
430 $table->setData($tableData);
431 if(
$_GET[
'ref'] ==
'mail') $this->tpl->setVariable(
'BUTTON_CANCEL', $this->lng->txt(
'cancel'));
433 $searchTpl->setVariable(
'TABLE', $table->getHtml());
434 $this->tpl->setContent($searchTpl->get());
436 if(
$_GET[
"ref"] !=
"wsp")
447 include_once
'Modules/Course/classes/class.ilCourseParticipants.php';
449 if (
$_GET[
"search_crs"] !=
"")
451 $_POST[
"search_crs"] = explode(
",",
$_GET[
"search_crs"]);
452 $_GET[
"search_crs"] =
"";
460 if(is_array(
$_POST[
'search_crs']))
462 $_POST[
'search_crs'] = array_filter(array_map(
'intval',
$_POST[
'search_crs']));
465 if (!is_array(
$_POST[
"search_crs"]) ||
466 count(
$_POST[
"search_crs"]) == 0)
469 $this->showMyCourses();
473 foreach(
$_POST[
'search_crs'] as $crs_id)
476 if($oTmpCrs->getShowMembers() == $oTmpCrs->SHOW_MEMBERS_DISABLED)
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();
485 $this->tpl->setTitle($this->lng->txt(
"mail_addressbook"));
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);
493 $this->lng->loadLanguageModule(
'crs');
494 include_once
'Services/Contact/classes/class.ilMailSearchCoursesMembersTableGUI.php';
495 $context =
$_GET[
"ref"] ?
$_GET[
"ref"] :
"mail";
497 $tableData =
array();
498 $searchTpl =
new ilTemplate(
'tpl.mail_search_template.html',
true,
true,
'Services/Contact');
499 foreach(
$_POST[
"search_crs"] as $crs_id)
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');
505 foreach ($course_members as $member)
508 if($tmp_usr->checkTimeLimit()==
false || $tmp_usr->getActive() == false )
520 $fullname = $name[
'lastname'].
', '.$name[
'firstname'];
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
534 $rowData[
'status'] =
'';
535 if($member != $this->
user->getId())
537 if($relation->isOwnedByRequest())
539 $rowData[
'status'] = $this->lng->txt(
'buddy_bs_state_' . $state_name .
'_a');
543 $rowData[
'status'] = $this->lng->txt(
'buddy_bs_state_' . $state_name .
'_p');
548 $tableData[] = $rowData;
551 $table->setData($tableData);
552 if (count($tableData))
554 $searchTpl->setVariable(
"TXT_MARKED_ENTRIES", $this->lng->txt(
"marked_entries"));
557 $searchTpl->setVariable(
'TABLE', $table->getHtml());
558 $this->tpl->setContent($searchTpl->get());
560 if(
$_GET[
"ref"] !=
"wsp")
569 if (
$_GET[
"view"] ==
"mycourses")
571 $ids = $_REQUEST[
"search_crs"];
579 $this->showMyCourses();
582 else if (
$_GET[
"view"] ==
"crs_members")
584 $ids = $_REQUEST[
"search_members"];
597 $this->showMyCourses();
603 if(!is_array($a_obj_ids))
605 $a_obj_ids =
array($a_obj_ids);
608 $existing = $this->wsp_access_handler->getPermissions($this->wsp_node_id);
610 foreach($a_obj_ids as $object_id)
612 if(!in_array($object_id, $existing))
614 $added = $this->wsp_access_handler->addPermission($this->wsp_node_id, $object_id);
622 $this->ctrl->redirectByClass(
"ilworkspaceaccessgui",
"share");
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
addPermission($a_obj_ids)
static _lookupLogin($a_user_id)
lookup login
static _lookupName($a_user_id)
lookup user name
static _hasUntrashedReference($a_obj_id)
checks wether an object has at least one reference that is not in trash
static convertUpperCamelCaseToUnderscoreCase($value)
Convert a value given in camel case conversion to underscore case conversion (e.g.
static getInstanceByGlobalUser()
static _getMembershipByType($a_usr_id, $a_type, $a_only_member_role=false)
get membership by type Get course or group membership
static _getInstanceByObjId($a_obj_id)
Get singleton instance.
__construct($wsp_access_handler=null, $wsp_node_id=null)
static _getAllReferences($a_id)
get all reference ids of object
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),'usr_data','lastname','usr_id') => sorts by lastname.
showMembers()
Show course members.
This class handles base functions for mail handling.
special template class to simplify handling of ITX/PEAR
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
Create styles array
The data for the language used.
User interface class for advanced drop-down selection lists.
static _lookupPref($a_usr_id, $a_keyword)
static redirect($a_script)
http redirect to other script