public function init() { $CC_CONFIG = Config::getConfig(); // Set the method for the display form to POST $this->setMethod('post'); $this->setDecorators(array(array('ViewScript', array('viewScript' => 'form/login.phtml')))); // Add username element $this->addElement('text', 'username', array('label' => _('Username:'******'class' => 'input_text', 'required' => true, 'value' => isset($CC_CONFIG['demo']) && $CC_CONFIG['demo'] == 1 ? 'admin' : '', 'filters' => array('StringTrim'), 'validators' => array('NotEmpty'), 'decorators' => array('ViewHelper'))); // Add password element $this->addElement('password', 'password', array('label' => _('Password:'******'class' => 'input_text', 'required' => true, 'value' => isset($CC_CONFIG['demo']) && $CC_CONFIG['demo'] == 1 ? 'admin' : '', 'filters' => array('StringTrim'), 'validators' => array('NotEmpty'), 'decorators' => array('ViewHelper'))); $locale = new Zend_Form_Element_Select("locale"); $locale->setLabel(_("Language:")); $locale->setMultiOptions(Application_Model_Locale::getLocales()); $locale->setDecorators(array('ViewHelper')); $this->addElement($locale); $recaptchaNeeded = false; if (Application_Model_LoginAttempts::getAttempts($_SERVER['REMOTE_ADDR']) >= 3) { $recaptchaNeeded = true; } if ($recaptchaNeeded) { // recaptcha $this->addRecaptcha(); } // Add the submit button $this->addElement('submit', 'submit', array('ignore' => true, 'label' => _('Login'), 'class' => 'ui-button ui-widget ui-state-default ui-button-text-only center', 'decorators' => array('ViewHelper'))); }
public function init() { $notEmptyValidator = Application_Form_Helper_ValidationTypes::overrideNotEmptyValidator(); $rangeValidator = Application_Form_Helper_ValidationTypes::overrideBetweenValidator(0, 59.9); $this->setDecorators(array(array('ViewScript', array('viewScript' => 'form/preferences_general.phtml')))); $defaultFadeIn = Application_Model_Preference::GetDefaultFadeIn(); $defaultFadeOut = Application_Model_Preference::GetDefaultFadeOut(); //Station name $this->addElement('text', 'stationName', array('class' => 'input_text', 'label' => _('Station Name'), 'required' => false, 'filters' => array('StringTrim'), 'value' => Application_Model_Preference::GetStationName(), 'decorators' => array('ViewHelper'))); //Default station fade in $this->addElement('text', 'stationDefaultCrossfadeDuration', array('class' => 'input_text', 'label' => _('Default Crossfade Duration (s):'), 'required' => true, 'filters' => array('StringTrim'), 'validators' => array(array($rangeValidator, $notEmptyValidator, 'regex', false, array('/^[0-9]{1,2}(\\.\\d{1})?$/', 'messages' => _('enter a time in seconds 0{.0}')))), 'value' => Application_Model_Preference::GetDefaultCrossfadeDuration(), 'decorators' => array('ViewHelper'))); //Default station fade in $this->addElement('text', 'stationDefaultFadeIn', array('class' => 'input_text', 'label' => _('Default Fade In (s):'), 'required' => true, 'filters' => array('StringTrim'), 'validators' => array(array($rangeValidator, $notEmptyValidator, 'regex', false, array('/^[0-9]{1,2}(\\.\\d{1})?$/', 'messages' => _('enter a time in seconds 0{.0}')))), 'value' => $defaultFadeIn, 'decorators' => array('ViewHelper'))); //Default station fade out $this->addElement('text', 'stationDefaultFadeOut', array('class' => 'input_text', 'label' => _('Default Fade Out (s):'), 'required' => true, 'filters' => array('StringTrim'), 'validators' => array(array($rangeValidator, $notEmptyValidator, 'regex', false, array('/^[0-9]{1,2}(\\.\\d{1})?$/', 'messages' => _('enter a time in seconds 0{.0}')))), 'value' => $defaultFadeOut, 'decorators' => array('ViewHelper'))); $third_party_api = new Zend_Form_Element_Radio('thirdPartyApi'); $third_party_api->setLabel(sprintf(_('Allow Remote Websites To Access "Schedule" Info?%s (Enable this to make front-end widgets work.)'), '<br>')); $third_party_api->setMultiOptions(array(_("Disabled"), _("Enabled"))); $third_party_api->setValue(Application_Model_Preference::GetAllow3rdPartyApi()); $third_party_api->setDecorators(array('ViewHelper')); $this->addElement($third_party_api); $locale = new Zend_Form_Element_Select("locale"); $locale->setLabel(_("Default Interface Language")); $locale->setMultiOptions(Application_Model_Locale::getLocales()); $locale->setValue(Application_Model_Preference::GetDefaultLocale()); $locale->setDecorators(array('ViewHelper')); $this->addElement($locale); /* Form Element for setting the Timezone */ $timezone = new Zend_Form_Element_Select("timezone"); $timezone->setLabel(_("Station Timezone")); $timezone->setMultiOptions(Application_Common_Timezone::getTimezones()); $timezone->setValue(Application_Model_Preference::GetDefaultTimezone()); $timezone->setDecorators(array('ViewHelper')); $this->addElement($timezone); /* Form Element for setting which day is the start of the week */ $week_start_day = new Zend_Form_Element_Select("weekStartDay"); $week_start_day->setLabel(_("Week Starts On")); $week_start_day->setMultiOptions($this->getWeekStartDays()); $week_start_day->setValue(Application_Model_Preference::GetWeekStartDay()); $week_start_day->setDecorators(array('ViewHelper')); $this->addElement($week_start_day); }
public function editUserAction() { $request = $this->getRequest(); $form = new Application_Form_EditUser(); if ($request->isPost()) { $formData = $request->getPost(); if ($form->isValid($formData) && $form->validateLogin($formData['cu_login'], $formData['cu_user_id'])) { $user = new Application_Model_User($formData['cu_user_id']); $user->setFirstName($formData['cu_first_name']); $user->setLastName($formData['cu_last_name']); // We don't allow 6 x's as a password. // The reason is because we use that as a password placeholder // on the client side. if ($formData['cu_password'] != "xxxxxx") { $user->setPassword($formData['cu_password']); } $user->setEmail($formData['cu_email']); $user->setCellPhone($formData['cu_cell_phone']); $user->setSkype($formData['cu_skype']); $user->setJabber($formData['cu_jabber']); $user->save(); Application_Model_Preference::SetUserLocale($formData['cu_locale']); Application_Model_Preference::SetUserTimezone($formData['cu_timezone']); //configure localization with new locale setting Application_Model_Locale::configureLocalization($formData['cu_locale']); //reinitialize form so language gets translated $form = new Application_Form_EditUser(); $this->view->successMessage = "<div class='success'>" . _("Settings updated successfully!") . "</div>"; } $this->view->form = $form; $this->view->html = $this->view->render('user/edit-user.phtml'); } $this->view->form = $form; $this->view->html = $this->view->render('user/edit-user.phtml'); }
require_once 'Locale.php'; require_once "DateHelper.php"; require_once "OsPath.php"; require_once "Database.php"; require_once "Timezone.php"; require_once __DIR__ . '/forms/helpers/ValidationTypes.php'; require_once __DIR__ . '/controllers/plugins/RabbitMqPlugin.php'; require_once APPLICATION_PATH . "/logging/Logging.php"; Logging::setLogPath('/var/log/airtime/zendphp.log'); Config::setAirtimeVersion(); require_once __DIR__ . "/configs/navigation.php"; Zend_Validate::setDefaultNamespaces("Zend"); $front = Zend_Controller_Front::getInstance(); $front->registerPlugin(new RabbitMqPlugin()); //localization configuration Application_Model_Locale::configureLocalization(); /* The bootstrap class should only be used to initialize actions that return a view. Actions that return JSON will not use the bootstrap class! */ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap { protected function _initDoctype() { $this->bootstrap('view'); $view = $this->getResource('view'); $view->doctype('XHTML1_STRICT'); } protected function _initGlobals() { $view = $this->getResource('view'); $baseUrl = Application_Common_OsPath::getBaseDir(); $view->headScript()->appendScript("var baseUrl = '{$baseUrl}'");
public function passwordChangeAction() { //uses separate layout without a navigation. $this->_helper->layout->setLayout('login'); $request = $this->getRequest(); $token = $request->getParam("token", false); $user_id = $request->getParam("user_id", 0); $form = new Application_Form_PasswordChange(); $auth = new Application_Model_Auth(); $user = CcSubjsQuery::create()->findPK($user_id); Application_Model_Locale::configureLocalization($request->getcookie('airtime_locale', 'en_CA')); //check validity of token if (!$auth->checkToken($user_id, $token, 'password.restore')) { Logging::debug("token not valid"); $this->_helper->redirector('index', 'login'); } if ($request->isPost() && $form->isValid($request->getPost())) { $user->setDbPass(md5($form->password->getValue())); $user->save(); $auth->invalidateTokens($user, 'password.restore'); $zend_auth = Zend_Auth::getInstance(); $zend_auth->clearIdentity(); $authAdapter = Application_Model_Auth::getAuthAdapter(); $authAdapter->setIdentity($user->getDbLogin())->setCredential($form->password->getValue()); $zend_auth->authenticate($authAdapter); //all info about this user from the login table omit only the password $userInfo = $authAdapter->getResultRowObject(null, 'password'); //the default storage is a session with namespace Zend_Auth $authStorage = $zend_auth->getStorage(); $authStorage->write($userInfo); $this->_helper->redirector('index', 'showbuilder'); } $this->view->form = $form; }
public function init() { /* $this->addElementPrefixPath('Application_Validate', '../application/validate', 'validate'); * */ $currentUser = Application_Model_User::getCurrentUser(); $currentUserId = $currentUser->getId(); $userData = Application_Model_User::GetUserData($currentUserId); $notEmptyValidator = Application_Form_Helper_ValidationTypes::overrideNotEmptyValidator(); $emailValidator = Application_Form_Helper_ValidationTypes::overrideEmailAddressValidator(); $notDemoValidator = new Application_Validate_NotDemoValidate(); $this->setDecorators(array(array('ViewScript', array('viewScript' => 'form/edit-user.phtml', "currentUser" => $currentUser->getLogin())))); $this->setAttrib('id', 'current-user-form'); $hidden = new Zend_Form_Element_Hidden('cu_user_id'); $hidden->setDecorators(array('ViewHelper')); $hidden->setValue($userData["id"]); $this->addElement($hidden); $login = new Zend_Form_Element_Text('cu_login'); $login->setLabel(_('Username:'******'class', 'input_text'); $login->setAttrib('readonly', 'readonly'); $login->setRequired(true); $login->addValidator($notEmptyValidator); $login->addFilter('StringTrim'); $login->setDecorators(array('viewHelper')); $this->addElement($login); $password = new Zend_Form_Element_Password('cu_password'); $password->setLabel(_('Password:'******'class', 'input_text'); $password->setRequired(true); $password->addFilter('StringTrim'); $password->addValidator($notEmptyValidator); $password->setDecorators(array('viewHelper')); $this->addElement($password); $passwordVerify = new Zend_Form_Element_Password('cu_passwordVerify'); $passwordVerify->setLabel(_('Verify Password:'******'class', 'input_text'); $passwordVerify->setRequired(true); $passwordVerify->addFilter('StringTrim'); $passwordVerify->addValidator($notEmptyValidator); $passwordVerify->addValidator($notDemoValidator); $passwordVerify->setDecorators(array('viewHelper')); $this->addElement($passwordVerify); $firstName = new Zend_Form_Element_Text('cu_first_name'); $firstName->setLabel(_('Firstname:')); $firstName->setValue($userData["first_name"]); $firstName->setAttrib('class', 'input_text'); $firstName->addFilter('StringTrim'); $firstName->setDecorators(array('viewHelper')); $this->addElement($firstName); $lastName = new Zend_Form_Element_Text('cu_last_name'); $lastName->setLabel(_('Lastname:')); $lastName->setValue($userData["last_name"]); $lastName->setAttrib('class', 'input_text'); $lastName->addFilter('StringTrim'); $lastName->setDecorators(array('viewHelper')); $this->addElement($lastName); $email = new Zend_Form_Element_Text('cu_email'); $email->setLabel(_('Email:')); $email->setValue($userData["email"]); $email->setAttrib('class', 'input_text'); $email->addFilter('StringTrim'); $email->setRequired(true); $email->addValidator($notEmptyValidator); $email->addValidator($emailValidator); $email->setDecorators(array('viewHelper')); $this->addElement($email); $cellPhone = new Zend_Form_Element_Text('cu_cell_phone'); $cellPhone->setLabel(_('Mobile Phone:')); $cellPhone->setValue($userData["cell_phone"]); $cellPhone->setAttrib('class', 'input_text'); $cellPhone->addFilter('StringTrim'); $cellPhone->setDecorators(array('viewHelper')); $this->addElement($cellPhone); $skype = new Zend_Form_Element_Text('cu_skype'); $skype->setLabel(_('Skype:')); $skype->setValue($userData["skype_contact"]); $skype->setAttrib('class', 'input_text'); $skype->addFilter('StringTrim'); $skype->setDecorators(array('viewHelper')); $this->addElement($skype); $jabber = new Zend_Form_Element_Text('cu_jabber'); $jabber->setLabel(_('Jabber:')); $jabber->setValue($userData["jabber_contact"]); $jabber->setAttrib('class', 'input_text'); $jabber->addFilter('StringTrim'); $jabber->addValidator($emailValidator); $jabber->setDecorators(array('viewHelper')); $this->addElement($jabber); $locale = new Zend_Form_Element_Select("cu_locale"); $locale->setLabel(_("Language:")); $locale->setMultiOptions(Application_Model_Locale::getLocales()); $locale->setValue(Application_Model_Preference::GetUserLocale($currentUserId)); $locale->setDecorators(array('ViewHelper')); $this->addElement($locale); $timezone = new Zend_Form_Element_Select("cu_timezone"); $timezone->setLabel(_("Interface Timezone:")); $timezone->setMultiOptions(Application_Common_Timezone::getTimezones()); $timezone->setValue(Application_Model_Preference::GetUserTimezone($currentUserId)); $timezone->setDecorators(array('ViewHelper')); $this->addElement($timezone); }