public function indexAction()
 {
     $this->defaultNamespace = new Zend_Session_Namespace('default');
     $this->myNamespace = new Zend_Session_Namespace('editParticipants');
     $ceId = $this->defaultNamespace->callingActionId;
     $this->view->callingActionId = $ceId;
     if ($this->getRequest()->isPost()) {
         //save form params to namespace
         $this->myNamespace->params = $this->getRequest()->getParams();
         //check which submit button has been clicked
         if ($this->getRequest()->getParam('Check_all') != NULL) {
             $this->myNamespace->checkAll = TRUE;
             $this->redirectTo('index');
         }
         if ($this->getRequest()->getParam('Uncheck_all') != NULL) {
             $this->myNamespace->checkAll = FALSE;
             $this->redirectTo('index');
         }
         if ($this->getRequest()->getParam('Remove_from_participants') != NULL) {
             $success = $this->deleteParticipants();
             if (!$success) {
                 //XXX show error
             }
             $this->redirectTo('index');
         }
         if ($this->getRequest()->getParam('Apply_to_selected') != NULL) {
             $success = $this->applySettingsToParticipants();
             if (!$success) {
                 ///XXX show error
             }
             $this->redirectTo('index');
         }
     } else {
         //not post
         //TODO getCaliExName and display in header
         $userTable = new User();
         $participantsTable = new Participant();
         $dbAdapter = Zend_Registry::get('DB_CONNECTION1');
         $select = $dbAdapter->select();
         $select->from(array('user' => $userTable->getTableName()), array(User::COL_LASTNAME, User::COL_FIRSTNAME, User::COL_USERNAME));
         $select->join(array('part' => $participantsTable->getTableName()), $dbAdapter->quoteIdentifier('user.' . User::COL_ID) . '=' . $dbAdapter->quoteIdentifier('part.' . Participant::COL_USER_ID), array(Participant::COL_ID, Participant::COL_NUMBER, Participant::COL_EXPERTISE_LEVEL, Participant::COL_STOCK_ASSESSMENT, Participant::COL_ROLE));
         $select->where($dbAdapter->quoteInto('part.' . Participant::COL_CE_ID . ' = ?', $ceId));
         //echo $select;
         $paginator = new Ble422_Paginator_Extended($select, $this->getRequest());
         $paginator->setHeader(array(array('raw' => User::COL_LASTNAME, 'name' => 'Last name'), array('raw' => User::COL_FIRSTNAME, 'name' => 'First name'), array('raw' => User::COL_USERNAME, 'name' => 'User name'), array('raw' => Participant::COL_NUMBER, 'name' => 'Reader no.'), array('raw' => Participant::COL_EXPERTISE_LEVEL, 'name' => 'Expertise level'), array('raw' => Participant::COL_STOCK_ASSESSMENT, 'name' => 'Stock assess.'), array('raw' => Participant::COL_ROLE, 'name' => 'Role')));
         $paginator->setCurrentPageNumber($this->getRequest()->getParam('page'))->setItemCountPerPage(50)->setPageRange(10)->orderBy($this->getRequest()->getParam('orderBy'));
         //$this->_getParam('pageRange'));
         Zend_View_Helper_PaginationControl::setDefaultViewPartial('partials/list_pagination_control.phtml');
         $this->view->paginator = $paginator;
         $this->defaultNamespace->callingAction = "ce/editparticipants/index";
         //callingActionId stays the same
         $this->view->callingAction = $this->defaultNamespace->callingAction;
         $this->view->callingActionId = $ceId;
         $this->view->ceName = Default_SimpleQuery::getCeName($ceId);
         $this->view->checkAll = $this->myNamespace->checkAll;
         unset($this->myNamespace->checkAll);
         //TODO partTable.phtml wird schon auf this->checkAll geprüft, vom Controller übergeben, ebenso reload bei uncheck all
     }
 }
 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
 }
 public function showAction()
 {
     $this->view->atDeId = $this->atDeId;
     $this->view->atDeName = Default_SimpleQuery::getAttributeName($this->atDeId);
     if (Default_ReferenceQuery::hasValueListData($this->atDeId)) {
         $table = new ValueList();
         $select = $table->select();
         $select->where(ValueList::COL_ATTRIBUTE_DESCRIPTOR_ID . "= ?", $this->atDeId, 'int');
         $rowset = $table->fetchAll($select);
         $array = $rowset->toArray();
         $this->view->list = $array;
         $this->render('list');
     }
 }
Example #5
0
 /**
  *
  * @param $key the subdirectory for csv and image files
  * @return unknown_type importImages/importFishes arrays with the IDs as key to see where dataimport eventually went wrong
  */
 public function beginImport($key)
 {
     $this->key = $key;
     $this->logger = new Ble422_ArrayLogger(self::RELATIVE_PATH_IMPORT_LOGS . $this->key . '_import_log.txt');
     $this->loadFromNamespace();
     //
     foreach ($this->rowHasUniqueUploadedFile as $key => $value) {
         $preparedDatasets[$key] = $this->preparedDatasets[$key];
     }
     //
     $importedFishes = array();
     $importedImages = array();
     $i = 0;
     $j = 0;
     $fishForm = new Fish_Form_Edit();
     $fish = new Fish();
     $imageForm = new Image_Form_Edit();
     $image = new Image();
     $numberCopiedFiles = 0;
     $dbAdapter = $fish->getAdapter();
     $dbAdapter->beginTransaction();
     try {
         //changed to local preparedDatasets to filter datasets with uploaded files used in other datasets of import
         foreach ($preparedDatasets as $rowNo => $dataset) {
             if (Default_SimpleQuery::isValueInTableColumn($dataset['fishFormDataset'][Fish::COL_SAMPLE_CODE], $fish, Fish::COL_SAMPLE_CODE, 'string')) {
                 //get id from already existing fish dataset and go on
                 if ($values = Default_SimpleQuery::getValuesFromTableColumnWhere($fish, Fish::COL_ID, Fish::COL_SAMPLE_CODE, $dataset['fishFormDataset'][Fish::COL_SAMPLE_CODE], 'string')) {
                     //test for amount of values, must be 1
                     if (count($values) == 1) {
                         $fishId = $values[0];
                     } else {
                         throw new Zend_Exception('Error: more/less than 1 id found for fish sample code');
                     }
                 }
             } else {
                 //create new fish dataset
                 $fishBaseData = array(Fish::COL_SAMPLE_CODE => $dataset['fishFormDataset'][Fish::COL_SAMPLE_CODE], Fish::COL_USER_ID => $this->userId);
                 $fishMetaData = $dataset['fishFormDataset'];
                 //unset($fishMetaData[Fish::COL_SAMPLE_CODE]);
                 $fishForm->populate($fishMetaData);
                 //insert fish
                 $fishId = $fish->insert($fishBaseData);
                 //now update fish with fish meta data
                 $fish->updateFishAndMetadata($fishForm, $fishId, $fishBaseData);
                 $importedFishes[$i][Fish::COL_ID] = $fishId;
                 $importedFishes[$i]['sourceCsvRow'] = $rowNo;
                 $i++;
             }
             // check wether a image shall be imported ------------------------
             $qu = new Default_ReferenceQuery();
             $filenames = $qu->getImageNames($dataset['fishFormDataset'][Fish::COL_SAMPLE_CODE]);
             //case non-sensitive
             foreach ($filenames as &$file) {
                 $file = strtolower($file);
             }
             $importImageFile = false;
             if (!empty($filenames)) {
                 //case non-sensitive
                 if (in_array(strtolower($dataset['imageFormDataset'][Image::COL_ORIGINAL_FILENAME]), $filenames) != FALSE) {
                     // Image is already in database
                     $importImageFile = false;
                 } else {
                     $importImageFile = true;
                 }
             } else {
                 $importImageFile = true;
             }
             // end check ------------------------------------------------------
             // import the images
             if ($importImageFile) {
                 //copy file to new path and rename
                 $completeSource = self::RELATIVE_PATH_UPLOAD_CACHE . $this->key . '/' . $dataset['imageFormDataset'][Image::COL_ORIGINAL_FILENAME];
                 $creator_guid = new Ble422_Guid();
                 $guid = $creator_guid->__toString();
                 $path_parts = pathinfo($completeSource);
                 $originalFileName = $path_parts['basename'];
                 //used later to create Image dataset
                 $newFileNameWithGuid = $guid . '.' . strtolower($path_parts['extension']);
                 //save extension in lower-case, needed for further processing in flex
                 //relative path with new filename, prefix dot&slash required
                 $completeDestination = './' . Image::RELATIVE_UPLOAD_PATH . '/' . $newFileNameWithGuid;
                 if (!copy($completeSource, $completeDestination)) {
                     throw new Zend_Exception("Error: copy fails, source: {$fileName}, destination: {$completeDestination}");
                 }
                 $ratio = $dataset['imageFormDataset'][Image::COL_RATIO_EXTERNAL];
                 $this->logger->log(array('received original file' => $completeSource));
                 $this->logger->log(array('copied uploaded file' => $completeDestination));
                 $numberCopiedFiles++;
                 //TODO write protect files
                 //create other image files
                 $tn_ratio = $image->processImage($completeDestination);
                 //case sensibility: original file name is saved like spelled in CSV file
                 $imageId = $image->insertImageDataset($completeDestination, $originalFileName, $fishId, $guid, $this->userId, $ratio, $tn_ratio);
                 //create image base and meta datasets
                 $imageMetaData = $dataset['imageFormDataset'];
                 $imageForm->populate($imageMetaData);
                 //$imageId = $image->insert($imageBaseData);
                 $image->updateImageAndMetadata($imageForm, $imageId);
                 $importedImages[$j]['sourceCsvRow'] = $rowNo;
                 $importedImages[$j][Image::COL_ID] = $imageId;
                 $importedImages[$j][Image::COL_FISH_ID] = $fishId;
                 $importedImages[$j][Image::COL_ORIGINAL_FILENAME] = $originalFileName;
                 $importedImages[$j]['completeDestination'] = $completeDestination;
                 $relativePathAndFileNameWorkingCopy = './' . Image::RELATIVE_PATH_IMAGE_SHRINKED_WORKING_COPIES . '/' . $guid . '.jpg';
                 $relativePathAndFileNameThumbnail = './' . Image::RELATIVE_PATH_IMAGE_THUMBNAILS . '/' . $guid . '.jpg';
                 $importedImages[$j]['completeWorkingCopy'] = $relativePathAndFileNameWorkingCopy;
                 $importedImages[$j]['completeThumbnail'] = $relativePathAndFileNameThumbnail;
                 $j++;
             }
         }
         $dbAdapter->commit();
         $this->logger->log(array('datasets committed, number of copied files into system' => $numberCopiedFiles));
         $returnCode = 'success';
         //delete upload cache dir
         Ble422_FileHelper::delete_directory(self::RELATIVE_PATH_UPLOAD_CACHE . $this->key);
     } catch (Exception $e) {
         $returnCode = 'error';
         $dbAdapter->rollBack();
         //delete copied/created files, else there will be orphaned files
         foreach ($importedImages as $image) {
             unlink($image['completeDestination']);
             unlink($image['completeWorkingCopy']);
             unlink($image['completeThumbnail']);
         }
         $this->logger->log(array('Error exception' => $e->getMessage()), 'ERROR, roll back of imported datasets and unsetting of files, see below');
         $this->logger->log(array('Roll back of importedFishes' => $importedFishes));
         $this->logger->log(array('Roll back of importedImages' => $importedImages));
         //delete upload cache dir
         Ble422_FileHelper::delete_directory(self::RELATIVE_PATH_UPLOAD_CACHE . $this->key);
         echo $e->getMessage();
     }
     $returnArray = array('returnCode' => $returnCode, 'importFishes' => $importedFishes, 'importImages' => $importedImages, 'numberCopiedFiles' => $numberCopiedFiles);
     $this->logger->log(array('data import' => $returnArray));
     return $returnArray;
 }
Example #6
0
 private function process(array $params)
 {
     //params-array filters (where) and/or shows more info (joins)
     $dbAdapter = Zend_Registry::get('DB_CONNECTION1');
     $select = $dbAdapter->select();
     $select->from(array('celist' => View_CeList::NAME), array(View_CeList::COL_WORK_NAME, View_CeList::COL_CAEX_NAME, View_CeList::COL_CAEX_DESC, View_CeList::COL_CAEX_ID, View_CeList::COL_WORK_ID, View_CeList::COL_CAEX_TRAIN, 'images' => new Zend_Db_Expr('count(cehim.' . CeHasImage::COL_ID . ')')));
     $select->joinLeft(array('exp' => Expertise::TABLE_NAME), $dbAdapter->quoteIdentifier('celist.' . View_CeList::COL_EXPE_ID) . '=' . $dbAdapter->quoteIdentifier('exp.' . Expertise::COL_ID));
     $select->joinLeft(array('key' => KeyTable::TABLE_NAME), $dbAdapter->quoteIdentifier('celist.' . View_CeList::COL_KETA_ID) . '=' . $dbAdapter->quoteIdentifier('key.' . KeyTable::COL_ID));
     $select->joinLeft(array('cehim' => CeHasImage::TABLE_NAME), $dbAdapter->quoteIdentifier('celist.' . View_CeList::COL_CAEX_ID) . '=' . $dbAdapter->quoteIdentifier('cehim.' . CeHasImage::COL_CALIBRATION_EXERCISE_ID), array());
     $select->joinLeft(array('vali1' => ValueList::TABLE_NAME), $dbAdapter->quoteIdentifier('vali1.' . ValueList::COL_ID) . '=' . $dbAdapter->quoteIdentifier('exp.' . Expertise::COL_SPECIES), array(Expertise::COL_SPECIES => 'vali1.' . ValueList::COL_VALUE));
     $select->joinLeft(array('vali2' => ValueList::TABLE_NAME), $dbAdapter->quoteIdentifier('vali2.' . ValueList::COL_ID) . '=' . $dbAdapter->quoteIdentifier('exp.' . Expertise::COL_SUBJECT), array(Expertise::COL_SUBJECT => 'vali2.' . ValueList::COL_VALUE));
     $select->group('celist.' . View_CeList::COL_CAEX_ID);
     $headerArray = array(array('raw' => View_CeList::COL_CAEX_NAME, 'name' => 'CE name'), array('raw' => View_CeList::COL_WORK_NAME, 'name' => 'Workshop name'), array('raw' => Expertise::COL_AREA, 'name' => 'Exp area'), array('raw' => Expertise::COL_SPECIES, 'name' => 'Exp species'), array('raw' => Expertise::COL_SUBJECT, 'name' => 'Exp subject'), array('raw' => KeyTable::COL_FILENAME, 'name' => 'Protocol'));
     if (array_key_exists(User::COL_ID, $params)) {
         //filter...
         $select->joinLeft(array('part' => Participant::TABLE_NAME), $dbAdapter->quoteIdentifier('celist.' . View_CeList::COL_CAEX_ID) . '=' . $dbAdapter->quoteIdentifier('part.' . Participant::COL_CE_ID), array('part.' . Participant::COL_ID));
         //where i am participant
         $select->where('part.' . Participant::COL_USER_ID . '=?', $params[User::COL_ID]);
         $userId = $params[User::COL_ID];
         $select->joinLeft(array('work' => Workshop::TABLE_NAME), 'work.' . Workshop::COL_ID . '=' . 'celist.' . View_CeList::COL_WORK_ID, array(Workshop::COL_USER_ID));
         //or where i am workshop-manager
         $select->orWhere('work.' . Workshop::COL_USER_ID . '= ?', $userId);
         array_push($headerArray, array('raw' => View_CeList::COL_IMAGES, 'name' => 'Images'));
     }
     if (array_key_exists(CalibrationExercise::COL_EXPERTISE_ID, $params)) {
         $select->where('celist.' . CalibrationExercise::COL_EXPERTISE_ID . '=?', $params[CalibrationExercise::COL_EXPERTISE_ID]);
         //			$select->joinLeft(array('cehim'=>CeHasImage::TABLE_NAME),
         //			$dbAdapter->quoteIdentifier('celist.' . View_CeList::COL_CAEX_ID). '=' . $dbAdapter->quoteIdentifier('cehim.' .CeHasImage::COL_CALIBRATION_EXERCISE_ID),
         //			array());
     }
     //Hinzugefügt am 14.10.2009 Tabellenzeilen mit WS name = training exercise
     //sollten nicht angezeigt werden (im Menüpunkt search calibration exercises)
     //kompletter if-Zweig wurde hinzugefügt
     if ($this->getRequest()->getModuleName() == 'ce' && $this->getRequest()->getControllerName() == 'search' && $this->getRequest()->getActionName() == 'list') {
         $select->where(CalibrationExercise::COL_WORKSHOP_ID . ' is not null');
     }
     //echo $select;
     /**
      * Paginator control
      */
     $paginator = new Ble422_Paginator_Extended($select, $this->getRequest());
     $paginator->setHeader($headerArray);
     $paginator->setCurrentPageNumber($this->getRequest()->getParam('page'))->setItemCountPerPage(10)->setPageRange(5)->orderBy($this->getRequest()->getParam('orderBy'));
     //$this->_getParam('pageRange'));
     Zend_View_Helper_PaginationControl::setDefaultViewPartial('partials/list_pagination_control.phtml');
     $detailId = $this->getRequest()->getParam('detailId');
     if ($detailId != null) {
         $detailId = intval($detailId);
         /**
          * show wether CE is stopped
          */
         try {
             if (Default_SimpleQuery::isCeStopped($detailId)) {
                 $this->view->ceInfo = 'CE is <b>STOPPED</b>';
             } else {
                 $this->view->ceInfo = 'CE is <b>RUNNING</b>';
             }
         } catch (exception $e) {
             $this->view->ceInfo = $e->getMessage();
         }
         /**
          * show Coordinator
          */
         if ($coordinators = Participant::getCoordinators($detailId)) {
             $this->view->ceCoordinators = $coordinators;
         }
         /**
          * imageset and shown attributes
          */
         $imagesetSelect = $dbAdapter->select();
         $imagesetSelect->from('v_imageset_info');
         $imagesetSelect->where(CalibrationExercise::COL_ID . '=?', $detailId);
         $imagesetSelect->group(AttributeDescriptor::COL_NAME);
         $imagesetArray = $dbAdapter->fetchAll($imagesetSelect);
         $this->view->imagesetArray = $imagesetArray;
         $shownAttrSelect = $dbAdapter->select();
         $shownAttrSelect->from(array('cehat' => CeHasAttributeDescriptor::TABLE_NAME));
         $shownAttrSelect->join(array('attr' => AttributeDescriptor::TABLE_NAME), 'cehat.' . CeHasAttributeDescriptor::COL_ATDE_ID . '= attr.' . AttributeDescriptor::COL_ID);
         $shownAttrSelect->where(CalibrationExercise::COL_ID . '=?', $detailId);
         $shownAttrArray = $dbAdapter->fetchAll($shownAttrSelect);
         $this->view->shownAttrArray = $shownAttrArray;
         $this->view->detailId = $detailId;
     }
     $this->view->userRole = AuthQuery::getUserRole();
     $this->view->expeId = $this->getRequest()->getParam(CalibrationExercise::COL_EXPERTISE_ID);
     $this->view->paginator = $paginator;
     $this->render('list');
 }
Example #7
0
 public function deleteAction()
 {
     //check if workshop has exercises if not then
     //delete workshop files
     //delete workshop
     //delete ws info
     //delete ce
     //delete imageset attributes -> DB on delete cascade
     //delete ce has image -> DB on delete cascade
     //delete ce has attribute desc. -> DB on delete cascade
     //delete participants -> DB on delete cascade
     //delete annotations -> DB on delete cascade
     //delete dots -> DB on delete cascade
     $request = $this->getRequest();
     $workId = intval($this->getRequest()->getParam(Workshop::COL_ID));
     if (AuthQuery::getUserRole() == 'admin') {
         if (Default_SimpleQuery::isValueInTableColumn($workId, new CalibrationExercise(), CalibrationExercise::COL_WORKSHOP_ID)) {
             $request = $this->getRequest();
             $workshop = new Workshop();
             $rowset = $workshop->find($workId);
             if (count($rowset) == 1) {
                 $table = new WorkshopInfo();
                 //$tableAdapter = $table->getAdapter();
                 $select = $table->select();
                 //$select->from(WorkshopInfo::TABLE_NAME);
                 $select->where(WorkshopInfo::COL_WORKSHOP_ID . ' = ?', $workId, 'int');
                 echo $select;
                 $rowset = $table->fetchAll($select);
                 if (count($rowset) >= 1) {
                     $rowsetArray = $rowset->toArray();
                     $RELATIVE_WORKSHOP_FILES_PATH = 'infoFiles';
                     //without pre- and post-slash!
                     foreach ($rowsetArray as $row) {
                         try {
                             $filename = $row[WorkshopInfo::COL_FILE];
                             if ($filename != NULL) {
                                 $myFile = $RELATIVE_WORKSHOP_FILES_PATH . '/' . $filename;
                                 $fh = fopen($myFile, 'w');
                                 fclose($fh);
                                 unlink($myFile);
                             }
                         } catch (Exception $e) {
                             throw new Zend_Exception('Error: can not open file');
                         }
                     }
                 }
                 //note: delete of workshop_info is executed from db
                 $workshop->delete($workshop->getAdapter()->quoteInto(Workshop::COL_ID . ' = ?', $workId));
             }
         }
     }
     $redirect = new Zend_Controller_Action_Helper_Redirector();
     $redirect->setGoto('myws', 'search', 'workshop');
 }
Example #8
0
 public function startceAction()
 {
     if (Default_SimpleQuery::isCeCompletelyDefined($this->callingCeId)) {
         $ceTable = new CalibrationExercise();
         $data = array(CalibrationExercise::COL_IS_STOPPED => 0);
         $ceTable->update($data, $ceTable->getAdapter()->quoteInto(CalibrationExercise::COL_ID . '=?', $this->callingCeId));
         $this->redirectTo('index', array(CalibrationExercise::COL_ID => $this->callingCeId));
         $this->defaultNamespace->message = NULL;
     } else {
         $this->defaultNamespace->message = '<red>Error: Calibration exercise not completely defined.</red>';
         $this->redirectTo('index', array(CalibrationExercise::COL_ID => $this->callingCeId));
     }
 }