diff --git a/application/controllers/UserController.php b/application/controllers/UserController.php index 92a99733e..964a384aa 100644 --- a/application/controllers/UserController.php +++ b/application/controllers/UserController.php @@ -400,6 +400,8 @@ class UserController extends Zend_Controller_Action public function logoutAction() { Zend_Auth::getInstance()->clearIdentity(); + $session = new Zend_Session_Namespace('wcheck'); + $session->unsetAll(); $this->_helper->layout()->disableLayout(); $request = $this->getRequest(); diff --git a/application/controllers/WorldcheckController.php b/application/controllers/WorldcheckController.php index 6e495ad77..d943baacf 100644 --- a/application/controllers/WorldcheckController.php +++ b/application/controllers/WorldcheckController.php @@ -1,12 +1,10 @@ getRequest(); $param = new stdClass(); - $param->dirSociete = $request->getParam('dirSociete'); - $param->dirNom = $request->getParam('dirNom'); + $dirNom = $request->getParam('dirNom'); + $param->dirNom = ($dirNom)?$dirNom:$request->getParam('dirSociete'); $param->dirPrenom = $request->getParam('dirPrenom'); $param->dirType = $request->getParam('dirType'); - - $data = new stdClass(); - $data->name = ($param->dirNom)?$param->dirNom:$param->dirSociete; - $data->nameType = $param->dirType; + $param->Siren = $request->getParam('siren'); $user = new Scores_Utilisateur(); + $session = new SessionWorldcheck(); $wc = new WsWorldCheck(); $wcLocal = new Application_Model_Worldcheck(); //check worldcheck data correctness in the session - if (!$user->getScreenerName() || $user->getScreenerName()!=$data->name || substr($user->getScreenerNameIdentifier(),0,3)!='so_' || $user->getNameType()!=$data->nameType) + if (!$session->getName() || $session->getName()!=$param->dirNom || substr($session->getNameIdentifier(),0,3)!='so_' || $session->getNameType()!=$param->dirType) { - $idClient = $user->getIdClient(); - $login = $user->getLogin(); - $localDBParams = $wcLocal->getScreenerId($idClient, $login, $data); - $this->nameIdentifier = $localDBParams->nameIdentifier; - - //Save nameIdentifier, name, nameType into session - $wcheck = new stdClass(); - $wcheck->screenerNameIdentifier = $this->nameIdentifier; - $wcheck->screenerName = $data->name; - $wcheck->matchCount = $localDBParams->matchCount; - $wcheck->nameType = $data->nameType; - - $auth = Zend_Auth::getInstance(); - if ( $auth->hasIdentity() ) { - $this->identity = $auth->getIdentity(); - } - $this->identity->wcheck = $wcheck; - $auth->getStorage()->write($this->identity); - //end + $param->idClient = $user->getIdClient(); + $param->login = $user->getLogin(); + $localDBParams = $wcLocal->getScreenerId($param); + $param->matchCount = $localDBParams->matchCount; + $param->nameIdentifier = $localDBParams->nameIdentifier; + $session->setSession($param); } - $this->nameIdentifier = $user->getScreenerNameIdentifier(); - $matchCount = $user->getMatchCount(); + $nameIdentifier = $session->getNameIdentifier(); + $matchCount = $session->getMatchCount(); - if ($matchCount!=0) + if ($matchCount!==0) { $summary = new stdClass(); - $summary->nameIdentifier = $this->nameIdentifier; + $summary->nameIdentifier = $nameIdentifier; $summary->matchType = 'WATCHLIST'; //get results by lastName @@ -76,7 +59,7 @@ class WorldcheckController extends Zend_Controller_Action $filteredWC = array(); foreach ($unfilteredWC as $entityId=>$shortData) { - if (stripos($shortData->lastName, $data->name)!==false || stripos($data->name, $shortData->lastName)!==false) { + if (stripos($shortData->lastName, $param->dirNom)!==false || stripos($param->dirNom, $shortData->lastName)!==false) { if (stripos($shortData->givenName, $param->dirPrenom)!==false || stripos($param->dirPrenom, $shortData->givenName)!==false) { $filteredWC[$entityId] = $shortData; } @@ -140,6 +123,7 @@ class WorldcheckController extends Zend_Controller_Action if ($request->getParam('dirNom')) $data->Nom = $request->getParam('dirNom'); if ($request->getParam('dirPrenom')) $data->Prenom = $request->getParam('dirPrenom'); if ($request->getParam('dirSociete')) $data->Societe = $request->getParam('dirSociete'); + if ($request->getParam('siren')) $data->Siren = $request->getParam('siren'); $wcLocal = new Application_Model_Worldcheck(); $occurrence = $wcLocal->getCount($data); @@ -155,11 +139,11 @@ class WorldcheckController extends Zend_Controller_Action public function matchcontentAction() { $request = $this->getRequest(); - $user = new Scores_Utilisateur(); + $session = new SessionWorldcheck(); $param = new stdClass(); $param->matchIdentifier = $request->getParam('matchIdentifier'); - $param->nameType = $user->getNameType(); + $param->nameType = $session->getNameType(); $wc = new WsWorldCheck(); $content = $wc->getDetailsContent($param); diff --git a/application/models/Worldcheck.php b/application/models/Worldcheck.php index 88ec2f271..ef56b8568 100644 --- a/application/models/Worldcheck.php +++ b/application/models/Worldcheck.php @@ -6,15 +6,14 @@ class Application_Model_Worldcheck extends Zend_Db_Table_Abstract /** * Return nameIdentifier and matchCount from local DB if found. * Otherwise get nameIdentifier and matchCount from WorldCheck - * @param string $idClient - * @param object $data + * @param object $param * @return object */ - public function getScreenerId($idClient, $login, $data) + public function getScreenerId($param) { $result = new stdClass(); $sql = $this->select() - ->where("idClient='".$idClient."' AND name='".$data->name."' AND nameType='".$data->nameType."' AND LEFT(nameIdentifier, 3)='so_'") + ->where("idClient='".$param->idClient."' AND name='".$param->dirNom."' AND nameType='".$param->dirType."' AND LEFT(nameIdentifier, 3)='so_'") ->order('dateInsert DESC'); if ($this->fetchRow($sql)) { @@ -22,19 +21,23 @@ class Application_Model_Worldcheck extends Zend_Db_Table_Abstract $result->matchCount = $this->fetchRow($sql)->matchCount; } else { - $wc = new WsWorldCheck(); + $wc = new WsWorldCheck(); + $data = new stdClass(); + $data->name = $param->dirNom; + $data->nameType = $param->dirType; $result->nameIdentifier = $wc->getScreener($data); $result->matchCount = $wc->getDetailsName($result->nameIdentifier)->unresolvedMatchCount; - $param = array( - 'idClient' => $idClient, - 'login' => $login, + $params = array( + 'idClient' => $param->idClient, + 'login' => $param->login, 'nameIdentifier' => $result->nameIdentifier, 'matchCount' => $result->matchCount, - 'name' => $data->name, - 'nameType' => $data->nameType, + 'name' => $param->dirNom, + 'siren' => $param->Siren, + 'nameType' => $param->dirType, 'dateInsert' => date('Y-m-d') ); - $sql = $this->insert($param); + $sql = $this->insert($params); } return $result; } diff --git a/application/views/default/scripts/dirigeant/liste.phtml b/application/views/default/scripts/dirigeant/liste.phtml index 814fbcb34..1badc73f5 100644 --- a/application/views/default/scripts/dirigeant/liste.phtml +++ b/application/views/default/scripts/dirigeant/liste.phtml @@ -105,10 +105,10 @@ table.data td { border:1px solid #ccc; padding:5px; }