]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - classes/User_username.php
staticGet for sub-Managed_DataObject classes now calls parent
[quix0rs-gnu-social.git] / classes / User_username.php
1 <?php
2 /**
3  * Table Definition for user_username
4  */
5 require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
6
7 class User_username extends Managed_DataObject
8 {
9     ###START_AUTOCODE
10     /* the code below is auto generated do not remove the above tag */
11
12     public $__table = 'user_username';                     // table name
13     public $user_id;                        // int(4)  not_null
14     public $provider_name;                  // varchar(255)  primary_key not_null
15     public $username;                       // varchar(255)  primary_key not_null
16     public $created;                        // datetime()   not_null
17     public $modified;                       // timestamp()   not_null default_CURRENT_TIMESTAMP
18
19     /* the code above is auto generated do not remove the tag below */
20     ###END_AUTOCODE
21
22     /**
23     * Register a user with a username on a given provider
24     * @param User User object
25     * @param string username on the given provider
26     * @param provider_name string name of the provider
27     * @return mixed User_username instance if the registration succeeded, false if it did not
28     */
29     static function register($user, $username, $provider_name)
30     {
31         $user_username = new User_username();
32         $user_username->user_id = $user->id;
33         $user_username->provider_name = $provider_name;
34         $user_username->username = $username;
35         $user_username->created = DB_DataObject_Cast::dateTime();
36
37         if($user_username->insert()){
38             return $user_username;
39         }else{
40             return false;
41         }
42     }
43
44     function table() {
45         return array(
46             'user_id'     => DB_DATAOBJECT_INT,
47             'username'   => DB_DATAOBJECT_STR,
48             'provider_name'   => DB_DATAOBJECT_STR ,
49             'created'   => DB_DATAOBJECT_STR + DB_DATAOBJECT_DATE + DB_DATAOBJECT_TIME
50         );
51     }
52
53     // now define the keys.
54     function keys() {
55         return array('provider_name' => 'K', 'username' => 'K');
56     }
57 }