Пример #1
0
 private function handleTreeEditPost()
 {
     $request = Request::getInstance();
     $values = $request->getRequest(Request::POST);
     try {
         if (!$request->exists('tree_id')) {
             throw new Exception('Node ontbreekt.');
         }
         if (!$request->exists('tag')) {
             throw new Exception('Tag ontbreekt.');
         }
         $tree_id = intval($request->getValue('tree_id'));
         $tag = $request->getValue('tag');
         $key = array('tree_id' => $tree_id, 'tag' => $tag);
         if ($this->exists($key)) {
             $this->update($key, $values);
         } else {
             $this->insert($values);
         }
         $treeRef = new NewsLetterTreeRef();
         $treeRef->delete($key);
         foreach ($values['ref_tree_id'] as $ref_tree_id) {
             $key['ref_tree_id'] = $ref_tree_id;
             $treeRef->insert($key);
         }
         viewManager::getInstance()->setType(ViewManager::ADMIN_OVERVIEW);
         $this->plugin->getReferer()->handleHttpGetRequest();
     } catch (Exception $e) {
         $template = new TemplateEngine();
         $template->setVariable('errorMessage', $e->getMessage(), false);
         // reset date values
         $online = $this->sqlParser->getFieldByName('online');
         $this->sqlParser->setFieldValue('online', strftime('%Y-%m-%d', strtotime($online->getValue())));
         $offline = $this->sqlParser->getFieldByName('offline');
         $this->sqlParser->setFieldValue('offline', strftime('%Y-%m-%d', strtotime($offline->getValue())));
         $this->handleTreeEditGet(false);
     }
 }