public function addModuleEntry($element, $enabled=1, $params='', $client=0)
	{
		if ($this->baseDb->tableExists('#__extensions'))
		{
			$name = $element;

			// First, make sure it isn't already there
			$query = "SELECT `extension_id` FROM `#__extensions` WHERE `name` = " . $this->baseDb->quote($name);
			$this->baseDb->setQuery($query);
			if ($this->baseDb->loadResult())
			{
				$this->log(sprintf('Extension entry already exists for module "%s"', $element));
				return true;
			}

			$ordering = 0;

			if (!empty($params) && is_array($params))
			{
				$params = json_encode($params);
			}

			$query = "INSERT INTO `#__extensions` (`name`, `type`, `element`, `folder`, `client_id`, `enabled`, `access`, `protected`, `manifest_cache`, `params`, `custom_data`, `system_data`, `checked_out`, `ordering`, `state`)";
			$query .= " VALUES ('{$name}', 'module', '{$element}', '', {$client}, {$enabled}, 1, 0, '', ".$this->baseDb->quote($params).", '', '', 0, {$ordering}, 0)";
			$this->baseDb->setQuery($query);
			$this->baseDb->query();

			$this->log(sprintf('Added extension entry for module "%s"', $element));

			return true;
		}

		$this->log(sprintf('Required table not found for adding module "%s"', $element), 'warning');

		return false;
	}
public function addModuleEntry($element, $enabled=1, $params='', $client=0)
	{
		if ($this->baseDb->tableExists('#__extensions'))
		{
			$name = $element;

			// First, make sure it isn't already there
			$query = "SELECT `extension_id` FROM `#__extensions` WHERE `name` = " . $this->baseDb->quote($name);
			$this->baseDb->setQuery($query);
			if ($this->baseDb->loadResult())
			{
				$this->log(sprintf('Extension entry already exists for module "%s"', $element));
				return true;
			}

			$ordering = 0;

			if (!empty($params) && is_array($params))
			{
				$params = json_encode($params);
			}

			$query = "INSERT INTO `#__extensions` (`name`, `type`, `element`, `folder`, `client_id`, `enabled`, `access`, `protected`, `manifest_cache`, `params`, `custom_data`, `system_data`, `checked_out`, `ordering`, `state`)";
			$query .= " VALUES ('{$name}', 'module', '{$element}', '', {$client}, {$enabled}, 1, 0, '', ".$this->baseDb->quote($params).", '', '', 0, {$ordering}, 0)";
			$this->baseDb->setQuery($query);
			$this->baseDb->query();

			$this->log(sprintf('Added extension entry for module "%s"', $element));

			return true;
		}

		$this->log(sprintf('Required table not found for adding module "%s"', $element), 'warning');

		return false;
	}
public function addModuleEntry ( $ element , $ enabled = 1 , $ params = '' , $ client = 0 ) { if ( $ this -> baseDb -> tableExists ( '#__extensions' ) ) { $ name = $ element ; // First, make sure it isn't already there $ query = "SELECT `extension_id` FROM `#__extensions` WHERE `name` = " . $ this -> baseDb -> quote ( $ name ) ; $ this -> baseDb -> setQuery ( $ query ) ; if ( $ this -> baseDb -> loadResult ( ) ) { $ this -> log ( sprintf ( 'Extension entry already exists for module "%s"' , $ element ) ) ; return true ; } $ ordering = 0 ; if ( ! empty ( $ params ) && is_array ( $ params ) ) { $ params = json_encode ( $ params ) ; } $ query = "INSERT INTO `#__extensions` (`name`, `type`, `element`, `folder`, `client_id`, `enabled`, `access`, `protected`, `manifest_cache`, `params`, `custom_data`, `system_data`, `checked_out`, `ordering`, `state`)" ; $ query .= " VALUES ('{$name}', 'module', '{$element}', '', {$client}, {$enabled}, 1, 0, '', " . $ this -> baseDb -> quote ( $ params ) . ", '', '', 0, {$ordering}, 0)" ; $ this -> baseDb -> setQuery ( $ query ) ; $ this -> baseDb -> query ( ) ; $ this -> log ( sprintf ( 'Added extension entry for module "%s"' , $ element ) ) ; return true ; } $ this -> log ( sprintf ( 'Required table not found for adding module "%s"' , $ element ) , 'warning' ) ; return false ; }
Add, as needed, the module entry to the appropriate table, depending on the CMS version

@param   string  $element  Plugin element
@param   int     $enabled  Whether or not the plugin should be enabled
@param   array   $params   Plugin params (if already known)
@param   int     $client   Client (site=0, admin=1)
@return  bool
Add as needed the module entry to the appropriate table depending on the CMS version