[Cpan-forum-commit] rev 87 - in trunk: lib/CPAN templates

svn at pti.co.il svn at pti.co.il
Sat Feb 5 22:57:15 IST 2005


Author: gabor
Date: 2005-02-05 22:57:15 +0200 (Sat, 05 Feb 2005)
New Revision: 87

Modified:
   trunk/lib/CPAN/Forum.pm
   trunk/templates/admin_edit_user.tmpl
Log:
admin can change e-mail address of user

Modified: trunk/lib/CPAN/Forum.pm
===================================================================
--- trunk/lib/CPAN/Forum.pm	2005-02-05 20:38:45 UTC (rev 86)
+++ trunk/lib/CPAN/Forum.pm	2005-02-05 20:57:15 UTC (rev 87)
@@ -192,8 +192,9 @@
   Enable <i>, <b> <br> and <a ..> with <p></p> pairs
   Remove the selection box from the post interface as it was not used there.
   Put the search form on the home page as well.
- 
   Admin can change e-mail address of any user
+
+
   Add paging
  
 
@@ -1875,15 +1876,29 @@
 		return $self->internal_error("", "restricted_area");
 	}
 	my $q = $self->query;
+	my $email = $q->param('email');
+	my $uid   = $q->param('uid'); # TODO error checking here !
+
+	$self->log->debug("admin_edit_user_process uid: '$uid'");
+	my ($person) = CPAN::Forum::Users->retrieve($uid);
+	if (not $person) {
+		return $self->internal_error("", "no_such_user");
+	}
+	$person->email($email);
+	$person->update;
+
+	$self->admin_edit_user($person->username, ['done']);
 }
 
 sub admin_edit_user {
-	my ($self) = @_;
+	my ($self, $username, $errors) = @_;
 	if (not $self->session->param("admin")) {
 		return $self->internal_error("", "restricted_area");
 	}
 	my $q = $self->query;
-	my $username = ${$self->param("path_parameters")}[0] || '';
+	if (not $username) {
+		$username = ${$self->param("path_parameters")}[0] || '';
+	}
 	$self->log->debug("admin_edit_user username: '$username'");
 
 	my ($person) = CPAN::Forum::Users->search(username => $username);
@@ -1894,6 +1909,12 @@
 	my $t = $self->load_tmpl("admin_edit_user.tmpl");
 	$t->param(this_username => $username);
 	$t->param(email => $person->email);
+	$t->param(uid   => $person->id);
+
+	if ($errors and ref($errors) eq "ARRAY") {
+		$t->param($_ => 1) foreach @$errors;
+	}
+
 	$t->output;
 
 }

Modified: trunk/templates/admin_edit_user.tmpl
===================================================================
--- trunk/templates/admin_edit_user.tmpl	2005-02-05 20:38:45 UTC (rev 86)
+++ trunk/templates/admin_edit_user.tmpl	2005-02-05 20:57:15 UTC (rev 87)
@@ -7,6 +7,7 @@
 <TMPL_IF done>
 <p>
 The information was updated
+<a href="/admin_edit_user/<TMPL_VAR this_username>">see it again</a>
 </p>
 <TMPL_ELSE>
 <div class="error">
@@ -16,10 +17,11 @@
 <p>
 Username: <TMPL_VAR this_username>
 </p>
-<form method="post" action="/">
+<form method="post" action="/admin_edit_user_process/">
 <p>
 <input type="hidden" name="rm" value="admin_edit_user_process" />
-E-mail: <input name="email" value="<TMPL_VAR email>" />
+<input type="hidden" name="uid" value="<TMPL_VAR uid>" />
+E-mail: <input name="email" value="<TMPL_VAR email>" /><br />
 <input type="submit" value="Update user" />
 </p>
 </form>



More information about the Cpan-forum-commit mailing list