[vhffs-dev] [1585] Moved IRC nick from 'user space' to 'admin space'.

[ Thread Index | Date Index | More vhffs.org/vhffs-dev Archives ]


Revision: 1585
Author:   guillaumito
Date:     2010-04-02 23:55:29 +0200 (Fri, 02 Apr 2010)
Log Message:
-----------
Moved IRC nick from 'user space' to 'admin space'. That means
moderator can no longer configure their IRC nick.

Modified Paths:
--------------
    trunk/vhffs-panel/templates/Makefile.am
    trunk/vhffs-panel/templates/user/prefs.tmpl
    trunk/vhffs-panel/user/prefs.pl

Added Paths:
-----------
    trunk/vhffs-panel/templates/user/ircnick.tmpl

Modified: trunk/vhffs-panel/templates/Makefile.am
===================================================================
--- trunk/vhffs-panel/templates/Makefile.am	2010-03-29 18:58:14 UTC (rev 1584)
+++ trunk/vhffs-panel/templates/Makefile.am	2010-04-02 21:55:29 UTC (rev 1585)
@@ -126,6 +126,7 @@
 	user/admin.tmpl \
 	user/create_complete.tmpl \
 	user/create.tmpl \
+	user/ircnick.tmpl \
 	user/mailuserspam.tmpl \
 	user/mailuser.tmpl \
 	user/mailuservirus.tmpl \

Added: trunk/vhffs-panel/templates/user/ircnick.tmpl
===================================================================
--- trunk/vhffs-panel/templates/user/ircnick.tmpl	                        (rev 0)
+++ trunk/vhffs-panel/templates/user/ircnick.tmpl	2010-04-02 21:55:29 UTC (rev 1585)
@@ -0,0 +1,7 @@
+<h2><TMPL_I18N KEY="IRC nick"></h2>
+<form method="post" action="#">
+    <p><label for="user_ircnick"><TMPL_VAR ESCAPE=1 NAME="TEXT_IRCNICK"> :</label>
+    <input name="ircnick" id="user_ircnick" value="<TMPL_VAR ESCAPE=1 NAME="VALUE_IRCNICK">" type="text" />
+    </p>
+    <p><input type="submit" name="update_ircnick_submit" value="<TMPL_I18N KEY="Update IRC nick">"/></p>
+</form>

Modified: trunk/vhffs-panel/templates/user/prefs.tmpl
===================================================================
--- trunk/vhffs-panel/templates/user/prefs.tmpl	2010-03-29 18:58:14 UTC (rev 1584)
+++ trunk/vhffs-panel/templates/user/prefs.tmpl	2010-04-02 21:55:29 UTC (rev 1585)
@@ -76,12 +76,6 @@
 					<input type="checkbox" name="NEWSLETTER" id="NEWSLETTER" <TMPL_IF NAME="NEWSLETTER_CHECKED">checked="checked"</TMPL_IF>/>
 				</p>
 </TMPL_IF>
-<TMPL_IF NAME="MODO">
-                                <p>
-                                        <label for="IRCNICK"><TMPL_VAR ESCAPE=1 NAME="TEXT_IRCNICK"> :</label>
-                                        <input name="IRCNICK" id="IRCNICK" value="<TMPL_VAR ESCAPE=1 NAME="VALUE_IRCNICK">" type="text" />
-                                </p>
-</TMPL_IF>
 				<TMPL_VAR ESCAPE=0 NAME="MAILUSER">
 				
 				<p class="button" id="buttonModify">
@@ -126,5 +120,6 @@
 
 <TMPL_IF NAME="ADMIN">
     <TMPL_VAR ESCAPE=0 NAME="ADMIN_PART">
+    <TMPL_INCLUDE NAME="ircnick.tmpl">
     <TMPL_INCLUDE NAME="admin.tmpl">
 </TMPL_IF>

Modified: trunk/vhffs-panel/user/prefs.pl
===================================================================
--- trunk/vhffs-panel/user/prefs.pl	2010-03-29 18:58:14 UTC (rev 1584)
+++ trunk/vhffs-panel/user/prefs.pl	2010-04-02 21:55:29 UTC (rev 1585)
@@ -98,7 +98,6 @@
 			my $shell = $cgi->param( 'SHELL' );
 			my $newslettercheckbox = $cgi->param('NEWSLETTER');
 			$newslettercheckbox = ( defined $newslettercheckbox && $newslettercheckbox eq 'on' );
-			my $ircnick = $cgi->param('IRCNICK');
 
 			my $pwd_change = 0;
 			my $mail_change = 0;
@@ -155,11 +154,6 @@
 				else {
 					$shell = Vhffs::Panel::User::default_shell( $ vhffs );
 				}
-    				if($userp->is_moderator || $userp->is_admin) {
-					if( $ircnick !~ /^[^<">]*$/ ) {
-						$panel->add_error( gettext( 'IRC nick is not correct !') );
-					}
-				}
 
 				if(! $panel->has_errors) {
 					$userp->set_firstname(  $firstname );
@@ -169,9 +163,6 @@
 					$userp->set_country( $country );
 					$userp->set_address( $address );
 					$userp->set_shell( $shell );
-    					if($userp->is_moderator || $userp->is_admin) {
-						$userp->set_ircnick( $ircnick );
-					}
 
 					if( ( length( $pass1 ) > 1 ) && ( $pass1 eq $pass2 ) ) { 
 						$pwd_change = 1;
@@ -316,6 +307,10 @@
 		}
 	}
 
+	elsif( defined $cgi->param('update_ircnick_submit') ) {
+		update_ircnick();
+	}
+
 	elsif( defined $cgi->param('update_permissions_submit') ) {
 		update_permissions();
 	}
@@ -478,12 +473,6 @@
 		}
 	}
 
-    if($userp->is_moderator || $userp->is_admin) {
-        $template->param( TEXT_IRCNICK => gettext('IRC nick') );
-        $template->param( VALUE_IRCNICK => $userp->get_ircnick);
-        $template->param( MODO => 1 );
-    }
-
     if($user->is_admin) {
     	my $adminpart = Vhffs::Panel::Object::admin_part( $panel, $userp );
     	$template->param( ADMIN_PART => $adminpart->output ) if( defined $adminpart );
@@ -492,12 +481,39 @@
         $template->param( USER_NORMAL => Vhffs::Constants::USER_NORMAL );
         $template->param( USER_MODERATOR => Vhffs::Constants::USER_MODERATOR );
         $template->param( USER_ADMIN => Vhffs::Constants::USER_ADMIN );
+        $template->param( TEXT_IRCNICK => gettext('IRC nick') );
+        $template->param( VALUE_IRCNICK => $userp->get_ircnick);
     }
 }
 
 $panel->build( $template );
 $panel->display;
 
+sub update_ircnick {
+    unless( $user->is_admin ) {
+        $panel->add_error( gettext('Only administrators can do this') );
+        return;
+    }
+
+    my $ircnick = $cgi->param('ircnick');
+    unless(defined $ircnick) {
+        $panel->add_error( gettext('CGI Error !') );
+        return;
+    }
+
+    if( $ircnick !~ /^[^<">]*$/ ) {
+        $panel->add_error( gettext( 'IRC nick is not correct !') );
+        return;
+    }
+
+    $userp->set_ircnick($ircnick);
+    if($userp->commit < 0) {
+        $panel->add_error( gettext('Unable to update user, please try again later') );
+    } else {
+        $panel->add_info( gettext('User successfully updated') );
+    }
+}
+
 sub update_permissions {
     unless( $user->is_admin ) {
         $panel->add_error( gettext('Only administrators can do this') );


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/