From 227d4b688949a70c1dd3923628a101e1f0208e15 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Mon, 15 Nov 2010 14:15:41 -0800 Subject: Stub ModPlus plugin: will hold experimental UI improvements for mod actions --- plugins/ModPlus/ModPlusPlugin.php | 43 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 plugins/ModPlus/ModPlusPlugin.php (limited to 'plugins') diff --git a/plugins/ModPlus/ModPlusPlugin.php b/plugins/ModPlus/ModPlusPlugin.php new file mode 100644 index 000000000..485b82181 --- /dev/null +++ b/plugins/ModPlus/ModPlusPlugin.php @@ -0,0 +1,43 @@ +. + */ + +if (!defined('STATUSNET')) { + exit(1); +} + +/** + * Some UI extras for now... + * + * @package ModPlusPlugin + * @maintainer Brion Vibber + */ +class ModPlusPlugin extends Plugin +{ + function onPluginVersion(&$versions) + { + $versions[] = array('name' => 'ModPlus', + 'version' => STATUSNET_VERSION, + 'author' => 'Brion Vibber', + 'homepage' => 'http://status.net/wiki/Plugin:ModPlus', + 'rawdescription' => + _m('UI extensions for profile moderation actions.')); + + return true; + } +} -- cgit v1.2.3-54-g00ecf From 0e763b49024703efc3e2bbadad83b03d3dd62790 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Mon, 15 Nov 2010 15:34:12 -0800 Subject: Stub RemoteprofileAction to show the standard profile header stuff for offsite users -- provides a way to get at the mod & block controls for remote users. --- plugins/ModPlus/ModPlusPlugin.php | 55 ++++++++++++++++++++++++++ plugins/ModPlus/remoteprofileaction.php | 69 +++++++++++++++++++++++++++++++++ 2 files changed, 124 insertions(+) create mode 100644 plugins/ModPlus/remoteprofileaction.php (limited to 'plugins') diff --git a/plugins/ModPlus/ModPlusPlugin.php b/plugins/ModPlus/ModPlusPlugin.php index 485b82181..89bbdf857 100644 --- a/plugins/ModPlus/ModPlusPlugin.php +++ b/plugins/ModPlus/ModPlusPlugin.php @@ -40,4 +40,59 @@ class ModPlusPlugin extends Plugin return true; } + + /** + * Load JS at runtime if we're logged in. + * + * @param Action $action + * @return boolean hook result + */ + function onEndShowScripts($action) + { + $user = common_current_user(); + if ($user) { + $action->script('plugins/ModPlus/modplus.js'); + } + return true; + } + + /** + * Autoloader + * + * Loads our classes if they're requested. + * + * @param string $cls Class requested + * + * @return boolean hook return + */ + function onAutoload($cls) + { + switch ($cls) + { + case 'RemoteprofileAction': + case 'RemoteProfileAction': + require_once dirname(__FILE__) . '/remoteprofileaction.php'; + return false; + default: + return true; + } + } + + /** + * Add OpenID-related paths to the router table + * + * Hook for RouterInitialized event. + * + * @param Net_URL_Mapper $m URL mapper + * + * @return boolean hook return + */ + function onStartInitializeRouter($m) + { + $m->connect('user/remote/:id', + array('action' => 'remoteprofile'), + array('id' => '[\d]+')); + + return true; + } } diff --git a/plugins/ModPlus/remoteprofileaction.php b/plugins/ModPlus/remoteprofileaction.php new file mode 100644 index 000000000..ca8204511 --- /dev/null +++ b/plugins/ModPlus/remoteprofileaction.php @@ -0,0 +1,69 @@ +arg('id'); + $this->user = false; + $this->profile = Profile::staticGet('id', $id); + + if (!$this->profile) { + $this->serverError(_('User has no profile.')); + return false; + } + + $this->tag = $this->trimmed('tag'); + $this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1; + common_set_returnto($this->selfUrl()); + return true; + } + + function handle($args) + { + // skip yadis thingy + $this->showPage(); + } + + function title() + { + // maybe fixed in 0.9.x + if (!empty($this->profile->fullname)) { + $base = $this->profile->fullname . ' (' . $this->profile->nickname . ') '; + } else { + $base = $this->profile->nickname; + } + } + + function showContent() + { + $this->showProfile(); + // don't show notices + } + + function getFeeds() + { + // none + } + + function extraHead() + { + // none + } + function showLocalNav() + { + // none...? + } + function showSections() + { + ProfileAction::showSections(); + // skip tag cloud + } + +} \ No newline at end of file -- cgit v1.2.3-54-g00ecf From 16f1c764c0ac89f922654f9f663faaada611b8e2 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Mon, 15 Nov 2010 15:40:07 -0800 Subject: RemoteProfileAction: redirect to the regular user profile page if given a local user. --- plugins/ModPlus/remoteprofileaction.php | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'plugins') diff --git a/plugins/ModPlus/remoteprofileaction.php b/plugins/ModPlus/remoteprofileaction.php index ca8204511..9c089ee23 100644 --- a/plugins/ModPlus/remoteprofileaction.php +++ b/plugins/ModPlus/remoteprofileaction.php @@ -19,6 +19,14 @@ class RemoteProfileAction extends ShowstreamAction return false; } + $user = User::staticGet('id', $this->profile->id); + if ($user) { + // This is a local user -- send to their regular profile. + $url = common_local_url('showstream', array('nickname' => $user->nickname)); + common_redirect($url); + return false; + } + $this->tag = $this->trimmed('tag'); $this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1; common_set_returnto($this->selfUrl()); -- cgit v1.2.3-54-g00ecf From 88c35c2ccea5edcd08708f30247dc51a7473ecce Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Mon, 15 Nov 2010 15:57:57 -0800 Subject: visual tweaks for RemoteProfileAction --- plugins/ModPlus/remoteprofileaction.php | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'plugins') diff --git a/plugins/ModPlus/remoteprofileaction.php b/plugins/ModPlus/remoteprofileaction.php index 9c089ee23..f3ddbc7c6 100644 --- a/plugins/ModPlus/remoteprofileaction.php +++ b/plugins/ModPlus/remoteprofileaction.php @@ -47,12 +47,23 @@ class RemoteProfileAction extends ShowstreamAction } else { $base = $this->profile->nickname; } + $host = parse_url($this->profile->profileurl, PHP_URL_HOST); + return sprintf(_m('%s on %s'), $base, $host); } - function showContent() + /** + * Instead of showing notices, link to the original offsite profile. + */ + function showNotices() { - $this->showProfile(); - // don't show notices + $url = $this->profile->profileurl; + $host = parse_url($url, PHP_URL_HOST); + $markdown = sprintf( + _m('This profile is registered on another site; see [the profile page on %s](%s).'), + $host, + $url); + $html = common_markup_to_html($markdown); + $this->raw($html); } function getFeeds() @@ -64,10 +75,13 @@ class RemoteProfileAction extends ShowstreamAction { // none } + function showLocalNav() { - // none...? + $nav = new PublicGroupNav($this); + $nav->show(); } + function showSections() { ProfileAction::showSections(); -- cgit v1.2.3-54-g00ecf From 5fdcba472b8673380248ab0d5dce45967f774caa Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Mon, 15 Nov 2010 16:12:16 -0800 Subject: RemoteProfileAction cleanup: - meta robots to prevent spidering - a little notice if silenced --- lib/userprofile.php | 7 +++++-- plugins/ModPlus/remoteprofileaction.php | 11 ++++++++++- 2 files changed, 15 insertions(+), 3 deletions(-) (limited to 'plugins') diff --git a/lib/userprofile.php b/lib/userprofile.php index 9124b7c94..2813f735e 100644 --- a/lib/userprofile.php +++ b/lib/userprofile.php @@ -321,6 +321,9 @@ class UserProfile extends Widget } $this->out->elementEnd('li'); + // Some actions won't be applicable to non-local users. + $isLocal = !empty($this->user); + if ($cur->hasRight(Right::SANDBOXUSER) || $cur->hasRight(Right::SILENCEUSER) || $cur->hasRight(Right::DELETEUSER)) { @@ -351,7 +354,7 @@ class UserProfile extends Widget $this->out->elementEnd('li'); } - if ($cur->hasRight(Right::DELETEUSER)) { + if ($isLocal && $cur->hasRight(Right::DELETEUSER)) { $this->out->elementStart('li', 'entity_delete'); $df = new DeleteUserForm($this->out, $this->profile, $r2args); $df->show(); @@ -361,7 +364,7 @@ class UserProfile extends Widget $this->out->elementEnd('li'); } - if ($cur->hasRight(Right::GRANTROLE)) { + if ($isLocal && $cur->hasRight(Right::GRANTROLE)) { $this->out->elementStart('li', 'entity_role'); $this->out->element('p', null, _('User role')); $this->out->elementStart('ul'); diff --git a/plugins/ModPlus/remoteprofileaction.php b/plugins/ModPlus/remoteprofileaction.php index f3ddbc7c6..5b25da170 100644 --- a/plugins/ModPlus/remoteprofileaction.php +++ b/plugins/ModPlus/remoteprofileaction.php @@ -64,6 +64,11 @@ class RemoteProfileAction extends ShowstreamAction $url); $html = common_markup_to_html($markdown); $this->raw($html); + + if ($this->profile->hasRole(Profile_role::SILENCED)) { + $markdown = _m('Site moderators have silenced this profile, which prevents delivery of new messages to any users on this site.'); + $this->raw(common_markup_to_html($markdown)); + } } function getFeeds() @@ -71,9 +76,13 @@ class RemoteProfileAction extends ShowstreamAction // none } + /** + * Don't do various extra stuff, and also trim some things to avoid crawlers. + */ function extraHead() { - // none + $this->element('meta', array('name' => 'robots', + 'content' => 'noindex,nofollow')); } function showLocalNav() -- cgit v1.2.3-54-g00ecf From fdcaac365354fb7315263373bae6094eab6aa3c8 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Mon, 15 Nov 2010 16:38:18 -0800 Subject: Tweak remote profile action: hide stats from sidebar, tweak wording on remote notice --- plugins/ModPlus/remoteprofileaction.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/ModPlus/remoteprofileaction.php b/plugins/ModPlus/remoteprofileaction.php index 5b25da170..caa5e6fbf 100644 --- a/plugins/ModPlus/remoteprofileaction.php +++ b/plugins/ModPlus/remoteprofileaction.php @@ -59,7 +59,8 @@ class RemoteProfileAction extends ShowstreamAction $url = $this->profile->profileurl; $host = parse_url($url, PHP_URL_HOST); $markdown = sprintf( - _m('This profile is registered on another site; see [the profile page on %s](%s).'), + _m('This remote profile is registered on another site; see [%s\'s original profile page on %s](%s).'), + $this->profile->nickname, $host, $url); $html = common_markup_to_html($markdown); @@ -97,4 +98,9 @@ class RemoteProfileAction extends ShowstreamAction // skip tag cloud } + function showStatistics() + { + // skip + } + } \ No newline at end of file -- cgit v1.2.3-54-g00ecf From 25170f272ca853c585531894d282c7545f00bf16 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Mon, 15 Nov 2010 17:32:33 -0800 Subject: visual cleanup on ModPlus remote profile info popup menu --- plugins/ModPlus/ModPlusPlugin.php | 18 ++++++++++++++++++ plugins/ModPlus/modplus.css | 23 +++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 plugins/ModPlus/modplus.css (limited to 'plugins') diff --git a/plugins/ModPlus/ModPlusPlugin.php b/plugins/ModPlus/ModPlusPlugin.php index 89bbdf857..3e7a8c745 100644 --- a/plugins/ModPlus/ModPlusPlugin.php +++ b/plugins/ModPlus/ModPlusPlugin.php @@ -56,6 +56,11 @@ class ModPlusPlugin extends Plugin return true; } + function onEndShowStatusNetStyles($action) { + $action->cssLink('plugins/ModPlus/modplus.css'); + return true; + } + /** * Autoloader * @@ -95,4 +100,17 @@ class ModPlusPlugin extends Plugin return true; } + + function onStartShowNoticeItem($item) + { + $profile = $item->profile; + $isRemote = !(User::staticGet('id', $profile->id)); + if ($isRemote) { + $target = common_local_url('remoteprofile', array('id' => $profile->id)); + $label = _m('Remote profile options...'); + $item->out->elementStart('div', 'remote-profile-options'); + $item->out->element('a', array('href' => $target), $label); + $item->out->elementEnd('div'); + } + } } diff --git a/plugins/ModPlus/modplus.css b/plugins/ModPlus/modplus.css new file mode 100644 index 000000000..8d2fc8fba --- /dev/null +++ b/plugins/ModPlus/modplus.css @@ -0,0 +1,23 @@ +.remote-profile-options { + position: absolute; + z-index: 999; + + background: url(../../theme/base/images/icons/twotone/green/admin.gif) no-repeat 8px 8px white; + border: solid 1px #c0c0c0; + + margin-top: 56px; + + padding: 6px 16px; + padding-left: 32px; + + -moz-border-radius: 8px; + -webkit-border-radius: 8px; + -msie-border-radius: 8px; + border-radius: 8px; + + box-shadow:3px 3px 7px rgba(194, 194, 194, 0.3); + -moz-box-shadow:3px 3px 7px rgba(194, 194, 194, 0.3); + -webkit-box-shadow:3px 3px 7px rgba(194, 194, 194, 0.3); + + display: none; +} -- cgit v1.2.3-54-g00ecf