ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilLPListOfProgressGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
17 include_once './Services/Tracking/classes/class.ilLearningProgressBaseGUI.php';
18 include_once './Services/Tracking/classes/class.ilLPStatusWrapper.php';
19 
21 {
22  var $tracked_user = null;
23  var $details_id = 0;
24  var $details_type = '';
25  var $details_mode = 0;
26 
27  function ilLPListOfProgressGUI($a_mode,$a_ref_id,$a_user_id = 0)
28  {
29  parent::ilLearningProgressBaseGUI($a_mode,$a_ref_id,$a_user_id);
30 
31  $this->__initUser($a_user_id);
32 
33  // Set item id for details
34  $this->__initDetails((int) $_GET['details_id']);
35  $this->ctrl->saveParameter($this,'details_id',$_REQUEST['details_id']);
36  }
37 
38 
42  function &executeCommand()
43  {
44  global $ilUser;
45 
46  $this->ctrl->setReturn($this, "show");
47  $this->ctrl->saveParameter($this,'user_id',$this->getUserId());
48  switch($this->ctrl->getNextClass())
49  {
50  case 'illpprogresstablegui':
51  include_once './Services/Tracking/classes/class.ilLPProgressTableGUI.php';
52  $table_gui = new ilLPProgressTableGUI($this, "", $this->tracked_user);
53  $this->ctrl->setReturn($this,'show');
54  $this->ctrl->forwardCommand($table_gui);
55  break;
56 
57  default:
58  $cmd = $this->__getDefaultCommand();
59  $this->$cmd();
60 
61  }
62  return true;
63  }
64 
65  function show()
66  {
67  global $ilObjDataCache;
68 
69  switch($this->getMode())
70  {
71  // Show only detail of current repository item if called from repository
72  case LP_MODE_REPOSITORY:
73  $this->__initDetails($this->getRefId());
74  return $this->details();
75 
77  // if called from user folder obj_id is id of current user
78  $this->__initUser($this->getUserId());
79  break;
80  }
81 
82  // not called from repository
83  $this->__showProgressList();
84  }
85 
86  function details()
87  {
88  global $ilObjDataCache,$ilCtrl,$rbacsystem;
89 
90  // Show back button to crs if called from crs. Otherwise if called from personal desktop or administration
91  // show back to list
92  if((int)$_GET['crs_id'])
93  {
94  $this->ctrl->setParameter($this,'details_id',(int) $_GET['crs_id']);
95  $this->__showButton($this->ctrl->getLinkTarget($this,'details'),$this->lng->txt('trac_view_crs'));
96  }
97  elseif($this->getMode() == LP_MODE_PERSONAL_DESKTOP or
98  $this->getMode() == LP_MODE_ADMINISTRATION or
99  $this->getMode() == LP_MODE_USER_FOLDER)
100  {
101  $this->__showButton($this->ctrl->getLinkTarget($this,'show'),$this->lng->txt('trac_view_list'));
102  }
103 
104  $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.lp_progress_container.html','Services/Tracking');
105 
106  include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
107  $info = new ilInfoScreenGUI($this);
108  $info->setFormAction($ilCtrl->getFormAction($this));
109  $this->__appendUserInfo($info, $this->tracked_user);
110  $this->__showObjectDetails($info,$this->details_obj_id);
111  $this->__appendLPDetails($info,$this->details_obj_id,$this->tracked_user->getId());
112 
113  // Finally set template variable
114  $this->tpl->setVariable("LM_INFO",$info->getHTML());
115 
116  include_once './Services/Tracking/classes/class.ilLPCollectionCache.php';
117  $obj_ids = array();
118  foreach(ilLPCollectionCache::_getItems($this->details_obj_id) as $ref_id)
119  {
120  switch($this->details_mode)
121  {
122  case LP_MODE_SCORM:
123  case LP_MODE_OBJECTIVES:
124  $obj_ids[] = $ref_id;
125  break;
126 
127  default:
128  $obj_ids[ilObject::_lookupObjectId($ref_id)] = array($ref_id);
129  break;
130  }
131  }
132 
133  $personal_only = !$rbacsystem->checkAccess('edit_learning_progress',$this->getRefId());
134 
135  include_once("./Services/Tracking/classes/class.ilLPProgressTableGUI.php");
136  $lp_table = new ilLPProgressTableGUI($this, "details", $this->tracked_user, $obj_ids, true, $this->details_mode, $personal_only, $this->details_obj_id);
137  $this->tpl->setVariable("LP_OBJECTS", $lp_table->getHTML());
138 
139  $this->tpl->setVariable("LEGEND",$this->__getLegendHTML());
140  }
141 
143  {
144  global $ilUser,$ilObjDataCache,$ilCtrl;
145 
146  $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.lp_list_progress.html','Services/Tracking');
147 
148  // User info
149  include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
150  $info = new ilInfoScreenGUI($this);
151  $info->setFormAction($ilCtrl->getFormAction($this));
152 
153  if ($this->__appendUserInfo($info, $this->tracked_user))
154  {
155  $this->tpl->setCurrentBlock("info_user");
156  $this->tpl->setVariable("USER_INFO",$info->getHTML());
157  $this->tpl->parseCurrentBlock();
158  }
159 
160  include_once("./Services/Tracking/classes/class.ilLPProgressTableGUI.php");
161  $lp_table = new ilLPProgressTableGUI($this, "", $this->tracked_user);
162  $this->tpl->setVariable("LP_OBJECTS", $lp_table->getHTML());
163 
164  $this->tpl->setVariable("LEGEND", $this->__getLegendHTML());
165  }
166 
167  function __initUser($a_usr_id = 0)
168  {
169  global $ilUser,$rbacreview,$rbacsystem;
170 
171  if($_POST['user_id'])
172  {
173  $a_usr_id = $_POST['user_id'];
174  $this->ctrl->setParameter($this,'user_id',$_POST['user_id']);
175  }
176 
177  if($a_usr_id)
178  {
179  $this->tracked_user = ilObjectFactory::getInstanceByObjId($a_usr_id);
180  }
181  else
182  {
183  $this->tracked_user = $ilUser;
184  }
185 
186  // #8762: see ilObjUserGUI->getTabs()
187  if($this->mode == LP_MODE_USER_FOLDER && $rbacsystem->checkAccess('read',$this->ref_id))
188  {
189  return true;
190  }
191 
192  // Check access
193  if(!$rbacreview->isAssigned($ilUser->getId(),SYSTEM_ROLE_ID))
194  {
195  $this->tracked_user = $ilUser;
196  }
197 
198  return true;
199  }
200 
201  function __initDetails($a_details_id)
202  {
203  global $ilObjDataCache;
204 
205  if(!$a_details_id)
206  {
207  $a_details_id = $this->getRefId();
208  }
209  if($a_details_id)
210  {
211  $ref_ids = ilObject::_getAllReferences($a_details_id);
212 
213  $this->details_id = $a_details_id;
214  $this->details_obj_id = $ilObjDataCache->lookupObjId($this->details_id);
215  $this->details_type = $ilObjDataCache->lookupType($this->details_obj_id);
216  $this->details_mode = ilLPObjSettings::_lookupMode($this->details_obj_id);
217  }
218  }
219 }
220 
221 ?>