示例#1
0
     break;
 case 'return_to_course_homepage':
     if (!$lp_found) {
         error_log('New LP - No learnpath given for stats', 0);
         require 'lp_list.php';
     } else {
         $_SESSION['oLP']->save_current();
         $_SESSION['oLP']->save_last();
         //declare variables to be used in lp_stats.php
         $lp_id = $_SESSION['oLP']->get_id();
         $list = $_SESSION['oLP']->get_flat_ordered_items_list($lp_id);
         $user_id = api_get_user_id();
         $stats_charset = $_SESSION['oLP']->encoding;
         // Delete Lp session
         api_session_unregister('oLP');
         api_session_unregister('lpobject');
         header('location:' . api_get_path(WEB_COURSE_PATH) . api_get_course_path() . '/index.php');
     }
     break;
 case 'search':
     /* Include the search script, it's smart enough to know when we are
      * searching or not
      */
     require 'lp_list_search.php';
     break;
 case 'course':
     /* Include the search script, it's smart enough to know when we are
      * searching or not
      */
     require 'lp_list_course.php';
     break;
                     $res = api_sql_query($sql_cloud_get_course, __FILE__, __LINE__);
                     if (Database::num_rows($res) > 0) {
                         $row = Database::fetch_array($res);
                         $cloud_courseId = $row['cloud_course_id'];
                     }
                     //echo $cloud_courseId.'<br/>';
                     cloud_deleteCourse($cloud_courseId);
                 }
             }
         }
         //////////////
         $_SESSION['refresh'] = 1;
         //remove lp from homepage if it is there
         $_SESSION['oLP']->toggle_visibility((int) $_GET['lp_id'], 'i');
         $_SESSION['oLP']->delete(null, (int) $_GET['lp_id'], 'remove');
         api_session_unregister('oLP');
         require 'lp_list.php';
     }
     break;
 case 'toggle_visible':
     //change lp visibility (inside lp tool)
     if (!api_is_allowed_to_edit()) {
         api_not_allowed(true);
     }
     if ($debug > 0) {
         error_log('New LP - visibility action triggered', 0);
     }
     if (!$lp_found) {
         error_log('New LP - No learnpath given for visibility', 0);
         require 'lp_list.php';
     } else {
/**
 * Render HTML Code to display top header of the Author tool (copy of renderCourseHeader function)
 * This function is called in /main/inc/tool_header.inc.php
 * @param string - title of current page
 * @return string - HTML code
 *
 */
function display_author_header()
{
    global $_course, $charset;
    // Check if the Lp object exists
    if (isset($_SESSION['lpobject'])) {
        if ($debug > 0) {
            error_log('New LP - SESSION[lpobject] is defined', 0);
        }
        $oLP = unserialize($_SESSION['lpobject']);
        if (is_object($oLP)) {
            if ($debug > 0) {
                error_log('New LP - oLP is object', 0);
            }
            if ($myrefresh == 1 or empty($oLP->cc) or $oLP->cc != api_get_course_id()) {
                if ($debug > 0) {
                    error_log('New LP - Course has changed, discard lp object', 0);
                }
                if ($myrefresh == 1) {
                    $myrefresh_id = $oLP->get_id();
                }
                $oLP = null;
                api_session_unregister('oLP');
                api_session_unregister('lpobject');
            } else {
                $_SESSION['oLP'] = $oLP;
                $lp_found = true;
            }
        }
    }
    // Get tocs from learnpath and convert for re-using in toggle menu
    $currentId = $_SESSION['oLP']->current;
    // Get menu items
    $menuItems = getMenuItemsFromToc($_SESSION['oLP']->get_toc(), $currentId);
    $title = api_convert_encoding($_SESSION['oLP']->get_name(), $charset, api_get_system_encoding());
    // Html header for the Author tool
    $html = "<div id='left'>" . "<a id=\"back2home\" class='course_main_home_button' width='42px' height='37px' href=" . api_get_path(WEB_COURSE_PATH) . $_course['path'] . '/index.php' . ">";
    $html .= '<img src="' . api_get_path(WEB_IMG_PATH) . 'spacer.gif" width="42px" height="37px" target="_self" onclick="window.parent.API.save_asset();" alt="' . $altHome . '" title="' . $altHome . '" />';
    $html .= '</a><div style="padding-top: 5px; padding-left: 53px;">' . renderCourseToggleMenu($menuItems) . "</div></div>";
    $html .= "<div id='courseTitle'>" . "<div class='container'>" . $title . "</div></div>" . "<div id='bg_end_title'></div>" . "";
    $altHome = api_convert_encoding(get_lang('CourseHomepageLink'), $charset, api_get_system_encoding());
    $arrows = "";
    // no navigation buttons if only one page
    $lp_count = $_SESSION['oLP']->get_total_learning_path_count();
    if ($lp_count >= 1) {
        $lp_id = Security::remove_XSS($_GET['lp_id']);
        // Get the previous and next Lp ID
        $lp_info = $_SESSION['oLP']->get_previous_and_next_lp($lp_id);
        $lp_previous = $lp_info['previous'];
        // Previous Lp ID
        $lp_next = $lp_info['next'];
        // Next Lp ID
        $controller = api_get_path(WEB_PATH) . 'main/newscorm/lp_controller.php';
        // Arrows
        $arrows = '<a class="prev_button" href="' . $controller . '?' . api_get_cidreq() . '&action=add_item&type=step&lp_id=' . $lp_previous . '">' . '<img id="coursepreviousbutton" src="../img/spacer.gif" class="button" title="' . get_lang('Previous') . '" /></a>' . '<a class="next_button" href="' . $controller . '?' . api_get_cidreq() . '&action=add_item&type=step&lp_id=' . $lp_next . '">' . '<img id="coursenextbutton" src="../img/spacer.gif" class="button" title="' . get_lang('Next') . '"/>' . '</a>';
    }
    //if($_REQUEST['action'] != "add_item" || $_REQUEST['type'] != "step")
    if ($_REQUEST['action'] == 'view') {
        $html .= "<div id='right'>" . $arrows . "</div>";
    }
    return $html;
}