Exemplo n.º 1
0
 /**
  * get visible tours for helpbar
  * 
  * @return array                  set of tours
  */
 public static function GetHelpbarTourData()
 {
     $visible_tours = array();
     $route = get_route();
     $tours = HelpTour::getToursByRoute($route);
     foreach ($tours as $index => $tour) {
         if ($tour->isVisible() and $tour->settings->access != 'link') {
             $visible_tours[$index] = $tour;
             if (($tour->settings->access == 'autostart' or $tour->settings->access == 'autostart_once') and !$GLOBALS['user']->cfg->TOUR_AUTOSTART_DISABLE) {
                 $user_visit = new HelpTourUser(array($tour->tour_id, $GLOBALS['user']->user_id));
                 if ($tour->settings->access == 'autostart_once' and $user_visit->isNew()) {
                     $active_tour_id = $tour->tour_id;
                     $active_tour_step_nr = 1;
                 } elseif ($tour->settings->access == 'autostart' and !$user_visit->completed) {
                     $active_tour_id = $tour->tour_id;
                     $active_tour_step_nr = 1;
                 }
             }
         }
     }
     //if there is an active tour, initialize it
     if ($_SESSION['active_tour']['tour_id'] and ($_SESSION['active_tour']['last_route'] == $route or $_SESSION['active_tour']['next_route'] == $route)) {
         $active_tour = new HelpTour($_SESSION['active_tour']['tour_id']);
         $step_nr = $_SESSION['active_tour']['step_nr'];
         if (!($_SESSION['active_tour']['last_route'] == $route) and $_SESSION['active_tour']['next_route'] == $route) {
             while ($_SESSION['active_tour']['last_route'] == $active_tour->steps[$step_nr - 1]->route) {
                 $step_nr++;
             }
         }
         if ($route == $active_tour->steps[$step_nr - 1]->route) {
             $_SESSION['active_tour']['step_nr'] = $step_nr;
             $active_tour_id = $_SESSION['active_tour']['tour_id'];
             $active_tour_step_nr = $step_nr;
         }
     }
     return array('tours' => $visible_tours, 'active_tour_id' => $active_tour_id, 'active_tour_step_nr' => $active_tour_step_nr);
 }