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
73 * Get an instance by key
75 * This is a utility method to get a single instance with a given key value.
77 * @param string $k Key to use to lookup
78 * @param mixed $v Value to lookup
80 * @return User_greeting_count object found, or null for no hits
84 function staticGet($k, $v=null)
86 return Memcached_DataObject::staticGet('Profile_detail', $k, $v);
90 * Get an instance by compound key
92 * This is a utility method to get a single instance with a given set of
93 * key-value pairs. Usually used for the primary key for a compound key; thus
96 * @param array $kv array of key-value mappings
98 * @return Bookmark object found, or null for no hits
102 function pkeyGet($kv)
104 return Memcached_DataObject::pkeyGet('Profile_detail', $kv);
107 static function schemaDef()
111 => 'Additional profile details for the ExtendedProfile plugin',
113 'id' => array('type' => 'serial', 'not null' => true),
114 'profile_id' => array('type' => 'int', 'not null' => true),
115 'field_name' => array(
120 'value_index' => array('type' => 'int'),
121 'field_value' => array('type' => 'text'),
122 'date' => array('type' => 'datetime'),
123 'rel' => array('type' => 'varchar', 'length' => 16),
124 'rel_profile' => array('type' => 'int'),
126 'type' => 'datetime',
130 'type' => 'timestamp',
134 'primary key' => array('id'),
135 'unique keys' => array(
136 'profile_detail_profile_id_field_name_value_index'
137 => array('profile_id', 'field_name', 'value_index'),