Blame view

php/classes/WSUserMgr.php 1.6 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
	protected $isSoap;
b8502f4d   Elena.Budnik   getStatus(), thro...
11
12
13
14
15
16
17
18
19
	
	private function throwError($errorType, $msg)
	{
		if ($this->isSoap) 
			throw new SoapFault($errorType, $msg); 
		else 
			return array("error" => $msg);
	}
	
4111d47d   Nathanael Jourdane   use coding conven...
20
21
22
23
	/*****************************************************************
	 *                           PUBLIC FUNCTIONS
	 *****************************************************************/

b2c5ec48   Elena.Budnik   corrected Nath. v...
24
25
	public function init($username, $password, $sessionID, $isSoap) 
	{
4111d47d   Nathanael Jourdane   use coding conven...
26
27
		$this->user = trim($username);
		$this->sessionID = trim($sessionID);
b2c5ec48   Elena.Budnik   corrected Nath. v...
28
		$this->passwd = trim($password);		
4111d47d   Nathanael Jourdane   use coding conven...
29

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

b2c5ec48   Elena.Budnik   corrected Nath. v...
32
33
34
		// Check if user has DD session already open, otherwise - login
		if ($this->ddCheckUser() != 0) 
		{
4111d47d   Nathanael Jourdane   use coding conven...
35
			if ($this->ddLogin() != 0) { // DD Login if user is not registered
b8502f4d   Elena.Budnik   getStatus(), thro...
36
				$this->throwError("loginError", "Login procedure failed");
4111d47d   Nathanael Jourdane   use coding conven...
37
38
			}

b8502f4d   Elena.Budnik   getStatus(), thro...
39
40
			if ($this->ddCheckUser() != 0) {
				$this->throwError("loginError", "CheckUser procedure failed");
4111d47d   Nathanael Jourdane   use coding conven...
41
			}
e3a52676   Nathanael Jourdane   webservice fix: c...
42
		}
b2c5ec48   Elena.Budnik   corrected Nath. v...
43
44
45
46
47
		
		$this->userdir = USERPATH."/".$this->user."/";
		
		if (!is_dir($this->userdir)) 
		{
e3a52676   Nathanael Jourdane   webservice fix: c...
48
			if (!$this->createDir()) {
b8502f4d   Elena.Budnik   getStatus(), thro...
49
				$this->throwError("loginError", "Cannot create UserDir"); 
e3a52676   Nathanael Jourdane   webservice fix: c...
50
			}
4111d47d   Nathanael Jourdane   use coding conven...
51
		}
b2c5ec48   Elena.Budnik   corrected Nath. v...
52
53
54
		
	//	$this->userWS = USERPATH . "/" . $this->user . "/WS/";
	//	chmod($this->userWS, 0775);
8077d2c5   Elena.Budnik   temporary commit ...
55
	//	$this->userMissions = $this->getAvailableMissionsByUser();
4111d47d   Nathanael Jourdane   use coding conven...
56

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

b2c5ec48   Elena.Budnik   corrected Nath. v...
62
63
	public function makeUserWS() 
	{
b8502f4d   Elena.Budnik   getStatus(), thro...
64
		$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
?>