ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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.

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  }
+ 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 102 of file class.ilTermsOfServiceHelper.php.

References $DIC.

103  {
104  global $DIC;
105 
106  require_once 'Services/TermsOfService/classes/class.ilTermsOfServiceDataGatewayFactory.php';
107  $factory = new ilTermsOfServiceDataGatewayFactory();
108  $factory->setDatabaseAdapter($DIC['ilDB']);
109  return $factory;
110  }
global $DIC

◆ getEntityFactory()

static ilTermsOfServiceHelper::getEntityFactory ( )
staticprivate
Returns
ilTermsOfServiceEntityFactory

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

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

◆ 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
+ 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  {
73  $entity = self::getEntityFactory()->getByName('ilTermsOfServiceAcceptanceEntity');
74  $data_gateway = self::getDataGatewayFactory()->getByName('ilTermsOfServiceAcceptanceDatabaseGateway');
75  $entity->setUserId($user->getId());
76  $entity->setTimestamp(time());
77  $entity->setIso2LanguageCode($document->getIso2LanguageCode());
78  $entity->setSource($document->getSource());
79  $entity->setSourceType($document->getSourceType());
80  $entity->setText($document->getContent());
81  $entity->setHash(md5($document->getContent()));
82  $data_gateway->trackAcceptance($entity);
83 
84  $user->writeAccepted(); // <- Has to be refactored in future releases
85 
87  }
88  }
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: