ILIAS  Release_4_1_x_branch Revision 61804
 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  global $objDefinition;
54 
55  include_once './Services/Tracking/classes/class.ilLPCollectionCache.php';
56  include_once './Services/Tracking/classes/class.ilLPStatusWrapper.php';
57  include_once './Services/Tracking/classes/class.ilLPObjSettings.php';
58 
59  global $ilObjDataCache;
60  $obj_id = $ilObjDataCache->lookupObjId($a_ref_id);
61 
62  // if completed no warning
63  if(in_array($a_usr_id,ilLPStatusWrapper::_getCompleted($obj_id)))
64  {
65  return false;
66  }
67  // if editing time reached => show warning
68  $timings =& ilTimingCache::_getTimings($a_ref_id);
69  if($timings['item']['timing_type'] == IL_CRS_TIMINGS_PRESETTING)
70  {
71  if($timings['item']['changeable'] and $timings['user'][$a_usr_id]['end'])
72  {
73  $end = $timings['user'][$a_usr_id]['end'];
74  }
75  else
76  {
77  $end = $timings['item']['suggestion_end'];
78  }
79  if($end < time())
80  {
81  return true;
82  }
83  }
84 
85  // objective_ids would get confused with ref_ids !
87  $objDefinition->isContainer(ilObject::_lookupType($obj_id)))
88  {
89  // No check subitems
90  foreach(ilLPCollectionCache::_getItems($obj_id) as $item)
91  {
92  if(ilTimingCache::_showWarning($item,$a_usr_id))
93  {
94  return true;
95  }
96  }
97  }
98 
99  // Really ???
100  return false;
101  }
102 }
103 ?>