summaryrefslogtreecommitdiff
path: root/actions
diff options
context:
space:
mode:
Diffstat (limited to 'actions')
-rw-r--r--actions/all.php24
-rw-r--r--actions/avatar.php4
-rw-r--r--actions/login.php16
-rw-r--r--actions/logout.php8
-rw-r--r--actions/newnotice.php16
-rw-r--r--actions/password.php2
-rw-r--r--actions/profilesettings.php4
-rw-r--r--actions/public.php8
-rw-r--r--actions/register.php30
-rw-r--r--actions/shownotice.php26
-rw-r--r--actions/subscribe.php26
-rw-r--r--actions/subscribed.php32
-rw-r--r--actions/subscriptions.php30
-rw-r--r--actions/unsubscribe.php16
14 files changed, 121 insertions, 121 deletions
diff --git a/actions/all.php b/actions/all.php
index 3994e8666..038572ba8 100644
--- a/actions/all.php
+++ b/actions/all.php
@@ -1,18 +1,18 @@
<?php
-/*
+/*
* Laconica - a distributed open-source microblogging tool
* Copyright (C) 2008, Controlez-Vous, Inc.
- *
+ *
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
@@ -24,31 +24,31 @@ require_once(INSTALLDIR.'/actions/showstream.php');
class AllAction extends ShowstreamAction {
// XXX: push this up to a common function.
-
+
function show_notices($profile) {
$notice = DB_DataObject::factory('notice');
-
+
# XXX: chokety and bad
$notice->whereAdd('EXISTS (SELECT subscribed from subscription where subscriber = '.$profile->id.' and subscribed = notice.profile_id)', 'OR');
$notice->whereAdd('profile_id = ' . $profile->id, 'OR');
-
+
$notice->orderBy('created DESC');
-
+
$page = $this->arg('page') || 1;
-
+
$notice->limit((($page-1)*NOTICES_PER_PAGE), NOTICES_PER_PAGE);
-
+
$notice->find();
-
+
common_element_start('div', 'notices');
common_element('h2', 'notices', _t('Notices'));
while ($notice->fetch()) {
$this->show_notice($notice);
}
-
+
# XXX: show a link for the next page
common_element_end('div');
}
diff --git a/actions/avatar.php b/actions/avatar.php
index 43f02a88d..33b5452d0 100644
--- a/actions/avatar.php
+++ b/actions/avatar.php
@@ -129,7 +129,7 @@ class AvatarAction extends SettingsAction {
$avatar->created = DB_DataObject_Cast::dateTime(); # current time
$val = $avatar->validate();
-
+
if ($val !== TRUE) {
$err = '';
foreach ($val as $k=>$v) {
@@ -138,7 +138,7 @@ class AvatarAction extends SettingsAction {
return;
}
}
-
+
foreach (array(AVATAR_PROFILE_SIZE, AVATAR_STREAM_SIZE, AVATAR_MINI_SIZE) as $size) {
$scaled[] = $this->scale_avatar($user, $avatar, $size);
}
diff --git a/actions/login.php b/actions/login.php
index ae1c7e7af..9f9c473b5 100644
--- a/actions/login.php
+++ b/actions/login.php
@@ -1,18 +1,18 @@
<?php
-/*
+/*
* Laconica - a distributed open-source microblogging tool
* Copyright (C) 2008, Controlez-Vous, Inc.
- *
+ *
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
@@ -20,7 +20,7 @@
if (!defined('LACONICA')) { exit(1); }
class LoginAction extends Action {
-
+
function handle($args) {
parent::handle($args);
if (common_logged_in()) {
@@ -43,7 +43,7 @@ class LoginAction extends Action {
common_server_error(_t('Error setting user.'));
return;
}
- # success!
+ # success!
common_redirect(common_local_url('all',
array('nickname' =>
$nickname)));
@@ -51,9 +51,9 @@ class LoginAction extends Action {
$this->show_form(_t('Incorrect username or password.'));
}
}
-
+
function show_form($error=NULL) {
-
+
common_show_header(_t('Login'));
if (!is_null($error)) {
common_element('div', array('class' => 'error'), $msg);
diff --git a/actions/logout.php b/actions/logout.php
index 053130b9f..4df69c3b3 100644
--- a/actions/logout.php
+++ b/actions/logout.php
@@ -1,18 +1,18 @@
<?php
-/*
+/*
* Laconica - a distributed open-source microblogging tool
* Copyright (C) 2008, Controlez-Vous, Inc.
- *
+ *
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
diff --git a/actions/newnotice.php b/actions/newnotice.php
index 5bbc91531..23f31028b 100644
--- a/actions/newnotice.php
+++ b/actions/newnotice.php
@@ -1,18 +1,18 @@
<?php
-/*
+/*
* Laconica - a distributed open-source microblogging tool
* Copyright (C) 2008, Controlez-Vous, Inc.
- *
+ *
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
@@ -20,7 +20,7 @@
if (!defined('LACONICA')) { exit(1); }
class NewnoticeAction extends Action {
-
+
function handle($args) {
parent::handle($args);
# XXX: Ajax!
@@ -40,7 +40,7 @@ class NewnoticeAction extends Action {
$this->show_form();
}
}
-
+
function save_new_notice() {
$user = common_current_user();
assert($user); # XXX: maybe an error instead...
@@ -49,7 +49,7 @@ class NewnoticeAction extends Action {
$notice->profile_id = $user->id; # user id *is* profile id
$notice->created = DB_DataObject_Cast::dateTime();
$notice->content = trim($this->arg('content'));
-
+
$val = $notice->validate();
if ($val === TRUE) {
return $notice->insert();
@@ -58,7 +58,7 @@ class NewnoticeAction extends Action {
return NULL;
}
}
-
+
function show_form() {
common_show_header(_t('New notice'));
common_element_start('form', array('id' => 'newnotice', 'method' => 'POST',
diff --git a/actions/password.php b/actions/password.php
index 3a89c99d3..8f770a969 100644
--- a/actions/password.php
+++ b/actions/password.php
@@ -69,7 +69,7 @@ class PasswordAction extends SettingsAction {
$this->show_form(_t('Error saving user; invalid.'));
return;
}
-
+
if (!$user->update($original)) {
common_server_error(_t('Can\'t save new password.'));
return;
diff --git a/actions/profilesettings.php b/actions/profilesettings.php
index a0c9527a2..e65840bda 100644
--- a/actions/profilesettings.php
+++ b/actions/profilesettings.php
@@ -76,7 +76,7 @@ class ProfilesettingsAction extends SettingsAction {
$this->show_form(_t('Error saving user; invalid.'));
return;
}
-
+
if (!$user->update($original)) {
common_server_error(_t('Couldnt update user.'));
return;
@@ -99,7 +99,7 @@ class ProfilesettingsAction extends SettingsAction {
$this->show_form(_t('Error saving profile; invalid.'));
return;
}
-
+
if (!$profile->update($orig_profile)) {
common_server_error(_t('Couldnt save profile.'));
return;
diff --git a/actions/public.php b/actions/public.php
index 777612579..c8a0eaa63 100644
--- a/actions/public.php
+++ b/actions/public.php
@@ -1,18 +1,18 @@
<?php
-/*
+/*
* Laconica - a distributed open-source microblogging tool
* Copyright (C) 2008, Controlez-Vous, Inc.
- *
+ *
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
diff --git a/actions/register.php b/actions/register.php
index 2fa663389..5da867b0f 100644
--- a/actions/register.php
+++ b/actions/register.php
@@ -1,18 +1,18 @@
<?php
-/*
+/*
* Laconica - a distributed open-source microblogging tool
* Copyright (C) 2008, Controlez-Vous, Inc.
- *
+ *
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
@@ -20,10 +20,10 @@
if (!defined('LACONICA')) { exit(1); }
class RegisterAction extends Action {
-
+
function handle($args) {
parent::handle($args);
-
+
if (common_logged_in()) {
common_user_error(_t('Already logged in.'));
} else if ($_SERVER['REQUEST_METHOD'] == 'POST') {
@@ -40,10 +40,10 @@ class RegisterAction extends Action {
$email = $this->arg('email');
# Input scrubbing
-
+
$nickname = common_canonical_nickname($nickname);
$email = common_canonical_email($email);
-
+
if ($this->nickname_exists($nickname)) {
$this->show_form(_t('Username already exists.'));
} else if ($this->email_exists($email)) {
@@ -63,14 +63,14 @@ class RegisterAction extends Action {
}
# checks if *CANONICAL* nickname exists
-
+
function nickname_exists($nickname) {
$user = User::staticGet('nickname', $nickname);
return ($user !== false);
}
# checks if *CANONICAL* email exists
-
+
function email_exists($email) {
$email = common_canonical_email($email);
$user = User::staticGet('email', $email);
@@ -83,7 +83,7 @@ class RegisterAction extends Action {
$profile->nickname = $nickname;
$profile->profileurl = common_profile_url($nickname);
$profile->created = DB_DataObject_Cast::dateTime(); # current time
-
+
$val = $profile->validate();
if ($val !== TRUE) {
# XXX: some feedback here, please!
@@ -99,7 +99,7 @@ class RegisterAction extends Action {
$user->password = common_munge_password($password, $id);
$user->email = $email;
$user->created = DB_DataObject_Cast::dateTime(); # current time
-
+
$val = $user->validate();
if ($val !== TRUE) {
# XXX: some feedback here, please!
@@ -107,7 +107,7 @@ class RegisterAction extends Action {
$profile->delete();
return FALSE;
}
-
+
$result = $user->insert();
if (!$result) {
# Try to clean up...
@@ -115,9 +115,9 @@ class RegisterAction extends Action {
}
return $result;
}
-
+
function show_form($error=NULL) {
-
+
common_show_header(_t('Register'));
common_element_start('form', array('method' => 'POST',
'id' => 'login',
diff --git a/actions/shownotice.php b/actions/shownotice.php
index ec91f1d4f..48e5861dd 100644
--- a/actions/shownotice.php
+++ b/actions/shownotice.php
@@ -1,18 +1,18 @@
<?php
-/*
+/*
* Laconica - a distributed open-source microblogging tool
* Copyright (C) 2008, Controlez-Vous, Inc.
- *
+ *
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
@@ -33,20 +33,20 @@ class ShownoticeAction extends Action {
if (!$notice->getProfile()) {
$this->no_such_notice();
}
-
+
# Looks like we're good; show the header
-
+
common_show_header($profile->nickname." status on ".$notice->created);
-
+
$this->show_notice($notice);
-
+
common_show_footer();
}
-
+
function no_such_notice() {
common_user_error('No such notice.');
}
-
+
function show_notice($notice) {
$profile = $notice->getProfile();
# XXX: RDFa
@@ -57,13 +57,13 @@ class ShownoticeAction extends Action {
'class' => 'avatar profile',
'width' => AVATAR_PROFILE_SIZE,
'height' => AVATAR_PROFILE_SIZE,
- 'alt' =>
- ($profile->fullname) ? $profile->fullname :
+ 'alt' =>
+ ($profile->fullname) ? $profile->fullname :
$profile->nickname));
}
common_element('a', array('href' => $profile->profileurl,
'class' => 'nickname',
- 'title' =>
+ 'title' =>
($profile->fullname) ? $profile->fullname :
$profile->nickname),
$profile->nickname);
diff --git a/actions/subscribe.php b/actions/subscribe.php
index ea3038236..1ca57a43b 100644
--- a/actions/subscribe.php
+++ b/actions/subscribe.php
@@ -1,18 +1,18 @@
<?php
-/*
+/*
* Laconica - a distributed open-source microblogging tool
* Copyright (C) 2008, Controlez-Vous, Inc.
- *
+ *
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
@@ -22,47 +22,47 @@ if (!defined('LACONICA')) { exit(1); }
class SubscribeAction extends Action {
function handle($args) {
parent::handle($args);
-
+
if (!common_logged_in()) {
common_user_error(_t('Not logged in.'));
return;
}
-
+
$other_nickname = $this->arg('subscribeto');
$other = User::staticGet('nickname', $other_nickname);
-
+
if (!$other) {
common_user_error(_t('No such user.'));
return;
}
-
+
$user = common_current_user();
if ($user->isSubscribed($other)) {
common_user_error(_t('Already subscribed!.'));
return;
}
-
+
$sub = new Subscription();
$sub->subscriber = $user->id;
$sub->subscribed = $other->id;
-
+
$sub->created = DB_DataObject_Cast::dateTime(); # current time
$val = $sub->validate();
-
+
if ($val !== TRUE) {
# XXX: give some error notice
common_server_error(_t('Subscription did not validate.'));
return;
}
-
+
if (!$sub->insert()) {
common_server_error(_t('Couldn\'t create subscription.'));
return;
}
-
+
common_redirect(common_local_url('all', array('nickname' =>
$user->nickname)));
}
diff --git a/actions/subscribed.php b/actions/subscribed.php
index eed2b6c2c..160267838 100644
--- a/actions/subscribed.php
+++ b/actions/subscribed.php
@@ -1,18 +1,18 @@
<?php
-/*
+/*
* Laconica - a distributed open-source microblogging tool
* Copyright (C) 2008, Controlez-Vous, Inc.
- *
+ *
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
@@ -22,7 +22,7 @@ if (!defined('LACONICA')) { exit(1); }
class SubscribedAction extends Action {
# Who is subscribed to a given user?
-
+
function handle($args) {
parent::handle($args);
$nickname = $this->arg('nickname');
@@ -34,7 +34,7 @@ class SubscribedAction extends Action {
if (!$user) {
$this->no_such_user();
}
-
+
$page = $this->arg('page') || 1;
common_show_header($profile->nickname . ": " . _t('Subscribers'));
$this->show_subscribed($profile, $page);
@@ -45,17 +45,17 @@ class SubscribedAction extends Action {
$subs = DB_DataObject::factory('subscription');
$subs->subscribed = $profile->id;
-
+
# We ask for an extra one to know if we need to do another page
-
+
$subs->limit((($page-1)*SUBSCRIPTIONS_PER_PAGE)+1, SUBSCRIPTIONS_PER_PAGE + 1);
$subs_count = $subs->find();
-
+
common_element_start('div', 'subscriptions');
-
+
$idx = 0;
-
+
while ($subs->fetch()) {
$idx++;
if ($idx % SUBSCRIPTIONS_PER_ROW == 1) {
@@ -78,27 +78,27 @@ class SubscribedAction extends Action {
common_element_end('a');
# XXX: subscribe form here
-
+
if ($idx % SUBSCRIPTIONS_PER_ROW == 0) {
common_element_end('div');
}
-
+
if ($idx == SUBSCRIPTIONS_PER_PAGE) {
break;
}
}
if ($page > 1) {
- common_element('a', array('href' =>
+ common_element('a', array('href' =>
common_local_url('subscriptions',
array('nickname' => $profile->nickname,
'page' => $page - 1)),
'class' => 'prev'),
_t('Previous'));
}
-
+
if ($subs_count > SUBSCRIPTIONS_PER_PAGE) {
- common_element('a', array('href' =>
+ common_element('a', array('href' =>
common_local_url('subscriptions',
array('nickname' => $profile->nickname,
'page' => $page + 1)),
diff --git a/actions/subscriptions.php b/actions/subscriptions.php
index ee073d126..37ed68a7f 100644
--- a/actions/subscriptions.php
+++ b/actions/subscriptions.php
@@ -1,18 +1,18 @@
<?php
-/*
+/*
* Laconica - a distributed open-source microblogging tool
* Copyright (C) 2008, Controlez-Vous, Inc.
- *
+ *
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
@@ -20,7 +20,7 @@
if (!defined('LACONICA')) { exit(1); }
class SubscriptionsAction extends Action {
-
+
function handle($args) {
parent::handle($args);
$nickname = $this->arg('nickname');
@@ -42,17 +42,17 @@ class SubscriptionsAction extends Action {
$subs = DB_DataObject::factory('subscription');
$subs->subscriber = $profile->id;
-
+
# We ask for an extra one to know if we need to do another page
-
+
$subs->limit((($page-1)*SUBSCRIPTIONS_PER_PAGE)+1, SUBSCRIPTIONS_PER_PAGE + 1);
$subs_count = $subs->find();
-
+
common_element_start('div', 'subscriptions');
-
+
$idx = 0;
-
+
while ($subs->fetch()) {
$idx++;
if ($idx % SUBSCRIPTIONS_PER_ROW == 1) {
@@ -75,27 +75,27 @@ class SubscriptionsAction extends Action {
common_element_end('a');
# XXX: subscribe form here
-
+
if ($idx % SUBSCRIPTIONS_PER_ROW == 0) {
common_element_end('div');
}
-
+
if ($idx == SUBSCRIPTIONS_PER_PAGE) {
break;
}
}
if ($page > 1) {
- common_element('a', array('href' =>
+ common_element('a', array('href' =>
common_local_url('subscriptions',
array('nickname' => $profile->nickname,
'page' => $page - 1)),
'class' => 'prev'),
_t('Previous'));
}
-
+
if ($subs_count > SUBSCRIPTIONS_PER_PAGE) {
- common_element('a', array('href' =>
+ common_element('a', array('href' =>
common_local_url('subscriptions',
array('nickname' => $profile->nickname,
'page' => $page + 1)),
diff --git a/actions/unsubscribe.php b/actions/unsubscribe.php
index 53a186036..bac752393 100644
--- a/actions/unsubscribe.php
+++ b/actions/unsubscribe.php
@@ -1,18 +1,18 @@
<?php
-/*
+/*
* Laconica - a distributed open-source microblogging tool
* Copyright (C) 2008, Controlez-Vous, Inc.
- *
+ *
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
@@ -30,22 +30,22 @@ class UnsubscribeAction extends Action {
common_user_error(_t('No such user.'));
return;
}
-
+
$user = common_current_user();
if (!$user->isSubscribed($other)) {
common_server_error(_t('Not subscribed!.'));
}
-
+
$sub = new Subscription();
$sub->subscriber = $user->id;
$sub->subscribed = $other->id;
-
+
if (!$sub->delete()) {
common_server_error(_t('Couldn\'t delete subscription.'));
return;
}
-
+
common_redirect(common_local_url('all', array('nickname' =>
$user->nickname)));
}