Issue #0001653: Seperate wcsession
This commit is contained in:
parent
3986269e4a
commit
4b7f7471ab
@ -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();
|
||||
|
@ -1,12 +1,10 @@
|
||||
<?php
|
||||
class WorldcheckController extends Zend_Controller_Action
|
||||
{
|
||||
protected $identity = null;
|
||||
protected $nameIdentifier;
|
||||
|
||||
public function init()
|
||||
{
|
||||
require_once '/WorldCheck/WsWorldCheck.php';
|
||||
require_once 'WorldCheck/SessionWorldcheck.php';
|
||||
}
|
||||
|
||||
/**
|
||||
@ -16,50 +14,35 @@ class WorldcheckController extends Zend_Controller_Action
|
||||
{
|
||||
$request = $this->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);
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -105,10 +105,10 @@ table.data td { border:1px solid #ccc; padding:5px; }
|
||||
<td>
|
||||
<?php
|
||||
if ($dir->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));
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
|
@ -59,7 +59,7 @@ echo $this->partial('identite/fiche-item.phtml', $this->dBlock['AutreSiren']);
|
||||
<h2>Raison sociale & Coordonnées</h2>
|
||||
<div class="paragraph">
|
||||
<div style="float:right;">
|
||||
<?php if($this->permission) echo $this->action('occurence','worldcheck', null, array('dirSociete'=>$this->infos->Nom, 'dirType' =>'ORGANISATION'));?>
|
||||
<?php if($this->permission) echo $this->action('occurence','worldcheck', null, array('dirSociete'=>$this->infos->Nom, 'dirType' =>'ORGANISATION', 'siren' => substr($this->siret, 0, 9)));?>
|
||||
</div>
|
||||
<table>
|
||||
<?php
|
||||
|
@ -11,7 +11,8 @@
|
||||
'dirNom' => $this->data->Nom,
|
||||
'dirPrenom' => $this->data->Prenom,
|
||||
'dirSociete' => $this->data->Societe,
|
||||
'dirType' => $this->data->Type);
|
||||
'dirType' => $this->data->Type,
|
||||
'siren' => $this->data->Siren,);
|
||||
?>
|
||||
<a class='wcheck' tooltip='<?=$qtipContent ?>' href="<?=$this->url($params, null, true)?>" style="cursor: pointer;" >
|
||||
<div id='<?=$this->occurrence;?>' class='img'></div></a><br/>
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
64
library/WorldCheck/SessionWorldcheck.php
Normal file
64
library/WorldCheck/SessionWorldcheck.php
Normal file
@ -0,0 +1,64 @@
|
||||
<?php
|
||||
class SessionWorldcheck
|
||||
{
|
||||
protected $index = 'wcheck';
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return $this->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;
|
||||
}
|
||||
}
|
@ -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';
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='worldcheck v2 2013-09-16';
|
Loading…
Reference in New Issue
Block a user