Merge branch '0.8.x' into notice-search-no-results
This commit is contained in:
commit
65f784120b
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,4 +1,5 @@
|
|||
avatar/*
|
||||
background/*
|
||||
files/*
|
||||
file/*
|
||||
_darcs/*
|
||||
|
@ -22,3 +23,4 @@ config-*.php
|
|||
good-config.php
|
||||
lac08.log
|
||||
php.log
|
||||
config.php.*
|
||||
|
|
63
README
63
README
|
@ -178,8 +178,9 @@ and the URLs are listed here for your convenience.
|
|||
- Facebook library. Used for the Facebook application.
|
||||
- PEAR Services_oEmbed. Used for some multimedia integration.
|
||||
- PEAR HTTP_Request is an oEmbed dependency.
|
||||
- PEAR Validat is an oEmbed dependency.e
|
||||
- PEAR Net_URL is an oEmbed dependency.2
|
||||
- PEAR Validate is an oEmbed dependency.
|
||||
- PEAR Net_URL2 is an oEmbed dependency.
|
||||
- Console_GetOpt for parsing command-line options.
|
||||
|
||||
A design goal of Laconica is that the basic Web functionality should
|
||||
work on even the most restrictive commercial hosting services.
|
||||
|
@ -1008,6 +1009,12 @@ avatar
|
|||
|
||||
For configuring avatar access.
|
||||
|
||||
dir: Directory to look for avatar files and to put them into.
|
||||
Defaults to avatar subdirectory of install directory; if
|
||||
you change it, make sure to change path, too.
|
||||
path: Path to avatars. Defaults to path for avatar subdirectory,
|
||||
but you can change it if you wish. Note that this will
|
||||
be included with the avatar server, too.
|
||||
server: If set, defines another server where avatars are stored in the
|
||||
root directory. Note that the 'avatar' subdir still has to be
|
||||
writeable. You'd typically use this to split HTTP requests on
|
||||
|
@ -1033,9 +1040,16 @@ theme
|
|||
-----
|
||||
|
||||
server: Like avatars, you can speed up page loading by pointing the
|
||||
theme file lookup to another server (virtual or real). The
|
||||
theme server's root path should map to the Laconica "theme"
|
||||
subdirectory. Defaults to NULL.
|
||||
theme file lookup to another server (virtual or real).
|
||||
Defaults to NULL, meaning to use the site server.
|
||||
dir: Directory where theme files are stored. Used to determine
|
||||
whether to show parts of a theme file. Defaults to the theme
|
||||
subdirectory of the install directory.
|
||||
path: Path part of theme URLs, before the theme name. Relative to the
|
||||
theme server. It may make sense to change this path when upgrading,
|
||||
(using version numbers as the path) to make sure that all files are
|
||||
reloaded by caching clients or proxies. Defaults to null,
|
||||
which means to use the site path + '/theme'.
|
||||
|
||||
xmpp
|
||||
----
|
||||
|
@ -1100,6 +1114,13 @@ database data in memcached <http://www.danga.com/memcached/>.
|
|||
enabled: Set to true to enable. Default false.
|
||||
server: a string with the hostname of the memcached server. Can also
|
||||
be an array of hostnames, if you've got more than one server.
|
||||
base: memcached uses key-value pairs to store data. We build long,
|
||||
funny-looking keys to make sure we don't have any conflicts. The
|
||||
base of the key is usually a simplified version of the site name
|
||||
(like "Identi.ca" => "identica"), but you can overwrite this if
|
||||
you need to. You can safely ignore it if you only have one
|
||||
Laconica site using your memcached server.
|
||||
port: Port to connect to; defaults to 11211.
|
||||
|
||||
sphinx
|
||||
------
|
||||
|
@ -1196,7 +1217,6 @@ reporturl: URL to post statistics to. Defaults to Laconica developers'
|
|||
set 'run' to 'never' than to set this value to something
|
||||
nonsensical.
|
||||
|
||||
|
||||
attachments
|
||||
-----------
|
||||
|
||||
|
@ -1211,6 +1231,11 @@ supported: an array of mime types you accept to store and distribute,
|
|||
like 'image/gif', 'video/mpeg', 'audio/mpeg', etc. Make sure you
|
||||
setup your server to properly reckognize the types you want to
|
||||
support.
|
||||
uploads: false to disable uploading files with notices (true by default).
|
||||
filecommand: The required MIME_Type library may need to use the 'file'
|
||||
command. It tries the one in the Web server's path, but if
|
||||
you're having problems with uploads, try setting this to the
|
||||
correct value. Note: 'file' must accept '-b' and '-i' options.
|
||||
|
||||
For quotas, be sure you've set the upload_max_filesize and post_max_size
|
||||
in php.ini to be large enough to handle your upload. In httpd.conf
|
||||
|
@ -1226,6 +1251,32 @@ user_quota: total size in bytes a user can store on this server. Each user
|
|||
monthly_quota: total size permitted in the current month. This is the total
|
||||
size in bytes that a user can upload each month.
|
||||
|
||||
group
|
||||
-----
|
||||
|
||||
Options for group functionality.
|
||||
|
||||
maxaliases: maximum number of aliases a group can have. Default 3. Set
|
||||
to 0 or less to prevent aliases in a group.
|
||||
|
||||
oohembed
|
||||
--------
|
||||
|
||||
oEmbed endpoint for multimedia attachments (links in posts).
|
||||
|
||||
endpoint: oohembed endpoint using http://oohembed.com/ software.
|
||||
|
||||
search
|
||||
------
|
||||
|
||||
Some stuff for search.
|
||||
|
||||
type: type of search. Ignored if PostgreSQL or Sphinx are enabled. Can either
|
||||
be 'fulltext' (default) or 'like'. The former is faster and more efficient
|
||||
but requires the lame old MyISAM engine for MySQL. The latter
|
||||
will work with InnoDB but could be miserably slow on large
|
||||
systems. We'll probably add another type sometime in the future,
|
||||
with our own indexing system (maybe like MediaWiki's).
|
||||
|
||||
Troubleshooting
|
||||
===============
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
* @link http://laconi.ca/
|
||||
*
|
||||
* Laconica - a distributed open-source microblogging tool
|
||||
* Copyright (C) 2008, Controlez-Vous, Inc.
|
||||
* Copyright (C) 2008, 2009, Control Yourself, 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
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
/*
|
||||
* Laconica - a distributed open-source microblogging tool
|
||||
* Copyright (C) 2008, Controlez-Vous, Inc.
|
||||
* Copyright (C) 2008, 2009, Control Yourself, 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
|
||||
|
@ -98,7 +98,13 @@ class AllAction extends ProfileAction
|
|||
|
||||
function showContent()
|
||||
{
|
||||
$cur = common_current_user();
|
||||
|
||||
if (!empty($cur) && $cur->id == $this->user->id) {
|
||||
$notice = $this->user->noticeInbox(($this->page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1);
|
||||
} else {
|
||||
$notice = $this->user->noticesWithFriends(($this->page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1);
|
||||
}
|
||||
|
||||
$nl = new NoticeList($notice, $this);
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* @link http://laconi.ca/
|
||||
*
|
||||
* Laconica - a distributed open-source microblogging tool
|
||||
* Copyright (C) 2008, Controlez-Vous, Inc.
|
||||
* Copyright (C) 2008, 2009, Control Yourself, 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
|
||||
|
@ -81,6 +81,14 @@ class AllrssAction extends Rss10Action
|
|||
*/
|
||||
function getNotices($limit=0)
|
||||
{
|
||||
$cur = common_current_user();
|
||||
|
||||
if (!empty($cur) && $cur->id == $user->id) {
|
||||
$notice = $this->user->noticeInbox(0, $limit);
|
||||
} else {
|
||||
$notice = $this->user->noticesWithFriends(0, $limit);
|
||||
}
|
||||
|
||||
$user = $this->user;
|
||||
$notice = $user->noticesWithFriends(0, $limit);
|
||||
$notices = array();
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
/*
|
||||
* Laconica - a distributed open-source microblogging tool
|
||||
* Copyright (C) 2008, Controlez-Vous, Inc.
|
||||
* Copyright (C) 2008, 2009, Control Yourself, 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
|
||||
|
|
|
@ -98,48 +98,6 @@ class AttachmentAction extends Action
|
|||
return $a->title();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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),
|
||||
strtotime($this->profile->modified),
|
||||
($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()
|
||||
{
|
||||
$avtime = ($this->avatar) ?
|
||||
strtotime($this->avatar->modified) : 0;
|
||||
|
||||
return 'W/"' . implode(':', array($this->arg('action'),
|
||||
common_language(),
|
||||
$this->notice->id,
|
||||
strtotime($this->notice->created),
|
||||
strtotime($this->profile->modified),
|
||||
$avtime)) . '"';
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Handle input
|
||||
*
|
||||
|
|
|
@ -74,46 +74,5 @@ class Attachment_ajaxAction extends AttachmentAction
|
|||
}
|
||||
$this->elementEnd('div');
|
||||
}
|
||||
|
||||
/**
|
||||
* 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),
|
||||
strtotime($this->profile->modified),
|
||||
($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()
|
||||
{
|
||||
$avtime = ($this->avatar) ?
|
||||
strtotime($this->avatar->modified) : 0;
|
||||
|
||||
return 'W/"' . implode(':', array($this->arg('action'),
|
||||
common_language(),
|
||||
$this->notice->id,
|
||||
strtotime($this->notice->created),
|
||||
strtotime($this->profile->modified),
|
||||
$avtime)) . '"';
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
* @link http://laconi.ca/
|
||||
*
|
||||
* Laconica - a distributed open-source microblogging tool
|
||||
* Copyright (C) 2008, Controlez-Vous, Inc.
|
||||
* Copyright (C) 2008, 2009, Control Yourself, 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
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
* @link http://laconi.ca/
|
||||
*
|
||||
* Laconica - a distributed open-source microblogging tool
|
||||
* Copyright (C) 2008, Controlez-Vous, Inc.
|
||||
* Copyright (C) 2008, 2009, Control Yourself, 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
|
||||
|
@ -125,16 +125,18 @@ class BlockAction extends Action
|
|||
function areYouSureForm()
|
||||
{
|
||||
$id = $this->profile->id;
|
||||
$this->elementStart('form', array('id' => 'block-' . $id,
|
||||
'method' => 'post',
|
||||
'class' => 'form_settings form_entity_block',
|
||||
'action' => common_local_url('block')));
|
||||
$this->elementStart('fieldset');
|
||||
$this->hidden('token', common_session_token());
|
||||
$this->element('legend', _('Block user'));
|
||||
$this->element('p', null,
|
||||
_('Are you sure you want to block this user? '.
|
||||
'Afterwards, they will be unsubscribed from you, '.
|
||||
'unable to subscribe to you in the future, and '.
|
||||
'you will not be notified of any @-replies from them.'));
|
||||
$this->elementStart('form', array('id' => 'block-' . $id,
|
||||
'method' => 'post',
|
||||
'class' => 'block',
|
||||
'action' => common_local_url('block')));
|
||||
$this->hidden('token', common_session_token());
|
||||
$this->element('input', array('id' => 'blockto-' . $id,
|
||||
'name' => 'blockto',
|
||||
'type' => 'hidden',
|
||||
|
@ -144,8 +146,9 @@ class BlockAction extends Action
|
|||
$this->hidden($k, $v);
|
||||
}
|
||||
}
|
||||
$this->submit('no', _('No'));
|
||||
$this->submit('yes', _('Yes'));
|
||||
$this->submit('form_action-no', _('No'), 'submit form_action-primary', 'no', _("Do not block this user from this group"));
|
||||
$this->submit('form_action-yes', _('Yes'), 'submit form_action-secondary', 'yes', _('Block this user from this group'));
|
||||
$this->elementEnd('fieldset');
|
||||
$this->elementEnd('form');
|
||||
}
|
||||
|
||||
|
@ -180,7 +183,7 @@ class BlockAction extends Action
|
|||
if ($action) {
|
||||
common_redirect(common_local_url($action, $args), 303);
|
||||
} else {
|
||||
common_redirect(common_local_url('subscriptions',
|
||||
common_redirect(common_local_url('subscribers',
|
||||
array('nickname' => $cur->nickname)),
|
||||
303);
|
||||
}
|
||||
|
|
315
actions/blockedfromgroup.php
Normal file
315
actions/blockedfromgroup.php
Normal file
|
@ -0,0 +1,315 @@
|
|||
<?php
|
||||
/**
|
||||
* Laconica, the distributed open-source microblogging tool
|
||||
*
|
||||
* List of group members
|
||||
*
|
||||
* 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 Group
|
||||
* @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);
|
||||
}
|
||||
|
||||
/**
|
||||
* List of profiles blocked from this group
|
||||
*
|
||||
* @category Group
|
||||
* @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 BlockedfromgroupAction extends GroupDesignAction
|
||||
{
|
||||
var $page = null;
|
||||
|
||||
function isReadOnly($args)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
function prepare($args)
|
||||
{
|
||||
parent::prepare($args);
|
||||
$this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
|
||||
|
||||
$nickname_arg = $this->arg('nickname');
|
||||
$nickname = common_canonical_nickname($nickname_arg);
|
||||
|
||||
// Permanent redirect on non-canonical nickname
|
||||
|
||||
if ($nickname_arg != $nickname) {
|
||||
$args = array('nickname' => $nickname);
|
||||
if ($this->page != 1) {
|
||||
$args['page'] = $this->page;
|
||||
}
|
||||
common_redirect(common_local_url('blockedfromgroup', $args), 301);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$nickname) {
|
||||
$this->clientError(_('No nickname'), 404);
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->group = User_group::staticGet('nickname', $nickname);
|
||||
|
||||
if (!$this->group) {
|
||||
$this->clientError(_('No such group'), 404);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function title()
|
||||
{
|
||||
if ($this->page == 1) {
|
||||
return sprintf(_('%s blocked profiles'),
|
||||
$this->group->nickname);
|
||||
} else {
|
||||
return sprintf(_('%s blocked profiles, page %d'),
|
||||
$this->group->nickname,
|
||||
$this->page);
|
||||
}
|
||||
}
|
||||
|
||||
function handle($args)
|
||||
{
|
||||
parent::handle($args);
|
||||
$this->showPage();
|
||||
}
|
||||
|
||||
function showPageNotice()
|
||||
{
|
||||
$this->element('p', 'instructions',
|
||||
_('A list of the users blocked from joining this group.'));
|
||||
}
|
||||
|
||||
function showLocalNav()
|
||||
{
|
||||
$nav = new GroupNav($this, $this->group);
|
||||
$nav->show();
|
||||
}
|
||||
|
||||
function showContent()
|
||||
{
|
||||
$offset = ($this->page-1) * PROFILES_PER_PAGE;
|
||||
$limit = PROFILES_PER_PAGE + 1;
|
||||
|
||||
$cnt = 0;
|
||||
|
||||
$blocked = $this->group->getBlocked($offset, $limit);
|
||||
|
||||
if ($blocked) {
|
||||
$blocked_list = new GroupBlockList($blocked, $this->group, $this);
|
||||
$cnt = $blocked_list->show();
|
||||
}
|
||||
|
||||
$blocked->free();
|
||||
|
||||
$this->pagination($this->page > 1, $cnt > PROFILES_PER_PAGE,
|
||||
$this->page, 'blockedfromgroup',
|
||||
array('nickname' => $this->group->nickname));
|
||||
}
|
||||
}
|
||||
|
||||
class GroupBlockList extends ProfileList
|
||||
{
|
||||
var $group = null;
|
||||
|
||||
function __construct($profile, $group, $action)
|
||||
{
|
||||
parent::__construct($profile, $action);
|
||||
|
||||
$this->group = $group;
|
||||
}
|
||||
|
||||
function newListItem($profile)
|
||||
{
|
||||
return new GroupBlockListItem($profile, $this->group, $this->action);
|
||||
}
|
||||
}
|
||||
|
||||
class GroupBlockListItem extends ProfileListItem
|
||||
{
|
||||
var $group = null;
|
||||
|
||||
function __construct($profile, $group, $action)
|
||||
{
|
||||
parent::__construct($profile, $action);
|
||||
|
||||
$this->group = $group;
|
||||
}
|
||||
|
||||
function showActions()
|
||||
{
|
||||
$this->startActions();
|
||||
$this->showGroupUnblockForm();
|
||||
$this->endActions();
|
||||
}
|
||||
|
||||
function showGroupUnblockForm()
|
||||
{
|
||||
$user = common_current_user();
|
||||
|
||||
if (!empty($user) && $user->id != $this->profile->id && $user->isAdmin($this->group)) {
|
||||
$this->out->elementStart('li', 'entity_block');
|
||||
$bf = new GroupUnblockForm($this->out, $this->profile, $this->group,
|
||||
array('action' => 'blockedfromgroup',
|
||||
'nickname' => $this->group->nickname));
|
||||
$bf->show();
|
||||
$this->out->elementEnd('li');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Form for unblocking a user from a group
|
||||
*
|
||||
* @category Form
|
||||
* @package Laconica
|
||||
* @author Evan Prodromou <evan@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/
|
||||
*
|
||||
* @see UnblockForm
|
||||
*/
|
||||
|
||||
class GroupUnblockForm extends Form
|
||||
{
|
||||
/**
|
||||
* Profile of user to block
|
||||
*/
|
||||
|
||||
var $profile = null;
|
||||
|
||||
/**
|
||||
* Group to block the user from
|
||||
*/
|
||||
|
||||
var $group = null;
|
||||
|
||||
/**
|
||||
* Return-to args
|
||||
*/
|
||||
|
||||
var $args = null;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param HTMLOutputter $out output channel
|
||||
* @param Profile $profile profile of user to block
|
||||
* @param User_group $group group to block user from
|
||||
* @param array $args return-to args
|
||||
*/
|
||||
|
||||
function __construct($out=null, $profile=null, $group=null, $args=null)
|
||||
{
|
||||
parent::__construct($out);
|
||||
|
||||
$this->profile = $profile;
|
||||
$this->group = $group;
|
||||
$this->args = $args;
|
||||
}
|
||||
|
||||
/**
|
||||
* ID of the form
|
||||
*
|
||||
* @return int ID of the form
|
||||
*/
|
||||
|
||||
function id()
|
||||
{
|
||||
// This should be unique for the page.
|
||||
return 'unblock-' . $this->profile->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* class of the form
|
||||
*
|
||||
* @return string class of the form
|
||||
*/
|
||||
|
||||
function formClass()
|
||||
{
|
||||
return 'form_group_unblock';
|
||||
}
|
||||
|
||||
/**
|
||||
* Action of the form
|
||||
*
|
||||
* @return string URL of the action
|
||||
*/
|
||||
|
||||
function action()
|
||||
{
|
||||
return common_local_url('groupunblock');
|
||||
}
|
||||
|
||||
/**
|
||||
* Legend of the Form
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function formLegend()
|
||||
{
|
||||
$this->out->element('legend', null, _('Unblock user from group'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Data elements of the form
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function formData()
|
||||
{
|
||||
$this->out->hidden('unblockto-' . $this->profile->id,
|
||||
$this->profile->id,
|
||||
'unblockto');
|
||||
$this->out->hidden('unblockgroup-' . $this->group->id,
|
||||
$this->group->id,
|
||||
'unblockgroup');
|
||||
if ($this->args) {
|
||||
foreach ($this->args as $k => $v) {
|
||||
$this->out->hidden('returnto-' . $k, $v);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Action elements
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function formActions()
|
||||
{
|
||||
$this->out->submit('submit', _('Unblock'), 'submit', null, _('Unblock this user'));
|
||||
}
|
||||
}
|
|
@ -217,6 +217,8 @@ class ConversationTree extends NoticeList
|
|||
|
||||
$this->out->elementStart('ol', array('class' => 'notices'));
|
||||
|
||||
sort($children);
|
||||
|
||||
foreach ($children as $child) {
|
||||
$this->showNoticePlus($child);
|
||||
}
|
||||
|
|
|
@ -1,264 +0,0 @@
|
|||
<?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 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);
|
||||
}
|
||||
|
||||
require_once INSTALLDIR.'/lib/accountsettingsaction.php';
|
||||
|
||||
|
||||
|
||||
class DesignsettingsAction extends AccountSettingsAction
|
||||
{
|
||||
/**
|
||||
* Title of the page
|
||||
*
|
||||
* @return string Title of the page
|
||||
*/
|
||||
|
||||
function title()
|
||||
{
|
||||
return _('Profile design');
|
||||
}
|
||||
|
||||
/**
|
||||
* Instructions for use
|
||||
*
|
||||
* @return instructions for use
|
||||
*/
|
||||
|
||||
function getInstructions()
|
||||
{
|
||||
return _('Customize the way your profile looks with a background image and a colour palette of your choice.');
|
||||
}
|
||||
|
||||
/**
|
||||
* 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' => 'form_settings_design',
|
||||
'class' => 'form_settings',
|
||||
'action' =>
|
||||
common_local_url('designsettings')));
|
||||
$this->elementStart('fieldset');
|
||||
$this->hidden('token', common_session_token());
|
||||
|
||||
$this->elementStart('fieldset', array('id' => 'settings_design_background-image'));
|
||||
$this->element('legend', null, _('Change background image'));
|
||||
$this->elementStart('ul', 'form_data');
|
||||
$this->elementStart('li');
|
||||
$this->element('label', array('for' => 'design_background-image_file'),
|
||||
_('Upload file'));
|
||||
$this->element('input', array('name' => 'design_background-image_file',
|
||||
'type' => 'file',
|
||||
'id' => 'design_background-image_file'));
|
||||
$this->element('p', 'form_guide', _('You can upload your personal background image. The maximum file size is 2Mb.'));
|
||||
$this->element('input', array('name' => 'MAX_FILE_SIZE',
|
||||
'type' => 'hidden',
|
||||
'id' => 'MAX_FILE_SIZE',
|
||||
'value' => ImageFile::maxFileSizeInt()));
|
||||
$this->elementEnd('li');
|
||||
$this->elementEnd('ul');
|
||||
$this->elementEnd('fieldset');
|
||||
|
||||
$this->elementStart('fieldset', array('id' => 'settings_design_color'));
|
||||
$this->element('legend', null, _('Change colours'));
|
||||
$this->elementStart('ul', 'form_data');
|
||||
|
||||
//This is a JSON object in the DB field. Here for testing. Remove later.
|
||||
$userSwatch = '{"body":{"background-color":"#F0F2F5"},
|
||||
"#content":{"background-color":"#FFFFFF"},
|
||||
"#aside_primary":{"background-color":"#CEE1E9"},
|
||||
"html body":{"color":"#000000"},
|
||||
"a":{"color":"#002E6E"}}';
|
||||
|
||||
//Default theme swatch -- Where should this be stored?
|
||||
$defaultSwatch = array('body' => array('background-color' => '#F0F2F5'),
|
||||
'#content' => array('background-color' => '#FFFFFF'),
|
||||
'#aside_primary' => array('background-color' => '#CEE1E9'),
|
||||
'html body' => array('color' => '#000000'),
|
||||
'a' => array('color' => '#002E6E'));
|
||||
|
||||
$userSwatch = ($userSwatch) ? json_decode($userSwatch, true) : $defaultSwatch;
|
||||
|
||||
$s = 0;
|
||||
$labelSwatch = array('Background',
|
||||
'Content',
|
||||
'Sidebar',
|
||||
'Text',
|
||||
'Links');
|
||||
foreach($userSwatch as $propertyvalue => $value) {
|
||||
$foo = array_values($value);
|
||||
$this->elementStart('li');
|
||||
$this->element('label', array('for' => 'swatch-'.$s), _($labelSwatch[$s]));
|
||||
$this->element('input', array('name' => 'swatch-'.$s, //prefer swatch[$s] ?
|
||||
'type' => 'text',
|
||||
'id' => 'swatch-'.$s,
|
||||
'class' => 'swatch',
|
||||
'maxlength' => '7',
|
||||
'size' => '7',
|
||||
'value' => $foo[0]));
|
||||
$this->elementEnd('li');
|
||||
$s++;
|
||||
}
|
||||
|
||||
$this->elementEnd('ul');
|
||||
$this->elementEnd('fieldset');
|
||||
|
||||
$this->element('input', array('id' => 'settings_design_reset',
|
||||
'type' => 'reset',
|
||||
'value' => 'Reset',
|
||||
'class' => 'submit form_action-primary',
|
||||
'title' => _('Reset back to default')));
|
||||
$this->submit('save', _('Save'), 'submit form_action-secondary', 'save', _('Save design'));
|
||||
|
||||
/*TODO: Check submitted form values:
|
||||
json_encode(form values)
|
||||
if submitted Swatch == DefaultSwatch, don't store in DB.
|
||||
else store in BD
|
||||
*/
|
||||
$this->elementEnd('fieldset');
|
||||
$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');
|
||||
|
||||
# Some validation
|
||||
|
||||
if (strlen($newpassword) < 6) {
|
||||
$this->showForm(_('Password must be 6 or more characters.'));
|
||||
return;
|
||||
} else 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);
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add the Farbtastic stylesheet
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function showStylesheets()
|
||||
{
|
||||
parent::showStylesheets();
|
||||
$farbtasticStyle =
|
||||
common_path('theme/base/css/farbtastic.css?version='.LACONICA_VERSION);
|
||||
|
||||
$this->element('link', array('rel' => 'stylesheet',
|
||||
'type' => 'text/css',
|
||||
'href' => $farbtasticStyle,
|
||||
'media' => 'screen, projection, tv'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the Farbtastic scripts
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function showScripts()
|
||||
{
|
||||
parent::showScripts();
|
||||
|
||||
$farbtasticPack = common_path('js/farbtastic/farbtastic.js');
|
||||
$farbtasticGo = common_path('js/farbtastic/farbtastic.go.js');
|
||||
|
||||
$this->element('script', array('type' => 'text/javascript',
|
||||
'src' => $farbtasticPack));
|
||||
$this->element('script', array('type' => 'text/javascript',
|
||||
'src' => $farbtasticGo));
|
||||
}
|
||||
}
|
|
@ -13,7 +13,7 @@
|
|||
* @link http://laconi.ca/
|
||||
*
|
||||
* Laconica - a distributed open-source microblogging tool
|
||||
* Copyright (C) 2008, Controlez-Vous, Inc.
|
||||
* Copyright (C) 2008, 2009, Control Yourself, 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
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* @link http://laconi.ca/
|
||||
*
|
||||
* Laconica - a distributed open-source microblogging tool
|
||||
* Copyright (C) 2008, Controlez-Vous, Inc.
|
||||
* Copyright (C) 2008, 2009, Control Yourself, 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
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
* @package Laconica
|
||||
* @author Evan Prodromou <evan@controlyourself.ca>
|
||||
* @author Sarven Capadisli <csarven@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/
|
||||
|
@ -40,14 +41,15 @@ if (!defined('LACONICA')) {
|
|||
* @category Group
|
||||
* @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 EditgroupAction extends Action
|
||||
class EditgroupAction extends GroupDesignAction
|
||||
{
|
||||
|
||||
var $msg;
|
||||
var $group = null;
|
||||
|
||||
function title()
|
||||
{
|
||||
|
@ -171,6 +173,7 @@ class EditgroupAction extends Action
|
|||
$homepage = $this->trimmed('homepage');
|
||||
$description = $this->trimmed('description');
|
||||
$location = $this->trimmed('location');
|
||||
$aliasstring = $this->trimmed('aliases');
|
||||
|
||||
if (!Validate::string($nickname, array('min_length' => 1,
|
||||
'max_length' => 64,
|
||||
|
@ -201,6 +204,39 @@ class EditgroupAction extends Action
|
|||
return;
|
||||
}
|
||||
|
||||
if (!empty($aliasstring)) {
|
||||
$aliases = array_map('common_canonical_nickname', array_unique(preg_split('/[\s,]+/', $aliasstring)));
|
||||
} else {
|
||||
$aliases = array();
|
||||
}
|
||||
|
||||
if (count($aliases) > common_config('group', 'maxaliases')) {
|
||||
$this->showForm(sprintf(_('Too many aliases! Maximum %d.'),
|
||||
common_config('group', 'maxaliases')));
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($aliases as $alias) {
|
||||
if (!Validate::string($alias, array('min_length' => 1,
|
||||
'max_length' => 64,
|
||||
'format' => NICKNAME_FMT))) {
|
||||
$this->showForm(sprintf(_('Invalid alias: "%s"'), $alias));
|
||||
return;
|
||||
}
|
||||
if ($this->nicknameExists($alias)) {
|
||||
$this->showForm(sprintf(_('Alias "%s" already in use. Try another one.'),
|
||||
$alias));
|
||||
return;
|
||||
}
|
||||
// XXX assumes alphanum nicknames
|
||||
if (strcmp($alias, $nickname) == 0) {
|
||||
$this->showForm(_('Alias can\'t be the same as nickname.'));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$this->group->query('BEGIN');
|
||||
|
||||
$orig = clone($this->group);
|
||||
|
||||
$this->group->nickname = $nickname;
|
||||
|
@ -217,6 +253,14 @@ class EditgroupAction extends Action
|
|||
$this->serverError(_('Could not update group.'));
|
||||
}
|
||||
|
||||
$result = $this->group->setAliases($aliases);
|
||||
|
||||
if (!$result) {
|
||||
$this->serverError(_('Could not create aliases.'));
|
||||
}
|
||||
|
||||
$this->group->query('COMMIT');
|
||||
|
||||
if ($this->group->nickname != $orig->nickname) {
|
||||
common_redirect(common_local_url('editgroup',
|
||||
array('nickname' => $nickname)),
|
||||
|
@ -229,9 +273,20 @@ class EditgroupAction extends Action
|
|||
function nicknameExists($nickname)
|
||||
{
|
||||
$group = User_group::staticGet('nickname', $nickname);
|
||||
return (!is_null($group) &&
|
||||
$group != false &&
|
||||
$group->id != $this->group->id);
|
||||
|
||||
if (!empty($group) &&
|
||||
$group->id != $this->group->id) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$alias = Group_alias::staticGet('alias', $nickname);
|
||||
|
||||
if (!empty($alias) &&
|
||||
$alias->group_id != $this->group->id) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
/*
|
||||
* Laconica - a distributed open-source microblogging tool
|
||||
* Copyright (C) 2008, Controlez-Vous, Inc.
|
||||
* Copyright (C) 2008, 2009, Control Yourself, 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
|
||||
|
@ -21,7 +21,6 @@ if (!defined('LACONICA')) { exit(1); }
|
|||
|
||||
require_once INSTALLDIR.'/lib/facebookaction.php';
|
||||
|
||||
|
||||
class FacebookhomeAction extends FacebookAction
|
||||
{
|
||||
|
||||
|
@ -142,7 +141,6 @@ class FacebookhomeAction extends FacebookAction
|
|||
FACEBOOK_PROMPTED_UPDATE_PREF, 'false');
|
||||
}
|
||||
|
||||
|
||||
function showNoticeForm()
|
||||
{
|
||||
$post_action = "$this->app_uri/index.php";
|
||||
|
@ -163,8 +161,7 @@ class FacebookhomeAction extends FacebookAction
|
|||
|
||||
function showContent()
|
||||
{
|
||||
$notice = $this->user->noticesWithFriends(($this->page-1) *
|
||||
NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1);
|
||||
$notice = $this->user->noticeInbox(($this->page-1) * NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1);
|
||||
|
||||
$nl = new NoticeList($notice, $this);
|
||||
|
||||
|
@ -275,5 +272,4 @@ class FacebookhomeAction extends FacebookAction
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
/*
|
||||
* Laconica - a distributed open-source microblogging tool
|
||||
* Copyright (C) 2008, Controlez-Vous, Inc.
|
||||
* Copyright (C) 2008, 2009, Control Yourself, 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
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
/*
|
||||
* Laconica - a distributed open-source microblogging tool
|
||||
* Copyright (C) 2008, Controlez-Vous, Inc.
|
||||
* Copyright (C) 2008, 2009, Control Yourself, 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
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
/*
|
||||
* Laconica - a distributed open-source microblogging tool
|
||||
* Copyright (C) 2008, Controlez-Vous, Inc.
|
||||
* Copyright (C) 2008, 2009, Control Yourself, 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
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
/*
|
||||
* Laconica - a distributed open-source microblogging tool
|
||||
* Copyright (C) 2008, Controlez-Vous, Inc.
|
||||
* Copyright (C) 2008, 2009, Control Yourself, 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
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
/*
|
||||
* Laconica - a distributed open-source microblogging tool
|
||||
* Copyright (C) 2008, Controlez-Vous, Inc.
|
||||
* Copyright (C) 2008, 2009, Control Yourself, 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
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* @link http://laconi.ca/
|
||||
*
|
||||
* Laconica - a distributed open-source microblogging tool
|
||||
* Copyright (C) 2008, Controlez-Vous, Inc.
|
||||
* Copyright (C) 2008, 2009, Control Yourself, 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
|
||||
|
|
|
@ -32,7 +32,7 @@ if (!defined('LACONICA')) {
|
|||
exit(1);
|
||||
}
|
||||
|
||||
require_once(INSTALLDIR.'/lib/profilelist.php');
|
||||
require_once INSTALLDIR.'/lib/profilelist.php';
|
||||
require_once INSTALLDIR.'/lib/publicgroupnav.php';
|
||||
|
||||
/**
|
||||
|
@ -107,7 +107,6 @@ class FeaturedAction extends Action
|
|||
|
||||
$featured_nicks = common_config('nickname', 'featured');
|
||||
|
||||
|
||||
if (count($featured_nicks) > 0) {
|
||||
|
||||
$quoted = array();
|
||||
|
@ -136,7 +135,7 @@ class FeaturedAction extends Action
|
|||
$cnt = $profile->find();
|
||||
|
||||
if ($cnt > 0) {
|
||||
$featured = new ProfileList($profile, null, $this);
|
||||
$featured = new ProfileList($profile, $this);
|
||||
$featured->show();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
/*
|
||||
* Laconica - a distributed open-source microblogging tool
|
||||
* Copyright (C) 2008, Controlez-Vous, Inc.
|
||||
* Copyright (C) 2008, 2009, Control Yourself, 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
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
/*
|
||||
* Laconica - a distributed open-source microblogging tool
|
||||
* Copyright (C) 2008, Controlez-Vous, Inc.
|
||||
* Copyright (C) 2008, 2009, Control Yourself, 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
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
/*
|
||||
* Laconica - a distributed open-source microblogging tool
|
||||
* Copyright (C) 2008, Controlez-Vous, Inc.
|
||||
* Copyright (C) 2008, 2009, Control Yourself, 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
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
/*
|
||||
* Laconica - a distributed open-source microblogging tool
|
||||
* Copyright (C) 2008, Controlez-Vous, Inc.
|
||||
* Copyright (C) 2008, 2009, Control Yourself, 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
|
||||
|
|
215
actions/groupblock.php
Normal file
215
actions/groupblock.php
Normal file
|
@ -0,0 +1,215 @@
|
|||
<?php
|
||||
/**
|
||||
* Block a user from a group action class.
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category Action
|
||||
* @package Laconica
|
||||
* @author Evan Prodromou <evan@controlyourself.ca>
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
|
||||
* @link http://laconi.ca/
|
||||
*
|
||||
* Laconica - a distributed open-source microblogging tool
|
||||
* Copyright (C) 2008, 2009, Control Yourself, 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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Block a user from a group
|
||||
*
|
||||
* @category Action
|
||||
* @package Laconica
|
||||
* @author Evan Prodromou <evan@controlyourself.ca>
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
|
||||
* @link http://laconi.ca/
|
||||
*/
|
||||
|
||||
class GroupblockAction extends Action
|
||||
{
|
||||
var $profile = null;
|
||||
var $group = null;
|
||||
|
||||
/**
|
||||
* Take arguments for running
|
||||
*
|
||||
* @param array $args $_REQUEST args
|
||||
*
|
||||
* @return boolean success flag
|
||||
*/
|
||||
|
||||
function prepare($args)
|
||||
{
|
||||
parent::prepare($args);
|
||||
if (!common_logged_in()) {
|
||||
$this->clientError(_('Not logged in.'));
|
||||
return false;
|
||||
}
|
||||
$token = $this->trimmed('token');
|
||||
if (empty($token) || $token != common_session_token()) {
|
||||
$this->clientError(_('There was a problem with your session token. Try again, please.'));
|
||||
return;
|
||||
}
|
||||
$id = $this->trimmed('blockto');
|
||||
if (empty($id)) {
|
||||
$this->clientError(_('No profile specified.'));
|
||||
return false;
|
||||
}
|
||||
$this->profile = Profile::staticGet('id', $id);
|
||||
if (empty($this->profile)) {
|
||||
$this->clientError(_('No profile with that ID.'));
|
||||
return false;
|
||||
}
|
||||
$group_id = $this->trimmed('blockgroup');
|
||||
if (empty($group_id)) {
|
||||
$this->clientError(_('No group specified.'));
|
||||
return false;
|
||||
}
|
||||
$this->group = User_group::staticGet('id', $group_id);
|
||||
if (empty($this->group)) {
|
||||
$this->clientError(_('No such group.'));
|
||||
return false;
|
||||
}
|
||||
$user = common_current_user();
|
||||
if (!$user->isAdmin($this->group)) {
|
||||
$this->clientError(_('Only an admin can block group members.'), 401);
|
||||
return false;
|
||||
}
|
||||
if (Group_block::isBlocked($this->group, $this->profile)) {
|
||||
$this->clientError(_('User is already blocked from group.'));
|
||||
return false;
|
||||
}
|
||||
// XXX: could have proactive blocks, but we don't have UI for it.
|
||||
if (!$this->profile->isMember($this->group)) {
|
||||
$this->clientError(_('User is not a member of group.'));
|
||||
return false;
|
||||
}
|
||||
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)
|
||||
{
|
||||
parent::handle($args);
|
||||
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||
if ($this->arg('no')) {
|
||||
common_redirect(common_local_url('groupmembers',
|
||||
array('nickname' => $this->group->nickname)),
|
||||
303);
|
||||
} elseif ($this->arg('yes')) {
|
||||
$this->blockProfile();
|
||||
} elseif ($this->arg('blockto')) {
|
||||
$this->showPage();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function showContent() {
|
||||
$this->areYouSureForm();
|
||||
}
|
||||
|
||||
function title() {
|
||||
return _('Block user from group');
|
||||
}
|
||||
|
||||
function showNoticeForm() {
|
||||
// nop
|
||||
}
|
||||
|
||||
/**
|
||||
* Confirm with user.
|
||||
*
|
||||
* Shows a confirmation form.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function areYouSureForm()
|
||||
{
|
||||
$id = $this->profile->id;
|
||||
$this->element('p', null,
|
||||
sprintf(_('Are you sure you want to block user "%s" from the group "%s"? '.
|
||||
'They will be removed from the group, unable to post, and '.
|
||||
'unable to subscribe to the group in the future.'),
|
||||
$this->profile->getBestName(),
|
||||
$this->group->getBestName()));
|
||||
$this->elementStart('form', array('id' => 'block-' . $id,
|
||||
'method' => 'post',
|
||||
'class' => 'block',
|
||||
'action' => common_local_url('groupblock')));
|
||||
$this->hidden('token', common_session_token());
|
||||
$this->hidden('blockto-' . $this->profile->id,
|
||||
$this->profile->id,
|
||||
'blockto');
|
||||
$this->hidden('blockgroup-' . $this->group->id,
|
||||
$this->group->id,
|
||||
'blockgroup');
|
||||
foreach ($this->args as $k => $v) {
|
||||
if (substr($k, 0, 9) == 'returnto-') {
|
||||
$this->hidden($k, $v);
|
||||
}
|
||||
}
|
||||
$this->submit('no', _('No'));
|
||||
$this->submit('yes', _('Yes'));
|
||||
$this->elementEnd('form');
|
||||
}
|
||||
|
||||
/**
|
||||
* Actually block a user.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function blockProfile()
|
||||
{
|
||||
$block = Group_block::blockProfile($this->group, $this->profile,
|
||||
common_current_user());
|
||||
|
||||
if (empty($block)) {
|
||||
$this->serverError(_("Database error blocking user from group."));
|
||||
return false;
|
||||
}
|
||||
|
||||
// Now, gotta figure where we go back to
|
||||
foreach ($this->args as $k => $v) {
|
||||
if ($k == 'returnto-action') {
|
||||
$action = $v;
|
||||
} elseif (substr($k, 0, 9) == 'returnto-') {
|
||||
$args[substr($k, 9)] = $v;
|
||||
}
|
||||
}
|
||||
|
||||
if ($action) {
|
||||
common_redirect(common_local_url($action, $args), 303);
|
||||
} else {
|
||||
common_redirect(common_local_url('groupmembers',
|
||||
array('nickname' => $this->group->nickname)),
|
||||
303);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
330
actions/groupdesignsettings.php
Normal file
330
actions/groupdesignsettings.php
Normal file
|
@ -0,0 +1,330 @@
|
|||
<?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 Sarven Capadisli <csarven@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/designsettings.php';
|
||||
|
||||
class GroupDesignSettingsAction extends DesignSettingsAction
|
||||
{
|
||||
var $group = null;
|
||||
|
||||
/**
|
||||
* Prepare to run
|
||||
*/
|
||||
|
||||
function prepare($args)
|
||||
{
|
||||
parent::prepare($args);
|
||||
|
||||
if (!common_config('inboxes','enabled')) {
|
||||
$this->serverError(_('Inboxes must be enabled for groups to work'));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!common_logged_in()) {
|
||||
$this->clientError(_('You must be logged in to edit a group.'));
|
||||
return false;
|
||||
}
|
||||
|
||||
$nickname_arg = $this->trimmed('nickname');
|
||||
$nickname = common_canonical_nickname($nickname_arg);
|
||||
|
||||
// Permanent redirect on non-canonical nickname
|
||||
|
||||
if ($nickname_arg != $nickname) {
|
||||
$args = array('nickname' => $nickname);
|
||||
common_redirect(common_local_url('groupdesignsettings', $args), 301);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$nickname) {
|
||||
$this->clientError(_('No nickname'), 404);
|
||||
return false;
|
||||
}
|
||||
|
||||
$groupid = $this->trimmed('groupid');
|
||||
|
||||
if ($groupid) {
|
||||
$this->group = User_group::staticGet('id', $groupid);
|
||||
} else {
|
||||
$this->group = User_group::staticGet('nickname', $nickname);
|
||||
}
|
||||
|
||||
if (!$this->group) {
|
||||
$this->clientError(_('No such group'), 404);
|
||||
return false;
|
||||
}
|
||||
|
||||
$cur = common_current_user();
|
||||
|
||||
if (!$cur->isAdmin($this->group)) {
|
||||
$this->clientError(_('You must be an admin to edit the group'), 403);
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->submitaction = common_local_url('groupdesignsettings',
|
||||
array('nickname' => $this->group->nickname));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* A design for this action
|
||||
*
|
||||
* if the group attribute has been set, returns that group's
|
||||
* design.
|
||||
*
|
||||
* @return Design a design object to use
|
||||
*/
|
||||
|
||||
function getDesign()
|
||||
{
|
||||
|
||||
if (empty($this->group)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $this->group->getDesign();
|
||||
}
|
||||
|
||||
/**
|
||||
* Title of the page
|
||||
*
|
||||
* @return string Title of the page
|
||||
*/
|
||||
|
||||
function title()
|
||||
{
|
||||
return _('Group design');
|
||||
}
|
||||
|
||||
/**
|
||||
* Instructions for use
|
||||
*
|
||||
* @return instructions for use
|
||||
*/
|
||||
|
||||
function getInstructions()
|
||||
{
|
||||
return _('Customize the way your group looks ' .
|
||||
'with a background image and a colour palette of your choice.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Override to show group nav stuff
|
||||
*
|
||||
* @return nothing
|
||||
*/
|
||||
|
||||
function showLocalNav()
|
||||
{
|
||||
$nav = new GroupNav($this, $this->group);
|
||||
$nav->show();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the design we want to edit
|
||||
*
|
||||
* @return Design
|
||||
*/
|
||||
|
||||
function getWorkingDesign() {
|
||||
|
||||
$design = null;
|
||||
|
||||
if (isset($this->group)) {
|
||||
$design = $this->group->getDesign();
|
||||
}
|
||||
|
||||
if (empty($design)) {
|
||||
$design = $this->defaultDesign();
|
||||
}
|
||||
|
||||
return $design;
|
||||
}
|
||||
|
||||
/**
|
||||
* Content area of the page
|
||||
*
|
||||
* Shows a form for changing the design
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function showContent()
|
||||
{
|
||||
$this->showDesignForm($this->getWorkingDesign());
|
||||
}
|
||||
|
||||
/**
|
||||
* Save or update the group's design settings
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function saveDesign()
|
||||
{
|
||||
try {
|
||||
|
||||
$bgcolor = new WebColor($this->trimmed('design_background'));
|
||||
$ccolor = new WebColor($this->trimmed('design_content'));
|
||||
$sbcolor = new WebColor($this->trimmed('design_sidebar'));
|
||||
$tcolor = new WebColor($this->trimmed('design_text'));
|
||||
$lcolor = new WebColor($this->trimmed('design_links'));
|
||||
|
||||
} catch (WebColorException $e) {
|
||||
$this->showForm($e->getMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
$onoff = $this->arg('design_background-image_onoff');
|
||||
|
||||
$on = false;
|
||||
$off = false;
|
||||
$tile = false;
|
||||
|
||||
if ($onoff == 'on') {
|
||||
$on = true;
|
||||
} else {
|
||||
$off = true;
|
||||
}
|
||||
|
||||
$repeat = $this->boolean('design_background-image_repeat');
|
||||
|
||||
if ($repeat) {
|
||||
$tile = true;
|
||||
}
|
||||
|
||||
$design = $this->group->getDesign();
|
||||
|
||||
if (!empty($design)) {
|
||||
|
||||
// update design
|
||||
|
||||
$original = clone($design);
|
||||
|
||||
$design->backgroundcolor = $bgcolor->intValue();
|
||||
$design->contentcolor = $ccolor->intValue();
|
||||
$design->sidebarcolor = $sbcolor->intValue();
|
||||
$design->textcolor = $tcolor->intValue();
|
||||
$design->linkcolor = $lcolor->intValue();
|
||||
$design->backgroundimage = $filepath;
|
||||
|
||||
$design->setDisposition($on, $off, $tile);
|
||||
|
||||
$result = $design->update($original);
|
||||
|
||||
if ($result === false) {
|
||||
common_log_db_error($design, 'UPDATE', __FILE__);
|
||||
$this->showForm(_('Couldn\'t update your design.'));
|
||||
return;
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
$this->group->query('BEGIN');
|
||||
|
||||
// save new design
|
||||
|
||||
$design = new Design();
|
||||
|
||||
$design->backgroundcolor = $bgcolor->intValue();
|
||||
$design->contentcolor = $ccolor->intValue();
|
||||
$design->sidebarcolor = $sbcolor->intValue();
|
||||
$design->textcolor = $tcolor->intValue();
|
||||
$design->linkcolor = $lcolor->intValue();
|
||||
$design->backgroundimage = $filepath;
|
||||
|
||||
$design->setDisposition($on, $off, $tile);
|
||||
|
||||
$id = $design->insert();
|
||||
|
||||
if (empty($id)) {
|
||||
common_log_db_error($id, 'INSERT', __FILE__);
|
||||
$this->showForm(_('Unable to save your design settings!'));
|
||||
return;
|
||||
}
|
||||
|
||||
$original = clone($this->group);
|
||||
$this->group->design_id = $id;
|
||||
$result = $this->group->update($original);
|
||||
|
||||
if (empty($result)) {
|
||||
common_log_db_error($original, 'UPDATE', __FILE__);
|
||||
$this->showForm(_('Unable to save your design settings!'));
|
||||
$this->group->query('ROLLBACK');
|
||||
return;
|
||||
}
|
||||
|
||||
$this->group->query('COMMIT');
|
||||
|
||||
}
|
||||
|
||||
$this->saveBackgroundImage($design);
|
||||
|
||||
$this->showForm(_('Design preferences saved.'), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle input and output a page (overrided)
|
||||
*
|
||||
* @param array $args $_REQUEST arguments
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function handle($args)
|
||||
{
|
||||
parent::handle($args);
|
||||
if (!common_logged_in()) {
|
||||
$this->clientError(_('Not logged in.'));
|
||||
return;
|
||||
} else if (!common_is_real_login()) {
|
||||
// Cookie theft means that automatic logins can't
|
||||
// change important settings or see private info, and
|
||||
// _all_ our settings are important
|
||||
common_set_returnto($this->selfUrl());
|
||||
$user = common_current_user();
|
||||
if ($user->hasOpenID()) {
|
||||
common_redirect(common_local_url('openidlogin'), 303);
|
||||
} else {
|
||||
common_redirect(common_local_url('login'), 303);
|
||||
}
|
||||
} else if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||
$this->handlePost();
|
||||
} else {
|
||||
$this->showForm();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -50,7 +50,7 @@ define('MAX_ORIGINAL', 480);
|
|||
* @link http://laconi.ca/
|
||||
*/
|
||||
|
||||
class GrouplogoAction extends Action
|
||||
class GrouplogoAction extends GroupDesignAction
|
||||
{
|
||||
var $mode = null;
|
||||
var $imagefile = null;
|
||||
|
|
|
@ -44,7 +44,7 @@ require_once INSTALLDIR.'/lib/publicgroupnav.php';
|
|||
* @link http://laconi.ca/
|
||||
*/
|
||||
|
||||
class GroupmembersAction extends Action
|
||||
class GroupmembersAction extends GroupDesignAction
|
||||
{
|
||||
var $page = null;
|
||||
|
||||
|
@ -127,7 +127,7 @@ class GroupmembersAction extends Action
|
|||
$members = $this->group->getMembers($offset, $limit);
|
||||
|
||||
if ($members) {
|
||||
$member_list = new ProfileList($members, null, $this);
|
||||
$member_list = new GroupMemberList($members, $this->group, $this);
|
||||
$cnt = $member_list->show();
|
||||
}
|
||||
|
||||
|
@ -138,3 +138,326 @@ class GroupmembersAction extends Action
|
|||
array('nickname' => $this->group->nickname));
|
||||
}
|
||||
}
|
||||
|
||||
class GroupMemberList extends ProfileList
|
||||
{
|
||||
var $group = null;
|
||||
|
||||
function __construct($profile, $group, $action)
|
||||
{
|
||||
parent::__construct($profile, $action);
|
||||
|
||||
$this->group = $group;
|
||||
}
|
||||
|
||||
function newListItem($profile)
|
||||
{
|
||||
return new GroupMemberListItem($profile, $this->group, $this->action);
|
||||
}
|
||||
}
|
||||
|
||||
class GroupMemberListItem extends ProfileListItem
|
||||
{
|
||||
var $group = null;
|
||||
|
||||
function __construct($profile, $group, $action)
|
||||
{
|
||||
parent::__construct($profile, $action);
|
||||
|
||||
$this->group = $group;
|
||||
}
|
||||
|
||||
function showActions()
|
||||
{
|
||||
$this->startActions();
|
||||
$this->showSubscribeButton();
|
||||
$this->showMakeAdminForm();
|
||||
$this->showGroupBlockForm();
|
||||
$this->endActions();
|
||||
}
|
||||
|
||||
function showMakeAdminForm()
|
||||
{
|
||||
$user = common_current_user();
|
||||
|
||||
if (!empty($user) && $user->id != $this->profile->id && $user->isAdmin($this->group) &&
|
||||
!$this->profile->isAdmin($this->group)) {
|
||||
$this->out->elementStart('li', 'entity_make_admin');
|
||||
$maf = new MakeAdminForm($this->out, $this->profile, $this->group,
|
||||
array('action' => 'groupmembers',
|
||||
'nickname' => $this->group->nickname));
|
||||
$maf->show();
|
||||
$this->out->elementEnd('li');
|
||||
}
|
||||
|
||||
}
|
||||
function showGroupBlockForm()
|
||||
{
|
||||
$user = common_current_user();
|
||||
|
||||
if (!empty($user) && $user->id != $this->profile->id && $user->isAdmin($this->group)) {
|
||||
$this->out->elementStart('li', 'entity_block');
|
||||
$bf = new GroupBlockForm($this->out, $this->profile, $this->group,
|
||||
array('action' => 'groupmembers',
|
||||
'nickname' => $this->group->nickname));
|
||||
$bf->show();
|
||||
$this->out->elementEnd('li');
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Form for blocking a user from a group
|
||||
*
|
||||
* @category Form
|
||||
* @package Laconica
|
||||
* @author Evan Prodromou <evan@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/
|
||||
*
|
||||
* @see BlockForm
|
||||
*/
|
||||
|
||||
class GroupBlockForm extends Form
|
||||
{
|
||||
/**
|
||||
* Profile of user to block
|
||||
*/
|
||||
|
||||
var $profile = null;
|
||||
|
||||
/**
|
||||
* Group to block the user from
|
||||
*/
|
||||
|
||||
var $group = null;
|
||||
|
||||
/**
|
||||
* Return-to args
|
||||
*/
|
||||
|
||||
var $args = null;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param HTMLOutputter $out output channel
|
||||
* @param Profile $profile profile of user to block
|
||||
* @param User_group $group group to block user from
|
||||
* @param array $args return-to args
|
||||
*/
|
||||
|
||||
function __construct($out=null, $profile=null, $group=null, $args=null)
|
||||
{
|
||||
parent::__construct($out);
|
||||
|
||||
$this->profile = $profile;
|
||||
$this->group = $group;
|
||||
$this->args = $args;
|
||||
}
|
||||
|
||||
/**
|
||||
* ID of the form
|
||||
*
|
||||
* @return int ID of the form
|
||||
*/
|
||||
|
||||
function id()
|
||||
{
|
||||
// This should be unique for the page.
|
||||
return 'block-' . $this->profile->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* class of the form
|
||||
*
|
||||
* @return string class of the form
|
||||
*/
|
||||
|
||||
function formClass()
|
||||
{
|
||||
return 'form_group_block';
|
||||
}
|
||||
|
||||
/**
|
||||
* Action of the form
|
||||
*
|
||||
* @return string URL of the action
|
||||
*/
|
||||
|
||||
function action()
|
||||
{
|
||||
return common_local_url('groupblock');
|
||||
}
|
||||
|
||||
/**
|
||||
* Legend of the Form
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function formLegend()
|
||||
{
|
||||
$this->out->element('legend', null, _('Block user from group'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Data elements of the form
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function formData()
|
||||
{
|
||||
$this->out->hidden('blockto-' . $this->profile->id,
|
||||
$this->profile->id,
|
||||
'blockto');
|
||||
$this->out->hidden('blockgroup-' . $this->group->id,
|
||||
$this->group->id,
|
||||
'blockgroup');
|
||||
if ($this->args) {
|
||||
foreach ($this->args as $k => $v) {
|
||||
$this->out->hidden('returnto-' . $k, $v);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Action elements
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function formActions()
|
||||
{
|
||||
$this->out->submit('submit', _('Block'), 'submit', null, _('Block this user'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Form for making a user an admin for a group
|
||||
*
|
||||
* @category Form
|
||||
* @package Laconica
|
||||
* @author Evan Prodromou <evan@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 MakeAdminForm extends Form
|
||||
{
|
||||
/**
|
||||
* Profile of user to block
|
||||
*/
|
||||
|
||||
var $profile = null;
|
||||
|
||||
/**
|
||||
* Group to block the user from
|
||||
*/
|
||||
|
||||
var $group = null;
|
||||
|
||||
/**
|
||||
* Return-to args
|
||||
*/
|
||||
|
||||
var $args = null;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param HTMLOutputter $out output channel
|
||||
* @param Profile $profile profile of user to block
|
||||
* @param User_group $group group to block user from
|
||||
* @param array $args return-to args
|
||||
*/
|
||||
|
||||
function __construct($out=null, $profile=null, $group=null, $args=null)
|
||||
{
|
||||
parent::__construct($out);
|
||||
|
||||
$this->profile = $profile;
|
||||
$this->group = $group;
|
||||
$this->args = $args;
|
||||
}
|
||||
|
||||
/**
|
||||
* ID of the form
|
||||
*
|
||||
* @return int ID of the form
|
||||
*/
|
||||
|
||||
function id()
|
||||
{
|
||||
// This should be unique for the page.
|
||||
return 'makeadmin-' . $this->profile->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* class of the form
|
||||
*
|
||||
* @return string class of the form
|
||||
*/
|
||||
|
||||
function formClass()
|
||||
{
|
||||
return 'form_make_admin';
|
||||
}
|
||||
|
||||
/**
|
||||
* Action of the form
|
||||
*
|
||||
* @return string URL of the action
|
||||
*/
|
||||
|
||||
function action()
|
||||
{
|
||||
return common_local_url('makeadmin', array('nickname' => $this->group->nickname));
|
||||
}
|
||||
|
||||
/**
|
||||
* Legend of the Form
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function formLegend()
|
||||
{
|
||||
$this->out->element('legend', null, _('Make user an admin of the group'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Data elements of the form
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function formData()
|
||||
{
|
||||
$this->out->hidden('profileid-' . $this->profile->id,
|
||||
$this->profile->id,
|
||||
'profileid');
|
||||
$this->out->hidden('groupid-' . $this->group->id,
|
||||
$this->group->id,
|
||||
'groupid');
|
||||
if ($this->args) {
|
||||
foreach ($this->args as $k => $v) {
|
||||
$this->out->hidden('returnto-' . $k, $v);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Action elements
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function formActions()
|
||||
{
|
||||
$this->out->submit('submit', _('Make Admin'), 'submit', null, _('Make this user an admin'));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -100,11 +100,13 @@ class GroupsAction extends Action
|
|||
|
||||
function showContent()
|
||||
{
|
||||
if (common_logged_in()) {
|
||||
$this->elementStart('p', array('id' => 'new_group'));
|
||||
$this->element('a', array('href' => common_local_url('newgroup'),
|
||||
'class' => 'more'),
|
||||
_('Create a new group'));
|
||||
$this->elementEnd('p');
|
||||
}
|
||||
|
||||
$offset = ($this->page-1) * GROUPS_PER_PAGE;
|
||||
$limit = GROUPS_PER_PAGE + 1;
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
* @link http://laconi.ca/
|
||||
*
|
||||
* Laconica - a distributed open-source microblogging tool
|
||||
* Copyright (C) 2008, Controlez-Vous, Inc.
|
||||
* Copyright (C) 2008, 2009, Control Yourself, 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
|
||||
|
|
149
actions/groupunblock.php
Normal file
149
actions/groupunblock.php
Normal file
|
@ -0,0 +1,149 @@
|
|||
<?php
|
||||
/**
|
||||
* Block a user from a group action class.
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category Action
|
||||
* @package Laconica
|
||||
* @author Evan Prodromou <evan@controlyourself.ca>
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
|
||||
* @link http://laconi.ca/
|
||||
*
|
||||
* Laconica - a distributed open-source microblogging tool
|
||||
* Copyright (C) 2008, 2009, Control Yourself, 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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unlock a user from a group
|
||||
*
|
||||
* @category Action
|
||||
* @package Laconica
|
||||
* @author Evan Prodromou <evan@controlyourself.ca>
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
|
||||
* @link http://laconi.ca/
|
||||
*/
|
||||
|
||||
class GroupunblockAction extends Action
|
||||
{
|
||||
var $profile = null;
|
||||
var $group = null;
|
||||
|
||||
/**
|
||||
* Take arguments for running
|
||||
*
|
||||
* @param array $args $_REQUEST args
|
||||
*
|
||||
* @return boolean success flag
|
||||
*/
|
||||
|
||||
function prepare($args)
|
||||
{
|
||||
parent::prepare($args);
|
||||
if (!common_logged_in()) {
|
||||
$this->clientError(_('Not logged in.'));
|
||||
return false;
|
||||
}
|
||||
$token = $this->trimmed('token');
|
||||
if (empty($token) || $token != common_session_token()) {
|
||||
$this->clientError(_('There was a problem with your session token. Try again, please.'));
|
||||
return;
|
||||
}
|
||||
$id = $this->trimmed('unblockto');
|
||||
if (empty($id)) {
|
||||
$this->clientError(_('No profile specified.'));
|
||||
return false;
|
||||
}
|
||||
$this->profile = Profile::staticGet('id', $id);
|
||||
if (empty($this->profile)) {
|
||||
$this->clientError(_('No profile with that ID.'));
|
||||
return false;
|
||||
}
|
||||
$group_id = $this->trimmed('unblockgroup');
|
||||
if (empty($group_id)) {
|
||||
$this->clientError(_('No group specified.'));
|
||||
return false;
|
||||
}
|
||||
$this->group = User_group::staticGet('id', $group_id);
|
||||
if (empty($this->group)) {
|
||||
$this->clientError(_('No such group.'));
|
||||
return false;
|
||||
}
|
||||
$user = common_current_user();
|
||||
if (!$user->isAdmin($this->group)) {
|
||||
$this->clientError(_('Only an admin can unblock group members.'), 401);
|
||||
return false;
|
||||
}
|
||||
if (!Group_block::isBlocked($this->group, $this->profile)) {
|
||||
$this->clientError(_('User is not blocked from group.'));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle request
|
||||
*
|
||||
* @param array $args $_REQUEST args; handled in prepare()
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function handle($args)
|
||||
{
|
||||
parent::handle($args);
|
||||
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||
$this->unblockProfile();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unblock a user.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function unblockProfile()
|
||||
{
|
||||
$result = Group_block::unblockProfile($this->group, $this->profile);
|
||||
|
||||
if (!$result) {
|
||||
$this->serverError(_('Error removing the block.'));
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($this->args as $k => $v) {
|
||||
if ($k == 'returnto-action') {
|
||||
$action = $v;
|
||||
} else if (substr($k, 0, 9) == 'returnto-') {
|
||||
$args[substr($k, 9)] = $v;
|
||||
}
|
||||
}
|
||||
|
||||
if ($action) {
|
||||
common_redirect(common_local_url($action, $args), 303);
|
||||
} else {
|
||||
common_redirect(common_local_url('blockedfromgroup',
|
||||
array('nickname' => $this->group->nickname)),
|
||||
303);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
/*
|
||||
* Laconica - a distributed open-source microblogging tool
|
||||
* Copyright (C) 2008, Controlez-Vous, Inc.
|
||||
* Copyright (C) 2008, 2009, Control Yourself, 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
|
||||
|
@ -19,7 +19,7 @@
|
|||
|
||||
if (!defined('LACONICA')) { exit(1); }
|
||||
|
||||
class InviteAction extends Action
|
||||
class InviteAction extends CurrentUserDesignAction
|
||||
{
|
||||
var $mode = null;
|
||||
var $error = null;
|
||||
|
|
|
@ -96,6 +96,11 @@ class JoingroupAction extends Action
|
|||
return false;
|
||||
}
|
||||
|
||||
if (Group_block::isBlocked($this->group, $cur->getProfile())) {
|
||||
$this->clientError(_('You have been blocked from that group by the admin.'), 403);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
* @link http://laconi.ca/
|
||||
*
|
||||
* Laconica - a distributed open-source microblogging tool
|
||||
* Copyright (C) 2008, Controlez-Vous, Inc.
|
||||
* Copyright (C) 2008, 2009, Control Yourself, 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
|
||||
|
|
166
actions/makeadmin.php
Normal file
166
actions/makeadmin.php
Normal file
|
@ -0,0 +1,166 @@
|
|||
<?php
|
||||
/**
|
||||
* Make another user an admin of a group
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category Action
|
||||
* @package Laconica
|
||||
* @author Evan Prodromou <evan@controlyourself.ca>
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
|
||||
* @link http://laconi.ca/
|
||||
*
|
||||
* Laconica - a distributed open-source microblogging tool
|
||||
* Copyright (C) 2008, 2009, Control Yourself, 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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Make another user an admin of a group
|
||||
*
|
||||
* @category Action
|
||||
* @package Laconica
|
||||
* @author Evan Prodromou <evan@controlyourself.ca>
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
|
||||
* @link http://laconi.ca/
|
||||
*/
|
||||
|
||||
class MakeadminAction extends Action
|
||||
{
|
||||
var $profile = null;
|
||||
var $group = null;
|
||||
|
||||
/**
|
||||
* Take arguments for running
|
||||
*
|
||||
* @param array $args $_REQUEST args
|
||||
*
|
||||
* @return boolean success flag
|
||||
*/
|
||||
|
||||
function prepare($args)
|
||||
{
|
||||
parent::prepare($args);
|
||||
if (!common_logged_in()) {
|
||||
$this->clientError(_('Not logged in.'));
|
||||
return false;
|
||||
}
|
||||
$token = $this->trimmed('token');
|
||||
if (empty($token) || $token != common_session_token()) {
|
||||
$this->clientError(_('There was a problem with your session token. Try again, please.'));
|
||||
return;
|
||||
}
|
||||
$id = $this->trimmed('profileid');
|
||||
if (empty($id)) {
|
||||
$this->clientError(_('No profile specified.'));
|
||||
return false;
|
||||
}
|
||||
$this->profile = Profile::staticGet('id', $id);
|
||||
if (empty($this->profile)) {
|
||||
$this->clientError(_('No profile with that ID.'));
|
||||
return false;
|
||||
}
|
||||
$group_id = $this->trimmed('groupid');
|
||||
if (empty($group_id)) {
|
||||
$this->clientError(_('No group specified.'));
|
||||
return false;
|
||||
}
|
||||
$this->group = User_group::staticGet('id', $group_id);
|
||||
if (empty($this->group)) {
|
||||
$this->clientError(_('No such group.'));
|
||||
return false;
|
||||
}
|
||||
$user = common_current_user();
|
||||
if (!$user->isAdmin($this->group)) {
|
||||
$this->clientError(_('Only an admin can make another user an admin.'), 401);
|
||||
return false;
|
||||
}
|
||||
if ($this->profile->isAdmin($this->group)) {
|
||||
$this->clientError(sprintf(_('%s is already an admin for group "%s".'),
|
||||
$this->profile->getBestName(),
|
||||
$this->group->getBestName()),
|
||||
401);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle request
|
||||
*
|
||||
* @param array $args $_REQUEST args; handled in prepare()
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function handle($args)
|
||||
{
|
||||
parent::handle($args);
|
||||
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||
$this->makeAdmin();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Make user an admin
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function makeAdmin()
|
||||
{
|
||||
$member = Group_member::pkeyGet(array('group_id' => $this->group->id,
|
||||
'profile_id' => $this->profile->id));
|
||||
|
||||
if (empty($member)) {
|
||||
$this->serverError(_('Can\'t get membership record for %s in group %s'),
|
||||
$this->profile->getBestName(),
|
||||
$this->group->getBestName());
|
||||
}
|
||||
|
||||
$orig = clone($member);
|
||||
|
||||
$member->is_admin = 1;
|
||||
|
||||
$result = $member->update($orig);
|
||||
|
||||
if (!$result) {
|
||||
common_log_db_error($member, 'UPDATE', __FILE__);
|
||||
$this->serverError(_('Can\'t make %s an admin for group %s'),
|
||||
$this->profile->getBestName(),
|
||||
$this->group->getBestName());
|
||||
}
|
||||
|
||||
foreach ($this->args as $k => $v) {
|
||||
if ($k == 'returnto-action') {
|
||||
$action = $v;
|
||||
} else if (substr($k, 0, 9) == 'returnto-') {
|
||||
$args[substr($k, 9)] = $v;
|
||||
}
|
||||
}
|
||||
|
||||
if ($action) {
|
||||
common_redirect(common_local_url($action, $args), 303);
|
||||
} else {
|
||||
common_redirect(common_local_url('groupmembers',
|
||||
array('nickname' => $this->group->nickname)),
|
||||
303);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -12,7 +12,7 @@
|
|||
* @link http://laconi.ca/
|
||||
*
|
||||
* Laconica - a distributed open-source microblogging tool
|
||||
* Copyright (C) 2008, Controlez-Vous, Inc.
|
||||
* Copyright (C) 2008, 2009, Control Yourself, 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
|
||||
|
|
|
@ -123,6 +123,7 @@ class NewgroupAction extends Action
|
|||
$homepage = $this->trimmed('homepage');
|
||||
$description = $this->trimmed('description');
|
||||
$location = $this->trimmed('location');
|
||||
$aliasstring = $this->trimmed('aliases');
|
||||
|
||||
if (!Validate::string($nickname, array('min_length' => 1,
|
||||
'max_length' => 64,
|
||||
|
@ -153,6 +154,37 @@ class NewgroupAction extends Action
|
|||
return;
|
||||
}
|
||||
|
||||
if (!empty($aliasstring)) {
|
||||
$aliases = array_map('common_canonical_nickname', array_unique(preg_split('/[\s,]+/', $aliasstring)));
|
||||
} else {
|
||||
$aliases = array();
|
||||
}
|
||||
|
||||
if (count($aliases) > common_config('group', 'maxaliases')) {
|
||||
$this->showForm(sprintf(_('Too many aliases! Maximum %d.'),
|
||||
common_config('group', 'maxaliases')));
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($aliases as $alias) {
|
||||
if (!Validate::string($alias, array('min_length' => 1,
|
||||
'max_length' => 64,
|
||||
'format' => NICKNAME_FMT))) {
|
||||
$this->showForm(sprintf(_('Invalid alias: "%s"'), $alias));
|
||||
return;
|
||||
}
|
||||
if ($this->nicknameExists($alias)) {
|
||||
$this->showForm(sprintf(_('Alias "%s" already in use. Try another one.'),
|
||||
$alias));
|
||||
return;
|
||||
}
|
||||
// XXX assumes alphanum nicknames
|
||||
if (strcmp($alias, $nickname) == 0) {
|
||||
$this->showForm(_('Alias can\'t be the same as nickname.'));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$cur = common_current_user();
|
||||
|
||||
// Checked in prepare() above
|
||||
|
@ -177,6 +209,12 @@ class NewgroupAction extends Action
|
|||
$this->serverError(_('Could not create group.'));
|
||||
}
|
||||
|
||||
$result = $group->setAliases($aliases);
|
||||
|
||||
if (!$result) {
|
||||
$this->serverError(_('Could not create aliases.'));
|
||||
}
|
||||
|
||||
$member = new Group_member();
|
||||
|
||||
$member->group_id = $group->id;
|
||||
|
@ -199,7 +237,18 @@ class NewgroupAction extends Action
|
|||
function nicknameExists($nickname)
|
||||
{
|
||||
$group = User_group::staticGet('nickname', $nickname);
|
||||
return (!is_null($group) && $group != false);
|
||||
|
||||
if (!empty($group)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$alias = Group_alias::staticGet('alias', $nickname);
|
||||
|
||||
if (!empty($alias)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -116,6 +116,9 @@ class NewnoticeAction extends Action
|
|||
function getUploadedFileType() {
|
||||
require_once 'MIME/Type.php';
|
||||
|
||||
$cmd = &PEAR::getStaticProperty('MIME_Type', 'fileCmd');
|
||||
$cmd = common_config('attachments', 'filecommand');
|
||||
|
||||
$filetype = MIME_Type::autoDetect($_FILES['attach']['tmp_name']);
|
||||
if (in_array($filetype, common_config('attachments', 'supported'))) {
|
||||
return $filetype;
|
||||
|
@ -221,17 +224,34 @@ class NewnoticeAction extends Action
|
|||
}
|
||||
}
|
||||
|
||||
if (isset($mimetype)) {
|
||||
$filename = $this->saveFile($mimetype);
|
||||
if (empty($filename)) {
|
||||
$this->clientError(_('Couldn\'t save file.'));
|
||||
}
|
||||
$fileurl = File::url($filename);
|
||||
$short_fileurl = common_shorten_url($fileurl);
|
||||
$content_shortened .= ' ' . $short_fileurl;
|
||||
if (mb_strlen($content_shortened) > 140) {
|
||||
$this->deleteFile($filename);
|
||||
$this->clientError(_('Max notice size is 140 chars, including attachment URL.'));
|
||||
}
|
||||
}
|
||||
|
||||
$notice = Notice::saveNew($user->id, $content_shortened, 'web', 1,
|
||||
($replyto == 'false') ? null : $replyto);
|
||||
|
||||
if (is_string($notice)) {
|
||||
if (isset($filename)) {
|
||||
$this->deleteFile($filename);
|
||||
}
|
||||
$this->clientError($notice);
|
||||
}
|
||||
|
||||
if (isset($mimetype)) {
|
||||
$this->storeFile($notice, $mimetype);
|
||||
$this->attachFile($notice, $filename, $mimetype, $short_fileurl);
|
||||
}
|
||||
$this->saveUrls($notice);
|
||||
|
||||
common_broadcast_notice($notice);
|
||||
|
||||
if ($this->boolean('ajax')) {
|
||||
|
@ -257,49 +277,73 @@ class NewnoticeAction extends Action
|
|||
}
|
||||
}
|
||||
|
||||
function storeFile($notice, $mimetype) {
|
||||
$filename = basename($_FILES['attach']['name']);
|
||||
$destination = "file/{$notice->id}-$filename";
|
||||
if (move_uploaded_file($_FILES['attach']['tmp_name'], INSTALLDIR . "/$destination")) {
|
||||
$file = new File;
|
||||
$file->url = common_local_url('file', array('notice' => $notice->id));
|
||||
$file->size = filesize(INSTALLDIR . "/$destination");
|
||||
$file->date = time();
|
||||
$file->mimetype = $mimetype;
|
||||
if ($file_id = $file->insert()) {
|
||||
$file_redir = new File_redirection;
|
||||
$file_redir->url = common_path($destination);
|
||||
$file_redir->file_id = $file_id;
|
||||
$file_redir->insert();
|
||||
function saveFile($mimetype) {
|
||||
|
||||
$f2p = new File_to_post;
|
||||
$f2p->file_id = $file_id;
|
||||
$f2p->post_id = $notice->id;
|
||||
$f2p->insert();
|
||||
} else {
|
||||
$this->clientError(_('There was a database error while saving your file. Please try again.'));
|
||||
$cur = common_current_user();
|
||||
|
||||
if (empty($cur)) {
|
||||
$this->serverError(_('Somehow lost the login in saveFile'));
|
||||
}
|
||||
|
||||
$basename = basename($_FILES['attach']['name']);
|
||||
|
||||
$filename = File::filename($cur->getProfile(), $basename, $mimetype);
|
||||
|
||||
$filepath = File::path($filename);
|
||||
|
||||
if (move_uploaded_file($_FILES['attach']['tmp_name'], $filepath)) {
|
||||
return $filename;
|
||||
} else {
|
||||
$this->clientError(_('File could not be moved to destination directory.'));
|
||||
}
|
||||
}
|
||||
|
||||
/** save all urls in the notice to the db
|
||||
*
|
||||
* follow redirects and save all available file information
|
||||
* (mimetype, date, size, oembed, etc.)
|
||||
*
|
||||
* @param class $notice Notice to pull URLs from
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function saveUrls($notice, $uploaded = null) {
|
||||
common_replace_urls_callback($notice->content, array($this, 'saveUrl'), $notice->id);
|
||||
function deleteFile($filename)
|
||||
{
|
||||
$filepath = File::path($filename);
|
||||
@unlink($filepath);
|
||||
}
|
||||
|
||||
function saveUrl($data) {
|
||||
list($url, $notice_id) = $data;
|
||||
$zzz = File::processNew($url, $notice_id);
|
||||
function attachFile($notice, $filename, $mimetype, $short)
|
||||
{
|
||||
$file = new File;
|
||||
$file->filename = $filename;
|
||||
|
||||
$file->url = common_local_url('file', array('notice' => $notice->id));
|
||||
|
||||
$filepath = File::path($filename);
|
||||
|
||||
$file->size = filesize($filepath);
|
||||
$file->date = time();
|
||||
$file->mimetype = $mimetype;
|
||||
|
||||
$file_id = $file->insert();
|
||||
|
||||
if (!$file_id) {
|
||||
common_log_db_error($file, "INSERT", __FILE__);
|
||||
$this->clientError(_('There was a database error while saving your file. Please try again.'));
|
||||
}
|
||||
|
||||
$file_redir = new File_redirection;
|
||||
$file_redir->url = File::url($filename);
|
||||
$file_redir->file_id = $file_id;
|
||||
|
||||
$result = $file_redir->insert();
|
||||
|
||||
if (!$result) {
|
||||
common_log_db_error($file_redir, "INSERT", __FILE__);
|
||||
$this->clientError(_('There was a database error while saving your file. Please try again.'));
|
||||
}
|
||||
|
||||
$f2p = new File_to_post;
|
||||
$f2p->file_id = $file_id;
|
||||
$f2p->post_id = $notice->id;
|
||||
$f2p->insert();
|
||||
|
||||
if (!$result) {
|
||||
common_log_db_error($f2p, "INSERT", __FILE__);
|
||||
$this->clientError(_('There was a database error while saving your file. Please try again.'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* @link http://laconi.ca/
|
||||
*
|
||||
* Laconica - a distributed open-source microblogging tool
|
||||
* Copyright (C) 2008, Controlez-Vous, Inc.
|
||||
* Copyright (C) 2008, 2009, Control Yourself, 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
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
* @link http://laconi.ca/
|
||||
*
|
||||
* Laconica - a distributed open-source microblogging tool
|
||||
* Copyright (C) 2008, Controlez-Vous, Inc.
|
||||
* Copyright (C) 2008, 2009, Control Yourself, 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
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* @link http://laconi.ca/
|
||||
*
|
||||
* Laconica - a distributed open-source microblogging tool
|
||||
* Copyright (C) 2008, Controlez-Vous, Inc.
|
||||
* Copyright (C) 2008, 2009, Control Yourself, 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
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
/*
|
||||
* Laconica - a distributed open-source microblogging tool
|
||||
* Copyright (C) 2008, Controlez-Vous, Inc.
|
||||
* Copyright (C) 2008, 2009, Control Yourself, 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
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* @link http://laconi.ca/
|
||||
*
|
||||
* Laconica - a distributed open-source microblogging tool
|
||||
* Copyright (C) 2008, Controlez-Vous, Inc.
|
||||
* Copyright (C) 2008, 2009, Control Yourself, 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
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
* @link http://laconi.ca/
|
||||
*
|
||||
* Laconica - a distributed open-source microblogging tool
|
||||
* Copyright (C) 2008, Controlez-Vous, Inc.
|
||||
* Copyright (C) 2008, 2009, Control Yourself, 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
|
||||
|
|
|
@ -124,7 +124,7 @@ class PeopletagAction extends Action
|
|||
|
||||
$profile->query(sprintf($qry, $this->tag, $lim));
|
||||
|
||||
$pl = new ProfileList($profile, null, $this);
|
||||
$pl = new ProfileList($profile, $this);
|
||||
$cnt = $pl->show();
|
||||
|
||||
$this->pagination($this->page > 1,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
/*
|
||||
* Laconica - a distributed open-source microblogging tool
|
||||
* Copyright (C) 2008, Controlez-Vous, Inc.
|
||||
* Copyright (C) 2008, 2009, Control Yourself, 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
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* @link http://laconi.ca/
|
||||
*
|
||||
* Laconica - a distributed open-source microblogging tool
|
||||
* Copyright (C) 2008, Controlez-Vous, Inc.
|
||||
* Copyright (C) 2008, 2009, Control Yourself, 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
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* @link http://laconi.ca/
|
||||
*
|
||||
* Laconica - a distributed open-source microblogging tool
|
||||
* Copyright (C) 2008, Controlez-Vous, Inc.
|
||||
* Copyright (C) 2008, 2009, Control Yourself, 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
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
/*
|
||||
* Laconica - a distributed open-source microblogging tool
|
||||
* Copyright (C) 2008, Controlez-Vous, Inc.
|
||||
* Copyright (C) 2008, 2009, Control Yourself, 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
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
/*
|
||||
* Laconica - a distributed open-source microblogging tool
|
||||
* Copyright (C) 2008, Controlez-Vous, Inc.
|
||||
* Copyright (C) 2008, 2009, Control Yourself, 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
|
||||
|
|
|
@ -45,9 +45,8 @@ require_once INSTALLDIR.'/lib/feedlist.php';
|
|||
* @link http://laconi.ca/
|
||||
*/
|
||||
|
||||
class RepliesAction extends Action
|
||||
class RepliesAction extends OwnerDesignAction
|
||||
{
|
||||
var $user = null;
|
||||
var $page = null;
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
/*
|
||||
* Laconica - a distributed open-source microblogging tool
|
||||
* Copyright (C) 2008, Controlez-Vous, Inc.
|
||||
* Copyright (C) 2008, 2009, Control Yourself, 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
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* @link http://laconi.ca/
|
||||
*
|
||||
* Laconica - a distributed open-source microblogging tool
|
||||
* Copyright (C) 2008, Controlez-Vous, Inc.
|
||||
* Copyright (C) 2008, 2009, Control Yourself, 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
|
||||
|
|
|
@ -45,7 +45,7 @@ require_once INSTALLDIR.'/lib/feedlist.php';
|
|||
* @link http://laconi.ca/
|
||||
*/
|
||||
|
||||
class ShowfavoritesAction extends Action
|
||||
class ShowfavoritesAction extends CurrentUserDesignAction
|
||||
{
|
||||
/** User we're getting the faves of */
|
||||
var $user = null;
|
||||
|
|
|
@ -47,10 +47,9 @@ define('MEMBERS_PER_SECTION', 27);
|
|||
* @link http://laconi.ca/
|
||||
*/
|
||||
|
||||
class ShowgroupAction extends Action
|
||||
class ShowgroupAction extends GroupDesignAction
|
||||
{
|
||||
/** group we're viewing. */
|
||||
var $group = null;
|
||||
|
||||
/** page we're viewing. */
|
||||
var $page = null;
|
||||
|
||||
|
@ -272,6 +271,17 @@ class ShowgroupAction extends Action
|
|||
$this->elementEnd('dl');
|
||||
}
|
||||
|
||||
if (common_config('group', 'maxaliases') > 0) {
|
||||
$aliases = $this->group->getAliases();
|
||||
|
||||
if (!empty($aliases)) {
|
||||
$this->elementStart('dl', 'entity_aliases');
|
||||
$this->element('dt', null, _('Aliases'));
|
||||
$this->element('dd', 'aliases', implode(' ', $aliases));
|
||||
$this->elementEnd('dl');
|
||||
}
|
||||
}
|
||||
|
||||
$this->elementEnd('div');
|
||||
|
||||
$this->elementStart('div', 'entity_actions');
|
||||
|
@ -283,7 +293,7 @@ class ShowgroupAction extends Action
|
|||
if ($cur->isMember($this->group)) {
|
||||
$lf = new LeaveForm($this, $this->group);
|
||||
$lf->show();
|
||||
} else {
|
||||
} else if (!Group_block::isBlocked($this->group, $cur->getProfile())) {
|
||||
$jf = new JoinForm($this, $this->group);
|
||||
$jf->show();
|
||||
}
|
||||
|
@ -344,7 +354,7 @@ class ShowgroupAction extends Action
|
|||
|
||||
$this->element('h2', null, _('Members'));
|
||||
|
||||
$pml = new ProfileMiniList($member, null, $this);
|
||||
$pml = new ProfileMiniList($member, $this);
|
||||
$cnt = $pml->show();
|
||||
if ($cnt == 0) {
|
||||
$this->element('p', null, _('(None)'));
|
||||
|
|
|
@ -209,7 +209,7 @@ class ShownoticeAction extends Action
|
|||
function showContent()
|
||||
{
|
||||
$this->elementStart('ol', array('class' => 'notices xoxo'));
|
||||
$nli = new NoticeListItem($this->notice, $this);
|
||||
$nli = new SingleNoticeItem($this->notice, $this);
|
||||
$nli->show();
|
||||
$this->elementEnd('ol');
|
||||
}
|
||||
|
@ -264,3 +264,29 @@ class ShownoticeAction extends Action
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
class SingleNoticeItem extends NoticeListItem
|
||||
{
|
||||
/**
|
||||
* recipe function for displaying a single notice.
|
||||
*
|
||||
* We overload to show attachments.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function show()
|
||||
{
|
||||
$this->showStart();
|
||||
$this->showNotice();
|
||||
$this->showNoticeAttachments();
|
||||
$this->showNoticeInfo();
|
||||
$this->showNoticeOptions();
|
||||
$this->showEnd();
|
||||
}
|
||||
|
||||
function showNoticeAttachments() {
|
||||
$al = new AttachmentList($this->notice, $this->out);
|
||||
$al->show();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -320,10 +320,14 @@ class ShowstreamAction extends ProfileAction
|
|||
$blocked = $cur->hasBlocked($this->profile);
|
||||
$this->elementStart('li', 'entity_block');
|
||||
if ($blocked) {
|
||||
$ubf = new UnblockForm($this, $this->profile);
|
||||
$ubf = new UnblockForm($this, $this->profile,
|
||||
array('action' => 'showstream',
|
||||
'nickname' => $this->profile->nickname));
|
||||
$ubf->show();
|
||||
} else {
|
||||
$bf = new BlockForm($this, $this->profile);
|
||||
$bf = new BlockForm($this, $this->profile,
|
||||
array('action' => 'showstream',
|
||||
'nickname' => $this->profile->nickname));
|
||||
$bf->show();
|
||||
}
|
||||
$this->elementEnd('li');
|
||||
|
@ -366,7 +370,7 @@ class ShowstreamAction extends ProfileAction
|
|||
{
|
||||
$notice = empty($this->tag)
|
||||
? $this->user->getNotices(($this->page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1)
|
||||
: $this->user->getTaggedNotices(($this->page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1, 0, 0, null, $this->tag);
|
||||
: $this->user->getTaggedNotices($this->tag, ($this->page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1, 0, 0, null);
|
||||
|
||||
$pnl = new ProfileNoticeList($notice, $this);
|
||||
$cnt = $pnl->show();
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
/*
|
||||
* Laconica - a distributed open-source microblogging tool
|
||||
* Copyright (C) 2008, Controlez-Vous, Inc.
|
||||
* Copyright (C) 2008, 2009, Control Yourself, 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
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
/*
|
||||
* Laconica - a distributed open-source microblogging tool
|
||||
* Copyright (C) 2008, Controlez-Vous, Inc.
|
||||
* Copyright (C) 2008, 2009, Control Yourself, 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
|
||||
|
|
|
@ -130,18 +130,34 @@ class SubscribersAction extends GalleryAction
|
|||
}
|
||||
}
|
||||
|
||||
class SubscribersList extends ProfileList
|
||||
class SubscribersList extends SubscriptionList
|
||||
{
|
||||
function newListItem($profile)
|
||||
{
|
||||
return new SubscribersListItem($profile, $this->owner, $this->action);
|
||||
}
|
||||
}
|
||||
|
||||
class SubscribersListItem extends SubscriptionListItem
|
||||
{
|
||||
function showActions()
|
||||
{
|
||||
$this->startActions();
|
||||
$this->showSubscribeButton();
|
||||
// Relevant code!
|
||||
$this->showBlockForm();
|
||||
$this->endActions();
|
||||
}
|
||||
|
||||
function showBlockForm()
|
||||
{
|
||||
$user = common_current_user();
|
||||
|
||||
if (!empty($user) && $this->owner->id == $user->id) {
|
||||
$bf = new BlockForm($this->out, $this->profile,
|
||||
array('action' => 'subscribers',
|
||||
'nickname' => $this->owner->nickname));
|
||||
$bf->show();
|
||||
}
|
||||
|
||||
function isReadOnly($args)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -137,22 +137,46 @@ class SubscriptionsAction extends GalleryAction
|
|||
}
|
||||
}
|
||||
|
||||
class SubscriptionsList extends ProfileList
|
||||
// XXX SubscriptionsList and SubscriptionList are dangerously close
|
||||
|
||||
class SubscriptionsList extends SubscriptionList
|
||||
{
|
||||
function showOwnerControls($profile)
|
||||
function newListItem($profile)
|
||||
{
|
||||
return new SubscriptionsListItem($profile, $this->owner, $this->action);
|
||||
}
|
||||
}
|
||||
|
||||
class SubscriptionsListItem extends SubscriptionListItem
|
||||
{
|
||||
function showProfile()
|
||||
{
|
||||
$this->startProfile();
|
||||
$this->showAvatar();
|
||||
$this->showFullName();
|
||||
$this->showLocation();
|
||||
$this->showHomepage();
|
||||
$this->showBio();
|
||||
$this->showTags();
|
||||
// Relevant portion!
|
||||
$this->showOwnerControls();
|
||||
$this->endProfile();
|
||||
}
|
||||
|
||||
function showOwnerControls()
|
||||
{
|
||||
$sub = Subscription::pkeyGet(array('subscriber' => $this->owner->id,
|
||||
'subscribed' => $profile->id));
|
||||
'subscribed' => $this->profile->id));
|
||||
if (!$sub) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->out->elementStart('form', array('id' => 'subedit-' . $profile->id,
|
||||
$this->out->elementStart('form', array('id' => 'subedit-' . $this->profile->id,
|
||||
'method' => 'post',
|
||||
'class' => 'form_subscription_edit',
|
||||
'action' => common_local_url('subedit')));
|
||||
$this->out->hidden('token', common_session_token());
|
||||
$this->out->hidden('profile', $profile->id);
|
||||
$this->out->hidden('profile', $this->profile->id);
|
||||
$this->out->checkbox('jabber', _('Jabber'), $sub->jabber);
|
||||
$this->out->checkbox('sms', _('SMS'), $sub->sms);
|
||||
$this->out->submit('save', _('Save'));
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
/*
|
||||
* Laconica - a distributed open-source microblogging tool
|
||||
* Copyright (C) 2008, Controlez-Vous, Inc.
|
||||
* Copyright (C) 2008, 2009, Control Yourself, 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
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
/*
|
||||
* Laconica - a distributed open-source microblogging tool
|
||||
* Copyright (C) 2008, Controlez-Vous, Inc.
|
||||
* Copyright (C) 2008, 2009, Control Yourself, 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
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
/*
|
||||
* Laconica - a distributed open-source microblogging tool
|
||||
* Copyright (C) 2008, Controlez-Vous, Inc.
|
||||
* Copyright (C) 2008, 2009, Control Yourself, 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
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
/*
|
||||
* Laconica - a distributed open-source microblogging tool
|
||||
* Copyright (C) 2008, Controlez-Vous, Inc.
|
||||
* Copyright (C) 2008, 2009, Control Yourself, 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
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
/*
|
||||
* Laconica - a distributed open-source microblogging tool
|
||||
* Copyright (C) 2008, Controlez-Vous, Inc.
|
||||
* Copyright (C) 2008, 2009, Control Yourself, 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
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
/*
|
||||
* Laconica - a distributed open-source microblogging tool
|
||||
* Copyright (C) 2008, Controlez-Vous, Inc.
|
||||
* Copyright (C) 2008, 2009, Control Yourself, 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
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
/*
|
||||
* Laconica - a distributed open-source microblogging tool
|
||||
* Copyright (C) 2008, Controlez-Vous, Inc.
|
||||
* Copyright (C) 2008, 2009, Control Yourself, 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
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
/*
|
||||
* Laconica - a distributed open-source microblogging tool
|
||||
* Copyright (C) 2008, Controlez-Vous, Inc.
|
||||
* Copyright (C) 2008, 2009, Control Yourself, 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
|
||||
|
@ -34,6 +34,11 @@ class TwitapifavoritesAction extends TwitterapiAction
|
|||
$user = $this->get_user($apidata['api_arg'], $apidata);
|
||||
|
||||
if (empty($user)) {
|
||||
if ($apidata['content-type'] == 'xml') {
|
||||
$this->show_single_xml_status($notice);
|
||||
} elseif ($apidata['content-type'] == 'json') {
|
||||
$this->show_single_json_status($notice);
|
||||
}
|
||||
$this->clientError('Not Found', 404, $apidata['content-type']);
|
||||
return;
|
||||
}
|
||||
|
@ -91,7 +96,6 @@ class TwitapifavoritesAction extends TwitterapiAction
|
|||
|
||||
// Check for RESTfulness
|
||||
if (!in_array($_SERVER['REQUEST_METHOD'], array('POST', 'DELETE'))) {
|
||||
// XXX: Twitter just prints the err msg, no XML / JSON.
|
||||
$this->clientError(_('This method requires a POST or DELETE.'),
|
||||
400, $apidata['content-type']);
|
||||
return;
|
||||
|
@ -103,7 +107,6 @@ class TwitapifavoritesAction extends TwitterapiAction
|
|||
}
|
||||
|
||||
$user = $apidata['user']; // Always the auth user
|
||||
|
||||
$notice_id = $apidata['api_arg'];
|
||||
$notice = Notice::staticGet($notice_id);
|
||||
|
||||
|
@ -115,7 +118,7 @@ class TwitapifavoritesAction extends TwitterapiAction
|
|||
|
||||
// XXX: Twitter lets you fave things repeatedly via api.
|
||||
if ($user->hasFave($notice)) {
|
||||
$this->clientError(_('This notice is already a favorite!'),
|
||||
$this->clientError(_('This status is already a favorite!'),
|
||||
403, $apidata['content-type']);
|
||||
return;
|
||||
}
|
||||
|
@ -123,7 +126,7 @@ class TwitapifavoritesAction extends TwitterapiAction
|
|||
$fave = Fave::addNew($user, $notice);
|
||||
|
||||
if (empty($fave)) {
|
||||
$this->serverError(_('Could not create favorite.'));
|
||||
$this->clientError(_('Could not create favorite.'));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -141,7 +144,55 @@ class TwitapifavoritesAction extends TwitterapiAction
|
|||
function destroy($args, $apidata)
|
||||
{
|
||||
parent::handle($args);
|
||||
$this->serverError(_('API method under construction.'), $code=501);
|
||||
|
||||
// Check for RESTfulness
|
||||
if (!in_array($_SERVER['REQUEST_METHOD'], array('POST', 'DELETE'))) {
|
||||
$this->clientError(_('This method requires a POST or DELETE.'),
|
||||
400, $apidata['content-type']);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!in_array($apidata['content-type'], array('xml', 'json'))) {
|
||||
$this->clientError(_('API method not found!'), $code = 404);
|
||||
return;
|
||||
}
|
||||
|
||||
$user = $apidata['user']; // Always the auth user
|
||||
$notice_id = $apidata['api_arg'];
|
||||
$notice = Notice::staticGet($notice_id);
|
||||
|
||||
if (empty($notice)) {
|
||||
$this->clientError(_('No status found with that ID.'),
|
||||
404, $apidata['content-type']);
|
||||
return;
|
||||
}
|
||||
|
||||
$fave = new Fave();
|
||||
$fave->user_id = $this->id;
|
||||
$fave->notice_id = $notice->id;
|
||||
|
||||
if (!$fave->find(true)) {
|
||||
$this->clientError(_('That status is not a favorite!'),
|
||||
403, $apidata['content-type']);
|
||||
return;
|
||||
}
|
||||
|
||||
$result = $fave->delete();
|
||||
|
||||
if (!$result) {
|
||||
common_log_db_error($fave, 'DELETE', __FILE__);
|
||||
$this->clientError(_('Could not delete favorite.'), 404);
|
||||
return;
|
||||
}
|
||||
|
||||
$user->blowFavesCache();
|
||||
|
||||
if ($apidata['content-type'] == 'xml') {
|
||||
$this->show_single_xml_status($notice);
|
||||
} elseif ($apidata['content-type'] == 'json') {
|
||||
$this->show_single_json_status($notice);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// XXX: these two funcs swiped from faves.
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
/*
|
||||
* Laconica - a distributed open-source microblogging tool
|
||||
* Copyright (C) 2008, Controlez-Vous, Inc.
|
||||
* Copyright (C) 2008, 2009, Control Yourself, 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
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
/*
|
||||
* Laconica - a distributed open-source microblogging tool
|
||||
* Copyright (C) 2008, Controlez-Vous, Inc.
|
||||
* Copyright (C) 2008, 2009, Control Yourself, 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
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
/*
|
||||
* Laconica - a distributed open-source microblogging tool
|
||||
* Copyright (C) 2008, Controlez-Vous, Inc.
|
||||
* Copyright (C) 2008, 2009, Control Yourself, 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
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
/*
|
||||
* Laconica - a distributed open-source microblogging tool
|
||||
* Copyright (C) 2008, Controlez-Vous, Inc.
|
||||
* Copyright (C) 2008, 2009, Control Yourself, 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
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
/*
|
||||
* Laconica - a distributed open-source microblogging tool
|
||||
* Copyright (C) 2008, Controlez-Vous, Inc.
|
||||
* Copyright (C) 2008, 2009, Control Yourself, 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
|
||||
|
@ -58,7 +58,7 @@ class TwitapiusersAction extends TwitterapiAction
|
|||
return;
|
||||
}
|
||||
|
||||
$twitter_user = $this->twitter_user_array($profile, true);
|
||||
$twitter_user = $this->twitter_user_array($user->getProfile(), true);
|
||||
|
||||
if ($apidata['content-type'] == 'xml') {
|
||||
$this->init_document('xml');
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
* @link http://laconi.ca/
|
||||
*
|
||||
* Laconica - a distributed open-source microblogging tool
|
||||
* Copyright (C) 2008, Controlez-Vous, Inc.
|
||||
* Copyright (C) 2008, 2009, Control Yourself, 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
|
||||
|
@ -118,7 +118,7 @@ class UnblockAction extends Action
|
|||
if ($action) {
|
||||
common_redirect(common_local_url($action, $args), 303);
|
||||
} else {
|
||||
common_redirect(common_local_url('subscriptions',
|
||||
common_redirect(common_local_url('subscribers',
|
||||
array('nickname' => $cur->nickname)),
|
||||
303);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
/*
|
||||
* Laconica - a distributed open-source microblogging tool
|
||||
* Copyright (C) 2008, Controlez-Vous, Inc.
|
||||
* Copyright (C) 2008, 2009, Control Yourself, 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
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
/*
|
||||
* Laconica - a distributed open-source microblogging tool
|
||||
* Copyright (C) 2008, Controlez-Vous, Inc.
|
||||
* Copyright (C) 2008, 2009, Control Yourself, 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
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
/*
|
||||
* Laconica - a distributed open-source microblogging tool
|
||||
* Copyright (C) 2008, Controlez-Vous, Inc.
|
||||
* Copyright (C) 2008, 2009, Control Yourself, 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
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* @link http://laconi.ca/
|
||||
|
||||
* Laconica - a distributed open-source microblogging tool
|
||||
* Copyright (C) 2008, Controlez-Vous, Inc.
|
||||
* Copyright (C) 2008, 2009, Control Yourself, 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
|
||||
|
|
208
actions/userdesignsettings.php
Normal file
208
actions/userdesignsettings.php
Normal file
|
@ -0,0 +1,208 @@
|
|||
<?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 Sarven Capadisli <csarven@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/designsettings.php';
|
||||
|
||||
class UserDesignSettingsAction extends DesignSettingsAction
|
||||
{
|
||||
|
||||
function prepare($args)
|
||||
{
|
||||
parent::prepare($args);
|
||||
$this->submitaction = common_local_url('userdesignsettings');
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Title of the page
|
||||
*
|
||||
* @return string Title of the page
|
||||
*/
|
||||
|
||||
function title()
|
||||
{
|
||||
return _('Profile design');
|
||||
}
|
||||
|
||||
/**
|
||||
* Instructions for use
|
||||
*
|
||||
* @return instructions for use
|
||||
*/
|
||||
|
||||
function getInstructions()
|
||||
{
|
||||
return _('Customize the way your profile looks ' .
|
||||
'with a background image and a colour palette of your choice.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the design we want to edit
|
||||
*
|
||||
* @return Design
|
||||
*/
|
||||
|
||||
function getWorkingDesign() {
|
||||
|
||||
$user = common_current_user();
|
||||
$design = $user->getDesign();
|
||||
|
||||
if (empty($design)) {
|
||||
$design = $this->defaultDesign();
|
||||
}
|
||||
|
||||
return $design;
|
||||
}
|
||||
|
||||
/**
|
||||
* Content area of the page
|
||||
*
|
||||
* Shows a form for changing the design
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function showContent()
|
||||
{
|
||||
$this->showDesignForm($this->getWorkingDesign());
|
||||
}
|
||||
|
||||
/**
|
||||
* Save or update the user's design settings
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function saveDesign()
|
||||
{
|
||||
try {
|
||||
|
||||
$bgcolor = new WebColor($this->trimmed('design_background'));
|
||||
$ccolor = new WebColor($this->trimmed('design_content'));
|
||||
$sbcolor = new WebColor($this->trimmed('design_sidebar'));
|
||||
$tcolor = new WebColor($this->trimmed('design_text'));
|
||||
$lcolor = new WebColor($this->trimmed('design_links'));
|
||||
|
||||
} catch (WebColorException $e) {
|
||||
$this->showForm($e->getMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
$onoff = $this->arg('design_background-image_onoff');
|
||||
|
||||
$on = false;
|
||||
$off = false;
|
||||
$tile = false;
|
||||
|
||||
if ($onoff == 'on') {
|
||||
$on = true;
|
||||
} else {
|
||||
$off = true;
|
||||
}
|
||||
|
||||
$repeat = $this->boolean('design_background-image_repeat');
|
||||
|
||||
if ($repeat) {
|
||||
$tile = true;
|
||||
}
|
||||
|
||||
$user = common_current_user();
|
||||
$design = $user->getDesign();
|
||||
|
||||
if (!empty($design)) {
|
||||
|
||||
$original = clone($design);
|
||||
|
||||
$design->backgroundcolor = $bgcolor->intValue();
|
||||
$design->contentcolor = $ccolor->intValue();
|
||||
$design->sidebarcolor = $sbcolor->intValue();
|
||||
$design->textcolor = $tcolor->intValue();
|
||||
$design->linkcolor = $lcolor->intValue();
|
||||
$design->backgroundimage = $filepath;
|
||||
|
||||
$design->setDisposition($on, $off, $tile);
|
||||
|
||||
$result = $design->update($original);
|
||||
|
||||
if ($result === false) {
|
||||
common_log_db_error($design, 'UPDATE', __FILE__);
|
||||
$this->showForm(_('Couldn\'t update your design.'));
|
||||
return;
|
||||
}
|
||||
|
||||
// update design
|
||||
} else {
|
||||
|
||||
$user->query('BEGIN');
|
||||
|
||||
// save new design
|
||||
$design = new Design();
|
||||
|
||||
$design->backgroundcolor = $bgcolor->intValue();
|
||||
$design->contentcolor = $ccolor->intValue();
|
||||
$design->sidebarcolor = $sbcolor->intValue();
|
||||
$design->textcolor = $tcolor->intValue();
|
||||
$design->linkcolor = $lcolor->intValue();
|
||||
$design->backgroundimage = $filepath;
|
||||
|
||||
$design->setDisposition($on, $off, $tile);
|
||||
|
||||
$id = $design->insert();
|
||||
|
||||
if (empty($id)) {
|
||||
common_log_db_error($id, 'INSERT', __FILE__);
|
||||
$this->showForm(_('Unable to save your design settings!'));
|
||||
return;
|
||||
}
|
||||
|
||||
$original = clone($user);
|
||||
$user->design_id = $id;
|
||||
$result = $user->update($original);
|
||||
|
||||
if (empty($result)) {
|
||||
common_log_db_error($original, 'UPDATE', __FILE__);
|
||||
$this->showForm(_('Unable to save your design settings!'));
|
||||
$user->query('ROLLBACK');
|
||||
return;
|
||||
}
|
||||
|
||||
$user->query('COMMIT');
|
||||
|
||||
}
|
||||
|
||||
$this->saveBackgroundImage($design);
|
||||
|
||||
$this->showForm(_('Design preferences saved.'), true);
|
||||
}
|
||||
}
|
|
@ -46,9 +46,8 @@ require_once INSTALLDIR.'/lib/grouplist.php';
|
|||
* @link http://laconi.ca/
|
||||
*/
|
||||
|
||||
class UsergroupsAction extends Action
|
||||
class UsergroupsAction extends OwnerDesignAction
|
||||
{
|
||||
var $user = null;
|
||||
var $page = null;
|
||||
var $profile = null;
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
/*
|
||||
* Laconica - a distributed open-source microblogging tool
|
||||
* Copyright (C) 2008, Controlez-Vous, Inc.
|
||||
* Copyright (C) 2008, 2009, Control Yourself, 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
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* @link http://laconi.ca/
|
||||
*
|
||||
* Laconica - a distributed open-source microblogging tool
|
||||
* Copyright (C) 2008, Controlez-Vous, Inc.
|
||||
* Copyright (C) 2008, 2009, Control Yourself, 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
|
||||
|
|
0
background/.gitignore
vendored
Normal file
0
background/.gitignore
vendored
Normal file
|
@ -55,19 +55,43 @@ class Avatar extends Memcached_DataObject
|
|||
|
||||
static function path($filename)
|
||||
{
|
||||
return INSTALLDIR . '/avatar/' . $filename;
|
||||
$dir = common_config('avatar', 'dir');
|
||||
|
||||
if ($dir[strlen($dir)-1] != '/') {
|
||||
$dir .= '/';
|
||||
}
|
||||
|
||||
return $dir . $filename;
|
||||
}
|
||||
|
||||
static function url($filename)
|
||||
{
|
||||
return common_path('avatar/'.$filename);
|
||||
$path = common_config('avatar', 'path');
|
||||
|
||||
if ($path[strlen($path)-1] != '/') {
|
||||
$path .= '/';
|
||||
}
|
||||
|
||||
if ($path[0] != '/') {
|
||||
$path = '/'.$path;
|
||||
}
|
||||
|
||||
$server = common_config('avatar', 'server');
|
||||
|
||||
if (empty($server)) {
|
||||
$server = common_config('site', 'server');
|
||||
}
|
||||
|
||||
// XXX: protocol
|
||||
|
||||
return 'http://'.$server.$path.$filename;
|
||||
}
|
||||
|
||||
function displayUrl()
|
||||
{
|
||||
$server = common_config('avatar', 'server');
|
||||
if ($server) {
|
||||
return 'http://'.$server.'/'.$this->filename;
|
||||
return Avatar::url($this->filename);
|
||||
} else {
|
||||
return $this->url;
|
||||
}
|
||||
|
|
155
classes/Design.php
Normal file
155
classes/Design.php
Normal file
|
@ -0,0 +1,155 @@
|
|||
<?php
|
||||
/*
|
||||
* Laconica - the distributed open-source microblogging tool
|
||||
* Copyright (C) 2009, Control Yourself, 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);
|
||||
}
|
||||
|
||||
define('BACKGROUND_ON', 1);
|
||||
define('BACKGROUND_OFF', 2);
|
||||
define('BACKGROUND_TILE', 4);
|
||||
|
||||
/**
|
||||
* Table Definition for design
|
||||
*/
|
||||
|
||||
require_once INSTALLDIR . '/classes/Memcached_DataObject.php';
|
||||
require_once INSTALLDIR . '/lib/webcolor.php';
|
||||
|
||||
class Design extends Memcached_DataObject
|
||||
{
|
||||
###START_AUTOCODE
|
||||
/* the code below is auto generated do not remove the above tag */
|
||||
|
||||
public $__table = 'design'; // table name
|
||||
public $id; // int(4) primary_key not_null
|
||||
public $backgroundcolor; // int(4)
|
||||
public $contentcolor; // int(4)
|
||||
public $sidebarcolor; // int(4)
|
||||
public $textcolor; // int(4)
|
||||
public $linkcolor; // int(4)
|
||||
public $backgroundimage; // varchar(255)
|
||||
public $disposition; // tinyint(1) default_1
|
||||
|
||||
/* Static get */
|
||||
function staticGet($k,$v=NULL) { return Memcached_DataObject::staticGet('Design',$k,$v); }
|
||||
|
||||
/* the code above is auto generated do not remove the tag below */
|
||||
###END_AUTOCODE
|
||||
|
||||
function showCSS($out)
|
||||
{
|
||||
try {
|
||||
|
||||
$bgcolor = new WebColor($this->backgroundcolor);
|
||||
$ccolor = new WebColor($this->contentcolor);
|
||||
$sbcolor = new WebColor($this->sidebarcolor);
|
||||
$tcolor = new WebColor($this->textcolor);
|
||||
$lcolor = new WebColor($this->linkcolor);
|
||||
|
||||
} catch (WebColorException $e) {
|
||||
// This shouldn't happen
|
||||
common_log(LOG_ERR, "Unable to create color for design $id.",
|
||||
__FILE__);
|
||||
}
|
||||
|
||||
$css = 'body { background-color: #' . $bgcolor->hexValue() . ' }' . "\n";
|
||||
$css .= '#content, #site_nav_local_views .current a { background-color: #';
|
||||
$css .= $ccolor->hexValue() . '} '."\n";
|
||||
$css .= '#aside_primary { background-color: #'. $sbcolor->hexValue() . ' }' . "\n";
|
||||
$css .= 'html body { color: #'. $tcolor->hexValue() . ' }'. "\n";
|
||||
$css .= 'a { color: #' . $lcolor->hexValue() . ' }' . "\n";
|
||||
|
||||
if (!empty($this->backgroundimage) &&
|
||||
$this->disposition & BACKGROUND_ON) {
|
||||
|
||||
$repeat = ($this->disposition & BACKGROUND_TILE) ?
|
||||
'background-repeat:repeat;' :
|
||||
'background-repeat:no-repeat;';
|
||||
|
||||
$css .= 'body { background-image:url(' .
|
||||
Design::url($this->backgroundimage) .
|
||||
'); ' . $repeat . ' }' . "\n";
|
||||
}
|
||||
|
||||
$out->element('style', array('type' => 'text/css'), $css);
|
||||
|
||||
}
|
||||
|
||||
static function filename($id, $extension, $extra=null)
|
||||
{
|
||||
return $id . (($extra) ? ('-' . $extra) : '') . $extension;
|
||||
}
|
||||
|
||||
static function path($filename)
|
||||
{
|
||||
$dir = common_config('background', 'dir');
|
||||
|
||||
if ($dir[strlen($dir)-1] != '/') {
|
||||
$dir .= '/';
|
||||
}
|
||||
|
||||
return $dir . $filename;
|
||||
}
|
||||
|
||||
static function url($filename)
|
||||
{
|
||||
$path = common_config('background', 'path');
|
||||
|
||||
if ($path[strlen($path)-1] != '/') {
|
||||
$path .= '/';
|
||||
}
|
||||
|
||||
if ($path[0] != '/') {
|
||||
$path = '/'.$path;
|
||||
}
|
||||
|
||||
$server = common_config('background', 'server');
|
||||
|
||||
if (empty($server)) {
|
||||
$server = common_config('site', 'server');
|
||||
}
|
||||
|
||||
// XXX: protocol
|
||||
|
||||
return 'http://'.$server.$path.$filename;
|
||||
}
|
||||
|
||||
function setDisposition($on, $off, $tile)
|
||||
{
|
||||
if ($on) {
|
||||
$this->disposition |= BACKGROUND_ON;
|
||||
} else {
|
||||
$this->disposition &= ~BACKGROUND_ON;
|
||||
}
|
||||
|
||||
if ($off) {
|
||||
$this->disposition |= BACKGROUND_OFF;
|
||||
} else {
|
||||
$this->disposition &= ~BACKGROUND_OFF;
|
||||
}
|
||||
|
||||
if ($tile) {
|
||||
$this->disposition |= BACKGROUND_TILE;
|
||||
} else {
|
||||
$this->disposition &= ~BACKGROUND_TILE;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
/*
|
||||
* Laconica - a distributed open-source microblogging tool
|
||||
* Copyright (C) 2008, Controlez-Vous, Inc.
|
||||
* Copyright (C) 2008, 2009, Control Yourself, 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
|
||||
|
@ -36,16 +36,18 @@ class File extends Memcached_DataObject
|
|||
/* the code below is auto generated do not remove the above tag */
|
||||
|
||||
public $__table = 'file'; // table name
|
||||
public $id; // int(11) not_null primary_key group_by
|
||||
public $id; // int(4) primary_key not_null
|
||||
public $url; // varchar(255) unique_key
|
||||
public $mimetype; // varchar(50)
|
||||
public $size; // int(11) group_by
|
||||
public $size; // int(4)
|
||||
public $title; // varchar(255)
|
||||
public $date; // int(11) group_by
|
||||
public $protected; // int(1) group_by
|
||||
public $date; // int(4)
|
||||
public $protected; // int(4)
|
||||
public $filename; // varchar(255)
|
||||
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
|
||||
|
||||
/* Static get */
|
||||
function staticGet($k,$v=NULL) { return DB_DataObject::staticGet('File',$k,$v); }
|
||||
function staticGet($k,$v=NULL) { return Memcached_DataObject::staticGet('File',$k,$v); }
|
||||
|
||||
/* the code above is auto generated do not remove the tag below */
|
||||
###END_AUTOCODE
|
||||
|
@ -79,7 +81,6 @@ class File extends Memcached_DataObject
|
|||
&& ('text/html' === substr($redir_data['type'], 0, 9))
|
||||
&& ($oembed_data = File_oembed::_getOembed($given_url))
|
||||
&& isset($oembed_data['json'])) {
|
||||
|
||||
File_oembed::saveNew($oembed_data['json'], $file_id);
|
||||
}
|
||||
return $x;
|
||||
|
@ -98,7 +99,6 @@ class File extends Memcached_DataObject
|
|||
if ($redir_url === $given_url) {
|
||||
$x = File::saveNew($redir_data, $given_url);
|
||||
$file_id = $x->id;
|
||||
|
||||
} else {
|
||||
$x = File::processNew($redir_url, $notice_id);
|
||||
$file_id = $x->id;
|
||||
|
@ -145,5 +145,52 @@ class File extends Memcached_DataObject
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// where should the file go?
|
||||
|
||||
static function filename($profile, $basename, $mimetype)
|
||||
{
|
||||
require_once 'MIME/Type/Extension.php';
|
||||
$mte = new MIME_Type_Extension();
|
||||
$ext = $mte->getExtension($mimetype);
|
||||
$nickname = $profile->nickname;
|
||||
$datestamp = strftime('%Y%m%dT%H%M%S', time());
|
||||
$random = strtolower(common_confirmation_code(32));
|
||||
return "$nickname-$datestamp-$random.$ext";
|
||||
}
|
||||
|
||||
static function path($filename)
|
||||
{
|
||||
$dir = common_config('attachments', 'dir');
|
||||
|
||||
if ($dir[strlen($dir)-1] != '/') {
|
||||
$dir .= '/';
|
||||
}
|
||||
|
||||
return $dir . $filename;
|
||||
}
|
||||
|
||||
static function url($filename)
|
||||
{
|
||||
$path = common_config('attachments', 'path');
|
||||
|
||||
if ($path[strlen($path)-1] != '/') {
|
||||
$path .= '/';
|
||||
}
|
||||
|
||||
if ($path[0] != '/') {
|
||||
$path = '/'.$path;
|
||||
}
|
||||
|
||||
$server = common_config('attachments', 'server');
|
||||
|
||||
if (empty($server)) {
|
||||
$server = common_config('site', 'server');
|
||||
}
|
||||
|
||||
// XXX: protocol
|
||||
|
||||
return 'http://'.$server.$path.$filename;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
/*
|
||||
* Laconica - a distributed open-source microblogging tool
|
||||
* Copyright (C) 2008, Controlez-Vous, Inc.
|
||||
* Copyright (C) 2008, 2009, Control Yourself, 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
|
||||
|
@ -31,29 +31,33 @@ class File_oembed extends Memcached_DataObject
|
|||
/* the code below is auto generated do not remove the above tag */
|
||||
|
||||
public $__table = 'file_oembed'; // table name
|
||||
public $id; // int(11) not_null primary_key group_by
|
||||
public $file_id; // int(11) unique_key group_by
|
||||
public $file_id; // int(4) primary_key not_null
|
||||
public $version; // varchar(20)
|
||||
public $type; // varchar(20)
|
||||
public $provider; // varchar(50)
|
||||
public $provider_url; // varchar(255)
|
||||
public $width; // int(11) group_by
|
||||
public $height; // int(11) group_by
|
||||
public $html; // blob(65535) blob
|
||||
public $width; // int(4)
|
||||
public $height; // int(4)
|
||||
public $html; // text()
|
||||
public $title; // varchar(255)
|
||||
public $author_name; // varchar(50)
|
||||
public $author_url; // varchar(255)
|
||||
public $url; // varchar(255)
|
||||
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
|
||||
|
||||
/* Static get */
|
||||
function staticGet($k,$v=NULL) { return DB_DataObject::staticGet('File_oembed',$k,$v); }
|
||||
function staticGet($k,$v=NULL) { return Memcached_DataObject::staticGet('File_oembed',$k,$v); }
|
||||
|
||||
/* the code above is auto generated do not remove the tag below */
|
||||
###END_AUTOCODE
|
||||
|
||||
function sequenceKey()
|
||||
{
|
||||
return array(false, false, false);
|
||||
}
|
||||
|
||||
function _getOembed($url, $maxwidth = 500, $maxheight = 400, $format = 'json') {
|
||||
$cmd = 'http://oohembed.com/oohembed/?url=' . urlencode($url);
|
||||
$cmd = common_config('oohembed', 'endpoint') . '?url=' . urlencode($url);
|
||||
if (is_int($maxwidth)) $cmd .= "&maxwidth=$maxwidth";
|
||||
if (is_int($maxheight)) $cmd .= "&maxheight=$maxheight";
|
||||
if (is_string($format)) $cmd .= "&format=$format";
|
||||
|
@ -84,4 +88,3 @@ class File_oembed extends Memcached_DataObject
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
/*
|
||||
* Laconica - a distributed open-source microblogging tool
|
||||
* Copyright (C) 2008, Controlez-Vous, Inc.
|
||||
* Copyright (C) 2008, 2009, Control Yourself, 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
|
||||
|
@ -25,7 +25,6 @@ require_once INSTALLDIR.'/classes/File_oembed.php';
|
|||
|
||||
define('USER_AGENT', 'Laconica user agent / file probe');
|
||||
|
||||
|
||||
/**
|
||||
* Table Definition for file_redirection
|
||||
*/
|
||||
|
@ -36,20 +35,18 @@ class File_redirection extends Memcached_DataObject
|
|||
/* the code below is auto generated do not remove the above tag */
|
||||
|
||||
public $__table = 'file_redirection'; // table name
|
||||
public $id; // int(11) not_null primary_key group_by
|
||||
public $url; // varchar(255) unique_key
|
||||
public $file_id; // int(11) group_by
|
||||
public $redirections; // int(11) group_by
|
||||
public $httpcode; // int(11) group_by
|
||||
public $url; // varchar(255) primary_key not_null
|
||||
public $file_id; // int(4)
|
||||
public $redirections; // int(4)
|
||||
public $httpcode; // int(4)
|
||||
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
|
||||
|
||||
/* Static get */
|
||||
function staticGet($k,$v=NULL) { return DB_DataObject::staticGet('File_redirection',$k,$v); }
|
||||
function staticGet($k,$v=NULL) { return Memcached_DataObject::staticGet('File_redirection',$k,$v); }
|
||||
|
||||
/* the code above is auto generated do not remove the tag below */
|
||||
###END_AUTOCODE
|
||||
|
||||
|
||||
|
||||
function _commonCurl($url, $redirs) {
|
||||
$curlh = curl_init();
|
||||
curl_setopt($curlh, CURLOPT_URL, $url);
|
||||
|
@ -86,8 +83,6 @@ class File_redirection extends Memcached_DataObject
|
|||
return $url;
|
||||
}
|
||||
|
||||
|
||||
|
||||
$curlh = File_redirection::_commonCurl($short_url, $redirs);
|
||||
// Don't include body in output
|
||||
curl_setopt($curlh, CURLOPT_NOBODY, true);
|
||||
|
@ -143,62 +138,7 @@ class File_redirection extends Memcached_DataObject
|
|||
}
|
||||
|
||||
function _userMakeShort($long_url, $user) {
|
||||
if (empty($user)) {
|
||||
// common current user does not find a user when called from the XMPP daemon
|
||||
// therefore we'll set one here fix, so that XMPP given URLs may be shortened
|
||||
$user->urlshorteningservice = 'ur1.ca';
|
||||
}
|
||||
$curlh = curl_init();
|
||||
curl_setopt($curlh, CURLOPT_CONNECTTIMEOUT, 20); // # seconds to wait
|
||||
curl_setopt($curlh, CURLOPT_USERAGENT, 'Laconica');
|
||||
curl_setopt($curlh, CURLOPT_RETURNTRANSFER, true);
|
||||
|
||||
switch($user->urlshorteningservice) {
|
||||
case 'ur1.ca':
|
||||
require_once INSTALLDIR.'/lib/Shorturl_api.php';
|
||||
$short_url_service = new LilUrl;
|
||||
$short_url = $short_url_service->shorten($long_url);
|
||||
break;
|
||||
|
||||
case '2tu.us':
|
||||
$short_url_service = new TightUrl;
|
||||
require_once INSTALLDIR.'/lib/Shorturl_api.php';
|
||||
$short_url = $short_url_service->shorten($long_url);
|
||||
break;
|
||||
|
||||
case 'ptiturl.com':
|
||||
require_once INSTALLDIR.'/lib/Shorturl_api.php';
|
||||
$short_url_service = new PtitUrl;
|
||||
$short_url = $short_url_service->shorten($long_url);
|
||||
break;
|
||||
|
||||
case 'bit.ly':
|
||||
curl_setopt($curlh, CURLOPT_URL, 'http://bit.ly/api?method=shorten&long_url='.urlencode($long_url));
|
||||
$short_url = current(json_decode(curl_exec($curlh))->results)->hashUrl;
|
||||
break;
|
||||
|
||||
case 'is.gd':
|
||||
curl_setopt($curlh, CURLOPT_URL, 'http://is.gd/api.php?longurl='.urlencode($long_url));
|
||||
$short_url = curl_exec($curlh);
|
||||
break;
|
||||
case 'snipr.com':
|
||||
curl_setopt($curlh, CURLOPT_URL, 'http://snipr.com/site/snip?r=simple&link='.urlencode($long_url));
|
||||
$short_url = curl_exec($curlh);
|
||||
break;
|
||||
case 'metamark.net':
|
||||
curl_setopt($curlh, CURLOPT_URL, 'http://metamark.net/api/rest/simple?long_url='.urlencode($long_url));
|
||||
$short_url = curl_exec($curlh);
|
||||
break;
|
||||
case 'tinyurl.com':
|
||||
curl_setopt($curlh, CURLOPT_URL, 'http://tinyurl.com/api-create.php?url='.urlencode($long_url));
|
||||
$short_url = curl_exec($curlh);
|
||||
break;
|
||||
default:
|
||||
$short_url = false;
|
||||
}
|
||||
|
||||
curl_close($curlh);
|
||||
|
||||
$short_url = common_shorten_url($long_url);
|
||||
if ($short_url) {
|
||||
$short_url = (string)$short_url;
|
||||
// store it
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
/*
|
||||
* Laconica - a distributed open-source microblogging tool
|
||||
* Copyright (C) 2008, Controlez-Vous, Inc.
|
||||
* Copyright (C) 2008, 2009, Control Yourself, 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
|
||||
|
@ -31,18 +31,23 @@ class File_thumbnail extends Memcached_DataObject
|
|||
/* the code below is auto generated do not remove the above tag */
|
||||
|
||||
public $__table = 'file_thumbnail'; // table name
|
||||
public $id; // int(11) not_null primary_key group_by
|
||||
public $file_id; // int(11) unique_key group_by
|
||||
public $file_id; // int(4) primary_key not_null
|
||||
public $url; // varchar(255) unique_key
|
||||
public $width; // int(11) group_by
|
||||
public $height; // int(11) group_by
|
||||
public $width; // int(4)
|
||||
public $height; // int(4)
|
||||
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
|
||||
|
||||
/* Static get */
|
||||
function staticGet($k,$v=NULL) { return DB_DataObject::staticGet('File_thumbnail',$k,$v); }
|
||||
function staticGet($k,$v=NULL) { return Memcached_DataObject::staticGet('File_thumbnail',$k,$v); }
|
||||
|
||||
/* the code above is auto generated do not remove the tag below */
|
||||
###END_AUTOCODE
|
||||
|
||||
function sequenceKey()
|
||||
{
|
||||
return array(false, false, false);
|
||||
}
|
||||
|
||||
function saveNew($data, $file_id) {
|
||||
$tn = new File_thumbnail;
|
||||
$tn->file_id = $file_id;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
/*
|
||||
* Laconica - a distributed open-source microblogging tool
|
||||
* Copyright (C) 2008, Controlez-Vous, Inc.
|
||||
* Copyright (C) 2008, 2009, Control Yourself, 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
|
||||
|
@ -31,12 +31,12 @@ class File_to_post extends Memcached_DataObject
|
|||
/* the code below is auto generated do not remove the above tag */
|
||||
|
||||
public $__table = 'file_to_post'; // table name
|
||||
public $id; // int(11) not_null primary_key group_by
|
||||
public $file_id; // int(11) multiple_key group_by
|
||||
public $post_id; // int(11) group_by
|
||||
public $file_id; // int(4) primary_key not_null
|
||||
public $post_id; // int(4) primary_key not_null
|
||||
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
|
||||
|
||||
/* Static get */
|
||||
function staticGet($k,$v=NULL) { return DB_DataObject::staticGet('File_to_post',$k,$v); }
|
||||
function staticGet($k,$v=NULL) { return Memcached_DataObject::staticGet('File_to_post',$k,$v); }
|
||||
|
||||
/* the code above is auto generated do not remove the tag below */
|
||||
###END_AUTOCODE
|
||||
|
|
41
classes/Group_alias.php
Normal file
41
classes/Group_alias.php
Normal file
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
/**
|
||||
* Table Definition for group_alias
|
||||
*
|
||||
* Laconica - a distributed open-source microblogging tool
|
||||
* Copyright (C) 2009, Control Yourself, 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.'/classes/Memcached_DataObject.php';
|
||||
|
||||
class Group_alias extends Memcached_DataObject
|
||||
{
|
||||
###START_AUTOCODE
|
||||
/* the code below is auto generated do not remove the above tag */
|
||||
|
||||
public $__table = 'group_alias'; // table name
|
||||
public $alias; // varchar(64) primary_key not_null
|
||||
public $group_id; // int(4) not_null
|
||||
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
|
||||
|
||||
/* Static get */
|
||||
function staticGet($k,$v=NULL) { return DB_DataObject::staticGet('Group_alias',$k,$v); }
|
||||
|
||||
/* the code above is auto generated do not remove the tag below */
|
||||
###END_AUTOCODE
|
||||
}
|
115
classes/Group_block.php
Normal file
115
classes/Group_block.php
Normal file
|
@ -0,0 +1,115 @@
|
|||
<?php
|
||||
/**
|
||||
* Table Definition for group_block
|
||||
*
|
||||
* Laconica - a distributed open-source microblogging tool
|
||||
* Copyright (C) 2008, 2009, Control Yourself, 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.'/classes/Memcached_DataObject.php';
|
||||
|
||||
class Group_block extends Memcached_DataObject
|
||||
{
|
||||
###START_AUTOCODE
|
||||
/* the code below is auto generated do not remove the above tag */
|
||||
|
||||
public $__table = 'group_block'; // table name
|
||||
public $group_id; // int(4) primary_key not_null
|
||||
public $blocked; // int(4) primary_key not_null
|
||||
public $blocker; // int(4) not_null
|
||||
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
|
||||
|
||||
/* Static get */
|
||||
function staticGet($k,$v=NULL) { return DB_DataObject::staticGet('Group_block',$k,$v); }
|
||||
|
||||
/* the code above is auto generated do not remove the tag below */
|
||||
###END_AUTOCODE
|
||||
|
||||
function &pkeyGet($kv)
|
||||
{
|
||||
return Memcached_DataObject::pkeyGet('Group_block', $kv);
|
||||
}
|
||||
|
||||
static function isBlocked($group, $profile)
|
||||
{
|
||||
$block = Group_block::pkeyGet(array('group_id' => $group->id,
|
||||
'blocked' => $profile->id));
|
||||
return !empty($block);
|
||||
}
|
||||
|
||||
static function blockProfile($group, $profile, $blocker)
|
||||
{
|
||||
// Insert the block
|
||||
|
||||
$block = new Group_block();
|
||||
|
||||
$block->query('BEGIN');
|
||||
|
||||
$block->group_id = $group->id;
|
||||
$block->blocked = $profile->id;
|
||||
$block->blocker = $blocker->id;
|
||||
|
||||
$result = $block->insert();
|
||||
|
||||
if (!$result) {
|
||||
common_log_db_error($block, 'INSERT', __FILE__);
|
||||
return null;
|
||||
}
|
||||
|
||||
// Delete membership if any
|
||||
|
||||
$member = new Group_member();
|
||||
|
||||
$member->group_id = $group->id;
|
||||
$member->profile_id = $profile->id;
|
||||
|
||||
if ($member->find(true)) {
|
||||
$result = $member->delete();
|
||||
if (!$result) {
|
||||
common_log_db_error($member, 'DELETE', __FILE__);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// Commit, since both have been done
|
||||
|
||||
$block->query('COMMIT');
|
||||
|
||||
return $block;
|
||||
}
|
||||
|
||||
static function unblockProfile($group, $profile)
|
||||
{
|
||||
$block = Group_block::pkeyGet(array('group_id' => $group->id,
|
||||
'blocked' => $profile->id));
|
||||
|
||||
if (empty($block)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$result = $block->delete();
|
||||
|
||||
if (!$result) {
|
||||
common_log_db_error($block, 'DELETE', __FILE__);
|
||||
return null;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
/*
|
||||
* Laconica - a distributed open-source microblogging tool
|
||||
* Copyright (C) 2008, Controlez-Vous, Inc.
|
||||
* Copyright (C) 2008, 2009, Control Yourself, 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
|
||||
|
@ -193,7 +193,14 @@ class Memcached_DataObject extends DB_DataObject
|
|||
// unable to connect to sphinx' search daemon
|
||||
if (!$connected) {
|
||||
if ('mysql' === common_config('db', 'type')) {
|
||||
$type = common_config('search', 'type');
|
||||
if ($type == 'like') {
|
||||
$search_engine = new MySQLLikeSearch($this, $table);
|
||||
} else if ($type == 'fulltext') {
|
||||
$search_engine = new MySQLSearch($this, $table);
|
||||
} else {
|
||||
throw new ServerException('Unknown search type: ' . $type);
|
||||
}
|
||||
} else {
|
||||
$search_engine = new PGSearch($this, $table);
|
||||
}
|
||||
|
@ -242,6 +249,7 @@ class Memcached_DataObject extends DB_DataObject
|
|||
if (common_config('db', 'type') == 'mysql' &&
|
||||
common_config('db', 'utf8')) {
|
||||
$conn = $DB->connection;
|
||||
if (!empty($conn)) {
|
||||
if ($DB instanceof DB_mysqli) {
|
||||
mysqli_set_charset($conn, 'utf8');
|
||||
} else if ($DB instanceof DB_mysql) {
|
||||
|
@ -249,6 +257,8 @@ class Memcached_DataObject extends DB_DataObject
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
/*
|
||||
* Laconica - a distributed open-source microblogging tool
|
||||
* Copyright (C) 2008, Controlez-Vous, Inc.
|
||||
* Copyright (C) 2008, 2009, Control Yourself, 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
|
||||
|
@ -29,6 +29,11 @@ require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
|
|||
|
||||
define('NOTICE_CACHE_WINDOW', 61);
|
||||
|
||||
define('NOTICE_LOCAL_PUBLIC', 1);
|
||||
define('NOTICE_REMOTE_OMB', 0);
|
||||
define('NOTICE_LOCAL_NONPUBLIC', -1);
|
||||
define('NOTICE_GATEWAY', -2);
|
||||
|
||||
class Notice extends Memcached_DataObject
|
||||
{
|
||||
###START_AUTOCODE
|
||||
|
@ -127,6 +132,11 @@ class Notice extends Memcached_DataObject
|
|||
|
||||
$final = common_shorten_links($content);
|
||||
|
||||
if (mb_strlen($final) > 140) {
|
||||
common_log(LOG_INFO, 'Rejecting notice that is too long.');
|
||||
return _('Problem saving notice. Too long.');
|
||||
}
|
||||
|
||||
if (!$profile) {
|
||||
common_log(LOG_ERR, 'Problem saving notice. Unknown user.');
|
||||
return _('Problem saving notice. Unknown user.');
|
||||
|
@ -212,6 +222,13 @@ class Notice extends Memcached_DataObject
|
|||
|
||||
$notice->addToInboxes();
|
||||
$notice->saveGroups();
|
||||
$notice->saveUrls();
|
||||
$orig2 = clone($notice);
|
||||
$notice->rendered = common_render_content($final, $notice);
|
||||
if (!$notice->update($orig2)) {
|
||||
common_log_db_error($notice, 'UPDATE', __FILE__);
|
||||
return _('Problem saving notice.');
|
||||
}
|
||||
|
||||
$notice->query('COMMIT');
|
||||
|
||||
|
@ -226,6 +243,22 @@ class Notice extends Memcached_DataObject
|
|||
return $notice;
|
||||
}
|
||||
|
||||
/** save all urls in the notice to the db
|
||||
*
|
||||
* follow redirects and save all available file information
|
||||
* (mimetype, date, size, oembed, etc.)
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function saveUrls() {
|
||||
common_replace_urls_callback($this->content, array($this, 'saveUrl'), $this->id);
|
||||
}
|
||||
|
||||
function saveUrl($data) {
|
||||
list($url, $notice_id) = $data;
|
||||
File::processNew($url, $notice_id);
|
||||
}
|
||||
|
||||
static function checkDupes($profile_id, $content) {
|
||||
$profile = Profile::staticGet($profile_id);
|
||||
if (!$profile) {
|
||||
|
@ -346,6 +379,12 @@ class Notice extends Memcached_DataObject
|
|||
if ($tag->find()) {
|
||||
while ($tag->fetch()) {
|
||||
$tag->blowCache($blowLast);
|
||||
$ck = 'profile:notice_ids_tagged:' . $this->profile_id . ':' . $tag->tag;
|
||||
|
||||
$cache->delete($ck);
|
||||
if ($blowLast) {
|
||||
$cache->delete($ck . ';last');
|
||||
}
|
||||
}
|
||||
}
|
||||
$tag->free();
|
||||
|
@ -367,8 +406,10 @@ class Notice extends Memcached_DataObject
|
|||
|
||||
while ($user->fetch()) {
|
||||
$cache->delete(common_cache_key('notice_inbox:by_user:'.$user->id));
|
||||
$cache->delete(common_cache_key('notice_inbox:by_user_own:'.$user->id));
|
||||
if ($blowLast) {
|
||||
$cache->delete(common_cache_key('notice_inbox:by_user:'.$user->id.';last'));
|
||||
$cache->delete(common_cache_key('notice_inbox:by_user_own:'.$user->id.';last'));
|
||||
}
|
||||
}
|
||||
$user->free();
|
||||
|
@ -747,9 +788,9 @@ class Notice extends Memcached_DataObject
|
|||
|
||||
foreach (array_unique($match[1]) as $nickname) {
|
||||
/* XXX: remote groups. */
|
||||
$group = User_group::staticGet('nickname', $nickname);
|
||||
$group = User_group::getForNickname($nickname);
|
||||
|
||||
if (!$group) {
|
||||
if (empty($group)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -788,7 +829,7 @@ class Notice extends Memcached_DataObject
|
|||
$inbox = new Notice_inbox();
|
||||
$UT = common_config('db','type')=='pgsql'?'"user"':'user';
|
||||
$qry = 'INSERT INTO notice_inbox (user_id, notice_id, created, source) ' .
|
||||
"SELECT $UT.id, " . $this->id . ", '" . $this->created . "', 2 " .
|
||||
"SELECT $UT.id, " . $this->id . ", '" . $this->created . "', " . NOTICE_INBOX_SOURCE_GROUP . " " .
|
||||
"FROM $UT JOIN group_member ON $UT.id = group_member.profile_id " .
|
||||
'WHERE group_member.group_id = ' . $group->id . ' ' .
|
||||
'AND NOT EXISTS (SELECT user_id, notice_id ' .
|
||||
|
|
|
@ -25,6 +25,10 @@ require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
|
|||
|
||||
define('INBOX_CACHE_WINDOW', 101);
|
||||
|
||||
define('NOTICE_INBOX_SOURCE_SUB', 1);
|
||||
define('NOTICE_INBOX_SOURCE_GROUP', 2);
|
||||
define('NOTICE_INBOX_SOURCE_GATEWAY', -1);
|
||||
|
||||
class Notice_inbox extends Memcached_DataObject
|
||||
{
|
||||
###START_AUTOCODE
|
||||
|
@ -43,20 +47,25 @@ class Notice_inbox extends Memcached_DataObject
|
|||
/* the code above is auto generated do not remove the tag below */
|
||||
###END_AUTOCODE
|
||||
|
||||
function stream($user_id, $offset, $limit, $since_id, $max_id, $since)
|
||||
function stream($user_id, $offset, $limit, $since_id, $max_id, $since, $own=false)
|
||||
{
|
||||
return Notice::stream(array('Notice_inbox', '_streamDirect'),
|
||||
array($user_id),
|
||||
'notice_inbox:by_user:'.$user_id,
|
||||
array($user_id, $own),
|
||||
($own) ? 'notice_inbox:by_user:'.$user_id :
|
||||
'notice_inbox:by_user_own:'.$user_id,
|
||||
$offset, $limit, $since_id, $max_id, $since);
|
||||
}
|
||||
|
||||
function _streamDirect($user_id, $offset, $limit, $since_id, $max_id, $since)
|
||||
function _streamDirect($user_id, $own, $offset, $limit, $since_id, $max_id, $since)
|
||||
{
|
||||
$inbox = new Notice_inbox();
|
||||
|
||||
$inbox->user_id = $user_id;
|
||||
|
||||
if (!$own) {
|
||||
$inbox->whereAdd('source != ' . NOTICE_INBOX_SOURCE_GATEWAY);
|
||||
}
|
||||
|
||||
if ($since_id != 0) {
|
||||
$inbox->whereAdd('notice_id > ' . $since_id);
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user