ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilTermsOfServiceHelper Class Reference
+ Collaboration diagram for ilTermsOfServiceHelper:

Static Public Member Functions

static isEnabled ()
 
static setStatus ($status)
 
static deleteAcceptanceHistoryByUser ($usr_id)
 
static getCurrentAcceptanceForUser (ilObjUser $user)
 
static getById ($id)
 
static trackAcceptance (ilObjUser $user, ilTermsOfServiceSignableDocument $document)
 

Static Private Member Functions

static getEntityFactory ()
 
static getDataGatewayFactory ()
 

Detailed Description

Author
Michael Jansen mjans.nosp@m.en@d.nosp@m.ataba.nosp@m.y.de
Version
$Id$

Definition at line 8 of file class.ilTermsOfServiceHelper.php.

Member Function Documentation

◆ deleteAcceptanceHistoryByUser()

static ilTermsOfServiceHelper::deleteAcceptanceHistoryByUser (   $usr_id)
static
Parameters
int$usr_id

Definition at line 33 of file class.ilTermsOfServiceHelper.php.

Referenced by ilTermsOfServiceAppEventListener\handleEvent().

34  {
35  $entity = self::getEntityFactory()->getByName('ilTermsOfServiceAcceptanceEntity');
36  $data_gateway = self::getDataGatewayFactory()->getByName('ilTermsOfServiceAcceptanceDatabaseGateway');
37  $entity->setUserId($usr_id);
38  $data_gateway->deleteAcceptanceHistoryByUser($entity);
39  }
+ Here is the caller graph for this function:

◆ getById()

static ilTermsOfServiceHelper::getById (   $id)
static
Parameters
integer$id
Returns
ilTermsOfServiceAcceptanceEntity

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

References $id.

Referenced by ilObjTermsOfServiceGUI\getAcceptedContentAsynch().

58  {
59  $entity = self::getEntityFactory()->getByName('ilTermsOfServiceAcceptanceEntity');
60  $data_gateway = self::getDataGatewayFactory()->getByName('ilTermsOfServiceAcceptanceDatabaseGateway');
61  $entity->setId($id);
62  return $data_gateway->loadById($entity);
63  }
if(!array_key_exists('StateId', $_REQUEST)) $id
+ Here is the caller graph for this function:

◆ getCurrentAcceptanceForUser()

static ilTermsOfServiceHelper::getCurrentAcceptanceForUser ( ilObjUser  $user)
static
Parameters
ilObjUser$user
Returns
ilTermsOfServiceAcceptanceEntity

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

References ilObject\getId().

Referenced by ilObjUserGUI\handleIgnoredRequiredFields().

46  {
47  $entity = self::getEntityFactory()->getByName('ilTermsOfServiceAcceptanceEntity');
48  $data_gateway = self::getDataGatewayFactory()->getByName('ilTermsOfServiceAcceptanceDatabaseGateway');
49  $entity->setUserId($user->getId());
50  return $data_gateway->loadCurrentAcceptanceOfUser($entity);
51  }
getId()
get object id public
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getDataGatewayFactory()

static ilTermsOfServiceHelper::getDataGatewayFactory ( )
staticprivate
Returns
ilTermsOfServiceDataGatewayFactory

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

References $DIC, and $factory.

102  {
103  global $DIC;
104 
105  require_once 'Services/TermsOfService/classes/class.ilTermsOfServiceDataGatewayFactory.php';
107  $factory->setDatabaseAdapter($DIC['ilDB']);
108  return $factory;
109  }
global $DIC
Definition: saml.php:7
$factory
Definition: metadata.php:47

◆ getEntityFactory()

static ilTermsOfServiceHelper::getEntityFactory ( )
staticprivate
Returns
ilTermsOfServiceEntityFactory

Definition at line 92 of file class.ilTermsOfServiceHelper.php.

93  {
94  require_once 'Services/TermsOfService/classes/class.ilTermsOfServiceEntityFactory.php';
95  return new ilTermsOfServiceEntityFactory();
96  }

◆ isEnabled()

static ilTermsOfServiceHelper::isEnabled ( )
static

◆ setStatus()

static ilTermsOfServiceHelper::setStatus (   $status)
static
Parameters
bool$status

Definition at line 23 of file class.ilTermsOfServiceHelper.php.

References $DIC.

Referenced by ilObjTermsOfService\saveStatus().

24  {
25  global $DIC;
26 
27  $DIC['ilSetting']->set('tos_status', (int) $status);
28  }
global $DIC
Definition: saml.php:7
+ Here is the caller graph for this function:

◆ trackAcceptance()

static ilTermsOfServiceHelper::trackAcceptance ( ilObjUser  $user,
ilTermsOfServiceSignableDocument  $document 
)
static
Parameters
ilObjUser$user
ilTermsOfServiceSignableDocument$document

Definition at line 69 of file class.ilTermsOfServiceHelper.php.

References ilTermsOfServiceSignableDocument\exists(), ilTermsOfServiceSignableDocument\getContent(), ilObject\getId(), ilTermsOfServiceSignableDocument\getIso2LanguageCode(), ilTermsOfServiceSignableDocument\getSource(), ilTermsOfServiceSignableDocument\getSourceType(), ilObjUser\hasToAcceptTermsOfServiceInSession(), time, and ilObjUser\writeAccepted().

Referenced by ilStartUpGUI\getAcceptance(), and ilAccountRegistrationGUI\saveForm().

70  {
71  if (self::isEnabled() && $document->exists()) {
72  $entity = self::getEntityFactory()->getByName('ilTermsOfServiceAcceptanceEntity');
73  $data_gateway = self::getDataGatewayFactory()->getByName('ilTermsOfServiceAcceptanceDatabaseGateway');
74  $entity->setUserId($user->getId());
75  $entity->setTimestamp(time());
76  $entity->setIso2LanguageCode($document->getIso2LanguageCode());
77  $entity->setSource($document->getSource());
78  $entity->setSourceType($document->getSourceType());
79  $entity->setText($document->getContent());
80  $entity->setHash(md5($document->getContent()));
81  $data_gateway->trackAcceptance($entity);
82 
83  $user->writeAccepted(); // <- Has to be refactored in future releases
84 
86  }
87  }
writeAccepted()
write accept date of user agreement to db
getId()
get object id public
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
hasToAcceptTermsOfServiceInSession($status=null)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

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