ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilLMNavigationStatus.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2019 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
14 {
15 
19  protected $current_page_id = null;
20 
24  protected $chapter_has_no_active_page = false;
25 
29  protected $deactivated_page = false;
30 
34  protected $lm;
35 
39  protected $lm_tree;
40 
44  protected $user;
45 
49  protected $lm_set;
50 
54  protected $cmd;
55 
59  protected $focus_id;
60 
64  protected $requested_obj_id;
65 
76  public function __construct(
78  int $request_obj_id,
82  string $cmd,
83  int $focus_id
84  ) {
85  $this->user = $user;
86  $this->requested_obj_id = (int) $request_obj_id;
87  $this->lm_tree = $lm_tree;
88  $this->lm = $lm;
89  $this->lm_set = $lm_set;
90  $this->cmd = $cmd;
91  $this->focus_id = $focus_id;
92 
93  $this->determineStatus();
94  }
95 
101  public function isChapterWithoutActivePage()
102  {
104  }
105 
111  public function isDeactivatedPage()
112  {
114  }
115 
121  public function getCurrentPage()
122  {
123  return $this->current_page_id;
124  }
125 
126 
130  protected function determineStatus()
131  {
132  $user = $this->user;
133 
134  $this->chapter_has_no_active_page = false;
135  $this->deactivated_page = false;
136 
137  // determine object id
138  if ($this->requested_obj_id == 0) {
139 
140  $obj_id = $this->lm_tree->getRootId();
141 
142  if ($this->cmd == "resume") {
143  if ($user->getId() != ANONYMOUS_USER_ID && ((int) $this->focus_id == 0)) {
144  $last_accessed_page = ilObjLearningModuleAccess::_getLastAccessedPage($this->lm->getRefId(), $user->getId());
145  // if last accessed page was final page do nothing, start over
146  if ($last_accessed_page &&
147  $last_accessed_page != $this->lm_tree->getLastActivePage()) {
148  $obj_id = $last_accessed_page;
149  }
150  }
151  }
152 
153  } else {
154  $obj_id = $this->requested_obj_id;
155  $active = ilLMPage::_lookupActive(
156  $obj_id,
157  $this->lm->getType(),
158  $this->lm_set->get("time_scheduled_page_activation")
159  );
160 
161  if (!$active &&
162  ilLMPageObject::_lookupType($obj_id) == "pg") {
163  $this->deactivated_page = true;
164  }
165  }
166 
167  // obj_id not in tree -> it is a unassigned page -> return page id
168  if (!$this->lm_tree->isInTree($obj_id)) {
169  $this->current_page_id = $obj_id;
170  return null;
171  }
172 
173  $curr_node = $this->lm_tree->getNodeData($obj_id);
174 
175  $active = ilLMPage::_lookupActive(
176  $obj_id,
177  $this->lm->getType(),
178  $this->lm_set->get("time_scheduled_page_activation")
179  );
180 
181  if ($curr_node["type"] == "pg" &&
182  $active) { // page in tree -> return page id
183  $page_id = $curr_node["obj_id"];
184  } else { // no page -> search for next page and return its id
185  $succ_node = true;
186  $active = false;
187  $page_id = $obj_id;
188  while ($succ_node && !$active) {
189  $succ_node = $this->lm_tree->fetchSuccessorNode($page_id, "pg");
190  $page_id = $succ_node["obj_id"];
191  $active = ilLMPage::_lookupActive(
192  $page_id,
193  $this->lm->getType(),
194  $this->lm_set->get("time_scheduled_page_activation")
195  );
196  }
197 
198  if ($succ_node["type"] != "pg") {
199  $this->chapter_has_no_active_page = true;
200  $this->current_page_id = 0;
201  return null;
202  }
203 
204  // if public access get first public page in chapter
205  if ($user->getId() == ANONYMOUS_USER_ID &&
206  $this->lm->getPublicAccessMode() == 'selected') {
207  $public = ilLMObject::_isPagePublic($page_id);
208 
209  while ($public === false && $page_id > 0) {
210  $succ_node = $this->lm_tree->fetchSuccessorNode($page_id, 'pg');
211  $page_id = $succ_node['obj_id'];
212  $public = ilLMObject::_isPagePublic($page_id);
213  }
214  }
215 
216  // check whether page found is within "clicked" chapter
217  if ($this->lm_tree->isInTree($page_id)) {
218  $path = $this->lm_tree->getPathId($page_id);
219  if (!in_array($this->requested_obj_id, $path)) {
220  $this->chapter_has_no_active_page = true;
221  }
222  }
223  }
224 
225  $this->current_page_id = $page_id;
226  }
227 }
Class ilObjLearningModule.
static _lookupType($a_obj_id, $a_lm_id=0)
Lookup type.
__construct(ilObjUser $user, int $request_obj_id, ilLMTree $lm_tree, ilObjLearningModule $lm, ilSetting $lm_set, string $cmd, int $focus_id)
Constructor.
getCurrentPage()
Has current chapter no avtive page?
determineStatus()
Determine status.
user()
Definition: user.php:4
static _lookupActive($a_id, $a_parent_type, $a_check_scheduled_activation=false, $a_lang="-")
lookup activation status
Checks current navigation request status.
isChapterWithoutActivePage()
Has current chapter no avtive page?
static _isPagePublic($a_node_id, $a_check_public_mode=false)
static _getLastAccessedPage($a_ref_id, $a_user_id="")
get last accessed page
isDeactivatedPage()
Has current chapter no avtive page?