public function indexAction()
 {
     //TODO: Überprüfung auf Passwort und unique E-Mail auch in EditController
     $namespace = new Zend_Session_Namespace('user');
     if ($this->getRequest()->isPost() and $this->form->isValid($this->getRequest()->getParams())) {
         if ($this->form->getValue('Token') == $namespace->Token) {
             //get parameters for test of unique username
             $userTable = new User();
             $tableRow = User::COL_USERNAME;
             $value = $this->getRequest()->getParam(User::COL_USERNAME);
             if ($this->getRequest()->getParam(User::COL_PASSWORD) != $this->getRequest()->getParam(User_Form_Edit::PASSWORD_CLONE)) {
                 $element = $this->form->getElement(User_Form_Edit::PASSWORD_CLONE);
                 $element->addError("Error: Your password and the repeating don't match.");
                 $this->form->markAsError();
                 return $this->render('index');
             } elseif (Default_SimpleQuery::isValueInTableColumn($value, $userTable, $tableRow, 'string')) {
                 $element = $this->form->getElement(User::COL_USERNAME);
                 $element->addError("Error: This username is already used.");
                 $this->form->markAsError();
                 return $this->render('index');
             } else {
                 try {
                     //values checked, insert
                     $guid = Ble422_Guid::getGuid();
                     $userTable = new User();
                     $userTable->getAdapter()->beginTransaction();
                     $userId = $userTable->insert(array(User::COL_USERNAME => $this->form->getValue(User::COL_USERNAME), User::COL_FIRSTNAME => $this->form->getValue(User::COL_FIRSTNAME), User::COL_LASTNAME => $this->form->getValue(User::COL_LASTNAME), User::COL_PASSWORD => "{SHA}" . base64_encode(pack("H*", sha1($this->form->getValue(User::COL_PASSWORD)))), User::COL_EMAIL => $this->form->getValue(User::COL_USERNAME), User::COL_INSTITUTION => $this->form->getValue(User::COL_INSTITUTION), User::COL_STREET => $this->form->getValue(User::COL_STREET), User::COL_COUNTRY => $this->form->getValue(User::COL_COUNTRY), User::COL_PHONE => $this->form->getValue(User::COL_PHONE), User::COL_FAX => $this->form->getValue(User::COL_FAX), User::COL_CITY => $this->form->getValue(User::COL_CITY), User::COL_GUID => $guid, User::COL_ACTIVE => 0));
                     $toAdress = $this->form->getValue(User::COL_USERNAME);
                     $bodyText = "Please click this link to confirm your new account:\r\n" . Zend_Registry::get('APP_HOST') . '/default/registeruser/confirm/' . User::COL_GUID . '/' . $guid;
                     $mail = new Default_Mail($toAdress, 'WebGR register user message', $bodyText);
                     $mail->send();
                     $userTable->getAdapter()->commit();
                     $namespace->Token = '';
                     $this->redirectTo('success');
                 } catch (Exception $e) {
                     $userTable->getAdapter()->rollBack();
                     throw new Exception('error at register a new user: '******'success');
         }
     } else {
         //no post or some element(s) not valid
         //$this->form->setAction(Zend_Controller_Front::getInstance()->getBaseUrl()."/user/new");
         if ($this->form->getValue('Token') == null) {
             $guid = new Ble422_Guid();
             $namespace->Token = $guid->__toString();
             $this->form->getElement('Token')->setValue($guid->__toString());
         }
     }
 }
 public function indexAction()
 {
     //remove all elements, only username (=e-mail) stays
     $this->form = new User_Form_Edit();
     $elems = $this->form->getElements();
     foreach ($elems as $elem) {
         if (!($elem->getName() == User::COL_USERNAME || $elem->getName() == 'submit')) {
             $this->form->removeElement($elem->getName());
         }
     }
     //#####################new###################################
     $this->form->setDecorators(array('FormElements', array('HtmlTag', array('tag' => 'table', 'class' => 'login_form')), array('Description', array('placement' => 'prepend')), 'Form'));
     $this->form->setElementDecorators(array('ViewHelper', 'Errors', array('decorator' => array('td' => 'HtmlTag'), 'options' => array('tag' => 'td')), array('Label', array('tag' => 'td')), array('decorator' => array('tr' => 'HtmlTag'), 'options' => array('tag' => 'tr'))));
     //###########################################################
     if ($this->getRequest()->isPost()) {
         if ($this->form->isValid($this->getRequest()->getParams())) {
             //lookup if e-mail exists and send mail
             $e_mail = $this->form->getValue(User::COL_USERNAME);
             if (Default_SimpleQuery::isValueInTableColumn($e_mail, new User(), User::COL_USERNAME, 'string')) {
                 $user = new User();
                 $select = $user->select();
                 $where = $user->getAdapter()->quoteInto(User::COL_USERNAME . ' = ?', $e_mail, 'string');
                 $select->where($where);
                 $rowset = $user->fetchAll($select);
                 if ($rowset->count() == 1) {
                     $newGuid = Ble422_Guid::getGuid();
                     $data = array(User::COL_GUID => $newGuid);
                     $user->update($data, $where);
                     $toAdress = $this->form->getValue(User::COL_USERNAME);
                     $host = Zend_Registry::get('APP_HOST');
                     $bodyText = 'Please click this link to reset your password:'******'/default/forgotpassword/myresetpassword/' . User::COL_GUID . '/' . $newGuid;
                     $mail = new Default_Mail($toAdress, 'WebGR forgot password message', $bodyText);
                     $mail->send();
                 }
             }
             //show message anyway, not depending on success
             Zend_Registry::set('MESSAGE', 'if you are known to the system, the message was sent');
             $this->view->message = 'if you are known to the system, the message was sent';
             $this->render('message');
         } else {
             //not valid
             $this->view->form = $this->form;
         }
     } else {
         //not post
         $this->view->form = $this->form;
     }
     //prevent robots and abuser to:
     //-	send e-mail to all possible e-mail adresses
     //-	send massive multiple e-mails to known adress
     //-	e-mail server dos
     //lookup if e-mail exists and send mail
     //show message anyway, not depending on success
 }
示例#3
0
 public function newselectexpAction()
 {
     $namespace = new Zend_Session_Namespace('training');
     if ($this->getRequest()->isPost()) {
         if ($this->form->isValid($this->getRequest()->getParams())) {
             if ($this->form->getValue('Token') == $namespace->Token) {
                 //insert/update
                 //get form value and set namespace
                 $this->defaultNamespace->expId = $this->form->getValue(CalibrationExercise::COL_EXPERTISE_ID);
                 $namespace->Token = $newToken;
                 $newToken = Ble422_Guid::getGuid();
                 $this->form->getElement('Token')->setValue($newToken);
                 //put validated values in GET params
                 $this->redirectTo('newselectavailablekeys', $this->form->getValues());
             } else {
                 //form token is not equal session token
                 $this->form->reset();
                 $this->redirectTo('outofdate');
             }
         } else {
             //not valid
             $this->render('form');
         }
     } else {
         //not post
         //$this->form = new Ce_Form_Search();
         //$this->form->setAction('/ce/new/newtrainselectavailablekeys/'.Workshop::COL_ID.'/TEMP');
         if ($this->form->getValue('Token') == null) {
             $guid = new Ble422_Guid();
             $namespace->Token = $guid->__toString();
             $this->form->getElement('Token')->setValue($guid->__toString());
             $this->view->form = $this->form;
             $this->render('form');
         }
     }
 }
示例#4
0
 public function indexAction()
 {
     if ($this->callingCeId == NULL) {
         $this->_forward("index", "index");
     }
     $dbAdapter = Zend_Registry::get('DB_CONNECTION1');
     $namespace = new Zend_Session_Namespace('ce');
     if ($this->getRequest()->isPost()) {
         if ($this->form->isValid($this->getRequest()->getParams())) {
             if ($this->form->getValue('Token') == $namespace->Token) {
                 //insert/update
                 $ceTable = new CalibrationExercise();
                 $data = array(CalibrationExercise::COL_NAME => $this->form->getValue(CalibrationExercise::COL_NAME), CalibrationExercise::COL_DESCRIPTION => $this->form->getValue(CalibrationExercise::COL_DESCRIPTION), CalibrationExercise::COL_COMPAREABLE => $this->form->getValue(CalibrationExercise::COL_COMPAREABLE), CalibrationExercise::COL_RANDOMIZED => $this->form->getValue(CalibrationExercise::COL_RANDOMIZED), CalibrationExercise::COL_WORKSHOP_ID => $this->form->getValue(CalibrationExercise::COL_WORKSHOP_ID), CalibrationExercise::COL_KEY_TABLE_ID => $this->form->getValue(CalibrationExercise::COL_KEY_TABLE_ID), CalibrationExercise::COL_EXPERTISE_ID => $this->form->getValue(CalibrationExercise::COL_EXPERTISE_ID));
                 $where = $ceTable->getAdapter()->quoteInto(CalibrationExercise::COL_ID . ' = ?', $this->form->getValue(CalibrationExercise::COL_ID));
                 $ceTable->update($data, $where);
                 $newToken = Ble422_Guid::getGuid();
                 $this->form->getElement('Token')->setValue($newToken);
                 $namespace->Token = $newToken;
             } else {
                 //form token is not equal session token
                 $this->form->reset();
                 $this->redirectTo('outofdate');
             }
         } else {
             //not valid
         }
     } else {
         //not post
         $this->form->setAction(Zend_Controller_Front::getInstance()->getBaseUrl() . '/ce/edit/index');
         if ($this->form->getValue('Token') == null) {
             $guid = new Ble422_Guid();
             $namespace->Token = $guid->__toString();
             $this->form->getElement('Token')->setValue($guid->__toString());
         }
         /**
          * get all set values for calibration exercise
          */
         //use Left Join to get the CE without assigned KeyTable/Expertise, too
         //use left join for workshop to get training ce's too
         $select = $dbAdapter->select();
         $select->from(array('ce' => CalibrationExercise::TABLE_NAME));
         $select->joinLeft(array('ws' => Workshop::TABLE_NAME), $dbAdapter->quoteIdentifier('ce.' . CalibrationExercise::COL_WORKSHOP_ID) . '=' . $dbAdapter->quoteIdentifier('ws.' . Workshop::COL_ID));
         $select->joinLeft(array('kt' => KeyTable::TABLE_NAME), $dbAdapter->quoteIdentifier('ce.' . CalibrationExercise::COL_KEY_TABLE_ID) . '=' . $dbAdapter->quoteIdentifier('kt.' . KeyTable::COL_ID));
         $select->joinLeft(array('exp' => Expertise::TABLE_NAME), $dbAdapter->quoteIdentifier('ce.' . CalibrationExercise::COL_EXPERTISE_ID) . '=' . $dbAdapter->quoteIdentifier('exp.' . Expertise::COL_ID));
         $select->where($dbAdapter->quoteIdentifier('ce.' . CalibrationExercise::COL_ID) . ' = ?', $this->callingCeId);
         $resultArray = $dbAdapter->fetchAll($select);
         //fill form with values
         $this->form->setValues($resultArray[0]);
     }
     $this->view->isStopped = $this->form->getValue(CalibrationExercise::COL_IS_STOPPED);
     if (isset($this->defaultNamespace->returningAction) && isset($this->defaultNamespace->returningActionId)) {
         switch ($this->defaultNamespace->returningAction) {
             case 'ce/editkeytable/index':
                 $this->form->getElement(CalibrationExercise::COL_KEY_TABLE_ID)->setValue($this->defaultNamespace->returningActionId);
                 break;
             case 'ce/editexpertise/index':
                 $this->form->getElement(CalibrationExercise::COL_EXPERTISE_ID)->setValue($this->defaultNamespace->returningActionId);
                 break;
             default:
                 $this->defaultNamespace->returningAction = NULL;
                 $this->defaultNamespace->returningActionId = NULL;
                 throw new Zend_Exception();
                 break;
         }
     }
     $this->defaultNamespace->returningAction = NULL;
     $this->defaultNamespace->returningActionId = NULL;
     /**
      * get Shown Attributes List
      */
     $selectShownAttr = $dbAdapter->select();
     $selectShownAttr->from(CeHasAttributeDescriptor::TABLE_NAME);
     $selectShownAttr->join(AttributeDescriptor::TABLE_NAME, CeHasAttributeDescriptor::TABLE_NAME . '.ATDE_ID = ' . AttributeDescriptor::TABLE_NAME . '.ATDE_ID', array(AttributeDescriptor::COL_NAME));
     $selectShownAttr->where(CeHasAttributeDescriptor::COL_CAEX_ID . " = ?", $this->callingCeId);
     $resultShownAttr = $dbAdapter->fetchAll($selectShownAttr);
     $this->view->resultShownAttr = $resultShownAttr;
     //remove already used attributes from selectbox
     $elem = $this->formAttrSelCon->getElement('attr');
     foreach ($resultShownAttr as $row) {
         $elem->removeMultiOption($row[AttributeDescriptor::COL_ID]);
     }
     unset($elem);
     //info/actions about participants
     $this->view->numOfParti = $this->countParticipants();
     $this->defaultNamespace->callingAction = 'ce/edit/index';
     $this->defaultNamespace->callingActionId = $this->callingCeId;
     $this->view->form = $this->form;
     $this->formAttrSelCon->setAction(Zend_Controller_Front::getInstance()->getBaseUrl() . '/ce/edit/addattribute');
     $this->view->formAttrSelCon = $this->formAttrSelCon;
     /**
      * imageset attributes fish and image
      */
     //---get Attributes List
     $selectAttr = $dbAdapter->select();
     $selectAttr->from(ImagesetAttributes::TABLE_NAME);
     $selectAttr->join(AttributeDescriptor::TABLE_NAME, ImagesetAttributes::TABLE_NAME . '.ATDE_ID = ' . AttributeDescriptor::TABLE_NAME . '.ATDE_ID');
     $selectAttr->joinLeft(ValueList::TABLE_NAME, AttributeDescriptor::TABLE_NAME . '.' . AttributeDescriptor::COL_UNIT . '=' . ValueList::TABLE_NAME . '.' . ValueList::COL_ID, array('UNIT' => ValueList::COL_VALUE));
     $selectAttr->where(ImagesetAttributes::COL_CE_ID . " = ?", $this->callingCeId);
     //show only FISH-group & IMAGE-group attributes
     $selectAttr->where('(' . AttributeDescriptor::COL_GROUP . " = ?", 'FISH');
     $selectAttr->orWhere(AttributeDescriptor::COL_GROUP . " = ?)", 'IMAGE');
     $resultAttr = $dbAdapter->fetchAll($selectAttr);
     //remove already used attributes from selectbox
     $elem = $this->formAttrSelConFish->getElement('attr');
     foreach ($resultAttr as $row) {
         $elem->removeMultiOption($row[AttributeDescriptor::COL_ID]);
     }
     unset($elem);
     //remove already used attributes from selectbox
     $elem = $this->formAttrSelConImage->getElement('attr');
     foreach ($resultAttr as $row) {
         $elem->removeMultiOption($row[AttributeDescriptor::COL_ID]);
     }
     unset($elem);
     //set add form
     $this->formAttrSelConFish->setAction(Zend_Controller_Front::getInstance()->getBaseUrl() . '/ce/edit/addimagesetattribute');
     $this->view->formAttrSelConFish = $this->formAttrSelConFish;
     $this->imageSetForm->addDynamicElements($resultAttr, true, true);
     if (Default_SimpleQuery::isCeStopped($this->callingCeId)) {
         $this->imageSetForm->addElement('submit', 'submit', array('label' => 'save'));
     } else {
         //set description to remove the "remove attribute"-link from form
         foreach ($this->imageSetForm->getElements() as $elem) {
             $elem->setDescription(NULL);
         }
     }
     //set dynamic values
     $this->imageSetForm->dynPopulate($resultAttr, ImagesetAttributes::COL_VALUE, array(CalibrationExercise::COL_ID => $this->callingCeId));
     if (count($resultAttr) == 0) {
         $this->view->noImageset = true;
     } else {
         $this->view->noImageset = false;
     }
     /**
      * get already defined imagelist
      */
     $selectImages = $dbAdapter->select();
     $selectImages->from(array('cehim' => CeHasImage::TABLE_NAME));
     $selectImages->join(array('im' => Image::TABLE_NAME), 'cehim.' . CeHasImage::COL_IMAGE_ID . '=' . 'im.' . Image::COL_ID);
     $selectImages->where(CalibrationExercise::COL_ID . '=?', $this->callingCeId);
     $this->view->imageArray = $dbAdapter->fetchAll($selectImages);
     $this->view->ceId = $this->callingCeId;
     $this->view->imageSetForm = $this->imageSetForm;
     //set add form
     $this->formAttrSelConImage->setAction(Zend_Controller_Front::getInstance()->getBaseUrl() . '/ce/edit/addimagesetattribute');
     $this->view->formAttrSelConImage = $this->formAttrSelConImage;
     if ($this->form->getElement(CalibrationExercise::COL_RANDOMIZED)->getValue() == 1) {
         $this->view->isRandom = TRUE;
     }
     $this->defaultNamespace->message = NULL;
 }