123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 |
- <?php
- if (!defined('STATUSNET')) {
- exit(1);
- }
- require_once INSTALLDIR . '/classes/Memcached_DataObject.php';
- class Notice_to_status extends Managed_DataObject
- {
- public $__table = 'notice_to_status';
- public $notice_id;
- public $status_id;
- public $created;
- public $modified;
- public static function schemaDef()
- {
- return array(
- 'fields' => array(
- 'notice_id' => array('type' => 'int', 'not null' => true, 'description' => 'local notice id'),
- 'status_id' => array('type' => 'int', 'size' => 'big', 'not null' => true, 'description' => 'twitter status id'),
- 'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
- 'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
- ),
- 'primary key' => array('notice_id'),
- 'unique keys' => array(
- 'status_id_key' => array('status_id'),
- ),
- 'foreign keys' => array(
- 'notice_to_status_notice_id_fkey' => array('notice', array('notice_id' => 'id')),
- ),
- );
- }
-
- static function saveNew($notice_id, $status_id)
- {
- if (empty($notice_id)) {
- throw new Exception("Invalid notice_id $notice_id");
- }
- $n2s = Notice_to_status::getKV('notice_id', $notice_id);
- if (!empty($n2s)) {
- return $n2s;
- }
- if (empty($status_id)) {
- throw new Exception("Invalid status_id $status_id");
- }
- $n2s = Notice_to_status::getKV('status_id', $status_id);
- if (!empty($n2s)) {
- return $n2s;
- }
- common_debug("Mapping notice {$notice_id} to Twitter status {$status_id}");
- $n2s = new Notice_to_status();
- $n2s->notice_id = $notice_id;
- $n2s->status_id = $status_id;
- $n2s->created = common_sql_now();
- $n2s->insert();
- return $n2s;
- }
- }
|