2011-04-11 14:20:26 +00:00
|
|
|
<?php
|
|
|
|
class Utilisateur
|
|
|
|
{
|
|
|
|
protected $identity = null;
|
|
|
|
|
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
$auth = Zend_Auth::getInstance();
|
|
|
|
$this->identity = $auth->getIdentity();
|
|
|
|
}
|
|
|
|
|
2011-04-11 15:50:39 +00:00
|
|
|
/**
|
|
|
|
* Retourne l'email de l'utilisateur
|
|
|
|
*/
|
|
|
|
public function getEmail()
|
|
|
|
{
|
|
|
|
return $this->identity->email;
|
|
|
|
}
|
2011-04-20 07:23:09 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Retourne le type de score
|
|
|
|
*/
|
|
|
|
public function getTypeScore()
|
|
|
|
{
|
|
|
|
if (isset($this->identity->typeScore)
|
|
|
|
&& !empty($this->identity->typeScore)){
|
|
|
|
return $this->identity->typeScore;
|
|
|
|
}
|
|
|
|
return '100';
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Retourne le nombre de réponse
|
|
|
|
*/
|
|
|
|
public function getNbRep()
|
|
|
|
{
|
|
|
|
return $this->identity->nbRep;
|
|
|
|
}
|
|
|
|
|
2011-04-11 15:50:39 +00:00
|
|
|
|
2011-04-18 13:38:30 +00:00
|
|
|
public function checkModeEdition()
|
|
|
|
{
|
|
|
|
//On vérfie le mode edition dans les permissions
|
2011-04-20 13:57:42 +00:00
|
|
|
if ( $this->checkPerm('edition') ) {
|
2011-04-18 13:38:30 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
//On vérfie le mode edition dans la session
|
|
|
|
if ( $this->identity->modeEdition ) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-04-11 15:50:39 +00:00
|
|
|
|
2011-04-11 14:20:26 +00:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* Vérifie que l'utilisateur possède bien un droits
|
|
|
|
* @param string $perm
|
|
|
|
* Le code de la permission
|
|
|
|
*/
|
|
|
|
public function checkPerm($perm)
|
|
|
|
{
|
|
|
|
$hasPerm = false;
|
|
|
|
if (preg_match('/\b'.$perm.'\b/i', $this->identity->droits)){
|
|
|
|
$hasPerm = true;
|
|
|
|
}
|
|
|
|
return $hasPerm;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function checkPref($pref)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|