WSUserMgr.php 1.9 KB
<?php
/**
 * @class WSUserMgr
 * @version $Id: WSUserMgr.php 2806 2015-03-02 15:31:05Z natacha $
 * @brief WebServices User Manager
 */

class WSUserMgr extends UserMgr 
{
	protected $isSoap;

	/*****************************************************************
	 *                           PUBLIC FUNCTIONS
	 *****************************************************************/

	public function init($username, $password, $sessionID, $isSoap) 
	{
		$this->user = trim($username);
		$this->sessionID = trim($sessionID);
		$this->passwd = trim($password);		

		$this->isSoap = isset($isSoap);

		// Check if user has DD session already open, otherwise - login
		if ($this->ddCheckUser() != 0) 
		{
			if ($this->ddLogin() != 0) { // DD Login if user is not registered
				if ($this->isSoap) throw new SoapFault("error", "Login procedure failed");
				else return array("error" => "Login procedure failed");
			}

			if ($this->ddCheckUser() != 0) 
			{
				if ($this->isSoap) throw new SoapFault("error", "CheckUser procedure failed");
				else return array("error" => "CheckUser procedure failed");
			}
		}
		
		$this->userdir = USERPATH."/".$this->user."/";
		
		if (!is_dir($this->userdir)) 
		{
			if (!$this->createDir()) {
				if ($this->isSoap) throw new SoapFault("error", "Cannot create UserDir");
				else return array("error" => "Cannot create UserDir"); 
			}
		}
		
	//	$this->userWS = USERPATH . "/" . $this->user . "/WS/";
	//	chmod($this->userWS, 0775);
	//	$this->userMissions = $this->getAvailableMissionsByUser();

		$this->setPath();
		
		return array('success' => true);
	}

	public function makeUserWS() 
	{
		 if (file_exists(USERWSDIR.'LocalParams.xml'))
			unlink(USERWSDIR.'LocalParams.xml');      
		// if (!file_exists(USERWSDIR.'LocalParams.xml'))
		symlink(DATAPATH.'/LocalData/LocalParams.xml', USERWSDIR.'LocalParams.xml');
		// $this->makeLocalTree();
		$this->makeRemoteTree();

		return $this->user;
	}
}
?>