Blame view

php/classes/WSUserMgr.php 1.9 KB
16035364   Benjamin Renard   First commit
1
2
3
4
<?php
/**
 * @class WSUserMgr
 * @version $Id: WSUserMgr.php 2806 2015-03-02 15:31:05Z natacha $
b2c5ec48   Elena.Budnik   corrected Nath. v...
5
 * @brief WebServices User Manager
16035364   Benjamin Renard   First commit
6
7
 */

b2c5ec48   Elena.Budnik   corrected Nath. v...
8
9
class WSUserMgr extends UserMgr 
{
4111d47d   Nathanael Jourdane   use coding conven...
10
11
12
13
14
15
	protected $isSoap;

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

b2c5ec48   Elena.Budnik   corrected Nath. v...
16
17
	public function init($username, $password, $sessionID, $isSoap) 
	{
4111d47d   Nathanael Jourdane   use coding conven...
18
19
		$this->user = trim($username);
		$this->sessionID = trim($sessionID);
b2c5ec48   Elena.Budnik   corrected Nath. v...
20
		$this->passwd = trim($password);		
4111d47d   Nathanael Jourdane   use coding conven...
21

b2c5ec48   Elena.Budnik   corrected Nath. v...
22
		$this->isSoap = isset($isSoap);
4111d47d   Nathanael Jourdane   use coding conven...
23

b2c5ec48   Elena.Budnik   corrected Nath. v...
24
25
26
		// Check if user has DD session already open, otherwise - login
		if ($this->ddCheckUser() != 0) 
		{
4111d47d   Nathanael Jourdane   use coding conven...
27
			if ($this->ddLogin() != 0) { // DD Login if user is not registered
b2c5ec48   Elena.Budnik   corrected Nath. v...
28
29
				if ($this->isSoap) throw new SoapFault("error", "Login procedure failed");
				else return array("error" => "Login procedure failed");
4111d47d   Nathanael Jourdane   use coding conven...
30
31
			}

b2c5ec48   Elena.Budnik   corrected Nath. v...
32
33
34
35
			if ($this->ddCheckUser() != 0) 
			{
				if ($this->isSoap) throw new SoapFault("error", "CheckUser procedure failed");
				else return array("error" => "CheckUser procedure failed");
4111d47d   Nathanael Jourdane   use coding conven...
36
			}
e3a52676   Nathanael Jourdane   webservice fix: c...
37
		}
b2c5ec48   Elena.Budnik   corrected Nath. v...
38
39
40
41
42
		
		$this->userdir = USERPATH."/".$this->user."/";
		
		if (!is_dir($this->userdir)) 
		{
e3a52676   Nathanael Jourdane   webservice fix: c...
43
			if (!$this->createDir()) {
b2c5ec48   Elena.Budnik   corrected Nath. v...
44
45
				if ($this->isSoap) throw new SoapFault("error", "Cannot create UserDir");
				else return array("error" => "Cannot create UserDir"); 
e3a52676   Nathanael Jourdane   webservice fix: c...
46
			}
4111d47d   Nathanael Jourdane   use coding conven...
47
		}
b2c5ec48   Elena.Budnik   corrected Nath. v...
48
49
50
		
	//	$this->userWS = USERPATH . "/" . $this->user . "/WS/";
	//	chmod($this->userWS, 0775);
8077d2c5   Elena.Budnik   temporary commit ...
51
	//	$this->userMissions = $this->getAvailableMissionsByUser();
4111d47d   Nathanael Jourdane   use coding conven...
52

b2c5ec48   Elena.Budnik   corrected Nath. v...
53
54
		$this->setPath();
		
e3a52676   Nathanael Jourdane   webservice fix: c...
55
		return array('success' => true);
4111d47d   Nathanael Jourdane   use coding conven...
56
57
	}

b2c5ec48   Elena.Budnik   corrected Nath. v...
58
59
	public function makeUserWS() 
	{
8077d2c5   Elena.Budnik   temporary commit ...
60
61
62
63
64
		 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();
4111d47d   Nathanael Jourdane   use coding conven...
65
66
		$this->makeRemoteTree();

b2c5ec48   Elena.Budnik   corrected Nath. v...
67
		return $this->user;
4111d47d   Nathanael Jourdane   use coding conven...
68
69
	}
}
4111d47d   Nathanael Jourdane   use coding conven...
70
?>