Example #1
0
 /**
  * Called after any type of action
  *
  * @param   string  $route  Which action is happening (install|uninstall|discover_install)
  * @param   JAdapterInstance  $adapter  The object responsible for running this script
  *
  * @return  boolean  True on success
  */
 public function postflight($route, JAdapterInstance $adapter)
 {
     if ($route == 'install' or $route == 'update') {
         com_install();
     }
     if ($route == 'uninstall') {
         com_uninstall();
     }
 }
Example #2
0
 /**
  * Called on installation
  *
  * @param   JAdapterInstance  $adapter  The object responsible for running this script
  *
  * @return  boolean  True on success
  */
 public function install($adapter)
 {
     $adminpath = JPATH_SITE . '/administrator/components/com_extplorer';
     com_install($adminpath);
     if (JVersion::isCompatible('3.0')) {
         rename($adminpath . '/extplorer.j30.php', $adminpath . '/extplorer.php');
     }
     return true;
 }
 public function postflight($action, $installer)
 {
     switch ($action) {
         case "install":
         case "update":
             include_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_simplelists' . DS . 'install.simplelists.php';
             if (function_exists('com_install')) {
                 com_install();
             }
             break;
     }
 }
 public function postflight($action, $installer)
 {
     switch ($action) {
         case 'install':
         case 'update':
             include_once JPATH_ADMINISTRATOR . '/components/com_simplelists/install.simplelists.php';
             if (function_exists('com_install')) {
                 // @todo: Removed in Joomla! 3.0
                 com_install();
             }
             // Remove obsolete files
             $files = array(JPATH_ADMINISTRATOR . '/components/com_simplelists/views/home/tmpl/default.php', JPATH_ADMINISTRATOR . '/components/com_simplelists/views/home/tmpl/default_ads.php', JPATH_ADMINISTRATOR . '/components/com_simplelists/views/home/tmpl/default_cpanel.php', JPATH_ADMINISTRATOR . '/components/com_simplelists/views/home/tmpl/feeds.php');
             foreach ($files as $file) {
                 if (file_exists($file)) {
                     @unlink($file);
                 }
             }
             break;
     }
 }
Example #5
0
 /**
  * Custom install method
  *
  * @access	public
  * @return	boolean	True on success
  * @since	1.5
  * Minor alteration - see below
  */
 function install()
 {
     // Get a database connector object
     $db =& $this->parent->getDBO();
     // Get the extension manifest object
     $manifest =& $this->parent->getManifest();
     $this->manifest =& $manifest->document;
     /**
      * ---------------------------------------------------------------------------------------------
      * Manifest Document Setup Section
      * ---------------------------------------------------------------------------------------------
      */
     // Set the plugin name
     $name =& $this->manifest->getElementByPath('name');
     $this->set('name', $name->data());
     // Get the plugin description
     $description =& $this->manifest->getElementByPath('description');
     if (is_a($description, 'JSimpleXMLElement')) {
         $this->parent->set('message', $description->data());
     } else {
         $this->parent->set('message', '');
     }
     $element =& $this->manifest->getElementByPath('files');
     // Plugin name is specified
     $plugin = $this->manifest->attributes('plugin');
     if (!empty($plugin)) {
         $this->parent->setPath('extension_root', JPATH_PLUGINS . DS . 'editors' . DS . 'jce' . DS . 'tiny_mce' . DS . 'plugins' . DS . $plugin);
     } else {
         $this->parent->abort('Extension Install: ' . JText::_('No JCE Plugin file specified'));
         return false;
     }
     /**
      * ---------------------------------------------------------------------------------------------
      * Filesystem Processing Section
      * ---------------------------------------------------------------------------------------------
      */
     // If the extension directory does not exist, lets create it
     $created = false;
     if (!file_exists($this->parent->getPath('extension_root'))) {
         if (!($created = JFolder::create($this->parent->getPath('extension_root')))) {
             $this->parent->abort('Plugin Install: ' . JText::_('Failed to create directory') . ': "' . $this->parent->getPath('extension_root') . '"');
             return false;
         }
     }
     // Set overwrite flag if not set by Manifest
     $this->parent->setOverwrite(true);
     /*
      * If we created the extension directory and will want to remove it if we
      * have to roll back the installation, lets add it to the installation
      * step stack
      */
     if ($created) {
         $this->parent->pushStep(array('type' => 'folder', 'path' => $this->parent->getPath('extension_root')));
     }
     // Copy all necessary files
     if ($this->parent->parseFiles($element, -1) === false) {
         // Install failed, roll back changes
         $this->parent->abort();
         return false;
     }
     // Parse optional tags -- language files for plugins
     $this->parent->parseLanguages($this->manifest->getElementByPath('languages'), 0);
     // If there is an install file, lets copy it.
     $installScriptElement =& $this->manifest->getElementByPath('installfile');
     if (is_a($installScriptElement, 'JSimpleXMLElement')) {
         // Make sure it hasn't already been copied (this would be an error in the xml install file)
         if (!file_exists($this->parent->getPath('extension_root') . DS . $installScriptElement->data())) {
             $path['src'] = $this->parent->getPath('source') . DS . $installScriptElement->data();
             $path['dest'] = $this->parent->getPath('extension_root') . DS . $installScriptElement->data();
             if (!$this->parent->copyFiles(array($path))) {
                 // Install failed, rollback changes
                 $this->parent->abort(JText::_('Component') . ' ' . JText::_('Install') . ': ' . JText::_('Could not copy PHP install file.'));
                 return false;
             }
         }
         $this->set('install.script', $installScriptElement->data());
     }
     // If there is an uninstall file, lets copy it.
     $uninstallScriptElement =& $this->manifest->getElementByPath('uninstallfile');
     if (is_a($uninstallScriptElement, 'JSimpleXMLElement')) {
         // Make sure it hasn't already been copied (this would be an error in the xml install file)
         if (!file_exists($this->parent->getPath('extension_root') . DS . $uninstallScriptElement->data())) {
             $path['src'] = $this->parent->getPath('source') . DS . $uninstallScriptElement->data();
             $path['dest'] = $this->parent->getPath('extension_root') . DS . $uninstallScriptElement->data();
             if (!$this->parent->copyFiles(array($path))) {
                 // Install failed, rollback changes
                 $this->parent->abort(JText::_('Component') . ' ' . JText::_('Install') . ': ' . JText::_('Could not copy PHP uninstall file.'));
                 return false;
             }
         }
     }
     /**
      * ---------------------------------------------------------------------------------------------
      * Database Processing Section
      * ---------------------------------------------------------------------------------------------
      */
     // Check to see if a plugin by the same name is already installed
     $query = 'SELECT id' . ' FROM #__jce_plugins' . ' WHERE name = ' . $db->Quote($plugin);
     $db->setQuery($query);
     if (!$db->Query()) {
         // Install failed, roll back changes
         $this->parent->abort('Plugin Install: ' . $db->stderr(true));
         return false;
     }
     $id = $db->loadResult();
     $row =& JTable::getInstance('plugin', 'JCETable');
     if ($id) {
         if (!$this->parent->getOverwrite()) {
             // Install failed, roll back changes
             $this->parent->abort('Plugin Install: ' . JText::_('Plugin') . ' "' . $plugin . '" ' . JText::_('already exists!'));
             return false;
         } else {
             $row->load($id);
         }
     }
     $icon = $this->manifest->getElementByPath('icon');
     $layout = $this->manifest->getElementByPath('layout');
     $row->title = $this->get('name');
     $row->name = $this->manifest->attributes('plugin');
     $row->type = 'plugin';
     $row->row = 4;
     $row->ordering = 1;
     $row->published = 1;
     $row->editable = 1;
     $row->icon = $icon->data();
     $row->layout = $layout->data();
     $row->iscore = 0;
     if (!$row->store()) {
         // Install failed, roll back changes
         $this->parent->abort('Plugin Install: ' . $db->stderr(true));
         return false;
     }
     // Process default extension installation (files are assumed to have been copied!)
     $element =& $this->manifest->getElementByPath('extensions');
     if (is_a($element, 'JSimpleXMLElement') && count($element->children())) {
         $extensions =& $element->children();
         foreach ($extensions as $extension) {
             if ($extension->attributes('name')) {
                 $query = 'INSERT INTO `#__jce_extensions` ' . ' VALUES ("", ' . (int) $row->id . ', ' . $db->Quote($extension->attributes('title')) . ', ' . $db->Quote($extension->attributes('name')) . ', ' . $db->Quote($extension->attributes('folder')) . ', 1 )';
                 $db->setQuery($query);
                 if (!$db->query()) {
                     // Install failed, raise error
                     JError::raiseWarning(100, 'Plugin Install: Unable to install default extension ' . $extension->attributes('title'));
                     return false;
                 }
             }
         }
     }
     // Since we have created a plugin item, we add it to the installation step stack
     // so that if we have to rollback the changes we can undo it.
     $this->parent->pushStep(array('type' => 'plugin', 'id' => $row->id));
     /**
      * ---------------------------------------------------------------------------------------------
      * Install plugin into Default Group
      * ---------------------------------------------------------------------------------------------
      */
     // Add to Default Group
     if ($row->type == 'plugin') {
         JTable::addIncludePath(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_jce' . DS . 'groups');
         $group =& JTable::getInstance('groups', 'JCETable');
         $query = 'SELECT id' . ' FROM #__jce_groups' . ' WHERE name = ' . $db->Quote('Default');
         $db->setQuery($query);
         $gid = $db->loadResult();
         $group->load($gid);
         // Add to plugins list
         $plugins = explode(',', $group->plugins);
         if (!in_array($row->id, explode(',', $group->plugins))) {
             $group->plugins .= ',' . $row->id;
         }
         // Add to last row if plugin has a layout icon
         if ($row->layout) {
             if (!in_array($row->id, preg_split('/[;,]+/', $group->rows))) {
                 $group->rows .= ',' . $row->id;
             }
         }
         if (!$group->store()) {
             JError::raiseWarning(100, 'Plugin Install: Unable to add plugin to Default group');
         }
     }
     /**
      * ---------------------------------------------------------------------------------------------
      * Finalization and Cleanup Section
      * ---------------------------------------------------------------------------------------------
      */
     // Lastly, we will copy the manifest file to its appropriate place.
     if (!$this->parent->copyManifest(-1)) {
         // Install failed, rollback changes
         $this->parent->abort('Plugin Install: ' . JText::_('Could not copy setup file'));
         return false;
     }
     /*
      * If we have an install script, lets include it, execute the custom
      * install method, and append the return value from the custom install
      * method to the installation message.
      */
     if ($this->get('install.script')) {
         if (is_file($this->parent->getPath('extension_root') . DS . $this->get('install.script'))) {
             ob_start();
             ob_implicit_flush(false);
             require_once $this->parent->getPath('extension_root') . DS . $this->get('install.script');
             if (function_exists('jce_install')) {
                 if (jce_install() === false) {
                     $this->parent->abort(JText::_('Plugin') . ' ' . JText::_('Install') . ': ' . JText::_('Custom install routine failure'));
                     return false;
                 }
             } else {
                 if (function_exists('com_install')) {
                     if (com_install() === false) {
                         $this->parent->abort(JText::_('Plugin') . ' ' . JText::_('Install') . ': ' . JText::_('Custom install routine failure'));
                         return false;
                     }
                 }
             }
             $msg = ob_get_contents();
             ob_end_clean();
             if ($msg != '') {
                 $this->parent->set('extension.message', $msg);
             }
         }
     }
     return true;
 }
Example #6
0
 /**
  * Custom install method
  * @param boolean True if installing from directory
  */
 function install($p_fromdir = null)
 {
     global $mosConfig_absolute_path, $database;
     if (!$this->preInstallCheck($p_fromdir, 'component')) {
         return false;
     }
     // aje moved down to here. ??  seemed to be some referencing problems
     $xml = $this->xmlDoc();
     // Set some vars
     $e =& $xml->getElementsByPath('name', 1);
     $this->elementName($e->getText());
     $this->elementDir(mosPathName($mosConfig_absolute_path . "/components/" . strtolower("com_" . str_replace(" ", "", $this->elementName())) . "/"));
     $this->componentAdminDir(mosPathName($mosConfig_absolute_path . "/administrator/components/" . strtolower("com_" . str_replace(" ", "", $this->elementName()))));
     if (file_exists($this->elementDir())) {
         $this->setError(1, 'Another component is already using directory: "' . $this->elementDir() . '"');
         return false;
     }
     if (!file_exists($this->elementDir()) && !mkdir($this->elementDir(), 0777)) {
         $this->setError(1, 'Failed to create directory "' . $this->elementDir() . '"');
         return false;
     }
     if (!file_exists($this->componentAdminDir()) && !mkdir($this->componentAdminDir(), 0777)) {
         $this->setError(1, 'Failed to create directory "' . $this->componentAdminDir() . '"');
         return false;
     }
     // Find files to copy
     if ($this->parseFiles('files') === false) {
         return false;
     }
     $this->parseFiles('images');
     $this->parseFiles('administration/files', '', '', 1);
     $this->parseFiles('administration/images', '', '', 1);
     // Are there any SQL queries??
     $query_element =& $xml->getElementsByPath('install/queries', 1);
     if (!is_null($query_element)) {
         $queries = $query_element->childNodes;
         foreach ($queries as $query) {
             $database->setQuery($query->getText());
             if (!$database->query()) {
                 $this->setError(1, "SQL Error " . $database->stderr(true));
                 return false;
             }
         }
     }
     // Is there an installfile
     $installfile_elemet =& $xml->getElementsByPath('installfile', 1);
     if (!is_null($installfile_elemet)) {
         // check if parse files has already copied the install.component.php file (error in 3rd party xml's!)
         if (!file_exists($this->componentAdminDir() . $installfile_elemet->getText())) {
             if (!$this->copyFiles($this->installDir(), $this->componentAdminDir(), array($installfile_elemet->getText()))) {
                 $this->setError(1, 'Could not copy PHP install file.');
                 return false;
             }
         }
         $this->hasInstallfile(true);
         $this->installFile($installfile_elemet->getText());
     }
     // Is there an uninstallfile
     $uninstallfile_elemet =& $xml->getElementsByPath('uninstallfile', 1);
     if (!is_null($uninstallfile_elemet)) {
         if (!file_exists($this->componentAdminDir() . $uninstallfile_elemet->getText())) {
             if (!$this->copyFiles($this->installDir(), $this->componentAdminDir(), array($uninstallfile_elemet->getText()))) {
                 $this->setError(1, 'Could not copy PHP uninstall file');
                 return false;
             }
         }
     }
     // Is the menues ?
     $adminmenu_element =& $xml->getElementsByPath('administration/menu', 1);
     if (!is_null($adminmenu_element)) {
         $adminsubmenu_element =& $xml->getElementsByPath('administration/submenu', 1);
         $com_name = strtolower("com_" . str_replace(" ", "", $this->elementName()));
         $com_admin_menuname = $adminmenu_element->getText();
         if (!is_null($adminsubmenu_element)) {
             $com_admin_menu_id = $this->createParentMenu($com_admin_menuname, $com_name);
             if ($com_admin_menu_id === false) {
                 return false;
             }
             $com_admin_submenus = $adminsubmenu_element->childNodes;
             $submenuordering = 0;
             foreach ($com_admin_submenus as $admin_submenu) {
                 $com = new mosComponent($database);
                 $com->name = $admin_submenu->getText();
                 $com->link = '';
                 $com->menuid = 0;
                 $com->parent = $com_admin_menu_id;
                 $com->iscore = 0;
                 if ($admin_submenu->getAttribute("act")) {
                     $com->admin_menu_link = "option={$com_name}&act=" . $admin_submenu->getAttribute("act");
                 } else {
                     if ($admin_submenu->getAttribute("task")) {
                         $com->admin_menu_link = "option={$com_name}&task=" . $admin_submenu->getAttribute("task");
                     } else {
                         if ($admin_submenu->getAttribute("link")) {
                             $com->admin_menu_link = $admin_submenu->getAttribute("link");
                         } else {
                             $com->admin_menu_link = "option={$com_name}";
                         }
                     }
                 }
                 $com->admin_menu_alt = $admin_submenu->getText();
                 $com->option = $com_name;
                 $com->ordering = $submenuordering++;
                 $com->admin_menu_img = "js/ThemeOffice/component.png";
                 if (!$com->store()) {
                     $this->setError(1, $database->stderr(true));
                     return false;
                 }
             }
         } else {
             $this->createParentMenu($com_admin_menuname, $com_name);
         }
     }
     $desc = '';
     if ($e =& $xml->getElementsByPath('description', 1)) {
         $desc = $this->elementName() . '<p>' . $e->getText() . '</p>';
     }
     $this->setError(0, $desc);
     if ($this->hasInstallfile()) {
         require_once $this->componentAdminDir() . "/" . $this->installFile();
         $ret = com_install();
         if ($ret != '') {
             $this->setError(0, $desc . $ret);
         }
     }
     return $this->copySetupFile();
 }
Example #7
0
 /**
  * Upgrade database schema
  */
 function upgrade()
 {
     require_once JPATH_COMPONENT . '/install.osmembership.php';
     com_install();
 }
 /**
  * Install method
  *
  * @access  public
  * @return  boolean True on success
  */
 public function install()
 {
     // Get a database connector object
     $db = $this->parent->getDBO();
     // Get the extension manifest object
     $manifest = $this->parent->getManifest();
     // setup manifest data
     $this->setManifest($manifest);
     $this->parent->set('name', $this->get('name'));
     $this->parent->set('version', $this->get('version'));
     $this->parent->set('message', $this->get('description'));
     $plugin = $this->get('plugin');
     $group = $this->get('group');
     $type = $this->get('type');
     // JCE Plugin
     if (!empty($plugin)) {
         if (version_compare($this->get('version'), '2.0.0', '<')) {
             $this->parent->abort(WFText::_('WF_INSTALLER_INCORRECT_VERSION'));
             return false;
         }
         $this->parent->setPath('extension_root', JPATH_COMPONENT_SITE . DS . 'editor' . DS . 'tiny_mce' . DS . 'plugins' . DS . $plugin);
     } else {
         // Non-JCE plugin type, probably JCE MediaBox or JCE Editor
         if ($type == 'plugin' && ($group == 'system' || $group == 'editors')) {
             require_once JPATH_LIBRARIES . DS . 'joomla' . DS . 'installer' . DS . 'adapters' . DS . 'plugin.php';
             $adapter = new JInstallerPlugin($this->parent, $db);
             $this->parent->setAdapter('plugin', $adapter);
             return $adapter->install();
         } else {
             $this->parent->abort(WFText::_('WF_INSTALLER_EXTENSION_INSTALL') . ' : ' . WFText::_('WF_INSTALLER_NO_PLUGIN_FILE'));
             return false;
         }
     }
     /**
      * ---------------------------------------------------------------------------------------------
      * Filesystem Processing Section
      * ---------------------------------------------------------------------------------------------
      */
     // If the extension directory does not exist, lets create it
     $created = false;
     if (!file_exists($this->parent->getPath('extension_root'))) {
         if (!($created = JFolder::create($this->parent->getPath('extension_root')))) {
             $this->parent->abort(WFText::_('WF_INSTALLER_PLUGIN_INSTALL') . ' : ' . WFText::_('WF_INSTALLER_MKDIR_ERROR') . ' : "' . $this->parent->getPath('extension_root') . '"');
             return false;
         }
     }
     // Set overwrite flag if not set by Manifest
     $this->parent->setOverwrite(true);
     /*
      * If we created the extension directory and will want to remove it if we
      * have to roll back the installation, lets add it to the installation
      * step stack
      */
     if ($created) {
         $this->parent->pushStep(array('type' => 'folder', 'path' => $this->parent->getPath('extension_root')));
     }
     // Copy all necessary files
     if (!$this->parent->parseFiles($this->get('files'), -1)) {
         // Install failed, roll back changes
         $this->parent->abort();
         return false;
     }
     // install languages
     $this->parent->parseLanguages($this->get('languages'), 0);
     // install media
     $this->parent->parseMedia($this->get('media'), 0);
     // Load the language file
     $language = JFactory::getLanguage();
     $language->load('com_jce_' . trim($plugin), JPATH_SITE);
     $install = $this->get('install.script');
     if ($install) {
         // Make sure it hasn't already been copied (this would be an error in the xml install file)
         if (!file_exists($this->parent->getPath('extension_root') . DS . $install)) {
             $path['src'] = $this->parent->getPath('source') . DS . $install;
             $path['dest'] = $this->parent->getPath('extension_root') . DS . $install;
             if (!$this->parent->copyFiles(array($path))) {
                 // Install failed, rollback changes
                 $this->parent->abort(JText('WF_INSTALLER_PLUGIN_INSTALL') . ' : ' . WFText::_('WF_INSTALLER_PHP_INSTALL_FILE_ERROR'));
                 return false;
             }
         }
     }
     $uninstall = $this->get('uninstall.script');
     if ($uninstall) {
         // Make sure it hasn't already been copied (this would be an error in the xml install file)
         if (!file_exists($this->parent->getPath('extension_root') . DS . $uninstall)) {
             $path['src'] = $this->parent->getPath('source') . DS . $uninstall;
             $path['dest'] = $this->parent->getPath('extension_root') . DS . $uninstall;
             if (!$this->parent->copyFiles(array($path))) {
                 // Install failed, rollback changes
                 $this->parent->abort(JText('WF_INSTALLER_PLUGIN_INSTALL') . ' : ' . WFText::_('WF_INSTALLER_PHP_UNINSTALL_FILE_ERROR'));
                 return false;
             }
         }
     }
     // Install plugin install default profile layout if a row is set
     if (is_numeric($this->get('row')) && intval($this->get('row'))) {
         // Add to Default Group
         $profile = JTable::getInstance('profiles', 'WFTable');
         $query = 'SELECT id' . ' FROM #__wf_profiles' . ' WHERE name = ' . $db->Quote('Default');
         $db->setQuery($query);
         $id = $db->loadResult();
         $profile->load($id);
         // Add to plugins list
         $plugins = explode(',', $profile->plugins);
         if (!in_array($this->get('plugin'), $plugins)) {
             $plugins[] = $this->get('plugin');
         }
         $profile->plugins = implode(',', $plugins);
         if ($this->get('icon')) {
             if (!in_array($this->get('plugin'), preg_split('/[;,]+/', $profile->rows))) {
                 // get rows as array
                 $rows = explode(';', $profile->rows);
                 // get key (row number)
                 $key = intval($this->get('row')) - 1;
                 // get row contents as array
                 $row = explode(',', $rows[$key]);
                 // add plugin name to end of row
                 $row[] = $this->get('plugin');
                 // add row data back to rows array
                 $rows[$key] = implode(',', $row);
                 $profile->rows = implode(';', $rows);
             }
         }
         if (!$profile->store()) {
             JError::raiseWarning(100, 'WF_INSTALLER_PLUGIN_PROFILE_ERROR');
         }
     }
     /**
      * ---------------------------------------------------------------------------------------------
      * Finalization and Cleanup Section
      * ---------------------------------------------------------------------------------------------
      */
     // Lastly, we will copy the manifest file to its appropriate place.
     if (!$this->parent->copyManifest(-1)) {
         // Install failed, rollback changes
         $this->parent->abort(WFText::_('WF_INSTALLER_PLUGIN_INSTALL') . ' : ' . WFText::_('WF_INSTALLER_SETUP_COPY_ERROR'));
         return false;
     }
     /*
      * If we have an install script, lets include it, execute the custom
      * install method, and append the return value from the custom install
      * method to the installation message.
      */
     $install = $this->get('install.script');
     if ($install) {
         if (file_exists($this->parent->getPath('extension_root') . DS . $install)) {
             ob_start();
             ob_implicit_flush(false);
             require_once $this->parent->getPath('extension_root') . DS . $install;
             if (function_exists('jce_install')) {
                 if (jce_install() === false) {
                     $this->parent->abort(WFText::_('WF_INSTALLER_PLUGIN_INSTALL') . ' : ' . WFText::_('WF_INSTALLER_CUSTOM_INSTALL_ERROR'));
                     return false;
                 }
             } else {
                 if (function_exists('com_install')) {
                     if (com_install() === false) {
                         $this->parent->abort(WFText::_('WF_INSTALLER_PLUGIN_INSTALL') . ' : ' . WFText::_('WF_INSTALLER_CUSTOM_INSTALL_ERROR'));
                         return false;
                     }
                 }
             }
             $msg = ob_get_contents();
             ob_end_clean();
             if ($msg != '') {
                 $this->parent->set('extension.message', $msg);
             }
         }
     } else {
         $this->parent->set('extension.message', '');
     }
     // post-install
     $this->addIndexfiles();
     return true;
 }
Example #9
0
 /**
  * Install method
  *
  * @access  public
  * @return  boolean True on success
  */
 public function install()
 {
     // Get a database connector object
     $db = $this->parent->getDBO();
     $this->setManifest();
     $plugin = $this->get('plugin');
     $group = $this->get('group');
     $type = $this->get('type');
     $folder = $this->get('folder');
     $extension = $this->get('extension');
     // JCE Plugin
     if (!empty($plugin) || !empty($extension)) {
         if (version_compare((string) $this->get('version'), '2.0', '<')) {
             $this->parent->abort(WFText::_('WF_INSTALLER_INCORRECT_VERSION'));
             return false;
         }
         // its an "extension"
         if ($extension) {
             $this->parent->setPath('extension_root', JPATH_COMPONENT_SITE . '/editor/extensions/' . $folder);
         } else {
             $this->parent->setPath('extension_root', JPATH_COMPONENT_SITE . '/editor/tiny_mce/plugins/' . $plugin);
         }
     } else {
         // Non-JCE plugin type, probably JCE MediaBox
         if ($type == 'plugin' && $group == 'system') {
             require_once JPATH_LIBRARIES . '/joomla/installer/adapters/plugin.php';
             // create adapter
             $adapter = new JInstallerPlugin($this->parent, $db);
             if (method_exists($adapter, 'loadLanguage')) {
                 $adapter->loadLanguage($this->parent->getPath('source'));
             }
             // set adapter
             $this->parent->setAdapter('plugin', $adapter);
             // isntall
             return $adapter->install();
         } else {
             $this->parent->abort(WFText::_('WF_INSTALLER_EXTENSION_INSTALL') . ' : ' . WFText::_('WF_INSTALLER_NO_PLUGIN_FILE'));
             return false;
         }
     }
     /**
      * ---------------------------------------------------------------------------------------------
      * Filesystem Processing Section
      * ---------------------------------------------------------------------------------------------
      */
     // If the extension directory does not exist, lets create it
     $created = false;
     if (!file_exists($this->parent->getPath('extension_root'))) {
         if (!($created = JFolder::create($this->parent->getPath('extension_root')))) {
             $this->parent->abort(WFText::_('WF_INSTALLER_PLUGIN_INSTALL') . ' : ' . WFText::_('WF_INSTALLER_MKDIR_ERROR') . ' : "' . $this->parent->getPath('extension_root') . '"');
             return false;
         }
     }
     // Set overwrite flag if not set by Manifest
     $this->parent->setOverwrite(true);
     /*
      * If we created the extension directory and will want to remove it if we
      * have to roll back the installation, lets add it to the installation
      * step stack
      */
     if ($created) {
         $this->parent->pushStep(array('type' => 'folder', 'path' => $this->parent->getPath('extension_root')));
     }
     // Copy all necessary files
     if (!$this->parent->parseFiles($this->get('files'), -1)) {
         // Install failed, roll back changes
         $this->parent->abort();
         return false;
     }
     // install languages
     $this->parent->parseLanguages($this->get('languages'), 0);
     // install media
     $this->parent->parseMedia($this->get('media'), 0);
     // Load the language file
     $language = JFactory::getLanguage();
     $language->load('com_jce_' . trim($plugin), JPATH_SITE);
     $install = (string) $this->get('install.script');
     if ($install) {
         // Make sure it hasn't already been copied (this would be an error in the xml install file)
         if (!file_exists($this->parent->getPath('extension_root') . '/' . $install)) {
             $path['src'] = $this->parent->getPath('source') . '/' . $install;
             $path['dest'] = $this->parent->getPath('extension_root') . '/' . $install;
             if (!$this->parent->copyFiles(array($path))) {
                 // Install failed, rollback changes
                 $this->parent->abort(WFText::_('WF_INSTALLER_PLUGIN_INSTALL') . ' : ' . WFText::_('WF_INSTALLER_PHP_INSTALL_FILE_ERROR'));
                 return false;
             }
         }
     }
     $uninstall = $this->get('uninstall.script');
     if ($uninstall) {
         // Make sure it hasn't already been copied (this would be an error in the xml install file)
         if (!file_exists($this->parent->getPath('extension_root') . '/' . $uninstall)) {
             $path['src'] = $this->parent->getPath('source') . '/' . $uninstall;
             $path['dest'] = $this->parent->getPath('extension_root') . '/' . $uninstall;
             if (!$this->parent->copyFiles(array($path))) {
                 // Install failed, rollback changes
                 $this->parent->abort(JText('WF_INSTALLER_PLUGIN_INSTALL') . ' : ' . WFText::_('WF_INSTALLER_PHP_UNINSTALL_FILE_ERROR'));
                 return false;
             }
         }
     }
     /**
      * ---------------------------------------------------------------------------------------------
      * Finalization and Cleanup Section
      * ---------------------------------------------------------------------------------------------
      */
     // Lastly, we will copy the manifest file to its appropriate place.
     if (!$this->parent->copyManifest(-1)) {
         // Install failed, rollback changes
         $this->parent->abort(WFText::_('WF_INSTALLER_PLUGIN_INSTALL') . ' : ' . WFText::_('WF_INSTALLER_SETUP_COPY_ERROR'));
         return false;
     }
     if ($install) {
         if (file_exists($this->parent->getPath('extension_root') . '/' . $install)) {
             ob_start();
             ob_implicit_flush(false);
             require_once $this->parent->getPath('extension_root') . '/' . $install;
             if (function_exists('jce_install')) {
                 if (jce_install() === false) {
                     $this->parent->abort(WFText::_('WF_INSTALLER_PLUGIN_INSTALL') . ' : ' . WFText::_('WF_INSTALLER_CUSTOM_INSTALL_ERROR'));
                     return false;
                 }
             } else {
                 if (function_exists('com_install')) {
                     if (com_install() === false) {
                         $this->parent->abort(WFText::_('WF_INSTALLER_PLUGIN_INSTALL') . ' : ' . WFText::_('WF_INSTALLER_CUSTOM_INSTALL_ERROR'));
                         return false;
                     }
                 }
             }
             $msg = ob_get_contents();
             ob_end_clean();
             if ($msg != '') {
                 $this->parent->set('extension.message', $msg);
             }
         }
     } else {
         $this->parent->set('extension.message', '');
     }
     $plugin = new StdClass();
     $plugin->name = $this->get('plugin');
     $plugin->icon = $this->parent->get('icon');
     $plugin->row = (int) $this->get('row');
     $plugin->path = $this->parent->getPath('extension_root');
     $plugin->type = $type;
     wfimport('admin.models.plugins');
     $model = new WFModelPlugins();
     $model->postInstall('install', $plugin, $this);
     return true;
 }
 public function install($parent)
 {
     return com_install();
 }
Example #11
0
 /**
  * Custom install method
  *
  * @access	public
  * @return	boolean	True on success
  * @since	1.5
  * Minor alteration - see below
  */
 function install()
 {
     // Get a database connector object
     $db =& $this->parent->getDBO();
     // Get the extension manifest object
     $manifest =& $this->parent->getManifest();
     $this->manifest =& $manifest;
     //$manifest->document;
     /**
      * ---------------------------------------------------------------------------------------------
      * Manifest Document Setup Section
      * ---------------------------------------------------------------------------------------------
      */
     // Set the component name
     $name = '';
     if ($this->manifest->name) {
         $name = $this->manifest->name;
         $this->set('name', $name->data());
     } else {
         $this->set('name', '');
     }
     // Get the component description
     $description =& $this->manifest->description;
     if (is_a($description, 'JXMLElement')) {
         $this->parent->set('message', $description->data());
     } else {
         $this->parent->set('message', '');
     }
     $element =& $this->manifest->files;
     // Plugin name is specified
     $pname = (string) $this->manifest->attributes()->plugin;
     if (!empty($pname)) {
         // ^ Use JCK_PLUGINS defined path
         $this->parent->setPath('extension_root', JCK_PLUGINS . DS . $pname);
     } else {
         $this->parent->abort('Extension Install: ' . JText::_('No plugin specified'));
         return false;
     }
     if ((string) $manifest->scriptfile) {
         $manifestScript = (string) $manifest->scriptfile;
         $manifestScriptFile = $this->parent->getPath('source') . DS . $manifestScript;
         if (is_file($manifestScriptFile)) {
             // load the file
             include_once $manifestScriptFile;
         }
         // Set the class name
         $classname = 'plgJCK' . $pname . 'InstallerScript';
         if (class_exists($classname)) {
             // create a new instance
             $this->parent->manifestClass = new $classname($this);
             // and set this so we can copy it later
             $this->set('manifest_script', $manifestScript);
             // Note: if we don't find the class, don't bother to copy the file
         }
         // run preflight if possible
         ob_start();
         ob_implicit_flush(false);
         if ($this->parent->manifestClass && method_exists($this->parent->manifestClass, 'preflight')) {
             if ($this->parent->manifestClass->preflight('install', $this) === false) {
                 // Install failed, rollback changes
                 $this->parent->abort(JText::_('Installer abort for custom plugin install script'));
                 return false;
             }
         }
         ob_end_clean();
     }
     /**
      * ---------------------------------------------------------------------------------------------
      * Filesystem Processing Section
      * ---------------------------------------------------------------------------------------------
      */
     // If the extension directory does not exist, lets create it
     $created = false;
     if (!file_exists($this->parent->getPath('extension_root'))) {
         if (!($created = JFolder::create($this->parent->getPath('extension_root')))) {
             $this->parent->abort('Plugin Install: ' . JText::_('Failed to create directory') . ': "' . $this->parent->getPath('extension_root') . '"');
             return false;
         }
     }
     /*
      * If we created the extension directory and will want to remove it if we
      * have to roll back the installation, lets add it to the installation
      * step stack
      */
     if ($created) {
         $this->parent->pushStep(array('type' => 'folder', 'path' => $this->parent->getPath('extension_root')));
     }
     // Copy all necessary files
     if ($this->parent->parseFiles($element, -1) === false) {
         // Install failed, roll back changes
         $this->parent->abort();
         return false;
     }
     // Parse optional tags -- language files for plugins
     $this->parent->parseLanguages($this->manifest->languages, 0);
     // If there is an install file, lets copy it.
     $installScriptElement =& $this->manifest->installfile;
     if (is_a($installScriptElement, 'JXMLElement')) {
         // Make sure it hasn't already been copied (this would be an error in the xml install file)
         if (!file_exists($this->parent->getPath('extension_root') . DS . $installScriptElement->data())) {
             $path['src'] = $this->parent->getPath('source') . DS . $installScriptElement->data();
             $path['dest'] = $this->parent->getPath('extension_root') . DS . $installScriptElement->data();
             if (!$this->parent->copyFiles(array($path))) {
                 // Install failed, rollback changes
                 $this->parent->abort(JText::_('Component') . ' ' . JText::_('Install') . ': ' . JText::_('Could not copy PHP install file.'));
                 return false;
             }
         }
         $this->set('install.script', $installScriptElement->data());
     }
     // If there is an uninstall file, lets copy it.
     $uninstallScriptElement =& $this->manifest->uninstallfile;
     if (is_a($uninstallScriptElement, 'JXMLElement')) {
         // Make sure it hasn't already been copied (this would be an error in the xml install file)
         if (!file_exists($this->parent->getPath('extension_root') . DS . $uninstallScriptElement->data())) {
             $path['src'] = $this->parent->getPath('source') . DS . $uninstallScriptElpement->data();
             $path['dest'] = $this->parent->getPath('extension_root') . DS . $uninstallScriptElement->data();
             if (!$this->parent->copyFiles(array($path))) {
                 // Install failed, rollback changes
                 $this->parent->abort(JText::_('Component') . ' ' . JText::_('Install') . ': ' . JText::_('Could not copy PHP uninstall file.'));
                 return false;
             }
         }
     }
     /**
      * ---------------------------------------------------------------------------------------------
      * Database Processing Section
      * ---------------------------------------------------------------------------------------------
      */
     // Check to see if a plugin by the same name is already installed
     // ^ Altered db query for #__JCK_PLUGINS
     $query = 'SELECT `id`' . ' FROM `#__jckplugins`' . ' WHERE name = ' . $db->Quote($pname);
     $db->setQuery($query);
     if (!$db->Query()) {
         // Install failed, roll back changes
         $this->parent->abort('Plugin Install: ' . $db->stderr(true));
         return false;
     }
     $id = $db->loadResult();
     // Was there a module already installed with the same name?
     if ($id) {
         $row = JTable::getInstance('plugin', 'JCKTable');
         $row->load($id);
     } else {
         $icon = $this->manifest->icon;
         // ^ Changes to plugin parameters. Use JCK Plugins Table class.
         $row = JTable::getInstance('plugin', 'JCKTable');
         $row->title = $this->get('name');
         $row->name = $pname;
         $row->type = 'plugin';
         $row->row = 4;
         $row->published = 1;
         $row->editable = 1;
         $row->icon = $icon ? $icon->data() : '';
         $row->iscore = 0;
         $row->params = $this->parent->getParams();
         if ($this->manifest->attributes()->parent) {
             $parentName = (string) $this->manifest->attributes()->parent;
             $row->setParent($parentName);
         }
         if (!$row->store()) {
             // Install failed, roll back changes
             $this->parent->abort('Plugin Install: ' . $db->stderr(true));
             return false;
         }
         // Since we have created a plugin item, we add it to the installation step stack
         // so that if we have to rollback the changes we can undo it.
         $this->parent->pushStep(array('type' => 'plugin', 'id' => $row->id));
     }
     /* -------------------------------------------------------------------------------------------
      * update editor plugin config file    AW 
      * -------------------------------------------------------------------------------------------
      */
     $config = JCKHelper::getEditorPluginConfig();
     if ($config->getValue($pname, false) === false) {
         $config->setValue($pname, 1);
         $cfgFile = CKEDITOR_LIBRARY . DS . 'plugins' . DS . 'toolbarplugins.php';
         // Get the config registry in PHP class format and write it to configuation.php
         if (!JFile::write($cfgFile, $config->toString('PHP', array('class' => 'JCKToolbarPlugins extends JCKPlugins')))) {
             JError::raiseWarning(100, 'Failed to publish ' . $pname . ' jckeditor plugin');
         }
         $config = JCKHelper::getEditorPluginConfig();
     }
     /**
      * ---------------------------------------------------------------------------------------------
      * Custom Installation Script Section
      * ---------------------------------------------------------------------------------------------
      */
     /*
      * If we have an install script, lets include it, execute the custom
      * install method, and append the return value from the custom install
      * method to the installation message.
      */
     if ($this->get('install.script')) {
         if (is_file($this->parent->getPath('extension_root') . DS . $this->get('install.script'))) {
             ob_start();
             ob_implicit_flush(false);
             require_once $this->parent->getPath('extension_root') . DS . $this->get('install.script');
             if (function_exists('com_install')) {
                 if (com_install() === false) {
                     $this->parent->abort(JText::_('Plugin') . ' ' . JText::_('Install') . ': ' . JText::_('Custom install routine failure'));
                     return false;
                 }
             }
             $msg = ob_get_contents();
             ob_end_clean();
             if ($msg != '') {
                 $this->parent->set('extension.message', $msg);
             }
         }
     }
     /**
      * ---------------------------------------------------------------------------------------------
      * Finalization and Cleanup Section
      * ---------------------------------------------------------------------------------------------
      */
     // Lastly, we will copy the manifest file to its appropriate place.
     if (!$this->parent->copyManifest(-1)) {
         // Install failed, rollback changes
         $this->parent->abort('Plugin Install: ' . JText::_('Could not copy setup file'));
         return false;
     }
     // And now we run the postflight
     ob_start();
     ob_implicit_flush(false);
     if ($this->parent->manifestClass && method_exists($this->parent->manifestClass, 'postflight')) {
         $this->parent->manifestClass->postflight('install', $this);
     }
     ob_end_clean();
     return true;
 }
Example #12
0
 /**
  * Install unregistered extensions that have been discovered.
  *
  * @return  mixed
  *
  * @since   11.1
  */
 public function discover_install()
 {
     // Need to find to find where the XML file is since we don't store this normally
     $client = JApplicationHelper::getClientInfo($this->parent->extension->client_id);
     $short_element = str_replace('com_', '', $this->parent->extension->element);
     $manifestPath = $client->path . '/components/' . $this->parent->extension->element . '/' . $short_element . '.xml';
     $this->parent->manifest = $this->parent->isManifest($manifestPath);
     $this->parent->setPath('manifest', $manifestPath);
     $this->parent->setPath('source', $client->path . '/components/' . $this->parent->extension->element);
     $this->parent->setPath('extension_root', $this->parent->getPath('source'));
     $manifest_details = JApplicationHelper::parseXMLInstallFile($this->parent->getPath('manifest'));
     $this->parent->extension->manifest_cache = json_encode($manifest_details);
     $this->parent->extension->state = 0;
     $this->parent->extension->name = $manifest_details['name'];
     $this->parent->extension->enabled = 1;
     $this->parent->extension->params = $this->parent->getParams();
     try {
         $this->parent->extension->store();
     } catch (JException $e) {
         JError::raiseWarning(101, JText::_('JLIB_INSTALLER_ERROR_COMP_DISCOVER_STORE_DETAILS'));
         return false;
     }
     // now we need to run any SQL it has, languages, media or menu stuff
     // Get a database connector object
     $db = $this->parent->getDbo();
     // Get the extension manifest object
     $this->manifest = $this->parent->getManifest();
     /**
      * ---------------------------------------------------------------------------------------------
      * Manifest Document Setup Section
      * ---------------------------------------------------------------------------------------------
      */
     // Set the extensions name
     $name = strtolower(JFilterInput::getInstance()->clean((string) $this->manifest->name, 'cmd'));
     if (substr($name, 0, 4) == "com_") {
         $element = $name;
     } else {
         $element = "com_{$name}";
     }
     $this->set('name', $name);
     $this->set('element', $element);
     // Get the component description
     $description = (string) $this->manifest->description;
     if ($description) {
         $this->parent->set('message', JText::_((string) $description));
     } else {
         $this->parent->set('message', '');
     }
     // Set the installation target paths
     $this->parent->setPath('extension_site', JPath::clean(JPATH_SITE . '/components/' . $this->get('element')));
     $this->parent->setPath('extension_administrator', JPath::clean(JPATH_ADMINISTRATOR . '/components/' . $this->get('element')));
     $this->parent->setPath('extension_root', $this->parent->getPath('extension_administrator'));
     // copy this as its used as a common base
     /**
      * ---------------------------------------------------------------------------------------------
      * Basic Checks Section
      * ---------------------------------------------------------------------------------------------
      */
     // Make sure that we have an admin element
     if (!$this->manifest->administration) {
         JError::raiseWarning(1, JText::_('JLIB_INSTALLER_ERROR_COMP_INSTALL_ADMIN_ELEMENT'));
         return false;
     }
     /**
      * ---------------------------------------------------------------------------------------------
      * Installer Trigger Loading
      * ---------------------------------------------------------------------------------------------
      */
     // If there is an manifest class file, lets load it; we'll copy it later (don't have dest yet)
     $manifestScript = (string) $this->manifest->scriptfile;
     if ($manifestScript) {
         $manifestScriptFile = $this->parent->getPath('source') . '/' . $manifestScript;
         if (is_file($manifestScriptFile)) {
             // load the file
             include_once $manifestScriptFile;
         }
         // Set the class name
         $classname = $element . 'InstallerScript';
         if (class_exists($classname)) {
             // create a new instance
             $this->parent->manifestClass = new $classname($this);
             // and set this so we can copy it later
             $this->set('manifest_script', $manifestScript);
             // Note: if we don't find the class, don't bother to copy the file
         }
     }
     // Run preflight if possible (since we know we're not an update)
     ob_start();
     ob_implicit_flush(false);
     if ($this->parent->manifestClass && method_exists($this->parent->manifestClass, 'preflight')) {
         if ($this->parent->manifestClass->preflight('discover_install', $this) === false) {
             // Install failed, rollback changes
             $this->parent->abort(JText::_('JLIB_INSTALLER_ABORT_COMP_INSTALL_CUSTOM_INSTALL_FAILURE'));
             return false;
         }
     }
     $msg = ob_get_contents();
     // create msg object; first use here
     ob_end_clean();
     // Normally we would copy files and create directories, lets skip to the optional files
     // Note: need to dereference things!
     // Parse optional tags
     //$this->parent->parseMedia($this->manifest->media);
     // We don't do language because 1.6 suggests moving to extension based languages
     //$this->parent->parseLanguages($this->manifest->languages);
     //$this->parent->parseLanguages($this->manifest->administration->languages, 1);
     /**
      * ---------------------------------------------------------------------------------------------
      * Database Processing Section
      * ---------------------------------------------------------------------------------------------
      */
     /*
      * Let's run the install queries for the component
      *	If Joomla 1.5 compatible, with discreet sql files - execute appropriate
      *	file for utf-8 support or non-utf-8 support
      */
     // Try for Joomla 1.5 type queries
     // second argument is the utf compatible version attribute
     if (isset($this->manifest->install->sql)) {
         $utfresult = $this->parent->parseSQLFiles($this->manifest->install->sql);
         if ($utfresult === false) {
             // Install failed, rollback changes
             $this->parent->abort(JText::sprintf('JLIB_INSTALLER_ABORT_COMP_INSTALL_SQL_ERROR', $db->stderr(true)));
             return false;
         }
     }
     // Time to build the admin menus
     if (!$this->_buildAdminMenus($this->parent->extension->extension_id)) {
         JError::raiseWarning(100, JText::_('JLIB_INSTALLER_ABORT_COMP_BUILDADMINMENUS_FAILED'));
         //$this->parent->abort(JText::sprintf('JLIB_INSTALLER_ABORT_COMP_INSTALL_ROLLBACK', $db->stderr(true)));
         //return false;
     }
     /**
      * ---------------------------------------------------------------------------------------------
      * Custom Installation Script Section
      * ---------------------------------------------------------------------------------------------
      */
     /*
      * If we have an install script, lets include it, execute the custom
      * install method, and append the return value from the custom install
      * method to the installation message.
      */
     // start legacy support
     if ($this->get('install_script')) {
         if (is_file($this->parent->getPath('extension_administrator') . '/' . $this->get('install_script'))) {
             ob_start();
             ob_implicit_flush(false);
             require_once $this->parent->getPath('extension_administrator') . '/' . $this->get('install_script');
             if (function_exists('com_install')) {
                 if (com_install() === false) {
                     $this->parent->abort(JText::_('JLIB_INSTALLER_ABORT_COMP_INSTALL_CUSTOM_INSTALL_FAILURE'));
                     return false;
                 }
             }
             // Append messages
             $msg .= ob_get_contents();
             ob_end_clean();
         }
     }
     // End legacy support
     // Start Joomla! 1.6
     ob_start();
     ob_implicit_flush(false);
     if ($this->parent->manifestClass && method_exists($this->parent->manifestClass, 'install')) {
         if ($this->parent->manifestClass->install($this) === false) {
             // Install failed, rollback changes
             $this->parent->abort(JText::_('JLIB_INSTALLER_ABORT_COMP_INSTALL_CUSTOM_INSTALL_FAILURE'));
             return false;
         }
     }
     $msg .= ob_get_contents();
     // append messages
     ob_end_clean();
     /**
      * ---------------------------------------------------------------------------------------------
      * Finalization and Cleanup Section
      * ---------------------------------------------------------------------------------------------
      */
     // Clobber any possible pending updates
     $update = JTable::getInstance('update');
     $uid = $update->find(array('element' => $this->get('element'), 'type' => 'component', 'client_id' => '', 'folder' => ''));
     if ($uid) {
         $update->delete($uid);
     }
     // And now we run the postflight
     ob_start();
     ob_implicit_flush(false);
     if ($this->parent->manifestClass && method_exists($this->parent->manifestClass, 'postflight')) {
         $this->parent->manifestClass->postflight('discover_install', $this);
     }
     $msg .= ob_get_contents();
     // append messages
     ob_end_clean();
     if ($msg != '') {
         $this->parent->set('extension_message', $msg);
     }
     return $this->parent->extension->extension_id;
 }
Example #13
0
 function install_component()
 {
     $com_name = 'com_' . str_replace(' ', '', strtolower($this->name));
     $this->user_dir = mosPathName(mamboCore::get('mosConfig_absolute_path') . '/components/' . $com_name);
     $this->admin_dir = mosPathName(mamboCore::get('mosConfig_absolute_path') . '/administrator/components/' . $com_name);
     $database =& mamboDatabase::getInstance();
     $sql = "SELECT COUNT(id) FROM #__components WHERE `option`='{$com_name}'";
     $database->setQuery($sql);
     if ($count = $database->loadResult()) {
         $this->errors->addErrorDetails(sprintf(T_('Installer error with %s: %s %s already installed'), $this->xmlfile, 'component', $com_name), _MOS_ERROR_WARN);
         return;
     }
     if (!$this->createDirectories($com_name)) {
         return;
     }
     $fmanager =& mosFileManager::getInstance();
     $here = mosPathName(dirname($this->xmlfile));
     $fmanager->forceCopy($this->xmlfile, $this->admin_dir . basename($this->xmlfile));
     foreach ($this->files as $ufile) {
         $fmanager->forceCopy($here . $ufile, $this->user_dir . $ufile);
     }
     foreach ($this->images as $uimage) {
         $fmanager->forceCopy($here . $uimage, $this->user_dir . $uimage);
     }
     foreach ($this->admin_files as $afile) {
         $fmanager->forceCopy($here . $afile, $this->admin_dir . $afile);
     }
     foreach ($this->admin_images as $aimage) {
         $fmanager->forceCopy($here . $aimage, $this->admin_dir . $aimage);
     }
     if ($this->installfile) {
         $fmanager->forceCopy($here . $this->installfile, $this->admin_dir . $this->installfile);
     }
     if ($this->uninstallfile) {
         $fmanager->forceCopy($here . $this->uninstallfile, $this->admin_dir . $this->uninstallfile);
     }
     foreach ($this->queries as $query) {
         $database->setQuery($query[0]);
         if (!$database->query()) {
             $this->errors->addErrorDetails(sprintf(T_('Installer error with %s: %s %s SQL error %s'), $this->xmlfile, 'component', $com_name, $database->stderr(true)), _MOS_ERROR_FATAL);
         }
     }
     if ($this->mainmenu) {
         $topid = $this->createComponentMenu(array($this->mainmenu), $com_name);
         foreach ($this->submenus as $submenu) {
             $this->createComponentMenu($submenu, $com_name, $topid);
         }
     }
     if ($this->installfile) {
         $ifile = mosPathName($this->admin_dir) . $this->installfile;
         if (is_file($ifile)) {
             global $mosConfig_absolute_path, $mosConfig_live_site, $acl, $database;
             require_once $ifile;
             $_ret = com_install();
             if ($_ret) {
                 // convert the first character of the returned string to be represented by an integer
                 $_type = intval(bin2hex($_ret[0])) - intval(bin2hex(_MOS_ERROR_INFORM));
                 switch ($_type) {
                     case _MOS_ERROR_INFORM:
                     case _MOS_ERROR_WARN:
                     case _MOS_ERROR_SEVERE:
                     case _MOS_ERROR_FATAL:
                         //strip off the first character
                         $_ret = substr($_ret, 1);
                         break;
                     default:
                         $_type = _MOS_ERROR_INFORM;
                         break;
                 }
                 if ($_type < _MOS_ERROR_FATAL) {
                     $this->errors->addErrorDetails(sprintf(T_('%s'), $_ret), $_type);
                 } else {
                     $this->errors->addErrorDetails(sprintf(T_('The com_install() function for component "%s" aborted with: %s'), $com_name, $_ret), $_type);
                 }
             }
         }
     }
     $this->errors->addErrorDetails($this->getDescription('component'), _MOS_ERROR_INFORM);
 }
Example #14
0
        static $installable;
        if (isset($installable)) {
            return $installable;
        }
        $db = JFactory::getDBO();
        foreach (array(function_exists('mysqli_connect') => "Your server don't have MySQLi.", version_compare(phpversion(), '5.2', '>=') => "Your PHP version is older than 5.2.", version_compare(JVERSION, '1.5.10', '>=') => "Your Joomla version is older than 1.5.10.", version_compare($db->getVersion(), '5.0.41', '>=') => "Your MySQL version is older than 5.0.41.") as $succeed => $fail) {
            if (!$succeed) {
                JError::raiseWarning(0, $fail);
                $installable = false;
                return false;
            }
        }
        return $installable = true;
    }
}
if (!com_install()) {
    return;
}
@set_time_limit(30);
//Install Nooku first, before anything else
$nooku = $this->parent->getPath('source') . '/nooku';
if (JFolder::exists($nooku)) {
    $installer = new JInstaller();
    $installer->install($nooku);
}
$this->name = strtolower($this->name);
$extname = 'com_' . $this->name;
// load the component language file
$language =& JFactory::getLanguage();
$language->load($extname);
$source = $this->parent->getPath('source');
 /**
  * Custom install method
  *
  * @access	public
  * @return	boolean	True on success
  * @since	1.5
  * Minor alteration - see below
  */
 function install()
 {
     // Get a database connector object
     $db =& $this->parent->getDBO();
     // Get the extension manifest object
     $manifest =& $this->parent->getManifest();
     $this->manifest =& $manifest;
     //$manifest->document;
     /**
      * ---------------------------------------------------------------------------------------------
      * Manifest Document Setup Section
      * ---------------------------------------------------------------------------------------------
      */
     // Set the component name
     $name = '';
     if ($this->manifest->name) {
         $name = $this->manifest->name;
         $this->set('name', $name->data());
     } else {
         $this->set('name', '');
     }
     // Get the component description
     $description =& $this->manifest->description;
     if (is_a($description, 'JXMLElement')) {
         $this->parent->set('message', $description->data());
     } else {
         $this->parent->set('message', '');
     }
     $element =& $this->manifest->files;
     // Plugin name is specified
     $pname = (string) $this->manifest->attributes()->plugin;
     //Get type
     $type = $this->manifest->attributes()->group;
     if (!empty($pname)) {
         // ^ Use JCK_PLUGINS defined path
         $this->parent->setPath('extension_root', JCK_PLUGINS . DS . $pname);
     } else {
         $this->parent->abort('Extension Install: ' . JText::_('No plugin specified'));
         return false;
     }
     if ((string) $manifest->scriptfile) {
         $manifestScript = (string) $manifest->scriptfile;
         $manifestScriptFile = $this->parent->getPath('source') . DS . $manifestScript;
         if (is_file($manifestScriptFile)) {
             // load the file
             include_once $manifestScriptFile;
         }
         // Set the class name
         $classname = 'plgJCK' . $pname . 'InstallerScript';
         if (class_exists($classname)) {
             // create a new instance
             $this->parent->manifestClass = new $classname($this);
             // and set this so we can copy it later
             $this->set('manifest_script', $manifestScript);
             // Note: if we don't find the class, don't bother to copy the file
         }
         // run preflight if possible
         ob_start();
         ob_implicit_flush(false);
         if ($this->parent->manifestClass && method_exists($this->parent->manifestClass, 'preflight')) {
             if ($this->parent->manifestClass->preflight('install', $this) === false) {
                 // Install failed, rollback changes
                 $this->parent->abort(JText::_('Installer abort for custom plugin install script'));
                 return false;
             }
         }
         ob_end_clean();
     }
     /**
      * ---------------------------------------------------------------------------------------------
      * Filesystem Processing Section
      * ---------------------------------------------------------------------------------------------
      */
     // If the extension directory does not exist, lets create it
     $created = false;
     if (!file_exists($this->parent->getPath('extension_root'))) {
         if (!($created = JFolder::create($this->parent->getPath('extension_root')))) {
             $this->parent->abort('Plugin Install: ' . JText::_('Failed to create directory') . ': "' . $this->parent->getPath('extension_root') . '"');
             return false;
         }
     }
     /*
      * If we created the extension directory and will want to remove it if we
      * have to roll back the installation, lets add it to the installation
      * step stack
      */
     if ($created) {
         $this->parent->pushStep(array('type' => 'folder', 'path' => $this->parent->getPath('extension_root')));
     }
     // Copy all necessary files
     if ($this->parent->parseFiles($element, -1) === false) {
         // Install failed, roll back changes
         $this->parent->abort();
         return false;
     }
     // Parse optional tags -- language files for plugins
     $this->parent->parseLanguages($this->manifest->languages, 0);
     // If there is an install file, lets copy it.
     $installScriptElement =& $this->manifest->installfile;
     if (is_a($installScriptElement, 'JXMLElement')) {
         // Make sure it hasn't already been copied (this would be an error in the xml install file)
         if (!file_exists($this->parent->getPath('extension_root') . DS . $installScriptElement->data())) {
             $path['src'] = $this->parent->getPath('source') . DS . $installScriptElement->data();
             $path['dest'] = $this->parent->getPath('extension_root') . DS . $installScriptElement->data();
             if (!$this->parent->copyFiles(array($path))) {
                 // Install failed, rollback changes
                 $this->parent->abort(JText::_('Component') . ' ' . JText::_('Install') . ': ' . JText::_('Could not copy PHP install file.'));
                 return false;
             }
         }
         $this->set('install.script', $installScriptElement->data());
     }
     // If there is an uninstall file, lets copy it.
     $uninstallScriptElement =& $this->manifest->uninstallfile;
     if (is_a($uninstallScriptElement, 'JXMLElement')) {
         // Make sure it hasn't already been copied (this would be an error in the xml install file)
         if (!file_exists($this->parent->getPath('extension_root') . DS . $uninstallScriptElement->data())) {
             $path['src'] = $this->parent->getPath('source') . DS . $uninstallScriptElpement->data();
             $path['dest'] = $this->parent->getPath('extension_root') . DS . $uninstallScriptElement->data();
             if (!$this->parent->copyFiles(array($path))) {
                 // Install failed, rollback changes
                 $this->parent->abort(JText::_('Component') . ' ' . JText::_('Install') . ': ' . JText::_('Could not copy PHP uninstall file.'));
                 return false;
             }
         }
     }
     /**
      * ---------------------------------------------------------------------------------------------
      * Database Processing Section
      * ---------------------------------------------------------------------------------------------
      */
     $type = isset($type) ? (string) $type : 'plugin';
     //Add group processimg
     // Check to see if a plugin by the same name is already installed
     // ^ Altered db query for #__JCK_PLUGINS
     $query = 'SELECT `id`' . ' FROM `#__jckplugins`' . ' WHERE name = ' . $db->Quote($pname);
     $db->setQuery($query);
     if (!$db->Query()) {
         // Install failed, roll back changes
         $this->parent->abort('Plugin Install: ' . $db->stderr(true));
         return false;
     }
     $id = $db->loadResult();
     // Was there a module already installed with the same name?
     if ($id) {
         if (!$this->parent->getOverwrite()) {
             // Install failed, roll back changes
             $this->parent->abort('Plugin Install: ' . JText::_('Plugin') . ' "' . $pname . '" ' . JText::_('already exists!'));
             return false;
         }
         $row =& JTable::getInstance('plugin', 'JCKTable');
         $row->type = $type;
         $row->load($id);
     } else {
         $icon = $this->manifest->icon;
         // ^ Changes to plugin parameters. Use JCK Plugins Table class.
         $row =& JTable::getInstance('plugin', 'JCKTable');
         $row->title = $this->get('name');
         $row->name = $pname;
         $row->type = $type;
         $row->row = 4;
         $row->published = 1;
         $row->editable = 1;
         $row->icon = $icon ? $icon->data() : '';
         $row->iscore = 0;
         $row->params = $this->parent->getParams();
         if ($this->manifest->attributes()->parent) {
             $parentName = (string) $this->manifest->attributes()->parent;
             $row->setParent($parentName);
         }
         if (!$row->store()) {
             // Install failed, roll back changes
             $this->parent->abort('Plugin Install: ' . $db->stderr(true));
             return false;
         }
         // Since we have created a plugin item, we add it to the installation step stack
         // so that if we have to rollback the changes we can undo it.
         $this->parent->pushStep(array('type' => 'plugin', 'id' => $row->id));
     }
     /* -------------------------------------------------------------------------------------------
      * update editor plugin config file    AW 
      * -------------------------------------------------------------------------------------------
      */
     $config =& JCKHelper::getEditorPluginConfig();
     $config->setValue($pname, 1);
     $cfgFile = CKEDITOR_LIBRARY . DS . 'plugins' . DS . 'toolbarplugins.php';
     // Get the config registry in PHP class format and write it to configuation.php
     if (!JFile::write($cfgFile, $config->toString('PHP', array('class' => 'JCKToolbarPlugins extends JCKPlugins')))) {
         JError::raiseWarning(100, 'Failed to publish ' . $pname . ' jckeditor plugin');
     }
     /**
      *-------------------------------------------------------------------------------------------
      * Add plugin to toolbars
      *-------------------------------------------------------------------------------------------
      */
     $CKfolder = CKEDITOR_LIBRARY . DS . 'toolbar';
     //$toolbarnames =& JCKHelper::getEditorToolbars();
     $toolbarnames = JRequest::getVar('selections', array());
     if (!empty($toolbarnames) && $row->icon) {
         $values = array();
         foreach ($toolbarnames as $toolbarname) {
             $tmpfilename = $CKfolder . DS . $toolbarname . '.php';
             require $tmpfilename;
             $classname = 'JCK' . ucfirst($toolbarname);
             $toolbar = new $classname();
             $pluginTitle = str_replace(' ', '', $row->title);
             $pluginTitle = $pluginTitle;
             if (isset($toolbar->{$pluginTitle})) {
                 continue;
             }
             //fix toolbar values or they will get wiped out
             foreach (get_object_vars($toolbar) as $k => $v) {
                 if (is_null($v)) {
                     $toolbar->{$k} = '';
                 }
                 if ($k[0] == '_') {
                     $toolbar->{$k} = NULL;
                 }
             }
             $toolbar->{$pluginTitle} = '';
             $toolbarConfig = new JRegistry('toolbar');
             $toolbarConfig->loadObject($toolbar);
             // Get the config registry in PHP class format and write it to configuation.php
             if (!JFile::write($tmpfilename, $toolbarConfig->toString('PHP', array('class' => $classname . ' extends JCKToolbar')))) {
                 JError::raiseWarning(100, 'Failed to add ' . $pname . 'plugin to  ' . $classname . ' toolbar');
             }
             //layout stuff
             $query = 'SELECT id' . ' FROM #__jcktoolbars' . ' WHERE name = "' . $toolbarname . '"';
             $db->setQuery($query);
             $toolbarid = $db->loadResult();
             if (!$toolbarid) {
                 continue;
             }
             $rowDetail = JCKHelper::getNextLayoutRow($toolbarid);
             $values[] = '(' . $toolbarid . ',' . $row->id . ',' . $rowDetail->rowid . ',' . $rowDetail->rowordering . ',1)';
         }
         //insert into layout table
         if (!empty($values)) {
             //Now delete dependencies
             $query = 'DELETE FROM #__jcktoolbarplugins' . ' WHERE pluginid =' . $row->id;
             $db->setQuery($query);
             if (!$db->query()) {
                 JError::raiseWarning(100, $db->getErrorMsg());
             }
             $query = 'INSERT INTO #__jcktoolbarplugins(toolbarid,pluginid,row,ordering,state) VALUES ' . implode(',', $values);
             $db->setQuery($query);
             if (!$db->query()) {
                 JError::raiseWarning(100, $db->getErrorMsg());
             }
         }
     }
     /**
      * ---------------------------------------------------------------------------------------------
      * Custom Installation Script Section
      * ---------------------------------------------------------------------------------------------
      */
     /*
      * If we have an install script, lets include it, execute the custom
      * install method, and append the return value from the custom install
      * method to the installation message.
      */
     if ($this->get('install.script')) {
         if (is_file($this->parent->getPath('extension_root') . DS . $this->get('install.script'))) {
             ob_start();
             ob_implicit_flush(false);
             require_once $this->parent->getPath('extension_root') . DS . $this->get('install.script');
             if (function_exists('com_install')) {
                 if (com_install() === false) {
                     $this->parent->abort(JText::_('Plugin') . ' ' . JText::_('Install') . ': ' . JText::_('Custom install routine failure'));
                     return false;
                 }
             }
             $msg = ob_get_contents();
             ob_end_clean();
             if ($msg != '') {
                 $this->parent->set('extension.message', $msg);
             }
         }
     }
     /**
      * ---------------------------------------------------------------------------------------------
      * Finalization and Cleanup Section
      * ---------------------------------------------------------------------------------------------
      */
     // Lastly, we will copy the manifest file to its appropriate place.
     if (!$this->parent->copyManifest(-1)) {
         // Install failed, rollback changes
         $this->parent->abort('Plugin Install: ' . JText::_('Could not copy setup file'));
         return false;
     }
     //make a copy of the plugin
     $src = $this->parent->getPath('extension_root');
     $dest = JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_jckman' . DS . 'editor' . DS . 'plugins' . DS . $pname;
     if (!JFolder::copy($src, $dest, null, true)) {
         // Install failed, roll back changes
         $this->parent->abort();
         return false;
     }
     // And now we run the postflight
     ob_start();
     ob_implicit_flush(false);
     if ($this->parent->manifestClass && method_exists($this->parent->manifestClass, 'postflight')) {
         $this->parent->manifestClass->postflight('install', $this);
     }
     ob_end_clean();
     return true;
 }
Example #16
0
 function install()
 {
     $extDir = JPATH_ROOT . DS . 'components' . DS . 'com_sef' . DS . 'sef_ext';
     // Check that the sef_ext directory is writable
     if (!is_writable($extDir)) {
         JError::raiseWarning(100, JText::_('The JoomSEF Extensions directory /components/com_sef/sef_ext is not writable, so you are not able to install any extensions.'));
         return false;
     }
     // Get a database connector object
     $db =& $this->parent->getDBO();
     // Get the extension manifest object
     $manifest =& $this->parent->getManifest();
     $this->manifest =& $manifest->document;
     // Set the extensions name
     $name =& $this->manifest->getElementByPath('name');
     $name = JFilterInput::clean($name->data(), 'string');
     $this->parent->set('name', $name);
     // Get the component description
     $description =& $this->manifest->getElementByPath('description');
     if (is_a($description, 'JSimpleXMLElement')) {
         $this->parent->set('message', $description->data());
     } else {
         $this->parent->set('message', '');
     }
     // Set the installation path
     $this->parent->setPath('extension_root', $extDir);
     /**
      * ---------------------------------------------------------------------------------------------
      * Filesystem Processing Section
      * ---------------------------------------------------------------------------------------------
      */
     // If the plugin directory does not exist, lets create it
     $created = false;
     if (!file_exists($this->parent->getPath('extension_root'))) {
         if (!($created = JFolder::create($this->parent->getPath('extension_root')))) {
             $this->parent->abort(JText::_('SEF Extension') . ' ' . JText::_('Install') . ': ' . JText::_('Failed to create directory') . ': "' . $this->parent->getPath('extension_root') . '"');
             return false;
         }
     }
     /*
      * If we created the plugin directory and will want to remove it if we
      * have to roll back the installation, lets add it to the installation
      * step stack
      */
     if ($created) {
         $this->parent->pushStep(array('type' => 'folder', 'path' => $this->parent->getPath('extension_root')));
     }
     // Copy all necessary files
     $element =& $this->manifest->getElementByPath('files');
     if ($this->parent->parseFiles($element, -1) === false) {
         // Install failed, roll back changes
         $this->parent->abort();
         return false;
     }
     // If there is an install file, lets copy it.
     $installScriptElement =& $this->manifest->getElementByPath('installfile');
     if (is_a($installScriptElement, 'JSimpleXMLElement')) {
         // Make sure it hasn't already been copied (this would be an error in the xml install file)
         if (!file_exists($this->parent->getPath('extension_root') . DS . $installScriptElement->data())) {
             $path['src'] = $this->parent->getPath('source') . DS . $installScriptElement->data();
             $path['dest'] = $this->parent->getPath('extension_root') . DS . $installScriptElement->data();
             if (!$this->parent->copyFiles(array($path))) {
                 // Install failed, rollback changes
                 $this->parent->abort(JText::_('SEF Extension') . ' ' . JText::_('Install') . ': ' . JText::_('Could not copy PHP install file.'));
                 return false;
             }
         }
         $this->set('install.script', $installScriptElement->data());
     }
     // If there is an uninstall file, lets copy it.
     $uninstallScriptElement =& $this->manifest->getElementByPath('uninstallfile');
     if (is_a($uninstallScriptElement, 'JSimpleXMLElement')) {
         // Make sure it hasn't already been copied (this would be an error in the xml install file)
         if (!file_exists($this->parent->getPath('extension_root') . DS . $uninstallScriptElement->data())) {
             $path['src'] = $this->parent->getPath('source') . DS . $uninstallScriptElement->data();
             $path['dest'] = $this->parent->getPath('extension_root') . DS . $uninstallScriptElement->data();
             if (!$this->parent->copyFiles(array($path))) {
                 // Install failed, rollback changes
                 $this->parent->abort(JText::_('SEF Extension') . ' ' . JText::_('Install') . ': ' . JText::_('Could not copy PHP uninstall file.'));
                 return false;
             }
         }
     }
     /**
      * ---------------------------------------------------------------------------------------------
      * Database Processing Section
      * ---------------------------------------------------------------------------------------------
      */
     /*
      * Let's run the install queries for the component
      *	If backward compatibility is required - run queries in xml file
      *	If Joomla 1.5 compatible, with discreet sql files - execute appropriate
      *	file for utf-8 support or non-utf-8 support
      */
     $result = $this->parent->parseQueries($this->manifest->getElementByPath('install/queries'));
     if ($result === false) {
         // Install failed, rollback changes
         $this->parent->abort(JText::_('SEF Extension') . ' ' . JText::_('Install') . ': ' . JText::_('SQL Error') . " " . $db->stderr(true));
         return false;
     } elseif ($result === 0) {
         // no backward compatibility queries found - try for Joomla 1.5 type queries
         // second argument is the utf compatible version attribute
         $utfresult = $this->parent->parseSQLFiles($this->manifest->getElementByPath('install/sql'));
         if ($utfresult === false) {
             // Install failed, rollback changes
             $this->parent->abort(JText::_('SEF Extension') . ' ' . JText::_('Install') . ': ' . JText::_('SQLERRORORFILE') . " " . $db->stderr(true));
             return false;
         }
     }
     // Insert extension into database
     $query = "SELECT `file` FROM `#__sefexts` WHERE `file` = " . $db->Quote(basename($this->parent->getPath('manifest')));
     $db->setQuery($query);
     $id = $db->loadResult();
     if (!$id) {
         $params = $this->_getDefaultParams();
         $filters = $this->_getDefaultFilters();
         $fields = array('`file`');
         $values = array($db->Quote(basename($this->parent->getPath('manifest'))));
         if (!empty($params)) {
             $fields[] = '`params`';
             $values[] = $db->Quote($params);
         }
         if (!empty($filters)) {
             $fields[] = '`filters`';
             $values[] = $db->Quote($filters);
         }
         $query = "INSERT INTO `#__sefexts` (" . implode(',', $fields) . ") VALUES (" . implode(',', $values) . ")";
         $db->setQuery($query);
         if (!$db->query()) {
             $this->parent->abort(JText::_('SEF Extension') . ' ' . JText::_('Install') . ': ' . JText::_('SQL Error') . " " . $db->stderr(true));
             return false;
         }
     }
     // Trash already created URLs for this extension
     $component = preg_replace('/.xml$/', '', basename($this->parent->getPath('manifest')));
     $query = "UPDATE `#__sefurls` SET `trashed` = '1' WHERE (`origurl` LIKE " . $db->Quote('%option=' . $component . '&%') . " OR `origurl` LIKE " . $db->Quote('%option=' . $component) . ")";
     $db->setQuery($query);
     if (!$db->query()) {
         $this->parent->abort(JText::_('SEF Extension') . ' ' . JText::_('Install') . ': ' . JText::_('SQL Error') . " " . $db->stderr(true));
         return false;
     }
     /**
      * ---------------------------------------------------------------------------------------------
      * Custom Installation Script Section
      * ---------------------------------------------------------------------------------------------
      */
     /*
      * If we have an install script, lets include it, execute the custom
      * install method, and append the return value from the custom install
      * method to the installation message.
      */
     if ($this->get('install.script')) {
         if (is_file($this->parent->getPath('extension_root') . DS . $this->get('install.script'))) {
             ob_start();
             ob_implicit_flush(false);
             require_once $this->parent->getPath('extension_root') . DS . $this->get('install.script');
             if (function_exists('com_install')) {
                 if (com_install() === false) {
                     $this->parent->abort(JText::_('SEF Extension') . ' ' . JText::_('Install') . ': ' . JText::_('Custom install routine failure'));
                     return false;
                 }
             }
             $msg = ob_get_contents();
             ob_end_clean();
             if ($msg != '') {
                 $this->parent->set('extension.message', $msg);
             }
         }
     }
     /**
      * ---------------------------------------------------------------------------------------------
      * Finalization and Cleanup Section
      * ---------------------------------------------------------------------------------------------
      */
     // Lastly, we will copy the manifest file to its appropriate place.
     if (!$this->parent->copyManifest(-1)) {
         // Install failed, rollback changes
         $this->parent->abort(JText::_('SEF Extension') . ' ' . JText::_('Install') . ': ' . JText::_('Could not copy setup file'));
         return false;
     }
     return true;
 }
Example #17
0
 function update($parent)
 {
     com_install();
 }
Example #18
0
 function install()
 {
     // Get the extension manifest object
     $this->manifest =& $this->parent->getManifest();
     // Set the extension's name
     $name = (string) $this->manifest->name;
     $this->parent->set('name', $name);
     // Set the extension's description
     $description = (string) $this->manifest->description;
     $this->parent->set('message', $description);
     // Set the installation path
     $this->parent->setPath('extension_root', JPATH_ADMINISTRATOR . '/components/com_mijosef/extensions');
     /**
      * ---------------------------------------------------------------------------------------------
      * Filesystem Processing Section
      * ---------------------------------------------------------------------------------------------
      */
     // If the extension directory does not exist, lets create it
     $created = false;
     if (!file_exists($this->parent->getPath('extension_root'))) {
         if (!($created = JFolder::create($this->parent->getPath('extension_root')))) {
             $this->parent->abort(JText::_('MijoSEF Extension') . ' ' . JText::_('Install') . ': ' . JText::_('Failed to create directory') . ': "' . $this->parent->getPath('extension_root') . '"');
             return false;
         }
     }
     if ($created) {
         $this->parent->pushStep(array('type' => 'folder', 'path' => $this->parent->getPath('extension_root')));
     }
     // Copy all necessary files
     $element =& $this->manifest->files;
     if ($this->parent->parseFiles($element, -1) === false) {
         // Install failed, roll back changes
         $this->parent->abort();
         return false;
     }
     // If there is an install file, lets copy it.
     $installScriptElement = (string) $this->manifest->installfile;
     if ($installScriptElement) {
         // Make sure it hasn't already been copied (this would be an error in the xml install file)
         if (!file_exists($this->parent->getPath('extension_root') . DS . $installScriptElement)) {
             $path['src'] = $this->parent->getPath('source') . DS . $installScriptElement;
             $path['dest'] = $this->parent->getPath('extension_root') . DS . $installScriptElement;
             if (!$this->parent->copyFiles(array($path))) {
                 // Install failed, rollback changes
                 $this->parent->abort(JText::_('MijoSEF Extension') . ' ' . JText::_('Install') . ': ' . JText::_('Could not copy PHP install file.'));
                 return false;
             }
         }
         $this->set('install.script', $installScriptElement);
     }
     // If there is an uninstall file, lets copy it.
     $uninstallScriptElement = (string) $this->manifest->uninstallfile;
     if ($uninstallScriptElement) {
         // Make sure it hasn't already been copied (this would be an error in the xml install file)
         if (!file_exists($this->parent->getPath('extension_root') . DS . $uninstallScriptElement)) {
             $path['src'] = $this->parent->getPath('source') . DS . $uninstallScriptElement;
             $path['dest'] = $this->parent->getPath('extension_root') . DS . $uninstallScriptElement;
             if (!$this->parent->copyFiles(array($path))) {
                 // Install failed, rollback changes
                 $this->parent->abort(JText::_('MijoSEF Extension') . ' ' . JText::_('Install') . ': ' . JText::_('Could not copy PHP uninstall file.'));
                 return false;
             }
         }
     }
     /**
      * ---------------------------------------------------------------------------------------------
      * Database Processing Section
      * ---------------------------------------------------------------------------------------------
      */
     $db =& JFactory::getDBO();
     /*
      * Let's run the install queries for the component
      *	If backward compatibility is required - run queries in xml file
      *	If Joomla 1.5 compatible, with discreet sql files - execute appropriate
      *	file for utf-8 support or non-utf-8 support
      */
     $result = $this->parent->parseQueries($this->manifest->install->queries);
     if ($result === false) {
         // Install failed, rollback changes
         $this->parent->abort(JText::_('MijoSEF Extension') . ' ' . JText::_('Install') . ': ' . JText::_('SQL Error') . " " . $db->stderr(true));
         return false;
     } elseif ($result === 0) {
         // no backward compatibility queries found - try for Joomla 1.5 type queries
         // second argument is the utf compatible version attribute
         $utfresult = $this->parent->parseSQLFiles($this->manifest->install->sql);
         if ($utfresult === false) {
             // Install failed, rollback changes
             $this->parent->abort(JText::_('MijoSEF Extension') . ' ' . JText::_('Install') . ': ' . JText::_('SQLERRORORFILE') . " " . $db->stderr(true));
             return false;
         }
     }
     // Get extension
     $extension = preg_replace('/.xml$/', '', basename($this->parent->getPath('manifest')));
     // Check if extension exists and upgrade is performed
     $db->setQuery("SELECT name, params FROM #__mijosef_extensions WHERE extension = '{$extension}'");
     $existing = $db->loadObject();
     $installation = false;
     // Existing Install
     if (!is_null($existing)) {
         if ($existing->name == "") {
             Mijosef::get('utility')->import('library.parameter');
             $old_p = new JRegistry($existing->params);
             $new_p = new JRegistry(self::_getDefaultParams());
             $new_p->set('prefix', $old_p->get('prefix', ''));
             $new_p->set('skip_menu', $old_p->get('skip_menu', '0'));
             $params = $new_p->toString();
             $db->setQuery("UPDATE #__mijosef_extensions SET name = '{$name}', params = '{$params}' WHERE extension = '{$extension}'");
             $db->query();
             $installation = true;
         }
     } else {
         JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_mijosef/tables');
         $row =& JTable::getInstance('MijosefExtensions', 'Table');
         $row->name = $name;
         $row->extension = $extension;
         $row->params = self::_getDefaultParams();
         $row->store();
         $installation = true;
     }
     // Remove already created URLs for this extension
     require_once JPATH_ADMINISTRATOR . '/components/com_mijosef/library/mijosef.php';
     $MijosefConfig =& Mijosef::getConfig();
     if ($installation && $MijosefConfig->purge_ext_urls == 1) {
         $db->setQuery("DELETE FROM #__mijosef_urls WHERE (url_real LIKE '%option={$extension}&%' OR url_real LIKE '%option={$extension}') AND params LIKE '%locked=0\nb%'");
         $db->query();
     }
     /**
      * ---------------------------------------------------------------------------------------------
      * Custom Installation Script Section
      * ---------------------------------------------------------------------------------------------
      */
     /*
      * If we have an install script, lets include it, execute the custom
      * install method, and append the return value from the custom install
      * method to the installation message.
      */
     if ($this->get('install.script')) {
         if (is_file($this->parent->getPath('extension_root') . DS . $this->get('install.script'))) {
             ob_start();
             ob_implicit_flush(false);
             require_once $this->parent->getPath('extension_root') . DS . $this->get('install.script');
             if (function_exists('com_install')) {
                 if (com_install() === false) {
                     $this->parent->abort(JText::_('MijoSEF Extension') . ' ' . JText::_('Install') . ': ' . JText::_('Custom install routine failure'));
                     return false;
                 }
             }
             $msg = ob_get_contents();
             ob_end_clean();
             if ($msg != '') {
                 $this->parent->set('extension.message', $msg);
             }
         }
     }
     /**
      * ---------------------------------------------------------------------------------------------
      * Finalization and Cleanup Section
      * ---------------------------------------------------------------------------------------------
      */
     // Lastly, we will copy the manifest file to its appropriate place.
     if (!$this->parent->copyManifest(-1)) {
         // Install failed, rollback changes
         $this->parent->abort(JText::_('Could not copy setup file'));
         return false;
     }
     return true;
 }
Example #19
0
 /**
  * Custom install method for components
  *
  * @access	public
  * @return	boolean	True on success
  * @since	1.5
  */
 function install()
 {
     // Get a database connector object
     $db =& $this->parent->getDBO();
     // Get the extension manifest object
     $manifest =& $this->parent->getManifest();
     $this->manifest =& $manifest->document;
     /**
      * ---------------------------------------------------------------------------------------------
      * Manifest Document Setup Section
      * ---------------------------------------------------------------------------------------------
      */
     // Set the extensions name
     $name =& $this->manifest->getElementByPath('name');
     $name = JFilterInput::clean($name->data(), 'cmd');
     $this->set('name', $name);
     // Get the component description
     $description =& $this->manifest->getElementByPath('description');
     if (is_a($description, 'JSimpleXMLElement')) {
         $this->parent->set('message', $description->data());
     } else {
         $this->parent->set('message', '');
     }
     // Get some important manifest elements
     $this->adminElement =& $this->manifest->getElementByPath('administration');
     $this->installElement =& $this->manifest->getElementByPath('install');
     $this->uninstallElement =& $this->manifest->getElementByPath('uninstall');
     // Set the installation target paths
     $this->parent->setPath('extension_site', JPath::clean(JPATH_SITE . DS . "components" . DS . strtolower("com_" . str_replace(" ", "", $this->get('name')))));
     $this->parent->setPath('extension_administrator', JPath::clean(JPATH_ADMINISTRATOR . DS . "components" . DS . strtolower("com_" . str_replace(" ", "", $this->get('name')))));
     /**
      * ---------------------------------------------------------------------------------------------
      * Basic Checks Section
      * ---------------------------------------------------------------------------------------------
      */
     // Make sure that we have an admin element
     if (!is_a($this->adminElement, 'JSimpleXMLElement')) {
         JError::raiseWarning(1, JText::_('Component') . ' ' . JText::_('Install') . ': ' . JText::_('The XML file did not contain an administration element'));
         return false;
     }
     /**
      * ---------------------------------------------------------------------------------------------
      * Filesystem Processing Section
      * ---------------------------------------------------------------------------------------------
      */
     /*
      * If the component site or admin directory already exists, then we will assume that the component is already
      * installed or another component is using that directory.
      */
     if ((file_exists($this->parent->getPath('extension_site')) || file_exists($this->parent->getPath('extension_administrator'))) && !$this->parent->getOverwrite()) {
         JError::raiseWarning(1, JText::_('Component') . ' ' . JText::_('Install') . ': ' . JText::_('Another component is already using directory') . ': "' . $this->parent->getPath('extension_site') . '"');
         return false;
     }
     // If the component directory does not exist, lets create it
     $created = false;
     if (!file_exists($this->parent->getPath('extension_site'))) {
         if (!($created = JFolder::create($this->parent->getPath('extension_site')))) {
             JError::raiseWarning(1, JText::_('Component') . ' ' . JText::_('Install') . ': ' . JText::_('Failed to create directory') . ': "' . $this->parent->getPath('extension_site') . '"');
             return false;
         }
     }
     /*
      * Since we created the component directory and will want to remove it if we have to roll back
      * the installation, lets add it to the installation step stack
      */
     if ($created) {
         $this->parent->pushStep(array('type' => 'folder', 'path' => $this->parent->getPath('extension_site')));
     }
     // If the component admin directory does not exist, lets create it
     $created = false;
     if (!file_exists($this->parent->getPath('extension_administrator'))) {
         if (!($created = JFolder::create($this->parent->getPath('extension_administrator')))) {
             JError::raiseWarning(1, JText::_('Component') . ' ' . JText::_('Install') . ': ' . JText::_('Failed to create directory') . ': "' . $this->parent->getPath('extension_administrator') . '"');
             // Install failed, rollback any changes
             $this->parent->abort();
             return false;
         }
     }
     /*
      * Since we created the component admin directory and we will want to remove it if we have to roll
      * back the installation, lets add it to the installation step stack
      */
     if ($created) {
         $this->parent->pushStep(array('type' => 'folder', 'path' => $this->parent->getPath('extension_administrator')));
     }
     // Find files to copy
     foreach ($this->manifest->children() as $child) {
         if (is_a($child, 'JSimpleXMLElement') && $child->name() == 'files') {
             if ($this->parent->parseFiles($child) === false) {
                 // Install failed, rollback any changes
                 $this->parent->abort();
                 return false;
             }
         }
     }
     foreach ($this->adminElement->children() as $child) {
         if (is_a($child, 'JSimpleXMLElement') && $child->name() == 'files') {
             if ($this->parent->parseFiles($child, 1) === false) {
                 // Install failed, rollback any changes
                 $this->parent->abort();
                 return false;
             }
         }
     }
     // Parse optional tags
     $this->parent->parseMedia($this->manifest->getElementByPath('media'));
     $this->parent->parseLanguages($this->manifest->getElementByPath('languages'));
     $this->parent->parseLanguages($this->manifest->getElementByPath('administration/languages'), 1);
     // Parse deprecated tags
     $this->parent->parseFiles($this->manifest->getElementByPath('images'));
     $this->parent->parseFiles($this->manifest->getElementByPath('administration/images'), 1);
     // If there is an install file, lets copy it.
     $installScriptElement =& $this->manifest->getElementByPath('installfile');
     if (is_a($installScriptElement, 'JSimpleXMLElement')) {
         // Make sure it hasn't already been copied (this would be an error in the xml install file)
         if (!file_exists($this->parent->getPath('extension_administrator') . DS . $installScriptElement->data())) {
             $path['src'] = $this->parent->getPath('source') . DS . $installScriptElement->data();
             $path['dest'] = $this->parent->getPath('extension_administrator') . DS . $installScriptElement->data();
             if (!$this->parent->copyFiles(array($path))) {
                 // Install failed, rollback changes
                 $this->parent->abort(JText::_('Component') . ' ' . JText::_('Install') . ': ' . JText::_('Could not copy PHP install file.'));
                 return false;
             }
         }
         $this->set('install.script', $installScriptElement->data());
     }
     // If there is an uninstall file, lets copy it.
     $uninstallScriptElement =& $this->manifest->getElementByPath('uninstallfile');
     if (is_a($uninstallScriptElement, 'JSimpleXMLElement')) {
         // Make sure it hasn't already been copied (this would be an error in the xml install file)
         if (!file_exists($this->parent->getPath('extension_administrator') . DS . $uninstallScriptElement->data())) {
             $path['src'] = $this->parent->getPath('source') . DS . $uninstallScriptElement->data();
             $path['dest'] = $this->parent->getPath('extension_administrator') . DS . $uninstallScriptElement->data();
             if (!$this->parent->copyFiles(array($path))) {
                 // Install failed, rollback changes
                 $this->parent->abort(JText::_('Component') . ' ' . JText::_('Install') . ': ' . JText::_('Could not copy PHP uninstall file.'));
                 return false;
             }
         }
     }
     /**
      * ---------------------------------------------------------------------------------------------
      * Database Processing Section
      * ---------------------------------------------------------------------------------------------
      */
     /*
      * Let's run the install queries for the component
      *	If backward compatibility is required - run queries in xml file
      *	If Joomla 1.5 compatible, with discreet sql files - execute appropriate
      *	file for utf-8 support or non-utf-8 support
      */
     $result = $this->parent->parseQueries($this->manifest->getElementByPath('install/queries'));
     if ($result === false) {
         // Install failed, rollback changes
         $this->parent->abort(JText::_('Component') . ' ' . JText::_('Install') . ': ' . JText::_('SQL Error') . " " . $db->stderr(true));
         return false;
     } elseif ($result === 0) {
         // no backward compatibility queries found - try for Joomla 1.5 type queries
         // second argument is the utf compatible version attribute
         $utfresult = $this->parent->parseSQLFiles($this->manifest->getElementByPath('install/sql'));
         if ($utfresult === false) {
             // Install failed, rollback changes
             $this->parent->abort(JText::_('Component') . ' ' . JText::_('Install') . ': ' . JText::_('SQLERRORORFILE') . " " . $db->stderr(true));
             return false;
         }
     }
     // Time to build the admin menus
     $this->_buildAdminMenus();
     /**
      * ---------------------------------------------------------------------------------------------
      * Custom Installation Script Section
      * ---------------------------------------------------------------------------------------------
      */
     /*
      * If we have an install script, lets include it, execute the custom
      * install method, and append the return value from the custom install
      * method to the installation message.
      */
     if ($this->get('install.script')) {
         if (is_file($this->parent->getPath('extension_administrator') . DS . $this->get('install.script'))) {
             ob_start();
             ob_implicit_flush(false);
             require_once $this->parent->getPath('extension_administrator') . DS . $this->get('install.script');
             if (function_exists('com_install')) {
                 if (com_install() === false) {
                     $this->parent->abort(JText::_('Component') . ' ' . JText::_('Install') . ': ' . JText::_('Custom install routine failure'));
                     return false;
                 }
             }
             $msg = ob_get_contents();
             ob_end_clean();
             if ($msg != '') {
                 $this->parent->set('extension.message', $msg);
             }
         }
     }
     /**
      * ---------------------------------------------------------------------------------------------
      * Finalization and Cleanup Section
      * ---------------------------------------------------------------------------------------------
      */
     // Lastly, we will copy the manifest file to its appropriate place.
     if (!$this->parent->copyManifest()) {
         // Install failed, rollback changes
         $this->parent->abort(JText::_('Component') . ' ' . JText::_('Install') . ': ' . JText::_('Could not copy setup file'));
         return false;
     }
     return true;
 }
Example #20
0
     break;
 case 'toggleajax':
     toggleProperty(aecGetParam('type'), aecGetParam('id'), aecGetParam('property'));
     exit;
     break;
 case 'addgroupajax':
     addGroup(aecGetParam('type'), aecGetParam('id'), aecGetParam('group'));
     exit;
     break;
 case 'removegroupajax':
     removeGroup(aecGetParam('type'), aecGetParam('id'), aecGetParam('group'));
     exit;
     break;
 case 'recallinstall':
     include_once JPATH_SITE . '/administrator/components/com_acctexp/install.acctexp.php';
     com_install();
     break;
 case 'initsettings':
     $aecConfig = new aecConfig();
     $aecConfig->initParams();
     echo 'SPLINES RETICULATED.';
     break;
 case 'parsertest':
     $top = new templateOverrideParser();
     break;
 case 'lessen':
     include_once JPATH_SITE . '/components/com_acctexp/lib/lessphp/lessc.inc.php';
     $less = new lessc();
     $less->setImportDir(array(JPATH_SITE . '/media/com_acctexp/less/'));
     //$less->setFormatter("compressed");
     $less->setPreserveComments(true);