ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilMemberAgreement Class Reference
+ Collaboration diagram for ilMemberAgreement:

Public Member Functions

 __construct ($a_usr_id, $a_obj_id)
 Constructor. More...
 
 setAccepted ($a_status)
 set accepted More...
 
 setAcceptanceTime ($a_timest)
 set acceptance time More...
 
 agreementRequired ()
 Checks whether the agreement is accepted This function return always true if no acceptance is required by global setting. More...
 
 isAccepted ()
 Is accepted. More...
 
 getAcceptanceTime ()
 get Acceptance time More...
 
 save ()
 save Acceptance settings More...
 
 delete ()
 Delete entry. More...
 
 read ()
 Read user entries. More...
 

Static Public Member Functions

static _readByObjId ($a_obj_id)
 Read user data by object id. More...
 
static _hasAgreementsByObjId ($a_obj_id)
 Check if there is any user agreement. More...
 
static _hasAgreements ()
 Check if there is any user agreement. More...
 
static _hasAccepted ($a_usr_id, $a_obj_id)
 Check if user has accepted agreement. More...
 
static lookupAcceptedAgreements ($a_obj_id)
 Lookup users who have accepted the agreement. More...
 
static _deleteByUser ($a_usr_id)
 Delete all entries by user. More...
 
static _deleteByObjId ($a_obj_id)
 Delete all entries by obj_id. More...
 
static _reset ()
 Reset all. More...
 
static _resetContainer ($a_container_id)
 Reset all agreements for a specific container. More...
 

Private Attributes

 $db
 
 $user_id
 
 $obj_id
 
 $type
 
 $privacy
 
 $accepted = false
 
 $acceptance_time = 0
 

Detailed Description

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
$Id$

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

Constructor & Destructor Documentation

◆ __construct()

ilMemberAgreement::__construct (   $a_usr_id,
  $a_obj_id 
)

Constructor.

public

Parameters
intusr_id
intobj_id

Definition at line 54 of file class.ilMemberAgreement.php.

References $DIC, $ilDB, ilPrivacySettings\_getInstance(), ilCourseDefinedFieldDefinition\_hasFields(), ilObject\_lookupType(), and read().

55  {
56  global $DIC;
57 
58  $ilDB = $DIC['ilDB'];
59 
60  $this->db = $ilDB;
61  $this->user_id = $a_usr_id;
62  $this->obj_id = $a_obj_id;
63  $this->type = ilObject::_lookupType($this->obj_id);
64 
65  $this->privacy = ilPrivacySettings::_getInstance();
66 
67  if ($this->privacy->confirmationRequired($this->type) or ilCourseDefinedFieldDefinition::_hasFields($this->obj_id)) {
68  $this->read();
69  }
70  }
global $DIC
Definition: saml.php:7
read()
Read user entries.
static _lookupType($a_id, $a_reference=false)
lookup object type
static _hasFields($a_container_id)
Check if there are any define fields.
global $ilDB
static _getInstance()
Get instance of ilPrivacySettings.
+ Here is the call graph for this function:

Member Function Documentation

◆ _deleteByObjId()

static ilMemberAgreement::_deleteByObjId (   $a_obj_id)
static

Delete all entries by obj_id.

public static

Parameters
intobj_id

Definition at line 216 of file class.ilMemberAgreement.php.

References $DIC, $ilDB, $query, and $res.

Referenced by ilObjectCustomUserFieldsGUI\deleteFields(), ilObjectCustomUserFieldsGUI\saveField(), ilObjectCustomUserFieldsGUI\saveFields(), and ilObjectCustomUserFieldsGUI\updateField().

217  {
218  global $DIC;
219 
220  $ilDB = $DIC['ilDB'];
221 
222  $query = "DELETE FROM member_agreement " .
223  "WHERE obj_id =" . $ilDB->quote($a_obj_id, 'integer') . " ";
224  $res = $ilDB->manipulate($query);
225 
226  return true;
227  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$query
global $ilDB
+ Here is the caller graph for this function:

◆ _deleteByUser()

static ilMemberAgreement::_deleteByUser (   $a_usr_id)
static

Delete all entries by user.

public static

Parameters
intuser id

Definition at line 196 of file class.ilMemberAgreement.php.

References $DIC, $ilDB, $query, and $res.

Referenced by ilCourseTest\testMemberAgreement().

197  {
198  global $DIC;
199 
200  $ilDB = $DIC['ilDB'];
201 
202  $query = "DELETE FROM member_agreement " .
203  "WHERE usr_id =" . $ilDB->quote($a_usr_id, 'integer') . " ";
204  $res = $ilDB->manipulate($query);
205 
206  return true;
207  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$query
global $ilDB
+ Here is the caller graph for this function:

◆ _hasAccepted()

static ilMemberAgreement::_hasAccepted (   $a_usr_id,
  $a_obj_id 
)
static

Check if user has accepted agreement.

public

Parameters

Definition at line 148 of file class.ilMemberAgreement.php.

References $DIC, $ilDB, $query, $res, $row, and ilDBConstants\FETCHMODE_OBJECT.

Referenced by ilObjGroupGUI\checkAgreement(), ilObjCourseGUI\checkAgreement(), and ilCourseTest\testMemberAgreement().

149  {
150  global $DIC;
151 
152  $ilDB = $DIC['ilDB'];
153 
154  $query = "SELECT accepted FROM member_agreement " .
155  "WHERE usr_id = " . $ilDB->quote($a_usr_id, 'integer') . " " .
156  "AND obj_id = " . $ilDB->quote($a_obj_id, 'integer');
157  $res = $ilDB->query($query);
159 
160  return $row->accepted == 1 ? true : false;
161  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$query
$row
global $ilDB
+ Here is the caller graph for this function:

◆ _hasAgreements()

static ilMemberAgreement::_hasAgreements ( )
static

Check if there is any user agreement.

public

Parameters
intobj_id

Definition at line 127 of file class.ilMemberAgreement.php.

References $DIC, $ilDB, $query, and $res.

Referenced by ilCustomUserFieldsGUI\initFieldDefinition(), ilCustomUserFieldsGUI\initForm(), ilObjPrivacySecurityGUI\showPrivacy(), and ilCourseTest\testMemberAgreement().

128  {
129  global $DIC;
130 
131  $ilDB = $DIC['ilDB'];
132 
133  $query = "SELECT * FROM member_agreement " .
134  "WHERE accepted = 1";
135 
136  $res = $ilDB->query($query);
137  return $res->numRows() ? true : false;
138  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$query
global $ilDB
+ Here is the caller graph for this function:

◆ _hasAgreementsByObjId()

static ilMemberAgreement::_hasAgreementsByObjId (   $a_obj_id)
static

Check if there is any user agreement.

public

Parameters
intobj_id

Definition at line 105 of file class.ilMemberAgreement.php.

References $DIC, $ilDB, $query, and $res.

Referenced by ilObjectCustomUserFieldsGUI\show(), and ilCourseTest\testMemberAgreement().

106  {
107  global $DIC;
108 
109  $ilDB = $DIC['ilDB'];
110 
111  $query = "SELECT * FROM member_agreement " .
112  "WHERE obj_id = " . $ilDB->quote($a_obj_id, 'integer') . " " .
113  "AND accepted = 1";
114 
115  $res = $ilDB->query($query);
116  return $res->numRows() ? true : false;
117  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$query
global $ilDB
+ Here is the caller graph for this function:

◆ _readByObjId()

static ilMemberAgreement::_readByObjId (   $a_obj_id)
static

Read user data by object id.

public

Parameters
intobj_id

Definition at line 80 of file class.ilMemberAgreement.php.

References $DIC, $ilDB, $query, $res, $row, and ilDBConstants\FETCHMODE_OBJECT.

Referenced by ilMemberExport\__construct().

81  {
82  global $DIC;
83 
84  $ilDB = $DIC['ilDB'];
85 
86  $query = "SELECT * FROM member_agreement " .
87  "WHERE obj_id = " . $ilDB->quote($a_obj_id, 'integer');
88 
89  $res = $ilDB->query($query);
90  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
91  $user_data[$row->usr_id]['accepted'] = $row->accepted;
92  $user_data[$row->usr_id]['acceptance_time'] = $row->acceptance_time;
93  }
94  return $user_data ? $user_data : array();
95  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$query
$row
global $ilDB
+ Here is the caller graph for this function:

◆ _reset()

static ilMemberAgreement::_reset ( )
static

Reset all.

Set all aggrement to 0. This is called after global settings have been modified.

public

Parameters

Definition at line 237 of file class.ilMemberAgreement.php.

References $DIC, $ilDB, $query, and $res.

Referenced by ilCustomUserFieldsGUI\create(), ilObjPrivacySecurityGUI\save_privacy(), ilObjUserFolderGUI\saveGlobalUserSettingsObject(), and ilCustomUserFieldsGUI\update().

238  {
239  global $DIC;
240 
241  $ilDB = $DIC['ilDB'];
242 
243  $query = "UPDATE member_agreement SET accepted = 0 ";
244  $res = $ilDB->manipulate($query);
245 
246  return true;
247  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$query
global $ilDB
+ Here is the caller graph for this function:

◆ _resetContainer()

static ilMemberAgreement::_resetContainer (   $a_container_id)
static

Reset all agreements for a specific container.

public static

Parameters
intobj_id of container

Definition at line 256 of file class.ilMemberAgreement.php.

References $DIC, $ilDB, $query, and $res.

257  {
258  global $DIC;
259 
260  $ilDB = $DIC['ilDB'];
261 
262  $query = "UPDATE member_agreement " .
263  "SET accepted = 0 " .
264  "WHERE obj_id = " . $ilDB->quote($a_container_id, 'integer') . " ";
265  $res = $ilDB->manipulate($query);
266 
267  return true;
268  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$query
global $ilDB

◆ agreementRequired()

ilMemberAgreement::agreementRequired ( )

Checks whether the agreement is accepted This function return always true if no acceptance is required by global setting.

public

Returns
bool

Definition at line 299 of file class.ilMemberAgreement.php.

References ilCourseDefinedFieldDefinition\_hasFields().

300  {
301  if (!$this->privacy->confirmationRequired($this->type) and !ilCourseDefinedFieldDefinition::_hasFields($this->obj_id)) {
302  return false;
303  }
304  return $this->accepted ? false : true;
305  }
static _hasFields($a_container_id)
Check if there are any define fields.
+ Here is the call graph for this function:

◆ delete()

ilMemberAgreement::delete ( )

Delete entry.

public

Definition at line 362 of file class.ilMemberAgreement.php.

References $DIC, $ilDB, $query, and $res.

363  {
364  global $DIC;
365 
366  $ilDB = $DIC['ilDB'];
367 
368  $query = "DELETE FROM member_agreement " .
369  "WHERE usr_id = " . $this->db->quote($this->user_id, 'integer') . " " .
370  "AND obj_id = " . $this->db->quote($this->obj_id, 'integer');
371  $res = $ilDB->manipulate($query);
372  return true;
373  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$query
global $ilDB

◆ getAcceptanceTime()

ilMemberAgreement::getAcceptanceTime ( )

get Acceptance time

public

Parameters

Definition at line 326 of file class.ilMemberAgreement.php.

References $acceptance_time.

Referenced by save().

327  {
328  return $this->acceptance_time;
329  }
+ Here is the caller graph for this function:

◆ isAccepted()

ilMemberAgreement::isAccepted ( )

Is accepted.

public

Parameters

Definition at line 314 of file class.ilMemberAgreement.php.

References $accepted.

Referenced by save().

315  {
316  return (bool) $this->accepted;
317  }
+ Here is the caller graph for this function:

◆ lookupAcceptedAgreements()

static ilMemberAgreement::lookupAcceptedAgreements (   $a_obj_id)
static

Lookup users who have accepted the agreement.

Parameters
int$a_obj_id
Returns

Definition at line 168 of file class.ilMemberAgreement.php.

References $DIC, $ilDB, $query, $res, $row, and ilDBConstants\FETCHMODE_ASSOC.

Referenced by ilBookingReservationsTableGUI\getItems(), ilTrQuery\getUDFAndHandlePrivacy(), and ilParticipantTableGUI\initSettings().

169  {
170  global $DIC;
171 
172  $ilDB = $DIC['ilDB'];
173 
174  $query = "SELECT usr_id FROM member_agreement " .
175  "WHERE obj_id = " . $ilDB->quote($a_obj_id, 'integer') . ' ' .
176  "AND accepted = 1 ";
177 
178  $res = $ilDB->query($query);
179  $user_ids = array();
180  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) {
181  $user_ids[] = $row['usr_id'];
182  }
183  return $user_ids;
184  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$query
$row
global $ilDB
+ Here is the caller graph for this function:

◆ read()

ilMemberAgreement::read ( )

Read user entries.

private

Definition at line 380 of file class.ilMemberAgreement.php.

References $query, $res, $row, and ilDBConstants\FETCHMODE_OBJECT.

Referenced by __construct().

381  {
382  $query = "SELECT * FROM member_agreement " .
383  "WHERE usr_id = " . $this->db->quote($this->user_id, 'integer') . " " .
384  "AND obj_id = " . $this->db->quote($this->obj_id, 'integer') . " ";
385 
386  $res = $this->db->query($query);
387  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
388  $this->accepted = $row->accepted;
389  $this->acceptance_time = $row->acceptance_time;
390  }
391  }
foreach($_POST as $key=> $value) $res
$query
$row
+ Here is the caller graph for this function:

◆ save()

ilMemberAgreement::save ( )

save Acceptance settings

public

Definition at line 337 of file class.ilMemberAgreement.php.

References $DIC, $ilDB, $query, getAcceptanceTime(), and isAccepted().

338  {
339  global $DIC;
340 
341  $ilDB = $DIC['ilDB'];
342 
343  $this->delete();
344 
345  $query = "INSERT INTO member_agreement (usr_id,obj_id,accepted,acceptance_time) " .
346  "VALUES( " .
347  $this->db->quote($this->user_id, 'integer') . ", " .
348  $this->db->quote($this->obj_id, 'integer') . ", " .
349  $this->db->quote((int) $this->isAccepted(), 'integer') . ", " .
350  $this->db->quote($this->getAcceptanceTime(), 'integer') . " " .
351  ")";
352  $ilDB->manipulate($query);
353  return true;
354  }
global $DIC
Definition: saml.php:7
getAcceptanceTime()
get Acceptance time
$query
global $ilDB
+ Here is the call graph for this function:

◆ setAcceptanceTime()

ilMemberAgreement::setAcceptanceTime (   $a_timest)

set acceptance time

public

Parameters
intunix time of acceptance

Definition at line 288 of file class.ilMemberAgreement.php.

289  {
290  $this->acceptance_time = $a_timest;
291  }

◆ setAccepted()

ilMemberAgreement::setAccepted (   $a_status)

set accepted

public

Parameters
boolstatus

Definition at line 276 of file class.ilMemberAgreement.php.

Referenced by ilRegistrationGUI\setAccepted().

277  {
278  $this->accepted = $a_status;
279  }
+ Here is the caller graph for this function:

Field Documentation

◆ $acceptance_time

ilMemberAgreement::$acceptance_time = 0
private

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

Referenced by getAcceptanceTime().

◆ $accepted

ilMemberAgreement::$accepted = false
private

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

Referenced by isAccepted().

◆ $db

ilMemberAgreement::$db
private

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

◆ $obj_id

ilMemberAgreement::$obj_id
private

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

◆ $privacy

ilMemberAgreement::$privacy
private

Definition at line 42 of file class.ilMemberAgreement.php.

◆ $type

ilMemberAgreement::$type
private

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

◆ $user_id

ilMemberAgreement::$user_id
private

Definition at line 38 of file class.ilMemberAgreement.php.


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