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']);
147 if(!$this->umail->doesRecipientStillExists($rcpt, $old_mail_data[
'rcp_to']))
149 array_push($members, $rcpt);
154 array_push($members, $rbacreview->getRoleMailboxAddress($role[
'obj_id']));
162 $mail_data = $this->umail->appendSearchResult($members,
'to');
164 $mail_data = $this->umail->getSavedData();
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"]
179 #$this->ctrl->returnToParent($this);
189 if (!is_array($this->umail->getSavedData()))
191 $this->umail->savePostData(
205 $ids = ((int)
$_GET[
'search_members']) ? array((
int)
$_GET[
'search_members']) :
$_POST[
'search_members'];
207 foreach ($ids as $member)
210 array_push($members, $login);
212 $mail_data = $this->umail->appendSearchResult($members,
"to");
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"]
227 #$this->ctrl->returnToParent($this);
237 $ids = ((int)
$_GET[
'search_members']) ? array((
int)
$_GET[
'search_members']) :
$_POST[
'search_members'];
239 if ((
int)$ids && !is_array($ids))
240 $ids = array((
int)$ids);
246 foreach ($ids as $member)
250 if (!$this->abook->checkEntry($login))
258 $this->abook->addEntry(
281 if (
$_GET[
"view"] ==
"mycourses" &&
282 $_GET[
"ref"] ==
"mail")
284 $this->ctrl->returnToParent($this);
288 $this->showMyCourses();
295 public function showMyCourses()
299 include_once
'Modules/Course/classes/class.ilCourseParticipants.php';
301 $this->tpl->setTitle($this->lng->txt(
'mail_addressbook') );
303 $searchTpl =
new ilTemplate(
'tpl.mail_search_template.html',
true,
true,
'Services/Contact');
305 $_GET[
'view'] =
'mycourses';
307 $lng->loadLanguageModule(
'crs');
309 include_once
'Services/Contact/classes/class.ilMailSearchCoursesTableGUI.php';
311 $table->setId(
'search_crs_tbl');
312 include_once
'Modules/Course/classes/class.ilCourseParticipants.php';
315 $tableData = array();
316 if (is_array($crs_ids) && count($crs_ids) > 0)
318 $num_courses_hidden_members = 0;
319 include_once(
"./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php");
320 foreach($crs_ids as $crs_id)
327 $isOffline = !$oTmpCrs->isActivated();
329 $showMemberListEnabled = (boolean)$oTmpCrs->getShowMembers();
331 $isPrivilegedUser = $rbacsystem->checkAccess(
'write', $ref_ids[0]);
333 if($hasUntrashedReferences && ((!$isOffline && $showMemberListEnabled) || $isPrivilegedUser))
336 $crs_members = $oCrsParticipants->getParticipants();
338 foreach($crs_members as $key => $member)
341 if($tmp_usr->checkTimeLimit()==
false || $tmp_usr->getActive() == false )
343 unset($crs_members[$key]);
348 $hiddenMembers =
false;
349 if((
int)$oTmpCrs->getShowMembers() == $oTmpCrs->SHOW_MEMBERS_DISABLED)
351 ++$num_courses_hidden_members;
352 $hiddenMembers =
true;
358 $path_arr = $tree->getPathFull(
$ref_id, $tree->getRootId());
361 foreach($path_arr as $data)
367 $path .= $data[
'title'];
372 $current_selection_list->setListTitle($this->lng->txt(
"actions"));
373 $current_selection_list->setId(
"act_".$counter);
375 $this->ctrl->setParameter($this,
'search_crs', $crs_id);
376 $this->ctrl->setParameter($this,
'view',
'mycourses');
378 if(
$_GET[
"ref"] ==
"mail")
380 if ($this->mailing_allowed)
381 $current_selection_list->addItem($this->lng->txt(
"mail_members"),
'', $this->ctrl->getLinkTarget($this,
"mail"));
383 else if(
$_GET[
"ref"] ==
"wsp")
385 $current_selection_list->addItem($this->lng->txt(
"wsp_share_with_members"),
'', $this->ctrl->getLinkTarget($this,
"share"));
387 $current_selection_list->addItem($this->lng->txt(
"mail_list_members"),
'', $this->ctrl->getLinkTarget($this,
"showMembers"));
389 $this->ctrl->clearParameters($this);
394 "CRS_NAME" => $ilObjDataCache->lookupTitle($crs_id),
395 "CRS_NO_MEMBERS" => count($crs_members),
397 'COMMAND_SELECTION_LIST' => $current_selection_list->getHTML(),
398 "hidden_members" => $hiddenMembers,
401 $tableData[] = $rowData;
411 if($num_courses_hidden_members > 0)
413 $searchTpl->setCurrentBlock(
'caption_block');
414 $searchTpl->setVariable(
'TXT_LIST_MEMBERS_NOT_AVAILABLE', $this->lng->txt(
'mail_crs_list_members_not_available'));
415 $searchTpl->parseCurrentBlock();
419 $searchTpl->setVariable(
'TXT_MARKED_ENTRIES', $lng->txt(
'marked_entries'));
421 $table->setData($tableData);
422 if(
$_GET[
'ref'] ==
'mail') $this->tpl->setVariable(
'BUTTON_CANCEL', $lng->txt(
'cancel'));
424 $searchTpl->setVariable(
'TABLE', $table->getHtml());
425 $tpl->setContent($searchTpl->get());
427 if(
$_GET[
"ref"] !=
"wsp")
440 include_once
'Modules/Course/classes/class.ilCourseParticipants.php';
442 if (
$_GET[
"search_crs"] !=
"")
444 $_POST[
"search_crs"] = explode(
",",
$_GET[
"search_crs"]);
445 $_GET[
"search_crs"] =
"";
453 if(is_array(
$_POST[
'search_crs']))
455 $_POST[
'search_crs'] = array_filter(array_map(
'intval',
$_POST[
'search_crs']));
458 if (!is_array(
$_POST[
"search_crs"]) ||
459 count(
$_POST[
"search_crs"]) == 0)
462 $this->showMyCourses();
466 foreach(
$_POST[
'search_crs'] as $crs_id)
469 if($oTmpCrs->getShowMembers() == $oTmpCrs->SHOW_MEMBERS_DISABLED)
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();
478 $this->tpl->setTitle($this->lng->txt(
"mail_addressbook"));
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);
486 $lng->loadLanguageModule(
'crs');
487 include_once
'Services/Contact/classes/class.ilMailSearchCoursesMembersTableGUI.php';
488 $context =
$_GET[
"ref"] ?
$_GET[
"ref"] :
"mail";
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)
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');
499 foreach ($course_members as $member)
502 if($tmp_usr->checkTimeLimit()==
false || $tmp_usr->getActive() == false )
514 $fullname = $name[
'lastname'].
', '.$name[
'firstname'];
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
525 $tableData[] = $rowData;
528 $table->setData($tableData);
529 if (count($tableData))
531 $searchTpl->setVariable(
"TXT_MARKED_ENTRIES",$lng->txt(
"marked_entries"));
534 $searchTpl->setVariable(
'TABLE', $table->getHtml());
535 $this->tpl->setContent($searchTpl->get());
537 if(
$_GET[
"ref"] !=
"wsp")
548 if (
$_GET[
"view"] ==
"mycourses")
558 $this->showMyCourses();
561 else if (
$_GET[
"view"] ==
"crs_members")
576 $this->showMyCourses();
582 if(!is_array($a_obj_ids))
584 $a_obj_ids = array($a_obj_ids);
587 $existing = $this->wsp_access_handler->getPermissions($this->wsp_node_id);
589 foreach($a_obj_ids as $object_id)
591 if(!in_array($object_id, $existing))
593 $added = $this->wsp_access_handler->addPermission($this->wsp_node_id, $object_id);
601 $this->ctrl->redirectByClass(
"ilworkspaceaccessgui",
"share");