]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - classes/User_username.php
This JavaScript file is located in js/ - Fixed paths for all targets.
[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     public static function schemaDef()
23     {
24         return array(
25             'fields' => array(
26                 'provider_name' => array('type' => 'varchar', 'length' => 255, 'description' => 'provider name'),
27                 'username' => array('type' => 'varchar', 'length' => 255, 'description' => 'username'),
28                 'user_id' => array('type' => 'int', 'not null' => true, 'description' => 'notice id this title relates to'),
29                 'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
30                 'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
31             ),
32             'primary key' => array('provider_name', 'username'),
33             'foreign keys' => array(
34                 'user_username_user_id_fkey' => array('user', array('user_id' => 'id')),
35             ),
36         );
37     }
38
39     /**
40     * Register a user with a username on a given provider
41     * @param User User object
42     * @param string username on the given provider
43     * @param provider_name string name of the provider
44     * @return mixed User_username instance if the registration succeeded, false if it did not
45     */
46     static function register($user, $username, $provider_name)
47     {
48         $user_username = new User_username();
49         $user_username->user_id = $user->id;
50         $user_username->provider_name = $provider_name;
51         $user_username->username = $username;
52         $user_username->created = common_sql_now();
53
54         if($user_username->insert()){
55             return $user_username;
56         }else{
57             return false;
58         }
59     }
60 }