src/Installer/Plugin.php
function copy($name, $new_name, $update = false)
	{
		//replace not-allowed characters with _
		$new_name = preg_replace('/([^a-zA-Z0-9_])/', '_', $new_name);

		//initialise response element
		$result = array();
		$result['status'] = false;

		if ($name && $new_name) {
			//check to see if an integration was selected
			$db = Factory::getDBO();

			$query = $db->getQuery(true)
				->select('count(*)')
				->from('#__jfusion')
				->where('original_name IS NULL')
				->where('name LIKE ' . $db->quote($name));

			$db->setQuery($query);
			$record = $db->loadResult();

			$query = $db->getQuery(true)
				->select('id')
				->from('#__jfusion')
				->where('name = ' . $db->quote($new_name));

			$db->setQuery($query);
			$exsist = $db->loadResult();
			if ($exsist) {
				throw new RuntimeException($new_name . ' ' . Text::_('ALREADY_IN_USE'));
			} else if ($record) {
				$JFusionPlugin = Factory::getAdmin($name);
				if ($JFusionPlugin->multiInstance()) {
					$db = Factory::getDBO();
					if (!$update) {
						//add the new entry in the JFusion plugin table
						$query = $db->getQuery(true)
							->select('*')
							->from('#__jfusion')
							->where('name = ' . $db->quote($name));

						$db->setQuery($query);
						$plugin_entry = $db->loadObject();
						$plugin_entry->name = $new_name;
						$plugin_entry->id = null;
						//only change the original name if this is not a copy itself
						if (empty($plugin_entry->original_name)) {
							$plugin_entry->original_name = $name;
						}
						$db->insertObject('#__jfusion', $plugin_entry, 'id');
					}
					$result['message'] = $new_name . ': ' . Text::_('PLUGIN') . ' ' . $name . ' ' . Text::_('COPY') . ' ' . Text::_('SUCCESS');
					$result['status'] = true;
				} else {
					throw new RuntimeException(Text::_('CANT_COPY'));
				}
			} else {
				throw new RuntimeException(Text::_('INVALID_SELECTED'));
			}
		} else {
			throw new RuntimeException(Text::_('NONE_SELECTED'));
		}
		return $result;
	}
function copy($name, $new_name, $update = false)
	{
		//replace not-allowed characters with _
		$new_name = preg_replace('/([^a-zA-Z0-9_])/', '_', $new_name);

		//initialise response element
		$result = array();
		$result['status'] = false;

		if ($name && $new_name) {
			//check to see if an integration was selected
			$db = Factory::getDBO();

			$query = $db->getQuery(true)
				->select('count(*)')
				->from('#__jfusion')
				->where('original_name IS NULL')
				->where('name LIKE ' . $db->quote($name));

			$db->setQuery($query);
			$record = $db->loadResult();

			$query = $db->getQuery(true)
				->select('id')
				->from('#__jfusion')
				->where('name = ' . $db->quote($new_name));

			$db->setQuery($query);
			$exsist = $db->loadResult();
			if ($exsist) {
				throw new RuntimeException($new_name . ' ' . Text::_('ALREADY_IN_USE'));
			} else if ($record) {
				$JFusionPlugin = Factory::getAdmin($name);
				if ($JFusionPlugin->multiInstance()) {
					$db = Factory::getDBO();
					if (!$update) {
						//add the new entry in the JFusion plugin table
						$query = $db->getQuery(true)
							->select('*')
							->from('#__jfusion')
							->where('name = ' . $db->quote($name));

						$db->setQuery($query);
						$plugin_entry = $db->loadObject();
						$plugin_entry->name = $new_name;
						$plugin_entry->id = null;
						//only change the original name if this is not a copy itself
						if (empty($plugin_entry->original_name)) {
							$plugin_entry->original_name = $name;
						}
						$db->insertObject('#__jfusion', $plugin_entry, 'id');
					}
					$result['message'] = $new_name . ': ' . Text::_('PLUGIN') . ' ' . $name . ' ' . Text::_('COPY') . ' ' . Text::_('SUCCESS');
					$result['status'] = true;
				} else {
					throw new RuntimeException(Text::_('CANT_COPY'));
				}
			} else {
				throw new RuntimeException(Text::_('INVALID_SELECTED'));
			}
		} else {
			throw new RuntimeException(Text::_('NONE_SELECTED'));
		}
		return $result;
	}
function copy ( $ name , $ new_name , $ update = false ) { //replace not-allowed characters with _ $ new_name = preg_replace ( '/([^a-zA-Z0-9_])/' , '_' , $ new_name ) ; //initialise response element $ result = array ( ) ; $ result [ 'status' ] = false ; if ( $ name && $ new_name ) { //check to see if an integration was selected $ db = Factory :: getDBO ( ) ; $ query = $ db -> getQuery ( true ) -> select ( 'count(*)' ) -> from ( '#__jfusion' ) -> where ( 'original_name IS NULL' ) -> where ( 'name LIKE ' . $ db -> quote ( $ name ) ) ; $ db -> setQuery ( $ query ) ; $ record = $ db -> loadResult ( ) ; $ query = $ db -> getQuery ( true ) -> select ( 'id' ) -> from ( '#__jfusion' ) -> where ( 'name = ' . $ db -> quote ( $ new_name ) ) ; $ db -> setQuery ( $ query ) ; $ exsist = $ db -> loadResult ( ) ; if ( $ exsist ) { throw new RuntimeException ( $ new_name . ' ' . Text :: _ ( 'ALREADY_IN_USE' ) ) ; } else if ( $ record ) { $ JFusionPlugin = Factory :: getAdmin ( $ name ) ; if ( $ JFusionPlugin -> multiInstance ( ) ) { $ db = Factory :: getDBO ( ) ; if ( ! $ update ) { //add the new entry in the JFusion plugin table $ query = $ db -> getQuery ( true ) -> select ( '*' ) -> from ( '#__jfusion' ) -> where ( 'name = ' . $ db -> quote ( $ name ) ) ; $ db -> setQuery ( $ query ) ; $ plugin_entry = $ db -> loadObject ( ) ; $ plugin_entry -> name = $ new_name ; $ plugin_entry -> id = null ; //only change the original name if this is not a copy itself if ( empty ( $ plugin_entry -> original_name ) ) { $ plugin_entry -> original_name = $ name ; } $ db -> insertObject ( '#__jfusion' , $ plugin_entry , 'id' ) ; } $ result [ 'message' ] = $ new_name . ': ' . Text :: _ ( 'PLUGIN' ) . ' ' . $ name . ' ' . Text :: _ ( 'COPY' ) . ' ' . Text :: _ ( 'SUCCESS' ) ; $ result [ 'status' ] = true ; } else { throw new RuntimeException ( Text :: _ ( 'CANT_COPY' ) ) ; } } else { throw new RuntimeException ( Text :: _ ( 'INVALID_SELECTED' ) ) ; } } else { throw new RuntimeException ( Text :: _ ( 'NONE_SELECTED' ) ) ; } return $ result ; }
handles copying JFusion plugins

@param string  $name     name of the JFusion plugin used
@param string  $new_name name of the copied plugin
@param boolean $update    mark if we updating a copied plugin

@throws RuntimeException
@return boolean
handles copying JFusion plugins