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; } Societe != '') { - echo $this->action('occurence','worldcheck', null, array('dirSociete'=>$dir->Societe, 'dirType' =>'ORGANISATION')); + echo $this->action('occurence','worldcheck', null, array('dirSociete'=>$dir->Societe, 'dirType' =>'ORGANISATION', 'siren'=>$dir->Siren)); } if ($dir->Nom != '') { - echo $this->action('occurence','worldcheck', null, array('dirNom'=>$dir->Nom, 'dirPrenom'=>$dir->Prenom, 'dirType' =>'INDIVIDUAL')); + echo $this->action('occurence','worldcheck', null, array('dirNom'=>$dir->Nom, 'dirPrenom'=>$dir->Prenom, 'dirType' =>'INDIVIDUAL', 'siren'=>$dir->Siren)); } ?> diff --git a/application/views/default/scripts/identite/fiche.phtml b/application/views/default/scripts/identite/fiche.phtml index 27e6fb79c..ec1b902b3 100644 --- a/application/views/default/scripts/identite/fiche.phtml +++ b/application/views/default/scripts/identite/fiche.phtml @@ -59,7 +59,7 @@ echo $this->partial('identite/fiche-item.phtml', $this->dBlock['AutreSiren']);

Raison sociale & Coordonnées

-permission) echo $this->action('occurence','worldcheck', null, array('dirSociete'=>$this->infos->Nom, 'dirType' =>'ORGANISATION'));?> +permission) echo $this->action('occurence','worldcheck', null, array('dirSociete'=>$this->infos->Nom, 'dirType' =>'ORGANISATION', 'siren' => substr($this->siret, 0, 9)));?>
$this->data->Nom, 'dirPrenom' => $this->data->Prenom, 'dirSociete' => $this->data->Societe, - 'dirType' => $this->data->Type); + 'dirType' => $this->data->Type, + 'siren' => $this->data->Siren,); ?>

diff --git a/library/Scores/Utilisateur.php b/library/Scores/Utilisateur.php index 54410a61d..49247cb81 100644 --- a/library/Scores/Utilisateur.php +++ b/library/Scores/Utilisateur.php @@ -280,66 +280,6 @@ class Scores_Utilisateur public function getLangTmp() { return $this->identity->langtmp; - } - - /** - * Retourne nameIdentifier of WorldCheck screener - */ - public function getScreenerNameIdentifier() - { - if (isset($this->identity->wcheck)) - { - return $this->identity->wcheck->screenerNameIdentifier; - } - else - { - return false; - } - } - - /** - * Retourne name of WorldCheck screener - */ - public function getScreenerName() - { - if (isset($this->identity->wcheck)) - { - return $this->identity->wcheck->screenerName; - } - else - { - return false; - } - } - - /** - * Retourne nameType of WorldCheck search - */ - public function getNameType() - { - if (isset($this->identity->wcheck)) - { - return $this->identity->wcheck->nameType; - } - else - { - return false; - } - } - - /** - * Retourne match count of WorldCheck search by lastName - */ - public function getMatchCount() - { - if (isset($this->identity->wcheck)) - { - return $this->identity->wcheck->matchCount; - } - else - { - return false; - } } /** diff --git a/library/WorldCheck/SessionWorldcheck.php b/library/WorldCheck/SessionWorldcheck.php new file mode 100644 index 000000000..5ae5508f4 --- /dev/null +++ b/library/WorldCheck/SessionWorldcheck.php @@ -0,0 +1,64 @@ +get('name'); + } + + public function getFName() + { + return $this->get('fName'); + } + + public function getSiren() + { + return $this->get('siren'); + } + + public function getNameIdentifier() + { + return $this->get('nameIdentifier'); + } + + public function getMatchCount() + { + return $this->get('matchCount'); + } + + public function getNameType() + { + return $this->get('nameType'); + } + + public function getIdClient() + { + return $this->get('idClient'); + } + + public function getLogin() + { + return $this->get('login'); + } + + public function setSession($param) + { + $session = new Zend_Session_Namespace($this->index); + $session->name = $param->dirNom; + $session->fName = $param->dirPrenom; + $session->siren = $param->Siren; + $session->nameIdentifier = $param->nameIdentifier; + $session->matchCount = $param->matchCount; + $session->nameType = $param->dirType; + $session->idClient = $param->idClient; + $session->login = $param->login; + } + + protected function get($key) + { + $session = new Zend_Session_Namespace($this->index); + return $session->$key; + } +} \ No newline at end of file diff --git a/scripts/build/config/_sql/structure/worldcheck.sql b/scripts/build/config/_sql/structure/worldcheck.sql index 0861715c5..b1a1c70c0 100644 --- a/scripts/build/config/_sql/structure/worldcheck.sql +++ b/scripts/build/config/_sql/structure/worldcheck.sql @@ -4,8 +4,9 @@ CREATE TABLE IF NOT EXISTS `worldcheck` ( `login` char(25) NOT NULL, `nameIdentifier` varchar(23) NOT NULL, `name` varchar(50) NOT NULL, + `siren` varchar(9) DEFAULT NULL, `nameType` enum('INDIVIDUAL', 'ORGANISATION') NOT NULL, `matchCount` int(4) DEFAULT NULL, `dateInsert` date NOT NULL, PRIMARY KEY (`id`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='worldcheck v1 2013-08-01'; \ No newline at end of file +) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='worldcheck v2 2013-09-16'; \ No newline at end of file