]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - plugins/Authentication/User_username.php
Merge branch '0.9.x' of git@gitorious.org:statusnet/mainline into 0.9.x
[quix0rs-gnu-social.git] / plugins / Authentication / User_username.php
1 <?php
2 /**
3  * Table Definition for user_username
4  */
5 require_once INSTALLDIR.'/classes/Plugin_DataObject.php';
6
7 class User_username extends Plugin_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     /* Static get */
20     function staticGet($k,$v=null)
21     { return Memcached_DataObject::staticGet('User_username',$k,$v); }
22
23     /* the code above is auto generated do not remove the tag below */
24     ###END_AUTOCODE
25
26     /**
27     * Register a user with a username on a given provider
28     * @param User User object
29     * @param string username on the given provider
30     * @param provider_name string name of the provider
31     * @return mixed User_username instance if the registration succeeded, false if it did not
32     */
33     static function register($user, $username, $provider_name)
34     {
35         $user_username = new User_username();
36         $user_username->user_id = $user->id;
37         $user_username->provider_name = $provider_name;
38         $user_username->username = $username;
39         $user_username->created = DB_DataObject_Cast::dateTime();
40         if($user_username->insert()){
41             return $user_username;
42         }else{
43             return false;
44         }
45     }
46
47     /**
48     * Get the TableDef object that represents the table backing this class
49     * @return TableDef TableDef instance
50     */
51     function tableDef()
52     {
53         return new TableDef($this->__table,
54                              array(new ColumnDef('provider_name', 'varchar',
55                                                  '255', false, 'PRI'),
56                                    new ColumnDef('username', 'varchar',
57                                                  '255', false, 'PRI'),
58                                    new ColumnDef('user_id', 'integer',
59                                                  null, false),
60                                    new ColumnDef('created', 'datetime',
61                                                  null, false),
62                                    new ColumnDef('modified', 'timestamp')));
63     }
64 }