[mb-commits] r9286 - in mb_server/branches/SubscribeToEditor: cgi-bin htdocs/comp/layout htdocs/show/user htdocs/user

root at musicbrainz.org root at musicbrainz.org
Mon Jul 23 23:32:20 UTC 2007


Author: murdos
Date: 2007-07-23 23:32:20 +0000 (Mon, 23 Jul 2007)
New Revision: 9286

Added:
   mb_server/branches/SubscribeToEditor/htdocs/user/subscribers.html
Modified:
   mb_server/branches/SubscribeToEditor/cgi-bin/UserStuff.pm
   mb_server/branches/SubscribeToEditor/htdocs/comp/layout/topmenu
   mb_server/branches/SubscribeToEditor/htdocs/show/user/index.html
   mb_server/branches/SubscribeToEditor/htdocs/user/subscribe.html
   mb_server/branches/SubscribeToEditor/htdocs/user/subscriptions.html
   mb_server/branches/SubscribeToEditor/htdocs/user/subscriptions.inc
Log:
User interface to subscribe/unsubscribe to editors & see subscriptions. 
Last step is sending mails (with UserSubscription.pm) ;)


Modified: mb_server/branches/SubscribeToEditor/cgi-bin/UserStuff.pm
===================================================================
--- mb_server/branches/SubscribeToEditor/cgi-bin/UserStuff.pm	2007-07-23 23:23:31 UTC (rev 9285)
+++ mb_server/branches/SubscribeToEditor/cgi-bin/UserStuff.pm	2007-07-23 23:32:20 UTC (rev 9286)
@@ -482,6 +482,13 @@
 	$ok;
 }
 
+sub GetSubscribers
+{
+	my $self = shift;
+	require UserSubscription;
+	return UserSubscription->GetSubscribersForEditor($self->{DBH}, $self->GetId);
+}
+
 sub MakeAutoModerator
 {
 	my $self = shift;

Modified: mb_server/branches/SubscribeToEditor/htdocs/comp/layout/topmenu
===================================================================
--- mb_server/branches/SubscribeToEditor/htdocs/comp/layout/topmenu	2007-07-23 23:23:31 UTC (rev 9285)
+++ mb_server/branches/SubscribeToEditor/htdocs/comp/layout/topmenu	2007-07-23 23:32:20 UTC (rev 9286)
@@ -360,6 +360,7 @@
 			{ name => "Change Password",	url => "/user/change-password.html",	 	login => 1 },
 			{ name => "Preferences",		url => "/user/preferences.html",			login => 1 },
 			{ name => "Subscriptions",		url => "/user/subscriptions.html", 			login => 1 },
+			{ name => "Subscribers",		url => "/user/subscribers.html", 			login => 1 },
 			{ name => "Logout",				url => "/logout.html",						login => 1 },
 			{ name => "Check donation status",		url => "/user/donationcheck.html",						login => 1 },
 			[

Modified: mb_server/branches/SubscribeToEditor/htdocs/show/user/index.html
===================================================================
--- mb_server/branches/SubscribeToEditor/htdocs/show/user/index.html	2007-07-23 23:23:31 UTC (rev 9285)
+++ mb_server/branches/SubscribeToEditor/htdocs/show/user/index.html	2007-07-23 23:32:20 UTC (rev 9286)
@@ -297,6 +297,26 @@
 			</tr>
 
 			<tr class="top">
+				<td class="label">
+					Subscribers:
+				</td>
+				<td>
+					<% scalar $user->GetSubscribers %>
+					&nbsp;
+					[ <a href="/user/subscribers.html?userid=<% $user->GetId %>">List</a>
+
+%		if(exists $session{user}
+%		   and not $user->IsSpecialEditor
+%		   and not $is_me)
+%		{
+					| <a href="/user/subscribe.html?editorid=<% $user->GetId %>">Subscribe to this editor</a>
+					| <a href="/user/subscribe.html?editorid=<% $user->GetId %>&amp;unsubscribe=1">Unsubscribe from this editor</a>
+%		}
+					]
+				</td>
+			</tr>
+
+			<tr class="top">
 				<td colspan="2">
 					<div style="border-bottom: 1px dotted #ccc; padding: 5px; margin-top: 25px; margin-bottom: 5px; font-weight: bold">
 						User statistics:

Modified: mb_server/branches/SubscribeToEditor/htdocs/user/subscribe.html
===================================================================
--- mb_server/branches/SubscribeToEditor/htdocs/user/subscribe.html	2007-07-23 23:23:31 UTC (rev 9285)
+++ mb_server/branches/SubscribeToEditor/htdocs/user/subscribe.html	2007-07-23 23:32:20 UTC (rev 9286)
@@ -21,7 +21,7 @@
 	#
 	# Summary:
 	# -----------------------------------------------------------------------------
-	# This page allows an user to modify their artist subscriptions.
+	# This page allows an user to modify its subscriptions.
 	#
 	# $Id$
 	#
@@ -30,6 +30,7 @@
 
 	@artistid => ()
 	@labelid => ()
+	@editorid => ()
 	$unsubscribe => 0
 
 </%args>
@@ -38,7 +39,7 @@
 	return $m->comp(
 		"/comp/redirect",
 		"/user/subscriptions.html",
-	) if not @artistid and not @labelid;
+	) if not @artistid and not @labelid and not @editorid;
 
 	$m->comp(
 		"/comp/checkloggedin", 1, 1,
@@ -48,6 +49,7 @@
 	my $mb = $m->comp("/comp/dblogin");
 	my @artists;
 	my @labels;
+	my @editors;
 
 	for my $artistid (@artistid)
 	{
@@ -80,7 +82,23 @@
 		push @labels, $label;
 	}
 
-	(@artists or @labels)
+	for my $editorid (@editorid)
+	{
+		MusicBrainz::Server::Validation::IsNonNegInteger($editorid)
+			and $editorid
+			or next;
+
+		my $ui = UserStuff->new($mb->{DBH});
+		my $editor = $ui->newFromId($editorid)
+			or next;
+
+		not $editor->IsSpecialEditor
+			or next;
+
+		push @editors, $editor;
+	}
+
+	(@artists or @labels or @editors)
 		or return $m->comp("/comp/badargs", 1, 1);
 
 	my $subs = UserSubscription->new($mb->{DBH});
@@ -105,6 +123,15 @@
 			);
 	}
 
+	if (@editors)
+	{
+		my $editormethod = $method . "Editors";
+		$subs->$editormethod(@editors)
+			or return $m->comp("/comp/error",
+				"Sorry, there was an error processing your request.", 1, 1,
+			);
+	}
+
 	# redirect user to subscribed users instead of the list of subscriptions
 	# if we came from the artist page.
 	if (scalar(@artistid) == 1)
@@ -119,6 +146,12 @@
 			"/show/label/subscriptions.html?label=".$labelid[0],
 		);
 	}
+	elsif (scalar(@editorid) == 1)
+	{
+		return $m->comp("/comp/redirect",
+			"/user/subscribers.html?userid=".$editorid[0],
+		);
+	}
 	else
 	{
 		return $m->comp("/comp/redirect", "/user/subscriptions.html");

Added: mb_server/branches/SubscribeToEditor/htdocs/user/subscribers.html

Modified: mb_server/branches/SubscribeToEditor/htdocs/user/subscriptions.html
===================================================================
--- mb_server/branches/SubscribeToEditor/htdocs/user/subscriptions.html	2007-07-23 23:23:31 UTC (rev 9285)
+++ mb_server/branches/SubscribeToEditor/htdocs/user/subscriptions.html	2007-07-23 23:32:20 UTC (rev 9286)
@@ -70,18 +70,20 @@
 	@$info = grep { defined $_->{name} } @$info;
 	my $labels = $subs->GetSubscribedLabels;
 	@$labels = grep { defined $_->{name} } @$labels;
+	my $editors = $subs->GetSubscribedEditors;
+	@$editors = grep { defined $_->{name} } @$editors;
 
 	# show public subscriptions of another user if the user we're
 	# are displaying the subscriptions of is not the current user.
-	return $m->comp("subscriptions.inc", user => $them, info => $info, labels => $labels)
+	return $m->comp("subscriptions.inc", user => $them, info => $info, labels => $labels, editors => $editors)
 		unless $is_me;
 
 </%perl>
 
 
-<& /comp/sidebar-notitle, pagetitle => "Your Artist and Label Subscriptions" &>
+<& /comp/sidebar-notitle, pagetitle => "Your Subscriptions" &>
 
-	<& /comp/tablebegin, title => "Your Artist and Label Subscriptions" &>
+	<& /comp/tablebegin, title => "Your Subscriptions" &>
 
 		<table class="formstyle">
 			<tr class="top">
@@ -116,24 +118,25 @@
 				<td class="label">Subscriptions:</td>
 				<td>
 
-% 	if (not @$info and not @$labels)
+% 	if (not @$info and not @$labels and not @$editors)
 %	{
 
-					You are not currently subscribed to any artists.&nbsp;
-					To subscribe to an artist, click the "Subscribe" link
-					on the artist's page.
+					You are not currently subscribed to any artists, labels or editors.&nbsp;
+					To subscribe to an artist (or a label or an editor), click the "Subscribe" link
+					on the artist's (or label's or editor's) page.
 
 % 	}
 %	else
 %	{
 
 					You are currently subscribed to
-					<% (@$info == 1) ? "this artist" : (@$info == 0 ? "no artists" : "these <strong>".scalar(@$info)."</strong> artists") |n %>
+					<% (@$info == 1) ? "this artist" : (@$info == 0 ? "no artists" : "these <strong>".scalar(@$info)."</strong> artists") |n %>, 
+					<% (@$labels == 1) ? "this label" : (@$labels == 0 ? "no labels" : "these <strong>".scalar(@$labels)."</strong> labels") |n %>
 					and
-					<% (@$labels == 1) ? "this label" : (@$labels == 1 ? "no labels" : "these <strong>".scalar(@$labels)."</strong> labels") |n %>. To
-					unsubscribe, activate the checkbox next to the artists or labels you would
+					<% (@$editors == 1) ? "this editor" : (@$editors == 0 ? "no editors" : "these <strong>".scalar(@$editors)."</strong> editors") |n %>. To
+					unsubscribe, activate the checkbox next to the artists, labels or editors you would
 					like to unsubscribe from, then click the button below. To subscribe
-					to an artist or a label, use the "Subscribe" link on the artist's or label's page.
+					to an artist, a label or an editor, use the "Subscribe" link on the artist's, label's or editor's page.
 %	}
 
 
@@ -231,6 +234,50 @@
 
 % 	}
 
+% 	if (@$editors)
+%	{
+
+			<tr>
+				<td colspan="2">&nbsp;</td>
+			</tr>
+			<tr>
+				<td>&nbsp;</td>
+				<td>
+
+%		my $row = 0;
+%		my @colours = ('#fff', '#ffe1b7');
+
+					<form method="post" action="/user/subscribe.html">
+						<table class="artistfilter-listing">
+
+% 		for my $editor (@$editors)
+%		{
+
+							<tr class="row<% $row++ % 2 %>">
+								<td><input type="checkbox" name="editorid" value="<% $editor->{subscribededitor} %>" /></td>
+								<td class="padright">
+									<& /comp/linkuser, id => $editor->{subscribededitor},
+										name => $editor->{name}, strong => 0 &></td>
+								<td>[ <a href="/mod/search/pre/editor.html?userid=<% $editor->{subscribededitor} %>">Edits</a> 
+									| <a href="/mod/search/pre/editor-open.html?userid=<% $editor->{subscribededitor} %>">Open edits</a> ]</td>
+							</tr>
+% 		}
+
+							<tr>
+								<td colspan="3">&nbsp;</td>
+							</tr>
+							<tr>
+								<td colspan="3">
+									<input type="hidden" name="unsubscribe" value="1" />
+									<input type="submit" value="Unsubcribe selected editors &raquo;" />
+								</td>
+							</tr>
+						</table>
+					</form>
+				</td>
+			</tr>
+% 	}
+
 		</table>
 
 	<& /comp/tableend &>

Modified: mb_server/branches/SubscribeToEditor/htdocs/user/subscriptions.inc
===================================================================
--- mb_server/branches/SubscribeToEditor/htdocs/user/subscriptions.inc	2007-07-23 23:23:31 UTC (rev 9285)
+++ mb_server/branches/SubscribeToEditor/htdocs/user/subscriptions.inc	2007-07-23 23:32:20 UTC (rev 9286)
@@ -32,6 +32,7 @@
 	$user
 	$info => ()
 	$labels => ()
+	$editors => ()
 	$private => 0
 
 </%args>
@@ -184,6 +185,64 @@
 				</td>
 			</tr>
 
+			<tr>
+				<td colspan="2">&nbsp;</td>			
+			</tr>			
+			<tr class="top">
+				<td colspan="2">
+					<div style="border-bottom: 1px dotted #ccc; padding: 5px; margin-bottom: 5px; font-weight: bold">
+						Editor subscriptions:
+					</div></td>
+			</tr>
+			
+			<tr class="top">
+				<td class="label">&nbsp;</td>
+				<td>
+				
+%	if ($private)
+%	{
+
+		<% $name %>'s editor subscriptions are private.
+
+%	}
+%	else
+%	{
+
+
+% 		my $row = 0;
+% 		if (not @$editors)
+%		{
+
+		No editor subscriptions found.
+
+%		}
+%		else
+%		{
+
+					<table class="artistfilter-listing">
+
+% 			for my $editor (@$editors)
+%			{
+
+						<tr class="row<% ++$row % 2 %>">
+							<td class="padright">
+								<& /comp/linkuser, id => $editor->{subscribededitor}, name => $editor->{name}, 
+									resolution =>  $editor->{resolution}, strong => 0 &></td>
+							<td>
+								[&nbsp;<a href="/mod/search/pre/editor.html?userid=<% $editor->{subscribededitor} %>">View edits</a>&nbsp;]</td>
+						</tr>
+
+% 			}
+
+					</table>
+
+% 		}
+% 	}
+
+				</td>
+			</tr>
+
+
 		</table>
 
 	<& /comp/tableend &>




More information about the MusicBrainz-commits mailing list