|
Perforce Chronicle 2012.2/486814
API Documentation
|
This is the user login form. More...
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 | |
This is the user login form.
| User_Form_Login::getAcl | ( | ) |
Get the ACL instance in use by this form.
| P4Cms_Acl_Exception | if 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.
| P4Cms_Acl | $acl | the acl instance to use. |
{
$this->_acl = $acl;
}
User_Form_Login::$_acl = null [protected] |