ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
ilLMNavigationStatus Class Reference

Checks current navigation request status. More...

+ Collaboration diagram for ilLMNavigationStatus:

Public Member Functions

 __construct (ilObjUser $user, int $request_obj_id, ilLMTree $lm_tree, ilObjLearningModule $lm, ilSetting $lm_set, $requested_back_page, string $cmd, int $focus_id)
 Constructor. More...
 
 isChapterWithoutActivePage ()
 Has current chapter no avtive page? More...
 
 isDeactivatedPage ()
 Has current chapter no avtive page? More...
 
 getCurrentPage ()
 Has current chapter no avtive page? More...
 
 getBackPageId ()
 Get back link page id. More...
 
 getSuccessorPageId ()
 
 getPredecessorPageId ()
 Get predecessor page id. More...
 

Protected Member Functions

 determineStatus ()
 Determine status. More...
 

Protected Attributes

 $current_page_id = null
 
 $chapter_has_no_active_page = false
 
 $deactivated_page = false
 
 $lm
 
 $lm_tree
 
 $user
 
 $lm_set
 
 $requested_back_page
 
 $cmd
 
 $focus_id
 
 $requested_obj_id
 

Detailed Description

Checks current navigation request status.

  • determines the current page (request may e.g. pass a chapter id, in this case the next page is searched)
  • determines if all pages of a chapter are deactivated
  • determines if the current page is deactivated
Author
killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de

Definition at line 13 of file class.ilLMNavigationStatus.php.

Constructor & Destructor Documentation

◆ __construct()

ilLMNavigationStatus::__construct ( ilObjUser  $user,
int  $request_obj_id,
ilLMTree  $lm_tree,
ilObjLearningModule  $lm,
ilSetting  $lm_set,
  $requested_back_page,
string  $cmd,
int  $focus_id 
)

Constructor.

Parameters
ilObjUser$user
$request_obj_id
ilLMTree$lm_tree
ilObjLearningModule$lm
ilSetting$lm_set
string$cmd
int$focus_id

Definition at line 81 of file class.ilLMNavigationStatus.php.

References $cmd, $focus_id, $lm, $lm_set, $lm_tree, $requested_back_page, $user, determineStatus(), and user().

90  {
91  $this->user = $user;
92  $this->requested_obj_id = (int) $request_obj_id;
93  $this->lm_tree = $lm_tree;
94  $this->lm = $lm;
95  $this->lm_set = $lm_set;
96  $this->requested_back_page = (int) $requested_back_page;
97  $this->cmd = $cmd;
98  $this->focus_id = $focus_id;
99 
100  $this->determineStatus();
101  }
determineStatus()
Determine status.
user()
Definition: user.php:4
+ Here is the call graph for this function:

Member Function Documentation

◆ determineStatus()

ilLMNavigationStatus::determineStatus ( )
protected

Determine status.

Definition at line 137 of file class.ilLMNavigationStatus.php.

References $requested_obj_id, $user, ilObjContentObjectAccess\_getLastAccessedPage(), ilLMObject\_isPagePublic(), ilPageObject\_lookupActive(), ilLMObject\_lookupContObjID(), ilLMObject\_lookupType(), and ANONYMOUS_USER_ID.

Referenced by __construct().

138  {
139  $user = $this->user;
140 
141  $this->chapter_has_no_active_page = false;
142  $this->deactivated_page = false;
143 
145  if ($requested_obj_id > 0 && ilLMObject::_lookupContObjID($requested_obj_id) != $this->lm->getId()) {
146  $requested_obj_id = 0;
147  }
148 
149  // determine object id
150  if ($requested_obj_id == 0) {
151  $obj_id = $this->lm_tree->getRootId();
152 
153  if ($this->cmd == "resume") {
154  if ($user->getId() != ANONYMOUS_USER_ID && ((int) $this->focus_id == 0)) {
155  $last_accessed_page = ilObjLearningModuleAccess::_getLastAccessedPage($this->lm->getRefId(), $user->getId());
156  // if last accessed page was final page do nothing, start over
157  if ($last_accessed_page &&
158  $last_accessed_page != $this->lm_tree->getLastActivePage()) {
159  $obj_id = $last_accessed_page;
160  }
161  }
162  }
163  } else {
165  $active = ilLMPage::_lookupActive(
166  $obj_id,
167  $this->lm->getType(),
168  $this->lm_set->get("time_scheduled_page_activation")
169  );
170 
171  if (!$active &&
173  $this->deactivated_page = true;
174  }
175  }
176 
177  // obj_id not in tree -> it is a unassigned page -> return page id
178  if (!$this->lm_tree->isInTree($obj_id)) {
179  $this->current_page_id = $obj_id;
180  return null;
181  }
182 
183  $curr_node = $this->lm_tree->getNodeData($obj_id);
184 
185  $active = ilLMPage::_lookupActive(
186  $obj_id,
187  $this->lm->getType(),
188  $this->lm_set->get("time_scheduled_page_activation")
189  );
190 
191  if ($curr_node["type"] == "pg" &&
192  $active) { // page in tree -> return page id
193  $page_id = $curr_node["obj_id"];
194  } else { // no page -> search for next page and return its id
195  $succ_node = true;
196  $active = false;
197  $page_id = $obj_id;
198  while ($succ_node && !$active) {
199  $succ_node = $this->lm_tree->fetchSuccessorNode($page_id, "pg");
200  $page_id = $succ_node["obj_id"];
201  $active = ilLMPage::_lookupActive(
202  $page_id,
203  $this->lm->getType(),
204  $this->lm_set->get("time_scheduled_page_activation")
205  );
206  }
207 
208  if ($succ_node["type"] != "pg") {
209  $this->chapter_has_no_active_page = true;
210  $this->current_page_id = 0;
211  return null;
212  }
213 
214  // if public access get first public page in chapter
215  if ($user->getId() == ANONYMOUS_USER_ID &&
216  $this->lm->getPublicAccessMode() == 'selected') {
217  $public = ilLMObject::_isPagePublic($page_id);
218 
219  while ($public === false && $page_id > 0) {
220  $succ_node = $this->lm_tree->fetchSuccessorNode($page_id, 'pg');
221  $page_id = $succ_node['obj_id'];
222  $public = ilLMObject::_isPagePublic($page_id);
223  }
224  }
225 
226  // check whether page found is within "clicked" chapter
227  if ($this->lm_tree->isInTree($page_id)) {
228  $path = $this->lm_tree->getPathId($page_id);
229  if (!in_array($requested_obj_id, $path)) {
230  $this->chapter_has_no_active_page = true;
231  }
232  }
233  }
234 
235  $this->current_page_id = $page_id;
236  }
static _lookupType($a_obj_id, $a_lm_id=0)
Lookup type.
const ANONYMOUS_USER_ID
Definition: constants.php:25
static _lookupContObjID($a_id)
get learning module / digibook id for lm object
static _lookupActive($a_id, $a_parent_type, $a_check_scheduled_activation=false, $a_lang="-")
lookup activation status
static _isPagePublic($a_node_id, $a_check_public_mode=false)
static _getLastAccessedPage($a_ref_id, $a_user_id="")
get last accessed page
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getBackPageId()

ilLMNavigationStatus::getBackPageId ( )

Get back link page id.

Returns
int

Definition at line 242 of file class.ilLMNavigationStatus.php.

References $current_page_id, and $requested_back_page.

242  : int
243  {
244  $page_id = $this->current_page_id;
245 
246  if (empty($page_id)) {
247  return 0;
248  }
249 
250  $back_pg = $this->requested_back_page;
251 
252  // process navigation for free page
253  if (!$this->lm_tree->isInTree($page_id)) {
254  return $back_pg;
255  }
256  return $back_pg;
257  }

◆ getCurrentPage()

ilLMNavigationStatus::getCurrentPage ( )

Has current chapter no avtive page?

Returns
int

Definition at line 128 of file class.ilLMNavigationStatus.php.

References $current_page_id.

◆ getPredecessorPageId()

ilLMNavigationStatus::getPredecessorPageId ( )

Get predecessor page id.

Returns
int

Definition at line 322 of file class.ilLMNavigationStatus.php.

References $current_page_id, $requested_obj_id, ilLMObject\_isPagePublic(), ilPageObject\_lookupActivationData(), ilPageObject\_lookupActive(), ANONYMOUS_USER_ID, ilUtil\now(), and user().

322  : int
323  {
324  $page_id = $this->current_page_id;
325  $user_id = $this->user->getId();
326 
327  // determine predecessor page id
328  $found = false;
329  if ($this->deactivated_page) {
330  $c_id = $this->requested_obj_id;
331  } else {
332  $c_id = $page_id;
333  }
334  while (!$found) {
335  $pre_node = $this->lm_tree->fetchPredecessorNode($c_id, "pg");
336  $c_id = $pre_node["obj_id"];
337  $active = ilLMPage::_lookupActive(
338  $c_id,
339  $this->lm->getType(),
340  $this->lm_set->get("time_scheduled_page_activation")
341  );
342  if ($pre_node["obj_id"] > 0 &&
343  $user_id == ANONYMOUS_USER_ID &&
344  ($this->lm->getPublicAccessMode() == "selected" &&
345  !ilLMObject::_isPagePublic($pre_node["obj_id"]))) {
346  $found = false;
347  } else {
348  if ($pre_node["obj_id"] > 0 && !$active) {
349  // look, whether activation data should be shown
350  $act_data = ilLMPage::_lookupActivationData((int) $pre_node["obj_id"], $this->lm->getType());
351  if ($act_data["show_activation_info"] &&
352  (ilUtil::now() < $act_data["activation_start"])) {
353  $found = true;
354  } else {
355  $found = false;
356  }
357  } else {
358  $found = true;
359  }
360  }
361  }
362  if (is_array($pre_node)) {
363  return (int) $pre_node["obj_id"];
364  }
365 
366  return 0;
367  }
const ANONYMOUS_USER_ID
Definition: constants.php:25
static now()
Return current timestamp in Y-m-d H:i:s format.
user()
Definition: user.php:4
static _lookupActive($a_id, $a_parent_type, $a_check_scheduled_activation=false, $a_lang="-")
lookup activation status
static _lookupActivationData($a_id, $a_parent_type, $a_lang="-")
Lookup activation data.
static _isPagePublic($a_node_id, $a_check_public_mode=false)
+ Here is the call graph for this function:

◆ getSuccessorPageId()

ilLMNavigationStatus::getSuccessorPageId ( )
Returns
int

Definition at line 262 of file class.ilLMNavigationStatus.php.

References $current_page_id, $requested_obj_id, ilLMObject\_isPagePublic(), ilPageObject\_lookupActivationData(), ilPageObject\_lookupActive(), ilLMObject\_lookupType(), ANONYMOUS_USER_ID, ilUtil\now(), and user().

262  : int
263  {
264  $page_id = $this->current_page_id;
265  $user_id = $this->user->getId();
266 
267  // determine successor page_id
268  $found = false;
269 
270  // empty chapter
271  if ($this->chapter_has_no_active_page &&
272  ilLMObject::_lookupType($this->requested_obj_id) == "st") {
273  $c_id = $this->requested_obj_id;
274  } else {
275  if ($this->deactivated_page) {
276  $c_id = $this->requested_obj_id;
277  } else {
278  $c_id = $page_id;
279  }
280  }
281  while (!$found) {
282  $succ_node = $this->lm_tree->fetchSuccessorNode($c_id, "pg");
283  $c_id = $succ_node["obj_id"];
284 
285  $active = ilLMPage::_lookupActive(
286  $c_id,
287  $this->lm->getType(),
288  $this->lm_set->get("time_scheduled_page_activation")
289  );
290 
291  if ($succ_node["obj_id"] > 0 &&
292  $user_id == ANONYMOUS_USER_ID &&
293  ($this->lm->getPublicAccessMode() == "selected" &&
294  !ilLMObject::_isPagePublic($succ_node["obj_id"]))) {
295  $found = false;
296  } else {
297  if ($succ_node["obj_id"] > 0 && !$active) {
298  // look, whether activation data should be shown
299  $act_data = ilLMPage::_lookupActivationData((int) $succ_node["obj_id"], $this->lm->getType());
300  if ($act_data["show_activation_info"] &&
301  (ilUtil::now() < $act_data["activation_start"])) {
302  $found = true;
303  } else {
304  $found = false;
305  }
306  } else {
307  $found = true;
308  }
309  }
310  }
311  if (is_array($succ_node)) {
312  return (int) $succ_node["obj_id"];
313  }
314 
315  return 0;
316  }
static _lookupType($a_obj_id, $a_lm_id=0)
Lookup type.
const ANONYMOUS_USER_ID
Definition: constants.php:25
static now()
Return current timestamp in Y-m-d H:i:s format.
user()
Definition: user.php:4
static _lookupActive($a_id, $a_parent_type, $a_check_scheduled_activation=false, $a_lang="-")
lookup activation status
static _lookupActivationData($a_id, $a_parent_type, $a_lang="-")
Lookup activation data.
static _isPagePublic($a_node_id, $a_check_public_mode=false)
+ Here is the call graph for this function:

◆ isChapterWithoutActivePage()

ilLMNavigationStatus::isChapterWithoutActivePage ( )

Has current chapter no avtive page?

Returns
bool

Definition at line 108 of file class.ilLMNavigationStatus.php.

References $chapter_has_no_active_page.

◆ isDeactivatedPage()

ilLMNavigationStatus::isDeactivatedPage ( )

Has current chapter no avtive page?

Returns
bool

Definition at line 118 of file class.ilLMNavigationStatus.php.

References $deactivated_page.

Field Documentation

◆ $chapter_has_no_active_page

ilLMNavigationStatus::$chapter_has_no_active_page = false
protected

Definition at line 24 of file class.ilLMNavigationStatus.php.

Referenced by isChapterWithoutActivePage().

◆ $cmd

ilLMNavigationStatus::$cmd
protected

Definition at line 59 of file class.ilLMNavigationStatus.php.

Referenced by __construct().

◆ $current_page_id

ilLMNavigationStatus::$current_page_id = null
protected

◆ $deactivated_page

ilLMNavigationStatus::$deactivated_page = false
protected

Definition at line 29 of file class.ilLMNavigationStatus.php.

Referenced by isDeactivatedPage().

◆ $focus_id

ilLMNavigationStatus::$focus_id
protected

Definition at line 64 of file class.ilLMNavigationStatus.php.

Referenced by __construct().

◆ $lm

ilLMNavigationStatus::$lm
protected

Definition at line 34 of file class.ilLMNavigationStatus.php.

Referenced by __construct().

◆ $lm_set

ilLMNavigationStatus::$lm_set
protected

Definition at line 49 of file class.ilLMNavigationStatus.php.

Referenced by __construct().

◆ $lm_tree

ilLMNavigationStatus::$lm_tree
protected

Definition at line 39 of file class.ilLMNavigationStatus.php.

Referenced by __construct().

◆ $requested_back_page

ilLMNavigationStatus::$requested_back_page
protected

Definition at line 54 of file class.ilLMNavigationStatus.php.

Referenced by __construct(), and getBackPageId().

◆ $requested_obj_id

ilLMNavigationStatus::$requested_obj_id
protected

◆ $user

ilLMNavigationStatus::$user
protected

Definition at line 44 of file class.ilLMNavigationStatus.php.

Referenced by __construct(), and determineStatus().


The documentation for this class was generated from the following file: