forked from GNUsocial/gnu-social
Merge branch 'master' into groups
Conflicts: .gitignore
This commit is contained in:
commit
4b9df58c90
4
.gitignore
vendored
4
.gitignore
vendored
@ -5,3 +5,7 @@ config.php
|
|||||||
.htaccess
|
.htaccess
|
||||||
*.tmproj
|
*.tmproj
|
||||||
dataobject.ini
|
dataobject.ini
|
||||||
|
*~
|
||||||
|
*.bak
|
||||||
|
*.orig
|
||||||
|
*.rej
|
||||||
|
4
README
4
README
@ -817,6 +817,10 @@ private: If set to 'true', anonymous users will be redirected to the
|
|||||||
authentication will require it. Note that this does not turn
|
authentication will require it. Note that this does not turn
|
||||||
off registration; use 'closed' or 'inviteonly' for the
|
off registration; use 'closed' or 'inviteonly' for the
|
||||||
behaviour you want.
|
behaviour you want.
|
||||||
|
notice: A plain string that will appear on every page. A good place
|
||||||
|
to put introductory information about your service, or info about
|
||||||
|
upgrades and outages, or other community info. Any HTML will
|
||||||
|
be escaped.
|
||||||
|
|
||||||
db
|
db
|
||||||
--
|
--
|
||||||
|
@ -38,7 +38,7 @@ class AccesstokenAction extends Action
|
|||||||
common_debug('printing the access token', __FILE__);
|
common_debug('printing the access token', __FILE__);
|
||||||
print $token;
|
print $token;
|
||||||
} catch (OAuthException $e) {
|
} catch (OAuthException $e) {
|
||||||
common_server_error($e->getMessage());
|
$this->serverError($e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,80 +19,86 @@
|
|||||||
|
|
||||||
if (!defined('LACONICA')) { exit(1); }
|
if (!defined('LACONICA')) { exit(1); }
|
||||||
|
|
||||||
require_once(INSTALLDIR.'/actions/showstream.php');
|
require_once INSTALLDIR.'/lib/personalgroupnav.php';
|
||||||
|
require_once INSTALLDIR.'/lib/noticelist.php';
|
||||||
|
require_once INSTALLDIR.'/lib/feedlist.php';
|
||||||
|
|
||||||
class AllAction extends StreamAction
|
class AllAction extends Action
|
||||||
{
|
{
|
||||||
|
var $user = null;
|
||||||
|
var $page = null;
|
||||||
|
|
||||||
|
function isReadOnly()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function prepare($args)
|
||||||
|
{
|
||||||
|
parent::prepare($args);
|
||||||
|
$nickname = common_canonical_nickname($this->arg('nickname'));
|
||||||
|
$this->user = User::staticGet('nickname', $nickname);
|
||||||
|
$this->page = $this->trimmed('page');
|
||||||
|
if (!$this->page) {
|
||||||
|
$this->page = 1;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
function handle($args)
|
function handle($args)
|
||||||
{
|
{
|
||||||
|
|
||||||
parent::handle($args);
|
parent::handle($args);
|
||||||
|
|
||||||
$nickname = common_canonical_nickname($this->arg('nickname'));
|
if (!$this->user) {
|
||||||
$user = User::staticGet('nickname', $nickname);
|
$this->clientError(_('No such user.'));
|
||||||
|
|
||||||
if (!$user) {
|
|
||||||
$this->client_error(_('No such user.'));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$profile = $user->getProfile();
|
$this->showPage();
|
||||||
|
|
||||||
if (!$profile) {
|
|
||||||
common_server_error(_('User has no profile.'));
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Looks like we're good; show the header
|
function title()
|
||||||
|
|
||||||
common_show_header(sprintf(_("%s and friends"), $profile->nickname),
|
|
||||||
array($this, 'show_header'), $user,
|
|
||||||
array($this, 'show_top'));
|
|
||||||
|
|
||||||
$this->show_notices($user);
|
|
||||||
|
|
||||||
common_show_footer();
|
|
||||||
}
|
|
||||||
|
|
||||||
function show_header($user)
|
|
||||||
{
|
{
|
||||||
common_element('link', array('rel' => 'alternate',
|
if ($this->page > 1) {
|
||||||
|
return sprintf(_("%s and friends, page %d"), $this->user->nickname, $this->page);
|
||||||
|
} else {
|
||||||
|
return sprintf(_("%s and friends"), $this->user->nickname);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function showFeeds()
|
||||||
|
{
|
||||||
|
$this->element('link', array('rel' => 'alternate',
|
||||||
'href' => common_local_url('allrss', array('nickname' =>
|
'href' => common_local_url('allrss', array('nickname' =>
|
||||||
$user->nickname)),
|
$this->user->nickname)),
|
||||||
'type' => 'application/rss+xml',
|
'type' => 'application/rss+xml',
|
||||||
'title' => sprintf(_('Feed for friends of %s'), $user->nickname)));
|
'title' => sprintf(_('Feed for friends of %s'), $this->user->nickname)));
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_top($user)
|
function showLocalNav()
|
||||||
{
|
{
|
||||||
$cur = common_current_user();
|
$nav = new PersonalGroupNav($this);
|
||||||
|
$nav->show();
|
||||||
if ($cur && $cur->id == $user->id) {
|
|
||||||
common_notice_form('all');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->views_menu();
|
function showExportData()
|
||||||
|
{
|
||||||
$this->show_feeds_list(array(0=>array('href'=>common_local_url('allrss', array('nickname' => $user->nickname)),
|
$fl = new FeedList($this);
|
||||||
|
$fl->show(array(0=>array('href'=>common_local_url('allrss', array('nickname' => $this->user->nickname)),
|
||||||
'type' => 'rss',
|
'type' => 'rss',
|
||||||
'version' => 'RSS 1.0',
|
'version' => 'RSS 1.0',
|
||||||
'item' => 'allrss')));
|
'item' => 'allrss')));
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_notices($user)
|
function showContent()
|
||||||
{
|
{
|
||||||
|
$notice = $this->user->noticesWithFriends(($this->page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1);
|
||||||
|
|
||||||
$page = $this->trimmed('page');
|
$nl = new NoticeList($notice, $this);
|
||||||
if (!$page) {
|
|
||||||
$page = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
$notice = $user->noticesWithFriends(($page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1);
|
$cnt = $nl->show();
|
||||||
|
|
||||||
$cnt = $this->show_notice_list($notice);
|
$this->pagination($this->page > 1, $cnt > NOTICES_PER_PAGE,
|
||||||
|
$this->page, 'all', array('nickname' => $this->user->nickname));
|
||||||
common_pagination($page > 1, $cnt > NOTICES_PER_PAGE,
|
|
||||||
$page, 'all', array('nickname' => $user->nickname));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ class AllrssAction extends Rss10Action
|
|||||||
$this->user = User::staticGet('nickname', $nickname);
|
$this->user = User::staticGet('nickname', $nickname);
|
||||||
|
|
||||||
if (!$this->user) {
|
if (!$this->user) {
|
||||||
common_user_error(_('No such user.'));
|
$this->clientError(_('No such user.'));
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
return true;
|
return true;
|
||||||
|
@ -103,10 +103,10 @@ class ApiAction extends Action
|
|||||||
|
|
||||||
call_user_func(array($action_obj, $this->api_method), $_REQUEST, $apidata);
|
call_user_func(array($action_obj, $this->api_method), $_REQUEST, $apidata);
|
||||||
} else {
|
} else {
|
||||||
common_user_error("API method not found!", $code=404);
|
$this->clientError("API method not found!", $code=404);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
common_user_error("API method not found!", $code=404);
|
$this->clientError("API method not found!", $code=404);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -159,10 +159,10 @@ class ApiAction extends Action
|
|||||||
if ($this->content_type == 'xml') {
|
if ($this->content_type == 'xml') {
|
||||||
header('Content-Type: application/xml; charset=utf-8');
|
header('Content-Type: application/xml; charset=utf-8');
|
||||||
common_start_xml();
|
common_start_xml();
|
||||||
common_element_start('hash');
|
$this->elementStart('hash');
|
||||||
common_element('error', null, $msg);
|
$this->element('error', null, $msg);
|
||||||
common_element('request', null, $_SERVER['REQUEST_URI']);
|
$this->element('request', null, $_SERVER['REQUEST_URI']);
|
||||||
common_element_end('hash');
|
$this->elementEnd('hash');
|
||||||
common_end_xml();
|
common_end_xml();
|
||||||
} else if ($this->content_type == 'json') {
|
} else if ($this->content_type == 'json') {
|
||||||
header('Content-Type: application/json; charset=utf-8');
|
header('Content-Type: application/json; charset=utf-8');
|
||||||
@ -174,7 +174,7 @@ class ApiAction extends Action
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function is_readonly()
|
function isReadOnly()
|
||||||
{
|
{
|
||||||
# NOTE: before handle(), can't use $this->arg
|
# NOTE: before handle(), can't use $this->arg
|
||||||
$apiaction = $_REQUEST['apiaction'];
|
$apiaction = $_REQUEST['apiaction'];
|
||||||
|
@ -26,28 +26,28 @@ class AvatarbynicknameAction extends Action
|
|||||||
parent::handle($args);
|
parent::handle($args);
|
||||||
$nickname = $this->trimmed('nickname');
|
$nickname = $this->trimmed('nickname');
|
||||||
if (!$nickname) {
|
if (!$nickname) {
|
||||||
$this->client_error(_('No nickname.'));
|
$this->clientError(_('No nickname.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$size = $this->trimmed('size');
|
$size = $this->trimmed('size');
|
||||||
if (!$size) {
|
if (!$size) {
|
||||||
$this->client_error(_('No size.'));
|
$this->clientError(_('No size.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$size = strtolower($size);
|
$size = strtolower($size);
|
||||||
if (!in_array($size, array('original', '96', '48', '24'))) {
|
if (!in_array($size, array('original', '96', '48', '24'))) {
|
||||||
$this->client_error(_('Invalid size.'));
|
$this->clientError(_('Invalid size.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$user = User::staticGet('nickname', $nickname);
|
$user = User::staticGet('nickname', $nickname);
|
||||||
if (!$user) {
|
if (!$user) {
|
||||||
$this->client_error(_('No such user.'));
|
$this->clientError(_('No such user.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$profile = $user->getProfile();
|
$profile = $user->getProfile();
|
||||||
if (!$profile) {
|
if (!$profile) {
|
||||||
$this->client_error(_('User has no profile.'));
|
$this->clientError(_('User has no profile.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ($size == 'original') {
|
if ($size == 'original') {
|
||||||
|
306
actions/avatarsettings.php
Normal file
306
actions/avatarsettings.php
Normal file
@ -0,0 +1,306 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Laconica, the distributed open-source microblogging tool
|
||||||
|
*
|
||||||
|
* Upload an avatar
|
||||||
|
*
|
||||||
|
* 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 Settings
|
||||||
|
* @package Laconica
|
||||||
|
* @author Evan Prodromou <evan@controlyourself.ca>
|
||||||
|
* @author Zach Copley <zach@controlyourself.ca>
|
||||||
|
* @copyright 2008-2009 Control Yourself, Inc.
|
||||||
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||||
|
* @link http://laconi.ca/
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (!defined('LACONICA')) {
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
require_once INSTALLDIR.'/lib/accountsettingsaction.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Upload an avatar
|
||||||
|
*
|
||||||
|
* We use jQuery to crop the image after upload.
|
||||||
|
*
|
||||||
|
* @category Settings
|
||||||
|
* @package Laconica
|
||||||
|
* @author Evan Prodromou <evan@controlyourself.ca>
|
||||||
|
* @author Zach Copley <zach@controlyourself.ca>
|
||||||
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||||
|
* @link http://laconi.ca/
|
||||||
|
*/
|
||||||
|
|
||||||
|
class AvatarsettingsAction extends AccountSettingsAction
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Title of the page
|
||||||
|
*
|
||||||
|
* @return string Title of the page
|
||||||
|
*/
|
||||||
|
|
||||||
|
function title()
|
||||||
|
{
|
||||||
|
return _('Avatar');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instructions for use
|
||||||
|
*
|
||||||
|
* @return instructions for use
|
||||||
|
*/
|
||||||
|
|
||||||
|
function getInstructions()
|
||||||
|
{
|
||||||
|
return _('Set your personal avatar.');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Content area of the page
|
||||||
|
*
|
||||||
|
* Shows a form for uploading an avatar.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
|
function showContent()
|
||||||
|
{
|
||||||
|
$user = common_current_user();
|
||||||
|
|
||||||
|
$profile = $user->getProfile();
|
||||||
|
|
||||||
|
if (!$profile) {
|
||||||
|
common_log_db_error($user, 'SELECT', __FILE__);
|
||||||
|
$this->serverError(_('User without matching profile'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$original = $profile->getOriginalAvatar();
|
||||||
|
|
||||||
|
$this->elementStart('form', array('enctype' => 'multipart/form-data',
|
||||||
|
'method' => 'POST',
|
||||||
|
'id' => 'avatar',
|
||||||
|
'action' =>
|
||||||
|
common_local_url('avatarsettings')));
|
||||||
|
$this->hidden('token', common_session_token());
|
||||||
|
|
||||||
|
if ($original) {
|
||||||
|
$this->elementStart('div',
|
||||||
|
array('id' => 'avatar_original',
|
||||||
|
'class' => 'avatar_view'));
|
||||||
|
$this->element('h3', null, _("Original:"));
|
||||||
|
$this->elementStart('div', array('id'=>'avatar_original_view'));
|
||||||
|
$this->element('img', array('src' => $original->url,
|
||||||
|
'class' => 'avatar original',
|
||||||
|
'width' => $original->width,
|
||||||
|
'height' => $original->height,
|
||||||
|
'alt' => $user->nickname));
|
||||||
|
$this->elementEnd('div');
|
||||||
|
$this->elementEnd('div');
|
||||||
|
}
|
||||||
|
|
||||||
|
$avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE);
|
||||||
|
|
||||||
|
if ($avatar) {
|
||||||
|
$this->elementStart('div',
|
||||||
|
array('id' => 'avatar_preview',
|
||||||
|
'class' => 'avatar_view'));
|
||||||
|
$this->element('h3', null, _("Preview:"));
|
||||||
|
$this->elementStart('div', array('id'=>'avatar_preview_view'));
|
||||||
|
$this->element('img', array('src' => $original->url,//$avatar->url,
|
||||||
|
'class' => 'avatar profile',
|
||||||
|
'width' => AVATAR_PROFILE_SIZE,
|
||||||
|
'height' => AVATAR_PROFILE_SIZE,
|
||||||
|
'alt' => $user->nickname));
|
||||||
|
$this->elementEnd('div');
|
||||||
|
$this->elementEnd('div');
|
||||||
|
|
||||||
|
foreach (array('avatar_crop_x', 'avatar_crop_y',
|
||||||
|
'avatar_crop_w', 'avatar_crop_h') as $crop_info) {
|
||||||
|
$this->element('input', array('name' => $crop_info,
|
||||||
|
'type' => 'hidden',
|
||||||
|
'id' => $crop_info));
|
||||||
|
}
|
||||||
|
$this->submit('crop', _('Crop'));
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->element('input', array('name' => 'MAX_FILE_SIZE',
|
||||||
|
'type' => 'hidden',
|
||||||
|
'id' => 'MAX_FILE_SIZE',
|
||||||
|
'value' => MAX_AVATAR_SIZE));
|
||||||
|
|
||||||
|
$this->elementStart('p');
|
||||||
|
|
||||||
|
$this->element('input', array('name' => 'avatarfile',
|
||||||
|
'type' => 'file',
|
||||||
|
'id' => 'avatarfile'));
|
||||||
|
$this->elementEnd('p');
|
||||||
|
|
||||||
|
$this->submit('upload', _('Upload'));
|
||||||
|
$this->elementEnd('form');
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle a post
|
||||||
|
*
|
||||||
|
* We mux on the button name to figure out what the user actually wanted.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
|
function handlePost()
|
||||||
|
{
|
||||||
|
// CSRF protection
|
||||||
|
|
||||||
|
$token = $this->trimmed('token');
|
||||||
|
if (!$token || $token != common_session_token()) {
|
||||||
|
$this->show_form(_('There was a problem with your session token. '.
|
||||||
|
'Try again, please.'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->arg('upload')) {
|
||||||
|
$this->uploadAvatar();
|
||||||
|
} else if ($this->arg('crop')) {
|
||||||
|
$this->cropAvatar();
|
||||||
|
} else {
|
||||||
|
$this->showForm(_('Unexpected form submission.'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle an image upload
|
||||||
|
*
|
||||||
|
* Does all the magic for handling an image upload, and crops the
|
||||||
|
* image by default.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
|
function uploadAvatar()
|
||||||
|
{
|
||||||
|
switch ($_FILES['avatarfile']['error']) {
|
||||||
|
case UPLOAD_ERR_OK: // success, jump out
|
||||||
|
break;
|
||||||
|
case UPLOAD_ERR_INI_SIZE:
|
||||||
|
case UPLOAD_ERR_FORM_SIZE:
|
||||||
|
$this->showForm(_('That file is too big.'));
|
||||||
|
return;
|
||||||
|
case UPLOAD_ERR_PARTIAL:
|
||||||
|
@unlink($_FILES['avatarfile']['tmp_name']);
|
||||||
|
$this->showForm(_('Partial upload.'));
|
||||||
|
return;
|
||||||
|
default:
|
||||||
|
$this->showForm(_('System error uploading file.'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$info = @getimagesize($_FILES['avatarfile']['tmp_name']);
|
||||||
|
|
||||||
|
if (!$info) {
|
||||||
|
@unlink($_FILES['avatarfile']['tmp_name']);
|
||||||
|
$this->showForm(_('Not an image or corrupt file.'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch ($info[2]) {
|
||||||
|
case IMAGETYPE_GIF:
|
||||||
|
case IMAGETYPE_JPEG:
|
||||||
|
case IMAGETYPE_PNG:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$this->showForm(_('Unsupported image file format.'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$user = common_current_user();
|
||||||
|
|
||||||
|
$profile = $user->getProfile();
|
||||||
|
|
||||||
|
if ($profile->setOriginal($_FILES['avatarfile']['tmp_name'])) {
|
||||||
|
$this->showForm(_('Avatar updated.'), true);
|
||||||
|
} else {
|
||||||
|
$this->showForm(_('Failed updating avatar.'));
|
||||||
|
}
|
||||||
|
|
||||||
|
@unlink($_FILES['avatarfile']['tmp_name']);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle the results of jcrop.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
|
function cropAvatar()
|
||||||
|
{
|
||||||
|
$user = common_current_user();
|
||||||
|
|
||||||
|
$profile = $user->getProfile();
|
||||||
|
|
||||||
|
$x = $this->arg('avatar_crop_x');
|
||||||
|
$y = $this->arg('avatar_crop_y');
|
||||||
|
$w = $this->arg('avatar_crop_w');
|
||||||
|
$h = $this->arg('avatar_crop_h');
|
||||||
|
|
||||||
|
if ($profile->crop_avatars($x, $y, $w, $h)) {
|
||||||
|
$this->showForm(_('Avatar updated.'), true);
|
||||||
|
} else {
|
||||||
|
$this->showForm(_('Failed updating avatar.'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add the jCrop stylesheet
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
|
function showStylesheets()
|
||||||
|
{
|
||||||
|
parent::showStylesheets();
|
||||||
|
$jcropStyle =
|
||||||
|
common_path('js/jcrop/jquery.Jcrop.css?version='.LACONICA_VERSION);
|
||||||
|
|
||||||
|
$this->element('link', array('rel' => 'stylesheet',
|
||||||
|
'type' => 'text/css',
|
||||||
|
'href' => $jcropStyle,
|
||||||
|
'media' => 'screen, projection, tv'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add the jCrop scripts
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
|
function showScripts()
|
||||||
|
{
|
||||||
|
parent::showScripts();
|
||||||
|
|
||||||
|
$jcropPack = common_path('js/jcrop/jquery.Jcrop.pack.js');
|
||||||
|
$jcropGo = common_path('js/jcrop/jquery.Jcrop.go.js');
|
||||||
|
|
||||||
|
$this->element('script', array('type' => 'text/javascript',
|
||||||
|
'src' => $jcropPack));
|
||||||
|
$this->element('script', array('type' => 'text/javascript',
|
||||||
|
'src' => $jcropGo));
|
||||||
|
}
|
||||||
|
}
|
@ -30,28 +30,28 @@ class BlockAction extends Action
|
|||||||
parent::prepare($args);
|
parent::prepare($args);
|
||||||
|
|
||||||
if (!common_logged_in()) {
|
if (!common_logged_in()) {
|
||||||
$this->client_error(_('Not logged in.'));
|
$this->clientError(_('Not logged in.'));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$token = $this->trimmed('token');
|
$token = $this->trimmed('token');
|
||||||
|
|
||||||
if (!$token || $token != common_session_token()) {
|
if (!$token || $token != common_session_token()) {
|
||||||
$this->client_error(_('There was a problem with your session token. Try again, please.'));
|
$this->clientError(_('There was a problem with your session token. Try again, please.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$id = $this->trimmed('blockto');
|
$id = $this->trimmed('blockto');
|
||||||
|
|
||||||
if (!$id) {
|
if (!$id) {
|
||||||
$this->client_error(_('No profile specified.'));
|
$this->clientError(_('No profile specified.'));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->profile = Profile::staticGet('id', $id);
|
$this->profile = Profile::staticGet('id', $id);
|
||||||
|
|
||||||
if (!$this->profile) {
|
if (!$this->profile) {
|
||||||
$this->client_error(_('No profile with that ID.'));
|
$this->clientError(_('No profile with that ID.'));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,34 +81,34 @@ class BlockAction extends Action
|
|||||||
|
|
||||||
common_show_header(_('Block user'));
|
common_show_header(_('Block user'));
|
||||||
|
|
||||||
common_element('p', null,
|
$this->element('p', null,
|
||||||
_('Are you sure you want to block this user? '.
|
_('Are you sure you want to block this user? '.
|
||||||
'Afterwards, they will be unsubscribed from you, '.
|
'Afterwards, they will be unsubscribed from you, '.
|
||||||
'unable to subscribe to you in the future, and '.
|
'unable to subscribe to you in the future, and '.
|
||||||
'you will not be notified of any @-replies from them.'));
|
'you will not be notified of any @-replies from them.'));
|
||||||
|
|
||||||
common_element_start('form', array('id' => 'block-' . $id,
|
$this->elementStart('form', array('id' => 'block-' . $id,
|
||||||
'method' => 'post',
|
'method' => 'post',
|
||||||
'class' => 'block',
|
'class' => 'block',
|
||||||
'action' => common_local_url('block')));
|
'action' => common_local_url('block')));
|
||||||
|
|
||||||
common_hidden('token', common_session_token());
|
$this->hidden('token', common_session_token());
|
||||||
|
|
||||||
common_element('input', array('id' => 'blockto-' . $id,
|
$this->element('input', array('id' => 'blockto-' . $id,
|
||||||
'name' => 'blockto',
|
'name' => 'blockto',
|
||||||
'type' => 'hidden',
|
'type' => 'hidden',
|
||||||
'value' => $id));
|
'value' => $id));
|
||||||
|
|
||||||
foreach ($this->args as $k => $v) {
|
foreach ($this->args as $k => $v) {
|
||||||
if (substr($k, 0, 9) == 'returnto-') {
|
if (substr($k, 0, 9) == 'returnto-') {
|
||||||
common_hidden($k, $v);
|
$this->hidden($k, $v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
common_submit('no', _('No'));
|
$this->submit('no', _('No'));
|
||||||
common_submit('yes', _('Yes'));
|
$this->submit('yes', _('Yes'));
|
||||||
|
|
||||||
common_element_end('form');
|
$this->elementEnd('form');
|
||||||
|
|
||||||
common_show_footer();
|
common_show_footer();
|
||||||
}
|
}
|
||||||
@ -119,14 +119,14 @@ class BlockAction extends Action
|
|||||||
$cur = common_current_user();
|
$cur = common_current_user();
|
||||||
|
|
||||||
if ($cur->hasBlocked($this->profile)) {
|
if ($cur->hasBlocked($this->profile)) {
|
||||||
$this->client_error(_('You have already blocked this user.'));
|
$this->clientError(_('You have already blocked this user.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = $cur->block($this->profile);
|
$result = $cur->block($this->profile);
|
||||||
|
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
$this->server_error(_('Failed to save block information.'));
|
$this->serverError(_('Failed to save block information.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/**
|
||||||
* Laconica - a distributed open-source microblogging tool
|
* Laconica, the distributed open-source microblogging tool
|
||||||
* Copyright (C) 2008, Controlez-Vous, Inc.
|
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* Confirm an address
|
||||||
|
*
|
||||||
|
* 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
|
* 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
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
@ -15,43 +18,80 @@
|
|||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* 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/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* @category Confirm
|
||||||
|
* @package Laconica
|
||||||
|
* @author Evan Prodromou <evan@controlyourself.ca>
|
||||||
|
* @copyright 2008-2009 Control Yourself, Inc.
|
||||||
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||||
|
* @link http://laconi.ca/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('LACONICA')) { exit(1); }
|
if (!defined('LACONICA')) {
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Confirm an address
|
||||||
|
*
|
||||||
|
* When users change their SMS, email, Jabber, or other addresses, we send out
|
||||||
|
* a confirmation code to make sure the owner of that address approves. This class
|
||||||
|
* accepts those codes.
|
||||||
|
*
|
||||||
|
* @category Confirm
|
||||||
|
* @package Laconica
|
||||||
|
* @author Evan Prodromou <evan@controlyourself.ca>
|
||||||
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||||
|
* @link http://laconi.ca/
|
||||||
|
*/
|
||||||
|
|
||||||
class ConfirmaddressAction extends Action
|
class ConfirmaddressAction extends Action
|
||||||
{
|
{
|
||||||
|
/** type of confirmation. */
|
||||||
|
|
||||||
|
var $type = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Accept a confirmation code
|
||||||
|
*
|
||||||
|
* Checks the code and confirms the address in the
|
||||||
|
* user record
|
||||||
|
*
|
||||||
|
* @param args $args $_REQUEST array
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
function handle($args)
|
function handle($args)
|
||||||
{
|
{
|
||||||
parent::handle($args);
|
parent::handle($args);
|
||||||
if (!common_logged_in()) {
|
if (!common_logged_in()) {
|
||||||
common_set_returnto($this->self_url());
|
common_set_returnto($this->selfUrl());
|
||||||
common_redirect(common_local_url('login'));
|
common_redirect(common_local_url('login'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$code = $this->trimmed('code');
|
$code = $this->trimmed('code');
|
||||||
if (!$code) {
|
if (!$code) {
|
||||||
$this->client_error(_('No confirmation code.'));
|
$this->clientError(_('No confirmation code.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$confirm = Confirm_address::staticGet('code', $code);
|
$confirm = Confirm_address::staticGet('code', $code);
|
||||||
if (!$confirm) {
|
if (!$confirm) {
|
||||||
$this->client_error(_('Confirmation code not found.'));
|
$this->clientError(_('Confirmation code not found.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$cur = common_current_user();
|
$cur = common_current_user();
|
||||||
if ($cur->id != $confirm->user_id) {
|
if ($cur->id != $confirm->user_id) {
|
||||||
$this->client_error(_('That confirmation code is not for you!'));
|
$this->clientError(_('That confirmation code is not for you!'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$type = $confirm->address_type;
|
$type = $confirm->address_type;
|
||||||
if (!in_array($type, array('email', 'jabber', 'sms'))) {
|
if (!in_array($type, array('email', 'jabber', 'sms'))) {
|
||||||
$this->server_error(sprintf(_('Unrecognized address type %s'), $type));
|
$this->serverError(sprintf(_('Unrecognized address type %s'), $type));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ($cur->$type == $confirm->address) {
|
if ($cur->$type == $confirm->address) {
|
||||||
$this->client_error(_('That address has already been confirmed.'));
|
$this->clientError(_('That address has already been confirmed.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,7 +111,7 @@ class ConfirmaddressAction extends Action
|
|||||||
|
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
common_log_db_error($cur, 'UPDATE', __FILE__);
|
common_log_db_error($cur, 'UPDATE', __FILE__);
|
||||||
$this->server_error(_('Couldn\'t update user.'));
|
$this->serverError(_('Couldn\'t update user.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,15 +123,41 @@ class ConfirmaddressAction extends Action
|
|||||||
|
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
common_log_db_error($confirm, 'DELETE', __FILE__);
|
common_log_db_error($confirm, 'DELETE', __FILE__);
|
||||||
$this->server_error(_('Couldn\'t delete email confirmation.'));
|
$this->serverError(_('Couldn\'t delete email confirmation.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$cur->query('COMMIT');
|
$cur->query('COMMIT');
|
||||||
|
|
||||||
common_show_header(_('Confirm Address'));
|
$this->type = $type;
|
||||||
common_element('p', null,
|
$this->showPage();
|
||||||
sprintf(_('The address "%s" has been confirmed for your account.'), $cur->$type));
|
}
|
||||||
common_show_footer();
|
|
||||||
|
/**
|
||||||
|
* Title of the page
|
||||||
|
*
|
||||||
|
* @return string title
|
||||||
|
*/
|
||||||
|
|
||||||
|
function title()
|
||||||
|
{
|
||||||
|
return _('Confirm Address');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show a confirmation message.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
|
function showContent()
|
||||||
|
{
|
||||||
|
$cur = common_current_user();
|
||||||
|
$type = $this->type;
|
||||||
|
|
||||||
|
$this->element('p', null,
|
||||||
|
sprintf(_('The address "%s" has been '.
|
||||||
|
'confirmed for your account.'),
|
||||||
|
$cur->$type));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -51,24 +51,24 @@ class DeletenoticeAction extends DeleteAction
|
|||||||
|
|
||||||
common_show_header($this->get_title(), array($this, 'show_header'), $error,
|
common_show_header($this->get_title(), array($this, 'show_header'), $error,
|
||||||
array($this, 'show_top'));
|
array($this, 'show_top'));
|
||||||
common_element_start('form', array('id' => 'notice_delete_form',
|
$this->elementStart('form', array('id' => 'notice_delete_form',
|
||||||
'method' => 'post',
|
'method' => 'post',
|
||||||
'action' => common_local_url('deletenotice')));
|
'action' => common_local_url('deletenotice')));
|
||||||
common_hidden('token', common_session_token());
|
$this->hidden('token', common_session_token());
|
||||||
common_hidden('notice', $this->trimmed('notice'));
|
$this->hidden('notice', $this->trimmed('notice'));
|
||||||
common_element_start('p');
|
$this->elementStart('p');
|
||||||
common_element('span', array('id' => 'confirmation_text'), _('Are you sure you want to delete this notice?'));
|
$this->element('span', array('id' => 'confirmation_text'), _('Are you sure you want to delete this notice?'));
|
||||||
|
|
||||||
common_element('input', array('id' => 'submit_no',
|
$this->element('input', array('id' => 'submit_no',
|
||||||
'name' => 'submit',
|
'name' => 'submit',
|
||||||
'type' => 'submit',
|
'type' => 'submit',
|
||||||
'value' => _('No')));
|
'value' => _('No')));
|
||||||
common_element('input', array('id' => 'submit_yes',
|
$this->element('input', array('id' => 'submit_yes',
|
||||||
'name' => 'submit',
|
'name' => 'submit',
|
||||||
'type' => 'submit',
|
'type' => 'submit',
|
||||||
'value' => _('Yes')));
|
'value' => _('Yes')));
|
||||||
common_element_end('p');
|
$this->elementEnd('p');
|
||||||
common_element_end('form');
|
$this->elementEnd('form');
|
||||||
common_show_footer();
|
common_show_footer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,289 +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 DeleteprofileAction extends Action
|
|
||||||
{
|
|
||||||
function handle($args)
|
|
||||||
{
|
|
||||||
parent::handle($args);
|
|
||||||
$this->server_error(_('Code not yet ready.'));
|
|
||||||
return;
|
|
||||||
if ('POST' === $_SERVER['REQUEST_METHOD']) {
|
|
||||||
$this->handle_post();
|
|
||||||
}
|
|
||||||
else if ('GET' === $_SERVER['REQUEST_METHOD']) {
|
|
||||||
$this->show_form();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function get_instructions()
|
|
||||||
{
|
|
||||||
return _('Export and delete your user information.');
|
|
||||||
}
|
|
||||||
|
|
||||||
function form_header($title, $msg=null, $success=false)
|
|
||||||
{
|
|
||||||
common_show_header($title,
|
|
||||||
null,
|
|
||||||
array($msg, $success),
|
|
||||||
array($this, 'show_top'));
|
|
||||||
}
|
|
||||||
|
|
||||||
function show_feeds_list($feeds)
|
|
||||||
{
|
|
||||||
common_element_start('div', array('class' => 'feedsdel'));
|
|
||||||
common_element('p', null, 'Feeds:');
|
|
||||||
common_element_start('ul', array('class' => 'xoxo'));
|
|
||||||
|
|
||||||
foreach ($feeds as $key => $value) {
|
|
||||||
$this->common_feed_item($feeds[$key]);
|
|
||||||
}
|
|
||||||
common_element_end('ul');
|
|
||||||
common_element_end('div');
|
|
||||||
}
|
|
||||||
|
|
||||||
//TODO move to common.php (and retrace its origin)
|
|
||||||
function common_feed_item($feed)
|
|
||||||
{
|
|
||||||
$user = common_current_user();
|
|
||||||
$nickname = $user->nickname;
|
|
||||||
|
|
||||||
switch($feed['item']) {
|
|
||||||
case 'notices': default:
|
|
||||||
$feed_classname = $feed['type'];
|
|
||||||
$feed_mimetype = "application/".$feed['type']."+xml";
|
|
||||||
$feed_title = "$nickname's ".$feed['version']." notice feed";
|
|
||||||
$feed['textContent'] = "RSS";
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'foaf':
|
|
||||||
$feed_classname = "foaf";
|
|
||||||
$feed_mimetype = "application/".$feed['type']."+xml";
|
|
||||||
$feed_title = "$nickname's FOAF file";
|
|
||||||
$feed['textContent'] = "FOAF";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
common_element_start('li');
|
|
||||||
common_element('a', array('href' => $feed['href'],
|
|
||||||
'class' => $feed_classname,
|
|
||||||
'type' => $feed_mimetype,
|
|
||||||
'title' => $feed_title),
|
|
||||||
$feed['textContent']);
|
|
||||||
common_element_end('li');
|
|
||||||
}
|
|
||||||
|
|
||||||
function show_form($msg=null, $success=false)
|
|
||||||
{
|
|
||||||
$this->form_header(_('Delete my account'), $msg, $success);
|
|
||||||
common_element('h2', null, _('Delete my account confirmation'));
|
|
||||||
$this->show_confirm_delete_form();
|
|
||||||
common_show_footer();
|
|
||||||
}
|
|
||||||
|
|
||||||
function show_confirm_delete_form()
|
|
||||||
{
|
|
||||||
$user = common_current_user();
|
|
||||||
$notices = DB_DataObject::factory('notice');
|
|
||||||
$notices->profile_id = $user->id;
|
|
||||||
$notice_count = (int) $notices->count();
|
|
||||||
|
|
||||||
common_element_start('form', array('method' => 'POST',
|
|
||||||
'id' => 'delete',
|
|
||||||
'action' =>
|
|
||||||
common_local_url('deleteprofile')));
|
|
||||||
|
|
||||||
common_hidden('token', common_session_token());
|
|
||||||
common_element('p', null, "Last chance to copy your notices and contacts by saving the two links below before deleting your account. Be careful, this operation cannot be undone.");
|
|
||||||
|
|
||||||
$this->show_feeds_list(array(0=>array('href'=>common_local_url('userrss', array('limit' => $notice_count, 'nickname' => $user->nickname)),
|
|
||||||
'type' => 'rss',
|
|
||||||
'version' => 'RSS 1.0',
|
|
||||||
'item' => 'notices'),
|
|
||||||
1=>array('href'=>common_local_url('foaf',array('nickname' => $user->nickname)),
|
|
||||||
'type' => 'rdf',
|
|
||||||
'version' => 'FOAF',
|
|
||||||
'item' => 'foaf')));
|
|
||||||
|
|
||||||
common_checkbox('confirmation', _('Check if you are sure you want to delete your account.'));
|
|
||||||
|
|
||||||
common_submit('deleteaccount', _('Delete my account'));
|
|
||||||
common_element_end('form');
|
|
||||||
}
|
|
||||||
|
|
||||||
function handle_post()
|
|
||||||
{
|
|
||||||
# CSRF protection
|
|
||||||
$token = $this->trimmed('token');
|
|
||||||
if (!$token || $token != common_session_token()) {
|
|
||||||
$this->show_form(_('There was a problem with your session token. Try again, please.'));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($this->arg('deleteaccount') && $this->arg('confirmation')) {
|
|
||||||
$this->delete_account();
|
|
||||||
}
|
|
||||||
$this->show_form();
|
|
||||||
}
|
|
||||||
|
|
||||||
function delete_account()
|
|
||||||
{
|
|
||||||
$user = common_current_user();
|
|
||||||
assert(!is_null($user)); # should already be checked
|
|
||||||
|
|
||||||
// deleted later through the profile
|
|
||||||
/*
|
|
||||||
$avatar = new Avatar;
|
|
||||||
$avatar->profile_id = $user->id;
|
|
||||||
$n_avatars_deleted = $avatar->delete();
|
|
||||||
*/
|
|
||||||
|
|
||||||
$fave = new Fave;
|
|
||||||
$fave->user_id = $user->id;
|
|
||||||
$n_faves_deleted = $fave->delete();
|
|
||||||
|
|
||||||
$confirmation = new Confirm_address;
|
|
||||||
$confirmation->user_id = $user->id;
|
|
||||||
$n_confirmations_deleted = $confirmation->delete();
|
|
||||||
|
|
||||||
// TODO foreign stuff...
|
|
||||||
|
|
||||||
$invitation = new Invitation;
|
|
||||||
$invitation->user_id = $user->id;
|
|
||||||
$n_invitations_deleted = $invitation->delete();
|
|
||||||
|
|
||||||
$message_from = new Message;
|
|
||||||
$message_from->from_profile = $user->id;
|
|
||||||
$n_messages_from_deleted = $message_from->delete();
|
|
||||||
|
|
||||||
$message_to = new Message;
|
|
||||||
$message_to->to_profile = $user->id;
|
|
||||||
$n_messages_to_deleted = $message_to->delete();
|
|
||||||
|
|
||||||
$notice_inbox = new Notice_inbox;
|
|
||||||
$notice_inbox->user_id = $user->id;
|
|
||||||
$n_notices_inbox_deleted = $notice_inbox->delete();
|
|
||||||
|
|
||||||
$profile_tagger = new Profile_tag;
|
|
||||||
$profile_tagger->tagger = $user->id;
|
|
||||||
$n_profiles_tagger_deleted = $profile_tagger->delete();
|
|
||||||
|
|
||||||
$profile_tagged = new Profile_tag;
|
|
||||||
$profile_tagged->tagged = $user->id;
|
|
||||||
$n_profiles_tagged_deleted = $profile_tagged->delete();
|
|
||||||
|
|
||||||
$remember_me = new Remember_me;
|
|
||||||
$remember_me->user_id = $user->id;
|
|
||||||
$n_remember_mes_deleted = $remember_me->delete();
|
|
||||||
|
|
||||||
$reply= new Reply;
|
|
||||||
$reply->profile_id = $user->id;
|
|
||||||
$n_replies_deleted = $reply->delete();
|
|
||||||
|
|
||||||
// FIXME we're not removings replies to deleted notices.
|
|
||||||
// notices should take care of that themselves.
|
|
||||||
|
|
||||||
$notice = new Notice;
|
|
||||||
$notice->profile_id = $user->id;
|
|
||||||
$n_notices_deleted = $notice->delete();
|
|
||||||
|
|
||||||
$subscriber = new Subscription;
|
|
||||||
$subscriber->subscriber = $user->id;
|
|
||||||
$n_subscribers_deleted = $subscriber->delete();
|
|
||||||
|
|
||||||
$subscribed = new Subscription;
|
|
||||||
$subscribed->subscribed = $user->id;
|
|
||||||
$n_subscribeds_deleted = $subscribed->delete();
|
|
||||||
|
|
||||||
$user_openid = new User_openid;
|
|
||||||
$user_openid->user_id = $user->id;
|
|
||||||
$n_user_openids_deleted = $user_openid->delete();
|
|
||||||
|
|
||||||
$profile = new Profile;
|
|
||||||
$profile->id = $user->id;
|
|
||||||
$profile->delete_avatars();
|
|
||||||
$n_profiles_deleted = $profile->delete();
|
|
||||||
$n_users_deleted = $user->delete();
|
|
||||||
|
|
||||||
// logout and redirect to public
|
|
||||||
common_set_user(null);
|
|
||||||
common_real_login(false); # not logged in
|
|
||||||
common_forgetme(); # don't log back in!
|
|
||||||
common_redirect(common_local_url('public'));
|
|
||||||
}
|
|
||||||
|
|
||||||
function show_top($arr)
|
|
||||||
{
|
|
||||||
$msg = $arr[0];
|
|
||||||
$success = $arr[1];
|
|
||||||
if ($msg) {
|
|
||||||
$this->message($msg, $success);
|
|
||||||
} else {
|
|
||||||
$inst = $this->get_instructions();
|
|
||||||
$output = common_markup_to_html($inst);
|
|
||||||
common_element_start('div', 'instructions');
|
|
||||||
common_raw($output);
|
|
||||||
common_element_end('div');
|
|
||||||
}
|
|
||||||
$this->settings_menu();
|
|
||||||
}
|
|
||||||
|
|
||||||
function settings_menu()
|
|
||||||
{
|
|
||||||
# action => array('prompt', 'title')
|
|
||||||
$menu =
|
|
||||||
array('profilesettings' =>
|
|
||||||
array(_('Profile'),
|
|
||||||
_('Change your profile settings')),
|
|
||||||
'emailsettings' =>
|
|
||||||
array(_('Email'),
|
|
||||||
_('Change email handling')),
|
|
||||||
'openidsettings' =>
|
|
||||||
array(_('OpenID'),
|
|
||||||
_('Add or remove OpenIDs')),
|
|
||||||
'smssettings' =>
|
|
||||||
array(_('SMS'),
|
|
||||||
_('Updates by SMS')),
|
|
||||||
'imsettings' =>
|
|
||||||
array(_('IM'),
|
|
||||||
_('Updates by instant messenger (IM)')),
|
|
||||||
'twittersettings' =>
|
|
||||||
array(_('Twitter'),
|
|
||||||
_('Twitter integration options')),
|
|
||||||
'othersettings' =>
|
|
||||||
array(_('Other'),
|
|
||||||
_('Other options')));
|
|
||||||
|
|
||||||
$action = $this->trimmed('action');
|
|
||||||
common_element_start('ul', array('id' => 'nav_views'));
|
|
||||||
foreach ($menu as $menuaction => $menudesc) {
|
|
||||||
if ($menuaction == 'imsettings' &&
|
|
||||||
!common_config('xmpp', 'enabled')) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
common_menu_item(common_local_url($menuaction),
|
|
||||||
$menudesc[0],
|
|
||||||
$menudesc[1],
|
|
||||||
$action == $menuaction);
|
|
||||||
}
|
|
||||||
common_element_end('ul');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -19,6 +19,8 @@
|
|||||||
|
|
||||||
if (!defined('LACONICA')) { exit(1); }
|
if (!defined('LACONICA')) { exit(1); }
|
||||||
|
|
||||||
|
require_once INSTALLDIR.'/lib/favorform.php';
|
||||||
|
|
||||||
class DisfavorAction extends Action
|
class DisfavorAction extends Action
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -28,7 +30,7 @@ class DisfavorAction extends Action
|
|||||||
parent::handle($args);
|
parent::handle($args);
|
||||||
|
|
||||||
if (!common_logged_in()) {
|
if (!common_logged_in()) {
|
||||||
common_user_error(_('Not logged in.'));
|
$this->clientError(_('Not logged in.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,7 +48,7 @@ class DisfavorAction extends Action
|
|||||||
$token = $this->trimmed('token-'.$notice->id);
|
$token = $this->trimmed('token-'.$notice->id);
|
||||||
|
|
||||||
if (!$token || $token != common_session_token()) {
|
if (!$token || $token != common_session_token()) {
|
||||||
$this->client_error(_("There was a problem with your session token. Try again, please."));
|
$this->clientError(_("There was a problem with your session token. Try again, please."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,7 +56,7 @@ class DisfavorAction extends Action
|
|||||||
$fave->user_id = $this->id;
|
$fave->user_id = $this->id;
|
||||||
$fave->notice_id = $notice->id;
|
$fave->notice_id = $notice->id;
|
||||||
if (!$fave->find(true)) {
|
if (!$fave->find(true)) {
|
||||||
$this->client_error(_('This notice is not a favorite!'));
|
$this->clientError(_('This notice is not a favorite!'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,21 +64,22 @@ class DisfavorAction extends Action
|
|||||||
|
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
common_log_db_error($fave, 'DELETE', __FILE__);
|
common_log_db_error($fave, 'DELETE', __FILE__);
|
||||||
$this->server_error(_('Could not delete favorite.'));
|
$this->serverError(_('Could not delete favorite.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$user->blowFavesCache();
|
$user->blowFavesCache();
|
||||||
|
|
||||||
if ($this->boolean('ajax')) {
|
if ($this->boolean('ajax')) {
|
||||||
common_start_html('text/xml;charset=utf-8', true);
|
$this->startHTML('text/xml;charset=utf-8', true);
|
||||||
common_element_start('head');
|
$this->elementStart('head');
|
||||||
common_element('title', null, _('Add to favorites'));
|
$this->element('title', null, _('Add to favorites'));
|
||||||
common_element_end('head');
|
$this->elementEnd('head');
|
||||||
common_element_start('body');
|
$this->elementStart('body');
|
||||||
common_favor_form($notice);
|
$favor = new FavorForm($this, $notice);
|
||||||
common_element_end('body');
|
$favor->show();
|
||||||
common_element_end('html');
|
$this->elementEnd('body');
|
||||||
|
$this->elementEnd('html');
|
||||||
} else {
|
} else {
|
||||||
common_redirect(common_local_url('showfavorites',
|
common_redirect(common_local_url('showfavorites',
|
||||||
array('nickname' => $user->nickname)));
|
array('nickname' => $user->nickname)));
|
||||||
|
@ -1,5 +1,17 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
|
||||||
|
/**
|
||||||
|
* Documentation action.
|
||||||
|
*
|
||||||
|
* PHP version 5
|
||||||
|
*
|
||||||
|
* @category Action
|
||||||
|
* @package Laconica
|
||||||
|
* @author Evan Prodromou <evan@controlyourself.ca>
|
||||||
|
* @author Robin Millette <millette@controlyourself.ca>
|
||||||
|
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
|
||||||
|
* @link http://laconi.ca/
|
||||||
|
*
|
||||||
* Laconica - a distributed open-source microblogging tool
|
* Laconica - a distributed open-source microblogging tool
|
||||||
* Copyright (C) 2008, Controlez-Vous, Inc.
|
* Copyright (C) 2008, Controlez-Vous, Inc.
|
||||||
*
|
*
|
||||||
@ -17,24 +29,64 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('LACONICA')) { exit(1); }
|
if (!defined('LACONICA')) {
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Documentation class.
|
||||||
|
*
|
||||||
|
* @category Action
|
||||||
|
* @package Laconica
|
||||||
|
* @author Evan Prodromou <evan@controlyourself.ca>
|
||||||
|
* @author Robin Millette <millette@controlyourself.ca>
|
||||||
|
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
|
||||||
|
* @link http://laconi.ca/
|
||||||
|
*/
|
||||||
class DocAction extends Action
|
class DocAction extends Action
|
||||||
{
|
{
|
||||||
|
var $filename;
|
||||||
|
var $title;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class handler.
|
||||||
|
*
|
||||||
|
* @param array $args array of arguments
|
||||||
|
*
|
||||||
|
* @return nothing
|
||||||
|
*/
|
||||||
function handle($args)
|
function handle($args)
|
||||||
{
|
{
|
||||||
parent::handle($args);
|
parent::handle($args);
|
||||||
$title = $this->trimmed('title');
|
$this->title = $this->trimmed('title');
|
||||||
$filename = INSTALLDIR.'/doc/'.$title;
|
$this->filename = INSTALLDIR.'/doc/'.$this->title;
|
||||||
if (!file_exists($filename)) {
|
if (!file_exists($this->filename)) {
|
||||||
common_user_error(_('No such document.'));
|
$this->clientError(_('No such document.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$c = file_get_contents($filename);
|
$this->showPage();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display content.
|
||||||
|
*
|
||||||
|
* @return nothing
|
||||||
|
*/
|
||||||
|
function showContent()
|
||||||
|
{
|
||||||
|
$c = file_get_contents($this->filename);
|
||||||
$output = common_markup_to_html($c);
|
$output = common_markup_to_html($c);
|
||||||
common_show_header(_(ucfirst($title)));
|
$this->raw($output);
|
||||||
common_raw($output);
|
}
|
||||||
common_show_footer();
|
|
||||||
|
/**
|
||||||
|
* Page title.
|
||||||
|
*
|
||||||
|
* @return page title
|
||||||
|
*/
|
||||||
|
function title()
|
||||||
|
{
|
||||||
|
return ucfirst($this->title);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/**
|
||||||
* Laconica - a distributed open-source microblogging tool
|
* Laconica, the distributed open-source microblogging tool
|
||||||
* Copyright (C) 2008, Controlez-Vous, Inc.
|
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* Settings for email
|
||||||
|
*
|
||||||
|
* 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
|
* 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
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
@ -15,110 +18,187 @@
|
|||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* 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/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* @category Settings
|
||||||
|
* @package Laconica
|
||||||
|
* @author Evan Prodromou <evan@controlyourself.ca>
|
||||||
|
* @author Zach Copley <zach@controlyourself.ca>
|
||||||
|
* @copyright 2008-2009 Control Yourself, Inc.
|
||||||
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||||
|
* @link http://laconi.ca/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('LACONICA')) { exit(1); }
|
if (!defined('LACONICA')) {
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
require_once(INSTALLDIR.'/lib/settingsaction.php');
|
require_once INSTALLDIR.'/lib/accountsettingsaction.php';
|
||||||
|
|
||||||
class EmailsettingsAction extends SettingsAction
|
/**
|
||||||
|
* Settings for email
|
||||||
|
*
|
||||||
|
* @category Settings
|
||||||
|
* @package Laconica
|
||||||
|
* @author Evan Prodromou <evan@controlyourself.ca>
|
||||||
|
* @author Zach Copley <zach@controlyourself.ca>
|
||||||
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||||
|
* @link http://laconi.ca/
|
||||||
|
*
|
||||||
|
* @see Widget
|
||||||
|
*/
|
||||||
|
|
||||||
|
class EmailsettingsAction extends AccountSettingsAction
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Title of the page
|
||||||
|
*
|
||||||
|
* @return string Title of the page
|
||||||
|
*/
|
||||||
|
|
||||||
function get_instructions()
|
function title()
|
||||||
|
{
|
||||||
|
return _('Email Settings');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instructions for use
|
||||||
|
*
|
||||||
|
* @return instructions for use
|
||||||
|
*/
|
||||||
|
|
||||||
|
function getInstructions()
|
||||||
{
|
{
|
||||||
return _('Manage how you get email from %%site.name%%.');
|
return _('Manage how you get email from %%site.name%%.');
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_form($msg=null, $success=false)
|
/**
|
||||||
|
* Content area of the page
|
||||||
|
*
|
||||||
|
* Shows a form for adding and removing email addresses and setting
|
||||||
|
* email preferences.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
|
function showContent()
|
||||||
{
|
{
|
||||||
$user = common_current_user();
|
$user = common_current_user();
|
||||||
$this->form_header(_('Email Settings'), $msg, $success);
|
|
||||||
common_element_start('form', array('method' => 'post',
|
$this->elementStart('form', array('method' => 'post',
|
||||||
'id' => 'emailsettings',
|
'id' => 'form_settings_email',
|
||||||
|
'class' => 'form_settings',
|
||||||
'action' =>
|
'action' =>
|
||||||
common_local_url('emailsettings')));
|
common_local_url('emailsettings')));
|
||||||
common_hidden('token', common_session_token());
|
|
||||||
|
|
||||||
common_element('h2', null, _('Address'));
|
$this->elementStart('fieldset', array('id' => 'settings_email_address'));
|
||||||
|
$this->element('legend', null, _('Address'));
|
||||||
|
$this->hidden('token', common_session_token());
|
||||||
|
|
||||||
if ($user->email) {
|
if ($user->email) {
|
||||||
common_element_start('p');
|
$this->element('p', array('id' => 'form_confirmed'), $user->email);
|
||||||
common_element('span', 'address confirmed', $user->email);
|
$this->element('p', array('class' => 'form_note'), _('Current confirmed email address.'));
|
||||||
common_element('span', 'input_instructions',
|
$this->hidden('email', $user->email);
|
||||||
_('Current confirmed email address.'));
|
$this->submit('remove', _('Remove'));
|
||||||
common_hidden('email', $user->email);
|
|
||||||
common_element_end('p');
|
|
||||||
common_submit('remove', _('Remove'));
|
|
||||||
} else {
|
} else {
|
||||||
$confirm = $this->get_confirmation();
|
$confirm = $this->getConfirmation();
|
||||||
if ($confirm) {
|
if ($confirm) {
|
||||||
common_element_start('p');
|
$this->element('p', array('id' => 'form_unconfirmed'), $confirm->address);
|
||||||
common_element('span', 'address unconfirmed', $confirm->address);
|
$this->element('p', array('class' => 'form_note'),
|
||||||
common_element('span', 'input_instructions',
|
_('Awaiting confirmation on this address. '.
|
||||||
_('Awaiting confirmation on this address. Check your inbox (and spam box!) for a message with further instructions.'));
|
'Check your inbox (and spam box!) for a message '.
|
||||||
common_hidden('email', $confirm->address);
|
'with further instructions.'));
|
||||||
common_element_end('p');
|
$this->hidden('email', $confirm->address);
|
||||||
common_submit('cancel', _('Cancel'));
|
$this->submit('cancel', _('Cancel'));
|
||||||
} else {
|
} else {
|
||||||
common_input('email', _('Email Address'),
|
$this->elementStart('ul', 'form_data');
|
||||||
|
$this->elementStart('li');
|
||||||
|
$this->input('email', _('Email Address'),
|
||||||
($this->arg('email')) ? $this->arg('email') : null,
|
($this->arg('email')) ? $this->arg('email') : null,
|
||||||
_('Email address, like "UserName@example.org"'));
|
_('Email address, like "UserName@example.org"'));
|
||||||
common_submit('add', _('Add'));
|
$this->elementEnd('li');
|
||||||
|
$this->elementEnd('ul');
|
||||||
|
$this->submit('add', _('Add'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$this->elementEnd('fieldset');
|
||||||
|
|
||||||
if ($user->email) {
|
if ($user->email) {
|
||||||
common_element('h2', null, _('Incoming email'));
|
$this->elementStart('fieldset', array('id' => 'settings_email_incoming'));
|
||||||
|
$this->element('legend',_('Incoming email'));
|
||||||
if ($user->incomingemail) {
|
if ($user->incomingemail) {
|
||||||
common_element_start('p');
|
$this->elementStart('p');
|
||||||
common_element('span', 'address', $user->incomingemail);
|
$this->element('span', 'address', $user->incomingemail);
|
||||||
common_element('span', 'input_instructions',
|
$this->element('span', 'input_instructions',
|
||||||
_('Send email to this address to post new notices.'));
|
_('Send email to this address to post new notices.'));
|
||||||
common_element_end('p');
|
$this->elementEnd('p');
|
||||||
common_submit('removeincoming', _('Remove'));
|
$this->submit('removeincoming', _('Remove'));
|
||||||
}
|
}
|
||||||
|
|
||||||
common_element_start('p');
|
$this->elementStart('p');
|
||||||
common_element('span', 'input_instructions',
|
$this->element('span', 'input_instructions',
|
||||||
_('Make a new email address for posting to; cancels the old one.'));
|
_('Make a new email address for posting to; '.
|
||||||
common_element_end('p');
|
'cancels the old one.'));
|
||||||
common_submit('newincoming', _('New'));
|
$this->elementEnd('p');
|
||||||
|
$this->submit('newincoming', _('New'));
|
||||||
|
$this->elementEnd('fieldset');
|
||||||
}
|
}
|
||||||
|
|
||||||
common_element('h2', null, _('Preferences'));
|
$this->elementStart('fieldset', array('id' => 'settings_email_preferences'));
|
||||||
|
$this->element('legend', null, _('Preferences'));
|
||||||
|
|
||||||
common_checkbox('emailnotifysub',
|
$this->elementStart('ul', 'form_data');
|
||||||
|
$this->elementStart('li');
|
||||||
|
$this->checkbox('emailnotifysub',
|
||||||
_('Send me notices of new subscriptions through email.'),
|
_('Send me notices of new subscriptions through email.'),
|
||||||
$user->emailnotifysub);
|
$user->emailnotifysub);
|
||||||
common_checkbox('emailnotifyfav',
|
$this->elementEnd('li');
|
||||||
_('Send me email when someone adds my notice as a favorite.'),
|
$this->elementStart('li');
|
||||||
|
$this->checkbox('emailnotifyfav',
|
||||||
|
_('Send me email when someone '.
|
||||||
|
'adds my notice as a favorite.'),
|
||||||
$user->emailnotifyfav);
|
$user->emailnotifyfav);
|
||||||
common_checkbox('emailnotifymsg',
|
$this->elementEnd('li');
|
||||||
|
$this->elementStart('li');
|
||||||
|
$this->checkbox('emailnotifymsg',
|
||||||
_('Send me email when someone sends me a private message.'),
|
_('Send me email when someone sends me a private message.'),
|
||||||
$user->emailnotifymsg);
|
$user->emailnotifymsg);
|
||||||
common_checkbox('emailnotifynudge',
|
$this->elementEnd('li');
|
||||||
|
$this->elementStart('li');
|
||||||
|
$this->checkbox('emailnotifynudge',
|
||||||
_('Allow friends to nudge me and send me an email.'),
|
_('Allow friends to nudge me and send me an email.'),
|
||||||
$user->emailnotifynudge);
|
$user->emailnotifynudge);
|
||||||
common_checkbox('emailpost',
|
$this->elementEnd('li');
|
||||||
|
$this->elementStart('li');
|
||||||
|
$this->checkbox('emailpost',
|
||||||
_('I want to post notices by email.'),
|
_('I want to post notices by email.'),
|
||||||
$user->emailpost);
|
$user->emailpost);
|
||||||
common_checkbox('emailmicroid',
|
$this->elementEnd('li');
|
||||||
|
$this->elementStart('li');
|
||||||
|
$this->checkbox('emailmicroid',
|
||||||
_('Publish a MicroID for my email address.'),
|
_('Publish a MicroID for my email address.'),
|
||||||
$user->emailmicroid);
|
$user->emailmicroid);
|
||||||
|
$this->elementEnd('li');
|
||||||
common_submit('save', _('Save'));
|
$this->elementEnd('ul');
|
||||||
|
$this->submit('save', _('Save'));
|
||||||
common_element_end('form');
|
$this->elementEnd('fieldset');
|
||||||
common_show_footer();
|
$this->elementEnd('form');
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_confirmation()
|
/**
|
||||||
|
* Gets any existing email address confirmations we're waiting for
|
||||||
|
*
|
||||||
|
* @return Confirm_address Email address confirmation for user, or null
|
||||||
|
*/
|
||||||
|
|
||||||
|
function getConfirmation()
|
||||||
{
|
{
|
||||||
$user = common_current_user();
|
$user = common_current_user();
|
||||||
|
|
||||||
$confirm = new Confirm_address();
|
$confirm = new Confirm_address();
|
||||||
|
|
||||||
$confirm->user_id = $user->id;
|
$confirm->user_id = $user->id;
|
||||||
$confirm->address_type = 'email';
|
$confirm->address_type = 'email';
|
||||||
|
|
||||||
if ($confirm->find(true)) {
|
if ($confirm->find(true)) {
|
||||||
return $confirm;
|
return $confirm;
|
||||||
} else {
|
} else {
|
||||||
@ -126,36 +206,51 @@ class EmailsettingsAction extends SettingsAction
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function handle_post()
|
/**
|
||||||
{
|
* Handle posts
|
||||||
|
*
|
||||||
|
* Since there are a lot of different options on the page, we
|
||||||
|
* figure out what we're supposed to do based on which button was
|
||||||
|
* pushed
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
# CSRF protection
|
function handlePost()
|
||||||
|
{
|
||||||
|
// CSRF protection
|
||||||
$token = $this->trimmed('token');
|
$token = $this->trimmed('token');
|
||||||
if (!$token || $token != common_session_token()) {
|
if (!$token || $token != common_session_token()) {
|
||||||
$this->show_form(_('There was a problem with your session token. Try again, please.'));
|
$this->show_form(_('There was a problem with your session token. '.
|
||||||
|
'Try again, please.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->arg('save')) {
|
if ($this->arg('save')) {
|
||||||
$this->save_preferences();
|
$this->savePreferences();
|
||||||
} else if ($this->arg('add')) {
|
} else if ($this->arg('add')) {
|
||||||
$this->add_address();
|
$this->addAddress();
|
||||||
} else if ($this->arg('cancel')) {
|
} else if ($this->arg('cancel')) {
|
||||||
$this->cancel_confirmation();
|
$this->cancelConfirmation();
|
||||||
} else if ($this->arg('remove')) {
|
} else if ($this->arg('remove')) {
|
||||||
$this->remove_address();
|
$this->removeAddress();
|
||||||
} else if ($this->arg('removeincoming')) {
|
} else if ($this->arg('removeincoming')) {
|
||||||
$this->remove_incoming();
|
$this->removeIncoming();
|
||||||
} else if ($this->arg('newincoming')) {
|
} else if ($this->arg('newincoming')) {
|
||||||
$this->new_incoming();
|
$this->newIncoming();
|
||||||
} else {
|
} else {
|
||||||
$this->show_form(_('Unexpected form submission.'));
|
$this->showForm(_('Unexpected form submission.'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function save_preferences()
|
/**
|
||||||
|
* Save email preferences
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
|
function savePreferences()
|
||||||
{
|
{
|
||||||
|
|
||||||
$emailnotifysub = $this->boolean('emailnotifysub');
|
$emailnotifysub = $this->boolean('emailnotifysub');
|
||||||
$emailnotifyfav = $this->boolean('emailnotifyfav');
|
$emailnotifyfav = $this->boolean('emailnotifyfav');
|
||||||
$emailnotifymsg = $this->boolean('emailnotifymsg');
|
$emailnotifymsg = $this->boolean('emailnotifymsg');
|
||||||
@ -165,7 +260,7 @@ class EmailsettingsAction extends SettingsAction
|
|||||||
|
|
||||||
$user = common_current_user();
|
$user = common_current_user();
|
||||||
|
|
||||||
assert(!is_null($user)); # should already be checked
|
assert(!is_null($user)); // should already be checked
|
||||||
|
|
||||||
$user->query('BEGIN');
|
$user->query('BEGIN');
|
||||||
|
|
||||||
@ -182,47 +277,54 @@ class EmailsettingsAction extends SettingsAction
|
|||||||
|
|
||||||
if ($result === false) {
|
if ($result === false) {
|
||||||
common_log_db_error($user, 'UPDATE', __FILE__);
|
common_log_db_error($user, 'UPDATE', __FILE__);
|
||||||
common_server_error(_('Couldn\'t update user.'));
|
$this->serverError(_('Couldn\'t update user.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$user->query('COMMIT');
|
$user->query('COMMIT');
|
||||||
|
|
||||||
$this->show_form(_('Preferences saved.'), true);
|
$this->showForm(_('Preferences saved.'), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
function add_address()
|
/**
|
||||||
{
|
* Add the address passed in by the user
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
|
function addAddress()
|
||||||
|
{
|
||||||
$user = common_current_user();
|
$user = common_current_user();
|
||||||
|
|
||||||
$email = $this->trimmed('email');
|
$email = $this->trimmed('email');
|
||||||
|
|
||||||
# Some validation
|
// Some validation
|
||||||
|
|
||||||
if (!$email) {
|
if (!$email) {
|
||||||
$this->show_form(_('No email address.'));
|
$this->showForm(_('No email address.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$email = common_canonical_email($email);
|
$email = common_canonical_email($email);
|
||||||
|
|
||||||
if (!$email) {
|
if (!$email) {
|
||||||
$this->show_form(_('Cannot normalize that email address'));
|
$this->showForm(_('Cannot normalize that email address'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!Validate::email($email, true)) {
|
if (!Validate::email($email, true)) {
|
||||||
$this->show_form(_('Not a valid email address'));
|
$this->showForm(_('Not a valid email address'));
|
||||||
return;
|
return;
|
||||||
} else if ($user->email == $email) {
|
} else if ($user->email == $email) {
|
||||||
$this->show_form(_('That is already your email address.'));
|
$this->showForm(_('That is already your email address.'));
|
||||||
return;
|
return;
|
||||||
} else if ($this->email_exists($email)) {
|
} else if ($this->emailExists($email)) {
|
||||||
$this->show_form(_('That email address already belongs to another user.'));
|
$this->showForm(_('That email address already belongs '.
|
||||||
|
'to another user.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$confirm = new Confirm_address();
|
$confirm = new Confirm_address();
|
||||||
|
|
||||||
$confirm->address = $email;
|
$confirm->address = $email;
|
||||||
$confirm->address_type = 'email';
|
$confirm->address_type = 'email';
|
||||||
$confirm->user_id = $user->id;
|
$confirm->user_id = $user->id;
|
||||||
@ -232,27 +334,37 @@ class EmailsettingsAction extends SettingsAction
|
|||||||
|
|
||||||
if ($result === false) {
|
if ($result === false) {
|
||||||
common_log_db_error($confirm, 'INSERT', __FILE__);
|
common_log_db_error($confirm, 'INSERT', __FILE__);
|
||||||
common_server_error(_('Couldn\'t insert confirmation code.'));
|
$this->serverError(_('Couldn\'t insert confirmation code.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
mail_confirm_address($user, $confirm->code, $user->nickname, $email);
|
mail_confirm_address($user, $confirm->code, $user->nickname, $email);
|
||||||
|
|
||||||
$msg = _('A confirmation code was sent to the email address you added. Check your inbox (and spam box!) for the code and instructions on how to use it.');
|
$msg = _('A confirmation code was sent to the email address you added. '.
|
||||||
|
'Check your inbox (and spam box!) for the code and instructions '.
|
||||||
|
'on how to use it.');
|
||||||
|
|
||||||
$this->show_form($msg, true);
|
$this->showForm($msg, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
function cancel_confirmation()
|
/**
|
||||||
|
* Handle a request to cancel email confirmation
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
|
function cancelConfirmation()
|
||||||
{
|
{
|
||||||
$email = $this->arg('email');
|
$email = $this->arg('email');
|
||||||
$confirm = $this->get_confirmation();
|
|
||||||
|
$confirm = $this->getConfirmation();
|
||||||
|
|
||||||
if (!$confirm) {
|
if (!$confirm) {
|
||||||
$this->show_form(_('No pending confirmation to cancel.'));
|
$this->showForm(_('No pending confirmation to cancel.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ($confirm->address != $email) {
|
if ($confirm->address != $email) {
|
||||||
$this->show_form(_('That is the wrong IM address.'));
|
$this->showForm(_('That is the wrong IM address.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -260,79 +372,115 @@ class EmailsettingsAction extends SettingsAction
|
|||||||
|
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
common_log_db_error($confirm, 'DELETE', __FILE__);
|
common_log_db_error($confirm, 'DELETE', __FILE__);
|
||||||
$this->server_error(_('Couldn\'t delete email confirmation.'));
|
$this->serverError(_('Couldn\'t delete email confirmation.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->show_form(_('Confirmation cancelled.'), true);
|
$this->showForm(_('Confirmation cancelled.'), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
function remove_address()
|
/**
|
||||||
{
|
* Handle a request to remove an address from the user's account
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
|
function removeAddress()
|
||||||
|
{
|
||||||
$user = common_current_user();
|
$user = common_current_user();
|
||||||
|
|
||||||
$email = $this->arg('email');
|
$email = $this->arg('email');
|
||||||
|
|
||||||
# Maybe an old tab open...?
|
// Maybe an old tab open...?
|
||||||
|
|
||||||
if ($user->email != $email) {
|
if ($user->email != $email) {
|
||||||
$this->show_form(_('That is not your email address.'));
|
$this->showForm(_('That is not your email address.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$user->query('BEGIN');
|
$user->query('BEGIN');
|
||||||
|
|
||||||
$original = clone($user);
|
$original = clone($user);
|
||||||
|
|
||||||
$user->email = null;
|
$user->email = null;
|
||||||
|
|
||||||
$result = $user->updateKeys($original);
|
$result = $user->updateKeys($original);
|
||||||
|
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
common_log_db_error($user, 'UPDATE', __FILE__);
|
common_log_db_error($user, 'UPDATE', __FILE__);
|
||||||
common_server_error(_('Couldn\'t update user.'));
|
$this->serverError(_('Couldn\'t update user.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$user->query('COMMIT');
|
$user->query('COMMIT');
|
||||||
|
|
||||||
$this->show_form(_('The address was removed.'), true);
|
$this->showForm(_('The address was removed.'), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
function remove_incoming()
|
/**
|
||||||
|
* Handle a request to remove an incoming email address
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
|
function removeIncoming()
|
||||||
{
|
{
|
||||||
$user = common_current_user();
|
$user = common_current_user();
|
||||||
|
|
||||||
if (!$user->incomingemail) {
|
if (!$user->incomingemail) {
|
||||||
$this->show_form(_('No incoming email address.'));
|
$this->showForm(_('No incoming email address.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$orig = clone($user);
|
$orig = clone($user);
|
||||||
|
|
||||||
$user->incomingemail = null;
|
$user->incomingemail = null;
|
||||||
|
|
||||||
if (!$user->updateKeys($orig)) {
|
if (!$user->updateKeys($orig)) {
|
||||||
common_log_db_error($user, 'UPDATE', __FILE__);
|
common_log_db_error($user, 'UPDATE', __FILE__);
|
||||||
$this->server_error(_("Couldn't update user record."));
|
$this->serverError(_("Couldn't update user record."));
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->show_form(_('Incoming email address removed.'), true);
|
$this->showForm(_('Incoming email address removed.'), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
function new_incoming()
|
/**
|
||||||
|
* Generate a new incoming email address
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
|
function newIncoming()
|
||||||
{
|
{
|
||||||
$user = common_current_user();
|
$user = common_current_user();
|
||||||
|
|
||||||
$orig = clone($user);
|
$orig = clone($user);
|
||||||
|
|
||||||
$user->incomingemail = mail_new_incoming_address();
|
$user->incomingemail = mail_new_incoming_address();
|
||||||
|
|
||||||
if (!$user->updateKeys($orig)) {
|
if (!$user->updateKeys($orig)) {
|
||||||
common_log_db_error($user, 'UPDATE', __FILE__);
|
common_log_db_error($user, 'UPDATE', __FILE__);
|
||||||
$this->server_error(_("Couldn't update user record."));
|
$this->serverError(_("Couldn't update user record."));
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->show_form(_('New incoming email address added.'), true);
|
$this->showForm(_('New incoming email address added.'), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
function email_exists($email)
|
/**
|
||||||
|
* Does another user already have this email address?
|
||||||
|
*
|
||||||
|
* Email addresses are unique for users.
|
||||||
|
*
|
||||||
|
* @param string $email Address to check
|
||||||
|
*
|
||||||
|
* @return boolean Whether the email already exists.
|
||||||
|
*/
|
||||||
|
|
||||||
|
function emailExists($email)
|
||||||
{
|
{
|
||||||
$user = common_current_user();
|
$user = common_current_user();
|
||||||
|
|
||||||
$other = User::staticGet('email', $email);
|
$other = User::staticGet('email', $email);
|
||||||
|
|
||||||
if (!$other) {
|
if (!$other) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
if (!defined('LACONICA')) { exit(1); }
|
if (!defined('LACONICA')) { exit(1); }
|
||||||
|
|
||||||
require_once(INSTALLDIR.'/lib/facebookaction.php');
|
require_once INSTALLDIR.'/lib/facebookaction.php';
|
||||||
|
|
||||||
class FacebookhomeAction extends FacebookAction
|
class FacebookhomeAction extends FacebookAction
|
||||||
{
|
{
|
||||||
@ -34,9 +34,43 @@ class FacebookhomeAction extends FacebookAction
|
|||||||
// Check to see whether there's already a Facebook link for this user
|
// Check to see whether there's already a Facebook link for this user
|
||||||
$flink = Foreign_link::getByForeignID($fbuid, FACEBOOK_SERVICE);
|
$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
|
||||||
|
// promt the user the first time she uses the app
|
||||||
|
if ($this->arg('skip')) {
|
||||||
|
$facebook->api_client->data_setUserPreference(
|
||||||
|
FACEBOOK_PROMPTED_UPDATE_PREF, 'true');
|
||||||
|
}
|
||||||
|
|
||||||
if ($flink) {
|
if ($flink) {
|
||||||
|
|
||||||
|
if ($_POST['submit'] == 'Send') {
|
||||||
|
$this->saveNewNotice($flink);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$user = $flink->getUser();
|
||||||
|
common_set_user($user);
|
||||||
|
|
||||||
|
// If this is the first time the user has started the app
|
||||||
|
// prompt for Facebook status update permission
|
||||||
|
if (!$facebook->api_client->users_hasAppPermission('status_update')) {
|
||||||
|
|
||||||
|
if ($facebook->api_client->data_getUserPreference(
|
||||||
|
FACEBOOK_PROMPTED_UPDATE_PREF) != 'true') {
|
||||||
|
$this->getUpdatePermission();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Use is authenticated and has already been prompted once for
|
||||||
|
// Facebook status update permission? Then show the main page
|
||||||
|
// of the app
|
||||||
$this->showHome($flink, null);
|
$this->showHome($flink, null);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
// User hasn't authenticated yet, prompt for creds
|
||||||
$this->login($fbuid);
|
$this->login($fbuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,8 +105,10 @@ class FacebookhomeAction extends FacebookAction
|
|||||||
// XXX: Do some error handling here
|
// XXX: Do some error handling here
|
||||||
|
|
||||||
$this->setDefaults();
|
$this->setDefaults();
|
||||||
|
//$this->showHome($flink, _('You can now use Identi.ca from Facebook!'));
|
||||||
|
|
||||||
$this->showHome($flink, _('You can now use Identi.ca from Facebook!'));
|
$this->getUpdatePermission();
|
||||||
|
return;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$msg = _('Incorrect username or password.');
|
$msg = _('Incorrect username or password.');
|
||||||
@ -80,6 +116,7 @@ class FacebookhomeAction extends FacebookAction
|
|||||||
}
|
}
|
||||||
|
|
||||||
$this->showLoginForm($msg);
|
$this->showLoginForm($msg);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function setDefaults()
|
function setDefaults()
|
||||||
@ -87,7 +124,10 @@ class FacebookhomeAction extends FacebookAction
|
|||||||
$facebook = get_facebook();
|
$facebook = get_facebook();
|
||||||
|
|
||||||
// A default prefix string for notices
|
// A default prefix string for notices
|
||||||
$facebook->api_client->data_setUserPreference(1, 'dented: ');
|
$facebook->api_client->data_setUserPreference(
|
||||||
|
FACEBOOK_NOTICE_PREFIX, 'dented: ');
|
||||||
|
$facebook->api_client->data_setUserPreference(
|
||||||
|
FACEBOOK_PROMPTED_UPDATE_PREF, 'false');
|
||||||
}
|
}
|
||||||
|
|
||||||
function showHome($flink, $msg)
|
function showHome($flink, $msg)
|
||||||
@ -101,19 +141,16 @@ class FacebookhomeAction extends FacebookAction
|
|||||||
$notice = $user->getCurrentNotice();
|
$notice = $user->getCurrentNotice();
|
||||||
update_profile_box($facebook, $fbuid, $user, $notice);
|
update_profile_box($facebook, $fbuid, $user, $notice);
|
||||||
|
|
||||||
|
$this->showHeader($msg);
|
||||||
|
$this->showNoticeForm($user);
|
||||||
|
$this->showNav('Home');
|
||||||
|
|
||||||
$this->show_header('Home');
|
echo $this->showNotices($user);
|
||||||
|
|
||||||
if ($msg) {
|
$this->showFooter();
|
||||||
common_element('fb:success', array('message' => $msg));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
echo $this->show_notices($user);
|
function showNotices($user)
|
||||||
|
|
||||||
$this->show_footer();
|
|
||||||
}
|
|
||||||
|
|
||||||
function show_notices($user)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
$page = $this->trimmed('page');
|
$page = $this->trimmed('page');
|
||||||
@ -123,16 +160,113 @@ class FacebookhomeAction extends FacebookAction
|
|||||||
|
|
||||||
$notice = $user->noticesWithFriends(($page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1);
|
$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,
|
facebookPagination($page > 1, $cnt > NOTICES_PER_PAGE,
|
||||||
$page, 'all', array('nickname' => $user->nickname));
|
$page, 'all', array('nickname' => $user->nickname));
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_notice_list($notice)
|
function showNoticeList($notice)
|
||||||
{
|
{
|
||||||
$nl = new NoticeList($notice);
|
$nl = new FacebookNoticeList($notice);
|
||||||
return $nl->show();
|
return $nl->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getUpdatePermission() {
|
||||||
|
|
||||||
|
$facebook = get_facebook();
|
||||||
|
$fbuid = $facebook->require_login();
|
||||||
|
|
||||||
|
startFBML();
|
||||||
|
|
||||||
|
$this->showStylesheets();
|
||||||
|
$this->showScripts();
|
||||||
|
|
||||||
|
$this->showLogo();
|
||||||
|
|
||||||
|
$this->elementStart('div', array('class' => 'content'));
|
||||||
|
|
||||||
|
// Figure what the URL of our app is.
|
||||||
|
$app_props = $facebook->api_client->Admin_getAppProperties(
|
||||||
|
array('canvas_name', 'application_name'));
|
||||||
|
$app_url = 'http://apps.facebook.com/' . $app_props['canvas_name'] . '/index.php';
|
||||||
|
$app_name = $app_props['application_name'];
|
||||||
|
|
||||||
|
$instructions = sprintf(_('If you would like the %s app to automatically update ' .
|
||||||
|
'your Facebook status with your latest notice, you need ' .
|
||||||
|
'to give it permission.'), $app_name);
|
||||||
|
|
||||||
|
$this->elementStart('p');
|
||||||
|
$this->element('span', array('id' => 'permissions_notice'), $instructions);
|
||||||
|
$this->elementEnd('p');
|
||||||
|
|
||||||
|
$this->elementStart('form', array('method' => 'post',
|
||||||
|
'action' => $app_url,
|
||||||
|
'id' => 'facebook-skip-permissions'));
|
||||||
|
|
||||||
|
$this->elementStart('ul', array('id' => 'fb-permissions-list'));
|
||||||
|
$this->elementStart('li', array('id' => 'fb-permissions-item'));
|
||||||
|
$this->elementStart('fb:prompt-permission', array('perms' => 'status_update',
|
||||||
|
'next_fbjs' => 'document.setLocation(\'' . $app_url . '\')'));
|
||||||
|
$this->element('span', array('class' => 'facebook-button'),
|
||||||
|
_('Allow Identi.ca to update my Facebook status'));
|
||||||
|
$this->elementEnd('fb:prompt-permission');
|
||||||
|
$this->elementEnd('li');
|
||||||
|
|
||||||
|
$this->elementStart('li', array('id' => 'fb-permissions-item'));
|
||||||
|
common_submit('skip', _('Skip'));
|
||||||
|
$this->elementEnd('li');
|
||||||
|
$this->elementEnd('ul');
|
||||||
|
|
||||||
|
$this->elementEnd('form');
|
||||||
|
$this->elementEnd('div');
|
||||||
|
|
||||||
|
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!');
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -41,26 +41,26 @@ class FacebookinviteAction extends FacebookAction
|
|||||||
$facebook = get_facebook();
|
$facebook = get_facebook();
|
||||||
$fbuid = $facebook->require_login();
|
$fbuid = $facebook->require_login();
|
||||||
|
|
||||||
$this->show_header('Invite');
|
$this->showHeader('Invite');
|
||||||
|
|
||||||
common_element('h2', null, _('Thanks for inviting your friends to use Identi.ca!'));
|
$this->element('h2', null, _('Thanks for inviting your friends to use Identi.ca!'));
|
||||||
common_element('p', null, _('Invitations have been sent to the following users:'));
|
$this->element('p', null, _('Invitations have been sent to the following users:'));
|
||||||
|
|
||||||
$friend_ids = $_POST['ids']; // Hmm... $this->arg('ids') doesn't seem to work
|
$friend_ids = $_POST['ids']; // Hmm... $this->arg('ids') doesn't seem to work
|
||||||
|
|
||||||
common_element_start("ul");
|
$this->elementStart("ul");
|
||||||
|
|
||||||
foreach ($friend_ids as $friend) {
|
foreach ($friend_ids as $friend) {
|
||||||
common_element_start('li');
|
$this->elementStart('li');
|
||||||
common_element('fb:profile-pic', array('uid' => $friend));
|
$this->element('fb:profile-pic', array('uid' => $friend));
|
||||||
common_element('fb:name', array('uid' => $friend,
|
$this->element('fb:name', array('uid' => $friend,
|
||||||
'capitalize' => 'true'));
|
'capitalize' => 'true'));
|
||||||
common_element_end('li');
|
$this->elementEnd('li');
|
||||||
}
|
}
|
||||||
|
|
||||||
common_element_end("ul");
|
$this->elementEnd("ul");
|
||||||
|
|
||||||
$this->show_footer();
|
$this->showFooter();
|
||||||
}
|
}
|
||||||
|
|
||||||
function showInviteForm()
|
function showInviteForm()
|
||||||
@ -69,7 +69,8 @@ class FacebookinviteAction extends FacebookAction
|
|||||||
$facebook = get_facebook();
|
$facebook = get_facebook();
|
||||||
$fbuid = $facebook->require_login();
|
$fbuid = $facebook->require_login();
|
||||||
|
|
||||||
$this->show_header('Invite');
|
$this->showHeader();
|
||||||
|
$this->showNav('Invite');
|
||||||
|
|
||||||
// Get a list of users who are already using the app for exclusion
|
// Get a list of users who are already using the app for exclusion
|
||||||
$exclude_ids = $facebook->api_client->friends_getAppUsers();
|
$exclude_ids = $facebook->api_client->friends_getAppUsers();
|
||||||
@ -77,34 +78,34 @@ class FacebookinviteAction extends FacebookAction
|
|||||||
$content = _('You have been invited to Identi.ca!') .
|
$content = _('You have been invited to Identi.ca!') .
|
||||||
htmlentities('<fb:req-choice url="http://apps.facebook.com/identica_app/" label="Add"/>');
|
htmlentities('<fb:req-choice url="http://apps.facebook.com/identica_app/" label="Add"/>');
|
||||||
|
|
||||||
common_element_start('fb:request-form', array('action' => 'invite.php',
|
$this->elementStart('fb:request-form', array('action' => 'invite.php',
|
||||||
'method' => 'post',
|
'method' => 'post',
|
||||||
'invite' => 'true',
|
'invite' => 'true',
|
||||||
'type' => 'Identi.ca',
|
'type' => 'Identi.ca',
|
||||||
'content' => $content));
|
'content' => $content));
|
||||||
common_hidden('invite', 'true');
|
$this->hidden('invite', 'true');
|
||||||
$actiontext = 'Invite your friends to use Identi.ca.';
|
$actiontext = 'Invite your friends to use Identi.ca.';
|
||||||
common_element('fb:multi-friend-selector', array('showborder' => 'false',
|
$this->element('fb:multi-friend-selector', array('showborder' => 'false',
|
||||||
'actiontext' => $actiontext,
|
'actiontext' => $actiontext,
|
||||||
'exclude_ids' => implode(',', $exclude_ids),
|
'exclude_ids' => implode(',', $exclude_ids),
|
||||||
'bypass' => 'cancel'));
|
'bypass' => 'cancel'));
|
||||||
|
|
||||||
common_element_end('fb:request-form');
|
$this->elementEnd('fb:request-form');
|
||||||
|
|
||||||
common_element('h2', null, _('Friends already using Identi.ca:'));
|
$this->element('h2', null, _('Friends already using Identi.ca:'));
|
||||||
common_element_start("ul");
|
$this->elementStart("ul");
|
||||||
|
|
||||||
foreach ($exclude_ids as $friend) {
|
foreach ($exclude_ids as $friend) {
|
||||||
common_element_start('li');
|
$this->elementStart('li');
|
||||||
common_element('fb:profile-pic', array('uid' => $friend));
|
$this->element('fb:profile-pic', array('uid' => $friend));
|
||||||
common_element('fb:name', array('uid' => $friend,
|
$this->element('fb:name', array('uid' => $friend,
|
||||||
'capitalize' => 'true'));
|
'capitalize' => 'true'));
|
||||||
common_element_end('li');
|
$this->elementEnd('li');
|
||||||
}
|
}
|
||||||
|
|
||||||
common_element_end("ul");
|
$this->elementEnd("ul");
|
||||||
|
|
||||||
$this->show_footer();
|
$this->showFooter();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
if (!defined('LACONICA')) { exit(1); }
|
if (!defined('LACONICA')) { exit(1); }
|
||||||
|
|
||||||
require_once(INSTALLDIR.'/lib/facebookaction.php');
|
require_once INSTALLDIR.'/lib/facebookaction.php';
|
||||||
|
|
||||||
class FacebookremoveAction extends FacebookAction
|
class FacebookremoveAction extends FacebookAction
|
||||||
{
|
{
|
||||||
@ -53,7 +53,7 @@ class FacebookremoveAction extends FacebookAction
|
|||||||
|
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
common_log_db_error($flink, 'DELETE', __FILE__);
|
common_log_db_error($flink, 'DELETE', __FILE__);
|
||||||
common_server_error(_('Couldn\'t remove Facebook user.'));
|
$this->serverError(_('Couldn\'t remove Facebook user.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
if (!defined('LACONICA')) { exit(1); }
|
if (!defined('LACONICA')) { exit(1); }
|
||||||
|
|
||||||
require_once(INSTALLDIR.'/lib/facebookaction.php');
|
require_once INSTALLDIR.'/lib/facebookaction.php';
|
||||||
|
|
||||||
class FacebooksettingsAction extends FacebookAction
|
class FacebooksettingsAction extends FacebookAction
|
||||||
{
|
{
|
||||||
@ -29,13 +29,13 @@ class FacebooksettingsAction extends FacebookAction
|
|||||||
parent::handle($args);
|
parent::handle($args);
|
||||||
|
|
||||||
if ($this->arg('save')) {
|
if ($this->arg('save')) {
|
||||||
$this->save_settings();
|
$this->saveSettings();
|
||||||
} else {
|
} else {
|
||||||
$this->show_form();
|
$this->showForm();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function save_settings() {
|
function saveSettings() {
|
||||||
|
|
||||||
$noticesync = $this->arg('noticesync');
|
$noticesync = $this->arg('noticesync');
|
||||||
$replysync = $this->arg('replysync');
|
$replysync = $this->arg('replysync');
|
||||||
@ -50,65 +50,76 @@ class FacebooksettingsAction extends FacebookAction
|
|||||||
$flink->set_flags($noticesync, $replysync, false);
|
$flink->set_flags($noticesync, $replysync, false);
|
||||||
$result = $flink->update($original);
|
$result = $flink->update($original);
|
||||||
|
|
||||||
$facebook->api_client->data_setUserPreference(1, substr($prefix, 0, 128));
|
$facebook->api_client->data_setUserPreference(FACEBOOK_NOTICE_PREFIX,
|
||||||
|
substr($prefix, 0, 128));
|
||||||
|
|
||||||
if ($result) {
|
if ($result) {
|
||||||
$this->show_form('Sync preferences saved.', true);
|
$this->showForm('Sync preferences saved.', true);
|
||||||
} else {
|
} else {
|
||||||
$this->show_form('There was a problem saving your sync preferences!');
|
$this->showForm('There was a problem saving your sync preferences!');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_form($msg = null, $success = false) {
|
function showForm($msg = null, $success = false) {
|
||||||
|
|
||||||
$facebook = get_facebook();
|
$facebook = get_facebook();
|
||||||
$fbuid = $facebook->require_login();
|
$fbuid = $facebook->require_login();
|
||||||
|
|
||||||
$flink = Foreign_link::getByForeignID($fbuid, FACEBOOK_SERVICE);
|
$flink = Foreign_link::getByForeignID($fbuid, FACEBOOK_SERVICE);
|
||||||
|
|
||||||
$this->show_header('Settings', $msg, $success);
|
$this->showHeader($msg, $success);
|
||||||
|
$this->showNav('Settings');
|
||||||
common_element_start('fb:if-section-not-added', array('section' => 'profile'));
|
|
||||||
common_element('h2', null, _('Add an Identi.ca box to my profile'));
|
|
||||||
common_element_start('p');
|
|
||||||
common_element('fb:add-section-button', array('section' => 'profile'));
|
|
||||||
common_element_end('p');
|
|
||||||
|
|
||||||
common_element_end('fb:if-section-not-added');
|
|
||||||
common_element_start('p');
|
|
||||||
common_element_start('fb:prompt-permission', array('perms' => 'status_update'));
|
|
||||||
common_element('h2', null, _('Allow Identi.ca to update my Facebook status'));
|
|
||||||
common_element_end('fb:prompt-permission');
|
|
||||||
common_element_end('p');
|
|
||||||
|
|
||||||
if ($facebook->api_client->users_hasAppPermission('status_update')) {
|
if ($facebook->api_client->users_hasAppPermission('status_update')) {
|
||||||
|
|
||||||
common_element_start('form', array('method' => 'post',
|
$this->elementStart('form', array('method' => 'post',
|
||||||
'id' => 'facebook_settings'));
|
'id' => 'facebook_settings'));
|
||||||
|
|
||||||
common_element('h2', null, _('Sync preferences'));
|
$this->element('h2', null, _('Sync preferences'));
|
||||||
|
|
||||||
common_checkbox('noticesync', _('Automatically update my Facebook status with my notices.'),
|
$this->checkbox('noticesync', _('Automatically update my Facebook status with my notices.'),
|
||||||
($flink) ? ($flink->noticesync & FOREIGN_NOTICE_SEND) : true);
|
($flink) ? ($flink->noticesync & FOREIGN_NOTICE_SEND) : true);
|
||||||
|
|
||||||
common_checkbox('replysync', _('Send local "@" replies to Facebook.'),
|
$this->checkbox('replysync', _('Send "@" replies to Facebook.'),
|
||||||
($flink) ? ($flink->noticesync & FOREIGN_NOTICE_SEND_REPLY) : true);
|
($flink) ? ($flink->noticesync & FOREIGN_NOTICE_SEND_REPLY) : true);
|
||||||
|
|
||||||
// function common_input($id, $label, $value=null,$instructions=null)
|
|
||||||
|
|
||||||
$prefix = $facebook->api_client->data_getUserPreference(1);
|
$prefix = $facebook->api_client->data_getUserPreference(1);
|
||||||
|
|
||||||
|
$this->input('prefix', _('Prefix'),
|
||||||
common_input('prefix', _('Prefix'),
|
|
||||||
($prefix) ? $prefix : null,
|
($prefix) ? $prefix : null,
|
||||||
_('A string to prefix notices with.'));
|
_('A string to prefix notices with.'));
|
||||||
common_submit('save', _('Save'));
|
$this->submit('save', _('Save'));
|
||||||
|
|
||||||
common_element_end('form');
|
$this->elementEnd('form');
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
// Figure what the URL of our app is.
|
||||||
|
$app_props = $facebook->api_client->Admin_getAppProperties(
|
||||||
|
array('canvas_name', 'application_name'));
|
||||||
|
$app_url = 'http://apps.facebook.com/' . $app_props['canvas_name'] . '/settings.php';
|
||||||
|
$app_name = $app_props['application_name'];
|
||||||
|
|
||||||
|
$instructions = sprintf(_('If you would like the %s app to automatically update ' .
|
||||||
|
'your Facebook status with your latest notice, you need ' .
|
||||||
|
'to give it permission.'), $app_name);
|
||||||
|
|
||||||
|
$this->elementStart('p');
|
||||||
|
$this->element('span', array('id' => 'permissions_notice'), $instructions);
|
||||||
|
$this->elementEnd('p');
|
||||||
|
|
||||||
|
$this->elementStart('ul', array('id' => 'fb-permissions-list'));
|
||||||
|
$this->elementStart('li', array('id' => 'fb-permissions-item'));
|
||||||
|
$this->elementStart('fb:prompt-permission', array('perms' => 'status_update',
|
||||||
|
'next_fbjs' => 'document.setLocation(\'' . $app_url . '\')'));
|
||||||
|
$this->element('span', array('class' => 'facebook-button'),
|
||||||
|
_('Allow Identi.ca to update my Facebook status'));
|
||||||
|
$this->elementEnd('fb:prompt-permission');
|
||||||
|
$this->elementEnd('li');
|
||||||
|
$this->elementEnd('ul');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->show_footer();
|
$this->showFooter();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
if (!defined('LACONICA')) { exit(1); }
|
if (!defined('LACONICA')) { exit(1); }
|
||||||
|
|
||||||
require_once(INSTALLDIR.'/lib/mail.php');
|
require_once(INSTALLDIR.'/lib/mail.php');
|
||||||
|
require_once INSTALLDIR.'/lib/disfavorform.php';
|
||||||
|
|
||||||
class FavorAction extends Action
|
class FavorAction extends Action
|
||||||
{
|
{
|
||||||
@ -29,7 +30,7 @@ class FavorAction extends Action
|
|||||||
parent::handle($args);
|
parent::handle($args);
|
||||||
|
|
||||||
if (!common_logged_in()) {
|
if (!common_logged_in()) {
|
||||||
common_user_error(_('Not logged in.'));
|
$this->clientError(_('Not logged in.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -48,19 +49,19 @@ class FavorAction extends Action
|
|||||||
|
|
||||||
$token = $this->trimmed('token-'.$notice->id);
|
$token = $this->trimmed('token-'.$notice->id);
|
||||||
if (!$token || $token != common_session_token()) {
|
if (!$token || $token != common_session_token()) {
|
||||||
$this->client_error(_("There was a problem with your session token. Try again, please."));
|
$this->clientError(_("There was a problem with your session token. Try again, please."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($user->hasFave($notice)) {
|
if ($user->hasFave($notice)) {
|
||||||
$this->client_error(_('This notice is already a favorite!'));
|
$this->clientError(_('This notice is already a favorite!'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$fave = Fave::addNew($user, $notice);
|
$fave = Fave::addNew($user, $notice);
|
||||||
|
|
||||||
if (!$fave) {
|
if (!$fave) {
|
||||||
$this->server_error(_('Could not create favorite.'));
|
$this->serverError(_('Could not create favorite.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,14 +69,15 @@ class FavorAction extends Action
|
|||||||
$user->blowFavesCache();
|
$user->blowFavesCache();
|
||||||
|
|
||||||
if ($this->boolean('ajax')) {
|
if ($this->boolean('ajax')) {
|
||||||
common_start_html('text/xml;charset=utf-8', true);
|
$this->startHTML('text/xml;charset=utf-8', true);
|
||||||
common_element_start('head');
|
$this->elementStart('head');
|
||||||
common_element('title', null, _('Disfavor favorite'));
|
$this->element('title', null, _('Disfavor favorite'));
|
||||||
common_element_end('head');
|
$this->elementEnd('head');
|
||||||
common_element_start('body');
|
$this->elementStart('body');
|
||||||
common_disfavor_form($notice);
|
$disfavor = new DisFavorForm($this, $notice);
|
||||||
common_element_end('body');
|
$disfavor->show();
|
||||||
common_element_end('html');
|
$this->elementEnd('body');
|
||||||
|
$this->elementEnd('html');
|
||||||
} else {
|
} else {
|
||||||
common_redirect(common_local_url('showfavorites',
|
common_redirect(common_local_url('showfavorites',
|
||||||
array('nickname' => $user->nickname)));
|
array('nickname' => $user->nickname)));
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/**
|
||||||
* Laconica - a distributed open-source microblogging tool
|
* Laconica, the distributed open-source microblogging tool
|
||||||
* Copyright (C) 2008, Controlez-Vous, Inc.
|
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* List of popular notices
|
||||||
|
*
|
||||||
|
* 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
|
* 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
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
@ -15,91 +18,179 @@
|
|||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* 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/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* @category Public
|
||||||
|
* @package Laconica
|
||||||
|
* @author Zach Copley <zach@controlyourself.ca>
|
||||||
|
* @author Evan Prodromou <evan@controlyourself.ca>
|
||||||
|
* @copyright 2008-2009 Control Yourself, Inc.
|
||||||
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||||
|
* @link http://laconi.ca/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('LACONICA')) { exit(1); }
|
if (!defined('LACONICA')) {
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
require_once(INSTALLDIR.'/lib/stream.php');
|
require_once INSTALLDIR.'/lib/publicgroupnav.php';
|
||||||
|
require_once INSTALLDIR.'/lib/noticelist.php';
|
||||||
|
|
||||||
class FavoritedAction extends StreamAction
|
/**
|
||||||
|
* List of popular notices
|
||||||
|
*
|
||||||
|
* We provide a list of the most popular notices. Popularity
|
||||||
|
* is measured by
|
||||||
|
*
|
||||||
|
* @category Personal
|
||||||
|
* @package Laconica
|
||||||
|
* @author Zach Copley <zach@controlyourself.ca>
|
||||||
|
* @author Evan Prodromou <evan@controlyourself.ca>
|
||||||
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||||
|
* @link http://laconi.ca/
|
||||||
|
*/
|
||||||
|
|
||||||
|
class FavoritedAction extends Action
|
||||||
{
|
{
|
||||||
|
var $page = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Title of the page
|
||||||
|
*
|
||||||
|
* @return string Title of the page
|
||||||
|
*/
|
||||||
|
|
||||||
|
function title()
|
||||||
|
{
|
||||||
|
if ($this->page == 1) {
|
||||||
|
return _('Popular notices');
|
||||||
|
} else {
|
||||||
|
return sprintf(_('Popular notices, page %d'), $this->page);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instructions for use
|
||||||
|
*
|
||||||
|
* @return instructions for use
|
||||||
|
*/
|
||||||
|
|
||||||
|
function getInstructions()
|
||||||
|
{
|
||||||
|
return _('The most popular notices on the site right now.');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is this page read-only?
|
||||||
|
*
|
||||||
|
* @return boolean true
|
||||||
|
*/
|
||||||
|
|
||||||
|
function isReadOnly()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Take arguments for running
|
||||||
|
*
|
||||||
|
* @param array $args $_REQUEST args
|
||||||
|
*
|
||||||
|
* @return boolean success flag
|
||||||
|
*
|
||||||
|
* @todo move queries from showContent() to here
|
||||||
|
*/
|
||||||
|
|
||||||
|
function prepare($args)
|
||||||
|
{
|
||||||
|
parent::prepare($args);
|
||||||
|
$this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle request
|
||||||
|
*
|
||||||
|
* Shows a page with list of favorite notices
|
||||||
|
*
|
||||||
|
* @param array $args $_REQUEST args; handled in prepare()
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
function handle($args)
|
function handle($args)
|
||||||
{
|
{
|
||||||
parent::handle($args);
|
parent::handle($args);
|
||||||
|
|
||||||
$page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
|
$this->showPage();
|
||||||
|
|
||||||
common_show_header(_('Popular notices'),
|
|
||||||
array($this, 'show_header'), null,
|
|
||||||
array($this, 'show_top'));
|
|
||||||
|
|
||||||
$this->show_notices($page);
|
|
||||||
|
|
||||||
common_show_footer();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_top()
|
/**
|
||||||
|
* Show the page notice
|
||||||
|
*
|
||||||
|
* Shows instructions for the page
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
|
function showPageNotice()
|
||||||
{
|
{
|
||||||
$instr = $this->get_instructions();
|
$instr = $this->getInstructions();
|
||||||
$output = common_markup_to_html($instr);
|
$output = common_markup_to_html($instr);
|
||||||
common_element_start('div', 'instructions');
|
|
||||||
common_raw($output);
|
$this->elementStart('div', 'instructions');
|
||||||
common_element_end('div');
|
$this->raw($output);
|
||||||
$this->public_views_menu();
|
$this->elementEnd('div');
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_header()
|
/**
|
||||||
|
* Local navigation
|
||||||
|
*
|
||||||
|
* This page is part of the public group, so show that.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
|
function showLocalNav()
|
||||||
{
|
{
|
||||||
return;
|
$nav = new PublicGroupNav($this);
|
||||||
|
$nav->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_instructions()
|
/**
|
||||||
{
|
* Content area
|
||||||
return _('Showing recently popular notices');
|
*
|
||||||
}
|
* Shows the list of popular notices
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
function show_notices($page)
|
function showContent()
|
||||||
{
|
{
|
||||||
|
$qry = 'SELECT notice.*, '.
|
||||||
$qry = 'SELECT notice.*, sum(exp(-(now() - fave.modified) / %s)) as weight ' .
|
'sum(exp(-(now() - fave.modified) / %s)) as weight ' .
|
||||||
'FROM notice JOIN fave ON notice.id = fave.notice_id ' .
|
'FROM notice JOIN fave ON notice.id = fave.notice_id ' .
|
||||||
'GROUP BY fave.notice_id ' .
|
'GROUP BY fave.notice_id ' .
|
||||||
'ORDER BY weight DESC';
|
'ORDER BY weight DESC';
|
||||||
|
|
||||||
$offset = ($page - 1) * NOTICES_PER_PAGE;
|
$offset = ($this->page - 1) * NOTICES_PER_PAGE;
|
||||||
$limit = NOTICES_PER_PAGE + 1;
|
$limit = NOTICES_PER_PAGE + 1;
|
||||||
|
|
||||||
if (common_config('db','type') == 'pgsql') {
|
if (common_config('db', 'type') == 'pgsql') {
|
||||||
$qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset;
|
$qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset;
|
||||||
} else {
|
} else {
|
||||||
$qry .= ' LIMIT ' . $offset . ', ' . $limit;
|
$qry .= ' LIMIT ' . $offset . ', ' . $limit;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Figure out how to cache this query
|
// XXX: Figure out how to cache this query
|
||||||
|
|
||||||
$notice = new Notice;
|
$notice = new Notice;
|
||||||
$notice->query(sprintf($qry, common_config('popular', 'dropoff')));
|
$notice->query(sprintf($qry, common_config('popular', 'dropoff')));
|
||||||
|
|
||||||
common_element_start('ul', array('id' => 'notices'));
|
$nl = new NoticeList($notice, $this);
|
||||||
|
|
||||||
$cnt = 0;
|
$cnt = $nl->show();
|
||||||
|
|
||||||
while ($notice->fetch() && $cnt <= NOTICES_PER_PAGE) {
|
$this->pagination($this->page > 1, $cnt > NOTICES_PER_PAGE,
|
||||||
$cnt++;
|
$this->page, 'favorited');
|
||||||
|
|
||||||
if ($cnt > NOTICES_PER_PAGE) {
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$item = new NoticeListItem($notice);
|
|
||||||
$item->show();
|
|
||||||
}
|
|
||||||
|
|
||||||
common_element_end('ul');
|
|
||||||
|
|
||||||
common_pagination($page > 1, $cnt > NOTICES_PER_PAGE,
|
|
||||||
$page, 'favorited');
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ class FavoritesrssAction extends Rss10Action
|
|||||||
$this->user = User::staticGet('nickname', $nickname);
|
$this->user = User::staticGet('nickname', $nickname);
|
||||||
|
|
||||||
if (!$this->user) {
|
if (!$this->user) {
|
||||||
common_user_error(_('No such user.'));
|
$this->clientError(_('No such user.'));
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
return true;
|
return true;
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/**
|
||||||
* Laconica - a distributed open-source microblogging tool
|
* Laconica, the distributed open-source microblogging tool
|
||||||
* Copyright (C) 2008, Controlez-Vous, Inc.
|
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* List of featured users
|
||||||
|
*
|
||||||
|
* 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
|
* 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
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
@ -15,53 +18,90 @@
|
|||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* 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/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* @category Public
|
||||||
|
* @package Laconica
|
||||||
|
* @author Zach Copley <zach@controlyourself.ca>
|
||||||
|
* @author Evan Prodromou <evan@controlyourself.ca>
|
||||||
|
* @copyright 2008-2009 Control Yourself, Inc.
|
||||||
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||||
|
* @link http://laconi.ca/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('LACONICA')) { exit(1); }
|
if (!defined('LACONICA')) {
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
require_once(INSTALLDIR.'/lib/stream.php');
|
|
||||||
require_once(INSTALLDIR.'/lib/profilelist.php');
|
require_once(INSTALLDIR.'/lib/profilelist.php');
|
||||||
|
require_once INSTALLDIR.'/lib/publicgroupnav.php';
|
||||||
|
|
||||||
class FeaturedAction extends StreamAction
|
/**
|
||||||
|
* List of featured users
|
||||||
|
*
|
||||||
|
* @category Public
|
||||||
|
* @package Laconica
|
||||||
|
* @author Zach Copley <zach@controlyourself.ca>
|
||||||
|
* @author Evan Prodromou <evan@controlyourself.ca>
|
||||||
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||||
|
* @link http://laconi.ca/
|
||||||
|
*/
|
||||||
|
|
||||||
|
class FeaturedAction extends Action
|
||||||
{
|
{
|
||||||
|
var $page = null;
|
||||||
|
|
||||||
|
function isReadOnly()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function prepare($args)
|
||||||
|
{
|
||||||
|
parent::prepare($args);
|
||||||
|
$this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function title()
|
||||||
|
{
|
||||||
|
if ($this->page == 1) {
|
||||||
|
return _('Featured users');
|
||||||
|
} else {
|
||||||
|
return sprintf(_('Featured users, page %d'), $this->page);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function handle($args)
|
function handle($args)
|
||||||
{
|
{
|
||||||
parent::handle($args);
|
parent::handle($args);
|
||||||
|
|
||||||
$page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
|
$this->showPage();
|
||||||
|
|
||||||
common_show_header(_('Featured users'),
|
|
||||||
array($this, 'show_header'), null,
|
|
||||||
array($this, 'show_top'));
|
|
||||||
|
|
||||||
$this->show_notices($page);
|
|
||||||
|
|
||||||
common_show_footer();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_top()
|
function showPageNotice()
|
||||||
{
|
{
|
||||||
$instr = $this->get_instructions();
|
$instr = $this->getInstructions();
|
||||||
$output = common_markup_to_html($instr);
|
$output = common_markup_to_html($instr);
|
||||||
common_element_start('div', 'instructions');
|
$this->elementStart('div', 'instructions');
|
||||||
common_raw($output);
|
$this->raw($output);
|
||||||
common_element_end('div');
|
$this->elementEnd('div');
|
||||||
$this->public_views_menu();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_header()
|
function showLocalNav()
|
||||||
{
|
{
|
||||||
|
$nav = new PublicGroupNav($this);
|
||||||
|
$nav->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_instructions()
|
function getInstructions()
|
||||||
{
|
{
|
||||||
return _('Featured users');
|
return sprintf(_('A selection of some of the great users on %s'),
|
||||||
|
common_config('site', 'name'));
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_notices($page)
|
function showContent()
|
||||||
{
|
{
|
||||||
|
|
||||||
// XXX: Note I'm doing it this two-stage way because a raw query
|
// XXX: Note I'm doing it this two-stage way because a raw query
|
||||||
// with a JOIN was *not* working. --Zach
|
// with a JOIN was *not* working. --Zach
|
||||||
|
|
||||||
@ -77,7 +117,7 @@ class FeaturedAction extends StreamAction
|
|||||||
|
|
||||||
$user = new User;
|
$user = new User;
|
||||||
$user->whereAdd(sprintf('nickname IN (%s)', implode(',', $quoted)));
|
$user->whereAdd(sprintf('nickname IN (%s)', implode(',', $quoted)));
|
||||||
$user->limit(($page - 1) * PROFILES_PER_PAGE, PROFILES_PER_PAGE + 1);
|
$user->limit(($this->page - 1) * PROFILES_PER_PAGE, PROFILES_PER_PAGE + 1);
|
||||||
$user->orderBy('user.nickname ASC');
|
$user->orderBy('user.nickname ASC');
|
||||||
|
|
||||||
$user->find();
|
$user->find();
|
||||||
@ -95,14 +135,14 @@ class FeaturedAction extends StreamAction
|
|||||||
$cnt = $profile->find();
|
$cnt = $profile->find();
|
||||||
|
|
||||||
if ($cnt > 0) {
|
if ($cnt > 0) {
|
||||||
$featured = new ProfileList($profile);
|
$featured = new ProfileList($profile, null, $this);
|
||||||
$featured->show_list();
|
$featured->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
$profile->free();
|
$profile->free();
|
||||||
|
|
||||||
common_pagination($page > 1, $cnt > PROFILES_PER_PAGE, $page, 'featured');
|
$this->pagination($this->page > 1, $cnt > PROFILES_PER_PAGE,
|
||||||
|
$this->page, 'featured');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,9 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/**
|
||||||
* Laconica - a distributed open-source microblogging tool
|
* Laconica, the distributed open-source microblogging tool
|
||||||
* Copyright (C) 2008, Controlez-Vous, Inc.
|
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* Complete adding an OpenID
|
||||||
|
*
|
||||||
|
* 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
|
* 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
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
@ -15,28 +18,68 @@
|
|||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* 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/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* @category Settings
|
||||||
|
* @package Laconica
|
||||||
|
* @author Evan Prodromou <evan@controlyourself.ca>
|
||||||
|
* @copyright 2008-2009 Control Yourself, Inc.
|
||||||
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||||
|
* @link http://laconi.ca/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('LACONICA')) { exit(1); }
|
if (!defined('LACONICA')) {
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
require_once(INSTALLDIR.'/lib/openid.php');
|
require_once INSTALLDIR.'/lib/openid.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Complete adding an OpenID
|
||||||
|
*
|
||||||
|
* Handle the return from an OpenID verification
|
||||||
|
*
|
||||||
|
* @category Settings
|
||||||
|
* @package Laconica
|
||||||
|
* @author Evan Prodromou <evan@controlyourself.ca>
|
||||||
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||||
|
* @link http://laconi.ca/
|
||||||
|
*/
|
||||||
|
|
||||||
class FinishaddopenidAction extends Action
|
class FinishaddopenidAction extends Action
|
||||||
{
|
{
|
||||||
|
var $msg = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle the redirect back from OpenID confirmation
|
||||||
|
*
|
||||||
|
* Check to see if the user's logged in, and then try
|
||||||
|
* to use the OpenID login system.
|
||||||
|
*
|
||||||
|
* @param array $args $_REQUEST arguments
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
function handle($args)
|
function handle($args)
|
||||||
{
|
{
|
||||||
parent::handle($args);
|
parent::handle($args);
|
||||||
if (!common_logged_in()) {
|
if (!common_logged_in()) {
|
||||||
common_user_error(_('Not logged in.'));
|
$this->clientError(_('Not logged in.'));
|
||||||
} else {
|
} else {
|
||||||
$this->try_login();
|
$this->tryLogin();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function try_login()
|
/**
|
||||||
|
* Try to log in using OpenID
|
||||||
|
*
|
||||||
|
* Check the OpenID for validity; potentially store it.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
|
function tryLogin()
|
||||||
{
|
{
|
||||||
|
|
||||||
$consumer =& oid_consumer();
|
$consumer =& oid_consumer();
|
||||||
|
|
||||||
$response = $consumer->complete(common_local_url('finishaddopenid'));
|
$response = $consumer->complete(common_local_url('finishaddopenid'));
|
||||||
@ -46,7 +89,8 @@ class FinishaddopenidAction extends Action
|
|||||||
return;
|
return;
|
||||||
} else if ($response->status == Auth_OpenID_FAILURE) {
|
} else if ($response->status == Auth_OpenID_FAILURE) {
|
||||||
// Authentication failed; display the error message.
|
// Authentication failed; display the error message.
|
||||||
$this->message(sprintf(_('OpenID authentication failed: %s'), $response->message));
|
$this->message(sprintf(_('OpenID authentication failed: %s'),
|
||||||
|
$response->message));
|
||||||
} else if ($response->status == Auth_OpenID_SUCCESS) {
|
} else if ($response->status == Auth_OpenID_SUCCESS) {
|
||||||
|
|
||||||
$display = $response->getDisplayIdentifier();
|
$display = $response->getDisplayIdentifier();
|
||||||
@ -60,6 +104,7 @@ class FinishaddopenidAction extends Action
|
|||||||
}
|
}
|
||||||
|
|
||||||
$cur =& common_current_user();
|
$cur =& common_current_user();
|
||||||
|
|
||||||
$other = oid_get_user($canonical);
|
$other = oid_get_user($canonical);
|
||||||
|
|
||||||
if ($other) {
|
if ($other) {
|
||||||
@ -71,7 +116,7 @@ class FinishaddopenidAction extends Action
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
# start a transaction
|
// start a transaction
|
||||||
|
|
||||||
$cur->query('BEGIN');
|
$cur->query('BEGIN');
|
||||||
|
|
||||||
@ -88,7 +133,7 @@ class FinishaddopenidAction extends Action
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# success!
|
// success!
|
||||||
|
|
||||||
$cur->query('COMMIT');
|
$cur->query('COMMIT');
|
||||||
|
|
||||||
@ -98,10 +143,43 @@ class FinishaddopenidAction extends Action
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show a failure message
|
||||||
|
*
|
||||||
|
* Something went wrong. Save the message, and show the page.
|
||||||
|
*
|
||||||
|
* @param string $msg Error message to show
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
function message($msg)
|
function message($msg)
|
||||||
{
|
{
|
||||||
common_show_header(_('OpenID Login'));
|
$this->message = $msg;
|
||||||
common_element('p', null, $msg);
|
$this->showPage();
|
||||||
common_show_footer();
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Title of the page
|
||||||
|
*
|
||||||
|
* @return string title
|
||||||
|
*/
|
||||||
|
|
||||||
|
function title()
|
||||||
|
{
|
||||||
|
return _('OpenID Login');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show error message
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
|
function showPageNotice()
|
||||||
|
{
|
||||||
|
if ($this->message) {
|
||||||
|
$this->element('p', 'error', $this->message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,68 +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); }
|
|
||||||
|
|
||||||
require_once(INSTALLDIR.'/lib/openid.php');
|
|
||||||
|
|
||||||
class FinishimmediateAction extends Action
|
|
||||||
{
|
|
||||||
|
|
||||||
function handle($args)
|
|
||||||
{
|
|
||||||
parent::handle($args);
|
|
||||||
|
|
||||||
$consumer = oid_consumer();
|
|
||||||
|
|
||||||
$response = $consumer->complete(common_local_url('finishimmediate'));
|
|
||||||
|
|
||||||
if ($response->status == Auth_OpenID_SUCCESS) {
|
|
||||||
$display = $response->getDisplayIdentifier();
|
|
||||||
$canonical = ($response->endpoint->canonicalID) ?
|
|
||||||
$response->endpoint->canonicalID : $response->getDisplayIdentifier();
|
|
||||||
|
|
||||||
$user = oid_get_user($canonical);
|
|
||||||
|
|
||||||
if ($user) {
|
|
||||||
oid_update_user($user, $sreg);
|
|
||||||
oid_set_last($display); # refresh for another year
|
|
||||||
common_set_user($user->nickname);
|
|
||||||
$this->go_backto();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Failure! Clear openid so we don't try it again
|
|
||||||
|
|
||||||
oid_clear_last();
|
|
||||||
$this->go_backto();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
function go_backto()
|
|
||||||
{
|
|
||||||
common_ensure_session();
|
|
||||||
$backto = $_SESSION['openid_immediate_backto'];
|
|
||||||
if (!$backto) {
|
|
||||||
# gar. Well, push them to the public page
|
|
||||||
$backto = common_local_url('public');
|
|
||||||
}
|
|
||||||
common_redirect($backto);
|
|
||||||
}
|
|
||||||
}
|
|
@ -28,7 +28,7 @@ class FinishopenidloginAction extends Action
|
|||||||
{
|
{
|
||||||
parent::handle($args);
|
parent::handle($args);
|
||||||
if (common_logged_in()) {
|
if (common_logged_in()) {
|
||||||
common_user_error(_('Already logged in.'));
|
$this->clientError(_('Already logged in.'));
|
||||||
} else if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
} else if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||||
$token = $this->trimmed('token');
|
$token = $this->trimmed('token');
|
||||||
if (!$token || $token != common_session_token()) {
|
if (!$token || $token != common_session_token()) {
|
||||||
@ -57,10 +57,10 @@ class FinishopenidloginAction extends Action
|
|||||||
function show_top($error=null)
|
function show_top($error=null)
|
||||||
{
|
{
|
||||||
if ($error) {
|
if ($error) {
|
||||||
common_element('div', array('class' => 'error'), $error);
|
$this->element('div', array('class' => 'error'), $error);
|
||||||
} else {
|
} else {
|
||||||
global $config;
|
global $config;
|
||||||
common_element('div', 'instructions',
|
$this->element('div', 'instructions',
|
||||||
sprintf(_('This is the first time you\'ve logged into %s so we must connect your OpenID to a local account. You can either create a new account, or connect with your existing account, if you have one.'), $config['site']['name']));
|
sprintf(_('This is the first time you\'ve logged into %s so we must connect your OpenID to a local account. You can either create a new account, or connect with your existing account, if you have one.'), $config['site']['name']));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -70,36 +70,36 @@ class FinishopenidloginAction extends Action
|
|||||||
common_show_header(_('OpenID Account Setup'), null, $error,
|
common_show_header(_('OpenID Account Setup'), null, $error,
|
||||||
array($this, 'show_top'));
|
array($this, 'show_top'));
|
||||||
|
|
||||||
common_element_start('form', array('method' => 'post',
|
$this->elementStart('form', array('method' => 'post',
|
||||||
'id' => 'account_connect',
|
'id' => 'account_connect',
|
||||||
'action' => common_local_url('finishopenidlogin')));
|
'action' => common_local_url('finishopenidlogin')));
|
||||||
common_hidden('token', common_session_token());
|
$this->hidden('token', common_session_token());
|
||||||
common_element('h2', null,
|
$this->element('h2', null,
|
||||||
_('Create new account'));
|
_('Create new account'));
|
||||||
common_element('p', null,
|
$this->element('p', null,
|
||||||
_('Create a new user with this nickname.'));
|
_('Create a new user with this nickname.'));
|
||||||
common_input('newname', _('New nickname'),
|
$this->input('newname', _('New nickname'),
|
||||||
($username) ? $username : '',
|
($username) ? $username : '',
|
||||||
_('1-64 lowercase letters or numbers, no punctuation or spaces'));
|
_('1-64 lowercase letters or numbers, no punctuation or spaces'));
|
||||||
common_element_start('p');
|
$this->elementStart('p');
|
||||||
common_element('input', array('type' => 'checkbox',
|
$this->element('input', array('type' => 'checkbox',
|
||||||
'id' => 'license',
|
'id' => 'license',
|
||||||
'name' => 'license',
|
'name' => 'license',
|
||||||
'value' => 'true'));
|
'value' => 'true'));
|
||||||
common_text(_('My text and files are available under '));
|
$this->text(_('My text and files are available under '));
|
||||||
common_element('a', array(href => common_config('license', 'url')),
|
$this->element('a', array(href => common_config('license', 'url')),
|
||||||
common_config('license', 'title'));
|
common_config('license', 'title'));
|
||||||
common_text(_(' except this private data: password, email address, IM address, phone number.'));
|
$this->text(_(' except this private data: password, email address, IM address, phone number.'));
|
||||||
common_element_end('p');
|
$this->elementEnd('p');
|
||||||
common_submit('create', _('Create'));
|
$this->submit('create', _('Create'));
|
||||||
common_element('h2', null,
|
$this->element('h2', null,
|
||||||
_('Connect existing account'));
|
_('Connect existing account'));
|
||||||
common_element('p', null,
|
$this->element('p', null,
|
||||||
_('If you already have an account, login with your username and password to connect it to your OpenID.'));
|
_('If you already have an account, login with your username and password to connect it to your OpenID.'));
|
||||||
common_input('nickname', _('Existing nickname'));
|
$this->input('nickname', _('Existing nickname'));
|
||||||
common_password('password', _('Password'));
|
$this->password('password', _('Password'));
|
||||||
common_submit('connect', _('Connect'));
|
$this->submit('connect', _('Connect'));
|
||||||
common_element_end('form');
|
$this->elementEnd('form');
|
||||||
common_show_footer();
|
common_show_footer();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -154,7 +154,7 @@ class FinishopenidloginAction extends Action
|
|||||||
function message($msg)
|
function message($msg)
|
||||||
{
|
{
|
||||||
common_show_header(_('OpenID Login'));
|
common_show_header(_('OpenID Login'));
|
||||||
common_element('p', null, $msg);
|
$this->element('p', null, $msg);
|
||||||
common_show_footer();
|
common_show_footer();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -179,7 +179,7 @@ class FinishopenidloginAction extends Action
|
|||||||
# FIXME: save invite code before redirect, and check here
|
# FIXME: save invite code before redirect, and check here
|
||||||
|
|
||||||
if (common_config('site', 'closed') || common_config('site', 'inviteonly')) {
|
if (common_config('site', 'closed') || common_config('site', 'inviteonly')) {
|
||||||
common_user_error(_('Registration not allowed.'));
|
$this->clientError(_('Registration not allowed.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -205,7 +205,7 @@ class FinishopenidloginAction extends Action
|
|||||||
list($display, $canonical, $sreg) = $this->get_saved_values();
|
list($display, $canonical, $sreg) = $this->get_saved_values();
|
||||||
|
|
||||||
if (!$display || !$canonical) {
|
if (!$display || !$canonical) {
|
||||||
common_server_error(_('Stored OpenID not found.'));
|
$this->serverError(_('Stored OpenID not found.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -214,7 +214,7 @@ class FinishopenidloginAction extends Action
|
|||||||
$other = oid_get_user($canonical);
|
$other = oid_get_user($canonical);
|
||||||
|
|
||||||
if ($other) {
|
if ($other) {
|
||||||
common_server_error(_('Creating new account for OpenID that already has a user.'));
|
$this->serverError(_('Creating new account for OpenID that already has a user.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -274,14 +274,14 @@ class FinishopenidloginAction extends Action
|
|||||||
list($display, $canonical, $sreg) = $this->get_saved_values();
|
list($display, $canonical, $sreg) = $this->get_saved_values();
|
||||||
|
|
||||||
if (!$display || !$canonical) {
|
if (!$display || !$canonical) {
|
||||||
common_server_error(_('Stored OpenID not found.'));
|
$this->serverError(_('Stored OpenID not found.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = oid_link_user($user->id, $canonical, $display);
|
$result = oid_link_user($user->id, $canonical, $display);
|
||||||
|
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
common_server_error(_('Error connecting user to OpenID.'));
|
$this->serverError(_('Error connecting user to OpenID.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,14 +30,14 @@ class FinishremotesubscribeAction extends Action
|
|||||||
parent::handle($args);
|
parent::handle($args);
|
||||||
|
|
||||||
if (common_logged_in()) {
|
if (common_logged_in()) {
|
||||||
common_user_error(_('You can use the local subscription!'));
|
$this->clientError(_('You can use the local subscription!'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$omb = $_SESSION['oauth_authorization_request'];
|
$omb = $_SESSION['oauth_authorization_request'];
|
||||||
|
|
||||||
if (!$omb) {
|
if (!$omb) {
|
||||||
common_user_error(_('Not expecting this response!'));
|
$this->clientError(_('Not expecting this response!'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,38 +51,38 @@ class FinishremotesubscribeAction extends Action
|
|||||||
# I think this is the success metric
|
# I think this is the success metric
|
||||||
|
|
||||||
if ($token != $omb['token']) {
|
if ($token != $omb['token']) {
|
||||||
common_user_error(_('Not authorized.'));
|
$this->clientError(_('Not authorized.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$version = $req->get_parameter('omb_version');
|
$version = $req->get_parameter('omb_version');
|
||||||
|
|
||||||
if ($version != OMB_VERSION_01) {
|
if ($version != OMB_VERSION_01) {
|
||||||
common_user_error(_('Unknown version of OMB protocol.'));
|
$this->clientError(_('Unknown version of OMB protocol.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$nickname = $req->get_parameter('omb_listener_nickname');
|
$nickname = $req->get_parameter('omb_listener_nickname');
|
||||||
|
|
||||||
if (!$nickname) {
|
if (!$nickname) {
|
||||||
common_user_error(_('No nickname provided by remote server.'));
|
$this->clientError(_('No nickname provided by remote server.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$profile_url = $req->get_parameter('omb_listener_profile');
|
$profile_url = $req->get_parameter('omb_listener_profile');
|
||||||
|
|
||||||
if (!$profile_url) {
|
if (!$profile_url) {
|
||||||
common_user_error(_('No profile URL returned by server.'));
|
$this->clientError(_('No profile URL returned by server.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Validate::uri($profile_url, array('allowed_schemes' => array('http', 'https')))) {
|
if (!Validate::uri($profile_url, array('allowed_schemes' => array('http', 'https')))) {
|
||||||
common_user_error(_('Invalid profile URL returned by server.'));
|
$this->clientError(_('Invalid profile URL returned by server.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($profile_url == common_local_url('showstream', array('nickname' => $nickname))) {
|
if ($profile_url == common_local_url('showstream', array('nickname' => $nickname))) {
|
||||||
common_user_error(_('You can use the local subscription!'));
|
$this->clientError(_('You can use the local subscription!'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,14 +91,14 @@ class FinishremotesubscribeAction extends Action
|
|||||||
$user = User::staticGet('nickname', $omb['listenee']);
|
$user = User::staticGet('nickname', $omb['listenee']);
|
||||||
|
|
||||||
if (!$user) {
|
if (!$user) {
|
||||||
common_user_error(_('User being listened to doesn\'t exist.'));
|
$this->clientError(_('User being listened to doesn\'t exist.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$other = User::staticGet('uri', $omb['listener']);
|
$other = User::staticGet('uri', $omb['listener']);
|
||||||
|
|
||||||
if ($other) {
|
if ($other) {
|
||||||
common_user_error(_('You can use the local subscription!'));
|
$this->clientError(_('You can use the local subscription!'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,7 +111,7 @@ class FinishremotesubscribeAction extends Action
|
|||||||
list($newtok, $newsecret) = $this->access_token($omb);
|
list($newtok, $newsecret) = $this->access_token($omb);
|
||||||
|
|
||||||
if (!$newtok || !$newsecret) {
|
if (!$newtok || !$newsecret) {
|
||||||
common_user_error(_('Couldn\'t convert request tokens to access tokens.'));
|
$this->clientError(_('Couldn\'t convert request tokens to access tokens.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -155,7 +155,7 @@ class FinishremotesubscribeAction extends Action
|
|||||||
$profile->created = DB_DataObject_Cast::dateTime(); # current time
|
$profile->created = DB_DataObject_Cast::dateTime(); # current time
|
||||||
$id = $profile->insert();
|
$id = $profile->insert();
|
||||||
if (!$id) {
|
if (!$id) {
|
||||||
common_server_error(_('Error inserting new profile'));
|
$this->serverError(_('Error inserting new profile'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$remote->id = $id;
|
$remote->id = $id;
|
||||||
@ -163,7 +163,7 @@ class FinishremotesubscribeAction extends Action
|
|||||||
|
|
||||||
if ($avatar_url) {
|
if ($avatar_url) {
|
||||||
if (!$this->add_avatar($profile, $avatar_url)) {
|
if (!$this->add_avatar($profile, $avatar_url)) {
|
||||||
common_server_error(_('Error inserting avatar'));
|
$this->serverError(_('Error inserting avatar'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -173,19 +173,19 @@ class FinishremotesubscribeAction extends Action
|
|||||||
|
|
||||||
if ($exists) {
|
if ($exists) {
|
||||||
if (!$remote->update($orig_remote)) {
|
if (!$remote->update($orig_remote)) {
|
||||||
common_server_error(_('Error updating remote profile'));
|
$this->serverError(_('Error updating remote profile'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$remote->created = DB_DataObject_Cast::dateTime(); # current time
|
$remote->created = DB_DataObject_Cast::dateTime(); # current time
|
||||||
if (!$remote->insert()) {
|
if (!$remote->insert()) {
|
||||||
common_server_error(_('Error inserting remote profile'));
|
$this->serverError(_('Error inserting remote profile'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($user->hasBlocked($profile)) {
|
if ($user->hasBlocked($profile)) {
|
||||||
$this->client_error(_('That user has blocked you from subscribing.'));
|
$this->clientError(_('That user has blocked you from subscribing.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -215,7 +215,7 @@ class FinishremotesubscribeAction extends Action
|
|||||||
|
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
common_log_db_error($sub, ($sub_exists) ? 'UPDATE' : 'INSERT', __FILE__);
|
common_log_db_error($sub, ($sub_exists) ? 'UPDATE' : 'INSERT', __FILE__);
|
||||||
common_user_error(_('Couldn\'t insert new subscription.'));
|
$this->clientError(_('Couldn\'t insert new subscription.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ define('BOTH', 0);
|
|||||||
class FoafAction extends Action
|
class FoafAction extends Action
|
||||||
{
|
{
|
||||||
|
|
||||||
function is_readonly()
|
function isReadOnly()
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -40,21 +40,21 @@ class FoafAction extends Action
|
|||||||
$user = User::staticGet('nickname', $nickname);
|
$user = User::staticGet('nickname', $nickname);
|
||||||
|
|
||||||
if (!$user) {
|
if (!$user) {
|
||||||
common_user_error(_('No such user.'), 404);
|
$this->clientError(_('No such user.'), 404);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$profile = $user->getProfile();
|
$profile = $user->getProfile();
|
||||||
|
|
||||||
if (!$profile) {
|
if (!$profile) {
|
||||||
common_server_error(_('User has no profile.'), 500);
|
$this->serverError(_('User has no profile.'), 500);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
header('Content-Type: application/rdf+xml');
|
header('Content-Type: application/rdf+xml');
|
||||||
|
|
||||||
common_start_xml();
|
common_start_xml();
|
||||||
common_element_start('rdf:RDF', array('xmlns:rdf' =>
|
$this->elementStart('rdf:RDF', array('xmlns:rdf' =>
|
||||||
'http://www.w3.org/1999/02/22-rdf-syntax-ns#',
|
'http://www.w3.org/1999/02/22-rdf-syntax-ns#',
|
||||||
'xmlns:rdfs' =>
|
'xmlns:rdfs' =>
|
||||||
'http://www.w3.org/2000/01/rdf-schema#',
|
'http://www.w3.org/2000/01/rdf-schema#',
|
||||||
@ -67,25 +67,25 @@ class FoafAction extends Action
|
|||||||
$this->show_ppd('', $user->uri);
|
$this->show_ppd('', $user->uri);
|
||||||
|
|
||||||
# XXX: might not be a person
|
# XXX: might not be a person
|
||||||
common_element_start('Person', array('rdf:about' =>
|
$this->elementStart('Person', array('rdf:about' =>
|
||||||
$user->uri));
|
$user->uri));
|
||||||
common_element('mbox_sha1sum', null, sha1('mailto:' . $user->email));
|
$this->element('mbox_sha1sum', null, sha1('mailto:' . $user->email));
|
||||||
if ($profile->fullname) {
|
if ($profile->fullname) {
|
||||||
common_element('name', null, $profile->fullname);
|
$this->element('name', null, $profile->fullname);
|
||||||
}
|
}
|
||||||
if ($profile->homepage) {
|
if ($profile->homepage) {
|
||||||
common_element('homepage', array('rdf:resource' => $profile->homepage));
|
$this->element('homepage', array('rdf:resource' => $profile->homepage));
|
||||||
}
|
}
|
||||||
if ($profile->bio) {
|
if ($profile->bio) {
|
||||||
common_element('rdfs:comment', null, $profile->bio);
|
$this->element('rdfs:comment', null, $profile->bio);
|
||||||
}
|
}
|
||||||
# XXX: more structured location data
|
# XXX: more structured location data
|
||||||
if ($profile->location) {
|
if ($profile->location) {
|
||||||
common_element_start('based_near');
|
$this->elementStart('based_near');
|
||||||
common_element_start('geo:SpatialThing');
|
$this->elementStart('geo:SpatialThing');
|
||||||
common_element('name', null, $profile->location);
|
$this->element('name', null, $profile->location);
|
||||||
common_element_end('geo:SpatialThing');
|
$this->elementEnd('geo:SpatialThing');
|
||||||
common_element_end('based_near');
|
$this->elementEnd('based_near');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->show_microblogging_account($profile, common_root_url());
|
$this->show_microblogging_account($profile, common_root_url());
|
||||||
@ -93,18 +93,18 @@ class FoafAction extends Action
|
|||||||
$avatar = $profile->getOriginalAvatar();
|
$avatar = $profile->getOriginalAvatar();
|
||||||
|
|
||||||
if ($avatar) {
|
if ($avatar) {
|
||||||
common_element_start('img');
|
$this->elementStart('img');
|
||||||
common_element_start('Image', array('rdf:about' => $avatar->url));
|
$this->elementStart('Image', array('rdf:about' => $avatar->url));
|
||||||
foreach (array(AVATAR_PROFILE_SIZE, AVATAR_STREAM_SIZE, AVATAR_MINI_SIZE) as $size) {
|
foreach (array(AVATAR_PROFILE_SIZE, AVATAR_STREAM_SIZE, AVATAR_MINI_SIZE) as $size) {
|
||||||
$scaled = $profile->getAvatar($size);
|
$scaled = $profile->getAvatar($size);
|
||||||
if (!$scaled->original) { # sometimes the original has one of our scaled sizes
|
if (!$scaled->original) { # sometimes the original has one of our scaled sizes
|
||||||
common_element_start('thumbnail');
|
$this->elementStart('thumbnail');
|
||||||
common_element('Image', array('rdf:about' => $scaled->url));
|
$this->element('Image', array('rdf:about' => $scaled->url));
|
||||||
common_element_end('thumbnail');
|
$this->elementEnd('thumbnail');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
common_element_end('Image');
|
$this->elementEnd('Image');
|
||||||
common_element_end('img');
|
$this->elementEnd('img');
|
||||||
}
|
}
|
||||||
|
|
||||||
# Get people user is subscribed to
|
# Get people user is subscribed to
|
||||||
@ -126,7 +126,7 @@ class FoafAction extends Action
|
|||||||
common_debug('Got a bad subscription: '.print_r($sub,true));
|
common_debug('Got a bad subscription: '.print_r($sub,true));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
common_element('knows', array('rdf:resource' => $other->uri));
|
$this->element('knows', array('rdf:resource' => $other->uri));
|
||||||
$person[$other->uri] = array(LISTENEE, $other);
|
$person[$other->uri] = array(LISTENEE, $other);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -156,7 +156,7 @@ class FoafAction extends Action
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
common_element_end('Person');
|
$this->elementEnd('Person');
|
||||||
|
|
||||||
foreach ($person as $uri => $p) {
|
foreach ($person as $uri => $p) {
|
||||||
$foaf_url = null;
|
$foaf_url = null;
|
||||||
@ -164,44 +164,44 @@ class FoafAction extends Action
|
|||||||
$foaf_url = common_local_url('foaf', array('nickname' => $p[1]->nickname));
|
$foaf_url = common_local_url('foaf', array('nickname' => $p[1]->nickname));
|
||||||
}
|
}
|
||||||
$profile = Profile::staticGet($p[1]->id);
|
$profile = Profile::staticGet($p[1]->id);
|
||||||
common_element_start('Person', array('rdf:about' => $uri));
|
$this->elementStart('Person', array('rdf:about' => $uri));
|
||||||
if ($p[0] == LISTENER || $p[0] == BOTH) {
|
if ($p[0] == LISTENER || $p[0] == BOTH) {
|
||||||
common_element('knows', array('rdf:resource' => $user->uri));
|
$this->element('knows', array('rdf:resource' => $user->uri));
|
||||||
}
|
}
|
||||||
$this->show_microblogging_account($profile, ($p[1] instanceof User) ?
|
$this->show_microblogging_account($profile, ($p[1] instanceof User) ?
|
||||||
common_root_url() : null);
|
common_root_url() : null);
|
||||||
if ($foaf_url) {
|
if ($foaf_url) {
|
||||||
common_element('rdfs:seeAlso', array('rdf:resource' => $foaf_url));
|
$this->element('rdfs:seeAlso', array('rdf:resource' => $foaf_url));
|
||||||
}
|
}
|
||||||
common_element_end('Person');
|
$this->elementEnd('Person');
|
||||||
if ($foaf_url) {
|
if ($foaf_url) {
|
||||||
$this->show_ppd($foaf_url, $uri);
|
$this->show_ppd($foaf_url, $uri);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
common_element_end('rdf:RDF');
|
$this->elementEnd('rdf:RDF');
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_ppd($foaf_url, $person_uri)
|
function show_ppd($foaf_url, $person_uri)
|
||||||
{
|
{
|
||||||
common_element_start('PersonalProfileDocument', array('rdf:about' => $foaf_url));
|
$this->elementStart('PersonalProfileDocument', array('rdf:about' => $foaf_url));
|
||||||
common_element('maker', array('rdf:resource' => $person_uri));
|
$this->element('maker', array('rdf:resource' => $person_uri));
|
||||||
common_element('primaryTopic', array('rdf:resource' => $person_uri));
|
$this->element('primaryTopic', array('rdf:resource' => $person_uri));
|
||||||
common_element_end('PersonalProfileDocument');
|
$this->elementEnd('PersonalProfileDocument');
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_microblogging_account($profile, $service=null)
|
function show_microblogging_account($profile, $service=null)
|
||||||
{
|
{
|
||||||
# Their account
|
# Their account
|
||||||
common_element_start('holdsAccount');
|
$this->elementStart('holdsAccount');
|
||||||
common_element_start('OnlineAccount');
|
$this->elementStart('OnlineAccount');
|
||||||
if ($service) {
|
if ($service) {
|
||||||
common_element('accountServiceHomepage', array('rdf:resource' =>
|
$this->element('accountServiceHomepage', array('rdf:resource' =>
|
||||||
$service));
|
$service));
|
||||||
}
|
}
|
||||||
common_element('accountName', null, $profile->nickname);
|
$this->element('accountName', null, $profile->nickname);
|
||||||
common_element('homepage', array('rdf:resource' => $profile->profileurl));
|
$this->element('homepage', array('rdf:resource' => $profile->profileurl));
|
||||||
common_element_end('OnlineAccount');
|
$this->elementEnd('OnlineAccount');
|
||||||
common_element_end('holdsAccount');
|
$this->elementEnd('holdsAccount');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/**
|
||||||
* Laconica - a distributed open-source microblogging tool
|
* Laconica, the distributed open-source microblogging tool
|
||||||
* Copyright (C) 2008, Controlez-Vous, Inc.
|
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* Settings for Jabber/XMPP integration
|
||||||
|
*
|
||||||
|
* 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
|
* 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
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
@ -15,85 +18,162 @@
|
|||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* 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/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* @category Settings
|
||||||
|
* @package Laconica
|
||||||
|
* @author Evan Prodromou <evan@controlyourself.ca>
|
||||||
|
* @copyright 2008-2009 Control Yourself, Inc.
|
||||||
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||||
|
* @link http://laconi.ca/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('LACONICA')) { exit(1); }
|
if (!defined('LACONICA')) {
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
require_once(INSTALLDIR.'/lib/settingsaction.php');
|
require_once INSTALLDIR.'/lib/connectsettingsaction.php';
|
||||||
require_once(INSTALLDIR.'/lib/jabber.php');
|
require_once INSTALLDIR.'/lib/jabber.php';
|
||||||
|
|
||||||
class ImsettingsAction extends SettingsAction
|
/**
|
||||||
|
* Settings for Jabber/XMPP integration
|
||||||
|
*
|
||||||
|
* @category Settings
|
||||||
|
* @package Laconica
|
||||||
|
* @author Evan Prodromou <evan@controlyourself.ca>
|
||||||
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||||
|
* @link http://laconi.ca/
|
||||||
|
*
|
||||||
|
* @see SettingsAction
|
||||||
|
*/
|
||||||
|
|
||||||
|
class ImsettingsAction extends ConnectSettingsAction
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Title of the page
|
||||||
|
*
|
||||||
|
* @return string Title of the page
|
||||||
|
*/
|
||||||
|
|
||||||
function get_instructions()
|
function title()
|
||||||
{
|
{
|
||||||
return _('You can send and receive notices through Jabber/GTalk [instant messages](%%doc.im%%). Configure your address and settings below.');
|
return _('IM Settings');
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_form($msg=null, $success=false)
|
/**
|
||||||
|
* Instructions for use
|
||||||
|
*
|
||||||
|
* @return instructions for use
|
||||||
|
*/
|
||||||
|
|
||||||
|
function getInstructions()
|
||||||
|
{
|
||||||
|
return _('You can send and receive notices through '.
|
||||||
|
'Jabber/GTalk [instant messages](%%doc.im%%). '.
|
||||||
|
'Configure your address and settings below.');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Content area of the page
|
||||||
|
*
|
||||||
|
* We make different sections of the form for the different kinds of
|
||||||
|
* functions, and have submit buttons with different names. These
|
||||||
|
* are muxed by handlePost() to see what the user really wants to do.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
|
function showContent()
|
||||||
{
|
{
|
||||||
$user = common_current_user();
|
$user = common_current_user();
|
||||||
$this->form_header(_('IM Settings'), $msg, $success);
|
$this->elementStart('form', array('method' => 'post',
|
||||||
common_element_start('form', array('method' => 'post',
|
'id' => 'form_settings_im',
|
||||||
'id' => 'imsettings',
|
'class' => 'form_settings',
|
||||||
'action' =>
|
'action' =>
|
||||||
common_local_url('imsettings')));
|
common_local_url('imsettings')));
|
||||||
common_hidden('token', common_session_token());
|
$this->elementStart('fieldset', array('id' => 'settings_im_address'));
|
||||||
|
$this->element('legend', null, _('Address'));
|
||||||
common_element('h2', null, _('Address'));
|
$this->hidden('token', common_session_token());
|
||||||
|
|
||||||
if ($user->jabber) {
|
if ($user->jabber) {
|
||||||
common_element_start('p');
|
$this->element('p', 'form_confirmed', $user->jabber);
|
||||||
common_element('span', 'address confirmed', $user->jabber);
|
$this->element('p', 'form_note',
|
||||||
common_element('span', 'input_instructions',
|
|
||||||
_('Current confirmed Jabber/GTalk address.'));
|
_('Current confirmed Jabber/GTalk address.'));
|
||||||
common_hidden('jabber', $user->jabber);
|
$this->hidden('jabber', $user->jabber);
|
||||||
common_element_end('p');
|
$this->submit('remove', _('Remove'));
|
||||||
common_submit('remove', _('Remove'));
|
|
||||||
} else {
|
} else {
|
||||||
$confirm = $this->get_confirmation();
|
$confirm = $this->getConfirmation();
|
||||||
if ($confirm) {
|
if ($confirm) {
|
||||||
common_element_start('p');
|
$this->element('p', 'form_unconfirmed', $confirm->address);
|
||||||
common_element('span', 'address unconfirmed', $confirm->address);
|
$this->element('p', 'form_note',
|
||||||
common_element('span', 'input_instructions',
|
sprintf(_('Awaiting confirmation on this address. '.
|
||||||
sprintf(_('Awaiting confirmation on this address. Check your Jabber/GTalk account for a message with further instructions. (Did you add %s to your buddy list?)'), jabber_daemon_address()));
|
'Check your Jabber/GTalk account for a '.
|
||||||
common_hidden('jabber', $confirm->address);
|
'message with further instructions. '.
|
||||||
common_element_end('p');
|
'(Did you add %s to your buddy list?)'),
|
||||||
common_submit('cancel', _('Cancel'));
|
jabber_daemon_address()));
|
||||||
|
$this->hidden('jabber', $confirm->address);
|
||||||
|
$this->submit('cancel', _('Cancel'));
|
||||||
} else {
|
} else {
|
||||||
common_input('jabber', _('IM Address'),
|
$this->elementStart('ul', 'form_data');
|
||||||
|
$this->elementStart('li');
|
||||||
|
$this->input('jabber', _('IM Address'),
|
||||||
($this->arg('jabber')) ? $this->arg('jabber') : null,
|
($this->arg('jabber')) ? $this->arg('jabber') : null,
|
||||||
sprintf(_('Jabber or GTalk address, like "UserName@example.org". First, make sure to add %s to your buddy list in your IM client or on GTalk.'), jabber_daemon_address()));
|
sprintf(_('Jabber or GTalk address, '.
|
||||||
common_submit('add', _('Add'));
|
'like "UserName@example.org". '.
|
||||||
|
'First, make sure to add %s to your '.
|
||||||
|
'buddy list in your IM client or on GTalk.'),
|
||||||
|
jabber_daemon_address()));
|
||||||
|
$this->elementEnd('li');
|
||||||
|
$this->elementEnd('ul');
|
||||||
|
$this->submit('add', _('Add'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$this->elementEnd('fieldset');
|
||||||
|
|
||||||
common_element('h2', null, _('Preferences'));
|
$this->elementStart('fieldset', array('id' => 'settings_im_preferences'));
|
||||||
|
$this->element('legend', null, _('Preferences'));
|
||||||
common_checkbox('jabbernotify',
|
$this->elementStart('ul', 'form_data');
|
||||||
|
$this->elementStart('li');
|
||||||
|
$this->checkbox('jabbernotify',
|
||||||
_('Send me notices through Jabber/GTalk.'),
|
_('Send me notices through Jabber/GTalk.'),
|
||||||
$user->jabbernotify);
|
$user->jabbernotify);
|
||||||
common_checkbox('updatefrompresence',
|
$this->elementEnd('li');
|
||||||
|
$this->elementStart('li');
|
||||||
|
$this->checkbox('updatefrompresence',
|
||||||
_('Post a notice when my Jabber/GTalk status changes.'),
|
_('Post a notice when my Jabber/GTalk status changes.'),
|
||||||
$user->updatefrompresence);
|
$user->updatefrompresence);
|
||||||
common_checkbox('jabberreplies',
|
$this->elementEnd('li');
|
||||||
_('Send me replies through Jabber/GTalk from people I\'m not subscribed to.'),
|
$this->elementStart('li');
|
||||||
|
$this->checkbox('jabberreplies',
|
||||||
|
_('Send me replies through Jabber/GTalk '.
|
||||||
|
'from people I\'m not subscribed to.'),
|
||||||
$user->jabberreplies);
|
$user->jabberreplies);
|
||||||
common_checkbox('jabbermicroid',
|
$this->elementEnd('li');
|
||||||
|
$this->elementStart('li');
|
||||||
|
$this->checkbox('jabbermicroid',
|
||||||
_('Publish a MicroID for my Jabber/GTalk address.'),
|
_('Publish a MicroID for my Jabber/GTalk address.'),
|
||||||
$user->jabbermicroid);
|
$user->jabbermicroid);
|
||||||
common_submit('save', _('Save'));
|
$this->elementEnd('li');
|
||||||
|
$this->elementEnd('ul');
|
||||||
common_element_end('form');
|
$this->submit('save', _('Save'));
|
||||||
common_show_footer();
|
$this->elementEnd('fieldset');
|
||||||
|
$this->elementEnd('form');
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_confirmation()
|
/**
|
||||||
|
* Get a confirmation code for this user
|
||||||
|
*
|
||||||
|
* @return Confirm_address address object for this user
|
||||||
|
*/
|
||||||
|
|
||||||
|
function getConfirmation()
|
||||||
{
|
{
|
||||||
$user = common_current_user();
|
$user = common_current_user();
|
||||||
|
|
||||||
$confirm = new Confirm_address();
|
$confirm = new Confirm_address();
|
||||||
|
|
||||||
$confirm->user_id = $user->id;
|
$confirm->user_id = $user->id;
|
||||||
$confirm->address_type = 'jabber';
|
$confirm->address_type = 'jabber';
|
||||||
|
|
||||||
if ($confirm->find(true)) {
|
if ($confirm->find(true)) {
|
||||||
return $confirm;
|
return $confirm;
|
||||||
} else {
|
} else {
|
||||||
@ -101,30 +181,50 @@ class ImsettingsAction extends SettingsAction
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function handle_post()
|
/**
|
||||||
{
|
* Handle posts to this form
|
||||||
|
*
|
||||||
|
* Based on the button that was pressed, muxes out to other functions
|
||||||
|
* to do the actual task requested.
|
||||||
|
*
|
||||||
|
* All sub-functions reload the form with a message -- success or failure.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
# CSRF protection
|
function handlePost()
|
||||||
|
{
|
||||||
|
// CSRF protection
|
||||||
$token = $this->trimmed('token');
|
$token = $this->trimmed('token');
|
||||||
if (!$token || $token != common_session_token()) {
|
if (!$token || $token != common_session_token()) {
|
||||||
$this->show_form(_('There was a problem with your session token. Try again, please.'));
|
$this->showForm(_('There was a problem with your session token. '.
|
||||||
|
'Try again, please.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->arg('save')) {
|
if ($this->arg('save')) {
|
||||||
$this->save_preferences();
|
$this->savePreferences();
|
||||||
} else if ($this->arg('add')) {
|
} else if ($this->arg('add')) {
|
||||||
$this->add_address();
|
$this->addAddress();
|
||||||
} else if ($this->arg('cancel')) {
|
} else if ($this->arg('cancel')) {
|
||||||
$this->cancel_confirmation();
|
$this->cancelConfirmation();
|
||||||
} else if ($this->arg('remove')) {
|
} else if ($this->arg('remove')) {
|
||||||
$this->remove_address();
|
$this->removeAddress();
|
||||||
} else {
|
} else {
|
||||||
$this->show_form(_('Unexpected form submission.'));
|
$this->showForm(_('Unexpected form submission.'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function save_preferences()
|
/**
|
||||||
|
* Save user's Jabber preferences
|
||||||
|
*
|
||||||
|
* These are the checkboxes at the bottom of the page. They're used to
|
||||||
|
* set different settings
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
|
function savePreferences()
|
||||||
{
|
{
|
||||||
|
|
||||||
$jabbernotify = $this->boolean('jabbernotify');
|
$jabbernotify = $this->boolean('jabbernotify');
|
||||||
@ -134,7 +234,7 @@ class ImsettingsAction extends SettingsAction
|
|||||||
|
|
||||||
$user = common_current_user();
|
$user = common_current_user();
|
||||||
|
|
||||||
assert(!is_null($user)); # should already be checked
|
assert(!is_null($user)); // should already be checked
|
||||||
|
|
||||||
$user->query('BEGIN');
|
$user->query('BEGIN');
|
||||||
|
|
||||||
@ -149,47 +249,56 @@ class ImsettingsAction extends SettingsAction
|
|||||||
|
|
||||||
if ($result === false) {
|
if ($result === false) {
|
||||||
common_log_db_error($user, 'UPDATE', __FILE__);
|
common_log_db_error($user, 'UPDATE', __FILE__);
|
||||||
common_server_error(_('Couldn\'t update user.'));
|
$this->serverError(_('Couldn\'t update user.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$user->query('COMMIT');
|
$user->query('COMMIT');
|
||||||
|
|
||||||
$this->show_form(_('Preferences saved.'), true);
|
$this->showForm(_('Preferences saved.'), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
function add_address()
|
/**
|
||||||
{
|
* Sends a confirmation to the address given
|
||||||
|
*
|
||||||
|
* Stores a confirmation record and sends out a
|
||||||
|
* Jabber message with the confirmation info.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
|
function addAddress()
|
||||||
|
{
|
||||||
$user = common_current_user();
|
$user = common_current_user();
|
||||||
|
|
||||||
$jabber = $this->trimmed('jabber');
|
$jabber = $this->trimmed('jabber');
|
||||||
|
|
||||||
# Some validation
|
// Some validation
|
||||||
|
|
||||||
if (!$jabber) {
|
if (!$jabber) {
|
||||||
$this->show_form(_('No Jabber ID.'));
|
$this->showForm(_('No Jabber ID.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$jabber = jabber_normalize_jid($jabber);
|
$jabber = jabber_normalize_jid($jabber);
|
||||||
|
|
||||||
if (!$jabber) {
|
if (!$jabber) {
|
||||||
$this->show_form(_('Cannot normalize that Jabber ID'));
|
$this->showForm(_('Cannot normalize that Jabber ID'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!jabber_valid_base_jid($jabber)) {
|
if (!jabber_valid_base_jid($jabber)) {
|
||||||
$this->show_form(_('Not a valid Jabber ID'));
|
$this->showForm(_('Not a valid Jabber ID'));
|
||||||
return;
|
return;
|
||||||
} else if ($user->jabber == $jabber) {
|
} else if ($user->jabber == $jabber) {
|
||||||
$this->show_form(_('That is already your Jabber ID.'));
|
$this->showForm(_('That is already your Jabber ID.'));
|
||||||
return;
|
return;
|
||||||
} else if ($this->jabber_exists($jabber)) {
|
} else if ($this->jabberExists($jabber)) {
|
||||||
$this->show_form(_('Jabber ID already belongs to another user.'));
|
$this->showForm(_('Jabber ID already belongs to another user.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$confirm = new Confirm_address();
|
$confirm = new Confirm_address();
|
||||||
|
|
||||||
$confirm->address = $jabber;
|
$confirm->address = $jabber;
|
||||||
$confirm->address_type = 'jabber';
|
$confirm->address_type = 'jabber';
|
||||||
$confirm->user_id = $user->id;
|
$confirm->user_id = $user->id;
|
||||||
@ -199,7 +308,7 @@ class ImsettingsAction extends SettingsAction
|
|||||||
|
|
||||||
if ($result === false) {
|
if ($result === false) {
|
||||||
common_log_db_error($confirm, 'INSERT', __FILE__);
|
common_log_db_error($confirm, 'INSERT', __FILE__);
|
||||||
common_server_error(_('Couldn\'t insert confirmation code.'));
|
$this->serverError(_('Couldn\'t insert confirmation code.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -209,21 +318,35 @@ class ImsettingsAction extends SettingsAction
|
|||||||
$jabber);
|
$jabber);
|
||||||
}
|
}
|
||||||
|
|
||||||
$msg = sprintf(_('A confirmation code was sent to the IM address you added. You must approve %s for sending messages to you.'), jabber_daemon_address());
|
$msg = sprintf(_('A confirmation code was sent '.
|
||||||
|
'to the IM address you added. '.
|
||||||
|
'You must approve %s for '.
|
||||||
|
'sending messages to you.'),
|
||||||
|
jabber_daemon_address());
|
||||||
|
|
||||||
$this->show_form($msg, true);
|
$this->showForm($msg, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
function cancel_confirmation()
|
/**
|
||||||
|
* Cancel a confirmation
|
||||||
|
*
|
||||||
|
* If a confirmation exists, cancel it.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
|
function cancelConfirmation()
|
||||||
{
|
{
|
||||||
$jabber = $this->arg('jabber');
|
$jabber = $this->arg('jabber');
|
||||||
$confirm = $this->get_confirmation();
|
|
||||||
|
$confirm = $this->getConfirmation();
|
||||||
|
|
||||||
if (!$confirm) {
|
if (!$confirm) {
|
||||||
$this->show_form(_('No pending confirmation to cancel.'));
|
$this->showForm(_('No pending confirmation to cancel.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ($confirm->address != $jabber) {
|
if ($confirm->address != $jabber) {
|
||||||
$this->show_form(_('That is the wrong IM address.'));
|
$this->showForm(_('That is the wrong IM address.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -231,46 +354,70 @@ class ImsettingsAction extends SettingsAction
|
|||||||
|
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
common_log_db_error($confirm, 'DELETE', __FILE__);
|
common_log_db_error($confirm, 'DELETE', __FILE__);
|
||||||
$this->server_error(_('Couldn\'t delete email confirmation.'));
|
$this->serverError(_('Couldn\'t delete email confirmation.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->show_form(_('Confirmation cancelled.'), true);
|
$this->showForm(_('Confirmation cancelled.'), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
function remove_address()
|
/**
|
||||||
{
|
* Remove an address
|
||||||
|
*
|
||||||
|
* If the user has a confirmed address, remove it.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
|
function removeAddress()
|
||||||
|
{
|
||||||
$user = common_current_user();
|
$user = common_current_user();
|
||||||
|
|
||||||
$jabber = $this->arg('jabber');
|
$jabber = $this->arg('jabber');
|
||||||
|
|
||||||
# Maybe an old tab open...?
|
// Maybe an old tab open...?
|
||||||
|
|
||||||
if ($user->jabber != $jabber) {
|
if ($user->jabber != $jabber) {
|
||||||
$this->show_form(_('That is not your Jabber ID.'));
|
$this->showForm(_('That is not your Jabber ID.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$user->query('BEGIN');
|
$user->query('BEGIN');
|
||||||
|
|
||||||
$original = clone($user);
|
$original = clone($user);
|
||||||
|
|
||||||
$user->jabber = null;
|
$user->jabber = null;
|
||||||
|
|
||||||
$result = $user->updateKeys($original);
|
$result = $user->updateKeys($original);
|
||||||
|
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
common_log_db_error($user, 'UPDATE', __FILE__);
|
common_log_db_error($user, 'UPDATE', __FILE__);
|
||||||
common_server_error(_('Couldn\'t update user.'));
|
$this->serverError(_('Couldn\'t update user.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$user->query('COMMIT');
|
$user->query('COMMIT');
|
||||||
|
|
||||||
# XXX: unsubscribe to the old address
|
// XXX: unsubscribe to the old address
|
||||||
|
|
||||||
$this->show_form(_('The address was removed.'), true);
|
$this->showForm(_('The address was removed.'), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
function jabber_exists($jabber)
|
/**
|
||||||
|
* Does this Jabber ID exist?
|
||||||
|
*
|
||||||
|
* Checks if we already have another user with this address.
|
||||||
|
*
|
||||||
|
* @param string $jabber Address to check
|
||||||
|
*
|
||||||
|
* @return boolean whether the Jabber ID exists
|
||||||
|
*/
|
||||||
|
|
||||||
|
function jabberExists($jabber)
|
||||||
{
|
{
|
||||||
$user = common_current_user();
|
$user = common_current_user();
|
||||||
|
|
||||||
$other = User::staticGet('jabber', $jabber);
|
$other = User::staticGet('jabber', $jabber);
|
||||||
|
|
||||||
if (!$other) {
|
if (!$other) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
|
@ -46,48 +46,41 @@ require_once INSTALLDIR.'/lib/mailbox.php';
|
|||||||
|
|
||||||
class InboxAction extends MailboxAction
|
class InboxAction extends MailboxAction
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* returns the title of the page
|
* Title of the page
|
||||||
*
|
*
|
||||||
* @param User $user current user
|
* @return string page title
|
||||||
* @param int $page current page
|
|
||||||
*
|
|
||||||
* @return string localised title of the page
|
|
||||||
*
|
|
||||||
* @see MailboxAction::getTitle()
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function getTitle($user, $page)
|
function title()
|
||||||
{
|
{
|
||||||
if ($page > 1) {
|
if ($this->page > 1) {
|
||||||
$title = sprintf(_("Inbox for %s - page %d"), $user->nickname, $page);
|
return sprintf(_("Inbox for %s - page %d"), $this->user->nickname,
|
||||||
|
$this->page);
|
||||||
} else {
|
} else {
|
||||||
$title = sprintf(_("Inbox for %s"), $user->nickname);
|
return sprintf(_("Inbox for %s"), $this->user->nickname);
|
||||||
}
|
}
|
||||||
return $title;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* retrieve the messages for this user and this page
|
* Retrieve the messages for this user and this page
|
||||||
*
|
*
|
||||||
* Does a query for the right messages
|
* Does a query for the right messages
|
||||||
*
|
*
|
||||||
* @param User $user The current user
|
|
||||||
* @param int $page The page the user is on
|
|
||||||
*
|
|
||||||
* @return Message data object with stream for messages
|
* @return Message data object with stream for messages
|
||||||
*
|
*
|
||||||
* @see MailboxAction::getMessages()
|
* @see MailboxAction::getMessages()
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function getMessages($user, $page)
|
function getMessages()
|
||||||
{
|
{
|
||||||
$message = new Message();
|
$message = new Message();
|
||||||
|
|
||||||
$message->to_profile = $user->id;
|
$message->to_profile = $this->user->id;
|
||||||
|
|
||||||
$message->orderBy('created DESC, id DESC');
|
$message->orderBy('created DESC, id DESC');
|
||||||
$message->limit((($page-1)*MESSAGES_PER_PAGE), MESSAGES_PER_PAGE + 1);
|
$message->limit((($this->page - 1) * MESSAGES_PER_PAGE),
|
||||||
|
MESSAGES_PER_PAGE + 1);
|
||||||
|
|
||||||
if ($message->find()) {
|
if ($message->find()) {
|
||||||
return $message;
|
return $message;
|
||||||
@ -97,15 +90,13 @@ class InboxAction extends MailboxAction
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* returns the profile we want to show with the message
|
* Returns the profile we want to show with the message
|
||||||
*
|
*
|
||||||
* For inboxes, we show the sender.
|
* For inboxes, we show the sender; for outboxes, the recipient.
|
||||||
*
|
*
|
||||||
* @param Message $message The message to get the profile for
|
* @param Message $message The message to get the profile for
|
||||||
*
|
*
|
||||||
* @return Profile The profile of the message sender
|
* @return Profile The profile that matches the message
|
||||||
*
|
|
||||||
* @see MailboxAction::getMessageProfile()
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function getMessageProfile($message)
|
function getMessageProfile($message)
|
||||||
@ -114,7 +105,7 @@ class InboxAction extends MailboxAction
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* instructions for using this page
|
* Instructions for using this page
|
||||||
*
|
*
|
||||||
* @return string localised instructions for using the page
|
* @return string localised instructions for using the page
|
||||||
*/
|
*/
|
||||||
|
@ -22,7 +22,7 @@ if (!defined('LACONICA')) { exit(1); }
|
|||||||
class InviteAction extends Action
|
class InviteAction extends Action
|
||||||
{
|
{
|
||||||
|
|
||||||
function is_readonly()
|
function isReadOnly()
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -31,7 +31,7 @@ class InviteAction extends Action
|
|||||||
{
|
{
|
||||||
parent::handle($args);
|
parent::handle($args);
|
||||||
if (!common_logged_in()) {
|
if (!common_logged_in()) {
|
||||||
$this->client_error(sprintf(_('You must be logged in to invite other users to use %s'),
|
$this->clientError(sprintf(_('You must be logged in to invite other users to use %s'),
|
||||||
common_config('site', 'name')));
|
common_config('site', 'name')));
|
||||||
return;
|
return;
|
||||||
} else if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
} else if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||||
@ -89,29 +89,29 @@ class InviteAction extends Action
|
|||||||
|
|
||||||
common_show_header(_('Invitation(s) sent'));
|
common_show_header(_('Invitation(s) sent'));
|
||||||
if ($already) {
|
if ($already) {
|
||||||
common_element('p', null, _('You are already subscribed to these users:'));
|
$this->element('p', null, _('You are already subscribed to these users:'));
|
||||||
common_element_start('ul');
|
$this->elementStart('ul');
|
||||||
foreach ($already as $other) {
|
foreach ($already as $other) {
|
||||||
common_element('li', null, sprintf(_('%s (%s)'), $other->nickname, $other->email));
|
$this->element('li', null, sprintf(_('%s (%s)'), $other->nickname, $other->email));
|
||||||
}
|
}
|
||||||
common_element_end('ul');
|
$this->elementEnd('ul');
|
||||||
}
|
}
|
||||||
if ($subbed) {
|
if ($subbed) {
|
||||||
common_element('p', null, _('These people are already users and you were automatically subscribed to them:'));
|
$this->element('p', null, _('These people are already users and you were automatically subscribed to them:'));
|
||||||
common_element_start('ul');
|
$this->elementStart('ul');
|
||||||
foreach ($subbed as $other) {
|
foreach ($subbed as $other) {
|
||||||
common_element('li', null, sprintf(_('%s (%s)'), $other->nickname, $other->email));
|
$this->element('li', null, sprintf(_('%s (%s)'), $other->nickname, $other->email));
|
||||||
}
|
}
|
||||||
common_element_end('ul');
|
$this->elementEnd('ul');
|
||||||
}
|
}
|
||||||
if ($sent) {
|
if ($sent) {
|
||||||
common_element('p', null, _('Invitation(s) sent to the following people:'));
|
$this->element('p', null, _('Invitation(s) sent to the following people:'));
|
||||||
common_element_start('ul');
|
$this->elementStart('ul');
|
||||||
foreach ($sent as $other) {
|
foreach ($sent as $other) {
|
||||||
common_element('li', null, $other);
|
$this->element('li', null, $other);
|
||||||
}
|
}
|
||||||
common_element_end('ul');
|
$this->elementEnd('ul');
|
||||||
common_element('p', null, _('You will be notified when your invitees accept the invitation and register on the site. Thanks for growing the community!'));
|
$this->element('p', null, _('You will be notified when your invitees accept the invitation and register on the site. Thanks for growing the community!'));
|
||||||
}
|
}
|
||||||
common_show_footer();
|
common_show_footer();
|
||||||
}
|
}
|
||||||
@ -119,12 +119,12 @@ class InviteAction extends Action
|
|||||||
function show_top($error=null)
|
function show_top($error=null)
|
||||||
{
|
{
|
||||||
if ($error) {
|
if ($error) {
|
||||||
common_element('p', 'error', $error);
|
$this->element('p', 'error', $error);
|
||||||
} else {
|
} else {
|
||||||
common_element_start('div', 'instructions');
|
$this->elementStart('div', 'instructions');
|
||||||
common_element('p', null,
|
$this->element('p', null,
|
||||||
_('Use this form to invite your friends and colleagues to use this service.'));
|
_('Use this form to invite your friends and colleagues to use this service.'));
|
||||||
common_element_end('div');
|
$this->elementEnd('div');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,22 +135,22 @@ class InviteAction extends Action
|
|||||||
|
|
||||||
common_show_header(_('Invite new users'), null, $error, array($this, 'show_top'));
|
common_show_header(_('Invite new users'), null, $error, array($this, 'show_top'));
|
||||||
|
|
||||||
common_element_start('form', array('method' => 'post',
|
$this->elementStart('form', array('method' => 'post',
|
||||||
'id' => 'invite',
|
'id' => 'invite',
|
||||||
'action' => common_local_url('invite')));
|
'action' => common_local_url('invite')));
|
||||||
common_hidden('token', common_session_token());
|
$this->hidden('token', common_session_token());
|
||||||
|
|
||||||
common_textarea('addresses', _('Email addresses'),
|
$this->textarea('addresses', _('Email addresses'),
|
||||||
$this->trimmed('addresses'),
|
$this->trimmed('addresses'),
|
||||||
_('Addresses of friends to invite (one per line)'));
|
_('Addresses of friends to invite (one per line)'));
|
||||||
|
|
||||||
common_textarea('personal', _('Personal message'),
|
$this->textarea('personal', _('Personal message'),
|
||||||
$this->trimmed('personal'),
|
$this->trimmed('personal'),
|
||||||
_('Optionally add a personal message to the invitation.'));
|
_('Optionally add a personal message to the invitation.'));
|
||||||
|
|
||||||
common_submit('send', _('Send'));
|
$this->submit('send', _('Send'));
|
||||||
|
|
||||||
common_element_end('form');
|
$this->elementEnd('form');
|
||||||
|
|
||||||
common_show_footer();
|
common_show_footer();
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/**
|
||||||
* Laconica - a distributed open-source microblogging tool
|
* Laconica, the distributed open-source microblogging tool
|
||||||
* Copyright (C) 2008, Controlez-Vous, Inc.
|
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* Login form
|
||||||
|
*
|
||||||
|
* 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
|
* 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
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
@ -15,47 +18,98 @@
|
|||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* 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/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* @category Login
|
||||||
|
* @package Laconica
|
||||||
|
* @author Evan Prodromou <evan@controlyourself.ca>
|
||||||
|
* @copyright 2008-2009 Control Yourself, Inc.
|
||||||
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||||
|
* @link http://laconi.ca/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('LACONICA')) { exit(1); }
|
if (!defined('LACONICA')) {
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Login form
|
||||||
|
*
|
||||||
|
* @category Personal
|
||||||
|
* @package Laconica
|
||||||
|
* @author Evan Prodromou <evan@controlyourself.ca>
|
||||||
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||||
|
* @link http://laconi.ca/
|
||||||
|
*/
|
||||||
|
|
||||||
class LoginAction extends Action
|
class LoginAction extends Action
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Has there been an error?
|
||||||
|
*/
|
||||||
|
|
||||||
function is_readonly()
|
var $error = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is this a read-only action?
|
||||||
|
*
|
||||||
|
* @return boolean false
|
||||||
|
*/
|
||||||
|
|
||||||
|
function isReadOnly()
|
||||||
{
|
{
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle input, produce output
|
||||||
|
*
|
||||||
|
* Switches on request method; either shows the form or handles its input.
|
||||||
|
*
|
||||||
|
* @param array $args $_REQUEST data
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
function handle($args)
|
function handle($args)
|
||||||
{
|
{
|
||||||
parent::handle($args);
|
parent::handle($args);
|
||||||
if (common_is_real_login()) {
|
if (common_is_real_login()) {
|
||||||
common_user_error(_('Already logged in.'));
|
$this->clientError(_('Already logged in.'));
|
||||||
} else if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
} else if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||||
$this->check_login();
|
$this->checkLogin();
|
||||||
} else {
|
} else {
|
||||||
$this->show_form();
|
$this->showForm();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function check_login()
|
/**
|
||||||
|
* Check the login data
|
||||||
|
*
|
||||||
|
* Determines if the login data is valid. If so, logs the user
|
||||||
|
* in, and redirects to the 'with friends' page, or to the stored
|
||||||
|
* return-to URL.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
|
function checkLogin()
|
||||||
{
|
{
|
||||||
# XXX: login throttle
|
// XXX: login throttle
|
||||||
|
|
||||||
# CSRF protection - token set in common_notice_form()
|
// CSRF protection - token set in common_notice_form()
|
||||||
$token = $this->trimmed('token');
|
$token = $this->trimmed('token');
|
||||||
if (!$token || $token != common_session_token()) {
|
if (!$token || $token != common_session_token()) {
|
||||||
$this->client_error(_('There was a problem with your session token. Try again, please.'));
|
$this->clientError(_('There was a problem with your session token. '.
|
||||||
|
'Try again, please.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$nickname = common_canonical_nickname($this->trimmed('nickname'));
|
$nickname = common_canonical_nickname($this->trimmed('nickname'));
|
||||||
$password = $this->arg('password');
|
$password = $this->arg('password');
|
||||||
if (common_check_user($nickname, $password)) {
|
if (common_check_user($nickname, $password)) {
|
||||||
# success!
|
// success!
|
||||||
if (!common_set_user($nickname)) {
|
if (!common_set_user($nickname)) {
|
||||||
common_server_error(_('Error setting user.'));
|
$this->serverError(_('Error setting user.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
common_real_login(true);
|
common_real_login(true);
|
||||||
@ -63,10 +117,10 @@ class LoginAction extends Action
|
|||||||
common_debug('Adding rememberme cookie for ' . $nickname);
|
common_debug('Adding rememberme cookie for ' . $nickname);
|
||||||
common_rememberme();
|
common_rememberme();
|
||||||
}
|
}
|
||||||
# success!
|
// success!
|
||||||
$url = common_get_returnto();
|
$url = common_get_returnto();
|
||||||
if ($url) {
|
if ($url) {
|
||||||
# We don't have to return to it again
|
// We don't have to return to it again
|
||||||
common_set_returnto(null);
|
common_set_returnto(null);
|
||||||
} else {
|
} else {
|
||||||
$url = common_local_url('all',
|
$url = common_local_url('all',
|
||||||
@ -75,13 +129,13 @@ class LoginAction extends Action
|
|||||||
}
|
}
|
||||||
common_redirect($url);
|
common_redirect($url);
|
||||||
} else {
|
} else {
|
||||||
$this->show_form(_('Incorrect username or password.'));
|
$this->showForm(_('Incorrect username or password.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
# success!
|
// success!
|
||||||
if (!common_set_user($user)) {
|
if (!common_set_user($user)) {
|
||||||
common_server_error(_('Error setting user.'));
|
$this->serverError(_('Error setting user.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,10 +145,10 @@ class LoginAction extends Action
|
|||||||
common_debug('Adding rememberme cookie for ' . $nickname);
|
common_debug('Adding rememberme cookie for ' . $nickname);
|
||||||
common_rememberme($user);
|
common_rememberme($user);
|
||||||
}
|
}
|
||||||
# success!
|
// success!
|
||||||
$url = common_get_returnto();
|
$url = common_get_returnto();
|
||||||
if ($url) {
|
if ($url) {
|
||||||
# We don't have to return to it again
|
// We don't have to return to it again
|
||||||
common_set_returnto(null);
|
common_set_returnto(null);
|
||||||
} else {
|
} else {
|
||||||
$url = common_local_url('all',
|
$url = common_local_url('all',
|
||||||
@ -104,35 +158,109 @@ class LoginAction extends Action
|
|||||||
common_redirect($url);
|
common_redirect($url);
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_form($error=null)
|
/**
|
||||||
|
* Store an error and show the page
|
||||||
|
*
|
||||||
|
* This used to show the whole page; now, it's just a wrapper
|
||||||
|
* that stores the error in an attribute.
|
||||||
|
*
|
||||||
|
* @param string $error error, if any.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
|
function showForm($error=null)
|
||||||
{
|
{
|
||||||
common_show_header(_('Login'), null, $error, array($this, 'show_top'));
|
$this->error = $error;
|
||||||
common_element_start('form', array('method' => 'post',
|
$this->showPage();
|
||||||
'id' => 'login',
|
|
||||||
'action' => common_local_url('login')));
|
|
||||||
common_input('nickname', _('Nickname'));
|
|
||||||
common_password('password', _('Password'));
|
|
||||||
common_checkbox('rememberme', _('Remember me'), false,
|
|
||||||
_('Automatically login in the future; ' .
|
|
||||||
'not for shared computers!'));
|
|
||||||
common_submit('submit', _('Login'));
|
|
||||||
common_hidden('token', common_session_token());
|
|
||||||
common_element_end('form');
|
|
||||||
common_element_start('p');
|
|
||||||
common_element('a', array('href' => common_local_url('recoverpassword')),
|
|
||||||
_('Lost or forgotten password?'));
|
|
||||||
common_element_end('p');
|
|
||||||
common_show_footer();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_instructions()
|
/**
|
||||||
|
* Title of the page
|
||||||
|
*
|
||||||
|
* @return string title of the page
|
||||||
|
*/
|
||||||
|
|
||||||
|
function title()
|
||||||
{
|
{
|
||||||
if (common_logged_in() &&
|
return _('Login');
|
||||||
!common_is_real_login() &&
|
}
|
||||||
common_get_returnto())
|
|
||||||
|
/**
|
||||||
|
* Show page notice
|
||||||
|
*
|
||||||
|
* Display a notice for how to use the page, or the
|
||||||
|
* error if it exists.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
|
function showPageNotice()
|
||||||
{
|
{
|
||||||
# rememberme logins have to reauthenticate before
|
if ($this->error) {
|
||||||
# changing any profile settings (cookie-stealing protection)
|
$this->element('p', 'error', $this->error);
|
||||||
|
} else {
|
||||||
|
$instr = $this->getInstructions();
|
||||||
|
$output = common_markup_to_html($instr);
|
||||||
|
|
||||||
|
$this->raw($output);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Core of the display code
|
||||||
|
*
|
||||||
|
* Shows the login form.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
|
function showContent()
|
||||||
|
{
|
||||||
|
$this->elementStart('form', array('method' => 'post',
|
||||||
|
'id' => 'form_login',
|
||||||
|
'class' => 'form_settings',
|
||||||
|
'action' => common_local_url('login')));
|
||||||
|
$this->elementStart('fieldset');
|
||||||
|
$this->element('legend', null, _('Login to site'));
|
||||||
|
$this->elementStart('ul', 'form_data');
|
||||||
|
$this->elementStart('li');
|
||||||
|
$this->input('nickname', _('Nickname'));
|
||||||
|
$this->elementEnd('li');
|
||||||
|
$this->elementStart('li');
|
||||||
|
$this->password('password', _('Password'));
|
||||||
|
$this->elementEnd('li');
|
||||||
|
$this->elementStart('li');
|
||||||
|
$this->checkbox('rememberme', _('Remember me'), false,
|
||||||
|
_('Automatically login in the future; ' .
|
||||||
|
'not for shared computers!'));
|
||||||
|
$this->elementEnd('li');
|
||||||
|
$this->elementEnd('ul');
|
||||||
|
$this->submit('submit', _('Login'));
|
||||||
|
$this->hidden('token', common_session_token());
|
||||||
|
$this->elementEnd('fieldset');
|
||||||
|
$this->elementEnd('form');
|
||||||
|
$this->elementStart('p');
|
||||||
|
$this->element('a', array('href' => common_local_url('recoverpassword')),
|
||||||
|
_('Lost or forgotten password?'));
|
||||||
|
$this->elementEnd('p');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instructions for using the form
|
||||||
|
*
|
||||||
|
* For "remembered" logins, we make the user re-login when they
|
||||||
|
* try to change settings. Different instructions for this case.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
|
function getInstructions()
|
||||||
|
{
|
||||||
|
if (common_logged_in() && !common_is_real_login() &&
|
||||||
|
common_get_returnto()) {
|
||||||
|
// rememberme logins have to reauthenticate before
|
||||||
|
// changing any profile settings (cookie-stealing protection)
|
||||||
return _('For security reasons, please re-enter your ' .
|
return _('For security reasons, please re-enter your ' .
|
||||||
'user name and password ' .
|
'user name and password ' .
|
||||||
'before changing your settings.');
|
'before changing your settings.');
|
||||||
@ -144,16 +272,17 @@ class LoginAction extends Action
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_top($error=null)
|
/**
|
||||||
|
* A local menu
|
||||||
|
*
|
||||||
|
* Shows different login/register actions.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
|
function showLocalNav()
|
||||||
{
|
{
|
||||||
if ($error) {
|
$nav = new LoginGroupNav($this);
|
||||||
common_element('p', 'error', $error);
|
$nav->show();
|
||||||
} else {
|
|
||||||
$instr = $this->get_instructions();
|
|
||||||
$output = common_markup_to_html($instr);
|
|
||||||
common_element_start('div', 'instructions');
|
|
||||||
common_raw($output);
|
|
||||||
common_element_end('div');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,16 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/**
|
||||||
|
* Logout action.
|
||||||
|
*
|
||||||
|
* PHP version 5
|
||||||
|
*
|
||||||
|
* @category Action
|
||||||
|
* @package Laconica
|
||||||
|
* @author Evan Prodromou <evan@controlyourself.ca>
|
||||||
|
* @author Robin Millette <millette@controlyourself.ca>
|
||||||
|
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
|
||||||
|
* @link http://laconi.ca/
|
||||||
|
*
|
||||||
* Laconica - a distributed open-source microblogging tool
|
* Laconica - a distributed open-source microblogging tool
|
||||||
* Copyright (C) 2008, Controlez-Vous, Inc.
|
* Copyright (C) 2008, Controlez-Vous, Inc.
|
||||||
*
|
*
|
||||||
@ -17,27 +28,51 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('LACONICA')) { exit(1); }
|
if (!defined('LACONICA')) {
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
require_once(INSTALLDIR.'/lib/openid.php');
|
require_once INSTALLDIR.'/lib/openid.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logout action class.
|
||||||
|
*
|
||||||
|
* @category Action
|
||||||
|
* @package Laconica
|
||||||
|
* @author Evan Prodromou <evan@controlyourself.ca>
|
||||||
|
* @author Robin Millette <millette@controlyourself.ca>
|
||||||
|
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
|
||||||
|
* @link http://laconi.ca/
|
||||||
|
*/
|
||||||
class LogoutAction extends Action
|
class LogoutAction extends Action
|
||||||
{
|
{
|
||||||
|
|
||||||
function is_readonly()
|
/**
|
||||||
|
* This is read only.
|
||||||
|
*
|
||||||
|
* @return boolean true
|
||||||
|
*/
|
||||||
|
function isReadOnly()
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class handler.
|
||||||
|
*
|
||||||
|
* @param array $args array of arguments
|
||||||
|
*
|
||||||
|
* @return nothing
|
||||||
|
*/
|
||||||
function handle($args)
|
function handle($args)
|
||||||
{
|
{
|
||||||
parent::handle($args);
|
parent::handle($args);
|
||||||
if (!common_logged_in()) {
|
if (!common_logged_in()) {
|
||||||
common_user_error(_('Not logged in.'));
|
$this->clientError(_('Not logged in.'));
|
||||||
} else {
|
} else {
|
||||||
common_set_user(null);
|
common_set_user(null);
|
||||||
common_real_login(false); # not logged in
|
common_real_login(false); // not logged in
|
||||||
common_forgetme(); # don't log back in!
|
common_forgetme(); // don't log back in!
|
||||||
common_redirect(common_local_url('public'));
|
common_redirect(common_local_url('public'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,16 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/**
|
||||||
|
* Microsummary action, see https://wiki.mozilla.org/Microsummaries
|
||||||
|
*
|
||||||
|
* PHP version 5
|
||||||
|
*
|
||||||
|
* @category Action
|
||||||
|
* @package Laconica
|
||||||
|
* @author Evan Prodromou <evan@controlyourself.ca>
|
||||||
|
* @author Robin Millette <millette@controlyourself.ca>
|
||||||
|
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
|
||||||
|
* @link http://laconi.ca/
|
||||||
|
*
|
||||||
* Laconica - a distributed open-source microblogging tool
|
* Laconica - a distributed open-source microblogging tool
|
||||||
* Copyright (C) 2008, Controlez-Vous, Inc.
|
* Copyright (C) 2008, Controlez-Vous, Inc.
|
||||||
*
|
*
|
||||||
@ -17,28 +28,45 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('LACONICA')) { exit(1); }
|
if (!defined('LACONICA')) {
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Microsummary action class.
|
||||||
|
*
|
||||||
|
* @category Action
|
||||||
|
* @package Laconica
|
||||||
|
* @author Evan Prodromou <evan@controlyourself.ca>
|
||||||
|
* @author Robin Millette <millette@controlyourself.ca>
|
||||||
|
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
|
||||||
|
* @link http://laconi.ca/
|
||||||
|
*/
|
||||||
class MicrosummaryAction extends Action
|
class MicrosummaryAction extends Action
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Class handler.
|
||||||
|
*
|
||||||
|
* @param array $args array of arguments
|
||||||
|
*
|
||||||
|
* @return nothing
|
||||||
|
*/
|
||||||
function handle($args)
|
function handle($args)
|
||||||
{
|
{
|
||||||
|
|
||||||
parent::handle($args);
|
parent::handle($args);
|
||||||
|
|
||||||
$nickname = common_canonical_nickname($this->arg('nickname'));
|
$nickname = common_canonical_nickname($this->arg('nickname'));
|
||||||
$user = User::staticGet('nickname', $nickname);
|
$user = User::staticGet('nickname', $nickname);
|
||||||
|
|
||||||
if (!$user) {
|
if (!$user) {
|
||||||
$this->client_error(_('No such user'), 404);
|
$this->clientError(_('No such user'), 404);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$notice = $user->getCurrentNotice();
|
$notice = $user->getCurrentNotice();
|
||||||
|
|
||||||
if (!$notice) {
|
if (!$notice) {
|
||||||
$this->client_error(_('No current status'), 404);
|
$this->clientError(_('No current status'), 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
header('Content-Type: text/plain');
|
header('Content-Type: text/plain');
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/**
|
||||||
* Laconica - a distributed open-source microblogging tool
|
* Laconica, the distributed open-source microblogging tool
|
||||||
* Copyright (C) 2008, Controlez-Vous, Inc.
|
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* Handler for posting new notices
|
||||||
|
*
|
||||||
|
* 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
|
* 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
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
@ -15,36 +18,87 @@
|
|||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* 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/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* @category Personal
|
||||||
|
* @package Laconica
|
||||||
|
* @author Evan Prodromou <evan@controlyourself.ca>
|
||||||
|
* @author Zach Copley <zach@controlyourself.ca>
|
||||||
|
* @author Sarven Capadisli <csarven@controlyourself.ca>
|
||||||
|
* @copyright 2008-2009 Control Yourself, Inc.
|
||||||
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||||
|
* @link http://laconi.ca/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('LACONICA')) { exit(1); }
|
if (!defined('LACONICA')) {
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Action for posting new direct messages
|
||||||
|
*
|
||||||
|
* @category Personal
|
||||||
|
* @package Laconica
|
||||||
|
* @author Evan Prodromou <evan@controlyourself.ca>
|
||||||
|
* @author Zach Copley <zach@controlyourself.ca>
|
||||||
|
* @author Sarven Capadisli <csarven@controlyourself.ca>
|
||||||
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||||
|
* @link http://laconi.ca/
|
||||||
|
*/
|
||||||
|
|
||||||
class NewmessageAction extends Action
|
class NewmessageAction extends Action
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Error message, if any
|
||||||
|
*/
|
||||||
|
|
||||||
|
var $msg = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Title of the page
|
||||||
|
*
|
||||||
|
* Note that this usually doesn't get called unless something went wrong
|
||||||
|
*
|
||||||
|
* @return string page title
|
||||||
|
*/
|
||||||
|
|
||||||
|
function title()
|
||||||
|
{
|
||||||
|
return _('New message');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle input, produce output
|
||||||
|
*
|
||||||
|
* @param array $args $_REQUEST contents
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
function handle($args)
|
function handle($args)
|
||||||
{
|
{
|
||||||
parent::handle($args);
|
parent::handle($args);
|
||||||
|
|
||||||
if (!common_logged_in()) {
|
if (!common_logged_in()) {
|
||||||
$this->client_error(_('Not logged in.'), 403);
|
$this->clientError(_('Not logged in.'), 403);
|
||||||
} else if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
} else if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||||
$this->save_new_message();
|
$this->saveNewMessage();
|
||||||
} else {
|
} else {
|
||||||
$this->show_form();
|
$this->showForm();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function save_new_message()
|
function saveNewMessage()
|
||||||
{
|
{
|
||||||
$user = common_current_user();
|
$user = common_current_user();
|
||||||
assert($user); # XXX: maybe an error instead...
|
assert($user); // XXX: maybe an error instead...
|
||||||
|
|
||||||
# CSRF protection
|
// CSRF protection
|
||||||
|
|
||||||
$token = $this->trimmed('token');
|
$token = $this->trimmed('token');
|
||||||
if (!$token || $token != common_session_token()) {
|
if (!$token || $token != common_session_token()) {
|
||||||
$this->show_form(_('There was a problem with your session token. Try again, please.'));
|
$this->showForm(_('There was a problem with your session token. ' .
|
||||||
|
'Try again, please.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,15 +106,18 @@ class NewmessageAction extends Action
|
|||||||
$to = $this->trimmed('to');
|
$to = $this->trimmed('to');
|
||||||
|
|
||||||
if (!$content) {
|
if (!$content) {
|
||||||
$this->show_form(_('No content!'));
|
$this->showForm(_('No content!'));
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
$content_shortened = common_shorten_links($content);
|
$content_shortened = common_shorten_links($content);
|
||||||
|
|
||||||
if (mb_strlen($content_shortened) > 140) {
|
if (mb_strlen($content_shortened) > 140) {
|
||||||
common_debug("Content = '$content_shortened'", __FILE__);
|
common_debug("Content = '$content_shortened'", __FILE__);
|
||||||
common_debug("mb_strlen(\$content) = " . mb_strlen($content_shortened), __FILE__);
|
common_debug("mb_strlen(\$content) = " .
|
||||||
$this->show_form(_('That\'s too long. Max message size is 140 chars.'));
|
mb_strlen($content_shortened),
|
||||||
|
__FILE__);
|
||||||
|
$this->showForm(_('That\'s too long. ' .
|
||||||
|
'Max message size is 140 chars.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -68,20 +125,21 @@ class NewmessageAction extends Action
|
|||||||
$other = User::staticGet('id', $to);
|
$other = User::staticGet('id', $to);
|
||||||
|
|
||||||
if (!$other) {
|
if (!$other) {
|
||||||
$this->show_form(_('No recipient specified.'));
|
$this->showForm(_('No recipient specified.'));
|
||||||
return;
|
return;
|
||||||
} else if (!$user->mutuallySubscribed($other)) {
|
} else if (!$user->mutuallySubscribed($other)) {
|
||||||
$this->client_error(_('You can\'t send a message to this user.'), 404);
|
$this->clientError(_('You can\'t send a message to this user.'), 404);
|
||||||
return;
|
return;
|
||||||
} else if ($user->id == $other->id) {
|
} else if ($user->id == $other->id) {
|
||||||
$this->client_error(_('Don\'t send a message to yourself; just say it to yourself quietly instead.'), 403);
|
$this->clientError(_('Don\'t send a message to yourself; ' .
|
||||||
|
'just say it to yourself quietly instead.'), 403);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$message = Message::saveNew($user->id, $other->id, $content, 'web');
|
$message = Message::saveNew($user->id, $other->id, $content, 'web');
|
||||||
|
|
||||||
if (is_string($message)) {
|
if (is_string($message)) {
|
||||||
$this->show_form($message);
|
$this->showForm($message);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,19 +150,8 @@ class NewmessageAction extends Action
|
|||||||
common_redirect($url, 303);
|
common_redirect($url, 303);
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_top($params)
|
function showForm($msg = null)
|
||||||
{
|
{
|
||||||
|
|
||||||
list($content, $user, $to) = $params;
|
|
||||||
|
|
||||||
assert(!is_null($user));
|
|
||||||
|
|
||||||
common_message_form($content, $user, $to);
|
|
||||||
}
|
|
||||||
|
|
||||||
function show_form($msg=null)
|
|
||||||
{
|
|
||||||
|
|
||||||
$content = $this->trimmed('content');
|
$content = $this->trimmed('content');
|
||||||
$user = common_current_user();
|
$user = common_current_user();
|
||||||
|
|
||||||
@ -113,29 +160,23 @@ class NewmessageAction extends Action
|
|||||||
$other = User::staticGet('id', $to);
|
$other = User::staticGet('id', $to);
|
||||||
|
|
||||||
if (!$other) {
|
if (!$other) {
|
||||||
$this->client_error(_('No such user'), 404);
|
$this->clientError(_('No such user'), 404);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$user->mutuallySubscribed($other)) {
|
if (!$user->mutuallySubscribed($other)) {
|
||||||
$this->client_error(_('You can\'t send a message to this user.'), 404);
|
$this->clientError(_('You can\'t send a message to this user.'), 404);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
common_show_header(_('New message'), null,
|
$this->msg = $msg;
|
||||||
array($content, $user, $other),
|
|
||||||
array($this, 'show_top'));
|
|
||||||
|
|
||||||
if ($msg) {
|
$this->showPage();
|
||||||
common_element('p', array('id'=>'error'), $msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
common_show_footer();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function notify($from, $to, $message)
|
function notify($from, $to, $message)
|
||||||
{
|
{
|
||||||
mail_notify_message($message, $from, $to);
|
mail_notify_message($message, $from, $to);
|
||||||
# XXX: Jabber, SMS notifications... probably queued
|
// XXX: Jabber, SMS notifications... probably queued
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/**
|
||||||
* Laconica - a distributed open-source microblogging tool
|
* Laconica, the distributed open-source microblogging tool
|
||||||
* Copyright (C) 2008, Controlez-Vous, Inc.
|
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* Handler for posting new notices
|
||||||
|
*
|
||||||
|
* 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
|
* 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
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
@ -15,53 +18,119 @@
|
|||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* 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/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* @category Personal
|
||||||
|
* @package Laconica
|
||||||
|
* @author Evan Prodromou <evan@controlyourself.ca>
|
||||||
|
* @author Zach Copley <zach@controlyourself.ca>
|
||||||
|
* @author Sarven Capadisli <csarven@controlyourself.ca>
|
||||||
|
* @copyright 2008-2009 Control Yourself, Inc.
|
||||||
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||||
|
* @link http://laconi.ca/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('LACONICA')) { exit(1); }
|
if (!defined('LACONICA')) {
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
require_once INSTALLDIR . '/lib/noticelist.php';
|
require_once INSTALLDIR.'/lib/noticelist.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Action for posting new notices
|
||||||
|
*
|
||||||
|
* @category Personal
|
||||||
|
* @package Laconica
|
||||||
|
* @author Evan Prodromou <evan@controlyourself.ca>
|
||||||
|
* @author Zach Copley <zach@controlyourself.ca>
|
||||||
|
* @author Sarven Capadisli <csarven@controlyourself.ca>
|
||||||
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||||
|
* @link http://laconi.ca/
|
||||||
|
*/
|
||||||
|
|
||||||
class NewnoticeAction extends Action
|
class NewnoticeAction extends Action
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Error message, if any
|
||||||
|
*/
|
||||||
|
|
||||||
|
var $msg = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Title of the page
|
||||||
|
*
|
||||||
|
* Note that this usually doesn't get called unless something went wrong
|
||||||
|
*
|
||||||
|
* @return string page title
|
||||||
|
*/
|
||||||
|
|
||||||
|
function title()
|
||||||
|
{
|
||||||
|
return _('New notice');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle input, produce output
|
||||||
|
*
|
||||||
|
* Switches based on GET or POST method. On GET, shows a form
|
||||||
|
* for posting a notice. On POST, saves the results of that form.
|
||||||
|
*
|
||||||
|
* Results may be a full page, or just a single notice list item,
|
||||||
|
* depending on whether AJAX was requested.
|
||||||
|
*
|
||||||
|
* @param array $args $_REQUEST contents
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
function handle($args)
|
function handle($args)
|
||||||
{
|
{
|
||||||
parent::handle($args);
|
parent::handle($args);
|
||||||
|
|
||||||
if (!common_logged_in()) {
|
if (!common_logged_in()) {
|
||||||
common_user_error(_('Not logged in.'));
|
$this->clientError(_('Not logged in.'));
|
||||||
} else if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
} else if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||||
|
|
||||||
# CSRF protection - token set in common_notice_form()
|
// CSRF protection - token set in common_notice_form()
|
||||||
$token = $this->trimmed('token');
|
$token = $this->trimmed('token');
|
||||||
if (!$token || $token != common_session_token()) {
|
if (!$token || $token != common_session_token()) {
|
||||||
$this->client_error(_('There was a problem with your session token. Try again, please.'));
|
$this->clientError(_('There was a problem with your session token. '.
|
||||||
|
'Try again, please.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->save_new_notice();
|
$this->saveNewNotice();
|
||||||
} else {
|
} else {
|
||||||
$this->show_form();
|
$this->showForm();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function save_new_notice()
|
/**
|
||||||
|
* Save a new notice, based on arguments
|
||||||
|
*
|
||||||
|
* If successful, will show the notice, or return an Ajax-y result.
|
||||||
|
* If not, it will show an error message -- possibly Ajax-y.
|
||||||
|
*
|
||||||
|
* Also, if the notice input looks like a command, it will run the
|
||||||
|
* command and show the results -- again, possibly ajaxy.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
|
function saveNewNotice()
|
||||||
{
|
{
|
||||||
|
|
||||||
$user = common_current_user();
|
$user = common_current_user();
|
||||||
assert($user); # XXX: maybe an error instead...
|
assert($user); // XXX: maybe an error instead...
|
||||||
$content = $this->trimmed('status_textarea');
|
$content = $this->trimmed('status_textarea');
|
||||||
|
|
||||||
if (!$content) {
|
if (!$content) {
|
||||||
$this->show_form(_('No content!'));
|
$this->showForm(_('No content!'));
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
$content_shortened = common_shorten_links($content);
|
$content_shortened = common_shorten_links($content);
|
||||||
|
|
||||||
if (mb_strlen($content_shortened) > 140) {
|
if (mb_strlen($content_shortened) > 140) {
|
||||||
common_debug("Content = '$content_shortened'", __FILE__);
|
$this->showForm(_('That\'s too long. '.
|
||||||
common_debug("mb_strlen(\$content) = " . mb_strlen($content_shortened), __FILE__);
|
'Max notice size is 140 chars.'));
|
||||||
$this->show_form(_('That\'s too long. Max notice size is 140 chars.'));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -81,24 +150,25 @@ class NewnoticeAction extends Action
|
|||||||
|
|
||||||
$replyto = $this->trimmed('inreplyto');
|
$replyto = $this->trimmed('inreplyto');
|
||||||
|
|
||||||
$notice = Notice::saveNew($user->id, $content, 'web', 1, ($replyto == 'false') ? null : $replyto);
|
$notice = Notice::saveNew($user->id, $content, 'web', 1,
|
||||||
|
($replyto == 'false') ? null : $replyto);
|
||||||
|
|
||||||
if (is_string($notice)) {
|
if (is_string($notice)) {
|
||||||
$this->show_form($notice);
|
$this->showForm($notice);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
common_broadcast_notice($notice);
|
common_broadcast_notice($notice);
|
||||||
|
|
||||||
if ($this->boolean('ajax')) {
|
if ($this->boolean('ajax')) {
|
||||||
common_start_html('text/xml;charset=utf-8', true);
|
$this->startHTML('text/xml;charset=utf-8', true);
|
||||||
common_element_start('head');
|
$this->elementStart('head');
|
||||||
common_element('title', null, _('Notice posted'));
|
$this->element('title', null, _('Notice posted'));
|
||||||
common_element_end('head');
|
$this->elementEnd('head');
|
||||||
common_element_start('body');
|
$this->elementStart('body');
|
||||||
$this->show_notice($notice);
|
$this->showNotice($notice);
|
||||||
common_element_end('body');
|
$this->elementEnd('body');
|
||||||
common_element_end('html');
|
$this->elementEnd('html');
|
||||||
} else {
|
} else {
|
||||||
$returnto = $this->trimmed('returnto');
|
$returnto = $this->trimmed('returnto');
|
||||||
|
|
||||||
@ -113,29 +183,64 @@ class NewnoticeAction extends Action
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function ajax_error_msg($msg)
|
/**
|
||||||
|
* Show an Ajax-y error message
|
||||||
|
*
|
||||||
|
* Goes back to the browser, where it's shown in a popup.
|
||||||
|
*
|
||||||
|
* @param string $msg Message to show
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
|
function ajaxErrorMsg($msg)
|
||||||
{
|
{
|
||||||
common_start_html('text/xml;charset=utf-8', true);
|
common_start_html('text/xml;charset=utf-8', true);
|
||||||
common_element_start('head');
|
$this->elementStart('head');
|
||||||
common_element('title', null, _('Ajax Error'));
|
$this->element('title', null, _('Ajax Error'));
|
||||||
common_element_end('head');
|
$this->elementEnd('head');
|
||||||
common_element_start('body');
|
$this->elementStart('body');
|
||||||
common_element('p', array('id' => 'error'), $msg);
|
$this->element('p', array('id' => 'error'), $msg);
|
||||||
common_element_end('body');
|
$this->elementEnd('body');
|
||||||
common_element_end('html');
|
$this->elementEnd('html');
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_top($content=null)
|
/**
|
||||||
{
|
* Formerly page output
|
||||||
common_notice_form(null, $content);
|
*
|
||||||
}
|
* This used to be the whole page output; now that's been largely
|
||||||
|
* subsumed by showPage. So this just stores an error message, if
|
||||||
|
* it was passed, and calls showPage.
|
||||||
|
*
|
||||||
|
* Note that since we started doing Ajax output, this page is rarely
|
||||||
|
* seen.
|
||||||
|
*
|
||||||
|
* @param string $msg An error message, if any
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
function show_form($msg=null)
|
function showForm($msg=null)
|
||||||
{
|
{
|
||||||
if ($msg && $this->boolean('ajax')) {
|
if ($msg && $this->boolean('ajax')) {
|
||||||
$this->ajax_error_msg($msg);
|
$this->ajaxErrorMsg($msg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->msg = $msg;
|
||||||
|
$this->showPage();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Overload for replies or bad results
|
||||||
|
*
|
||||||
|
* We show content in the notice form if there were replies or results.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
|
function showNoticeForm()
|
||||||
|
{
|
||||||
$content = $this->trimmed('status_textarea');
|
$content = $this->trimmed('status_textarea');
|
||||||
if (!$content) {
|
if (!$content) {
|
||||||
$replyto = $this->trimmed('replyto');
|
$replyto = $this->trimmed('replyto');
|
||||||
@ -144,18 +249,41 @@ class NewnoticeAction extends Action
|
|||||||
$content = '@' . $profile->nickname . ' ';
|
$content = '@' . $profile->nickname . ' ';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
common_show_header(_('New notice'), null, $content,
|
|
||||||
array($this, 'show_top'));
|
$notice_form = new NoticeForm($this, $content);
|
||||||
if ($msg) {
|
$notice_form->show();
|
||||||
common_element('p', array('id' => 'error'), $msg);
|
|
||||||
}
|
|
||||||
common_show_footer();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_notice($notice)
|
/**
|
||||||
|
* Show an error message
|
||||||
|
*
|
||||||
|
* Shows an error message if there is one.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
* @todo maybe show some instructions?
|
||||||
|
*/
|
||||||
|
|
||||||
|
function showPageNotice()
|
||||||
{
|
{
|
||||||
$nli = new NoticeListItem($notice);
|
if ($this->msg) {
|
||||||
|
$this->element('p', array('id' => 'error'), $this->msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Output a notice
|
||||||
|
*
|
||||||
|
* Used to generate the notice code for Ajax results.
|
||||||
|
*
|
||||||
|
* @param Notice $notice Notice that was saved
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
|
function showNotice($notice)
|
||||||
|
{
|
||||||
|
$nli = new NoticeListItem($notice, $this);
|
||||||
$nli->show();
|
$nli->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -58,7 +58,7 @@ class NoticesearchAction extends SearchAction
|
|||||||
}
|
}
|
||||||
if ($cnt > 0) {
|
if ($cnt > 0) {
|
||||||
$terms = preg_split('/[\s,]+/', $q);
|
$terms = preg_split('/[\s,]+/', $q);
|
||||||
common_element_start('ul', array('id' => 'notices'));
|
$this->elementStart('ul', array('id' => 'notices'));
|
||||||
for ($i = 0; $i < min($cnt, NOTICES_PER_PAGE); $i++) {
|
for ($i = 0; $i < min($cnt, NOTICES_PER_PAGE); $i++) {
|
||||||
if ($notice->fetch()) {
|
if ($notice->fetch()) {
|
||||||
$this->show_notice($notice, $terms);
|
$this->show_notice($notice, $terms);
|
||||||
@ -67,9 +67,9 @@ class NoticesearchAction extends SearchAction
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
common_element_end('ul');
|
$this->elementEnd('ul');
|
||||||
} else {
|
} else {
|
||||||
common_element('p', 'error', _('No results'));
|
$this->element('p', 'error', _('No results'));
|
||||||
}
|
}
|
||||||
|
|
||||||
common_pagination($page > 1, $cnt > NOTICES_PER_PAGE,
|
common_pagination($page > 1, $cnt > NOTICES_PER_PAGE,
|
||||||
@ -82,7 +82,7 @@ class NoticesearchAction extends SearchAction
|
|||||||
$q = $arr[0];
|
$q = $arr[0];
|
||||||
}
|
}
|
||||||
if ($q) {
|
if ($q) {
|
||||||
common_element('link', array('rel' => 'alternate',
|
$this->element('link', array('rel' => 'alternate',
|
||||||
'href' => common_local_url('noticesearchrss',
|
'href' => common_local_url('noticesearchrss',
|
||||||
array('q' => $q)),
|
array('q' => $q)),
|
||||||
'type' => 'application/rss+xml',
|
'type' => 'application/rss+xml',
|
||||||
@ -97,62 +97,62 @@ class NoticesearchAction extends SearchAction
|
|||||||
$profile = $notice->getProfile();
|
$profile = $notice->getProfile();
|
||||||
if (!$profile) {
|
if (!$profile) {
|
||||||
common_log_db_error($notice, 'SELECT', __FILE__);
|
common_log_db_error($notice, 'SELECT', __FILE__);
|
||||||
$this->server_error(_('Notice without matching profile'));
|
$this->serverError(_('Notice without matching profile'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
# XXX: RDFa
|
# XXX: RDFa
|
||||||
common_element_start('li', array('class' => 'notice_single',
|
$this->elementStart('li', array('class' => 'notice_single',
|
||||||
'id' => 'notice-' . $notice->id));
|
'id' => 'notice-' . $notice->id));
|
||||||
$avatar = $profile->getAvatar(AVATAR_STREAM_SIZE);
|
$avatar = $profile->getAvatar(AVATAR_STREAM_SIZE);
|
||||||
common_element_start('a', array('href' => $profile->profileurl));
|
$this->elementStart('a', array('href' => $profile->profileurl));
|
||||||
common_element('img', array('src' => ($avatar) ? common_avatar_display_url($avatar) : common_default_avatar(AVATAR_STREAM_SIZE),
|
$this->element('img', array('src' => ($avatar) ? common_avatar_display_url($avatar) : common_default_avatar(AVATAR_STREAM_SIZE),
|
||||||
'class' => 'avatar stream',
|
'class' => 'avatar stream',
|
||||||
'width' => AVATAR_STREAM_SIZE,
|
'width' => AVATAR_STREAM_SIZE,
|
||||||
'height' => AVATAR_STREAM_SIZE,
|
'height' => AVATAR_STREAM_SIZE,
|
||||||
'alt' =>
|
'alt' =>
|
||||||
($profile->fullname) ? $profile->fullname :
|
($profile->fullname) ? $profile->fullname :
|
||||||
$profile->nickname));
|
$profile->nickname));
|
||||||
common_element_end('a');
|
$this->elementEnd('a');
|
||||||
common_element('a', array('href' => $profile->profileurl,
|
$this->element('a', array('href' => $profile->profileurl,
|
||||||
'class' => 'nickname'),
|
'class' => 'nickname'),
|
||||||
$profile->nickname);
|
$profile->nickname);
|
||||||
# FIXME: URL, image, video, audio
|
# FIXME: URL, image, video, audio
|
||||||
common_element_start('p', array('class' => 'content'));
|
$this->elementStart('p', array('class' => 'content'));
|
||||||
if ($notice->rendered) {
|
if ($notice->rendered) {
|
||||||
common_raw($this->highlight($notice->rendered, $terms));
|
$this->raw($this->highlight($notice->rendered, $terms));
|
||||||
} else {
|
} else {
|
||||||
# XXX: may be some uncooked notices in the DB,
|
# XXX: may be some uncooked notices in the DB,
|
||||||
# we cook them right now. This should probably disappear in future
|
# we cook them right now. This should probably disappear in future
|
||||||
# versions (>> 0.4.x)
|
# versions (>> 0.4.x)
|
||||||
common_raw($this->highlight(common_render_content($notice->content, $notice), $terms));
|
$this->raw($this->highlight(common_render_content($notice->content, $notice), $terms));
|
||||||
}
|
}
|
||||||
common_element_end('p');
|
$this->elementEnd('p');
|
||||||
$noticeurl = common_local_url('shownotice', array('notice' => $notice->id));
|
$noticeurl = common_local_url('shownotice', array('notice' => $notice->id));
|
||||||
common_element_start('p', 'time');
|
$this->elementStart('p', 'time');
|
||||||
common_element('a', array('class' => 'permalink',
|
$this->element('a', array('class' => 'permalink',
|
||||||
'href' => $noticeurl,
|
'href' => $noticeurl,
|
||||||
'title' => common_exact_date($notice->created)),
|
'title' => common_exact_date($notice->created)),
|
||||||
common_date_string($notice->created));
|
common_date_string($notice->created));
|
||||||
if ($notice->reply_to) {
|
if ($notice->reply_to) {
|
||||||
$replyurl = common_local_url('shownotice', array('notice' => $notice->reply_to));
|
$replyurl = common_local_url('shownotice', array('notice' => $notice->reply_to));
|
||||||
common_text(' (');
|
$this->text(' (');
|
||||||
common_element('a', array('class' => 'inreplyto',
|
$this->element('a', array('class' => 'inreplyto',
|
||||||
'href' => $replyurl),
|
'href' => $replyurl),
|
||||||
_('in reply to...'));
|
_('in reply to...'));
|
||||||
common_text(')');
|
$this->text(')');
|
||||||
}
|
}
|
||||||
common_element_start('a',
|
$this->elementStart('a',
|
||||||
array('href' => common_local_url('newnotice',
|
array('href' => common_local_url('newnotice',
|
||||||
array('replyto' => $profile->nickname)),
|
array('replyto' => $profile->nickname)),
|
||||||
'onclick' => 'doreply("'.$profile->nickname.'"); return false',
|
'onclick' => 'doreply("'.$profile->nickname.'"); return false',
|
||||||
'title' => _('reply'),
|
'title' => _('reply'),
|
||||||
'class' => 'replybutton'));
|
'class' => 'replybutton'));
|
||||||
common_hidden('posttoken', common_session_token());
|
$this->hidden('posttoken', common_session_token());
|
||||||
|
|
||||||
common_raw('→');
|
$this->raw('→');
|
||||||
common_element_end('a');
|
$this->elementEnd('a');
|
||||||
common_element_end('p');
|
$this->elementEnd('p');
|
||||||
common_element_end('li');
|
$this->elementEnd('li');
|
||||||
}
|
}
|
||||||
|
|
||||||
function highlight($text, $terms)
|
function highlight($text, $terms)
|
||||||
|
@ -1,5 +1,17 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
|
||||||
|
/**
|
||||||
|
* User by ID action class.
|
||||||
|
*
|
||||||
|
* PHP version 5
|
||||||
|
*
|
||||||
|
* @category Action
|
||||||
|
* @package Laconica
|
||||||
|
* @author Evan Prodromou <evan@controlyourself.ca>
|
||||||
|
* @author Robin Millette <millette@controlyourself.ca>
|
||||||
|
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
|
||||||
|
* @link http://laconi.ca/
|
||||||
|
*
|
||||||
* Laconica - a distributed open-source microblogging tool
|
* Laconica - a distributed open-source microblogging tool
|
||||||
* Copyright (C) 2008, Controlez-Vous, Inc.
|
* Copyright (C) 2008, Controlez-Vous, Inc.
|
||||||
*
|
*
|
||||||
@ -17,19 +29,37 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('LACONICA')) { exit(1); }
|
if (!defined('LACONICA')) {
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
require_once(INSTALLDIR.'/lib/mail.php');
|
require_once INSTALLDIR.'/lib/mail.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Nudge a user action class.
|
||||||
|
*
|
||||||
|
* @category Action
|
||||||
|
* @package Laconica
|
||||||
|
* @author Evan Prodromou <evan@controlyourself.ca>
|
||||||
|
* @author Robin Millette <millette@controlyourself.ca>
|
||||||
|
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
|
||||||
|
* @link http://laconi.ca/
|
||||||
|
*/
|
||||||
class NudgeAction extends Action
|
class NudgeAction extends Action
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Class handler.
|
||||||
|
*
|
||||||
|
* @param array $args array of arguments
|
||||||
|
*
|
||||||
|
* @return nothing
|
||||||
|
*/
|
||||||
function handle($args)
|
function handle($args)
|
||||||
{
|
{
|
||||||
parent::handle($args);
|
parent::handle($args);
|
||||||
|
|
||||||
if (!common_logged_in()) {
|
if (!common_logged_in()) {
|
||||||
$this->client_error(_('Not logged in.'));
|
$this->clientError(_('Not logged in.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -37,21 +67,21 @@ class NudgeAction extends Action
|
|||||||
$other = User::staticGet('nickname', $this->arg('nickname'));
|
$other = User::staticGet('nickname', $this->arg('nickname'));
|
||||||
|
|
||||||
if ($_SERVER['REQUEST_METHOD'] != 'POST') {
|
if ($_SERVER['REQUEST_METHOD'] != 'POST') {
|
||||||
common_redirect(common_local_url('showstream', array('nickname' => $other->nickname)));
|
common_redirect(common_local_url('showstream',
|
||||||
|
array('nickname' => $other->nickname)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
# CSRF protection
|
// CSRF protection
|
||||||
|
|
||||||
$token = $this->trimmed('token');
|
$token = $this->trimmed('token');
|
||||||
|
|
||||||
if (!$token || $token != common_session_token()) {
|
if (!$token || $token != common_session_token()) {
|
||||||
$this->client_error(_('There was a problem with your session token. Try again, please.'));
|
$this->clientError(_('There was a problem with your session token. Try again, please.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$other->email || !$other->emailnotifynudge) {
|
if (!$other->email || !$other->emailnotifynudge) {
|
||||||
$this->client_error(_('This user doesn\'t allow nudges or hasn\'t confirmed or set his email yet.'));
|
$this->clientError(_('This user doesn\'t allow nudges or hasn\'t confirmed or set his email yet.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,13 +89,13 @@ class NudgeAction extends Action
|
|||||||
|
|
||||||
if ($this->boolean('ajax')) {
|
if ($this->boolean('ajax')) {
|
||||||
common_start_html('text/xml;charset=utf-8', true);
|
common_start_html('text/xml;charset=utf-8', true);
|
||||||
common_element_start('head');
|
$this->elementStart('head');
|
||||||
common_element('title', null, _('Nudge sent'));
|
$this->element('title', null, _('Nudge sent'));
|
||||||
common_element_end('head');
|
$this->elementEnd('head');
|
||||||
common_element_start('body');
|
$this->elementStart('body');
|
||||||
common_nudge_response();
|
common_nudge_response();
|
||||||
common_element_end('body');
|
$this->elementEnd('body');
|
||||||
common_element_end('html');
|
$this->elementEnd('html');
|
||||||
} else {
|
} else {
|
||||||
// display a confirmation to the user
|
// display a confirmation to the user
|
||||||
common_redirect(common_local_url('showstream',
|
common_redirect(common_local_url('showstream',
|
||||||
@ -73,14 +103,22 @@ class NudgeAction extends Action
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Do the actual notification
|
||||||
|
*
|
||||||
|
* @param class $user nudger
|
||||||
|
* @param class $other nudgee
|
||||||
|
*
|
||||||
|
* @return nothing
|
||||||
|
*/
|
||||||
function notify($user, $other)
|
function notify($user, $other)
|
||||||
{
|
{
|
||||||
if ($other->id != $user->id) {
|
if ($other->id != $user->id) {
|
||||||
if ($other->email && $other->emailnotifynudge) {
|
if ($other->email && $other->emailnotifynudge) {
|
||||||
mail_notify_nudge($user, $other);
|
mail_notify_nudge($user, $other);
|
||||||
}
|
}
|
||||||
# XXX: notify by IM
|
// XXX: notify by IM
|
||||||
# XXX: notify by SMS
|
// XXX: notify by SMS
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ class OpenidloginAction extends Action
|
|||||||
{
|
{
|
||||||
parent::handle($args);
|
parent::handle($args);
|
||||||
if (common_logged_in()) {
|
if (common_logged_in()) {
|
||||||
common_user_error(_('Already logged in.'));
|
$this->clientError(_('Already logged in.'));
|
||||||
} else if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
} else if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||||
$openid_url = $this->trimmed('openid_url');
|
$openid_url = $this->trimmed('openid_url');
|
||||||
|
|
||||||
@ -66,13 +66,13 @@ class OpenidloginAction extends Action
|
|||||||
function show_top($error=null)
|
function show_top($error=null)
|
||||||
{
|
{
|
||||||
if ($error) {
|
if ($error) {
|
||||||
common_element('div', array('class' => 'error'), $error);
|
$this->element('div', array('class' => 'error'), $error);
|
||||||
} else {
|
} else {
|
||||||
$instr = $this->get_instructions();
|
$instr = $this->get_instructions();
|
||||||
$output = common_markup_to_html($instr);
|
$output = common_markup_to_html($instr);
|
||||||
common_element_start('div', 'instructions');
|
$this->elementStart('div', 'instructions');
|
||||||
common_raw($output);
|
$this->raw($output);
|
||||||
common_element_end('div');
|
$this->elementEnd('div');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,18 +80,18 @@ class OpenidloginAction extends Action
|
|||||||
{
|
{
|
||||||
common_show_header(_('OpenID Login'), null, $error, array($this, 'show_top'));
|
common_show_header(_('OpenID Login'), null, $error, array($this, 'show_top'));
|
||||||
$formaction = common_local_url('openidlogin');
|
$formaction = common_local_url('openidlogin');
|
||||||
common_element_start('form', array('method' => 'post',
|
$this->elementStart('form', array('method' => 'post',
|
||||||
'id' => 'openidlogin',
|
'id' => 'openidlogin',
|
||||||
'action' => $formaction));
|
'action' => $formaction));
|
||||||
common_hidden('token', common_session_token());
|
$this->hidden('token', common_session_token());
|
||||||
common_input('openid_url', _('OpenID URL'),
|
$this->input('openid_url', _('OpenID URL'),
|
||||||
$openid_url,
|
$openid_url,
|
||||||
_('Your OpenID URL'));
|
_('Your OpenID URL'));
|
||||||
common_checkbox('rememberme', _('Remember me'), false,
|
$this->checkbox('rememberme', _('Remember me'), false,
|
||||||
_('Automatically login in the future; ' .
|
_('Automatically login in the future; ' .
|
||||||
'not for shared computers!'));
|
'not for shared computers!'));
|
||||||
common_submit('submit', _('Login'));
|
$this->submit('submit', _('Login'));
|
||||||
common_element_end('form');
|
$this->elementEnd('form');
|
||||||
common_show_footer();
|
common_show_footer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/**
|
||||||
* Laconica - a distributed open-source microblogging tool
|
* Laconica, the distributed open-source microblogging tool
|
||||||
* Copyright (C) 2008, Controlez-Vous, Inc.
|
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* Settings for OpenID
|
||||||
|
*
|
||||||
|
* 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
|
* 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
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
@ -15,147 +18,217 @@
|
|||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* 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/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* @category Settings
|
||||||
|
* @package Laconica
|
||||||
|
* @author Evan Prodromou <evan@controlyourself.ca>
|
||||||
|
* @copyright 2008-2009 Control Yourself, Inc.
|
||||||
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||||
|
* @link http://laconi.ca/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('LACONICA')) { exit(1); }
|
if (!defined('LACONICA')) {
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
require_once(INSTALLDIR.'/lib/settingsaction.php');
|
require_once INSTALLDIR.'/lib/accountsettingsaction.php';
|
||||||
require_once(INSTALLDIR.'/lib/openid.php');
|
require_once INSTALLDIR.'/lib/openid.php';
|
||||||
|
|
||||||
class OpenidsettingsAction extends SettingsAction
|
/**
|
||||||
|
* Settings for OpenID
|
||||||
|
*
|
||||||
|
* Lets users add, edit and delete OpenIDs from their account
|
||||||
|
*
|
||||||
|
* @category Settings
|
||||||
|
* @package Laconica
|
||||||
|
* @author Evan Prodromou <evan@controlyourself.ca>
|
||||||
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||||
|
* @link http://laconi.ca/
|
||||||
|
*/
|
||||||
|
|
||||||
|
class OpenidsettingsAction extends AccountSettingsAction
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Title of the page
|
||||||
|
*
|
||||||
|
* @return string Page title
|
||||||
|
*/
|
||||||
|
|
||||||
function get_instructions()
|
function title()
|
||||||
|
{
|
||||||
|
return _('OpenID settings');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instructions for use
|
||||||
|
*
|
||||||
|
* @return string Instructions for use
|
||||||
|
*/
|
||||||
|
|
||||||
|
function getInstructions()
|
||||||
{
|
{
|
||||||
return _('[OpenID](%%doc.openid%%) lets you log into many sites ' .
|
return _('[OpenID](%%doc.openid%%) lets you log into many sites ' .
|
||||||
' with the same user account. '.
|
' with the same user account. '.
|
||||||
' Manage your associated OpenIDs from here.');
|
' Manage your associated OpenIDs from here.');
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_form($msg=null, $success=false)
|
/**
|
||||||
{
|
* Show the form for OpenID management
|
||||||
|
*
|
||||||
|
* We have one form with a few different submit buttons to do different things.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
|
function showContent()
|
||||||
|
{
|
||||||
$user = common_current_user();
|
$user = common_current_user();
|
||||||
|
|
||||||
$this->form_header(_('OpenID settings'), $msg, $success);
|
$this->elementStart('form', array('method' => 'post',
|
||||||
|
'id' => 'form_settings_openid_add',
|
||||||
common_element_start('form', array('method' => 'post',
|
'class' => 'form_settings',
|
||||||
'id' => 'openidadd',
|
|
||||||
'action' =>
|
'action' =>
|
||||||
common_local_url('openidsettings')));
|
common_local_url('openidsettings')));
|
||||||
common_hidden('token', common_session_token());
|
$this->elementStart('fieldset', array('id' => 'settings_openid_add'));
|
||||||
common_element('h2', null, _('Add OpenID'));
|
$this->element('legend', null, _('Add OpenID'));
|
||||||
common_element('p', null,
|
$this->hidden('token', common_session_token());
|
||||||
|
$this->element('p', 'form_guide',
|
||||||
_('If you want to add an OpenID to your account, ' .
|
_('If you want to add an OpenID to your account, ' .
|
||||||
'enter it in the box below and click "Add".'));
|
'enter it in the box below and click "Add".'));
|
||||||
common_element_start('p');
|
$this->elementStart('ul', 'form_data');
|
||||||
common_element('label', array('for' => 'openid_url'),
|
$this->elementStart('li');
|
||||||
|
$this->element('label', array('for' => 'openid_url'),
|
||||||
_('OpenID URL'));
|
_('OpenID URL'));
|
||||||
common_element('input', array('name' => 'openid_url',
|
$this->element('input', array('name' => 'openid_url',
|
||||||
'type' => 'text',
|
'type' => 'text',
|
||||||
'id' => 'openid_url'));
|
'id' => 'openid_url'));
|
||||||
common_element('input', array('type' => 'submit',
|
$this->elementEnd('li');
|
||||||
'id' => 'add',
|
$this->elementEnd('ul');
|
||||||
|
$this->element('input', array('type' => 'submit',
|
||||||
|
'id' => 'settings_openid_add_action-submit',
|
||||||
'name' => 'add',
|
'name' => 'add',
|
||||||
'class' => 'submit',
|
'class' => 'submit',
|
||||||
'value' => _('Add')));
|
'value' => _('Add')));
|
||||||
common_element_end('p');
|
$this->elementEnd('fieldset');
|
||||||
common_element_end('form');
|
$this->elementEnd('form');
|
||||||
|
|
||||||
$oid = new User_openid();
|
$oid = new User_openid();
|
||||||
|
|
||||||
$oid->user_id = $user->id;
|
$oid->user_id = $user->id;
|
||||||
|
|
||||||
$cnt = $oid->find();
|
$cnt = $oid->find();
|
||||||
|
|
||||||
if ($cnt > 0) {
|
if ($cnt > 0) {
|
||||||
|
|
||||||
common_element('h2', null, _('Remove OpenID'));
|
$this->element('h2', null, _('Remove OpenID'));
|
||||||
|
|
||||||
if ($cnt == 1 && !$user->password) {
|
if ($cnt == 1 && !$user->password) {
|
||||||
|
|
||||||
common_element('p', null,
|
$this->element('p', 'form_guide',
|
||||||
_('Removing your only OpenID would make it impossible to log in! ' .
|
_('Removing your only OpenID '.
|
||||||
'If you need to remove it, add another OpenID first.'));
|
'would make it impossible to log in! ' .
|
||||||
|
'If you need to remove it, '.
|
||||||
|
'add another OpenID first.'));
|
||||||
|
|
||||||
if ($oid->fetch()) {
|
if ($oid->fetch()) {
|
||||||
common_element_start('p');
|
$this->elementStart('p');
|
||||||
common_element('a', array('href' => $oid->canonical),
|
$this->element('a', array('href' => $oid->canonical),
|
||||||
$oid->display);
|
$oid->display);
|
||||||
common_element_end('p');
|
$this->elementEnd('p');
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
common_element('p', null,
|
$this->element('p', 'form_guide',
|
||||||
_('You can remove an OpenID from your account '.
|
_('You can remove an OpenID from your account '.
|
||||||
'by clicking the button marked "Remove".'));
|
'by clicking the button marked "Remove".'));
|
||||||
$idx = 0;
|
$idx = 0;
|
||||||
|
|
||||||
while ($oid->fetch()) {
|
while ($oid->fetch()) {
|
||||||
common_element_start('form', array('method' => 'POST',
|
$this->elementStart('form',
|
||||||
'id' => 'openiddelete' . $idx,
|
array('method' => 'POST',
|
||||||
|
'id' => 'form_settings_openid_delete' . $idx,
|
||||||
|
'class' => 'form_settings',
|
||||||
'action' =>
|
'action' =>
|
||||||
common_local_url('openidsettings')));
|
common_local_url('openidsettings')));
|
||||||
common_element_start('p');
|
$this->elementStart('fieldset');
|
||||||
common_hidden('token', common_session_token());
|
$this->hidden('token', common_session_token());
|
||||||
common_element('a', array('href' => $oid->canonical),
|
$this->element('a', array('href' => $oid->canonical),
|
||||||
$oid->display);
|
$oid->display);
|
||||||
common_element('input', array('type' => 'hidden',
|
$this->element('input', array('type' => 'hidden',
|
||||||
'id' => 'openid_url'.$idx,
|
'id' => 'openid_url'.$idx,
|
||||||
'name' => 'openid_url',
|
'name' => 'openid_url',
|
||||||
'value' => $oid->canonical));
|
'value' => $oid->canonical));
|
||||||
common_element('input', array('type' => 'submit',
|
$this->element('input', array('type' => 'submit',
|
||||||
'id' => 'remove'.$idx,
|
'id' => 'remove'.$idx,
|
||||||
'name' => 'remove',
|
'name' => 'remove',
|
||||||
'class' => 'submit',
|
'class' => 'submit remove',
|
||||||
'value' => _('Remove')));
|
'value' => _('Remove')));
|
||||||
common_element_end('p');
|
$this->elementEnd('fieldset');
|
||||||
common_element_end('form');
|
$this->elementEnd('form');
|
||||||
$idx++;
|
$idx++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
common_show_footer();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function handle_post()
|
/**
|
||||||
|
* Handle a POST request
|
||||||
|
*
|
||||||
|
* Muxes to different sub-functions based on which button was pushed
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
|
function handlePost()
|
||||||
{
|
{
|
||||||
# CSRF protection
|
// CSRF protection
|
||||||
$token = $this->trimmed('token');
|
$token = $this->trimmed('token');
|
||||||
if (!$token || $token != common_session_token()) {
|
if (!$token || $token != common_session_token()) {
|
||||||
$this->show_form(_('There was a problem with your session token. Try again, please.'));
|
$this->showForm(_('There was a problem with your session token. '.
|
||||||
|
'Try again, please.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->arg('add')) {
|
if ($this->arg('add')) {
|
||||||
$result = oid_authenticate($this->trimmed('openid_url'), 'finishaddopenid');
|
$result = oid_authenticate($this->trimmed('openid_url'),
|
||||||
if (is_string($result)) { # error message
|
'finishaddopenid');
|
||||||
$this->show_form($result);
|
if (is_string($result)) { // error message
|
||||||
|
$this->showForm($result);
|
||||||
}
|
}
|
||||||
} else if ($this->arg('remove')) {
|
} else if ($this->arg('remove')) {
|
||||||
$this->remove_openid();
|
$this->removeOpenid();
|
||||||
} else {
|
} else {
|
||||||
$this->show_form(_('Something weird happened.'));
|
$this->showForm(_('Something weird happened.'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function remove_openid()
|
/**
|
||||||
|
* Handles a request to remove an OpenID from the user's account
|
||||||
|
*
|
||||||
|
* Validates input and, if everything is OK, deletes the OpenID.
|
||||||
|
* Reloads the form with a success or error notification.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
|
function removeOpenid()
|
||||||
{
|
{
|
||||||
|
|
||||||
$openid_url = $this->trimmed('openid_url');
|
$openid_url = $this->trimmed('openid_url');
|
||||||
|
|
||||||
$oid = User_openid::staticGet('canonical', $openid_url);
|
$oid = User_openid::staticGet('canonical', $openid_url);
|
||||||
|
|
||||||
if (!$oid) {
|
if (!$oid) {
|
||||||
$this->show_form(_('No such OpenID.'));
|
$this->showForm(_('No such OpenID.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$cur = common_current_user();
|
$cur = common_current_user();
|
||||||
if (!$cur || $oid->user_id != $cur->id) {
|
if (!$cur || $oid->user_id != $cur->id) {
|
||||||
$this->show_form(_('That OpenID does not belong to you.'));
|
$this->showForm(_('That OpenID does not belong to you.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$oid->delete();
|
$oid->delete();
|
||||||
$this->show_form(_('OpenID removed.'), true);
|
$this->showForm(_('OpenID removed.'), true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,21 +41,21 @@ class OpensearchAction extends Action
|
|||||||
header('Content-Type: text/html');
|
header('Content-Type: text/html');
|
||||||
|
|
||||||
common_start_xml();
|
common_start_xml();
|
||||||
common_element_start('OpenSearchDescription', array('xmlns' => 'http://a9.com/-/spec/opensearch/1.1/'));
|
$this->elementStart('OpenSearchDescription', array('xmlns' => 'http://a9.com/-/spec/opensearch/1.1/'));
|
||||||
|
|
||||||
$short_name = common_config('site', 'name').' '.$short_name;
|
$short_name = common_config('site', 'name').' '.$short_name;
|
||||||
common_element('ShortName', null, $short_name);
|
$this->element('ShortName', null, $short_name);
|
||||||
common_element('Contact', null, common_config('site', 'email'));
|
$this->element('Contact', null, common_config('site', 'email'));
|
||||||
common_element('Url', array('type' => 'text/html', 'method' => 'get',
|
$this->element('Url', array('type' => 'text/html', 'method' => 'get',
|
||||||
'template' => str_replace('---', '{searchTerms}', common_local_url($type, array('q' => '---')))));
|
'template' => str_replace('---', '{searchTerms}', common_local_url($type, array('q' => '---')))));
|
||||||
common_element('Image', array('height' => 16, 'width' => 16, 'type' => 'image/vnd.microsoft.icon'), common_path('favicon.ico'));
|
$this->element('Image', array('height' => 16, 'width' => 16, 'type' => 'image/vnd.microsoft.icon'), common_path('favicon.ico'));
|
||||||
common_element('Image', array('height' => 50, 'width' => 50, 'type' => 'image/png'), theme_path('logo.png'));
|
$this->element('Image', array('height' => 50, 'width' => 50, 'type' => 'image/png'), theme_path('logo.png'));
|
||||||
common_element('AdultContent', null, 'false');
|
$this->element('AdultContent', null, 'false');
|
||||||
common_element('Language', null, common_language());
|
$this->element('Language', null, common_language());
|
||||||
common_element('OutputEncoding', null, 'UTF-8');
|
$this->element('OutputEncoding', null, 'UTF-8');
|
||||||
common_element('InputEncoding', null, 'UTF-8');
|
$this->element('InputEncoding', null, 'UTF-8');
|
||||||
|
|
||||||
common_element_end('OpenSearchDescription');
|
$this->elementEnd('OpenSearchDescription');
|
||||||
common_end_xml();
|
common_end_xml();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/**
|
||||||
* Laconica - a distributed open-source microblogging tool
|
* Laconica, the distributed open-source microblogging tool
|
||||||
* Copyright (C) 2008, Controlez-Vous, Inc.
|
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* Miscellaneous settings
|
||||||
|
*
|
||||||
|
* 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
|
* 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
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
@ -15,32 +18,82 @@
|
|||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* 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/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* @category Settings
|
||||||
|
* @package Laconica
|
||||||
|
* @author Robin Millette <millette@controlyourself.ca>
|
||||||
|
* @author Evan Prodromou <evan@controlyourself.ca>
|
||||||
|
* @copyright 2008-2009 Control Yourself, Inc.
|
||||||
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||||
|
* @link http://laconi.ca/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('LACONICA')) { exit(1); }
|
if (!defined('LACONICA')) {
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
require_once(INSTALLDIR.'/lib/settingsaction.php');
|
require_once INSTALLDIR.'/lib/accountsettingsaction.php';
|
||||||
|
|
||||||
class OthersettingsAction extends SettingsAction
|
/**
|
||||||
|
* Miscellaneous settings actions
|
||||||
|
*
|
||||||
|
* Currently this just manages URL shortening.
|
||||||
|
*
|
||||||
|
* @category Settings
|
||||||
|
* @package Laconica
|
||||||
|
* @author Robin Millette <millette@controlyourself.ca>
|
||||||
|
* @author Zach Copley <zach@controlyourself.ca>
|
||||||
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||||
|
* @link http://laconi.ca/
|
||||||
|
*/
|
||||||
|
|
||||||
|
class OthersettingsAction extends AccountSettingsAction
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Title of the page
|
||||||
|
*
|
||||||
|
* @return string Title of the page
|
||||||
|
*/
|
||||||
|
|
||||||
function get_instructions()
|
function title()
|
||||||
|
{
|
||||||
|
return _('Other Settings');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instructions for use
|
||||||
|
*
|
||||||
|
* @return instructions for use
|
||||||
|
*/
|
||||||
|
|
||||||
|
function getInstructions()
|
||||||
{
|
{
|
||||||
return _('Manage various other options.');
|
return _('Manage various other options.');
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_form($msg=null, $success=false)
|
/**
|
||||||
|
* Content area of the page
|
||||||
|
*
|
||||||
|
* Shows a form for uploading an avatar.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
|
function showContent()
|
||||||
{
|
{
|
||||||
$user = common_current_user();
|
$user = common_current_user();
|
||||||
|
|
||||||
$this->form_header(_('Other Settings'), $msg, $success);
|
|
||||||
|
|
||||||
common_element('h2', null, _('URL Auto-shortening'));
|
$this->elementStart('form', array('method' => 'post',
|
||||||
common_element_start('form', array('method' => 'post',
|
'id' => 'form_settings_other',
|
||||||
'id' => 'othersettings',
|
'class' => 'form_settings',
|
||||||
'action' =>
|
'action' =>
|
||||||
common_local_url('othersettings')));
|
common_local_url('othersettings')));
|
||||||
common_hidden('token', common_session_token());
|
$this->elementStart('fieldset');
|
||||||
|
$this->element('legend', null, _('URL Auto-shortening'));
|
||||||
|
$this->hidden('token', common_session_token());
|
||||||
|
|
||||||
|
// I18N
|
||||||
|
|
||||||
$services = array(
|
$services = array(
|
||||||
'' => 'None',
|
'' => 'None',
|
||||||
@ -54,118 +107,47 @@ class OthersettingsAction extends SettingsAction
|
|||||||
'metamark.net' => 'metamark.net'
|
'metamark.net' => 'metamark.net'
|
||||||
);
|
);
|
||||||
|
|
||||||
common_dropdown('urlshorteningservice', _('Service'), $services, _('Automatic shortening service to use.'), false, $user->urlshorteningservice);
|
$this->elementStart('ul', 'form_data');
|
||||||
|
$this->elementStart('li');
|
||||||
common_submit('save', _('Save'));
|
$this->dropdown('urlshorteningservice', _('Service'),
|
||||||
|
$services, _('Automatic shortening service to use.'),
|
||||||
common_element_end('form');
|
false, $user->urlshorteningservice);
|
||||||
|
$this->elementEnd('li');
|
||||||
// common_element('h2', null, _('Delete my account'));
|
$this->elementEnd('ul');
|
||||||
// $this->show_delete_form();
|
$this->submit('save', _('Save'));
|
||||||
|
$this->elementEnd('fieldset');
|
||||||
common_show_footer();
|
$this->elementEnd('form');
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_feeds_list($feeds)
|
/**
|
||||||
|
* Handle a post
|
||||||
|
*
|
||||||
|
* Saves the changes to url-shortening prefs and shows a success or failure
|
||||||
|
* message.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
|
function handlePost()
|
||||||
{
|
{
|
||||||
common_element_start('div', array('class' => 'feedsdel'));
|
// CSRF protection
|
||||||
common_element('p', null, 'Feeds:');
|
|
||||||
common_element_start('ul', array('class' => 'xoxo'));
|
|
||||||
|
|
||||||
foreach ($feeds as $key => $value) {
|
|
||||||
$this->common_feed_item($feeds[$key]);
|
|
||||||
}
|
|
||||||
common_element_end('ul');
|
|
||||||
common_element_end('div');
|
|
||||||
}
|
|
||||||
|
|
||||||
//TODO move to common.php (and retrace its origin)
|
|
||||||
function common_feed_item($feed)
|
|
||||||
{
|
|
||||||
$user = common_current_user();
|
|
||||||
$nickname = $user->nickname;
|
|
||||||
|
|
||||||
switch($feed['item']) {
|
|
||||||
case 'notices': default:
|
|
||||||
$feed_classname = $feed['type'];
|
|
||||||
$feed_mimetype = "application/".$feed['type']."+xml";
|
|
||||||
$feed_title = "$nickname's ".$feed['version']." notice feed";
|
|
||||||
$feed['textContent'] = "RSS";
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'foaf':
|
|
||||||
$feed_classname = "foaf";
|
|
||||||
$feed_mimetype = "application/".$feed['type']."+xml";
|
|
||||||
$feed_title = "$nickname's FOAF file";
|
|
||||||
$feed['textContent'] = "FOAF";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
common_element_start('li');
|
|
||||||
common_element('a', array('href' => $feed['href'],
|
|
||||||
'class' => $feed_classname,
|
|
||||||
'type' => $feed_mimetype,
|
|
||||||
'title' => $feed_title),
|
|
||||||
$feed['textContent']);
|
|
||||||
common_element_end('li');
|
|
||||||
}
|
|
||||||
|
|
||||||
// function show_delete_form() {
|
|
||||||
// $user = common_current_user();
|
|
||||||
// $notices = DB_DataObject::factory('notice');
|
|
||||||
// $notices->profile_id = $user->id;
|
|
||||||
// $notice_count = (int) $notices->count();
|
|
||||||
//
|
|
||||||
// common_element_start('form', array('method' => 'POST',
|
|
||||||
// 'id' => 'delete',
|
|
||||||
// 'action' =>
|
|
||||||
// common_local_url('deleteprofile')));
|
|
||||||
//
|
|
||||||
// common_hidden('token', common_session_token());
|
|
||||||
// common_element('p', null, "You can copy your notices and contacts by saving the two links below before deleting your account. Be careful, this operation cannot be undone.");
|
|
||||||
//
|
|
||||||
// $this->show_feeds_list(array(0=>array('href'=>common_local_url('userrss', array('limit' => $notice_count, 'nickname' => $user->nickname)),
|
|
||||||
// 'type' => 'rss',
|
|
||||||
// 'version' => 'RSS 1.0',
|
|
||||||
// 'item' => 'notices'),
|
|
||||||
// 1=>array('href'=>common_local_url('foaf',array('nickname' => $user->nickname)),
|
|
||||||
// 'type' => 'rdf',
|
|
||||||
// 'version' => 'FOAF',
|
|
||||||
// 'item' => 'foaf')));
|
|
||||||
//
|
|
||||||
// common_submit('deleteaccount', _('Delete my account'));
|
|
||||||
// common_element_end('form');
|
|
||||||
// }
|
|
||||||
|
|
||||||
function handle_post()
|
|
||||||
{
|
|
||||||
|
|
||||||
# CSRF protection
|
|
||||||
$token = $this->trimmed('token');
|
$token = $this->trimmed('token');
|
||||||
if (!$token || $token != common_session_token()) {
|
if (!$token || $token != common_session_token()) {
|
||||||
$this->show_form(_('There was a problem with your session token. Try again, please.'));
|
$this->showForm(_('There was a problem with your session token. '.
|
||||||
|
'Try again, please.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->arg('save')) {
|
|
||||||
$this->save_preferences();
|
|
||||||
}else {
|
|
||||||
$this->show_form(_('Unexpected form submission.'));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function save_preferences()
|
|
||||||
{
|
|
||||||
|
|
||||||
$urlshorteningservice = $this->trimmed('urlshorteningservice');
|
$urlshorteningservice = $this->trimmed('urlshorteningservice');
|
||||||
|
|
||||||
if (!is_null($urlshorteningservice) && strlen($urlshorteningservice) > 50) {
|
if (!is_null($urlshorteningservice) && strlen($urlshorteningservice) > 50) {
|
||||||
$this->show_form(_('URL shortening service is too long (max 50 chars).'));
|
$this->showForm(_('URL shortening service is too long (max 50 chars).'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$user = common_current_user();
|
$user = common_current_user();
|
||||||
|
|
||||||
assert(!is_null($user)); # should already be checked
|
assert(!is_null($user)); // should already be checked
|
||||||
|
|
||||||
$user->query('BEGIN');
|
$user->query('BEGIN');
|
||||||
|
|
||||||
@ -177,12 +159,12 @@ class OthersettingsAction extends SettingsAction
|
|||||||
|
|
||||||
if ($result === false) {
|
if ($result === false) {
|
||||||
common_log_db_error($user, 'UPDATE', __FILE__);
|
common_log_db_error($user, 'UPDATE', __FILE__);
|
||||||
common_server_error(_('Couldn\'t update user.'));
|
$this->serverError(_('Couldn\'t update user.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$user->query('COMMIT');
|
$user->query('COMMIT');
|
||||||
|
|
||||||
$this->show_form(_('Preferences saved.'), true);
|
$this->showForm(_('Preferences saved.'), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -47,24 +47,19 @@ require_once INSTALLDIR.'/lib/mailbox.php';
|
|||||||
class OutboxAction extends MailboxAction
|
class OutboxAction extends MailboxAction
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* returns the title of the page
|
* Title of the page
|
||||||
*
|
*
|
||||||
* @param User $user current user
|
* @return string page title
|
||||||
* @param int $page current page
|
|
||||||
*
|
|
||||||
* @return string localised title of the page
|
|
||||||
*
|
|
||||||
* @see MailboxAction::getTitle()
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function getTitle($user, $page)
|
function title()
|
||||||
{
|
{
|
||||||
if ($page > 1) {
|
if ($this->page > 1) {
|
||||||
$title = sprintf(_("Outbox for %s - page %d"), $user->nickname, $page);
|
return sprintf(_("Outbox for %s - page %d"),
|
||||||
|
$this->user->nickname, $page);
|
||||||
} else {
|
} else {
|
||||||
$title = sprintf(_("Outbox for %s"), $user->nickname);
|
return sprintf(_("Outbox for %s"), $this->user->nickname);
|
||||||
}
|
}
|
||||||
return $title;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -72,21 +67,19 @@ class OutboxAction extends MailboxAction
|
|||||||
*
|
*
|
||||||
* Does a query for the right messages
|
* Does a query for the right messages
|
||||||
*
|
*
|
||||||
* @param User $user The current user
|
|
||||||
* @param int $page The page the user is on
|
|
||||||
*
|
|
||||||
* @return Message data object with stream for messages
|
* @return Message data object with stream for messages
|
||||||
*
|
*
|
||||||
* @see MailboxAction::getMessages()
|
* @see MailboxAction::getMessages()
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function getMessages($user, $page)
|
function getMessages()
|
||||||
{
|
{
|
||||||
$message = new Message();
|
$message = new Message();
|
||||||
|
|
||||||
$message->from_profile = $user->id;
|
$message->from_profile = $this->user->id;
|
||||||
$message->orderBy('created DESC, id DESC');
|
$message->orderBy('created DESC, id DESC');
|
||||||
$message->limit((($page-1)*MESSAGES_PER_PAGE), MESSAGES_PER_PAGE + 1);
|
$message->limit((($this->page - 1) * MESSAGES_PER_PAGE),
|
||||||
|
MESSAGES_PER_PAGE + 1);
|
||||||
|
|
||||||
if ($message->find()) {
|
if ($message->find()) {
|
||||||
return $message;
|
return $message;
|
||||||
|
161
actions/passwordsettings.php
Normal file
161
actions/passwordsettings.php
Normal file
@ -0,0 +1,161 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Laconica, the distributed open-source microblogging tool
|
||||||
|
*
|
||||||
|
* Change user password
|
||||||
|
*
|
||||||
|
* 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 Settings
|
||||||
|
* @package Laconica
|
||||||
|
* @author Evan Prodromou <evan@controlyourself.ca>
|
||||||
|
* @author Zach Copley <zach@controlyourself.ca>
|
||||||
|
* @copyright 2008-2009 Control Yourself, Inc.
|
||||||
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||||
|
* @link http://laconi.ca/
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (!defined('LACONICA')) {
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
require_once INSTALLDIR.'/lib/accountsettingsaction.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Change password
|
||||||
|
*
|
||||||
|
* @category Settings
|
||||||
|
* @package Laconica
|
||||||
|
* @author Evan Prodromou <evan@controlyourself.ca>
|
||||||
|
* @author Zach Copley <zach@controlyourself.ca>
|
||||||
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||||
|
* @link http://laconi.ca/
|
||||||
|
*/
|
||||||
|
|
||||||
|
class PasswordsettingsAction extends AccountSettingsAction
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Title of the page
|
||||||
|
*
|
||||||
|
* @return string Title of the page
|
||||||
|
*/
|
||||||
|
|
||||||
|
function title()
|
||||||
|
{
|
||||||
|
return _('Change password');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instructions for use
|
||||||
|
*
|
||||||
|
* @return instructions for use
|
||||||
|
*/
|
||||||
|
|
||||||
|
function getInstructions()
|
||||||
|
{
|
||||||
|
return _('Change your password.');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Content area of the page
|
||||||
|
*
|
||||||
|
* Shows a form for changing the password
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
|
function showContent()
|
||||||
|
{
|
||||||
|
$user = common_current_user();
|
||||||
|
$this->elementStart('form', array('method' => 'POST',
|
||||||
|
'id' => 'password',
|
||||||
|
'action' =>
|
||||||
|
common_local_url('profilesettings')));
|
||||||
|
|
||||||
|
$this->hidden('token', common_session_token());
|
||||||
|
|
||||||
|
// Users who logged in with OpenID won't have a pwd
|
||||||
|
if ($user->password) {
|
||||||
|
$this->password('oldpassword', _('Old password'));
|
||||||
|
}
|
||||||
|
$this->password('newpassword', _('New password'),
|
||||||
|
_('6 or more characters'));
|
||||||
|
$this->password('confirm', _('Confirm'),
|
||||||
|
_('same as password above'));
|
||||||
|
$this->submit('changepass', _('Change'));
|
||||||
|
$this->elementEnd('form');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle a post
|
||||||
|
*
|
||||||
|
* Validate input and save changes. Reload the form with a success
|
||||||
|
* or error message.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
|
function handlePost()
|
||||||
|
{
|
||||||
|
// CSRF protection
|
||||||
|
|
||||||
|
$token = $this->trimmed('token');
|
||||||
|
if (!$token || $token != common_session_token()) {
|
||||||
|
$this->showForm(_('There was a problem with your session token. '.
|
||||||
|
'Try again, please.'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$user = common_current_user();
|
||||||
|
assert(!is_null($user)); // should already be checked
|
||||||
|
|
||||||
|
// FIXME: scrub input
|
||||||
|
|
||||||
|
$newpassword = $this->arg('newpassword');
|
||||||
|
$confirm = $this->arg('confirm');
|
||||||
|
|
||||||
|
if (0 != strcmp($newpassword, $confirm)) {
|
||||||
|
$this->showForm(_('Passwords don\'t match.'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($user->password) {
|
||||||
|
$oldpassword = $this->arg('oldpassword');
|
||||||
|
|
||||||
|
if (!common_check_user($user->nickname, $oldpassword)) {
|
||||||
|
$this->showForm(_('Incorrect old password'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$original = clone($user);
|
||||||
|
|
||||||
|
$user->password = common_munge_password($newpassword, $user->id);
|
||||||
|
|
||||||
|
$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;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->showForm(_('Password saved.'), true);
|
||||||
|
}
|
||||||
|
}
|
@ -60,7 +60,7 @@ class PeoplesearchAction extends SearchAction
|
|||||||
$results = new PeopleSearchResults($profile, $terms);
|
$results = new PeopleSearchResults($profile, $terms);
|
||||||
$results->show_list();
|
$results->show_list();
|
||||||
} else {
|
} else {
|
||||||
common_element('p', 'error', _('No results'));
|
$this->element('p', 'error', _('No results'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$profile->free();
|
$profile->free();
|
||||||
|
@ -32,7 +32,7 @@ class PeopletagAction extends Action
|
|||||||
$tag = $this->trimmed('tag');
|
$tag = $this->trimmed('tag');
|
||||||
|
|
||||||
if (!common_valid_profile_tag($tag)) {
|
if (!common_valid_profile_tag($tag)) {
|
||||||
$this->client_error(sprintf(_('Not a valid people tag: %s'), $tag));
|
$this->clientError(sprintf(_('Not a valid people tag: %s'), $tag));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,11 +90,11 @@ class PeopletagAction extends Action
|
|||||||
{
|
{
|
||||||
$instr = sprintf(_('These are users who have tagged themselves "%s" ' .
|
$instr = sprintf(_('These are users who have tagged themselves "%s" ' .
|
||||||
'to show a common interest, characteristic, hobby or job.'), $tag);
|
'to show a common interest, characteristic, hobby or job.'), $tag);
|
||||||
common_element_start('div', 'instructions');
|
$this->elementStart('div', 'instructions');
|
||||||
common_element_start('p');
|
$this->elementStart('p');
|
||||||
common_text($instr);
|
$this->text($instr);
|
||||||
common_element_end('p');
|
$this->elementEnd('p');
|
||||||
common_element_end('div');
|
$this->elementEnd('div');
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_title()
|
function get_title()
|
||||||
|
@ -36,7 +36,7 @@ class PostnoticeAction extends Action
|
|||||||
print "omb_version=".OMB_VERSION_01;
|
print "omb_version=".OMB_VERSION_01;
|
||||||
}
|
}
|
||||||
} catch (OAuthException $e) {
|
} catch (OAuthException $e) {
|
||||||
common_server_error($e->getMessage());
|
$this->serverError($e->getMessage());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -45,36 +45,36 @@ class PostnoticeAction extends Action
|
|||||||
{
|
{
|
||||||
$version = $req->get_parameter('omb_version');
|
$version = $req->get_parameter('omb_version');
|
||||||
if ($version != OMB_VERSION_01) {
|
if ($version != OMB_VERSION_01) {
|
||||||
common_user_error(_('Unsupported OMB version'), 400);
|
$this->clientError(_('Unsupported OMB version'), 400);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
# First, check to see
|
# First, check to see
|
||||||
$listenee = $req->get_parameter('omb_listenee');
|
$listenee = $req->get_parameter('omb_listenee');
|
||||||
$remote_profile = Remote_profile::staticGet('uri', $listenee);
|
$remote_profile = Remote_profile::staticGet('uri', $listenee);
|
||||||
if (!$remote_profile) {
|
if (!$remote_profile) {
|
||||||
common_user_error(_('Profile unknown'), 403);
|
$this->clientError(_('Profile unknown'), 403);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$sub = Subscription::staticGet('token', $token->key);
|
$sub = Subscription::staticGet('token', $token->key);
|
||||||
if (!$sub) {
|
if (!$sub) {
|
||||||
common_user_error(_('No such subscription'), 403);
|
$this->clientError(_('No such subscription'), 403);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$content = $req->get_parameter('omb_notice_content');
|
$content = $req->get_parameter('omb_notice_content');
|
||||||
$content_shortened = common_shorten_links($content);
|
$content_shortened = common_shorten_links($content);
|
||||||
if (mb_strlen($content_shortened) > 140) {
|
if (mb_strlen($content_shortened) > 140) {
|
||||||
common_user_error(_('Invalid notice content'), 400);
|
$this->clientError(_('Invalid notice content'), 400);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$notice_uri = $req->get_parameter('omb_notice');
|
$notice_uri = $req->get_parameter('omb_notice');
|
||||||
if (!Validate::uri($notice_uri) &&
|
if (!Validate::uri($notice_uri) &&
|
||||||
!common_valid_tag($notice_uri)) {
|
!common_valid_tag($notice_uri)) {
|
||||||
common_user_error(_('Invalid notice uri'), 400);
|
$this->clientError(_('Invalid notice uri'), 400);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$notice_url = $req->get_parameter('omb_notice_url');
|
$notice_url = $req->get_parameter('omb_notice_url');
|
||||||
if ($notice_url && !common_valid_http_url($notice_url)) {
|
if ($notice_url && !common_valid_http_url($notice_url)) {
|
||||||
common_user_error(_('Invalid notice url'), 400);
|
$this->clientError(_('Invalid notice url'), 400);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$notice = Notice::staticGet('uri', $notice_uri);
|
$notice = Notice::staticGet('uri', $notice_uri);
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/**
|
||||||
* Laconica - a distributed open-source microblogging tool
|
* Laconica, the distributed open-source microblogging tool
|
||||||
* Copyright (C) 2008, Controlez-Vous, Inc.
|
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* Change profile settings
|
||||||
|
*
|
||||||
|
* 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
|
* 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
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
@ -15,207 +18,162 @@
|
|||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* 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/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* @category Settings
|
||||||
|
* @package Laconica
|
||||||
|
* @author Evan Prodromou <evan@controlyourself.ca>
|
||||||
|
* @author Zach Copley <zach@controlyourself.ca>
|
||||||
|
* @copyright 2008-2009 Control Yourself, Inc.
|
||||||
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||||
|
* @link http://laconi.ca/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('LACONICA')) { exit(1); }
|
if (!defined('LACONICA')) {
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
require_once(INSTALLDIR.'/lib/settingsaction.php');
|
require_once INSTALLDIR.'/lib/accountsettingsaction.php';
|
||||||
|
|
||||||
class ProfilesettingsAction extends SettingsAction
|
/**
|
||||||
|
* Change profile settings
|
||||||
|
*
|
||||||
|
* @category Settings
|
||||||
|
* @package Laconica
|
||||||
|
* @author Evan Prodromou <evan@controlyourself.ca>
|
||||||
|
* @author Zach Copley <zach@controlyourself.ca>
|
||||||
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||||
|
* @link http://laconi.ca/
|
||||||
|
*/
|
||||||
|
|
||||||
|
class ProfilesettingsAction extends AccountSettingsAction
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Title of the page
|
||||||
|
*
|
||||||
|
* @return string Title of the page
|
||||||
|
*/
|
||||||
|
|
||||||
function get_instructions()
|
function title()
|
||||||
|
{
|
||||||
|
return _('Profile settings');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instructions for use
|
||||||
|
*
|
||||||
|
* @return instructions for use
|
||||||
|
*/
|
||||||
|
|
||||||
|
function getInstructions()
|
||||||
{
|
{
|
||||||
return _('You can update your personal profile info here '.
|
return _('You can update your personal profile info here '.
|
||||||
'so people know more about you.');
|
'so people know more about you.');
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_form($msg=null, $success=false)
|
/**
|
||||||
|
* Content area of the page
|
||||||
|
*
|
||||||
|
* Shows a form for uploading an avatar.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
|
function showContent()
|
||||||
{
|
{
|
||||||
$this->form_header(_('Profile settings'), $msg, $success);
|
|
||||||
$this->show_settings_form();
|
|
||||||
common_element('h2', null, _('Avatar'));
|
|
||||||
$this->show_avatar_form();
|
|
||||||
common_element('h2', null, _('Change password'));
|
|
||||||
$this->show_password_form();
|
|
||||||
// common_element('h2', null, _('Delete my account'));
|
|
||||||
// $this->show_delete_form();
|
|
||||||
common_show_footer();
|
|
||||||
}
|
|
||||||
|
|
||||||
function handle_post()
|
|
||||||
{
|
|
||||||
|
|
||||||
# CSRF protection
|
|
||||||
|
|
||||||
$token = $this->trimmed('token');
|
|
||||||
if (!$token || $token != common_session_token()) {
|
|
||||||
$this->show_form(_('There was a problem with your session token. Try again, please.'));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($this->arg('save')) {
|
|
||||||
$this->save_profile();
|
|
||||||
} else if ($this->arg('upload')) {
|
|
||||||
$this->upload_avatar();
|
|
||||||
} else if ($this->arg('crop')) {
|
|
||||||
$this->crop_avatar();
|
|
||||||
} else if ($this->arg('changepass')) {
|
|
||||||
$this->change_password();
|
|
||||||
} else {
|
|
||||||
$this->show_form(_('Unexpected form submission.'));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function show_settings_form()
|
|
||||||
{
|
|
||||||
|
|
||||||
$user = common_current_user();
|
$user = common_current_user();
|
||||||
$profile = $user->getProfile();
|
$profile = $user->getProfile();
|
||||||
|
|
||||||
common_element_start('form', array('method' => 'POST',
|
$this->elementStart('form', array('method' => 'POST',
|
||||||
'id' => 'profilesettings',
|
'id' => 'form_settings_profile',
|
||||||
|
'class' => 'form_settings',
|
||||||
'action' => common_local_url('profilesettings')));
|
'action' => common_local_url('profilesettings')));
|
||||||
common_hidden('token', common_session_token());
|
$this->elementStart('fieldset');
|
||||||
|
$this->element('legend', null, _('Profile information'));
|
||||||
|
$this->hidden('token', common_session_token());
|
||||||
|
|
||||||
# too much common patterns here... abstractable?
|
# too much common patterns here... abstractable?
|
||||||
|
|
||||||
common_input('nickname', _('Nickname'),
|
$this->elementStart('ul', 'form_data');
|
||||||
|
$this->elementStart('li');
|
||||||
|
$this->input('nickname', _('Nickname'),
|
||||||
($this->arg('nickname')) ? $this->arg('nickname') : $profile->nickname,
|
($this->arg('nickname')) ? $this->arg('nickname') : $profile->nickname,
|
||||||
_('1-64 lowercase letters or numbers, no punctuation or spaces'));
|
_('1-64 lowercase letters or numbers, no punctuation or spaces'));
|
||||||
common_input('fullname', _('Full name'),
|
$this->elementEnd('li');
|
||||||
|
$this->elementStart('li');
|
||||||
|
$this->input('fullname', _('Full name'),
|
||||||
($this->arg('fullname')) ? $this->arg('fullname') : $profile->fullname);
|
($this->arg('fullname')) ? $this->arg('fullname') : $profile->fullname);
|
||||||
common_input('homepage', _('Homepage'),
|
$this->elementEnd('li');
|
||||||
|
$this->elementStart('li');
|
||||||
|
$this->input('homepage', _('Homepage'),
|
||||||
($this->arg('homepage')) ? $this->arg('homepage') : $profile->homepage,
|
($this->arg('homepage')) ? $this->arg('homepage') : $profile->homepage,
|
||||||
_('URL of your homepage, blog, or profile on another site'));
|
_('URL of your homepage, blog, or profile on another site'));
|
||||||
common_textarea('bio', _('Bio'),
|
$this->elementEnd('li');
|
||||||
|
$this->elementStart('li');
|
||||||
|
$this->textarea('bio', _('Bio'),
|
||||||
($this->arg('bio')) ? $this->arg('bio') : $profile->bio,
|
($this->arg('bio')) ? $this->arg('bio') : $profile->bio,
|
||||||
_('Describe yourself and your interests in 140 chars'));
|
_('Describe yourself and your interests in 140 chars'));
|
||||||
common_input('location', _('Location'),
|
$this->elementEnd('li');
|
||||||
|
$this->elementStart('li');
|
||||||
|
$this->input('location', _('Location'),
|
||||||
($this->arg('location')) ? $this->arg('location') : $profile->location,
|
($this->arg('location')) ? $this->arg('location') : $profile->location,
|
||||||
_('Where you are, like "City, State (or Region), Country"'));
|
_('Where you are, like "City, State (or Region), Country"'));
|
||||||
common_input('tags', _('Tags'),
|
$this->elementEnd('li');
|
||||||
|
$this->elementStart('li');
|
||||||
|
$this->input('tags', _('Tags'),
|
||||||
($this->arg('tags')) ? $this->arg('tags') : implode(' ', $user->getSelfTags()),
|
($this->arg('tags')) ? $this->arg('tags') : implode(' ', $user->getSelfTags()),
|
||||||
_('Tags for yourself (letters, numbers, -, ., and _), comma- or space- separated'));
|
_('Tags for yourself (letters, numbers, -, ., and _), comma- or space- separated'));
|
||||||
|
$this->elementEnd('li');
|
||||||
|
$this->elementStart('li');
|
||||||
$language = common_language();
|
$language = common_language();
|
||||||
common_dropdown('language', _('Language'), get_nice_language_list(), _('Preferred language'), true, $language);
|
$this->dropdown('language', _('Language'),
|
||||||
|
get_nice_language_list(), _('Preferred language'),
|
||||||
|
true, $language);
|
||||||
|
$this->elementEnd('li');
|
||||||
$timezone = common_timezone();
|
$timezone = common_timezone();
|
||||||
$timezones = array();
|
$timezones = array();
|
||||||
foreach(DateTimeZone::listIdentifiers() as $k => $v) {
|
foreach(DateTimeZone::listIdentifiers() as $k => $v) {
|
||||||
$timezones[$v] = $v;
|
$timezones[$v] = $v;
|
||||||
}
|
}
|
||||||
common_dropdown('timezone', _('Timezone'), $timezones, _('What timezone are you normally in?'), true, $timezone);
|
$this->elementStart('li');
|
||||||
|
$this->dropdown('timezone', _('Timezone'),
|
||||||
|
$timezones, _('What timezone are you normally in?'),
|
||||||
|
true, $timezone);
|
||||||
|
$this->elementEnd('li');
|
||||||
|
$this->elementStart('li');
|
||||||
|
$this->checkbox('autosubscribe',
|
||||||
|
_('Automatically subscribe to whoever '.
|
||||||
|
'subscribes to me (best for non-humans)'),
|
||||||
|
($this->arg('autosubscribe')) ?
|
||||||
|
$this->boolean('autosubscribe') : $user->autosubscribe);
|
||||||
|
$this->elementEnd('li');
|
||||||
|
$this->elementEnd('ul');
|
||||||
|
$this->submit('save', _('Save'));
|
||||||
|
|
||||||
common_checkbox('autosubscribe', _('Automatically subscribe to whoever subscribes to me (best for non-humans)'),
|
$this->elementEnd('fieldset');
|
||||||
($this->arg('autosubscribe')) ? $this->boolean('autosubscribe') : $user->autosubscribe);
|
$this->elementEnd('form');
|
||||||
|
|
||||||
common_submit('save', _('Save'));
|
|
||||||
|
|
||||||
common_element_end('form');
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_avatar_form()
|
/**
|
||||||
|
* Handle a post
|
||||||
|
*
|
||||||
|
* Validate input and save changes. Reload the form with a success
|
||||||
|
* or error message.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
|
function handlePost()
|
||||||
{
|
{
|
||||||
|
# CSRF protection
|
||||||
|
|
||||||
$user = common_current_user();
|
$token = $this->trimmed('token');
|
||||||
$profile = $user->getProfile();
|
if (!$token || $token != common_session_token()) {
|
||||||
|
$this->showForm(_('There was a problem with your session token. '.
|
||||||
if (!$profile) {
|
'Try again, please.'));
|
||||||
common_log_db_error($user, 'SELECT', __FILE__);
|
|
||||||
$this->server_error(_('User without matching profile'));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$original = $profile->getOriginalAvatar();
|
|
||||||
|
|
||||||
|
|
||||||
common_element_start('form', array('enctype' => 'multipart/form-data',
|
|
||||||
'method' => 'POST',
|
|
||||||
'id' => 'avatar',
|
|
||||||
'action' =>
|
|
||||||
common_local_url('profilesettings')));
|
|
||||||
common_hidden('token', common_session_token());
|
|
||||||
|
|
||||||
if ($original) {
|
|
||||||
common_element_start('div', array('id'=>'avatar_original', 'class'=>'avatar_view'));
|
|
||||||
common_element('h3', null, _("Original:"));
|
|
||||||
common_element_start('div', array('id'=>'avatar_original_view'));
|
|
||||||
common_element('img', array('src' => $original->url,
|
|
||||||
'class' => 'avatar original',
|
|
||||||
'width' => $original->width,
|
|
||||||
'height' => $original->height,
|
|
||||||
'alt' => $user->nickname));
|
|
||||||
common_element_end('div');
|
|
||||||
common_element_end('div');
|
|
||||||
}
|
|
||||||
|
|
||||||
$avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE);
|
|
||||||
|
|
||||||
if ($avatar) {
|
|
||||||
common_element_start('div', array('id'=>'avatar_preview', 'class'=>'avatar_view'));
|
|
||||||
common_element('h3', null, _("Preview:"));
|
|
||||||
common_element_start('div', array('id'=>'avatar_preview_view'));
|
|
||||||
common_element('img', array('src' => $original->url,//$avatar->url,
|
|
||||||
'class' => 'avatar profile',
|
|
||||||
'width' => AVATAR_PROFILE_SIZE,
|
|
||||||
'height' => AVATAR_PROFILE_SIZE,
|
|
||||||
'alt' => $user->nickname));
|
|
||||||
common_element_end('div');
|
|
||||||
common_element_end('div');
|
|
||||||
|
|
||||||
foreach(array('avatar_crop_x', 'avatar_crop_y', 'avatar_crop_w', 'avatar_crop_h') as $crop_info) {
|
|
||||||
common_element('input', array('name' => $crop_info,
|
|
||||||
'type' => 'hidden',
|
|
||||||
'id' => $crop_info));
|
|
||||||
}
|
|
||||||
common_submit('crop', _('Crop'));
|
|
||||||
}
|
|
||||||
|
|
||||||
common_element('input', array('name' => 'MAX_FILE_SIZE',
|
|
||||||
'type' => 'hidden',
|
|
||||||
'id' => 'MAX_FILE_SIZE',
|
|
||||||
'value' => MAX_AVATAR_SIZE));
|
|
||||||
|
|
||||||
common_element_start('p');
|
|
||||||
|
|
||||||
common_element('input', array('name' => 'avatarfile',
|
|
||||||
'type' => 'file',
|
|
||||||
'id' => 'avatarfile'));
|
|
||||||
common_element_end('p');
|
|
||||||
|
|
||||||
common_submit('upload', _('Upload'));
|
|
||||||
common_element_end('form');
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function show_password_form()
|
|
||||||
{
|
|
||||||
|
|
||||||
$user = common_current_user();
|
|
||||||
common_element_start('form', array('method' => 'POST',
|
|
||||||
'id' => 'password',
|
|
||||||
'action' =>
|
|
||||||
common_local_url('profilesettings')));
|
|
||||||
|
|
||||||
common_hidden('token', common_session_token());
|
|
||||||
|
|
||||||
# Users who logged in with OpenID won't have a pwd
|
|
||||||
if ($user->password) {
|
|
||||||
common_password('oldpassword', _('Old password'));
|
|
||||||
}
|
|
||||||
common_password('newpassword', _('New password'),
|
|
||||||
_('6 or more characters'));
|
|
||||||
common_password('confirm', _('Confirm'),
|
|
||||||
_('same as password above'));
|
|
||||||
common_submit('changepass', _('Change'));
|
|
||||||
common_element_end('form');
|
|
||||||
}
|
|
||||||
|
|
||||||
function save_profile()
|
|
||||||
{
|
|
||||||
$nickname = $this->trimmed('nickname');
|
$nickname = $this->trimmed('nickname');
|
||||||
$fullname = $this->trimmed('fullname');
|
$fullname = $this->trimmed('fullname');
|
||||||
$homepage = $this->trimmed('homepage');
|
$homepage = $this->trimmed('homepage');
|
||||||
@ -231,32 +189,32 @@ class ProfilesettingsAction extends SettingsAction
|
|||||||
if (!Validate::string($nickname, array('min_length' => 1,
|
if (!Validate::string($nickname, array('min_length' => 1,
|
||||||
'max_length' => 64,
|
'max_length' => 64,
|
||||||
'format' => VALIDATE_NUM . VALIDATE_ALPHA_LOWER))) {
|
'format' => VALIDATE_NUM . VALIDATE_ALPHA_LOWER))) {
|
||||||
$this->show_form(_('Nickname must have only lowercase letters and numbers and no spaces.'));
|
$this->showForm(_('Nickname must have only lowercase letters and numbers and no spaces.'));
|
||||||
return;
|
return;
|
||||||
} else if (!User::allowed_nickname($nickname)) {
|
} else if (!User::allowed_nickname($nickname)) {
|
||||||
$this->show_form(_('Not a valid nickname.'));
|
$this->showForm(_('Not a valid nickname.'));
|
||||||
return;
|
return;
|
||||||
} else if (!is_null($homepage) && (strlen($homepage) > 0) &&
|
} else if (!is_null($homepage) && (strlen($homepage) > 0) &&
|
||||||
!Validate::uri($homepage, array('allowed_schemes' => array('http', 'https')))) {
|
!Validate::uri($homepage, array('allowed_schemes' => array('http', 'https')))) {
|
||||||
$this->show_form(_('Homepage is not a valid URL.'));
|
$this->showForm(_('Homepage is not a valid URL.'));
|
||||||
return;
|
return;
|
||||||
} else if (!is_null($fullname) && strlen($fullname) > 255) {
|
} else if (!is_null($fullname) && strlen($fullname) > 255) {
|
||||||
$this->show_form(_('Full name is too long (max 255 chars).'));
|
$this->showForm(_('Full name is too long (max 255 chars).'));
|
||||||
return;
|
return;
|
||||||
} else if (!is_null($bio) && strlen($bio) > 140) {
|
} else if (!is_null($bio) && strlen($bio) > 140) {
|
||||||
$this->show_form(_('Bio is too long (max 140 chars).'));
|
$this->showForm(_('Bio is too long (max 140 chars).'));
|
||||||
return;
|
return;
|
||||||
} else if (!is_null($location) && strlen($location) > 255) {
|
} else if (!is_null($location) && strlen($location) > 255) {
|
||||||
$this->show_form(_('Location is too long (max 255 chars).'));
|
$this->showForm(_('Location is too long (max 255 chars).'));
|
||||||
return;
|
return;
|
||||||
} else if (is_null($timezone) || !in_array($timezone, DateTimeZone::listIdentifiers())) {
|
} else if (is_null($timezone) || !in_array($timezone, DateTimeZone::listIdentifiers())) {
|
||||||
$this->show_form(_('Timezone not selected.'));
|
$this->showForm(_('Timezone not selected.'));
|
||||||
return;
|
return;
|
||||||
} else if ($this->nickname_exists($nickname)) {
|
} else if ($this->nicknameExists($nickname)) {
|
||||||
$this->show_form(_('Nickname already in use. Try another one.'));
|
$this->showForm(_('Nickname already in use. Try another one.'));
|
||||||
return;
|
return;
|
||||||
} else if (!is_null($language) && strlen($language) > 50) {
|
} else if (!is_null($language) && strlen($language) > 50) {
|
||||||
$this->show_form(_('Language is too long (max 50 chars).'));
|
$this->showForm(_('Language is too long (max 50 chars).'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -268,7 +226,7 @@ class ProfilesettingsAction extends SettingsAction
|
|||||||
|
|
||||||
foreach ($tags as $tag) {
|
foreach ($tags as $tag) {
|
||||||
if (!common_valid_profile_tag($tag)) {
|
if (!common_valid_profile_tag($tag)) {
|
||||||
$this->show_form(sprintf(_('Invalid tag: "%s"'), $tag));
|
$this->showForm(sprintf(_('Invalid tag: "%s"'), $tag));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -298,7 +256,7 @@ class ProfilesettingsAction extends SettingsAction
|
|||||||
|
|
||||||
if ($result === false) {
|
if ($result === false) {
|
||||||
common_log_db_error($user, 'UPDATE', __FILE__);
|
common_log_db_error($user, 'UPDATE', __FILE__);
|
||||||
common_server_error(_('Couldn\'t update user.'));
|
$this->serverError(_('Couldn\'t update user.'));
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
# Re-initialize language environment if it changed
|
# Re-initialize language environment if it changed
|
||||||
@ -318,7 +276,7 @@ class ProfilesettingsAction extends SettingsAction
|
|||||||
|
|
||||||
if ($result === false) {
|
if ($result === false) {
|
||||||
common_log_db_error($user, 'UPDATE', __FILE__);
|
common_log_db_error($user, 'UPDATE', __FILE__);
|
||||||
common_server_error(_('Couldn\'t update user for autosubscribe.'));
|
$this->serverError(_('Couldn\'t update user for autosubscribe.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -341,7 +299,7 @@ class ProfilesettingsAction extends SettingsAction
|
|||||||
|
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
common_log_db_error($profile, 'UPDATE', __FILE__);
|
common_log_db_error($profile, 'UPDATE', __FILE__);
|
||||||
common_server_error(_('Couldn\'t save profile.'));
|
$this->serverError(_('Couldn\'t save profile.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -350,7 +308,7 @@ class ProfilesettingsAction extends SettingsAction
|
|||||||
$result = $user->setSelfTags($tags);
|
$result = $user->setSelfTags($tags);
|
||||||
|
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
common_server_error(_('Couldn\'t save tags.'));
|
$this->serverError(_('Couldn\'t save tags.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -358,76 +316,10 @@ class ProfilesettingsAction extends SettingsAction
|
|||||||
|
|
||||||
common_broadcast_profile($profile);
|
common_broadcast_profile($profile);
|
||||||
|
|
||||||
$this->show_form(_('Settings saved.'), true);
|
$this->showForm(_('Settings saved.'), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function nicknameExists($nickname)
|
||||||
function upload_avatar()
|
|
||||||
{
|
|
||||||
switch ($_FILES['avatarfile']['error']) {
|
|
||||||
case UPLOAD_ERR_OK: # success, jump out
|
|
||||||
break;
|
|
||||||
case UPLOAD_ERR_INI_SIZE:
|
|
||||||
case UPLOAD_ERR_FORM_SIZE:
|
|
||||||
$this->show_form(_('That file is too big.'));
|
|
||||||
return;
|
|
||||||
case UPLOAD_ERR_PARTIAL:
|
|
||||||
@unlink($_FILES['avatarfile']['tmp_name']);
|
|
||||||
$this->show_form(_('Partial upload.'));
|
|
||||||
return;
|
|
||||||
default:
|
|
||||||
$this->show_form(_('System error uploading file.'));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$info = @getimagesize($_FILES['avatarfile']['tmp_name']);
|
|
||||||
|
|
||||||
if (!$info) {
|
|
||||||
@unlink($_FILES['avatarfile']['tmp_name']);
|
|
||||||
$this->show_form(_('Not an image or corrupt file.'));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch ($info[2]) {
|
|
||||||
case IMAGETYPE_GIF:
|
|
||||||
case IMAGETYPE_JPEG:
|
|
||||||
case IMAGETYPE_PNG:
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
$this->show_form(_('Unsupported image file format.'));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$user = common_current_user();
|
|
||||||
$profile = $user->getProfile();
|
|
||||||
|
|
||||||
if ($profile->setOriginal($_FILES['avatarfile']['tmp_name'])) {
|
|
||||||
$this->show_form(_('Avatar updated.'), true);
|
|
||||||
} else {
|
|
||||||
$this->show_form(_('Failed updating avatar.'));
|
|
||||||
}
|
|
||||||
|
|
||||||
@unlink($_FILES['avatarfile']['tmp_name']);
|
|
||||||
}
|
|
||||||
|
|
||||||
function crop_avatar() {
|
|
||||||
|
|
||||||
$user = common_current_user();
|
|
||||||
$profile = $user->getProfile();
|
|
||||||
|
|
||||||
$x = $this->arg('avatar_crop_x');
|
|
||||||
$y = $this->arg('avatar_crop_y');
|
|
||||||
$w = $this->arg('avatar_crop_w');
|
|
||||||
$h = $this->arg('avatar_crop_h');
|
|
||||||
|
|
||||||
if ($profile->crop_avatars($x, $y, $w, $h)) {
|
|
||||||
$this->show_form(_('Avatar updated.'), true);
|
|
||||||
} else {
|
|
||||||
$this->show_form(_('Failed updating avatar.'));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function nickname_exists($nickname)
|
|
||||||
{
|
{
|
||||||
$user = common_current_user();
|
$user = common_current_user();
|
||||||
$other = User::staticGet('nickname', $nickname);
|
$other = User::staticGet('nickname', $nickname);
|
||||||
@ -437,48 +329,4 @@ class ProfilesettingsAction extends SettingsAction
|
|||||||
return $other->id != $user->id;
|
return $other->id != $user->id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function change_password()
|
|
||||||
{
|
|
||||||
|
|
||||||
$user = common_current_user();
|
|
||||||
assert(!is_null($user)); # should already be checked
|
|
||||||
|
|
||||||
# FIXME: scrub input
|
|
||||||
|
|
||||||
$newpassword = $this->arg('newpassword');
|
|
||||||
$confirm = $this->arg('confirm');
|
|
||||||
$token = $this->arg('token');
|
|
||||||
|
|
||||||
if (0 != strcmp($newpassword, $confirm)) {
|
|
||||||
$this->show_form(_('Passwords don\'t match.'));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($user->password) {
|
|
||||||
$oldpassword = $this->arg('oldpassword');
|
|
||||||
|
|
||||||
if (!common_check_user($user->nickname, $oldpassword)) {
|
|
||||||
$this->show_form(_('Incorrect old password'));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$original = clone($user);
|
|
||||||
|
|
||||||
$user->password = common_munge_password($newpassword, $user->id);
|
|
||||||
|
|
||||||
$val = $user->validate();
|
|
||||||
if ($val !== true) {
|
|
||||||
$this->show_form(_('Error saving user; invalid.'));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!$user->update($original)) {
|
|
||||||
common_server_error(_('Can\'t save new password.'));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->show_form(_('Password saved.'), true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/**
|
||||||
* Laconica - a distributed open-source microblogging tool
|
* Laconica, the distributed open-source microblogging tool
|
||||||
* Copyright (C) 2008, Controlez-Vous, Inc.
|
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* Action for displaying the public stream
|
||||||
|
*
|
||||||
|
* 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
|
* 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
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
@ -15,91 +18,183 @@
|
|||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* 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/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* @category Public
|
||||||
|
* @package Laconica
|
||||||
|
* @author Evan Prodromou <evan@controlyourself.ca>
|
||||||
|
* @copyright 2008-2009 Control Yourself, Inc.
|
||||||
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||||
|
* @link http://laconi.ca/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('LACONICA')) { exit(1); }
|
if (!defined('LACONICA')) {
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
require_once(INSTALLDIR.'/lib/stream.php');
|
require_once INSTALLDIR.'/lib/publicgroupnav.php';
|
||||||
|
require_once INSTALLDIR.'/lib/noticelist.php';
|
||||||
|
require_once INSTALLDIR.'/lib/feedlist.php';
|
||||||
|
|
||||||
class PublicAction extends StreamAction
|
/**
|
||||||
|
* Action for displaying the public stream
|
||||||
|
*
|
||||||
|
* @category Public
|
||||||
|
* @package Laconica
|
||||||
|
* @author Evan Prodromou <evan@controlyourself.ca>
|
||||||
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||||
|
* @link http://laconi.ca/
|
||||||
|
*
|
||||||
|
* @see PublicrssAction
|
||||||
|
* @see PublicxrdsAction
|
||||||
|
*/
|
||||||
|
|
||||||
|
class PublicAction extends Action
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* page of the stream we're on; default = 1
|
||||||
|
*/
|
||||||
|
|
||||||
|
var $page = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Read and validate arguments
|
||||||
|
*
|
||||||
|
* @param array $args URL parameters
|
||||||
|
*
|
||||||
|
* @return boolean success value
|
||||||
|
*/
|
||||||
|
|
||||||
|
function prepare($args)
|
||||||
|
{
|
||||||
|
parent::prepare($args);
|
||||||
|
$this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* handle request
|
||||||
|
*
|
||||||
|
* Show the public stream, using recipe method showPage()
|
||||||
|
*
|
||||||
|
* @param array $args arguments, mostly unused
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
function handle($args)
|
function handle($args)
|
||||||
{
|
{
|
||||||
parent::handle($args);
|
parent::handle($args);
|
||||||
|
|
||||||
$page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
|
|
||||||
|
|
||||||
header('X-XRDS-Location: '. common_local_url('publicxrds'));
|
header('X-XRDS-Location: '. common_local_url('publicxrds'));
|
||||||
|
|
||||||
common_show_header(_('Public timeline'),
|
$this->showPage();
|
||||||
array($this, 'show_header'), null,
|
|
||||||
array($this, 'show_top'));
|
|
||||||
|
|
||||||
# XXX: Public sidebar here?
|
|
||||||
|
|
||||||
$this->show_notices($page);
|
|
||||||
|
|
||||||
common_show_footer();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_top()
|
/**
|
||||||
|
* Title of the page
|
||||||
|
*
|
||||||
|
* @return page title, including page number if over 1
|
||||||
|
*/
|
||||||
|
|
||||||
|
function title()
|
||||||
{
|
{
|
||||||
if (common_logged_in()) {
|
if ($this->page > 1) {
|
||||||
common_notice_form('public');
|
return sprintf(_('Public timeline, page %d'), $this->page);
|
||||||
} else {
|
} else {
|
||||||
$instr = $this->get_instructions();
|
return _('Public timeline');
|
||||||
$output = common_markup_to_html($instr);
|
}
|
||||||
common_element_start('div', 'instructions');
|
|
||||||
common_raw($output);
|
|
||||||
common_element_end('div');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->public_views_menu();
|
/**
|
||||||
|
* Output <head> elements for RSS and Atom feeds
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
$this->show_feeds_list(array(0=>array('href'=>common_local_url('publicrss'),
|
function showFeeds()
|
||||||
|
{
|
||||||
|
$this->element('link', array('rel' => 'alternate',
|
||||||
|
'href' => common_local_url('publicrss'),
|
||||||
|
'type' => 'application/rss+xml',
|
||||||
|
'title' => _('Public Stream Feed')));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extra head elements
|
||||||
|
*
|
||||||
|
* We include a <meta> element linking to the publicxrds page, for OpenID
|
||||||
|
* client-side authentication.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
|
function extraHead()
|
||||||
|
{
|
||||||
|
// for client side of OpenID authentication
|
||||||
|
$this->element('meta', array('http-equiv' => 'X-XRDS-Location',
|
||||||
|
'content' => common_local_url('publicxrds')));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show tabset for this page
|
||||||
|
*
|
||||||
|
* Uses the PublicGroupNav widget
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @see PublicGroupNav
|
||||||
|
*/
|
||||||
|
|
||||||
|
function showLocalNav()
|
||||||
|
{
|
||||||
|
$nav = new PublicGroupNav($this);
|
||||||
|
$nav->show();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fill the content area
|
||||||
|
*
|
||||||
|
* Shows a list of the notices in the public stream, with some pagination
|
||||||
|
* controls.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
|
function showContent()
|
||||||
|
{
|
||||||
|
$notice = Notice::publicStream(($this->page-1)*NOTICES_PER_PAGE,
|
||||||
|
NOTICES_PER_PAGE + 1);
|
||||||
|
|
||||||
|
if (!$notice) {
|
||||||
|
$this->serverError(_('Could not retrieve public stream.'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$nl = new NoticeList($notice, $this);
|
||||||
|
|
||||||
|
$cnt = $nl->show();
|
||||||
|
|
||||||
|
$this->pagination($this->page > 1, $cnt > NOTICES_PER_PAGE,
|
||||||
|
$this->page, 'public');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Makes a list of exported feeds for this page
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
* @todo I18N
|
||||||
|
*/
|
||||||
|
|
||||||
|
function showExportData()
|
||||||
|
{
|
||||||
|
$fl = new FeedList($this);
|
||||||
|
$fl->show(array(0 => array('href' => common_local_url('publicrss'),
|
||||||
'type' => 'rss',
|
'type' => 'rss',
|
||||||
'version' => 'RSS 1.0',
|
'version' => 'RSS 1.0',
|
||||||
'item' => 'publicrss'),
|
'item' => 'publicrss'),
|
||||||
1=>array('href'=>common_local_url('publicatom'),
|
1 => array('href' => common_local_url('publicatom'),
|
||||||
'type' => 'atom',
|
'type' => 'atom',
|
||||||
'version' => 'Atom 1.0',
|
'version' => 'Atom 1.0',
|
||||||
'item' => 'publicatom')));
|
'item' => 'publicatom')));
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_instructions()
|
|
||||||
{
|
|
||||||
return _('This is %%site.name%%, a [micro-blogging](http://en.wikipedia.org/wiki/Micro-blogging) service ' .
|
|
||||||
'based on the Free Software [Laconica](http://laconi.ca/) tool. ' .
|
|
||||||
'[Join now](%%action.register%%) to share notices about yourself with friends, family, and colleagues! ([Read more](%%doc.help%%))');
|
|
||||||
}
|
|
||||||
|
|
||||||
function show_header()
|
|
||||||
{
|
|
||||||
common_element('link', array('rel' => 'alternate',
|
|
||||||
'href' => common_local_url('publicrss'),
|
|
||||||
'type' => 'application/rss+xml',
|
|
||||||
'title' => _('Public Stream Feed')));
|
|
||||||
# for client side of OpenID authentication
|
|
||||||
common_element('meta', array('http-equiv' => 'X-XRDS-Location',
|
|
||||||
'content' => common_local_url('publicxrds')));
|
|
||||||
}
|
|
||||||
|
|
||||||
function show_notices($page)
|
|
||||||
{
|
|
||||||
|
|
||||||
$cnt = 0;
|
|
||||||
$notice = Notice::publicStream(($page-1)*NOTICES_PER_PAGE,
|
|
||||||
NOTICES_PER_PAGE + 1);
|
|
||||||
|
|
||||||
if (!$notice) {
|
|
||||||
$this->server_error(_('Could not retrieve public stream.'));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$cnt = $this->show_notice_list($notice);
|
|
||||||
|
|
||||||
common_pagination($page > 1, $cnt > NOTICES_PER_PAGE,
|
|
||||||
$page, 'public');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,17 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
|
||||||
|
/**
|
||||||
|
* Public RSS action class.
|
||||||
|
*
|
||||||
|
* PHP version 5
|
||||||
|
*
|
||||||
|
* @category Action
|
||||||
|
* @package Laconica
|
||||||
|
* @author Evan Prodromou <evan@controlyourself.ca>
|
||||||
|
* @author Robin Millette <millette@controlyourself.ca>
|
||||||
|
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
|
||||||
|
* @link http://laconi.ca/
|
||||||
|
*
|
||||||
* Laconica - a distributed open-source microblogging tool
|
* Laconica - a distributed open-source microblogging tool
|
||||||
* Copyright (C) 2008, Controlez-Vous, Inc.
|
* Copyright (C) 2008, Controlez-Vous, Inc.
|
||||||
*
|
*
|
||||||
@ -17,27 +29,45 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('LACONICA')) { exit(1); }
|
if (!defined('LACONICA')) {
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
require_once(INSTALLDIR.'/lib/rssaction.php');
|
require_once INSTALLDIR.'/lib/rssaction.php';
|
||||||
|
|
||||||
// Formatting of RSS handled by Rss10Action
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Formatting of RSS handled by Rss10Action
|
||||||
|
*
|
||||||
|
* @category Action
|
||||||
|
* @package Laconica
|
||||||
|
* @author Evan Prodromou <evan@controlyourself.ca>
|
||||||
|
* @author Robin Millette <millette@controlyourself.ca>
|
||||||
|
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
|
||||||
|
* @link http://laconi.ca/
|
||||||
|
*/
|
||||||
class PublicrssAction extends Rss10Action
|
class PublicrssAction extends Rss10Action
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Initialization.
|
||||||
|
*
|
||||||
|
* @return boolean true
|
||||||
|
*/
|
||||||
function init()
|
function init()
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_notices($limit=0)
|
/**
|
||||||
|
* Get notices
|
||||||
|
*
|
||||||
|
* @param integer $limit max number of notices to return
|
||||||
|
*
|
||||||
|
* @return array notices
|
||||||
|
*/
|
||||||
|
function getNotices($limit=0)
|
||||||
{
|
{
|
||||||
|
|
||||||
$notices = array();
|
$notices = array();
|
||||||
|
|
||||||
$notice = Notice::publicStream(0, ($limit == 0) ? 48 : $limit);
|
$notice = Notice::publicStream(0, ($limit == 0) ? 48 : $limit);
|
||||||
|
|
||||||
while ($notice->fetch()) {
|
while ($notice->fetch()) {
|
||||||
$notices[] = clone($notice);
|
$notices[] = clone($notice);
|
||||||
}
|
}
|
||||||
@ -45,18 +75,30 @@ class PublicrssAction extends Rss10Action
|
|||||||
return $notices;
|
return $notices;
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_channel()
|
/**
|
||||||
|
* Get channel.
|
||||||
|
*
|
||||||
|
* @return array associative array on channel information
|
||||||
|
*/
|
||||||
|
function getChannel()
|
||||||
{
|
{
|
||||||
global $config;
|
global $config;
|
||||||
$c = array('url' => common_local_url('publicrss'),
|
$c = array(
|
||||||
'title' => sprintf(_('%s Public Stream'), $config['site']['name']),
|
'url' => common_local_url('publicrss')
|
||||||
'link' => common_local_url('public'),
|
, 'title' => sprintf(_('%s Public Stream'), $config['site']['name'])
|
||||||
'description' => sprintf(_('All updates for %s'), $config['site']['name']));
|
, 'link' => common_local_url('public')
|
||||||
|
, 'description' => sprintf(_('All updates for %s'), $config['site']['name']));
|
||||||
return $c;
|
return $c;
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_image()
|
/**
|
||||||
|
* Get image.
|
||||||
|
*
|
||||||
|
* @return nothing
|
||||||
|
*/
|
||||||
|
function getImage()
|
||||||
{
|
{
|
||||||
return null;
|
// nop
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
149
actions/publictagcloud.php
Normal file
149
actions/publictagcloud.php
Normal file
@ -0,0 +1,149 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Laconica, the distributed open-source microblogging tool
|
||||||
|
*
|
||||||
|
* Public tag cloud for notices
|
||||||
|
*
|
||||||
|
* 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 Public
|
||||||
|
* @package Laconica
|
||||||
|
* @author Mike Cochrane <mikec@mikenz.geek.nz>
|
||||||
|
* @author Evan Prodromou <evan@controlyourself.ca>
|
||||||
|
* @copyright 2008 Mike Cochrane
|
||||||
|
* @copyright 2008-2009 Control Yourself, Inc.
|
||||||
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||||
|
* @link http://laconi.ca/
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (!defined('LACONICA')) { exit(1); }
|
||||||
|
|
||||||
|
define('TAGS_PER_PAGE', 100);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Public tag cloud for notices
|
||||||
|
*
|
||||||
|
* @category Personal
|
||||||
|
* @package Laconica
|
||||||
|
* @author Mike Cochrane <mikec@mikenz.geek.nz>
|
||||||
|
* @author Evan Prodromou <evan@controlyourself.ca>
|
||||||
|
* @copyright 2008 Mike Cochrane
|
||||||
|
* @copyright 2008-2009 Control Yourself, Inc.
|
||||||
|
* @link http://laconi.ca/
|
||||||
|
*/
|
||||||
|
|
||||||
|
class PublictagcloudAction extends Action
|
||||||
|
{
|
||||||
|
function isReadOnly()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function title()
|
||||||
|
{
|
||||||
|
return _('Public tag cloud');
|
||||||
|
}
|
||||||
|
|
||||||
|
function showPageNotice()
|
||||||
|
{
|
||||||
|
$this->element('p', 'instructions',
|
||||||
|
sprintf(_('These are most popular recent tags on %s '),
|
||||||
|
common_config('site', 'name')));
|
||||||
|
}
|
||||||
|
|
||||||
|
function showLocalNav()
|
||||||
|
{
|
||||||
|
$nav = new PublicGroupNav($this);
|
||||||
|
$nav->show();
|
||||||
|
}
|
||||||
|
|
||||||
|
function handle($args)
|
||||||
|
{
|
||||||
|
parent::handle($args);
|
||||||
|
$this->showPage();
|
||||||
|
}
|
||||||
|
|
||||||
|
function showContent()
|
||||||
|
{
|
||||||
|
# This should probably be cached rather than recalculated
|
||||||
|
$tags = new Notice_tag();
|
||||||
|
|
||||||
|
#Need to clear the selection and then only re-add the field
|
||||||
|
#we are grouping by, otherwise it's not a valid 'group by'
|
||||||
|
#even though MySQL seems to let it slide...
|
||||||
|
$tags->selectAdd();
|
||||||
|
$tags->selectAdd('tag');
|
||||||
|
|
||||||
|
#Add the aggregated columns...
|
||||||
|
$tags->selectAdd('max(notice_id) as last_notice_id');
|
||||||
|
if(common_config('db','type')=='pgsql') {
|
||||||
|
$calc='sum(exp(-extract(epoch from (now()-created))/%s)) as weight';
|
||||||
|
} else {
|
||||||
|
$calc='sum(exp(-(now() - created)/%s)) as weight';
|
||||||
|
}
|
||||||
|
$tags->selectAdd(sprintf($calc, common_config('tag', 'dropoff')));
|
||||||
|
$tags->groupBy('tag');
|
||||||
|
$tags->orderBy('weight DESC');
|
||||||
|
|
||||||
|
$tags->limit(TAGS_PER_PAGE);
|
||||||
|
|
||||||
|
$cnt = $tags->find();
|
||||||
|
|
||||||
|
if ($cnt > 0) {
|
||||||
|
$this->elementStart('p', 'tagcloud');
|
||||||
|
|
||||||
|
$tw = array();
|
||||||
|
$sum = 0;
|
||||||
|
while ($tags->fetch()) {
|
||||||
|
$tw[$tags->tag] = $tags->weight;
|
||||||
|
$sum += $tags->weight;
|
||||||
|
}
|
||||||
|
|
||||||
|
ksort($tw);
|
||||||
|
|
||||||
|
foreach ($tw as $tag => $weight) {
|
||||||
|
$this->showTag($tag, $weight, $weight/$sum);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->elementEnd('p');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function showTag($tag, $weight, $relative)
|
||||||
|
{
|
||||||
|
# XXX: these should probably tune to the size of the site
|
||||||
|
if ($relative > 0.1) {
|
||||||
|
$cls = 'largest';
|
||||||
|
} else if ($relative > 0.05) {
|
||||||
|
$cls = 'verylarge';
|
||||||
|
} else if ($relative > 0.02) {
|
||||||
|
$cls = 'large';
|
||||||
|
} else if ($relative > 0.01) {
|
||||||
|
$cls = 'medium';
|
||||||
|
} else if ($relative > 0.005) {
|
||||||
|
$cls = 'small';
|
||||||
|
} else if ($relative > 0.002) {
|
||||||
|
$cls = 'verysmall';
|
||||||
|
} else {
|
||||||
|
$cls = 'smallest';
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->element('a', array('class' => "$cls weight-$weight relative-$relative",
|
||||||
|
'href' => common_local_url('tag', array('tag' => $tag))),
|
||||||
|
$tag);
|
||||||
|
$this->text(' ');
|
||||||
|
}
|
||||||
|
}
|
@ -26,7 +26,7 @@ require_once(INSTALLDIR.'/lib/openid.php');
|
|||||||
class PublicxrdsAction extends Action
|
class PublicxrdsAction extends Action
|
||||||
{
|
{
|
||||||
|
|
||||||
function is_readonly()
|
function isReadOnly()
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -39,45 +39,45 @@ class PublicxrdsAction extends Action
|
|||||||
header('Content-Type: application/xrds+xml');
|
header('Content-Type: application/xrds+xml');
|
||||||
|
|
||||||
common_start_xml();
|
common_start_xml();
|
||||||
common_element_start('XRDS', array('xmlns' => 'xri://$xrds'));
|
$this->elementStart('XRDS', array('xmlns' => 'xri://$xrds'));
|
||||||
|
|
||||||
common_element_start('XRD', array('xmlns' => 'xri://$xrd*($v*2.0)',
|
$this->elementStart('XRD', array('xmlns' => 'xri://$xrd*($v*2.0)',
|
||||||
'xmlns:simple' => 'http://xrds-simple.net/core/1.0',
|
'xmlns:simple' => 'http://xrds-simple.net/core/1.0',
|
||||||
'version' => '2.0'));
|
'version' => '2.0'));
|
||||||
|
|
||||||
common_element('Type', null, 'xri://$xrds*simple');
|
$this->element('Type', null, 'xri://$xrds*simple');
|
||||||
|
|
||||||
foreach (array('finishopenidlogin', 'finishaddopenid', 'finishimmediate') as $finish) {
|
foreach (array('finishopenidlogin', 'finishaddopenid', 'finishimmediate') as $finish) {
|
||||||
$this->show_service(Auth_OpenID_RP_RETURN_TO_URL_TYPE,
|
$this->show_service(Auth_OpenID_RP_RETURN_TO_URL_TYPE,
|
||||||
common_local_url($finish));
|
common_local_url($finish));
|
||||||
}
|
}
|
||||||
|
|
||||||
common_element_end('XRD');
|
$this->elementEnd('XRD');
|
||||||
|
|
||||||
common_element_end('XRDS');
|
$this->elementEnd('XRDS');
|
||||||
common_end_xml();
|
common_end_xml();
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_service($type, $uri, $params=null, $sigs=null, $localId=null)
|
function show_service($type, $uri, $params=null, $sigs=null, $localId=null)
|
||||||
{
|
{
|
||||||
common_element_start('Service');
|
$this->elementStart('Service');
|
||||||
if ($uri) {
|
if ($uri) {
|
||||||
common_element('URI', null, $uri);
|
$this->element('URI', null, $uri);
|
||||||
}
|
}
|
||||||
common_element('Type', null, $type);
|
$this->element('Type', null, $type);
|
||||||
if ($params) {
|
if ($params) {
|
||||||
foreach ($params as $param) {
|
foreach ($params as $param) {
|
||||||
common_element('Type', null, $param);
|
$this->element('Type', null, $param);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($sigs) {
|
if ($sigs) {
|
||||||
foreach ($sigs as $sig) {
|
foreach ($sigs as $sig) {
|
||||||
common_element('Type', null, $sig);
|
$this->element('Type', null, $sig);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($localId) {
|
if ($localId) {
|
||||||
common_element('LocalID', null, $localId);
|
$this->element('LocalID', null, $localId);
|
||||||
}
|
}
|
||||||
common_element_end('Service');
|
$this->elementEnd('Service');
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -30,7 +30,7 @@ class RecoverpasswordAction extends Action
|
|||||||
{
|
{
|
||||||
parent::handle($args);
|
parent::handle($args);
|
||||||
if (common_logged_in()) {
|
if (common_logged_in()) {
|
||||||
$this->client_error(_('You are already logged in!'));
|
$this->clientError(_('You are already logged in!'));
|
||||||
return;
|
return;
|
||||||
} else if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
} else if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||||
if ($this->arg('recover')) {
|
if ($this->arg('recover')) {
|
||||||
@ -38,7 +38,7 @@ class RecoverpasswordAction extends Action
|
|||||||
} else if ($this->arg('reset')) {
|
} else if ($this->arg('reset')) {
|
||||||
$this->reset_password();
|
$this->reset_password();
|
||||||
} else {
|
} else {
|
||||||
$this->client_error(_('Unexpected form submission.'));
|
$this->clientError(_('Unexpected form submission.'));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if ($this->trimmed('code')) {
|
if ($this->trimmed('code')) {
|
||||||
@ -56,18 +56,18 @@ class RecoverpasswordAction extends Action
|
|||||||
$confirm = Confirm_address::staticGet('code', $code);
|
$confirm = Confirm_address::staticGet('code', $code);
|
||||||
|
|
||||||
if (!$confirm) {
|
if (!$confirm) {
|
||||||
$this->client_error(_('No such recovery code.'));
|
$this->clientError(_('No such recovery code.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ($confirm->address_type != 'recover') {
|
if ($confirm->address_type != 'recover') {
|
||||||
$this->client_error(_('Not a recovery code.'));
|
$this->clientError(_('Not a recovery code.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$user = User::staticGet($confirm->user_id);
|
$user = User::staticGet($confirm->user_id);
|
||||||
|
|
||||||
if (!$user) {
|
if (!$user) {
|
||||||
$this->server_error(_('Recovery code for unknown user.'));
|
$this->serverError(_('Recovery code for unknown user.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,7 +80,7 @@ class RecoverpasswordAction extends Action
|
|||||||
|
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
common_log_db_error($confirm, 'DELETE', __FILE__);
|
common_log_db_error($confirm, 'DELETE', __FILE__);
|
||||||
common_server_error(_('Error with confirmation code.'));
|
$this->serverError(_('Error with confirmation code.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,7 +91,7 @@ class RecoverpasswordAction extends Action
|
|||||||
common_log(LOG_WARNING,
|
common_log(LOG_WARNING,
|
||||||
'Attempted redemption on recovery code ' .
|
'Attempted redemption on recovery code ' .
|
||||||
'that is ' . $touched . ' seconds old. ');
|
'that is ' . $touched . ' seconds old. ');
|
||||||
$this->client_error(_('This confirmation code is too old. ' .
|
$this->clientError(_('This confirmation code is too old. ' .
|
||||||
'Please start again.'));
|
'Please start again.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -105,7 +105,7 @@ class RecoverpasswordAction extends Action
|
|||||||
$result = $user->updateKeys($orig);
|
$result = $user->updateKeys($orig);
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
common_log_db_error($user, 'UPDATE', __FILE__);
|
common_log_db_error($user, 'UPDATE', __FILE__);
|
||||||
$this->server_error(_('Could not update user with confirmed email address.'));
|
$this->serverError(_('Could not update user with confirmed email address.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -141,24 +141,24 @@ class RecoverpasswordAction extends Action
|
|||||||
function show_top($msg=null)
|
function show_top($msg=null)
|
||||||
{
|
{
|
||||||
if ($msg) {
|
if ($msg) {
|
||||||
common_element('div', 'error', $msg);
|
$this->element('div', 'error', $msg);
|
||||||
} else {
|
} else {
|
||||||
common_element_start('div', 'instructions');
|
$this->elementStart('div', 'instructions');
|
||||||
common_element('p', null,
|
$this->element('p', null,
|
||||||
_('If you\'ve forgotten or lost your' .
|
_('If you\'ve forgotten or lost your' .
|
||||||
' password, you can get a new one sent to' .
|
' password, you can get a new one sent to' .
|
||||||
' the email address you have stored ' .
|
' the email address you have stored ' .
|
||||||
' in your account.'));
|
' in your account.'));
|
||||||
common_element_end('div');
|
$this->elementEnd('div');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_password_top($msg=null)
|
function show_password_top($msg=null)
|
||||||
{
|
{
|
||||||
if ($msg) {
|
if ($msg) {
|
||||||
common_element('div', 'error', $msg);
|
$this->element('div', 'error', $msg);
|
||||||
} else {
|
} else {
|
||||||
common_element('div', 'instructions',
|
$this->element('div', 'instructions',
|
||||||
_('You\'ve been identified. Enter a ' .
|
_('You\'ve been identified. Enter a ' .
|
||||||
' new password below. '));
|
' new password below. '));
|
||||||
}
|
}
|
||||||
@ -170,15 +170,15 @@ class RecoverpasswordAction extends Action
|
|||||||
common_show_header(_('Recover password'), null,
|
common_show_header(_('Recover password'), null,
|
||||||
$msg, array($this, 'show_top'));
|
$msg, array($this, 'show_top'));
|
||||||
|
|
||||||
common_element_start('form', array('method' => 'post',
|
$this->elementStart('form', array('method' => 'post',
|
||||||
'id' => 'recoverpassword',
|
'id' => 'recoverpassword',
|
||||||
'action' => common_local_url('recoverpassword')));
|
'action' => common_local_url('recoverpassword')));
|
||||||
common_input('nicknameoremail', _('Nickname or email'),
|
$this->input('nicknameoremail', _('Nickname or email'),
|
||||||
$this->trimmed('nicknameoremail'),
|
$this->trimmed('nicknameoremail'),
|
||||||
_('Your nickname on this server, ' .
|
_('Your nickname on this server, ' .
|
||||||
'or your registered email address.'));
|
'or your registered email address.'));
|
||||||
common_submit('recover', _('Recover'));
|
$this->submit('recover', _('Recover'));
|
||||||
common_element_end('form');
|
$this->elementEnd('form');
|
||||||
common_show_footer();
|
common_show_footer();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -188,16 +188,16 @@ class RecoverpasswordAction extends Action
|
|||||||
common_show_header(_('Reset password'), null,
|
common_show_header(_('Reset password'), null,
|
||||||
$msg, array($this, 'show_password_top'));
|
$msg, array($this, 'show_password_top'));
|
||||||
|
|
||||||
common_element_start('form', array('method' => 'post',
|
$this->elementStart('form', array('method' => 'post',
|
||||||
'id' => 'recoverpassword',
|
'id' => 'recoverpassword',
|
||||||
'action' => common_local_url('recoverpassword')));
|
'action' => common_local_url('recoverpassword')));
|
||||||
common_hidden('token', common_session_token());
|
$this->hidden('token', common_session_token());
|
||||||
common_password('newpassword', _('New password'),
|
$this->password('newpassword', _('New password'),
|
||||||
_('6 or more characters, and don\'t forget it!'));
|
_('6 or more characters, and don\'t forget it!'));
|
||||||
common_password('confirm', _('Confirm'),
|
$this->password('confirm', _('Confirm'),
|
||||||
_('Same as password above'));
|
_('Same as password above'));
|
||||||
common_submit('reset', _('Reset'));
|
$this->submit('reset', _('Reset'));
|
||||||
common_element_end('form');
|
$this->elementEnd('form');
|
||||||
common_show_footer();
|
common_show_footer();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -240,7 +240,7 @@ class RecoverpasswordAction extends Action
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!$user->email && !$confirm_email) {
|
if (!$user->email && !$confirm_email) {
|
||||||
$this->client_error(_('No registered email address for that user.'));
|
$this->clientError(_('No registered email address for that user.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -254,7 +254,7 @@ class RecoverpasswordAction extends Action
|
|||||||
|
|
||||||
if (!$confirm->insert()) {
|
if (!$confirm->insert()) {
|
||||||
common_log_db_error($confirm, 'INSERT', __FILE__);
|
common_log_db_error($confirm, 'INSERT', __FILE__);
|
||||||
$this->server_error(_('Error saving address confirmation.'));
|
$this->serverError(_('Error saving address confirmation.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -278,7 +278,7 @@ class RecoverpasswordAction extends Action
|
|||||||
mail_to_user($user, _('Password recovery requested'), $body, $confirm->address);
|
mail_to_user($user, _('Password recovery requested'), $body, $confirm->address);
|
||||||
|
|
||||||
common_show_header(_('Password recovery requested'));
|
common_show_header(_('Password recovery requested'));
|
||||||
common_element('p', null,
|
$this->element('p', null,
|
||||||
_('Instructions for recovering your password ' .
|
_('Instructions for recovering your password ' .
|
||||||
'have been sent to the email address registered to your ' .
|
'have been sent to the email address registered to your ' .
|
||||||
'account.'));
|
'account.'));
|
||||||
@ -298,7 +298,7 @@ class RecoverpasswordAction extends Action
|
|||||||
$user = $this->get_temp_user();
|
$user = $this->get_temp_user();
|
||||||
|
|
||||||
if (!$user) {
|
if (!$user) {
|
||||||
$this->client_error(_('Unexpected password reset.'));
|
$this->clientError(_('Unexpected password reset.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -322,21 +322,21 @@ class RecoverpasswordAction extends Action
|
|||||||
|
|
||||||
if (!$user->update($original)) {
|
if (!$user->update($original)) {
|
||||||
common_log_db_error($user, 'UPDATE', __FILE__);
|
common_log_db_error($user, 'UPDATE', __FILE__);
|
||||||
common_server_error(_('Can\'t save new password.'));
|
$this->serverError(_('Can\'t save new password.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->clear_temp_user();
|
$this->clear_temp_user();
|
||||||
|
|
||||||
if (!common_set_user($user->nickname)) {
|
if (!common_set_user($user->nickname)) {
|
||||||
common_server_error(_('Error setting user.'));
|
$this->serverError(_('Error setting user.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
common_real_login(true);
|
common_real_login(true);
|
||||||
|
|
||||||
common_show_header(_('Password saved.'));
|
common_show_header(_('Password saved.'));
|
||||||
common_element('p', null, _('New password successfully saved. ' .
|
$this->element('p', null, _('New password successfully saved. ' .
|
||||||
'You are now logged in.'));
|
'You are now logged in.'));
|
||||||
common_show_footer();
|
common_show_footer();
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/**
|
||||||
* Laconica - a distributed open-source microblogging tool
|
* Laconica, the distributed open-source microblogging tool
|
||||||
* Copyright (C) 2008, Controlez-Vous, Inc.
|
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* Register a new user account
|
||||||
|
*
|
||||||
|
* 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
|
* 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
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
@ -15,32 +18,100 @@
|
|||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* 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/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* @category Login
|
||||||
|
* @package Laconica
|
||||||
|
* @author Evan Prodromou <evan@controlyourself.ca>
|
||||||
|
* @copyright 2008-2009 Control Yourself, Inc.
|
||||||
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||||
|
* @link http://laconi.ca/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('LACONICA')) { exit(1); }
|
if (!defined('LACONICA')) {
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An action for registering a new user account
|
||||||
|
*
|
||||||
|
* @category Login
|
||||||
|
* @package Laconica
|
||||||
|
* @author Evan Prodromou <evan@controlyourself.ca>
|
||||||
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||||
|
* @link http://laconi.ca/
|
||||||
|
*/
|
||||||
|
|
||||||
class RegisterAction extends Action
|
class RegisterAction extends Action
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Has there been an error?
|
||||||
|
*/
|
||||||
|
|
||||||
|
var $error = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Have we registered?
|
||||||
|
*/
|
||||||
|
|
||||||
|
var $registered = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Title of the page
|
||||||
|
*
|
||||||
|
* @return string title
|
||||||
|
*/
|
||||||
|
|
||||||
|
function title()
|
||||||
|
{
|
||||||
|
if ($this->registered) {
|
||||||
|
return _('Registration successful');
|
||||||
|
} else {
|
||||||
|
return _('Register');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle input, produce output
|
||||||
|
*
|
||||||
|
* Switches on request method; either shows the form or handles its input.
|
||||||
|
*
|
||||||
|
* Checks if registration is closed and shows an error if so.
|
||||||
|
*
|
||||||
|
* @param array $args $_REQUEST data
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
function handle($args)
|
function handle($args)
|
||||||
{
|
{
|
||||||
parent::handle($args);
|
parent::handle($args);
|
||||||
|
|
||||||
if (common_config('site', 'closed')) {
|
if (common_config('site', 'closed')) {
|
||||||
common_user_error(_('Registration not allowed.'));
|
$this->clientError(_('Registration not allowed.'));
|
||||||
} else if (common_logged_in()) {
|
} else if (common_logged_in()) {
|
||||||
common_user_error(_('Already logged in.'));
|
$this->clientError(_('Already logged in.'));
|
||||||
} else if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
} else if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||||
$this->try_register();
|
$this->tryRegister();
|
||||||
} else {
|
} else {
|
||||||
$this->show_form();
|
$this->showForm();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function try_register()
|
/**
|
||||||
|
* Try to register a user
|
||||||
|
*
|
||||||
|
* Validates the input and tries to save a new user and profile
|
||||||
|
* record. On success, shows an instructions page.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
|
function tryRegister()
|
||||||
{
|
{
|
||||||
$token = $this->trimmed('token');
|
$token = $this->trimmed('token');
|
||||||
if (!$token || $token != common_session_token()) {
|
if (!$token || $token != common_session_token()) {
|
||||||
$this->show_form(_('There was a problem with your session token. Try again, please.'));
|
$this->showForm(_('There was a problem with your session token. '.
|
||||||
|
'Try again, please.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,12 +122,12 @@ class RegisterAction extends Action
|
|||||||
$bio = $this->trimmed('bio');
|
$bio = $this->trimmed('bio');
|
||||||
$location = $this->trimmed('location');
|
$location = $this->trimmed('location');
|
||||||
|
|
||||||
# We don't trim these... whitespace is OK in a password!
|
// We don't trim these... whitespace is OK in a password!
|
||||||
|
|
||||||
$password = $this->arg('password');
|
$password = $this->arg('password');
|
||||||
$confirm = $this->arg('confirm');
|
$confirm = $this->arg('confirm');
|
||||||
|
|
||||||
# invitation code, if any
|
// invitation code, if any
|
||||||
|
|
||||||
$code = $this->trimmed('code');
|
$code = $this->trimmed('code');
|
||||||
|
|
||||||
@ -65,84 +136,109 @@ class RegisterAction extends Action
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (common_config('site', 'inviteonly') && !($code && $invite)) {
|
if (common_config('site', 'inviteonly') && !($code && $invite)) {
|
||||||
$this->client_error(_('Sorry, only invited people can register.'));
|
$this->clientError(_('Sorry, only invited people can register.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Input scrubbing
|
// Input scrubbing
|
||||||
|
|
||||||
$nickname = common_canonical_nickname($nickname);
|
$nickname = common_canonical_nickname($nickname);
|
||||||
$email = common_canonical_email($email);
|
$email = common_canonical_email($email);
|
||||||
|
|
||||||
if (!$this->boolean('license')) {
|
if (!$this->boolean('license')) {
|
||||||
$this->show_form(_('You can\'t register if you don\'t agree to the license.'));
|
$this->showForm(_('You can\'t register if you don\'t '.
|
||||||
|
'agree to the license.'));
|
||||||
} else if ($email && !Validate::email($email, true)) {
|
} else if ($email && !Validate::email($email, true)) {
|
||||||
$this->show_form(_('Not a valid email address.'));
|
$this->showForm(_('Not a valid email address.'));
|
||||||
} else if (!Validate::string($nickname, array('min_length' => 1,
|
} else if (!Validate::string($nickname, array('min_length' => 1,
|
||||||
'max_length' => 64,
|
'max_length' => 64,
|
||||||
'format' => VALIDATE_NUM . VALIDATE_ALPHA_LOWER))) {
|
'format' => NICKNAME_FMT))) {
|
||||||
$this->show_form(_('Nickname must have only lowercase letters and numbers and no spaces.'));
|
$this->showForm(_('Nickname must have only lowercase letters '.
|
||||||
} else if ($this->nickname_exists($nickname)) {
|
'and numbers and no spaces.'));
|
||||||
$this->show_form(_('Nickname already in use. Try another one.'));
|
} else if ($this->nicknameExists($nickname)) {
|
||||||
|
$this->showForm(_('Nickname already in use. Try another one.'));
|
||||||
} else if (!User::allowed_nickname($nickname)) {
|
} else if (!User::allowed_nickname($nickname)) {
|
||||||
$this->show_form(_('Not a valid nickname.'));
|
$this->showForm(_('Not a valid nickname.'));
|
||||||
} else if ($this->email_exists($email)) {
|
} else if ($this->emailExists($email)) {
|
||||||
$this->show_form(_('Email address already exists.'));
|
$this->showForm(_('Email address already exists.'));
|
||||||
} else if (!is_null($homepage) && (strlen($homepage) > 0) &&
|
} else if (!is_null($homepage) && (strlen($homepage) > 0) &&
|
||||||
!Validate::uri($homepage, array('allowed_schemes' => array('http', 'https')))) {
|
!Validate::uri($homepage,
|
||||||
$this->show_form(_('Homepage is not a valid URL.'));
|
array('allowed_schemes' =>
|
||||||
|
array('http', 'https')))) {
|
||||||
|
$this->showForm(_('Homepage is not a valid URL.'));
|
||||||
return;
|
return;
|
||||||
} else if (!is_null($fullname) && strlen($fullname) > 255) {
|
} else if (!is_null($fullname) && strlen($fullname) > 255) {
|
||||||
$this->show_form(_('Full name is too long (max 255 chars).'));
|
$this->showForm(_('Full name is too long (max 255 chars).'));
|
||||||
return;
|
return;
|
||||||
} else if (!is_null($bio) && strlen($bio) > 140) {
|
} else if (!is_null($bio) && strlen($bio) > 140) {
|
||||||
$this->show_form(_('Bio is too long (max 140 chars).'));
|
$this->showForm(_('Bio is too long (max 140 chars).'));
|
||||||
return;
|
return;
|
||||||
} else if (!is_null($location) && strlen($location) > 255) {
|
} else if (!is_null($location) && strlen($location) > 255) {
|
||||||
$this->show_form(_('Location is too long (max 255 chars).'));
|
$this->showForm(_('Location is too long (max 255 chars).'));
|
||||||
return;
|
return;
|
||||||
} else if (strlen($password) < 6) {
|
} else if (strlen($password) < 6) {
|
||||||
$this->show_form(_('Password must be 6 or more characters.'));
|
$this->showForm(_('Password must be 6 or more characters.'));
|
||||||
return;
|
return;
|
||||||
} else if ($password != $confirm) {
|
} else if ($password != $confirm) {
|
||||||
$this->show_form(_('Passwords don\'t match.'));
|
$this->showForm(_('Passwords don\'t match.'));
|
||||||
} else if ($user = User::register(array('nickname' => $nickname, 'password' => $password, 'email' => $email,
|
} else if ($user = User::register(array('nickname' => $nickname,
|
||||||
'fullname' => $fullname, 'homepage' => $homepage, 'bio' => $bio,
|
'password' => $password,
|
||||||
'location' => $location, 'code' => $code))) {
|
'email' => $email,
|
||||||
|
'fullname' => $fullname,
|
||||||
|
'homepage' => $homepage,
|
||||||
|
'bio' => $bio,
|
||||||
|
'location' => $location,
|
||||||
|
'code' => $code))) {
|
||||||
if (!$user) {
|
if (!$user) {
|
||||||
$this->show_form(_('Invalid username or password.'));
|
$this->showForm(_('Invalid username or password.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
# success!
|
// success!
|
||||||
if (!common_set_user($user)) {
|
if (!common_set_user($user)) {
|
||||||
common_server_error(_('Error setting user.'));
|
$this->serverError(_('Error setting user.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
# this is a real login
|
// this is a real login
|
||||||
common_real_login(true);
|
common_real_login(true);
|
||||||
if ($this->boolean('rememberme')) {
|
if ($this->boolean('rememberme')) {
|
||||||
common_debug('Adding rememberme cookie for ' . $nickname);
|
common_debug('Adding rememberme cookie for ' . $nickname);
|
||||||
common_rememberme($user);
|
common_rememberme($user);
|
||||||
}
|
}
|
||||||
# Re-init language env in case it changed (not yet, but soon)
|
// Re-init language env in case it changed (not yet, but soon)
|
||||||
common_init_language();
|
common_init_language();
|
||||||
$this->show_success();
|
$this->showSuccess();
|
||||||
} else {
|
} else {
|
||||||
$this->show_form(_('Invalid username or password.'));
|
$this->showForm(_('Invalid username or password.'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# checks if *CANONICAL* nickname exists
|
/**
|
||||||
|
* Does the given nickname already exist?
|
||||||
|
*
|
||||||
|
* Checks a canonical nickname against the database.
|
||||||
|
*
|
||||||
|
* @param string $nickname nickname to check
|
||||||
|
*
|
||||||
|
* @return boolean true if the nickname already exists
|
||||||
|
*/
|
||||||
|
|
||||||
function nickname_exists($nickname)
|
function nicknameExists($nickname)
|
||||||
{
|
{
|
||||||
$user = User::staticGet('nickname', $nickname);
|
$user = User::staticGet('nickname', $nickname);
|
||||||
return ($user !== false);
|
return ($user !== false);
|
||||||
}
|
}
|
||||||
|
|
||||||
# checks if *CANONICAL* email exists
|
/**
|
||||||
|
* Does the given email address already exist?
|
||||||
|
*
|
||||||
|
* Checks a canonical email address against the database.
|
||||||
|
*
|
||||||
|
* @param string $email email address to check
|
||||||
|
*
|
||||||
|
* @return boolean true if the address already exists
|
||||||
|
*/
|
||||||
|
|
||||||
function email_exists($email)
|
function emailExists($email)
|
||||||
{
|
{
|
||||||
$email = common_canonical_email($email);
|
$email = common_canonical_email($email);
|
||||||
if (!$email || strlen($email) == 0) {
|
if (!$email || strlen($email) == 0) {
|
||||||
@ -152,26 +248,78 @@ class RegisterAction extends Action
|
|||||||
return ($user !== false);
|
return ($user !== false);
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_top($error=null)
|
/**
|
||||||
|
* Instructions or a notice for the page
|
||||||
|
*
|
||||||
|
* Shows the error, if any, or instructions for registration.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
|
function showPageNotice()
|
||||||
{
|
{
|
||||||
if ($error) {
|
if ($this->registered) {
|
||||||
common_element('p', 'error', $error);
|
return;
|
||||||
|
} else if ($this->error) {
|
||||||
|
$this->element('p', 'error', $this->error);
|
||||||
} else {
|
} else {
|
||||||
$instr = common_markup_to_html(_('With this form you can create a new account. ' .
|
$instr =
|
||||||
'You can then post notices and link up to friends and colleagues. '.
|
common_markup_to_html(_('With this form you can create '.
|
||||||
|
' a new account. ' .
|
||||||
|
'You can then post notices and '.
|
||||||
|
'link up to friends and colleagues. '.
|
||||||
'(Have an [OpenID](http://openid.net/)? ' .
|
'(Have an [OpenID](http://openid.net/)? ' .
|
||||||
'Try our [OpenID registration](%%action.openidlogin%%)!)'));
|
'Try our [OpenID registration]'.
|
||||||
|
'(%%action.openidlogin%%)!)'));
|
||||||
|
|
||||||
common_element_start('div', 'instructions');
|
$this->elementStart('div', 'instructions');
|
||||||
common_raw($instr);
|
$this->raw($instr);
|
||||||
common_element_end('div');
|
$this->elementEnd('div');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_form($error=null)
|
/**
|
||||||
|
* Wrapper for showing a page
|
||||||
|
*
|
||||||
|
* Stores an error and shows the page
|
||||||
|
*
|
||||||
|
* @param string $error Error, if any
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
|
function showForm($error=null)
|
||||||
{
|
{
|
||||||
global $config;
|
$this->error = $error;
|
||||||
|
$this->showPage();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the page content
|
||||||
|
*
|
||||||
|
* Either shows the registration form or, if registration was successful,
|
||||||
|
* instructions for using the site.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
|
function showContent()
|
||||||
|
{
|
||||||
|
if ($this->registered) {
|
||||||
|
$this->showSuccessContent();
|
||||||
|
} else {
|
||||||
|
$this->showFormContent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the registration form
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
|
function showFormContent()
|
||||||
|
{
|
||||||
$code = $this->trimmed('code');
|
$code = $this->trimmed('code');
|
||||||
|
|
||||||
if ($code) {
|
if ($code) {
|
||||||
@ -179,90 +327,170 @@ class RegisterAction extends Action
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (common_config('site', 'inviteonly') && !($code && $invite)) {
|
if (common_config('site', 'inviteonly') && !($code && $invite)) {
|
||||||
$this->client_error(_('Sorry, only invited people can register.'));
|
$this->clientError(_('Sorry, only invited people can register.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
common_show_header(_('Register'), null, $error, array($this, 'show_top'));
|
$this->elementStart('form', array('method' => 'post',
|
||||||
common_element_start('form', array('method' => 'post',
|
'id' => 'form_register',
|
||||||
'id' => 'login',
|
'class' => 'form_settings',
|
||||||
'action' => common_local_url('register')));
|
'action' => common_local_url('register')));
|
||||||
|
$this->elementStart('fieldset');
|
||||||
common_hidden('token', common_session_token());
|
$this->element('legend', null, 'Account settings');
|
||||||
|
$this->hidden('token', common_session_token());
|
||||||
|
|
||||||
if ($code) {
|
if ($code) {
|
||||||
common_hidden('code', $code);
|
$this->hidden('code', $code);
|
||||||
}
|
}
|
||||||
|
|
||||||
common_input('nickname', _('Nickname'), $this->trimmed('nickname'),
|
$this->elementStart('ul', 'form_data');
|
||||||
_('1-64 lowercase letters or numbers, no punctuation or spaces. Required.'));
|
$this->elementStart('li');
|
||||||
common_password('password', _('Password'),
|
$this->input('nickname', _('Nickname'), $this->trimmed('nickname'),
|
||||||
|
_('1-64 lowercase letters or numbers, '.
|
||||||
|
'no punctuation or spaces. Required.'));
|
||||||
|
$this->elementEnd('li');
|
||||||
|
$this->elementStart('li');
|
||||||
|
$this->password('password', _('Password'),
|
||||||
_('6 or more characters. Required.'));
|
_('6 or more characters. Required.'));
|
||||||
common_password('confirm', _('Confirm'),
|
$this->elementEnd('li');
|
||||||
|
$this->elementStart('li');
|
||||||
|
$this->password('confirm', _('Confirm'),
|
||||||
_('Same as password above. Required.'));
|
_('Same as password above. Required.'));
|
||||||
|
$this->elementEnd('li');
|
||||||
|
$this->elementStart('li');
|
||||||
if ($invite && $invite->address_type == 'email') {
|
if ($invite && $invite->address_type == 'email') {
|
||||||
common_input('email', _('Email'), $invite->address,
|
$this->input('email', _('Email'), $invite->address,
|
||||||
_('Used only for updates, announcements, and password recovery'));
|
_('Used only for updates, announcements, '.
|
||||||
|
'and password recovery'));
|
||||||
} else {
|
} else {
|
||||||
common_input('email', _('Email'), $this->trimmed('email'),
|
$this->input('email', _('Email'), $this->trimmed('email'),
|
||||||
_('Used only for updates, announcements, and password recovery'));
|
_('Used only for updates, announcements, '.
|
||||||
|
'and password recovery'));
|
||||||
}
|
}
|
||||||
common_input('fullname', _('Full name'),
|
$this->elementEnd('li');
|
||||||
|
$this->elementStart('li');
|
||||||
|
$this->input('fullname', _('Full name'),
|
||||||
$this->trimmed('fullname'),
|
$this->trimmed('fullname'),
|
||||||
_('Longer name, preferably your "real" name'));
|
_('Longer name, preferably your "real" name'));
|
||||||
common_input('homepage', _('Homepage'),
|
$this->elementEnd('li');
|
||||||
|
$this->elementStart('li');
|
||||||
|
$this->input('homepage', _('Homepage'),
|
||||||
$this->trimmed('homepage'),
|
$this->trimmed('homepage'),
|
||||||
_('URL of your homepage, blog, or profile on another site'));
|
_('URL of your homepage, blog, '.
|
||||||
common_textarea('bio', _('Bio'),
|
'or profile on another site'));
|
||||||
|
$this->elementEnd('li');
|
||||||
|
$this->elementStart('li');
|
||||||
|
$this->textarea('bio', _('Bio'),
|
||||||
$this->trimmed('bio'),
|
$this->trimmed('bio'),
|
||||||
_('Describe yourself and your interests in 140 chars'));
|
_('Describe yourself and your '.
|
||||||
common_input('location', _('Location'),
|
'interests in 140 chars'));
|
||||||
|
$this->elementEnd('li');
|
||||||
|
$this->elementStart('li');
|
||||||
|
$this->input('location', _('Location'),
|
||||||
$this->trimmed('location'),
|
$this->trimmed('location'),
|
||||||
_('Where you are, like "City, State (or Region), Country"'));
|
_('Where you are, like "City, '.
|
||||||
common_checkbox('rememberme', _('Remember me'),
|
'State (or Region), Country"'));
|
||||||
|
$this->elementEnd('li');
|
||||||
|
$this->elementStart('li', array('id' => 'settings_rememberme'));
|
||||||
|
$this->checkbox('rememberme', _('Remember me'),
|
||||||
$this->boolean('rememberme'),
|
$this->boolean('rememberme'),
|
||||||
_('Automatically login in the future; not for shared computers!'));
|
_('Automatically login in the future; '.
|
||||||
common_element_start('p');
|
'not for shared computers!'));
|
||||||
|
$this->elementEnd('li');
|
||||||
$attrs = array('type' => 'checkbox',
|
$attrs = array('type' => 'checkbox',
|
||||||
'id' => 'license',
|
'id' => 'license',
|
||||||
|
'class' => 'checkbox',
|
||||||
'name' => 'license',
|
'name' => 'license',
|
||||||
'value' => 'true');
|
'value' => 'true');
|
||||||
if ($this->boolean('license')) {
|
if ($this->boolean('license')) {
|
||||||
$attrs['checked'] = 'checked';
|
$attrs['checked'] = 'checked';
|
||||||
}
|
}
|
||||||
common_element('input', $attrs);
|
$this->elementStart('li');
|
||||||
common_text(_('My text and files are available under '));
|
$this->element('input', $attrs);
|
||||||
common_element('a', array('href' => $config['license']['url']),
|
$this->text(_('My text and files are available under '));
|
||||||
|
$this->element('a', array('href' => common_config('license', 'url')),
|
||||||
$config['license']['title']);
|
$config['license']['title']);
|
||||||
common_text(_(' except this private data: password, email address, IM address, phone number.'));
|
$this->text(_(' except this private data: password, '.
|
||||||
common_element_end('p');
|
'email address, IM address, phone number.'));
|
||||||
common_submit('submit', _('Register'));
|
$this->elementEnd('li');
|
||||||
common_element_end('form');
|
$this->elementEnd('ul');
|
||||||
common_show_footer();
|
$this->submit('submit', _('Register'));
|
||||||
|
$this->elementEnd('fieldset');
|
||||||
|
$this->elementEnd('form');
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_success()
|
/**
|
||||||
|
* Show some information about registering for the site
|
||||||
|
*
|
||||||
|
* Save the registration flag, run showPage
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
|
function showSuccess()
|
||||||
|
{
|
||||||
|
$this->registered = true;
|
||||||
|
$this->showPage();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show some information about registering for the site
|
||||||
|
*
|
||||||
|
* Gives some information and options for new registrees.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
|
function showSuccessContent()
|
||||||
{
|
{
|
||||||
$nickname = $this->arg('nickname');
|
$nickname = $this->arg('nickname');
|
||||||
common_show_header(_('Registration successful'));
|
|
||||||
common_element_start('div', 'success');
|
$profileurl = common_local_url('showstream',
|
||||||
$instr = sprintf(_('Congratulations, %s! And welcome to %%%%site.name%%%%. From here, you may want to...'. "\n\n" .
|
array('nickname' => $nickname));
|
||||||
'* Go to [your profile](%s) and post your first message.' . "\n" .
|
|
||||||
'* Add a [Jabber/GTalk address](%%%%action.imsettings%%%%) so you can send notices through instant messages.' . "\n" .
|
$this->elementStart('div', 'success');
|
||||||
'* [Search for people](%%%%action.peoplesearch%%%%) that you may know or that share your interests. ' . "\n" .
|
$instr = sprintf(_('Congratulations, %s! And welcome to %%%%site.name%%%%. '.
|
||||||
'* Update your [profile settings](%%%%action.profilesettings%%%%) to tell others more about you. ' . "\n" .
|
'From here, you may want to...'. "\n\n" .
|
||||||
'* Read over the [online docs](%%%%doc.help%%%%) for features you may have missed. ' . "\n\n" .
|
'* Go to [your profile](%s) '.
|
||||||
'Thanks for signing up and we hope you enjoy using this service.'),
|
'and post your first message.' . "\n" .
|
||||||
$nickname, common_local_url('showstream', array('nickname' => $nickname)));
|
'* Add a [Jabber/GTalk address]'.
|
||||||
common_raw(common_markup_to_html($instr));
|
'(%%%%action.imsettings%%%%) '.
|
||||||
|
'so you can send notices '.
|
||||||
|
'through instant messages.' . "\n" .
|
||||||
|
'* [Search for people](%%%%action.peoplesearch%%%%) '.
|
||||||
|
'that you may know or '.
|
||||||
|
'that share your interests. ' . "\n" .
|
||||||
|
'* Update your [profile settings]'.
|
||||||
|
'(%%%%action.profilesettings%%%%)'.
|
||||||
|
' to tell others more about you. ' . "\n" .
|
||||||
|
'* Read over the [online docs](%%%%doc.help%%%%)'.
|
||||||
|
' for features you may have missed. ' . "\n\n" .
|
||||||
|
'Thanks for signing up and we hope '.
|
||||||
|
'you enjoy using this service.'),
|
||||||
|
$nickname, $profileurl);
|
||||||
|
|
||||||
|
$this->raw(common_markup_to_html($instr));
|
||||||
|
|
||||||
$have_email = $this->trimmed('email');
|
$have_email = $this->trimmed('email');
|
||||||
if ($have_email) {
|
if ($have_email) {
|
||||||
$emailinstr = _('(You should receive a message by email momentarily, with ' .
|
$emailinstr = _('(You should receive a message by email '.
|
||||||
'instructions on how to confirm your email address.)');
|
'momentarily, with ' .
|
||||||
common_raw(common_markup_to_html($emailinstr));
|
'instructions on how to confirm '.
|
||||||
|
'your email address.)');
|
||||||
|
$this->raw(common_markup_to_html($emailinstr));
|
||||||
}
|
}
|
||||||
common_element_end('div');
|
$this->elementEnd('div');
|
||||||
common_show_footer();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the login group nav menu
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
|
function showLocalNav()
|
||||||
|
{
|
||||||
|
$nav = new LoginGroupNav($this);
|
||||||
|
$nav->show();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ class RemotesubscribeAction extends Action
|
|||||||
parent::handle($args);
|
parent::handle($args);
|
||||||
|
|
||||||
if (common_logged_in()) {
|
if (common_logged_in()) {
|
||||||
common_user_error(_('You can use the local subscription!'));
|
$this->clientError(_('You can use the local subscription!'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,13 +61,13 @@ class RemotesubscribeAction extends Action
|
|||||||
function show_top($err=null)
|
function show_top($err=null)
|
||||||
{
|
{
|
||||||
if ($err) {
|
if ($err) {
|
||||||
common_element('div', 'error', $err);
|
$this->element('div', 'error', $err);
|
||||||
} else {
|
} else {
|
||||||
$instructions = $this->get_instructions();
|
$instructions = $this->get_instructions();
|
||||||
$output = common_markup_to_html($instructions);
|
$output = common_markup_to_html($instructions);
|
||||||
common_element_start('div', 'instructions');
|
$this->elementStart('div', 'instructions');
|
||||||
common_raw($output);
|
$this->raw($output);
|
||||||
common_element_end('p');
|
$this->elementEnd('p');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,15 +79,15 @@ class RemotesubscribeAction extends Action
|
|||||||
array($this, 'show_top'));
|
array($this, 'show_top'));
|
||||||
# id = remotesubscribe conflicts with the
|
# id = remotesubscribe conflicts with the
|
||||||
# button on profile page
|
# button on profile page
|
||||||
common_element_start('form', array('id' => 'remsub', 'method' => 'post',
|
$this->elementStart('form', array('id' => 'remsub', 'method' => 'post',
|
||||||
'action' => common_local_url('remotesubscribe')));
|
'action' => common_local_url('remotesubscribe')));
|
||||||
common_hidden('token', common_session_token());
|
$this->hidden('token', common_session_token());
|
||||||
common_input('nickname', _('User nickname'), $nickname,
|
$this->input('nickname', _('User nickname'), $nickname,
|
||||||
_('Nickname of the user you want to follow'));
|
_('Nickname of the user you want to follow'));
|
||||||
common_input('profile_url', _('Profile URL'), $profile,
|
$this->input('profile_url', _('Profile URL'), $profile,
|
||||||
_('URL of your profile on another compatible microblogging service'));
|
_('URL of your profile on another compatible microblogging service'));
|
||||||
common_submit('submit', _('Subscribe'));
|
$this->submit('submit', _('Subscribe'));
|
||||||
common_element_end('form');
|
$this->elementEnd('form');
|
||||||
common_show_footer();
|
common_show_footer();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -342,7 +342,7 @@ class RemotesubscribeAction extends Action
|
|||||||
$profile = $user->getProfile();
|
$profile = $user->getProfile();
|
||||||
if (!$profile) {
|
if (!$profile) {
|
||||||
common_log_db_error($user, 'SELECT', __FILE__);
|
common_log_db_error($user, 'SELECT', __FILE__);
|
||||||
$this->server_error(_('User without matching profile'));
|
$this->serverError(_('User without matching profile'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/**
|
||||||
* Laconica - a distributed open-source microblogging tool
|
* Laconica, the distributed open-source microblogging tool
|
||||||
* Copyright (C) 2008, Controlez-Vous, Inc.
|
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* List of replies
|
||||||
|
*
|
||||||
|
* 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
|
* 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
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
@ -15,86 +18,177 @@
|
|||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* 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/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* @category Personal
|
||||||
|
* @package Laconica
|
||||||
|
* @author Evan Prodromou <evan@controlyourself.ca>
|
||||||
|
* @copyright 2008-2009 Control Yourself, Inc.
|
||||||
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||||
|
* @link http://laconi.ca/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('LACONICA')) { exit(1); }
|
if (!defined('LACONICA')) {
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
require_once(INSTALLDIR.'/actions/showstream.php');
|
require_once INSTALLDIR.'/lib/personalgroupnav.php';
|
||||||
|
require_once INSTALLDIR.'/lib/noticelist.php';
|
||||||
|
require_once INSTALLDIR.'/lib/feedlist.php';
|
||||||
|
|
||||||
class RepliesAction extends StreamAction
|
/**
|
||||||
|
* List of replies
|
||||||
|
*
|
||||||
|
* @category Personal
|
||||||
|
* @package Laconica
|
||||||
|
* @author Evan Prodromou <evan@controlyourself.ca>
|
||||||
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||||
|
* @link http://laconi.ca/
|
||||||
|
*/
|
||||||
|
|
||||||
|
class RepliesAction extends Action
|
||||||
{
|
{
|
||||||
|
var $user = null;
|
||||||
|
var $page = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prepare the object
|
||||||
|
*
|
||||||
|
* Check the input values and initialize the object.
|
||||||
|
* Shows an error page on bad input.
|
||||||
|
*
|
||||||
|
* @param array $args $_REQUEST data
|
||||||
|
*
|
||||||
|
* @return boolean success flag
|
||||||
|
*/
|
||||||
|
|
||||||
|
function prepare($args)
|
||||||
|
{
|
||||||
|
parent::prepare($args);
|
||||||
|
|
||||||
|
$nickname = common_canonical_nickname($this->arg('nickname'));
|
||||||
|
|
||||||
|
$this->user = User::staticGet('nickname', $nickname);
|
||||||
|
|
||||||
|
if (!$this->user) {
|
||||||
|
$this->clientError(_('No such user.'));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$profile = $this->user->getProfile();
|
||||||
|
|
||||||
|
if (!$profile) {
|
||||||
|
$this->serverError(_('User has no profile.'));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle a request
|
||||||
|
*
|
||||||
|
* Just show the page. All args already handled.
|
||||||
|
*
|
||||||
|
* @param array $args $_REQUEST data
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
function handle($args)
|
function handle($args)
|
||||||
{
|
{
|
||||||
|
|
||||||
parent::handle($args);
|
parent::handle($args);
|
||||||
|
$this->showPage();
|
||||||
$nickname = common_canonical_nickname($this->arg('nickname'));
|
|
||||||
$user = User::staticGet('nickname', $nickname);
|
|
||||||
|
|
||||||
if (!$user) {
|
|
||||||
$this->no_such_user();
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$profile = $user->getProfile();
|
/**
|
||||||
|
* Title of the page
|
||||||
|
*
|
||||||
|
* Includes name of user and page number.
|
||||||
|
*
|
||||||
|
* @return string title of page
|
||||||
|
*/
|
||||||
|
|
||||||
if (!$profile) {
|
function title()
|
||||||
common_server_error(_('User has no profile.'));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
# Looks like we're good; show the header
|
|
||||||
|
|
||||||
common_show_header(sprintf(_("Replies to %s"), $profile->nickname),
|
|
||||||
array($this, 'show_header'), $user,
|
|
||||||
array($this, 'show_top'));
|
|
||||||
|
|
||||||
$this->show_replies($user);
|
|
||||||
|
|
||||||
common_show_footer();
|
|
||||||
}
|
|
||||||
|
|
||||||
function no_such_user()
|
|
||||||
{
|
{
|
||||||
common_user_error(_('No such user.'));
|
if ($this->page == 1) {
|
||||||
|
return sprintf(_("Replies to %s"), $this->user->nickname);
|
||||||
|
} else {
|
||||||
|
return sprintf(_("Replies to %s, page %d"),
|
||||||
|
$profile->nickname,
|
||||||
|
$this->page);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_header($user)
|
/**
|
||||||
|
* Feeds for the <head> section
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
|
function showFeeds()
|
||||||
{
|
{
|
||||||
common_element('link', array('rel' => 'alternate',
|
$rssurl = common_local_url('repliesrss',
|
||||||
'href' => common_local_url('repliesrss', array('nickname' =>
|
array('nickname' => $this->user->nickname));
|
||||||
$user->nickname)),
|
$rsstitle = sprintf(_('Feed for replies to %s'), $this->user->nickname);
|
||||||
|
|
||||||
|
$this->element('link', array('rel' => 'alternate',
|
||||||
|
'href' => $rssurl,
|
||||||
'type' => 'application/rss+xml',
|
'type' => 'application/rss+xml',
|
||||||
'title' => sprintf(_('Feed for replies to %s'), $user->nickname)));
|
'title' => $rsstitle));
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_top($user)
|
/**
|
||||||
|
* show the personal group nav
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
|
function showLocalNav()
|
||||||
{
|
{
|
||||||
$cur = common_current_user();
|
$nav = new PersonalGroupNav($this);
|
||||||
|
$nav->show();
|
||||||
if ($cur && $cur->id == $user->id) {
|
|
||||||
common_notice_form('replies');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->views_menu();
|
/**
|
||||||
|
* Show the replies feed links
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
$this->show_feeds_list(array(0=>array('href'=>common_local_url('repliesrss', array('nickname' => $user->nickname)),
|
function showExportData()
|
||||||
|
{
|
||||||
|
$fl = new FeedList($this);
|
||||||
|
|
||||||
|
$rssurl = common_local_url('repliesrss',
|
||||||
|
array('nickname' => $this->user->nickname));
|
||||||
|
|
||||||
|
$fl->show(array(0=>array('href'=> $rssurl,
|
||||||
'type' => 'rss',
|
'type' => 'rss',
|
||||||
'version' => 'RSS 1.0',
|
'version' => 'RSS 1.0',
|
||||||
'item' => 'repliesrss')));
|
'item' => 'repliesrss')));
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_replies($user)
|
/**
|
||||||
|
* Show the content
|
||||||
|
*
|
||||||
|
* A list of notices that are replies to the user, plus pagination.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
|
function showContent()
|
||||||
{
|
{
|
||||||
|
$notice = $this->user->getReplies(($this->page-1) * NOTICES_PER_PAGE,
|
||||||
|
NOTICES_PER_PAGE + 1);
|
||||||
|
|
||||||
$page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
|
$nl = new NoticeList($notice, $this);
|
||||||
|
|
||||||
$notice = $user->getReplies(($page-1) * NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1);
|
$cnt = $nl->show();
|
||||||
|
|
||||||
$cnt = $this->show_notice_list($notice);
|
$this->pagination($this->page > 1, $cnt > NOTICES_PER_PAGE,
|
||||||
|
$this->page, 'replies',
|
||||||
common_pagination($page > 1, $cnt > NOTICES_PER_PAGE,
|
array('nickname' => $this->user->nickname));
|
||||||
$page, 'replies', array('nickname' => $user->nickname));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ class RepliesrssAction extends Rss10Action
|
|||||||
$this->user = User::staticGet('nickname', $nickname);
|
$this->user = User::staticGet('nickname', $nickname);
|
||||||
|
|
||||||
if (!$this->user) {
|
if (!$this->user) {
|
||||||
common_user_error(_('No such user.'));
|
$this->clientError(_('No such user.'));
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
return true;
|
return true;
|
||||||
|
@ -24,7 +24,7 @@ require_once(INSTALLDIR.'/lib/omb.php');
|
|||||||
class RequesttokenAction extends Action
|
class RequesttokenAction extends Action
|
||||||
{
|
{
|
||||||
|
|
||||||
function is_readonly()
|
function isReadOnly()
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -39,7 +39,7 @@ class RequesttokenAction extends Action
|
|||||||
$token = $server->fetch_request_token($req);
|
$token = $server->fetch_request_token($req);
|
||||||
print $token;
|
print $token;
|
||||||
} catch (OAuthException $e) {
|
} catch (OAuthException $e) {
|
||||||
common_server_error($e->getMessage());
|
$this->serverError($e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/**
|
||||||
* Laconica - a distributed open-source microblogging tool
|
* Laconica, the distributed open-source microblogging tool
|
||||||
* Copyright (C) 2008, Controlez-Vous, Inc.
|
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* List of replies
|
||||||
|
*
|
||||||
|
* 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
|
* 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
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
@ -15,88 +18,197 @@
|
|||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* 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/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* @category Personal
|
||||||
|
* @package Laconica
|
||||||
|
* @author Evan Prodromou <evan@controlyourself.ca>
|
||||||
|
* @copyright 2008-2009 Control Yourself, Inc.
|
||||||
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||||
|
* @link http://laconi.ca/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('LACONICA')) { exit(1); }
|
if (!defined('LACONICA')) {
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
require_once(INSTALLDIR.'/actions/showstream.php');
|
require_once INSTALLDIR.'/lib/personalgroupnav.php';
|
||||||
|
require_once INSTALLDIR.'/lib/noticelist.php';
|
||||||
|
require_once INSTALLDIR.'/lib/feedlist.php';
|
||||||
|
|
||||||
class ShowfavoritesAction extends StreamAction
|
/**
|
||||||
|
* List of replies
|
||||||
|
*
|
||||||
|
* @category Personal
|
||||||
|
* @package Laconica
|
||||||
|
* @author Evan Prodromou <evan@controlyourself.ca>
|
||||||
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||||
|
* @link http://laconi.ca/
|
||||||
|
*/
|
||||||
|
|
||||||
|
class ShowfavoritesAction extends Action
|
||||||
{
|
{
|
||||||
|
/** User we're getting the faves of */
|
||||||
|
var $user = null;
|
||||||
|
/** Page of the faves we're on */
|
||||||
|
var $page = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is this a read-only page?
|
||||||
|
*
|
||||||
|
* @return boolean true
|
||||||
|
*/
|
||||||
|
|
||||||
|
function isReadOnly()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Title of the page
|
||||||
|
*
|
||||||
|
* Includes name of user and page number.
|
||||||
|
*
|
||||||
|
* @return string title of page
|
||||||
|
*/
|
||||||
|
|
||||||
|
function title()
|
||||||
|
{
|
||||||
|
if ($this->page == 1) {
|
||||||
|
return sprintf(_("%s favorite notices"), $this->user->nickname);
|
||||||
|
} else {
|
||||||
|
return sprintf(_("%s favorite notices, page %d"),
|
||||||
|
$this->user->nickname,
|
||||||
|
$this->page);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prepare the object
|
||||||
|
*
|
||||||
|
* Check the input values and initialize the object.
|
||||||
|
* Shows an error page on bad input.
|
||||||
|
*
|
||||||
|
* @param array $args $_REQUEST data
|
||||||
|
*
|
||||||
|
* @return boolean success flag
|
||||||
|
*/
|
||||||
|
|
||||||
|
function prepare($args)
|
||||||
|
{
|
||||||
|
parent::prepare($args);
|
||||||
|
|
||||||
|
$nickname = common_canonical_nickname($this->arg('nickname'));
|
||||||
|
|
||||||
|
$this->user = User::staticGet('nickname', $nickname);
|
||||||
|
|
||||||
|
if (!$this->user) {
|
||||||
|
$this->clientError(_('No such user.'));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->page = $this->trimmed('page');
|
||||||
|
|
||||||
|
if (!$this->page) {
|
||||||
|
$this->page = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle a request
|
||||||
|
*
|
||||||
|
* Just show the page. All args already handled.
|
||||||
|
*
|
||||||
|
* @param array $args $_REQUEST data
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
function handle($args)
|
function handle($args)
|
||||||
{
|
{
|
||||||
|
|
||||||
parent::handle($args);
|
parent::handle($args);
|
||||||
|
$this->showPage();
|
||||||
$nickname = common_canonical_nickname($this->arg('nickname'));
|
|
||||||
$user = User::staticGet('nickname', $nickname);
|
|
||||||
|
|
||||||
if (!$user) {
|
|
||||||
$this->client_error(_('No such user.'));
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$profile = $user->getProfile();
|
/**
|
||||||
|
* Feeds for the <head> section
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
if (!$profile) {
|
function showFeeds()
|
||||||
common_server_error(_('User has no profile.'));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
# Looks like we're good; show the header
|
|
||||||
|
|
||||||
common_show_header(sprintf(_("%s favorite notices"), $profile->nickname),
|
|
||||||
array($this, 'show_header'), $user,
|
|
||||||
array($this, 'show_top'));
|
|
||||||
|
|
||||||
$this->show_notices($user);
|
|
||||||
|
|
||||||
common_show_footer();
|
|
||||||
}
|
|
||||||
|
|
||||||
function show_header($user)
|
|
||||||
{
|
{
|
||||||
common_element('link', array('rel' => 'alternate',
|
$feedurl = common_local_url('favoritesrss',
|
||||||
'href' => common_local_url('favoritesrss', array('nickname' =>
|
array('nickname' =>
|
||||||
$user->nickname)),
|
$this->user->nickname));
|
||||||
|
$feedtitle = sprintf(_('Feed for favorites of %s'),
|
||||||
|
$this->user->nickname);
|
||||||
|
|
||||||
|
$this->element('link', array('rel' => 'alternate',
|
||||||
|
'href' => $feedurl,
|
||||||
'type' => 'application/rss+xml',
|
'type' => 'application/rss+xml',
|
||||||
'title' => sprintf(_('Feed for favorites of %s'), $user->nickname)));
|
'title' => $feedtitle));
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_top($user)
|
/**
|
||||||
|
* show the personal group nav
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
|
function showLocalNav()
|
||||||
{
|
{
|
||||||
$cur = common_current_user();
|
$nav = new PersonalGroupNav($this);
|
||||||
|
$nav->show();
|
||||||
if ($cur && $cur->id == $user->id) {
|
|
||||||
common_notice_form('all');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->show_feeds_list(array(0=>array('href'=>common_local_url('favoritesrss', array('nickname' => $user->nickname)),
|
/**
|
||||||
|
* Show the replies feed links
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
|
function showExportData()
|
||||||
|
{
|
||||||
|
$feedurl = common_local_url('favoritesrss',
|
||||||
|
array('nickname' =>
|
||||||
|
$this->user->nickname));
|
||||||
|
|
||||||
|
$fl = new FeedList($this);
|
||||||
|
|
||||||
|
// XXX: I18N
|
||||||
|
|
||||||
|
$fl->show(array(0=>array('href'=> $feedurl,
|
||||||
'type' => 'rss',
|
'type' => 'rss',
|
||||||
'version' => 'RSS 1.0',
|
'version' => 'RSS 1.0',
|
||||||
'item' => 'Favorites')));
|
'item' => 'Favorites')));
|
||||||
$this->views_menu();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_notices($user)
|
/**
|
||||||
|
* Show the content
|
||||||
|
*
|
||||||
|
* A list of notices that this user has marked as a favorite
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
|
function showContent()
|
||||||
{
|
{
|
||||||
|
$notice = $this->user->favoriteNotices(($this->page-1)*NOTICES_PER_PAGE,
|
||||||
$page = $this->trimmed('page');
|
NOTICES_PER_PAGE + 1);
|
||||||
if (!$page) {
|
|
||||||
$page = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
$notice = $user->favoriteNotices(($page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1);
|
|
||||||
|
|
||||||
if (!$notice) {
|
if (!$notice) {
|
||||||
$this->server_error(_('Could not retrieve favorite notices.'));
|
$this->serverError(_('Could not retrieve favorite notices.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$cnt = $this->show_notice_list($notice);
|
$nl = new NoticeList($notice, $this);
|
||||||
|
|
||||||
common_pagination($page > 1, $cnt > NOTICES_PER_PAGE,
|
$cnt = $nl->show();
|
||||||
$page, 'showfavorites', array('nickname' => $user->nickname));
|
|
||||||
|
$this->pagination($this->page > 1, $cnt > NOTICES_PER_PAGE,
|
||||||
|
$this->page, 'showfavorites',
|
||||||
|
array('nickname' => $this->user->nickname));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/**
|
||||||
* Laconica - a distributed open-source microblogging tool
|
* Laconica, the distributed open-source microblogging tool
|
||||||
* Copyright (C) 2008, Controlez-Vous, Inc.
|
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* Show a single message
|
||||||
|
*
|
||||||
|
* 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
|
* 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
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
@ -15,94 +18,162 @@
|
|||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* 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/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* @category Personal
|
||||||
|
* @package Laconica
|
||||||
|
* @author Evan Prodromou <evan@controlyourself.ca>
|
||||||
|
* @copyright 2008-2009 Control Yourself, Inc.
|
||||||
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||||
|
* @link http://laconi.ca/
|
||||||
*/
|
*/
|
||||||
|
if (!defined('LACONICA')) {
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
if (!defined('LACONICA')) { exit(1); }
|
require_once INSTALLDIR.'/lib/mailbox.php';
|
||||||
|
|
||||||
require_once(INSTALLDIR.'/lib/mailbox.php');
|
/**
|
||||||
|
* Show a single message
|
||||||
|
*
|
||||||
|
* // XXX: It is totally weird how this works!
|
||||||
|
*
|
||||||
|
* @category Personal
|
||||||
|
* @package Laconica
|
||||||
|
* @author Evan Prodromou <evan@controlyourself.ca>
|
||||||
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||||
|
* @link http://laconi.ca/
|
||||||
|
*/
|
||||||
|
|
||||||
class ShowmessageAction extends MailboxAction
|
class ShowmessageAction extends MailboxAction
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Message object to show
|
||||||
|
*/
|
||||||
|
|
||||||
|
var $message = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The current user
|
||||||
|
*/
|
||||||
|
|
||||||
|
var $user = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load attributes based on database arguments
|
||||||
|
*
|
||||||
|
* Loads all the DB stuff
|
||||||
|
*
|
||||||
|
* @param array $args $_REQUEST array
|
||||||
|
*
|
||||||
|
* @return success flag
|
||||||
|
*/
|
||||||
|
|
||||||
|
function prepare($args)
|
||||||
|
{
|
||||||
|
parent::prepare($args);
|
||||||
|
|
||||||
|
$this->page = 1;
|
||||||
|
|
||||||
|
$id = $this->trimmed('message');
|
||||||
|
$this->message = Message::staticGet('id', $id);
|
||||||
|
|
||||||
|
if (!$this->message) {
|
||||||
|
$this->clientError(_('No such message.'), 404);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->user = common_current_user();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
function handle($args)
|
function handle($args)
|
||||||
{
|
{
|
||||||
|
|
||||||
Action::handle($args);
|
Action::handle($args);
|
||||||
|
|
||||||
$message = $this->get_message();
|
if ($this->user && ($this->user->id == $this->message->from_profile ||
|
||||||
|
$this->user->id == $this->message->to_profile)) {
|
||||||
if (!$message) {
|
$this->showPage();
|
||||||
$this->client_error(_('No such message.'), 404);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$cur = common_current_user();
|
|
||||||
|
|
||||||
if ($cur && ($cur->id == $message->from_profile || $cur->id == $message->to_profile)) {
|
|
||||||
$this->show_page($cur, 1);
|
|
||||||
} else {
|
} else {
|
||||||
$this->client_error(_('Only the sender and recipient may read this message.'), 403);
|
$this->clientError(_('Only the sender and recipient ' .
|
||||||
|
'may read this message.'), 403);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_message()
|
function title()
|
||||||
{
|
{
|
||||||
$id = $this->trimmed('message');
|
if ($this->user->id == $this->message->from_profile) {
|
||||||
$message = Message::staticGet('id', $id);
|
$to = $this->message->getTo();
|
||||||
return $message;
|
return sprintf(_("Message to %1\$s on %2\$s"),
|
||||||
}
|
|
||||||
|
|
||||||
function get_title($user, $page)
|
|
||||||
{
|
|
||||||
$message = $this->get_message();
|
|
||||||
if (!$message) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($user->id == $message->from_profile) {
|
|
||||||
$to = $message->getTo();
|
|
||||||
$title = sprintf(_("Message to %1\$s on %2\$s"),
|
|
||||||
$to->nickname,
|
$to->nickname,
|
||||||
common_exact_date($message->created));
|
common_exact_date($this->message->created));
|
||||||
} else if ($user->id == $message->to_profile) {
|
} else if ($this->user->id == $this->message->to_profile) {
|
||||||
$from = $message->getFrom();
|
$from = $this->message->getFrom();
|
||||||
$title = sprintf(_("Message from %1\$s on %2\$s"),
|
return sprintf(_("Message from %1\$s on %2\$s"),
|
||||||
$from->nickname,
|
$from->nickname,
|
||||||
common_exact_date($message->created));
|
common_exact_date($this->message->created));
|
||||||
}
|
}
|
||||||
return $title;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_messages($user, $page)
|
function getMessages()
|
||||||
{
|
{
|
||||||
$message = new Message();
|
$message = new Message();
|
||||||
$message->id = $this->trimmed('message');
|
$message->id = $this->message->id;
|
||||||
$message->find();
|
$message->find();
|
||||||
return $message;
|
return $message;
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_message_profile($message)
|
function getMessageProfile()
|
||||||
{
|
{
|
||||||
$user = common_current_user();
|
if ($this->user->id == $this->message->from_profile) {
|
||||||
if ($user->id == $message->from_profile) {
|
return $this->message->getTo();
|
||||||
return $message->getTo();
|
} else if ($this->user->id == $this->message->to_profile) {
|
||||||
} else if ($user->id == $message->to_profile) {
|
return $this->message->getFrom();
|
||||||
return $message->getFrom();
|
|
||||||
} else {
|
} else {
|
||||||
# This shouldn't happen
|
// This shouldn't happen
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_instructions()
|
/**
|
||||||
|
* Don't show local navigation
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
|
function showLocalNavBlock()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Don't show page notice
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
|
function showPageNoticeBlock()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Don't show aside
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
|
function showAside()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Don't show any instructions
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
|
||||||
|
function getInstructions()
|
||||||
{
|
{
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
function views_menu()
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
@ -1,9 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/**
|
||||||
* Laconica - a distributed open-source microblogging tool
|
* Laconica, the distributed open-source microblogging tool
|
||||||
* Copyright (C) 2008, Controlez-Vous, Inc.
|
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* Show a single notice
|
||||||
|
*
|
||||||
|
* 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
|
* 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
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
@ -15,36 +18,80 @@
|
|||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* 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/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* @category Personal
|
||||||
|
* @package Laconica
|
||||||
|
* @author Evan Prodromou <evan@controlyourself.ca>
|
||||||
|
* @copyright 2008-2009 Control Yourself, Inc.
|
||||||
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||||
|
* @link http://laconi.ca/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('LACONICA')) { exit(1); }
|
if (!defined('LACONICA')) {
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
require_once(INSTALLDIR.'/lib/stream.php');
|
require_once INSTALLDIR.'/lib/personalgroupnav.php';
|
||||||
|
require_once INSTALLDIR.'/lib/noticelist.php';
|
||||||
|
require_once INSTALLDIR.'/lib/feedlist.php';
|
||||||
|
|
||||||
class ShownoticeAction extends StreamAction
|
/**
|
||||||
|
* Show a single notice
|
||||||
|
*
|
||||||
|
* @category Personal
|
||||||
|
* @package Laconica
|
||||||
|
* @author Evan Prodromou <evan@controlyourself.ca>
|
||||||
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||||
|
* @link http://laconi.ca/
|
||||||
|
*/
|
||||||
|
|
||||||
|
class ShownoticeAction extends Action
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Notice object to show
|
||||||
|
*/
|
||||||
|
|
||||||
var $notice = null;
|
var $notice = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Profile of the notice object
|
||||||
|
*/
|
||||||
|
|
||||||
var $profile = null;
|
var $profile = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Avatar of the profile of the notice object
|
||||||
|
*/
|
||||||
|
|
||||||
var $avatar = null;
|
var $avatar = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load attributes based on database arguments
|
||||||
|
*
|
||||||
|
* Loads all the DB stuff
|
||||||
|
*
|
||||||
|
* @param array $args $_REQUEST array
|
||||||
|
*
|
||||||
|
* @return success flag
|
||||||
|
*/
|
||||||
|
|
||||||
function prepare($args)
|
function prepare($args)
|
||||||
{
|
{
|
||||||
|
|
||||||
parent::prepare($args);
|
parent::prepare($args);
|
||||||
|
|
||||||
$id = $this->arg('notice');
|
$id = $this->arg('notice');
|
||||||
|
|
||||||
$this->notice = Notice::staticGet($id);
|
$this->notice = Notice::staticGet($id);
|
||||||
|
|
||||||
if (!$this->notice) {
|
if (!$this->notice) {
|
||||||
$this->client_error(_('No such notice.'), 404);
|
$this->clientError(_('No such notice.'), 404);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->profile = $this->notice->getProfile();
|
$this->profile = $this->notice->getProfile();
|
||||||
|
|
||||||
if (!$this->profile) {
|
if (!$this->profile) {
|
||||||
$this->server_error(_('Notice has no profile'), 500);
|
$this->serverError(_('Notice has no profile'), 500);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,45 +100,147 @@ class ShownoticeAction extends StreamAction
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function last_modified()
|
/**
|
||||||
|
* Is this action read-only?
|
||||||
|
*
|
||||||
|
* @return boolean true
|
||||||
|
*/
|
||||||
|
|
||||||
|
function isReadOnly()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Last-modified date for page
|
||||||
|
*
|
||||||
|
* When was the content of this page last modified? Based on notice,
|
||||||
|
* profile, avatar.
|
||||||
|
*
|
||||||
|
* @return int last-modified date as unix timestamp
|
||||||
|
*/
|
||||||
|
|
||||||
|
function lastModified()
|
||||||
{
|
{
|
||||||
return max(strtotime($this->notice->created),
|
return max(strtotime($this->notice->created),
|
||||||
strtotime($this->profile->modified),
|
strtotime($this->profile->modified),
|
||||||
($this->avatar) ? strtotime($this->avatar->modified) : 0);
|
($this->avatar) ? strtotime($this->avatar->modified) : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An entity tag for this page
|
||||||
|
*
|
||||||
|
* Shows the ETag for the page, based on the notice ID and timestamps
|
||||||
|
* for the notice, profile, and avatar. It's weak, since we change
|
||||||
|
* the date text "one hour ago", etc.
|
||||||
|
*
|
||||||
|
* @return string etag
|
||||||
|
*/
|
||||||
|
|
||||||
function etag()
|
function etag()
|
||||||
{
|
{
|
||||||
|
$avtime = ($this->avatar) ?
|
||||||
|
strtotime($this->avatar->modified) : 0;
|
||||||
|
|
||||||
return 'W/"' . implode(':', array($this->arg('action'),
|
return 'W/"' . implode(':', array($this->arg('action'),
|
||||||
common_language(),
|
common_language(),
|
||||||
$this->notice->id,
|
$this->notice->id,
|
||||||
strtotime($this->notice->created),
|
strtotime($this->notice->created),
|
||||||
strtotime($this->profile->modified),
|
strtotime($this->profile->modified),
|
||||||
($this->avatar) ? strtotime($this->avatar->modified) : 0)) . '"';
|
$avtime)) . '"';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Title of the page
|
||||||
|
*
|
||||||
|
* @return string title of the page
|
||||||
|
*/
|
||||||
|
|
||||||
|
function title()
|
||||||
|
{
|
||||||
|
return sprintf(_('%1$s\'s status on %2$s'),
|
||||||
|
$this->profile->nickname,
|
||||||
|
common_exact_date($this->notice->created));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle input
|
||||||
|
*
|
||||||
|
* Only handles get, so just show the page.
|
||||||
|
*
|
||||||
|
* @param array $args $_REQUEST data (unused)
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
function handle($args)
|
function handle($args)
|
||||||
{
|
{
|
||||||
|
|
||||||
parent::handle($args);
|
parent::handle($args);
|
||||||
|
|
||||||
common_show_header(sprintf(_('%1$s\'s status on %2$s'),
|
$this->showPage();
|
||||||
$this->profile->nickname,
|
|
||||||
common_exact_date($this->notice->created)),
|
|
||||||
array($this, 'show_header'), null,
|
|
||||||
array($this, 'show_top'));
|
|
||||||
|
|
||||||
common_element_start('ul', array('id' => 'notices'));
|
|
||||||
$nli = new NoticeListItem($this->notice);
|
|
||||||
$nli->show();
|
|
||||||
common_element_end('ul');
|
|
||||||
|
|
||||||
common_show_footer();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_header()
|
|
||||||
{
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Don't show local navigation
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
|
function showLocalNavBlock()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fill the content area of the page
|
||||||
|
*
|
||||||
|
* Shows a single notice list item.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
|
function showContent()
|
||||||
|
{
|
||||||
|
$this->elementStart('ul', array('class' => 'notices'));
|
||||||
|
$nli = new NoticeListItem($this->notice, $this);
|
||||||
|
$nli->show();
|
||||||
|
$this->elementEnd('ul');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Don't show page notice
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
|
function showPageNoticeBlock()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Don't show aside
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
|
function showAside() {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extra <head> content
|
||||||
|
*
|
||||||
|
* We show the microid(s) for the author, if any.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
|
function extraHead()
|
||||||
|
{
|
||||||
$user = User::staticGet($this->profile->id);
|
$user = User::staticGet($this->profile->id);
|
||||||
|
|
||||||
if (!$user) {
|
if (!$user) {
|
||||||
@ -99,26 +248,17 @@ class ShownoticeAction extends StreamAction
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($user->emailmicroid && $user->email && $this->notice->uri) {
|
if ($user->emailmicroid && $user->email && $this->notice->uri) {
|
||||||
common_element('meta', array('name' => 'microid',
|
$id = new Microid('mailto:'. $user->email,
|
||||||
'content' => "mailto+http:sha1:" . sha1(sha1('mailto:' . $user->email) . sha1($this->notice->uri))));
|
$this->notice->uri);
|
||||||
|
$this->element('meta', array('name' => 'microid',
|
||||||
|
'content' => $id->toString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($user->jabbermicroid && $user->jabber && $this->notice->uri) {
|
if ($user->jabbermicroid && $user->jabber && $this->notice->uri) {
|
||||||
common_element('meta', array('name' => 'microid',
|
$id = new Microid('xmpp:', $user->jabber,
|
||||||
'content' => "xmpp+http:sha1:" . sha1(sha1('xmpp:' . $user->jabber) . sha1($this->notice->uri))));
|
$this->notice->uri);
|
||||||
|
$this->element('meta', array('name' => 'microid',
|
||||||
|
'content' => $id->toString()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_top()
|
|
||||||
{
|
|
||||||
$cur = common_current_user();
|
|
||||||
if ($cur && $cur->id == $this->profile->id) {
|
|
||||||
common_notice_form();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function no_such_notice()
|
|
||||||
{
|
|
||||||
common_user_error(_('No such notice.'));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/**
|
||||||
* Laconica - a distributed open-source microblogging tool
|
* Laconica, the distributed open-source microblogging tool
|
||||||
* Copyright (C) 2008, Controlez-Vous, Inc.
|
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* User profile page
|
||||||
|
*
|
||||||
|
* 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
|
* 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
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
@ -15,27 +18,65 @@
|
|||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* 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/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* @category Personal
|
||||||
|
* @package Laconica
|
||||||
|
* @author Evan Prodromou <evan@controlyourself.ca>
|
||||||
|
* @author Sarven Capadisli <csarven@controlyourself.ca>
|
||||||
|
* @copyright 2008-2009 Control Yourself, Inc.
|
||||||
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||||
|
* @link http://laconi.ca/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('LACONICA')) { exit(1); }
|
if (!defined('LACONICA')) {
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
require_once(INSTALLDIR.'/lib/stream.php');
|
require_once INSTALLDIR.'/lib/personalgroupnav.php';
|
||||||
|
require_once INSTALLDIR.'/lib/noticelist.php';
|
||||||
|
require_once INSTALLDIR.'/lib/feedlist.php';
|
||||||
|
|
||||||
define('SUBSCRIPTIONS_PER_ROW', 4);
|
/**
|
||||||
define('SUBSCRIPTIONS', 80);
|
* User profile page
|
||||||
|
*
|
||||||
|
* When I created this page, "show stream" seemed like the best name for it.
|
||||||
|
* Now, it seems like a really bad name.
|
||||||
|
*
|
||||||
|
* It shows a stream of the user's posts, plus lots of profile info, links
|
||||||
|
* to subscriptions and stuff, etc.
|
||||||
|
*
|
||||||
|
* @category Personal
|
||||||
|
* @package Laconica
|
||||||
|
* @author Evan Prodromou <evan@controlyourself.ca>
|
||||||
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||||
|
* @link http://laconi.ca/
|
||||||
|
*/
|
||||||
|
|
||||||
class ShowstreamAction extends StreamAction
|
class ShowstreamAction extends Action
|
||||||
{
|
{
|
||||||
|
var $user = null;
|
||||||
|
var $page = null;
|
||||||
|
var $profile = null;
|
||||||
|
|
||||||
function handle($args)
|
function title()
|
||||||
{
|
{
|
||||||
|
if ($this->page == 1) {
|
||||||
|
return $this->user->nickname;
|
||||||
|
} else {
|
||||||
|
return sprintf(_("%s, page %d"),
|
||||||
|
$this->user->nickname,
|
||||||
|
$this->page);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
parent::handle($args);
|
function prepare($args)
|
||||||
|
{
|
||||||
|
parent::prepare($args);
|
||||||
|
|
||||||
$nickname_arg = $this->arg('nickname');
|
$nickname_arg = $this->arg('nickname');
|
||||||
$nickname = common_canonical_nickname($nickname_arg);
|
$nickname = common_canonical_nickname($nickname_arg);
|
||||||
|
|
||||||
# Permanent redirect on non-canonical nickname
|
// Permanent redirect on non-canonical nickname
|
||||||
|
|
||||||
if ($nickname_arg != $nickname) {
|
if ($nickname_arg != $nickname) {
|
||||||
$args = array('nickname' => $nickname);
|
$args = array('nickname' => $nickname);
|
||||||
@ -43,263 +84,314 @@ class ShowstreamAction extends StreamAction
|
|||||||
$args['page'] = $this->arg['page'];
|
$args['page'] = $this->arg['page'];
|
||||||
}
|
}
|
||||||
common_redirect(common_local_url('showstream', $args), 301);
|
common_redirect(common_local_url('showstream', $args), 301);
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$user = User::staticGet('nickname', $nickname);
|
$this->user = User::staticGet('nickname', $nickname);
|
||||||
|
|
||||||
if (!$user) {
|
if (!$this->user) {
|
||||||
$this->no_such_user();
|
$this->clientError(_('No such user.'), 404);
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$profile = $user->getProfile();
|
$this->profile = $this->user->getProfile();
|
||||||
|
|
||||||
if (!$profile) {
|
if (!$this->profile) {
|
||||||
common_server_error(_('User has no profile.'));
|
$this->serverError(_('User has no profile.'));
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Looks like we're good; start output
|
$this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
|
||||||
|
|
||||||
# For YADIS discovery, we also have a <meta> tag
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function handle($args)
|
||||||
|
{
|
||||||
|
|
||||||
|
// Looks like we're good; start output
|
||||||
|
|
||||||
|
// For YADIS discovery, we also have a <meta> tag
|
||||||
|
|
||||||
header('X-XRDS-Location: '. common_local_url('xrds', array('nickname' =>
|
header('X-XRDS-Location: '. common_local_url('xrds', array('nickname' =>
|
||||||
$user->nickname)));
|
$this->user->nickname)));
|
||||||
|
|
||||||
common_show_header($profile->nickname,
|
$this->showPage();
|
||||||
array($this, 'show_header'), $user,
|
|
||||||
array($this, 'show_top'));
|
|
||||||
|
|
||||||
$this->show_profile($profile);
|
|
||||||
|
|
||||||
$this->show_notices($user);
|
|
||||||
|
|
||||||
common_show_footer();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_top($user)
|
function showContent()
|
||||||
{
|
{
|
||||||
$cur = common_current_user();
|
$this->showProfile();
|
||||||
|
$this->showNotices();
|
||||||
if ($cur && $cur->id == $user->id) {
|
|
||||||
common_notice_form('showstream');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->views_menu();
|
function showLocalNav()
|
||||||
|
{
|
||||||
|
$nav = new PersonalGroupNav($this);
|
||||||
|
$nav->show();
|
||||||
|
}
|
||||||
|
|
||||||
$this->show_feeds_list(array(0=>array('href'=>common_local_url('userrss', array('nickname' => $user->nickname)),
|
function showPageTitle()
|
||||||
|
{
|
||||||
|
$this->element('h1', NULL, $this->profile->nickname._("'s profile"));
|
||||||
|
}
|
||||||
|
|
||||||
|
function showPageNoticeBlock()
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
function showExportData()
|
||||||
|
{
|
||||||
|
$fl = new FeedList($this);
|
||||||
|
$fl->show(array(0=>array('href'=>common_local_url('userrss',
|
||||||
|
array('nickname' => $this->user->nickname)),
|
||||||
'type' => 'rss',
|
'type' => 'rss',
|
||||||
'version' => 'RSS 1.0',
|
'version' => 'RSS 1.0',
|
||||||
'item' => 'notices'),
|
'item' => 'notices'),
|
||||||
1=>array('href'=>common_local_url('usertimeline', array('nickname' => $user->nickname)),
|
1=>array('href'=>common_local_url('usertimeline',
|
||||||
|
array('nickname' => $this->user->nickname)),
|
||||||
'type' => 'atom',
|
'type' => 'atom',
|
||||||
'version' => 'Atom 1.0',
|
'version' => 'Atom 1.0',
|
||||||
'item' => 'usertimeline'),
|
'item' => 'usertimeline'),
|
||||||
|
2=>array('href'=>common_local_url('foaf',
|
||||||
2=>array('href'=>common_local_url('foaf',array('nickname' => $user->nickname)),
|
array('nickname' => $this->user->nickname)),
|
||||||
'type' => 'rdf',
|
'type' => 'rdf',
|
||||||
'version' => 'FOAF',
|
'version' => 'FOAF',
|
||||||
'item' => 'foaf')));
|
'item' => 'foaf')));
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_header($user)
|
function showFeeds()
|
||||||
{
|
{
|
||||||
# Feeds
|
// Feeds
|
||||||
common_element('link', array('rel' => 'alternate',
|
$this->element('link', array('rel' => 'alternate',
|
||||||
'href' => common_local_url('api',
|
'href' => common_local_url('api',
|
||||||
array('apiaction' => 'statuses',
|
array('apiaction' => 'statuses',
|
||||||
'method' => 'user_timeline.rss',
|
'method' => 'user_timeline.rss',
|
||||||
'argument' => $user->nickname)),
|
'argument' => $this->user->nickname)),
|
||||||
'type' => 'application/rss+xml',
|
'type' => 'application/rss+xml',
|
||||||
'title' => sprintf(_('Notice feed for %s'), $user->nickname)));
|
'title' => sprintf(_('Notice feed for %s'), $this->user->nickname)));
|
||||||
common_element('link', array('rel' => 'alternate feed',
|
$this->element('link', array('rel' => 'alternate feed',
|
||||||
'href' => common_local_url('api',
|
'href' => common_local_url('api',
|
||||||
array('apiaction' => 'statuses',
|
array('apiaction' => 'statuses',
|
||||||
'method' => 'user_timeline.atom',
|
'method' => 'user_timeline.atom',
|
||||||
'argument' => $user->nickname)),
|
'argument' => $this->user->nickname)),
|
||||||
'type' => 'application/atom+xml',
|
'type' => 'application/atom+xml',
|
||||||
'title' => sprintf(_('Notice feed for %s'), $user->nickname)));
|
'title' => sprintf(_('Notice feed for %s'), $this->user->nickname)));
|
||||||
common_element('link', array('rel' => 'alternate',
|
$this->element('link', array('rel' => 'alternate',
|
||||||
'href' => common_local_url('userrss', array('nickname' =>
|
'href' => common_local_url('userrss', array('nickname' =>
|
||||||
$user->nickname)),
|
$this->user->nickname)),
|
||||||
'type' => 'application/rdf+xml',
|
'type' => 'application/rdf+xml',
|
||||||
'title' => sprintf(_('Notice feed for %s'), $user->nickname)));
|
'title' => sprintf(_('Notice feed for %s'), $this->user->nickname)));
|
||||||
# FOAF
|
}
|
||||||
common_element('link', array('rel' => 'meta',
|
|
||||||
|
function extraHead()
|
||||||
|
{
|
||||||
|
// FOAF
|
||||||
|
$this->element('link', array('rel' => 'meta',
|
||||||
'href' => common_local_url('foaf', array('nickname' =>
|
'href' => common_local_url('foaf', array('nickname' =>
|
||||||
$user->nickname)),
|
$this->user->nickname)),
|
||||||
'type' => 'application/rdf+xml',
|
'type' => 'application/rdf+xml',
|
||||||
'title' => 'FOAF'));
|
'title' => 'FOAF'));
|
||||||
# for remote subscriptions etc.
|
// for remote subscriptions etc.
|
||||||
common_element('meta', array('http-equiv' => 'X-XRDS-Location',
|
$this->element('meta', array('http-equiv' => 'X-XRDS-Location',
|
||||||
'content' => common_local_url('xrds', array('nickname' =>
|
'content' => common_local_url('xrds', array('nickname' =>
|
||||||
$user->nickname))));
|
$this->user->nickname))));
|
||||||
$profile = $user->getProfile();
|
|
||||||
if ($profile->bio) {
|
if ($this->profile->bio) {
|
||||||
common_element('meta', array('name' => 'description',
|
$this->element('meta', array('name' => 'description',
|
||||||
'content' => $profile->bio));
|
'content' => $this->profile->bio));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($user->emailmicroid && $user->email && $profile->profileurl) {
|
if ($this->user->emailmicroid && $this->user->email && $this->profile->profileurl) {
|
||||||
common_element('meta', array('name' => 'microid',
|
$id = new Microid('mailto:'.$this->user->email,
|
||||||
'content' => "mailto+http:sha1:" . sha1(sha1('mailto:' . $user->email) . sha1($profile->profileurl))));
|
$this->selfUrl());
|
||||||
|
$this->element('meta', array('name' => 'microid',
|
||||||
|
'content' => $id->toString()));
|
||||||
}
|
}
|
||||||
if ($user->jabbermicroid && $user->jabber && $profile->profileurl) {
|
if ($this->user->jabbermicroid && $this->user->jabber && $this->profile->profileurl) {
|
||||||
common_element('meta', array('name' => 'microid',
|
$id = new Microid('xmpp:'.$this->user->jabber,
|
||||||
'content' => "xmpp+http:sha1:" . sha1(sha1('xmpp:' . $user->jabber) . sha1($profile->profileurl))));
|
$this->selfUrl());
|
||||||
|
$this->element('meta', array('name' => 'microid',
|
||||||
|
'content' => $id->toString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
# See https://wiki.mozilla.org/Microsummaries
|
// See https://wiki.mozilla.org/Microsummaries
|
||||||
|
|
||||||
common_element('link', array('rel' => 'microsummary',
|
$this->element('link', array('rel' => 'microsummary',
|
||||||
'href' => common_local_url('microsummary',
|
'href' => common_local_url('microsummary',
|
||||||
array('nickname' => $profile->nickname))));
|
array('nickname' => $this->profile->nickname))));
|
||||||
}
|
}
|
||||||
|
|
||||||
function no_such_user()
|
function showProfile()
|
||||||
{
|
{
|
||||||
$this->client_error(_('No such user.'), 404);
|
$this->elementStart('div', array('id' => 'user_profile', 'class' => 'vcard author'));
|
||||||
}
|
$this->element('h2', null, _('User profile'));
|
||||||
|
|
||||||
function show_profile($profile)
|
$avatar = $this->profile->getAvatar(AVATAR_PROFILE_SIZE);
|
||||||
{
|
$this->elementStart('dl', 'user_depiction');
|
||||||
|
$this->element('dt', null, _('Photo'));
|
||||||
common_element_start('div', array('id' => 'profile', 'class' => 'vcard'));
|
$this->elementStart('dd');
|
||||||
|
$this->element('img', array('src' => ($avatar) ? common_avatar_display_url($avatar) : common_default_avatar(AVATAR_PROFILE_SIZE),
|
||||||
$this->show_personal($profile);
|
'class' => 'photo avatar',
|
||||||
|
|
||||||
$this->show_last_notice($profile);
|
|
||||||
|
|
||||||
$cur = common_current_user();
|
|
||||||
|
|
||||||
$this->show_subscriptions($profile);
|
|
||||||
|
|
||||||
common_element_end('div');
|
|
||||||
}
|
|
||||||
|
|
||||||
function show_personal($profile)
|
|
||||||
{
|
|
||||||
|
|
||||||
$avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE);
|
|
||||||
common_element_start('div', array('id' => 'profile_avatar'));
|
|
||||||
common_element('img', array('src' => ($avatar) ? common_avatar_display_url($avatar) : common_default_avatar(AVATAR_PROFILE_SIZE),
|
|
||||||
'class' => 'avatar profile photo',
|
|
||||||
'width' => AVATAR_PROFILE_SIZE,
|
'width' => AVATAR_PROFILE_SIZE,
|
||||||
'height' => AVATAR_PROFILE_SIZE,
|
'height' => AVATAR_PROFILE_SIZE,
|
||||||
'alt' => $profile->nickname));
|
'alt' => $this->profile->nickname));
|
||||||
|
$this->elementEnd('dd');
|
||||||
|
$this->elementEnd('dl');
|
||||||
|
|
||||||
common_element_start('ul', array('id' => 'profile_actions'));
|
$this->elementStart('dl', 'user_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');
|
||||||
|
|
||||||
common_element_start('li', array('id' => 'profile_subscribe'));
|
if ($this->profile->fullname) {
|
||||||
|
$this->elementStart('dl', 'user_fn');
|
||||||
|
$this->element('dt', null, _('Full name'));
|
||||||
|
$this->elementStart('dd');
|
||||||
|
$this->element('span', 'fn', $this->profile->fullname);
|
||||||
|
$this->elementEnd('dd');
|
||||||
|
$this->elementEnd('dl');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->profile->location) {
|
||||||
|
$this->elementStart('dl', 'user_location');
|
||||||
|
$this->element('dt', null, _('Location'));
|
||||||
|
$this->element('dd', 'location', $this->profile->location);
|
||||||
|
$this->elementEnd('dl');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->profile->homepage) {
|
||||||
|
$this->elementStart('dl', 'user_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');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->profile->bio) {
|
||||||
|
$this->elementStart('dl', 'user_note');
|
||||||
|
$this->element('dt', null, _('Note'));
|
||||||
|
$this->element('dd', 'note', $this->profile->bio);
|
||||||
|
$this->elementEnd('dl');
|
||||||
|
}
|
||||||
|
|
||||||
|
$tags = Profile_tag::getTags($this->profile->id, $this->profile->id);
|
||||||
|
if (count($tags) > 0) {
|
||||||
|
$this->elementStart('dl', 'user_tags');
|
||||||
|
$this->element('dt', null, _('Tags'));
|
||||||
|
$this->elementStart('dd');
|
||||||
|
$this->elementStart('ul', 'tags xoxo');
|
||||||
|
foreach ($tags as $tag) {
|
||||||
|
$this->elementStart('li');
|
||||||
|
$this->element('span', 'mark_hash', '#');
|
||||||
|
$this->element('a', array('rel' => 'tag',
|
||||||
|
'href' => common_local_url('peopletag',
|
||||||
|
array('tag' => $tag))),
|
||||||
|
$tag);
|
||||||
|
$this->elementEnd('li');
|
||||||
|
}
|
||||||
|
$this->elementEnd('ul');
|
||||||
|
$this->elementEnd('dd');
|
||||||
|
$this->elementEnd('dl');
|
||||||
|
}
|
||||||
|
$this->elementEnd('div');
|
||||||
|
|
||||||
|
|
||||||
|
$this->elementStart('div', array('id' => 'user_actions'));
|
||||||
|
$this->element('h2', null, _('User actions'));
|
||||||
|
$this->elementStart('ul');
|
||||||
|
$this->elementStart('li', array('id' => 'user_subscribe'));
|
||||||
$cur = common_current_user();
|
$cur = common_current_user();
|
||||||
if ($cur) {
|
if ($cur) {
|
||||||
if ($cur->id != $profile->id) {
|
if ($cur->id != $this->profile->id) {
|
||||||
if ($cur->isSubscribed($profile)) {
|
if ($cur->isSubscribed($this->profile)) {
|
||||||
common_unsubscribe_form($profile);
|
$sf = new SubscribeForm($this, $this->profile);
|
||||||
|
$sf->show();
|
||||||
} else {
|
} else {
|
||||||
common_subscribe_form($profile);
|
$usf = new UnsubscribeForm($this, $this->profile);
|
||||||
|
$usf->show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$this->show_remote_subscribe_link($profile);
|
$this->showRemoteSubscribeLink();
|
||||||
}
|
}
|
||||||
common_element_end('li');
|
$this->elementEnd('li');
|
||||||
|
|
||||||
$user = User::staticGet('id', $profile->id);
|
common_profile_new_message_nudge($cur, $this->user, $this->profile);
|
||||||
common_profile_new_message_nudge($cur, $user, $profile);
|
|
||||||
|
|
||||||
if ($cur && $cur->id != $profile->id) {
|
if ($cur && $cur->id != $this->profile->id) {
|
||||||
$blocked = $cur->hasBlocked($profile);
|
$blocked = $cur->hasBlocked($this->profile);
|
||||||
common_element_start('li', array('id' => 'profile_block'));
|
$this->elementStart('li', array('id' => 'user_block'));
|
||||||
if ($blocked) {
|
if ($blocked) {
|
||||||
common_unblock_form($profile, array('action' => 'showstream',
|
$bf = new BlockForm($this, $this->profile);
|
||||||
'nickname' => $profile->nickname));
|
$bf->show();
|
||||||
} else {
|
} else {
|
||||||
common_block_form($profile, array('action' => 'showstream',
|
$ubf = new UnblockForm($this, $this->profile);
|
||||||
'nickname' => $profile->nickname));
|
$ubf->show();
|
||||||
}
|
}
|
||||||
common_element_end('li');
|
$this->elementEnd('li');
|
||||||
|
}
|
||||||
|
$this->elementEnd('ul');
|
||||||
|
$this->elementEnd('div');
|
||||||
}
|
}
|
||||||
|
|
||||||
common_element_end('ul');
|
function showRemoteSubscribeLink()
|
||||||
|
|
||||||
common_element_end('div');
|
|
||||||
|
|
||||||
common_element_start('div', array('id' => 'profile_information'));
|
|
||||||
|
|
||||||
if ($profile->fullname) {
|
|
||||||
common_element('h1', array('class' => 'fn'), $profile->fullname . ' (' . $profile->nickname . ')');
|
|
||||||
} else {
|
|
||||||
common_element('h1', array('class' => 'fn nickname'), $profile->nickname);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($profile->location) {
|
|
||||||
common_element('p', 'location', $profile->location);
|
|
||||||
}
|
|
||||||
if ($profile->bio) {
|
|
||||||
common_element('p', 'description note', $profile->bio);
|
|
||||||
}
|
|
||||||
if ($profile->homepage) {
|
|
||||||
common_element_start('p', 'website');
|
|
||||||
common_element('a', array('href' => $profile->homepage,
|
|
||||||
'rel' => 'me', 'class' => 'url'),
|
|
||||||
$profile->homepage);
|
|
||||||
common_element_end('p');
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->show_statistics($profile);
|
|
||||||
|
|
||||||
common_element_end('div');
|
|
||||||
}
|
|
||||||
|
|
||||||
function show_remote_subscribe_link($profile)
|
|
||||||
{
|
{
|
||||||
$url = common_local_url('remotesubscribe',
|
$url = common_local_url('remotesubscribe',
|
||||||
array('nickname' => $profile->nickname));
|
array('nickname' => $this->profile->nickname));
|
||||||
common_element('a', array('href' => $url,
|
$this->element('a', array('href' => $url,
|
||||||
'id' => 'remotesubscribe'),
|
'id' => 'remotesubscribe'),
|
||||||
_('Subscribe'));
|
_('Subscribe'));
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_unsubscribe_form($profile)
|
function showNotices()
|
||||||
{
|
{
|
||||||
common_element_start('form', array('id' => 'unsubscribe', 'method' => 'post',
|
$notice = $this->user->getNotices(($this->page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1);
|
||||||
'action' => common_local_url('unsubscribe')));
|
|
||||||
common_hidden('token', common_session_token());
|
$pnl = new ProfileNoticeList($notice, $this);
|
||||||
common_element('input', array('id' => 'unsubscribeto',
|
$cnt = $pnl->show();
|
||||||
'name' => 'unsubscribeto',
|
|
||||||
'type' => 'hidden',
|
$this->pagination($this->page>1, $cnt>NOTICES_PER_PAGE, $this->page,
|
||||||
'value' => $profile->nickname));
|
'showstream', array('nickname' => $this->user->nickname));
|
||||||
common_element('input', array('type' => 'submit',
|
|
||||||
'class' => 'submit',
|
|
||||||
'value' => _('Unsubscribe')));
|
|
||||||
common_element_end('form');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_subscriptions($profile)
|
function showSections()
|
||||||
{
|
{
|
||||||
global $config;
|
$this->showStatistics();
|
||||||
|
$this->showSubscriptions();
|
||||||
|
}
|
||||||
|
|
||||||
$subs = DB_DataObject::factory('subscription');
|
function showSubscriptions()
|
||||||
$subs->subscriber = $profile->id;
|
{
|
||||||
$subs->whereAdd('subscribed != ' . $profile->id);
|
$subs = new Subscription();
|
||||||
|
$subs->subscriber = $this->profile->id;
|
||||||
|
$subs->whereAdd('subscribed != ' . $this->profile->id);
|
||||||
|
|
||||||
$subs->orderBy('created DESC');
|
$subs->orderBy('created DESC');
|
||||||
|
|
||||||
# We ask for an extra one to know if we need to do another page
|
// We ask for an extra one to know if we need to do another page
|
||||||
|
|
||||||
$subs->limit(0, SUBSCRIPTIONS + 1);
|
$subs->limit(0, SUBSCRIPTIONS + 1);
|
||||||
|
|
||||||
$subs_count = $subs->find();
|
$subs_count = $subs->find();
|
||||||
|
|
||||||
common_element_start('div', array('id' => 'subscriptions'));
|
$this->elementStart('div', array('id' => 'user_subscriptions',
|
||||||
|
'class' => 'section'));
|
||||||
|
|
||||||
common_element('h2', null, _('Subscriptions'));
|
$this->element('h2', null, _('Subscriptions'));
|
||||||
|
|
||||||
if ($subs_count > 0) {
|
if ($subs_count > 0) {
|
||||||
|
|
||||||
common_element_start('ul', array('id' => 'subscriptions_avatars'));
|
$this->elementStart('ul', 'users');
|
||||||
|
|
||||||
for ($i = 0; $i < min($subs_count, SUBSCRIPTIONS); $i++) {
|
for ($i = 0; $i < min($subs_count, SUBSCRIPTIONS); $i++) {
|
||||||
|
|
||||||
@ -315,146 +407,104 @@ class ShowstreamAction extends StreamAction
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
common_element_start('li', 'vcard');
|
$this->elementStart('li', 'vcard');
|
||||||
common_element_start('a', array('title' => ($other->fullname) ?
|
$this->elementStart('a', array('title' => ($other->fullname) ?
|
||||||
$other->fullname :
|
$other->fullname :
|
||||||
$other->nickname,
|
$other->nickname,
|
||||||
'href' => $other->profileurl,
|
'href' => $other->profileurl,
|
||||||
'rel' => 'contact',
|
'rel' => 'contact',
|
||||||
'class' => 'subscription fn url'));
|
'class' => 'url'));
|
||||||
$avatar = $other->getAvatar(AVATAR_MINI_SIZE);
|
$avatar = $other->getAvatar(AVATAR_MINI_SIZE);
|
||||||
common_element('img', array('src' => (($avatar) ? common_avatar_display_url($avatar) : common_default_avatar(AVATAR_MINI_SIZE)),
|
$this->element('img', array('src' => (($avatar) ? common_avatar_display_url($avatar) : common_default_avatar(AVATAR_MINI_SIZE)),
|
||||||
'width' => AVATAR_MINI_SIZE,
|
'width' => AVATAR_MINI_SIZE,
|
||||||
'height' => AVATAR_MINI_SIZE,
|
'height' => AVATAR_MINI_SIZE,
|
||||||
'class' => 'avatar mini photo',
|
'class' => 'avatar photo',
|
||||||
'alt' => ($other->fullname) ?
|
'alt' => ($other->fullname) ?
|
||||||
$other->fullname :
|
$other->fullname :
|
||||||
$other->nickname));
|
$other->nickname));
|
||||||
common_element_end('a');
|
$this->element('span', 'fn nickname', $other->nickname);
|
||||||
common_element_end('li');
|
$this->elementEnd('a');
|
||||||
|
$this->elementEnd('li');
|
||||||
}
|
}
|
||||||
|
|
||||||
common_element_end('ul');
|
$this->elementEnd('ul');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($subs_count > SUBSCRIPTIONS) {
|
if ($subs_count > SUBSCRIPTIONS) {
|
||||||
common_element_start('p', array('id' => 'subscriptions_viewall'));
|
$this->elementStart('p');
|
||||||
|
|
||||||
common_element('a', array('href' => common_local_url('subscriptions',
|
$this->element('a', array('href' => common_local_url('subscriptions',
|
||||||
array('nickname' => $profile->nickname)),
|
array('nickname' => $this->profile->nickname)),
|
||||||
'class' => 'moresubscriptions'),
|
'class' => 'mores'),
|
||||||
_('All subscriptions'));
|
_('All subscriptions'));
|
||||||
common_element_end('p');
|
$this->elementEnd('p');
|
||||||
}
|
}
|
||||||
|
|
||||||
common_element_end('div');
|
$this->elementEnd('div');
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_statistics($profile)
|
function showStatistics()
|
||||||
{
|
{
|
||||||
|
|
||||||
// XXX: WORM cache this
|
// XXX: WORM cache this
|
||||||
$subs = DB_DataObject::factory('subscription');
|
$subs = new Subscription();
|
||||||
$subs->subscriber = $profile->id;
|
$subs->subscriber = $this->profile->id;
|
||||||
$subs_count = (int) $subs->count() - 1;
|
$subs_count = (int) $subs->count() - 1;
|
||||||
|
|
||||||
$subbed = DB_DataObject::factory('subscription');
|
$subbed = new Subscription();
|
||||||
$subbed->subscribed = $profile->id;
|
$subbed->subscribed = $this->profile->id;
|
||||||
$subbed_count = (int) $subbed->count() - 1;
|
$subbed_count = (int) $subbed->count() - 1;
|
||||||
|
|
||||||
$notices = DB_DataObject::factory('notice');
|
$notices = new Notice();
|
||||||
$notices->profile_id = $profile->id;
|
$notices->profile_id = $this->profile->id;
|
||||||
$notice_count = (int) $notices->count();
|
$notice_count = (int) $notices->count();
|
||||||
|
|
||||||
common_element_start('div', 'statistics');
|
$this->elementStart('div', array('id' => 'user_statistics',
|
||||||
common_element('h2', 'statistics', _('Statistics'));
|
'class' => 'section'));
|
||||||
|
|
||||||
# Other stats...?
|
$this->element('h2', null, _('Statistics'));
|
||||||
common_element_start('dl', 'statistics');
|
|
||||||
common_element('dt', 'membersince', _('Member since'));
|
|
||||||
common_element('dd', 'membersince', date('j M Y',
|
|
||||||
strtotime($profile->created)));
|
|
||||||
|
|
||||||
common_element_start('dt', 'subscriptions');
|
// Other stats...?
|
||||||
common_element('a', array('href' => common_local_url('subscriptions',
|
$this->elementStart('dl', 'user_member-since');
|
||||||
array('nickname' => $profile->nickname))),
|
$this->element('dt', null, _('Member since'));
|
||||||
|
$this->element('dd', null, date('j M Y',
|
||||||
|
strtotime($this->profile->created)));
|
||||||
|
$this->elementEnd('dl');
|
||||||
|
|
||||||
|
$this->elementStart('dl', 'user_subscriptions');
|
||||||
|
$this->elementStart('dt');
|
||||||
|
$this->element('a', array('href' => common_local_url('subscriptions',
|
||||||
|
array('nickname' => $this->profile->nickname))),
|
||||||
_('Subscriptions'));
|
_('Subscriptions'));
|
||||||
common_element_end('dt');
|
$this->elementEnd('dt');
|
||||||
common_element('dd', 'subscriptions', (is_int($subs_count)) ? $subs_count : '0');
|
$this->element('dd', null, (is_int($subs_count)) ? $subs_count : '0');
|
||||||
common_element_start('dt', 'subscribers');
|
$this->elementEnd('dl');
|
||||||
common_element('a', array('href' => common_local_url('subscribers',
|
|
||||||
array('nickname' => $profile->nickname))),
|
$this->elementStart('dl', 'user_subscribers');
|
||||||
|
$this->elementStart('dt');
|
||||||
|
$this->element('a', array('href' => common_local_url('subscribers',
|
||||||
|
array('nickname' => $this->profile->nickname))),
|
||||||
_('Subscribers'));
|
_('Subscribers'));
|
||||||
common_element_end('dt');
|
$this->elementEnd('dt');
|
||||||
common_element('dd', 'subscribers', (is_int($subbed_count)) ? $subbed_count : '0');
|
$this->element('dd', 'subscribers', (is_int($subbed_count)) ? $subbed_count : '0');
|
||||||
common_element('dt', 'notices', _('Notices'));
|
$this->elementEnd('dl');
|
||||||
common_element('dd', 'notices', (is_int($notice_count)) ? $notice_count : '0');
|
|
||||||
# XXX: link these to something
|
|
||||||
common_element('dt', 'tags', _('Tags'));
|
|
||||||
common_element_start('dd', 'tags');
|
|
||||||
$tags = Profile_tag::getTags($profile->id, $profile->id);
|
|
||||||
|
|
||||||
common_element_start('ul', 'tags xoxo');
|
$this->elementStart('dl', 'user_notices');
|
||||||
foreach ($tags as $tag) {
|
$this->element('dt', null, _('Notices'));
|
||||||
common_element_start('li');
|
$this->element('dd', null, (is_int($notice_count)) ? $notice_count : '0');
|
||||||
common_element('a', array('rel' => 'bookmark tag',
|
$this->elementEnd('dl');
|
||||||
'href' => common_local_url('peopletag',
|
|
||||||
array('tag' => $tag))),
|
|
||||||
$tag);
|
|
||||||
common_element_end('li');
|
|
||||||
}
|
|
||||||
common_element_end('ul');
|
|
||||||
common_element_end('dd');
|
|
||||||
|
|
||||||
common_element_end('dl');
|
$this->elementEnd('div');
|
||||||
|
|
||||||
common_element_end('div');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_notices($user)
|
|
||||||
{
|
|
||||||
|
|
||||||
$page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
|
|
||||||
|
|
||||||
$notice = $user->getNotices(($page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1);
|
|
||||||
|
|
||||||
$pnl = new ProfileNoticeList($notice);
|
|
||||||
$cnt = $pnl->show();
|
|
||||||
|
|
||||||
common_pagination($page>1, $cnt>NOTICES_PER_PAGE, $page,
|
|
||||||
'showstream', array('nickname' => $user->nickname));
|
|
||||||
}
|
|
||||||
|
|
||||||
function show_last_notice($profile)
|
|
||||||
{
|
|
||||||
|
|
||||||
common_element('h2', null, _('Currently'));
|
|
||||||
|
|
||||||
$notice = $profile->getCurrentNotice();
|
|
||||||
|
|
||||||
if ($notice) {
|
|
||||||
# FIXME: URL, image, video, audio
|
|
||||||
common_element_start('p', array('class' => 'notice_current'));
|
|
||||||
if ($notice->rendered) {
|
|
||||||
common_raw($notice->rendered);
|
|
||||||
} else {
|
|
||||||
# XXX: may be some uncooked notices in the DB,
|
|
||||||
# we cook them right now. This can probably disappear in future
|
|
||||||
# versions (>> 0.4.x)
|
|
||||||
common_raw(common_render_content($notice->content, $notice));
|
|
||||||
}
|
|
||||||
common_element_end('p');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# We don't show the author for a profile, since we already know who it is!
|
// We don't show the author for a profile, since we already know who it is!
|
||||||
|
|
||||||
class ProfileNoticeList extends NoticeList
|
class ProfileNoticeList extends NoticeList
|
||||||
{
|
{
|
||||||
function newListItem($notice)
|
function newListItem($notice)
|
||||||
{
|
{
|
||||||
return new ProfileNoticeListItem($notice);
|
return new ProfileNoticeListItem($notice, $this->out);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/**
|
||||||
* Laconica - a distributed open-source microblogging tool
|
* Laconica, the distributed open-source microblogging tool
|
||||||
* Copyright (C) 2008, Controlez-Vous, Inc.
|
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* Settings for SMS
|
||||||
|
*
|
||||||
|
* 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
|
* 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
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
@ -15,103 +18,177 @@
|
|||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* 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/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* @category Settings
|
||||||
|
* @package Laconica
|
||||||
|
* @author Evan Prodromou <evan@controlyourself.ca>
|
||||||
|
* @copyright 2008-2009 Control Yourself, Inc.
|
||||||
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||||
|
* @link http://laconi.ca/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('LACONICA')) { exit(1); }
|
if (!defined('LACONICA')) {
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
require_once(INSTALLDIR.'/lib/settingsaction.php');
|
require_once INSTALLDIR.'/lib/connectsettingsaction.php';
|
||||||
require_once(INSTALLDIR.'/actions/emailsettings.php');
|
|
||||||
|
|
||||||
class SmssettingsAction extends EmailsettingsAction
|
/**
|
||||||
|
* Settings for SMS
|
||||||
|
*
|
||||||
|
* @category Settings
|
||||||
|
* @package Laconica
|
||||||
|
* @author Evan Prodromou <evan@controlyourself.ca>
|
||||||
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||||
|
* @link http://laconi.ca/
|
||||||
|
*
|
||||||
|
* @see SettingsAction
|
||||||
|
*/
|
||||||
|
|
||||||
|
class SmssettingsAction extends ConnectSettingsAction
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Title of the page
|
||||||
|
*
|
||||||
|
* @return string Title of the page
|
||||||
|
*/
|
||||||
|
|
||||||
function get_instructions()
|
function title()
|
||||||
|
{
|
||||||
|
return _('SMS Settings');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instructions for use
|
||||||
|
*
|
||||||
|
* @return instructions for use
|
||||||
|
*/
|
||||||
|
|
||||||
|
function getInstructions()
|
||||||
{
|
{
|
||||||
return _('You can receive SMS messages through email from %%site.name%%.');
|
return _('You can receive SMS messages through email from %%site.name%%.');
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_form($msg=null, $success=false)
|
/**
|
||||||
|
* Content area of the page
|
||||||
|
*
|
||||||
|
* Shows a form for adding and removing SMS phone numbers and setting
|
||||||
|
* SMS preferences.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
|
function showContent()
|
||||||
{
|
{
|
||||||
$user = common_current_user();
|
$user = common_current_user();
|
||||||
$this->form_header(_('SMS Settings'), $msg, $success);
|
|
||||||
common_element_start('form', array('method' => 'post',
|
$this->elementStart('form', array('method' => 'post',
|
||||||
'id' => 'smssettings',
|
'id' => 'form_settings_sms',
|
||||||
|
'class' => 'form_settings',
|
||||||
'action' =>
|
'action' =>
|
||||||
common_local_url('smssettings')));
|
common_local_url('smssettings')));
|
||||||
common_hidden('token', common_session_token());
|
|
||||||
common_element('h2', null, _('Address'));
|
$this->elementStart('fieldset', array('id' => 'settings_sms_address'));
|
||||||
|
$this->element('legend', null, _('Address'));
|
||||||
|
$this->hidden('token', common_session_token());
|
||||||
|
|
||||||
if ($user->sms) {
|
if ($user->sms) {
|
||||||
common_element_start('p');
|
|
||||||
$carrier = $user->getCarrier();
|
$carrier = $user->getCarrier();
|
||||||
common_element('span', 'address confirmed', $user->sms . ' (' . $carrier->name . ')');
|
$this->element('p', 'form_confirmed',
|
||||||
common_element('span', 'input_instructions',
|
$user->sms . ' (' . $carrier->name . ')');
|
||||||
|
$this->element('p', 'form_guide',
|
||||||
_('Current confirmed SMS-enabled phone number.'));
|
_('Current confirmed SMS-enabled phone number.'));
|
||||||
common_hidden('sms', $user->sms);
|
$this->hidden('sms', $user->sms);
|
||||||
common_hidden('carrier', $user->carrier);
|
$this->hidden('carrier', $user->carrier);
|
||||||
common_element_end('p');
|
$this->submit('remove', _('Remove'));
|
||||||
common_submit('remove', _('Remove'));
|
|
||||||
} else {
|
} else {
|
||||||
$confirm = $this->get_confirmation();
|
$confirm = $this->getConfirmation();
|
||||||
if ($confirm) {
|
if ($confirm) {
|
||||||
$carrier = Sms_carrier::staticGet($confirm->address_extra);
|
$carrier = Sms_carrier::staticGet($confirm->address_extra);
|
||||||
common_element_start('p');
|
$this->element('p', 'form_unconfirmed',
|
||||||
common_element('span', 'address unconfirmed', $confirm->address . ' (' . $carrier->name . ')');
|
$confirm->address . ' (' . $carrier->name . ')');
|
||||||
common_element('span', 'input_instructions',
|
$this->element('p', 'form_guide',
|
||||||
_('Awaiting confirmation on this phone number.'));
|
_('Awaiting confirmation on this phone number.'));
|
||||||
common_hidden('sms', $confirm->address);
|
$this->hidden('sms', $confirm->address);
|
||||||
common_hidden('carrier', $confirm->address_extra);
|
$this->hidden('carrier', $confirm->address_extra);
|
||||||
common_element_end('p');
|
$this->submit('cancel', _('Cancel'));
|
||||||
common_submit('cancel', _('Cancel'));
|
|
||||||
common_input('code', _('Confirmation code'), null,
|
$this->elementStart('ul', 'form_data');
|
||||||
|
$this->elementStart('li');
|
||||||
|
$this->input('code', _('Confirmation code'), null,
|
||||||
_('Enter the code you received on your phone.'));
|
_('Enter the code you received on your phone.'));
|
||||||
common_submit('confirm', _('Confirm'));
|
$this->elementEnd('li');
|
||||||
|
$this->elementEnd('ul');
|
||||||
|
$this->submit('confirm', _('Confirm'));
|
||||||
} else {
|
} else {
|
||||||
common_input('sms', _('SMS Phone number'),
|
$this->elementStart('ul', 'form_data');
|
||||||
|
$this->elementStart('li');
|
||||||
|
$this->input('sms', _('SMS Phone number'),
|
||||||
($this->arg('sms')) ? $this->arg('sms') : null,
|
($this->arg('sms')) ? $this->arg('sms') : null,
|
||||||
_('Phone number, no punctuation or spaces, with area code'));
|
_('Phone number, no punctuation or spaces, '.
|
||||||
$this->carrier_select();
|
'with area code'));
|
||||||
common_submit('add', _('Add'));
|
$this->elementEnd('li');
|
||||||
|
$this->elementEnd('ul');
|
||||||
|
$this->carrierSelect();
|
||||||
|
$this->submit('add', _('Add'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$this->elementEnd('fieldset');
|
||||||
|
|
||||||
if ($user->sms) {
|
if ($user->sms) {
|
||||||
common_element('h2', null, _('Incoming email'));
|
$this->elementStart('fieldset', array('id' => 'settings_sms_incoming_email'));
|
||||||
|
$this->element('legend', null, _('Incoming email'));
|
||||||
|
|
||||||
if ($user->incomingemail) {
|
if ($user->incomingemail) {
|
||||||
common_element_start('p');
|
$this->element('p', 'form_unconfirmed', $user->incomingemail);
|
||||||
common_element('span', 'address', $user->incomingemail);
|
$this->element('p', 'form_note',
|
||||||
common_element('span', 'input_instructions',
|
|
||||||
_('Send email to this address to post new notices.'));
|
_('Send email to this address to post new notices.'));
|
||||||
common_element_end('p');
|
$this->submit('removeincoming', _('Remove'));
|
||||||
common_submit('removeincoming', _('Remove'));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
common_element_start('p');
|
$this->element('p', 'form_guide',
|
||||||
common_element('span', 'input_instructions',
|
_('Make a new email address for posting to; '.
|
||||||
_('Make a new email address for posting to; cancels the old one.'));
|
'cancels the old one.'));
|
||||||
common_element_end('p');
|
$this->submit('newincoming', _('New'));
|
||||||
common_submit('newincoming', _('New'));
|
$this->elementEnd('fieldset');
|
||||||
}
|
}
|
||||||
|
|
||||||
common_element('h2', null, _('Preferences'));
|
$this->elementStart('fieldset', array('id' => 'settings_sms_preferences'));
|
||||||
|
$this->element('legend', null, _('Preferences'));
|
||||||
|
|
||||||
common_checkbox('smsnotify',
|
$this->elementStart('ul', 'form_data');
|
||||||
_('Send me notices through SMS; I understand I may incur exorbitant charges from my carrier.'),
|
$this->elementStart('li');
|
||||||
|
$this->checkbox('smsnotify',
|
||||||
|
_('Send me notices through SMS; '.
|
||||||
|
'I understand I may incur '.
|
||||||
|
'exorbitant charges from my carrier.'),
|
||||||
$user->smsnotify);
|
$user->smsnotify);
|
||||||
|
$this->elementEnd('li');
|
||||||
|
$this->elementEnd('ul');
|
||||||
|
|
||||||
common_submit('save', _('Save'));
|
$this->submit('save', _('Save'));
|
||||||
|
|
||||||
common_element_end('form');
|
$this->elementEnd('fieldset');
|
||||||
common_show_footer();
|
$this->elementEnd('form');
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_confirmation()
|
/**
|
||||||
|
* Get a pending confirmation, if any, for this user
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
* @todo very similar to EmailsettingsAction::getConfirmation(); refactor?
|
||||||
|
*/
|
||||||
|
|
||||||
|
function getConfirmation()
|
||||||
{
|
{
|
||||||
$user = common_current_user();
|
$user = common_current_user();
|
||||||
|
|
||||||
$confirm = new Confirm_address();
|
$confirm = new Confirm_address();
|
||||||
|
|
||||||
$confirm->user_id = $user->id;
|
$confirm->user_id = $user->id;
|
||||||
$confirm->address_type = 'sms';
|
$confirm->address_type = 'sms';
|
||||||
|
|
||||||
if ($confirm->find(true)) {
|
if ($confirm->find(true)) {
|
||||||
return $confirm;
|
return $confirm;
|
||||||
} else {
|
} else {
|
||||||
@ -119,44 +196,62 @@ class SmssettingsAction extends EmailsettingsAction
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function handle_post()
|
/**
|
||||||
{
|
* Handle posts to this form
|
||||||
|
*
|
||||||
|
* Based on the button that was pressed, muxes out to other functions
|
||||||
|
* to do the actual task requested.
|
||||||
|
*
|
||||||
|
* All sub-functions reload the form with a message -- success or failure.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
# CSRF protection
|
function handlePost()
|
||||||
|
{
|
||||||
|
// CSRF protection
|
||||||
|
|
||||||
$token = $this->trimmed('token');
|
$token = $this->trimmed('token');
|
||||||
if (!$token || $token != common_session_token()) {
|
if (!$token || $token != common_session_token()) {
|
||||||
$this->show_form(_('There was a problem with your session token. Try again, please.'));
|
$this->showForm(_('There was a problem with your session token. '.
|
||||||
|
'Try again, please.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->arg('save')) {
|
if ($this->arg('save')) {
|
||||||
$this->save_preferences();
|
$this->savePreferences();
|
||||||
} else if ($this->arg('add')) {
|
} else if ($this->arg('add')) {
|
||||||
$this->add_address();
|
$this->addAddress();
|
||||||
} else if ($this->arg('cancel')) {
|
} else if ($this->arg('cancel')) {
|
||||||
$this->cancel_confirmation();
|
$this->cancelConfirmation();
|
||||||
} else if ($this->arg('remove')) {
|
} else if ($this->arg('remove')) {
|
||||||
$this->remove_address();
|
$this->removeAddress();
|
||||||
} else if ($this->arg('removeincoming')) {
|
} else if ($this->arg('removeincoming')) {
|
||||||
$this->remove_incoming();
|
$this->removeIncoming();
|
||||||
} else if ($this->arg('newincoming')) {
|
} else if ($this->arg('newincoming')) {
|
||||||
$this->new_incoming();
|
$this->newIncoming();
|
||||||
} else if ($this->arg('confirm')) {
|
} else if ($this->arg('confirm')) {
|
||||||
$this->confirm_code();
|
$this->confirmCode();
|
||||||
} else {
|
} else {
|
||||||
$this->show_form(_('Unexpected form submission.'));
|
$this->showForm(_('Unexpected form submission.'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function save_preferences()
|
/**
|
||||||
|
* Handle a request to save preferences
|
||||||
|
*
|
||||||
|
* Sets the user's SMS preferences in the DB.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
|
function savePreferences()
|
||||||
{
|
{
|
||||||
|
|
||||||
$smsnotify = $this->boolean('smsnotify');
|
$smsnotify = $this->boolean('smsnotify');
|
||||||
|
|
||||||
$user = common_current_user();
|
$user = common_current_user();
|
||||||
|
|
||||||
assert(!is_null($user)); # should already be checked
|
assert(!is_null($user)); // should already be checked
|
||||||
|
|
||||||
$user->query('BEGIN');
|
$user->query('BEGIN');
|
||||||
|
|
||||||
@ -168,46 +263,55 @@ class SmssettingsAction extends EmailsettingsAction
|
|||||||
|
|
||||||
if ($result === false) {
|
if ($result === false) {
|
||||||
common_log_db_error($user, 'UPDATE', __FILE__);
|
common_log_db_error($user, 'UPDATE', __FILE__);
|
||||||
common_server_error(_('Couldn\'t update user.'));
|
$this->serverError(_('Couldn\'t update user.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$user->query('COMMIT');
|
$user->query('COMMIT');
|
||||||
|
|
||||||
$this->show_form(_('Preferences saved.'), true);
|
$this->showForm(_('Preferences saved.'), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
function add_address()
|
/**
|
||||||
{
|
* Add a new SMS number for confirmation
|
||||||
|
*
|
||||||
|
* When the user requests a new SMS number, sends a confirmation
|
||||||
|
* message.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
|
function addAddress()
|
||||||
|
{
|
||||||
$user = common_current_user();
|
$user = common_current_user();
|
||||||
|
|
||||||
$sms = $this->trimmed('sms');
|
$sms = $this->trimmed('sms');
|
||||||
$carrier_id = $this->trimmed('carrier');
|
$carrier_id = $this->trimmed('carrier');
|
||||||
|
|
||||||
# Some validation
|
// Some validation
|
||||||
|
|
||||||
if (!$sms) {
|
if (!$sms) {
|
||||||
$this->show_form(_('No phone number.'));
|
$this->showForm(_('No phone number.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$carrier_id) {
|
if (!$carrier_id) {
|
||||||
$this->show_form(_('No carrier selected.'));
|
$this->showForm(_('No carrier selected.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$sms = common_canonical_sms($sms);
|
$sms = common_canonical_sms($sms);
|
||||||
|
|
||||||
if ($user->sms == $sms) {
|
if ($user->sms == $sms) {
|
||||||
$this->show_form(_('That is already your phone number.'));
|
$this->showForm(_('That is already your phone number.'));
|
||||||
return;
|
return;
|
||||||
} else if ($this->sms_exists($sms)) {
|
} else if ($this->smsExists($sms)) {
|
||||||
$this->show_form(_('That phone number already belongs to another user.'));
|
$this->showForm(_('That phone number already belongs to another user.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$confirm = new Confirm_address();
|
$confirm = new Confirm_address();
|
||||||
|
|
||||||
$confirm->address = $sms;
|
$confirm->address = $sms;
|
||||||
$confirm->address_extra = $carrier_id;
|
$confirm->address_extra = $carrier_id;
|
||||||
$confirm->address_type = 'sms';
|
$confirm->address_type = 'sms';
|
||||||
@ -218,7 +322,7 @@ class SmssettingsAction extends EmailsettingsAction
|
|||||||
|
|
||||||
if ($result === false) {
|
if ($result === false) {
|
||||||
common_log_db_error($confirm, 'INSERT', __FILE__);
|
common_log_db_error($confirm, 'INSERT', __FILE__);
|
||||||
common_server_error(_('Couldn\'t insert confirmation code.'));
|
$this->serverError(_('Couldn\'t insert confirmation code.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -228,25 +332,34 @@ class SmssettingsAction extends EmailsettingsAction
|
|||||||
$user->nickname,
|
$user->nickname,
|
||||||
$carrier->toEmailAddress($sms));
|
$carrier->toEmailAddress($sms));
|
||||||
|
|
||||||
$msg = _('A confirmation code was sent to the phone number you added. Check your inbox (and spam box!) for the code and instructions on how to use it.');
|
$msg = _('A confirmation code was sent to the phone number you added. '.
|
||||||
|
'Check your phone for the code and instructions '.
|
||||||
|
'on how to use it.');
|
||||||
|
|
||||||
$this->show_form($msg, true);
|
$this->showForm($msg, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
function cancel_confirmation()
|
/**
|
||||||
{
|
* Cancel a pending confirmation
|
||||||
|
*
|
||||||
|
* Cancels the confirmation.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
|
function cancelConfirmation()
|
||||||
|
{
|
||||||
$sms = $this->trimmed('sms');
|
$sms = $this->trimmed('sms');
|
||||||
$carrier = $this->trimmed('carrier');
|
$carrier = $this->trimmed('carrier');
|
||||||
|
|
||||||
$confirm = $this->get_confirmation();
|
$confirm = $this->getConfirmation();
|
||||||
|
|
||||||
if (!$confirm) {
|
if (!$confirm) {
|
||||||
$this->show_form(_('No pending confirmation to cancel.'));
|
$this->showForm(_('No pending confirmation to cancel.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ($confirm->address != $sms) {
|
if ($confirm->address != $sms) {
|
||||||
$this->show_form(_('That is the wrong confirmation number.'));
|
$this->showForm(_('That is the wrong confirmation number.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -254,47 +367,68 @@ class SmssettingsAction extends EmailsettingsAction
|
|||||||
|
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
common_log_db_error($confirm, 'DELETE', __FILE__);
|
common_log_db_error($confirm, 'DELETE', __FILE__);
|
||||||
$this->server_error(_('Couldn\'t delete email confirmation.'));
|
$this->serverError(_('Couldn\'t delete email confirmation.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->show_form(_('Confirmation cancelled.'), true);
|
$this->showForm(_('Confirmation cancelled.'), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
function remove_address()
|
/**
|
||||||
{
|
* Remove a phone number from the user's account
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
|
function removeAddress()
|
||||||
|
{
|
||||||
$user = common_current_user();
|
$user = common_current_user();
|
||||||
|
|
||||||
$sms = $this->arg('sms');
|
$sms = $this->arg('sms');
|
||||||
$carrier = $this->arg('carrier');
|
$carrier = $this->arg('carrier');
|
||||||
|
|
||||||
# Maybe an old tab open...?
|
// Maybe an old tab open...?
|
||||||
|
|
||||||
if ($user->sms != $sms) {
|
if ($user->sms != $sms) {
|
||||||
$this->show_form(_('That is not your phone number.'));
|
$this->showForm(_('That is not your phone number.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$user->query('BEGIN');
|
$user->query('BEGIN');
|
||||||
|
|
||||||
$original = clone($user);
|
$original = clone($user);
|
||||||
|
|
||||||
$user->sms = null;
|
$user->sms = null;
|
||||||
$user->carrier = null;
|
$user->carrier = null;
|
||||||
$user->smsemail = null;
|
$user->smsemail = null;
|
||||||
|
|
||||||
$result = $user->updateKeys($original);
|
$result = $user->updateKeys($original);
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
common_log_db_error($user, 'UPDATE', __FILE__);
|
common_log_db_error($user, 'UPDATE', __FILE__);
|
||||||
common_server_error(_('Couldn\'t update user.'));
|
$this->serverError(_('Couldn\'t update user.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$user->query('COMMIT');
|
$user->query('COMMIT');
|
||||||
|
|
||||||
$this->show_form(_('The address was removed.'), true);
|
$this->showForm(_('The address was removed.'), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
function sms_exists($sms)
|
/**
|
||||||
|
* Does this sms number exist in our database?
|
||||||
|
*
|
||||||
|
* Also checks if it belongs to someone else
|
||||||
|
*
|
||||||
|
* @param string $sms phone number to check
|
||||||
|
*
|
||||||
|
* @return boolean does the number exist
|
||||||
|
*/
|
||||||
|
|
||||||
|
function smsExists($sms)
|
||||||
{
|
{
|
||||||
$user = common_current_user();
|
$user = common_current_user();
|
||||||
|
|
||||||
$other = User::staticGet('sms', $sms);
|
$other = User::staticGet('sms', $sms);
|
||||||
|
|
||||||
if (!$other) {
|
if (!$other) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
@ -302,38 +436,54 @@ class SmssettingsAction extends EmailsettingsAction
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function carrier_select()
|
/**
|
||||||
|
* Show a drop-down box with all the SMS carriers in the DB
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
|
function carrierSelect()
|
||||||
{
|
{
|
||||||
$carrier = new Sms_carrier();
|
$carrier = new Sms_carrier();
|
||||||
|
|
||||||
$cnt = $carrier->find();
|
$cnt = $carrier->find();
|
||||||
|
|
||||||
common_element_start('p');
|
$this->elementStart('ul', 'form_data');
|
||||||
common_element('label', array('for' => 'carrier'));
|
$this->elementStart('li');
|
||||||
common_element_start('select', array('name' => 'carrier',
|
$this->element('label', array('for' => 'carrier'), _('Mobile carrier'));
|
||||||
|
$this->elementStart('select', array('name' => 'carrier',
|
||||||
'id' => 'carrier'));
|
'id' => 'carrier'));
|
||||||
common_element('option', array('value' => 0),
|
$this->element('option', array('value' => 0),
|
||||||
_('Select a carrier'));
|
_('Select a carrier'));
|
||||||
while ($carrier->fetch()) {
|
while ($carrier->fetch()) {
|
||||||
common_element('option', array('value' => $carrier->id),
|
$this->element('option', array('value' => $carrier->id),
|
||||||
$carrier->name);
|
$carrier->name);
|
||||||
}
|
}
|
||||||
common_element_end('select');
|
$this->elementEnd('select');
|
||||||
common_element_end('p');
|
$this->element('p', 'form_guide',
|
||||||
common_element('span', 'input_instructions',
|
|
||||||
sprintf(_('Mobile carrier for your phone. '.
|
sprintf(_('Mobile carrier for your phone. '.
|
||||||
'If you know a carrier that accepts ' .
|
'If you know a carrier that accepts ' .
|
||||||
'SMS over email but isn\'t listed here, ' .
|
'SMS over email but isn\'t listed here, ' .
|
||||||
'send email to let us know at %s.'),
|
'send email to let us know at %s.'),
|
||||||
common_config('site', 'email')));
|
common_config('site', 'email')));
|
||||||
|
$this->elementEnd('li');
|
||||||
|
$this->elementEnd('ul');
|
||||||
}
|
}
|
||||||
|
|
||||||
function confirm_code()
|
/**
|
||||||
{
|
* Confirm an SMS confirmation code
|
||||||
|
*
|
||||||
|
* Redirects to the confirmaddress page for this code
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
|
function confirmCode()
|
||||||
|
{
|
||||||
$code = $this->trimmed('code');
|
$code = $this->trimmed('code');
|
||||||
|
|
||||||
if (!$code) {
|
if (!$code) {
|
||||||
$this->show_form(_('No code entered'));
|
$this->showForm(_('No code entered'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,28 +30,28 @@ class SubeditAction extends Action
|
|||||||
parent::prepare($args);
|
parent::prepare($args);
|
||||||
|
|
||||||
if (!common_logged_in()) {
|
if (!common_logged_in()) {
|
||||||
$this->client_error(_('Not logged in.'));
|
$this->clientError(_('Not logged in.'));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$token = $this->trimmed('token');
|
$token = $this->trimmed('token');
|
||||||
|
|
||||||
if (!$token || $token != common_session_token()) {
|
if (!$token || $token != common_session_token()) {
|
||||||
$this->client_error(_('There was a problem with your session token. Try again, please.'));
|
$this->clientError(_('There was a problem with your session token. Try again, please.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$id = $this->trimmed('profile');
|
$id = $this->trimmed('profile');
|
||||||
|
|
||||||
if (!$id) {
|
if (!$id) {
|
||||||
$this->client_error(_('No profile specified.'));
|
$this->clientError(_('No profile specified.'));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->profile = Profile::staticGet('id', $id);
|
$this->profile = Profile::staticGet('id', $id);
|
||||||
|
|
||||||
if (!$this->profile) {
|
if (!$this->profile) {
|
||||||
$this->client_error(_('No profile with that ID.'));
|
$this->clientError(_('No profile with that ID.'));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,7 +68,7 @@ class SubeditAction extends Action
|
|||||||
'subscribed' => $this->profile->id));
|
'subscribed' => $this->profile->id));
|
||||||
|
|
||||||
if (!$sub) {
|
if (!$sub) {
|
||||||
$this->client_error(_('You are not subscribed to that profile.'));
|
$this->clientError(_('You are not subscribed to that profile.'));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,7 +81,7 @@ class SubeditAction extends Action
|
|||||||
|
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
common_log_db_error($sub, 'UPDATE', __FILE__);
|
common_log_db_error($sub, 'UPDATE', __FILE__);
|
||||||
$this->server_error(_('Could not save subscription.'));
|
$this->serverError(_('Could not save subscription.'));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ class SubscribeAction extends Action
|
|||||||
parent::handle($args);
|
parent::handle($args);
|
||||||
|
|
||||||
if (!common_logged_in()) {
|
if (!common_logged_in()) {
|
||||||
common_user_error(_('Not logged in.'));
|
$this->clientError(_('Not logged in.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,7 +43,7 @@ class SubscribeAction extends Action
|
|||||||
$token = $this->trimmed('token');
|
$token = $this->trimmed('token');
|
||||||
|
|
||||||
if (!$token || $token != common_session_token()) {
|
if (!$token || $token != common_session_token()) {
|
||||||
$this->client_error(_('There was a problem with your session token. Try again, please.'));
|
$this->clientError(_('There was a problem with your session token. Try again, please.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,26 +52,26 @@ class SubscribeAction extends Action
|
|||||||
$other = User::staticGet('id', $other_id);
|
$other = User::staticGet('id', $other_id);
|
||||||
|
|
||||||
if (!$other) {
|
if (!$other) {
|
||||||
$this->client_error(_('Not a local user.'));
|
$this->clientError(_('Not a local user.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = subs_subscribe_to($user, $other);
|
$result = subs_subscribe_to($user, $other);
|
||||||
|
|
||||||
if($result != true) {
|
if($result != true) {
|
||||||
common_user_error($result);
|
$this->clientError($result);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->boolean('ajax')) {
|
if ($this->boolean('ajax')) {
|
||||||
common_start_html('text/xml;charset=utf-8', true);
|
common_start_html('text/xml;charset=utf-8', true);
|
||||||
common_element_start('head');
|
$this->elementStart('head');
|
||||||
common_element('title', null, _('Subscribed'));
|
$this->element('title', null, _('Subscribed'));
|
||||||
common_element_end('head');
|
$this->elementEnd('head');
|
||||||
common_element_start('body');
|
$this->elementStart('body');
|
||||||
common_unsubscribe_form($other->getProfile());
|
common_unsubscribe_form($other->getProfile());
|
||||||
common_element_end('body');
|
$this->elementEnd('body');
|
||||||
common_element_end('html');
|
$this->elementEnd('html');
|
||||||
} else {
|
} else {
|
||||||
common_redirect(common_local_url('subscriptions', array('nickname' =>
|
common_redirect(common_local_url('subscriptions', array('nickname' =>
|
||||||
$user->nickname)));
|
$user->nickname)));
|
||||||
|
@ -72,16 +72,16 @@ class SubscriptionsList extends ProfileList
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
common_element_start('form', array('id' => 'subedit-' . $profile->id,
|
$this->elementStart('form', array('id' => 'subedit-' . $profile->id,
|
||||||
'method' => 'post',
|
'method' => 'post',
|
||||||
'class' => 'subedit',
|
'class' => 'subedit',
|
||||||
'action' => common_local_url('subedit')));
|
'action' => common_local_url('subedit')));
|
||||||
common_hidden('token', common_session_token());
|
$this->hidden('token', common_session_token());
|
||||||
common_hidden('profile', $profile->id);
|
$this->hidden('profile', $profile->id);
|
||||||
common_checkbox('jabber', _('Jabber'), $sub->jabber);
|
$this->checkbox('jabber', _('Jabber'), $sub->jabber);
|
||||||
common_checkbox('sms', _('SMS'), $sub->sms);
|
$this->checkbox('sms', _('SMS'), $sub->sms);
|
||||||
common_submit('save', _('Save'));
|
$this->submit('save', _('Save'));
|
||||||
common_element_end('form');
|
$this->elementEnd('form');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -79,7 +79,7 @@ class SupAction extends Action
|
|||||||
return $updates;
|
return $updates;
|
||||||
}
|
}
|
||||||
|
|
||||||
function is_readonly()
|
function isReadOnly()
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
165
actions/tag.php
165
actions/tag.php
@ -19,154 +19,71 @@
|
|||||||
|
|
||||||
if (!defined('LACONICA')) { exit(1); }
|
if (!defined('LACONICA')) { exit(1); }
|
||||||
|
|
||||||
require_once(INSTALLDIR.'/actions/showstream.php');
|
class TagAction extends Action
|
||||||
define('TAGS_PER_PAGE', 100);
|
|
||||||
|
|
||||||
class TagAction extends StreamAction
|
|
||||||
{
|
{
|
||||||
|
function prepare($args)
|
||||||
|
{
|
||||||
|
parent::prepare($args);
|
||||||
|
$this->tag = $this->trimmed('tag');
|
||||||
|
|
||||||
|
if (!$this->tag) {
|
||||||
|
common_redirect(common_local_url('publictagcloud'), 301);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function title()
|
||||||
|
{
|
||||||
|
if ($this->page == 1) {
|
||||||
|
return sprintf(_("Notices tagged with %s"), $this->tag);
|
||||||
|
} else {
|
||||||
|
return sprintf(_("Notices tagged with %s, page %d"),
|
||||||
|
$this->tag,
|
||||||
|
$this->page);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function handle($args)
|
function handle($args)
|
||||||
{
|
{
|
||||||
|
|
||||||
parent::handle($args);
|
parent::handle($args);
|
||||||
|
|
||||||
# Looks like we're good; show the header
|
$this->showPage();
|
||||||
|
|
||||||
if (isset($args['tag']) && $args['tag']) {
|
|
||||||
$tag = $args['tag'];
|
|
||||||
common_show_header(sprintf(_("Notices tagged with %s"), $tag),
|
|
||||||
array($this, 'show_header'), $tag,
|
|
||||||
array($this, 'show_top'));
|
|
||||||
$this->show_notices($tag);
|
|
||||||
} else {
|
|
||||||
common_show_header(_("Tags"),
|
|
||||||
array($this, 'show_header'), '',
|
|
||||||
array($this, 'show_top'));
|
|
||||||
$this->show_tags();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
common_show_footer();
|
function showFeeds()
|
||||||
}
|
|
||||||
|
|
||||||
function show_header($tag = false)
|
|
||||||
{
|
{
|
||||||
if ($tag) {
|
$this->element('link', array('rel' => 'alternate',
|
||||||
common_element('link', array('rel' => 'alternate',
|
'href' => common_local_url('tagrss', array('tag' => $this->tag)),
|
||||||
'href' => common_local_url('tagrss', array('tag' => $tag)),
|
|
||||||
'type' => 'application/rss+xml',
|
'type' => 'application/rss+xml',
|
||||||
'title' => sprintf(_('Feed for tag %s'), $tag)));
|
'title' => sprintf(_('Feed for tag %s'), $this->tag)));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_instructions()
|
function showPageNotice()
|
||||||
{
|
{
|
||||||
return _('Showing most popular tags from the last week');
|
return sprintf(_('Messages tagged "%s", most recent first'), $this->tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_top($tag = false)
|
function showExportData()
|
||||||
{
|
{
|
||||||
if (!$tag) {
|
$fl = new FeedList($this);
|
||||||
$instr = $this->get_instructions();
|
$fl->show(array(0=>array('href'=>common_local_url('tagrss', array('tag' => $this->tag)),
|
||||||
$output = common_markup_to_html($instr);
|
|
||||||
common_element_start('div', 'instructions');
|
|
||||||
common_raw($output);
|
|
||||||
common_element_end('div');
|
|
||||||
$this->public_views_menu();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$this->show_feeds_list(array(0=>array('href'=>common_local_url('tagrss'),
|
|
||||||
'type' => 'rss',
|
'type' => 'rss',
|
||||||
'version' => 'RSS 1.0',
|
'version' => 'RSS 1.0',
|
||||||
'item' => 'tagrss')));
|
'item' => 'tagrss')));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
function show_tags()
|
function showContent()
|
||||||
{
|
{
|
||||||
# This should probably be cached rather than recalculated
|
$notice = Notice_tag::getStream($this->tag, (($this->page-1)*NOTICES_PER_PAGE), NOTICES_PER_PAGE + 1);
|
||||||
$tags = DB_DataObject::factory('Notice_tag');
|
|
||||||
|
|
||||||
#Need to clear the selection and then only re-add the field
|
$nl = new NoticeList($notice, $this);
|
||||||
#we are grouping by, otherwise it's not a valid 'group by'
|
|
||||||
#even though MySQL seems to let it slide...
|
|
||||||
$tags->selectAdd();
|
|
||||||
$tags->selectAdd('tag');
|
|
||||||
|
|
||||||
#Add the aggregated columns...
|
$cnt = $nl->show();
|
||||||
$tags->selectAdd('max(notice_id) as last_notice_id');
|
|
||||||
if(common_config('db','type')=='pgsql') {
|
|
||||||
$calc='sum(exp(-extract(epoch from (now()-created))/%s)) as weight';
|
|
||||||
} else {
|
|
||||||
$calc='sum(exp(-(now() - created)/%s)) as weight';
|
|
||||||
}
|
|
||||||
$tags->selectAdd(sprintf($calc, common_config('tag', 'dropoff')));
|
|
||||||
$tags->groupBy('tag');
|
|
||||||
$tags->orderBy('weight DESC');
|
|
||||||
|
|
||||||
# $tags->whereAdd('created > "' . strftime('%Y-%m-%d %H:%M:%S', strtotime('-1 MONTH')) . '"');
|
$this->pagination($this->page > 1, $cnt > NOTICES_PER_PAGE,
|
||||||
|
$this->page, 'tag', array('tag' => $this->tag));
|
||||||
$tags->limit(TAGS_PER_PAGE);
|
|
||||||
|
|
||||||
$cnt = $tags->find();
|
|
||||||
|
|
||||||
if ($cnt > 0) {
|
|
||||||
common_element_start('p', 'tagcloud');
|
|
||||||
|
|
||||||
$tw = array();
|
|
||||||
$sum = 0;
|
|
||||||
while ($tags->fetch()) {
|
|
||||||
$tw[$tags->tag] = $tags->weight;
|
|
||||||
$sum += $tags->weight;
|
|
||||||
}
|
|
||||||
|
|
||||||
ksort($tw);
|
|
||||||
|
|
||||||
foreach ($tw as $tag => $weight) {
|
|
||||||
$this->show_tag($tag, $weight, $weight/$sum);
|
|
||||||
}
|
|
||||||
|
|
||||||
common_element_end('p');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function show_tag($tag, $weight, $relative)
|
|
||||||
{
|
|
||||||
|
|
||||||
# XXX: these should probably tune to the size of the site
|
|
||||||
if ($relative > 0.1) {
|
|
||||||
$cls = 'largest';
|
|
||||||
} else if ($relative > 0.05) {
|
|
||||||
$cls = 'verylarge';
|
|
||||||
} else if ($relative > 0.02) {
|
|
||||||
$cls = 'large';
|
|
||||||
} else if ($relative > 0.01) {
|
|
||||||
$cls = 'medium';
|
|
||||||
} else if ($relative > 0.005) {
|
|
||||||
$cls = 'small';
|
|
||||||
} else if ($relative > 0.002) {
|
|
||||||
$cls = 'verysmall';
|
|
||||||
} else {
|
|
||||||
$cls = 'smallest';
|
|
||||||
}
|
|
||||||
|
|
||||||
common_element('a', array('class' => "$cls weight-$weight relative-$relative",
|
|
||||||
'href' => common_local_url('tag', array('tag' => $tag))),
|
|
||||||
$tag);
|
|
||||||
common_text(' ');
|
|
||||||
}
|
|
||||||
|
|
||||||
function show_notices($tag)
|
|
||||||
{
|
|
||||||
|
|
||||||
$cnt = 0;
|
|
||||||
|
|
||||||
$page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
|
|
||||||
|
|
||||||
$notice = Notice_tag::getStream($tag, (($page-1)*NOTICES_PER_PAGE), NOTICES_PER_PAGE + 1);
|
|
||||||
|
|
||||||
$cnt = $this->show_notice_list($notice);
|
|
||||||
|
|
||||||
common_pagination($page > 1, $cnt > NOTICES_PER_PAGE,
|
|
||||||
$page, 'tag', array('tag' => $tag));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ class TagotherAction extends Action
|
|||||||
parent::handle($args);
|
parent::handle($args);
|
||||||
|
|
||||||
if (!common_logged_in()) {
|
if (!common_logged_in()) {
|
||||||
$this->client_error(_('Not logged in'), 403);
|
$this->clientError(_('Not logged in'), 403);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -39,12 +39,12 @@ class TagotherAction extends Action
|
|||||||
} else {
|
} else {
|
||||||
$id = $this->trimmed('id');
|
$id = $this->trimmed('id');
|
||||||
if (!$id) {
|
if (!$id) {
|
||||||
$this->client_error(_('No id argument.'));
|
$this->clientError(_('No id argument.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$profile = Profile::staticGet('id', $id);
|
$profile = Profile::staticGet('id', $id);
|
||||||
if (!$profile) {
|
if (!$profile) {
|
||||||
$this->client_error(_('No profile with that ID.'));
|
$this->clientError(_('No profile with that ID.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$this->show_form($profile);
|
$this->show_form($profile);
|
||||||
@ -61,7 +61,7 @@ class TagotherAction extends Action
|
|||||||
|
|
||||||
$avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE);
|
$avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE);
|
||||||
|
|
||||||
common_element('img', array('src' => ($avatar) ? common_avatar_display_url($avatar) : common_default_avatar(AVATAR_PROFILE_SIZE),
|
$this->element('img', array('src' => ($avatar) ? common_avatar_display_url($avatar) : common_default_avatar(AVATAR_PROFILE_SIZE),
|
||||||
'class' => 'avatar stream',
|
'class' => 'avatar stream',
|
||||||
'width' => AVATAR_PROFILE_SIZE,
|
'width' => AVATAR_PROFILE_SIZE,
|
||||||
'height' => AVATAR_PROFILE_SIZE,
|
'height' => AVATAR_PROFILE_SIZE,
|
||||||
@ -69,39 +69,39 @@ class TagotherAction extends Action
|
|||||||
($profile->fullname) ? $profile->fullname :
|
($profile->fullname) ? $profile->fullname :
|
||||||
$profile->nickname));
|
$profile->nickname));
|
||||||
|
|
||||||
common_element('a', array('href' => $profile->profileurl,
|
$this->element('a', array('href' => $profile->profileurl,
|
||||||
'class' => 'external profile nickname'),
|
'class' => 'external profile nickname'),
|
||||||
$profile->nickname);
|
$profile->nickname);
|
||||||
|
|
||||||
if ($profile->fullname) {
|
if ($profile->fullname) {
|
||||||
common_element_start('div', 'fullname');
|
$this->elementStart('div', 'fullname');
|
||||||
if ($profile->homepage) {
|
if ($profile->homepage) {
|
||||||
common_element('a', array('href' => $profile->homepage),
|
$this->element('a', array('href' => $profile->homepage),
|
||||||
$profile->fullname);
|
$profile->fullname);
|
||||||
} else {
|
} else {
|
||||||
common_text($profile->fullname);
|
$this->text($profile->fullname);
|
||||||
}
|
}
|
||||||
common_element_end('div');
|
$this->elementEnd('div');
|
||||||
}
|
}
|
||||||
if ($profile->location) {
|
if ($profile->location) {
|
||||||
common_element('div', 'location', $profile->location);
|
$this->element('div', 'location', $profile->location);
|
||||||
}
|
}
|
||||||
if ($profile->bio) {
|
if ($profile->bio) {
|
||||||
common_element('div', 'bio', $profile->bio);
|
$this->element('div', 'bio', $profile->bio);
|
||||||
}
|
}
|
||||||
|
|
||||||
common_element_start('form', array('method' => 'post',
|
$this->elementStart('form', array('method' => 'post',
|
||||||
'id' => 'tag_user',
|
'id' => 'tag_user',
|
||||||
'name' => 'tagother',
|
'name' => 'tagother',
|
||||||
'action' => $this->self_url()));
|
'action' => $this->selfUrl()));
|
||||||
common_hidden('token', common_session_token());
|
$this->hidden('token', common_session_token());
|
||||||
common_hidden('id', $profile->id);
|
$this->hidden('id', $profile->id);
|
||||||
common_input('tags', _('Tags'),
|
$this->input('tags', _('Tags'),
|
||||||
($this->arg('tags')) ? $this->arg('tags') : implode(' ', Profile_tag::getTags($user->id, $profile->id)),
|
($this->arg('tags')) ? $this->arg('tags') : implode(' ', Profile_tag::getTags($user->id, $profile->id)),
|
||||||
_('Tags for this user (letters, numbers, -, ., and _), comma- or space- separated'));
|
_('Tags for this user (letters, numbers, -, ., and _), comma- or space- separated'));
|
||||||
|
|
||||||
common_submit('save', _('Save'));
|
$this->submit('save', _('Save'));
|
||||||
common_element_end('form');
|
$this->elementEnd('form');
|
||||||
common_show_footer();
|
common_show_footer();
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -121,7 +121,7 @@ class TagotherAction extends Action
|
|||||||
$profile = Profile::staticGet('id', $id);
|
$profile = Profile::staticGet('id', $id);
|
||||||
|
|
||||||
if (!$profile) {
|
if (!$profile) {
|
||||||
$this->client_error(_('No such profile.'));
|
$this->clientError(_('No such profile.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -147,14 +147,14 @@ class TagotherAction extends Action
|
|||||||
!Subscription::pkeyGet(array('subscriber' => $profile->id,
|
!Subscription::pkeyGet(array('subscriber' => $profile->id,
|
||||||
'subscribed' => $user->id)))
|
'subscribed' => $user->id)))
|
||||||
{
|
{
|
||||||
$this->client_error(_('You can only tag people you are subscribed to or who are subscribed to you.'));
|
$this->clientError(_('You can only tag people you are subscribed to or who are subscribed to you.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = Profile_tag::setTags($user->id, $profile->id, $tags);
|
$result = Profile_tag::setTags($user->id, $profile->id, $tags);
|
||||||
|
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
$this->client_error(_('Could not save tags.'));
|
$this->clientError(_('Could not save tags.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -162,20 +162,20 @@ class TagotherAction extends Action
|
|||||||
|
|
||||||
if ($this->boolean('ajax')) {
|
if ($this->boolean('ajax')) {
|
||||||
common_start_html('text/xml');
|
common_start_html('text/xml');
|
||||||
common_element_start('head');
|
$this->elementStart('head');
|
||||||
common_element('title', null, _('Tags'));
|
$this->element('title', null, _('Tags'));
|
||||||
common_element_end('head');
|
$this->elementEnd('head');
|
||||||
common_element_start('body');
|
$this->elementStart('body');
|
||||||
common_element_start('p', 'subtags');
|
$this->elementStart('p', 'subtags');
|
||||||
foreach ($tags as $tag) {
|
foreach ($tags as $tag) {
|
||||||
common_element('a', array('href' => common_local_url($action,
|
$this->element('a', array('href' => common_local_url($action,
|
||||||
array('nickname' => $user->nickname,
|
array('nickname' => $user->nickname,
|
||||||
'tag' => $tag))),
|
'tag' => $tag))),
|
||||||
$tag);
|
$tag);
|
||||||
}
|
}
|
||||||
common_element_end('p');
|
$this->elementEnd('p');
|
||||||
common_element_end('body');
|
$this->elementEnd('body');
|
||||||
common_element_end('html');
|
$this->elementEnd('html');
|
||||||
} else {
|
} else {
|
||||||
common_redirect(common_local_url($action, array('nickname' =>
|
common_redirect(common_local_url($action, array('nickname' =>
|
||||||
$user->nickname)));
|
$user->nickname)));
|
||||||
@ -186,12 +186,12 @@ class TagotherAction extends Action
|
|||||||
{
|
{
|
||||||
list($profile, $error) = $arr;
|
list($profile, $error) = $arr;
|
||||||
if ($error) {
|
if ($error) {
|
||||||
common_element('p', 'error', $error);
|
$this->element('p', 'error', $error);
|
||||||
} else {
|
} else {
|
||||||
common_element_start('div', 'instructions');
|
$this->elementStart('div', 'instructions');
|
||||||
common_element('p', null,
|
$this->element('p', null,
|
||||||
_('Use this form to add tags to your subscribers or subscriptions.'));
|
_('Use this form to add tags to your subscribers or subscriptions.'));
|
||||||
common_element_end('div');
|
$this->elementEnd('div');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ class TagrssAction extends Rss10Action
|
|||||||
$this->tag = Notice_tag::staticGet('tag', $tag);
|
$this->tag = Notice_tag::staticGet('tag', $tag);
|
||||||
|
|
||||||
if (!$this->tag) {
|
if (!$this->tag) {
|
||||||
common_user_error(_('No such tag.'));
|
$this->clientError(_('No such tag.'));
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
return true;
|
return true;
|
||||||
|
@ -29,7 +29,7 @@ class TwitapiaccountAction extends TwitterapiAction
|
|||||||
parent::handle($args);
|
parent::handle($args);
|
||||||
|
|
||||||
if (!in_array($apidata['content-type'], array('xml', 'json'))) {
|
if (!in_array($apidata['content-type'], array('xml', 'json'))) {
|
||||||
common_user_error(_('API method not found!'), $code = 404);
|
$this->clientError(_('API method not found!'), $code = 404);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -39,7 +39,7 @@ class TwitapiaccountAction extends TwitterapiAction
|
|||||||
function end_session($args, $apidata)
|
function end_session($args, $apidata)
|
||||||
{
|
{
|
||||||
parent::handle($args);
|
parent::handle($args);
|
||||||
common_server_error(_('API method under construction.'), $code=501);
|
$this->serverError(_('API method under construction.'), $code=501);
|
||||||
}
|
}
|
||||||
|
|
||||||
function update_location($args, $apidata)
|
function update_location($args, $apidata)
|
||||||
@ -47,7 +47,7 @@ class TwitapiaccountAction extends TwitterapiAction
|
|||||||
parent::handle($args);
|
parent::handle($args);
|
||||||
|
|
||||||
if ($_SERVER['REQUEST_METHOD'] != 'POST') {
|
if ($_SERVER['REQUEST_METHOD'] != 'POST') {
|
||||||
$this->client_error(_('This method requires a POST.'), 400, $apidata['content-type']);
|
$this->clientError(_('This method requires a POST.'), 400, $apidata['content-type']);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,7 +56,7 @@ class TwitapiaccountAction extends TwitterapiAction
|
|||||||
if (!is_null($location) && strlen($location) > 255) {
|
if (!is_null($location) && strlen($location) > 255) {
|
||||||
|
|
||||||
// XXX: But Twitter just truncates and runs with it. -- Zach
|
// XXX: But Twitter just truncates and runs with it. -- Zach
|
||||||
$this->client_error(_('That\'s too long. Max notice size is 255 chars.'), 406, $apidate['content-type']);
|
$this->clientError(_('That\'s too long. Max notice size is 255 chars.'), 406, $apidate['content-type']);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,7 +64,7 @@ class TwitapiaccountAction extends TwitterapiAction
|
|||||||
$profile = $user->getProfile();
|
$profile = $user->getProfile();
|
||||||
|
|
||||||
if (!$profile) {
|
if (!$profile) {
|
||||||
common_server_error(_('User has no profile.'));
|
$this->serverError(_('User has no profile.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,7 +75,7 @@ class TwitapiaccountAction extends TwitterapiAction
|
|||||||
|
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
common_log_db_error($profile, 'UPDATE', __FILE__);
|
common_log_db_error($profile, 'UPDATE', __FILE__);
|
||||||
common_server_error(_('Couldn\'t save profile.'));
|
$this->serverError(_('Couldn\'t save profile.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,12 +91,12 @@ class TwitapiaccountAction extends TwitterapiAction
|
|||||||
function update_delivery_device($args, $apidata)
|
function update_delivery_device($args, $apidata)
|
||||||
{
|
{
|
||||||
parent::handle($args);
|
parent::handle($args);
|
||||||
common_server_error(_('API method under construction.'), $code=501);
|
$this->serverError(_('API method under construction.'), $code=501);
|
||||||
}
|
}
|
||||||
|
|
||||||
function rate_limit_status($args, $apidata)
|
function rate_limit_status($args, $apidata)
|
||||||
{
|
{
|
||||||
parent::handle($args);
|
parent::handle($args);
|
||||||
common_server_error(_('API method under construction.'), $code=501);
|
$this->serverError(_('API method under construction.'), $code=501);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -32,7 +32,7 @@ class TwitapiblocksAction extends TwitterapiAction
|
|||||||
$blockee = $this->get_user($apidata['api_arg'], $apidata);
|
$blockee = $this->get_user($apidata['api_arg'], $apidata);
|
||||||
|
|
||||||
if (!$blockee) {
|
if (!$blockee) {
|
||||||
$this->client_error('Not Found', 404, $apidata['content-type']);
|
$this->clientError('Not Found', 404, $apidata['content-type']);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -44,7 +44,7 @@ class TwitapiblocksAction extends TwitterapiAction
|
|||||||
$this->show_profile($blockee, $type);
|
$this->show_profile($blockee, $type);
|
||||||
$this->end_document($type);
|
$this->end_document($type);
|
||||||
} else {
|
} else {
|
||||||
common_server_error(_('Block user failed.'));
|
$this->serverError(_('Block user failed.'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,7 +54,7 @@ class TwitapiblocksAction extends TwitterapiAction
|
|||||||
$blockee = $this->get_user($apidata['api_arg'], $apidata);
|
$blockee = $this->get_user($apidata['api_arg'], $apidata);
|
||||||
|
|
||||||
if (!$blockee) {
|
if (!$blockee) {
|
||||||
$this->client_error('Not Found', 404, $apidata['content-type']);
|
$this->clientError('Not Found', 404, $apidata['content-type']);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,7 +66,7 @@ class TwitapiblocksAction extends TwitterapiAction
|
|||||||
$this->show_profile($blockee, $type);
|
$this->show_profile($blockee, $type);
|
||||||
$this->end_document($type);
|
$this->end_document($type);
|
||||||
} else {
|
} else {
|
||||||
common_server_error(_('Unblock user failed.'));
|
$this->serverError(_('Unblock user failed.'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -108,7 +108,7 @@ class Twitapidirect_messagesAction extends TwitterapiAction
|
|||||||
$this->show_json_dmsgs($message);
|
$this->show_json_dmsgs($message);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
common_user_error(_('API method not found!'), $code = 404);
|
$this->clientError(_('API method not found!'), $code = 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -119,7 +119,7 @@ class Twitapidirect_messagesAction extends TwitterapiAction
|
|||||||
parent::handle($args);
|
parent::handle($args);
|
||||||
|
|
||||||
if ($_SERVER['REQUEST_METHOD'] != 'POST') {
|
if ($_SERVER['REQUEST_METHOD'] != 'POST') {
|
||||||
$this->client_error(_('This method requires a POST.'), 400, $apidata['content-type']);
|
$this->clientError(_('This method requires a POST.'), 400, $apidata['content-type']);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -134,11 +134,11 @@ class Twitapidirect_messagesAction extends TwitterapiAction
|
|||||||
$content = $this->trimmed('text');
|
$content = $this->trimmed('text');
|
||||||
|
|
||||||
if (!$content) {
|
if (!$content) {
|
||||||
$this->client_error(_('No message text!'), $code = 406, $apidata['content-type']);
|
$this->clientError(_('No message text!'), $code = 406, $apidata['content-type']);
|
||||||
} else {
|
} else {
|
||||||
$content_shortened = common_shorten_links($content);
|
$content_shortened = common_shorten_links($content);
|
||||||
if (mb_strlen($content_shortened) > 140) {
|
if (mb_strlen($content_shortened) > 140) {
|
||||||
$this->client_error(_('That\'s too long. Max message size is 140 chars.'),
|
$this->clientError(_('That\'s too long. Max message size is 140 chars.'),
|
||||||
$code = 406, $apidata['content-type']);
|
$code = 406, $apidata['content-type']);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -147,15 +147,15 @@ class Twitapidirect_messagesAction extends TwitterapiAction
|
|||||||
$other = $this->get_user($this->trimmed('user'));
|
$other = $this->get_user($this->trimmed('user'));
|
||||||
|
|
||||||
if (!$other) {
|
if (!$other) {
|
||||||
$this->client_error(_('Recipient user not found.'), $code = 403, $apidata['content-type']);
|
$this->clientError(_('Recipient user not found.'), $code = 403, $apidata['content-type']);
|
||||||
return;
|
return;
|
||||||
} else if (!$user->mutuallySubscribed($other)) {
|
} else if (!$user->mutuallySubscribed($other)) {
|
||||||
$this->client_error(_('Can\'t send direct messages to users who aren\'t your friend.'),
|
$this->clientError(_('Can\'t send direct messages to users who aren\'t your friend.'),
|
||||||
$code = 403, $apidata['content-type']);
|
$code = 403, $apidata['content-type']);
|
||||||
return;
|
return;
|
||||||
} else if ($user->id == $other->id) {
|
} else if ($user->id == $other->id) {
|
||||||
// Sending msgs to yourself is allowed by Twitter
|
// Sending msgs to yourself is allowed by Twitter
|
||||||
$this->client_error(_('Don\'t send a message to yourself; just say it to yourself quietly instead.'),
|
$this->clientError(_('Don\'t send a message to yourself; just say it to yourself quietly instead.'),
|
||||||
$code = 403, $apidata['content-type']);
|
$code = 403, $apidata['content-type']);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -164,7 +164,7 @@ class Twitapidirect_messagesAction extends TwitterapiAction
|
|||||||
html_entity_decode($content, ENT_NOQUOTES, 'UTF-8'), $source);
|
html_entity_decode($content, ENT_NOQUOTES, 'UTF-8'), $source);
|
||||||
|
|
||||||
if (is_string($message)) {
|
if (is_string($message)) {
|
||||||
$this->server_error($message);
|
$this->serverError($message);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -181,14 +181,14 @@ class Twitapidirect_messagesAction extends TwitterapiAction
|
|||||||
function destroy($args, $apidata)
|
function destroy($args, $apidata)
|
||||||
{
|
{
|
||||||
parent::handle($args);
|
parent::handle($args);
|
||||||
common_server_error(_('API method under construction.'), $code=501);
|
$this->serverError(_('API method under construction.'), $code=501);
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_xml_dmsgs($message)
|
function show_xml_dmsgs($message)
|
||||||
{
|
{
|
||||||
|
|
||||||
$this->init_document('xml');
|
$this->init_document('xml');
|
||||||
common_element_start('direct-messages', array('type' => 'array'));
|
$this->elementStart('direct-messages', array('type' => 'array'));
|
||||||
|
|
||||||
if (is_array($messages)) {
|
if (is_array($messages)) {
|
||||||
foreach ($message as $m) {
|
foreach ($message as $m) {
|
||||||
@ -202,7 +202,7 @@ class Twitapidirect_messagesAction extends TwitterapiAction
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
common_element_end('direct-messages');
|
$this->elementEnd('direct-messages');
|
||||||
$this->end_document('xml');
|
$this->end_document('xml');
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -236,13 +236,13 @@ class Twitapidirect_messagesAction extends TwitterapiAction
|
|||||||
|
|
||||||
$this->init_document('rss');
|
$this->init_document('rss');
|
||||||
|
|
||||||
common_element_start('channel');
|
$this->elementStart('channel');
|
||||||
common_element('title', null, $title);
|
$this->element('title', null, $title);
|
||||||
|
|
||||||
common_element('link', null, $link);
|
$this->element('link', null, $link);
|
||||||
common_element('description', null, $subtitle);
|
$this->element('description', null, $subtitle);
|
||||||
common_element('language', null, 'en-us');
|
$this->element('language', null, 'en-us');
|
||||||
common_element('ttl', null, '40');
|
$this->element('ttl', null, '40');
|
||||||
|
|
||||||
if (is_array($message)) {
|
if (is_array($message)) {
|
||||||
foreach ($message as $m) {
|
foreach ($message as $m) {
|
||||||
@ -256,7 +256,7 @@ class Twitapidirect_messagesAction extends TwitterapiAction
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
common_element_end('channel');
|
$this->elementEnd('channel');
|
||||||
$this->end_twitter_rss();
|
$this->end_twitter_rss();
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -266,12 +266,12 @@ class Twitapidirect_messagesAction extends TwitterapiAction
|
|||||||
|
|
||||||
$this->init_document('atom');
|
$this->init_document('atom');
|
||||||
|
|
||||||
common_element('title', null, $title);
|
$this->element('title', null, $title);
|
||||||
$siteserver = common_config('site', 'server');
|
$siteserver = common_config('site', 'server');
|
||||||
common_element('id', null, "tag:$siteserver,2008:DirectMessage");
|
$this->element('id', null, "tag:$siteserver,2008:DirectMessage");
|
||||||
common_element('link', array('href' => $link, 'rel' => 'alternate', 'type' => 'text/html'), null);
|
$this->element('link', array('href' => $link, 'rel' => 'alternate', 'type' => 'text/html'), null);
|
||||||
common_element('updated', null, common_date_iso8601(strftime('%c')));
|
$this->element('updated', null, common_date_iso8601(strftime('%c')));
|
||||||
common_element('subtitle', null, $subtitle);
|
$this->element('subtitle', null, $subtitle);
|
||||||
|
|
||||||
if (is_array($message)) {
|
if (is_array($message)) {
|
||||||
foreach ($message as $m) {
|
foreach ($message as $m) {
|
||||||
|
@ -32,14 +32,14 @@ class TwitapifavoritesAction extends TwitterapiAction
|
|||||||
$user = $this->get_user($apidata['api_arg'], $apidata);
|
$user = $this->get_user($apidata['api_arg'], $apidata);
|
||||||
|
|
||||||
if (!$user) {
|
if (!$user) {
|
||||||
$this->client_error('Not Found', 404, $apidata['content-type']);
|
$this->clientError('Not Found', 404, $apidata['content-type']);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$profile = $user->getProfile();
|
$profile = $user->getProfile();
|
||||||
|
|
||||||
if (!$profile) {
|
if (!$profile) {
|
||||||
common_server_error(_('User has no profile.'));
|
$this->serverError(_('User has no profile.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,7 +56,7 @@ class TwitapifavoritesAction extends TwitterapiAction
|
|||||||
$notice = $user->favoriteNotices((($page-1)*20), $count);
|
$notice = $user->favoriteNotices((($page-1)*20), $count);
|
||||||
|
|
||||||
if (!$notice) {
|
if (!$notice) {
|
||||||
common_server_error(_('Could not retrieve favorite notices.'));
|
$this->serverError(_('Could not retrieve favorite notices.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,7 +82,7 @@ class TwitapifavoritesAction extends TwitterapiAction
|
|||||||
$this->show_json_timeline($notice);
|
$this->show_json_timeline($notice);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
common_user_error(_('API method not found!'), $code = 404);
|
$this->clientError(_('API method not found!'), $code = 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -94,12 +94,12 @@ class TwitapifavoritesAction extends TwitterapiAction
|
|||||||
// Check for RESTfulness
|
// Check for RESTfulness
|
||||||
if (!in_array($_SERVER['REQUEST_METHOD'], array('POST', 'DELETE'))) {
|
if (!in_array($_SERVER['REQUEST_METHOD'], array('POST', 'DELETE'))) {
|
||||||
// XXX: Twitter just prints the err msg, no XML / JSON.
|
// XXX: Twitter just prints the err msg, no XML / JSON.
|
||||||
$this->client_error(_('This method requires a POST or DELETE.'), 400, $apidata['content-type']);
|
$this->clientError(_('This method requires a POST or DELETE.'), 400, $apidata['content-type']);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!in_array($apidata['content-type'], array('xml', 'json'))) {
|
if (!in_array($apidata['content-type'], array('xml', 'json'))) {
|
||||||
common_user_error(_('API method not found!'), $code = 404);
|
$this->clientError(_('API method not found!'), $code = 404);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,20 +109,20 @@ class TwitapifavoritesAction extends TwitterapiAction
|
|||||||
$notice = Notice::staticGet($notice_id);
|
$notice = Notice::staticGet($notice_id);
|
||||||
|
|
||||||
if (!$notice) {
|
if (!$notice) {
|
||||||
$this->client_error(_('No status found with that ID.'), 404, $apidata['content-type']);
|
$this->clientError(_('No status found with that ID.'), 404, $apidata['content-type']);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// XXX: Twitter lets you fave things repeatedly via api.
|
// XXX: Twitter lets you fave things repeatedly via api.
|
||||||
if ($user->hasFave($notice)) {
|
if ($user->hasFave($notice)) {
|
||||||
$this->client_error(_('This notice is already a favorite!'), 403, $apidata['content-type']);
|
$this->clientError(_('This notice is already a favorite!'), 403, $apidata['content-type']);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$fave = Fave::addNew($user, $notice);
|
$fave = Fave::addNew($user, $notice);
|
||||||
|
|
||||||
if (!$fave) {
|
if (!$fave) {
|
||||||
common_server_error(_('Could not create favorite.'));
|
$this->serverError(_('Could not create favorite.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -140,7 +140,7 @@ class TwitapifavoritesAction extends TwitterapiAction
|
|||||||
function destroy($args, $apidata)
|
function destroy($args, $apidata)
|
||||||
{
|
{
|
||||||
parent::handle($args);
|
parent::handle($args);
|
||||||
common_server_error(_('API method under construction.'), $code=501);
|
$this->serverError(_('API method under construction.'), $code=501);
|
||||||
}
|
}
|
||||||
|
|
||||||
// XXX: these two funcs swiped from faves. Maybe put in util.php, or some common base class?
|
// XXX: these two funcs swiped from faves. Maybe put in util.php, or some common base class?
|
||||||
|
@ -29,7 +29,7 @@ class TwitapifriendshipsAction extends TwitterapiAction
|
|||||||
parent::handle($args);
|
parent::handle($args);
|
||||||
|
|
||||||
if ($_SERVER['REQUEST_METHOD'] != 'POST') {
|
if ($_SERVER['REQUEST_METHOD'] != 'POST') {
|
||||||
$this->client_error(_('This method requires a POST.'), 400, $apidata['content-type']);
|
$this->clientError(_('This method requires a POST.'), 400, $apidata['content-type']);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -38,7 +38,7 @@ class TwitapifriendshipsAction extends TwitterapiAction
|
|||||||
$other = $this->get_user($id);
|
$other = $this->get_user($id);
|
||||||
|
|
||||||
if (!$other) {
|
if (!$other) {
|
||||||
$this->client_error(_('Could not follow user: User not found.'), 403, $apidata['content-type']);
|
$this->clientError(_('Could not follow user: User not found.'), 403, $apidata['content-type']);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,7 +46,7 @@ class TwitapifriendshipsAction extends TwitterapiAction
|
|||||||
|
|
||||||
if ($user->isSubscribed($other)) {
|
if ($user->isSubscribed($other)) {
|
||||||
$errmsg = sprintf(_('Could not follow user: %s is already on your list.'), $other->nickname);
|
$errmsg = sprintf(_('Could not follow user: %s is already on your list.'), $other->nickname);
|
||||||
$this->client_error($errmsg, 403, $apidata['content-type']);
|
$this->clientError($errmsg, 403, $apidata['content-type']);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,7 +62,7 @@ class TwitapifriendshipsAction extends TwitterapiAction
|
|||||||
|
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
$errmsg = sprintf(_('Could not follow user: %s is already on your list.'), $other->nickname);
|
$errmsg = sprintf(_('Could not follow user: %s is already on your list.'), $other->nickname);
|
||||||
$this->client_error($errmsg, 400, $apidata['content-type']);
|
$this->clientError($errmsg, 400, $apidata['content-type']);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,7 +82,7 @@ class TwitapifriendshipsAction extends TwitterapiAction
|
|||||||
parent::handle($args);
|
parent::handle($args);
|
||||||
|
|
||||||
if (!in_array($_SERVER['REQUEST_METHOD'], array('POST', 'DELETE'))) {
|
if (!in_array($_SERVER['REQUEST_METHOD'], array('POST', 'DELETE'))) {
|
||||||
$this->client_error(_('This method requires a POST or DELETE.'), 400, $apidata['content-type']);
|
$this->clientError(_('This method requires a POST or DELETE.'), 400, $apidata['content-type']);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,7 +102,7 @@ class TwitapifriendshipsAction extends TwitterapiAction
|
|||||||
$sub->delete();
|
$sub->delete();
|
||||||
$sub->query('COMMIT');
|
$sub->query('COMMIT');
|
||||||
} else {
|
} else {
|
||||||
$this->client_error(_('You are not friends with the specified user.'), 403, $apidata['content-type']);
|
$this->clientError(_('You are not friends with the specified user.'), 403, $apidata['content-type']);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -118,7 +118,7 @@ class TwitapifriendshipsAction extends TwitterapiAction
|
|||||||
parent::handle($args);
|
parent::handle($args);
|
||||||
|
|
||||||
if (!in_array($apidata['content-type'], array('xml', 'json'))) {
|
if (!in_array($apidata['content-type'], array('xml', 'json'))) {
|
||||||
common_user_error(_('API method not found!'), $code = 404);
|
$this->clientError(_('API method not found!'), $code = 404);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -129,7 +129,7 @@ class TwitapifriendshipsAction extends TwitterapiAction
|
|||||||
$user_b = $this->get_user($user_b_id);
|
$user_b = $this->get_user($user_b_id);
|
||||||
|
|
||||||
if (!$user_a || !$user_b) {
|
if (!$user_a || !$user_b) {
|
||||||
$this->client_error(_('Two user ids or screen_names must be supplied.'), 400, $apidata['content-type']);
|
$this->clientError(_('Two user ids or screen_names must be supplied.'), 400, $apidata['content-type']);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -142,7 +142,7 @@ class TwitapifriendshipsAction extends TwitterapiAction
|
|||||||
switch ($apidata['content-type']) {
|
switch ($apidata['content-type']) {
|
||||||
case 'xml':
|
case 'xml':
|
||||||
$this->init_document('xml');
|
$this->init_document('xml');
|
||||||
common_element('friends', null, $result);
|
$this->element('friends', null, $result);
|
||||||
$this->end_document('xml');
|
$this->end_document('xml');
|
||||||
break;
|
break;
|
||||||
case 'json':
|
case 'json':
|
||||||
|
@ -34,14 +34,14 @@ class TwitapihelpAction extends TwitterapiAction
|
|||||||
|
|
||||||
if ($apidata['content-type'] == 'xml') {
|
if ($apidata['content-type'] == 'xml') {
|
||||||
$this->init_document('xml');
|
$this->init_document('xml');
|
||||||
common_element('ok', null, 'true');
|
$this->element('ok', null, 'true');
|
||||||
$this->end_document('xml');
|
$this->end_document('xml');
|
||||||
} elseif ($apidata['content-type'] == 'json') {
|
} elseif ($apidata['content-type'] == 'json') {
|
||||||
$this->init_document('json');
|
$this->init_document('json');
|
||||||
print '"ok"';
|
print '"ok"';
|
||||||
$this->end_document('json');
|
$this->end_document('json');
|
||||||
} else {
|
} else {
|
||||||
common_user_error(_('API method not found!'), $code=404);
|
$this->clientError(_('API method not found!'), $code=404);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -49,7 +49,7 @@ class TwitapihelpAction extends TwitterapiAction
|
|||||||
function downtime_schedule($args, $apidata)
|
function downtime_schedule($args, $apidata)
|
||||||
{
|
{
|
||||||
parent::handle($args);
|
parent::handle($args);
|
||||||
common_server_error(_('API method under construction.'), $code=501);
|
$this->serverError(_('API method under construction.'), $code=501);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -70,7 +70,7 @@ class TwitapilaconicaAction extends TwitterapiAction
|
|||||||
switch ($apidata['content-type']) {
|
switch ($apidata['content-type']) {
|
||||||
case 'xml':
|
case 'xml':
|
||||||
$this->init_document('xml');
|
$this->init_document('xml');
|
||||||
common_element('version', null, LACONICA_VERSION);
|
$this->element('version', null, LACONICA_VERSION);
|
||||||
$this->end_document('xml');
|
$this->end_document('xml');
|
||||||
break;
|
break;
|
||||||
case 'json':
|
case 'json':
|
||||||
@ -79,7 +79,7 @@ class TwitapilaconicaAction extends TwitterapiAction
|
|||||||
$this->end_document('json');
|
$this->end_document('json');
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$this->client_error(_('API method not found!'), $code=404);
|
$this->clientError(_('API method not found!'), $code=404);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -115,10 +115,10 @@ class TwitapilaconicaAction extends TwitterapiAction
|
|||||||
switch ($apidata['content-type']) {
|
switch ($apidata['content-type']) {
|
||||||
case 'xml':
|
case 'xml':
|
||||||
$this->init_document('xml');
|
$this->init_document('xml');
|
||||||
common_element_start('config');
|
$this->elementStart('config');
|
||||||
// XXX: check that all sections and settings are legal XML elements
|
// XXX: check that all sections and settings are legal XML elements
|
||||||
foreach ($keys as $section => $settings) {
|
foreach ($keys as $section => $settings) {
|
||||||
common_element_start($section);
|
$this->elementStart($section);
|
||||||
foreach ($settings as $setting) {
|
foreach ($settings as $setting) {
|
||||||
$value = common_config($section, $setting);
|
$value = common_config($section, $setting);
|
||||||
if (is_array($value)) {
|
if (is_array($value)) {
|
||||||
@ -128,11 +128,11 @@ class TwitapilaconicaAction extends TwitterapiAction
|
|||||||
} else if ($value === true) {
|
} else if ($value === true) {
|
||||||
$value = 'true';
|
$value = 'true';
|
||||||
}
|
}
|
||||||
common_element($setting, null, $value);
|
$this->element($setting, null, $value);
|
||||||
}
|
}
|
||||||
common_element_end($section);
|
$this->elementEnd($section);
|
||||||
}
|
}
|
||||||
common_element_end('config');
|
$this->elementEnd('config');
|
||||||
$this->end_document('xml');
|
$this->end_document('xml');
|
||||||
break;
|
break;
|
||||||
case 'json':
|
case 'json':
|
||||||
@ -148,7 +148,7 @@ class TwitapilaconicaAction extends TwitterapiAction
|
|||||||
$this->end_document('json');
|
$this->end_document('json');
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$this->client_error(_('API method not found!'), $code=404);
|
$this->clientError(_('API method not found!'), $code=404);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -169,6 +169,6 @@ class TwitapilaconicaAction extends TwitterapiAction
|
|||||||
function wadl($args, $apidata)
|
function wadl($args, $apidata)
|
||||||
{
|
{
|
||||||
parent::handle($args);
|
parent::handle($args);
|
||||||
common_server_error(_('API method under construction.'), 501);
|
$this->serverError(_('API method under construction.'), 501);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,13 +28,13 @@ class TwitapinotificationsAction extends TwitterapiAction
|
|||||||
function follow($args, $apidata)
|
function follow($args, $apidata)
|
||||||
{
|
{
|
||||||
parent::handle($args);
|
parent::handle($args);
|
||||||
common_server_error(_('API method under construction.'), $code=501);
|
$this->serverError(_('API method under construction.'), $code=501);
|
||||||
}
|
}
|
||||||
|
|
||||||
function leave($args, $apidata)
|
function leave($args, $apidata)
|
||||||
{
|
{
|
||||||
parent::handle($args);
|
parent::handle($args);
|
||||||
common_server_error(_('API method under construction.'), $code=501);
|
$this->serverError(_('API method under construction.'), $code=501);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -76,12 +76,12 @@ class TwitapistatusesAction extends TwitterapiAction
|
|||||||
$this->show_json_timeline($notice);
|
$this->show_json_timeline($notice);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
common_user_error(_('API method not found!'), $code = 404);
|
$this->clientError(_('API method not found!'), $code = 404);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
common_server_error(_('Couldn\'t find any statuses.'), $code = 503);
|
$this->serverError(_('Couldn\'t find any statuses.'), $code = 503);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -144,7 +144,7 @@ class TwitapistatusesAction extends TwitterapiAction
|
|||||||
$this->show_json_timeline($notice);
|
$this->show_json_timeline($notice);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
common_user_error(_('API method not found!'), $code = 404);
|
$this->clientError(_('API method not found!'), $code = 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -157,14 +157,14 @@ class TwitapistatusesAction extends TwitterapiAction
|
|||||||
$user = $this->get_user($apidata['api_arg'], $apidata);
|
$user = $this->get_user($apidata['api_arg'], $apidata);
|
||||||
|
|
||||||
if (!$user) {
|
if (!$user) {
|
||||||
$this->client_error('Not Found', 404, $apidata['content-type']);
|
$this->clientError('Not Found', 404, $apidata['content-type']);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$profile = $user->getProfile();
|
$profile = $user->getProfile();
|
||||||
|
|
||||||
if (!$profile) {
|
if (!$profile) {
|
||||||
common_server_error(_('User has no profile.'));
|
$this->serverError(_('User has no profile.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -225,7 +225,7 @@ class TwitapistatusesAction extends TwitterapiAction
|
|||||||
$this->show_json_timeline($notice);
|
$this->show_json_timeline($notice);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
common_user_error(_('API method not found!'), $code = 404);
|
$this->clientError(_('API method not found!'), $code = 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -236,12 +236,12 @@ class TwitapistatusesAction extends TwitterapiAction
|
|||||||
parent::handle($args);
|
parent::handle($args);
|
||||||
|
|
||||||
if (!in_array($apidata['content-type'], array('xml', 'json'))) {
|
if (!in_array($apidata['content-type'], array('xml', 'json'))) {
|
||||||
common_user_error(_('API method not found!'), $code = 404);
|
$this->clientError(_('API method not found!'), $code = 404);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($_SERVER['REQUEST_METHOD'] != 'POST') {
|
if ($_SERVER['REQUEST_METHOD'] != 'POST') {
|
||||||
$this->client_error(_('This method requires a POST.'), 400, $apidata['content-type']);
|
$this->clientError(_('This method requires a POST.'), 400, $apidata['content-type']);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -273,7 +273,7 @@ class TwitapistatusesAction extends TwitterapiAction
|
|||||||
// as "truncated." Sending this error may screw up some clients
|
// as "truncated." Sending this error may screw up some clients
|
||||||
// that assume Twitter will truncate for them. Should we just
|
// that assume Twitter will truncate for them. Should we just
|
||||||
// truncate too? -- Zach
|
// truncate too? -- Zach
|
||||||
$this->client_error(_('That\'s too long. Max notice size is 140 chars.'), $code = 406, $apidata['content-type']);
|
$this->clientError(_('That\'s too long. Max notice size is 140 chars.'), $code = 406, $apidata['content-type']);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -306,7 +306,7 @@ class TwitapistatusesAction extends TwitterapiAction
|
|||||||
if ($reply) {
|
if ($reply) {
|
||||||
$reply_to = $in_reply_to_status_id;
|
$reply_to = $in_reply_to_status_id;
|
||||||
} else {
|
} else {
|
||||||
$this->client_error(_('Not found'), $code = 404, $apidata['content-type']);
|
$this->clientError(_('Not found'), $code = 404, $apidata['content-type']);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -315,7 +315,7 @@ class TwitapistatusesAction extends TwitterapiAction
|
|||||||
$source, 1, $reply_to);
|
$source, 1, $reply_to);
|
||||||
|
|
||||||
if (is_string($notice)) {
|
if (is_string($notice)) {
|
||||||
$this->server_error($notice);
|
$this->serverError($notice);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -389,7 +389,7 @@ class TwitapistatusesAction extends TwitterapiAction
|
|||||||
$this->show_json_timeline($notices);
|
$this->show_json_timeline($notices);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
common_user_error(_('API method not found!'), $code = 404);
|
$this->clientError(_('API method not found!'), $code = 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -399,7 +399,7 @@ class TwitapistatusesAction extends TwitterapiAction
|
|||||||
parent::handle($args);
|
parent::handle($args);
|
||||||
|
|
||||||
if (!in_array($apidata['content-type'], array('xml', 'json'))) {
|
if (!in_array($apidata['content-type'], array('xml', 'json'))) {
|
||||||
common_user_error(_('API method not found!'), $code = 404);
|
$this->clientError(_('API method not found!'), $code = 404);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -415,7 +415,7 @@ class TwitapistatusesAction extends TwitterapiAction
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// XXX: Twitter just sets a 404 header and doens't bother to return an err msg
|
// XXX: Twitter just sets a 404 header and doens't bother to return an err msg
|
||||||
$this->client_error(_('No status with that ID found.'), 404, $apidata['content-type']);
|
$this->clientError(_('No status with that ID found.'), 404, $apidata['content-type']);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -426,14 +426,14 @@ class TwitapistatusesAction extends TwitterapiAction
|
|||||||
parent::handle($args);
|
parent::handle($args);
|
||||||
|
|
||||||
if (!in_array($apidata['content-type'], array('xml', 'json'))) {
|
if (!in_array($apidata['content-type'], array('xml', 'json'))) {
|
||||||
common_user_error(_('API method not found!'), $code = 404);
|
$this->clientError(_('API method not found!'), $code = 404);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for RESTfulness
|
// Check for RESTfulness
|
||||||
if (!in_array($_SERVER['REQUEST_METHOD'], array('POST', 'DELETE'))) {
|
if (!in_array($_SERVER['REQUEST_METHOD'], array('POST', 'DELETE'))) {
|
||||||
// XXX: Twitter just prints the err msg, no XML / JSON.
|
// XXX: Twitter just prints the err msg, no XML / JSON.
|
||||||
$this->client_error(_('This method requires a POST or DELETE.'), 400, $apidata['content-type']);
|
$this->clientError(_('This method requires a POST or DELETE.'), 400, $apidata['content-type']);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -443,7 +443,7 @@ class TwitapistatusesAction extends TwitterapiAction
|
|||||||
$notice = Notice::staticGet($notice_id);
|
$notice = Notice::staticGet($notice_id);
|
||||||
|
|
||||||
if (!$notice) {
|
if (!$notice) {
|
||||||
$this->client_error(_('No status found with that ID.'), 404, $apidata['content-type']);
|
$this->clientError(_('No status found with that ID.'), 404, $apidata['content-type']);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -460,7 +460,7 @@ class TwitapistatusesAction extends TwitterapiAction
|
|||||||
$this->show_single_json_status($notice);
|
$this->show_single_json_status($notice);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$this->client_error(_('You may not delete another user\'s status.'), 403, $apidata['content-type']);
|
$this->clientError(_('You may not delete another user\'s status.'), 403, $apidata['content-type']);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -487,7 +487,7 @@ class TwitapistatusesAction extends TwitterapiAction
|
|||||||
$user = $this->get_user($apidata['api_arg'], $apidata);
|
$user = $this->get_user($apidata['api_arg'], $apidata);
|
||||||
|
|
||||||
if (!$user) {
|
if (!$user) {
|
||||||
$this->client_error('Not Found', 404, $apidata['content-type']);
|
$this->clientError('Not Found', 404, $apidata['content-type']);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -500,7 +500,7 @@ class TwitapistatusesAction extends TwitterapiAction
|
|||||||
$profile = $user->getProfile();
|
$profile = $user->getProfile();
|
||||||
|
|
||||||
if (!$profile) {
|
if (!$profile) {
|
||||||
common_server_error(_('User has no profile.'));
|
$this->serverError(_('User has no profile.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -538,11 +538,11 @@ class TwitapistatusesAction extends TwitterapiAction
|
|||||||
{
|
{
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
case 'xml':
|
case 'xml':
|
||||||
common_element_start('users', array('type' => 'array'));
|
$this->elementStart('users', array('type' => 'array'));
|
||||||
foreach ($profiles as $profile) {
|
foreach ($profiles as $profile) {
|
||||||
$this->show_profile($profile);
|
$this->show_profile($profile);
|
||||||
}
|
}
|
||||||
common_element_end('users');
|
$this->elementEnd('users');
|
||||||
break;
|
break;
|
||||||
case 'json':
|
case 'json':
|
||||||
$arrays = array();
|
$arrays = array();
|
||||||
@ -552,14 +552,14 @@ class TwitapistatusesAction extends TwitterapiAction
|
|||||||
print json_encode($arrays);
|
print json_encode($arrays);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$this->client_error(_('unsupported file type'));
|
$this->clientError(_('unsupported file type'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function featured($args, $apidata)
|
function featured($args, $apidata)
|
||||||
{
|
{
|
||||||
parent::handle($args);
|
parent::handle($args);
|
||||||
common_server_error(_('API method under construction.'), $code=501);
|
$this->serverError(_('API method under construction.'), $code=501);
|
||||||
}
|
}
|
||||||
|
|
||||||
function supported($cmd)
|
function supported($cmd)
|
||||||
|
@ -29,7 +29,7 @@ class TwitapiusersAction extends TwitterapiAction
|
|||||||
parent::handle($args);
|
parent::handle($args);
|
||||||
|
|
||||||
if (!in_array($apidata['content-type'], array('xml', 'json'))) {
|
if (!in_array($apidata['content-type'], array('xml', 'json'))) {
|
||||||
common_user_error(_('API method not found!'), $code = 404);
|
$this->clientError(_('API method not found!'), $code = 404);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -44,7 +44,7 @@ class TwitapiusersAction extends TwitterapiAction
|
|||||||
|
|
||||||
if (!$user) {
|
if (!$user) {
|
||||||
// XXX: Twitter returns a random(?) user instead of throwing and err! -- Zach
|
// XXX: Twitter returns a random(?) user instead of throwing and err! -- Zach
|
||||||
$this->client_error(_('Not found.'), 404, $apidata['content-type']);
|
$this->clientError(_('Not found.'), 404, $apidata['content-type']);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/**
|
||||||
* Laconica - a distributed open-source microblogging tool
|
* Laconica, the distributed open-source microblogging tool
|
||||||
* Copyright (C) 2008, Controlez-Vous, Inc.
|
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* Settings for Twitter integration
|
||||||
|
*
|
||||||
|
* 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
|
* 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
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
@ -15,86 +18,167 @@
|
|||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* 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/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* @category Settings
|
||||||
|
* @package Laconica
|
||||||
|
* @author Evan Prodromou <evan@controlyourself.ca>
|
||||||
|
* @copyright 2008-2009 Control Yourself, Inc.
|
||||||
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||||
|
* @link http://laconi.ca/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('LACONICA')) { exit(1); }
|
if (!defined('LACONICA')) {
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
require_once(INSTALLDIR.'/lib/settingsaction.php');
|
require_once INSTALLDIR.'/lib/connectsettingsaction.php';
|
||||||
|
|
||||||
define('SUBSCRIPTIONS', 80);
|
define('SUBSCRIPTIONS', 80);
|
||||||
|
|
||||||
class TwittersettingsAction extends SettingsAction
|
/**
|
||||||
{
|
* Settings for Twitter integration
|
||||||
|
*
|
||||||
|
* @category Settings
|
||||||
|
* @package Laconica
|
||||||
|
* @author Evan Prodromou <evan@controlyourself.ca>
|
||||||
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||||
|
* @link http://laconi.ca/
|
||||||
|
*
|
||||||
|
* @see SettingsAction
|
||||||
|
*/
|
||||||
|
|
||||||
function get_instructions()
|
class TwittersettingsAction extends ConnectSettingsAction
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Title of the page
|
||||||
|
*
|
||||||
|
* @return string Title of the page
|
||||||
|
*/
|
||||||
|
|
||||||
|
function title()
|
||||||
{
|
{
|
||||||
return _('Add your Twitter account to automatically send your notices to Twitter, ' .
|
_('Twitter settings');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instructions for use
|
||||||
|
*
|
||||||
|
* @return instructions for use
|
||||||
|
*/
|
||||||
|
|
||||||
|
function getInstructions()
|
||||||
|
{
|
||||||
|
return _('Add your Twitter account to automatically send '.
|
||||||
|
' your notices to Twitter, ' .
|
||||||
'and subscribe to Twitter friends already here.');
|
'and subscribe to Twitter friends already here.');
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_form($msg=null, $success=false)
|
/**
|
||||||
|
* Content area of the page
|
||||||
|
*
|
||||||
|
* Shows a form for associating a Twitter account with this
|
||||||
|
* Laconica account. Also lets the user set preferences.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
|
function showContent()
|
||||||
{
|
{
|
||||||
$user = common_current_user();
|
$user = common_current_user();
|
||||||
|
|
||||||
$profile = $user->getProfile();
|
$profile = $user->getProfile();
|
||||||
|
|
||||||
$fuser = null;
|
$fuser = null;
|
||||||
|
|
||||||
$flink = Foreign_link::getByUserID($user->id, 1); // 1 == Twitter
|
$flink = Foreign_link::getByUserID($user->id, 1); // 1 == Twitter
|
||||||
|
|
||||||
if ($flink) {
|
if ($flink) {
|
||||||
$fuser = $flink->getForeignUser();
|
$fuser = $flink->getForeignUser();
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->form_header(_('Twitter settings'), $msg, $success);
|
$this->elementStart('form', array('method' => 'post',
|
||||||
common_element_start('form', array('method' => 'post',
|
'id' => 'form_settings_twitter',
|
||||||
'id' => 'twittersettings',
|
'class' => 'form_settings',
|
||||||
'action' =>
|
'action' =>
|
||||||
common_local_url('twittersettings')));
|
common_local_url('twittersettings')));
|
||||||
common_hidden('token', common_session_token());
|
$this->elementStart('fieldset', array('id' => 'settings_twitter_account'));
|
||||||
|
$this->element('legend', null, _('Twitter Account'));
|
||||||
common_element('h2', null, _('Twitter Account'));
|
$this->hidden('token', common_session_token());
|
||||||
|
$this->elementStart('ul', 'form_data');
|
||||||
if ($fuser) {
|
if ($fuser) {
|
||||||
common_element_start('p');
|
$this->elementStart('li');
|
||||||
|
$this->element('span', 'twitter_user', $fuser->nickname);
|
||||||
common_element('span', 'twitter_user', $fuser->nickname);
|
$this->element('a', array('href' => $fuser->uri), $fuser->uri);
|
||||||
common_element('a', array('href' => $fuser->uri), $fuser->uri);
|
$this->element('p', 'form_guide',
|
||||||
common_element('span', 'input_instructions',
|
|
||||||
_('Current verified Twitter account.'));
|
_('Current verified Twitter account.'));
|
||||||
common_hidden('flink_foreign_id', $flink->foreign_id);
|
$this->hidden('flink_foreign_id', $flink->foreign_id);
|
||||||
common_element_end('p');
|
$this->submit('remove', _('Remove'));
|
||||||
common_submit('remove', _('Remove'));
|
$this->elementEnd('li');
|
||||||
} else {
|
} else {
|
||||||
common_input('twitter_username', _('Twitter user name'),
|
$this->elementStart('li');
|
||||||
($this->arg('twitter_username')) ? $this->arg('twitter_username') : $profile->nickname,
|
$this->input('twitter_username', _('Twitter user name'),
|
||||||
|
($this->arg('twitter_username')) ?
|
||||||
|
$this->arg('twitter_username') :
|
||||||
|
$profile->nickname,
|
||||||
_('No spaces, please.')); // hey, it's what Twitter says
|
_('No spaces, please.')); // hey, it's what Twitter says
|
||||||
|
$this->elementEnd('li');
|
||||||
common_password('twitter_password', _('Twitter password'));
|
$this->elementStart('li');
|
||||||
|
$this->password('twitter_password', _('Twitter password'));
|
||||||
|
$this->elementend('li');
|
||||||
}
|
}
|
||||||
|
$this->elementEnd('ul');
|
||||||
|
$this->elementEnd('fieldset');
|
||||||
|
|
||||||
common_element('h2', null, _('Preferences'));
|
$this->elementStart('fieldset',
|
||||||
|
array('id' => 'settings_twitter_preferences'));
|
||||||
|
$this->element('legend', null, _('Preferences'));
|
||||||
|
|
||||||
common_checkbox('noticesync', _('Automatically send my notices to Twitter.'),
|
$this->elementStart('ul', 'form_data');
|
||||||
($flink) ? ($flink->noticesync & FOREIGN_NOTICE_SEND) : true);
|
$this->elementStart('li');
|
||||||
|
$this->checkbox('noticesync',
|
||||||
common_checkbox('replysync', _('Send local "@" replies to Twitter.'),
|
_('Automatically send my notices to Twitter.'),
|
||||||
($flink) ? ($flink->noticesync & FOREIGN_NOTICE_SEND_REPLY) : true);
|
($flink) ?
|
||||||
|
($flink->noticesync & FOREIGN_NOTICE_SEND) :
|
||||||
common_checkbox('friendsync', _('Subscribe to my Twitter friends here.'),
|
true);
|
||||||
($flink) ? ($flink->friendsync & FOREIGN_FRIEND_RECV) : false);
|
$this->elementEnd('li');
|
||||||
|
$this->elementStart('li');
|
||||||
|
$this->checkbox('replysync',
|
||||||
|
_('Send local "@" replies to Twitter.'),
|
||||||
|
($flink) ?
|
||||||
|
($flink->noticesync & FOREIGN_NOTICE_SEND_REPLY) :
|
||||||
|
true);
|
||||||
|
$this->elementEnd('li');
|
||||||
|
$this->elementStart('li');
|
||||||
|
$this->checkbox('friendsync',
|
||||||
|
_('Subscribe to my Twitter friends here.'),
|
||||||
|
($flink) ?
|
||||||
|
($flink->friendsync & FOREIGN_FRIEND_RECV) :
|
||||||
|
false);
|
||||||
|
$this->elementEnd('li');
|
||||||
|
$this->elementEnd('ul');
|
||||||
|
|
||||||
if ($flink) {
|
if ($flink) {
|
||||||
common_submit('save', _('Save'));
|
$this->submit('save', _('Save'));
|
||||||
} else {
|
} else {
|
||||||
common_submit('add', _('Add'));
|
$this->submit('add', _('Add'));
|
||||||
|
}
|
||||||
|
$this->elementEnd('fieldset');
|
||||||
|
|
||||||
|
$this->showTwitterSubscriptions();
|
||||||
|
|
||||||
|
$this->elementEnd('form');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->show_twitter_subscriptions();
|
/**
|
||||||
|
* Gets some of the user's Twitter friends
|
||||||
|
*
|
||||||
|
* Gets the number of Twitter friends that are on this
|
||||||
|
* instance of Laconica.
|
||||||
|
*
|
||||||
|
* @return array array of User objects
|
||||||
|
*/
|
||||||
|
|
||||||
common_element_end('form');
|
function subscribedTwitterUsers()
|
||||||
|
|
||||||
common_show_footer();
|
|
||||||
}
|
|
||||||
|
|
||||||
function subscribed_twitter_users()
|
|
||||||
{
|
{
|
||||||
|
|
||||||
$current_user = common_current_user();
|
$current_user = common_current_user();
|
||||||
@ -123,17 +207,27 @@ class TwittersettingsAction extends SettingsAction
|
|||||||
return $users;
|
return $users;
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_twitter_subscriptions()
|
/**
|
||||||
|
* Show user's Twitter friends
|
||||||
|
*
|
||||||
|
* Gets the number of Twitter friends that are on this
|
||||||
|
* instance of Laconica, and shows their mini-avatars.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
|
function showTwitterSubscriptions()
|
||||||
{
|
{
|
||||||
|
|
||||||
$friends = $this->subscribed_twitter_users();
|
$friends = $this->subscribedTwitterUsers();
|
||||||
|
|
||||||
$friends_count = count($friends);
|
$friends_count = count($friends);
|
||||||
|
|
||||||
if ($friends_count > 0) {
|
if ($friends_count > 0) {
|
||||||
|
|
||||||
common_element('h3', null, _('Twitter Friends'));
|
$this->element('h3', null, _('Twitter Friends'));
|
||||||
common_element_start('div', array('id' => 'subscriptions'));
|
$this->elementStart('div', array('id' => 'subscriptions'));
|
||||||
common_element_start('ul', array('id' => 'subscriptions_avatars'));
|
$this->elementStart('ul', array('id' => 'subscriptions_avatars'));
|
||||||
|
|
||||||
for ($i = 0; $i < min($friends_count, SUBSCRIPTIONS); $i++) {
|
for ($i = 0; $i < min($friends_count, SUBSCRIPTIONS); $i++) {
|
||||||
|
|
||||||
@ -144,71 +238,82 @@ class TwittersettingsAction extends SettingsAction
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
common_element_start('li');
|
$this->elementStart('li');
|
||||||
common_element_start('a', array('title' => ($other->fullname) ?
|
$this->elementStart('a', array('title' => ($other->fullname) ?
|
||||||
$other->fullname :
|
$other->fullname :
|
||||||
$other->nickname,
|
$other->nickname,
|
||||||
'href' => $other->profileurl,
|
'href' => $other->profileurl,
|
||||||
'rel' => 'contact',
|
'rel' => 'contact',
|
||||||
'class' => 'subscription'));
|
'class' => 'subscription'));
|
||||||
|
|
||||||
$avatar = $other->getAvatar(AVATAR_MINI_SIZE);
|
$avatar = $other->getAvatar(AVATAR_MINI_SIZE);
|
||||||
common_element('img', array('src' => (($avatar) ? common_avatar_display_url($avatar) : common_default_avatar(AVATAR_MINI_SIZE)),
|
|
||||||
|
$avatar_url = ($avatar) ?
|
||||||
|
common_avatar_display_url($avatar) :
|
||||||
|
common_default_avatar(AVATAR_MINI_SIZE);
|
||||||
|
|
||||||
|
$this->element('img', array('src' => $avatar_url,
|
||||||
'width' => AVATAR_MINI_SIZE,
|
'width' => AVATAR_MINI_SIZE,
|
||||||
'height' => AVATAR_MINI_SIZE,
|
'height' => AVATAR_MINI_SIZE,
|
||||||
'class' => 'avatar mini',
|
'class' => 'avatar mini',
|
||||||
'alt' => ($other->fullname) ?
|
'alt' => ($other->fullname) ?
|
||||||
$other->fullname :
|
$other->fullname :
|
||||||
$other->nickname));
|
$other->nickname));
|
||||||
common_element_end('a');
|
$this->elementEnd('a');
|
||||||
common_element_end('li');
|
$this->elementEnd('li');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
common_element_end('ul');
|
$this->elementEnd('ul');
|
||||||
common_element_end('div');
|
$this->elementEnd('div');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// XXX Figure out a way to show all Twitter friends... ?
|
|
||||||
|
|
||||||
/*
|
|
||||||
if ($subs_count > SUBSCRIPTIONS) {
|
|
||||||
common_element_start('p', array('id' => 'subscriptions_viewall'));
|
|
||||||
|
|
||||||
common_element('a', array('href' => common_local_url('subscriptions',
|
|
||||||
array('nickname' => $profile->nickname)),
|
|
||||||
'class' => 'moresubscriptions'),
|
|
||||||
_('All subscriptions'));
|
|
||||||
common_element_end('p');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle posts to this form
|
||||||
|
*
|
||||||
|
* Based on the button that was pressed, muxes out to other functions
|
||||||
|
* to do the actual task requested.
|
||||||
|
*
|
||||||
|
* All sub-functions reload the form with a message -- success or failure.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
|
|
||||||
}
|
function handlePost()
|
||||||
|
|
||||||
function handle_post()
|
|
||||||
{
|
{
|
||||||
|
|
||||||
# CSRF protection
|
// CSRF protection
|
||||||
$token = $this->trimmed('token');
|
$token = $this->trimmed('token');
|
||||||
if (!$token || $token != common_session_token()) {
|
if (!$token || $token != common_session_token()) {
|
||||||
$this->show_form(_('There was a problem with your session token. Try again, please.'));
|
$this->showForm(_('There was a problem with your session token. '.
|
||||||
|
'Try again, please.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->arg('save')) {
|
if ($this->arg('save')) {
|
||||||
$this->save_preferences();
|
$this->savePreferences();
|
||||||
} else if ($this->arg('add')) {
|
} else if ($this->arg('add')) {
|
||||||
$this->add_twitter_acct();
|
$this->addTwitterAccount();
|
||||||
} else if ($this->arg('remove')) {
|
} else if ($this->arg('remove')) {
|
||||||
$this->remove_twitter_acct();
|
$this->removeTwitterAccount();
|
||||||
} else {
|
} else {
|
||||||
$this->show_form(_('Unexpected form submission.'));
|
$this->showForm(_('Unexpected form submission.'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function add_twitter_acct()
|
/**
|
||||||
|
* Associate a Twitter account with the user's account
|
||||||
|
*
|
||||||
|
* Validates post input; verifies it against Twitter; and if
|
||||||
|
* successful stores in the database.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
|
function addTwitterAccount()
|
||||||
{
|
{
|
||||||
|
|
||||||
$screen_name = $this->trimmed('twitter_username');
|
$screen_name = $this->trimmed('twitter_username');
|
||||||
$password = $this->trimmed('twitter_password');
|
$password = $this->trimmed('twitter_password');
|
||||||
$noticesync = $this->boolean('noticesync');
|
$noticesync = $this->boolean('noticesync');
|
||||||
@ -216,35 +321,38 @@ class TwittersettingsAction extends SettingsAction
|
|||||||
$friendsync = $this->boolean('friendsync');
|
$friendsync = $this->boolean('friendsync');
|
||||||
|
|
||||||
if (!Validate::string($screen_name,
|
if (!Validate::string($screen_name,
|
||||||
array( 'min_length' => 1,
|
array('min_length' => 1,
|
||||||
'max_length' => 15,
|
'max_length' => 15,
|
||||||
'format' => VALIDATE_NUM . VALIDATE_ALPHA . '_'))) {
|
'format' => VALIDATE_NUM.VALIDATE_ALPHA.'_'))) {
|
||||||
$this->show_form(
|
$this->showForm(_('Username must have only numbers, '.
|
||||||
_('Username must have only numbers, upper- and lowercase letters, and underscore (_). 15 chars max.'));
|
'upper- and lowercase letters, '.
|
||||||
|
'and underscore (_). 15 chars max.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$this->verify_credentials($screen_name, $password)) {
|
if (!$this->verifyCredentials($screen_name, $password)) {
|
||||||
$this->show_form(_('Could not verify your Twitter credentials!'));
|
$this->showForm(_('Could not verify your Twitter credentials!'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$twit_user = twitter_user_info($screen_name, $password);
|
$twit_user = twitter_user_info($screen_name, $password);
|
||||||
|
|
||||||
if (!$twit_user) {
|
if (!$twit_user) {
|
||||||
$this->show_form(sprintf(_('Unable to retrieve account information for "%s" from Twitter.'),
|
$this->showForm(sprintf(_('Unable to retrieve account information '.
|
||||||
|
'For "%s" from Twitter.'),
|
||||||
$screen_name));
|
$screen_name));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!save_twitter_user($twit_user->id, $screen_name)) {
|
if (!save_twitter_user($twit_user->id, $screen_name)) {
|
||||||
$this->show_form(_('Unable to save your Twitter settings!'));
|
$this->showForm(_('Unable to save your Twitter settings!'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$user = common_current_user();
|
$user = common_current_user();
|
||||||
|
|
||||||
$flink = DB_DataObject::factory('foreign_link');
|
$flink = new Foreign_link();
|
||||||
|
|
||||||
$flink->user_id = $user->id;
|
$flink->user_id = $user->id;
|
||||||
$flink->foreign_id = $twit_user->id;
|
$flink->foreign_id = $twit_user->id;
|
||||||
$flink->service = 1; // Twitter
|
$flink->service = 1; // Twitter
|
||||||
@ -257,7 +365,7 @@ class TwittersettingsAction extends SettingsAction
|
|||||||
|
|
||||||
if (!$flink_id) {
|
if (!$flink_id) {
|
||||||
common_log_db_error($flink, 'INSERT', __FILE__);
|
common_log_db_error($flink, 'INSERT', __FILE__);
|
||||||
$this->show_form(_('Unable to save your Twitter settings!'));
|
$this->showForm(_('Unable to save your Twitter settings!'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -265,19 +373,26 @@ class TwittersettingsAction extends SettingsAction
|
|||||||
save_twitter_friends($user, $twit_user->id, $screen_name, $password);
|
save_twitter_friends($user, $twit_user->id, $screen_name, $password);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->show_form(_('Twitter settings saved.'), true);
|
$this->showForm(_('Twitter settings saved.'), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
function remove_twitter_acct()
|
/**
|
||||||
{
|
* Disassociate an existing Twitter account from this account
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
|
function removeTwitterAccount()
|
||||||
|
{
|
||||||
$user = common_current_user();
|
$user = common_current_user();
|
||||||
|
|
||||||
$flink = Foreign_link::getByUserID($user->id, 1);
|
$flink = Foreign_link::getByUserID($user->id, 1);
|
||||||
|
|
||||||
$flink_foreign_id = $this->arg('flink_foreign_id');
|
$flink_foreign_id = $this->arg('flink_foreign_id');
|
||||||
|
|
||||||
# Maybe an old tab open...?
|
// Maybe an old tab open...?
|
||||||
if ($flink->foreign_id != $flink_foreign_id) {
|
if ($flink->foreign_id != $flink_foreign_id) {
|
||||||
$this->show_form(_('That is not your Twitter account.'));
|
$this->showForm(_('That is not your Twitter account.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -285,16 +400,21 @@ class TwittersettingsAction extends SettingsAction
|
|||||||
|
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
common_log_db_error($flink, 'DELETE', __FILE__);
|
common_log_db_error($flink, 'DELETE', __FILE__);
|
||||||
common_server_error(_('Couldn\'t remove Twitter user.'));
|
$this->serverError(_('Couldn\'t remove Twitter user.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->show_form(_('Twitter account removed.'), true);
|
$this->showForm(_('Twitter account removed.'), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
function save_preferences()
|
/**
|
||||||
{
|
* Save user's Twitter-bridging preferences
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
|
function savePreferences()
|
||||||
|
{
|
||||||
$noticesync = $this->boolean('noticesync');
|
$noticesync = $this->boolean('noticesync');
|
||||||
$friendsync = $this->boolean('friendsync');
|
$friendsync = $this->boolean('friendsync');
|
||||||
$replysync = $this->boolean('replysync');
|
$replysync = $this->boolean('replysync');
|
||||||
@ -305,7 +425,7 @@ class TwittersettingsAction extends SettingsAction
|
|||||||
|
|
||||||
if (!$flink) {
|
if (!$flink) {
|
||||||
common_log_db_error($flink, 'SELECT', __FILE__);
|
common_log_db_error($flink, 'SELECT', __FILE__);
|
||||||
$this->show_form(_('Couldn\'t save Twitter preferences.'));
|
$this->showForm(_('Couldn\'t save Twitter preferences.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -316,19 +436,21 @@ class TwittersettingsAction extends SettingsAction
|
|||||||
|
|
||||||
if (!$fuser) {
|
if (!$fuser) {
|
||||||
common_log_db_error($fuser, 'SELECT', __FILE__);
|
common_log_db_error($fuser, 'SELECT', __FILE__);
|
||||||
$this->show_form(_('Couldn\'t save Twitter preferences.'));
|
$this->showForm(_('Couldn\'t save Twitter preferences.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$screen_name = $fuser->nickname;
|
$screen_name = $fuser->nickname;
|
||||||
|
|
||||||
$original = clone($flink);
|
$original = clone($flink);
|
||||||
|
|
||||||
$flink->set_flags($noticesync, $replysync, $friendsync);
|
$flink->set_flags($noticesync, $replysync, $friendsync);
|
||||||
|
|
||||||
$result = $flink->update($original);
|
$result = $flink->update($original);
|
||||||
|
|
||||||
if ($result === false) {
|
if ($result === false) {
|
||||||
common_log_db_error($flink, 'UPDATE', __FILE__);
|
common_log_db_error($flink, 'UPDATE', __FILE__);
|
||||||
$this->show_form(_('Couldn\'t save Twitter preferences.'));
|
$this->showForm(_('Couldn\'t save Twitter preferences.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -336,12 +458,22 @@ class TwittersettingsAction extends SettingsAction
|
|||||||
save_twitter_friends($user, $flink->foreign_id, $screen_name, $password);
|
save_twitter_friends($user, $flink->foreign_id, $screen_name, $password);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->show_form(_('Twitter preferences saved.'), true);
|
$this->showForm(_('Twitter preferences saved.'), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
function verify_credentials($screen_name, $password)
|
/**
|
||||||
|
* Verifies a username and password against Twitter's API
|
||||||
|
*
|
||||||
|
* @param string $screen_name Twitter user name
|
||||||
|
* @param string $password Twitter password
|
||||||
|
*
|
||||||
|
* @return boolean success flag
|
||||||
|
*/
|
||||||
|
|
||||||
|
function verifyCredentials($screen_name, $password)
|
||||||
{
|
{
|
||||||
$uri = 'http://twitter.com/account/verify_credentials.json';
|
$uri = 'http://twitter.com/account/verifyCredentials.json';
|
||||||
|
|
||||||
$data = get_twitter_data($uri, $screen_name, $password);
|
$data = get_twitter_data($uri, $screen_name, $password);
|
||||||
|
|
||||||
if (!$data) {
|
if (!$data) {
|
||||||
@ -354,7 +486,7 @@ class TwittersettingsAction extends SettingsAction
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$twitter_id = $user->status->id;
|
$twitter_id = $user->id;
|
||||||
|
|
||||||
if ($twitter_id) {
|
if ($twitter_id) {
|
||||||
return $twitter_id;
|
return $twitter_id;
|
||||||
@ -363,5 +495,4 @@ class TwittersettingsAction extends SettingsAction
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
@ -30,28 +30,28 @@ class UnblockAction extends Action
|
|||||||
parent::prepare($args);
|
parent::prepare($args);
|
||||||
|
|
||||||
if (!common_logged_in()) {
|
if (!common_logged_in()) {
|
||||||
$this->client_error(_('Not logged in.'));
|
$this->clientError(_('Not logged in.'));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$token = $this->trimmed('token');
|
$token = $this->trimmed('token');
|
||||||
|
|
||||||
if (!$token || $token != common_session_token()) {
|
if (!$token || $token != common_session_token()) {
|
||||||
$this->client_error(_('There was a problem with your session token. Try again, please.'));
|
$this->clientError(_('There was a problem with your session token. Try again, please.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$id = $this->trimmed('unblockto');
|
$id = $this->trimmed('unblockto');
|
||||||
|
|
||||||
if (!$id) {
|
if (!$id) {
|
||||||
$this->client_error(_('No profile specified.'));
|
$this->clientError(_('No profile specified.'));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->profile = Profile::staticGet('id', $id);
|
$this->profile = Profile::staticGet('id', $id);
|
||||||
|
|
||||||
if (!$this->profile) {
|
if (!$this->profile) {
|
||||||
$this->client_error(_('No profile with that ID.'));
|
$this->clientError(_('No profile with that ID.'));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,7 +74,7 @@ class UnblockAction extends Action
|
|||||||
$result = $cur->unblock($this->profile);
|
$result = $cur->unblock($this->profile);
|
||||||
|
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
$this->server_error(_('Error removing the block.'));
|
$this->serverError(_('Error removing the block.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ class UnsubscribeAction extends Action
|
|||||||
{
|
{
|
||||||
parent::handle($args);
|
parent::handle($args);
|
||||||
if (!common_logged_in()) {
|
if (!common_logged_in()) {
|
||||||
common_user_error(_('Not logged in.'));
|
$this->clientError(_('Not logged in.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,40 +40,40 @@ class UnsubscribeAction extends Action
|
|||||||
$token = $this->trimmed('token');
|
$token = $this->trimmed('token');
|
||||||
|
|
||||||
if (!$token || $token != common_session_token()) {
|
if (!$token || $token != common_session_token()) {
|
||||||
$this->client_error(_('There was a problem with your session token. Try again, please.'));
|
$this->clientError(_('There was a problem with your session token. Try again, please.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$other_id = $this->arg('unsubscribeto');
|
$other_id = $this->arg('unsubscribeto');
|
||||||
|
|
||||||
if (!$other_id) {
|
if (!$other_id) {
|
||||||
$this->client_error(_('No profile id in request.'));
|
$this->clientError(_('No profile id in request.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$other = Profile::staticGet('id', $other_id);
|
$other = Profile::staticGet('id', $other_id);
|
||||||
|
|
||||||
if (!$other_id) {
|
if (!$other_id) {
|
||||||
$this->client_error(_('No profile with that id.'));
|
$this->clientError(_('No profile with that id.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = subs_unsubscribe_to($user, $other);
|
$result = subs_unsubscribe_to($user, $other);
|
||||||
|
|
||||||
if ($result != true) {
|
if ($result != true) {
|
||||||
common_user_error($result);
|
$this->clientError($result);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->boolean('ajax')) {
|
if ($this->boolean('ajax')) {
|
||||||
common_start_html('text/xml;charset=utf-8', true);
|
common_start_html('text/xml;charset=utf-8', true);
|
||||||
common_element_start('head');
|
$this->elementStart('head');
|
||||||
common_element('title', null, _('Unsubscribed'));
|
$this->element('title', null, _('Unsubscribed'));
|
||||||
common_element_end('head');
|
$this->elementEnd('head');
|
||||||
common_element_start('body');
|
$this->elementStart('body');
|
||||||
common_subscribe_form($other);
|
common_subscribe_form($other);
|
||||||
common_element_end('body');
|
$this->elementEnd('body');
|
||||||
common_element_end('html');
|
$this->elementEnd('html');
|
||||||
} else {
|
} else {
|
||||||
common_redirect(common_local_url('subscriptions', array('nickname' =>
|
common_redirect(common_local_url('subscriptions', array('nickname' =>
|
||||||
$user->nickname)));
|
$user->nickname)));
|
||||||
|
@ -37,7 +37,7 @@ class UpdateprofileAction extends Action
|
|||||||
print "omb_version=".OMB_VERSION_01;
|
print "omb_version=".OMB_VERSION_01;
|
||||||
}
|
}
|
||||||
} catch (OAuthException $e) {
|
} catch (OAuthException $e) {
|
||||||
$this->server_error($e->getMessage());
|
$this->serverError($e->getMessage());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -46,14 +46,14 @@ class UpdateprofileAction extends Action
|
|||||||
{
|
{
|
||||||
$version = $req->get_parameter('omb_version');
|
$version = $req->get_parameter('omb_version');
|
||||||
if ($version != OMB_VERSION_01) {
|
if ($version != OMB_VERSION_01) {
|
||||||
$this->client_error(_('Unsupported OMB version'), 400);
|
$this->clientError(_('Unsupported OMB version'), 400);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
# First, check to see if listenee exists
|
# First, check to see if listenee exists
|
||||||
$listenee = $req->get_parameter('omb_listenee');
|
$listenee = $req->get_parameter('omb_listenee');
|
||||||
$remote = Remote_profile::staticGet('uri', $listenee);
|
$remote = Remote_profile::staticGet('uri', $listenee);
|
||||||
if (!$remote) {
|
if (!$remote) {
|
||||||
$this->client_error(_('Profile unknown'), 404);
|
$this->clientError(_('Profile unknown'), 404);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
# Second, check to see if they should be able to post updates!
|
# Second, check to see if they should be able to post updates!
|
||||||
@ -64,72 +64,72 @@ class UpdateprofileAction extends Action
|
|||||||
$sub->subscribed = $remote->id;
|
$sub->subscribed = $remote->id;
|
||||||
$sub->token = $token->key;
|
$sub->token = $token->key;
|
||||||
if (!$sub->find(true)) {
|
if (!$sub->find(true)) {
|
||||||
$this->client_error(_('You did not send us that profile'), 403);
|
$this->clientError(_('You did not send us that profile'), 403);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$profile = Profile::staticGet('id', $remote->id);
|
$profile = Profile::staticGet('id', $remote->id);
|
||||||
if (!$profile) {
|
if (!$profile) {
|
||||||
# This one is our fault
|
# This one is our fault
|
||||||
$this->server_error(_('Remote profile with no matching profile'), 500);
|
$this->serverError(_('Remote profile with no matching profile'), 500);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$nickname = $req->get_parameter('omb_listenee_nickname');
|
$nickname = $req->get_parameter('omb_listenee_nickname');
|
||||||
if ($nickname && !Validate::string($nickname, array('min_length' => 1,
|
if ($nickname && !Validate::string($nickname, array('min_length' => 1,
|
||||||
'max_length' => 64,
|
'max_length' => 64,
|
||||||
'format' => VALIDATE_NUM . VALIDATE_ALPHA_LOWER))) {
|
'format' => VALIDATE_NUM . VALIDATE_ALPHA_LOWER))) {
|
||||||
$this->client_error(_('Nickname must have only lowercase letters and numbers and no spaces.'));
|
$this->clientError(_('Nickname must have only lowercase letters and numbers and no spaces.'));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$license = $req->get_parameter('omb_listenee_license');
|
$license = $req->get_parameter('omb_listenee_license');
|
||||||
if ($license && !common_valid_http_url($license)) {
|
if ($license && !common_valid_http_url($license)) {
|
||||||
$this->client_error(sprintf(_("Invalid license URL '%s'"), $license));
|
$this->clientError(sprintf(_("Invalid license URL '%s'"), $license));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$profile_url = $req->get_parameter('omb_listenee_profile');
|
$profile_url = $req->get_parameter('omb_listenee_profile');
|
||||||
if ($profile_url && !common_valid_http_url($profile_url)) {
|
if ($profile_url && !common_valid_http_url($profile_url)) {
|
||||||
$this->client_error(sprintf(_("Invalid profile URL '%s'."), $profile_url));
|
$this->clientError(sprintf(_("Invalid profile URL '%s'."), $profile_url));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
# optional stuff
|
# optional stuff
|
||||||
$fullname = $req->get_parameter('omb_listenee_fullname');
|
$fullname = $req->get_parameter('omb_listenee_fullname');
|
||||||
if ($fullname && strlen($fullname) > 255) {
|
if ($fullname && strlen($fullname) > 255) {
|
||||||
$this->client_error(_("Full name is too long (max 255 chars)."));
|
$this->clientError(_("Full name is too long (max 255 chars)."));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$homepage = $req->get_parameter('omb_listenee_homepage');
|
$homepage = $req->get_parameter('omb_listenee_homepage');
|
||||||
if ($homepage && (!common_valid_http_url($homepage) || strlen($homepage) > 255)) {
|
if ($homepage && (!common_valid_http_url($homepage) || strlen($homepage) > 255)) {
|
||||||
$this->client_error(sprintf(_("Invalid homepage '%s'"), $homepage));
|
$this->clientError(sprintf(_("Invalid homepage '%s'"), $homepage));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$bio = $req->get_parameter('omb_listenee_bio');
|
$bio = $req->get_parameter('omb_listenee_bio');
|
||||||
if ($bio && strlen($bio) > 140) {
|
if ($bio && strlen($bio) > 140) {
|
||||||
$this->client_error(_("Bio is too long (max 140 chars)."));
|
$this->clientError(_("Bio is too long (max 140 chars)."));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$location = $req->get_parameter('omb_listenee_location');
|
$location = $req->get_parameter('omb_listenee_location');
|
||||||
if ($location && strlen($location) > 255) {
|
if ($location && strlen($location) > 255) {
|
||||||
$this->client_error(_("Location is too long (max 255 chars)."));
|
$this->clientError(_("Location is too long (max 255 chars)."));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$avatar = $req->get_parameter('omb_listenee_avatar');
|
$avatar = $req->get_parameter('omb_listenee_avatar');
|
||||||
if ($avatar) {
|
if ($avatar) {
|
||||||
if (!common_valid_http_url($avatar) || strlen($avatar) > 255) {
|
if (!common_valid_http_url($avatar) || strlen($avatar) > 255) {
|
||||||
$this->client_error(sprintf(_("Invalid avatar URL '%s'"), $avatar));
|
$this->clientError(sprintf(_("Invalid avatar URL '%s'"), $avatar));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$size = @getimagesize($avatar);
|
$size = @getimagesize($avatar);
|
||||||
if (!$size) {
|
if (!$size) {
|
||||||
$this->client_error(sprintf(_("Can't read avatar URL '%s'"), $avatar));
|
$this->clientError(sprintf(_("Can't read avatar URL '%s'"), $avatar));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if ($size[0] != AVATAR_PROFILE_SIZE || $size[1] != AVATAR_PROFILE_SIZE) {
|
if ($size[0] != AVATAR_PROFILE_SIZE || $size[1] != AVATAR_PROFILE_SIZE) {
|
||||||
$this->client_error(sprintf(_("Wrong size image at '%s'"), $avatar));
|
$this->clientError(sprintf(_("Wrong size image at '%s'"), $avatar));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!in_array($size[2], array(IMAGETYPE_GIF, IMAGETYPE_JPEG,
|
if (!in_array($size[2], array(IMAGETYPE_GIF, IMAGETYPE_JPEG,
|
||||||
IMAGETYPE_PNG))) {
|
IMAGETYPE_PNG))) {
|
||||||
$this->client_error(sprintf(_("Wrong image type for '%s'"), $avatar));
|
$this->clientError(sprintf(_("Wrong image type for '%s'"), $avatar));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -156,14 +156,14 @@ class UpdateprofileAction extends Action
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!$profile->update($orig_profile)) {
|
if (!$profile->update($orig_profile)) {
|
||||||
$this->server_error(_('Could not save new profile info'), 500);
|
$this->serverError(_('Could not save new profile info'), 500);
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
if ($avatar) {
|
if ($avatar) {
|
||||||
$temp_filename = tempnam(sys_get_temp_dir(), 'listenee_avatar');
|
$temp_filename = tempnam(sys_get_temp_dir(), 'listenee_avatar');
|
||||||
copy($avatar, $temp_filename);
|
copy($avatar, $temp_filename);
|
||||||
if (!$profile->setOriginal($temp_filename)) {
|
if (!$profile->setOriginal($temp_filename)) {
|
||||||
$this->server_error(_('Could not save avatar info'), 500);
|
$this->serverError(_('Could not save avatar info'), 500);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,7 @@ class UserauthorizationAction extends Action
|
|||||||
common_debug('getting new request', __FILE__);
|
common_debug('getting new request', __FILE__);
|
||||||
$req = $this->get_new_request();
|
$req = $this->get_new_request();
|
||||||
if (!$req) {
|
if (!$req) {
|
||||||
$this->client_error(_('No request found!'));
|
$this->clientError(_('No request found!'));
|
||||||
}
|
}
|
||||||
common_debug('validating request', __FILE__);
|
common_debug('validating request', __FILE__);
|
||||||
# XXX: only validate new requests, since nonce is one-time use
|
# XXX: only validate new requests, since nonce is one-time use
|
||||||
@ -64,7 +64,7 @@ class UserauthorizationAction extends Action
|
|||||||
$this->show_form($req);
|
$this->show_form($req);
|
||||||
} catch (OAuthException $e) {
|
} catch (OAuthException $e) {
|
||||||
$this->clear_request();
|
$this->clear_request();
|
||||||
$this->client_error($e->getMessage());
|
$this->clientError($e->getMessage());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,51 +84,51 @@ class UserauthorizationAction extends Action
|
|||||||
$avatar = $req->get_parameter('omb_listenee_avatar');
|
$avatar = $req->get_parameter('omb_listenee_avatar');
|
||||||
|
|
||||||
common_show_header(_('Authorize subscription'));
|
common_show_header(_('Authorize subscription'));
|
||||||
common_element('p', null, _('Please check these details to make sure '.
|
$this->element('p', null, _('Please check these details to make sure '.
|
||||||
'that you want to subscribe to this user\'s notices. '.
|
'that you want to subscribe to this user\'s notices. '.
|
||||||
'If you didn\'t just ask to subscribe to someone\'s notices, '.
|
'If you didn\'t just ask to subscribe to someone\'s notices, '.
|
||||||
'click "Cancel".'));
|
'click "Cancel".'));
|
||||||
common_element_start('div', 'profile');
|
$this->elementStart('div', 'profile');
|
||||||
if ($avatar) {
|
if ($avatar) {
|
||||||
common_element('img', array('src' => $avatar,
|
$this->element('img', array('src' => $avatar,
|
||||||
'class' => 'avatar profile',
|
'class' => 'avatar profile',
|
||||||
'width' => AVATAR_PROFILE_SIZE,
|
'width' => AVATAR_PROFILE_SIZE,
|
||||||
'height' => AVATAR_PROFILE_SIZE,
|
'height' => AVATAR_PROFILE_SIZE,
|
||||||
'alt' => $nickname));
|
'alt' => $nickname));
|
||||||
}
|
}
|
||||||
common_element('a', array('href' => $profile,
|
$this->element('a', array('href' => $profile,
|
||||||
'class' => 'external profile nickname'),
|
'class' => 'external profile nickname'),
|
||||||
$nickname);
|
$nickname);
|
||||||
if ($fullname) {
|
if ($fullname) {
|
||||||
common_element_start('div', 'fullname');
|
$this->elementStart('div', 'fullname');
|
||||||
if ($homepage) {
|
if ($homepage) {
|
||||||
common_element('a', array('href' => $homepage),
|
$this->element('a', array('href' => $homepage),
|
||||||
$fullname);
|
$fullname);
|
||||||
} else {
|
} else {
|
||||||
common_text($fullname);
|
$this->text($fullname);
|
||||||
}
|
}
|
||||||
common_element_end('div');
|
$this->elementEnd('div');
|
||||||
}
|
}
|
||||||
if ($location) {
|
if ($location) {
|
||||||
common_element('div', 'location', $location);
|
$this->element('div', 'location', $location);
|
||||||
}
|
}
|
||||||
if ($bio) {
|
if ($bio) {
|
||||||
common_element('div', 'bio', $bio);
|
$this->element('div', 'bio', $bio);
|
||||||
}
|
}
|
||||||
common_element_start('div', 'license');
|
$this->elementStart('div', 'license');
|
||||||
common_element('a', array('href' => $license,
|
$this->element('a', array('href' => $license,
|
||||||
'class' => 'license'),
|
'class' => 'license'),
|
||||||
$license);
|
$license);
|
||||||
common_element_end('div');
|
$this->elementEnd('div');
|
||||||
common_element_end('div');
|
$this->elementEnd('div');
|
||||||
common_element_start('form', array('method' => 'post',
|
$this->elementStart('form', array('method' => 'post',
|
||||||
'id' => 'userauthorization',
|
'id' => 'userauthorization',
|
||||||
'name' => 'userauthorization',
|
'name' => 'userauthorization',
|
||||||
'action' => common_local_url('userauthorization')));
|
'action' => common_local_url('userauthorization')));
|
||||||
common_hidden('token', common_session_token());
|
$this->hidden('token', common_session_token());
|
||||||
common_submit('accept', _('Accept'));
|
$this->submit('accept', _('Accept'));
|
||||||
common_submit('reject', _('Reject'));
|
$this->submit('reject', _('Reject'));
|
||||||
common_element_end('form');
|
$this->elementEnd('form');
|
||||||
common_show_footer();
|
common_show_footer();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -137,7 +137,7 @@ class UserauthorizationAction extends Action
|
|||||||
$req = $this->get_stored_request();
|
$req = $this->get_stored_request();
|
||||||
|
|
||||||
if (!$req) {
|
if (!$req) {
|
||||||
common_user_error(_('No authorization request!'));
|
$this->clientError(_('No authorization request!'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -145,10 +145,10 @@ class UserauthorizationAction extends Action
|
|||||||
|
|
||||||
if ($this->arg('accept')) {
|
if ($this->arg('accept')) {
|
||||||
if (!$this->authorize_token($req)) {
|
if (!$this->authorize_token($req)) {
|
||||||
$this->client_error(_('Error authorizing token'));
|
$this->clientError(_('Error authorizing token'));
|
||||||
}
|
}
|
||||||
if (!$this->save_remote_profile($req)) {
|
if (!$this->save_remote_profile($req)) {
|
||||||
$this->client_error(_('Error saving remote profile'));
|
$this->clientError(_('Error saving remote profile'));
|
||||||
}
|
}
|
||||||
if (!$callback) {
|
if (!$callback) {
|
||||||
$this->show_accept_message($req->get_parameter('oauth_token'));
|
$this->show_accept_message($req->get_parameter('oauth_token'));
|
||||||
@ -160,7 +160,7 @@ class UserauthorizationAction extends Action
|
|||||||
$profile = $user->getProfile();
|
$profile = $user->getProfile();
|
||||||
if (!$profile) {
|
if (!$profile) {
|
||||||
common_log_db_error($user, 'SELECT', __FILE__);
|
common_log_db_error($user, 'SELECT', __FILE__);
|
||||||
$this->server_error(_('User without matching profile'));
|
$this->serverError(_('User without matching profile'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$params['omb_listener_nickname'] = $user->nickname;
|
$params['omb_listener_nickname'] = $user->nickname;
|
||||||
@ -328,18 +328,18 @@ class UserauthorizationAction extends Action
|
|||||||
function show_accept_message($tok)
|
function show_accept_message($tok)
|
||||||
{
|
{
|
||||||
common_show_header(_('Subscription authorized'));
|
common_show_header(_('Subscription authorized'));
|
||||||
common_element('p', null,
|
$this->element('p', null,
|
||||||
_('The subscription has been authorized, but no '.
|
_('The subscription has been authorized, but no '.
|
||||||
'callback URL was passed. Check with the site\'s instructions for '.
|
'callback URL was passed. Check with the site\'s instructions for '.
|
||||||
'details on how to authorize the subscription. Your subscription token is:'));
|
'details on how to authorize the subscription. Your subscription token is:'));
|
||||||
common_element('blockquote', 'token', $tok);
|
$this->element('blockquote', 'token', $tok);
|
||||||
common_show_footer();
|
common_show_footer();
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_reject_message($tok)
|
function show_reject_message($tok)
|
||||||
{
|
{
|
||||||
common_show_header(_('Subscription rejected'));
|
common_show_header(_('Subscription rejected'));
|
||||||
common_element('p', null,
|
$this->element('p', null,
|
||||||
_('The subscription has been rejected, but no '.
|
_('The subscription has been rejected, but no '.
|
||||||
'callback URL was passed. Check with the site\'s instructions for '.
|
'callback URL was passed. Check with the site\'s instructions for '.
|
||||||
'details on how to fully reject the subscription.'));
|
'details on how to fully reject the subscription.'));
|
||||||
|
@ -1,5 +1,17 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
|
||||||
|
/**
|
||||||
|
* User by ID action class.
|
||||||
|
*
|
||||||
|
* PHP version 5
|
||||||
|
*
|
||||||
|
* @category Action
|
||||||
|
* @package Laconica
|
||||||
|
* @author Evan Prodromou <evan@controlyourself.ca>
|
||||||
|
* @author Robin Millette <millette@controlyourself.ca>
|
||||||
|
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
|
||||||
|
* @link http://laconi.ca/
|
||||||
|
|
||||||
* Laconica - a distributed open-source microblogging tool
|
* Laconica - a distributed open-source microblogging tool
|
||||||
* Copyright (C) 2008, Controlez-Vous, Inc.
|
* Copyright (C) 2008, Controlez-Vous, Inc.
|
||||||
*
|
*
|
||||||
@ -17,36 +29,60 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('LACONICA')) { exit(1); }
|
if (!defined('LACONICA')) {
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* User by ID action class.
|
||||||
|
*
|
||||||
|
* @category Action
|
||||||
|
* @package Laconica
|
||||||
|
* @author Evan Prodromou <evan@controlyourself.ca>
|
||||||
|
* @author Robin Millette <millette@controlyourself.ca>
|
||||||
|
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
|
||||||
|
* @link http://laconi.ca/
|
||||||
|
*/
|
||||||
class UserbyidAction extends Action
|
class UserbyidAction extends Action
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
function is_readonly()
|
* Is read only?
|
||||||
|
*
|
||||||
|
* @return boolean true
|
||||||
|
*/
|
||||||
|
function isReadOnly()
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class handler.
|
||||||
|
*
|
||||||
|
* @param array $args array of arguments
|
||||||
|
*
|
||||||
|
* @return nothing
|
||||||
|
*/
|
||||||
function handle($args)
|
function handle($args)
|
||||||
{
|
{
|
||||||
parent::handle($args);
|
parent::handle($args);
|
||||||
$id = $this->trimmed('id');
|
$id = $this->trimmed('id');
|
||||||
if (!$id) {
|
if (!$id) {
|
||||||
$this->client_error(_('No id.'));
|
$this->clientError(_('No id.'));
|
||||||
}
|
}
|
||||||
$user =& User::staticGet($id);
|
$user =& User::staticGet($id);
|
||||||
if (!$user) {
|
if (!$user) {
|
||||||
$this->client_error(_('No such user.'));
|
$this->clientError(_('No such user.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
// support redirecting to FOAF rdf/xml if the agent prefers it
|
// support redirecting to FOAF rdf/xml if the agent prefers it
|
||||||
$page_prefs = 'application/rdf+xml,text/html,application/xhtml+xml,application/xml;q=0.3,text/xml;q=0.2';
|
$page_prefs = 'application/rdf+xml,text/html,application/xhtml+xml,application/xml;q=0.3,text/xml;q=0.2';
|
||||||
$httpaccept = isset($_SERVER['HTTP_ACCEPT']) ? $_SERVER['HTTP_ACCEPT'] : null;
|
$httpaccept = isset($_SERVER['HTTP_ACCEPT'])
|
||||||
|
? $_SERVER['HTTP_ACCEPT'] : null;
|
||||||
$type = common_negotiate_type(common_accept_to_prefs($httpaccept),
|
$type = common_negotiate_type(common_accept_to_prefs($httpaccept),
|
||||||
common_accept_to_prefs($page_prefs));
|
common_accept_to_prefs($page_prefs));
|
||||||
$page = $type == 'application/rdf+xml' ? 'foaf' : 'showstream';
|
$page = $type == 'application/rdf+xml' ? 'foaf' : 'showstream';
|
||||||
|
|
||||||
$url = common_local_url($page, array('nickname' => $user->nickname));
|
$url = common_local_url($page, array('nickname' => $user->nickname));
|
||||||
common_redirect($url, 303);
|
common_redirect($url, 303);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ class UserrssAction extends Rss10Action
|
|||||||
$this->user = User::staticGet('nickname', $nickname);
|
$this->user = User::staticGet('nickname', $nickname);
|
||||||
|
|
||||||
if (!$this->user) {
|
if (!$this->user) {
|
||||||
common_user_error(_('No such user.'));
|
$this->clientError(_('No such user.'));
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
return true;
|
return true;
|
||||||
@ -78,7 +78,7 @@ class UserrssAction extends Rss10Action
|
|||||||
$profile = $user->getProfile();
|
$profile = $user->getProfile();
|
||||||
if (!$profile) {
|
if (!$profile) {
|
||||||
common_log_db_error($user, 'SELECT', __FILE__);
|
common_log_db_error($user, 'SELECT', __FILE__);
|
||||||
$this->server_error(_('User without matching profile'));
|
$this->serverError(_('User without matching profile'));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
$avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE);
|
$avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE);
|
||||||
|
@ -24,7 +24,7 @@ require_once(INSTALLDIR.'/lib/omb.php');
|
|||||||
class XrdsAction extends Action
|
class XrdsAction extends Action
|
||||||
{
|
{
|
||||||
|
|
||||||
function is_readonly()
|
function isReadOnly()
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -35,7 +35,7 @@ class XrdsAction extends Action
|
|||||||
$nickname = $this->trimmed('nickname');
|
$nickname = $this->trimmed('nickname');
|
||||||
$user = User::staticGet('nickname', $nickname);
|
$user = User::staticGet('nickname', $nickname);
|
||||||
if (!$user) {
|
if (!$user) {
|
||||||
common_user_error(_('No such user.'));
|
$this->clientError(_('No such user.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$this->show_xrds($user);
|
$this->show_xrds($user);
|
||||||
@ -47,14 +47,14 @@ class XrdsAction extends Action
|
|||||||
header('Content-Type: application/xrds+xml');
|
header('Content-Type: application/xrds+xml');
|
||||||
|
|
||||||
common_start_xml();
|
common_start_xml();
|
||||||
common_element_start('XRDS', array('xmlns' => 'xri://$xrds'));
|
$this->elementStart('XRDS', array('xmlns' => 'xri://$xrds'));
|
||||||
|
|
||||||
common_element_start('XRD', array('xmlns' => 'xri://$xrd*($v*2.0)',
|
$this->elementStart('XRD', array('xmlns' => 'xri://$xrd*($v*2.0)',
|
||||||
'xml:id' => 'oauth',
|
'xml:id' => 'oauth',
|
||||||
'xmlns:simple' => 'http://xrds-simple.net/core/1.0',
|
'xmlns:simple' => 'http://xrds-simple.net/core/1.0',
|
||||||
'version' => '2.0'));
|
'version' => '2.0'));
|
||||||
|
|
||||||
common_element('Type', null, 'xri://$xrds*simple');
|
$this->element('Type', null, 'xri://$xrds*simple');
|
||||||
|
|
||||||
$this->show_service(OAUTH_ENDPOINT_REQUEST,
|
$this->show_service(OAUTH_ENDPOINT_REQUEST,
|
||||||
common_local_url('requesttoken'),
|
common_local_url('requesttoken'),
|
||||||
@ -77,16 +77,16 @@ class XrdsAction extends Action
|
|||||||
array(OAUTH_AUTH_HEADER, OAUTH_POST_BODY),
|
array(OAUTH_AUTH_HEADER, OAUTH_POST_BODY),
|
||||||
array(OAUTH_HMAC_SHA1));
|
array(OAUTH_HMAC_SHA1));
|
||||||
|
|
||||||
common_element_end('XRD');
|
$this->elementEnd('XRD');
|
||||||
|
|
||||||
# XXX: decide whether to include user's ID/nickname in postNotice URL
|
# XXX: decide whether to include user's ID/nickname in postNotice URL
|
||||||
|
|
||||||
common_element_start('XRD', array('xmlns' => 'xri://$xrd*($v*2.0)',
|
$this->elementStart('XRD', array('xmlns' => 'xri://$xrd*($v*2.0)',
|
||||||
'xml:id' => 'omb',
|
'xml:id' => 'omb',
|
||||||
'xmlns:simple' => 'http://xrds-simple.net/core/1.0',
|
'xmlns:simple' => 'http://xrds-simple.net/core/1.0',
|
||||||
'version' => '2.0'));
|
'version' => '2.0'));
|
||||||
|
|
||||||
common_element('Type', null, 'xri://$xrds*simple');
|
$this->element('Type', null, 'xri://$xrds*simple');
|
||||||
|
|
||||||
$this->show_service(OMB_ENDPOINT_POSTNOTICE,
|
$this->show_service(OMB_ENDPOINT_POSTNOTICE,
|
||||||
common_local_url('postnotice'));
|
common_local_url('postnotice'));
|
||||||
@ -94,44 +94,44 @@ class XrdsAction extends Action
|
|||||||
$this->show_service(OMB_ENDPOINT_UPDATEPROFILE,
|
$this->show_service(OMB_ENDPOINT_UPDATEPROFILE,
|
||||||
common_local_url('updateprofile'));
|
common_local_url('updateprofile'));
|
||||||
|
|
||||||
common_element_end('XRD');
|
$this->elementEnd('XRD');
|
||||||
|
|
||||||
common_element_start('XRD', array('xmlns' => 'xri://$xrd*($v*2.0)',
|
$this->elementStart('XRD', array('xmlns' => 'xri://$xrd*($v*2.0)',
|
||||||
'version' => '2.0'));
|
'version' => '2.0'));
|
||||||
|
|
||||||
common_element('Type', null, 'xri://$xrds*simple');
|
$this->element('Type', null, 'xri://$xrds*simple');
|
||||||
|
|
||||||
$this->show_service(OAUTH_DISCOVERY,
|
$this->show_service(OAUTH_DISCOVERY,
|
||||||
'#oauth');
|
'#oauth');
|
||||||
$this->show_service(OMB_NAMESPACE,
|
$this->show_service(OMB_NAMESPACE,
|
||||||
'#omb');
|
'#omb');
|
||||||
|
|
||||||
common_element_end('XRD');
|
$this->elementEnd('XRD');
|
||||||
|
|
||||||
common_element_end('XRDS');
|
$this->elementEnd('XRDS');
|
||||||
common_end_xml();
|
common_end_xml();
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_service($type, $uri, $params=null, $sigs=null, $localId=null)
|
function show_service($type, $uri, $params=null, $sigs=null, $localId=null)
|
||||||
{
|
{
|
||||||
common_element_start('Service');
|
$this->elementStart('Service');
|
||||||
if ($uri) {
|
if ($uri) {
|
||||||
common_element('URI', null, $uri);
|
$this->element('URI', null, $uri);
|
||||||
}
|
}
|
||||||
common_element('Type', null, $type);
|
$this->element('Type', null, $type);
|
||||||
if ($params) {
|
if ($params) {
|
||||||
foreach ($params as $param) {
|
foreach ($params as $param) {
|
||||||
common_element('Type', null, $param);
|
$this->element('Type', null, $param);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($sigs) {
|
if ($sigs) {
|
||||||
foreach ($sigs as $sig) {
|
foreach ($sigs as $sig) {
|
||||||
common_element('Type', null, $sig);
|
$this->element('Type', null, $sig);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($localId) {
|
if ($localId) {
|
||||||
common_element('LocalID', null, $localId);
|
$this->element('LocalID', null, $localId);
|
||||||
}
|
}
|
||||||
common_element_end('Service');
|
$this->elementEnd('Service');
|
||||||
}
|
}
|
||||||
}
|
}
|
2
doc/faq
2
doc/faq
@ -12,7 +12,7 @@ and fans.
|
|||||||
How is %%site.name%% different from Twitter, Jaiku, Pownce, Plurk, others?
|
How is %%site.name%% different from Twitter, Jaiku, Pownce, Plurk, others?
|
||||||
--------------------------------------------------------------------------
|
--------------------------------------------------------------------------
|
||||||
|
|
||||||
%%site.name%% is an [Open Network Service](http://opendefinition.org/osd). Our main
|
%%site.name%% is an [Open Network Service](http://opendefinition.org/ossd). Our main
|
||||||
goal is to provide a fair and transparent service that preserves users' autonomy. In
|
goal is to provide a fair and transparent service that preserves users' autonomy. In
|
||||||
particular, all the software used for %%site.name%% is [Free Software](http://en.wikipedia.org/wiki/Free_Software), and all the data is available
|
particular, all the software used for %%site.name%% is [Free Software](http://en.wikipedia.org/wiki/Free_Software), and all the data is available
|
||||||
under the [%%license.title%%](%%license.url%%) license, making it Open Data.
|
under the [%%license.title%%](%%license.url%%) license, making it Open Data.
|
||||||
|
@ -52,8 +52,9 @@ RewriteRule ^main/tagother$ index.php?action=tagother [L,QSA]
|
|||||||
|
|
||||||
RewriteRule ^main/block$ index.php?action=block [L,QSA]
|
RewriteRule ^main/block$ index.php?action=block [L,QSA]
|
||||||
|
|
||||||
RewriteRule ^settings/delete$ index.php?action=deleteprofile [L,QSA]
|
|
||||||
RewriteRule ^settings/profile$ index.php?action=profilesettings [L,QSA]
|
RewriteRule ^settings/profile$ index.php?action=profilesettings [L,QSA]
|
||||||
|
RewriteRule ^settings/avatar$ index.php?action=avatarsettings [L,QSA]
|
||||||
|
RewriteRule ^settings/password$ index.php?action=passwordsettings [L,QSA]
|
||||||
RewriteRule ^settings/openid$ index.php?action=openidsettings [L,QSA]
|
RewriteRule ^settings/openid$ index.php?action=openidsettings [L,QSA]
|
||||||
RewriteRule ^settings/im$ index.php?action=imsettings [L,QSA]
|
RewriteRule ^settings/im$ index.php?action=imsettings [L,QSA]
|
||||||
RewriteRule ^settings/email$ index.php?action=emailsettings [L,QSA]
|
RewriteRule ^settings/email$ index.php?action=emailsettings [L,QSA]
|
||||||
@ -75,7 +76,7 @@ RewriteRule ^message/(\d+)$ index.php?action=showmessage&message=$1 [L,QSA]
|
|||||||
|
|
||||||
RewriteRule ^user/(\d+)$ index.php?action=userbyid&id=$1 [L,QSA]
|
RewriteRule ^user/(\d+)$ index.php?action=userbyid&id=$1 [L,QSA]
|
||||||
|
|
||||||
RewriteRule ^tags/?$ index.php?action=tag [L,QSA]
|
RewriteRule ^tags/?$ index.php?action=publictagcloud [L,QSA]
|
||||||
RewriteRule ^tag/([a-zA-Z0-9]+)/rss$ index.php?action=tagrss&tag=$1 [L,QSA]
|
RewriteRule ^tag/([a-zA-Z0-9]+)/rss$ index.php?action=tagrss&tag=$1 [L,QSA]
|
||||||
RewriteRule ^tag(/(.*))?$ index.php?action=tag&tag=$2 [L,QSA]
|
RewriteRule ^tag(/(.*))?$ index.php?action=tag&tag=$2 [L,QSA]
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ if (file_exists($actionfile)) {
|
|||||||
|
|
||||||
$action_obj = new $action_class();
|
$action_obj = new $action_class();
|
||||||
|
|
||||||
if ($config['db']['mirror'] && $action_obj->is_readonly()) {
|
if ($config['db']['mirror'] && $action_obj->isReadOnly()) {
|
||||||
if (is_array($config['db']['mirror'])) {
|
if (is_array($config['db']['mirror'])) {
|
||||||
// "load balancing", ha ha
|
// "load balancing", ha ha
|
||||||
$k = array_rand($config['db']['mirror']);
|
$k = array_rand($config['db']['mirror']);
|
||||||
|
18
js/facebookapp.js
Normal file
18
js/facebookapp.js
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
/*
|
||||||
|
* 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/>.
|
||||||
|
*/
|
||||||
|
|
@ -1,41 +0,0 @@
|
|||||||
$(function(){
|
|
||||||
jQuery("#avatar_original img.avatar").Jcrop({ onChange: showPreview,
|
|
||||||
setSelect: [ 0, 0, $("#avatar_original img.avatar").attr("width"), $("#avatar_original img.avatar").attr("height") ],
|
|
||||||
onSelect: updateCoords,
|
|
||||||
aspectRatio: 1,
|
|
||||||
boxWidth: 480,
|
|
||||||
boxHeight: 480,
|
|
||||||
bgColor: '#000',
|
|
||||||
bgOpacity: .4
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
function showPreview(coords) {
|
|
||||||
var rx = 96 / coords.w;
|
|
||||||
var ry = 96 / coords.h;
|
|
||||||
|
|
||||||
var img_width = $("#avatar_original img.avatar").attr("width");
|
|
||||||
var img_height = $("#avatar_original img.avatar").attr("height");
|
|
||||||
|
|
||||||
|
|
||||||
$('#avatar_preview img.avatar').css({
|
|
||||||
width: Math.round(rx *img_width) + 'px',
|
|
||||||
height: Math.round(ry * img_height) + 'px',
|
|
||||||
marginLeft: '-' + Math.round(rx * coords.x) + 'px',
|
|
||||||
marginTop: '-' + Math.round(ry * coords.y) + 'px'
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
function updateCoords(c) {
|
|
||||||
$('#avatar_crop_x').val(c.x);
|
|
||||||
$('#avatar_crop_y').val(c.y);
|
|
||||||
$('#avatar_crop_w').val(c.w);
|
|
||||||
$('#avatar_crop_h').val(c.h);
|
|
||||||
};
|
|
||||||
|
|
||||||
function checkCoords() {
|
|
||||||
if (parseInt($('#avatar_crop_w').val())) return true;
|
|
||||||
alert('Please select a crop region then press submit.');
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
|
|
41
js/jquery.Jcrop.go.js
Normal file
41
js/jquery.Jcrop.go.js
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
$(function(){
|
||||||
|
jQuery("#photo_original img").Jcrop({
|
||||||
|
onChange: showPreview,
|
||||||
|
setSelect: [ 0, 0, $("#photo_original img").attr("width"), $("#photo_original img").attr("height") ],
|
||||||
|
onSelect: updateCoords,
|
||||||
|
aspectRatio: 1,
|
||||||
|
boxWidth: 480,
|
||||||
|
boxHeight: 480,
|
||||||
|
bgColor: '#000',
|
||||||
|
bgOpacity: .4
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
function showPreview(coords) {
|
||||||
|
var rx = 96 / coords.w;
|
||||||
|
var ry = 96 / coords.h;
|
||||||
|
|
||||||
|
var img_width = $("#photo_original img").attr("width");
|
||||||
|
var img_height = $("#photo_original img").attr("height");
|
||||||
|
|
||||||
|
$('#photo_preview img').css({
|
||||||
|
width: Math.round(rx *img_width) + 'px',
|
||||||
|
height: Math.round(ry * img_height) + 'px',
|
||||||
|
marginLeft: '-' + Math.round(rx * coords.x) + 'px',
|
||||||
|
marginTop: '-' + Math.round(ry * coords.y) + 'px'
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
function updateCoords(c) {
|
||||||
|
$('#photo_crop_x').val(c.x);
|
||||||
|
$('#photo_crop_y').val(c.y);
|
||||||
|
$('#photo_crop_w').val(c.w);
|
||||||
|
$('#photo_crop_h').val(c.h);
|
||||||
|
};
|
||||||
|
|
||||||
|
function checkCoords() {
|
||||||
|
if (parseInt($('#photo_crop_w').val())) return true;
|
||||||
|
alert('Please select a crop region then press submit.');
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
3894
js/jquery.js
vendored
3894
js/jquery.js
vendored
File diff suppressed because it is too large
Load Diff
43
js/jquery.min.js
vendored
43
js/jquery.min.js
vendored
File diff suppressed because one or more lines are too long
67
js/util.js
67
js/util.js
@ -20,21 +20,21 @@ $(document).ready(function(){
|
|||||||
// count character on keyup
|
// count character on keyup
|
||||||
function counter(event){
|
function counter(event){
|
||||||
var maxLength = 140;
|
var maxLength = 140;
|
||||||
var currentLength = $("#status_textarea").val().length;
|
var currentLength = $("#notice_data-text").val().length;
|
||||||
var remaining = maxLength - currentLength;
|
var remaining = maxLength - currentLength;
|
||||||
var counter = $("#counter");
|
var counter = $("#notice_text-count");
|
||||||
counter.text(remaining);
|
counter.text(remaining);
|
||||||
|
|
||||||
if (remaining <= 0) {
|
if (remaining <= 0) {
|
||||||
$("#status_form").addClass("response_error");
|
$("#form_notice").addClass("warning");
|
||||||
} else {
|
} else {
|
||||||
$("#status_form").removeClass("response_error");
|
$("#form_notice").removeClass("warning");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function submitonreturn(event) {
|
function submitonreturn(event) {
|
||||||
if (event.keyCode == 13) {
|
if (event.keyCode == 13) {
|
||||||
$("#status_form").submit();
|
$("#form_notice").submit();
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
return false;
|
return false;
|
||||||
@ -42,15 +42,15 @@ $(document).ready(function(){
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($("#status_textarea").length) {
|
if ($("#notice_data-text").length) {
|
||||||
$("#status_textarea").bind("keyup", counter);
|
$("#notice_data-text").bind("keyup", counter);
|
||||||
$("#status_textarea").bind("keydown", submitonreturn);
|
$("#notice_data-text").bind("keydown", submitonreturn);
|
||||||
|
|
||||||
// run once in case there's something in there
|
// run once in case there's something in there
|
||||||
counter();
|
counter();
|
||||||
|
|
||||||
// set the focus
|
// set the focus
|
||||||
$("#status_textarea").focus();
|
$("#notice_data-text").focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
// XXX: refactor this code
|
// XXX: refactor this code
|
||||||
@ -81,10 +81,10 @@ $(document).ready(function(){
|
|||||||
this.appendChild(ajax);
|
this.appendChild(ajax);
|
||||||
}
|
}
|
||||||
|
|
||||||
$("form.favor").ajaxForm(favoptions);
|
$("form.form_favor").ajaxForm(favoptions);
|
||||||
$("form.disfavor").ajaxForm(disoptions);
|
$("form.form_disfavor").ajaxForm(disoptions);
|
||||||
$("form.favor").each(addAjaxHidden);
|
$("form.form_favor").each(addAjaxHidden);
|
||||||
$("form.disfavor").each(addAjaxHidden);
|
$("form.form_disfavor").each(addAjaxHidden);
|
||||||
|
|
||||||
$("#nudge").ajaxForm ({ dataType: 'xml',
|
$("#nudge").ajaxForm ({ dataType: 'xml',
|
||||||
beforeSubmit: function(xml) { $("form#nudge input[type=submit]").attr("disabled", "disabled");
|
beforeSubmit: function(xml) { $("form#nudge input[type=submit]").attr("disabled", "disabled");
|
||||||
@ -136,12 +136,12 @@ $(document).ready(function(){
|
|||||||
|
|
||||||
|
|
||||||
var PostNotice = { dataType: 'xml',
|
var PostNotice = { dataType: 'xml',
|
||||||
beforeSubmit: function(formData, jqForm, options) { if ($("#status_textarea").get(0).value.length == 0) {
|
beforeSubmit: function(formData, jqForm, options) { if ($("#notice_data-text").get(0).value.length == 0) {
|
||||||
$("#status_form").addClass("response_error");
|
$("#form_notice").addClass("warning");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$("#status_form input[type=submit]").attr("disabled", "disabled");
|
$("#notice_action-submit").attr("disabled", "disabled");
|
||||||
$("#status_form input[type=submit]").addClass("disabled");
|
$("#notice_action-submit").addClass("disabled");
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
success: function(xml) { if ($("#error", xml).length > 0 || $("#command_result", xml).length > 0) {
|
success: function(xml) { if ($("#error", xml).length > 0 || $("#command_result", xml).length > 0) {
|
||||||
@ -150,28 +150,37 @@ $(document).ready(function(){
|
|||||||
alert(result);
|
alert(result);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$("#notices").prepend(document._importNode($("li", xml).get(0), true));
|
$("#notices_primary .notices").prepend(document._importNode($("li", xml).get(0), true));
|
||||||
$("#status_textarea").val("");
|
$("#notice_data-text").val("");
|
||||||
counter();
|
counter();
|
||||||
$(".notice_single:first").css({display:"none"});
|
$("#notices_primary .notice:first").css({display:"none"});
|
||||||
$(".notice_single:first").fadeIn(2500);
|
$("#notices_primary .notice:first").fadeIn(2500);
|
||||||
}
|
}
|
||||||
$("#status_form input[type=submit]").removeAttr("disabled");
|
$("#notice_action-submit").removeAttr("disabled");
|
||||||
$("#status_form input[type=submit]").removeClass("disabled");
|
$("#notice_action-submit").removeClass("disabled");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
$("#status_form").ajaxForm(PostNotice);
|
$("#form_notice").ajaxForm(PostNotice);
|
||||||
$("#status_form").each(addAjaxHidden);
|
$("#form_notice").each(addAjaxHidden);
|
||||||
|
|
||||||
|
$(".notice").hover(
|
||||||
|
function () {
|
||||||
|
$(this).addClass('hover');
|
||||||
|
},
|
||||||
|
function () {
|
||||||
|
$(this).removeClass('hover');
|
||||||
|
}
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
function doreply(nick,id) {
|
function doreply(nick,id) {
|
||||||
rgx_username = /^[0-9a-zA-Z\-_.]*$/;
|
rgx_username = /^[0-9a-zA-Z\-_.]*$/;
|
||||||
if (nick.match(rgx_username)) {
|
if (nick.match(rgx_username)) {
|
||||||
replyto = "@" + nick + " ";
|
replyto = "@" + nick + " ";
|
||||||
if ($("#status_textarea").length) {
|
if ($("#notice_data-text").length) {
|
||||||
$("#status_textarea").val(replyto);
|
$("#notice_data-text").val(replyto);
|
||||||
$("form#status_form input#inreplyto").val(id);
|
$("#form_notice input#notice_in-reply-to").val(id);
|
||||||
$("#status_textarea").focus();
|
$("#notice_data-text").focus();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -44,3 +44,4 @@ document._importNode = function(node, allChildren) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
134
lib/accountsettingsaction.php
Normal file
134
lib/accountsettingsaction.php
Normal file
@ -0,0 +1,134 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Laconica, the distributed open-source microblogging tool
|
||||||
|
*
|
||||||
|
* Base class for account settings actions
|
||||||
|
*
|
||||||
|
* 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 Settings
|
||||||
|
* @package Laconica
|
||||||
|
* @author Evan Prodromou <evan@controlyourself.ca>
|
||||||
|
* @copyright 2008-2009 Control Yourself, Inc.
|
||||||
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||||
|
* @link http://laconi.ca/
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (!defined('LACONICA')) {
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
require_once INSTALLDIR.'/lib/settingsaction.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Base class for account settings actions
|
||||||
|
*
|
||||||
|
* @category Settings
|
||||||
|
* @package Laconica
|
||||||
|
* @author Evan Prodromou <evan@controlyourself.ca>
|
||||||
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||||
|
* @link http://laconi.ca/
|
||||||
|
*
|
||||||
|
* @see Widget
|
||||||
|
*/
|
||||||
|
|
||||||
|
class AccountSettingsAction extends SettingsAction
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Show the local navigation menu
|
||||||
|
*
|
||||||
|
* This is the same for all settings, so we show it here.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
|
function showLocalNav()
|
||||||
|
{
|
||||||
|
$menu = new AccountSettingsNav($this);
|
||||||
|
$menu->show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A widget for showing the settings group local nav menu
|
||||||
|
*
|
||||||
|
* @category Widget
|
||||||
|
* @package Laconica
|
||||||
|
* @author Evan Prodromou <evan@controlyourself.ca>
|
||||||
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||||
|
* @link http://laconi.ca/
|
||||||
|
*
|
||||||
|
* @see HTMLOutputter
|
||||||
|
*/
|
||||||
|
|
||||||
|
class AccountSettingsNav extends Widget
|
||||||
|
{
|
||||||
|
var $action = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Construction
|
||||||
|
*
|
||||||
|
* @param Action $action current action, used for output
|
||||||
|
*/
|
||||||
|
|
||||||
|
function __construct($action=null)
|
||||||
|
{
|
||||||
|
parent::__construct($action);
|
||||||
|
$this->action = $action;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the menu
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
|
function show()
|
||||||
|
{
|
||||||
|
# action => array('prompt', 'title')
|
||||||
|
$menu =
|
||||||
|
array('profilesettings' =>
|
||||||
|
array(_('Profile'),
|
||||||
|
_('Change your profile settings')),
|
||||||
|
'avatarsettings' =>
|
||||||
|
array(_('Avatar'),
|
||||||
|
_('Upload an avatar')),
|
||||||
|
'passwordsettings' =>
|
||||||
|
array(_('Password'),
|
||||||
|
_('Change your password')),
|
||||||
|
'emailsettings' =>
|
||||||
|
array(_('Email'),
|
||||||
|
_('Change email handling')),
|
||||||
|
'openidsettings' =>
|
||||||
|
array(_('OpenID'),
|
||||||
|
_('Add or remove OpenIDs')),
|
||||||
|
'othersettings' =>
|
||||||
|
array(_('Other'),
|
||||||
|
_('Other options')));
|
||||||
|
|
||||||
|
$action_name = $this->action->trimmed('action');
|
||||||
|
$this->action->elementStart('ul', array('class' => 'nav'));
|
||||||
|
|
||||||
|
foreach ($menu as $menuaction => $menudesc) {
|
||||||
|
$this->action->menuItem(common_local_url($menuaction),
|
||||||
|
$menudesc[0],
|
||||||
|
$menudesc[1],
|
||||||
|
$action_name === $menuaction);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->action->elementEnd('ul');
|
||||||
|
}
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user