]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - _darcs/pristine/classes/Foreign_link.php
replace all tabs with four spaces
[quix0rs-gnu-social.git] / _darcs / pristine / classes / Foreign_link.php
1 <?php
2 /**
3  * Table Definition for foreign_link
4  */
5 require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
6
7 class Foreign_link extends Memcached_DataObject 
8 {
9     ###START_AUTOCODE
10     /* the code below is auto generated do not remove the above tag */
11
12     public $__table = 'foreign_link';                    // table name
13     public $user_id;                         // int(4)  primary_key not_null
14     public $foreign_id;                      // int(4)  primary_key not_null
15     public $service;                         // int(4)  primary_key not_null
16     public $credentials;                     // varchar(255)  
17     public $noticesync;                      // tinyint(1)   not_null default_1
18     public $friendsync;                      // tinyint(1)   not_null default_2
19     public $profilesync;                     // tinyint(1)   not_null default_1
20     public $created;                         // datetime()   not_null
21     public $modified;                        // timestamp()   not_null default_CURRENT_TIMESTAMP
22
23     /* Static get */
24     function staticGet($k,$v=NULL) { return Memcached_DataObject::staticGet('Foreign_link',$k,$v); }
25
26     /* the code above is auto generated do not remove the tag below */
27     ###END_AUTOCODE
28
29     // XXX:  This only returns a 1->1 single obj mapping.  Change?  Or make
30     // a getForeignUsers() that returns more than one? --Zach
31     static function getByUserID($user_id, $service) {
32         $flink = new Foreign_link();
33         $flink->service = $service;
34         $flink->user_id = $user_id;
35         $flink->limit(1);
36
37         if ($flink->find(TRUE)) {
38             return $flink;
39         }
40
41         return NULL;        
42     }
43     
44     static function getByForeignID($foreign_id, $service) {
45         $flink = new Foreign_link();
46         $flink->service = $service;
47         $flink->foreign_id = $foreign_id;
48         $flink->limit(1);
49
50         if ($flink->find(TRUE)) {
51             return $flink;
52         }
53
54         return NULL;        
55     }
56         
57     # Convenience methods
58     function getForeignUser() {        
59         $fuser = new Foreign_user();
60         $fuser->service = $this->service;
61         $fuser->id = $this->foreign_id;
62         
63         $fuser->limit(1);
64         
65         if ($fuser->find(TRUE)) {
66             return $fuser;
67         }
68         
69         return NULL;        
70     }
71     
72     function getUser() {
73         return User::staticGet($this->user_id);
74     }
75         
76 }