Perforce Chronicle 2012.2/486814
API Documentation

User_Form_Login Class Reference

This is the user login form. More...

Inheritance diagram for User_Form_Login:
P4Cms_Form

List of all members.

Public Member Functions

 getAcl ()
 Get the ACL instance in use by this form.
 init ()
 Defines the elements that make up the login form.
 setAcl (P4Cms_Acl $acl)
 Set the ACL instance to use.

Protected Attributes

 $_acl = null

Detailed Description

This is the user login form.

Copyright:
2011-2012 Perforce Software. All rights reserved
License:
Please see LICENSE.txt in top-level folder of this distribution.
Version:
2012.2/486814

Member Function Documentation

User_Form_Login::getAcl ( )

Get the ACL instance in use by this form.

Returns:
P4Cms_Acl the acl in use by the form.
Exceptions:
P4Cms_Acl_Exceptionif no acl has been set.
    {
        if (!$this->_acl instanceof P4Cms_Acl) {
            throw new P4Cms_Acl_Exception(
                "Cannot get acl. No acl has been set."
            );
        }

        return $this->_acl;
    }
User_Form_Login::init ( )

Defines the elements that make up the login form.

Called automatically when the form object is created.

    {
        // form should use p4cms-ui styles.
        $this->setAttrib('class', 'p4cms-ui login-form p4cms-user-login');
        
        // form should submit on enter
        $this->setAttrib('submitOnEnter', true);

        // set the method for the form to POST
        $this->setMethod('post');

        // add a field to collect the user name.
        $this->addElement(
            'text',
            'user',
            array(
                'label'         => 'User',
                'required'      => true,
                'description'   => "Enter your email address or username.",
                'filters'       => array('StringTrim'),
                'size'          => 20
            )
        );

        // add a field to collect the user's password
        $this->addElement(
            'password',
            'password',
            array(
                'label'         => 'Password',
                'required'      => false,
                'size'          => 20
            )
        );

        // add the submit button
        $this->addElement(
            'SubmitButton',
            'login',
            array(
                'label'     => 'Login',
                'required'  => false,
                'ignore'    => true,
                'class'     => 'preferred'
            )
        );
        $buttons = array('login');

        // add an 'add user' button, if we have appropriate permissions
        $user = P4Cms_User::fetchActive();
        if ($user->isAllowed('users', 'add', $this->getAcl()) && P4_User::isAutoUserCreationEnabled()) {
            $this->addElement(
                'Button',
                'addNewUser',
                array(
                    'label'     => 'New User',
                    'class'     => 'add-button',
                    'ignore'    => true,
                    'onclick'   => 'window.location = p4cms.url({module: "user", controller: "index", action: "add"});',
                )
            );
            $buttons[] = 'addNewUser';
        }

        // put the button in a fieldset.
        $this->addDisplayGroup(
            $buttons,
            'buttons',
            array('class' => 'buttons')
        );
    }
User_Form_Login::setAcl ( P4Cms_Acl acl)

Set the ACL instance to use.

Parameters:
P4Cms_Acl$aclthe acl instance to use.
    {
        $this->_acl = $acl;
    }

Member Data Documentation

User_Form_Login::$_acl = null [protected]

The documentation for this class was generated from the following file: