* @link http://status.net/
* @link http://twitter.com/
*/
-
class TwitterBridgePlugin extends Plugin
{
-
const VERSION = STATUSNET_VERSION;
public $adminImportControl = false; // Should the 'import' checkbox be exposed in the admin panel?
/**
* Initializer for the plugin.
*/
-
function initialize()
{
// Allow the key and secret to be passed in
*
* @return boolean result
*/
-
static function hasKeys()
{
$ckey = common_config('twitter', 'consumer_key');
*
* @return boolean hook return
*/
-
function onRouterInitialized($m)
{
$m->connect('admin/twitter', array('action' => 'twitteradminpanel'));
*
* @return boolean hook value
*/
-
function onPluginVersion(&$versions)
{
$versions[] = array(
'author' => 'Zach Copley, Julien C',
'homepage' => 'http://status.net/wiki/Plugin:TwitterBridge',
'rawdescription' => _m(
- 'The Twitter "bridge" plugin allows you to integrate ' .
- 'your StatusNet instance with ' .
+ 'The Twitter "bridge" plugin allows integration ' .
+ 'of a StatusNet instance with ' .
'<a href="http://twitter.com/">Twitter</a>.'
)
);
*
* @return boolean hook value; true means continue processing, false means stop.
*/
-
function onCheckSchema()
{
$schema = Schema::get();
// home_timeline, messages (in), messages (out), ...
$schema->ensureTable('twitter_synch_status',
- array(new ColumnDef('user_id', 'integer', null,
+ array(new ColumnDef('foreign_id', 'bigint', null,
false, 'PRI'),
new ColumnDef('timeline', 'varchar', 255,
false, 'PRI'),
new ColumnDef('last_id', 'bigint', null, // XXX: check for PostgreSQL
false),
new ColumnDef('created', 'datetime', null,
+ false),
+ new ColumnDef('modified', 'datetime', null,
false)));
// For storing user-submitted flags on profiles
new ColumnDef('created', 'datetime', null,
false)));
- // We update any notices that may have come in from
- // Twitter that we don't have a status_id for. Note that
- // this won't catch notices that originated at this StatusNet site.
-
- $n = new Notice();
-
- $n->query('SELECT notice.id, notice.uri ' .
- 'FROM notice LEFT JOIN notice_to_status ' .
- 'ON notice.id = notice_to_status.notice_id ' .
- 'WHERE notice.source = "twitter"' .
- 'AND notice_to_status.status_id IS NULL');
-
- while ($n->fetch()) {
- if (preg_match('#^http://twitter.com/[\w_.]+/status/(\d+)$#', $n->uri, $match)) {
-
- $status_id = $match[1];
-
- Notice_to_status::saveNew($n->id, $status_id);
- }
- }
-
return true;
}
/**
- * If a notice gets deleted, remove the Notice_to_status mapping
+ * If a notice gets deleted, remove the Notice_to_status mapping and
+ * delete the status on Twitter.
*
+ * @param User $user The user doing the deleting
* @param Notice $notice The notice getting deleted
*
* @return boolean hook value
*/
-
- function onNoticeDeleteRelated($notice)
+ function onStartDeleteOwnNotice(User $user, Notice $notice)
{
$n2s = Notice_to_status::staticGet('notice_id', $notice->id);
if (!empty($n2s)) {
- $user = common_current_user();
-
- if (empty($user) || $user->id != $notice->profile_id) {
- $this->log(LOG_INFO, "Skipping deleting notice for {$notice->id} since it doesn't seem to be by the author.");
- return true;
- }
-
$flink = Foreign_link::getByUserID($notice->profile_id,
TWITTER_SERVICE); // twitter service
* @param Notice $notice being favored
* @return hook return value
*/
-
function onEndFavorNotice(Profile $profile, Notice $notice)
{
$flink = Foreign_link::getByUserID($profile->id,
*
* @return hook return value
*/
-
function onEndDisfavorNotice(Profile $profile, Notice $notice)
{
$flink = Foreign_link::getByUserID($profile->id,