forked from GNUsocial/gnu-social
Merge branch '0.9.x' of git@gitorious.org:statusnet/mainline into 0.9.x
This commit is contained in:
commit
f6d67781a1
@ -160,6 +160,7 @@ class ApiAction extends Action
|
|||||||
|
|
||||||
static $bareauth = array('statuses/user_timeline',
|
static $bareauth = array('statuses/user_timeline',
|
||||||
'statuses/friends_timeline',
|
'statuses/friends_timeline',
|
||||||
|
'statuses/home_timeline',
|
||||||
'statuses/friends',
|
'statuses/friends',
|
||||||
'statuses/replies',
|
'statuses/replies',
|
||||||
'statuses/mentions',
|
'statuses/mentions',
|
||||||
|
@ -32,15 +32,45 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
require_once INSTALLDIR.'/lib/deleteaction.php';
|
class DeletenoticeAction extends Action
|
||||||
|
|
||||||
class DeletenoticeAction extends DeleteAction
|
|
||||||
{
|
{
|
||||||
var $error = null;
|
var $error = null;
|
||||||
|
var $user = null;
|
||||||
|
var $notice = null;
|
||||||
|
var $profile = null;
|
||||||
|
var $user_profile = null;
|
||||||
|
|
||||||
|
function prepare($args)
|
||||||
|
{
|
||||||
|
parent::prepare($args);
|
||||||
|
|
||||||
|
$this->user = common_current_user();
|
||||||
|
$notice_id = $this->trimmed('notice');
|
||||||
|
$this->notice = Notice::staticGet($notice_id);
|
||||||
|
|
||||||
|
if (!$this->notice) {
|
||||||
|
common_user_error(_('No such notice.'));
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->profile = $this->notice->getProfile();
|
||||||
|
$this->user_profile = $this->user->getProfile();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
function handle($args)
|
function handle($args)
|
||||||
{
|
{
|
||||||
parent::handle($args);
|
parent::handle($args);
|
||||||
|
|
||||||
|
if (!common_logged_in()) {
|
||||||
|
common_user_error(_('Not logged in.'));
|
||||||
|
exit;
|
||||||
|
} else if ($this->notice->profile_id != $this->user_profile->id &&
|
||||||
|
!$this->user->hasRight(Right::deleteOthersNotice)) {
|
||||||
|
common_user_error(_('Can\'t delete this notice.'));
|
||||||
|
exit;
|
||||||
|
}
|
||||||
// XXX: Ajax!
|
// XXX: Ajax!
|
||||||
|
|
||||||
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||||
|
@ -94,7 +94,13 @@ class File extends Memcached_DataObject
|
|||||||
$file_redir = File_redirection::staticGet('url', $given_url);
|
$file_redir = File_redirection::staticGet('url', $given_url);
|
||||||
if (empty($file_redir)) {
|
if (empty($file_redir)) {
|
||||||
$redir_data = File_redirection::where($given_url);
|
$redir_data = File_redirection::where($given_url);
|
||||||
|
if (is_array($redir_data)) {
|
||||||
$redir_url = $redir_data['url'];
|
$redir_url = $redir_data['url'];
|
||||||
|
} elseif (is_string($redir_data)) {
|
||||||
|
$redir_url = $redir_data;
|
||||||
|
} else {
|
||||||
|
throw new ServerException("Can't process url '$given_url'");
|
||||||
|
}
|
||||||
// TODO: max field length
|
// TODO: max field length
|
||||||
if ($redir_url === $given_url || strlen($redir_url) > 255) {
|
if ($redir_url === $given_url || strlen($redir_url) > 255) {
|
||||||
$x = File::saveNew($redir_data, $given_url);
|
$x = File::saveNew($redir_data, $given_url);
|
||||||
|
@ -79,6 +79,9 @@ class File_redirection extends Memcached_DataObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(strpos($short_url,'://') === false){
|
||||||
|
return $short_url;
|
||||||
|
}
|
||||||
$curlh = File_redirection::_commonCurl($short_url, $redirs);
|
$curlh = File_redirection::_commonCurl($short_url, $redirs);
|
||||||
// Don't include body in output
|
// Don't include body in output
|
||||||
curl_setopt($curlh, CURLOPT_NOBODY, true);
|
curl_setopt($curlh, CURLOPT_NOBODY, true);
|
||||||
|
@ -711,4 +711,33 @@ class User extends Memcached_DataObject
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Does this user have the right to do X?
|
||||||
|
*
|
||||||
|
* With our role-based authorization, this is merely a lookup for whether the user
|
||||||
|
* has a particular role. The implementation currently uses a switch statement
|
||||||
|
* to determine if the user has the pre-defined role to exercise the right. Future
|
||||||
|
* implementations may allow per-site roles, and different mappings of roles to rights.
|
||||||
|
*
|
||||||
|
* @param $right string Name of the right, usually a constant in class Right
|
||||||
|
* @return boolean whether the user has the right in question
|
||||||
|
*/
|
||||||
|
|
||||||
|
function hasRight($right)
|
||||||
|
{
|
||||||
|
$result = false;
|
||||||
|
if (Event::handle('UserRightsCheck', array($this, $right, &$result))) {
|
||||||
|
switch ($right)
|
||||||
|
{
|
||||||
|
case Right::deleteOthersNotice:
|
||||||
|
$result = $this->hasRole('moderator');
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$result = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
212
lib/common.php
212
lib/common.php
@ -53,6 +53,7 @@ require_once('DB/DataObject/Cast.php'); # for dates
|
|||||||
if (!function_exists('gettext')) {
|
if (!function_exists('gettext')) {
|
||||||
require_once("php-gettext/gettext.inc");
|
require_once("php-gettext/gettext.inc");
|
||||||
}
|
}
|
||||||
|
|
||||||
require_once(INSTALLDIR.'/lib/language.php');
|
require_once(INSTALLDIR.'/lib/language.php');
|
||||||
|
|
||||||
// This gets included before the config file, so that admin code and plugins
|
// This gets included before the config file, so that admin code and plugins
|
||||||
@ -93,214 +94,17 @@ if (isset($path)) {
|
|||||||
null;
|
null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// default configuration, overwritten in config.php
|
require_once(INSTALLDIR.'/lib/default.php');
|
||||||
|
|
||||||
$config =
|
// Set config values initially to default values
|
||||||
array('site' =>
|
|
||||||
array('name' => 'Just another StatusNet microblog',
|
$config = $default;
|
||||||
'server' => $_server,
|
|
||||||
'theme' => 'default',
|
// default configuration, overwritten in config.php
|
||||||
'path' => $_path,
|
|
||||||
'logfile' => null,
|
|
||||||
'logo' => null,
|
|
||||||
'logdebug' => false,
|
|
||||||
'fancy' => false,
|
|
||||||
'locale_path' => INSTALLDIR.'/locale',
|
|
||||||
'language' => 'en_US',
|
|
||||||
'languages' => get_all_languages(),
|
|
||||||
'email' =>
|
|
||||||
array_key_exists('SERVER_ADMIN', $_SERVER) ? $_SERVER['SERVER_ADMIN'] : null,
|
|
||||||
'broughtby' => null,
|
|
||||||
'timezone' => 'UTC',
|
|
||||||
'broughtbyurl' => null,
|
|
||||||
'closed' => false,
|
|
||||||
'inviteonly' => false,
|
|
||||||
'private' => false,
|
|
||||||
'ssl' => 'never',
|
|
||||||
'sslserver' => null,
|
|
||||||
'shorturllength' => 30,
|
|
||||||
'dupelimit' => 60, # default for same person saying the same thing
|
|
||||||
'textlimit' => 140,
|
|
||||||
),
|
|
||||||
'syslog' =>
|
|
||||||
array('appname' => 'statusnet', # for syslog
|
|
||||||
'priority' => 'debug', # XXX: currently ignored
|
|
||||||
'facility' => LOG_USER),
|
|
||||||
'queue' =>
|
|
||||||
array('enabled' => false,
|
|
||||||
'subsystem' => 'db', # default to database, or 'stomp'
|
|
||||||
'stomp_server' => null,
|
|
||||||
'queue_basename' => 'statusnet',
|
|
||||||
'stomp_username' => null,
|
|
||||||
'stomp_password' => null,
|
|
||||||
),
|
|
||||||
'license' =>
|
|
||||||
array('url' => 'http://creativecommons.org/licenses/by/3.0/',
|
|
||||||
'title' => 'Creative Commons Attribution 3.0',
|
|
||||||
'image' => 'http://i.creativecommons.org/l/by/3.0/80x15.png'),
|
|
||||||
'mail' =>
|
|
||||||
array('backend' => 'mail',
|
|
||||||
'params' => null),
|
|
||||||
'nickname' =>
|
|
||||||
array('blacklist' => array(),
|
|
||||||
'featured' => array()),
|
|
||||||
'profile' =>
|
|
||||||
array('banned' => array(),
|
|
||||||
'biolimit' => null),
|
|
||||||
'avatar' =>
|
|
||||||
array('server' => null,
|
|
||||||
'dir' => INSTALLDIR . '/avatar/',
|
|
||||||
'path' => $_path . '/avatar/'),
|
|
||||||
'background' =>
|
|
||||||
array('server' => null,
|
|
||||||
'dir' => INSTALLDIR . '/background/',
|
|
||||||
'path' => $_path . '/background/'),
|
|
||||||
'public' =>
|
|
||||||
array('localonly' => true,
|
|
||||||
'blacklist' => array(),
|
|
||||||
'autosource' => array()),
|
|
||||||
'theme' =>
|
|
||||||
array('server' => null,
|
|
||||||
'dir' => null,
|
|
||||||
'path'=> null),
|
|
||||||
'throttle' =>
|
|
||||||
array('enabled' => false, // whether to throttle edits; false by default
|
|
||||||
'count' => 20, // number of allowed messages in timespan
|
|
||||||
'timespan' => 600), // timespan for throttling
|
|
||||||
'xmpp' =>
|
|
||||||
array('enabled' => false,
|
|
||||||
'server' => 'INVALID SERVER',
|
|
||||||
'port' => 5222,
|
|
||||||
'user' => 'update',
|
|
||||||
'encryption' => true,
|
|
||||||
'resource' => 'uniquename',
|
|
||||||
'password' => 'blahblahblah',
|
|
||||||
'host' => null, # only set if != server
|
|
||||||
'debug' => false, # print extra debug info
|
|
||||||
'public' => array()), # JIDs of users who want to receive the public stream
|
|
||||||
'invite' =>
|
|
||||||
array('enabled' => true),
|
|
||||||
'sphinx' =>
|
|
||||||
array('enabled' => false,
|
|
||||||
'server' => 'localhost',
|
|
||||||
'port' => 3312),
|
|
||||||
'tag' =>
|
|
||||||
array('dropoff' => 864000.0),
|
|
||||||
'popular' =>
|
|
||||||
array('dropoff' => 864000.0),
|
|
||||||
'daemon' =>
|
|
||||||
array('piddir' => '/var/run',
|
|
||||||
'user' => false,
|
|
||||||
'group' => false),
|
|
||||||
'emailpost' =>
|
|
||||||
array('enabled' => true),
|
|
||||||
'sms' =>
|
|
||||||
array('enabled' => true),
|
|
||||||
'twitter' =>
|
|
||||||
array('enabled' => true),
|
|
||||||
'twitterbridge' =>
|
|
||||||
array('enabled' => false),
|
|
||||||
'integration' =>
|
|
||||||
array('source' => 'StatusNet', # source attribute for Twitter
|
|
||||||
'taguri' => $_server.',2009'), # base for tag URIs
|
|
||||||
'twitter' =>
|
|
||||||
array('consumer_key' => null,
|
|
||||||
'consumer_secret' => null),
|
|
||||||
'memcached' =>
|
|
||||||
array('enabled' => false,
|
|
||||||
'server' => 'localhost',
|
|
||||||
'base' => null,
|
|
||||||
'port' => 11211),
|
|
||||||
'ping' =>
|
|
||||||
array('notify' => array()),
|
|
||||||
'inboxes' =>
|
|
||||||
array('enabled' => true), # on by default for new sites
|
|
||||||
'newuser' =>
|
|
||||||
array('default' => null,
|
|
||||||
'welcome' => null),
|
|
||||||
'snapshot' =>
|
|
||||||
array('run' => 'web',
|
|
||||||
'frequency' => 10000,
|
|
||||||
'reporturl' => 'http://status.net/stats/report'),
|
|
||||||
'attachments' =>
|
|
||||||
array('server' => null,
|
|
||||||
'dir' => INSTALLDIR . '/file/',
|
|
||||||
'path' => $_path . '/file/',
|
|
||||||
'supported' => array('image/png',
|
|
||||||
'image/jpeg',
|
|
||||||
'image/gif',
|
|
||||||
'image/svg+xml',
|
|
||||||
'audio/mpeg',
|
|
||||||
'audio/x-speex',
|
|
||||||
'application/ogg',
|
|
||||||
'application/pdf',
|
|
||||||
'application/vnd.oasis.opendocument.text',
|
|
||||||
'application/vnd.oasis.opendocument.text-template',
|
|
||||||
'application/vnd.oasis.opendocument.graphics',
|
|
||||||
'application/vnd.oasis.opendocument.graphics-template',
|
|
||||||
'application/vnd.oasis.opendocument.presentation',
|
|
||||||
'application/vnd.oasis.opendocument.presentation-template',
|
|
||||||
'application/vnd.oasis.opendocument.spreadsheet',
|
|
||||||
'application/vnd.oasis.opendocument.spreadsheet-template',
|
|
||||||
'application/vnd.oasis.opendocument.chart',
|
|
||||||
'application/vnd.oasis.opendocument.chart-template',
|
|
||||||
'application/vnd.oasis.opendocument.image',
|
|
||||||
'application/vnd.oasis.opendocument.image-template',
|
|
||||||
'application/vnd.oasis.opendocument.formula',
|
|
||||||
'application/vnd.oasis.opendocument.formula-template',
|
|
||||||
'application/vnd.oasis.opendocument.text-master',
|
|
||||||
'application/vnd.oasis.opendocument.text-web',
|
|
||||||
'application/x-zip',
|
|
||||||
'application/zip',
|
|
||||||
'text/plain',
|
|
||||||
'video/mpeg',
|
|
||||||
'video/mp4',
|
|
||||||
'video/quicktime',
|
|
||||||
'video/mpeg'),
|
|
||||||
'file_quota' => 5000000,
|
|
||||||
'user_quota' => 50000000,
|
|
||||||
'monthly_quota' => 15000000,
|
|
||||||
'uploads' => true,
|
|
||||||
'filecommand' => '/usr/bin/file',
|
|
||||||
),
|
|
||||||
'group' =>
|
|
||||||
array('maxaliases' => 3,
|
|
||||||
'desclimit' => null),
|
|
||||||
'oohembed' => array('endpoint' => 'http://oohembed.com/oohembed/'),
|
|
||||||
'search' =>
|
|
||||||
array('type' => 'fulltext'),
|
|
||||||
'sessions' =>
|
|
||||||
array('handle' => false, // whether to handle sessions ourselves
|
|
||||||
'debug' => false), // debugging output for sessions
|
|
||||||
'design' =>
|
|
||||||
array('backgroundcolor' => null, // null -> 'use theme default'
|
|
||||||
'contentcolor' => null,
|
|
||||||
'sidebarcolor' => null,
|
|
||||||
'textcolor' => null,
|
|
||||||
'linkcolor' => null,
|
|
||||||
'backgroundimage' => null,
|
|
||||||
'disposition' => null),
|
|
||||||
'notice' =>
|
|
||||||
array('contentlimit' => null),
|
|
||||||
'message' =>
|
|
||||||
array('contentlimit' => null),
|
|
||||||
'http' =>
|
|
||||||
array('client' => 'curl'), // XXX: should this be the default?
|
|
||||||
);
|
|
||||||
|
|
||||||
$config['db'] = &PEAR::getStaticProperty('DB_DataObject','options');
|
$config['db'] = &PEAR::getStaticProperty('DB_DataObject','options');
|
||||||
|
|
||||||
$config['db'] =
|
$config['db'] = $default['db'];
|
||||||
array('database' => 'YOU HAVE TO SET THIS IN config.php',
|
|
||||||
'schema_location' => INSTALLDIR . '/classes',
|
|
||||||
'class_location' => INSTALLDIR . '/classes',
|
|
||||||
'require_prefix' => 'classes/',
|
|
||||||
'class_prefix' => '',
|
|
||||||
'mirror' => null,
|
|
||||||
'utf8' => true,
|
|
||||||
'db_driver' => 'DB', # XXX: JanRain libs only work with DB
|
|
||||||
'quote_identifiers' => false,
|
|
||||||
'type' => 'mysql' );
|
|
||||||
|
|
||||||
// Backward compatibility
|
// Backward compatibility
|
||||||
|
|
||||||
|
232
lib/default.php
Normal file
232
lib/default.php
Normal file
@ -0,0 +1,232 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* StatusNet, the distributed open-source microblogging tool
|
||||||
|
*
|
||||||
|
* Default settings for core configuration
|
||||||
|
*
|
||||||
|
* 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 Config
|
||||||
|
* @package StatusNet
|
||||||
|
* @author Evan Prodromou <evan@status.net>
|
||||||
|
* @copyright 2008-9 StatusNet, Inc.
|
||||||
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||||
|
* @link http://status.net/
|
||||||
|
*/
|
||||||
|
|
||||||
|
$default =
|
||||||
|
array('site' =>
|
||||||
|
array('name' => 'Just another StatusNet microblog',
|
||||||
|
'server' => $_server,
|
||||||
|
'theme' => 'default',
|
||||||
|
'path' => $_path,
|
||||||
|
'logfile' => null,
|
||||||
|
'logo' => null,
|
||||||
|
'logdebug' => false,
|
||||||
|
'fancy' => false,
|
||||||
|
'locale_path' => INSTALLDIR.'/locale',
|
||||||
|
'language' => 'en_US',
|
||||||
|
'languages' => get_all_languages(),
|
||||||
|
'email' =>
|
||||||
|
array_key_exists('SERVER_ADMIN', $_SERVER) ? $_SERVER['SERVER_ADMIN'] : null,
|
||||||
|
'broughtby' => null,
|
||||||
|
'timezone' => 'UTC',
|
||||||
|
'broughtbyurl' => null,
|
||||||
|
'closed' => false,
|
||||||
|
'inviteonly' => false,
|
||||||
|
'private' => false,
|
||||||
|
'ssl' => 'never',
|
||||||
|
'sslserver' => null,
|
||||||
|
'shorturllength' => 30,
|
||||||
|
'dupelimit' => 60, # default for same person saying the same thing
|
||||||
|
'textlimit' => 140,
|
||||||
|
),
|
||||||
|
'db' =>
|
||||||
|
array('database' => 'YOU HAVE TO SET THIS IN config.php',
|
||||||
|
'schema_location' => INSTALLDIR . '/classes',
|
||||||
|
'class_location' => INSTALLDIR . '/classes',
|
||||||
|
'require_prefix' => 'classes/',
|
||||||
|
'class_prefix' => '',
|
||||||
|
'mirror' => null,
|
||||||
|
'utf8' => true,
|
||||||
|
'db_driver' => 'DB', # XXX: JanRain libs only work with DB
|
||||||
|
'quote_identifiers' => false,
|
||||||
|
'type' => 'mysql' ),
|
||||||
|
'syslog' =>
|
||||||
|
array('appname' => 'statusnet', # for syslog
|
||||||
|
'priority' => 'debug', # XXX: currently ignored
|
||||||
|
'facility' => LOG_USER),
|
||||||
|
'queue' =>
|
||||||
|
array('enabled' => false,
|
||||||
|
'subsystem' => 'db', # default to database, or 'stomp'
|
||||||
|
'stomp_server' => null,
|
||||||
|
'queue_basename' => 'statusnet',
|
||||||
|
'stomp_username' => null,
|
||||||
|
'stomp_password' => null,
|
||||||
|
),
|
||||||
|
'license' =>
|
||||||
|
array('url' => 'http://creativecommons.org/licenses/by/3.0/',
|
||||||
|
'title' => 'Creative Commons Attribution 3.0',
|
||||||
|
'image' => 'http://i.creativecommons.org/l/by/3.0/80x15.png'),
|
||||||
|
'mail' =>
|
||||||
|
array('backend' => 'mail',
|
||||||
|
'params' => null),
|
||||||
|
'nickname' =>
|
||||||
|
array('blacklist' => array(),
|
||||||
|
'featured' => array()),
|
||||||
|
'profile' =>
|
||||||
|
array('banned' => array(),
|
||||||
|
'biolimit' => null),
|
||||||
|
'avatar' =>
|
||||||
|
array('server' => null,
|
||||||
|
'dir' => INSTALLDIR . '/avatar/',
|
||||||
|
'path' => $_path . '/avatar/'),
|
||||||
|
'background' =>
|
||||||
|
array('server' => null,
|
||||||
|
'dir' => INSTALLDIR . '/background/',
|
||||||
|
'path' => $_path . '/background/'),
|
||||||
|
'public' =>
|
||||||
|
array('localonly' => true,
|
||||||
|
'blacklist' => array(),
|
||||||
|
'autosource' => array()),
|
||||||
|
'theme' =>
|
||||||
|
array('server' => null,
|
||||||
|
'dir' => null,
|
||||||
|
'path'=> null),
|
||||||
|
'throttle' =>
|
||||||
|
array('enabled' => false, // whether to throttle edits; false by default
|
||||||
|
'count' => 20, // number of allowed messages in timespan
|
||||||
|
'timespan' => 600), // timespan for throttling
|
||||||
|
'xmpp' =>
|
||||||
|
array('enabled' => false,
|
||||||
|
'server' => 'INVALID SERVER',
|
||||||
|
'port' => 5222,
|
||||||
|
'user' => 'update',
|
||||||
|
'encryption' => true,
|
||||||
|
'resource' => 'uniquename',
|
||||||
|
'password' => 'blahblahblah',
|
||||||
|
'host' => null, # only set if != server
|
||||||
|
'debug' => false, # print extra debug info
|
||||||
|
'public' => array()), # JIDs of users who want to receive the public stream
|
||||||
|
'invite' =>
|
||||||
|
array('enabled' => true),
|
||||||
|
'sphinx' =>
|
||||||
|
array('enabled' => false,
|
||||||
|
'server' => 'localhost',
|
||||||
|
'port' => 3312),
|
||||||
|
'tag' =>
|
||||||
|
array('dropoff' => 864000.0),
|
||||||
|
'popular' =>
|
||||||
|
array('dropoff' => 864000.0),
|
||||||
|
'daemon' =>
|
||||||
|
array('piddir' => '/var/run',
|
||||||
|
'user' => false,
|
||||||
|
'group' => false),
|
||||||
|
'emailpost' =>
|
||||||
|
array('enabled' => true),
|
||||||
|
'sms' =>
|
||||||
|
array('enabled' => true),
|
||||||
|
'twitter' =>
|
||||||
|
array('enabled' => true),
|
||||||
|
'twitterbridge' =>
|
||||||
|
array('enabled' => false),
|
||||||
|
'integration' =>
|
||||||
|
array('source' => 'StatusNet', # source attribute for Twitter
|
||||||
|
'taguri' => $_server.',2009'), # base for tag URIs
|
||||||
|
'twitter' =>
|
||||||
|
array('consumer_key' => null,
|
||||||
|
'consumer_secret' => null),
|
||||||
|
'memcached' =>
|
||||||
|
array('enabled' => false,
|
||||||
|
'server' => 'localhost',
|
||||||
|
'base' => null,
|
||||||
|
'port' => 11211),
|
||||||
|
'ping' =>
|
||||||
|
array('notify' => array()),
|
||||||
|
'inboxes' =>
|
||||||
|
array('enabled' => true), # on by default for new sites
|
||||||
|
'newuser' =>
|
||||||
|
array('default' => null,
|
||||||
|
'welcome' => null),
|
||||||
|
'snapshot' =>
|
||||||
|
array('run' => 'web',
|
||||||
|
'frequency' => 10000,
|
||||||
|
'reporturl' => 'http://status.net/stats/report'),
|
||||||
|
'attachments' =>
|
||||||
|
array('server' => null,
|
||||||
|
'dir' => INSTALLDIR . '/file/',
|
||||||
|
'path' => $_path . '/file/',
|
||||||
|
'supported' => array('image/png',
|
||||||
|
'image/jpeg',
|
||||||
|
'image/gif',
|
||||||
|
'image/svg+xml',
|
||||||
|
'audio/mpeg',
|
||||||
|
'audio/x-speex',
|
||||||
|
'application/ogg',
|
||||||
|
'application/pdf',
|
||||||
|
'application/vnd.oasis.opendocument.text',
|
||||||
|
'application/vnd.oasis.opendocument.text-template',
|
||||||
|
'application/vnd.oasis.opendocument.graphics',
|
||||||
|
'application/vnd.oasis.opendocument.graphics-template',
|
||||||
|
'application/vnd.oasis.opendocument.presentation',
|
||||||
|
'application/vnd.oasis.opendocument.presentation-template',
|
||||||
|
'application/vnd.oasis.opendocument.spreadsheet',
|
||||||
|
'application/vnd.oasis.opendocument.spreadsheet-template',
|
||||||
|
'application/vnd.oasis.opendocument.chart',
|
||||||
|
'application/vnd.oasis.opendocument.chart-template',
|
||||||
|
'application/vnd.oasis.opendocument.image',
|
||||||
|
'application/vnd.oasis.opendocument.image-template',
|
||||||
|
'application/vnd.oasis.opendocument.formula',
|
||||||
|
'application/vnd.oasis.opendocument.formula-template',
|
||||||
|
'application/vnd.oasis.opendocument.text-master',
|
||||||
|
'application/vnd.oasis.opendocument.text-web',
|
||||||
|
'application/x-zip',
|
||||||
|
'application/zip',
|
||||||
|
'text/plain',
|
||||||
|
'video/mpeg',
|
||||||
|
'video/mp4',
|
||||||
|
'video/quicktime',
|
||||||
|
'video/mpeg'),
|
||||||
|
'file_quota' => 5000000,
|
||||||
|
'user_quota' => 50000000,
|
||||||
|
'monthly_quota' => 15000000,
|
||||||
|
'uploads' => true,
|
||||||
|
'filecommand' => '/usr/bin/file',
|
||||||
|
),
|
||||||
|
'group' =>
|
||||||
|
array('maxaliases' => 3,
|
||||||
|
'desclimit' => null),
|
||||||
|
'oohembed' => array('endpoint' => 'http://oohembed.com/oohembed/'),
|
||||||
|
'search' =>
|
||||||
|
array('type' => 'fulltext'),
|
||||||
|
'sessions' =>
|
||||||
|
array('handle' => false, // whether to handle sessions ourselves
|
||||||
|
'debug' => false), // debugging output for sessions
|
||||||
|
'design' =>
|
||||||
|
array('backgroundcolor' => null, // null -> 'use theme default'
|
||||||
|
'contentcolor' => null,
|
||||||
|
'sidebarcolor' => null,
|
||||||
|
'textcolor' => null,
|
||||||
|
'linkcolor' => null,
|
||||||
|
'backgroundimage' => null,
|
||||||
|
'disposition' => null),
|
||||||
|
'notice' =>
|
||||||
|
array('contentlimit' => null),
|
||||||
|
'message' =>
|
||||||
|
array('contentlimit' => null),
|
||||||
|
'http' =>
|
||||||
|
array('client' => 'curl'), // XXX: should this be the default?
|
||||||
|
);
|
@ -1,74 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* StatusNet, the distributed open-source microblogging tool
|
|
||||||
*
|
|
||||||
* Base class for deleting things
|
|
||||||
*
|
|
||||||
* 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 Personal
|
|
||||||
* @package StatusNet
|
|
||||||
* @author Evan Prodromou <evan@status.net>
|
|
||||||
* @author Sarven Capadisli <csarven@status.net>
|
|
||||||
* @copyright 2008 StatusNet, Inc.
|
|
||||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
|
||||||
* @link http://status.net/
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (!defined('STATUSNET') && !defined('LACONICA')) {
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
class DeleteAction extends Action
|
|
||||||
{
|
|
||||||
var $user = null;
|
|
||||||
var $notice = null;
|
|
||||||
var $profile = null;
|
|
||||||
var $user_profile = null;
|
|
||||||
|
|
||||||
function prepare($args)
|
|
||||||
{
|
|
||||||
parent::prepare($args);
|
|
||||||
|
|
||||||
$this->user = common_current_user();
|
|
||||||
$notice_id = $this->trimmed('notice');
|
|
||||||
$this->notice = Notice::staticGet($notice_id);
|
|
||||||
|
|
||||||
if (!$this->notice) {
|
|
||||||
common_user_error(_('No such notice.'));
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->profile = $this->notice->getProfile();
|
|
||||||
$this->user_profile = $this->user->getProfile();
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
function handle($args)
|
|
||||||
{
|
|
||||||
parent::handle($args);
|
|
||||||
|
|
||||||
if (!common_logged_in()) {
|
|
||||||
common_user_error(_('Not logged in.'));
|
|
||||||
exit;
|
|
||||||
} else if ($this->notice->profile_id != $this->user_profile->id) {
|
|
||||||
common_user_error(_('Can\'t delete this notice.'));
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -472,7 +472,10 @@ class NoticeListItem extends Widget
|
|||||||
function showDeleteLink()
|
function showDeleteLink()
|
||||||
{
|
{
|
||||||
$user = common_current_user();
|
$user = common_current_user();
|
||||||
if ($user && $this->notice->profile_id == $user->id) {
|
|
||||||
|
if (!empty($user) &&
|
||||||
|
($this->notice->profile_id == $user->id || $user->hasRight(Right::deleteOthersNotice))) {
|
||||||
|
|
||||||
$deleteurl = common_local_url('deletenotice',
|
$deleteurl = common_local_url('deletenotice',
|
||||||
array('notice' => $this->notice->id));
|
array('notice' => $this->notice->id));
|
||||||
$this->out->element('a', array('href' => $deleteurl,
|
$this->out->element('a', array('href' => $deleteurl,
|
||||||
|
50
lib/right.php
Normal file
50
lib/right.php
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* StatusNet, the distributed open-source microblogging tool
|
||||||
|
*
|
||||||
|
* Class for user rights
|
||||||
|
*
|
||||||
|
* 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 Authorization
|
||||||
|
* @package StatusNet
|
||||||
|
* @author Evan Prodromou <evan@status.net>
|
||||||
|
* @copyright 2009 StatusNet, Inc.
|
||||||
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||||
|
* @link http://status.net/
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (!defined('STATUSNET') && !defined('LACONICA')) {
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* class for rights
|
||||||
|
*
|
||||||
|
* Mostly for holding the rights constants
|
||||||
|
*
|
||||||
|
* @category Authorization
|
||||||
|
* @package StatusNet
|
||||||
|
* @author Evan Prodromou <evan@status.net>
|
||||||
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||||
|
* @link http://status.net/
|
||||||
|
*/
|
||||||
|
|
||||||
|
class Right
|
||||||
|
{
|
||||||
|
const deleteOthersNotice = 'deleteothersnotice';
|
||||||
|
}
|
||||||
|
|
@ -522,12 +522,13 @@ function common_linkify($url) {
|
|||||||
|
|
||||||
if(strpos($url, '@') !== false && strpos($url, ':') === false) {
|
if(strpos($url, '@') !== false && strpos($url, ':') === false) {
|
||||||
//url is an email address without the mailto: protocol
|
//url is an email address without the mailto: protocol
|
||||||
return XMLStringer::estring('a', array('href' => "mailto:$url", 'rel' => 'external'), $url);
|
$canon = "mailto:$url";
|
||||||
}
|
$longurl = "mailto:$url";
|
||||||
|
}else{
|
||||||
|
|
||||||
$canon = File_redirection::_canonUrl($url);
|
$canon = File_redirection::_canonUrl($url);
|
||||||
|
|
||||||
$longurl_data = File_redirection::where($url);
|
$longurl_data = File_redirection::where($canon);
|
||||||
if (is_array($longurl_data)) {
|
if (is_array($longurl_data)) {
|
||||||
$longurl = $longurl_data['url'];
|
$longurl = $longurl_data['url'];
|
||||||
} elseif (is_string($longurl_data)) {
|
} elseif (is_string($longurl_data)) {
|
||||||
@ -535,7 +536,7 @@ function common_linkify($url) {
|
|||||||
} else {
|
} else {
|
||||||
throw new ServerException("Can't linkify url '$url'");
|
throw new ServerException("Can't linkify url '$url'");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
$attrs = array('href' => $canon, 'title' => $longurl, 'rel' => 'external');
|
$attrs = array('href' => $canon, 'title' => $longurl, 'rel' => 'external');
|
||||||
|
|
||||||
$is_attachment = false;
|
$is_attachment = false;
|
||||||
|
@ -101,7 +101,7 @@ function newSub($i)
|
|||||||
|
|
||||||
$to = User::staticGet('nickname', $tunic);
|
$to = User::staticGet('nickname', $tunic);
|
||||||
|
|
||||||
if (empty($from)) {
|
if (empty($to)) {
|
||||||
throw new Exception("Can't find user '$tunic'.");
|
throw new Exception("Can't find user '$tunic'.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@ if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) {
|
|||||||
|
|
||||||
define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
|
define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
|
||||||
define('STATUSNET', true);
|
define('STATUSNET', true);
|
||||||
|
define('LACONICA', true);
|
||||||
|
|
||||||
require_once INSTALLDIR . '/lib/common.php';
|
require_once INSTALLDIR . '/lib/common.php';
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@ if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) {
|
|||||||
|
|
||||||
define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
|
define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
|
||||||
define('STATUSNET', true);
|
define('STATUSNET', true);
|
||||||
|
define('LACONICA', true);
|
||||||
|
|
||||||
require_once INSTALLDIR . '/lib/common.php';
|
require_once INSTALLDIR . '/lib/common.php';
|
||||||
|
|
||||||
@ -28,69 +29,71 @@ class URLDetectionTest extends PHPUnit_Framework_TestCase
|
|||||||
array('not a link :: no way',
|
array('not a link :: no way',
|
||||||
'not a link :: no way'),
|
'not a link :: no way'),
|
||||||
array('link http://www.somesite.com/xyz/35637563@N00/52803365/ link',
|
array('link http://www.somesite.com/xyz/35637563@N00/52803365/ link',
|
||||||
'link <a href="http://www.somesite.com/xyz/35637563@N00/52803365/" rel="external">http://www.somesite.com/xyz/35637563@N00/52803365/</a> link'),
|
'link <a href="http://www.somesite.com/xyz/35637563@N00/52803365/" title="http://www.somesite.com/xyz/35637563@N00/52803365/" rel="external">http://www.somesite.com/xyz/35637563@N00/52803365/</a> link'),
|
||||||
array('http://127.0.0.1',
|
array('http://127.0.0.1',
|
||||||
'<a href="http://127.0.0.1/" rel="external">http://127.0.0.1</a>'),
|
'<a href="http://127.0.0.1/" title="http://127.0.0.1/" rel="external">http://127.0.0.1</a>'),
|
||||||
array('127.0.0.1',
|
array('127.0.0.1',
|
||||||
'<a href="http://127.0.0.1/" rel="external">127.0.0.1</a>'),
|
'<a href="http://127.0.0.1/" title="http://127.0.0.1/" rel="external">127.0.0.1</a>'),
|
||||||
array('127.0.0.1:99',
|
array('127.0.0.1:99',
|
||||||
'<a href="http://127.0.0.1:99/" rel="external">127.0.0.1:99</a>'),
|
'<a href="http://127.0.0.1:99/" title="http://127.0.0.1:99/" rel="external">127.0.0.1:99</a>'),
|
||||||
array('127.0.0.1/Name:test.php',
|
array('127.0.0.1/Name:test.php',
|
||||||
'<a href="http://127.0.0.1/Name:test.php" rel="external">127.0.0.1/Name:test.php</a>'),
|
'<a href="http://127.0.0.1/Name:test.php" title="http://127.0.0.1/Name:test.php" rel="external">127.0.0.1/Name:test.php</a>'),
|
||||||
array('127.0.0.1/~test',
|
array('127.0.0.1/~test',
|
||||||
'<a href="http://127.0.0.1/~test" rel="external">127.0.0.1/~test</a>'),
|
'<a href="http://127.0.0.1/~test" title="http://127.0.0.1/~test" rel="external">127.0.0.1/~test</a>'),
|
||||||
array('127.0.0.1/+test',
|
array('127.0.0.1/+test',
|
||||||
'<a href="http://127.0.0.1/+test" rel="external">127.0.0.1/+test</a>'),
|
'<a href="http://127.0.0.1/+test" title="http://127.0.0.1/+test" rel="external">127.0.0.1/+test</a>'),
|
||||||
array('127.0.0.1/$test',
|
array('127.0.0.1/$test',
|
||||||
'<a href="http://127.0.0.1/$test" rel="external">127.0.0.1/$test</a>'),
|
'<a href="http://127.0.0.1/$test" title="http://127.0.0.1/$test" rel="external">127.0.0.1/$test</a>'),
|
||||||
array('127.0.0.1/\'test',
|
array('127.0.0.1/\'test',
|
||||||
'<a href="http://127.0.0.1/\'test" rel="external">127.0.0.1/\'test</a>'),
|
'<a href="http://127.0.0.1/\'test" title="http://127.0.0.1/\'test" rel="external">127.0.0.1/\'test</a>'),
|
||||||
array('127.0.0.1/"test',
|
array('127.0.0.1/"test',
|
||||||
'<a href="http://127.0.0.1/"test" rel="external">127.0.0.1/"test</a>'),
|
'<a href="http://127.0.0.1/"test" title="http://127.0.0.1/"test" rel="external">127.0.0.1/"test</a>'),
|
||||||
array('127.0.0.1/-test',
|
array('127.0.0.1/-test',
|
||||||
'<a href="http://127.0.0.1/-test" rel="external">127.0.0.1/-test</a>'),
|
'<a href="http://127.0.0.1/-test" title="http://127.0.0.1/-test" rel="external">127.0.0.1/-test</a>'),
|
||||||
array('127.0.0.1/_test',
|
array('127.0.0.1/_test',
|
||||||
'<a href="http://127.0.0.1/_test" rel="external">127.0.0.1/_test</a>'),
|
'<a href="http://127.0.0.1/_test" title="http://127.0.0.1/_test" rel="external">127.0.0.1/_test</a>'),
|
||||||
array('127.0.0.1/!test',
|
array('127.0.0.1/!test',
|
||||||
'<a href="http://127.0.0.1/!test" rel="external">127.0.0.1/!test</a>'),
|
'<a href="http://127.0.0.1/!test" title="http://127.0.0.1/!test" rel="external">127.0.0.1/!test</a>'),
|
||||||
array('127.0.0.1/*test',
|
array('127.0.0.1/*test',
|
||||||
'<a href="http://127.0.0.1/*test" rel="external">127.0.0.1/*test</a>'),
|
'<a href="http://127.0.0.1/*test" title="http://127.0.0.1/*test" rel="external">127.0.0.1/*test</a>'),
|
||||||
array('127.0.0.1/test%20stuff',
|
array('127.0.0.1/test%20stuff',
|
||||||
'<a href="http://127.0.0.1/test%20stuff" rel="external">127.0.0.1/test%20stuff</a>'),
|
'<a href="http://127.0.0.1/test%20stuff" title="http://127.0.0.1/test%20stuff" rel="external">127.0.0.1/test%20stuff</a>'),
|
||||||
array('http://[::1]:99/test.php',
|
array('http://[::1]:99/test.php',
|
||||||
'<a href="http://[::1]:99/test.php" rel="external">http://[::1]:99/test.php</a>'),
|
'<a href="http://[::1]:99/test.php" title="http://[::1]:99/test.php" rel="external">http://[::1]:99/test.php</a>'),
|
||||||
array('http://::1/test.php',
|
array('http://::1/test.php',
|
||||||
'<a href="http://::1/test.php" rel="external">http://::1/test.php</a>'),
|
'<a href="http://::1/test.php" title="http://::1/test.php" rel="external">http://::1/test.php</a>'),
|
||||||
array('http://::1',
|
array('http://::1',
|
||||||
'<a href="http://::1/" rel="external">http://::1</a>'),
|
'<a href="http://::1/" title="http://::1/" rel="external">http://::1</a>'),
|
||||||
array('2001:4978:1b5:0:21d:e0ff:fe66:59ab/test.php',
|
array('2001:4978:1b5:0:21d:e0ff:fe66:59ab/test.php',
|
||||||
'<a href="http://2001:4978:1b5:0:21d:e0ff:fe66:59ab/test.php" rel="external">2001:4978:1b5:0:21d:e0ff:fe66:59ab/test.php</a>'),
|
'<a href="http://2001:4978:1b5:0:21d:e0ff:fe66:59ab/test.php" title="http://2001:4978:1b5:0:21d:e0ff:fe66:59ab/test.php" rel="external">2001:4978:1b5:0:21d:e0ff:fe66:59ab/test.php</a>'),
|
||||||
array('[2001:4978:1b5:0:21d:e0ff:fe66:59ab]:99/test.php',
|
array('[2001:4978:1b5:0:21d:e0ff:fe66:59ab]:99/test.php',
|
||||||
'<a href="http://[2001:4978:1b5:0:21d:e0ff:fe66:59ab]:99/test.php" rel="external">[2001:4978:1b5:0:21d:e0ff:fe66:59ab]:99/test.php</a>'),
|
'<a href="http://[2001:4978:1b5:0:21d:e0ff:fe66:59ab]:99/test.php" title="http://[2001:4978:1b5:0:21d:e0ff:fe66:59ab]:99/test.php" rel="external">[2001:4978:1b5:0:21d:e0ff:fe66:59ab]:99/test.php</a>'),
|
||||||
array('2001:4978:1b5:0:21d:e0ff:fe66:59ab',
|
array('2001:4978:1b5:0:21d:e0ff:fe66:59ab',
|
||||||
'<a href="http://2001:4978:1b5:0:21d:e0ff:fe66:59ab/" rel="external">2001:4978:1b5:0:21d:e0ff:fe66:59ab</a>'),
|
'<a href="http://2001:4978:1b5:0:21d:e0ff:fe66:59ab/" title="http://2001:4978:1b5:0:21d:e0ff:fe66:59ab/" rel="external">2001:4978:1b5:0:21d:e0ff:fe66:59ab</a>'),
|
||||||
array('http://127.0.0.1',
|
array('http://127.0.0.1',
|
||||||
'<a href="http://127.0.0.1/" rel="external">http://127.0.0.1</a>'),
|
'<a href="http://127.0.0.1/" title="http://127.0.0.1/" rel="external">http://127.0.0.1</a>'),
|
||||||
array('example.com',
|
array('example.com',
|
||||||
'<a href="http://example.com/" rel="external">example.com</a>'),
|
'<a href="http://example.com/" title="http://example.com/" rel="external">example.com</a>'),
|
||||||
array('example.com',
|
array('example.com',
|
||||||
'<a href="http://example.com/" rel="external">example.com</a>'),
|
'<a href="http://example.com/" title="http://example.com/" rel="external">example.com</a>'),
|
||||||
array('http://example.com',
|
array('http://example.com',
|
||||||
'<a href="http://example.com/" rel="external">http://example.com</a>'),
|
'<a href="http://example.com/" title="http://example.com/" rel="external">http://example.com</a>'),
|
||||||
array('http://example.com.',
|
array('http://example.com.',
|
||||||
'<a href="http://example.com/" rel="external">http://example.com</a>.'),
|
'<a href="http://example.com/" title="http://example.com/" rel="external">http://example.com</a>.'),
|
||||||
array('/var/lib/example.so',
|
array('/var/lib/example.so',
|
||||||
'/var/lib/example.so'),
|
'/var/lib/example.so'),
|
||||||
array('example',
|
array('example',
|
||||||
'example'),
|
'example'),
|
||||||
array('user@example.com',
|
array('user@example.com',
|
||||||
'<a href="mailto:user@example.com" rel="external">user@example.com</a>'),
|
'<a href="mailto:user@example.com" title="mailto:user@example.com" rel="external">user@example.com</a>'),
|
||||||
array('user_name+other@example.com',
|
array('user_name+other@example.com',
|
||||||
'<a href="mailto:user_name+other@example.com" rel="external">user_name+other@example.com</a>'),
|
'<a href="mailto:user_name+other@example.com" title="mailto:user_name+other@example.com" rel="external">user_name+other@example.com</a>'),
|
||||||
array('mailto:user@example.com',
|
array('mailto:user@example.com',
|
||||||
'<a href="mailto:user@example.com" rel="external">mailto:user@example.com</a>'),
|
'<a href="mailto:user@example.com" title="mailto:user@example.com" rel="external">mailto:user@example.com</a>'),
|
||||||
array('mailto:user@example.com?subject=test',
|
array('mailto:user@example.com?subject=test',
|
||||||
'<a href="mailto:user@example.com?subject=test" rel="external">mailto:user@example.com?subject=test</a>'),
|
'<a href="mailto:user@example.com?subject=test" title="mailto:user@example.com?subject=test" rel="external">mailto:user@example.com?subject=test</a>'),
|
||||||
|
array('xmpp:user@example.com',
|
||||||
|
'<a href="xmpp:user@example.com" title="xmpp:user@example.com" rel="external">xmpp:user@example.com</a>'),
|
||||||
array('#example',
|
array('#example',
|
||||||
'#<span class="tag"><a href="' . common_local_url('tag', array('tag' => common_canonical_tag('example'))) . '" rel="tag">example</a></span>'),
|
'#<span class="tag"><a href="' . common_local_url('tag', array('tag' => common_canonical_tag('example'))) . '" rel="tag">example</a></span>'),
|
||||||
array('#example.com',
|
array('#example.com',
|
||||||
@ -98,165 +101,165 @@ class URLDetectionTest extends PHPUnit_Framework_TestCase
|
|||||||
array('#.net',
|
array('#.net',
|
||||||
'#<span class="tag"><a href="' . common_local_url('tag', array('tag' => common_canonical_tag('.net'))) . '" rel="tag">.net</a></span>'),
|
'#<span class="tag"><a href="' . common_local_url('tag', array('tag' => common_canonical_tag('.net'))) . '" rel="tag">.net</a></span>'),
|
||||||
array('http://example',
|
array('http://example',
|
||||||
'<a href="http://example/" rel="external">http://example</a>'),
|
'<a href="http://example/" title="http://example/" rel="external">http://example</a>'),
|
||||||
array('http://3xampl3',
|
array('http://3xampl3',
|
||||||
'<a href="http://3xampl3/" rel="external">http://3xampl3</a>'),
|
'<a href="http://3xampl3/" title="http://3xampl3/" rel="external">http://3xampl3</a>'),
|
||||||
array('http://example/',
|
array('http://example/',
|
||||||
'<a href="http://example/" rel="external">http://example/</a>'),
|
'<a href="http://example/" title="http://example/" rel="external">http://example/</a>'),
|
||||||
array('http://example/path',
|
array('http://example/path',
|
||||||
'<a href="http://example/path" rel="external">http://example/path</a>'),
|
'<a href="http://example/path" title="http://example/path" rel="external">http://example/path</a>'),
|
||||||
array('http://example.com',
|
array('http://example.com',
|
||||||
'<a href="http://example.com/" rel="external">http://example.com</a>'),
|
'<a href="http://example.com/" title="http://example.com/" rel="external">http://example.com</a>'),
|
||||||
array('https://example.com',
|
array('https://example.com',
|
||||||
'<a href="https://example.com/" rel="external">https://example.com</a>'),
|
'<a href="https://example.com/" title="https://example.com/" rel="external">https://example.com</a>'),
|
||||||
array('ftp://example.com',
|
array('ftp://example.com',
|
||||||
'<a href="ftp://example.com/" rel="external">ftp://example.com</a>'),
|
'<a href="ftp://example.com/" title="ftp://example.com/" rel="external">ftp://example.com</a>'),
|
||||||
array('ftps://example.com',
|
array('ftps://example.com',
|
||||||
'<a href="ftps://example.com/" rel="external">ftps://example.com</a>'),
|
'<a href="ftps://example.com/" title="ftps://example.com/" rel="external">ftps://example.com</a>'),
|
||||||
array('http://user@example.com',
|
array('http://user@example.com',
|
||||||
'<a href="http://user@example.com/" rel="external">http://user@example.com</a>'),
|
'<a href="http://user@example.com/" title="http://user@example.com/" rel="external">http://user@example.com</a>'),
|
||||||
array('http://user:pass@example.com',
|
array('http://user:pass@example.com',
|
||||||
'<a href="http://user:pass@example.com/" rel="external">http://user:pass@example.com</a>'),
|
'<a href="http://user:pass@example.com/" title="http://user:pass@example.com/" rel="external">http://user:pass@example.com</a>'),
|
||||||
array('http://example.com:8080',
|
array('http://example.com:8080',
|
||||||
'<a href="http://example.com:8080/" rel="external">http://example.com:8080</a>'),
|
'<a href="http://example.com:8080/" title="http://example.com:8080/" rel="external">http://example.com:8080</a>'),
|
||||||
array('http://example.com:8080/test.php',
|
array('http://example.com:8080/test.php',
|
||||||
'<a href="http://example.com:8080/test.php" rel="external">http://example.com:8080/test.php</a>'),
|
'<a href="http://example.com:8080/test.php" title="http://example.com:8080/test.php" rel="external">http://example.com:8080/test.php</a>'),
|
||||||
array('example.com:8080/test.php',
|
array('example.com:8080/test.php',
|
||||||
'<a href="http://example.com:8080/test.php" rel="external">example.com:8080/test.php</a>'),
|
'<a href="http://example.com:8080/test.php" title="http://example.com:8080/test.php" rel="external">example.com:8080/test.php</a>'),
|
||||||
array('http://www.example.com',
|
array('http://www.example.com',
|
||||||
'<a href="http://www.example.com/" rel="external">http://www.example.com</a>'),
|
'<a href="http://www.example.com/" title="http://www.example.com/" rel="external">http://www.example.com</a>'),
|
||||||
array('http://example.com/',
|
array('http://example.com/',
|
||||||
'<a href="http://example.com/" rel="external">http://example.com/</a>'),
|
'<a href="http://example.com/" title="http://example.com/" rel="external">http://example.com/</a>'),
|
||||||
array('http://example.com/path',
|
array('http://example.com/path',
|
||||||
'<a href="http://example.com/path" rel="external">http://example.com/path</a>'),
|
'<a href="http://example.com/path" title="http://example.com/path" rel="external">http://example.com/path</a>'),
|
||||||
array('http://example.com/path.html',
|
array('http://example.com/path.html',
|
||||||
'<a href="http://example.com/path.html" rel="external">http://example.com/path.html</a>'),
|
'<a href="http://example.com/path.html" title="http://example.com/path.html" rel="external">http://example.com/path.html</a>'),
|
||||||
array('http://example.com/path.html#fragment',
|
array('http://example.com/path.html#fragment',
|
||||||
'<a href="http://example.com/path.html#fragment" rel="external">http://example.com/path.html#fragment</a>'),
|
'<a href="http://example.com/path.html#fragment" title="http://example.com/path.html#fragment" rel="external">http://example.com/path.html#fragment</a>'),
|
||||||
array('http://example.com/path.php?foo=bar&bar=foo',
|
array('http://example.com/path.php?foo=bar&bar=foo',
|
||||||
'<a href="http://example.com/path.php?foo=bar&bar=foo" rel="external">http://example.com/path.php?foo=bar&bar=foo</a>'),
|
'<a href="http://example.com/path.php?foo=bar&bar=foo" title="http://example.com/path.php?foo=bar&bar=foo" rel="external">http://example.com/path.php?foo=bar&bar=foo</a>'),
|
||||||
array('http://example.com.',
|
array('http://example.com.',
|
||||||
'<a href="http://example.com/" rel="external">http://example.com</a>.'),
|
'<a href="http://example.com/" title="http://example.com/" rel="external">http://example.com</a>.'),
|
||||||
array('http://müllärör.de',
|
array('http://müllärör.de',
|
||||||
'<a href="http://müllärör.de/" rel="external">http://müllärör.de</a>'),
|
'<a href="http://müllärör.de/" title="http://müllärör.de/" rel="external">http://müllärör.de</a>'),
|
||||||
array('http://ﺱﺲﺷ.com',
|
array('http://ﺱﺲﺷ.com',
|
||||||
'<a href="http://ﺱﺲﺷ.com/" rel="external">http://ﺱﺲﺷ.com</a>'),
|
'<a href="http://ﺱﺲﺷ.com/" title="http://ﺱﺲﺷ.com/" rel="external">http://ﺱﺲﺷ.com</a>'),
|
||||||
array('http://сделаткартинки.com',
|
array('http://сделаткартинки.com',
|
||||||
'<a href="http://сделаткартинки.com/" rel="external">http://сделаткартинки.com</a>'),
|
'<a href="http://сделаткартинки.com/" title="http://сделаткартинки.com/" rel="external">http://сделаткартинки.com</a>'),
|
||||||
array('http://tūdaliņ.lv',
|
array('http://tūdaliņ.lv',
|
||||||
'<a href="http://tūdaliņ.lv/" rel="external">http://tūdaliņ.lv</a>'),
|
'<a href="http://tūdaliņ.lv/" title="http://tūdaliņ.lv/" rel="external">http://tūdaliņ.lv</a>'),
|
||||||
array('http://brændendekærlighed.com',
|
array('http://brændendekærlighed.com',
|
||||||
'<a href="http://brændendekærlighed.com/" rel="external">http://brændendekærlighed.com</a>'),
|
'<a href="http://brændendekærlighed.com/" title="http://brændendekærlighed.com/" rel="external">http://brændendekærlighed.com</a>'),
|
||||||
array('http://あーるいん.com',
|
array('http://あーるいん.com',
|
||||||
'<a href="http://あーるいん.com/" rel="external">http://あーるいん.com</a>'),
|
'<a href="http://あーるいん.com/" title="http://あーるいん.com/" rel="external">http://あーるいん.com</a>'),
|
||||||
array('http://예비교사.com',
|
array('http://예비교사.com',
|
||||||
'<a href="http://예비교사.com/" rel="external">http://예비교사.com</a>'),
|
'<a href="http://예비교사.com/" title="http://예비교사.com/" rel="external">http://예비교사.com</a>'),
|
||||||
array('http://example.com.',
|
array('http://example.com.',
|
||||||
'<a href="http://example.com/" rel="external">http://example.com</a>.'),
|
'<a href="http://example.com/" title="http://example.com/" rel="external">http://example.com</a>.'),
|
||||||
array('http://example.com?',
|
array('http://example.com?',
|
||||||
'<a href="http://example.com/" rel="external">http://example.com</a>?'),
|
'<a href="http://example.com/" title="http://example.com/" rel="external">http://example.com</a>?'),
|
||||||
array('http://example.com!',
|
array('http://example.com!',
|
||||||
'<a href="http://example.com/" rel="external">http://example.com</a>!'),
|
'<a href="http://example.com/" title="http://example.com/" rel="external">http://example.com</a>!'),
|
||||||
array('http://example.com,',
|
array('http://example.com,',
|
||||||
'<a href="http://example.com/" rel="external">http://example.com</a>,'),
|
'<a href="http://example.com/" title="http://example.com/" rel="external">http://example.com</a>,'),
|
||||||
array('http://example.com;',
|
array('http://example.com;',
|
||||||
'<a href="http://example.com/" rel="external">http://example.com</a>;'),
|
'<a href="http://example.com/" title="http://example.com/" rel="external">http://example.com</a>;'),
|
||||||
array('http://example.com:',
|
array('http://example.com:',
|
||||||
'<a href="http://example.com/" rel="external">http://example.com</a>:'),
|
'<a href="http://example.com/" title="http://example.com/" rel="external">http://example.com</a>:'),
|
||||||
array('\'http://example.com\'',
|
array('\'http://example.com\'',
|
||||||
'\'<a href="http://example.com/" rel="external">http://example.com</a>\''),
|
'\'<a href="http://example.com/" title="http://example.com/" rel="external">http://example.com</a>\''),
|
||||||
array('"http://example.com"',
|
array('"http://example.com"',
|
||||||
'"<a href="http://example.com/" rel="external">http://example.com</a>"'),
|
'"<a href="http://example.com/" title="http://example.com/" rel="external">http://example.com</a>"'),
|
||||||
array('http://example.com',
|
array('http://example.com',
|
||||||
'<a href="http://example.com/" rel="external">http://example.com</a>'),
|
'<a href="http://example.com/" title="http://example.com/" rel="external">http://example.com</a>'),
|
||||||
array('(http://example.com)',
|
array('(http://example.com)',
|
||||||
'(<a href="http://example.com/" rel="external">http://example.com</a>)'),
|
'(<a href="http://example.com/" title="http://example.com/" rel="external">http://example.com</a>)'),
|
||||||
array('[http://example.com]',
|
array('[http://example.com]',
|
||||||
'[<a href="http://example.com/" rel="external">http://example.com</a>]'),
|
'[<a href="http://example.com/" title="http://example.com/" rel="external">http://example.com</a>]'),
|
||||||
array('<http://example.com>',
|
array('<http://example.com>',
|
||||||
'<<a href="http://example.com/" rel="external">http://example.com</a>>'),
|
'<<a href="http://example.com/" title="http://example.com/" rel="external">http://example.com</a>>'),
|
||||||
array('http://example.com/path/(foo)/bar',
|
array('http://example.com/path/(foo)/bar',
|
||||||
'<a href="http://example.com/path/(foo)/bar" rel="external">http://example.com/path/(foo)/bar</a>'),
|
'<a href="http://example.com/path/(foo)/bar" title="http://example.com/path/(foo)/bar" rel="external">http://example.com/path/(foo)/bar</a>'),
|
||||||
array('http://example.com/path/[foo]/bar',
|
array('http://example.com/path/[foo]/bar',
|
||||||
'<a href="http://example.com/path/[foo]/bar" rel="external">http://example.com/path/[foo]/bar</a>'),
|
'<a href="http://example.com/path/[foo]/bar" title="http://example.com/path/[foo]/bar" rel="external">http://example.com/path/[foo]/bar</a>'),
|
||||||
array('http://example.com/path/foo/(bar)',
|
array('http://example.com/path/foo/(bar)',
|
||||||
'<a href="http://example.com/path/foo/(bar)" rel="external">http://example.com/path/foo/(bar)</a>'),
|
'<a href="http://example.com/path/foo/(bar)" title="http://example.com/path/foo/(bar)" rel="external">http://example.com/path/foo/(bar)</a>'),
|
||||||
//Not a valid url - urls cannot contain unencoded square brackets
|
//Not a valid url - urls cannot contain unencoded square brackets
|
||||||
array('http://example.com/path/foo/[bar]',
|
array('http://example.com/path/foo/[bar]',
|
||||||
'<a href="http://example.com/path/foo/[bar]" rel="external">http://example.com/path/foo/[bar]</a>'),
|
'<a href="http://example.com/path/foo/[bar]" title="http://example.com/path/foo/[bar]" rel="external">http://example.com/path/foo/[bar]</a>'),
|
||||||
array('Hey, check out my cool site http://example.com okay?',
|
array('Hey, check out my cool site http://example.com okay?',
|
||||||
'Hey, check out my cool site <a href="http://example.com/" rel="external">http://example.com</a> okay?'),
|
'Hey, check out my cool site <a href="http://example.com/" title="http://example.com/" rel="external">http://example.com</a> okay?'),
|
||||||
array('What about parens (e.g. http://example.com/path/foo/(bar))?',
|
array('What about parens (e.g. http://example.com/path/foo/(bar))?',
|
||||||
'What about parens (e.g. <a href="http://example.com/path/foo/(bar)" rel="external">http://example.com/path/foo/(bar)</a>)?'),
|
'What about parens (e.g. <a href="http://example.com/path/foo/(bar)" title="http://example.com/path/foo/(bar)" rel="external">http://example.com/path/foo/(bar)</a>)?'),
|
||||||
array('What about parens (e.g. http://example.com/path/foo/(bar)?',
|
array('What about parens (e.g. http://example.com/path/foo/(bar)?',
|
||||||
'What about parens (e.g. <a href="http://example.com/path/foo/(bar)" rel="external">http://example.com/path/foo/(bar)</a>?'),
|
'What about parens (e.g. <a href="http://example.com/path/foo/(bar)" title="http://example.com/path/foo/(bar)" rel="external">http://example.com/path/foo/(bar)</a>?'),
|
||||||
array('What about parens (e.g. http://example.com/path/foo/(bar).)?',
|
array('What about parens (e.g. http://example.com/path/foo/(bar).)?',
|
||||||
'What about parens (e.g. <a href="http://example.com/path/foo/(bar)" rel="external">http://example.com/path/foo/(bar)</a>.)?'),
|
'What about parens (e.g. <a href="http://example.com/path/foo/(bar)" title="http://example.com/path/foo/(bar)" rel="external">http://example.com/path/foo/(bar)</a>.)?'),
|
||||||
//Not a valid url - urls cannot contain unencoded commas
|
//Not a valid url - urls cannot contain unencoded commas
|
||||||
array('What about parens (e.g. http://example.com/path/(foo,bar)?',
|
array('What about parens (e.g. http://example.com/path/(foo,bar)?',
|
||||||
'What about parens (e.g. <a href="http://example.com/path/(foo,bar)" rel="external">http://example.com/path/(foo,bar)</a>?'),
|
'What about parens (e.g. <a href="http://example.com/path/(foo,bar)" title="http://example.com/path/(foo,bar)" rel="external">http://example.com/path/(foo,bar)</a>?'),
|
||||||
array('Unbalanced too (e.g. http://example.com/path/((((foo)/bar)?',
|
array('Unbalanced too (e.g. http://example.com/path/((((foo)/bar)?',
|
||||||
'Unbalanced too (e.g. <a href="http://example.com/path/((((foo)/bar)" rel="external">http://example.com/path/((((foo)/bar)</a>?'),
|
'Unbalanced too (e.g. <a href="http://example.com/path/((((foo)/bar)" title="http://example.com/path/((((foo)/bar)" rel="external">http://example.com/path/((((foo)/bar)</a>?'),
|
||||||
array('Unbalanced too (e.g. http://example.com/path/(foo))))/bar)?',
|
array('Unbalanced too (e.g. http://example.com/path/(foo))))/bar)?',
|
||||||
'Unbalanced too (e.g. <a href="http://example.com/path/(foo))))/bar" rel="external">http://example.com/path/(foo))))/bar</a>)?'),
|
'Unbalanced too (e.g. <a href="http://example.com/path/(foo))))/bar" title="http://example.com/path/(foo))))/bar" rel="external">http://example.com/path/(foo))))/bar</a>)?'),
|
||||||
array('Unbalanced too (e.g. http://example.com/path/foo/((((bar)?',
|
array('Unbalanced too (e.g. http://example.com/path/foo/((((bar)?',
|
||||||
'Unbalanced too (e.g. <a href="http://example.com/path/foo/((((bar)" rel="external">http://example.com/path/foo/((((bar)</a>?'),
|
'Unbalanced too (e.g. <a href="http://example.com/path/foo/((((bar)" title="http://example.com/path/foo/((((bar)" rel="external">http://example.com/path/foo/((((bar)</a>?'),
|
||||||
array('Unbalanced too (e.g. http://example.com/path/foo/(bar))))?',
|
array('Unbalanced too (e.g. http://example.com/path/foo/(bar))))?',
|
||||||
'Unbalanced too (e.g. <a href="http://example.com/path/foo/(bar)" rel="external">http://example.com/path/foo/(bar)</a>)))?'),
|
'Unbalanced too (e.g. <a href="http://example.com/path/foo/(bar)" title="http://example.com/path/foo/(bar)" rel="external">http://example.com/path/foo/(bar)</a>)))?'),
|
||||||
array('example.com',
|
array('example.com',
|
||||||
'<a href="http://example.com/" rel="external">example.com</a>'),
|
'<a href="http://example.com/" title="http://example.com/" rel="external">example.com</a>'),
|
||||||
array('example.org',
|
array('example.org',
|
||||||
'<a href="http://example.org/" rel="external">example.org</a>'),
|
'<a href="http://example.org/" title="http://example.org/" rel="external">example.org</a>'),
|
||||||
array('example.co.uk',
|
array('example.co.uk',
|
||||||
'<a href="http://example.co.uk/" rel="external">example.co.uk</a>'),
|
'<a href="http://example.co.uk/" title="http://example.co.uk/" rel="external">example.co.uk</a>'),
|
||||||
array('www.example.co.uk',
|
array('www.example.co.uk',
|
||||||
'<a href="http://www.example.co.uk/" rel="external">www.example.co.uk</a>'),
|
'<a href="http://www.example.co.uk/" title="http://www.example.co.uk/" rel="external">www.example.co.uk</a>'),
|
||||||
array('farm1.images.example.co.uk',
|
array('farm1.images.example.co.uk',
|
||||||
'<a href="http://farm1.images.example.co.uk/" rel="external">farm1.images.example.co.uk</a>'),
|
'<a href="http://farm1.images.example.co.uk/" title="http://farm1.images.example.co.uk/" rel="external">farm1.images.example.co.uk</a>'),
|
||||||
array('example.museum',
|
array('example.museum',
|
||||||
'<a href="http://example.museum/" rel="external">example.museum</a>'),
|
'<a href="http://example.museum/" title="http://example.museum/" rel="external">example.museum</a>'),
|
||||||
array('example.travel',
|
array('example.travel',
|
||||||
'<a href="http://example.travel/" rel="external">example.travel</a>'),
|
'<a href="http://example.travel/" title="http://example.travel/" rel="external">example.travel</a>'),
|
||||||
array('example.com.',
|
array('example.com.',
|
||||||
'<a href="http://example.com/" rel="external">example.com</a>.'),
|
'<a href="http://example.com/" title="http://example.com/" rel="external">example.com</a>.'),
|
||||||
array('example.com?',
|
array('example.com?',
|
||||||
'<a href="http://example.com/" rel="external">example.com</a>?'),
|
'<a href="http://example.com/" title="http://example.com/" rel="external">example.com</a>?'),
|
||||||
array('example.com!',
|
array('example.com!',
|
||||||
'<a href="http://example.com/" rel="external">example.com</a>!'),
|
'<a href="http://example.com/" title="http://example.com/" rel="external">example.com</a>!'),
|
||||||
array('example.com,',
|
array('example.com,',
|
||||||
'<a href="http://example.com/" rel="external">example.com</a>,'),
|
'<a href="http://example.com/" title="http://example.com/" rel="external">example.com</a>,'),
|
||||||
array('example.com;',
|
array('example.com;',
|
||||||
'<a href="http://example.com/" rel="external">example.com</a>;'),
|
'<a href="http://example.com/" title="http://example.com/" rel="external">example.com</a>;'),
|
||||||
array('example.com:',
|
array('example.com:',
|
||||||
'<a href="http://example.com/" rel="external">example.com</a>:'),
|
'<a href="http://example.com/" title="http://example.com/" rel="external">example.com</a>:'),
|
||||||
array('\'example.com\'',
|
array('\'example.com\'',
|
||||||
'\'<a href="http://example.com/" rel="external">example.com</a>\''),
|
'\'<a href="http://example.com/" title="http://example.com/" rel="external">example.com</a>\''),
|
||||||
array('"example.com"',
|
array('"example.com"',
|
||||||
'"<a href="http://example.com/" rel="external">example.com</a>"'),
|
'"<a href="http://example.com/" title="http://example.com/" rel="external">example.com</a>"'),
|
||||||
array('example.com',
|
array('example.com',
|
||||||
'<a href="http://example.com/" rel="external">example.com</a>'),
|
'<a href="http://example.com/" title="http://example.com/" rel="external">example.com</a>'),
|
||||||
array('(example.com)',
|
array('(example.com)',
|
||||||
'(<a href="http://example.com/" rel="external">example.com</a>)'),
|
'(<a href="http://example.com/" title="http://example.com/" rel="external">example.com</a>)'),
|
||||||
array('[example.com]',
|
array('[example.com]',
|
||||||
'[<a href="http://example.com/" rel="external">example.com</a>]'),
|
'[<a href="http://example.com/" title="http://example.com/" rel="external">example.com</a>]'),
|
||||||
array('<example.com>',
|
array('<example.com>',
|
||||||
'<<a href="http://example.com/" rel="external">example.com</a>>'),
|
'<<a href="http://example.com/" title="http://example.com/" rel="external">example.com</a>>'),
|
||||||
array('Hey, check out my cool site example.com okay?',
|
array('Hey, check out my cool site example.com okay?',
|
||||||
'Hey, check out my cool site <a href="http://example.com/" rel="external">example.com</a> okay?'),
|
'Hey, check out my cool site <a href="http://example.com/" title="http://example.com/" rel="external">example.com</a> okay?'),
|
||||||
array('Hey, check out my cool site example.com.I made it.',
|
array('Hey, check out my cool site example.com.I made it.',
|
||||||
'Hey, check out my cool site <a href="http://example.com/" rel="external">example.com</a>.I made it.'),
|
'Hey, check out my cool site <a href="http://example.com/" title="http://example.com/" rel="external">example.com</a>.I made it.'),
|
||||||
array('Hey, check out my cool site example.com.Funny thing...',
|
array('Hey, check out my cool site example.com.Funny thing...',
|
||||||
'Hey, check out my cool site <a href="http://example.com/" rel="external">example.com</a>.Funny thing...'),
|
'Hey, check out my cool site <a href="http://example.com/" title="http://example.com/" rel="external">example.com</a>.Funny thing...'),
|
||||||
array('Hey, check out my cool site example.com.You will love it.',
|
array('Hey, check out my cool site example.com.You will love it.',
|
||||||
'Hey, check out my cool site <a href="http://example.com/" rel="external">example.com</a>.You will love it.'),
|
'Hey, check out my cool site <a href="http://example.com/" title="http://example.com/" rel="external">example.com</a>.You will love it.'),
|
||||||
array('What about parens (e.g. example.com/path/foo/(bar))?',
|
array('What about parens (e.g. example.com/path/foo/(bar))?',
|
||||||
'What about parens (e.g. <a href="http://example.com/path/foo/(bar)" rel="external">example.com/path/foo/(bar)</a>)?'),
|
'What about parens (e.g. <a href="http://example.com/path/foo/(bar)" title="http://example.com/path/foo/(bar)" rel="external">example.com/path/foo/(bar)</a>)?'),
|
||||||
array('What about parens (e.g. example.com/path/foo/(bar)?',
|
array('What about parens (e.g. example.com/path/foo/(bar)?',
|
||||||
'What about parens (e.g. <a href="http://example.com/path/foo/(bar)" rel="external">example.com/path/foo/(bar)</a>?'),
|
'What about parens (e.g. <a href="http://example.com/path/foo/(bar)" title="http://example.com/path/foo/(bar)" rel="external">example.com/path/foo/(bar)</a>?'),
|
||||||
array('What about parens (e.g. example.com/path/foo/(bar).)?',
|
array('What about parens (e.g. example.com/path/foo/(bar).)?',
|
||||||
'What about parens (e.g. <a href="http://example.com/path/foo/(bar)" rel="external">example.com/path/foo/(bar)</a>.)?'),
|
'What about parens (e.g. <a href="http://example.com/path/foo/(bar)" title="http://example.com/path/foo/(bar)" rel="external">example.com/path/foo/(bar)</a>.)?'),
|
||||||
array('What about parens (e.g. example.com/path/(foo,bar)?',
|
array('What about parens (e.g. example.com/path/(foo,bar)?',
|
||||||
'What about parens (e.g. <a href="http://example.com/path/(foo,bar)" rel="external">example.com/path/(foo,bar)</a>?'),
|
'What about parens (e.g. <a href="http://example.com/path/(foo,bar)" title="http://example.com/path/(foo,bar)" rel="external">example.com/path/(foo,bar)</a>?'),
|
||||||
array('file.ext',
|
array('file.ext',
|
||||||
'file.ext'),
|
'file.ext'),
|
||||||
array('file.html',
|
array('file.html',
|
||||||
|
59
tests/UserRightsTest.php
Normal file
59
tests/UserRightsTest.php
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) {
|
||||||
|
print "This script must be run from the command line\n";
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
|
||||||
|
define('STATUSNET', true);
|
||||||
|
|
||||||
|
require_once INSTALLDIR . '/lib/common.php';
|
||||||
|
|
||||||
|
class UserRightsTest extends PHPUnit_Framework_TestCase
|
||||||
|
{
|
||||||
|
protected $user = null;
|
||||||
|
|
||||||
|
function setUp()
|
||||||
|
{
|
||||||
|
$this->user = User::register(array('nickname' => 'userrightstestuser'));
|
||||||
|
}
|
||||||
|
|
||||||
|
function tearDown()
|
||||||
|
{
|
||||||
|
$profile = $this->user->getProfile();
|
||||||
|
$this->user->delete();
|
||||||
|
$profile->delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
function testInvalidRole()
|
||||||
|
{
|
||||||
|
$this->assertFalse($this->user->hasRole('invalidrole'));
|
||||||
|
}
|
||||||
|
|
||||||
|
function standardRoles()
|
||||||
|
{
|
||||||
|
return array('admin', 'moderator');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dataProvider standardRoles
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
function testUngrantedRole($role)
|
||||||
|
{
|
||||||
|
$this->assertFalse($this->user->hasRole($role));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dataProvider standardRoles
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
function testGrantedRole($role)
|
||||||
|
{
|
||||||
|
$this->user->grantRole($role);
|
||||||
|
$this->assertFalse($this->user->hasRole($role));
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user