ILIAS  trunk Revision v11.0_alpha-1769-g99a433fe2dc
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator 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 63 of file class.ilECSUserConsentModalGUI.php.

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

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->remote_object = $this->initRemoteObject();
86  $this->initMidAndServer();
87  $this->obj_id = $this->remote_object->getId();
88  }
static getInstance()
Get the singelton instance of this ilECSExportManager.
static getInstance()
Get the singleton instance of this ilECSImportManager.
global $DIC
Definition: shib_login.php:22
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 158 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().

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

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

Referenced by addLinkToToolbar().

150  : void
151  {
153  foreach ($components as $component) {
154  $toolbar->addComponent($component);
155  }
156  }
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 124 of file class.ilECSUserConsentModalGUI.php.

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

Referenced by ilRemoteObjectBaseGUI\infoScreen().

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

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

Referenced by addLinkToToolbar().

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

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

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

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

Referenced by initConsentForm().

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

◆ getOrganisation()

ilECSUserConsentModalGUI::getOrganisation ( )
protected

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

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

Referenced by initConsentForm().

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

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

Referenced by ilRemoteObjectBaseListGUI\insertTitle().

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

Referenced by addLinkToToolbar(), and getTitleLink().

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

◆ initConsentForm()

ilECSUserConsentModalGUI::initConsentForm ( )
protected

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

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

Referenced by getConsentModalComponents().

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

References ilECSImportManager\getInstance().

Referenced by __construct().

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

References ilObjectFactory\getInstanceByRefId().

Referenced by __construct().

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

Referenced by addLinkToToolbar(), and getTitleLink().

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

◆ lookupOrganization()

ilECSUserConsentModalGUI::lookupOrganization ( )
protected

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

Referenced by initConsentForm().

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

◆ saveConsent()

ilECSUserConsentModalGUI::saveConsent ( ilPropertyFormGUI  $form)
protected

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

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

Referenced by getConsentModalComponents().

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