/**
  * Get the current page id
  *
  * @return bool|int current page id
  */
 function getCurrentPageId()
 {
     global $ilUser;
     if (!$this->offlineMode() && $this->current_page_id !== false) {
         return $this->current_page_id;
     }
     include_once "./Modules/LearningModule/classes/class.ilLMPage.php";
     $this->chapter_has_no_active_page = false;
     $this->deactivated_page = false;
     // determine object id
     if (empty($_GET["obj_id"])) {
         $obj_id = $this->lm_tree->getRootId();
     } else {
         $obj_id = $_GET["obj_id"];
         $active = ilLMPage::_lookupActive($obj_id, $this->lm->getType(), $this->lm_set->get("time_scheduled_page_activation"));
         if (!$active && ilLMPageObject::_lookupType($obj_id) == "pg") {
             $this->deactivated_page = true;
         }
     }
     // obj_id not in tree -> it is a unassigned page -> return page id
     if (!$this->lm_tree->isInTree($obj_id)) {
         return $obj_id;
     }
     $curr_node = $this->lm_tree->getNodeData($obj_id);
     $active = ilLMPage::_lookupActive($obj_id, $this->lm->getType(), $this->lm_set->get("time_scheduled_page_activation"));
     if ($curr_node["type"] == "pg" && $active) {
         $page_id = $curr_node["obj_id"];
     } else {
         $succ_node = true;
         $active = false;
         $page_id = $obj_id;
         while ($succ_node && !$active) {
             $succ_node = $this->lm_tree->fetchSuccessorNode($page_id, "pg");
             $page_id = $succ_node["obj_id"];
             $active = ilLMPage::_lookupActive($page_id, $this->lm->getType(), $this->lm_set->get("time_scheduled_page_activation"));
         }
         if ($succ_node["type"] != "pg") {
             $this->chapter_has_no_active_page = true;
             return 0;
         }
         // if public access get first public page in chapter
         if (($ilUser->getId() == ANONYMOUS_USER_ID || $this->needs_to_be_purchased) && $this->lm_gui->object->getPublicAccessMode() == 'selected') {
             $public = ilLMObject::_isPagePublic($page_id);
             while ($public === false && $page_id > 0) {
                 $succ_node = $this->lm_tree->fetchSuccessorNode($page_id, 'pg');
                 $page_id = $succ_node['obj_id'];
                 $public = ilLMObject::_isPagePublic($page_id);
             }
         }
         // check whether page found is within "clicked" chapter
         if ($this->lm_tree->isInTree($page_id)) {
             $path = $this->lm_tree->getPathId($page_id);
             if (!in_array($_GET["obj_id"], $path)) {
                 $this->chapter_has_no_active_page = true;
             }
         }
     }
     $this->current_page_id = $page_id;
     return $page_id;
 }