public function updateAction() { $table = new Workshop(); $request = $this->getRequest(); $updateValues = $request->getParams(); $wsNamespace = new Zend_Session_Namespace('workshop'); //$this->view->WORK_ID = $updateValues[Workshop::COL_ID]; $workId = intval($this->getRequest()->getParam(Workshop::COL_ID)); $this->view->WORK_ID = $workId; //if user is not actual workshop manager, redirect if (!AuthQuery::getUserId() == Default_SimpleQuery::getWsManagerUserId($workId)) { $this->redirectTo('list', 'search', 'workshop'); return; } if ($request->isPost()) { if ($this->getRequest()->getParam('save') != null) { //save Button clicked if ($this->form->isValid($updateValues)) { if ($this->form->getValue('Token') == $wsNamespace->Token) { $data = array(Workshop::COL_NAME => $this->form->getValue(Workshop::COL_NAME), Workshop::COL_LOCATION => $this->form->getValue(Workshop::COL_LOCATION), Workshop::COL_START_DATE => $this->form->getValue(Workshop::COL_START_DATE), Workshop::COL_END_DATE => $this->form->getValue(Workshop::COL_END_DATE), Workshop::COL_HOST_ORGANISATION => $this->form->getValue(Workshop::COL_HOST_ORGANISATION), Workshop::COL_USER_ID => $this->form->getValue(Workshop::COL_USER_ID)); $table->update($data, Workshop::COL_ID . " = '" . $this->form->getValue(Workshop::COL_ID) . "'"); $wsNamespace->unsetAll(); $this->redirectTo(); } else { $this->form->reset(); $this->render('outOfDate'); } } } else { if ($this->getRequest()->getParam('setManager') != null) { // new ws manager button clicked $wsNamespace->formValues = $this->getRequest()->getParams(); $defaultNamespace = new Zend_Session_Namespace('default'); $defaultNamespace->callingAction = 'workshop/edit/update'; $defaultNamespace->callingActionId = $request->getParam(Workshop::COL_ID); $this->redirectTo('index', 'search', 'user'); } else { // new ws manager has choosen and is loading $userTable = new User(); $userResult = $userTable->find($this->getRequest()->getParam(Workshop::COL_USER_ID))->current(); if ($userResult != null) { $userArray = $userResult->toArray(); } else { $userArray = array(Workshop::COL_USER_ID => null, User::COL_USERNAME => 'not valid'); } $valueArray = $wsNamespace->formValues; $valueArray[Workshop::COL_USER_ID] = $userArray[Workshop::COL_USER_ID]; $valueArray[User::COL_USERNAME] = $userArray[User::COL_USERNAME]; $this->form->isValid($valueArray); if ($this->form->getValue('Token') == null) { $guid = new Ble422_guid(); $wsNamespace->Token = $guid->__toString(); $this->form->getElement('Token')->setValue($guid->__toString()); } } } } else { // first call load form with default values $rowset = $table->find($request->getParam(Workshop::COL_ID))->current(); if ($rowset != null) { $this->form->setValues($rowset->toArray()); } $this->form->setAction(Zend_Controller_Front::getInstance()->getBaseUrl() . "/workshop/edit/update"); // Get part_id and part_role $userTable = new User(); $userResult = $userTable->find($this->form->getValue(Workshop::COL_USER_ID))->current(); if ($userResult != null) { $userArray = $userResult->toArray(); } else { $userArray = array(Workshop::COL_USER_ID => null, User::COL_USERNAME => 'not valid'); } $this->form->isValidPartial(array(Workshop::COL_USER_ID => $userArray[User::COL_ID], User::COL_USERNAME => $userArray[User::COL_USERNAME])); $guid = new Ble422_Guid(); $wsNamespace->Token = $guid->__toString(); $this->form->getElement('Token')->setValue($guid->__toString()); } }
public function deleterecursiveAction() { //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 //auskommentiert am 14.10.2009 weil RAW DELETE in der Calibration exercise list //nicht immer funktionierte (wenn WS name = training exercise war) //stattdessen soll die cdId aus dem Request geholt werden //$ceId = $this->callingCeId; $ceId = $this->getRequest()->getParam(CalibrationExercise::COL_ID); $ce = new CalibrationExercise(); if ($this->userRole == 'admin' || AuthQuery::getUserId() == Default_SimpleQuery::getWsManagerUserId(Default_SimpleQuery::getWorkshopId($ceId))) { $rowset = $ce->find($ceId); if (count($rowset) == 1) { $ce->delete($ce->getAdapter()->quoteInto(CalibrationExercise::COL_ID . ' = ?', $ceId)); } } $Redirect = new Zend_Controller_Action_Helper_Redirector(); if ($this->defaultNamespace->callingAction == 'ce/search/myce') { $Redirect->setGotoSimple('myce', 'search', 'ce'); } elseif ($this->defaultNamespace->callingAction == 'ce/search/list') { $Redirect->setGotoSimple('list', 'search', 'ce'); } }