Commit ca35ee3d6f5337bc9e0cc2d20a1f2c0f93fa2c69

Authored by Benjamin Renard
1 parent 0f9ec8f6

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,7 +23,7 @@ class UserMgr
23 'USERTEMPDIR' => 'TEMP'); 23 'USERTEMPDIR' => 'TEMP');
24 protected $userGrps; 24 protected $userGrps;
25 protected $userGrpsCheckSum; //use to know if there is a modification in user groups 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 protected $paramMgr, $baseExtXml; 27 protected $paramMgr, $baseExtXml;
28 protected $datasetsTimeRestriction; 28 protected $datasetsTimeRestriction;
29 protected $datasetsTimeRestrictionCheckSum; 29 protected $datasetsTimeRestrictionCheckSum;
@@ -75,10 +75,15 @@ class UserMgr @@ -75,10 +75,15 @@ class UserMgr
75 $this->user = $_GET['sessionID']; 75 $this->user = $_GET['sessionID'];
76 else if (isset($sessionID)) 76 else if (isset($sessionID))
77 $this->user = $sessionID; 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 //TODO if needed?? set session ID 87 //TODO if needed?? set session ID
83 protected function setID() {} 88 protected function setID() {}
84 89
@@ -119,7 +124,7 @@ class UserMgr @@ -119,7 +124,7 @@ class UserMgr
119 // "email" => ($theUser->length > 0) ? $theUser->item(0)->getAttribute("email") : "undefined", 124 // "email" => ($theUser->length > 0) ? $theUser->item(0)->getAttribute("email") : "undefined",
120 // "date" => ($theUser->length > 0) ? $theUser->item(0)->getAttribute("date") : "undefined", 125 // "date" => ($theUser->length > 0) ? $theUser->item(0)->getAttribute("date") : "undefined",
121 // "news" => ($theUser->length > 0) ? $theUser->item(0)->getAttribute("news") : "0"); 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 $wsSize = intval($this->getWsSize()/1024./1024.); 128 $wsSize = intval($this->getWsSize()/1024./1024.);
124 $quota = intval($this->getSpecialSettings()/1024./1024.); 129 $quota = intval($this->getSpecialSettings()/1024./1024.);
125 $info['total'] = $quota; 130 $info['total'] = $quota;
@@ -131,7 +136,7 @@ class UserMgr @@ -131,7 +136,7 @@ class UserMgr
131 136
132 public function resetPwd($crt_pwd, $new_pwd) 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 public function createDir() 142 public function createDir()
@@ -149,7 +154,7 @@ class UserMgr @@ -149,7 +154,7 @@ class UserMgr
149 if (isset($this->userGrps)) { 154 if (isset($this->userGrps)) {
150 return; 155 return;
151 } 156 }
152 - $info = $this->amdaClient->getUserInfo($this->user); 157 + $info = $this->getAmdaClient()->getUserInfo($this->user);
153 158
154 $this->userGrpsCheckSum = ''; 159 $this->userGrpsCheckSum = '';
155 if (!empty($info['group'])) { 160 if (!empty($info['group'])) {
@@ -179,7 +184,7 @@ class UserMgr @@ -179,7 +184,7 @@ class UserMgr
179 } 184 }
180 185
181 $this->datasetsTimeRestrictionCheckSum = ''; 186 $this->datasetsTimeRestrictionCheckSum = '';
182 - $this->datasetsTimeRestriction = $this->amdaClient->getDatasetsWithTimeRestriction(); 187 + $this->datasetsTimeRestriction = $this->getAmdaClient()->getDatasetsWithTimeRestriction();
183 188
184 if ($this->datasetsTimeRestriction !== FALSE) { 189 if ($this->datasetsTimeRestriction !== FALSE) {
185 foreach ($this->datasetsTimeRestriction as &$datasetTimeRestriction) { 190 foreach ($this->datasetsTimeRestriction as &$datasetTimeRestriction) {