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/classes/class.ilAddressbook.php";
27 public function __construct($wsp_access_handler = null, $wsp_node_id = null)
36 $this->wsp_access_handler = $wsp_access_handler;
37 $this->wsp_node_id = $wsp_node_id;
40 include_once
"Services/Mail/classes/class.ilMail.php";
42 $this->mailing_allowed = $rbacsystem->checkAccess(
'internal_mail',$mail->getMailObjectReferenceId());
44 $this->ctrl->saveParameter($this,
"mobj_id");
45 $this->ctrl->saveParameter($this,
"ref");
53 $forward_class = $this->ctrl->getNextClass($this);
54 switch($forward_class)
57 if (!(
$cmd = $this->ctrl->getCmd()))
59 $cmd =
"showMyCourses";
71 if (
$_GET[
"view"] ==
"mycourses")
73 $ids = ((int)
$_GET[
'search_crs']) ? array((
int)
$_GET[
'search_crs']) :
$_POST[
'search_crs'];
82 $this->showMyCourses();
85 else if (
$_GET[
"view"] ==
"crs_members")
87 $ids = ((int)
$_GET[
'search_members']) ? array((
int)
$_GET[
'search_members']) :
$_POST[
'search_members'];
100 $this->showMyCourses();
110 if (!is_array($old_mail_data = $this->umail->getSavedData()))
112 $this->umail->savePostData(
126 require_once
'./Services/Object/classes/class.ilObject.php';
128 $ids = ((int)
$_GET[
'search_crs']) ? array((
int)
$_GET[
'search_crs']) :
$_POST[
'search_crs'];
130 foreach ($ids as $crs_id)
136 $roles = $rbacreview->getAssignableChildRoles($ref_id);
137 foreach ($roles as $role)
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_')
143 if(isset($old_mail_data[
'rcp_to']) &&
144 trim($old_mail_data[
'rcp_to']) !=
'')
146 $rcpt = $rbacreview->getRoleMailboxAddress($role[
'obj_id']);
148 if(!$this->umail->doesRecipientStillExists($rcpt, $old_mail_data[
'rcp_to']))
152 array_push($members,
'#'.$role[
'title']);
161 array_push($members,
'#'.$role[
'title']);
169 $mail_data = $this->umail->appendSearchResult($members,
'to');
171 $mail_data = $this->umail->getSavedData();
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"]
186 #$this->ctrl->returnToParent($this);
196 if (!is_array($this->umail->getSavedData()))
198 $this->umail->savePostData(
212 $ids = ((int)
$_GET[
'search_members']) ? array((
int)
$_GET[
'search_members']) :
$_POST[
'search_members'];
214 foreach ($ids as $member)
217 array_push($members, $login);
219 $mail_data = $this->umail->appendSearchResult($members,
"to");
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"]
234 #$this->ctrl->returnToParent($this);
244 $ids = ((int)
$_GET[
'search_members']) ? array((
int)
$_GET[
'search_members']) :
$_POST[
'search_members'];
246 if ((
int)$ids && !is_array($ids))
247 $ids = array((
int)$ids);
253 foreach ($ids as $member)
257 if (!$this->abook->checkEntry($login))
265 $this->abook->addEntry(
288 if (
$_GET[
"view"] ==
"mycourses" &&
289 $_GET[
"ref"] ==
"mail")
291 $this->ctrl->returnToParent($this);
295 $this->showMyCourses();
302 public function showMyCourses()
306 include_once
'Modules/Course/classes/class.ilCourseParticipants.php';
308 $this->tpl->setTitle($this->lng->txt(
'mail_addressbook') );
310 $searchTpl =
new ilTemplate(
'tpl.mail_search_template.html',
true,
true,
'Services/Contact');
312 $_GET[
'view'] =
'mycourses';
314 $lng->loadLanguageModule(
'crs');
316 include_once
'Services/Contact/classes/class.ilMailSearchCoursesTableGUI.php';
318 $table->setId(
'search_crs_tbl');
319 include_once
'Modules/Course/classes/class.ilCourseParticipants.php';
322 $tableData = array();
323 if (is_array($crs_ids) && count($crs_ids) > 0)
325 $num_courses_hidden_members = 0;
326 include_once(
"./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php");
327 foreach($crs_ids as $crs_id)
334 $isOffline = !$oTmpCrs->isActivated();
336 $showMemberListEnabled = (boolean)$oTmpCrs->getShowMembers();
338 $isPrivilegedUser = $rbacsystem->checkAccess(
'write', $ref_ids[0]);
340 if($hasUntrashedReferences && ((!$isOffline && $showMemberListEnabled) || $isPrivilegedUser))
343 $crs_members = $oCrsParticipants->getParticipants();
345 foreach($crs_members as $key => $member)
348 if($tmp_usr->checkTimeLimit()==
false || $tmp_usr->getActive() == false )
350 unset($crs_members[$key]);
355 $hiddenMembers =
false;
356 if((
int)$oTmpCrs->getShowMembers() == $oTmpCrs->SHOW_MEMBERS_DISABLED)
358 ++$num_courses_hidden_members;
359 $hiddenMembers =
true;
365 $path_arr = $tree->getPathFull(
$ref_id, $tree->getRootId());
368 foreach($path_arr as $data)
374 $path .= $data[
'title'];
379 $current_selection_list->setListTitle($this->lng->txt(
"actions"));
380 $current_selection_list->setId(
"act_".$counter);
382 $this->ctrl->setParameter($this,
'search_crs', $crs_id);
383 $this->ctrl->setParameter($this,
'view',
'mycourses');
385 if(
$_GET[
"ref"] ==
"mail")
387 if ($this->mailing_allowed)
388 $current_selection_list->addItem($this->lng->txt(
"mail_members"),
'', $this->ctrl->getLinkTarget($this,
"mail"));
390 else if(
$_GET[
"ref"] ==
"wsp")
392 $current_selection_list->addItem($this->lng->txt(
"wsp_share_with_members"),
'', $this->ctrl->getLinkTarget($this,
"share"));
394 $current_selection_list->addItem($this->lng->txt(
"mail_list_members"),
'', $this->ctrl->getLinkTarget($this,
"showMembers"));
396 $this->ctrl->clearParameters($this);
401 "CRS_NAME" => $ilObjDataCache->lookupTitle($crs_id),
402 "CRS_NO_MEMBERS" => count($crs_members),
404 'COMMAND_SELECTION_LIST' => $current_selection_list->getHTML(),
405 "hidden_members" => $hiddenMembers,
408 $tableData[] = $rowData;
418 if($num_courses_hidden_members > 0)
420 $searchTpl->setCurrentBlock(
'caption_block');
421 $searchTpl->setVariable(
'TXT_LIST_MEMBERS_NOT_AVAILABLE', $this->lng->txt(
'mail_crs_list_members_not_available'));
422 $searchTpl->parseCurrentBlock();
426 $searchTpl->setVariable(
'TXT_MARKED_ENTRIES', $lng->txt(
'marked_entries'));
428 $table->setData($tableData);
429 if(
$_GET[
'ref'] ==
'mail') $this->tpl->setVariable(
'BUTTON_CANCEL', $lng->txt(
'cancel'));
431 $searchTpl->setVariable(
'TABLE', $table->getHtml());
432 $tpl->setContent($searchTpl->get());
434 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($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 $lng->loadLanguageModule(
'crs');
494 include_once
'Services/Contact/classes/class.ilMailSearchCoursesMembersTableGUI.php';
495 $context =
$_GET[
"ref"] ?
$_GET[
"ref"] :
"mail";
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)
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');
506 foreach ($course_members as $member)
509 if($tmp_usr->checkTimeLimit()==
false || $tmp_usr->getActive() == false )
521 $fullname = $name[
'lastname'].
', '.$name[
'firstname'];
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
532 $tableData[] = $rowData;
535 $table->setData($tableData);
536 if (count($tableData))
538 $searchTpl->setVariable(
"TXT_MARKED_ENTRIES",$lng->txt(
"marked_entries"));
541 $searchTpl->setVariable(
'TABLE', $table->getHtml());
542 $this->tpl->setContent($searchTpl->get());
544 if(
$_GET[
"ref"] !=
"wsp")
555 if (
$_GET[
"view"] ==
"mycourses")
565 $this->showMyCourses();
568 else if (
$_GET[
"view"] ==
"crs_members")
583 $this->showMyCourses();
589 if(!is_array($a_obj_ids))
591 $a_obj_ids = array($a_obj_ids);
594 $existing = $this->wsp_access_handler->getPermissions($this->wsp_node_id);
596 foreach($a_obj_ids as $object_id)
598 if(!in_array($object_id, $existing))
600 $added = $this->wsp_access_handler->addPermission($this->wsp_node_id, $object_id);
608 $this->ctrl->redirectByClass(
"ilworkspaceaccessgui",
"share");