]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - plugins/ExtendedProfile/classes/Profile_detail.php
Merge mmn's 'nightly' changes
[quix0rs-gnu-social.git] / plugins / ExtendedProfile / classes / Profile_detail.php
1 <?php
2 /*
3  * StatusNet - the distributed open-source microblogging tool
4  * Copyright (C) 2011, StatusNet, Inc.
5  *
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.
10  *
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.
15  *
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/>.
18  */
19
20 if (!defined('STATUSNET')) {
21     exit(1);
22 }
23
24 /**
25  * DataObject class to store extended profile fields. Allows for storing
26  * multiple values per a "field_name" (field_name property is not unique).
27  *
28  * Example:
29  *
30  *     Jed's Phone Numbers
31  *     home  : 510-384-1992
32  *     mobile: 510-719-1139
33  *     work  : 415-231-1121
34  *
35  * We can store these phone numbers in a "field" represented by three
36  * Profile_detail objects, each named 'phone_number' like this:
37  *
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;
43  *
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;
49  *
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;
55  *
56  */
57 class Profile_detail extends Managed_DataObject
58 {
59     public $__table = 'profile_detail';
60
61     public $id;
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
69     public $created;
70     public $modified;
71
72     static function schemaDef()
73     {
74         return array(
75             // No need for i18n. Table properties.
76             'description'
77                 => 'Additional profile details for the ExtendedProfile plugin',
78             'fields'      => array(
79                 'id'          => array('type' => 'serial', 'not null' => true),
80                 'profile_id'  => array('type' => 'int', 'not null' => true),
81                 'field_name'  => array(
82                     'type'     => 'varchar',
83                     'length'   => 16,
84                     'not null' => true
85                 ),
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'),
91                 'created'     => array(
92                     'type'     => 'datetime',
93                     'not null' => true
94                  ),
95                 'modified'    => array(
96                     'type' => 'timestamp',
97                     'not null' => true
98                 ),
99             ),
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'),
104             )
105         );
106     }
107 }