summaryrefslogtreecommitdiff
path: root/actions
diff options
context:
space:
mode:
Diffstat (limited to 'actions')
-rw-r--r--actions/password.php91
-rw-r--r--actions/profilesettings.php102
-rw-r--r--actions/settings.php52
-rw-r--r--actions/shownotice.php16
-rw-r--r--actions/showstream.php15
-rw-r--r--actions/subscribed.php9
-rw-r--r--actions/subscriptions.php9
7 files changed, 234 insertions, 60 deletions
diff --git a/actions/password.php b/actions/password.php
new file mode 100644
index 000000000..31831d3a9
--- /dev/null
+++ b/actions/password.php
@@ -0,0 +1,91 @@
+<?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/>.
+ */
+
+if (!defined('LACONICA')) { exit(1) }
+
+class PasswordAction extends SettingsAction {
+
+ function handle($args) {
+ parent::handle($args);
+ if (!common_logged_in()) {
+ common_user_error(_t('Not logged in.'));
+ return;
+ }
+ if ($this->arg('METHOD') == 'POST') {
+ $this->handle_post();
+ } else {
+ $this->show_form();
+ }
+ }
+
+ function show_form($msg=NULL, $success=false) {
+ common_show_header(_t('Change password'));
+ $this->settings_menu();
+ if ($msg) {
+ common_element('div', ($success) ? 'success' : 'error',
+ $msg);
+ }
+ common_start_element('form', array('method' => 'POST',
+ 'id' => 'password',
+ 'action' =>
+ common_local_url('password')));
+ common_password('oldpassword', _t('Old password'));
+ common_password('newpassword', _t('New password'));
+ common_password('confirm', _t('Confirm'));
+ common_element('input', array('name' => 'submit',
+ 'type' => 'submit',
+ 'id' => 'submit'),
+ _t('Login'));
+ common_element('input', array('name' => 'cancel',
+ 'type' => 'button',
+ 'id' => 'cancel'),
+ _t('Cancel'));
+ }
+
+ function handle_post() {
+
+ $user = common_current_user();
+ assert(!is_null($user)); # should already be checked
+
+ # FIXME: scrub input
+
+ $oldpassword = $this->arg('oldpassword');
+ $newpassword = $this->arg('newpassword');
+ $confirm = $this->arg('confirm');
+
+ if (0 != strcmp($newpassword, $confirm)) {
+ $this->show_form(_t('Passwords don\'t match'));
+ return;
+ }
+
+ if (!common_check_user($user->nickname, $oldpassword)) {
+ $this->show_form(_t('Incorrect old password'));
+ return;
+ }
+
+ $user->password = common_munge_password($newpassword, $user->id);
+
+ if (!$user->update()) {
+ common_server_error(_t('Can\'t save new password.'));
+ return;
+ }
+
+ $this->show_form(_t('Password saved'), true);
+ }
+} \ No newline at end of file
diff --git a/actions/profilesettings.php b/actions/profilesettings.php
new file mode 100644
index 000000000..b87cea7de
--- /dev/null
+++ b/actions/profilesettings.php
@@ -0,0 +1,102 @@
+<?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/>.
+ */
+
+if (!defined('LACONICA')) { exit(1) }
+
+class ProfilesettingsAction extends SettingsAction {
+
+ function handle($args) {
+ parent::handle($args);
+ if (!common_logged_in()) {
+ common_user_error(_t('Not logged in.'));
+ return;
+ }
+ if ($this->arg('METHOD') == 'POST') {
+ $this->handle_post();
+ } else {
+ $this->show_form();
+ }
+ }
+
+ function show_form($msg=NULL, $success=false) {
+ common_show_header(_t('Profile settings'));
+ $this->settings_menu();
+ if ($msg) {
+ common_element('div', ($success) ? 'success' : 'error',
+ $msg);
+ }
+ common_start_element('form', array('method' => 'POST',
+ 'id' => 'profilesettings',
+ 'action' =>
+ common_local_url('profilesettings')));
+ common_input('nickname', _t('Nickname'));
+ common_input('fullname', _t('Full name'));
+ common_input('email', _t('Email address'));
+ common_input('homepage', _t('Homepage'));
+ common_input('bio', _t('Bio'));
+ common_input('location', _t('Location'));
+ common_element('input', array('name' => 'submit',
+ 'type' => 'submit',
+ 'id' => 'submit'),
+ _t('Login'));
+ common_element('input', array('name' => 'cancel',
+ 'type' => 'button',
+ 'id' => 'cancel'),
+ _t('Cancel'));
+ common_show_footer();
+ }
+
+ function handle_post() {
+ $nickname = $this->arg('nickname');
+ $fullname = $this->arg('fullname');
+ $email = $this->arg('email');
+ $homepage = $this->arg('homepage');
+ $bio = $this->arg('bio');
+ $location = $this->arg('location');
+
+ $user = common_current_user();
+ assert(!is_null($user)); # should already be checked
+
+ # FIXME: scrub input
+ # FIXME: transaction!
+
+ $user->nickname = $this->arg('nickname');
+ $user->email = $this->arg('email');
+
+ if (!$user->update()) {
+ common_server_error(_t('Couldnt update user.'));
+ return;
+ }
+
+ $profile = $user->getProfile();
+
+ $profile->nickname = $user->nickname;
+ $profile->fullname = $this->arg('fullname');
+ $profile->homepage = $this->arg('homepage');
+ $profile->bio = $this->arg('bio');
+ $profile->location = $this->arg('location');
+
+ if (!$profile->update()) {
+ common_server_error(_t('Couldnt save profile.'));
+ return;
+ }
+
+ $this->show_form(_t('Settings saved.'), TRUE);
+ }
+} \ No newline at end of file
diff --git a/actions/settings.php b/actions/settings.php
deleted file mode 100644
index ea8074efc..000000000
--- a/actions/settings.php
+++ /dev/null
@@ -1,52 +0,0 @@
-<?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/>.
- */
-
-if (!defined('LACONICA')) { exit(1) }
-
-class SettingsAction extends Action {
-
- function handle($args) {
- parent::handle($args);
- if ($this->arg('METHOD') == 'POST') {
- $nickname = $this->arg('nickname');
- $fullname = $this->arg('fullname');
- $email = $this->arg('email');
- $homepage = $this->arg('homepage');
- $bio = $this->arg('bio');
- $location = $this->arg('location');
- $oldpass = $this->arg('oldpass');
- $password = $this->arg('password');
- $confirm = $this->arg('confirm');
-
- if ($password) {
- if ($password != $confirm) {
- $this->show_form(_t('Passwords don\'t match.'));
- }
- } else if (
-
- $error = $this->save_settings($nickname, $fullname, $email, $homepage,
- $bio, $location, $password);
- if (!$error) {
- $this->show_form(_t('Settings saved.'), TRUE);
- } else {
- $this->show_form($error);
- }
- } else {
- $this->show_form();
- }
diff --git a/actions/shownotice.php b/actions/shownotice.php
index b0128e6e9..2e14963bb 100644
--- a/actions/shownotice.php
+++ b/actions/shownotice.php
@@ -51,9 +51,21 @@ class ShownoticeAction extends Action {
$profile = $notice->getProfile();
# XXX: RDFa
common_start_element('div', array('class' => 'notice'));
- # FIXME: add the avatar
+ $avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE);
+ if ($avatar) {
+ common_element('img', array('src' => $avatar->url,
+ 'class' => 'avatar profile',
+ 'width' => AVATAR_PROFILE_SIZE,
+ 'height' => AVATAR_PROFILE_SIZE,
+ 'alt' =>
+ ($profile->fullname) ? $profile->fullname :
+ $profile->nickname));
+ }
common_start_element('a', array('href' => $profile->profileurl,
- 'class' => 'nickname'),
+ 'class' => 'nickname',
+ 'title' =>
+ ($profile->fullname) ? $profile->fullname :
+ $profile->nickname)),
$profile->nickname);
# FIXME: URL, image, video, audio
common_element('span', array('class' => 'content'),
diff --git a/actions/showstream.php b/actions/showstream.php
index d476bd297..8272e1038 100644
--- a/actions/showstream.php
+++ b/actions/showstream.php
@@ -86,6 +86,14 @@ class ShowstreamAction extends StreamAction {
function show_profile($profile) {
common_start_element('div', 'profile');
+ $avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE);
+ if ($avatar) {
+ common_element('img', array('src' => $avatar->url,
+ 'class' => 'avatar profile',
+ 'width' => AVATAR_PROFILE_SIZE,
+ 'height' => AVATAR_PROFILE_SIZE,
+ 'title' => $profile->nickname));
+ }
common_element('span', 'nickname', $profile->nickname);
if ($profile->fullname) {
if ($profile->homepage) {
@@ -144,8 +152,11 @@ class ShowstreamAction extends StreamAction {
$subs->nickname,
'href' => $subs->profileurl,
'class' => 'subscription'));
- common_element('img', array('src' => $subs->avatar,
- 'class' => 'avatar'));
+ $avatar = $subs->getAvatar(AVATAR_MINI_SIZE);
+ common_element('img', array('src' => (($avatar) ? $avatar->url : DEFAULT_MINI_AVATAR),
+ 'width' => AVATAR_MINI_SIZE,
+ 'height' => AVATAR_MINI_SIZE,
+ 'class' => 'avatar mini'));
common_end_element('a');
if ($cnt % SUBSCRIPTIONS_PER_ROW == 0) {
diff --git a/actions/subscribed.php b/actions/subscribed.php
index 924e2b67b..f24470f02 100644
--- a/actions/subscribed.php
+++ b/actions/subscribed.php
@@ -64,9 +64,14 @@ class SubscribedAction extends Action {
$subs->nickname,
'href' => $subs->profileurl,
'class' => 'subscription'));
- common_element('img', array('src' => $subs->avatar,
- 'class' => 'avatar'));
+ $avatar = $subs->getAvatar(AVATAR_STREAM_SIZE);
+ common_element('img', array('src' => (($avatar) ? $avatar->url : DEFAULT_STREAM_AVATAR),
+ 'width' => AVATAR_STREAM_SIZE,
+ 'height' => AVATAR_STREAM_SIZE,
+ 'class' => 'avatar stream'));
common_end_element('a');
+
+ # XXX: subscribe form here
if ($idx % SUBSCRIPTIONS_PER_ROW == 0) {
common_end_element('div');
diff --git a/actions/subscriptions.php b/actions/subscriptions.php
index 653c6d2b5..87b8a4e48 100644
--- a/actions/subscriptions.php
+++ b/actions/subscriptions.php
@@ -61,9 +61,14 @@ class SubscriptionsAction extends Action {
$subs->nickname,
'href' => $subs->profileurl,
'class' => 'subscription'));
- common_element('img', array('src' => $subs->avatar,
- 'class' => 'avatar'));
+ $avatar = $subs->getAvatar(AVATAR_STREAM_SIZE);
+ common_element('img', array('src' => (($avatar) ? $avatar->url : DEFAULT_STREAM_AVATAR),
+ 'width' => AVATAR_STREAM_SIZE,
+ 'height' => AVATAR_STREAM_SIZE,
+ 'class' => 'avatar stream'));
common_end_element('a');
+
+ # XXX: subscribe form here
if ($idx % SUBSCRIPTIONS_PER_ROW == 0) {
common_end_element('div');