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(
'mail_visible',$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'];
85 else if (
$_GET[
"view"] ==
"crs_members")
87 $ids = ((int)
$_GET[
'search_members']) ? array((
int)
$_GET[
'search_members']) :
$_POST[
'search_members'];
106 global $ilUser,
$lng, $rbacreview;
110 if (!is_array($old_mail_data = $this->umail->getSavedData()))
112 $this->umail->savePostData(
126 require_once
'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);
304 global
$lng, $ilUser, $ilObjDataCache, $tree,
$tpl, $rbacsystem;
306 include_once
'Modules/Course/classes/class.ilCourseParticipants.php';
308 $this->tpl->setTitle($this->lng->txt(
'mail') );
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)
331 $isOffline = $oTmpCrs->getOfflineStatus();
333 $showMemberListEnabled = (boolean)$oTmpCrs->getShowMembers();
335 $isPrivilegedUser = $rbacsystem->checkAccess(
'edit', $ref_ids[0]);
337 if($hasUntrashedReferences && ((!$isOffline && $showMemberListEnabled) || $isPrivilegedUser))
340 $crs_members = $oCrsParticipants->getParticipants();
342 foreach($crs_members as $key => $member)
345 if($tmp_usr->checkTimeLimit()==
false || $tmp_usr->getActive() == false )
347 unset($crs_members[$key]);
352 $hiddenMembers =
false;
353 if((
int)$oTmpCrs->getShowMembers() == $oTmpCrs->SHOW_MEMBERS_DISABLED)
355 ++$num_courses_hidden_members;
356 $hiddenMembers =
true;
362 $path_arr = $tree->getPathFull(
$ref_id, $tree->getRootId());
365 foreach($path_arr as
$data)
371 $path .= $data[
'title'];
376 $current_selection_list->setListTitle($this->lng->txt(
"actions"));
377 $current_selection_list->setId(
"act_".$counter);
379 $this->ctrl->setParameter($this,
'search_crs', $crs_id);
380 $this->ctrl->setParameter($this,
'view',
'mycourses');
382 if(
$_GET[
"ref"] ==
"mail")
384 if ($this->mailing_allowed)
385 $current_selection_list->addItem($this->lng->txt(
"mail_members"),
'', $this->ctrl->getLinkTarget($this,
"mail"));
387 else if(
$_GET[
"ref"] ==
"wsp")
389 $current_selection_list->addItem($this->lng->txt(
"wsp_share_with_members"),
'', $this->ctrl->getLinkTarget($this,
"share"));
391 $current_selection_list->addItem($this->lng->txt(
"mail_list_members"),
'', $this->ctrl->getLinkTarget($this,
"showMembers"));
393 $this->ctrl->clearParameters($this);
398 "CRS_NAME" => $ilObjDataCache->lookupTitle($crs_id),
399 "CRS_NO_MEMBERS" => count($crs_members),
401 'COMMAND_SELECTION_LIST' => $current_selection_list->getHTML(),
402 "hidden_members" => $hiddenMembers,
405 $tableData[] = $rowData;
415 if($num_courses_hidden_members > 0)
417 $searchTpl->setCurrentBlock(
'caption_block');
418 $searchTpl->setVariable(
'TXT_LIST_MEMBERS_NOT_AVAILABLE', $this->lng->txt(
'mail_crs_list_members_not_available'));
419 $searchTpl->parseCurrentBlock();
423 $searchTpl->setVariable(
'TXT_MARKED_ENTRIES', $lng->txt(
'marked_entries'));
425 $table->setData($tableData);
426 if(
$_GET[
'ref'] ==
'mail') $this->tpl->setVariable(
'BUTTON_CANCEL', $lng->txt(
'cancel'));
428 $searchTpl->setVariable(
'TABLE', $table->getHtml());
429 $tpl->setContent($searchTpl->get());
431 if(
$_GET[
"ref"] !=
"wsp")
442 global
$lng, $ilUser, $ilObjDataCache;
444 include_once
'Modules/Course/classes/class.ilCourseParticipants.php';
446 if (
$_GET[
"search_crs"] !=
"")
448 $_POST[
"search_crs"] = explode(
",",
$_GET[
"search_crs"]);
449 $_GET[
"search_crs"] =
"";
457 if (!is_array(
$_POST[
"search_crs"]) ||
458 count(
$_POST[
"search_crs"]) == 0)
465 foreach(
$_POST[
'search_crs'] as $crs_id)
468 if($oTmpCrs->getShowMembers() == $oTmpCrs->SHOW_MEMBERS_DISABLED)
470 unset(
$_POST[
'search_crs']);
471 ilUtil::sendInfo($lng->txt(
'mail_crs_list_members_not_available_for_at_least_one_crs'));
477 $this->tpl->setTitle($this->lng->txt(
"mail"));
479 $this->ctrl->setParameter($this,
"view",
"crs_members");
480 if (
$_GET[
"ref"] !=
"") $this->ctrl->setParameter($this,
"ref",
$_GET[
"ref"]);
481 if (is_array(
$_POST[
"search_crs"])) $this->ctrl->setParameter($this,
"search_crs", implode(
",",
$_POST[
"search_crs"]));
482 $this->tpl->setVariable(
"ACTION", $this->ctrl->getFormAction($this));
483 $this->ctrl->clearParameters($this);
485 $lng->loadLanguageModule(
'crs');
486 include_once
'Services/Contact/classes/class.ilMailSearchCoursesMembersTableGUI.php';
487 $context =
$_GET[
"ref"] ?
$_GET[
"ref"] :
"mail";
489 $table->setId(
'show_crs_mmbrs_tbl');
490 $tableData = array();
491 $searchTpl =
new ilTemplate(
'tpl.mail_search_template.html',
true,
true,
'Services/Contact');
492 foreach(
$_POST[
"search_crs"] as $crs_id)
494 $members_obj = ilCourseParticipants::_getinstanceByObjId($crs_id);
495 $tmp_members = $members_obj->getParticipants();
496 $course_members =
ilUtil::_sortIds($tmp_members,
'usr_data',
'lastname',
'usr_id');
498 foreach ($course_members as $member)
501 if($tmp_usr->checkTimeLimit()==
false || $tmp_usr->getActive() == false )
513 $fullname = $name[
'lastname'].
', '.$name[
'firstname'];
516 'MEMBERS_ID' => $member,
517 'MEMBERS_LOGIN' => $login,
518 'MEMBERS_NAME' => $fullname,
519 'MEMBERS_CRS_GRP' => $ilObjDataCache->lookupTitle($crs_id),
520 'MEMBERS_IN_ADDRESSBOOK' => $this->abook->checkEntryByLogin($login) ? $lng->txt(
"yes") : $lng->txt(
"no"),
521 'search_crs' => $crs_id
523 $tableData[] = $rowData;
526 $table->setData($tableData);
527 if (count($tableData))
532 $searchTpl->setVariable(
"TXT_MARKED_ENTRIES",$lng->txt(
"marked_entries"));
535 $searchTpl->setVariable(
'TABLE', $table->getHtml());
536 $this->tpl->setContent($searchTpl->get());
538 if(
$_GET[
"ref"] !=
"wsp")
549 if (
$_GET[
"view"] ==
"mycourses")
562 else if (
$_GET[
"view"] ==
"crs_members")
583 if(!is_array($a_obj_ids))
585 $a_obj_ids = array($a_obj_ids);
588 $existing = $this->wsp_access_handler->getPermissions($this->wsp_node_id);
590 foreach($a_obj_ids as $object_id)
592 if(!in_array($object_id, $existing))
594 $added = $this->wsp_access_handler->addPermission($this->wsp_node_id, $object_id);
602 $this->ctrl->redirectByClass(
"ilworkspaceaccessgui",
"share");