Fixes nationalities deletion.
[platal.git] / modules / profile / general.inc.php
index 4359cac..470d7ec 100644 (file)
@@ -19,6 +19,8 @@
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************/
 
+require_once 'name.func.inc.php';
+
 class ProfileSettingSearchNames implements ProfileSetting
 {
     private $private_name_end;
@@ -38,8 +40,7 @@ class ProfileSettingSearchNames implements ProfileSetting
 
     private function prepareField($value)
     {
-        $value = mb_strtoupper($value);
-        return preg_replace('/[^A-Z]/', ' ', $value);
+        return name_to_basename($value);
     }
 
     private function prepare(ProfilePage &$page, $field, $value, $init, &$success)
@@ -153,11 +154,18 @@ class ProfileSettingSearchNames implements ProfileSetting
                 }
                 if ($sn['pub']) {
                     if (isset($sn['particle']) && ($sn['particle'] != '')) {
+                        // particle is before first blank
                         list($particle, $name) = explode(' ', $sn['name'], 2);
                         $particle = trim($particle) . ' ';
                         if (!$name) {
+                            // particle is before first quote
                             list($particle, $name) = explode('\'', $sn['name'], 2);
                             $particle = trim($particle);
+                            if (!$name) {
+                                // actually there is no particle
+                                $particle = '';
+                                $name = $sn['name'];
+                            }
                         }
                     } else {
                         $particle = '';
@@ -555,7 +563,8 @@ class ProfileSettingGeneral extends ProfilePage
         if ($this->changed['yourself']) {
             XDB::execute('UPDATE  accounts
                              SET  display_name = {?}
-                           WHERE  pid = {?}', $this->pid());
+                           WHERE  uid = {?}',
+                         $this->values['yourself'], $this->owner->id());
         }
         if ($this->changed['promo_display']) {
             if ($this->values['promo_display']{0} == $this->profile->mainEducation()