Add 'hidden' flag to text descriptions of the 'pub' flag
[platal.git] / modules / profile / general.inc.php
index f382e7b..f9da015 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2011 Polytechnique.org                              *
+ *  Copyright (C) 2003-2014 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
@@ -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']);
@@ -461,7 +453,7 @@ class ProfileSettingNetworking implements ProfileSetting
     }
 
     public function getText($value) {
-        static $pubs = array('public' => 'publique', 'ax' => 'annuaire AX', 'private' => 'privé');
+        static $pubs = array('public' => 'publique', 'ax' => 'annuaire papier', 'private' => 'privé', 'hidden' => 'administrateurs');
         $networkings = array();
         foreach ($value as $network) {
             $networkings[] = $network['name'] . ' : ' . $network['address'] . ' (affichage ' . $pubs[$network['pub']] . ')';
@@ -524,7 +516,7 @@ class ProfileSettingHobby implements ProfileSetting
     }
 
     public function getText($value) {
-        static $pubs = array('public' => 'publique', 'private' => 'privé');
+        static $pubs = array('public' => 'publique', 'ax' => 'annuaire papier', 'private' => 'privé', 'hidden' => 'administrateurs');
         $hobbies = array();
         foreach (self::$type as $type) {
             $hobbies[$type] = array();
@@ -653,6 +645,7 @@ class ProfilePageGeneral extends ProfilePage
             $this->settings['deathdate'] = new ProfileSettingDate(true);
             $this->settings['birthdate'] = new ProfileSettingDate(true);
             $this->settings['birthdate_ref'] = new ProfileSettingDate(true);
+            $this->settings['axfreetext'] = null;
         } else {
             $this->settings['yourself'] = null;
             $this->settings['birthdate'] = new ProfileSettingDate();
@@ -673,7 +666,7 @@ class ProfilePageGeneral extends ProfilePage
         // Checkout all data...
         $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.freetext, p.freetext_pub, p.axfreetext, p.ax_id AS matricule_ax, pd.yourself,
                                    p.deathdate, IF(p.birthdate_ref = 0, '', p.birthdate_ref) AS birthdate_ref,
                                    p.title AS profile_title
                              FROM  profiles              AS p
@@ -706,7 +699,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['profile_title']) {
+            || $this->changed['axfreetext'] || $this->changed['email_directory'] || $this->changed['profile_title']) {
             if ($this->values['nationality3'] == "") {
                 $this->values['nationality3'] = NULL;
             }
@@ -739,11 +732,11 @@ class ProfilePageGeneral extends ProfilePage
 
             XDB::execute("UPDATE  profiles
                              SET  nationality1 = {?}, nationality2 = {?}, nationality3 = {?}, birthdate = {?},
-                                  freetext = {?}, freetext_pub = {?}, email_directory = {?}, title = {?}
+                                  freetext = {?}, freetext_pub = {?}, axfreetext = {?}, 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->values['freetext'], $this->values['freetext_pub'], $this->values['axfreetext'], $new_email,
                           $this->values['profile_title'], $this->pid());
         }
         if ($this->changed['photo_pub']) {
@@ -832,5 +825,5 @@ class ProfilePageGeneral extends ProfilePage
     }
 }
 
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
+// vim:set et sw=4 sts=4 sws=4 foldmethod=marker fenc=utf-8:
 ?>