Ejemplo n.º 1
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;
 }
Ejemplo n.º 2
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');
 }