]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Extended profile - fix some issues saving and displaying dates
authorZach Copley <zach@status.net>
Wed, 16 Mar 2011 08:09:38 +0000 (01:09 -0700)
committerZach Copley <zach@status.net>
Wed, 16 Mar 2011 08:09:38 +0000 (01:09 -0700)
plugins/ExtendedProfile/extendedprofile.php
plugins/ExtendedProfile/extendedprofilewidget.php
plugins/ExtendedProfile/profiledetailsettingsaction.php

index 673680f02704d16b766a8e1e8c24910b53460432..fa632e5073886b9eca4fe2664db1329516049345 100644 (file)
@@ -98,6 +98,15 @@ class ExtendedProfile
         }
     }
 
+    function getDateValue($name) {
+        $key = strtolower($name);
+        if (array_key_exists($key, $this->fields)) {
+            return $this->fields[$key][0]->date;
+        } else {
+            return null;
+        }
+    }
+
     // XXX: getPhones, getIms, and getWebsites pretty much do the same thing,
     //      so refactor.
     function getPhones()
index 25a0ab8b2036f49537a7ba67e46026a044ab0a73..622beff32f1bddf9992bffdbf74b10240ce5a690 100644 (file)
@@ -493,11 +493,14 @@ class ExtendedProfileWidget extends Form
             $this->out->text($this->ext->getTextValue($name));
             break;
         case 'date':
-            $this->out->element(
-                'div',
-                array('class' => 'field date'),
-                date('j M Y', strtotime($this->ext->getTextValue($name)))
-            );
+            $value = $this->ext->getDateValue($name);
+            if (!empty($value)) {
+                $this->out->element(
+                    'div',
+                    array('class' => 'field date'),
+                    date('j M Y', strtotime($value))
+                );
+            }
             break;
         case 'person':
             $this->out->text($this->ext->getTextValue($name));
@@ -549,7 +552,7 @@ class ExtendedProfileWidget extends Form
             $out->input(
                 $id,
                 null,
-                date('j M Y', strtotime($this->ext->getTextValue($name)))
+                date('j M Y', strtotime($this->ext->getDateValue($name)))
             );
             break;
         case 'person':
index 13bf43b927d457e2f0e7b216357ef5576fe6a610..719717e088f972b1d77f35b8dbac09d27e28d6c6 100644 (file)
@@ -113,10 +113,14 @@ class ProfileDetailSettingsAction extends ProfileSettingsAction
 
             foreach ($dateFieldNames as $name) {
                 $value = $this->trimmed('extprofile-' . $name);
+                $dateVal = $this->parseDate($name, $value);
                 $this->saveField(
                     $user,
                     $name,
-                    $this->parseDate($name, $value)
+                    null,
+                    null,
+                    null,
+                    $dateVal
                 );
             }