3 * StatusNet - the distributed open-source microblogging tool
4 * Copyright (C) 2011, StatusNet, Inc.
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Affero General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Affero General Public License for more details.
16 * You should have received a copy of the GNU Affero General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 if (!defined('STATUSNET')) {
25 * DataObject class to store extended profile fields. Allows for storing
26 * multiple values per a "field_name" (field_name property is not unique).
32 * mobile: 510-719-1139
35 * We can store these phone numbers in a "field" represented by three
36 * Profile_detail objects, each named 'phone_number' like this:
38 * $phone1 = new Profile_detail();
39 * $phone1->field_name = 'phone_number';
40 * $phone1->rel = 'home';
41 * $phone1->field_value = '510-384-1992';
42 * $phone1->value_index = 1;
44 * $phone1 = new Profile_detail();
45 * $phone1->field_name = 'phone_number';
46 * $phone1->rel = 'mobile';
47 * $phone1->field_value = '510-719-1139';
48 * $phone1->value_index = 2;
50 * $phone1 = new Profile_detail();
51 * $phone1->field_name = 'phone_number';
52 * $phone1->rel = 'work';
53 * $phone1->field_value = '415-231-1121';
54 * $phone1->value_index = 3;
57 class Profile_detail extends Managed_DataObject
59 public $__table = 'profile_detail';
62 public $profile_id; // profile this is for
63 public $rel; // detail for some field types; eg "home", "mobile", "work" for phones or "aim", "irc", "xmpp" for IM
64 public $field_name; // name
65 public $field_value; // primary text value
66 public $value_index; // relative ordering of multiple values in the same field
67 public $date; // related date
68 public $ref_profile; // for people types, allows pointing to a known profile in the system
72 static function schemaDef()
75 // No need for i18n. Table properties.
77 => 'Additional profile details for the ExtendedProfile plugin',
79 'id' => array('type' => 'serial', 'not null' => true),
80 'profile_id' => array('type' => 'int', 'not null' => true),
81 'field_name' => array(
86 'value_index' => array('type' => 'int'),
87 'field_value' => array('type' => 'text'),
88 'date' => array('type' => 'datetime'),
89 'rel' => array('type' => 'varchar', 'length' => 16),
90 'rel_profile' => array('type' => 'int'),
96 'type' => 'timestamp',
100 'primary key' => array('id'),
101 'unique keys' => array(
102 'profile_detail_profile_id_field_name_value_index'
103 => array('profile_id', 'field_name', 'value_index'),