]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - classes/Foreign_user.php
TwitterBridge messing about, Twitter OAuth requires Authorization header now?
[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         $fuser = new Foreign_user();
46         $fuser->id      = $id;
47         $fuser->service = $service;
48         $fuser->limit(1);
49
50         if (!$fuser->find(true)) {
51             throw new NoResultException($fuser);
52         }
53
54         return $fuser;
55     }
56
57     static function getByNickname($nickname, $service)
58     {
59         if (empty($nickname) || empty($service)) {
60             throw new ServerException('Empty nickname or service for Foreign_user::getByNickname');
61         }
62
63         $fuser = new Foreign_user();
64         $fuser->service = $service;
65         $fuser->nickname = $nickname;
66         $fuser->limit(1);
67
68         if (!$fuser->find(true)) {
69             throw new NoResultException($fuser);
70         }
71
72         return $fuser;
73     }
74 }