From 65f9b5d954f35e9a89edaad9dfdb48f61bc9c2c5 Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Wed, 9 Mar 2011 11:27:29 -0800 Subject: [PATCH] Attempt to save field (doesn't work right yet) --- .../profiledetailsettingsaction.php | 44 ++++++++++++++++++- 1 file changed, 42 insertions(+), 2 deletions(-) diff --git a/plugins/ExtendedProfile/profiledetailsettingsaction.php b/plugins/ExtendedProfile/profiledetailsettingsaction.php index d1153cc075..ce0828c3e1 100644 --- a/plugins/ExtendedProfile/profiledetailsettingsaction.php +++ b/plugins/ExtendedProfile/profiledetailsettingsaction.php @@ -93,13 +93,50 @@ class ProfileDetailSettingsAction extends SettingsAction $profile = $user->getProfile(); + $simpleFieldNames = array('title'); - $simple_fields = array('title', 'manager', 'tags', 'spouse'); + foreach ($simpleFieldNames as $name) { + $value = $this->trimmed('extprofile-' . $name); + $this->saveSimpleField($user, $name, $value); + } $this->showForm(_('Details saved.'), true); } + function saveSimpleField($user, $name, $value) + { + $profile = $user->getProfile(); + + $detail = new Profile_detail(); + + $detail->profile_id = $profile->id; + $detail->field = $name; + $detail->field_index = 1; + + $result = $detail->find(true); + + + if (empty($result)) { + $detail->value = $value; + + $detail->created = common_sql_now(); + + common_debug("XXXXXXXXXXXXXXX not found"); + //common_debug('bbbbbbbbbbbb ' . var_export($detail, true)); + + $result = $detail->insert(); + } else { + common_debug('zzzzz FOUND'); + $orig = clone($detail); + $detail->value = $value; + $result = $detail->update($orig); + } + + $detail->free(); + + } + /** * Save fields that should be stored in the main profile object * @@ -136,9 +173,12 @@ class ProfileDetailSettingsAction extends SettingsAction $profile = $user->getProfile(); + $oldTags = $user->getSelfTags(); + $newTags = array_diff($tags, $oldTags); + if ($fullname != $profile->fullname || $location != $profile->location - || $tags != $profile->tags + || !empty($newTags) || $bio != $profile->bio) { $orig = clone($profile);