Example #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');
 }