r724: Error box model for register.php
authorRobert Sesek <rsesek@bluestatic.org>
Sun, 15 Jan 2006 08:29:22 +0000 (08:29 +0000)
committerRobert Sesek <rsesek@bluestatic.org>
Sun, 15 Jan 2006 08:29:22 +0000 (08:29 +0000)
register.php
templates/register.tpl

index 1d10eaebdbe39c2a1c66bf9f38a85f848b7f2182..4e2dd1297d4130e3c9bf1118b6462b344cac9a04 100755 (executable)
@@ -22,29 +22,6 @@ require_once('./global.php');
 
 // ###################################################################
 
-if (empty($_REQUEST['do']))
-{
-       if ($bugsys->userinfo['userid'])
-       {
-               $message->error($lang->string('Sorry, you are already registered.'));
-       }
-       
-       if (!$bugsys->options['allownewreg'])
-       {
-               $message->error($lang->string('Sorry, we don\'t allow new registrations.'));
-       }
-
-       foreach ($bugsys->datastore['language'] AS $value => $temp)
-       {
-               $label = $temp['title'];
-               eval('$opts .= "' . $template->fetch('selectoption') . '";');
-       }
-       
-       eval('$template->flush("' . $template->fetch('register') . '");');
-}
-
-// ###################################################################
-
 if ($_POST['do'] == 'insert')
 {
        if ($bugsys->userinfo['userid'])
@@ -97,101 +74,128 @@ if ($_POST['do'] == 'insert')
                $message->items[] = $lang->string('That display name is already in use by another user.');
        }
        
-       if ($message->items)
-       {
-               $message->error_list_process();
-               $message->error();
-       }
-       
-       $salt = $funct->rand(15);
-       
-       if ($bugsys->options['verifyemail'])
+       if (!$message->items)
        {
-               $usergroupid = 3;
-       }
-       else
-       {
-               if ($bugsys->options['moderatenewusers'])
+               $salt = $funct->rand(15);
+               
+               if ($bugsys->options['verifyemail'])
                {
-                       $usergroupid = 4;
+                       $usergroupid = 3;
                }
                else
                {
-                       $usergroupid = 2;
+                       if ($bugsys->options['moderatenewusers'])
+                       {
+                               $usergroupid = 4;
+                       }
+                       else
+                       {
+                               $usergroupid = 2;
+                       }
                }
-       }
-       
-       $db->query("
-               INSERT INTO " . TABLE_PREFIX . "user
-                       (email, displayname, password, salt, authkey, showemail, showcolours, languageid, usergroupid)
-               VALUES
-                       ('" . $bugsys->in['email'] . "',
-                       '" . $bugsys->in['displayname'] . "',
-                       '" . md5(md5($bugsys->in['password']) . md5($salt)) . "',
-                       '$salt',
-                       '" . $funct->rand() . "',
-                       " . intval($bugsys->in['showemail']) . ",
-                       1,
-                       " . intval($bugsys->in['languageid']) . ",
-                       $usergroupid
-               )"
-       );
-       
-       $userid = $db->insert_id();
-       
-       // Verify email address
-       if ($usergroupid == 3)
-       {
-               $activationid = $funct->rand(25);
-               
-               $db->query("INSERT INTO " . TABLE_PREFIX . "useractivation (userid, activator, dateline, usergroupid) VALUES ($userid, '$activationid', " . TIMENOW . ", 2)");
                
-               $mail->to = $bugsys->in['email'];
-               $mail->subject =  sprintf($lang->string('Welcome to %1$s'), $bugsys->options['trackertitle']);
-               $mail->body = sprintf($lang->string('Hi %1$s,
-
-Welcome to the %2$s tracker. Before you can begin posting bug reports, you\'ll need to activae your account. To do this, please click this link:
-
-%3$s/register.php?do=activate&userid=%4$s&activator=%5$s'),
-
-                                                               $bugsys->in['displayname'],
-                                                               $bugsys->options['trackertitle'],
-                                                               $bugsys->options['trackerurl'],
-                                                               $userid,
-                                                               $activationid
+               $db->query("
+                       INSERT INTO " . TABLE_PREFIX . "user
+                               (email, displayname, password, salt, authkey, showemail, showcolours, languageid, usergroupid)
+                       VALUES
+                               ('" . $bugsys->in['email'] . "',
+                               '" . $bugsys->in['displayname'] . "',
+                               '" . md5(md5($bugsys->in['password']) . md5($salt)) . "',
+                               '$salt',
+                               '" . $funct->rand() . "',
+                               " . intval($bugsys->in['showemail']) . ",
+                               1,
+                               " . intval($bugsys->in['languageid']) . ",
+                               $usergroupid
+                       )"
                );
                
-               $mail->send();
-       
-               $message->message($lang->string('You now need to activate your account via email.'));
-       }
-       else if ($usergroupid == 4 OR $usergroupid == 2)
-       {
-               if ($bugsys->options['sendwelcomemail'])
+               $userid = $db->insert_id();
+               
+               // Verify email address
+               if ($usergroupid == 3)
                {
+                       $activationid = $funct->rand(25);
+                       
+                       $db->query("INSERT INTO " . TABLE_PREFIX . "useractivation (userid, activator, dateline, usergroupid) VALUES ($userid, '$activationid', " . TIMENOW . ", 2)");
+                       
                        $mail->to = $bugsys->in['email'];
-                       $mail->subject = sprintf($lang->string('Welcome to %1$s'), $bugsys->options['trackertitle']);
+                       $mail->subject =  sprintf($lang->string('Welcome to %1$s'), $bugsys->options['trackertitle']);
                        $mail->body = sprintf($lang->string('Hi %1$s,
-
-Thank you for taking the time to register at %2$s. We look forward to your contributations to making our products better.
-
-If you have any questions, please don\'t hesitate to contact the webmaster.'),
-                                                               $bugsys->in['displayname'],
-                                                               $bugsys->options['trackertitle']
+       
+       Welcome to the %2$s tracker. Before you can begin posting bug reports, you\'ll need to activae your account. To do this, please click this link:
+       
+       %3$s/register.php?do=activate&userid=%4$s&activator=%5$s'),
+       
+                                                                       $bugsys->in['displayname'],
+                                                                       $bugsys->options['trackertitle'],
+                                                                       $bugsys->options['trackerurl'],
+                                                                       $userid,
+                                                                       $activationid
                        );
                        
                        $mail->send();
-               }
                
-               if ($usergroupid == 4)
-               {
-                       $message->message($lang->string('Your account is pending approval.'));
+                       $message->message($lang->string('You now need to activate your account via email.'));
                }
-               else
+               else if ($usergroupid == 4 OR $usergroupid == 2)
                {
-                       $message->message($lang->string('Thank you for registering. You may now use your account.'));
+                       if ($bugsys->options['sendwelcomemail'])
+                       {
+                               $mail->to = $bugsys->in['email'];
+                               $mail->subject = sprintf($lang->string('Welcome to %1$s'), $bugsys->options['trackertitle']);
+                               $mail->body = sprintf($lang->string('Hi %1$s,
+       
+       Thank you for taking the time to register at %2$s. We look forward to your contributations to making our products better.
+       
+       If you have any questions, please don\'t hesitate to contact the webmaster.'),
+                                                                       $bugsys->in['displayname'],
+                                                                       $bugsys->options['trackertitle']
+                               );
+                               
+                               $mail->send();
+                       }
+                       
+                       if ($usergroupid == 4)
+                       {
+                               $message->message($lang->string('Your account is pending approval.'));
+                       }
+                       else
+                       {
+                               $message->message($lang->string('Thank you for registering. You may now use your account.'));
+                       }
                }
        }
+       else
+       {
+               $_REQUEST['do'] = '';
+               $show['errors'] = true;
+               $message->error_list_process();
+       }
+}
+
+// ###################################################################
+
+if (empty($_REQUEST['do']))
+{
+       if ($bugsys->userinfo['userid'])
+       {
+               $message->error($lang->string('Sorry, you are already registered.'));
+       }
+       
+       if (!$bugsys->options['allownewreg'])
+       {
+               $message->error($lang->string('Sorry, we don\'t allow new registrations.'));
+       }
+
+       foreach ($bugsys->datastore['language'] AS $value => $temp)
+       {
+               $label = $temp['title'];
+               $selected = ($value == $bugsys->in['languageid']);
+               eval('$opts .= "' . $template->fetch('selectoption') . '";');
+       }
+       
+       eval('$template->flush("' . $template->fetch('register') . '");');
 }
 
 // ###################################################################
index 17bd382133b52294069523892f6e03c82a8e2f8b..22234d21ac4a34838c82fe381ee0252facdb7e48 100644 (file)
@@ -10,6 +10,13 @@ $headinclude
 
 $header
 
+<if condition="$show['errors']">
+<div class="error">
+       {@"The following errors occurred"}:
+       {$message->process}
+</div>
+</if>
+
 <form action="register.php" name="register" method="post">
 <input type="hidden" name="do" value="insert" />
 
@@ -18,12 +25,12 @@ $header
                <div class="box-head">{@"Register"}</div>
                
                <div class="box-mid">
-                       <div><strong>{@"Email"}:</strong> <input type="text" name="email" size="30" /></div>
-                       <div><strong>{@"Confirm Email"}:</strong> <input type="text" name="confirmemail" size="30" /></div>
-                       <div><strong>{@"Display Name"}:</strong> <input type="text" name="displayname" size="30" /></div>
+                       <div><strong>{@"Email"}:</strong> <input type="text" name="email" size="30" value="{$bugsys->in['email']}" /></div>
+                       <div><strong>{@"Confirm Email"}:</strong> <input type="text" name="confirmemail" size="30" value="{$bugsys->in['confirmemail']}" /></div>
+                       <div><strong>{@"Display Name"}:</strong> <input type="text" name="displayname" size="30" value="{$bugsys->in['displayname']}" /></div>
                        <div><strong>{@"Password"}:</strong> <input type="password" name="password" size="30" /></div>
                        <div><strong>{@"Confirm Password"}:</strong> <input type="password" name="confirmpassword" size="30" /></div>
-                       <div><strong>{@"Show My Email Publicly"}:</strong> <input type="checkbox" value="1" name="showemail" /> {@"Yes"}</div>
+                       <div><strong>{@"Show My Email Publicly"}:</strong> <input type="checkbox" value="1" name="showemail"<if condition="$bugsys->in['showemail']"> checked="checked"</if> /> {@"Yes"}</div>
                        <div><strong>{@"Language"}:</strong> <select name="languageid">$opts</select></div>
                </div>