ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
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 63 of file class.ilECSUserConsentModalGUI.php.

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

67  {
68  global $DIC;
69 
70  $this->usr_id = $a_usr_id;
71  $this->ref_id = $a_ref_id;
72  $this->remote_gui = $remote_gui;
73  $this->consents = ilECSUserConsents::getInstanceByUserId($this->usr_id);
74  $this->importManager = ilECSImportManager::getInstance();
75  $this->exportManager = ilECSExportManager::getInstance();
76 
77  $this->ui_factory = $DIC->ui()->factory();
78  $this->ui_renderer = $DIC->ui()->renderer();
79  $this->request = $DIC->http()->request();
80  $this->lng = $DIC->language();
81  $this->lng->loadLanguageModule('ecs');
82  $this->ctrl = $DIC->ctrl();
83  $this->objDefinition = $DIC['objDefinition'];
84 
85  $this->toolbar = $DIC->toolbar();
86  $this->remote_object = $this->initRemoteObject();
87  $this->initMidAndServer();
88  $this->obj_id = $this->remote_object->getId();
89  }
static getInstance()
Get the singelton instance of this ilECSExportManager.
static getInstance()
Get the singleton instance of this ilECSImportManager.
global $DIC
Definition: shib_login.php:26
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 159 of file class.ilECSUserConsentModalGUI.php.

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

161  : RepositoryObject {
162  $components = $this->getConsentModalComponents(self::TRIGGER_TYPE_CARD);
163  foreach ($components as $component) {
164  if ($component === null) {
165  continue;
166  }
167  $this->toolbar->addComponent($component);
168 
169  $image = $card->getImage();
170  $image = $image->withOnClick($component->getShowSignal());
171  $card = $card
172  ->withImage($image)
173  ->withTitleAction($component->getShowSignal());
174  }
175  return $card;
176  }
$components
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
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 151 of file class.ilECSUserConsentModalGUI.php.

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

Referenced by addLinkToToolbar().

151  : void
152  {
154  foreach ($components as $component) {
155  $toolbar->addComponent($component);
156  }
157  }
addComponent(\ILIAS\UI\Component\Component $a_comp)
$components
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 125 of file class.ilECSUserConsentModalGUI.php.

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

Referenced by ilRemoteObjectBaseGUI\infoScreen().

125  : void
126  {
127  if (
128  $this->usr_id === ANONYMOUS_USER_ID ||
129  $this->isLocalObject()
130  ) {
131  return;
132  }
133  if ($this->hasConsented()) {
134  $this->addRemoteLinkToToolbar($toolbar);
135  } else {
136  $this->addConsentModalToToolbar($toolbar);
137  }
138  }
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 140 of file class.ilECSUserConsentModalGUI.php.

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

Referenced by addLinkToToolbar().

140  : void
141  {
142  $button = $this->ui_factory
143  ->button()
144  ->standard(
145  $this->lng->txt($this->remote_object->getType() . '_call'),
146  $this->ctrl->getLinkTarget($this->remote_gui, 'call')
147  );
148  $toolbar->addComponent($button);
149  }
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 178 of file class.ilECSUserConsentModalGUI.php.

References $id, $valid, initConsentForm(), ILIAS\Repository\lng(), null, saveConsent(), and ILIAS\UI\Implementation\Component\withOnLoadCode().

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

180  : array {
181  $form = $this->initConsentForm();
182  $form_id = 'form_' . $form->getId();
183  $agree = $this->ui_factory->button()
184  ->primary($this->lng->txt('ecs_consent_modal_btn_accept'), '#')
185  ->withOnLoadCode(
186  function ($id) use ($form_id) {
187  return "$('#$id').click(function() { $('#$form_id').submit(); return false; });";
188  }
189  );
190 
191  $submitted = (string) ($this->request->getParsedBody()['cmd'] ?? '');
192  $valid = true;
193  $error_html = '';
194  if (strcmp($submitted, 'submit') === 0) {
195  if (!$this->saveConsent($form)) {
196  $form->setValuesByPost();
197  $error = $this->ui_factory->messageBox()->failure(
198  $this->lng->txt('ecs_consent_required')
199  );
200  $error_html = $this->ui_renderer->render([$error]);
201  $valid = false;
202  }
203  }
204 
205  $modal = $this->ui_factory->modal()->roundtrip(
206  $this->lng->txt('ecs_consent_modal_title'),
207  $this->ui_factory->legacy()->content(
208  $error_html .
209  $form->getHTML()
210  )
211  )->withActionButtons([$agree]);
212  if (!$valid) {
213  $modal = $modal->withOnLoad($modal->getShowSignal());
214  }
215 
216  $button = null;
217  if ($a_trigger_type === self::TRIGGER_TYPE_STANDARD) {
218  $button = $this->ui_factory->button()->standard(
219  $this->lng->txt($this->remote_object->getType() . '_call'),
220  '#'
221  )->withOnClick(
222  $modal->getShowSignal()
223  );
224  } elseif ($a_trigger_type === self::TRIGGER_TYPE_SHY) {
225  $button = $this->ui_factory->button()->shy(
226  $this->remote_object->getTitle(),
227  '#'
228  )->withOnClick(
229  $modal->getShowSignal()
230  );
231  }
232  return [$button, $modal];
233  }
$valid
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
$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 351 of file class.ilECSUserConsentModalGUI.php.

Referenced by initConsentForm().

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

◆ getOrganisation()

ilECSUserConsentModalGUI::getOrganisation ( )
protected

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

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

Referenced by initConsentForm().

332  {
333  $server_id = $this->importManager->lookupServerId($this->obj_id);
334  if (0 === $server_id) {
335  return null;
336  }
338  $server_id
339  );
340  try {
341  $part = $community_reader->getParticipantByMID($this->mid);
342  if ($part instanceof ilECSParticipant) {
343  return $part->getOrganisation();
344  }
345  return null;
346  } catch (ilECSConnectorException $e) {
347  return null;
348  }
349  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
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 112 of file class.ilECSUserConsentModalGUI.php.

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

Referenced by ilRemoteObjectBaseListGUI\insertTitle().

112  : string
113  {
114  if (
115  $this->usr_id === ANONYMOUS_USER_ID ||
116  $this->isLocalObject() ||
117  $this->hasConsented()
118  ) {
119  return '';
120  }
121  $components = $this->getConsentModalComponents(self::TRIGGER_TYPE_SHY);
122  return $this->ui_renderer->render($components);
123  }
const ANONYMOUS_USER_ID
Definition: constants.php:27
$components
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 91 of file class.ilECSUserConsentModalGUI.php.

Referenced by addLinkToToolbar(), and getTitleLink().

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

◆ initConsentForm()

ilECSUserConsentModalGUI::initConsentForm ( )
protected

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

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

Referenced by getConsentModalComponents().

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

◆ initMidAndServer()

ilECSUserConsentModalGUI::initMidAndServer ( )
protected

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

References ilECSImportManager\getInstance().

Referenced by __construct().

96  : void
97  {
98  $this->mid = $this->remote_object->getMID();
99  $this->server_id = ilECSImportManager::getInstance()->lookupServerId($this->remote_object->getId());
100  }
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 360 of file class.ilECSUserConsentModalGUI.php.

References ilObjectFactory\getInstanceByRefId().

Referenced by __construct().

361  {
362  $remote = ilObjectFactory::getInstanceByRefId($this->ref_id);
363  if (!$remote instanceof ilRemoteObjectBase) {
364  throw new ilObjectNotFoundException(
365  'Invalid ref_id given: ' . $this->ref_id
366  );
367  }
368  return $remote;
369  }
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 107 of file class.ilECSUserConsentModalGUI.php.

Referenced by addLinkToToolbar(), and getTitleLink().

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

◆ lookupOrganization()

ilECSUserConsentModalGUI::lookupOrganization ( )
protected

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

Referenced by initConsentForm().

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

◆ saveConsent()

ilECSUserConsentModalGUI::saveConsent ( ilPropertyFormGUI  $form)
protected

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

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

Referenced by getConsentModalComponents().

235  : bool
236  {
237  $consented = (bool) ($this->request->getParsedBody()['consent'] ?? 0);
238  $ref_id_hidden = (int) ($this->request->getParsedBody()['consented_ref_id'] ?? 0);
239  $ref_type_hidden = (string) ($this->request->getParsedBody()['consented_type'] ?? '');
240  if ($consented) {
241  $this->consents->add($this->server_id, $this->mid);
242  $this->ctrl->setParameterByClass(
243  $ref_type_hidden,
244  'ref_id',
245  $ref_id_hidden
246  );
247  $this->ctrl->redirectToURL(
248  $this->ctrl->getLinkTargetByClass(
249  [
250  ilRepositoryGUI::class,
251  $ref_type_hidden
252  ],
253  'call'
254  )
255  );
256  return true;
257  }
258  return false;
259  }
+ 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 51 of file class.ilECSUserConsentModalGUI.php.

◆ $ctrl

ilCtrlInterface ilECSUserConsentModalGUI::$ctrl
protected

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

◆ $exportManager

ilECSExportManager ilECSUserConsentModalGUI::$exportManager
protected

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

◆ $importManager

ilECSImportManager ilECSUserConsentModalGUI::$importManager
protected

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

◆ $lng

ilLanguage ilECSUserConsentModalGUI::$lng
protected

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

◆ $mid

int ilECSUserConsentModalGUI::$mid
private

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

◆ $obj_id

int ilECSUserConsentModalGUI::$obj_id
private

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

◆ $objDefinition

ilObjectDefinition ilECSUserConsentModalGUI::$objDefinition
protected

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

◆ $ref_id

int ilECSUserConsentModalGUI::$ref_id
private

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

◆ $remote_gui

ilRemoteObjectBaseGUI ilECSUserConsentModalGUI::$remote_gui = null
protected

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

Referenced by __construct().

◆ $remote_object

ilRemoteObjectBase ilECSUserConsentModalGUI::$remote_object
protected

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

◆ $request

RequestInterface ilECSUserConsentModalGUI::$request
protected

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

◆ $server_id

int ilECSUserConsentModalGUI::$server_id
private

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

◆ $toolbar

ilToolbarGUI ilECSUserConsentModalGUI::$toolbar
protected

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

◆ $ui_factory

UIFactory ilECSUserConsentModalGUI::$ui_factory
protected

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

◆ $ui_renderer

UIRenderer ilECSUserConsentModalGUI::$ui_renderer
protected

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

◆ $usr_id

int ilECSUserConsentModalGUI::$usr_id
private

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

◆ CMD_RENDER_MODAL

const ilECSUserConsentModalGUI::CMD_RENDER_MODAL = 'renderConsentModal'

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

◆ CMD_SAVE_CONSENT

const ilECSUserConsentModalGUI::CMD_SAVE_CONSENT = 'saveConsent'

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

◆ TRIGGER_TYPE_CARD

const ilECSUserConsentModalGUI::TRIGGER_TYPE_CARD = 3
protected

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

◆ TRIGGER_TYPE_SHY

const ilECSUserConsentModalGUI::TRIGGER_TYPE_SHY = 1
protected

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

◆ TRIGGER_TYPE_STANDARD

const ilECSUserConsentModalGUI::TRIGGER_TYPE_STANDARD = 2
protected

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


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