X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=modules%2Fprofile%2Fgeneral.inc.php;h=d95416b526b5e27721995796445a5b16b3a9f780;hb=fe5ccad978199cfbe71c583280b999769a27c9b2;hp=2ca66c69941bdaa3feb9b5bcb82f3426a0b7d3bf;hpb=e0d6b3af1435db9f8ddd72f7c6a9e536654dd4f1;p=platal.git diff --git a/modules/profile/general.inc.php b/modules/profile/general.inc.php index 2ca66c6..d95416b 100644 --- a/modules/profile/general.inc.php +++ b/modules/profile/general.inc.php @@ -63,25 +63,18 @@ class ProfileSettingSearchNames implements ProfileSetting public function value(ProfilePage $page, $field, $value, &$success) { + require_once 'name.func.inc.php'; $success = true; if (is_null($value)) { $request = NamesReq::getPublicNames($page->pid()); if (!$request) { - $value['public_names'] = XDB::fetchOneAssoc('SELECT particles, lastname_main, lastname_marital, lastname_ordinary, + $value['public_names'] = XDB::fetchOneAssoc('SELECT lastname_main, lastname_marital, lastname_ordinary, firstname_main, firstname_ordinary, pseudonym FROM profile_public_names WHERE pid = {?}', $page->pid()); - - $flags = new PlFlagSet($value['public_names']['particles']); - unset($value['public_names']['particles']); - static $suffixes = array('main', 'marital', 'ordinary'); - - foreach ($suffixes as $suffix) { - $value['public_names']['particle_' . $suffix] = $flags->hasFlag($suffix); - } } else { $value['public_names'] = $request; Platal::page()->assign('validation', true); @@ -94,7 +87,7 @@ class ProfileSettingSearchNames implements ProfileSetting $page->pid()); } else { foreach ($value['public_names'] as $key => $name) { - $value['public_names'][$key] = trim($name); + $value['public_names'][$key] = capitalize_name(trim($name)); } if (isset($value['private_names'])) { foreach ($value['private_names'] as $key => $name) { @@ -110,7 +103,6 @@ class ProfileSettingSearchNames implements ProfileSetting } } - require_once 'name.func.inc.php'; $public_name = build_first_name($value['public_names']) . ' ' . build_full_last_name($value['public_names'], $page->profile->isFemale()); if (isset($value['private_names'])) { $private_name_end = build_private_name($value['private_names']); @@ -482,6 +474,7 @@ class ProfileSettingHobby implements ProfileSetting public function value(ProfilePage $page, $field, $value, &$success) { + $success = true; if (is_null($value)) { $value = XDB::fetchAllAssoc('SELECT type, text, pub FROM profile_hobby @@ -491,7 +484,6 @@ class ProfileSettingHobby implements ProfileSetting if (!is_array($value)) { return array(); } - $success = true; foreach($value as $i => &$hobby) { $hobby['text'] = trim($hobby['text']); if (!$hobby['text'] ||!in_array($hobby['type'], self::$type)) { @@ -633,6 +625,7 @@ class ProfilePageGeneral extends ProfilePage $this->settings['nationality1'] = $this->settings['nationality2'] = $this->settings['nationality3'] = $this->settings['promo_display'] + = $this->settings['profile_title'] = null; $this->settings['email_directory'] = new ProfileSettingEmail(); $this->settings['email_directory_new'] = new ProfileSettingEmailDirectory(); @@ -664,6 +657,7 @@ class ProfilePageGeneral extends ProfilePage $this->watched['freetext'] = true; } + Platal::page()->assign('is_registered', ($this->owner->perms ? true : false)); } protected function _fetchData() @@ -672,7 +666,8 @@ class ProfilePageGeneral extends ProfilePage $res = XDB::query("SELECT p.nationality1, p.nationality2, p.nationality3, IF(p.birthdate = 0, '', p.birthdate) AS birthdate, p.email_directory as email_directory, pd.promo AS promo_display, p.freetext, p.freetext_pub, p.ax_id AS matricule_ax, pd.yourself, - p.deathdate, IF(p.birthdate_ref = 0, '', p.birthdate_ref) AS birthdate_ref + p.deathdate, IF(p.birthdate_ref = 0, '', p.birthdate_ref) AS birthdate_ref, + p.title AS profile_title FROM profiles AS p INNER JOIN profile_display AS pd ON (pd.pid = p.pid) WHERE p.pid = {?}", $this->pid()); @@ -703,7 +698,7 @@ class ProfilePageGeneral extends ProfilePage { if ($this->changed['nationality1'] || $this->changed['nationality2'] || $this->changed['nationality3'] || $this->changed['birthdate'] || $this->changed['freetext'] || $this->changed['freetext_pub'] - || $this->changed['email_directory']) { + || $this->changed['email_directory'] || $this->changed['profile_title']) { if ($this->values['nationality3'] == "") { $this->values['nationality3'] = NULL; } @@ -736,11 +731,12 @@ class ProfilePageGeneral extends ProfilePage XDB::execute("UPDATE profiles SET nationality1 = {?}, nationality2 = {?}, nationality3 = {?}, birthdate = {?}, - freetext = {?}, freetext_pub = {?}, email_directory = {?} + freetext = {?}, freetext_pub = {?}, email_directory = {?}, title = {?} WHERE pid = {?}", $this->values['nationality1'], $this->values['nationality2'], $this->values['nationality3'], ProfileSettingDate::toSQLDate($this->values['birthdate']), - $this->values['freetext'], $this->values['freetext_pub'], $new_email, $this->pid()); + $this->values['freetext'], $this->values['freetext_pub'], $new_email, + $this->values['profile_title'], $this->pid()); } if ($this->changed['photo_pub']) { XDB::execute("UPDATE profile_photos @@ -777,7 +773,7 @@ class ProfilePageGeneral extends ProfilePage } } } - if ($this->orig['birthdate_ref'] == 0 && !S::user()->isMe($this->owner) && $this->changed['birthdate_ref']) { + if ($this->changed['birthdate_ref'] && S::admin() && !$this->owner->perms) { XDB::execute('UPDATE profiles SET birthdate_ref = {?} WHERE pid = {?}',