ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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(), array, 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)
Create styles array
The data for the language used.
+ 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 $end, $obj_id, $timings, _getTimings(), ilLPStatus\_hasUserCompleted(), ilObjectLP\getInstance(), time, and ilObjectActivation\TIMINGS_PRESETTING.

170  {
171  global $ilObjDataCache;
172 
173  $obj_id = $ilObjDataCache->lookupObjId($a_ref_id);
174 
175  // if completed no warning
176  include_once './Services/Tracking/classes/class.ilLPStatus.php';
177  if (ilLPStatus::_hasUserCompleted($obj_id, $a_usr_id)) {
178  return false;
179  }
180 
181  // if editing time reached => show warning
183  if ($timings['item']['timing_type'] == ilObjectActivation::TIMINGS_PRESETTING) {
184  if ($timings['item']['changeable'] and $timings['user'][$a_usr_id]['end']) {
185  $end = $timings['user'][$a_usr_id]['end'];
186  } else {
187  $end = $timings['item']['suggestion_end'];
188  }
189  if ($end < time()) {
190  return true;
191  }
192  }
193 
194  include_once './Services/Object/classes/class.ilObjectLP.php';
196  $collection = $olp->getCollectionInstance();
197  if ($collection instanceof ilLPCollectionOfRepositoryObjects) {
198  foreach ($collection->getItems() as $item) {
199  if (ilTimingCache::_showWarning($item, $a_usr_id)) {
200  return true;
201  }
202  }
203  }
204 
205  // Really ???
206  return false;
207  }
$end
Definition: saml1-acs.php:18
static _showWarning($a_ref_id, $a_usr_id)
static _hasUserCompleted($a_obj_id, $a_user_id)
Lookup user object completion.
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
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, and time.

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  }
$end
Definition: saml1-acs.php:18
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.

◆ 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: