static function newResponse($extension_id, $profile_id, $value) { $response = new GNUsocialProfileExtensionResponse(); $response->extension_id = $extension_id; $response->profile_id = $profile_id; $response->value = $value; $response->id = $response->insert(); if (!$response->id) { common_log_db_error($response, 'INSERT', __FILE__); throw new ServerException(_m('Error creating new response.')); } return $response; }
function onEndProfileSaveForm($action) { $fields = GNUsocialProfileExtensionField::allFields(); $user = common_current_user(); $profile = $user->getProfile(); foreach ($fields as $field) { $val = $action->trimmed($field->systemname); $response = new GNUsocialProfileExtensionResponse(); $response->profile_id = $profile->id; $response->extension_id = $field->id; if ($response->find()) { $response->fetch(); $response->value = $val; if ($response->validate()) { if (empty($val)) { $response->delete(); } else { $response->update(); } } } else { $response->value = $val; $response->insert(); } } }