示例#1
0
 public function __construct($options = array())
 {
     parent::__construct($options);
     $this->setAttrib('id', 'signup');
     // Create and configure username element:
     $username = $this->createElement('text', 'username', array('label' => 'model-account-username'));
     $username->setRequired(true)->addFilter('StringTrim')->addFilter('Alnum')->addFilter('StripTags')->addValidator('StringLength', false, array(3, 64))->setAttrib('maxlength', '64');
     // First Name
     $firstName = $this->createElement('text', 'firstName', array('label' => 'model-account-firstName'));
     $firstName->setRequired(true)->addFilter('StringToLower')->addFilter('StringTrim')->addFilter('StripTags')->addFilter(new Ot_Filter_Ucwords())->setAttrib('maxlength', '64');
     // Last Name
     $lastName = $this->createElement('text', 'lastName', array('label' => 'model-account-lastName'));
     $lastName->setRequired(true)->addFilter('StringTrim')->addFilter('StringToLower')->addFilter('StripTags')->addFilter(new Ot_Filter_Ucwords())->setAttrib('maxlength', '64');
     // Password field
     $password = $this->createElement('password', 'password', array('label' => 'model-account-password'));
     $password->setRequired(true)->addValidator('StringLength', false, array($this->_minPasswordLength, $this->_maxPasswordLength))->addFilter('StringTrim')->addFilter('StripTags');
     // Password confirmation field
     $passwordConf = $this->createElement('password', 'passwordConf', array('label' => 'model-account-passwordConf'));
     $passwordConf->setRequired(true)->addValidator('StringLength', false, array($this->_minPasswordLength, $this->_maxPasswordLength))->addValidator('Identical', false, array('token' => 'password'))->addFilter('StringTrim')->addFilter('StripTags');
     // Email address field
     $email = $this->createElement('text', 'emailAddress', array('label' => 'model-account-emailAddress'));
     $email->setRequired(true)->addFilter('StringTrim')->addValidator('EmailAddress');
     $timezone = $this->createElement('select', 'timezone', array('label' => 'model-account-timezone'));
     $timezone->addMultiOptions(Ot_Model_Timezone::getTimezoneList());
     $timezone->setValue(date_default_timezone_get());
     $this->addElements(array($username, $password, $passwordConf, $firstName, $lastName, $email, $timezone));
     $aar = new Ot_Account_Attribute_Register();
     $vars = $aar->getVars();
     foreach ($vars as $v) {
         $elm = $v->renderFormElement();
         $elm->clearDecorators();
         $elm->setBelongsTo('accountAttributes');
         $this->addElement($elm);
     }
     $cahr = new Ot_CustomAttribute_HostRegister();
     $thisHost = $cahr->getHost('Ot_Profile');
     if (is_null($thisHost)) {
         throw new Ot_Exception_Data('msg-error-objectNotSetup');
     }
     $customAttributes = $thisHost->getAttributes();
     foreach ($customAttributes as $a) {
         $elm = $a['var']->renderFormElement();
         $elm->clearDecorators();
         $elm->setBelongsTo('customAttributes');
         $this->addElement($elm);
     }
     $this->addElement('submit', 'submit', array('buttonType' => Twitter_Bootstrap_Form_Element_Submit::BUTTON_PRIMARY, 'label' => 'Create My Account'));
     $this->addElement('button', 'cancel', array('label' => 'form-button-cancel', 'type' => 'button'));
     $this->addDisplayGroup(array('submit', 'cancel'), 'actions', array('disableLoadDefaultDecorators' => true, 'decorators' => array('Actions')));
     return $this;
 }
示例#2
0
 /**
  * Updates the currently logged in user's account information (the user 
  * associated with the API key)
  * 
  * Params
  * ===========================    
  * Required:
  *   - firstName: The first name of the user
  *   - lastName: The last name of the user
  *   - emailAddress: The email address of the user
  *   - timezone: The timezone of the user (America/New_York, etc.)
  *
  */
 public function put($params)
 {
     if (!Zend_Auth::getInstance()->hasIdentity()) {
         throw new Ot_Exception_Access('msg-error-apiAccessDenied');
     }
     $this->checkForEmptyParams(array('firstName', 'lastName', 'emailAddress', 'timezone'), $params);
     if (!in_array($params['timezone'], Ot_Model_Timezone::getTimezoneList())) {
         throw new Ot_Exception_Data('msg-error-invalidTimezone');
     }
     $otAccount = new Ot_Model_DbTable_Account();
     $accountId = Zend_Auth::getInstance()->getIdentity()->accountId;
     $data = array('accountId' => $accountId, 'firstName' => $params['firstName'], 'lastName' => $params['lastName'], 'emailAddress' => $params['emailAddress'], 'timezone' => $params['timezone']);
     $otAccount->update($data, null);
     return true;
 }
示例#3
0
 public function __construct($new = false, $me = false, $options = array())
 {
     parent::__construct($options);
     $acl = Zend_Registry::get('acl');
     $this->setAttrib('id', 'account');
     $authAdapter = new Ot_Model_DbTable_AuthAdapter();
     $adapters = $authAdapter->fetchAll(null, 'displayOrder');
     // Realm Select box
     $realmSelect = $this->createElement('select', 'realm', array('label' => 'Login Method'));
     foreach ($adapters as $adapter) {
         $realmSelect->addMultiOption($adapter->adapterKey, $adapter->name . (!$adapter->enabled ? ' (Disabled)' : ''));
     }
     // Create and configure username element:
     $username = $this->createElement('text', 'username', array('label' => 'model-account-username'));
     $username->setRequired(true)->addFilter('StringTrim')->addFilter('Alnum')->addFilter('StripTags')->addValidator('StringLength', false, array(3, 64))->setAttrib('maxlength', '64');
     // First Name
     $firstName = $this->createElement('text', 'firstName', array('label' => 'model-account-firstName'));
     $firstName->setRequired(true)->addFilter('StringToLower')->addFilter('StringTrim')->addFilter('StripTags')->addFilter(new Ot_Filter_Ucwords())->setAttrib('maxlength', '64');
     // Last Name
     $lastName = $this->createElement('text', 'lastName', array('label' => 'model-account-lastName'));
     $lastName->setRequired(true)->addFilter('StringTrim')->addFilter('StringToLower')->addFilter('StripTags')->addFilter(new Ot_Filter_Ucwords())->setAttrib('maxlength', '64');
     // Email address field
     $email = $this->createElement('text', 'emailAddress', array('label' => 'model-account-emailAddress'));
     $email->setRequired(true)->addFilter('StringTrim')->addValidator('EmailAddress');
     $timezone = $this->createElement('select', 'timezone', array('label' => 'model-account-timezone'));
     $timezone->addMultiOptions(Ot_Model_Timezone::getTimezoneList());
     $timezone->setValue(date_default_timezone_get());
     // Role select box
     $roleSelect = $this->createElement('multiselect', 'role', array('label' => 'model-account-role'));
     $roleSelect->setRequired(true);
     $roleSelect->setDescription('You may select multiple roles for a user');
     $roles = $acl->getAvailableRoles();
     foreach ($roles as $r) {
         $roleSelect->addMultiOption($r['roleId'], $r['name']);
     }
     if ($new) {
         $this->addElements(array($realmSelect, $username, $roleSelect, $firstName, $lastName, $email, $timezone));
     } else {
         if ($me) {
             $this->addElements(array($firstName, $lastName, $email, $timezone));
         } else {
             $realmSelect->setAttrib('disabled', 'disabled');
             $username->setAttrib('disabled', 'disabled');
             $this->addElements(array($realmSelect, $username, $roleSelect, $firstName, $lastName, $email, $timezone));
         }
     }
     $aar = new Ot_Account_Attribute_Register();
     $vars = $aar->getVars();
     foreach ($vars as $v) {
         $elm = $v->renderFormElement();
         $elm->clearDecorators();
         $elm->setBelongsTo('accountAttributes');
         $this->addElement($elm);
     }
     $cahr = new Ot_CustomAttribute_HostRegister();
     $thisHost = $cahr->getHost('Ot_Profile');
     if (is_null($thisHost)) {
         throw new Ot_Exception_Data('msg-error-objectNotSetup');
     }
     $customAttributes = $thisHost->getAttributes();
     foreach ($customAttributes as $a) {
         $elm = $a['var']->renderFormElement();
         $elm->clearDecorators();
         $elm->setBelongsTo('customAttributes');
         $this->addElement($elm);
     }
     $this->addElement('submit', 'submit', array('buttonType' => Twitter_Bootstrap_Form_Element_Submit::BUTTON_PRIMARY, 'label' => 'form-button-save'));
     $this->addElement('button', 'cancel', array('label' => 'form-button-cancel', 'type' => 'button'));
     $this->addDisplayGroup(array('submit', 'cancel'), 'actions', array('disableLoadDefaultDecorators' => true, 'decorators' => array('Actions')));
     return $this;
 }