change how Foreign_link fetches, and fix mixup between user-ids and foreign-ids in twittersettings
darcs-hash:20080923054413-5ed1f-a317e07925101215e87d2db0c574d20c1cfac665.gz
This commit is contained in:
parent
44f7dc2a76
commit
858e55f5b4
@ -35,7 +35,7 @@ class TwittersettingsAction extends SettingsAction {
|
|||||||
$flink = Foreign_link::getForeignLink($user->id, 1); // 1 == Twitter
|
$flink = Foreign_link::getForeignLink($user->id, 1); // 1 == Twitter
|
||||||
|
|
||||||
if ($flink) {
|
if ($flink) {
|
||||||
$fuser = Foreign_user::staticGet('user_id', $flink->user_id);
|
$fuser = Foreign_user::getForeignUser($flink->foreign_id, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->form_header(_('Twitter settings'), $msg, $success);
|
$this->form_header(_('Twitter settings'), $msg, $success);
|
||||||
@ -54,7 +54,7 @@ class TwittersettingsAction extends SettingsAction {
|
|||||||
common_element('a', array('href' => $fuser->uri), $fuser->uri);
|
common_element('a', array('href' => $fuser->uri), $fuser->uri);
|
||||||
common_element('span', 'input_instructions',
|
common_element('span', 'input_instructions',
|
||||||
_('Current verified Twitter account.'));
|
_('Current verified Twitter account.'));
|
||||||
common_hidden('flink_user_id', $flink->user_id);
|
common_hidden('flink_foreign_id', $flink->foreign_id);
|
||||||
common_element_end('p');
|
common_element_end('p');
|
||||||
common_submit('remove', _('Remove'));
|
common_submit('remove', _('Remove'));
|
||||||
} else {
|
} else {
|
||||||
@ -175,14 +175,14 @@ class TwittersettingsAction extends SettingsAction {
|
|||||||
// For now we assume one Twitter acct per Laconica acct
|
// For now we assume one Twitter acct per Laconica acct
|
||||||
$flink = Foreign_link::getForeignLink($user->id, 1);
|
$flink = Foreign_link::getForeignLink($user->id, 1);
|
||||||
$fuser = Foreign_user::getForeignUser($flink->foreign_id, 1);
|
$fuser = Foreign_user::getForeignUser($flink->foreign_id, 1);
|
||||||
$flink_user_id = $this->arg('flink_user_id');
|
$flink_foreign_id = $this->arg('flink_foreign_id');
|
||||||
|
|
||||||
if (!$flink) {
|
if (!$flink) {
|
||||||
common_debug("couldn't get flink");
|
common_debug("couldn't get flink");
|
||||||
}
|
}
|
||||||
|
|
||||||
# Maybe an old tab open...?
|
# Maybe an old tab open...?
|
||||||
if ($flink->user_id != $flink_user_id) {
|
if ($flink->foreign_id != $flink_foreign_id) {
|
||||||
common_debug("flink user_id = " . $flink->user_id);
|
common_debug("flink user_id = " . $flink->user_id);
|
||||||
$this->show_form(_('That is not your Twitter account.'));
|
$this->show_form(_('That is not your Twitter account.'));
|
||||||
return;
|
return;
|
||||||
@ -191,7 +191,7 @@ class TwittersettingsAction extends SettingsAction {
|
|||||||
$result = $fuser->delete();
|
$result = $fuser->delete();
|
||||||
|
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
common_log_db_error($flink, 'DELETE', __FILE__);
|
common_log_db_error($fuser, 'DELETE', __FILE__);
|
||||||
$this->show_form(_('Couldn\'t remove Twitter user.'));
|
$this->show_form(_('Couldn\'t remove Twitter user.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -30,12 +30,11 @@ class Foreign_link extends DB_DataObject
|
|||||||
// a getForeignUsers() that returns more than one? --Zach
|
// a getForeignUsers() that returns more than one? --Zach
|
||||||
static function getForeignLink($user_id, $service) {
|
static function getForeignLink($user_id, $service) {
|
||||||
$flink = new Foreign_link();
|
$flink = new Foreign_link();
|
||||||
$flink->whereAdd("service = $service");
|
$flink->service = $service;
|
||||||
$flink->whereAdd("user_id = $user_id");
|
$flink->user_id = $user_id;
|
||||||
$flink->limit(1);
|
$flink->limit(1);
|
||||||
|
|
||||||
if ($flink->find()) {
|
if ($flink->find(TRUE)) {
|
||||||
$flink->fetch();
|
|
||||||
return $flink;
|
return $flink;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -44,13 +43,15 @@ class Foreign_link extends DB_DataObject
|
|||||||
|
|
||||||
// Convenience method
|
// Convenience method
|
||||||
function getForeignUser() {
|
function getForeignUser() {
|
||||||
|
|
||||||
$fuser = new Foreign_user();
|
$fuser = new Foreign_user();
|
||||||
$fuser->whereAdd('service = ' . $this->service);
|
|
||||||
$fuser->whereAdd('id = ' . $this->foreign_id);
|
$fuser->service = $this->service;
|
||||||
|
$fuser->id = $this->foreign_id;
|
||||||
|
|
||||||
$fuser->limit(1);
|
$fuser->limit(1);
|
||||||
|
|
||||||
if ($fuser->find()) {
|
if ($fuser->find(TRUE)) {
|
||||||
$fuser->fetch();
|
|
||||||
return $fuser;
|
return $fuser;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user