Blame view

php/WebServices/WSUserMgr.php 1.51 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
	
	private function throwError($errorType, $msg)
	{
		if ($this->isSoap) 
			throw new SoapFault($errorType, $msg); 
		else 
a9cf38ab   Elena.Budnik   return error for ...
17
			exit(json_encode(array("error" => $msg)));
b8502f4d   Elena.Budnik   getStatus(), thro...
18
	}
4111d47d   Nathanael Jourdane   use coding conven...
19

1ba8d04c   Elena.Budnik   time tables list,...
20
	public function init($username, $password, $sessionID, $setPathOnly, $isSoap) 
b2c5ec48   Elena.Budnik   corrected Nath. v...
21
	{
4111d47d   Nathanael Jourdane   use coding conven...
22
		$this->user = trim($username);
1ba8d04c   Elena.Budnik   time tables list,...
23
24
25
26
		if (isset($sessionID))
			$this->sessionID = trim($sessionID);
		if (isset($password))
			$this->passwd = trim($password);		
4111d47d   Nathanael Jourdane   use coding conven...
27

2b27251b   Elena.Budnik   isSoap is always set
28
29
		$this->isSoap = $isSoap;
	
1ba8d04c   Elena.Budnik   time tables list,...
30
		if (isset($password) && ! $setPathOnly)
b2c5ec48   Elena.Budnik   corrected Nath. v...
31
		{
1ba8d04c   Elena.Budnik   time tables list,...
32
33
34
35
			// 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
2b27251b   Elena.Budnik   isSoap is always set
36
					$this->throwError("loginError", "Login procedure failed for $username : Check your password");
1ba8d04c   Elena.Budnik   time tables list,...
37
				}
4111d47d   Nathanael Jourdane   use coding conven...
38

1ba8d04c   Elena.Budnik   time tables list,...
39
				if ($this->ddCheckUser() != 0) {
2b27251b   Elena.Budnik   isSoap is always set
40
					$this->throwError("loginError", "CheckUser procedure failed for $username : Check your password");
1ba8d04c   Elena.Budnik   time tables list,...
41
				}
4111d47d   Nathanael Jourdane   use coding conven...
42
			}
e3a52676   Nathanael Jourdane   webservice fix: c...
43
		}
b2c5ec48   Elena.Budnik   corrected Nath. v...
44
45
46
47
48
		
		$this->userdir = USERPATH."/".$this->user."/";
		
		if (!is_dir($this->userdir)) 
		{
e3a52676   Nathanael Jourdane   webservice fix: c...
49
			if (!$this->createDir()) {
b8502f4d   Elena.Budnik   getStatus(), thro...
50
				$this->throwError("loginError", "Cannot create UserDir"); 
e3a52676   Nathanael Jourdane   webservice fix: c...
51
			}
4111d47d   Nathanael Jourdane   use coding conven...
52
		}
4111d47d   Nathanael Jourdane   use coding conven...
53

b2c5ec48   Elena.Budnik   corrected Nath. v...
54
		$this->setPath();
1ba8d04c   Elena.Budnik   time tables list,...
55
56
57
		if ( $setPathOnly )
			return array('success' => true);
			
b64d304e   Elena.Budnik   implement groups ...
58
		$this->userGrps = $this->getUserGrps();	
b8502f4d   Elena.Budnik   getStatus(), thro...
59
		$this->makeLocalTree();
4111d47d   Nathanael Jourdane   use coding conven...
60
61
		$this->makeRemoteTree();

1ba8d04c   Elena.Budnik   time tables list,...
62
		return array('success' => true);
4111d47d   Nathanael Jourdane   use coding conven...
63
64
	}
}
4111d47d   Nathanael Jourdane   use coding conven...
65
?>