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