summaryrefslogtreecommitdiff
path: root/actions
diff options
context:
space:
mode:
authorEvan Prodromou <evan@status.net>2009-11-07 13:03:52 -0500
committerEvan Prodromou <evan@status.net>2009-11-07 13:03:52 -0500
commitd9cde0ef80ee838a99035d44f0286b3cc902e332 (patch)
treeac9d74d52a06890db71f61ac934e75b937c19753 /actions
parentf2b642ce822c480cfc418c38106cc18c3a428cf4 (diff)
parent2d8ad0409d8e78ec35a65156bc375eacbe561963 (diff)
Merge branch '0.9.x' into userflag
Diffstat (limited to 'actions')
-rw-r--r--actions/apiaccountupdateprofileimage.php151
-rw-r--r--actions/apifriendshipsexists.php13
-rw-r--r--actions/apigrouplistall.php4
-rw-r--r--actions/apigroupmembership.php4
-rw-r--r--actions/apigroupshow.php4
-rw-r--r--actions/apihelptest.php4
-rw-r--r--actions/apistatusesshow.php4
-rw-r--r--actions/apistatusesupdate.php23
-rw-r--r--actions/apistatusnetversion.php4
-rw-r--r--actions/apitimelinefriends.php2
-rw-r--r--actions/apitimelinegroup.php4
-rw-r--r--actions/apitimelinepublic.php4
-rw-r--r--actions/apitimelinetag.php4
-rw-r--r--actions/apiusershow.php4
-rw-r--r--actions/avatarsettings.php16
-rw-r--r--actions/login.php55
-rw-r--r--actions/newmessage.php9
-rw-r--r--actions/passwordsettings.php31
-rw-r--r--actions/register.php6
-rw-r--r--actions/showstream.php259
20 files changed, 278 insertions, 327 deletions
diff --git a/actions/apiaccountupdateprofileimage.php b/actions/apiaccountupdateprofileimage.php
new file mode 100644
index 000000000..72fb361bf
--- /dev/null
+++ b/actions/apiaccountupdateprofileimage.php
@@ -0,0 +1,151 @@
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * Update the authenticating user's profile image
+ *
+ * PHP version 5
+ *
+ * LICENCE: 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/>.
+ *
+ * @category API
+ * @package StatusNet
+ * @author Zach Copley <zach@status.net>
+ * @copyright 2009 StatusNet, Inc.
+ * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
+ * @link http://status.net/
+ */
+
+if (!defined('STATUSNET')) {
+ exit(1);
+}
+
+require_once INSTALLDIR . '/lib/apiauth.php';
+
+/**
+ * Updates the authenticating user's profile image. Note that this API method
+ * expects raw multipart data, not a URL to an image.
+ *
+ * @category API
+ * @package StatusNet
+ * @author Zach Copley <zach@status.net>
+ * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
+ * @link http://status.net/
+ */
+
+class ApiAccountUpdateProfileImageAction extends ApiAuthAction
+{
+
+ /**
+ * Take arguments for running
+ *
+ * @param array $args $_REQUEST args
+ *
+ * @return boolean success flag
+ *
+ */
+
+ function prepare($args)
+ {
+ parent::prepare($args);
+
+ $this->user = $this->auth_user;
+
+ return true;
+ }
+
+ /**
+ * Handle the request
+ *
+ * Check whether the credentials are valid and output the result
+ *
+ * @param array $args $_REQUEST data (unused)
+ *
+ * @return void
+ */
+
+ function handle($args)
+ {
+ parent::handle($args);
+
+ if ($_SERVER['REQUEST_METHOD'] != 'POST') {
+ $this->clientError(
+ _('This method requires a POST.'),
+ 400, $this->format
+ );
+ return;
+ }
+
+ // Workaround for PHP returning empty $_POST and $_FILES when POST
+ // length > post_max_size in php.ini
+
+ if (empty($_FILES)
+ && empty($_POST)
+ && ($_SERVER['CONTENT_LENGTH'] > 0)
+ ) {
+ $msg = _('The server was unable to handle that much POST ' .
+ 'data (%s bytes) due to its current configuration.');
+
+ $this->clientError(sprintf($msg, $_SERVER['CONTENT_LENGTH']));
+ return;
+ }
+
+ if (empty($this->user)) {
+ $this->clientError(_('No such user!'), 404, $this->format);
+ return;
+ }
+
+ try {
+ $imagefile = ImageFile::fromUpload('image');
+ } catch (Exception $e) {
+ $this->clientError($e->getMessage(), 400, $this->format);
+ return;
+ }
+
+ $filename = Avatar::filename(
+ $user->id,
+ image_type_to_extension($imagefile->type),
+ null,
+ 'tmp'.common_timestamp()
+ );
+
+ $filepath = Avatar::path($filename);
+
+ move_uploaded_file($imagefile->filepath, $filepath);
+
+ $profile = $this->user->getProfile();
+
+ if (empty($profile)) {
+ $this->clientError(_('User has no profile.'));
+ return;
+ }
+
+ $profile->setOriginal($filename);
+
+ common_broadcast_profile($profile);
+
+ $twitter_user = $this->twitterUserArray($this->user->getProfile(), true);
+
+ if ($this->format == 'xml') {
+ $this->initDocument('xml');
+ $this->showTwitterXmlUser($twitter_user);
+ $this->endDocument('xml');
+ } elseif ($this->format == 'json') {
+ $this->initDocument('json');
+ $this->showJsonObjects($twitter_user);
+ $this->endDocument('json');
+ }
+ }
+
+}
diff --git a/actions/apifriendshipsexists.php b/actions/apifriendshipsexists.php
index ae50c512c..c040b9f6a 100644
--- a/actions/apifriendshipsexists.php
+++ b/actions/apifriendshipsexists.php
@@ -33,7 +33,7 @@ if (!defined('STATUSNET')) {
exit(1);
}
-require_once INSTALLDIR . '/lib/api.php';
+require_once INSTALLDIR . '/lib/apiprivateauth.php';
/**
* Tests for the existence of friendship between two users. Will return true if
@@ -48,7 +48,7 @@ require_once INSTALLDIR . '/lib/api.php';
* @link http://status.net/
*/
-class ApiFriendshipsExistsAction extends ApiAction
+class ApiFriendshipsExistsAction extends ApiPrivateAuthAction
{
var $user_a = null;
var $user_b = null;
@@ -69,16 +69,7 @@ class ApiFriendshipsExistsAction extends ApiAction
$user_a_id = $this->trimmed('user_a');
$user_b_id = $this->trimmed('user_b');
- common_debug("user_a = " . $user_a_id);
- common_debug("user_b = " . $user_b_id);
-
-
$this->user_a = $this->getTargetUser($user_a_id);
-
- if (empty($this->user_a)) {
- common_debug('gargargra');
- }
-
$this->user_b = $this->getTargetUser($user_b_id);
return true;
diff --git a/actions/apigrouplistall.php b/actions/apigrouplistall.php
index 89469f36f..c597839a8 100644
--- a/actions/apigrouplistall.php
+++ b/actions/apigrouplistall.php
@@ -34,7 +34,7 @@ if (!defined('STATUSNET')) {
exit(1);
}
-require_once INSTALLDIR . '/lib/api.php';
+require_once INSTALLDIR . '/lib/apiprivateauth.php';
/**
* Returns of the lastest 20 groups for the site
@@ -49,7 +49,7 @@ require_once INSTALLDIR . '/lib/api.php';
* @link http://status.net/
*/
-class ApiGroupListAllAction extends ApiAction
+class ApiGroupListAllAction extends ApiPrivateAuthAction
{
var $groups = null;
diff --git a/actions/apigroupmembership.php b/actions/apigroupmembership.php
index b31e47b39..d221a6418 100644
--- a/actions/apigroupmembership.php
+++ b/actions/apigroupmembership.php
@@ -34,7 +34,7 @@ if (!defined('STATUSNET')) {
exit(1);
}
-require_once INSTALLDIR . '/lib/api.php';
+require_once INSTALLDIR . '/lib/apiprivateauth.php';
/**
* List 20 newest members of the group specified by name or ID.
@@ -49,7 +49,7 @@ require_once INSTALLDIR . '/lib/api.php';
* @link http://status.net/
*/
-class ApiGroupMembershipAction extends ApiAction
+class ApiGroupMembershipAction extends ApiPrivateAuthAction
{
var $group = null;
var $profiles = null;
diff --git a/actions/apigroupshow.php b/actions/apigroupshow.php
index 2bdb22bc4..b745ff92f 100644
--- a/actions/apigroupshow.php
+++ b/actions/apigroupshow.php
@@ -34,7 +34,7 @@ if (!defined('STATUSNET')) {
exit(1);
}
-require_once INSTALLDIR . '/lib/api.php';
+require_once INSTALLDIR . '/lib/apiprivateauth.php';
/**
* Outputs detailed information about the group specified by ID
@@ -49,7 +49,7 @@ require_once INSTALLDIR . '/lib/api.php';
* @link http://status.net/
*/
-class ApiGroupShowAction extends ApiAction
+class ApiGroupShowAction extends ApiPrivateAuthAction
{
var $group = null;
diff --git a/actions/apihelptest.php b/actions/apihelptest.php
index e4ef55f2e..f2c459e6f 100644
--- a/actions/apihelptest.php
+++ b/actions/apihelptest.php
@@ -32,7 +32,7 @@ if (!defined('STATUSNET')) {
exit(1);
}
-require_once INSTALLDIR . '/lib/api.php';
+require_once INSTALLDIR . '/lib/apiprivateauth.php';
/**
* Returns the string "ok" in the requested format with a 200 OK HTTP status code.
@@ -45,7 +45,7 @@ require_once INSTALLDIR . '/lib/api.php';
* @link http://status.net/
*/
-class ApiHelpTestAction extends ApiAction
+class ApiHelpTestAction extends ApiPrivateAuthAction
{
/**
diff --git a/actions/apistatusesshow.php b/actions/apistatusesshow.php
index 3be22ca59..e26c009c4 100644
--- a/actions/apistatusesshow.php
+++ b/actions/apistatusesshow.php
@@ -37,7 +37,7 @@ if (!defined('STATUSNET')) {
exit(1);
}
-require_once INSTALLDIR . '/lib/api.php';
+require_once INSTALLDIR . '/lib/apiprivateauth.php';
/**
* Returns the notice specified by id as a Twitter-style status and inline user
@@ -55,7 +55,7 @@ require_once INSTALLDIR . '/lib/api.php';
* @link http://status.net/
*/
-class ApiStatusesShowAction extends ApiAction
+class ApiStatusesShowAction extends ApiPrivateAuthAction
{
var $notice_id = null;
diff --git a/actions/apistatusesupdate.php b/actions/apistatusesupdate.php
index 898a4bd72..e369fa71e 100644
--- a/actions/apistatusesupdate.php
+++ b/actions/apistatusesupdate.php
@@ -80,7 +80,7 @@ class ApiStatusesUpdateAction extends ApiAuthAction
$this->status = $this->trimmed('status');
$this->source = $this->trimmed('source');
- if (empty($this->source) || in_array($source, $this->reserved_sources)) {
+ if (empty($this->source) || in_array($source, self::$reserved_sources)) {
$this->source = 'api';
}
@@ -112,6 +112,20 @@ class ApiStatusesUpdateAction extends ApiAuthAction
return;
}
+ // Workaround for PHP returning empty $_POST and $_FILES when POST
+ // length > post_max_size in php.ini
+
+ if (empty($_FILES)
+ && empty($_POST)
+ && ($_SERVER['CONTENT_LENGTH'] > 0)
+ ) {
+ $msg = _('The server was unable to handle that much POST ' .
+ 'data (%s bytes) due to its current configuration.');
+
+ $this->clientError(sprintf($msg, $_SERVER['CONTENT_LENGTH']));
+ return;
+ }
+
if (empty($this->status)) {
$this->clientError(
'Client must provide a \'status\' parameter with a value.',
@@ -126,13 +140,6 @@ class ApiStatusesUpdateAction extends ApiAuthAction
return;
}
- // Workaround for PHP returning empty $_FILES when POST length > PHP settings
-
- if (empty($_POST) && ($_SERVER['CONTENT_LENGTH'] > 0)) {
- $this->clientError(_('Unable to handle that much POST data!'));
- return;
- }
-
$status_shortened = common_shorten_links($this->status);
if (Notice::contentTooLong($status_shortened)) {
diff --git a/actions/apistatusnetversion.php b/actions/apistatusnetversion.php
index e73ab983b..bbf891a89 100644
--- a/actions/apistatusnetversion.php
+++ b/actions/apistatusnetversion.php
@@ -32,7 +32,7 @@ if (!defined('STATUSNET')) {
exit(1);
}
-require_once INSTALLDIR . '/lib/api.php';
+require_once INSTALLDIR . '/lib/apiprivateauth.php';
/**
* Returns a version number for this version of StatusNet, which
@@ -48,7 +48,7 @@ require_once INSTALLDIR . '/lib/api.php';
* @link http://status.net/
*/
-class ApiStatusnetVersionAction extends ApiAction
+class ApiStatusnetVersionAction extends ApiPrivateAuthAction
{
/**
* Take arguments for running
diff --git a/actions/apitimelinefriends.php b/actions/apitimelinefriends.php
index 1ea35866e..66dd3f2b2 100644
--- a/actions/apitimelinefriends.php
+++ b/actions/apitimelinefriends.php
@@ -72,7 +72,7 @@ class ApiTimelineFriendsAction extends ApiBareAuthAction
function prepare($args)
{
parent::prepare($args);
-
+ common_debug("api friends_timeline");
$this->user = $this->getTargetUser($this->arg('id'));
if (empty($this->user)) {
diff --git a/actions/apitimelinegroup.php b/actions/apitimelinegroup.php
index 5d0542918..f25f6ba51 100644
--- a/actions/apitimelinegroup.php
+++ b/actions/apitimelinegroup.php
@@ -34,7 +34,7 @@ if (!defined('STATUSNET')) {
exit(1);
}
-require_once INSTALLDIR . '/lib/api.php';
+require_once INSTALLDIR . '/lib/apiprivateauth.php';
/**
* Returns the most recent notices (default 20) posted to the group specified by ID
@@ -49,7 +49,7 @@ require_once INSTALLDIR . '/lib/api.php';
* @link http://status.net/
*/
-class ApiTimelineGroupAction extends ApiAction
+class ApiTimelineGroupAction extends ApiPrivateAuthAction
{
var $group = null;
diff --git a/actions/apitimelinepublic.php b/actions/apitimelinepublic.php
index 58e267734..7a8504259 100644
--- a/actions/apitimelinepublic.php
+++ b/actions/apitimelinepublic.php
@@ -37,7 +37,7 @@ if (!defined('STATUSNET')) {
exit(1);
}
-require_once INSTALLDIR . '/lib/api.php';
+require_once INSTALLDIR . '/lib/apiprivateauth.php';
/**
* Returns the most recent notices (default 20) posted by everybody
@@ -55,7 +55,7 @@ require_once INSTALLDIR . '/lib/api.php';
* @link http://status.net/
*/
-class ApiTimelinePublicAction extends ApiAction
+class ApiTimelinePublicAction extends ApiPrivateAuthAction
{
var $notices = null;
diff --git a/actions/apitimelinetag.php b/actions/apitimelinetag.php
index a274daac0..452593c11 100644
--- a/actions/apitimelinetag.php
+++ b/actions/apitimelinetag.php
@@ -34,7 +34,7 @@ if (!defined('STATUSNET')) {
exit(1);
}
-require_once INSTALLDIR . '/lib/api.php';
+require_once INSTALLDIR . '/lib/apiprivateauth.php';
/**
* Returns the 20 most recent notices tagged by a given tag
@@ -49,7 +49,7 @@ require_once INSTALLDIR . '/lib/api.php';
* @link http://status.net/
*/
-class ApiTimelineTagAction extends ApiAction
+class ApiTimelineTagAction extends ApiPrivateAuthAction
{
var $notices = null;
diff --git a/actions/apiusershow.php b/actions/apiusershow.php
index b3a939b43..aa7aec5a4 100644
--- a/actions/apiusershow.php
+++ b/actions/apiusershow.php
@@ -34,7 +34,7 @@ if (!defined('STATUSNET')) {
exit(1);
}
-require_once INSTALLDIR . '/lib/api.php';
+require_once INSTALLDIR . '/lib/apiprivateauth.php';
/**
* Ouputs information for a user, specified by ID or screen name.
@@ -50,7 +50,7 @@ require_once INSTALLDIR . '/lib/api.php';
* @link http://status.net/
*/
-class ApiUserShowAction extends ApiAction
+class ApiUserShowAction extends ApiPrivateAuthAction
{
/**
* Take arguments for running
diff --git a/actions/avatarsettings.php b/actions/avatarsettings.php
index ded419dd7..879e44842 100644
--- a/actions/avatarsettings.php
+++ b/actions/avatarsettings.php
@@ -244,11 +244,25 @@ class AvatarsettingsAction extends AccountSettingsAction
function handlePost()
{
+ // Workaround for PHP returning empty $_POST and $_FILES when POST
+ // length > post_max_size in php.ini
+
+ if (empty($_FILES)
+ && empty($_POST)
+ && ($_SERVER['CONTENT_LENGTH'] > 0)
+ ) {
+ $msg = _('The server was unable to handle that much POST ' .
+ 'data (%s bytes) due to its current configuration.');
+
+ $this->showForm(sprintf($msg, $_SERVER['CONTENT_LENGTH']));
+ return;
+ }
+
// CSRF protection
$token = $this->trimmed('token');
if (!$token || $token != common_session_token()) {
- $this->show_form(_('There was a problem with your session token. '.
+ $this->showForm(_('There was a problem with your session token. '.
'Try again, please.'));
return;
}
diff --git a/actions/login.php b/actions/login.php
index f6d016310..ad57dd667 100644
--- a/actions/login.php
+++ b/actions/login.php
@@ -79,6 +79,8 @@ class LoginAction extends Action
$this->clientError(_('Already logged in.'));
} else if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$this->checkLogin();
+ } else if (isset($args['user_id']) && isset($args['token'])){
+ $this->checkLogin($args['user_id'],$args['token']);
} else {
common_ensure_session();
$this->showForm();
@@ -95,23 +97,48 @@ class LoginAction extends Action
* @return void
*/
- function checkLogin()
+ function checkLogin($user_id=null, $token=null)
{
- // XXX: login throttle
-
- // CSRF protection - token set in NoticeForm
- $token = $this->trimmed('token');
- if (!$token || $token != common_session_token()) {
- $this->clientError(_('There was a problem with your session token. '.
- 'Try again, please.'));
- return;
+ if(isset($token) && isset($user_id)){
+ //Token based login (from the LoginCommand)
+ $login_token = Login_token::staticGet('user_id',$user_id);
+ if($login_token && $login_token->token == $token){
+ if($login_token->modified > time()+2*60){
+ //token has expired
+ //delete the token as it is useless
+ $login_token->delete();
+ $this->showForm(_('Invalid or expired token.'));
+ return;
+ }else{
+ //delete the token so it cannot be reused
+ $login_token->delete();
+ //it's a valid token - let them log in
+ $user = User::staticGet('id', $user_id);
+ //$user = User::staticGet('nickname', "candrews");
+ }
+ }else{
+ $this->showForm(_('Invalid or expired token.'));
+ return;
+ }
+ }else{
+ // Regular form submission login
+
+ // XXX: login throttle
+
+ // CSRF protection - token set in NoticeForm
+ $token = $this->trimmed('token');
+ if (!$token || $token != common_session_token()) {
+ $this->clientError(_('There was a problem with your session token. '.
+ 'Try again, please.'));
+ return;
+ }
+
+ $nickname = common_canonical_nickname($this->trimmed('nickname'));
+ $password = $this->arg('password');
+
+ $user = common_check_user($nickname, $password);
}
- $nickname = common_canonical_nickname($this->trimmed('nickname'));
- $password = $this->arg('password');
-
- $user = common_check_user($nickname, $password);
-
if (!$user) {
$this->showForm(_('Incorrect username or password.'));
return;
diff --git a/actions/newmessage.php b/actions/newmessage.php
index 37fca1ca2..095a7d1d3 100644
--- a/actions/newmessage.php
+++ b/actions/newmessage.php
@@ -224,15 +224,14 @@ class NewmessageAction extends Action
$this->msg = $msg;
if ($this->trimmed('ajax')) {
- $this->startHTML('text/xml;charset=UTF-8');
+ header('Content-Type: text/xml;charset=utf-8');
+ $this->xw->startDocument('1.0', 'UTF-8');
+ $this->elementStart('html');
$this->elementStart('head');
$this->element('title', null, _('New message'));
$this->elementEnd('head');
$this->elementStart('body');
- if (common_logged_in()) {
- $this->showNoticeForm();
- }
- $this->elementEnd('div');
+ $this->showNoticeForm();
$this->elementEnd('body');
$this->endHTML();
}
diff --git a/actions/passwordsettings.php b/actions/passwordsettings.php
index cd4beac3f..87eb45a7d 100644
--- a/actions/passwordsettings.php
+++ b/actions/passwordsettings.php
@@ -164,23 +164,32 @@ class PasswordsettingsAction extends AccountSettingsAction
$this->showForm(_('Incorrect old password'));
return;
}
+ }else{
+ $oldpassword = null;
}
- $original = clone($user);
+ $errormsg = false;
+ if(! Event::handle('ChangePassword', array($user->nickname, $oldpassword, $newpassword, &$errormsg))){
+ //no handler changed the password, so change the password internally
+ $original = clone($user);
- $user->password = common_munge_password($newpassword, $user->id);
+ $user->password = common_munge_password($newpassword, $user->id);
- $val = $user->validate();
- if ($val !== true) {
- $this->showForm(_('Error saving user; invalid.'));
- return;
- }
+ $val = $user->validate();
+ if ($val !== true) {
+ $this->showForm(_('Error saving user; invalid.'));
+ return;
+ }
- if (!$user->update($original)) {
- $this->serverError(_('Can\'t save new password.'));
- return;
+ if (!$user->update($original)) {
+ $this->serverError(_('Can\'t save new password.'));
+ return;
+ }
}
- $this->showForm(_('Password saved.'), true);
+ if($errormsg === false)
+ $this->showForm(_('Password saved.'), true);
+ else
+ $this->showForm($errormsg);
}
}
diff --git a/actions/register.php b/actions/register.php
index a6c1a903a..57f8e7bdf 100644
--- a/actions/register.php
+++ b/actions/register.php
@@ -56,6 +56,12 @@ class RegisterAction extends Action
var $registered = false;
/**
+ * Are we processing an invite?
+ */
+
+ var $invite = null;
+
+ /**
* Prepare page to run
*
*
diff --git a/actions/showstream.php b/actions/showstream.php
index 4f4806037..663638c18 100644
--- a/actions/showstream.php
+++ b/actions/showstream.php
@@ -33,6 +33,7 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
}
require_once INSTALLDIR.'/lib/personalgroupnav.php';
+require_once INSTALLDIR.'/lib/userprofile.php';
require_once INSTALLDIR.'/lib/noticelist.php';
require_once INSTALLDIR.'/lib/profileminilist.php';
require_once INSTALLDIR.'/lib/groupminilist.php';
@@ -181,262 +182,8 @@ class ShowstreamAction extends ProfileAction
function showProfile()
{
- $this->showProfileData();
- $this->showEntityActions();
- }
-
- function showProfileData()
- {
- if (Event::handle('StartProfilePageProfileSection', array(&$this, $this->profile))) {
-
- $this->elementStart('div', 'entity_profile vcard author');
- $this->element('h2', null, _('User profile'));
-
- if (Event::handle('StartProfilePageProfileElements', array(&$this, $this->profile))) {
-
- $this->showAvatar();
- $this->showNickname();
- $this->showFullName();
- $this->showLocation();
- $this->showHomepage();
- $this->showBio();
- $this->showProfileTags();
-
- Event::handle('EndProfilePageProfileElements', array(&$this, $this->profile));
- }
-
- $this->elementEnd('div');
- Event::handle('EndProfilePageProfileSection', array(&$this, $this->profile));
- }
- }
-
- function showAvatar()
- {
- if (Event::handle('StartProfilePageAvatar', array($this, $this->profile))) {
-
- $avatar = $this->profile->getAvatar(AVATAR_PROFILE_SIZE);
-
- $this->elementStart('dl', 'entity_depiction');
- $this->element('dt', null, _('Photo'));
- $this->elementStart('dd');
- $this->element('img', array('src' => ($avatar) ? $avatar->displayUrl() : Avatar::defaultImage(AVATAR_PROFILE_SIZE),
- 'class' => 'photo avatar',
- 'width' => AVATAR_PROFILE_SIZE,
- 'height' => AVATAR_PROFILE_SIZE,
- 'alt' => $this->profile->nickname));
- $this->elementEnd('dd');
-
- $user = User::staticGet('id', $this->profile->id);
-
- $cur = common_current_user();
- if ($cur && $cur->id == $user->id) {
- $this->elementStart('dd');
- $this->element('a', array('href' => common_local_url('avatarsettings')), _('Edit Avatar'));
- $this->elementEnd('dd');
- }
-
- $this->elementEnd('dl');
-
- Event::handle('EndProfilePageAvatar', array($this, $this->profile));
- }
- }
-
- function showNickname()
- {
- if (Event::handle('StartProfilePageNickname', array($this, $this->profile))) {
-
- $this->elementStart('dl', 'entity_nickname');
- $this->element('dt', null, _('Nickname'));
- $this->elementStart('dd');
- $hasFN = ($this->profile->fullname) ? 'nickname url uid' : 'fn nickname url uid';
- $this->element('a', array('href' => $this->profile->profileurl,
- 'rel' => 'me', 'class' => $hasFN),
- $this->profile->nickname);
- $this->elementEnd('dd');
- $this->elementEnd('dl');
-
- Event::handle('EndProfilePageNickname', array($this, $this->profile));
- }
- }
-
- function showFullName()
- {
- if (Event::handle('StartProfilePageFullName', array($this, $this->profile))) {
- if ($this->profile->fullname) {
- $this->elementStart('dl', 'entity_fn');
- $this->element('dt', null, _('Full name'));
- $this->elementStart('dd');
- $this->element('span', 'fn', $this->profile->fullname);
- $this->elementEnd('dd');
- $this->elementEnd('dl');
- }
- Event::handle('EndProfilePageFullName', array($this, $this->profile));
- }
- }
-
- function showLocation()
- {
- if (Event::handle('StartProfilePageLocation', array($this, $this->profile))) {
- if ($this->profile->location) {
- $this->elementStart('dl', 'entity_location');
- $this->element('dt', null, _('Location'));
- $this->element('dd', 'label', $this->profile->location);
- $this->elementEnd('dl');
- }
- Event::handle('EndProfilePageLocation', array($this, $this->profile));
- }
- }
-
- function showHomepage()
- {
- if (Event::handle('StartProfilePageHomepage', array($this, $this->profile))) {
- if ($this->profile->homepage) {
- $this->elementStart('dl', 'entity_url');
- $this->element('dt', null, _('URL'));
- $this->elementStart('dd');
- $this->element('a', array('href' => $this->profile->homepage,
- 'rel' => 'me', 'class' => 'url'),
- $this->profile->homepage);
- $this->elementEnd('dd');
- $this->elementEnd('dl');
- }
- Event::handle('EndProfilePageHomepage', array($this, $this->profile));
- }
- }
-
- function showBio()
- {
- if (Event::handle('StartProfilePageBio', array($this, $this->profile))) {
- if ($this->profile->bio) {
- $this->elementStart('dl', 'entity_note');
- $this->element('dt', null, _('Note'));
- $this->element('dd', 'note', $this->profile->bio);
- $this->elementEnd('dl');
- }
- Event::handle('EndProfilePageBio', array($this, $this->profile));
- }
- }
-
- function showProfileTags()
- {
- if (Event::handle('StartProfilePageProfileTags', array($this, $this->profile))) {
- $tags = Profile_tag::getTags($this->profile->id, $this->profile->id);
-
- if (count($tags) > 0) {
- $this->elementStart('dl', 'entity_tags');
- $this->element('dt', null, _('Tags'));
- $this->elementStart('dd');
- $this->elementStart('ul', 'tags xoxo');
- foreach ($tags as $tag) {
- $this->elementStart('li');
- // Avoid space by using raw output.
- $pt = '<span class="mark_hash">#</span><a rel="tag" href="' .
- common_local_url('peopletag', array('tag' => $tag)) .
- '">' . $tag . '</a>';
- $this->raw($pt);
- $this->elementEnd('li');
- }
- $this->elementEnd('ul');
- $this->elementEnd('dd');
- $this->elementEnd('dl');
- }
- Event::handle('EndProfilePageProfileTags', array($this, $this->profile));
- }
- }
-
- function showEntityActions()
- {
- if (Event::handle('StartProfilePageActionsSection', array(&$this, $this->profile))) {
-
- $cur = common_current_user();
-
- $this->elementStart('div', 'entity_actions');
- $this->element('h2', null, _('User actions'));
- $this->elementStart('ul');
-
- if (Event::handle('StartProfilePageActionsElements', array(&$this, $this->profile))) {
- if (empty($cur)) { // not logged in
- $this->elementStart('li', 'entity_subscribe');
- $this->showRemoteSubscribeLink();
- $this->elementEnd('li');
- } else {
- if ($cur->id == $this->profile->id) { // your own page
- $this->elementStart('li', 'entity_edit');
- $this->element('a', array('href' => common_local_url('profilesettings'),
- 'title' => _('Edit profile settings')),
- _('Edit'));
- $this->elementEnd('li');
- } else { // someone else's page
-
- // subscribe/unsubscribe button
-
- $this->elementStart('li', 'entity_subscribe');
-
- if ($cur->isSubscribed($this->profile)) {
- $usf = new UnsubscribeForm($this, $this->profile);
- $usf->show();
- } else {
- $sf = new SubscribeForm($this, $this->profile);
- $sf->show();
- }
- $this->elementEnd('li');
-
- if ($cur->mutuallySubscribed($this->user)) {
-
- // message
-
- $this->elementStart('li', 'entity_send-a-message');
- $this->element('a', array('href' => common_local_url('newmessage', array('to' => $this->user->id)),
- 'title' => _('Send a direct message to this user')),
- _('Message'));
- $this->elementEnd('li');
-
- // nudge
-
- if ($this->user->email && $this->user->emailnotifynudge) {
- $this->elementStart('li', 'entity_nudge');
- $nf = new NudgeForm($this, $this->user);
- $nf->show();
- $this->elementEnd('li');
- }
- }
-
- // block/unblock
-
- $blocked = $cur->hasBlocked($this->profile);
- $this->elementStart('li', 'entity_block');
- if ($blocked) {
- $ubf = new UnblockForm($this, $this->profile,
- array('action' => 'showstream',
- 'nickname' => $this->profile->nickname));
- $ubf->show();
- } else {
- $bf = new BlockForm($this, $this->profile,
- array('action' => 'showstream',
- 'nickname' => $this->profile->nickname));
- $bf->show();
- }
- $this->elementEnd('li');
- }
- }
-
- Event::handle('EndProfilePageActionsElements', array(&$this, $this->profile));
- }
-
- $this->elementEnd('ul');
- $this->elementEnd('div');
-
- Event::handle('EndProfilePageActionsSection', array(&$this, $this->profile));
- }
- }
-
- function showRemoteSubscribeLink()
- {
- $url = common_local_url('remotesubscribe',
- array('nickname' => $this->profile->nickname));
- $this->element('a', array('href' => $url,
- 'class' => 'entity_remote_subscribe'),
- _('Subscribe'));
+ $profile = new UserProfile($this, $this->user, $this->profile);
+ $profile->show();
}
function showEmptyListMessage()