/** * handle pre delete checks and additions * this function removed the plugin files * * @param array filtered values for insertion * @return void * @see DbConnector::handlePreDelete */ protected function handlePreDelete($id, $values) { $siteTheme = new SystemSiteTheme(); $searchcriteria = array('theme_id' => $values['id']); if ($siteTheme->exists($searchcriteria)) { throw new Exception("Theme {$values['name']} is beeing used by a page. Remove it first."); } $detail = $this->getDetail($id); if ($detail['selected']) { throw new Exception("Cannot delete a default theme. First use another theme as default."); } if ($detail['classname'] == $this->director->getConfig()->admin_theme) { throw new Exception("Cannot delete a administration theme. First specify another theme in adminmanager config file."); } }
/** * handle pre update checks and additions * eg. check for uniqueness of set default values * * @param array filtered values for insertion * @param array filtered values for insertion * @return void * @see DbConnector::handlePreInsert */ protected function handlePreUpdate($id, $values) { if ($values['tree_root_id'] > 0) { throw new Exception("Root node must be smaller than 1"); } $sqlParser = clone $this->sqlParser; $sqlParser->addCriteria(new SqlCriteria('grp_name', $values['name'])); $sqlParser->addCriteria(new SqlCriteria('grp_language', $values['language'])); $sqlParser->addCriteria(new SqlCriteria('grp_id', $id['id'], '<>')); $query = $sqlParser->getSql(SqlParser::PKEY); $db = $this->getDb(); $res = $db->query($query); if ($db->isError($res)) { throw new Exception($res->getDebugInfo()); } if ($res->numRows() > 0) { throw new Exception('Website already exists.'); } // only 1 default selected theme can exist if (array_key_exists('startpage', $values) && $values['startpage']) { $this->deselect(); } // rearrange tree $current = $this->getDetail($id); if ($current['tree_root_id'] != $values['tree_root_id']) { // check if current id is shared with others. if so, skip theme, tag and plugin move $sqlParser = clone $this->sqlParser; $sqlParser->addCriteria(new SqlCriteria('grp_tree_root_id', $current['tree_root_id'])); $sqlParser->addCriteria(new SqlCriteria('grp_id', $id['id'], '<>')); $query = $sqlParser->getSql(SqlParser::PKEY); $res = $db->query($query); if ($db->isError($res)) { throw new Exception($res->getDebugInfo()); } if ($res->numRows() < 1) { // move theme to new parent $siteTheme = new SystemSiteTheme(); $siteTheme->changeNode($current['tree_root_id'], $values['tree_root_id']); // move tag to new parent $siteTag = new SystemSiteTag(); $siteTag->changeNode($current['tree_root_id'], $values['tree_root_id']); // move plugins to new parent $sitePlugin = $this->director->siteManager->systemSite->getSitePlugin(); $sitePlugin->changeNode($current['tree_root_id'], $values['tree_root_id']); // move acl to new parent $acl = new Acl(); $acl->changeNode($current['tree_root_id'], $values['tree_root_id']); } // move child nodes $site = new SystemSite(); $site->moveToNode($current['tree_root_id'], $id['id'], $values['tree_root_id']); // clear cache $cache = Cache::getInstance(); $cache->clear(); } }