Commit 1977fa90b985c092cc4908fdbfc55f89087eb1c9

Authored by Elena.Budnik
2 parents e566b28b b6e4778f

conflict while merge with master

php/WebServices/WSUserMgr.php
... ... @@ -55,6 +55,7 @@ class WSUserMgr extends UserMgr
55 55 if ( $setPathOnly )
56 56 return array('success' => true);
57 57  
  58 + $this->userGrps = $this->getUserGrps();
58 59 $this->makeLocalTree();
59 60 $this->makeRemoteTree();
60 61  
... ...
php/WebServices/WebServer.php
... ... @@ -38,6 +38,7 @@ class WebServer
38 38  
39 39 if (isset($vars['userID'])){
40 40 $this->userID = $vars['userID'];
  41 + IHMConfigClass::setUserName($this->userID);
41 42 }
42 43 else {
43 44 $this->userID = 'impex';
... ... @@ -53,10 +54,10 @@ class WebServer
53 54 return array('success' => true, 'vars' => $vars);
54 55 }
55 56  
56   - private function initUserMgr($setPatOnly = false)
  57 + private function initUserMgr($setPathOnly = false)
57 58 {
58 59 $wsUserMgr = new WSUserMgr();
59   - $wsUserMgr->init($this->userID, $this->userPWD, $this->sessionID, $setPatOnly, $this->isSoap);
  60 + $wsUserMgr->init($this->userID, $this->userPWD, $this->sessionID, $setPathOnly, $this->isSoap);
60 61  
61 62 $this->IPclient = $wsUserMgr->getIPClient();
62 63  
... ... @@ -296,7 +297,34 @@ class WebServer
296 297  
297 298 return array('success' => true, 'token' => $newToken);
298 299 }
  300 +
  301 + private function excludePrivateNodes($locParamSrc, $locParamDst)
  302 + {
  303 + $locParamSrcDom = new DomDocument("1.0");
  304 + $locParamSrcDom->preserveWhiteSpace = FALSE; /// Important !!! otherwise removeChild() leaves empty text nodes
  305 +
  306 + if (!$locParamSrcDom->load($locParamSrc))
  307 + $this->throwError("getObsDataTree", "Cannot load Amda Local DataBase Parameters description file".$this->userID);
  308 +
  309 + $xp = new domxpath($locParamSrcDom);
  310 + $restricted = $xp->query("//*[@group]");
299 311  
  312 + foreach ($restricted as $node) {
  313 + $parentNode = $node->parentNode;
  314 + $parentNode->removeChild($node);
  315 +
  316 + if (!$parentNode->hasChildNodes()) {
  317 + if ($parentNode->parentNode){
  318 + $parentParentNode = $parentNode->parentNode;
  319 + $parentParentNode->removeChild($parentNode);
  320 + }
  321 + }
  322 + }
  323 +
  324 + if (!$locParamSrcDom->save(WSConfigClass::getWsResultDir().$locParamDst))
  325 + $this->throwError('workspaceError', 'Cannot save Amda Local DataBase Parameters description file'.$this->userID);
  326 + }
  327 +
300 328 /************************** WEB SERVICES **************************************/
301 329  
302 330 /*
... ... @@ -308,11 +336,13 @@ class WebServer
308 336 $this->initUserMgr();
309 337  
310 338 $locParamSrc = USERWSDIR.'LocalParams.xml';
  339 +
311 340 $locParamDst = substr(strtolower(__FUNCTION__),3).'_'.$this->userID.'_'.$this->requestTime.'_AmdaLocalDataBaseParameters.xml';
312 341  
313   - if (!copy($locParamSrc,WSConfigClass::getWsResultDir().$locParamDst))
314   - $this->throwError('workspaceError', 'No Amda Local DataBase Parameters description file');
  342 +// if (!copy($locParamSrc,WSConfigClass::getWsResultDir().$locParamDst))
  343 +// $this->throwError('workspaceError', 'No Amda Local DataBase Parameters description file');
315 344  
  345 + $this->excludePrivateNodes($locParamSrc,$locParamDst);
316 346 return array('success' => true,'WorkSpace' => array("LocalDataBaseParameters" => WSConfigClass::getUrl().$locParamDst));
317 347 }
318 348  
... ... @@ -332,8 +362,10 @@ class WebServer
332 362 $locParamDst = substr(strtolower(__FUNCTION__),3).'_'.$this->userID.'_'.$this->requestTime.'_AmdaLocalDataBaseParameters.xml';
333 363 $wsParamDst = substr(strtolower(__FUNCTION__),3).'_'.$this->userID.'_'.$this->requestTime.'_UserDefinedParameters.xml';
334 364  
335   - if (!copy($locParamSrc, WSConfigClass::getWsResultDir().$locParamDst))
336   - $this->throwError('workspaceError', 'No Amda Local DataBase Parameters description file for '.$this->userID);
  365 +// if (!copy($locParamSrc, WSConfigClass::getWsResultDir().$locParamDst))
  366 +// $this->throwError('workspaceError', 'No Amda Local DataBase Parameters description file for '.$this->userID);
  367 +
  368 + $this->excludePrivateNodes($locParamSrc,$locParamDst);
337 369  
338 370 if (!copy($wsParamSrc, WSConfigClass::getWsResultDir().$wsParamDst))
339 371 return array('success' => true,'ParameterList' =>
... ...
php/classes/UserMgr.php
... ... @@ -29,6 +29,7 @@ class UserMgr
29 29 public $isOldWS = true;
30 30 public $isNewInfo = false;
31 31 public $isSpecialInfo = null;
  32 + public $isGuest = false;
32 33  
33 34 function __construct($username = NULL, $password = NULL, $sessionID = NULL)
34 35 {
... ... @@ -51,6 +52,7 @@ class UserMgr
51 52 // Process Guest Login
52 53 if (strcasecmp(trim($_POST['username']),"guest") == 0) {
53 54 $this->processGuestLogin();
  55 + $this->isGuest = true;
54 56 }
55 57 else {
56 58 $this->user = trim($_POST['username']);
... ... @@ -535,12 +537,17 @@ class UserMgr
535 537 if (!$this->createDir()) {
536 538 die("Login for ".$this->user." failed: Can't create WS dirs");
537 539 }
538   - $this->isFirst = true;
539   - $convert = new UserWsTransfer($this->user);
540   -
541   - $res = $convert->checkWS();
542   - if (!$res['success'])
  540 + $this->isFirst = true;
  541 +
  542 + if ($this->isGuest) {
543 543 $this->isOldWS = false;
  544 + }
  545 + else {
  546 + $convert = new UserWsTransfer($this->user);
  547 + $res = $convert->checkWS();
  548 + if (!$res['success'])
  549 + $this->isOldWS = false;
  550 + }
544 551 }
545 552  
546 553 if (file_exists($this->userdir.'newLogin')) {
... ... @@ -553,14 +560,12 @@ class UserMgr
553 560 // if new info exists it will be shown to :
554 561 // public => to all
555 562 // special => to group members
556   - if (file_exists($this->userdir.'newInfo'))
557   - {
  563 + if (file_exists($this->userdir.'newInfo')) {
558 564 $amdaInfo = new AmdaNews($this->user);
559 565 $info = $this->getUserInfo($this->user);
560 566 $status = $amdaInfo->makeInfo($info['group']);
561 567  
562 568 if ($status) $this->isNewInfo = true;
563   -
564 569 unlink($this->userdir.'newInfo');
565 570 }
566 571 touch($this->userdir.'newLogin');
... ...