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) {
106 case 'ilbuddysystemgui':
108 $this->error->raiseError($this->lng->txt(
'msg_no_perm_read'), $this->error->MESSAGE);
111 require_once
'Services/Contact/BuddySystem/classes/class.ilBuddySystemGUI.php';
112 $this->ctrl->saveParameter($this,
'search_crs');
113 $this->ctrl->setReturn($this,
'showMembers');
118 if (!($cmd = $this->ctrl->getCmd())) {
119 $cmd =
"showMyCourses";
130 if (
$_GET[
"view"] ==
"mycourses") {
131 $ids = ((int)
$_GET[
'search_crs']) ? array((
int)
$_GET[
'search_crs']) :
$_POST[
'search_crs'];
137 $this->showMyCourses();
139 } elseif (
$_GET[
"view"] ==
"crs_members") {
140 $ids = ((int)
$_GET[
'search_members']) ? array((
int)
$_GET[
'search_members']) :
$_POST[
'search_members'];
148 $this->showMyCourses();
156 if (!is_array($old_mail_data = $this->umail->getSavedData())) {
157 $this->umail->savePostData(
158 $this->
user->getId(),
171 require_once
'./Services/Object/classes/class.ilObject.php';
172 require_once
'Services/Mail/classes/Address/Type/class.ilMailRoleAddressType.php';
173 $ids = ((int)
$_GET[
'search_crs']) ? array((
int)
$_GET[
'search_crs']) :
$_POST[
'search_crs'];
175 foreach ($ids as $crs_id) {
178 foreach ($ref_ids as $ref_id) {
179 $roles = $this->rbacreview->getAssignableChildRoles($ref_id);
180 foreach ($roles as $role) {
181 if (substr($role[
'title'], 0, 14) ==
'il_crs_member_' ||
182 substr($role[
'title'], 0, 13) ==
'il_crs_tutor_' ||
183 substr($role[
'title'], 0, 13) ==
'il_crs_admin_') {
184 if (isset($old_mail_data[
'rcp_to']) &&
185 trim($old_mail_data[
'rcp_to']) !=
'') {
186 $rcpt = (new \ilRoleMailboxAddress($role[
'obj_id']))->value();
187 if (!$this->umail->existsRecipient($rcpt, (
string) $old_mail_data[
'rcp_to'])) {
188 array_push($members, $rcpt);
198 if (count($members)) {
199 $mail_data = $this->umail->appendSearchResult($members,
'to');
201 $mail_data = $this->umail->getSavedData();
204 $this->umail->savePostData(
205 $mail_data[
"user_id"],
206 $mail_data[
"attachments"],
207 $mail_data[
"rcp_to"],
208 $mail_data[
"rcp_cc"],
209 $mail_data[
"rcp_bcc"],
210 $mail_data[
"m_type"],
211 $mail_data[
"m_email"],
212 $mail_data[
"m_subject"],
213 $mail_data[
"m_message"],
214 $mail_data[
"use_placeholders"],
215 $mail_data[
'tpl_ctx_id'],
216 $mail_data[
'tpl_ctx_params']
219 #$this->ctrl->returnToParent($this); 227 if (!is_array($this->umail->getSavedData())) {
228 $this->umail->savePostData(
229 $this->
user->getId(),
242 $ids = ((int)
$_GET[
'search_members']) ? array((
int)
$_GET[
'search_members']) :
$_POST[
'search_members'];
244 foreach ($ids as $member) {
246 array_push($members,
$login);
248 $mail_data = $this->umail->appendSearchResult($members,
"to");
250 $this->umail->savePostData(
251 $mail_data[
"user_id"],
252 $mail_data[
"attachments"],
253 $mail_data[
"rcp_to"],
254 $mail_data[
"rcp_cc"],
255 $mail_data[
"rcp_bcc"],
256 $mail_data[
"m_type"],
257 $mail_data[
"m_email"],
258 $mail_data[
"m_subject"],
259 $mail_data[
"m_message"],
260 $mail_data[
"use_placeholders"],
261 $mail_data[
'tpl_ctx_id'],
262 $mail_data[
'tpl_ctx_params']
265 #$this->ctrl->returnToParent($this); 274 if (
$_GET[
"view"] ==
"mycourses" &&
275 $_GET[
"ref"] ==
"mail") {
276 $this->ctrl->returnToParent($this);
278 $this->showMyCourses();
285 public function showMyCourses()
287 include_once
'Modules/Course/classes/class.ilCourseParticipants.php';
289 $this->tpl->setTitle($this->lng->txt(
'mail_addressbook'));
291 $searchTpl =
new ilTemplate(
'tpl.mail_search_template.html',
true,
true,
'Services/Contact');
293 $_GET[
'view'] =
'mycourses';
295 $this->lng->loadLanguageModule(
'crs');
297 include_once
'Services/Contact/classes/class.ilMailSearchCoursesTableGUI.php';
299 $table->setId(
'search_crs_tbl');
300 include_once
'Modules/Course/classes/class.ilCourseParticipants.php';
303 $tableData = array();
304 if (is_array($crs_ids) && count($crs_ids) > 0) {
305 $num_courses_hidden_members = 0;
306 include_once(
"./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php");
307 foreach ($crs_ids as $crs_id) {
313 $isOffline = !$oTmpCrs->isActivated();
315 $showMemberListEnabled = (boolean) $oTmpCrs->getShowMembers();
317 $isPrivilegedUser = $this->rbacsystem->checkAccess(
'write', $ref_ids[0]);
319 if ($hasUntrashedReferences && ((!$isOffline && $showMemberListEnabled) || $isPrivilegedUser)) {
321 $crs_members = $oCrsParticipants->getParticipants();
323 foreach ($crs_members as
$key => $member) {
325 if (!$tmp_usr->getActive()) {
326 unset($crs_members[
$key]);
330 $hiddenMembers =
false;
331 if ((
int) $oTmpCrs->getShowMembers() == $oTmpCrs->SHOW_MEMBERS_DISABLED) {
332 ++$num_courses_hidden_members;
333 $hiddenMembers =
true;
338 $ref_id = current($ref_ids);
339 $path_arr = $this->tree->getPathFull($ref_id, $this->tree->getRootId());
342 foreach ($path_arr as
$data) {
343 if ($path_counter++) {
346 $path .= $data[
'title'];
348 $path = $this->lng->txt(
'path') .
': ' .
$path;
351 $current_selection_list->setListTitle($this->lng->txt(
"actions"));
352 $current_selection_list->setId(
"act_" . $counter);
354 $this->ctrl->setParameter($this,
'search_crs', $crs_id);
355 $this->ctrl->setParameter($this,
'view',
'mycourses');
357 if (
$_GET[
"ref"] ==
"mail") {
358 if ($this->mailing_allowed) {
359 $current_selection_list->addItem($this->lng->txt(
"mail_members"),
'', $this->ctrl->getLinkTarget($this,
"mail"));
361 } elseif (
$_GET[
"ref"] ==
"wsp") {
362 $current_selection_list->addItem($this->lng->txt(
"wsp_share_with_members"),
'', $this->ctrl->getLinkTarget($this,
"share"));
364 $current_selection_list->addItem($this->lng->txt(
"mail_list_members"),
'', $this->ctrl->getLinkTarget($this,
"showMembers"));
366 $this->ctrl->clearParameters($this);
370 "CRS_NAME" => $this->cache->lookupTitle($crs_id),
371 "CRS_NO_MEMBERS" => count($crs_members),
373 'COMMAND_SELECTION_LIST' => $current_selection_list->getHTML(),
374 "hidden_members" => $hiddenMembers,
377 $tableData[] = $rowData;
381 if ($num_courses_hidden_members > 0) {
382 $searchTpl->setCurrentBlock(
'caption_block');
383 $searchTpl->setVariable(
'TXT_LIST_MEMBERS_NOT_AVAILABLE', $this->lng->txt(
'mail_crs_list_members_not_available'));
384 $searchTpl->parseCurrentBlock();
388 $searchTpl->setVariable(
'TXT_MARKED_ENTRIES', $this->lng->txt(
'marked_entries'));
390 $table->setData($tableData);
391 if (
$_GET[
'ref'] ==
'mail') {
392 $this->tpl->setVariable(
'BUTTON_CANCEL', $this->lng->txt(
'cancel'));
395 $searchTpl->setVariable(
'TABLE',
$table->getHtml());
396 $this->tpl->setContent($searchTpl->get());
398 if (
$_GET[
"ref"] !=
"wsp") {
408 include_once
'Modules/Course/classes/class.ilCourseParticipants.php';
410 if (
$_GET[
"search_crs"] !=
"") {
411 $_POST[
"search_crs"] = explode(
",",
$_GET[
"search_crs"]);
412 $_GET[
"search_crs"] =
"";
413 } elseif (
$_SESSION[
"search_crs"] !=
"") {
418 if (is_array(
$_POST[
'search_crs'])) {
419 $_POST[
'search_crs'] = array_filter(array_map(
'intval',
$_POST[
'search_crs']));
422 if (!is_array(
$_POST[
"search_crs"]) ||
423 count(
$_POST[
"search_crs"]) == 0) {
425 $this->showMyCourses();
427 foreach (
$_POST[
'search_crs'] as $crs_id) {
429 if ($oTmpCrs->getShowMembers() == $oTmpCrs->SHOW_MEMBERS_DISABLED) {
430 unset(
$_POST[
'search_crs']);
431 ilUtil::sendInfo($this->lng->txt(
'mail_crs_list_members_not_available_for_at_least_one_crs'));
432 return $this->showMyCourses();
437 $this->tpl->setTitle($this->lng->txt(
"mail_addressbook"));
439 $this->ctrl->setParameter($this,
"view",
"crs_members");
440 if (
$_GET[
"ref"] !=
"") {
441 $this->ctrl->setParameter($this,
"ref",
$_GET[
"ref"]);
443 if (is_array(
$_POST[
"search_crs"])) {
444 $this->ctrl->setParameter($this,
"search_crs", implode(
",",
$_POST[
"search_crs"]));
446 $this->tpl->setVariable(
"ACTION", $this->ctrl->getFormAction($this));
447 $this->ctrl->clearParameters($this);
449 $this->lng->loadLanguageModule(
'crs');
450 include_once
'Services/Contact/classes/class.ilMailSearchCoursesMembersTableGUI.php';
453 $tableData = array();
454 $searchTpl =
new ilTemplate(
'tpl.mail_search_template.html',
true,
true,
'Services/Contact');
455 foreach (
$_POST[
"search_crs"] as $crs_id) {
456 $members_obj = ilCourseParticipants::_getinstanceByObjId($crs_id);
457 $tmp_members = $members_obj->getParticipants();
458 $course_members =
ilUtil::_sortIds($tmp_members,
'usr_data',
'lastname',
'usr_id');
460 foreach ($course_members as $member) {
462 if (!$tmp_usr->getActive()) {
471 $fullname =
$name[
'lastname'] .
', ' .
$name[
'firstname'];
475 'members_id' => $member,
476 'members_login' =>
$login,
477 'members_name' => $fullname,
478 'members_crs_grp' => $this->cache->lookupTitle($crs_id),
479 'search_crs' => $crs_id
485 $rowData[
'status'] =
'';
486 if ($member != $this->
user->getId()) {
487 if ($relation->isOwnedByRequest()) {
488 $rowData[
'status'] = $this->lng->txt(
'buddy_bs_state_' . $state_name .
'_a');
490 $rowData[
'status'] = $this->lng->txt(
'buddy_bs_state_' . $state_name .
'_p');
495 $tableData[] = $rowData;
498 $table->setData($tableData);
500 if (count($tableData)) {
501 $searchTpl->setVariable(
"TXT_MARKED_ENTRIES", $this->lng->txt(
"marked_entries"));
504 $searchTpl->setVariable(
'TABLE',
$table->getHtml());
505 $this->tpl->setContent($searchTpl->get());
507 if (
$_GET[
"ref"] !=
"wsp") {
515 if (
$_GET[
"view"] ==
"mycourses") {
516 $ids = $_REQUEST[
"search_crs"];
517 if (is_array($ids) &&
sizeof($ids)) {
521 $this->showMyCourses();
523 } elseif (
$_GET[
"view"] ==
"crs_members") {
524 $ids = $_REQUEST[
"search_members"];
525 if (is_array($ids) &&
sizeof($ids)) {
532 $this->showMyCourses();
538 if (!is_array($a_obj_ids)) {
539 $a_obj_ids = array($a_obj_ids);
542 $existing = $this->wsp_access_handler->getPermissions($this->wsp_node_id);
544 foreach ($a_obj_ids as $object_id) {
545 if (!in_array($object_id, $existing)) {
546 $added = $this->wsp_access_handler->addPermission($this->wsp_node_id, $object_id);
551 ilUtil::sendSuccess($this->lng->txt(
"wsp_share_success"),
true);
553 $this->ctrl->redirectByClass(
"ilworkspaceaccessgui",
"share");
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
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.
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
User interface class for advanced drop-down selection lists.
static _lookupPref($a_usr_id, $a_keyword)
if(empty($password)) $table
static redirect($a_script)