2011-04-11 16:20:26 +02:00
|
|
|
<?php
|
2012-05-20 18:31:28 +02:00
|
|
|
class Scores_Utilisateur
|
2011-04-11 16:20:26 +02:00
|
|
|
{
|
|
|
|
protected $identity = null;
|
2012-05-20 18:31:28 +02:00
|
|
|
|
2011-04-11 16:20:26 +02:00
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
$auth = Zend_Auth::getInstance();
|
|
|
|
$this->identity = $auth->getIdentity();
|
|
|
|
}
|
|
|
|
|
2011-05-23 12:00:47 +02:00
|
|
|
/**
|
|
|
|
* Détermine si l'utilisateur est Administrateur
|
|
|
|
*/
|
2011-05-03 17:44:07 +02:00
|
|
|
public function isAdmin()
|
|
|
|
{
|
|
|
|
if ($this->identity->profil == 'Administrateur'){
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-05-23 12:00:47 +02:00
|
|
|
/**
|
|
|
|
* Détermine si l'utilisateur est SuperAdministrateur
|
|
|
|
*/
|
2011-05-03 17:44:07 +02:00
|
|
|
public function isSuperAdmin()
|
|
|
|
{
|
|
|
|
if ($this->identity->profil == 'SuperAdministrateur'){
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2012-05-20 18:31:28 +02:00
|
|
|
|
2011-05-23 12:00:47 +02:00
|
|
|
/**
|
|
|
|
* Retourne le profile utilisateur
|
|
|
|
*/
|
|
|
|
public function getProfil()
|
|
|
|
{
|
|
|
|
return $this->identity->profil;
|
|
|
|
}
|
2012-05-20 18:31:28 +02:00
|
|
|
|
2011-05-03 17:44:07 +02:00
|
|
|
/**
|
|
|
|
* Retourne l'identifiant client
|
|
|
|
*/
|
|
|
|
public function getIdClient()
|
|
|
|
{
|
|
|
|
return $this->identity->idClient;
|
|
|
|
}
|
2012-05-20 18:31:28 +02:00
|
|
|
|
2011-05-03 17:44:07 +02:00
|
|
|
/**
|
|
|
|
* Retourne l'identifiant de l'utilisateur
|
|
|
|
*/
|
|
|
|
public function getId()
|
|
|
|
{
|
|
|
|
return $this->identity->id;
|
|
|
|
}
|
2012-05-20 18:31:28 +02:00
|
|
|
|
2011-04-28 12:26:36 +02:00
|
|
|
/**
|
|
|
|
* Retourne le login de l'utiliateur
|
|
|
|
*/
|
|
|
|
public function getLogin()
|
|
|
|
{
|
|
|
|
return $this->identity->username;
|
|
|
|
}
|
2012-05-20 18:31:28 +02:00
|
|
|
|
2011-04-28 12:26:36 +02:00
|
|
|
/**
|
|
|
|
* Retourne le password de l'utilisateur
|
|
|
|
*/
|
|
|
|
public function getPassword()
|
|
|
|
{
|
|
|
|
return $this->identity->password;
|
|
|
|
}
|
2012-05-20 18:31:28 +02:00
|
|
|
|
2011-05-19 16:13:12 +02:00
|
|
|
/**
|
|
|
|
* Retourne le nom de l'utiliateur
|
|
|
|
*/
|
|
|
|
public function getNom()
|
|
|
|
{
|
|
|
|
return $this->identity->nom;
|
|
|
|
}
|
2012-05-20 18:31:28 +02:00
|
|
|
|
2011-05-19 16:13:12 +02:00
|
|
|
/**
|
|
|
|
* Retourne le prénom de l'utiliateur
|
|
|
|
*/
|
|
|
|
public function getPrenom()
|
|
|
|
{
|
|
|
|
return $this->identity->prenom;
|
|
|
|
}
|
2012-05-20 18:31:28 +02:00
|
|
|
|
2011-04-11 17:50:39 +02:00
|
|
|
/**
|
|
|
|
* Retourne l'email de l'utilisateur
|
|
|
|
*/
|
|
|
|
public function getEmail()
|
|
|
|
{
|
|
|
|
return $this->identity->email;
|
|
|
|
}
|
2012-05-20 18:31:28 +02:00
|
|
|
|
2011-05-20 10:31:31 +02:00
|
|
|
/**
|
|
|
|
* Retourne le téléphone de l'utilisateur
|
|
|
|
*/
|
|
|
|
public function getTel()
|
|
|
|
{
|
|
|
|
return $this->identity->tel;
|
|
|
|
}
|
2012-05-20 18:31:28 +02:00
|
|
|
|
2011-05-20 10:31:31 +02:00
|
|
|
/**
|
|
|
|
* Retourne le fax de l'utilisateur
|
|
|
|
*/
|
|
|
|
public function getFax()
|
|
|
|
{
|
|
|
|
return $this->identity->fax;
|
|
|
|
}
|
2011-04-20 09:23:09 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Retourne le type de score
|
|
|
|
*/
|
|
|
|
public function getTypeScore()
|
|
|
|
{
|
|
|
|
if (isset($this->identity->typeScore)
|
|
|
|
&& !empty($this->identity->typeScore)){
|
|
|
|
return $this->identity->typeScore;
|
|
|
|
}
|
|
|
|
return '100';
|
|
|
|
}
|
2012-05-20 18:31:28 +02:00
|
|
|
|
2011-04-20 09:23:09 +02:00
|
|
|
/**
|
|
|
|
* Retourne le nombre de réponse
|
|
|
|
*/
|
|
|
|
public function getNbRep()
|
|
|
|
{
|
2011-06-29 16:39:54 +02:00
|
|
|
return $this->identity->nbReponses;
|
2011-04-20 09:23:09 +02:00
|
|
|
}
|
2012-05-20 18:31:28 +02:00
|
|
|
|
2011-06-29 14:21:16 +02:00
|
|
|
/**
|
|
|
|
* Retourne l'adresse Ip de l'utilisateur
|
|
|
|
*/
|
2011-06-29 14:22:59 +02:00
|
|
|
public function getIpAddress()
|
2011-06-29 14:21:16 +02:00
|
|
|
{
|
|
|
|
if ( !isset($this->identity->ip) || empty($this->identity->ip) ){
|
|
|
|
return $_SERVER['REMOTE_ADDR'];
|
|
|
|
}
|
|
|
|
return $this->identity->ip;
|
|
|
|
}
|
2012-05-20 18:31:28 +02:00
|
|
|
|
2012-03-15 16:24:06 +01:00
|
|
|
/**
|
|
|
|
* Retourne la date de dernière connexion
|
|
|
|
*/
|
|
|
|
public function getDateDerniereConnexion()
|
|
|
|
{
|
|
|
|
return $this->identity->dateDerniereConnexion;
|
2012-05-20 18:31:28 +02:00
|
|
|
}
|
|
|
|
|
2011-04-28 12:26:36 +02:00
|
|
|
/**
|
|
|
|
* Vérifie que l'utiliasteur a le mode edition
|
|
|
|
* @return boolean
|
|
|
|
*/
|
2011-04-18 15:38:30 +02:00
|
|
|
public function checkModeEdition()
|
|
|
|
{
|
|
|
|
//On vérfie le mode edition dans les permissions
|
2011-04-20 15:57:42 +02:00
|
|
|
if ( $this->checkPerm('edition') ) {
|
2011-04-18 15:38:30 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
//On vérfie le mode edition dans la session
|
|
|
|
if ( $this->identity->modeEdition ) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2012-05-20 18:31:28 +02:00
|
|
|
|
|
|
|
|
2011-04-11 16:20:26 +02:00
|
|
|
/**
|
|
|
|
* Vérifie que l'utilisateur possède bien un droits
|
|
|
|
* @param string $perm
|
|
|
|
* Le code de la permission
|
2012-03-01 14:10:25 +01:00
|
|
|
* @return boolean
|
2011-04-11 16:20:26 +02:00
|
|
|
*/
|
|
|
|
public function checkPerm($perm)
|
|
|
|
{
|
|
|
|
$hasPerm = false;
|
|
|
|
if (preg_match('/\b'.$perm.'\b/i', $this->identity->droits)){
|
|
|
|
$hasPerm = true;
|
|
|
|
}
|
|
|
|
return $hasPerm;
|
|
|
|
}
|
2012-05-20 18:31:28 +02:00
|
|
|
|
2011-04-21 15:32:27 +02:00
|
|
|
/**
|
|
|
|
* Vérifie que l'utilisateur à cocher cette préférence
|
|
|
|
* @param string $pref
|
|
|
|
*/
|
2011-04-11 16:20:26 +02:00
|
|
|
public function checkPref($pref)
|
|
|
|
{
|
2011-04-21 12:10:43 +02:00
|
|
|
$hasPref = false;
|
|
|
|
if (preg_match('/\b'.$pref.'\b/i', $this->identity->pref)){
|
2011-04-21 15:36:04 +02:00
|
|
|
$hasPref = true;
|
2011-04-21 12:10:43 +02:00
|
|
|
}
|
|
|
|
return $hasPref;
|
2011-04-11 16:20:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|