summaryrefslogtreecommitdiff
path: root/actions
diff options
context:
space:
mode:
Diffstat (limited to 'actions')
-rw-r--r--actions/facebookhome.php93
-rw-r--r--actions/facebookinvite.php3
-rw-r--r--actions/facebookremove.php2
-rw-r--r--actions/facebooksettings.php4
4 files changed, 70 insertions, 32 deletions
diff --git a/actions/facebookhome.php b/actions/facebookhome.php
index 7430cc41f..3696df90a 100644
--- a/actions/facebookhome.php
+++ b/actions/facebookhome.php
@@ -30,6 +30,9 @@ class FacebookhomeAction extends FacebookAction
$facebook = get_facebook();
$fbuid = $facebook->require_login();
+
+ // Check to see whether there's already a Facebook link for this user
+ $flink = Foreign_link::getByForeignID($fbuid, FACEBOOK_SERVICE);
// If the user has opted not to initially allow the app to have
// Facebook status update permission, store that preference. Only
@@ -39,11 +42,13 @@ class FacebookhomeAction extends FacebookAction
FACEBOOK_PROMPTED_UPDATE_PREF, 'true');
}
- // Check to see whether there's already a Facebook link for this user
- $flink = Foreign_link::getByForeignID($fbuid, FACEBOOK_SERVICE);
-
if ($flink) {
+ if ($_POST['submit'] == 'Send') {
+ $this->saveNewNotice($flink);
+ return;
+ }
+
$user = $flink->getUser();
common_set_user($user);
@@ -136,19 +141,16 @@ class FacebookhomeAction extends FacebookAction
$notice = $user->getCurrentNotice();
update_profile_box($facebook, $fbuid, $user, $notice);
-
- $this->showHeader('Home');
-
- if ($msg) {
- common_element('fb:success', array('message' => $msg));
- }
-
- echo $this->show_notices($user);
+ $this->showHeader($msg);
+ $this->showNoticeForm($user);
+ $this->showNav('Home');
+
+ echo $this->showNotices($user);
$this->showFooter();
}
- function show_notices($user)
+ function showNotices($user)
{
$page = $this->trimmed('page');
@@ -158,13 +160,13 @@ class FacebookhomeAction extends FacebookAction
$notice = $user->noticesWithFriends(($page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1);
- $cnt = $this->show_notice_list($notice);
+ $cnt = $this->showNoticeList($notice);
- common_pagination($page > 1, $cnt > NOTICES_PER_PAGE,
- $page, 'all', array('nickname' => $user->nickname));
+ facebookPagination($page > 1, $cnt > NOTICES_PER_PAGE,
+ $page, 'all', array('nickname' => $user->nickname));
}
- function show_notice_list($notice)
+ function showNoticeList($notice)
{
$nl = new FacebookNoticeList($notice);
return $nl->show();
@@ -175,19 +177,10 @@ class FacebookhomeAction extends FacebookAction
$facebook = get_facebook();
$fbuid = $facebook->require_login();
- start_fbml();
+ startFBML();
- common_element('link', array('rel' => 'stylesheet',
- 'type' => 'text/css',
- 'href' => getFacebookBaseCSS()));
-
- common_element('link', array('rel' => 'stylesheet',
- 'type' => 'text/css',
- 'href' => getFacebookThemeCSS()));
-
- common_element('script', array('type' => 'text/javascript',
- 'src' => getFacebookJS()),
- ' ');
+ $this->showStylesheets();
+ $this->showScripts();
$this->showLogo();
@@ -231,5 +224,49 @@ class FacebookhomeAction extends FacebookAction
common_end_xml();
}
+
+ function saveNewNotice($flink)
+ {
+
+ $user = $flink->getUser();
+ $content = $_POST['status_textarea'];
+
+ if (!$content) {
+ $this->showHome($flink, _('No content!'));
+ return;
+ } else {
+ $content_shortened = common_shorten_links($content);
+
+ if (mb_strlen($content_shortened) > 140) {
+ common_debug("Content = '$content_shortened'", __FILE__);
+ common_debug("mb_strlen(\$content) = " . mb_strlen($content_shortened), __FILE__);
+ $this->showHome($flink, _('That\'s too long. Max notice size is 140 chars.'));
+ return;
+ }
+ }
+
+ $inter = new CommandInterpreter();
+
+ $cmd = $inter->handle_command($user, $content_shortened);
+
+ if ($cmd) {
+ $cmd->execute(new WebChannel());
+ return;
+ }
+
+ $replyto = $this->trimmed('inreplyto');
+
+ $notice = Notice::saveNew($user->id, $content,
+ 'Facebook', 1, ($replyto == 'false') ? null : $replyto);
+
+ if (is_string($notice)) {
+ $this->showHome($flink, 'Error!');
+ return;
+ }
+
+ common_broadcast_notice($notice);
+ $this->showHome($flink, 'Success!');
+ }
+
}
diff --git a/actions/facebookinvite.php b/actions/facebookinvite.php
index d7e82dae7..e67bfaa00 100644
--- a/actions/facebookinvite.php
+++ b/actions/facebookinvite.php
@@ -69,7 +69,8 @@ class FacebookinviteAction extends FacebookAction
$facebook = get_facebook();
$fbuid = $facebook->require_login();
- $this->showHeader('Invite');
+ $this->showHeader();
+ $this->showNav('Invite');
// Get a list of users who are already using the app for exclusion
$exclude_ids = $facebook->api_client->friends_getAppUsers();
diff --git a/actions/facebookremove.php b/actions/facebookremove.php
index a200fefbf..557c0655b 100644
--- a/actions/facebookremove.php
+++ b/actions/facebookremove.php
@@ -19,7 +19,7 @@
if (!defined('LACONICA')) { exit(1); }
-require_once(INSTALLDIR.'/lib/facebookaction.php');
+require_once INSTALLDIR.'/lib/facebookaction.php';
class FacebookremoveAction extends FacebookAction
{
diff --git a/actions/facebooksettings.php b/actions/facebooksettings.php
index 84e9a343b..a08abc937 100644
--- a/actions/facebooksettings.php
+++ b/actions/facebooksettings.php
@@ -67,8 +67,8 @@ class FacebooksettingsAction extends FacebookAction
$flink = Foreign_link::getByForeignID($fbuid, FACEBOOK_SERVICE);
- $this->showHeader('Settings', $msg, $success);
-
+ $this->showHeader($msg, $success);
+ $this->showNav('Settings');
if ($facebook->api_client->users_hasAppPermission('status_update')) {