ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilContactUserActionProvider.php
Go to the documentation of this file.
1<?php declare(strict_types=1);
2/* Copyright (c) 1998-2015 ILIAS open source, Extended GPL, see docs/LICENSE */
3
9{
11 protected $user;
12
15 'ilBuddySystemLinkedRelationState' => '_contact_approved',
16 'ilBuddySystemIgnoredRequestRelationState' => '_contact_ignored'
17 ];
18
22 public function __construct()
23 {
24 global $DIC;
25
27
28 $this->user = $DIC['ilUser'];
29 }
30
34 public function getComponentId()
35 {
36 return 'contact';
37 }
38
42 public function getActionTypes()
43 {
44 $this->lng->loadLanguageModule('buddysystem');
45 return [
46 'handle_req' => $this->lng->txt('buddy_handle_contact_request')
47 ];
48 }
49
53 public function collectActionsForTargetUser($a_target_user)
54 {
56
57 if (!ilBuddySystem::getInstance()->isEnabled()) {
58 return $coll;
59 }
60
61 if (ilObjUser::_isAnonymous($this->getUserId()) || $this->user->isAnonymous()) {
62 return $coll;
63 }
64
66 $requested_contacts = $buddyList->getRequestRelationsForOwner()->getKeys();
67
68 if (in_array($a_target_user, $requested_contacts)) {
69 $this->lng->loadLanguageModule('buddysystem');
70
71 $relation = $buddyList->getRelationByUserId($a_target_user);
72 foreach ($relation->getCurrentPossibleTargetStates() as $target_state) {
73 $f = new ilUserAction();
74 $f->setText(
75 $this->lng->txt(
76 'buddy_bs_act_btn_txt_requested_to_' .
77 ilStr::convertUpperCamelCaseToUnderscoreCase($target_state->getName())
78 )
79 );
80 $f->setType('handle_req');
81 $f->setHref(
83 $a_target_user,
84 'usr',
85 true,
86 $this->stateToPermLinkMap[get_class($target_state)]
87 )
88 );
89 $f->setData([
90 'current-state' => get_class($relation->getState()),
91 'target-state' => get_class($target_state),
92 'buddy-id' => $a_target_user,
93 'action' => $target_state->getAction()
94 ]);
95 $coll->addAction($f);
96 }
97 }
98
99 return $coll;
100 }
101}
user()
Definition: user.php:4
An exception for terminatinating execution or to throw for unit testing.
static getInstanceByGlobalUser()
Class ilContactUserActionProvider.
collectActionsForTargetUser($a_target_user)
@inheritDoc
__construct()
ilContactUserActionProvider constructor.
static _isAnonymous($usr_id)
static convertUpperCamelCaseToUnderscoreCase($value)
Convert a value given in camel case conversion to underscore case conversion (e.g.
A class that provides a collection of actions on users.
Action that can be performed on a user.
global $DIC
Definition: goto.php:24
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc