class Command
{
-
var $user = null;
function __construct($user=null)
}
}
-
/**
* Override this with the meat!
*
{
$user = null;
if (Event::handle('StartCommandGetUser', array($this, $arg, &$user))) {
- $user = User::staticGet('nickname', $arg);
+ $user = User::staticGet('nickname', Nickname::normalize($arg));
}
Event::handle('EndCommandGetUser', array($this, $arg, &$user));
if (!$user){
function handle($channel)
{
$notice = $this->getNotice($this->other);
+
+ $fave = new Fave();
+ $fave->user_id = $this->user->id;
+ $fave->notice_id = $notice->id;
+ $fave->find();
+
+ if ($fave->fetch()) {
+ // TRANS: Error message text shown when a favorite could not be set because it has already been favorited.
+ $channel->error($this->user, _('Could not create favorite: already favorited.'));
+ return;
+ }
+
$fave = Fave::addNew($this->user->getProfile(), $notice);
if (!$fave) {
$other = User::staticGet('id', $notice->profile_id);
- if ($other && $other->id != $user->id) {
+ if ($other && $other->id != $this->user->id) {
if ($other->email && $other->emailnotifyfav) {
mail_notify_fave($other, $this->user, $notice);
}
// TRANS: Text shown when a notice has been marked as favourite successfully.
$channel->output($this->user, _('Notice marked as fave.'));
}
-
}
class JoinCommand extends Command
$cur->nickname,
$group->nickname));
}
-
}
+
class DropCommand extends Command
{
var $other = null;
$cur->nickname,
$group->nickname));
}
-
}
class WhoisCommand extends Command
// TRANS: Whois output.
// TRANS: %1$s nickname of the queried user, %2$s is their profile URL.
- $whois = sprintf(_("%1\$s (%2\$s)"), $recipient->nickname,
+ $whois = sprintf(_m('WHOIS',"%1\$s (%2\$s)"), $recipient->nickname,
$recipient->profileurl);
if ($recipient->fullname) {
// TRANS: Whois output. %s is the full name of the queried user.
throw $e;
}
// TRANS: Command exception text shown when trying to send a direct message to a remote user (a user not registered at the current server).
+ // TRANS: %s is a remote profile.
throw new CommandException(sprintf(_('%s is a remote profile; you can only send direct messages to users on the same server.'), $this->other));
}
return;
}
- $this->text = common_shorten_links($this->text);
+ $this->text = $this->user->shortenLinks($this->text);
if (Message::contentTooLong($this->text)) {
// XXX: i18n. Needs plural support.
- // TRANS: Message given if content is too long.
+ // TRANS: Message given if content is too long. %1$sd is used for plural.
// TRANS: %1$d is the maximum number of characters, %2$d is the number of submitted characters.
- $channel->error($this->user, sprintf(_('Message too long - maximum is %1$d characters, you sent %2$d.'),
+ $channel->error($this->user, sprintf(_m('Message too long - maximum is %1$d character, you sent %2$d.',
+ 'Message too long - maximum is %1$d characters, you sent %2$d.',
+ Message::maxContent()),
Message::maxContent(), mb_strlen($this->text)));
return;
}
return;
}
- $this->text = common_shorten_links($this->text);
+ $this->text = $this->user->shortenLinks($this->text);
if (Notice::contentTooLong($this->text)) {
// XXX: i18n. Needs plural support.
- // TRANS: Message given if content of a notice for a reply is too long.
+ // TRANS: Message given if content of a notice for a reply is too long. %1$d is used for plural.
// TRANS: %1$d is the maximum number of characters, %2$d is the number of submitted characters.
- $channel->error($this->user, sprintf(_('Notice too long - maximum is %1$d characters, you sent %2$d.'),
+ $channel->error($this->user, sprintf(_m('Notice too long - maximum is %1$d character, you sent %2$d.',
+ 'Notice too long - maximum is %1$d characters, you sent %2$d.',
+ Notice::maxContent()),
Notice::maxContent(), mb_strlen($this->text)));
return;
}
class GetCommand extends Command
{
-
var $other = null;
function __construct($user, $other)
class SubCommand extends Command
{
-
var $other = null;
function __construct($user, $other)
class UnsubCommand extends Command
{
-
var $other = null;
function __construct($user, $other)
class OffCommand extends Command
{
var $other = null;
+
function __construct($user, $other=null)
{
parent::__construct($user);
function handle($channel)
{
$channel->output($this->user,
- // TRANS: Help text for commands.
+ // TRANS: Help text for commands. Do not translate the command names themselves; they are fixed strings.
_("Commands:\n".
"on - turn on notifications\n".
"off - turn off notifications\n".