ILIAS  Release_5_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 'Services/Object/classes/class.ilObjectActivation.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'] = ilObjectActivation::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 $ilObjDataCache;
54 
55  $obj_id = $ilObjDataCache->lookupObjId($a_ref_id);
56 
57  // if completed no warning
58  include_once './Services/Tracking/classes/class.ilLPStatus.php';
59  if(ilLPStatus::_hasUserCompleted($obj_id, $a_usr_id))
60  {
61  return false;
62  }
63 
64  // if editing time reached => show warning
65  $timings =& ilTimingCache::_getTimings($a_ref_id);
66  if($timings['item']['timing_type'] == ilObjectActivation::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 
82  include_once './Services/Object/classes/class.ilObjectLP.php';
83  $olp = ilObjectLP::getInstance($obj_id);
84  $collection = $olp->getCollectionInstance();
85  if($collection instanceof ilLPCollectionOfRepositoryObjects)
86  {
87  foreach($collection->getItems() as $item)
88  {
89  if(ilTimingCache::_showWarning($item, $a_usr_id))
90  {
91  return true;
92  }
93  }
94  }
95 
96  // Really ???
97  return false;
98  }
99 }
100 ?>