/**
  * Update the element in the database
  *
  * @return DbUser
  */
 public function update()
 {
     /*
      * Update:
      *      - formation
      *      - niveau
      *      - filiere
      *      - uvs
      *      - semesters history
      */
     $persist = false;
     $user = $this->database;
     $history = $user->addCureentSemesterToHistory();
     $niveau = null;
     $branch = $this->ldap->getNiveau();
     preg_match('/^[^0-9]+/i', $this->ldap->getNiveau(), $match);
     if (isset($match[0])) {
         $branch = $match[0];
         $niveau = str_replace($branch, '', $this->ldap->getNiveau());
     }
     // Updates
     if (ucfirst(strtolower($this->ldap->getFormation())) != $this->database->getFormation()) {
         $persist = true;
         $user->setFormation(ucfirst(strtolower($this->ldap->getFormation())));
     }
     if ($niveau != $this->database->getNiveau()) {
         $persist = true;
         $user->setNiveau($niveau);
     }
     if ($branch != $this->database->getBranch()) {
         $persist = true;
         $user->setBranch($branch);
     }
     if ($this->ldap->getFiliere() != $this->database->getFiliere()) {
         $persist = true;
         $user->setFiliere($this->ldap->getFiliere());
     }
     if (implode('|', $this->ldap->getUvs()) != $this->database->getUvs()) {
         $persist = true;
         $user->setUvs(implode('|', $this->ldap->getUvs()));
     }
     /*
      * Add badges
      */
     if (substr($history['niveau'], 0, 2) == 'TC' && substr($user->getNiveau(), 0, 2) != 'TC') {
         BadgesManager::userAddBadge($user, 'tc_survivor');
         BadgesManager::userPersistBadges($user);
     }
     if ($persist) {
         $this->doctrine->getManager()->persist($user);
     }
     return $persist;
 }
 /**
  * @param User $user
  * @return array
  */
 private function getData(User $user)
 {
     return ['login' => $user->getLogin(), 'studentId' => $user->getStudentId(), 'email' => $user->getMail(), 'firstName' => $user->getFirstName(), 'lastName' => $user->getLastName(), 'fullName' => $user->getFullName(), 'branch' => $user->getBranch(), 'level' => $user->getNiveau(), 'speciality' => $user->getFiliere(), 'phone' => $user->getPhoneNumber(), 'phonePrivacy' => $this->displayPrivacy($user->getPhoneNumberPrivacy()), 'sex' => $user->getSex(), 'sexPrivacy' => $this->displayPrivacy($user->getSexPrivacy()), 'nationality' => $user->getNationality(), 'nationalityPrivacy' => $this->displayPrivacy($user->getNationalityPrivacy()), 'adress' => $user->getAdress(), 'adressPrivacy' => $this->displayPrivacy($user->getAdressPrivacy()), 'postalCode' => $user->getPostalCode(), 'postalCodePrivacy' => $this->displayPrivacy($user->getPostalCodePrivacy()), 'city' => $user->getCity(), 'cityPrivacy' => $this->displayPrivacy($user->getCityPrivacy()), 'country' => $user->getCountry(), 'countryPrivacy' => $this->displayPrivacy($user->getCountryPrivacy()), 'birthday' => $user->getBirthday(), 'birthdayPrivacy' => $this->displayPrivacy($user->getBirthdayPrivacy()), 'birthdayDisplayOnlyAge' => $user->getBirthdayDisplayOnlyAge(), 'personnalMail' => $user->getPersonnalMail(), 'personnalMailPrivacy' => $this->displayPrivacy($user->getPersonnalMailPrivacy()), 'uvs' => $user->getUvsList(), 'surname' => $user->getSurnom(), 'website' => $user->getWebsite(), 'facebook' => $user->getFacebook(), 'twitter' => $user->getTwitter(), 'linkedin' => $user->getLinkedin(), 'viadeo' => $user->getViadeo(), 'isStudent' => $user->getIsStudent(), 'bdeMember' => $user->hasActiveMembership()];
 }
 /**
  * @param User $user
  * @return array
  */
 private function getData(User $user)
 {
     return ['login' => $user->getLogin(), 'studentId' => $user->getStudentId(), 'email' => $user->getMail(), 'firstName' => $user->getFirstName(), 'lastName' => $user->getLastName(), 'fullName' => $user->getFullName(), 'branch' => $user->getBranch(), 'level' => $user->getNiveau(), 'speciality' => $user->getFiliere(), 'surname' => $user->getSurnom(), 'jadis' => $user->getJadis(), 'passions' => $user->getPassions(), 'birthday' => $user->getBirthdayPrivacy() == User::PRIVACY_PUBLIC && $user->getBirthday() ? $user->getBirthday()->format(\DateTime::ISO8601) : null, 'website' => $user->getWebsite(), 'facebook' => $user->getFacebook(), 'twitter' => $user->getTwitter(), 'linkedin' => $user->getLinkedin(), 'viadeo' => $user->getViadeo(), 'isStudent' => $user->getIsStudent(), 'bdeMember' => $user->hasActiveMembership()];
 }