cvs: pearweb /include pear-database.php /public_html account-request.php
| From: | Daniel Convissor | Date: | Wed, 16 Jun 2004 07:24:43 +0000 |
| Subject: | cvs: pearweb /include pear-database.php /public_html account-request.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-20719@lists.php.net to get a copy of this message | ||
danielc Wed Jun 16 03:24:43 2004 EDT
Modified files:
/pearweb/include pear-database.php
/pearweb/public_html account-request.php
Log:
Work toward making a common user interface throughout pearweb...
* Tweak account request form and process to use common styles
for forms and error messages.
* Simplified field names for required field error messages.
* Add accesskey.
* A bit of coding standards cleanup.
http://cvs.php.net/diff.php/pearweb/include/pear-database.php?r1=1.207&r2=1.208&ty=u Index: pearweb/include/pear-database.php diff -u pearweb/include/pear-database.php:1.207 pearweb/include/pear-database.php:1.208 --- pearweb/include/pear-database.php:1.207 Tue Jun 15 17:24:49 2004 +++ pearweb/include/pear-database.php Wed Jun 16 03:24:43 2004 @@ -17,7 +17,7 @@ | Tomas V.V.Cox <cox@php.net> | | Martin Jansen <mj@php.net> | +----------------------------------------------------------------------+ - $Id: pear-database.php,v 1.207 2004/06/15 21:24:49 danielc Exp $ + $Id: pear-database.php,v 1.208 2004/06/16 07:24:43 danielc Exp $ */ require_once 'DB/storage.php'; @@ -2048,44 +2048,51 @@ /** * Add a new user account * + * @param array $data Information about the user + * + * @return mixed true if there are no problems, false if sending the + * email failed or an array of error messages if problems + * * @access public - * @param array Information about the user - * @return mixed PEAR_Error or true */ function add(&$data) { global $dbh; - PEAR::pushErrorHandling(PEAR_ERROR_CALLBACK, "display_error"); + PEAR::pushErrorHandling(PEAR_ERROR_RETURN); + $errors = array(); - $required = array("handle" => "your desired username", - "firstname" => "your first name", - "lastname" => "your last name", - "email" => "your email address", - "purpose" => "the purpose of your PEAR account"); + $required = array( + 'handle' => 'Username', + 'firstname' => 'First Name', + 'lastname' => 'Last Name', + 'email' => 'Email address', + 'purpose' => 'Intended purpose', + ); $name = $data['firstname'] . " " . $data['lastname']; foreach ($required as $field => $desc) { if (empty($data[$field])) { $data['jumpto'] = $field; - return PEAR::raiseError("Please enter $desc!"); + $errors[] = 'Please enter ' . $desc; } } if (!preg_match(PEAR_COMMON_USER_NAME_REGEX, $data['handle'])) { - return PEAR::raiseError("Username must start with a letter and contain only letters and digits."); + $errors[] = 'Username must start with a letter and contain' + . ' only letters and digits'; } if ($data['password'] != $data['password2']) { $data['password'] = $data['password2'] = ""; $data['jumpto'] = "password"; - return PEAR::raiseError("Passwords did not match"); + $errors[] = 'Passwords did not match'; } if (!$data['password']) { $data['jumpto'] = "password"; - return PEAR::raiseError("Empty passwords not allowed"); + $errors[] = 'Empty passwords not allowed'; } $handle = strtolower($data['handle']); @@ -2093,15 +2100,26 @@ if (isset($obj->created)) { $data['jumpto'] = "handle"; - return PEAR::raiseError("Sorry, that username is already taken"); + $errors[] = 'Sorry, that username is already taken'; + } + + if ($errors) { + $data['display_form'] = true; + return $errors; } $err = $obj->insert($handle); if (DB::isError($err)) { - display_error("$handle: " . DB::errorMessage($err)); - $data['jumpto'] = "handle"; - return PEAR::raiseError($handle . ": " . DB::errorMessage($err)); + if ($err->getCode() == DB_ERROR_ALREADY_EXISTS) { + $data['display_form'] = true; + $data['jumpto'] = 'handle'; + $errors[] = 'Sorry, that username is already taken'; + } else { + $data['display_form'] = false; + $errors[] = $err->getMessage(); + } + return $errors; } $data['display_form'] = false; @@ -2117,18 +2135,16 @@ 'password' => $md5pw, 'registered' => 0, 'userinfo' => $userinfo); - $errors = 0; + foreach ($set_vars as $var => $value) { $err = $obj->set($var, $value); if (PEAR::isError($err)) { - print "Failed setting $var: "; - print $err->getMessage(); - print "<br />\n"; - $errors++; + $errors[] = "Failed setting $var: " . $err->getMessage(); } } - if ($errors > 0) { - return PEAR::setError("There were errors while storing the user information."); + if ($errors) { + array_unshift($errors, 'set'); + return $errors; } $msg = "Requested from: {$_SERVER['REMOTE_ADDR']}\n". http://cvs.php.net/diff.php/pearweb/public_html/account-request.php?r1=1.31&r2=1.32&ty=u Index: pearweb/public_html/account-request.php diff -u pearweb/public_html/account-request.php:1.31 pearweb/public_html/account-request.php:1.32 --- pearweb/public_html/account-request.php:1.31 Wed Jun 9 02:23:52 2004 +++ pearweb/public_html/account-request.php Wed Jun 16 03:24:43 2004 @@ -15,139 +15,198 @@ +----------------------------------------------------------------------+ | Authors: | +----------------------------------------------------------------------+ - $Id: account-request.php,v 1.31 2004/06/09 06:23:52 danielc Exp $ + $Id: account-request.php,v 1.32 2004/06/16 07:24:43 danielc Exp $ */ -require_once "HTML/Form.php"; +require_once 'HTML/Form.php'; -function display_error($msg) -{ - global $errorMsg; - if (is_object($msg)) { - $msg = $msg->getMessage(); +/** + * Prints a message explaining the errors found in the users's submission + * + * @param array $errors an array of the errors found + * + * @return void + */ +function display_errors($errors) +{ + echo '<div class="errors">'; + if (count($errors) > 1) { + echo 'You need to do the following before your submission '; + echo 'will be accepted:'; + echo "<ul>\n"; + foreach ($errors as $error) { + if (is_object($error)) { + $error = $error->getMessage(); + } + echo '<li>' . $error . "</li>\n"; + } + echo "</ul>\n"; + } else { + echo $errors[0]; } - $errorMsg .= "<font color=\"#CC0000\" size=\"+1\">$msg</font><br />\n"; + echo '</div>'; } + $display_form = true; -$width = 60; -$errorMsg = ""; -$jumpto = "handle"; +$width = 60; +$errors = array(); +$jumpto = 'handle'; do { if (isset($_POST['submit'])) { response_header("Account Request Submitted"); if (empty($_POST['comments_read'])) { - display_error("Obviously you did not read all the comments concerning " - . "the need for an account. Please read them again."); + $errors[] = 'Obviously you did not read all the comments' + . ' concerning the need for an account. Please read ' + . 'them again.'; $display_form = true; - break; } - if (isset($_POST['purposecheck']) && count($_POST['purposecheck'])){ - display_error("We could not have said it more clearly. Read everything on " - . "this page and look at the form you are submitting carefully."); + if (isset($_POST['purposecheck']) && count($_POST['purposecheck'])) { + $errors[] = 'We could not have said it more clearly. Read ' + . 'everything on this page and look at the form ' + . 'you are submitting carefully.'; $display_form = true; + } + + if ($errors) { break; } + // The add method performs further validation then creates the acct $ok = user::add($_POST); if (!empty($_POST['jumpto'])) { $jumpto = $_POST['jumpto']; } + if (isset($_POST['display_form'])) { $display_form = $_POST['display_form']; } - if (!PEAR::isError($ok)) { - if ($ok == true) { - print "<h2>Account Request Submitted</h2>\n"; - print "Your account request has been submitted, it will ". - "be reviewed by a human shortly. This may take from two ". - "minutes to several days, depending on how much time people ". - "have. ". - "You will get an email when your account is open, or if ". - "your request was rejected for some reason."; + if (is_array($ok)) { + if ($ok[0] == 'set') { + print '<div class="warnings">'; + print '<h2>There were errors while storing the user '; + print "information.</h2>\n"; + print "<ul>\n <li>"; + array_shift($ok); + print implode("</li>\n <li>", $ok); + print "</li>\n</ul>"; + print '<p>Please drop an email about this to the '; + print '<a href="mailto:pear-dev@lists.php.net">pear-dev</a> '; + print 'mailing list.</p>'; + print "\n</div>\n"; } else { - print "<h2>Possible Problem!</h2>\n"; - print "Your account request has been submitted, but there ". - "were problems mailing one or more administrators. ". - "If you don't hear anything about your account in a few ". - "days, please drop a mail about it to the <i>pear-dev</i> ". - "mailing list."; + $errors = $ok; } - print "<br />Click <a href=\"/\">here</a> to go back to the front page.\n"; - $display_form = false; - } - break; + break; + } elseif ($ok == true) { + print '<div class="thanks">'; + print "<h2>Account Request Submitted</h2>\n"; + print "Your account request has been submitted, it will ". + "be reviewed by a human shortly. This may take from two ". + "minutes to several days, depending on how much time people ". + "have. ". + "You will get an email when your account is open, or if ". + "your request was rejected for some reason."; + print "\n</div>\n"; + } else { + print '<div class="warnings">'; + print "<h2>Possible Problem!</h2>\n"; + print "Your account request has been submitted, but there ". + "were problems mailing one or more administrators. ". + "If you don't hear anything about your account in a few ". + "days, please drop a mail about it to the <i>pear-dev</i> ". + "mailing list."; + print "\n</div>\n"; + } + + print '<br />Click <a href="/">here</a>'; + print ' to go back to the home page.' . "\n"; + $display_form = false; } } while (0); + if ($display_form) { - response_header("Request Account"); + response_header('Request Account'); - print "<h1>Request Account</h1> + print <<<MSG + +<h1>Request Account</h1> <p> -You only need to request an account if you + You only need to request an account if you: </p> <ul> -<li>Are planning to contribute a new package to PEAR and want to -propose this to the PEAR developer community.</li> - -<li>Are going to help in the maintenance of an existing package. This -needs to be approved by the current maintainers of the package or by -the <a href=\"/group/\">PEAR Group</a>.</li> + <li> + Are planning to contribute a new package to PEAR and want to propose this + to the PEAR developer community. + </li> + <li> + Are going to help in the maintenance of an existing package. This needs + to be approved by the current maintainers of the package or by the <a + href="/group/">PEAR Group</a>. + </li> </ul> <p> -If the reason for your request does not fall under one of the -reasons above, please contact the <a href=\"mailto:pear-dev@lists.php.net\"> -PEAR developers mailing list</a>. + If the reason for your request does not fall under one of the + reasons above, please contact the <a href="mailto:pear-dev@lists.php.net"> + PEAR developers mailing list</a>. </p> -<p>You do <b>not</b> need an account to: +<p> + You do <strong>not</strong> need an account to: </p> <ul> -<li>Download, install and/or use PEAR packages.</li> -<li>Submit patches or code improvements for a particular package. -Please use the <a href=\"/bugs/\">bug reporting system</a> for that -purpose.</li> -<li>Propose modifications to an existing package. Please use the -<a href=\"mailto:pear-dev@lists.php.net\">PEAR developers mailing -list</a> for that or directly contact the maintainers of the package -in question.</li> + <li> + Download, install and/or use PEAR packages. + </li> + <li> + Submit patches or code improvements for a particular package. + Please use the <a href="/bugs/">bug reporting system</a> for that purpose. + </li> + <li> + Propose modifications to an existing package. Please use the + <a href="mailto:pear-dev@lists.php.net">PEAR developers mailing list</a> for + that or directly contact the maintainers of the package in question. + </li> </ul> <p> -These are not the only reasons for requests being rejected, but the most -common ones. + These are not the only reasons for requests being rejected, but the most + common ones. </p> -<p>If you want to contribute a package to PEAR, make sure that you have -followed all rules concerning PEAR packages. Also, before a package -may be released, the code code must comply with the -<a href=\"http://pear.php.net/manual/en/standards.php\">PEAR Coding -Standards</a>.</p> - -<p>Bogus, incomplete or incorrect requests will be summarily denied.</p>"; - - print "<a name=\"requestform\" />\n"; - - if (isset($errorMsg)) { - print "<table>\n"; - print " <tr>\n"; - print " <td> </td>\n"; - print " <td><b>$errorMsg</b></td>\n"; - print " </tr>\n"; - print "</table>\n"; +<p> + If you want to contribute a package to PEAR, make sure that you have + followed all rules concerning PEAR packages. Also, before a package + may be released, the code code must comply with the + <a href="http://pear.php.net/manual/en/standards.php">PEAR Coding + Standards</a>. +</p> + +<p> + Bogus, incomplete or incorrect requests will be summarily denied. +</p> + +MSG; + + + print '<a name="requestform" id="requestform"></a>'; + + if ($errors) { + display_errors($errors); } + $invalid_purposes = array( 'Learn about PEAR.', 'Use PEAR.', @@ -156,29 +215,58 @@ 'Suggest new features.', 'Browse pear.php.net.' ); - $purposechecks = ''; - foreach ($invalid_purposes as $i => $purposeKey) - { - $purposechecks .= HTML_Form::returnCheckBox("purposecheck[$i]", @$_POST['purposecheck'][$i] ? 'on' : 'off'); - $purposechecks .= "$purposeKey <br />"; - } - - print "<form action=\"" . $_SERVER['PHP_SELF'] . "#requestform\" method=\"post\" name=\"request_form\">\n"; - $bb = new BorderBox("Request account", "90%", "", 2, true); - $bb->horizHeadRow("Username:", HTML_Form::returnText("handle", @$_POST['handle'], 12)); - $bb->horizHeadRow("First Name:", HTML_Form::returnText("firstname", @$_POST['firstname'])); - $bb->horizHeadRow("Last Name:", HTML_Form::returnText("lastname", @$_POST['lastname'])); - $bb->horizHeadRow("Password:", HTML_Form::returnPassword("password", null, 10) . " Again: " . HTML_Form::returnPassword("password2", null, 10)); - $bb->horizHeadRow("Email address:", HTML_Form::returnText("email", @$_POST['email'])); - $bb->horizHeadRow("Show email address?", HTML_Form::returnCheckbox("showemail", @$_POST['showemail'])); - $bb->horizHeadRow("Homepage", HTML_Form::returnText("homepage", @$_POST['homepage'])); - $bb->horizHeadRow("Purpose of your PEAR account:<br/>(Check all that apply)", $purposechecks); - $bb->horizHeadRow("If your intended purpose is not in the list, please state it here:", HTML_Form::returnTextarea("purpose", stripslashes(@$_POST['purpose']))); - $bb->horizHeadRow("More relevant information<br />about you (optional):", HTML_Form::returnTextarea("moreinfo", stripslashes(@$_POST['moreinfo']))); - $bb->horizHeadRow("You have read all the comments above:", HTML_Form::returnCheckbox("comments_read", @$_POST['comments_read'])); - $bb->horizHeadRow("<input type=\"submit\" name=\"submit\" /> <input type=\"reset\" />"); - $bb->end(); - print "</form>"; + $purposechecks = ''; + foreach ($invalid_purposes as $i => $purposeKey) + { + $purposechecks .= HTML_Form::returnCheckBox("purposecheck[$i]", @$_POST['purposecheck'][$i] ? 'on' : 'off'); + $purposechecks .= "$purposeKey <br />"; + } + + $form = new HTML_Form($_SERVER['PHP_SELF'] . '#requestform', 'post'); + + $form->addText('handle', 'Use<span class="underline">r</span>name:', + @$_POST['handle'], 12, 20, 'accesskey="r"', + 'class="form-label_left"', 'class="form-input"'); + $form->addText('firstname', 'First Name:', + @$_POST['firstname'], 20, null, '', + 'class="form-label_left"', 'class="form-input"'); + $form->addText('lastname', 'Last Name:', + @$_POST['lastname'], 20, null, '', + 'class="form-label_left"', 'class="form-input"'); + $form->addPassword('password', 'Password:', + '', 10, null, '', + 'class="form-label_left"', 'class="form-input"'); + $form->addText('email', 'Email address:', + @$_POST['email'], 20, null, '', + 'class="form-label_left"', 'class="form-input"'); + $form->addCheckbox('showemail', 'Show email address?', + @$_POST['showemail'], '', + 'class="form-label_left"', 'class="form-input"'); + $form->addText('homepage', 'Homepage:', + @$_POST['homepage'], 20, null, '', + 'class="form-label_left"', 'class="form-input"'); + $form->addPlaintext('Purpose of your PEAR account:' + . '<p class="cell_note">(Check all that apply)</p>', + $purposechecks, + 'class="form-label_left"', 'class="form-input"'); + $form->addTextarea('purpose', + 'If your intended purpose is not in the list, please state it here:', + stripslashes(@$_POST['purpose']), 40, 5, null, '', + 'class="form-label_left"', 'class="form-input"'); + $form->addTextarea('moreinfo', + 'More relevant information about you:' + . '<p class="cell_note">(optional)</p>', + stripslashes(@$_POST['moreinfo']), 40, 5, null, '', + 'class="form-label_left"', 'class="form-input"'); + $form->addCheckbox('comments_read', + 'You have read all of the comments above:', + @$_POST['comments_read'], '', + 'class="form-label_left"', 'class="form-input"'); + $form->addSubmit('submit', 'Submit Query', '', + 'class="form-label_left"', 'class="form-input"'); + + $form->display('class="form-holder" cellspacing="1" border="1"', + 'Request account', 'class="form-caption"'); if ($jumpto) { print "<script language=\"JavaScript\" type=\"text/javascript\">\n<!--\n";
http://cvs.php.net/diff.php/pearweb/include/pear-database.php?r1=1.207&r2=1.208&ty=u Index: pearweb/include/pear-database.php diff -u pearweb/include/pear-database.php:1.207 pearweb/include/pear-database.php:1.208 --- pearweb/include/pear-database.php:1.207 Tue Jun 15 17:24:49 2004 +++ pearweb/include/pear-database.php Wed Jun 16 03:24:43 2004 @@ -17,7 +17,7 @@ | Tomas V.V.Cox <cox@php.net> | | Martin Jansen <mj@php.net> | +----------------------------------------------------------------------+ - $Id: pear-database.php,v 1.207 2004/06/15 21:24:49 danielc Exp $ + $Id: pear-database.php,v 1.208 2004/06/16 07:24:43 danielc Exp $ */ require_once 'DB/storage.php'; @@ -2048,44 +2048,51 @@ /** * Add a new user account * + * @param array $data Information about the user + * + * @return mixed true if there are no problems, false if sending the + * email failed or an array of error messages if problems + * * @access public - * @param array Information about the user - * @return mixed PEAR_Error or true */ function add(&$data) { global $dbh; - PEAR::pushErrorHandling(PEAR_ERROR_CALLBACK, "display_error"); + PEAR::pushErrorHandling(PEAR_ERROR_RETURN); + $errors = array(); - $required = array("handle" => "your desired username", - "firstname" => "your first name", - "lastname" => "your last name", - "email" => "your email address", - "purpose" => "the purpose of your PEAR account"); + $required = array( + 'handle' => 'Username', + 'firstname' => 'First Name', + 'lastname' => 'Last Name', + 'email' => 'Email address', + 'purpose' => 'Intended purpose', + ); $name = $data['firstname'] . " " . $data['lastname']; foreach ($required as $field => $desc) { if (empty($data[$field])) { $data['jumpto'] = $field; - return PEAR::raiseError("Please enter $desc!"); + $errors[] = 'Please enter ' . $desc; } } if (!preg_match(PEAR_COMMON_USER_NAME_REGEX, $data['handle'])) { - return PEAR::raiseError("Username must start with a letter and contain only letters and digits."); + $errors[] = 'Username must start with a letter and contain' + . ' only letters and digits'; } if ($data['password'] != $data['password2']) { $data['password'] = $data['password2'] = ""; $data['jumpto'] = "password"; - return PEAR::raiseError("Passwords did not match"); + $errors[] = 'Passwords did not match'; } if (!$data['password']) { $data['jumpto'] = "password"; - return PEAR::raiseError("Empty passwords not allowed"); + $errors[] = 'Empty passwords not allowed'; } $handle = strtolower($data['handle']); @@ -2093,15 +2100,26 @@ if (isset($obj->created)) { $data['jumpto'] = "handle"; - return PEAR::raiseError("Sorry, that username is already taken"); + $errors[] = 'Sorry, that username is already taken'; + } + + if ($errors) { + $data['display_form'] = true; + return $errors; } $err = $obj->insert($handle); if (DB::isError($err)) { - display_error("$handle: " . DB::errorMessage($err)); - $data['jumpto'] = "handle"; - return PEAR::raiseError($handle . ": " . DB::errorMessage($err)); + if ($err->getCode() == DB_ERROR_ALREADY_EXISTS) { + $data['display_form'] = true; + $data['jumpto'] = 'handle'; + $errors[] = 'Sorry, that username is already taken'; + } else { + $data['display_form'] = false; + $errors[] = $err->getMessage(); + } + return $errors; } $data['display_form'] = false; @@ -2117,18 +2135,16 @@ 'password' => $md5pw, 'registered' => 0, 'userinfo' => $userinfo); - $errors = 0; + foreach ($set_vars as $var => $value) { $err = $obj->set($var, $value); if (PEAR::isError($err)) { - print "Failed setting $var: "; - print $err->getMessage(); - print "<br />\n"; - $errors++; + $errors[] = "Failed setting $var: " . $err->getMessage(); } } - if ($errors > 0) { - return PEAR::setError("There were errors while storing the user information."); + if ($errors) { + array_unshift($errors, 'set'); + return $errors; } $msg = "Requested from: {$_SERVER['REMOTE_ADDR']}\n". http://cvs.php.net/diff.php/pearweb/public_html/account-request.php?r1=1.31&r2=1.32&ty=u Index: pearweb/public_html/account-request.php diff -u pearweb/public_html/account-request.php:1.31 pearweb/public_html/account-request.php:1.32 --- pearweb/public_html/account-request.php:1.31 Wed Jun 9 02:23:52 2004 +++ pearweb/public_html/account-request.php Wed Jun 16 03:24:43 2004 @@ -15,139 +15,198 @@ +----------------------------------------------------------------------+ | Authors: | +----------------------------------------------------------------------+ - $Id: account-request.php,v 1.31 2004/06/09 06:23:52 danielc Exp $ + $Id: account-request.php,v 1.32 2004/06/16 07:24:43 danielc Exp $ */ -require_once "HTML/Form.php"; +require_once 'HTML/Form.php'; -function display_error($msg) -{ - global $errorMsg; - if (is_object($msg)) { - $msg = $msg->getMessage(); +/** + * Prints a message explaining the errors found in the users's submission + * + * @param array $errors an array of the errors found + * + * @return void + */ +function display_errors($errors) +{ + echo '<div class="errors">'; + if (count($errors) > 1) { + echo 'You need to do the following before your submission '; + echo 'will be accepted:'; + echo "<ul>\n"; + foreach ($errors as $error) { + if (is_object($error)) { + $error = $error->getMessage(); + } + echo '<li>' . $error . "</li>\n"; + } + echo "</ul>\n"; + } else { + echo $errors[0]; } - $errorMsg .= "<font color=\"#CC0000\" size=\"+1\">$msg</font><br />\n"; + echo '</div>'; } + $display_form = true; -$width = 60; -$errorMsg = ""; -$jumpto = "handle"; +$width = 60; +$errors = array(); +$jumpto = 'handle'; do { if (isset($_POST['submit'])) { response_header("Account Request Submitted"); if (empty($_POST['comments_read'])) { - display_error("Obviously you did not read all the comments concerning " - . "the need for an account. Please read them again."); + $errors[] = 'Obviously you did not read all the comments' + . ' concerning the need for an account. Please read ' + . 'them again.'; $display_form = true; - break; } - if (isset($_POST['purposecheck']) && count($_POST['purposecheck'])){ - display_error("We could not have said it more clearly. Read everything on " - . "this page and look at the form you are submitting carefully."); + if (isset($_POST['purposecheck']) && count($_POST['purposecheck'])) { + $errors[] = 'We could not have said it more clearly. Read ' + . 'everything on this page and look at the form ' + . 'you are submitting carefully.'; $display_form = true; + } + + if ($errors) { break; } + // The add method performs further validation then creates the acct $ok = user::add($_POST); if (!empty($_POST['jumpto'])) { $jumpto = $_POST['jumpto']; } + if (isset($_POST['display_form'])) { $display_form = $_POST['display_form']; } - if (!PEAR::isError($ok)) { - if ($ok == true) { - print "<h2>Account Request Submitted</h2>\n"; - print "Your account request has been submitted, it will ". - "be reviewed by a human shortly. This may take from two ". - "minutes to several days, depending on how much time people ". - "have. ". - "You will get an email when your account is open, or if ". - "your request was rejected for some reason."; + if (is_array($ok)) { + if ($ok[0] == 'set') { + print '<div class="warnings">'; + print '<h2>There were errors while storing the user '; + print "information.</h2>\n"; + print "<ul>\n <li>"; + array_shift($ok); + print implode("</li>\n <li>", $ok); + print "</li>\n</ul>"; + print '<p>Please drop an email about this to the '; + print '<a href="mailto:pear-dev@lists.php.net">pear-dev</a> '; + print 'mailing list.</p>'; + print "\n</div>\n"; } else { - print "<h2>Possible Problem!</h2>\n"; - print "Your account request has been submitted, but there ". - "were problems mailing one or more administrators. ". - "If you don't hear anything about your account in a few ". - "days, please drop a mail about it to the <i>pear-dev</i> ". - "mailing list."; + $errors = $ok; } - print "<br />Click <a href=\"/\">here</a> to go back to the front page.\n"; - $display_form = false; - } - break; + break; + } elseif ($ok == true) { + print '<div class="thanks">'; + print "<h2>Account Request Submitted</h2>\n"; + print "Your account request has been submitted, it will ". + "be reviewed by a human shortly. This may take from two ". + "minutes to several days, depending on how much time people ". + "have. ". + "You will get an email when your account is open, or if ". + "your request was rejected for some reason."; + print "\n</div>\n"; + } else { + print '<div class="warnings">'; + print "<h2>Possible Problem!</h2>\n"; + print "Your account request has been submitted, but there ". + "were problems mailing one or more administrators. ". + "If you don't hear anything about your account in a few ". + "days, please drop a mail about it to the <i>pear-dev</i> ". + "mailing list."; + print "\n</div>\n"; + } + + print '<br />Click <a href="/">here</a>'; + print ' to go back to the home page.' . "\n"; + $display_form = false; } } while (0); + if ($display_form) { - response_header("Request Account"); + response_header('Request Account'); - print "<h1>Request Account</h1> + print <<<MSG + +<h1>Request Account</h1> <p> -You only need to request an account if you + You only need to request an account if you: </p> <ul> -<li>Are planning to contribute a new package to PEAR and want to -propose this to the PEAR developer community.</li> - -<li>Are going to help in the maintenance of an existing package. This -needs to be approved by the current maintainers of the package or by -the <a href=\"/group/\">PEAR Group</a>.</li> + <li> + Are planning to contribute a new package to PEAR and want to propose this + to the PEAR developer community. + </li> + <li> + Are going to help in the maintenance of an existing package. This needs + to be approved by the current maintainers of the package or by the <a + href="/group/">PEAR Group</a>. + </li> </ul> <p> -If the reason for your request does not fall under one of the -reasons above, please contact the <a href=\"mailto:pear-dev@lists.php.net\"> -PEAR developers mailing list</a>. + If the reason for your request does not fall under one of the + reasons above, please contact the <a href="mailto:pear-dev@lists.php.net"> + PEAR developers mailing list</a>. </p> -<p>You do <b>not</b> need an account to: +<p> + You do <strong>not</strong> need an account to: </p> <ul> -<li>Download, install and/or use PEAR packages.</li> -<li>Submit patches or code improvements for a particular package. -Please use the <a href=\"/bugs/\">bug reporting system</a> for that -purpose.</li> -<li>Propose modifications to an existing package. Please use the -<a href=\"mailto:pear-dev@lists.php.net\">PEAR developers mailing -list</a> for that or directly contact the maintainers of the package -in question.</li> + <li> + Download, install and/or use PEAR packages. + </li> + <li> + Submit patches or code improvements for a particular package. + Please use the <a href="/bugs/">bug reporting system</a> for that purpose. + </li> + <li> + Propose modifications to an existing package. Please use the + <a href="mailto:pear-dev@lists.php.net">PEAR developers mailing list</a> for + that or directly contact the maintainers of the package in question. + </li> </ul> <p> -These are not the only reasons for requests being rejected, but the most -common ones. + These are not the only reasons for requests being rejected, but the most + common ones. </p> -<p>If you want to contribute a package to PEAR, make sure that you have -followed all rules concerning PEAR packages. Also, before a package -may be released, the code code must comply with the -<a href=\"http://pear.php.net/manual/en/standards.php\">PEAR Coding -Standards</a>.</p> - -<p>Bogus, incomplete or incorrect requests will be summarily denied.</p>"; - - print "<a name=\"requestform\" />\n"; - - if (isset($errorMsg)) { - print "<table>\n"; - print " <tr>\n"; - print " <td> </td>\n"; - print " <td><b>$errorMsg</b></td>\n"; - print " </tr>\n"; - print "</table>\n"; +<p> + If you want to contribute a package to PEAR, make sure that you have + followed all rules concerning PEAR packages. Also, before a package + may be released, the code code must comply with the + <a href="http://pear.php.net/manual/en/standards.php">PEAR Coding + Standards</a>. +</p> + +<p> + Bogus, incomplete or incorrect requests will be summarily denied. +</p> + +MSG; + + + print '<a name="requestform" id="requestform"></a>'; + + if ($errors) { + display_errors($errors); } + $invalid_purposes = array( 'Learn about PEAR.', 'Use PEAR.', @@ -156,29 +215,58 @@ 'Suggest new features.', 'Browse pear.php.net.' ); - $purposechecks = ''; - foreach ($invalid_purposes as $i => $purposeKey) - { - $purposechecks .= HTML_Form::returnCheckBox("purposecheck[$i]", @$_POST['purposecheck'][$i] ? 'on' : 'off'); - $purposechecks .= "$purposeKey <br />"; - } - - print "<form action=\"" . $_SERVER['PHP_SELF'] . "#requestform\" method=\"post\" name=\"request_form\">\n"; - $bb = new BorderBox("Request account", "90%", "", 2, true); - $bb->horizHeadRow("Username:", HTML_Form::returnText("handle", @$_POST['handle'], 12)); - $bb->horizHeadRow("First Name:", HTML_Form::returnText("firstname", @$_POST['firstname'])); - $bb->horizHeadRow("Last Name:", HTML_Form::returnText("lastname", @$_POST['lastname'])); - $bb->horizHeadRow("Password:", HTML_Form::returnPassword("password", null, 10) . " Again: " . HTML_Form::returnPassword("password2", null, 10)); - $bb->horizHeadRow("Email address:", HTML_Form::returnText("email", @$_POST['email'])); - $bb->horizHeadRow("Show email address?", HTML_Form::returnCheckbox("showemail", @$_POST['showemail'])); - $bb->horizHeadRow("Homepage", HTML_Form::returnText("homepage", @$_POST['homepage'])); - $bb->horizHeadRow("Purpose of your PEAR account:<br/>(Check all that apply)", $purposechecks); - $bb->horizHeadRow("If your intended purpose is not in the list, please state it here:", HTML_Form::returnTextarea("purpose", stripslashes(@$_POST['purpose']))); - $bb->horizHeadRow("More relevant information<br />about you (optional):", HTML_Form::returnTextarea("moreinfo", stripslashes(@$_POST['moreinfo']))); - $bb->horizHeadRow("You have read all the comments above:", HTML_Form::returnCheckbox("comments_read", @$_POST['comments_read'])); - $bb->horizHeadRow("<input type=\"submit\" name=\"submit\" /> <input type=\"reset\" />"); - $bb->end(); - print "</form>"; + $purposechecks = ''; + foreach ($invalid_purposes as $i => $purposeKey) + { + $purposechecks .= HTML_Form::returnCheckBox("purposecheck[$i]", @$_POST['purposecheck'][$i] ? 'on' : 'off'); + $purposechecks .= "$purposeKey <br />"; + } + + $form = new HTML_Form($_SERVER['PHP_SELF'] . '#requestform', 'post'); + + $form->addText('handle', 'Use<span class="underline">r</span>name:', + @$_POST['handle'], 12, 20, 'accesskey="r"', + 'class="form-label_left"', 'class="form-input"'); + $form->addText('firstname', 'First Name:', + @$_POST['firstname'], 20, null, '', + 'class="form-label_left"', 'class="form-input"'); + $form->addText('lastname', 'Last Name:', + @$_POST['lastname'], 20, null, '', + 'class="form-label_left"', 'class="form-input"'); + $form->addPassword('password', 'Password:', + '', 10, null, '', + 'class="form-label_left"', 'class="form-input"'); + $form->addText('email', 'Email address:', + @$_POST['email'], 20, null, '', + 'class="form-label_left"', 'class="form-input"'); + $form->addCheckbox('showemail', 'Show email address?', + @$_POST['showemail'], '', + 'class="form-label_left"', 'class="form-input"'); + $form->addText('homepage', 'Homepage:', + @$_POST['homepage'], 20, null, '', + 'class="form-label_left"', 'class="form-input"'); + $form->addPlaintext('Purpose of your PEAR account:' + . '<p class="cell_note">(Check all that apply)</p>', + $purposechecks, + 'class="form-label_left"', 'class="form-input"'); + $form->addTextarea('purpose', + 'If your intended purpose is not in the list, please state it here:', + stripslashes(@$_POST['purpose']), 40, 5, null, '', + 'class="form-label_left"', 'class="form-input"'); + $form->addTextarea('moreinfo', + 'More relevant information about you:' + . '<p class="cell_note">(optional)</p>', + stripslashes(@$_POST['moreinfo']), 40, 5, null, '', + 'class="form-label_left"', 'class="form-input"'); + $form->addCheckbox('comments_read', + 'You have read all of the comments above:', + @$_POST['comments_read'], '', + 'class="form-label_left"', 'class="form-input"'); + $form->addSubmit('submit', 'Submit Query', '', + 'class="form-label_left"', 'class="form-input"'); + + $form->display('class="form-holder" cellspacing="1" border="1"', + 'Request account', 'class="form-caption"'); if ($jumpto) { print "<script language=\"JavaScript\" type=\"text/javascript\">\n<!--\n";