]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - classes/Foreign_link.php
change NOTICE_GATEWAY to Notice::GATEWAY so autoloading works
[quix0rs-gnu-social.git] / 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;                      // bigint(8)  primary_key not_null unsigned
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 $last_noticesync;                 // datetime()
21     public $last_friendsync;                 // datetime()
22     public $created;                         // datetime()   not_null
23     public $modified;                        // timestamp()   not_null default_CURRENT_TIMESTAMP
24
25     /* Static get */
26     function staticGet($k,$v=null)
27     { return Memcached_DataObject::staticGet('Foreign_link',$k,$v); }
28
29     /* the code above is auto generated do not remove the tag below */
30     ###END_AUTOCODE
31
32     // XXX:  This only returns a 1->1 single obj mapping.  Change?  Or make
33     // a getForeignUsers() that returns more than one? --Zach
34     static function getByUserID($user_id, $service)
35     {
36         $flink = new Foreign_link();
37         $flink->service = $service;
38         $flink->user_id = $user_id;
39         $flink->limit(1);
40
41         if ($flink->find(true)) {
42             return $flink;
43         }
44
45         return null;
46     }
47
48     static function getByForeignID($foreign_id, $service)
49     {
50         $flink = new Foreign_link();
51         $flink->service = $service;
52         $flink->foreign_id = $foreign_id;
53         $flink->limit(1);
54
55         if ($flink->find(true)) {
56             return $flink;
57         }
58
59         return null;
60     }
61
62     function set_flags($noticesend, $noticerecv, $replysync, $friendsync)
63     {
64         if ($noticesend) {
65             $this->noticesync |= FOREIGN_NOTICE_SEND;
66         } else {
67             $this->noticesync &= ~FOREIGN_NOTICE_SEND;
68         }
69         
70         if ($noticerecv) {
71             $this->noticesync |= FOREIGN_NOTICE_RECV;
72         } else {
73             $this->noticesync &= ~FOREIGN_NOTICE_RECV;
74         }
75
76         if ($replysync) {
77             $this->noticesync |= FOREIGN_NOTICE_SEND_REPLY;
78         } else {
79             $this->noticesync &= ~FOREIGN_NOTICE_SEND_REPLY;
80         }
81
82         if ($friendsync) {
83             $this->friendsync |= FOREIGN_FRIEND_RECV;
84         } else {
85             $this->friendsync &= ~FOREIGN_FRIEND_RECV;
86         }
87
88         $this->profilesync = 0;
89     }
90
91     # Convenience methods
92     function getForeignUser()
93     {
94         $fuser = new Foreign_user();
95         $fuser->service = $this->service;
96         $fuser->id = $this->foreign_id;
97
98         $fuser->limit(1);
99
100         if ($fuser->find(true)) {
101             return $fuser;
102         }
103
104         return null;
105     }
106
107     function getUser()
108     {
109         return User::staticGet($this->user_id);
110     }
111
112 }