Commit ca35ee3d6f5337bc9e0cc2d20a1f2c0f93fa2c69
1 parent
0f9ec8f6
Exists in
master
and in
6 other branches
Init AmdaClient only if required
Showing
1 changed file
with
12 additions
and
7 deletions
Show diff stats
php/classes/UserMgr.php
... | ... | @@ -23,7 +23,7 @@ class UserMgr |
23 | 23 | 'USERTEMPDIR' => 'TEMP'); |
24 | 24 | protected $userGrps; |
25 | 25 | protected $userGrpsCheckSum; //use to know if there is a modification in user groups |
26 | - protected $amdaClient; //client to dd webservice | |
26 | + protected $amdaClient = NULL; //client to dd webservice | |
27 | 27 | protected $paramMgr, $baseExtXml; |
28 | 28 | protected $datasetsTimeRestriction; |
29 | 29 | protected $datasetsTimeRestrictionCheckSum; |
... | ... | @@ -75,10 +75,15 @@ class UserMgr |
75 | 75 | $this->user = $_GET['sessionID']; |
76 | 76 | else if (isset($sessionID)) |
77 | 77 | $this->user = $sessionID; |
78 | - //TODO if AmdaClient is needed ? | |
79 | - $this->amdaClient = new AmdaClient(); | |
80 | 78 | } |
81 | 79 | |
80 | + private function getAmdaClient() { | |
81 | + if (!isset($this->amdaClient)) { | |
82 | + $this->amdaClient = new AmdaClient(); | |
83 | + } | |
84 | + return $this->amdaClient; | |
85 | + } | |
86 | + | |
82 | 87 | //TODO if needed?? set session ID |
83 | 88 | protected function setID() {} |
84 | 89 | |
... | ... | @@ -119,7 +124,7 @@ class UserMgr |
119 | 124 | // "email" => ($theUser->length > 0) ? $theUser->item(0)->getAttribute("email") : "undefined", |
120 | 125 | // "date" => ($theUser->length > 0) ? $theUser->item(0)->getAttribute("date") : "undefined", |
121 | 126 | // "news" => ($theUser->length > 0) ? $theUser->item(0)->getAttribute("news") : "0"); |
122 | - $info = $this->amdaClient->getUserInfo($this->user); | |
127 | + $info = $this->getAmdaClient()->getUserInfo($this->user); | |
123 | 128 | $wsSize = intval($this->getWsSize()/1024./1024.); |
124 | 129 | $quota = intval($this->getSpecialSettings()/1024./1024.); |
125 | 130 | $info['total'] = $quota; |
... | ... | @@ -131,7 +136,7 @@ class UserMgr |
131 | 136 | |
132 | 137 | public function resetPwd($crt_pwd, $new_pwd) |
133 | 138 | { |
134 | - return $this->amdaClient->resetUserPwd($this->user, $crt_pwd, $new_pwd); | |
139 | + return $this->getAmdaClient()->resetUserPwd($this->user, $crt_pwd, $new_pwd); | |
135 | 140 | } |
136 | 141 | |
137 | 142 | public function createDir() |
... | ... | @@ -149,7 +154,7 @@ class UserMgr |
149 | 154 | if (isset($this->userGrps)) { |
150 | 155 | return; |
151 | 156 | } |
152 | - $info = $this->amdaClient->getUserInfo($this->user); | |
157 | + $info = $this->getAmdaClient()->getUserInfo($this->user); | |
153 | 158 | |
154 | 159 | $this->userGrpsCheckSum = ''; |
155 | 160 | if (!empty($info['group'])) { |
... | ... | @@ -179,7 +184,7 @@ class UserMgr |
179 | 184 | } |
180 | 185 | |
181 | 186 | $this->datasetsTimeRestrictionCheckSum = ''; |
182 | - $this->datasetsTimeRestriction = $this->amdaClient->getDatasetsWithTimeRestriction(); | |
187 | + $this->datasetsTimeRestriction = $this->getAmdaClient()->getDatasetsWithTimeRestriction(); | |
183 | 188 | |
184 | 189 | if ($this->datasetsTimeRestriction !== FALSE) { |
185 | 190 | foreach ($this->datasetsTimeRestriction as &$datasetTimeRestriction) { | ... | ... |