public function deleteTreshold($parameters = array()) { $view = new ui($this); $flash = new popupController(); $model = new directorywatchertresholdModel(); $tresholds = $model->getfromId($parameters['id']); if (count($tresholds) == 1) { $treshold = $tresholds[0]; if ($parameters['sure'] == 'sure') { try { $model->deletebyId($treshold->getId()); } catch (Exception $e) { $flash->createflash(array('name' => 'err', 'type' => 'error', 'content' => 'Deze treshold werd niet goed verwijderd.')); return false; } $flash->createflash(array('name' => 'success', 'type' => 'success', 'content' => 'De gegevens zijn goed verwijderd.')); $this->response->assign('gridextra_' . $parameters['-gridid-'], 'innerHTML', ''); $grid = new mygrid($parameters['-gridid-']); $grid->registerAddrequest('directorywatcher', 'addTreshold', array('title' => 'Treshold toevoegen', 'currentid' => $parameters['currentid'])); $grid->unregisterRequest('-edit-'); $grid->unregisterRequest('-delete-'); $testmodel = new dirstatusModel(); $current = $testmodel->getfromId($parameters['currentid']); $current = $current[0]; $parent = $current->getParent(); $parenttresholds = array(); if ($parent != '') { $parentobj = $testmodel->getfromPath($parent); $parentobj = $parentobj[0]; $parenttresholds = $model->getfromPath($parent); while (count($parenttresholds) == 0 && $parent != '') { $parent = $parentobj->getParent(); $parentobj = $testmodel->getfromPath($parent); $parentobj = $parentobj[0]; $parenttresholds = $model->getfromPath($parent); } } if (count($parenttresholds) == 0 && $parent == '') { $parent = '_default_'; $parenttresholds = $model->getfromPath($parent); } $grid->setDefaultconditions(array('path' => array('mode' => '=', 'value' => $parent))); return true; } else { $view->assign('treshold', $treshold); return $view->fetch('directorywatcher_deletetreshold.tpl'); } } else { $flash->createflash(array('name' => 'err', 'type' => 'warning', 'content' => 'Deze treshold werd niet gevonden.')); return false; } }
// Get the dispatcher require_once FRAMEWORK . DS . 'dispatcher.php'; // And fire it up try { //$disp = new dispatcher(); } catch (Exception $e) { echo $e->getMessage(); echo $e->getTrace(); } $model = new dirstatusModel(); $errmodel = new dirstatuserrlistModel(); $statuses = $model->get(array('status' => array('mode' => '=', 'value' => ''))); foreach ($statuses as $object) { echo 'processing ' . $object->getPath() . "\n"; $testmodel = new directorywatchertresholdModel(); $currentresholds = $testmodel->getfromPath($object->getPath()); if (count($currentresholds) == 0) { $parent = $object->getParent(); $parenttresholds = array(); if ($parent != '') { $parentobj = $model->getfromPath($parent); $parentobj = $parentobj[0]; $parenttresholds = $testmodel->getfromPath($parent); while (count($parenttresholds) == 0 && $parent != '') { $parent = $parentobj->getParent(); $parentobj = $model->getfromPath($parent); $parentobj = $parentobj[0]; $parenttresholds = $testmodel->getfromPath($parent); } } if (count($parenttresholds) == 0 && $parent == '') {