forked from GNUsocial/gnu-social
Merge branch '0.9.x' into 1.0.x
This commit is contained in:
@@ -50,6 +50,7 @@ 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.
|
||||
@@ -322,5 +323,17 @@ class TwitterBridgePlugin extends Plugin
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expose the adminImportControl setting to the administration panel code.
|
||||
* This allows us to disable the import bridge enabling checkbox for administrators,
|
||||
* since on a bulk farm site we can't yet automate the import daemon setup.
|
||||
*
|
||||
* @return boolean hook value;
|
||||
*/
|
||||
function onTwitterBridgeAdminImportControl()
|
||||
{
|
||||
return (bool)$this->adminImportControl;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@@ -75,8 +75,6 @@ function save_twitter_user($twitter_id, $screen_name)
|
||||
|
||||
if (!empty($fuser)) {
|
||||
|
||||
$result = true;
|
||||
|
||||
// Delete old record if Twitter user changed screen name
|
||||
|
||||
if ($fuser->nickname != $screen_name) {
|
||||
@@ -88,6 +86,25 @@ function save_twitter_user($twitter_id, $screen_name)
|
||||
$screen_name,
|
||||
$oldname));
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
// Kill any old, invalid records for this screen name
|
||||
|
||||
$fuser = Foreign_user::getByNickname($screen_name, TWITTER_SERVICE);
|
||||
|
||||
if (!empty($fuser)) {
|
||||
$fuser->delete();
|
||||
common_log(
|
||||
LOG_INFO,
|
||||
sprintf(
|
||||
'Twitter bridge - deteted old record for Twitter ' .
|
||||
'screen name "%s" belonging to Twitter ID %d.',
|
||||
$screen_name,
|
||||
$fuser->id
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return add_twitter_user($twitter_id, $screen_name);
|
||||
|
@@ -92,9 +92,11 @@ class TwitteradminpanelAction extends AdminPanelAction
|
||||
);
|
||||
|
||||
static $booleans = array(
|
||||
'twitter' => array('signin'),
|
||||
'twitterimport' => array('enabled')
|
||||
'twitter' => array('signin')
|
||||
);
|
||||
if (Event::handle('TwitterBridgeAdminImportControl')) {
|
||||
$booleans['twitterimport'] = array('enabled');
|
||||
}
|
||||
|
||||
$values = array();
|
||||
|
||||
@@ -155,6 +157,13 @@ class TwitteradminpanelAction extends AdminPanelAction
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function isImportEnabled()
|
||||
{
|
||||
// Since daemon setup isn't automated yet...
|
||||
// @todo: if merged into main queues, detect presence of daemon config
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
class TwitterAdminPanelForm extends AdminForm
|
||||
@@ -263,13 +272,15 @@ class TwitterAdminPanelForm extends AdminForm
|
||||
);
|
||||
$this->unli();
|
||||
|
||||
$this->li();
|
||||
$this->out->checkbox(
|
||||
'enabled', _m('Enable Twitter import'),
|
||||
(bool) $this->value('enabled', 'twitterimport'),
|
||||
_m('Allow users to import their Twitter friends\' timelines')
|
||||
);
|
||||
$this->unli();
|
||||
if (Event::handle('TwitterBridgeAdminImportControl')) {
|
||||
$this->li();
|
||||
$this->out->checkbox(
|
||||
'enabled', _m('Enable Twitter import'),
|
||||
(bool) $this->value('enabled', 'twitterimport'),
|
||||
_m('Allow users to import their Twitter friends\' timelines. Requires daemons to be manually configured.')
|
||||
);
|
||||
$this->unli();
|
||||
}
|
||||
|
||||
$this->out->elementEnd('ul');
|
||||
|
||||
|
Reference in New Issue
Block a user