2011-02-03 01:29:34 +00:00
|
|
|
<?php
|
2011-02-04 01:15:12 +00:00
|
|
|
/*
|
|
|
|
* StatusNet - the distributed open-source microblogging tool
|
|
|
|
* Copyright (C) 2011, StatusNet, Inc.
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2011-02-03 01:29:34 +00:00
|
|
|
*/
|
2011-02-04 01:15:12 +00:00
|
|
|
|
|
|
|
if (!defined('STATUSNET')) {
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
2011-03-08 01:26:19 +00:00
|
|
|
/**
|
|
|
|
* DataObject class to store extended profile fields. Allows for storing
|
2011-03-10 02:00:24 +00:00
|
|
|
* multiple values per a "field_name" (field_name property is not unique).
|
2011-03-08 01:26:19 +00:00
|
|
|
*
|
|
|
|
* 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();
|
2011-03-10 02:00:24 +00:00
|
|
|
* $phone1->field_name = 'phone_number';
|
2011-03-08 01:26:19 +00:00
|
|
|
* $phone1->rel = 'home';
|
2011-03-10 02:16:02 +00:00
|
|
|
* $phone1->field_value = '510-384-1992';
|
2011-03-10 02:00:24 +00:00
|
|
|
* $phone1->value_index = 1;
|
2011-03-08 01:26:19 +00:00
|
|
|
*
|
|
|
|
* $phone1 = new Profile_detail();
|
2011-03-10 02:00:24 +00:00
|
|
|
* $phone1->field_name = 'phone_number';
|
2011-03-08 01:26:19 +00:00
|
|
|
* $phone1->rel = 'mobile';
|
2011-03-10 02:16:02 +00:00
|
|
|
* $phone1->field_value = '510-719-1139';
|
2011-03-10 02:00:24 +00:00
|
|
|
* $phone1->value_index = 2;
|
2011-03-08 01:26:19 +00:00
|
|
|
*
|
|
|
|
* $phone1 = new Profile_detail();
|
2011-03-10 02:00:24 +00:00
|
|
|
* $phone1->field_name = 'phone_number';
|
2011-03-08 01:26:19 +00:00
|
|
|
* $phone1->rel = 'work';
|
2011-03-10 02:00:24 +00:00
|
|
|
* $phone1->field_value = '415-231-1121';
|
|
|
|
* $phone1->value_index = 3;
|
2011-03-08 01:26:19 +00:00
|
|
|
*
|
|
|
|
*/
|
2011-03-10 02:00:24 +00:00
|
|
|
class Profile_detail extends Managed_DataObject
|
2011-02-03 01:29:34 +00:00
|
|
|
{
|
2011-03-08 01:26:19 +00:00
|
|
|
public $__table = 'profile_detail';
|
2011-02-04 01:15:12 +00:00
|
|
|
|
2011-02-03 01:29:34 +00:00
|
|
|
public $id;
|
2011-03-10 02:00:24 +00:00
|
|
|
public $profile_id; // profile this is for
|
2011-03-08 01:26:19 +00:00
|
|
|
public $rel; // detail for some field types; eg "home", "mobile", "work" for phones or "aim", "irc", "xmpp" for IM
|
2011-03-10 02:00:24 +00:00
|
|
|
public $field_name; // name
|
2011-03-10 02:16:02 +00:00
|
|
|
public $field_value; // primary text value
|
2011-03-10 02:00:24 +00:00
|
|
|
public $value_index; // relative ordering of multiple values in the same field
|
2011-02-03 01:29:34 +00:00
|
|
|
public $ref_profile; // for people types, allows pointing to a known profile in the system
|
2011-02-04 01:15:12 +00:00
|
|
|
public $created;
|
|
|
|
public $modified;
|
|
|
|
|
|
|
|
/**
|
2011-03-10 02:00:24 +00:00
|
|
|
* Get an instance by key
|
2011-02-04 01:15:12 +00:00
|
|
|
*
|
2011-03-10 02:00:24 +00:00
|
|
|
* This is a utility method to get a single instance with a given key value.
|
2011-02-04 01:15:12 +00:00
|
|
|
*
|
2011-03-10 02:00:24 +00:00
|
|
|
* @param string $k Key to use to lookup
|
|
|
|
* @param mixed $v Value to lookup
|
2011-03-08 01:26:19 +00:00
|
|
|
*
|
2011-03-10 02:00:24 +00:00
|
|
|
* @return User_greeting_count object found, or null for no hits
|
2011-03-08 01:26:19 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2011-03-10 02:00:24 +00:00
|
|
|
function staticGet($k, $v=null)
|
2011-02-04 01:15:12 +00:00
|
|
|
{
|
2011-03-10 02:00:24 +00:00
|
|
|
return Memcached_DataObject::staticGet('Profile_detail', $k, $v);
|
2011-02-04 01:15:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2011-03-10 02:00:24 +00:00
|
|
|
* Get an instance by compound key
|
2011-02-04 01:15:12 +00:00
|
|
|
*
|
2011-03-10 02:00:24 +00:00
|
|
|
* This is a utility method to get a single instance with a given set of
|
|
|
|
* key-value pairs. Usually used for the primary key for a compound key; thus
|
|
|
|
* the name.
|
2011-02-04 01:15:12 +00:00
|
|
|
*
|
2011-03-10 02:00:24 +00:00
|
|
|
* @param array $kv array of key-value mappings
|
2011-02-04 01:15:12 +00:00
|
|
|
*
|
2011-03-10 02:00:24 +00:00
|
|
|
* @return Bookmark object found, or null for no hits
|
2011-02-04 01:15:12 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2011-03-10 02:00:24 +00:00
|
|
|
function pkeyGet($kv)
|
2011-02-04 01:15:12 +00:00
|
|
|
{
|
2011-03-10 02:00:24 +00:00
|
|
|
return Memcached_DataObject::pkeyGet('Profile_detail', $kv);
|
2011-02-04 01:15:12 +00:00
|
|
|
}
|
|
|
|
|
2011-03-10 02:00:24 +00:00
|
|
|
static function schemaDef()
|
2011-02-04 01:15:12 +00:00
|
|
|
{
|
2011-03-10 02:00:24 +00:00
|
|
|
return array(
|
|
|
|
'description'
|
|
|
|
=> 'Additional profile details for the ExtendedProfile plugin',
|
|
|
|
'fields' => array(
|
|
|
|
'id' => array('type' => 'serial', 'not null' => true),
|
|
|
|
'profile_id' => array('type' => 'int', 'not null' => true),
|
|
|
|
'field_name' => array(
|
|
|
|
'type' => 'varchar',
|
|
|
|
'length' => 16,
|
|
|
|
'not null' => true
|
|
|
|
),
|
|
|
|
'value_index' => array('type' => 'int'),
|
|
|
|
'field_value' => array('type' => 'text'),
|
|
|
|
'rel' => array('type' => 'varchar', 'length' => 16),
|
|
|
|
'rel_profile' => array('type' => 'int'),
|
|
|
|
'created' => array(
|
|
|
|
'type' => 'datetime',
|
|
|
|
'not null' => true
|
|
|
|
),
|
|
|
|
'modified' => array(
|
|
|
|
'type' => 'timestamp',
|
|
|
|
'not null' => true
|
|
|
|
),
|
|
|
|
),
|
|
|
|
'primary key' => array('id'),
|
|
|
|
'unique keys' => array(
|
2011-03-10 02:16:02 +00:00
|
|
|
'profile_detail_profile_id_field_name_value_index'
|
2011-03-10 02:00:24 +00:00
|
|
|
=> array('profile_id', 'field_name', 'value_index'),
|
|
|
|
)
|
|
|
|
);
|
2011-02-04 01:15:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|