summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorEvan Prodromou <evan@status.net>2009-11-17 08:04:14 -0500
committerEvan Prodromou <evan@status.net>2009-11-17 08:04:14 -0500
commitbac2d80c919a78d5cafd57f712872a90cda04847 (patch)
treed2df10a582edc0bf9e043f1c764953a290927678 /lib
parent9a1a83e8ebe5ad39838e6363f1537a1a5232b9cb (diff)
parent6a1afda259c5223449f679a64f932e36df5ebe39 (diff)
Merge branch '0.9.x' into adminpanel
Conflicts: classes/User.php
Diffstat (limited to 'lib')
-rw-r--r--lib/Shorturl_api.php67
-rw-r--r--lib/action.php19
-rw-r--r--lib/blockform.php99
-rw-r--r--lib/command.php68
-rw-r--r--lib/commandinterpreter.php18
-rw-r--r--lib/common.php14
-rw-r--r--lib/deleteuserform.php79
-rw-r--r--lib/grouplist.php6
-rw-r--r--lib/jabber.php8
-rw-r--r--lib/mail.php19
-rw-r--r--lib/mailbox.php2
-rw-r--r--lib/oauthstore.php4
-rw-r--r--lib/plugin.php14
-rw-r--r--lib/profileactionform.php187
-rw-r--r--lib/profileformaction.php139
-rw-r--r--lib/profilelist.php8
-rw-r--r--lib/right.php10
-rw-r--r--lib/router.php5
-rw-r--r--lib/sandboxform.php80
-rw-r--r--lib/schema.php41
-rw-r--r--lib/silenceform.php80
-rw-r--r--lib/subs.php6
-rw-r--r--lib/unblockform.php98
-rw-r--r--lib/unsandboxform.php82
-rw-r--r--lib/unsilenceform.php80
-rw-r--r--lib/userprofile.php47
-rw-r--r--lib/util.php32
27 files changed, 1008 insertions, 304 deletions
diff --git a/lib/Shorturl_api.php b/lib/Shorturl_api.php
deleted file mode 100644
index de4d55012..000000000
--- a/lib/Shorturl_api.php
+++ /dev/null
@@ -1,67 +0,0 @@
-<?php
-/*
- * StatusNet - the distributed open-source microblogging tool
- * Copyright (C) 2008, 2009, StatusNet, 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('STATUSNET') && !defined('LACONICA')) { exit(1); }
-
-abstract class ShortUrlApi
-{
- protected $service_url;
- protected $long_limit = 27;
-
- function __construct($service_url)
- {
- $this->service_url = $service_url;
- }
-
- function shorten($url)
- {
- if ($this->is_long($url)) return $this->shorten_imp($url);
- return $url;
- }
-
- protected abstract function shorten_imp($url);
-
- protected function is_long($url) {
- return strlen($url) >= common_config('site', 'shorturllength');
- }
-
- protected function http_post($data)
- {
- $request = HTTPClient::start();
- $response = $request->post($this->service_url, null, $data);
- return $response->getBody();
- }
-
- protected function http_get($url)
- {
- $request = HTTPClient::start();
- $response = $request->get($this->service_url . urlencode($url));
- return $response->getBody();
- }
-
- protected function tidy($response) {
- $response = str_replace('&nbsp;', ' ', $response);
- $config = array('output-xhtml' => true);
- $tidy = new tidy;
- $tidy->parseString($response, $config, 'utf8');
- $tidy->cleanRepair();
- return (string)$tidy;
- }
-}
-
diff --git a/lib/action.php b/lib/action.php
index edb70c3d9..9c7060bba 100644
--- a/lib/action.php
+++ b/lib/action.php
@@ -990,6 +990,18 @@ class Action extends HTMLOutputter // lawsuit
function selfUrl()
{
+ list($action, $args) = $this->returnToArgs();
+ return common_local_url($action, $args);
+ }
+
+ /**
+ * Returns arguments sufficient for re-constructing URL
+ *
+ * @return array two elements: action, other args
+ */
+
+ function returnToArgs()
+ {
$action = $this->trimmed('action');
$args = $this->args;
unset($args['action']);
@@ -1002,8 +1014,7 @@ class Action extends HTMLOutputter // lawsuit
foreach (array_keys($_COOKIE) as $cookie) {
unset($args[$cookie]);
}
-
- return common_local_url($action, $args);
+ return array($action, $args);
}
/**
@@ -1052,8 +1063,7 @@ class Action extends HTMLOutputter // lawsuit
{
// Does a little before-after block for next/prev page
if ($have_before || $have_after) {
- $this->elementStart('div', array('class' => 'pagination'));
- $this->elementStart('dl', null);
+ $this->elementStart('dl', 'pagination');
$this->element('dt', null, _('Pagination'));
$this->elementStart('dd', null);
$this->elementStart('ul', array('class' => 'nav'));
@@ -1078,7 +1088,6 @@ class Action extends HTMLOutputter // lawsuit
$this->elementEnd('ul');
$this->elementEnd('dd');
$this->elementEnd('dl');
- $this->elementEnd('div');
}
}
diff --git a/lib/blockform.php b/lib/blockform.php
index 4820d09af..b6652b1f6 100644
--- a/lib/blockform.php
+++ b/lib/blockform.php
@@ -32,8 +32,6 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
exit(1);
}
-require_once INSTALLDIR.'/lib/form.php';
-
/**
* Form for blocking a user
*
@@ -47,109 +45,38 @@ require_once INSTALLDIR.'/lib/form.php';
* @see UnblockForm
*/
-class BlockForm extends Form
+class BlockForm extends ProfileActionForm
{
/**
- * Profile of user to block
- */
-
- var $profile = null;
-
- /**
- * Return-to args
- */
-
- var $args = null;
-
- /**
- * Constructor
+ * Action this form provides
*
- * @param HTMLOutputter $out output channel
- * @param Profile $profile profile of user to block
- * @param array $args return-to args
+ * @return string Name of the action, lowercased.
*/
- function __construct($out=null, $profile=null, $args=null)
+ function target()
{
- parent::__construct($out);
-
- $this->profile = $profile;
- $this->args = $args;
+ return 'block';
}
/**
- * ID of the form
- *
- * @return int ID of the form
- */
-
- function id()
- {
- return 'block-' . $this->profile->id;
- }
-
-
- /**
- * class of the form
- *
- * @return string class of the form
- */
-
- function formClass()
- {
- return 'form_user_block';
- }
-
-
- /**
- * Action of the form
- *
- * @return string URL of the action
- */
-
- function action()
- {
- return common_local_url('block');
- }
-
-
- /**
- * Legend of the Form
- *
- * @return void
- */
- function formLegend()
- {
- $this->out->element('legend', null, _('Block this user'));
- }
-
-
- /**
- * Data elements of the form
+ * Title of the form
*
- * @return void
+ * @return string Title of the form, internationalized
*/
- function formData()
+ function title()
{
- $this->out->hidden('blockto-' . $this->profile->id,
- $this->profile->id,
- 'blockto');
- if ($this->args) {
- foreach ($this->args as $k => $v) {
- $this->out->hidden('returnto-' . $k, $v);
- }
- }
+ return _('Block');
}
/**
- * Action elements
+ * Description of the form
*
- * @return void
+ * @return string description of the form, internationalized
*/
- function formActions()
+ function description()
{
- $this->out->submit('submit', _('Block'), 'submit', null, _('Block this user'));
+ return _('Block this user');
}
}
diff --git a/lib/command.php b/lib/command.php
index 2ec3320de..7e98156b6 100644
--- a/lib/command.php
+++ b/lib/command.php
@@ -605,6 +605,71 @@ class LoginCommand extends Command
}
}
+class SubscriptionsCommand extends Command
+{
+ function execute($channel)
+ {
+ $profile = $this->user->getSubscriptions(0);
+ $nicknames=array();
+ while ($profile->fetch()) {
+ $nicknames[]=$profile->nickname;
+ }
+ if(count($nicknames)==0){
+ $out=_('You are not subscribed to anyone.');
+ }else{
+ $out = ngettext('You are subscribed to this person:',
+ 'You are subscribed to these people:',
+ count($nicknames));
+ $out .= ' ';
+ $out .= implode(', ',$nicknames);
+ }
+ $channel->output($this->user,$out);
+ }
+}
+
+class SubscribersCommand extends Command
+{
+ function execute($channel)
+ {
+ $profile = $this->user->getSubscribers();
+ $nicknames=array();
+ while ($profile->fetch()) {
+ $nicknames[]=$profile->nickname;
+ }
+ if(count($nicknames)==0){
+ $out=_('No one is subscribed to you.');
+ }else{
+ $out = ngettext('This person is subscribed to you:',
+ 'These people are subscribed to you:',
+ count($nicknames));
+ $out .= ' ';
+ $out .= implode(', ',$nicknames);
+ }
+ $channel->output($this->user,$out);
+ }
+}
+
+class GroupsCommand extends Command
+{
+ function execute($channel)
+ {
+ $group = $this->user->getGroups();
+ $groups=array();
+ while ($group->fetch()) {
+ $groups[]=$group->nickname;
+ }
+ if(count($groups)==0){
+ $out=_('You are not a member of any groups.');
+ }else{
+ $out = ngettext('You are a member of this group:',
+ 'You are a member of these groups:',
+ count($nicknames));
+ $out.=implode(', ',$groups);
+ }
+ $channel->output($this->user,$out);
+ }
+}
+
class HelpCommand extends Command
{
function execute($channel)
@@ -615,6 +680,9 @@ class HelpCommand extends Command
"off - turn off notifications\n".
"help - show this help\n".
"follow <nickname> - subscribe to user\n".
+ "groups - lists the groups you have joined\n".
+ "subscriptions - list the people you follow\n".
+ "subscribers - list the people that follow you\n".
"leave <nickname> - unsubscribe from user\n".
"d <nickname> <text> - direct message to user\n".
"get <nickname> - get last notice from user\n".
diff --git a/lib/commandinterpreter.php b/lib/commandinterpreter.php
index d878fe268..665015afc 100644
--- a/lib/commandinterpreter.php
+++ b/lib/commandinterpreter.php
@@ -47,6 +47,24 @@ class CommandInterpreter
} else {
return new LoginCommand($user);
}
+ case 'subscribers':
+ if ($arg) {
+ return null;
+ } else {
+ return new SubscribersCommand($user);
+ }
+ case 'subscriptions':
+ if ($arg) {
+ return null;
+ } else {
+ return new SubscriptionsCommand($user);
+ }
+ case 'groups':
+ if ($arg) {
+ return null;
+ } else {
+ return new GroupsCommand($user);
+ }
case 'on':
if ($arg) {
list($other, $extra) = $this->split_arg($arg);
diff --git a/lib/common.php b/lib/common.php
index 6aac46807..063d7d9d9 100644
--- a/lib/common.php
+++ b/lib/common.php
@@ -19,6 +19,9 @@
if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); }
+//exit with 200 response, if this is checking fancy from the installer
+if (isset($_REQUEST['p']) && $_REQUEST['p'] == 'check-fancy') { exit; }
+
define('STATUSNET_VERSION', '0.9.0dev');
define('LACONICA_VERSION', STATUSNET_VERSION); // compatibility
@@ -38,12 +41,18 @@ define('FOREIGN_NOTICE_SEND_REPLY', 4);
define('FOREIGN_FRIEND_SEND', 1);
define('FOREIGN_FRIEND_RECV', 2);
-define_syslog_variables();
-
# append our extlib dir as the last-resort place to find libs
set_include_path(get_include_path() . PATH_SEPARATOR . INSTALLDIR . '/extlib/');
+# To protect against upstream libraries which haven't updated
+# for PHP 5.3 where dl() function may not be present...
+if (!function_exists('dl')) {
+ function dl($library) {
+ return false;
+ }
+}
+
# global configuration object
require_once('PEAR.php');
@@ -229,7 +238,6 @@ require_once INSTALLDIR.'/lib/util.php';
require_once INSTALLDIR.'/lib/action.php';
require_once INSTALLDIR.'/lib/mail.php';
require_once INSTALLDIR.'/lib/subs.php';
-require_once INSTALLDIR.'/lib/Shorturl_api.php';
require_once INSTALLDIR.'/lib/clientexception.php';
require_once INSTALLDIR.'/lib/serverexception.php';
diff --git a/lib/deleteuserform.php b/lib/deleteuserform.php
new file mode 100644
index 000000000..09ea8f68d
--- /dev/null
+++ b/lib/deleteuserform.php
@@ -0,0 +1,79 @@
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * Form for deleting a user
+ *
+ * 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 Form
+ * @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')) {
+ exit(1);
+}
+
+/**
+ * Form for deleting a user
+ *
+ * @category Form
+ * @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 DeleteUserForm extends ProfileActionForm
+{
+ /**
+ * Action this form provides
+ *
+ * @return string Name of the action, lowercased.
+ */
+
+ function target()
+ {
+ return 'deleteuser';
+ }
+
+ /**
+ * Title of the form
+ *
+ * @return string Title of the form, internationalized
+ */
+
+ function title()
+ {
+ return _('Delete');
+ }
+
+ /**
+ * Description of the form
+ *
+ * @return string description of the form, internationalized
+ */
+
+ function description()
+ {
+ return _('Delete this user');
+ }
+}
diff --git a/lib/grouplist.php b/lib/grouplist.php
index cc734bdd0..99bff9cdc 100644
--- a/lib/grouplist.php
+++ b/lib/grouplist.php
@@ -85,18 +85,18 @@ class GroupList extends Widget
function showGroup()
{
- $this->out->elementStart('li', array('class' => 'profile',
+ $this->out->elementStart('li', array('class' => 'profile hentry',
'id' => 'group-' . $this->group->id));
$user = common_current_user();
- $this->out->elementStart('div', 'entity_profile vcard');
+ $this->out->elementStart('div', 'entity_profile vcard entry-content');
$logo = ($this->group->stream_logo) ?
$this->group->stream_logo : User_group::defaultLogo(AVATAR_STREAM_SIZE);
$this->out->elementStart('a', array('href' => $this->group->homeUrl(),
- 'class' => 'url',
+ 'class' => 'url entry-title',
'rel' => 'contact group'));
$this->out->element('img', array('src' => $logo,
'class' => 'photo avatar',
diff --git a/lib/jabber.php b/lib/jabber.php
index 73f2ec660..a8e295ea5 100644
--- a/lib/jabber.php
+++ b/lib/jabber.php
@@ -176,7 +176,7 @@ function jabber_format_entry($profile, $notice)
$xs = new XMLStringer();
$xs->elementStart('html', array('xmlns' => 'http://jabber.org/protocol/xhtml-im'));
$xs->elementStart('body', array('xmlns' => 'http://www.w3.org/1999/xhtml'));
- $xs->element("img", array('src'=> $profile->avatarUrl(AVATAR_MINI_SIZE) , 'alt' => $profile->nickname));
+ $xs->element("img", array('src'=> $profile->avatarUrl(AVATAR_MINI_SIZE)));
$xs->element('a', array('href' => $profile->profileurl),
$profile->nickname);
$xs->text(": ");
@@ -185,11 +185,11 @@ function jabber_format_entry($profile, $notice)
} else {
$xs->raw(common_render_content($notice->content, $notice));
}
- $xs->raw(" ");
+ $xs->text(" ");
$xs->element('a', array(
'href'=>common_local_url('conversation',
array('id' => $notice->conversation)).'#notice-'.$notice->id
- ),sprintf(_('notice id: %s'),$notice->id));
+ ),sprintf(_('[%s]'),$notice->id));
$xs->elementEnd('body');
$xs->elementEnd('html');
@@ -481,5 +481,5 @@ function jabber_public_notice($notice)
function jabber_format_notice(&$profile, &$notice)
{
- return $profile->nickname . ': ' . $notice->content;
+ return $profile->nickname . ': ' . $notice->content . ' [' . $notice->id . ']';
}
diff --git a/lib/mail.php b/lib/mail.php
index 5218059e9..dffac3262 100644
--- a/lib/mail.php
+++ b/lib/mail.php
@@ -216,7 +216,8 @@ function mail_subscribe_notify($listenee, $listener)
function mail_subscribe_notify_profile($listenee, $other)
{
- if ($listenee->email && $listenee->emailnotifysub) {
+ if ($other->hasRight(Right::EMAILONSUBSCRIBE) &&
+ $listenee->email && $listenee->emailnotifysub) {
// use the recipient's localization
common_init_locale($listenee->language);
@@ -545,6 +546,10 @@ function mail_notify_message($message, $from=null, $to=null)
function mail_notify_fave($other, $user, $notice)
{
+ if (!$user->hasRight(Right::EMAILONFAVE)) {
+ return;
+ }
+
$profile = $user->getProfile();
$bestname = $profile->getBestName();
@@ -594,10 +599,14 @@ function mail_notify_attn($user, $notice)
$sender = $notice->getProfile();
+ if (!$sender->hasRight(Right::EMAILONREPLY)) {
+ return;
+ }
+
$bestname = $sender->getBestName();
common_init_locale($user->language);
-
+
if ($notice->conversation != $notice->id) {
$conversationEmailText = "The full conversation can be read here:\n\n".
"\t%5\$s\n\n ";
@@ -607,9 +616,9 @@ function mail_notify_attn($user, $notice)
$conversationEmailText = "%5\$s";
$conversationUrl = null;
}
-
+
$subject = sprintf(_('%s (@%s) sent a notice to your attention'), $bestname, $sender->nickname);
-
+
$body = sprintf(_("%1\$s (@%9\$s) just sent a notice to your attention (an '@-reply') on %2\$s.\n\n".
"The notice is here:\n\n".
"\t%3\$s\n\n" .
@@ -635,7 +644,7 @@ function mail_notify_attn($user, $notice)
array('nickname' => $user->nickname)),//%7
common_local_url('emailsettings'), //%8
$sender->nickname); //%9
-
+
common_init_locale();
mail_to_user($user, $subject, $body);
}
diff --git a/lib/mailbox.php b/lib/mailbox.php
index e1d384a06..90a58b4c4 100644
--- a/lib/mailbox.php
+++ b/lib/mailbox.php
@@ -282,7 +282,7 @@ class MailboxAction extends CurrentUserDesignAction
$ns->name);
$this->elementEnd('span');
} else {
- $this->out->element('span', 'device', $source_name);
+ $this->element('span', 'device', $source_name);
}
break;
}
diff --git a/lib/oauthstore.php b/lib/oauthstore.php
index a4ea5ad4d..b04bcbb8b 100644
--- a/lib/oauthstore.php
+++ b/lib/oauthstore.php
@@ -462,6 +462,10 @@ class StatusNetOAuthDataStore extends OAuthDataStore
$subscribed = $this->_getAnyProfile($subscribed_user_uri);
$subscriber = $this->_getAnyProfile($subscriber_uri);
+ if (!$subscriber->hasRight(Right::SUBSCRIBE)) {
+ return _('You have been banned from subscribing.');
+ }
+
$sub->subscribed = $subscribed->id;
$sub->subscriber = $subscriber->id;
diff --git a/lib/plugin.php b/lib/plugin.php
index 59bf3ba9d..87d7be5a7 100644
--- a/lib/plugin.php
+++ b/lib/plugin.php
@@ -76,18 +76,4 @@ class Plugin
{
return true;
}
-
- /*
- * the name of the shortener
- * shortenerInfo associative array with additional information. One possible element is 'freeService' which can be true or false
- * shortener array, first element is the name of the class, second element is an array to be passed as constructor parameters to the class
- */
- function registerUrlShortener($name, $shortenerInfo, $shortener)
- {
- global $_shorteners;
- if(!is_array($_shorteners)){
- $_shorteners=array();
- }
- $_shorteners[$name]=array('info'=>$shortenerInfo, 'callInfo'=>$shortener);
- }
}
diff --git a/lib/profileactionform.php b/lib/profileactionform.php
new file mode 100644
index 000000000..24d4595c0
--- /dev/null
+++ b/lib/profileactionform.php
@@ -0,0 +1,187 @@
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * Superclass for forms that operate on a profile
+ *
+ * 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 Form
+ * @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')) {
+ exit(1);
+}
+
+/**
+ * Superclass for forms that operate on a profile
+ *
+ * Certain forms (block, silence, userflag, sandbox, delete) work on
+ * a single profile and work almost the same. So, this form extracts
+ * a lot of the common code to simplify those forms.
+ *
+ * @category Form
+ * @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 ProfileActionForm extends Form
+{
+ /**
+ * Profile of user to act on
+ */
+
+ var $profile = null;
+
+ /**
+ * Return-to args
+ */
+
+ var $args = null;
+
+ /**
+ * Constructor
+ *
+ * @param HTMLOutputter $out output channel
+ * @param Profile $profile profile of user to act on
+ * @param array $args return-to args
+ */
+
+ function __construct($out=null, $profile=null, $args=null)
+ {
+ parent::__construct($out);
+
+ $this->profile = $profile;
+ $this->args = $args;
+ }
+
+ /**
+ * ID of the form
+ *
+ * @return int ID of the form
+ */
+
+ function id()
+ {
+ return $this->target() . '-' . $this->profile->id;
+ }
+
+ /**
+ * class of the form
+ *
+ * @return string class of the form
+ */
+
+ function formClass()
+ {
+ return 'form_user_'.$this->target();
+ }
+
+ /**
+ * Action of the form
+ *
+ * @return string URL of the action
+ */
+
+ function action()
+ {
+ return common_local_url($this->target());
+ }
+
+ /**
+ * Legend of the Form
+ *
+ * @return void
+ */
+
+ function formLegend()
+ {
+ $this->out->element('legend', null, $this->description());
+ }
+
+ /**
+ * Data elements of the form
+ *
+ * @return void
+ */
+
+ function formData()
+ {
+ $action = $this->target();
+
+ $this->out->hidden($action.'to-' . $this->profile->id,
+ $this->profile->id,
+ 'profileid');
+
+ 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', $this->title(), 'submit',
+ null, $this->description());
+ }
+
+ /**
+ * Action this form targets
+ *
+ * @return string Name of the action, lowercased.
+ */
+
+ function target()
+ {
+ return null;
+ }
+
+ /**
+ * Title of the form
+ *
+ * @return string Title of the form, internationalized
+ */
+
+ function title()
+ {
+ return null;
+ }
+
+ /**
+ * Description of the form
+ *
+ * @return string description of the form, internationalized
+ */
+
+ function description()
+ {
+ return null;
+ }
+}
diff --git a/lib/profileformaction.php b/lib/profileformaction.php
new file mode 100644
index 000000000..8cb5f6a93
--- /dev/null
+++ b/lib/profileformaction.php
@@ -0,0 +1,139 @@
+<?php
+/**
+ * Superclass for actions that operate on a user
+ *
+ * PHP version 5
+ *
+ * StatusNet - the distributed open-source microblogging tool
+ * Copyright (C) 2009, StatusNet, 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/>.
+ *
+ * @category Action
+ * @package StatusNet
+ * @author Evan Prodromou <evan@status.net>
+ * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
+ * @link http://status.net/
+ */
+
+if (!defined('STATUSNET') && !defined('LACONICA')) {
+ exit(1);
+}
+
+/**
+ * Superclass for actions that operate on a user
+ *
+ * @category Action
+ * @package StatusNet
+ * @author Evan Prodromou <evan@status.net>
+ * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
+ * @link http://status.net/
+ */
+
+class ProfileFormAction extends Action
+{
+ var $profile = null;
+
+ /**
+ * Take arguments for running
+ *
+ * @param array $args $_REQUEST args
+ *
+ * @return boolean success flag
+ */
+
+ function prepare($args)
+ {
+ parent::prepare($args);
+
+ $this->checkSessionToken();
+
+ if (!common_logged_in()) {
+ $this->clientError(_('Not logged in.'));
+ return false;
+ }
+
+ $id = $this->trimmed('profileid');
+
+ if (!$id) {
+ $this->clientError(_('No profile specified.'));
+ return false;
+ }
+
+ $this->profile = Profile::staticGet('id', $id);
+
+ if (!$this->profile) {
+ $this->clientError(_('No profile with that ID.'));
+ 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') {
+ $this->handlePost();
+ $this->returnToArgs();
+ }
+ }
+
+ /**
+ * Return to the calling page based on hidden arguments
+ *
+ * @return void
+ */
+
+ function returnToArgs()
+ {
+ 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 {
+ $this->clientError(_("No return-to arguments"));
+ }
+ }
+
+ /**
+ * handle a POST request
+ *
+ * sub-classes should overload this request
+ *
+ * @return void
+ */
+
+ function handlePost()
+ {
+ $this->serverError(_("unimplemented method"));
+ }
+}
diff --git a/lib/profilelist.php b/lib/profilelist.php
index bbb722701..3412d41d1 100644
--- a/lib/profilelist.php
+++ b/lib/profilelist.php
@@ -76,7 +76,7 @@ class ProfileList extends Widget
function startList()
{
- $this->out->elementStart('ul', 'profiles');
+ $this->out->elementStart('ul', 'profiles xoxo');
}
function endList()
@@ -140,7 +140,7 @@ class ProfileListItem extends Widget
function startItem()
{
- $this->out->elementStart('li', array('class' => 'profile',
+ $this->out->elementStart('li', array('class' => 'profile hentry',
'id' => 'profile-' . $this->profile->id));
}
@@ -175,14 +175,14 @@ class ProfileListItem extends Widget
function startProfile()
{
- $this->out->elementStart('div', 'entity_profile vcard');
+ $this->out->elementStart('div', 'entity_profile vcard entry-content');
}
function showAvatar()
{
$avatar = $this->profile->getAvatar(AVATAR_STREAM_SIZE);
$this->out->elementStart('a', array('href' => $this->profile->profileurl,
- 'class' => 'url',
+ 'class' => 'url entry-title',
'rel' => 'contact'));
$this->out->element('img', array('src' => ($avatar) ? $avatar->displayUrl() : Avatar::defaultImage(AVATAR_STREAM_SIZE),
'class' => 'photo avatar',
diff --git a/lib/right.php b/lib/right.php
index 4fc981af0..5e66eae0e 100644
--- a/lib/right.php
+++ b/lib/right.php
@@ -47,5 +47,15 @@ class Right
{
const DELETEOTHERSNOTICE = 'deleteothersnotice';
const CONFIGURESITE = 'configuresite';
+ const DELETEUSER = 'deleteuser';
+ const SILENCEUSER = 'silenceuser';
+ const SANDBOXUSER = 'sandboxuser';
+ const NEWNOTICE = 'newnotice';
+ const PUBLICNOTICE = 'publicnotice';
+ const NEWMESSAGE = 'newmessage';
+ const SUBSCRIBE = 'subscribe';
+ const EMAILONREPLY = 'emailonreply';
+ const EMAILONSUBSCRIBE = 'emailonsubscribe';
+ const EMAILONFAVE = 'emailonfave';
}
diff --git a/lib/router.php b/lib/router.php
index b143cd537..9629267ac 100644
--- a/lib/router.php
+++ b/lib/router.php
@@ -96,7 +96,10 @@ class Router
'unsubscribe', 'confirmaddress', 'recoverpassword',
'invite', 'favor', 'disfavor', 'sup',
'block', 'unblock', 'subedit',
- 'groupblock', 'groupunblock');
+ 'groupblock', 'groupunblock',
+ 'sandbox', 'unsandbox',
+ 'silence', 'unsilence',
+ 'deleteuser');
foreach ($main as $a) {
$m->connect('main/'.$a, array('action' => $a));
diff --git a/lib/sandboxform.php b/lib/sandboxform.php
new file mode 100644
index 000000000..7a98e0a5f
--- /dev/null
+++ b/lib/sandboxform.php
@@ -0,0 +1,80 @@
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * Form for sandboxing a user
+ *
+ * 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 Form
+ * @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')) {
+ exit(1);
+}
+
+/**
+ * Form for sandboxing a user
+ *
+ * @category Form
+ * @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/
+ *
+ * @see UnSandboxForm
+ */
+
+class SandboxForm extends ProfileActionForm
+{
+ /**
+ * Action this form provides
+ *
+ * @return string Name of the action, lowercased.
+ */
+
+ function target()
+ {
+ return 'sandbox';
+ }
+
+ /**
+ * Title of the form
+ *
+ * @return string Title of the form, internationalized
+ */
+
+ function title()
+ {
+ return _('Sandbox');
+ }
+
+ /**
+ * Description of the form
+ *
+ * @return string description of the form, internationalized
+ */
+
+ function description()
+ {
+ return _('Sandbox this user');
+ }
+}
diff --git a/lib/schema.php b/lib/schema.php
index 1e0c1f3e9..560884d9f 100644
--- a/lib/schema.php
+++ b/lib/schema.php
@@ -373,6 +373,26 @@ class Schema
}
/**
+ * Ensures that the table that backs a given
+ * Plugin_DataObject class exists.
+ *
+ * If the table does not yet exist, it will
+ * create the table. If it does exist, it will
+ * alter the table to match the column definitions.
+ *
+ * @param Plugin_DataObject $dataObjectClass
+ *
+ * @return boolean success flag
+ */
+
+ public function ensureDataObject($dataObjectClass)
+ {
+ $obj = new $dataObjectClass();
+ $tableDef = $obj->tableDef();
+ return $this->ensureTable($tableDef->name,$tableDef->columns);
+ }
+
+ /**
* Ensures that a table exists with the given
* name and the given column definitions.
*
@@ -544,6 +564,19 @@ class TableDef
public $name;
/** array of ColumnDef objects for the columns. */
public $columns;
+
+ /**
+ * Constructor.
+ *
+ * @param string $name name of the table
+ * @param array $columns columns in the table
+ */
+
+ function __construct($name=null,$columns=null)
+ {
+ $this->name = $name;
+ $this->columns = $columns;
+ }
}
/**
@@ -576,6 +609,8 @@ class ColumnDef
/** 'extra' stuff. Returned by MySQL, largely
* unused. */
public $extra;
+ /** auto increment this field if no value is specific for it during an insert **/
+ public $auto_increment;
/**
* Constructor.
@@ -591,7 +626,7 @@ class ColumnDef
function __construct($name=null, $type=null, $size=null,
$nullable=true, $key=null, $default=null,
- $extra=null)
+ $extra=null, $auto_increment=false)
{
$this->name = strtolower($name);
$this->type = strtolower($type);
@@ -600,6 +635,7 @@ class ColumnDef
$this->key = $key;
$this->default = $default;
$this->extra = $extra;
+ $this->auto_increment = $auto_increment;
}
/**
@@ -617,7 +653,8 @@ class ColumnDef
$this->_typeMatch($other) &&
$this->_defaultMatch($other) &&
$this->_nullMatch($other) &&
- $this->key == $other->key);
+ $this->key == $other->key &&
+ $this->auto_increment == $other->auto_increment);
}
/**
diff --git a/lib/silenceform.php b/lib/silenceform.php
new file mode 100644
index 000000000..9673fa120
--- /dev/null
+++ b/lib/silenceform.php
@@ -0,0 +1,80 @@
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * Form for silencing a user
+ *
+ * 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 Form
+ * @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')) {
+ exit(1);
+}
+
+/**
+ * Form for silencing a user
+ *
+ * @category Form
+ * @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/
+ *
+ * @see UnSilenceForm
+ */
+
+class SilenceForm extends ProfileActionForm
+{
+ /**
+ * Action this form provides
+ *
+ * @return string Name of the action, lowercased.
+ */
+
+ function target()
+ {
+ return 'silence';
+ }
+
+ /**
+ * Title of the form
+ *
+ * @return string Title of the form, internationalized
+ */
+
+ function title()
+ {
+ return _('Silence');
+ }
+
+ /**
+ * Description of the form
+ *
+ * @return string description of the form, internationalized
+ */
+
+ function description()
+ {
+ return _('Silence this user');
+ }
+}
diff --git a/lib/subs.php b/lib/subs.php
index 934380b76..2fc3160de 100644
--- a/lib/subs.php
+++ b/lib/subs.php
@@ -44,6 +44,10 @@ function subs_subscribe_user($user, $other_nickname)
function subs_subscribe_to($user, $other)
{
+ if (!$user->hasRight(Right::SUBSCRIBE)) {
+ return _('You have been banned from subscribing.');
+ }
+
if ($user->isSubscribed($other)) {
return _('Already subscribed!');
}
@@ -121,7 +125,7 @@ function subs_unsubscribe_user($user, $other_nickname)
function subs_unsubscribe_to($user, $other)
{
if (!$user->isSubscribed($other))
- return _('Not subscribed!.');
+ return _('Not subscribed!');
$sub = DB_DataObject::factory('subscription');
diff --git a/lib/unblockform.php b/lib/unblockform.php
index f1343757c..4fe28b21a 100644
--- a/lib/unblockform.php
+++ b/lib/unblockform.php
@@ -28,12 +28,10 @@
* @link http://status.net/
*/
-if (!defined('STATUSNET') && !defined('LACONICA')) {
+if (!defined('STATUSNET')) {
exit(1);
}
-require_once INSTALLDIR.'/lib/form.php';
-
/**
* Form for unblocking a user
*
@@ -47,106 +45,38 @@ require_once INSTALLDIR.'/lib/form.php';
* @see BlockForm
*/
-class UnblockForm extends Form
+class UnblockForm extends ProfileActionForm
{
/**
- * Profile of user to unblock
- */
-
- var $profile = null;
-
- /**
- * Return-to args
- */
-
- var $args = null;
-
- /**
- * Constructor
- *
- * @param HTMLOutputter $out output channel
- * @param Profile $profile profile of user to unblock
- * @param array $args return-to args
- */
-
- function __construct($out=null, $profile=null, $args=null)
- {
- parent::__construct($out);
-
- $this->profile = $profile;
- $this->args = $args;
- }
-
- /**
- * ID of the form
- *
- * @return int ID of the form
- */
-
- function id()
- {
- return 'unblock-' . $this->profile->id;
- }
-
- /**
- * class of the form
+ * Action this form provides
*
- * @return string class of the form
+ * @return string Name of the action, lowercased.
*/
- function formClass()
+ function target()
{
- return 'form_user_unblock';
+ return 'unblock';
}
/**
- * Action of the form
- *
- * @return string URL of the action
- */
-
- function action()
- {
- return common_local_url('unblock');
- }
-
- /**
- * Legend of the Form
- *
- * @return void
- */
- function formLegend()
- {
- $this->out->element('legend', null, _('Unblock this user'));
- }
-
-
- /**
- * Data elements of the form
+ * Title of the form
*
- * @return void
+ * @return string Title of the form, internationalized
*/
- function formData()
+ function title()
{
- $this->out->hidden('unblockto-' . $this->profile->id,
- $this->profile->id,
- 'unblockto');
- if ($this->args) {
- foreach ($this->args as $k => $v) {
- $this->out->hidden('returnto-' . $k, $v);
- }
- }
+ return _('Unblock');
}
/**
- * Action elements
+ * Description of the form
*
- * @return void
+ * @return string description of the form, internationalized
*/
- function formActions()
+ function description()
{
- $this->out->submit('submit', _('Unblock'), 'submit', null, _('Unblock this user'));
+ return _('Unlock this user');
}
}
diff --git a/lib/unsandboxform.php b/lib/unsandboxform.php
new file mode 100644
index 000000000..a77634244
--- /dev/null
+++ b/lib/unsandboxform.php
@@ -0,0 +1,82 @@
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * Form for unsandboxing a user
+ *
+ * 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 Form
+ * @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')) {
+ exit(1);
+}
+
+/**
+ * Form for unsandboxing a user
+ *
+ * Removes the "sandboxed" role for a user.
+ *
+ * @category Form
+ * @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/
+ *
+ * @see UnSandboxForm
+ */
+
+class UnsandboxForm extends ProfileActionForm
+{
+ /**
+ * Action this form provides
+ *
+ * @return string Name of the action, lowercased.
+ */
+
+ function target()
+ {
+ return 'unsandbox';
+ }
+
+ /**
+ * Title of the form
+ *
+ * @return string Title of the form, internationalized
+ */
+
+ function title()
+ {
+ return _('Unsandbox');
+ }
+
+ /**
+ * Description of the form
+ *
+ * @return string description of the form, internationalized
+ */
+
+ function description()
+ {
+ return _('Unsandbox this user');
+ }
+}
diff --git a/lib/unsilenceform.php b/lib/unsilenceform.php
new file mode 100644
index 000000000..ac02b8b6c
--- /dev/null
+++ b/lib/unsilenceform.php
@@ -0,0 +1,80 @@
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * Form for unsilencing a user
+ *
+ * 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 Form
+ * @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')) {
+ exit(1);
+}
+
+/**
+ * Form for unsilencing a user
+ *
+ * @category Form
+ * @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/
+ *
+ * @see SilenceForm
+ */
+
+class UnSilenceForm extends ProfileActionForm
+{
+ /**
+ * Action this form provides
+ *
+ * @return string Name of the action, lowercased.
+ */
+
+ function target()
+ {
+ return 'unsilence';
+ }
+
+ /**
+ * Title of the form
+ *
+ * @return string Title of the form, internationalized
+ */
+
+ function title()
+ {
+ return _('Unsilence');
+ }
+
+ /**
+ * Description of the form
+ *
+ * @return string description of the form, internationalized
+ */
+
+ function description()
+ {
+ return _('Unsilence this user');
+ }
+}
diff --git a/lib/userprofile.php b/lib/userprofile.php
index 4f9d4984f..ee205af85 100644
--- a/lib/userprofile.php
+++ b/lib/userprofile.php
@@ -283,22 +283,57 @@ class UserProfile extends Widget
}
}
+ // return-to args, so we don't have to keep re-writing them
+
+ list($action, $r2args) = $this->out->returnToArgs();
+
+ // push the action into the list
+
+ $r2args['action'] = $action;
+
// block/unblock
$blocked = $cur->hasBlocked($this->profile);
$this->out->elementStart('li', 'entity_block');
if ($blocked) {
- $ubf = new UnblockForm($this->out, $this->profile,
- array('action' => 'showstream',
- 'nickname' => $this->profile->nickname));
+ $ubf = new UnblockForm($this->out, $this->profile, $r2args);
$ubf->show();
} else {
- $bf = new BlockForm($this->out, $this->profile,
- array('action' => 'showstream',
- 'nickname' => $this->profile->nickname));
+ $bf = new BlockForm($this->out, $this->profile, $r2args);
$bf->show();
}
$this->out->elementEnd('li');
+
+ if ($cur->hasRight(Right::SANDBOXUSER)) {
+ $this->out->elementStart('li', 'entity_sandbox');
+ if ($this->user->isSandboxed()) {
+ $usf = new UnSandboxForm($this->out, $this->profile, $r2args);
+ $usf->show();
+ } else {
+ $sf = new SandboxForm($this->out, $this->profile, $r2args);
+ $sf->show();
+ }
+ $this->out->elementEnd('li');
+ }
+
+ if ($cur->hasRight(Right::SILENCEUSER)) {
+ $this->out->elementStart('li', 'entity_silence');
+ if ($this->user->isSilenced()) {
+ $usf = new UnSilenceForm($this->out, $this->profile, $r2args);
+ $usf->show();
+ } else {
+ $sf = new SilenceForm($this->out, $this->profile, $r2args);
+ $sf->show();
+ }
+ $this->out->elementEnd('li');
+ }
+
+ if ($cur->hasRight(Right::DELETEUSER)) {
+ $this->out->elementStart('li', 'entity_delete');
+ $df = new DeleteUserForm($this->out, $this->profile, $r2args);
+ $df->show();
+ $this->out->elementEnd('li');
+ }
}
}
diff --git a/lib/util.php b/lib/util.php
index 81160d052..68f3520db 100644
--- a/lib/util.php
+++ b/lib/util.php
@@ -350,8 +350,11 @@ function common_current_user()
common_ensure_session();
$id = isset($_SESSION['userid']) ? $_SESSION['userid'] : false;
if ($id) {
- $_cur = User::staticGet($id);
- return $_cur;
+ $user = User::staticGet($id);
+ if ($user) {
+ $_cur = $user;
+ return $_cur;
+ }
}
}
@@ -1420,25 +1423,18 @@ function common_shorten_url($long_url)
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
- $svc = 'ur1.ca';
+ $shortenerName = 'ur1.ca';
} else {
- $svc = $user->urlshorteningservice;
- }
- global $_shorteners;
- if (!isset($_shorteners[$svc])) {
- //the user selected service doesn't exist, so default to ur1.ca
- $svc = 'ur1.ca';
- }
- if (!isset($_shorteners[$svc])) {
- // no shortener plugins installed.
- return $long_url;
+ $shortenerName = $user->urlshorteningservice;
}
- $reflectionObj = new ReflectionClass($_shorteners[$svc]['callInfo'][0]);
- $short_url_service = $reflectionObj->newInstanceArgs($_shorteners[$svc]['callInfo'][1]);
- $short_url = $short_url_service->shorten($long_url);
-
- return $short_url;
+ if(Event::handle('StartShortenUrl', array($long_url,$shortenerName,&$shortenedUrl))){
+ //URL wasn't shortened, so return the long url
+ return $long_url;
+ }else{
+ //URL was shortened, so return the result
+ return $shortenedUrl;
+ }
}
function common_client_ip()