public function savePreferences($context){ if(CdiPreferences::save()) { // apply config changes if(CdiUtil::isCdiSlave()) { CdiSlave::install(); } else if (CdiUtil::isCdiMaster()) { CdiMaster::install(); } else { CdiDBSync::install(); } } else { Administration::instance()->Page->pageAlert(_('An unknown error occurred while saving preferences for CDI. Your changes have not been saved.')); return false; } }
// We should not be processing any queries when the extension is disabled or when we are the Master instance if((!class_exists('Administration')) || !CdiUtil::isEnabled()) { $result["status"] = "error"; $result["message"] = "You can only execute actions from within Symphony and when the CDI extension is enabled"; Symphony::Log()->pushToLog('[CDI] You can only execute actions from within Symphony and when the CDI extension is enabled', E_NOTICE, true); } // Clean the database and log files when the cdi_clear action is called if(isset($_POST["action"]["cdi_clear"])) { try { if(CdiUtil::isCdiMaster()) { CdiMaster::uninstall(); CdiMaster::install(); } else if (CdiUtil::isCdiSlave()) { CdiSlave::uninstall(); CdiSlave::install(); } else if(CdiUtil::isCdiDBSync()) { CdiDBSync::uninstall(); CdiDBSync::install(); } $result["status"] = 'success'; } catch(Exception $e) { $result["status"] = "error"; $result["message"] = $e->getMessage(); Symphony::Log()->pushToLog('[CDI] ' . $e->getMessage(), E_ERROR, true); } } // Clean the database backup list when cdi_clear_restore action is called else if(isset($_POST["action"]["cdi_clear_restore"])) { try {
<?php require_once(EXTENSIONS . '/cdi/lib/class.cdiutil.php'); require_once(EXTENSIONS . '/cdi/lib/class.cdislave.php'); // We should not be processing any queries when the extension is disabled or when we are the Master instance if((!class_exists('Administration')) || !CdiUtil::isEnabled() || (CdiUtil::isCdiMaster() || CdiUtil::isCdiDBSync())) { echo "WARNING: You are not calling this page from Symphony, the CDI extension is disabled or you are running the queryies on the Master instance. No queries have been executed."; } else { $callback = Administration::getPageCallback(); if(Symphony::Configuration()->get('api_key','cdi') !== $callback['context'][0]){ echo "WARNING: Invalid API key. The correct key can be found in the configuration page."; die(); } else{ CdiSlave::update(); } } die();