/** * delete a plugin item * * @param array whith id [fieldname => value] * @param string name of the tag that is being deleted * @param integer id of the tree * @return void */ public function deletePlugin($values, $plugin_type) { $ref = $this->getObject($plugin_type); switch ($plugin_type) { case self::TYPE_DEFAULT: // delete reference ids require_once 'NewsLetterTreeRef.php'; $treeref = new NewsLetterTreeRef(); $key = array('ref_tree_id' => $values['tree_id']); $treeref->delete($key); $key = array('tree_id' => $values['tree_id'], 'tag' => $values['tag']); // delete settings require_once 'NewsLetterSettings.php'; $obj = new NewsLetterSettings($this); $obj->delete($key); // delete users require_once 'NewsLetterUser.php'; $obj = new NewsLetterUser($this); $obj->delete($key); // delete user groups require_once 'NewsLetterGroup.php'; $obj = new NewsLetterGroup($this); $obj->delete($key); // delete usergroup links $obj->deleteUserGroup($values['tree_id'], $values['tag']); // delete news items $list = $ref->getList($key); foreach ($list['data'] as $item) { $key = $ref->getKey($item); $ref->delete($key); } break; default: $key = $ref->getKey($values); $ref->delete($key); } }
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); } }