Ejemplo n.º 1
0
 public function init()
 {
     $this->setAttrib('id', 'auth_lost_password')->setAttrib('name', 'auth_lost_password');
     $this->addElement(OSS_Form_Auth::createUsernameElement());
     $this->addElement(OSS_Form::createSubmitElement('submit', _('Reset Password')));
     $this->addElement(OSS_Form_Auth::createReturnToLoginElement());
 }
Ejemplo n.º 2
0
 public function init()
 {
     $this->setAttrib('id', 'auth_lost_username')->setAttrib('name', 'auth_lost_username');
     $this->addElement(OSS_Form_User::createEmailElement());
     $this->addElement(OSS_Form::createSubmitElement('submit', _('Find Username(s)')));
     $this->addElement(OSS_Form_Auth::createReturnToLoginElement());
 }
Ejemplo n.º 3
0
 public function init()
 {
     $this->setAttrib('id', 'change_password')->setAttrib('name', 'change_password')->setAction(OSS_Utils::genUrl('profile', 'change-password'));
     $this->addElement(OSS_Form_Auth::createPasswordElement('current_password')->setLabel(_('Current Password'))->setAttrib('class', 'span6'));
     $this->addElement(OSS_Form_Auth::createPasswordElement('new_password')->removeValidator('stringLength')->addValidator('stringLength', false, array(8, 255, 'UTF-8'))->setLabel(_('New Password'))->setAttrib('class', 'span6'));
     $this->addElement(OSS_Form_Auth::createPasswordConfirmElement('confirm_password', 'new_password')->setAttrib('class', 'span6'));
     $this->addElement(OSS_Form::createSubmitElement('submit', _('Change Password')));
 }
Ejemplo n.º 4
0
 public function init()
 {
     $this->setAttrib('id', 'customer_notes')->setAttrib('name', 'customer_notes')->setAction(OSS_Utils::genUrl('profile', 'update-customer-notes'));
     $notify = $this->createElement('radio', 'notify');
     $notify->addMultiOptions(['none' => 'Disable all email notifications', 'default' => 'Email me on changes to only watched customers and notes', 'all' => 'Email me on any change to any customer note'])->setValue('default');
     $this->addElement($notify);
     $this->addElement(OSS_Form::createSubmitElement('submit', _('Change Notification Preference')));
 }
Ejemplo n.º 5
0
 public function init()
 {
     $this->setAttrib('id', 'auth_reset_password')->setAttrib('name', 'auth_reset_password');
     $this->addElement(OSS_Form_Auth::createUsernameElement());
     $this->addElement(OSS_Form_Auth::createPasswordResetTokenElement());
     $this->addElement(OSS_Form_Auth::createPasswordElement()->removeValidator('stringLength')->addValidator('stringLength', false, array(8, 30, 'UTF-8')));
     $this->addElement(OSS_Form_Auth::createPasswordConfirmElement());
     $this->addElement(OSS_Form::createSubmitElement('submit', _('Reset Password')));
     $this->addElement(OSS_Form_Auth::createReturnToLoginElement());
 }
Ejemplo n.º 6
0
 public function init()
 {
     $this->setAttrib('id', 'auth_reset_password')->setAttrib('name', 'auth_reset_password');
     $this->addElement(OSS_Form_Auth::createUsernameElement());
     $this->addElement(OSS_Form_Auth::createPasswordResetTokenElement());
     $this->addElement(OSS_Form_Auth::createPasswordElement());
     $this->addElement(OSS_Form_Auth::createPasswordConfirmElement());
     $this->addElement(OSS_Form::createSubmitElement('submit', _('Reset Password')));
     $this->_addActionsDisplayGroupElement(OSS_Form_Auth::createReturnToLoginElement());
 }
Ejemplo n.º 7
0
 public function init()
 {
     $this->setAttrib('id', 'auth_login')->setAttrib('name', 'auth_login');
     $this->addElement(OSS_Form_Auth::createUsernameElement());
     $this->addElement(OSS_Form_Auth::createPasswordElement());
     //$this->addElement( OSS_Form_Auth::createRememberMeElement() );
     $this->addElement(OSS_Form::createSubmitElement('submit', _('Login')));
     $this->addElement(OSS_Form_Auth::createLostPasswordElement());
     $this->addElement(OSS_Form_Auth::createLostUsernameElement());
 }
 /**
  * Pre db flush hook that can be overridden by subclasses for add and edit.
  *
  * This is called if the user POSTs a valid form after the posted
  * data has been assigned to the object and just before it is (persisted
  * if adding) and the database is flushed.
  *
  * This hook can prevent flushing by returning false.
  *
  * **NB: You should not `flush()` here unless you know what you are doing**
  *
  * A call to `flush()` is made after this method returns true ensuring a
  * transactional `flush()` for all.
  *
  * @param OSS_Form $form The Send form object
  * @param \Entities\Infrastructure $object The Doctrine2 entity (being edited or blank for add)
  * @param bool $isEdit True if we are editing, otherwise false
  * @return bool If false, the form is not persisted
  */
 protected function addPreFlush($form, $object, $isEdit)
 {
     $ixp = $this->getD2R('\\Entities\\IXP')->find($form->getValue('ixp'));
     if (!$ixp) {
         $this->addMessage('There is an issue with your infrastructures as we could not load an infrastructure with ID ' . $form->getValue('ixp'), OSS_Message::ERROR);
         return false;
     }
     $object->setIXP($ixp);
     // if we're setting this infra as the primary, ensure the rest in this IXP are not primary
     if ($object->getIsPrimary()) {
         foreach ($ixp->getInfrastructures() as $i) {
             if ($i->getId() != $object->getId()) {
                 $i->setIsPrimary(false);
             }
         }
     }
     return true;
 }
Ejemplo n.º 9
0
 /**
  * Post process hook for add and edit actions.
  *
  * This is called immediately after the initstantiation of the form object and, if
  * editing, includes the Doctrine2 entity `$object`.
  *
  * If you need to have, for example, edit values set in the form, then use the
  * `addPrepare()` hook rather than this one.
  *
  * @see addPrepare()
  * @param OSS_Form $form The form object
  * @param object $object The Doctrine2 entity (being edited or blank for add)
  * @param bool $isEdit True of we are editing an object, false otherwise
  * @param array $options Options passed onto Zend_Form
  * @param string $cancelLocation Where to redirect to if 'Cancal' is clicked
  */
 protected function formPostProcess($form, $object, $isEdit, $options = null, $cancelLocation = null)
 {
     if ($object->getIRRDB() instanceof \Entities\IRRDBConfig) {
         $form->getElement('irrdb')->setValue($object->getIRRDB()->getId());
     }
     $form->enableResller($this->resellerMode());
     $form->setMultiIXP($this->multiIXP(), $isEdit);
     if ($this->resellerMode()) {
         if ($object->getReseller() instanceof \Entities\Customer) {
             $form->getElement('isResold')->setValue(true);
             $form->getElement('reseller')->setValue($object->getReseller()->getId());
         }
     }
     if ($isEdit) {
         $form->assignEntityToForm($object->getBillingDetails(), $this);
         $form->assignEntityToForm($object->getRegistrationDetails(), $this);
         $form->updateCancelLocation(OSS_Utils::genUrl('customer', 'overview', null, ['id' => $object->getId()]));
     }
     return true;
 }
Ejemplo n.º 10
0
 /**
  * Post process hook for add and edit actions.
  *
  * This is called immediately after the initstantiation of the form object and, if
  * editing, includes the Doctrine2 entity `$object`.
  *
  * If you need to have, for example, edit values set in the form, then use the
  * `addPrepare()` hook rather than this one.
  *
  * @see addPrepare()
  * @param OSS_Form $form The form object
  * @param \Entities\Vlan $object The Doctrine2 entity (being edited or blank for add)
  * @param bool $isEdit True of we are editing an object, false otherwise
  * @param array $options Options passed onto Zend_Form
  * @param string $cancelLocation Where to redirect to if 'Cancal' is clicked
  */
 protected function formPostProcess($form, $object, $isEdit, $options = null, $cancelLocation = null)
 {
     if ($isEdit) {
         $form->getElement('infrastructure')->setValue($object->getInfrastructure()->getId());
     }
     return true;
 }
 /**
  * Post process hook that can be overridden by subclasses for add and edit actions.
  *
  * This is called immediately after the initstantiation of the form object and, if
  * editing, includes the Doctrine2 entity `$object`.
  *
  * If you need to have, for example, edit values set in the form, then use the
  * `addPrepare()` hook rather than this one.
  *
  * @see addPrepare()
  * @param OSS_Form $form The form object
  * @param \Entities\ContactGroup $object The Doctrine2 entity (being edited or blank for add)
  * @param bool $isEdit True of we are editing an object, false otherwise
  * @param array $options Options passed onto Zend_Form
  * @param string $cancelLocation Where to redirect to if 'Cancal' is clicked
  */
 protected function formPostProcess($form, $object, $isEdit, $options = null, $cancelLocation = null)
 {
     $form->getElement('type')->setMultiOptions($this->_options['contact']['group']['types']);
 }
/**
 * Get form elements
 *
 * @category   OSS
 * @package    OSS_Smarty
 * @subpackage Functions
 *
 * @param OSS_Form $formObj Form to get elements
 * @param array &$validationRules Array of rules for validate elements
 * @return void
 */
function __vimbadmin_getFormElements($formObj, &$validationRules)
{
    foreach ($formObj->getElements() as $oneElement) {
        $fieldId = $oneElement->getID();
        if (get_class($oneElement) == 'Zend_Form_Element_Checkbox') {
            $validationRules[$fieldId]['field_type'] = get_class($oneElement);
        }
        if ($oneElement->isRequired() == true) {
            $validationRules[$fieldId]['required'] = true;
        }
        foreach ($oneElement->getValidators() as $oneValidator) {
            switch (get_class($oneValidator)) {
                case 'Zend_Validate_NotEmpty':
                    $validationRules[$fieldId]['notEmpty'] = true;
                    break;
                case 'Zend_Validate_StringLength':
                    $validationRules[$fieldId]['minlength'] = $oneValidator->getMin();
                    $validationRules[$fieldId]['maxlength'] = $oneValidator->getMax();
                    break;
                case 'Zend_Validate_EmailAddress':
                    $validationRules[$fieldId]['email'] = true;
                    break;
                case 'Zend_Validate_Digits':
                    $validationRules[$fieldId]['digits'] = true;
                    break;
                case 'Zend_Validate_Int':
                    $validationRules[$fieldId]['integer'] = true;
                    break;
                case 'Zend_Validate_Float':
                    $validationRules[$fieldId]['number'] = true;
                    break;
                case 'Zend_Validate_Ccnum':
                    $validationRules[$fieldId]['creditcard'] = true;
                    break;
                case 'Zend_Validate_InArray':
                    $validationRules[$fieldId]['inArray'] = $oneValidator->getHaystack();
                    break;
                case 'Zend_Validate_Between':
                    if ($oneValidator->getInclusive()) {
                        $validationRules[$fieldId]['betweenIn'] = array($oneValidator->getMin(), $oneValidator->getMax());
                    } else {
                        $validationRules[$fieldId]['betweenEx'] = array($oneValidator->getMin(), $oneValidator->getMax());
                    }
                    break;
                case 'Zend_Validate_LessThan':
                    $validationRules[$fieldId]['lessThan'] = $oneValidator->getMax();
                    break;
                case 'Zend_Validate_GreaterThan':
                    $validationRules[$fieldId]['greaterThan'] = $oneValidator->getMin();
                    break;
                case 'Zend_Validate_Hostname':
                    $validationRules[$fieldId]['hostname'] = true;
                    break;
                case 'ViMbAdmin_Validate_IdenticalField':
                    $validationRules[$fieldId]['equalTo'] = '#' . $oneValidator->getFieldName();
                    break;
                default:
                    break;
            }
            // switch ( validator class )
        }
        // foreach validators
    }
    // foreach elements
}
Ejemplo n.º 13
0
 /**
  * Prevalidation hook that can be overridden by subclasses for add and edit.
  *
  * This is called if the user POSTs a form just before the form is validated by Zend
  *
  * @param OSS_Form $form The Send form object
  * @param object $object The Doctrine2 entity (being edited or blank for add)
  * @param bool $isEdit True if we are editing, otherwise false
  * @return bool If false, the form is not validated or processed
  */
 protected function addPreValidate($form, $object, $isEdit)
 {
     if (isset($_POST['login']) && $_POST['login'] == '1') {
         $form->getElement("username")->setRequired(true);
         if (!$isEdit && $this->getUser()->getPrivs() == \Entities\User::AUTH_SUPERUSER) {
             $form->getElement("password")->setRequired(true);
             $form->getElement("privs")->setRequired(true);
         }
     } else {
         $_POST['login'] = 0;
     }
     $this->view->contactGroups = $this->_postedGroupsToArray();
     return true;
 }
Ejemplo n.º 14
0
 /**
  * Add the required CAPTCHA elements to a form
  *
  * @param OSS_Form $form The form to add the elements to
  * @return OSS_Form The same form for fluent interfaces
  */
 public static function addCaptchaElements($form)
 {
     $form->addElement(self::createIdElement());
     $form->addElement(self::createRequestNewImageElement());
     $form->addElement(self::createInputElement());
     return $form;
 }