ILIAS  release_8 Revision v8.24
ilECSUserConsents Class Reference

Class ilECSUserConsents. More...

+ Collaboration diagram for ilECSUserConsents:

Public Member Functions

 getUserId ()
 
 hasConsented (int $server_id, int $a_mid)
 
 delete ()
 
 add (int $server_id, int $a_mid)
 

Static Public Member Functions

static getInstanceByUserId (int $a_usr_id)
 

Protected Member Functions

 __construct (int $a_usr_id)
 
 read ()
 

Protected Attributes

ilDBInterface $db
 

Private Attributes

int $usr_id
 
array $consents = []
 

Static Private Attributes

static array $instances = []
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilECSUserConsents::__construct ( int  $a_usr_id)
protected

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

40 {
41 global $DIC;
42
43 $this->db = $DIC->database();
44 $this->usr_id = $a_usr_id;
45 if ($a_usr_id > 0) {
46 $this->read();
47 }
48 }
global $DIC
Definition: feed.php:28

References $DIC, and read().

+ Here is the call graph for this function:

Member Function Documentation

◆ add()

ilECSUserConsents::add ( int  $server_id,
int  $a_mid 
)

Definition at line 76 of file class.ilECSUserConsents.php.

76 : void
77 {
78 if (!$this->hasConsented($server_id, $a_mid)) {
79 $consent = new ilECSUserConsent($this->getUserId(), $server_id, $a_mid);
80 $consent->save();
81 $this->consents["{$server_id}:{$a_mid}"] = $consent;
82 }
83 }
Class ilECSUserConsent.
hasConsented(int $server_id, int $a_mid)

References getUserId(), and hasConsented().

+ Here is the call graph for this function:

◆ delete()

ilECSUserConsents::delete ( )

Definition at line 68 of file class.ilECSUserConsents.php.

68 : void
69 {
70 foreach ($this->consents as $mid => $consent) {
71 $consent->delete();
72 }
73 $this->consents = [];
74 }

◆ getInstanceByUserId()

static ilECSUserConsents::getInstanceByUserId ( int  $a_usr_id)
static

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

50 : self
51 {
52 if (!isset(self::$instances[$a_usr_id])) {
53 self::$instances[$a_usr_id] = new self($a_usr_id);
54 }
55 return self::$instances[$a_usr_id];
56 }

Referenced by ilECSUserConsentModalGUI\__construct().

+ Here is the caller graph for this function:

◆ getUserId()

ilECSUserConsents::getUserId ( )

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

58 : int
59 {
60 return $this->usr_id;
61 }

References $usr_id.

Referenced by add(), and read().

+ Here is the caller graph for this function:

◆ hasConsented()

ilECSUserConsents::hasConsented ( int  $server_id,
int  $a_mid 
)

Definition at line 63 of file class.ilECSUserConsents.php.

63 : bool
64 {
65 return array_key_exists("{$server_id}:{$a_mid}", $this->consents);
66 }

Referenced by add().

+ Here is the caller graph for this function:

◆ read()

ilECSUserConsents::read ( )
protected

Definition at line 85 of file class.ilECSUserConsents.php.

85 : void
86 {
87 $query = 'SELECT * FROM ecs_user_consent ' .
88 'WHERE usr_id = ' . $this->db->quote(
89 $this->getUserId(),
91 );
92 $res = $this->db->query($query);
93 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
94 $this->consents["{$row->server_id}:{$row->mid}"] = new ilECSUserConsent(
95 (int) $row->usr_id,
96 (int) $row->server_id,
97 (int) $row->mid
98 );
99 }
100 }
$res
Definition: ltiservices.php:69
$query

References $query, $res, ilDBConstants\FETCHMODE_OBJECT, getUserId(), and ilDBConstants\T_INTEGER.

Referenced by __construct().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $consents

array ilECSUserConsents::$consents = []
private

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

◆ $db

ilDBInterface ilECSUserConsents::$db
protected

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

◆ $instances

array ilECSUserConsents::$instances = []
staticprivate

Definition at line 29 of file class.ilECSUserConsents.php.

◆ $usr_id

int ilECSUserConsents::$usr_id
private

Definition at line 31 of file class.ilECSUserConsents.php.

Referenced by getUserId().


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