]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - plugins/RSSCloud/RSSCloudSubscription.php
don't save statuses from protected users
[quix0rs-gnu-social.git] / plugins / RSSCloud / RSSCloudSubscription.php
1 <?php
2 /*
3  * StatusNet - the distributed open-source microblogging tool
4  * Copyright (C) 2008, 2009, StatusNet, Inc.
5  *
6  * This program is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU Affero General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU Affero General Public License for more details.
15  *
16  * You should have received a copy of the GNU Affero General Public License
17  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
18  */
19
20 if (!defined('STATUSNET') && !defined('LACONICA')) {
21     exit(1);
22 }
23
24 /**
25  * Table Definition for rsscloud_subscription
26  */
27
28 require_once INSTALLDIR . '/classes/Memcached_DataObject.php';
29
30 class RSSCloudSubscription extends Memcached_DataObject {
31
32     var $__table='rsscloud_subscription'; // table name
33     var $subscribed;                      // int    primary key user id
34     var $url;                             // string primary key
35     var $failures;                        // int
36     var $created;                         // datestamp()
37     var $modified;                        // timestamp()   not_null default_CURRENT_TIMESTAMP
38
39     function staticGet($k,$v=NULL) { return DB_DataObject::staticGet('DataObjects_Grp',$k,$v); }
40
41     function table()
42     {
43
44         $db = $this->getDatabaseConnection();
45         $dbtype = $db->phptype;
46
47         $cols = array('subscribed' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL,
48                       'url'        => DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL,
49                       'failures'   => DB_DATAOBJECT_INT,
50                       'created'    => DB_DATAOBJECT_STR + DB_DATAOBJECT_DATE + DB_DATAOBJECT_TIME + DB_DATAOBJECT_NOTNULL,
51                       'modified'  => ($dbtype == 'mysql' || $dbtype == 'mysqli') ?
52                       DB_DATAOBJECT_MYSQLTIMESTAMP + DB_DATAOBJECT_NOTNULL :
53                       DB_DATAOBJECT_STR + DB_DATAOBJECT_DATE + DB_DATAOBJECT_TIME
54                       );
55
56         return $cols;
57     }
58
59     function keys()
60     {
61         return array('subscribed' => 'N', 'url' => 'N');
62     }
63
64     static function getSubscription($subscribed, $url)
65     {
66         $sub = new RSSCloudSubscription();
67         $sub->whereAdd("subscribed = $subscribed");
68         $sub->whereAdd("url = '$url'");
69         $sub->limit(1);
70
71         if ($sub->find()) {
72             $sub->fetch();
73             return $sub;
74         }
75
76         return false;
77     }
78
79 }