ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilMailSearchObjectsTableGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22{
23 protected ilObjUser $user;
25 protected object $parentObject;
26 protected array $mode;
27 protected bool $mailing_allowed;
28
32 public function __construct($a_parent_obj, string $type = 'crs', string $context = 'mail')
33 {
34 global $DIC;
35
36 $this->lng = $DIC['lng'];
37 $this->ctrl = $DIC['ilCtrl'];
38 $this->user = $DIC['ilUser'];
39 $this->rbacsystem = $DIC['rbacsystem'];
40
41 $this->lng->loadLanguageModule('crs');
42 $this->lng->loadLanguageModule('buddysystem');
43
44 if ($context === 'mail') {
45 $mail = new ilMail($this->user->getId());
46 $this->mailing_allowed = $this->rbacsystem->checkAccess('internal_mail', $mail->getMailObjectReferenceId());
47 }
48
49 $mode = [];
50 if ($type === 'crs') {
51 $mode['short'] = 'crs';
52 $mode['long'] = 'course';
53 $mode['checkbox'] = 'search_crs';
54 $mode['tableprefix'] = 'crstable';
55 $mode['lng_mail'] = $this->lng->txt('mail_my_courses');
56 $mode['view'] = 'myobjects';
57 $this->setTitle($mode['lng_mail']);
58 } elseif ($type === 'grp') {
59 $mode['short'] = 'grp';
60 $mode['long'] = 'group';
61 $mode['checkbox'] = 'search_grp';
62 $mode['tableprefix'] = 'grptable';
63 $mode['lng_mail'] = $this->lng->txt('mail_my_groups');
64 $mode['view'] = 'myobjects';
65 $this->setTitle($mode['lng_mail']);
66 }
67
68 $this->setId('search_' . $mode['short']);
69 parent::__construct($a_parent_obj);
70
71 $this->parentObject = $a_parent_obj;
72 $this->mode = $mode;
73 $this->context = $context;
74
75 $this->ctrl->setParameter($a_parent_obj, 'view', $mode['view']);
76
77 $http = $DIC['http'];
78 $refinery = $DIC->refinery();
79
80
81 if (
82 $http->wrapper()->query()->has('ref') &&
83 $http->wrapper()->query()->retrieve('ref', $refinery->kindlyTo()->string()) !== ''
84 ) {
85 $this->ctrl->setParameter(
86 $a_parent_obj,
87 'ref',
88 $http->wrapper()->query()->retrieve('ref', $refinery->kindlyTo()->string())
89 );
90 }
91
92 if ($http->wrapper()->post()->has($mode['checkbox'])) {
93 $ids = $http->wrapper()->post()->retrieve(
94 $mode['checkbox'],
95 $refinery->kindlyTo()->listOf(
96 $refinery->in()->series([
97 $refinery->kindlyTo()->int(),
98 $refinery->kindlyTo()->string()
99 ])
100 )
101 );
102
103 if ($ids !== []) {
104 $this->ctrl->setParameter(
105 $a_parent_obj,
106 $mode['checkbox'],
107 implode(', ', $ids)
108 );
109 }
110 }
111
112 $this->setFormAction($this->ctrl->getFormAction($a_parent_obj));
113 $this->ctrl->clearParameters($a_parent_obj);
114
115 $this->setSelectAllCheckbox($mode["checkbox"] . '[]');
116 $this->setRowTemplate('tpl.mail_search_objects_row.html', 'components/ILIAS/Contact');
117
118 $this->setShowRowsSelector(true);
119
120 $this->addColumn('', '', '1px', true);
121 $this->addColumn($mode["lng_mail"], 'OBJECT_NAME', '30%');
122 $this->addColumn($this->lng->txt('path'), 'OBJECT_PATH', '30%');
123 $this->addColumn($this->lng->txt('obj_count_members'), 'OBJECT_NO_MEMBERS', '20%');
124 $this->addColumn($this->lng->txt('actions'), '', '19%');
125
126 if ($context === "mail") {
127 if ($this->mailing_allowed) {
128 $this->addMultiCommand('mail', $this->lng->txt('mail_members'));
129 }
130 } elseif ($context === "wsp") {
131 $this->lng->loadLanguageModule("wsp");
132 $this->addMultiCommand('share', $this->lng->txt('wsp_share_with_members'));
133 }
134 $this->addMultiCommand('showMembers', $this->lng->txt('mail_list_members'));
135
136 if (
137 $http->wrapper()->query()->has('ref') &&
138 $http->wrapper()->query()->retrieve('ref', $refinery->to()->string()) === 'mail'
139 ) {
140 $this->addCommandButton('cancel', $this->lng->txt('cancel'));
141 }
142 }
143
144 protected function fillRow(array $a_set): void
145 {
146 if ($a_set['hidden_members']) {
147 $this->tpl->setCurrentBlock('caption_asterisk');
148 $this->tpl->touchBlock('caption_asterisk');
149 $this->tpl->parseCurrentBlock();
150 }
151 foreach ($a_set as $key => $value) {
152 $this->tpl->setVariable(strtoupper($key), $value);
153 }
154 $this->tpl->setVariable('SHORT', $this->mode["short"]);
155 }
156
157 public function numericOrdering(string $a_field): bool
158 {
159 return $a_field === 'OBJECT_NO_MEMBERS';
160 }
161}
__construct($a_parent_obj, string $type='crs', string $context='mail')
fillRow(array $a_set)
Standard Version of Fill Row.
numericOrdering(string $a_field)
Should this field be sorted numeric?
User class.
class ilRbacSystem system function like checkAccess, addActiveRole ... Supporting system functions ar...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setShowRowsSelector(bool $a_value)
Toggle rows-per-page selector.
setTitle(string $a_title, string $a_icon="", string $a_icon_alt="")
addCommandButton(string $a_cmd, string $a_text, string $a_onclick='', string $a_id="", string $a_class="")
addMultiCommand(string $a_cmd, string $a_text)
setFormAction(string $a_form_action, bool $a_multipart=false)
addColumn(string $a_text, string $a_sort_field="", string $a_width="", bool $a_is_checkbox_action_column=false, string $a_class="", string $a_tooltip="", bool $a_tooltip_with_html=false)
setSelectAllCheckbox(string $a_select_all_checkbox, bool $a_select_all_on_top=false)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setId(string $a_val)
$http
Definition: deliver.php:30
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26