WSUserMgr.php
1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?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;
private function throwError($errorType, $msg)
{
if ($this->isSoap)
throw new SoapFault($errorType, $msg);
else
return array("error" => $msg);
}
public function init($username, $password, $sessionID, $setPathOnly, $isSoap)
{
$this->user = trim($username);
if (isset($sessionID))
$this->sessionID = trim($sessionID);
if (isset($password))
$this->passwd = trim($password);
$this->isSoap = isset($isSoap);
if (isset($password) && ! $setPathOnly)
{
// 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
$this->throwError("loginError", "Login procedure failed");
}
if ($this->ddCheckUser() != 0) {
$this->throwError("loginError", "CheckUser procedure failed");
}
}
}
$this->userdir = USERPATH."/".$this->user."/";
if (!is_dir($this->userdir))
{
if (!$this->createDir()) {
$this->throwError("loginError", "Cannot create UserDir");
}
}
$this->setPath();
if ( $setPathOnly )
return array('success' => true);
$this->makeLocalTree();
$this->makeRemoteTree();
return array('success' => true);
}
}
?>