<?php
/*************************************************************************/
/* SPAGHETTILEARNING - E-Learning System                                 */
/* ============================================                          */
/*                                                                       */
/* Copyright (c) 2004 by Emanuele Sandri (esandri@tiscali.it)  			 */
/*																		 */
/* This program is free software. You can redistribute it and/or modify  */
/* it under the terms of the GNU General Public License as published by  */
/* the Free Software Foundation; either version 2 of the License.        */
/*************************************************************************/

if(isset($_REQUEST['GLOBALS'])) die('GLOBALS overwrite attempt detected');
if(!defined("IN_DOCEBO")) define("IN_DOCEBO", true);

/**
 * 
 * @module soapserver.php
 * @version $Id: soaplms.php 469 2006-07-21 09:33:46Z fabio $
 * @copyright 2004
 */

require_once(dirname(__FILE__) . '/../../config.php' );
require($GLOBALS['where_config'].'/config.php');
$GLOBALS['dbConn'] = mysql_connect($GLOBALS['dbhost'], $GLOBALS['dbuname'], $GLOBALS['dbpass']);
if( !$GLOBALS['dbConn'] ) 
	die( "Can't connect to db. Check configurations" );

if( !mysql_select_db($GLOBALS['dbname'], $GLOBALS['dbConn']) ) 
	die( "Database not found. Check configurations" );

@mysql_query("SET NAMES '".$GLOBALS['db_conn_names']."'", $GLOBALS['dbConn']);
@mysql_query("SET CHARACTER SET '".$GLOBALS['db_conn_char_set']."'", $GLOBALS['dbConn']);

require_once($GLOBALS['where_framework'].'/setting.php');
require_once($GLOBALS['where_lms'].'/setting.php');

// activate debug if needed
if($GLOBALS['framework']['do_debug'] == 'on') {
	@error_reporting(E_ALL);
	@ini_set('display_errors', 1);
} else {
	@error_reporting(E_COMPILE_ERROR|E_ERROR|E_CORE_ERROR);
}

//cookie lifetime
session_set_cookie_params( 0 );
//session lifetime ( max inactivity time )
ini_set('session.gc_maxlifetime', $GLOBALS['lms']['ttlSession']);

session_name("docebo_session");
session_start();

// load regional setting
require_once($GLOBALS['where_framework']."/lib/lib.regset.php");
$GLOBALS['regset'] = new RegionalSettings();

// load current user from session
require_once($GLOBALS['where_framework'].'/lib/lib.user.php');
$GLOBALS['current_user'] =& DoceboUser::createDoceboUserFromSession('public_area');
													
$prefix = $GLOBALS['prefix_lms'];

//$GLOBALS['current_user']->loadUserSectionST('/lms/course/public/');

// Utils and so on
require_once($GLOBALS['where_lms'].'/lib/lib.php');

// create instance of StdPageWriter
require_once($GLOBALS['where_framework'].'/lib/lib.pagewriter.php');
StdPageWriter::createInstance();

// load standard language module and put it global
$glang =& DoceboLanguage::createInstance( 'standard', 'framework');
$glang->setGlobal();


require_once($GLOBALS['where_lms'].'/lib/lib.preoperation.php');



require_once(dirname(__FILE__) . '/scorm_tracking.php');
require_once(dirname(__FILE__) . '/scorm_items.php');
require_once(dirname(__FILE__) . '/config.scorm.php');
require_once(dirname(__FILE__) . '/scorm_items_track.php');
require_once($GLOBALS['where_framework'] . '/addons/soap/SOAP/Server.php');

/**
 * SOAPLMS
 * 
 * @package SCORM
 * @author ema Emanuele Sandri
 * @copyright Copyright (c) 2004
 * @version $Id: soaplms.php 469 2006-07-21 09:33:46Z fabio $
 * @access public
 **/
class SOAPLMS {
	var $__dispatch_map = array(); 

	// Required function by SOAP_Server
	function __dispatch($methodname)
	{
		soap__dbgOut($methodname);
		if (isset($this->__dispatch_map[$methodname]))
			return $this->__dispatch_map[$methodname];
		return null;
	} 
	// Constructor builds PEAR::SOAP Server
	function SOAPLMS ()
	{ 
		// Define the signature of the dispatch map
		$this->__dispatch_map['Finish'] =
		array(	'in' => array( 	'idUser' => 'string',
								'idReference' => 'string',
								'idscorm_item' => 'string'
								),
				'out' => array(	'status' => 'string',
								'error' => 'string',
								'errorString' => 'string')
			);
		$this->__dispatch_map['GetValue'] =
		array(	'in' => array( 	'idUser' => 'string',
								'idReference' => 'string',
								'idscorm_item' => 'string',
								'param' => 'string'),
				'out' => array(	'status' => 'string',
								'error' => 'string',
								'errorString' => 'string',
								'value' => 'string')
			);
		$this->__dispatch_map['SetValue'] =
		array(	'in' => array( 	'idUser' => 'string',
								'idReference' => 'string',
								'idscorm_item' => 'string',
								'param' => 'string',
								'value' => 'string'
								),
				'out' => array(	'status' => 'string',
								'error' => 'string',
								'errorString' => 'string'
								)
			);
	} 
	
	function Initialize( $idUser, $idReference, $idscorm_item ) {
		soap__dbgOut("+Initialize($idUser, $idReference, $idscorm_item )");

		$dbconn = $GLOBALS['dbConn'];
		
		$itemtrack = new Scorm_ItemsTrack($dbconn, $GLOBALS['prefix_lms']);
		$rs = $itemtrack->getItemTrack( $idUser, $idReference, $idscorm_item );
		
		$arrItemTrackData = mysql_fetch_assoc( $rs );
		
		$trackobj = new Scorm_Tracking( NULL, NULL, $arrItemTrackData['idscorm_tracking'], NULL, $dbconn, FALSE, FALSE );
		if( $trackobj->getErrorCode() != 0 ) {
			soap__dbgOut("Finish error: ". $trackobj->getErrorText());
		}
		
		$xmldoc =& $trackobj->getXmlDoc();

		soap__dbgOut("-Initialize($idUser, $idReference, $idscorm_item )");
		return $xmldoc->dump_mem(true);
		
	}
	
	function Finish( $idUser, $idReference, $idscorm_item ) {
		soap__dbgOut("+Finish($idUser, $idReference, $idscorm_item )");
		
		$status = "success";
		$error = "";
		$errorString = "";
		$lesson_status = "";
		
		$dbconn = $GLOBALS['dbConn'];
			
		$itemtrack = new Scorm_ItemsTrack($dbconn, $GLOBALS['prefix_lms']);
		$rs = $itemtrack->getItemTrack( $idUser, $idReference, $idscorm_item );
		
		$arrItemTrackData = mysql_fetch_assoc( $rs );
		
		soap__dbgOut("before: Scorm_Tracking( NULL, NULL, {$arrItemTrackData['idscorm_tracking']}, NULL, $dbconn, FALSE, FALSE );");
		$trackobj = new Scorm_Tracking( NULL, NULL, $arrItemTrackData['idscorm_tracking'], NULL, $dbconn, FALSE, FALSE );
		if( $trackobj->getErrorCode() != 0 ) {
			soap__dbgOut("Finish error: ". $trackobj->getErrorText());
		}
		soap__dbgOut("Finish: evaluate cmi.core.lesson_status");
		if( $trackobj->getParam('cmi.core.credit', false) == 'credit' ) {
			$itemobj = new Scorm_Item( NULL, FALSE, NULL, $dbconn, false, $arrItemTrackData['idscorm_item'] );
			if( $itemobj ) {
				if( strlen($itemobj->adlcp_masteryscore) > 0 ) {
					if( $trackobj->getParam('cmi.core.score.raw', false) >= $itemobj->adlcp_masteryscore ) {
						$trackobj->setParam('cmi.core.lesson_status', 'passed', false, true);
						$trackobj->setParam('cmi.core.credit', 'no-credit', false, true);
						$lesson_status = 'passed';
						soap__dbgOut("Finish: set cmi.core.lesson_status=passed");
					} else if( $trackobj->getParam('cmi.core.lesson_status', false) != 'passed') {
						$trackobj->setParam('cmi.core.lesson_status', 'failed', false, true);
						$lesson_status = 'failed';
						soap__dbgOut("Finish: set cmi.core.lesson_status=failed");
					} else {
						$trackobj->setParam('cmi.core.credit', 'no-credit', false, true);	
						$lesson_status = 'passed';
					}
				} else {
					$lesson_status =  $trackobj->getParam('cmi.core.lesson_status', false);
					if( $lesson_status == 'passed' || $lesson_status == 'completed' )
						$trackobj->setParam('cmi.core.credit', 'no-credit', false, true);							
				}
			}
			$itemtrack->setStatus($idUser, $idReference, $idscorm_item, $lesson_status );
		}
		
		soap__dbgOut("Finish: evaluate cmi.core.entry");
		if( $trackobj->getParam('cmi.core.exit', false) == "suspend" ) {
			$trackobj->setParam('cmi.core.entry', 'resume', false, true);
		} else {
			$trackobj->setParam('cmi.core.entry', '', false, true);
		}

		soap__dbgOut("Finish: evaluate cmi.core.total_time");
		$sessTime = $trackobj->getParam('cmi.core.session_time', false);
		$totTime = $trackobj->getParam('cmi.core.total_time', false);
		if( strlen($sessTime) > 0 ) {
			$totTime = sumScormTime($sessTime,$totTime);
			$trackobj->setParam('cmi.core.total_time', $totTime, false, true);
		}
			
		soap__dbgOut("Finish return status = $status");
		return $this->makeResponse($status,$error,$errorString );
	}
	
	function makeResponse( $status, $error, $errorString ) {
		return '<?xml version="1.0" encoding="ISO-8859-1" ?>'
			.'<response>'
				.'<status>'.$status.'</status>'
				.'<error>'.$error.'</error>'
				.'<errorString>'.htmlentities($errorString).'</errorString>'
			.'</response>';
	}
	
	function GetValue( $idUser, $idReference, $idscorm_item, $param) {
		//echo "<!-- SOAPLMS::GetValue( $userid, $scoid, $scormpackage, $param ) -->\n";
		soap__dbgOut("+GetValue( $idUser, $idReference, $idscorm_item, $param)");
		$dbconn = $GLOBALS['dbConn'];

		// get item_track
		$itemtrack = new Scorm_ItemsTrack($dbconn, $GLOBALS['prefix_lms']);
		$rs = $itemtrack->getItemTrack( $idUser, $idReference, $idscorm_item );
		
		$arrItemTrackData = mysql_fetch_assoc( $rs );
		
		// get tracking
		soap__dbgOut("before: Scorm_Tracking(NULL, NULL, {$arrItemTrackData['idscorm_tracking']}, NULL, $dbconn, FALSE, FALSE);");
		$trackobj = new Scorm_Tracking(NULL, NULL, $arrItemTrackData['idscorm_tracking'], NULL, $dbconn, FALSE, FALSE);
		soap__dbgOut("after: Scorm_Tracking(NULL, NULL, {$arrItemTrackData['idscorm_tracking']}, NULL, $dbconn, FALSE, FALSE);");
		
		if( $trackobj->getErrorCode() != 0 ) {
			soap__dbgOut("Scorm_Tracking error: ". $trackobj->getErrorText());
		}
		
		if (($value = $trackobj->getParam($param)) === false) {
			soap__dbgOut("Scorm_Tracking getParam($param) return false");
			soap__dbgOut("Scorm_Tracking error: ". $trackobj->getErrorCode() ."\n".$trackobj->getErrorText());
			$status = "error";
			$error = $trackobj->getErrorCode();
			$errorString = $trackobj->getErrorText();
		} else {
			soap__dbgOut("Scorm_Tracking getParam($param) return $value");
			$status = "success";
			$error = "";
			$errorString = "";
		} 
		$arr_result = array(new SOAP_Value('status', 'string', $status),
			new SOAP_Value('error', 'string', $error),
			new SOAP_Value('errorString', 'string', $errorString),
			new SOAP_Value('value', 'string', $value)
			);
		//soap__dbgOut($arr_result);
        soap__dbgOut("-GetValue return status = $status, value = $value");
		return $arr_result;
	} 

	function SetValuesFromXML(  $idUser, $idReference, $idscorm_item, $xmldoc) {
        soap__dbgOut("+SetValuesFromXML( $idUser, $idReference, $idscorm_item, $xmldoc)");
		$dbconn = $GLOBALS['dbConn'];
		
		// get item_track
		$itemtrack = new Scorm_ItemsTrack($dbconn, $GLOBALS['prefix_lms']);
		$rs = $itemtrack->getItemTrack( $idUser, $idReference, $idscorm_item );
		
		$arrItemTrackData = mysql_fetch_assoc( $rs );

		// get tracking
		$trackobj = new Scorm_Tracking(NULL, NULL, $arrItemTrackData['idscorm_tracking'], NULL, $dbconn, FALSE, FALSE);

		if( $trackobj->setParamXML($xmldoc) === false ) {
		    soap__dbgOut("Scorm_Tracking setParamXML($xmldoc) return false");
			soap__dbgOut("Scorm_Tracking error: ". $trackobj->getErrorCode() ."\n".$trackobj->getErrorText());
		    $status = "error";
			$error = $trackobj->getErrorCode();
			$errorString = $trackobj->getErrorText();			
		} else {
			soap__dbgOut("Scorm_Tracking setParam($param, $value) return true");
			$status = "success";
			$error = "";
			$errorString = "";			
		}
		
		//$arr_result = array('status' => $status, 'error' => $error, 'errorString' => $errorString );
		
		soap__dbgOut("-SetValuesFromXML return $status");
		return $this->makeResponse( $status, $error, $errorString );
	} 
	
	function SetValue(  $idUser, $idReference, $idscorm_item, $param, $value)
	{
        soap__dbgOut("+SetValue( $idUser, $idReference, $idscorm_item, $param, $value)");
		$dbconn = $GLOBALS['dbConn'];
		
		// get item_track
		$itemtrack = new Scorm_ItemsTrack($dbconn, $GLOBALS['prefix_lms']);
		$rs = $itemtrack->getItemTrack( $idUser, $idReference, $idscorm_item );
		
		$arrItemTrackData = mysql_fetch_assoc( $rs );

		// get tracking
		soap__dbgOut("before: Scorm_Tracking(NULL, NULL, {$arrItemTrackData['idscorm_tracking']}, NULL, $dbconn, FALSE, FALSE);");
		$trackobj = new Scorm_Tracking(NULL, NULL, $arrItemTrackData['idscorm_tracking'], NULL, $dbconn, FALSE, FALSE);
		soap__dbgOut("after: Scorm_Tracking(NULL, NULL, {$arrItemTrackData['idscorm_tracking']}, NULL, $dbconn, FALSE, FALSE);");

		if (($trackobj->setParam($param, $value)) === false) {
		    soap__dbgOut("Scorm_Tracking setParam($param, $value) return false");
			soap__dbgOut("Scorm_Tracking error: ". $trackobj->getErrorCode() ."\n".$trackobj->getErrorText());
		    $status = "error";
			$error = $trackobj->getErrorCode();
			$errorString = $trackobj->getErrorText();
		} else {
			soap__dbgOut("Scorm_Tracking setParam($param, $value) return true");
			$status = "success";
			$error = "";
			$errorString = "";
		} 
		$arr_result = array(new SOAP_Value('status', 'string', $status),
			new SOAP_Value('error', 'string', $error),
			new SOAP_Value('errorString', 'string', $errorString)
			);
       soap__dbgOut("-SetValue return $status");
       return $arr_result;
	} 
} 

function err_handler($errno, $errstr, $errfile, $errline) {
	$fout = fopen("/tmp/soaperror.txt", "a");
	fwrite($fout, "error number ".$errno."\n: ".$errstr."\n file: ".$errfile."\n line: ".$errline."\n");
	fclose($fout);
	return;
}

$lms = new SOAPLMS;
// Switch off notices to all GET

// Instantiate PEAR::SOAP SOAP_Server
$soapServer = new SOAP_Server;
// Build the object map (using this instance) + add a namespace
$soapServer->addObjectMap($lms, 'urn:SOAPLMS');

soap__dbgOut("+Arequest");
if( (isset($_GET['op']) && $_GET['op'] == 'Finish') ) {
	// load xml document
	$xmlRequest = domxml_open_mem( $GLOBALS['HTTP_RAW_POST_DATA'] );
	$rootRequest = $xmlRequest->document_element();
	// get idUser from xml document
	$node_array = $rootRequest->get_elements_by_tagname('idUser');
	$idUser = $node_array[0]->get_content();
	// get idReference from xml document
	$node_array = $rootRequest->get_elements_by_tagname('idReference');
	$idReference = $node_array[0]->get_content();
	// get idscorm_item from xml document
	$node_array = $rootRequest->get_elements_by_tagname('idscorm_item');
	$idscorm_item = $node_array[0]->get_content();
	
	// remove the "remove" tag
	$node_array = $rootRequest->get_elements_by_tagname('remove');
	$node_parent = $node_array[0]->parent_node();
	$node_parent->remove_child($node_array[0]);
	
	header( 'Content-type: text/xml' );
	// set parameters
	$lms->SetValuesFromXML( $idUser, $idReference, $idscorm_item, $xmlRequest );
	
	// call to finish
	echo $lms->Finish( $idUser, $idReference, $idscorm_item );
} else if( (isset($_GET['op']) && $_GET['op'] == 'Commit') ) {
	// load xml document
	$xmlRequest = domxml_open_mem( $GLOBALS['HTTP_RAW_POST_DATA'] );
	$rootRequest = $xmlRequest->document_element();
	// get idUser from xml document
	$node_array = $rootRequest->get_elements_by_tagname('idUser');
	$idUser = $node_array[0]->get_content();
	// get idReference from xml document
	$node_array = $rootRequest->get_elements_by_tagname('idReference');
	$idReference = $node_array[0]->get_content();
	// get idscorm_item from xml document
	$node_array = $rootRequest->get_elements_by_tagname('idscorm_item');
	$idscorm_item = $node_array[0]->get_content();
	// remove the "remove" tag
	$node_array = $rootRequest->get_elements_by_tagname('remove');
	$node_parent = $node_array[0]->parent_node();
	$node_parent->remove_child($node_array[0]);
	
	header( 'Content-type: text/xml' );
	// set parameters
	echo $lms->SetValuesFromXML( $idUser, $idReference, $idscorm_item, $xmlRequest );
} else if( (isset($_GET['op']) && $_GET['op'] == 'Initialize') ) {
	$xmlRequest = domxml_open_mem( $GLOBALS['HTTP_RAW_POST_DATA'] );
	$rootRequest = $xmlRequest->document_element();
	$node_array = $rootRequest->get_elements_by_tagname('idUser');
	$idUser = $node_array[0]->get_content();
	$node_array = $rootRequest->get_elements_by_tagname('idReference');
	$idReference = $node_array[0]->get_content();
	$node_array = $rootRequest->get_elements_by_tagname('idscorm_item');
	$idscorm_item = $node_array[0]->get_content();
	header( 'Content-type: text/xml' );
	echo $lms->Initialize( $idUser, $idReference, $idscorm_item );
} else if ( (isset($_GET['op']) && $_GET['op'] == 'scolms') 
  || (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == 'POST')) {
	soap__dbgOut("+Soap server");
	$soapServer->service($GLOBALS['HTTP_RAW_POST_DATA']);
	if( $soapServer->__isfault() ) {
		soap__dbgOut(" Soap fault: ".$soapServer->__getfault() );
	} else {
		soap__dbgOut(" Soap no fault");
	}
	soap__dbgOut("-Soap server");
} else if (isset($_GET['op']) && $_GET['op'] == 'scoload') {
	/* Load sco!
	// called to load sco with
	// $_GET parameters are
		idReference
		idUser
		idscorm_resource
		idscorm_item
		idscorm_organization
		idscorm_package
	*/
	soap__dbgOut("+Sco launcher: 	idReference = ".$_GET['idReference']
								.", idUser = ".$_GET['idUser']
								.", idscorm_resource = ".$_GET['idscorm_resource']
								.", idscorm_item = ".$_GET['idscorm_item']
								.", idscorm_organization = ".$_GET['idscorm_organization']
								.", idscorm_package = ".$_GET['idscorm_package'] );

	/* ####security team#### */
	if( !(	is_numeric ( $_GET['idReference'] ) && is_numeric ( $_GET['idUser'] ) 
		&&	is_numeric ( $_GET['idscorm_resource'] ) && is_numeric ( $_GET['idscorm_item'] )
		&&	is_numeric ( $_GET['idscorm_organization'] ) && is_numeric ( $_GET['idscorm_package'] ) ) )
	{
		die( "Malformed input scoload" );
		echo "idReference = ".$_GET['idReference']
								.", idUser = ".$_GET['idUser']
								.", idscorm_resource = ".$_GET['idscorm_resource']
								.", idscorm_item = ".$_GET['idscorm_item']
								.", idscorm_organization = ".$_GET['idscorm_organization']
								.", idscorm_package = ".$_GET['idscorm_package'];
	}
	$dbconn = $GLOBALS['dbConn'];
/*
	query for tracking record based on 
	- userid: identifier of user
	- scoid: identifier of sco from imsmanifest
	- idscormpackage: identifier of content package from imsmanifest
	
	 
	 
	- userid: identifier of user
	- scoid: identifier of resource in db
 	- idscormpackage: identifier of content package from imsmanifest
 */	
 	/**
	 * we need 
	 * path to find base of content package 	
	 * href to find relative resource			
	 * scormtype to know how manage resource	
	 * idscorm_tracking to initialize fields  	
	 **/
	 
	$query = "SELECT path, href, scormtype"
			." FROM ".$GLOBALS['prefix_lms']."_scorm_resources, ".$GLOBALS['prefix_lms']."_scorm_package"
			." WHERE ".$GLOBALS['prefix_lms']."_scorm_resources.idscorm_package = ".$GLOBALS['prefix_lms']."_scorm_package.idscorm_package"
			."   AND idscorm_resource = '".$_GET['idscorm_resource']."'";
	$result = mysql_query($query)
				or die( "Error on load sco: ". mysql_error() . "[ $query ]");
	list($path, $href, $scormtype) = mysql_fetch_array($result);
	
	// get item_track
	$itemtrack = new Scorm_ItemsTrack($dbconn, $GLOBALS['prefix_lms']);
	$rs = $itemtrack->getItemTrack( $_GET['idUser'], $_GET['idReference'], $_GET['idscorm_item']);
	
	$arrItemTrackData = mysql_fetch_assoc( $rs );
	
	if( $arrItemTrackData['idscorm_tracking'] === NULL ) {
		// The record don't exist => create a new one
		
		$trackobj = new Scorm_Tracking($_GET['idUser'],  $_GET['idReference'], $_GET['idscorm_item'], $_GET['idscorm_package'], $dbconn, true, true);
		if( $trackobj->getErrorCode() != 0) {
			die( "record don't exist then try to create but error:". $trackobj->getErrorText() );
		}
		list($adlcp_masteryscore,$adlcp_maxtimeallowed,$adlcp_timelimitaction ) = 
			mysql_fetch_row(mysql_query( "SELECT adlcp_masteryscore,adlcp_maxtimeallowed,adlcp_timelimitaction"
										." FROM learning_scorm_items"
										." WHERE idscorm_item=".$_GET['idscorm_item'] ));
		// tracking initializations
		if( $scormtype == 'sco' ) 
			$trackobj->setParam('cmi.core.lesson_status', 'not attempted', false, true);
		else
			$trackobj->setParam('cmi.core.lesson_status', 'completed', false, true);
			
		if( $trackobj->getErrorCode() != 0) {
			die( "setParam error:". $trackobj->getErrorText() );
		}
		// -- already set by precompileXmlDoc in ScormTraking object
		// $trackobj->setParam('cmi.core.student_id', $sal_getUserId(), false, true);
		$trackobj->setParam('cmi.core.student_name', $sal_getUserName(), false, true);
		$trackobj->setParam('cmi.core.credit', 'credit', false, true);
		$trackobj->setParam('cmi.core.lesson_mode', 'normal', false, true);
		$trackobj->setParam('cmi.core.entry', 'ab-initio', false, true);
		$trackobj->setParam('cmi.core.total_time', '0000:00:00.00', false, true);
		$trackobj->setParam('cmi.student_data.mastery_score', $adlcp_masteryscore, false, true);
		$trackobj->setParam('cmi.student_data.max_time_allowed', $adlcp_maxtimeallowed, false, true);
		$trackobj->setParam('cmi.student_data.time_limit_action', $adlcp_timelimitaction, false, true);

		$itemtrack->setTracking($arrItemTrackData['idscorm_item_track'],$trackobj->idtrack);
		if( $scormtype == 'asset' )
			$itemtrack->setStatus($_GET['idUser'], $_GET['idReference'], $_GET['idscorm_item'], 'completed' );
	}
	$scopath = str_replace ( '\\', '/', $GLOBALS['where_files_relative'].'/doceboLms/'.$GLOBALS['lms']['pathscorm']);
	
	//echo $GLOBALS['lms']['url'].$scopath.$path."/".$href;
	//echo "\nscopath = $scopath\n";
	//print_r( $GLOBALS['lms'] );
	//exit;	
	jumpTo( $scopath.$path."/".$href);
} else {
	// Deal with WSDL / Disco here
	require_once(dirname(__FILE__) . '/../../addons/soap/SOAP/Disco.php');
	// Create the Disco server
	$disco = new SOAP_DISCO_Server($soapServer, 'SOAPLMS');
	header("Content-type: text/xml");
	if (isset($_SERVER['QUERY_STRING']) &&
			strcasecmp($_SERVER['QUERY_STRING'], 'wsdl') == 0) {
		echo $disco->getWSDL(); // if we're talking http://www.example.com/index.php?wsdl
	} else {
		echo $disco->getDISCO();
	} 
	exit;
} 

?>
