19 declare(strict_types=1);
42 public function __construct(
object $a_parent_obj,
string $a_parent_cmd)
46 $this->containerTemplate = $DIC[
'tpl'];
47 $this->
user = $DIC[
'ilUser'];
49 $this->
setId(
'buddy_system_tbl');
52 $this->
lng->loadLanguageModule(
'buddysystem');
54 $this->hasAccessToMailSystem = $DIC->rbac()->system()->checkAccess(
59 $chatSettings =
new ilSetting(
'chatroom');
60 $this->isChatEnabled = (bool) $chatSettings->get(
'chat_enabled',
'0');
65 $this->
setTitle($this->
lng->txt(
'buddy_tbl_title_relations'));
67 if ($this->hasAccessToMailSystem || $this->isChatEnabled) {
70 if ($this->hasAccessToMailSystem) {
73 if ($this->isChatEnabled) {
78 $this->
addColumn($this->
lng->txt(
'name'),
'public_name');
80 $this->
addColumn($this->
lng->txt(
'buddy_tbl_state_actions_col_label'),
'',
'',
false,
'ilRight');
82 $this->
setRowTemplate(
'tpl.buddy_system_relation_table_row.html',
'Services/Contact/BuddySystem');
100 $this->
lng->txt(
'buddy_tbl_filter_state'),
101 self::STATE_FILTER_ELM_ID
106 foreach ($state_factory->getValidStates() as $state) {
107 if ($state->isInitial()) {
111 $state_filter_mapper = $state_factory->getTableFilterStateMapper($state);
112 $options += $state_filter_mapper->optionsForState();
114 $relations_state_selection->
setOptions([
'' => $this->
lng->txt(
'please_choose')] + $options);
116 $relations_state_selection->readFromSession();
117 $this->
filter[
'relation_state_type'] = $relations_state_selection->getValue();
121 $public_name->readFromSession();
122 $this->
filter[
'public_name'] = $public_name->getValue();
130 public function applyFilterValue(
string $filterKey, $value):
void 133 foreach ($filterItems as $item) {
135 if ($item->getPostVar() === $filterKey) {
136 $item->setValueByArray([$filterKey => $value]);
137 $item->writeToSession();
153 $state_filter = (string) $this->
filter[self::STATE_FILTER_ELM_ID];
155 $relations = $relations->filter(
function (
ilBuddySystemRelation $relation) use ($state_filter, $state_factory):
bool {
156 $state_filter_mapper = $state_factory->getTableFilterStateMapper($relation->
getState());
157 return $state_filter ===
'' || $state_filter_mapper->filterMatchesRelation($state_filter, $relation);
163 $logins = array_map(
static function (
string $value):
string {
165 preg_match_all(
'/\[([^\[]+?)\]/', $value, $matches);
167 is_array($matches) &&
168 isset($matches[1]) &&
169 is_array($matches[1]) &&
170 isset($matches[1][count($matches[1]) - 1])
171 ) ? $matches[1][count($matches[1]) - 1] :
'';
174 $public_name_query = (string) ($this->
filter[
'public_name'] ??
'');
181 $usrId = $relations->getKey($relation);
184 0 === ilStr::strlen($public_name_query) ||
186 ilStr::strtolower($public_names[$usrId]),
187 ilStr::strtolower($public_name_query)
189 ilStr::strpos(ilStr::strtolower($logins[$usrId]), ilStr::strtolower($public_name_query)) !== false
192 if (!$hasMatchingName) {
199 foreach ($relations->toArray() as $usr_id => $relation) {
202 'public_name' => $public_names[$usr_id],
203 'login' => $logins[$usr_id]
213 protected function fillRow(array $a_set): void
215 if ($this->hasAccessToMailSystem) {
220 if ((!$this->
user->isAnonymous() && $public_profile ===
'y') || $public_profile ===
'g') {
221 $this->
ctrl->setParameterByClass(ilPublicUserProfileGUI::class,
'user', $a_set[
'usr_id']);
222 $profile_target = $this->
ctrl->getLinkTargetByClass(
223 ilPublicUserProfileGUI::class,
226 $a_set[
'profile_link'] = $profile_target;
227 $a_set[
'linked_public_name'] = $a_set[
'public_name'];
229 $a_set[
'profile_link_login'] = $profile_target;
230 $a_set[
'linked_login'] = $a_set[
'login'];
232 $a_set[
'unlinked_public_name'] = $a_set[
'public_name'];
233 $a_set[
'unlinked_login'] = $a_set[
'login'];
237 parent::fillRow($a_set);
246 'tpl.buddy_system_relation_table_listener.html',
249 'Services/Contact/BuddySystem' 251 $listener_tpl->setVariable(
'TABLE_ID', $this->
getId());
252 $listener_tpl->setVariable(
'FILTER_ELM_ID', self::STATE_FILTER_ELM_ID);
253 $listener_tpl->setVariable(
258 return parent::render() . $listener_tpl->get();
static getInstance(?ilLanguage $lng=null)
bool $hasAccessToMailSystem
static getInstanceByGlobalUser()
static getNamePresentation( $a_user_id, bool $a_user_image=false, bool $a_profile_link=false, string $a_profile_back_link="", bool $a_force_first_lastname=false, bool $a_omit_login=false, bool $a_sortable=true, bool $a_return_data_array=false, $a_ctrl_path="ilpublicuserprofilegui")
Default behaviour is:
setFormAction(string $a_form_action, bool $a_multipart=false)
addFilterItem(ilTableFilterItem $a_input_item, bool $a_optional=false)
ilGlobalTemplateInterface $containerTemplate
setResetCommand(string $a_val, string $a_caption="")
setSelectAllCheckbox(string $a_select_all_checkbox, bool $a_select_all_on_top=false)
static _lookupPref(int $a_usr_id, string $a_keyword)
setExternalSorting(bool $a_val)
__construct(object $a_parent_obj, string $a_parent_cmd)
setDefaultOrderField(string $a_defaultorderfield)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setFilterCommand(string $a_val, string $a_caption="")
setDefaultOrderDirection(string $a_defaultorderdirection)
setTitle(string $a_title, string $a_icon="", string $a_icon_alt="")
__construct(Container $dic, ilPlugin $plugin)
static getMailObjectRefId()
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)
const STATE_FILTER_ELM_ID
getFilterItems(bool $a_optionals=false)
addMultiCommand(string $a_cmd, string $a_text)
static _lookupActive(int $a_usr_id)
setExternalSegmentation(bool $a_val)