ILIAS  Release_4_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilTimingCache.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2001 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
24 
32 include_once 'Modules/Course/classes/class.ilCourseItems.php';
33 include_once 'Modules/Course/classes/Timings/class.ilTimingPlaned.php';
34 
36 {
37  function &_getTimings($a_ref_id)
38  {
39  static $cache = array();
40 
41  if(isset($cache[$a_ref_id]))
42  {
43  return $cache[$a_ref_id];
44  }
45  $cache[$a_ref_id]['item'] = ilCourseItems::_getItem($a_ref_id);
46  $cache[$a_ref_id]['user'] = ilTimingPlaned::_getPlanedTimingsByItem($a_ref_id);
47 
48  return $cache[$a_ref_id];
49  }
50 
51  function _showWarning($a_ref_id,$a_usr_id)
52  {
53  include_once './Services/Tracking/classes/class.ilLPCollectionCache.php';
54  include_once './Services/Tracking/classes/class.ilLPStatusWrapper.php';
55 
56  global $ilObjDataCache;
57  $obj_id = $ilObjDataCache->lookupObjId($a_ref_id);
58 
59  // if completed no warning
60  if(in_array($a_usr_id,ilLPStatusWrapper::_getCompleted($obj_id)))
61  {
62  return false;
63  }
64  // if editing time reached => show warning
65  $timings =& ilTimingCache::_getTimings($a_ref_id);
66  if($timings['item']['timing_type'] == IL_CRS_TIMINGS_PRESETTING)
67  {
68  if($timings['item']['changeable'] and $timings['user'][$a_usr_id]['end'])
69  {
70  $end = $timings['user'][$a_usr_id]['end'];
71  }
72  else
73  {
74  $end = $timings['item']['suggestion_end'];
75  }
76  if($end < time())
77  {
78  return true;
79  }
80  }
81  // No check subitems
82  foreach(ilLPCollectionCache::_getItems($obj_id) as $item)
83  {
84  if(ilTimingCache::_showWarning($item,$a_usr_id))
85  {
86  return true;
87  }
88  }
89  // Really ???
90  return false;
91  }
92 }
93 ?>