ILIAS  release_8 Revision v8.19-1-g4e8f2f9140c
All Data Structures Namespaces Files Functions Variables Modules Pages
ilECSUserConsentModalGUI Class Reference
+ Collaboration diagram for ilECSUserConsentModalGUI:

Public Member Functions

 __construct (int $a_usr_id, int $a_ref_id, ilRemoteObjectBaseGUI $remote_gui=null)
 
 hasConsented ()
 
 getTitleLink ()
 
 addLinkToToolbar (ilToolbarGUI $toolbar)
 
 addConsentModalToToolbar (ilToolbarGUI $toolbar)
 
 addConsentModalToCard (RepositoryObject $card)
 

Data Fields

const CMD_RENDER_MODAL = 'renderConsentModal'
 
const CMD_SAVE_CONSENT = 'saveConsent'
 

Protected Member Functions

 initMidAndServer ()
 
 lookupOrganization ()
 
 isLocalObject ()
 
 addRemoteLinkToToolbar (ilToolbarGUI $toolbar)
 
 getConsentModalComponents (int $a_trigger_type=self::TRIGGER_TYPE_STANDARD)
 
 saveConsent (ilPropertyFormGUI $form)
 
 initConsentForm ()
 
 getOrganisation ()
 
 getGUIClassName ()
 
 initRemoteObject ()
 

Protected Attributes

const TRIGGER_TYPE_SHY = 1
 
const TRIGGER_TYPE_STANDARD = 2
 
const TRIGGER_TYPE_CARD = 3
 
ilRemoteObjectBaseGUI $remote_gui = null
 
ilRemoteObjectBase $remote_object
 
ilECSUserConsents $consents
 
ilECSImportManager $importManager
 
ilECSExportManager $exportManager
 
UIRenderer $ui_renderer
 
UIFactory $ui_factory
 
RequestInterface $request
 
ilToolbarGUI $toolbar
 
ilLanguage $lng
 
ilCtrlInterface $ctrl
 
ilObjectDefinition $objDefinition
 

Private Attributes

int $usr_id
 
int $ref_id
 
int $obj_id
 
int $mid
 
int $server_id
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilECSUserConsentModalGUI::__construct ( int  $a_usr_id,
int  $a_ref_id,
ilRemoteObjectBaseGUI  $remote_gui = null 
)

Definition at line 62 of file class.ilECSUserConsentModalGUI.php.

References $DIC, $remote_gui, ILIAS\Repository\ctrl(), ilECSImportManager\getInstance(), ilECSExportManager\getInstance(), ilECSUserConsents\getInstanceByUserId(), initMidAndServer(), initRemoteObject(), and ILIAS\Repository\lng().

66  {
67  global $DIC;
68 
69  $this->usr_id = $a_usr_id;
70  $this->ref_id = $a_ref_id;
71  $this->remote_gui = $remote_gui;
72  $this->consents = ilECSUserConsents::getInstanceByUserId($this->usr_id);
73  $this->importManager = ilECSImportManager::getInstance();
74  $this->exportManager = ilECSExportManager::getInstance();
75 
76  $this->ui_factory = $DIC->ui()->factory();
77  $this->ui_renderer = $DIC->ui()->renderer();
78  $this->request = $DIC->http()->request();
79  $this->lng = $DIC->language();
80  $this->lng->loadLanguageModule('ecs');
81  $this->ctrl = $DIC->ctrl();
82  $this->objDefinition = $DIC['objDefinition'];
83 
84  $this->remote_object = $this->initRemoteObject();
85  $this->initMidAndServer();
86  $this->obj_id = $this->remote_object->getId();
87  }
static getInstance()
Get the singelton instance of this ilECSExportManager.
global $DIC
Definition: feed.php:28
static getInstance()
Get the singleton instance of this ilECSImportManager.
static getInstanceByUserId(int $a_usr_id)
+ Here is the call graph for this function:

Member Function Documentation

◆ addConsentModalToCard()

ilECSUserConsentModalGUI::addConsentModalToCard ( RepositoryObject  $card)

Definition at line 157 of file class.ilECSUserConsentModalGUI.php.

References getConsentModalComponents(), ILIAS\UI\Component\Card\Card\getImage(), ILIAS\Repository\toolbar(), and ILIAS\UI\Component\Card\Card\withImage().

159  : RepositoryObject {
160  $components = $this->getConsentModalComponents(self::TRIGGER_TYPE_CARD);
161  foreach ($components as $component) {
162  if ($component === null) {
163  continue;
164  }
165  $this->toolbar->addComponent($component);
166 
167  $image = $card->getImage();
168  $image = $image->withOnClick($component->getShowSignal());
169  $card = $card
170  ->withImage($image)
171  ->withTitleAction($component->getShowSignal());
172  }
173  return $card;
174  }
getImage()
Get the image of the card.
withImage(Image $image)
Set the image of the card.
getConsentModalComponents(int $a_trigger_type=self::TRIGGER_TYPE_STANDARD)
+ Here is the call graph for this function:

◆ addConsentModalToToolbar()

ilECSUserConsentModalGUI::addConsentModalToToolbar ( ilToolbarGUI  $toolbar)

Definition at line 149 of file class.ilECSUserConsentModalGUI.php.

References ilToolbarGUI\addComponent(), and getConsentModalComponents().

Referenced by addLinkToToolbar().

149  : void
150  {
151  $components = $this->getConsentModalComponents();
152  foreach ($components as $component) {
153  $toolbar->addComponent($component);
154  }
155  }
addComponent(\ILIAS\UI\Component\Component $a_comp)
getConsentModalComponents(int $a_trigger_type=self::TRIGGER_TYPE_STANDARD)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addLinkToToolbar()

ilECSUserConsentModalGUI::addLinkToToolbar ( ilToolbarGUI  $toolbar)

Definition at line 123 of file class.ilECSUserConsentModalGUI.php.

References addConsentModalToToolbar(), addRemoteLinkToToolbar(), ANONYMOUS_USER_ID, hasConsented(), and isLocalObject().

Referenced by ilRemoteObjectBaseGUI\infoScreen().

123  : void
124  {
125  if (
126  $this->usr_id === ANONYMOUS_USER_ID ||
127  $this->isLocalObject()
128  ) {
129  return;
130  }
131  if ($this->hasConsented()) {
132  $this->addRemoteLinkToToolbar($toolbar);
133  } else {
134  $this->addConsentModalToToolbar($toolbar);
135  }
136  }
const ANONYMOUS_USER_ID
Definition: constants.php:27
addConsentModalToToolbar(ilToolbarGUI $toolbar)
addRemoteLinkToToolbar(ilToolbarGUI $toolbar)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addRemoteLinkToToolbar()

ilECSUserConsentModalGUI::addRemoteLinkToToolbar ( ilToolbarGUI  $toolbar)
protected

Definition at line 138 of file class.ilECSUserConsentModalGUI.php.

References ilToolbarGUI\addComponent(), ILIAS\Repository\ctrl(), and ILIAS\Repository\lng().

Referenced by addLinkToToolbar().

138  : void
139  {
140  $button = $this->ui_factory
141  ->button()
142  ->standard(
143  $this->lng->txt($this->remote_object->getType() . '_call'),
144  $this->ctrl->getLinkTarget($this->remote_gui, 'call')
145  );
146  $toolbar->addComponent($button);
147  }
addComponent(\ILIAS\UI\Component\Component $a_comp)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getConsentModalComponents()

ilECSUserConsentModalGUI::getConsentModalComponents ( int  $a_trigger_type = self::TRIGGER_TYPE_STANDARD)
protected

Definition at line 176 of file class.ilECSUserConsentModalGUI.php.

References $id, $valid, initConsentForm(), ILIAS\Repository\lng(), and saveConsent().

Referenced by addConsentModalToCard(), addConsentModalToToolbar(), and getTitleLink().

178  : array {
179  $form = $this->initConsentForm();
180  $form_id = 'form_' . $form->getId();
181  $agree = $this->ui_factory->button()
182  ->primary('Agree and Proceed', '#')
183  ->withOnLoadCode(
184  function ($id) use ($form_id) {
185  return "$('#$id').click(function() { $('#$form_id').submit(); return false; });";
186  }
187  );
188 
189  $submitted = (string) ($this->request->getParsedBody()['cmd'] ?? '');
190  $valid = true;
191  $error_html = '';
192  if (strcmp($submitted, 'submit') === 0) {
193  if (!$this->saveConsent($form)) {
194  $form->setValuesByPost();
195  $error = $this->ui_factory->messageBox()->failure(
196  $this->lng->txt('ecs_consent_required')
197  );
198  $error_html = $this->ui_renderer->render([$error]);
199  $valid = false;
200  }
201  }
202 
203  $modal = $this->ui_factory->modal()->roundtrip(
204  $this->lng->txt('ecs_consent_modal_title'),
205  $this->ui_factory->legacy(
206  $error_html .
207  $form->getHTML()
208  )
209  )->withActionButtons([$agree]);
210  if (!$valid) {
211  $modal = $modal->withOnLoad($modal->getShowSignal());
212  }
213 
214  $button = null;
215  if ($a_trigger_type === self::TRIGGER_TYPE_STANDARD) {
216  $button = $this->ui_factory->button()->standard(
217  $this->lng->txt($this->remote_object->getType() . '_call'),
218  '#'
219  )->withOnClick(
220  $modal->getShowSignal()
221  );
222  } elseif ($a_trigger_type === self::TRIGGER_TYPE_SHY) {
223  $button = $this->ui_factory->button()->shy(
224  $this->remote_object->getTitle(),
225  '#'
226  )->withOnClick(
227  $modal->getShowSignal()
228  );
229  }
230  return [$button, $modal];
231  }
$valid
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getGUIClassName()

ilECSUserConsentModalGUI::getGUIClassName ( )
protected

Definition at line 349 of file class.ilECSUserConsentModalGUI.php.

Referenced by initConsentForm().

349  : string
350  {
351  return get_class($this->remote_gui);
352  }
+ Here is the caller graph for this function:

◆ getOrganisation()

ilECSUserConsentModalGUI::getOrganisation ( )
protected

Definition at line 329 of file class.ilECSUserConsentModalGUI.php.

References Vendor\Package\$e, and ilECSCommunityReader\getInstanceByServerId().

Referenced by initConsentForm().

330  {
331  $server_id = $this->importManager->lookupServerId($this->obj_id);
332  if (0 === $server_id) {
333  return null;
334  }
336  $server_id
337  );
338  try {
339  $part = $community_reader->getParticipantByMID($this->mid);
340  if ($part instanceof ilECSParticipant) {
341  return $part->getOrganisation();
342  }
343  return null;
344  } catch (ilECSConnectorException $e) {
345  return null;
346  }
347  }
static getInstanceByServerId(int $a_server_id)
Get instance by server id.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getTitleLink()

ilECSUserConsentModalGUI::getTitleLink ( )

Definition at line 110 of file class.ilECSUserConsentModalGUI.php.

References ANONYMOUS_USER_ID, getConsentModalComponents(), hasConsented(), and isLocalObject().

Referenced by ilRemoteObjectBaseListGUI\insertTitle().

110  : string
111  {
112  if (
113  $this->usr_id === ANONYMOUS_USER_ID ||
114  $this->isLocalObject() ||
115  $this->hasConsented()
116  ) {
117  return '';
118  }
119  $components = $this->getConsentModalComponents(self::TRIGGER_TYPE_SHY);
120  return $this->ui_renderer->render($components);
121  }
const ANONYMOUS_USER_ID
Definition: constants.php:27
getConsentModalComponents(int $a_trigger_type=self::TRIGGER_TYPE_STANDARD)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hasConsented()

ilECSUserConsentModalGUI::hasConsented ( )

Definition at line 89 of file class.ilECSUserConsentModalGUI.php.

Referenced by addLinkToToolbar(), and getTitleLink().

89  : bool
90  {
91  return $this->consents->hasConsented($this->server_id, $this->mid);
92  }
+ Here is the caller graph for this function:

◆ initConsentForm()

ilECSUserConsentModalGUI::initConsentForm ( )
protected

Definition at line 259 of file class.ilECSUserConsentModalGUI.php.

References $provider, ilObject\_lookupTitle(), getGUIClassName(), getOrganisation(), ILIAS\Repository\lng(), lookupOrganization(), ilCheckboxInputGUI\setValue(), and ilNonEditableValueGUI\setValue().

Referenced by getConsentModalComponents().

260  {
261  $form = new ilPropertyFormGUI();
262  $form->setId(uniqid('form', false));
263  $form->setFormAction('#');
264 
265  $ref_id_hidden = new ilHiddenInputGUI('consented_ref_id');
266  $ref_id_hidden->setValue((string) $this->ref_id);
267  $form->addItem($ref_id_hidden);
268  $ref_type_hidden = new ilHiddenInputGUI('consented_type');
269  $ref_type_hidden->setValue($this->getGUIClassName());
270  $form->addItem($ref_type_hidden);
271  $title = new ilNonEditableValueGUI(
272  $this->lng->txt('title'),
273  'title'
274  );
275  $title->setValue(
276  ilObject::_lookupTitle($this->obj_id)
277  );
278  $form->addItem($title);
279 
280  $target = new ilNonEditableValueGUI(
281  $this->lng->txt('ecs_form_target_platform'),
282  'organisation'
283  );
284  $target->setValue($this->lookupOrganization());
285  $form->addItem($target);
286 
287  // provider
288  $organisation = $this->getOrganisation();
289  if ($organisation instanceof ilECSOrganisation) {
291  $this->lng->txt('organization'),
292  'provider'
293  );
294  $provider->setValue($organisation->getName());
295  $form->addItem($provider);
296  }
297 
298  $consent = new ilCheckboxInputGUI(
299  $this->lng->txt('ecs_form_consent'),
300  'consent'
301  );
302  $consent->setValue("1");
303  $consent->setChecked($this->consents->hasConsented($this->server_id, $this->mid));
304  $consent->setRequired(true);
305  $form->addItem($consent);
306 
307  $user_data_fields = [];
308  foreach (['login',
309  'firstname',
310  'lastname',
311  'email',
312  'institution'
313  ] as $field) {
314  $user_data_fields[] = $this->lng->txt('ecs_' . $field);
315  }
316  $listing = $this->ui_factory->listing()->unordered($user_data_fields);
317  $listing_html = $this->ui_renderer->render([$listing]);
318  $consent->setOptionTitle(
319  $this->lng->txt(
320  'ecs_form_consent_option_title'
321  ) . '<br />' . $listing_html
322  );
323  $submit = new ilHiddenInputGUI('cmd');
324  $submit->setValue('submit');
325  $form->addItem($submit);
326  return $form;
327  }
This class represents a checkbox property in a property form.
$provider
Definition: ltitoken.php:83
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _lookupTitle(int $obj_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initMidAndServer()

ilECSUserConsentModalGUI::initMidAndServer ( )
protected

Definition at line 94 of file class.ilECSUserConsentModalGUI.php.

References ilECSImportManager\getInstance().

Referenced by __construct().

94  : void
95  {
96  $this->mid = $this->remote_object->getMID();
97  $this->server_id = ilECSImportManager::getInstance()->lookupServerId($this->remote_object->getId());
98  }
static getInstance()
Get the singleton instance of this ilECSImportManager.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initRemoteObject()

ilECSUserConsentModalGUI::initRemoteObject ( )
protected
Exceptions
ilDatabaseException
ilObjectNotFoundException

Definition at line 358 of file class.ilECSUserConsentModalGUI.php.

References ilObjectFactory\getInstanceByRefId().

Referenced by __construct().

359  {
360  $remote = ilObjectFactory::getInstanceByRefId($this->ref_id);
361  if (!$remote instanceof ilRemoteObjectBase) {
362  throw new ilObjectNotFoundException(
363  'Invalid ref_id given: ' . $this->ref_id
364  );
365  }
366  return $remote;
367  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getInstanceByRefId(int $ref_id, bool $stop_on_error=true)
get an instance of an Ilias object by reference id
Remote object app base class.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isLocalObject()

ilECSUserConsentModalGUI::isLocalObject ( )
protected

Definition at line 105 of file class.ilECSUserConsentModalGUI.php.

Referenced by addLinkToToolbar(), and getTitleLink().

105  : bool
106  {
107  return $this->remote_object->isLocalObject();
108  }
+ Here is the caller graph for this function:

◆ lookupOrganization()

ilECSUserConsentModalGUI::lookupOrganization ( )
protected

Definition at line 100 of file class.ilECSUserConsentModalGUI.php.

Referenced by initConsentForm().

100  : string
101  {
102  return $this->remote_object->getOrganization();
103  }
+ Here is the caller graph for this function:

◆ saveConsent()

ilECSUserConsentModalGUI::saveConsent ( ilPropertyFormGUI  $form)
protected

Definition at line 233 of file class.ilECSUserConsentModalGUI.php.

References ILIAS\Repository\ctrl(), and ILIAS\Repository\int().

Referenced by getConsentModalComponents().

233  : bool
234  {
235  $consented = (bool) ($this->request->getParsedBody()['consent'] ?? 0);
236  $ref_id_hidden = (int) ($this->request->getParsedBody()['consented_ref_id'] ?? 0);
237  $ref_type_hidden = (string) ($this->request->getParsedBody()['consented_type'] ?? '');
238  if ($consented) {
239  $this->consents->add($this->server_id, $this->mid);
240  $this->ctrl->setParameterByClass(
241  $ref_type_hidden,
242  'ref_id',
243  $ref_id_hidden
244  );
245  $this->ctrl->redirectToURL(
246  $this->ctrl->getLinkTargetByClass(
247  [
248  ilRepositoryGUI::class,
249  $ref_type_hidden
250  ],
251  'call'
252  )
253  );
254  return true;
255  }
256  return false;
257  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $consents

ilECSUserConsents ilECSUserConsentModalGUI::$consents
protected

Definition at line 50 of file class.ilECSUserConsentModalGUI.php.

◆ $ctrl

ilCtrlInterface ilECSUserConsentModalGUI::$ctrl
protected

Definition at line 59 of file class.ilECSUserConsentModalGUI.php.

◆ $exportManager

ilECSExportManager ilECSUserConsentModalGUI::$exportManager
protected

Definition at line 52 of file class.ilECSUserConsentModalGUI.php.

◆ $importManager

ilECSImportManager ilECSUserConsentModalGUI::$importManager
protected

Definition at line 51 of file class.ilECSUserConsentModalGUI.php.

◆ $lng

ilLanguage ilECSUserConsentModalGUI::$lng
protected

Definition at line 58 of file class.ilECSUserConsentModalGUI.php.

◆ $mid

int ilECSUserConsentModalGUI::$mid
private

Definition at line 45 of file class.ilECSUserConsentModalGUI.php.

◆ $obj_id

int ilECSUserConsentModalGUI::$obj_id
private

Definition at line 44 of file class.ilECSUserConsentModalGUI.php.

◆ $objDefinition

ilObjectDefinition ilECSUserConsentModalGUI::$objDefinition
protected

Definition at line 60 of file class.ilECSUserConsentModalGUI.php.

◆ $ref_id

int ilECSUserConsentModalGUI::$ref_id
private

Definition at line 43 of file class.ilECSUserConsentModalGUI.php.

◆ $remote_gui

ilRemoteObjectBaseGUI ilECSUserConsentModalGUI::$remote_gui = null
protected

Definition at line 48 of file class.ilECSUserConsentModalGUI.php.

Referenced by __construct().

◆ $remote_object

ilRemoteObjectBase ilECSUserConsentModalGUI::$remote_object
protected

Definition at line 49 of file class.ilECSUserConsentModalGUI.php.

◆ $request

RequestInterface ilECSUserConsentModalGUI::$request
protected

Definition at line 56 of file class.ilECSUserConsentModalGUI.php.

◆ $server_id

int ilECSUserConsentModalGUI::$server_id
private

Definition at line 46 of file class.ilECSUserConsentModalGUI.php.

◆ $toolbar

ilToolbarGUI ilECSUserConsentModalGUI::$toolbar
protected

Definition at line 57 of file class.ilECSUserConsentModalGUI.php.

◆ $ui_factory

UIFactory ilECSUserConsentModalGUI::$ui_factory
protected

Definition at line 55 of file class.ilECSUserConsentModalGUI.php.

◆ $ui_renderer

UIRenderer ilECSUserConsentModalGUI::$ui_renderer
protected

Definition at line 54 of file class.ilECSUserConsentModalGUI.php.

◆ $usr_id

int ilECSUserConsentModalGUI::$usr_id
private

Definition at line 42 of file class.ilECSUserConsentModalGUI.php.

◆ CMD_RENDER_MODAL

const ilECSUserConsentModalGUI::CMD_RENDER_MODAL = 'renderConsentModal'

Definition at line 35 of file class.ilECSUserConsentModalGUI.php.

◆ CMD_SAVE_CONSENT

const ilECSUserConsentModalGUI::CMD_SAVE_CONSENT = 'saveConsent'

Definition at line 36 of file class.ilECSUserConsentModalGUI.php.

◆ TRIGGER_TYPE_CARD

const ilECSUserConsentModalGUI::TRIGGER_TYPE_CARD = 3
protected

Definition at line 40 of file class.ilECSUserConsentModalGUI.php.

◆ TRIGGER_TYPE_SHY

const ilECSUserConsentModalGUI::TRIGGER_TYPE_SHY = 1
protected

Definition at line 38 of file class.ilECSUserConsentModalGUI.php.

◆ TRIGGER_TYPE_STANDARD

const ilECSUserConsentModalGUI::TRIGGER_TYPE_STANDARD = 2
protected

Definition at line 39 of file class.ilECSUserConsentModalGUI.php.


The documentation for this class was generated from the following file: