ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilTimingCache Class Reference

class ilTimingCache More...

+ Collaboration diagram for ilTimingCache:

Public Member Functions

 __construct ($ref_id)
 ilTimingCache constructor. More...
 
 isWarningRequired ($usr_id)
 

Static Public Member Functions

static getInstanceByRefId ($ref_id)
 
static & _getTimings ($a_ref_id)
 
static _showWarning ($a_ref_id, $a_usr_id)
 

Protected Member Functions

 readObjectInformation ()
 Read timing information for object. More...
 

Private Attributes

 $ref_id = 0
 
 $obj_id = 0
 
 $timings_active = false
 
 $timings = array()
 
 $timings_user = array()
 
 $collection_items = array()
 
 $completed_users = array()
 

Static Private Attributes

static $instances = array()
 

Detailed Description

class ilTimingCache

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

Definition at line 32 of file class.ilTimingCache.php.

Constructor & Destructor Documentation

◆ __construct()

ilTimingCache::__construct (   $ref_id)

ilTimingCache constructor.

Definition at line 77 of file class.ilTimingCache.php.

References $ref_id, ilObject\_lookupObjId(), and readObjectInformation().

78  {
79  $this->ref_id = $ref_id;
80  $this->obj_id = ilObject::_lookupObjId($this->ref_id);
81  $this->readObjectInformation();
82  }
readObjectInformation()
Read timing information for object.
static _lookupObjId($a_id)
+ Here is the call graph for this function:

Member Function Documentation

◆ _getTimings()

static& ilTimingCache::_getTimings (   $a_ref_id)
static
Deprecated:
7
Parameters
$a_ref_id
Returns
mixed

Definition at line 150 of file class.ilTimingCache.php.

References ilTimingPlaned\_getPlanedTimingsByItem(), and ilObjectActivation\getItem().

Referenced by _showWarning(), and ilLPTableBaseGUI\showTimingsWarning().

151  {
152  static $cache = array();
153 
154  if (isset($cache[$a_ref_id])) {
155  return $cache[$a_ref_id];
156  }
157  $cache[$a_ref_id]['item'] = ilObjectActivation::getItem($a_ref_id);
158  $cache[$a_ref_id]['user'] = ilTimingPlaned::_getPlanedTimingsByItem($a_ref_id);
159 
160  return $cache[$a_ref_id];
161  }
static getItem($a_ref_id)
Get item data.
static _getPlanedTimingsByItem($a_item_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _showWarning()

static ilTimingCache::_showWarning (   $a_ref_id,
  $a_usr_id 
)
static
Deprecated:
7
Parameters
$a_ref_id
$a_usr_id
Returns
bool

Definition at line 169 of file class.ilTimingCache.php.

References $DIC, $end, $obj_id, $timings, _getTimings(), ilLPStatus\_hasUserCompleted(), ilObjectLP\getInstance(), and ilObjectActivation\TIMINGS_PRESETTING.

170  {
171  global $DIC;
172 
173  $ilObjDataCache = $DIC['ilObjDataCache'];
174 
175  $obj_id = $ilObjDataCache->lookupObjId($a_ref_id);
176 
177  // if completed no warning
178  include_once './Services/Tracking/classes/class.ilLPStatus.php';
179  if (ilLPStatus::_hasUserCompleted($obj_id, $a_usr_id)) {
180  return false;
181  }
182 
183  // if editing time reached => show warning
184  $timings = &ilTimingCache::_getTimings($a_ref_id);
185  if ($timings['item']['timing_type'] == ilObjectActivation::TIMINGS_PRESETTING) {
186  if ($timings['item']['changeable'] and $timings['user'][$a_usr_id]['end']) {
187  $end = $timings['user'][$a_usr_id]['end'];
188  } else {
189  $end = $timings['item']['suggestion_end'];
190  }
191  if ($end < time()) {
192  return true;
193  }
194  }
195 
196  include_once './Services/Object/classes/class.ilObjectLP.php';
198  $collection = $olp->getCollectionInstance();
199  if ($collection instanceof ilLPCollectionOfRepositoryObjects) {
200  foreach ($collection->getItems() as $item) {
201  if (ilTimingCache::_showWarning($item, $a_usr_id)) {
202  return true;
203  }
204  }
205  }
206 
207  // Really ???
208  return false;
209  }
global $DIC
Definition: saml.php:7
static _showWarning($a_ref_id, $a_usr_id)
static _hasUserCompleted($a_obj_id, $a_user_id)
Lookup user object completion.
static getInstance($a_obj_id)
static & _getTimings($a_ref_id)
+ Here is the call graph for this function:

◆ getInstanceByRefId()

static ilTimingCache::getInstanceByRefId (   $ref_id)
static
Parameters
$ref_id
Returns
ilTimingCache

Definition at line 88 of file class.ilTimingCache.php.

References $ref_id.

Referenced by ilLPTableBaseGUI\showTimingsWarning().

89  {
90  if (!isset(self::$instances[$ref_id])) {
91  self::$instances[$ref_id] = new self($ref_id);
92  }
93  return self::$instances[$ref_id];
94  }
+ Here is the caller graph for this function:

◆ isWarningRequired()

ilTimingCache::isWarningRequired (   $usr_id)
Parameters
int$usr_id
Returns
bool

Definition at line 100 of file class.ilTimingCache.php.

References $end.

101  {
102  if (in_array($usr_id, $this->completed_users)) {
103  return false;
104  }
105  foreach ($this->collection_items as $item) {
106  $item_instance = self::getInstanceByRefId($item);
107  if ($item_instance->isWarningRequired($usr_id)) {
108  return true;
109  }
110  }
111  if (!$this->timings_active) {
112  return false;
113  }
114 
115  // check constraints
116  if ($this->timings['changeable'] && isset($this->timings_user[$usr_id]['end'])) {
117  $end = $this->timings_user[$usr_id]['end'];
118  } else {
119  $end = $this->timings['suggestion_end'];
120  }
121  return $end < time();
122  }

◆ readObjectInformation()

ilTimingCache::readObjectInformation ( )
protected

Read timing information for object.

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

References ilLPStatus\_getCompleted(), ilTimingPlaned\_getPlanedTimingsByItem(), ilObjectLP\getInstance(), ilObjectActivation\getItem(), and ilObjectActivation\TIMINGS_PRESETTING.

Referenced by __construct().

128  {
129  $this->timings = ilObjectActivation::getItem($this->ref_id);
130  $this->timings_active = false;
131  if ($this->timings['timing_type'] == ilObjectActivation::TIMINGS_PRESETTING) {
132  $this->timings_active = true;
133  $this->timings_user = ilTimingPlaned::_getPlanedTimingsByItem($this->ref_id);
134  }
135 
136  $olp = ilObjectLP::getInstance($this->obj_id);
137  $collection = $olp->getCollectionInstance();
138  if ($collection instanceof ilLPCollectionOfRepositoryObjects) {
139  $this->collection_items = $collection->getItems();
140  }
141  $this->completed_users = ilLPStatus::_getCompleted($this->obj_id);
142  }
static getItem($a_ref_id)
Get item data.
static _getPlanedTimingsByItem($a_item_id)
static _getCompleted($a_obj_id)
static getInstance($a_obj_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $collection_items

ilTimingCache::$collection_items = array()
private

Definition at line 67 of file class.ilTimingCache.php.

◆ $completed_users

ilTimingCache::$completed_users = array()
private

Definition at line 72 of file class.ilTimingCache.php.

◆ $instances

ilTimingCache::$instances = array()
staticprivate

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

◆ $obj_id

ilTimingCache::$obj_id = 0
private

Definition at line 47 of file class.ilTimingCache.php.

Referenced by _showWarning().

◆ $ref_id

ilTimingCache::$ref_id = 0
private

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

Referenced by __construct(), and getInstanceByRefId().

◆ $timings

ilTimingCache::$timings = array()
private

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

Referenced by _showWarning().

◆ $timings_active

ilTimingCache::$timings_active = false
private

Definition at line 52 of file class.ilTimingCache.php.

◆ $timings_user

ilTimingCache::$timings_user = array()
private

Definition at line 62 of file class.ilTimingCache.php.


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