예제 #1
0
	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 {
			CdiDumpDB::uninstall();
예제 #2
0
		public static function appendInstanceMode() {
			$div = new XMLElement('div', NULL, array('class' => 'instanceMode'));
			$div->appendChild(new XMLElement('h3','Instance Mode',array('style' => 'margin: 5px 0;')));
			$label = Widget::Label();
			if(!CdiUtil::isCdiSlave() && !CdiUtil::isCdiDBSyncSlave()) {
				$label->setAttribute('style','position:relative;padding-left:18px;');
			} else {
				$label->setAttribute('style','margin-bottom: 2px;position:relative;padding-left:18px;');
			}
			$input = Widget::Input('settings[cdi][is-slave]', 'yes', 'checkbox');
			$input->setAttribute('style','position:absolute;left:0px;');
			$input->setAttribute('class','instance-mode');
			if(CdiUtil::canBeMasterInstance()) {
				if(CdiUtil::isCdiSlave() || CdiUtil::isCdiDBSyncSlave()) { $input->setAttribute('checked', 'checked'); }
				$label->setValue($input->generate() . ' This is a "Slave" instance (no structural changes will be registered)');
			} else {
				$input->setAttribute('checked', 'checked');
				$input->setAttribute('disabled', 'disabled');
				$label->setValue($input->generate() . ' This can only be a "Slave" instance due to insufficient write permissions.');
			}
			$div->appendChild($label);
			if(CdiUtil::isCdiSlave() || CdiUtil::isCdiDBSyncSlave())
			{
				$label = Widget::Label();
				$label->setAttribute('style','position:relative;padding-left:18px;');
				$input = Widget::Input('settings[cdi][disable_blueprints]', 'yes', 'checkbox');
				$input->setAttribute('style','position:absolute;left:0px;');
				if(CdiUtil::hasDisabledBlueprints()) {
					$input->setAttribute('checked', 'checked');
				}
				$label->setValue($input->generate() . ' Disable structural changes on this instance.');
				$div->appendChild($label);
			}
			if(CdiUtil::isCdiMaster() || CdiUtil::isCdiSlave()) {
				$div->appendChild(new XMLElement('p', 'The extension is designed to allow automatic propagation of structural changes between environments in a DTAP setup.
													   It is imperitive that you have a single "Master" instance (usually your development environment). This is important because the auto-increment values need to be exactly the same on each database table in every environment. 
													   Switching between modes is therefore not recommended. If needed, make sure you only switch instance mode after you have ensured that you have restored all databases from the same source and cleared the CDI logs on all instances.', array('class' => 'help')));
			} else if (CdiUtil::isCdiDBSync()) {
				$div->appendChild(new XMLElement('p', 'The extension is designed to allow manual propagation of structural changes between environments in a DTAP setup.
													   It is imperitive that you have a single "Master" instance (usually your development environment). This is important because the auto-increment values need to be exactly the same on each database table in every environment. 
													   Switching between modes is therefore not recommended. If needed, make sure you only switch instance mode after you have ensured that you have restored all databases from the same source.', array('class' => 'help')));
			}
			$div->appendChild(new XMLElement('p', 'You need to save your changes before you can configure this instance, or reload the page to cancel.<br />Be advised: changing instances mode will reset any instance specific configuration settings', array('class' => 'cdiInstanceRestart', 'style' => 'display:none;')));
			return $div;
		}
예제 #3
0
		public function appendPreferences($context){
			// Import the db_sync.sql file when the cdi_import action is called
			// The import action is the only left to require a post-back because AJAX file upload is cumbersome
			if(isset($_POST["action"]["cdi_import"])) {
				CdiDBSync::import();
			} else if(isset($_POST["action"]["dumpdb_restore"])) {
				CdiDumpDB::restore();
			}
			
			// Create the Preferences user-interface for the CDI extension
			$group = new XMLElement('fieldset');
			$group->setAttribute('class', 'cdi settings');
			$group->appendChild(new XMLElement('legend', 'Continuous Database Integration'));
			$group->appendChild(new XMLElement('div', '<span class="image">&#160;</span><span>Processing... please wait.</span>', array('class' => 'help cdiLoading cdiHidden')));
			Administration::instance()->Page->Form->setAttribute('enctype', 'multipart/form-data');
			
			$group->appendChild(CdiPreferences::appendCdiMode());
			if(CdiUtil::isCdi()) {
				$group->appendChild(CdiPreferences::appendCdiPreferences());
			} else if(CdiUtil::isCdiDBSync()) {
				$group->appendChild(CdiPreferences::appendDBSyncPreferences());
			}

			// Append preferences
			$context['wrapper']->appendChild($group);
		}
예제 #4
0
<?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();