. /** * Allows administrators to define additional profile fields for the users of a GNU social installation. * * @category Widget * @package GNU social * @author Max Shinn * @author Diogo Cordeiro * @copyright 2011-2019 Free Software Foundation, Inc http://www.fsf.org * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later */ defined('GNUSOCIAL') || die(); function gnusocial_profile_merge(&$profile) { $responses = GNUsocialProfileExtensionResponse::findResponsesByProfile($profile->id); $profile->customfields = []; foreach ($responses as $response) { $title = $response->systemname; $profile->$title = $response->value; $profile->customfields[] = $title; } } function gnusocial_field_systemname_validate($systemname) { // Ensure it doesn't exist already $fields = GNUsocialProfileExtensionField::allFields(); foreach ($fields as $field) { if ($field->systemname == $systemname) { return false; } } // Ensure that it consist of only alphanumeric characters return ctype_alnum($systemname); }