RSSCloudSubscription.php 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. if (!defined('STATUSNET') && !defined('LACONICA')) {
  20. exit(1);
  21. }
  22. /**
  23. * Table Definition for rsscloud_subscription
  24. */
  25. require_once INSTALLDIR . '/classes/Memcached_DataObject.php';
  26. class RSSCloudSubscription extends Memcached_DataObject {
  27. var $__table='rsscloud_subscription'; // table name
  28. var $subscribed; // int primary key user id
  29. var $url; // string primary key
  30. var $failures; // int
  31. var $created; // datestamp()
  32. var $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
  33. static function getKV($k,$v=NULL) { return DB_DataObject::staticGet('DataObjects_Grp',$k,$v); }
  34. function table()
  35. {
  36. $db = $this->getDatabaseConnection();
  37. $dbtype = $db->phptype;
  38. $cols = array('subscribed' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL,
  39. 'url' => DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL,
  40. 'failures' => DB_DATAOBJECT_INT,
  41. 'created' => DB_DATAOBJECT_STR + DB_DATAOBJECT_DATE + DB_DATAOBJECT_TIME + DB_DATAOBJECT_NOTNULL,
  42. 'modified' => ($dbtype == 'mysql' || $dbtype == 'mysqli') ?
  43. DB_DATAOBJECT_MYSQLTIMESTAMP + DB_DATAOBJECT_NOTNULL :
  44. DB_DATAOBJECT_STR + DB_DATAOBJECT_DATE + DB_DATAOBJECT_TIME
  45. );
  46. return $cols;
  47. }
  48. function keys()
  49. {
  50. return array('subscribed' => 'N', 'url' => 'N');
  51. }
  52. static function getSubscription($subscribed, $url)
  53. {
  54. $sub = new RSSCloudSubscription();
  55. $sub->whereAdd("subscribed = $subscribed");
  56. $sub->whereAdd("url = '$url'");
  57. $sub->limit(1);
  58. if ($sub->find()) {
  59. $sub->fetch();
  60. return $sub;
  61. }
  62. return false;
  63. }
  64. }