]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - classes/Foreign_user.php
Merge branch 'nightly' of git.gnu.io:gnu/gnu-social into nightly
[quix0rs-gnu-social.git] / classes / Foreign_user.php
1 <?php
2 /**
3  * Table Definition for foreign_user
4  */
5 require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
6
7 class Foreign_user extends Managed_DataObject
8 {
9     ###START_AUTOCODE
10     /* the code below is auto generated do not remove the above tag */
11
12     public $__table = 'foreign_user';                    // table name
13     public $id;                              // bigint(8)  primary_key not_null
14     public $service;                         // int(4)  primary_key not_null
15     public $uri;                             // varchar(191)  unique_key not_null   not 255 because utf8mb4 takes more space
16     public $nickname;                        // varchar(191)   not 255 because utf8mb4 takes more space
17     public $created;                         // datetime()   not_null
18     public $modified;                        // timestamp()   not_null default_CURRENT_TIMESTAMP
19
20     /* the code above is auto generated do not remove the tag below */
21     ###END_AUTOCODE
22
23     public static function schemaDef()
24     {
25         return array(
26             'fields' => array(
27                 'id' => array('type' => 'int', 'size' => 'big', 'not null' => true, 'description' => 'unique numeric key on foreign service'),
28                 'service' => array('type' => 'int', 'not null' => true, 'description' => 'foreign key to service'),
29                 'uri' => array('type' => 'varchar', 'length' => 191, 'not null' => true, 'description' => 'identifying URI'),
30                 'nickname' => array('type' => 'varchar', 'length' => 191, 'description' => 'nickname on foreign service'),
31                 'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
32                 'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
33             ),
34             'primary key' => array('id', 'service'),
35             'foreign keys' => array(
36                 'foreign_user_service_fkey' => array('foreign_service', array('service' => 'id')),
37             ),
38             'unique keys' => array(
39                 'foreign_user_uri_key' => array('uri'),
40             ),
41         );
42     }
43
44     static function getForeignUser($id, $service) {
45
46         $fuser = new Foreign_user();
47
48         $fuser->id      = $id;
49         $fuser->service = $service;
50
51         $fuser->limit(1);
52
53         $result = $fuser->find(true);
54
55         return empty($result) ? null : $fuser;
56     }
57
58     static function getByNickname($nickname, $service)
59     {
60         if (empty($nickname) || empty($service)) {
61             return null;
62         } else {
63             $fuser = new Foreign_user();
64             $fuser->service = $service;
65             $fuser->nickname = $nickname;
66             $fuser->limit(1);
67
68             $result = $fuser->find(true);
69
70             return empty($result) ? null : $fuser;
71         }
72     }
73 }