*/ class UserCurrent extends UserAbstract { /** * @var bool */ protected $affectationFineSiDispo = false; /** * Point d'entrée. * * @param boolean $affectationFineSiDispo Indique s'il faut prendre en compte l'affectation * plus fine (ucbnSousStructure) si elle existe, à la place de l'affectation standard (niveau 2) * @return self */ public function __invoke($affectationFineSiDispo = false) { $this->setAffectationFineSiDispo($affectationFineSiDispo); return $this; } /** * Retourne le code HTML généré par cette aide de vue. * * @return string */ public function __toString() { $id = 'user-current-info'; $userStatusHelper = $this->getView()->plugin('userStatus'); /* @var $userStatusHelper \UnicaenAuth\View\Helper\UserStatus */ $status = $userStatusHelper(false); if ($this->getIdentity()) { $userProfileHelper = $this->getView()->plugin('userProfile'); /* @var $userProfileHelper \UnicaenAuth\View\Helper\UserProfile */ $userInfoHelper = $this->getView()->plugin('userInfo'); /* @var $userInfoHelper \UnicaenAuth\View\Helper\UserInfo */ $content = $userProfileHelper . $userInfoHelper($this->getAffectationFineSiDispo()); } else { $content = _("Aucun"); if ($this->getTranslator()) { $content = $this->getTranslator()->translate($content, $this->getTranslatorTextDomain()); } } $content = preg_replace('/\r\n|\n|\r/', '', $content); $title = _("Utilisateur connecté à l'application"); if ($this->getTranslator()) { $title = $this->getTranslator()->translate($title, $this->getTranslatorTextDomain()); } $out = <<$status EOS; $out .= PHP_EOL; $out .= << $(function() { $("#$id").popover({ html: true, container: '#navbar' }); }); EOS; $out .= PHP_EOL; return $out; } /** * Indique si l'affichage de l'affectation fine éventuelle est activé ou non. * * @return bool */ public function getAffectationFineSiDispo() { return $this->affectationFineSiDispo; } /** * Active ou non l'affichage de l'affectation fine éventuelle. * * @param bool $affectationFineSiDispo * @return self */ public function setAffectationFineSiDispo($affectationFineSiDispo = true) { $this->affectationFineSiDispo = $affectationFineSiDispo; return $this; } }