From fa0dae4cb1eba0d65923ea96821897fd568ef70a Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Sun, 20 Sep 2009 21:39:57 -0700 Subject: [PATCH 1/4] Don't trigger E_NOTICE when looking for commands in the notice input explode() only returns one item if there was no space, leading to an E_NOTICE about an undefined array index in the list($a,$b) pattern. --- lib/commandinterpreter.php | 42 ++++++++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/lib/commandinterpreter.php b/lib/commandinterpreter.php index 6e4340e5dc..60fc4c3c44 100644 --- a/lib/commandinterpreter.php +++ b/lib/commandinterpreter.php @@ -28,7 +28,7 @@ class CommandInterpreter # XXX: localise $text = preg_replace('/\s+/', ' ', trim($text)); - list($cmd, $arg) = explode(' ', $text, 2); + list($cmd, $arg) = $this->split_arg($text); # We try to support all the same commands as Twitter, see # http://getsatisfaction.com/twitter/topics/what_are_the_twitter_commands @@ -43,7 +43,7 @@ class CommandInterpreter return new HelpCommand($user); case 'on': if ($arg) { - list($other, $extra) = explode(' ', $arg, 2); + list($other, $extra) = $this->split_arg($arg); if ($extra) { return null; } else { @@ -54,7 +54,7 @@ class CommandInterpreter } case 'off': if ($arg) { - list($other, $extra) = explode(' ', $arg, 2); + list($other, $extra) = $this->split_arg($arg); if ($extra) { return null; } else { @@ -74,7 +74,7 @@ class CommandInterpreter if (!$arg) { return null; } - list($other, $extra) = explode(' ', $arg, 2); + list($other, $extra) = $this->split_arg($arg); if ($extra) { return null; } else { @@ -84,7 +84,7 @@ class CommandInterpreter if (!$arg) { return null; } - list($other, $extra) = explode(' ', $arg, 2); + list($other, $extra) = $this->split_arg($arg); if ($extra) { return null; } else { @@ -95,7 +95,7 @@ class CommandInterpreter if (!$arg) { return null; } - list($other, $extra) = explode(' ', $arg, 2); + list($other, $extra) = $this->split_arg($arg); if ($extra) { return null; } else { @@ -106,7 +106,7 @@ class CommandInterpreter if (!$arg) { return null; } - list($other, $extra) = explode(' ', $arg, 2); + list($other, $extra) = $this->split_arg($arg); if ($extra) { return null; } else { @@ -117,7 +117,7 @@ class CommandInterpreter if (!$arg) { return null; } - list($other, $extra) = explode(' ', $arg, 2); + list($other, $extra) = $this->split_arg($arg); if ($extra) { return null; } else { @@ -128,7 +128,7 @@ class CommandInterpreter if (!$arg) { return null; } - list($other, $extra) = explode(' ', $arg, 2); + list($other, $extra) = $this->split_arg($arg); if (!$extra) { return null; } else { @@ -138,7 +138,7 @@ class CommandInterpreter if (!$arg) { return null; } - list($other, $extra) = explode(' ', $arg, 2); + list($other, $extra) = $this->split_arg($arg); if ($extra) { return null; } else { @@ -148,7 +148,7 @@ class CommandInterpreter if (!$arg) { return null; } - list($other, $extra) = explode(' ', $arg, 2); + list($other, $extra) = $this->split_arg($arg); if ($extra) { return null; } else { @@ -158,7 +158,7 @@ class CommandInterpreter if (!$arg) { return null; } - list($other, $extra) = explode(' ', $arg, 2); + list($other, $extra) = $this->split_arg($arg); if ($extra) { return null; } else { @@ -173,7 +173,7 @@ class CommandInterpreter if (!$arg) { return null; } - list($other, $extra) = explode(' ', $arg, 2); + list($other, $extra) = $this->split_arg($arg); if ($extra) { return null; } else { @@ -183,7 +183,7 @@ class CommandInterpreter if (!$arg) { return null; } - list($word, $extra) = explode(' ', $arg, 2); + list($word, $extra) = $this->split_arg($arg); if ($extra) { return null; } else if ($word == 'off') { @@ -195,7 +195,7 @@ class CommandInterpreter if (!$arg) { return null; } - list($word, $extra) = explode(' ', $arg, 2); + list($word, $extra) = $this->split_arg($arg); if ($extra) { return null; } else if ($word == 'all') { @@ -213,5 +213,17 @@ class CommandInterpreter return false; } } + + /** + * Split arguments without triggering a PHP notice warning + */ + function split_arg($text) + { + $pieces = explode(' ', $text, 2); + if (count($pieces) == 1) { + $pieces[] = null; + } + return $pieces; + } } From 5eaf9f7d2eebaf6f656bfbd3d04f8a17c31898d2 Mon Sep 17 00:00:00 2001 From: Craig Andrews Date: Mon, 12 Oct 2009 21:21:00 -0400 Subject: [PATCH 2/4] Added a new plugin that requires a user to have a validated email address before being allowed to post notices --- .../RequireValidatedEmailPlugin.php | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 plugins/RequireValidatedEmail/RequireValidatedEmailPlugin.php diff --git a/plugins/RequireValidatedEmail/RequireValidatedEmailPlugin.php b/plugins/RequireValidatedEmail/RequireValidatedEmailPlugin.php new file mode 100644 index 0000000000..4806538a04 --- /dev/null +++ b/plugins/RequireValidatedEmail/RequireValidatedEmailPlugin.php @@ -0,0 +1,52 @@ +. + * + * @category Plugin + * @package StatusNet + * @author Craig Andrews + * @copyright 2009 Craig Andrews http://candrews.integralblue.com + * @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 RequireValidatedEmailPlugin extends Plugin +{ + function __construct() + { + parent::__construct(); + } + + function onStartNoticeSave($notice) + { + $user = User::staticGet('id', $notice->profile_id); + if (!empty($user)) { // it's a remote notice + if (empty($user->email)) { + throw new ClientException(_("You must validate your email address before posting.")); + } + } + return true; + } +} + From 16243737606d4e1f29a94e07369e69f430d3ecc8 Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Tue, 13 Oct 2009 11:44:56 +0000 Subject: [PATCH 3/4] Updated default theme to use the CSS Sprites method for common icons --- theme/default/css/display.css | 48 ++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 21 deletions(-) diff --git a/theme/default/css/display.css b/theme/default/css/display.css index 86369cb993..3993da7177 100644 --- a/theme/default/css/display.css +++ b/theme/default/css/display.css @@ -88,7 +88,7 @@ color:#333333; color:#000000; } #form_notice label[for=notice_data-attach] { -background:transparent url(../../base/images/icons/twotone/green/clip-01.gif) no-repeat 0 45%; +background:transparent url(../../base/images/icons/icons-01.png) no-repeat 0 -328px; } #form_notice #notice_data-attach { opacity:0; @@ -150,16 +150,18 @@ background-color:#9BB43E; #export_data li a { background-repeat:no-repeat; -background-position:0 45%; } #export_data li a.rss { -background-image:url(../../base/images/icons/icon_rss.png); +background-image:url(../../base/images/icons/icons-01.png); +background-position:0 -130px; } #export_data li a.atom { -background-image:url(../../base/images/icons/icon_atom.png); +background-image:url(../../base/images/icons/icons-01.png); +background-position:0 -64px; } #export_data li a.foaf { -background-image:url(../../base/images/icons/icon_foaf.gif); +background-image:url(../../base/images/icons/icons-01.png); +background-position:0 1px; } .entity_edit a, @@ -171,7 +173,6 @@ background-image:url(../../base/images/icons/icon_foaf.gif); .form_group_unblock input.submit, .entity_nudge p, .form_make_admin input.submit { -background-position: 0 40%; background-repeat: no-repeat; background-color:transparent; } @@ -189,43 +190,48 @@ background-color:#87B4C8; } .entity_edit a { -background-image:url(../../base/images/icons/twotone/green/edit.gif); +background-image:url(../../base/images/icons/icons-01.png); +background-position: 0 -718px; } .entity_send-a-message a { -background-image:url(../../base/images/icons/twotone/green/quote.gif); +background-image:url(../../base/images/icons/icons-01.png); +background-position: 0 -849px; } .entity_nudge p, .form_user_nudge input.submit { -background-image:url(../../base/images/icons/twotone/green/mail.gif); +background-image:url(../../base/images/icons/icons-01.png); +background-position: 0 -785px; } .form_user_block input.submit, .form_user_unblock input.submit, .form_group_block input.submit, .form_group_unblock input.submit { -background-image:url(../../base/images/icons/twotone/green/shield.gif); +background-image:url(../../base/images/icons/icons-01.png); +background-position: 0 -918px; } .form_make_admin input.submit { -background-image:url(../../base/images/icons/twotone/green/admin.gif); +background-image:url(../../base/images/icons/icons-01.png); +background-position: 0 -983px; } /* NOTICES */ .notice .attachment { -background:transparent url(../../base/images/icons/twotone/green/clip-02.gif) no-repeat 0 45%; +background:transparent url(../../base/images/icons/icons-01.png) no-repeat 0 -394px; } #attachments .attachment { background:none; } .notice-options .notice_reply { -background:transparent url(../../base/images/icons/twotone/green/reply.gif) no-repeat 0 45%; +background:transparent url(../../base/images/icons/icons-01.png) no-repeat 0 -589px; } .notice-options form.form_favor input.submit { -background:transparent url(../../base/images/icons/twotone/green/favourite.gif) no-repeat 0 45%; +background:transparent url(../../base/images/icons/icons-01.png) no-repeat 0 -457px; } .notice-options form.form_disfavor input.submit { -background:transparent url(../../base/images/icons/twotone/green/disfavourite.gif) no-repeat 0 45%; +background:transparent url(../../base/images/icons/icons-01.png) no-repeat 0 -523px; } .notice-options .notice_delete { -background:transparent url(../../base/images/icons/twotone/green/trash.gif) no-repeat 0 45%; +background:transparent url(../../base/images/icons/icons-01.png) no-repeat 0 -655px; } .notices div.entry-content, @@ -262,7 +268,7 @@ background-color:rgba(200, 200, 200, 0.300); /*END: NOTICES */ #new_group a { -background:transparent url(../../base/images/icons/twotone/green/news.gif) no-repeat 0 45%; +background:transparent url(../../base/images/icons/icons-01.png) no-repeat 0 -1054px; } .pagination .nav_prev a, @@ -271,10 +277,10 @@ background-repeat:no-repeat; border-color:#C8D1D5; } .pagination .nav_prev a { -background-image:url(../../base/images/icons/twotone/green/arrow-left.gif); -background-position:10% 45%; +background-image:url(../../base/images/icons/icons-01.png); +background-position:10% -187px; } .pagination .nav_next a { -background-image:url(../../base/images/icons/twotone/green/arrow-right.gif); -background-position:90% 45%; +background-image:url(../../base/images/icons/icons-01.png); +background-position:105% -252px; } From 659a04b556f75551548c0b2fff633b15cd114135 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Tue, 13 Oct 2009 16:54:57 +0000 Subject: [PATCH 4/4] Include long-form attachment URL in notice if URL shortening is disabled. Previously, the attachment URL would simply be dropped when shortening returned false instead of a short URL... the attachment was present if you clicked through to notice details but didn't appear in the timeline, making it nigh-impossible to see the attachment. --- actions/newnotice.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/actions/newnotice.php b/actions/newnotice.php index d5b0332f48..9ee031f936 100644 --- a/actions/newnotice.php +++ b/actions/newnotice.php @@ -240,6 +240,10 @@ class NewnoticeAction extends Action $this->maybeAddRedir($fileRecord->id, $fileurl); $short_fileurl = common_shorten_url($fileurl); + if (!$short_fileurl) { + // todo -- Consider forcing default shortener if none selected? + $short_fileurl = $fileurl; + } $content_shortened .= ' ' . $short_fileurl; if (Notice::contentTooLong($content_shortened)) {