ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 $ilDB, ilPrivacySettings\_getInstance(), ilCourseDefinedFieldDefinition\_hasFields(), ilObject\_lookupType(), and read().

55  {
56  global $ilDB;
57 
58  $this->db = $ilDB;
59  $this->user_id = $a_usr_id;
60  $this->obj_id = $a_obj_id;
61  $this->type = ilObject::_lookupType($this->obj_id);
62 
63  $this->privacy = ilPrivacySettings::_getInstance();
64 
65  if ($this->privacy->confirmationRequired($this->type) or ilCourseDefinedFieldDefinition::_hasFields($this->obj_id)) {
66  $this->read();
67  }
68  }
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 202 of file class.ilMemberAgreement.php.

References $ilDB, $query, and $res.

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

203  {
204  global $ilDB;
205 
206  $query = "DELETE FROM member_agreement " .
207  "WHERE obj_id =" . $ilDB->quote($a_obj_id, 'integer') . " ";
208  $res = $ilDB->manipulate($query);
209 
210  return true;
211  }
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 184 of file class.ilMemberAgreement.php.

References $ilDB, $query, and $res.

Referenced by ilCourseTest\testMemberAgreement().

185  {
186  global $ilDB;
187 
188  $query = "DELETE FROM member_agreement " .
189  "WHERE usr_id =" . $ilDB->quote($a_usr_id, 'integer') . " ";
190  $res = $ilDB->manipulate($query);
191 
192  return true;
193  }
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 140 of file class.ilMemberAgreement.php.

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

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

141  {
142  global $ilDB;
143 
144  $query = "SELECT accepted FROM member_agreement " .
145  "WHERE usr_id = " . $ilDB->quote($a_usr_id, 'integer') . " " .
146  "AND obj_id = " . $ilDB->quote($a_obj_id, 'integer');
147  $res = $ilDB->query($query);
149 
150  return $row->accepted == 1 ? true : false;
151  }
foreach($_POST as $key=> $value) $res
$query
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 121 of file class.ilMemberAgreement.php.

References $ilDB, $query, and $res.

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

122  {
123  global $ilDB;
124 
125  $query = "SELECT * FROM member_agreement " .
126  "WHERE accepted = 1";
127 
128  $res = $ilDB->query($query);
129  return $res->numRows() ? true : false;
130  }
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 101 of file class.ilMemberAgreement.php.

References $ilDB, $query, and $res.

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

102  {
103  global $ilDB;
104 
105  $query = "SELECT * FROM member_agreement " .
106  "WHERE obj_id = " . $ilDB->quote($a_obj_id, 'integer') . " " .
107  "AND accepted = 1";
108 
109  $res = $ilDB->query($query);
110  return $res->numRows() ? true : false;
111  }
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 78 of file class.ilMemberAgreement.php.

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

Referenced by ilMemberExport\__construct().

79  {
80  global $ilDB;
81 
82  $query = "SELECT * FROM member_agreement " .
83  "WHERE obj_id = " . $ilDB->quote($a_obj_id, 'integer');
84 
85  $res = $ilDB->query($query);
86  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
87  $user_data[$row->usr_id]['accepted'] = $row->accepted;
88  $user_data[$row->usr_id]['acceptance_time'] = $row->acceptance_time;
89  }
90  return $user_data ? $user_data : array();
91  }
foreach($_POST as $key=> $value) $res
$query
Create styles array
The data for the language used.
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 221 of file class.ilMemberAgreement.php.

References $ilDB, $query, and $res.

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

222  {
223  global $ilDB;
224 
225  $query = "UPDATE member_agreement SET accepted = 0 ";
226  $res = $ilDB->manipulate($query);
227 
228  return true;
229  }
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 238 of file class.ilMemberAgreement.php.

References $ilDB, $query, and $res.

239  {
240  global $ilDB;
241 
242  $query = "UPDATE member_agreement " .
243  "SET accepted = 0 " .
244  "WHERE obj_id = " . $ilDB->quote($a_container_id, 'integer') . " ";
245  $res = $ilDB->manipulate($query);
246 
247  return true;
248  }
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 279 of file class.ilMemberAgreement.php.

References ilCourseDefinedFieldDefinition\_hasFields().

280  {
281  if (!$this->privacy->confirmationRequired($this->type) and !ilCourseDefinedFieldDefinition::_hasFields($this->obj_id)) {
282  return false;
283  }
284  return $this->accepted ? false : true;
285  }
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 340 of file class.ilMemberAgreement.php.

References $ilDB, $query, and $res.

341  {
342  global $ilDB;
343 
344  $query = "DELETE FROM member_agreement " .
345  "WHERE usr_id = " . $this->db->quote($this->user_id, 'integer') . " " .
346  "AND obj_id = " . $this->db->quote($this->obj_id, 'integer');
347  $res = $ilDB->manipulate($query);
348  return true;
349  }
foreach($_POST as $key=> $value) $res
$query
global $ilDB

◆ getAcceptanceTime()

ilMemberAgreement::getAcceptanceTime ( )

get Acceptance time

public

Parameters

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

References $acceptance_time.

Referenced by save().

307  {
308  return $this->acceptance_time;
309  }
+ Here is the caller graph for this function:

◆ isAccepted()

ilMemberAgreement::isAccepted ( )

Is accepted.

public

Parameters

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

References $accepted.

Referenced by save().

295  {
296  return (bool) $this->accepted;
297  }
+ 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 158 of file class.ilMemberAgreement.php.

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

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

159  {
160  global $ilDB;
161 
162  $query = "SELECT usr_id FROM member_agreement " .
163  "WHERE obj_id = " . $ilDB->quote($a_obj_id, 'integer') . ' ' .
164  "AND accepted = 1 ";
165 
166  $res = $ilDB->query($query);
167  $user_ids = array();
168  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) {
169  $user_ids[] = $row['usr_id'];
170  }
171  return $user_ids;
172  }
foreach($_POST as $key=> $value) $res
$query
Create styles array
The data for the language used.
global $ilDB
+ Here is the caller graph for this function:

◆ read()

ilMemberAgreement::read ( )

Read user entries.

private

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

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

Referenced by __construct().

357  {
358  $query = "SELECT * FROM member_agreement " .
359  "WHERE usr_id = " . $this->db->quote($this->user_id, 'integer') . " " .
360  "AND obj_id = " . $this->db->quote($this->obj_id, 'integer') . " ";
361 
362  $res = $this->db->query($query);
363  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
364  $this->accepted = $row->accepted;
365  $this->acceptance_time = $row->acceptance_time;
366  }
367  }
foreach($_POST as $key=> $value) $res
$query
+ Here is the caller graph for this function:

◆ save()

ilMemberAgreement::save ( )

save Acceptance settings

public

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

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

318  {
319  global $ilDB;
320 
321  $this->delete();
322 
323  $query = "INSERT INTO member_agreement (usr_id,obj_id,accepted,acceptance_time) " .
324  "VALUES( " .
325  $this->db->quote($this->user_id, 'integer') . ", " .
326  $this->db->quote($this->obj_id, 'integer') . ", " .
327  $this->db->quote((int) $this->isAccepted(), 'integer') . ", " .
328  $this->db->quote($this->getAcceptanceTime(), 'integer') . " " .
329  ")";
330  $ilDB->manipulate($query);
331  return true;
332  }
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 268 of file class.ilMemberAgreement.php.

269  {
270  $this->acceptance_time = $a_timest;
271  }

◆ setAccepted()

ilMemberAgreement::setAccepted (   $a_status)

set accepted

public

Parameters
boolstatus

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

Referenced by ilRegistrationGUI\setAccepted().

257  {
258  $this->accepted = $a_status;
259  }
+ 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: