コード例 #1
0
 public function saveAction()
 {
     $this->getRequest()->isPost();
     $this->buildForm("admin/group/save");
     if ($this->gForm->isValid($_POST)) {
         $values = $this->gForm->getValues();
     }
     //Build Group Object
     $group = new Group();
     //Upload Logo
     if (copy($values['logo'], Zend_Registry::get('config')->files->logo->dir . DIRECTORY_SEPARATOR . basename($values['logo']))) {
         $values['logo'] = Zend_Registry::get('config')->files->logo->dir . "/" . basename($values['logo']);
     }
     //Convert polygon cordenates
     preg_match_all("/\\(([0-9\\.\\,\\-\\s]*)\\)[\\,]?/", $values['area_coords'], $rawcoords);
     foreach ($rawcoords[1] as $coord) {
         $cvalues = explode(",", $coord);
         $cobj = new stdClass();
         $cobj->lat = trim($cvalues[0]);
         $cobj->lng = trim($cvalues[1]);
         $coords[] = $cobj;
     }
     $values['area_coords'] = json_encode($coords);
     //Register Administrators
     $admins = explode(",", $values['admins']);
     foreach ($admins as $adm) {
         if ($adm != "") {
             $group->Admins[]->user_id = $adm;
         }
     }
     //Go through Activity Types
     $actvTypes = Doctrine_Query::create()->from('ActivityType')->orderBy("weight")->execute();
     foreach ($actvTypes as $atype) {
         $atype_key = "atype_" . $atype->atype;
         $aSource = new ActivitySource();
         $aSource->atype = $atype->atype;
         $aSource->target = $values[$atype_key];
         $group->ActivitySources[] = $aSource;
     }
     //populate group
     $group->fromArray($values);
     //Save Group
     $group->save();
     var_dump($values, $group->toArray());
     //Grab pre-saved venues and tie group_id
     $venues = Doctrine_Query::create()->from('Venue')->where("Venue.name LIKE ?", array($values['tmp_id'] . '%'))->execute();
     foreach ($venues as $venue) {
         $venue->name = str_replace($values['tmp_id'] . "_", "", $venue->name);
         $venue->group_id = $group->id;
         $venue->save();
     }
     $this->_helper->flashMessenger("Group added!");
     //$this->_helper->redirector('index');
     $this->_helper->viewRenderer->setNoRender();
     $this->_helper->layout->disableLayout();
 }
コード例 #2
0
ファイル: Form.php プロジェクト: BGCX262/zupal-svn-to-git
 /**
  *
  * @param array $pParam
  * @return boolean
  */
 public function isValid($pParam)
 {
     foreach ($pParam as $f => $v) {
         $pParam[$f] = stripslashes($v);
     }
     return parent::isValid($pParam);
 }
コード例 #3
0
 public function ajouterAction()
 {
     $form = new Zend_Form();
     $form->setMethod('post');
     $form->addElement('text', 'TITRE_E', array('label' => 'Titre de l\'émission : ', 'required' => true, 'filters' => array('StringTrim')));
     $form->addElement('text', 'THEME', array('label' => 'Theme : ', 'required' => true, 'filters' => array('StringTrim')));
     $form->addElement('text', 'ANIMATEURS', array('label' => 'Animateur(s) : ', 'required' => true, 'filters' => array('StringTrim')));
     $form->addElement('text', 'DUREE', array('label' => 'Durée de l\'émission : ', 'required' => true, 'filters' => array('Int')));
     $form->addElement('text', 'PATH_E', array('label' => 'Lien vers le podcast : ', 'required' => false, 'filters' => array('StringTrim')));
     $submit = new Zend_Form_Element_Submit('submit');
     $submit->setLabel('Ajouter');
     $form->addElement($submit);
     if ($this->_request->isPost()) {
         $formData = $this->_request->getPost();
         if ($form->isValid($formData)) {
             $dba = Zend_Registry::get('dba');
             $datas = array('THEME' => $formData["THEME"], 'ANIMATEURS' => $formData["ANIMATEURS"], 'DUREE' => $formData["DUREE"], 'TITRE_E' => $formData["TITRE_E"], 'PATH_E' => $formData["PATH_E"]);
             $dba->beginTransaction();
             try {
                 $dba->insert('EMISSION', $datas);
                 $dba->commit();
             } catch (Exception $e) {
                 $dba->rollBack();
                 echo $e->getMessage();
             }
             $this->_helper->redirector('index');
         } else {
             $form->populate($formData);
         }
     }
     $this->view->form = $form;
 }
コード例 #4
0
 public function isValid($formData = array())
 {
     if (isset($formData['property_postcode']) && '' != trim($formData['property_postcode'])) {
         $postcode = trim($formData['property_postcode']);
         $postcodeLookup = new Manager_Core_Postcode();
         $addresses = $postcodeLookup->getPropertiesByPostcode(preg_replace('/[^\\w\\ ]/', '', $postcode));
         $addressList = array('' => '--- please select ---');
         foreach ($addresses as $address) {
             $addressList[$address['id']] = $address['singleLineWithoutPostcode'];
         }
         $ins_address = $this->getElement('property_address');
         $ins_address->setMultiOptions($addressList);
         $validator = new Zend_Validate_InArray(array('haystack' => array_keys($addressList)));
         $validator->setMessages(array(Zend_Validate_InArray::NOT_IN_ARRAY => 'Insured address does not match with postcode'));
         $ins_address->addValidator($validator, true);
     }
     // If a value for an address lookup is present, the house name or number is not required
     if (isset($formData['is_foreign_address']) && 'Yes' == $formData['is_foreign_address']) {
         $this->getElement('property_postcode')->setRequired(false);
         $this->getElement('property_address')->setRequired(false);
     }
     if (isset($formData['property_postcode'])) {
         $this->getElement('property_number_name')->setRequired(false);
     }
     return parent::isValid($formData);
 }
コード例 #5
0
 /** THis is where they pick the duration */
 function bookingAction()
 {
     $this->layout('layout/layout-appointment-summary');
     $layoutViewModel = $this->layout();
     $progress = new ViewModel(['step' => 3]);
     $progress->setTemplate('application/progress');
     $layoutViewModel->addChild($progress, 'progress');
     $service = $this->serviceDataMapper()->find($this->params('service'));
     $durations = array();
     foreach ($service['durations'] as $duration) {
         $durations[$duration] = $this->durationLabels[$duration];
     }
     $form = new \Zend_Form();
     $form->addElement('radio', 'appointment_duration', array('label' => 'Appointment Duration', 'multiOptions' => $durations, 'separator' => ''));
     if ($this->getRequest()->isPost() && $form->isValid($this->params()->fromPost())) {
         $url = $this->url()->fromRoute('make-booking', array('action' => 'booking2', 'duration' => $form->getValue('appointment_duration'), 'service' => $this->params('service'), 'day' => $this->params('day')));
         $this->redirect()->toUrl($url);
         return;
     }
     $this->viewParams['form'] = $form;
     $summary = new ViewModel($this->params()->fromRoute());
     $summary->setTemplate('application/summary');
     $layoutViewModel->addChild($summary, 'appointment_summary');
     $viewModel = new ViewModel($this->viewParams);
     $viewModel->setTemplate('application/booking');
     return $viewModel;
 }
コード例 #6
0
ファイル: Step3.php プロジェクト: AlexEvesDeveloper/hl-stuff
 public function isValid($postData)
 {
     if (isset($postData['how_hear']) && $postData['how_hear'] == "Other") {
         $this->getElement('other')->setRequired(true);
     }
     return parent::isValid($postData);
 }
コード例 #7
0
ファイル: Login.php プロジェクト: AlexEvesDeveloper/hl-stuff
 public function isValid($data)
 {
     // add email to request data as
     // isValid seems to remove any data currently loaded into the form
     $email = $this->getElement('email')->getValue();
     $data['email'] = $email;
     $validationResult = parent::isValid($data);
     // Perform login validation
     $auth = Zend_Auth::getInstance();
     $auth->setStorage(new Zend_Auth_Storage_Session('homelet_customer'));
     if ($data['password'] != '') {
         // Process login
         $customerManager = new Manager_Core_Customer();
         $adapter = $customerManager->getAuthAdapter(array('email' => $data['email'], 'password' => $data['password']));
         $result = $auth->authenticate($adapter);
         if ($result->isValid()) {
             $email = $this->getElement('email');
             $newCustomer = $customerManager->getCustomerByEmailAddress($email->getValue());
             if ($newCustomer->getEmailValidated() !== true) {
                 $auth->clearIdentity();
                 $this->setDescription("Unfortunately you haven't validated your email address yet. We've sent you an email which includes a link to validate your My HomeLet account. You'll need to validate your account to continue. If you've not received your validation email or if you're unable to access your account, please call us on 0845 117 6000.");
                 return false;
             }
             $storage = $auth->getStorage();
             $storage->write($adapter->getResultRowObject(array('title', 'first_name', 'last_name', 'email_address', 'id')));
         } else {
             $this->setDescription('Your account details are incorrect, please try again');
             return false;
         }
     }
     // All valid above, return parents validation result
     return $validationResult;
 }
コード例 #8
0
 public function detailAction()
 {
     $newsUrl = $this->getRequest()->getParam('url', null);
     try {
         $news = $this->newsRepository->fetchEntityByUrl($newsUrl);
     } catch (\Exception $e) {
         throw new \Exception($e->getMessage(), 404);
     }
     $this->view->headTitle($news->headline);
     $this->view->headMeta()->setName('description', $this->_helper->truncate($news->content, 255));
     $configForm = $this->getInvokeArg('bootstrap')->getResource('configForm');
     $commentForm = new \Zend_Form($configForm->comment);
     if ($this->getRequest()->isPost()) {
         if ($commentForm->isValid($_POST)) {
             try {
                 $values = $commentForm->getValues();
                 unset($values['csrf']);
                 unset($values['firstname']);
                 # SpamDetection
                 $values['news'] = $news;
                 $this->commentRepository->saveEntity($values);
                 $commentForm->reset();
                 #$this->_helper->systemMessages('notice', 'Kommentar erfolgreich gespeichert');
             } catch (\Exception $e) {
                 $log = $this->getInvokeArg('bootstrap')->log;
                 $log->log($e->getMessage(), \Zend_Log::ERR, array('trace' => $e->getTraceAsString()));
                 #$this->_helper->systemMessages('error', 'Kommentar konnte nicht gespeichert werden');
             }
         }
     }
     $commentForm->setAction('/news/' . $newsUrl);
     $this->view->form = $commentForm;
     $this->view->news = $news;
 }
コード例 #9
0
 public function editAction()
 {
     $configForm = $this->getInvokeArg('bootstrap')->getResource('configForm');
     $userForm = new Zend_Form($configForm->user);
     $userId = $this->getRequest()->getParam('id', null);
     if ($this->getRequest()->isPost()) {
         if ($userForm->isValid($_POST)) {
             try {
                 $values = $userForm->getValues();
                 unset($values['password_repeat']);
                 $userId = $this->userRepository->saveEntity($values);
                 $this->_helper->systemMessages('notice', 'Nutzer erfolgreich gespeichert');
             } catch (\Exception $e) {
                 $log = $this->getInvokeArg('bootstrap')->log;
                 $log->log($e->getMessage(), \Zend_Log::ERR, array('trace' => $e->getTraceAsString()));
                 $this->_helper->systemMessages('error', 'Nutzer konnte nicht gespeichert werden');
             }
         }
     } else {
         try {
             $entity = $this->userRepository->fetchEntity($userId);
             $userForm->populate($entity->toArray());
         } catch (\Exception $e) {
             throw new \Exception($e->getMessage(), 404);
         }
     }
     $userForm->setAction('/admin/user/edit/' . $userId);
     $this->view->form = $userForm;
 }
コード例 #10
0
 public function loginAction()
 {
     $configForm = $this->getInvokeArg('bootstrap')->getResource('configForm');
     $loginForm = new \Zend_Form($configForm->login);
     if ($this->getRequest()->isPost()) {
         if ($loginForm->isValid($_POST)) {
             try {
                 $auth = $this->getInvokeArg('bootstrap')->auth;
                 $auth->setIdentity($loginForm->getValue('login'))->setCredential($loginForm->getValue('password'));
                 $result = \Zend_Auth::getInstance()->authenticate($auth);
                 if ($result->isValid()) {
                     $this->_redirect('/admin');
                 } else {
                     $this->_helper->systemMessages('error', 'Anmeldung verweigert');
                 }
             } catch (\Exception $e) {
                 $log = $this->getInvokeArg('bootstrap')->log;
                 $log->log($e->getMessage(), \Zend_Log::ERR, array('trace' => $e->getTraceAsString()));
                 $this->_helper->systemMessages('error', 'Fehler bei der Anmeldung');
             }
         }
     }
     $loginForm->setAction('/login');
     $this->view->form = $loginForm;
 }
コード例 #11
0
ファイル: Form.php プロジェクト: BGCX262/zsoc-svn-to-git
 public function isValid($data)
 {
     parent::isValid($data);
     $event = new Bc_Form_Event(Bc_Form_Event::FORM_VALIDATE_EVENT, $this);
     $event->dispatch();
     return !$this->_errorsExist;
 }
コード例 #12
0
 public function removeAction()
 {
     $form = new Zend_Form();
     $form->setView(new Zend_View());
     $form->setMethod('post');
     $form->setAction('');
     $form->setAttrib('class', 'devel');
     $form->setAttrib('title', 'Remove wizard - ' . $this->getRequest()->getParam('name'));
     $handleOptions = explode(',', $this->getRequest()->getParam('handles'));
     $referenceOptions = explode(',', $this->getRequest()->getParam('references'));
     $handleOptionsUsed = explode(',', $this->getRequest()->getParam('handles_used'));
     $handleOptionsHidden = $form->createElement('hidden', 'handles', array('decorators' => array('ViewHelper')));
     $referenceOptionsHidden = $form->createElement('hidden', 'references', array('decorators' => array('ViewHelper')));
     $handleOptionsUsedHidden = $form->createElement('hidden', 'handles_used', array('decorators' => array('ViewHelper')));
     $handle = $form->createElement('radio', 'handle', array('label' => 'Handle', 'required' => true, 'multiOptions' => array_combine($handleOptions, $handleOptions), 'description' => 'NOTE: This are the handles that this block appears in: ' . $this->getRequest()->getParam('handles_used')));
     $reference = $form->createElement('radio', 'reference', array('label' => 'Reference', 'required' => true, 'multiOptions' => array_combine($referenceOptions, $referenceOptions)));
     $name = $form->createElement('text', 'name', array('label' => 'Name', 'required' => true));
     $submit = $form->createElement('submit', 'submit', array('label' => 'Submit'));
     $form->addElements(array($handleOptionsHidden, $referenceOptionsHidden, $handleOptionsUsedHidden, $handle, $reference, $name, $submit));
     if ($form->isValid($this->getRequest()->getParams())) {
         $localXmlWriter = Mage::getModel('devel/writer_localxml');
         $localXmlWriter->addRemove($form->handle->getValue(), $form->reference->getValue(), $form->name->getValue());
         $localXmlWriter->save();
         die('DONE. You need to reload to see changes!');
     } else {
         $this->loadLayout();
         $this->getLayout()->getUpdate()->load('devel_layout_wizard');
         $this->getLayout()->generateXml();
         $this->loadLayout();
         $this->getLayout()->getBlock('devel_wizard_form')->setForm($form);
         $this->renderLayout();
     }
 }
コード例 #13
0
 /**
  * Check if the entire form is valid
  *
  * @return boolean
  */
 public function isValid()
 {
     // Get the form data from the session
     $formData = $this->getFormSessionData();
     // Validate the form using the session data
     return $this->_form->isValid($formData);
 }
コード例 #14
0
ファイル: Form.php プロジェクト: bombayworks/currycms
 /** @inheritdoc */
 public function isValid($data)
 {
     if ($this->csrfCheck) {
         $this->addCsrfProtection();
     }
     return parent::isValid($data);
 }
コード例 #15
0
ファイル: Form.php プロジェクト: dafik/dfi
 /**
  * Proxy to {@link Zend_Form::isValid()}.
  *
  * Calls {@link self::buildBootstrapErrorDecorators()} for
  * {@link parent::isValid()} returning false.
  *
  * @param array $values
  * @return bool
  * @throws Zend_Form_Exception
  */
 public function isValid($values)
 {
     $validCheck = parent::isValid($values);
     if ($validCheck === false) {
         $this->buildBootstrapErrorDecorators();
     }
     return $validCheck;
 }
コード例 #16
0
ファイル: demo.php プロジェクト: Tony133/zf-web
 public function indexAction()
 {
     $form = new Zend_Form(array('method' => 'post', 'enctype' => Zend_Form::ENCTYPE_MULTIPART, 'elements' => array('picture' => array('file', array('destination' => '../media/tmp/')), 'submit' => array('submit'))));
     if ($this->getRequest()->isPost()) {
         $form->isValid($_POST);
     }
     $this->view->form = $form;
 }
コード例 #17
0
 public function isValid($data)
 {
     // validate that the value given for the 'newPasswordConfirm' field is identical to the 'newPassword' field
     $validator = new Zend_Validate_Identical($data['newPassword']);
     $validator->setMessages(array(Zend_Validate_Identical::NOT_SAME => 'Passwords do not match', Zend_Validate_Identical::MISSING_TOKEN => 'Passwords do not match'));
     $this->getElement('newPasswordConfirm')->addValidator($validator);
     return parent::isValid($data);
 }
コード例 #18
0
 public function isValid($data)
 {
     // If the user is disabled to change search profile he can not change any search settings.
     if (OpenSKOS_Db_Table_Users::requireFromIdentity()->disableSearchProfileChanging) {
         $this->addError(_('You are not allowed to change your detailed search options.'));
     }
     return parent::isValid($data);
 }
コード例 #19
0
ファイル: User.php プロジェクト: laiello/teacherq
 protected function _save(Zend_Form $form, array $info, $defaults = array())
 {
     if (!$form->isValid($info)) {
         return false;
     }
     $data = $form->getValues();
     if (array_key_exists('passwd', $data) && '' != $data['passwd']) {
     }
 }
コード例 #20
0
 public function isValid($formData = array())
 {
     if (isset($formData['completion_method']) && $formData['completion_method'] == "2") {
         $this->getElement('email')->setRequired(true);
     } else {
         $this->getElement('email')->setRequired(false);
     }
     return parent::isValid($formData);
 }
コード例 #21
0
ファイル: Business.php プロジェクト: nidorx/Zend_Dao_Vo
    /**
     * Faz a validação do formulário 
     * 
     * @param Nidorx_Form $form
     * @param Array $data 
     */
    public function validateForm(Zend_Form $form, $data)
    {

        if ($form->isValid($data)) {
            return true;
        };

        return false;
    }
コード例 #22
0
 public function isValid($data)
 {
     /*        $this->getElement('password_confirm')
                     ->addValidator('Identical', true, $data['client_password'])
                     ->getValidator('Identical')
                     ->setMessages(array('notSame' => 'Please check your passwords as they do not match.'));
     */
     return parent::isValid($data);
 }
コード例 #23
0
ファイル: Abstract.php プロジェクト: kminkov/Blog
 public function isValid($data)
 {
     foreach ($data as $key => $val) {
         if (is_string($val)) {
             $data[$key] = stripslashes($val);
         }
     }
     return parent::isValid($data);
 }
コード例 #24
0
ファイル: Form.php プロジェクト: georgepaul/socialstrap
 /**
  *
  * unique name validator
  */
 public function isValid($data)
 {
     // return on false to see previous errors
     if (parent::isValid($data) == false) {
         return false;
     }
     $translator = $this->getTranslator();
     $this->getElement('name')->addValidator('Db_NoRecordExists', false, array('table' => 'profiles', 'field' => 'name'))->setErrorMessages(array($translator->translate('This username is not available')));
     return parent::isValid($data);
 }
コード例 #25
0
 public function isValid($data)
 {
     if (isset($data[self::$_idParam]) && $data[self::$_idParam] == $this->_getFormid()) {
         //unset($data[self::$_idParam]);
         return parent::isValid($data);
     } else {
         //ничо
         return false;
     }
 }
コード例 #26
0
ファイル: Contact2.php プロジェクト: jbazant/mtgim
 /**
  * Validace formulare
  * @param array $data
  * @return bool
  */
 public function isValid($data)
 {
     if (parent::isValid($data)) {
         // sem patri specialni logika validace
         // prozatim ovsem zadna neni potreba
         return TRUE;
     } else {
         return FALSE;
     }
 }
コード例 #27
0
 public function isValid($data)
 {
     $isValid = parent::isValid($data);
     $checkPrivacy = $this->getElement('Privacy');
     if ($data["SupportFeedback"] == "1" && $data["Privacy"] != "1") {
         $checkPrivacy->addError("You have to agree to privacy policy.");
         $isValid = false;
     }
     return $isValid;
 }
コード例 #28
0
ファイル: Registration.php プロジェクト: Zerone/ImJob.org
 public function isValid($data)
 {
     $isValid = parent::isValid($data);
     $password = $this->getElement('password');
     $confirm_password = $this->getElement('confirm_password');
     if ($password->getValue() != $confirm_password->getValue() && $isValid) {
         $isValid = false;
         $confirm_password->addError("Password didn't match.");
     }
     return $isValid;
 }
コード例 #29
0
 public function contactFormAction()
 {
     //create the form
     $form = new Zend_Form();
     //this page should post back to itself
     $form->setAction($_SERVER['REQUEST_URI']);
     $form->setMethod('post');
     $name = $form->createElement('text', 'name');
     $name->setLabel($this->view->getTranslation('Your Name') . ': ');
     $name->setRequired(TRUE);
     $name->addFilter('StripTags');
     $name->addErrorMessage($this->view->getTranslation('Your name is required!'));
     $name->setAttrib('size', 30);
     $email = $form->createElement('text', 'email');
     $email->setLabel($this->view->getTranslation('Your Email') . ': ');
     $email->setRequired(TRUE);
     $email->addValidator('EmailAddress');
     $email->addErrorMessage($this->view->getTranslation('Invalid email address!'));
     $email->setAttrib('size', 30);
     $subject = $form->createElement('text', 'subject');
     $subject->setLabel($this->view->getTranslation('Subject') . ': ');
     $subject->setRequired(TRUE);
     $subject->addFilter('StripTags');
     $subject->addErrorMessage($this->view->getTranslation('The subject is required!'));
     $subject->setAttrib('size', 40);
     $message = $form->createElement('textarea', 'message');
     $message->setLabel($this->view->getTranslation('Message') . ': ');
     $message->setRequired(TRUE);
     $message->addErrorMessage($this->view->getTranslation('The message is required!'));
     $message->setAttrib('cols', 35);
     $message->setAttrib('rows', 10);
     $captcha = new Zend_Form_Element_Captcha('captcha', array('label' => $this->view->getTranslation('Please verify you\'re a human'), 'captcha' => array('captcha' => 'Figlet', 'wordLen' => 6, 'timeout' => 300)));
     $form->addElement($name);
     $form->addElement($email);
     $form->addElement($subject);
     $form->addElement($message);
     $form->addElement($captcha);
     $form->addElement('submit', 'submitContactForm', array('label' => $this->view->getTranslation('Send Message')));
     $this->view->form = $form;
     if ($this->_request->isPost() && Digitalus_Filter_Post::has('submitContactForm')) {
         if ($form->isValid($_POST)) {
             //get form data
             $data = $form->getValues();
             //get the module data
             $module = new Digitalus_Module();
             $moduleData = $module->getData();
             //render the message
             $this->view->data = $data;
             $htmlMessage = $this->view->render('public/message.phtml');
             $mail = new Digitalus_Mail();
             $this->view->isSent = $mail->send($moduleData->email, array($data['email'], $data['name']), $data['subject'], $htmlMessage);
         }
     }
 }
コード例 #30
0
 public function setupForm()
 {
     $form1 = new Zend_Form_SubForm();
     $form1->addElement('text', 'foo', array('label' => 'Sub Foo: ', 'required' => true, 'validators' => array('NotEmpty', 'Alpha')))->addElement('text', 'bar', array('label' => 'Sub Bar: ', 'required' => true, 'validators' => array('Alpha', 'Alnum')));
     $form2 = new Zend_Form();
     $form2->addElement('text', 'foo', array('label' => 'Master Foo: ', 'required' => true, 'validators' => array('NotEmpty', 'Alpha')))->addElement('text', 'bar', array('required' => true, 'validators' => array('Alpha', 'Alnum')))->addSubForm($form1, 'sub');
     $form2->isValid(array('foo' => '', 'bar' => 'foo 2 u 2', 'sub' => array('foo' => '', 'bar' => 'foo 2 u 2')));
     $form2->setView($this->getView());
     $this->decorator->setElement($form2);
     $this->form = $form2;
     return $form2;
 }