Commit f5e8085d authored by David Surville's avatar David Surville
Browse files

[Evolution] Développement UnicaenLdap WIP

parent 8d66ec30
......@@ -18,6 +18,25 @@ use Zend\Ldap\Exception\LdapException;
*/
class People extends Entity
{
/**
* Constantes pour les champs eduPersonAffiliation et eduPersonPrimaryAffiliation
*/
const STATUS_AFFILIATE = 'affiliate';
const STATUS_ALUM = 'alum';
const STATUS_EMERITUS = 'emeritus';
const STATUS_EMPLOYEE = 'employee';
const STATUS_FACULTY = 'faculty';
const STATUS_MEMBER = 'member';
const STATUS_REGISTERED_READER = 'registered-reader';
const STATUS_RESEARCHER = 'researcher';
const STATUS_RETIRED = 'retired';
const STATUS_STAFF = 'staff';
const STATUS_STUDENT = 'student';
const STATUS_TEACHER = 'teacher';
/**
* @var string
*/
protected $type = 'People';
/**
......@@ -208,18 +227,18 @@ class People extends Entity
* @var array
*/
protected $eduPersonAffiliationAuthorizedValues = [
'affiliate',
'alum',
'emeritus',
'employee',
'faculty',
'member',
'registered-reader',
'researcher',
'retired',
'staff',
'student',
'teacher',
self::STATUS_AFFILIATE,
self::STATUS_ALUM,
self::STATUS_EMERITUS,
self::STATUS_EMPLOYEE,
self::STATUS_FACULTY,
self::STATUS_MEMBER,
self::STATUS_REGISTERED_READER,
self::STATUS_RESEARCHER,
self::STATUS_RETIRED,
self::STATUS_STAFF,
self::STATUS_STUDENT,
self::STATUS_TEACHER,
];
/**
......
......@@ -70,27 +70,175 @@ class People extends BasePeople
}
/**
* Retourne le nom complet de cet individu LDAP.
* Retourne le nom complet.
*
* @param boolean $nomEnMajuscule Mettre le nom de famille en majuscules ?
* @param boolean $avecCivilite Inclure la civilité ?
* @param boolean $prenomDabord Mettre le prénom avant le nom de famille ?
* @param boolean $uppercaseName nom de famille en majuscules
* @param boolean $withCivility inclure la civilité
* @param boolean $firstNameFirst prénom avant le nom de famille
* @return string
*/
public function getNomComplet($nomEnMajuscule = false, $avecCivilite = false, $prenomDabord = false)
public function getFullName($uppercaseName = false, $withCivility = false, $firstNameFirst = false)
{
$sn = $this->get('sn');
$sn = $this->sn;
$sn = is_array($sn) ? current($sn) : $sn;
if (!$sn) {
return '';
}
$nom = $nomEnMajuscule ? strtoupper($sn) : $sn;
$prenom = $this->get('givenname');
$civilite = $avecCivilite ? ' ' . $this->get('supannCivilite') : null;
$nom = $uppercaseName ? mb_strtoupper($sn, 'UTF-8') : $sn;
$prenom = $this->givenName;
$civilite = $withCivility ? $this->supannCivilite . ' ' : '';
return ($prenomDabord ? $prenom . ' ' . $nom : $nom . ' ' . $prenom) . $civilite;
return $civilite . ($firstNameFirst ? $prenom . ' ' . $nom : $nom . ' ' . $prenom);
}
/**
* Retourne la date de naissance
*
* @return DateTime|false
*/
public function getDateOfBirth()
{
return DateTime::createFromFormat('Ymd h:i:s', $this->schacDateOfBirth . ' 00:00:00');
}
/**
* Retourne la date d'expiration
*
* @return DateTime|false
*/
public function getExpiryDate()
{
return DateTime::createFromFormat('Ymd h:i:s', $this->schacExpiryDate . ' 00:00:00');
}
/**
* @param string $status
* @return bool
*/
protected function whichStatus(string $status): bool
{
return in_array($status, (array)$this->eduPersonAffiliation);
}
/**
* Check "affiliate" status
*
* @return bool
*/
public function isAffiliate(): bool
{
return $this->whichStatus(parent::STATUS_AFFILIATE);
}
/**
* Check "alum" status
*
* @return bool
*/
public function isAlum(): bool
{
return $this->whichStatus(parent::STATUS_ALUM);
}
/**
* Check "emeritus" status
*
* @return bool
*/
public function isEmeritus(): bool
{
return $this->whichStatus(parent::STATUS_EMERITUS);
}
/**
* Check "employee" status
*
* @return bool
*/
public function isEmployee(): bool
{
return $this->whichStatus(parent::STATUS_EMPLOYEE);
}
/**
* Check "faculty" status
*
* @return bool
*/
public function isFaculty(): bool
{
return $this->whichStatus(parent::STATUS_FACULTY);
}
/**
* Check "member" status
*
* @return bool
*/
public function isMember(): bool
{
return $this->whichStatus(parent::STATUS_MEMBER);
}
/**
* Check "registered reader" status
*
* @return bool
*/
public function isRegisteredReader(): bool
{
return $this->whichStatus(parent::STATUS_REGISTERED_READER);
}
/**
* Check "researcher" status
*
* @return bool
*/
public function isResearcher(): bool
{
return $this->whichStatus(parent::STATUS_RESEARCHER);
}
/**
* Check "retired" status
*
* @return bool
*/
public function isRetired(): bool
{
return $this->whichStatus(parent::STATUS_RETIRED);
}
/**
* Check "staff" status
*
* @return bool
*/
public function isStaff(): bool
{
return $this->whichStatus(parent::STATUS_STAFF);
}
/**
* Check "student" status
*
* @return bool
*/
public function isStudent(): bool
{
return $this->whichStatus(parent::STATUS_STUDENT);
}
/**
* Check "teacher" status
*
* @return bool
*/
public function isTeacher(): bool
{
return $this->whichStatus(parent::STATUS_TEACHER);
}
/**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment