示例#1
0
 public function deleterecursiveAction()
 {
     //delete workshop files
     //delete workshop -> triggers delete ce
     //delete ws info -> DB on delete cascade
     //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') {
         $request = $this->getRequest();
         $workId = intval($this->getRequest()->getParam(Workshop::COL_ID));
         $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');
 }
示例#2
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');
 }
示例#3
0
 public function detailsAction()
 {
     $wsId = $this->getRequest()->getParam(Workshop::COL_ID);
     $dbAdapter = Zend_Registry::get('DB_CONNECTION1');
     $wsSelect = $dbAdapter->select();
     $wsSelect->from(array('work' => Workshop::TABLE_NAME));
     $wsSelect->join(array('inst' => ValueList::TABLE_NAME), 'inst.' . ValueList::COL_ID . "=" . 'work.' . Workshop::COL_HOST_ORGANISATION, array('instname' => ValueList::COL_NAME));
     $wsSelect->join(array('local' => ValueList::TABLE_NAME), 'local.' . ValueList::COL_ID . "=" . 'work.' . Workshop::COL_LOCATION, array('location' => ValueList::COL_NAME));
     $wsSelect->join(array('user' => User::TABLE_NAME), 'user.' . User::COL_ID . "=" . 'work.' . Workshop::COL_USER_ID, array('manager' => User::COL_USERNAME));
     $wsSelect->where(Workshop::COL_ID . '=?', $wsId);
     $workshopArray = $dbAdapter->fetchAll($wsSelect);
     /**
      * ce list
      */
     $ceSelect = $dbAdapter->select();
     $ceSelect->from(CalibrationExercise::TABLE_NAME);
     $ceSelect->where(CalibrationExercise::COL_WORKSHOP_ID . '=?', $wsId);
     $this->view->ceArray = $dbAdapter->fetchAll($ceSelect);
     /**
      * links
      */
     $infoTable = new WorkshopInfo();
     $linkSelect = $infoTable->select();
     $linkSelect->where(WorkshopInfo::COL_WORKSHOP_ID . "=?", $wsId);
     $linkSelect->where(WorkshopInfo::COL_FILE . " IS NULL");
     $linkResult = $infoTable->fetchAll($linkSelect);
     if ($linkResult != null) {
         $linkArray = $linkResult->toArray();
     } else {
         $linkArray = array();
     }
     /**
      * files
      */
     $fileSelect = $infoTable->select();
     $fileSelect->where(WorkshopInfo::COL_WORKSHOP_ID . "=?", $wsId);
     $fileSelect->where(WorkshopInfo::COL_LINK . " IS NULL");
     $fileResult = $infoTable->fetchAll($fileSelect);
     if ($fileResult != null) {
         $fileArray = $fileResult->toArray();
     } else {
         $fileArray = array();
     }
     $this->view->userRole = AuthQuery::getUserRole();
     $this->view->workshopArray = $workshopArray[0];
     $this->view->linkArray = $linkArray;
     $this->view->fileArray = $fileArray;
     $this->view->wsId = $wsId;
 }