. /* * @copyright 1012 StatusNet, Inc. * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later */ defined('GNUSOCIAL') || die(); /** * DataObject class to store extended profile fields. Allows for storing * multiple values per a "field_name" (field_name property is not unique). * * Example: * * Jed's Phone Numbers * home : 510-384-1992 * mobile: 510-719-1139 * work : 415-231-1121 * * We can store these phone numbers in a "field" represented by three * Profile_detail objects, each named 'phone_number' like this: * * $phone1 = new Profile_detail(); * $phone1->field_name = 'phone_number'; * $phone1->rel = 'home'; * $phone1->field_value = '510-384-1992'; * $phone1->value_index = 1; * * $phone1 = new Profile_detail(); * $phone1->field_name = 'phone_number'; * $phone1->rel = 'mobile'; * $phone1->field_value = '510-719-1139'; * $phone1->value_index = 2; * * $phone1 = new Profile_detail(); * $phone1->field_name = 'phone_number'; * $phone1->rel = 'work'; * $phone1->field_value = '415-231-1121'; * $phone1->value_index = 3; * */ class Profile_detail extends Managed_DataObject { public $__table = 'profile_detail'; public $id; public $profile_id; // profile this is for public $rel; // detail for some field types; eg "home", "mobile", "work" for phones or "aim", "irc", "xmpp" for IM public $field_name; // name public $field_value; // primary text value public $value_index; // relative ordering of multiple values in the same field public $date; // related date public $ref_profile; // for people types, allows pointing to a known profile in the system public $created; public $modified; public static function schemaDef() { return [ // No need for i18n. Table properties. 'description' => 'Additional profile details for the ExtendedProfile plugin', 'fields' => [ 'id' => ['type' => 'serial', 'not null' => true], 'profile_id' => ['type' => 'int', 'not null' => true], 'field_name' => [ 'type' => 'varchar', 'length' => 16, 'not null' => true, ], 'value_index' => ['type' => 'int'], 'field_value' => ['type' => 'text'], 'date' => ['type' => 'datetime'], 'rel' => ['type' => 'varchar', 'length' => 16], 'rel_profile' => ['type' => 'int'], 'created' => [ 'type' => 'datetime', 'not null' => true, ], 'modified' => [ 'type' => 'timestamp', 'not null' => true, ], ], 'primary key' => ['id'], 'unique keys' => [ 'profile_detail_profile_id_field_name_value_index_key' => ['profile_id', 'field_name', 'value_index'] ], ]; } }