public function updateTreeId($sourceNodeId, $destinationNodeId) { $searchcriteria = array('tree_id' => $sourceNodeId); $sqlParser = clone $this->sqlParser; $sqlParser->parseCriteria($searchcriteria, false); $this->parseCriteria($sqlParser, $searchcriteria); $sqlParser->setFieldValue('tree_id', $destinationNodeId); $query = $sqlParser->getSql(SqlParser::MOD_UPDATE_FIELDS); $db = $this->getDb(); $res = $db->query($query); if ($db->isError($res)) { throw new Exception($res->getDebugInfo()); } // update treeref $treeRef = new PollTreeRef(); $treeRef->updateRefTreeId($sourceNodeId, $destinationNodeId); // update settings $settings = $this->getPollSettings(); $settings->updateTreeId($tag, $tree_id, $newTag); }
/** * 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 'PollTreeRef.php'; $treeref = new PollTreeRef(); $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 'PollSettings.php'; $settings = new PollSettings($this); $treeref->delete($key); // delete poll_ 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 PollTreeRef(); $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); } }