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';
75 public function __construct($wsp_access_handler = null, $wsp_node_id = null)
79 $this->tpl = $DIC[
'tpl'];
80 $this->ctrl = $DIC[
'ilCtrl'];
81 $this->lng = $DIC[
'lng'];
82 $this->
user = $DIC[
'ilUser'];
83 $this->error = $DIC[
'ilErr'];
84 $this->rbacsystem = $DIC[
'rbacsystem'];
85 $this->rbacreview = $DIC[
'rbacreview'];
86 $this->tree = $DIC[
'tree'];
87 $this->cache = $DIC[
'ilObjDataCache'];
88 $this->refinery = $DIC->refinery();
91 $this->wsp_access_handler = $wsp_access_handler;
92 $this->wsp_node_id = $wsp_node_id;
95 include_once
"Services/Mail/classes/class.ilMail.php";
97 $this->mailing_allowed = $this->rbacsystem->checkAccess(
'internal_mail', $mail->getMailObjectReferenceId());
99 $this->ctrl->saveParameter($this,
"mobj_id");
100 $this->ctrl->saveParameter($this,
"ref");
108 if (isset(
$_GET[
'ref'])) {
110 $context = $this->refinery->byTrying([
111 $this->refinery->kindlyTo()->string(),
112 $this->refinery->custom()->transformation(
static function ($value) use ($always) {
115 ])->transform(
$_GET[
'ref']);
123 $forward_class = $this->ctrl->getNextClass($this);
124 switch ($forward_class) {
125 case 'ilbuddysystemgui':
127 $this->error->raiseError($this->lng->txt(
'msg_no_perm_read'), $this->error->MESSAGE);
130 require_once
'Services/Contact/BuddySystem/classes/class.ilBuddySystemGUI.php';
131 $this->ctrl->saveParameter($this,
'search_crs');
132 $this->ctrl->setReturn($this,
'showMembers');
137 if (!($cmd = $this->ctrl->getCmd())) {
138 $cmd =
"showMyCourses";
149 if (
$_GET[
"view"] ==
"mycourses") {
150 $ids = ((int)
$_GET[
'search_crs']) ? array((
int)
$_GET[
'search_crs']) :
$_POST[
'search_crs'];
156 $this->showMyCourses();
158 } elseif (
$_GET[
"view"] ==
"crs_members") {
159 $ids = ((int)
$_GET[
'search_members']) ? array((
int)
$_GET[
'search_members']) :
$_POST[
'search_members'];
167 $this->showMyCourses();
175 if (!is_array($old_mail_data = $this->umail->getSavedData())) {
176 $this->umail->savePostData(
177 $this->
user->getId(),
190 require_once
'./Services/Object/classes/class.ilObject.php';
191 require_once
'Services/Mail/classes/Address/Type/class.ilMailRoleAddressType.php';
192 $ids = ((int)
$_GET[
'search_crs']) ? array((
int)
$_GET[
'search_crs']) :
$_POST[
'search_crs'];
194 foreach ($ids as $crs_id) {
197 foreach ($ref_ids as $ref_id) {
198 $roles = $this->rbacreview->getAssignableChildRoles($ref_id);
201 $this->
user->getId(),
204 if (!$can_send_mails) {
208 foreach ($roles as $role) {
209 if (substr($role[
'title'], 0, 14) ==
'il_crs_member_' ||
210 substr($role[
'title'], 0, 13) ==
'il_crs_tutor_' ||
211 substr($role[
'title'], 0, 13) ==
'il_crs_admin_') {
212 if (isset($old_mail_data[
'rcp_to']) &&
213 trim($old_mail_data[
'rcp_to']) !=
'') {
214 $rcpt = (new \ilRoleMailboxAddress($role[
'obj_id']))->value();
215 if (!$this->umail->existsRecipient($rcpt, (
string) $old_mail_data[
'rcp_to'])) {
216 array_push($members, $rcpt);
226 if (count($members)) {
227 $mail_data = $this->umail->appendSearchResult($members,
'to');
229 $mail_data = $this->umail->getSavedData();
232 $this->umail->savePostData(
233 $mail_data[
"user_id"],
234 $mail_data[
"attachments"],
235 $mail_data[
"rcp_to"],
236 $mail_data[
"rcp_cc"],
237 $mail_data[
"rcp_bcc"],
238 $mail_data[
"m_email"],
239 $mail_data[
"m_subject"],
240 $mail_data[
"m_message"],
241 $mail_data[
"use_placeholders"],
242 $mail_data[
'tpl_ctx_id'],
243 $mail_data[
'tpl_ctx_params']
246 #$this->ctrl->returnToParent($this); 254 if (!is_array($this->umail->getSavedData())) {
255 $this->umail->savePostData(
256 $this->
user->getId(),
269 $ids = ((int)
$_GET[
'search_members']) ? array((
int)
$_GET[
'search_members']) :
$_POST[
'search_members'];
271 foreach ($ids as $member) {
273 array_push($members,
$login);
275 $mail_data = $this->umail->appendSearchResult($members,
"to");
277 $this->umail->savePostData(
278 $mail_data[
"user_id"],
279 $mail_data[
"attachments"],
280 $mail_data[
"rcp_to"],
281 $mail_data[
"rcp_cc"],
282 $mail_data[
"rcp_bcc"],
283 $mail_data[
"m_email"],
284 $mail_data[
"m_subject"],
285 $mail_data[
"m_message"],
286 $mail_data[
"use_placeholders"],
287 $mail_data[
'tpl_ctx_id'],
288 $mail_data[
'tpl_ctx_params']
291 #$this->ctrl->returnToParent($this); 300 if (
$_GET[
"view"] ==
"mycourses" &&
301 $_GET[
"ref"] ==
"mail") {
302 $this->ctrl->returnToParent($this);
304 $this->showMyCourses();
311 public function showMyCourses()
313 include_once
'Modules/Course/classes/class.ilCourseParticipants.php';
315 $this->tpl->setTitle($this->lng->txt(
'mail_addressbook'));
317 $searchTpl =
new ilTemplate(
'tpl.mail_search_template.html',
true,
true,
'Services/Contact');
319 $_GET[
'view'] =
'mycourses';
321 $this->lng->loadLanguageModule(
'crs');
323 include_once
'Services/Contact/classes/class.ilMailSearchCoursesTableGUI.php';
325 $table->setId(
'search_crs_tbl');
326 include_once
'Modules/Course/classes/class.ilCourseParticipants.php';
329 $tableData = array();
330 if (is_array($crs_ids) && count($crs_ids) > 0) {
331 $num_courses_hidden_members = 0;
332 include_once(
"./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php");
333 foreach ($crs_ids as $crs_id) {
339 $isOffline = !$oTmpCrs->isActivated();
341 $showMemberListEnabled = (boolean) $oTmpCrs->getShowMembers();
343 $isPrivilegedUser = $this->rbacsystem->checkAccess(
'write', $ref_ids[0]);
344 $oTmpCrs->setRefId($ref_ids[0]);
348 $this->
user->getId(),
352 if ($hasUntrashedReferences &&
353 ((!$isOffline && ($showMemberListEnabled || $can_send_mails)) || $isPrivilegedUser)) {
355 $crs_members = $oCrsParticipants->getParticipants();
357 foreach ($crs_members as $key => $member) {
360 unset($crs_members[$key]);
364 $hiddenMembers =
false;
365 if ((
int) $oTmpCrs->getShowMembers() == $oTmpCrs->SHOW_MEMBERS_DISABLED) {
366 ++$num_courses_hidden_members;
367 $hiddenMembers =
true;
372 $ref_id = current($ref_ids);
373 $path_arr = $this->tree->getPathFull($ref_id, $this->tree->getRootId());
376 foreach ($path_arr as
$data) {
377 if ($path_counter++) {
380 $path .= $data[
'title'];
382 $path = $this->lng->txt(
'path') .
': ' . $path;
385 $current_selection_list->setListTitle($this->lng->txt(
"actions"));
386 $current_selection_list->setId(
"act_" . $counter);
388 $this->ctrl->setParameter($this,
'search_crs', $crs_id);
389 $this->ctrl->setParameter($this,
'view',
'mycourses');
392 if ($this->mailing_allowed && $can_send_mails) {
393 $current_selection_list->addItem($this->lng->txt(
"mail_members"),
'', $this->ctrl->getLinkTarget($this,
"mail"));
396 $current_selection_list->addItem($this->lng->txt(
"wsp_share_with_members"),
'', $this->ctrl->getLinkTarget($this,
"share"));
398 $current_selection_list->addItem($this->lng->txt(
"mail_list_members"),
'', $this->ctrl->getLinkTarget($this,
"showMembers"));
400 $this->ctrl->clearParameters($this);
404 "CRS_NAME" => $this->cache->lookupTitle($crs_id),
405 "CRS_NO_MEMBERS" => count($crs_members),
407 'COMMAND_SELECTION_LIST' => $current_selection_list->getHTML(),
408 "hidden_members" => $hiddenMembers,
409 "can_send_mails" => $can_send_mails,
412 $tableData[] = $rowData;
416 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', $this->lng->txt(
'marked_entries'));
425 $table->setData($tableData);
426 if (
$_GET[
'ref'] ==
'mail') {
427 $this->tpl->setVariable(
'BUTTON_CANCEL', $this->lng->txt(
'cancel'));
430 $searchTpl->setVariable(
'TABLE', $table->getHtml());
431 $this->tpl->setContent($searchTpl->get());
433 if (
$_GET[
"ref"] !=
"wsp") {
434 $this->tpl->printToStdout();
443 include_once
'Modules/Course/classes/class.ilCourseParticipants.php';
445 if (
$_GET[
"search_crs"] !=
"") {
446 $_POST[
"search_crs"] = explode(
",",
$_GET[
"search_crs"]);
447 $_GET[
"search_crs"] =
"";
448 } elseif (
$_SESSION[
"search_crs"] !=
"") {
453 if (is_array(
$_POST[
'search_crs'])) {
454 $_POST[
'search_crs'] = array_filter(array_map(
'intval',
$_POST[
'search_crs']));
457 if (!is_array(
$_POST[
"search_crs"]) ||
458 count(
$_POST[
"search_crs"]) == 0) {
460 $this->showMyCourses();
462 foreach (
$_POST[
'search_crs'] as $crs_id) {
464 if ($oTmpCrs->getShowMembers() == $oTmpCrs->SHOW_MEMBERS_DISABLED) {
465 unset(
$_POST[
'search_crs']);
466 ilUtil::sendInfo($this->lng->txt(
'mail_crs_list_members_not_available_for_at_least_one_crs'));
467 return $this->showMyCourses();
472 $this->tpl->setTitle($this->lng->txt(
"mail_addressbook"));
474 $this->ctrl->setParameter($this,
"view",
"crs_members");
475 if (
$_GET[
"ref"] !=
"") {
476 $this->ctrl->setParameter($this,
"ref",
$_GET[
"ref"]);
478 if (is_array(
$_POST[
"search_crs"])) {
479 $this->ctrl->setParameter($this,
"search_crs", implode(
",",
$_POST[
"search_crs"]));
481 $this->tpl->setVariable(
"ACTION", $this->ctrl->getFormAction($this));
482 $this->ctrl->clearParameters($this);
484 $this->lng->loadLanguageModule(
'crs');
485 include_once
'Services/Contact/classes/class.ilMailSearchCoursesMembersTableGUI.php';
488 $tableData = array();
489 $searchTpl =
new ilTemplate(
'tpl.mail_search_template.html',
true,
true,
'Services/Contact');
490 foreach (
$_POST[
"search_crs"] as $crs_id) {
491 $members_obj = ilCourseParticipants::_getinstanceByObjId($crs_id);
492 $tmp_members = $members_obj->getParticipants();
493 $course_members =
ilUtil::_sortIds($tmp_members,
'usr_data',
'lastname',
'usr_id');
495 foreach ($course_members as $member) {
497 if (!$tmp_usr->getActive()) {
506 $fullname =
$name[
'lastname'] .
', ' .
$name[
'firstname'];
510 'members_id' => $member,
511 'members_login' =>
$login,
512 'members_name' => $fullname,
513 'members_crs_grp' => $this->cache->lookupTitle($crs_id),
514 'search_crs' => $crs_id
520 $rowData[
'status'] =
'';
521 if ($member != $this->
user->getId()) {
522 if ($relation->isOwnedByActor()) {
523 $rowData[
'status'] = $this->lng->txt(
'buddy_bs_state_' . $state_name .
'_a');
525 $rowData[
'status'] = $this->lng->txt(
'buddy_bs_state_' . $state_name .
'_p');
530 $tableData[] = $rowData;
533 $table->setData($tableData);
535 if (count($tableData)) {
536 $searchTpl->setVariable(
"TXT_MARKED_ENTRIES", $this->lng->txt(
"marked_entries"));
539 $searchTpl->setVariable(
'TABLE', $table->getHtml());
540 $this->tpl->setContent($searchTpl->get());
542 if (
$_GET[
"ref"] !=
"wsp") {
543 $this->tpl->printToStdout();
550 if (
$_GET[
"view"] ==
"mycourses") {
551 $ids = $_REQUEST[
"search_crs"];
552 if (!is_array($ids) && $ids !==
"") {
555 if (is_array($ids) &&
sizeof($ids)) {
559 $this->showMyCourses();
561 } elseif (
$_GET[
"view"] ==
"crs_members") {
562 $ids = $_REQUEST[
"search_members"];
563 if (is_array($ids) &&
sizeof($ids)) {
570 $this->showMyCourses();
576 if (!is_array($a_obj_ids)) {
577 $a_obj_ids = array($a_obj_ids);
580 $existing = $this->wsp_access_handler->getPermissions($this->wsp_node_id);
582 foreach ($a_obj_ids as $object_id) {
583 if (!in_array($object_id, $existing)) {
584 $added = $this->wsp_access_handler->addPermission($this->wsp_node_id, $object_id);
589 ilUtil::sendSuccess($this->lng->txt(
"wsp_share_success"),
true);
591 $this->ctrl->redirectByClass(
"ilworkspaceaccessgui",
"share");
addPermission($a_obj_ids)
static _lookupLogin($a_user_id)
lookup login
static canSendMailToMembers( $ref_id_or_instance, ?int $usr_id=null, ?int $mail_obj_ref_id=null)
This method was introduced as a band-aid fix for #22764.
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
Class ilRoleMailboxAddress.
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.
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
static _lookupPref($a_usr_id, $a_keyword)
static getMailObjectRefId()
Determines the reference id of the mail object and stores this information in a local cache variable...
static _lookupActive($a_usr_id)
Check user account active.
static redirect($a_script)