      1: <?php
      2:
      3: /**
      4:  *
      5:  * The rendering class for the PersonObject class
      6:  *
      7:  * @package alpha::view
      8:  * @since 1.0
      9:  * @author John Collins <dev@alphaframework.org>
     10:  * @version $Id: PersonView.inc 1548 2012-07-29 17:07:07Z alphadevx $
     11:  * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
     12:  * @copyright Copyright (c) 2012, John Collins (founder of Alpha Framework).
     13:  * All rights reserved.
     14:  *
     15:  * <pre>
     16:  * Redistribution and use in source and binary forms, with or
     17:  * without modification, are permitted provided that the
     18:  * following conditions are met:
     19:  *
     20:  * * Redistributions of source code must retain the above
     21:  *   copyright notice, this list of conditions and the
     22:  *   following disclaimer.
     23:  * * Redistributions in binary form must reproduce the above
     24:  *   copyright notice, this list of conditions and the
     25:  *   following disclaimer in the documentation and/or other
     26:  *   materials provided with the distribution.
     27:  * * Neither the name of the Alpha Framework nor the names
     28:  *   of its contributors may be used to endorse or promote
     29:  *   products derived from this software without specific
     30:  *   prior written permission.
     31:  *
     32:  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
     33:  * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
     34:  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
     35:  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
     36:  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
     37:  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
     38:  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     39:  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
     40:  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     41:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     42:  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
     43:  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
     44:  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     45:  * </pre>
     46:  *
     47:  */
     48: class PersonView extends AlphaView {
     49:
     50:     /**
     51:      * Method to render the login HTML form
     52:      *
     53:      * @return string
     54:      * @since 1.0
     55:      */
     56:     public function displayLoginForm() {
     57:         global $config;
     58:
     59:         $html = '<div class="bordered" style="text-align:center; padding:10px; margin:10px;">';
     60:         $html .= '<form action="'.FrontController::generateSecureURL('act=Login&no-forceframe=true').'" method="POST" id="loginForm">';
     61:         $html .= '<table cols="2" align="center">';
     62:         $html .= '<tr>';
     63:         $stringBox = new StringBox(new String(isset($_POST["email"])? $_POST["email"] : ''), $this->BO->getDataLabel('email'), 'email', 'loginForm', '50');
     64:         $html .= $stringBox->render(true);
     65:         $html .= '</tr>';
     66:         $html .= '<tr>';
     67:         $password = new String();
     68:         $password->isPassword();
     69:         $stringBox = new StringBox($password, $this->BO->getDataLabel('password'), 'password', 'loginForm', '50');
     70:         $html .= $stringBox->render(true);
     71:         $html .= '</tr>';
     72:         $html .= '<tr><td colspan="2">';
     73:         $temp = new Button("submit","Login","loginBut");
     74:         $html .= '<div align="center">'.$temp->render(80).'</div>';
     75:         $html .= '</td></tr>';
     76:
     77:         $html .= $this->renderSecurityFields();
     78:
     79:         $html .= '</table>';
     80:         $html .= '</form>';
     81:
     82:         $html .= '<p><a href="'.FrontController::generateSecureURL('act=Login&reset=true&no-forceframe=true').'">Forgotten your password?</a></p>';
     83:         $html .= '</div>';
     84:
     85:         return $html;
     86:     }
     87:
     88:     /**
     89:      * Method to render the reset password HTML form
     90:      *
     91:      * @return string
     92:      * @since 1.0
     93:      */
     94:     public function displayResetForm() {
     95:         global $config;
     96:
     97:         $html = '<p>If you have forgotten your password, you can use this form to have a new password automatically generated and sent to your e-mail address.</p>';
     98:         $html .= '<table cols="2">';
     99:         $html .= '<form action="'.FrontController::generateSecureURL('act=Login&reset=true&no-forceframe=true').'" method="POST">';
    100:         $html .= '<tr>';
    101:         $html .= '  <td>E-mail Address</td> <td><input type="text" name="email" size="50" value="'.(isset($_POST["email"])? $_POST["email"] : '').'"/></td>';
    102:         $html .= '</tr>';
    103:         $html .= '<tr><td colspan="2">';
    104:         $temp = new Button("submit","Reset Password","resetBut");
    105:         $html .= $temp->render();
    106:         $html .= '&nbsp;&nbsp;';
    107:         $temp = new Button("document.location.replace('".$config->get('app.url')."')","Cancel","cancelBut");
    108:         $html .= $temp->render();
    109:         $html .= '</td></tr>';
    110:
    111:         $html .= $this->renderSecurityFields();
    112:
    113:         $html .= '</form>';
    114:         $html .= '</table>';
    115:
    116:         return $html;
    117:     }
    118:
    119:     /**
    120:      * Method to render the user registration form
    121:      *
    122:      * @return string
    123:      * @since 1.0
    124:      */
    125:     public function displayRegisterForm() {
    126:         global $config;
    127:
    128:         $html = '<p>In order to access this site, you will need to create a user account.  In order to do so, please provide a valid email address below and a password will be sent to your inbox shortly (you can change your password once you log in).</p>';
    129:         $html .= '<table cols="2">';
    130:         $html .= '<form action="'.$_SERVER["PHP_SELF"].'?reset=true" method="POST">';
    131:         $html .= '<tr>';
    132:         $html .= '  <td>Forum name</td> <td><input type="text" name="displayname" size="50" value="'.(isset($_POST["displayname"])? $_POST["displayname"] : '').'"/></td>';
    133:         $html .= '</tr>';
    134:         $html .= '<tr>';
    135:         $html .= '  <td>E-mail Address</td> <td><input type="text" name="email" size="50" value="'.(isset($_POST["email"])? $_POST["email"] : '').'"/></td>';
    136:         $html .= '</tr>';
    137:         $html .= '<tr><td colspan="2">';
    138:         $temp = new Button("submit","Register","registerBut");
    139:         $html .= $temp->render();
    140:         $html .= '&nbsp;&nbsp;';
    141:         $temp = new Button("document.location.replace('".$config->get('app.url')."')","Cancel","cancelBut");
    142:         $html .= $temp->render();
    143:         $html .= '</td></tr>';
    144:
    145:         $html .= $this->renderSecurityFields();
    146:
    147:         $html .= '</form>';
    148:         $html .= '</table>';
    149:
    150:         return $html;
    151:     }
    152: }
    153:
    154: ?>
    155: