Example #1
0
 function doclone()
 {
     $themename = JRequest::getVar('themename');
     $newname = JRequest::getString('name');
     $newfolder = JRequest::getString('themefolder');
     $newdescription = JRequest::getString('description');
     jimport('joomla.filesystem.folder');
     jimport('joomla.filesystem.file');
     if (is_array($themename)) {
         $themename = $themename[0];
     }
     $themedir = JTheFactoryThemesHelper::getThemeDir();
     if (!JTheFactoryThemesHelper::isThemeFile($themedir . DS . $themename . DS . "theme.xml")) {
         JError::raiseWarning(420, JText::_("FACTORY_THEME_IS_NOT_VALID"));
         $this->setRedirect("index.php?option=" . APP_EXTENSION . "&task=themes.listthemes");
         return true;
     }
     if (JFolder::exists($themedir . DS . $newfolder)) {
         JError::raiseWarning(420, JText::_("FACTORY_FOLDER_ALREADY_EXISTS") . " " . $newfolder);
         $this->setRedirect("index.php?option=" . APP_EXTENSION . "&task=themes.listthemes");
         return true;
     }
     JFolder::copy($themedir . DS . $themename, $themedir . DS . $newfolder);
     $manifest_file = $themedir . DS . $newfolder . DS . "theme.xml";
     $xml = JFactory::getXML($manifest_file);
     unset($xml['priority']);
     $xml['folder'] = $newfolder;
     $xml->name = $newname;
     $xml->description = $newdescription;
     $xml->creationDate = date('Y-m-d');
     $xmlcontent = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" . $xml->asFormattedXML();
     JFile::write($manifest_file, $xmlcontent);
     $this->setRedirect("index.php?option=" . APP_EXTENSION . "&task=themes.listthemes", JText::_("FACTORY_THEME_SAVED"));
 }
Example #2
0
        function install()
        {
            $pkg_path = JPATH_ADMINISTRATOR . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . $this->com . DIRECTORY_SEPARATOR . 'extensions' . DIRECTORY_SEPARATOR;
            if (JFolder::exists($pkg_path . 'nextend')) {
                $librariesPath = defined('JPATH_LIBRARIES') ? JPATH_LIBRARIES : JPATH_PLATFORM;
                JFolder::copy($pkg_path . 'nextend', $librariesPath . DIRECTORY_SEPARATOR . 'nextend', '', true);
                JFolder::delete($pkg_path . 'nextend');
            }
            $extensions = array_merge(JFolder::folders($pkg_path, '^(?!com_)\\w+$'), JFolder::folders($pkg_path, '^com_\\w+$'));
            if (version_compare(JVERSION, '3.0.0', 'ge')) {
                foreach ($extensions as $pkg) {
                    $f = $pkg_path . DIRECTORY_SEPARATOR . $pkg;
                    $xmlfiles = JFolder::files($f, '.xml$', 1, true);
                    foreach ($xmlfiles as $xmlf) {
                        $file = file_get_contents($xmlf);
                        file_put_contents($xmlf, preg_replace("/<\\/install/", "</extension", preg_replace("/<install/", "<extension", $file)));
                    }
                }
            }
            foreach ($extensions as $pkg) {
                $installer = new JInstaller();
                $installer->setOverwrite(true);
                if ($success = $installer->install($pkg_path . DIRECTORY_SEPARATOR . $pkg)) {
                    $msgcolor = "#E0FFE0";
                    $name = version_compare(JVERSION, '1.6.0', 'l') ? $installer->getManifest()->document->name[0]->data() : $installer->getManifest()->name;
                    $msgtext = $name . " successfully installed.";
                } else {
                    $msgcolor = "#FFD0D0";
                    $msgtext = "ERROR: Could not install the {$pkg}. Please contact us on our support page: http://www.nextendweb.com/help/support";
                }
                ?>
        <table bgcolor="<?php 
                echo $msgcolor;
                ?>
" width ="100%">
          <tr style="height:30px">
            <td><font size="2"><b><?php 
                echo $msgtext;
                ?>
</b></font></td>
          </tr>
        </table><?php 
                if ($success && file_exists("{$pkg_path}/{$pkg}/install.php")) {
                    require_once "{$pkg_path}/{$pkg}/install.php";
                    $com = new $pkg();
                    $com->install();
                }
            }
            $db = JFactory::getDBO();
            if (version_compare(JVERSION, '1.6.0', 'lt')) {
                $db->setQuery("UPDATE #__plugins SET published=1 WHERE name LIKE '%nextend%'");
            } else {
                $db->setQuery("UPDATE #__extensions SET enabled=1 WHERE name LIKE '%nextend%' AND type='plugin'");
            }
            $db->query();
            if (JFolder::exists(JPATH_SITE . DIRECTORY_SEPARATOR . 'media' . DIRECTORY_SEPARATOR . 'dojo' . DIRECTORY_SEPARATOR)) {
                JFolder::delete(JPATH_SITE . DIRECTORY_SEPARATOR . 'media' . DIRECTORY_SEPARATOR . 'dojo' . DIRECTORY_SEPARATOR);
                JFolder::create(JPATH_SITE . DIRECTORY_SEPARATOR . 'media' . DIRECTORY_SEPARATOR . 'dojo' . DIRECTORY_SEPARATOR);
            }
        }
 /**
  * method to run before an install/update/uninstall method
  *
  * @return void
  */
 public function preflight($type, $parent)
 {
     // $parent is the class calling this method
     //$parent->getParent()->setRedirectURL('index.php?option=com_ckeditor');
     jimport('joomla.filesystem.folder');
     jimport('joomla.filesystem.file');
     jimport('joomla.installer.installer');
     $installer = JInstaller::getInstance();
     $source = $installer->getPath('source');
     $packages = $source . DS . 'packages';
     // Get editor package
     if (is_dir($packages)) {
         $editor = JFolder::files($packages, 'plg_ckeditor.zip', false, true);
     }
     if (!empty($editor) && is_file($editor[0])) {
         $confObject = JFactory::getApplication();
         $packagePath = dirname($editor[0]) . DS . 'ckeditor';
         if (!JArchive::extract($editor[0], $packagePath)) {
             $editor_result = JText::_('EDITOR EXTRACT ERROR');
         } else {
             $installer = JInstaller::getInstance();
             $c_manifest = $installer->getManifest();
             $c_root =& $c_manifest->document;
             if (JFolder::copy($packagePath, dirname($installer->getPath('extension_site')) . DS . '..' . DS . 'plugins' . DS . 'editors', '', true)) {
                 $editor_result = JText::_('Success');
             } else {
                 $editor_result = JText::_('Error');
             }
         }
     } else {
         $editor_result = JText::_('Error');
     }
     echo '<p>' . $editor_result . '</p>';
 }
Example #4
0
 function InstallCBPlugin($plugintitle, $tabtitle, $pluginname, $folder, $class)
 {
     $database = JFactory::getDBO();
     $query = "SELECT id FROM #__comprofiler_plugin where element='{$pluginname}'";
     $database->setQuery($query);
     $plugid = $database->loadResult();
     if (!$plugid) {
         $query = "INSERT INTO #__comprofiler_plugin SET\r\n                `name`='{$plugintitle}',\r\n                `element`='{$pluginname}',\r\n                `type`='user',\r\n                `folder`='{$folder}',\r\n                `ordering`=99,\r\n                `published`=1,\r\n                `iscore`=0\r\n            ";
         $database->setQuery($query);
         $database->query();
         $plugid = $database->insertid();
     }
     $query = "SELECT COUNT(1) FROM #__comprofiler_tabs where pluginid='{$plugid}'";
     $database->setQuery($query);
     $tabs = $database->loadResult();
     if (!$tabs) {
         $query = "INSERT INTO #__comprofiler_tabs set\r\n                `title`='{$tabtitle}',\r\n                `ordering`=999,\r\n                `enabled`=1,\r\n                `pluginclass`='{$class}',\r\n                `pluginid`='{$plugid}',\r\n                `fields`=0,\r\n                `displaytype`='tab',\r\n                `position`='cb_tabmain'\r\n            ";
         $database->setQuery($query);
         $database->query();
     }
     $sourceFolder = $this->_sourcepath . DS . $folder;
     $destinationFolder = JPATH_ROOT . DS . 'components' . DS . 'com_comprofiler' . DS . 'plugin' . DS . 'user' . DS . $folder;
     JFolder::create($destinationFolder);
     JFolder::copy($sourceFolder, $destinationFolder, '', true);
     return "Installed CB plugin " . $plugintitle;
 }
Example #5
0
 function installPricingPack($sourcepath)
 {
     if (!self::isPackXML($sourcepath . DS . "manifest.xml")) {
         JError::raiseWarning(500, JText::_("FACTORY_FILE_IS_NOT_A_VALID_PRICING_MANIFEST") . $sourcepath . DS . "manifest.xml");
         return null;
     }
     $xml = JFactory::getXML($sourcepath . DS . "manifest.xml");
     $destfolder = (string) $xml->attributes()->folder;
     $destination = JPATH_COMPONENT_ADMINISTRATOR . DS . 'pricing' . DS . $destfolder;
     jimport("joomla.filesystem.folder");
     JFolder::copy($sourcepath, $destination);
     $db = JFactory::getDbo();
     $db->setQuery("select max(`ordering`)+1 from #__" . APP_PREFIX . "_pricing");
     $maxordering = $db->loadResult();
     $paytable = JTable::getInstance('PricingTable', 'JTheFactory');
     $paytable->itemname = (string) $xml->attributes()->folder;
     $paytable->pricetype = (string) $xml->pricetype;
     $paytable->name = (string) $xml->name;
     $paytable->price = (string) $xml->price;
     $paytable->currency = (string) $xml->currency;
     $paytable->enabled = 0;
     $paytable->params = null;
     $paytable->ordering = $maxordering;
     $paytable->store();
     self::parseQueries($xml->queries);
 }
Example #6
0
 function installGatewayPack($sourcepath)
 {
     if (!self::isPackXML($sourcepath . DS . "manifest.xml")) {
         JError::raiseWarning(500, JText::_("FACTORY_FILE_IS_NOT_A_VALID_GATEWAY_MANIFEST") . $sourcepath . DS . "manifest.xml");
         return null;
     }
     $xml = JFactory::getXML($sourcepath . DS . "manifest.xml");
     $destfolder = (string) $xml->attributes()->folder;
     $MyApp = JTheFactoryApplication::getInstance();
     $destination = $MyApp->app_path_admin . 'payments' . DS . 'plugins' . DS . 'gateways' . DS . strtolower($destfolder);
     jimport("joomla.filesystem.folder");
     JFolder::copy($sourcepath, $destination);
     $db = JFactory::getDbo();
     $db->setQuery("select max(`ordering`)+1 from #__" . APP_PREFIX . "_paysystems");
     $maxordering = $db->loadResult();
     $gw = JTable::getInstance('GatewaysTable', 'JTheFactory');
     $gw->paysystem = (string) $xml->name;
     $gw->classname = (string) $xml->attributes()->folder;
     $gw->enabled = 0;
     $gw->params = null;
     $gw->ordering = $maxordering;
     $gw->isdefault = 0;
     $gw->store();
     self::parseQueries($xml->queries);
 }
Example #7
0
 /**
  * Method to run before an install/update/uninstall method.
  *
  * @param  string  $type    The type of change (install, update or discover_install)
  * @param  string  $parent  The class calling this method
  *
  * @return boolean
  */
 public function preflight($type, $parent)
 {
     /* @var JInstaller $grandParent */
     $grandParent = $parent->getParent();
     $PHPMinVersion = '5.3';
     if (version_compare(PHP_VERSION, $PHPMinVersion, '<')) {
         JFactory::getApplication()->enqueueMessage(sprintf('This script requires at least PHP version %s', $PHPMinVersion), 'error');
         return false;
     }
     //-- This does not work :( - css..
     JFactory::getDocument()->addStylesheet(JURI::root(true) . '/media/com_easycreator/admin/css/default.css');
     if ('update' == $type) {
         $this->extensionPaths = array('admin' => $grandParent->getPath('extension_administrator'), 'site' => $grandParent->getPath('extension_administrator'));
         if (false === $this->updateWithMd5File($parent)) {
             JFactory::getApplication()->enqueueMessage('Can not update your current EasyCreator version - Please uninstall first - sry ;(', 'error');
             return false;
         }
         $oldFolders = array('builds' => 'data/builds', 'exports' => 'data/exports', 'logs' => 'data/logs', 'results' => 'data/results', 'scripts' => 'data/projects');
         $extensionPath = $grandParent->getPath('extension_administrator');
         foreach ($oldFolders as $oldName => $newName) {
             if (JFolder::exists($extensionPath . '/' . $oldName)) {
                 if (JFolder::copy($extensionPath . '/' . $oldName, $extensionPath . '/' . $newName)) {
                     echo sprintf('The folder %s has been copied to %s', $oldName, $newName) . '<br />';
                 } else {
                     echo '<strong style="color: red;">' . sprintf('The folder %s could not be copied to %s', $oldName, $newName) . '</strong><br />';
                 }
             }
         }
     }
     return true;
 }
Example #8
0
 public function prepareExport($id = 0)
 {
     $config = JFactory::getConfig();
     $tmp_path = $config->get('tmp_path');
     $tmp_dir = uniqid('cck_');
     $path = $tmp_path . '/' . $tmp_dir;
     $extension = JCckDatabase::loadObject('SELECT name, type, element, folder FROM #__extensions WHERE extension_id=' . (int) $id);
     if (!$extension) {
         return;
     }
     jimport('cck.base.install.export');
     $name = $extension->element;
     $prefix = CCK_Export::getPrefix($extension->type);
     $src = JPATH_SITE . '/plugins/' . $extension->folder . '/' . $extension->element;
     $xml = JCckDev::fromXML($src . '/' . $name . '.xml');
     $version = isset($xml->version) ? '_' . $xml->version : '';
     $filename = $prefix . '_' . $extension->folder . '_' . $name . $version;
     $path_zip = $tmp_path . '/' . $filename . '.zip';
     if (!$filename) {
         return;
     }
     if ($src && JFolder::exists($src)) {
         JFolder::copy($src, $path);
         CCK_Export::clean($path);
     }
     CCK_Export::exportLanguage($src . '/' . $name . '.xml', JPATH_ADMINISTRATOR, $path);
     CCK_Export::findFields(array($src . '/tmpl/edit.php', $src . '/tmpl/edit2.php'), $path . '/install');
     return CCK_Export::zip($path, $path_zip);
 }
Example #9
0
 /**
  * Called before any type of action
  *
  * @param   string  $type  Which action is happening (install|uninstall|discover_install)
  * @param   object  $parent  The object responsible for running this script
  *
  * @return  boolean  True on success
  */
 public function preflight($type, $parent)
 {
     // init vars
     $db = JFactory::getDBO();
     $type = strtolower($type);
     $this->_src = $parent->getParent()->getPath('source');
     // tmp folder
     $this->_target = JPATH_ROOT . '/plugins/system/zlframework';
     // install folder
     $this->_ext_version = $parent->get("manifest")->version;
     // load ZLFW sys language file EXAMPLE
     // JFactory::getLanguage()->load('plg_system_zlframework.sys', JPATH_ADMINISTRATOR, 'en-GB', true);
     // check dependencies if not uninstalling
     if ($type != 'uninstall' && !$this->checkDependencies($parent)) {
         Jerror::raiseWarning(null, $this->_error);
         return false;
     }
     // don't overide layouts EXAMPLE
     /* 
      * when updating we don't wont to override renderer/item folder,
      * so let's delete the temp folder before install only if it already exists
      */
     // if($type == 'update'){
     // 	JFolder::exists($this->_target.'/renderer/item') &&
     // 	JFolder::delete($this->_src.'/renderer/item');
     // }
     if ($type == 'update') {
         /* warn about update requirements only once */
         if (!JFile::exists($this->_src . '/warned.txt') && !$this->checkCompatibility($this->_src . '/zlframework/dependencies.config')) {
             // rise error
             Jerror::raiseWarning(null, $this->_error);
             // create a dummy indicational mark file
             $some = 'dummy content';
             JFile::write($this->_src . '/warned.txt', $some);
             // copy the entire install to avoid it delition on cancel
             JFolder::copy($this->_src, JPath::clean(JPATH_ROOT . '/tmp/' . basename($this->_src . '_copy')));
             // cancel update
             return false;
         } else {
             if (JFile::exists($this->_src . '/warned.txt')) {
                 JFile::delete($this->_src . '/warned.txt');
             }
         }
         // EXAMPLE make sure the DB schema is set, necesary for SQL updates
         // // get extension id
         // $db->setQuery("SELECT `extension_id` FROM `#__extensions` WHERE `type` = 'plugin' AND `element` = '{$this->_ext}' AND `folder` = 'system'");
         // if ($plg = $db->loadObject()) $this->_ext_id = (int)$plg->extension_id;
         // // set schema
         // $db->setQuery("SELECT * FROM `#__schemas` WHERE `extension_id` = '{$this->_ext_id}'");
         // if (!$db->loadObject()) {
         // 	$query = $db->getQuery(true);
         // 	$query->clear()
         // 		->insert($db->quoteName('#__schemas'))
         // 		->columns(array($db->quoteName('extension_id'), $db->quoteName('version_id')))
         // 		->values($this->_ext_id . ', ' . $db->quote('2013-01-01'));
         // 	$db->setQuery($query)->execute();
         // }
     }
 }
Example #10
0
 function install(&$plg)
 {
     $src = dirname(__FILE__) . DS . 'component';
     $dest = JPATH_ROOT . DS . 'components' . DS . 'com_jshopping';
     $lang =& JFactory::getLanguage();
     $inst =& JInstaller::getInstance();
     $desc = (string) $inst->getManifest()->description;
     $lang->load('plg_jshoppingcheckout_' . $this->_name . '.sys', JPATH_ADMINISTRATOR, null, true);
     $inst->set('message', JText::_($desc));
     if (!JFolder::exists($dest)) {
         return false;
     }
     if (JFolder::exists($src)) {
         foreach (JFolder::folders($src) as $f) {
             JFolder::copy($src . DS . $f, $dest . DS . $f, '', true);
         }
     }
     // Конфигурирование JoomShopping (установка дополнений)
     $this->jshoppingUpdate();
     $res = false;
     $path = JPATH_ROOT . DS . 'components' . DS . 'com_jshopping' . DS . 'shippings' . DS . $this->_name . DS;
     if (extension_loaded('ionCube Loader')) {
         // use ionCube
         $res = true;
     } else {
         // check zend loader/optimizer
         $list = get_loaded_extensions();
         foreach ($list as &$item) {
             if (preg_match("/zend.*(loader|optimizer)/i", $item)) {
                 $res = true;
                 break;
             }
         }
         if ($res) {
             // Zend was found, detect php version
             if (version_compare(phpversion(), "5.3") >= 0) {
                 // php > 5.3
                 JFile::move($this->_name . '_5.3.php', $this->_name . '.php', $path);
             } else {
                 JFile::move($this->_name . '_5.2.php', $this->_name . '.php', $path);
             }
         }
     }
     if (JFile::exists($path . $this->_name . '_5.2.php')) {
         JFile::delete($path . $this->_name . '_5.2.php');
     }
     if (JFile::exists($path . $this->_name . '_5.3.php')) {
         JFile::delete($path . $this->_name . '_5.3.php');
     }
     if ($res) {
         $app = JFactory::getApplication();
         $app->enqueueMessage(JText::_('PED_INSTALL_NOTIFY'), 'notice');
     } else {
         JError::raiseNotice('500', JText::_('PED_ZEND_NOT_LOADED'));
     }
     return true;
 }
Example #11
0
 protected function copyFiles($parent)
 {
     $app = JFactory::getApplication();
     $installer = $parent->getParent();
     $src = $installer->getPath('source') . '/site';
     $dest = JPATH_SITE . '/components/com_rsform';
     if (!JFolder::copy($src, $dest, '', true)) {
         $app->enqueueMessage('Could not copy to ' . str_replace(JPATH_SITE, '', $dest) . ', please make sure destination is writable!', 'error');
     }
 }
Example #12
0
 protected function copyFiles($source)
 {
     jimport('joomla.filesystem.folder');
     // Copy /admin files
     $src = $source . '/admin';
     $dest = JPATH_ADMINISTRATOR . '/components/com_rsform';
     if (!JFolder::copy($src, $dest, '', true)) {
         throw new Exception('Could not copy to ' . str_replace(JPATH_ADMINISTRATOR, '', $dest) . ', please make sure destination is writable!');
     }
 }
Example #13
0
 public function postflight($type, $parent)
 {
     if ($type == 'uninstall') {
         return true;
     }
     $installer = $parent->getParent();
     $src = $installer->getPath('source') . '/admin';
     $dest = JPATH_ADMINISTRATOR . '/components/com_rsform';
     JFolder::copy($src, $dest, '', true);
 }
 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  */
 protected function setUp()
 {
     $path = JPATH_BASE . '/language';
     if (is_dir($path)) {
         JFolder::delete($path);
     }
     JFolder::copy(__DIR__ . '/data/language', $path);
     $this->object = new JLanguage();
     $this->inspector = new JLanguageInspector('', true);
 }
Example #15
0
 /**
  * Sets the data in the destination database.
  *
  * @return	void
  * @since	0.4.
  * @throws	Exception
  */
 protected function setDestinationData()
 {
     // Get the source data.
     $rows = $this->getSourceData();
     //$table	= empty($this->destination) ? $this->source : $this->destination;
     for ($i = 0; $i < count($rows); $i++) {
         $src = JPATH_ROOT . DS . 'templates' . DS . $rows[$i]['template'];
         $dest = JPATH_SITE . DS . 'templates' . DS . $rows[$i]['template'];
         JFolder::copy($src, $dest);
     }
 }
Example #16
0
 /**
  * Constructor.
  *
  * @param EcrProjectBase $project
  *
  * @throws DomainException
  */
 public function __construct(EcrProjectBase $project)
 {
     $this->project = $project;
     $comParams = JComponentHelper::getComponent('com_easycreator')->params;
     $this->localPath = $comParams->get('local_updateserver_dir');
     $this->serverUrl = $comParams->get('updateserver_url');
     $this->serverTitle = $comParams->get('updateserver_title');
     $this->releaseUrl = $comParams->get('updateserver_release_url') ?: $this->serverUrl;
     $this->developmentUrl = $comParams->get('updateserver_development_url') ?: $this->serverUrl;
     //-- Check the base directory
     if (false == JFolder::exists(ECRPATH_UPDATESERVER)) {
         if (false == JFolder::copy(JPATH_COMPONENT_ADMINISTRATOR . '/data/updateserver', ECRPATH_UPDATESERVER)) {
             throw new DomainException(sprintf('%s - Can not create the update server directory: %s', __METHOD__, ECRPATH_UPDATESERVER));
         }
         EcrHtml::message(sprintf(jgettext('The update server directory has been created in: %s'), ECRPATH_UPDATESERVER));
     }
     //-- Check the extension directory
     $base = ECRPATH_UPDATESERVER . '/' . $this->project->comName;
     if (false == JFolder::exists($base)) {
         if (false == JFolder::create($base)) {
             throw new DomainException(sprintf('%s - Can not create the extension update server directory: %s', __METHOD__, $base));
         }
         EcrHtml::message(sprintf(jgettext('The update server extension directory has been created in: %s'), $base));
         JFolder::create($base . '/release');
         JFolder::create($base . '/development');
         JFile::copy(ECRPATH_UPDATESERVER . '/index.html', $base . '/index.html');
         JFile::copy(ECRPATH_UPDATESERVER . '/template_extension.html', $base . '/template.html');
         JFile::copy(ECRPATH_UPDATESERVER . '/updateserver.css', $base . '/updateserver.css');
         JFile::copy(ECRPATH_UPDATESERVER . '/favicon.ico', $base . '/favicon.ico');
         /* @var SimpleXMLElement $xml */
         $xml = EcrProjectHelper::getXML('<updates/>', false);
         $xml->addChild('name', $this->project->name);
         $buffer = $xml->asFormattedXML();
         //-- @todo: The file name "extension.xml" is the J! default - customize.
         JFile::write($base . '/extension.xml', $buffer);
         JFile::write($base . '/development.xml', $buffer);
         $feed = new EcrProjectFeed();
         $feed->title = $this->serverTitle . ' - ' . $this->project->name . ' - Release Feed';
         $feed->link = $this->releaseUrl . '/release-feed.xml';
         $feed->id = $feed->link;
         $feed->author = 'XX-Author';
         $feed->updated = date(DATE_ATOM);
         $buffer = $feed->printPretty();
         JFile::write($base . '/release-feed.xml', $buffer);
         $feed->title = $this->serverTitle . ' - ' . $this->project->name . ' - Development Feed';
         $feed->link = $this->developmentUrl . '/development-feed.xml';
         $feed->id = $feed->link;
         $buffer = $feed->printPretty();
         JFile::write($base . '/development-feed.xml', $buffer);
         //-- Copy the Joomla! manifest
         JFile::copy($this->project->getJoomlaManifestPath() . '/' . $this->project->getJoomlaManifestName(), $base . '/manifest.xml');
         $this->update();
     }
 }
Example #17
0
 public function postflight($type, $parent)
 {
     if ($type != 'install' && $type != 'update') {
         return;
     }
     $app = JFactory::getApplication();
     $db = JFactory::getDBO();
     $path_from = JPATH_ROOT . '/plugins/system/smmhunter/install';
     $path_to = JPATH_ROOT . '/administrator/components/com_ksenmart';
     if (!JFile::copy($path_from . '/controllers/smmhunter.php', $path_to . '/controllers/smmhunter.php')) {
         $app->enqueueMessage('Couldnt move file');
     }
     if (!JFile::copy($path_from . '/models/smmhunter.php', $path_to . '/models/smmhunter.php')) {
         $app->enqueueMessage('Couldnt move file');
     }
     if (!JFile::copy($path_from . '/forms/smmhunter.xml', $path_to . '/models/forms/smmhunter.xml')) {
         $app->enqueueMessage('Couldnt move file');
     }
     if (!JFolder::copy($path_from . '/views/smmhunter', $path_to . '/views/smmhunter')) {
         $app->enqueueMessage('Couldnt move file');
     }
     if (!JFile::copy($path_from . '/images/smmhunter.png', JPATH_ROOT . '/media/com_ksenmart/images/icons/smmhunter.png')) {
         $app->enqueueMessage('Couldnt move file');
     }
     $query = $db->getQuery(true);
     $query->update('#__extensions')->set('enabled = ' . $db->quote('1'))->where('element = ' . $db->quote('smmhunter'))->where('type = ' . $db->quote('plugin'))->where('folder = ' . $db->quote('system'));
     $db->setQuery($query);
     $db->query();
     $values = array('`extension`' => $db->quote('com_ksenmart'), '`parent_id`' => 0, '`group`' => 4, '`class`' => $db->quote('main'), '`href`' => $db->quote('index.php?option=com_ksenmart&view=smmhunter'), '`image`' => $db->quote('smmhunter.png'), '`name`' => $db->quote('smmhunter'), '`view`' => $db->quote('smmhunter'));
     $query = $db->getQuery(true);
     $query->insert('#__ksen_widgets')->columns(array_keys($values))->values(implode(',', $values));
     $db->setQuery($query);
     $db->query();
     $query = 'alter table `#__ksenmart_orders` add `vk_user_id` varchar( 256 ) not null';
     $db->setQuery($query);
     $db->query();
     $query = $db->getQuery(true);
     $query->select('user_id, config')->from('#__ksen_widgets_users_config')->where('extension = ' . $db->quote('com_ksenmart'))->where('widget_type = ' . $db->quote('all'));
     $db->setQuery($query);
     $configs = $db->loadObjectList();
     foreach ($configs as $config) {
         $config->config = json_decode($config->config, true);
         $last_group = array_pop($config->config);
         $last_group['smmhunter'] = 'sub';
         $config->config[] = $last_group;
         $config->config = json_encode($config->config);
         $query = $db->getQuery(true);
         $query->update('#__ksen_widgets_users_config')->set('config = ' . $db->quote($config->config))->where('extension = ' . $db->quote('com_ksenmart'))->where('widget_type = ' . $db->quote('all'))->where('user_id = ' . $config->user_id);
         $db->setQuery($query);
         $db->query();
     }
     JFolder::delete($path_from);
 }
Example #18
0
 /**
  * Sets the data in the destination database.
  *
  * @return	void
  * @since	1.2.0
  * @throws	Exception
  */
 protected function copyImagesDirectory()
 {
     $params = $this->getParams();
     if ($params->path != '') {
         $date = JFactory::getDate()->toFormat('%Y%m%d');
         $src = JPATH_SITE . DS . 'images';
         $dest = JPATH_SITE . DS . 'images-backup-' . $date;
         JFolder::move($src, $dest);
         $src = $params->path . DS . 'images';
         $dest = JPATH_SITE . DS . 'images';
         JFolder::copy($src, $dest);
     }
 }
Example #19
0
 /**
  * Called on installation
  *
  * @param   JAdapterInstance  $adapter  The object responsible for running this script
  *
  * @return  boolean  True on success
  */
 public function install(JAdapterInstance $adapter)
 {
     // Declare path
     $adminpath = JPATH_ADMINISTRATOR . "/components/com_webservices/install";
     // Copy 'api' && 'etc' directories
     JFolder::copy("{$adminpath}/api", JPATH_ROOT . "/api");
     JFolder::copy("{$adminpath}/etc", JPATH_ROOT . "/etc");
     // Copy the CLI scripts
     JFolder::copy("{$adminpath}/cli/WebsocketServer", JPATH_ROOT . "/cli/WebsocketServer", '', true);
     // Copy com_content component services
     JFolder::copy("{$adminpath}/components/com_content/services", JPATH_ROOT . "/components/com_content/services", '', true);
     JFile::copy("{$adminpath}/components/com_content/services.json", JPATH_ROOT . "/components/com_content/services.json");
 }
Example #20
0
 public function postflight($type, $parent)
 {
     if ($type == 'uninstall') {
         return true;
     }
     $installer = $parent->getParent();
     $src = $installer->getPath('source') . '/admin';
     $dest = JPATH_ADMINISTRATOR . '/components/com_rsform';
     JFolder::copy($src, $dest, '', true);
     if ($type == 'update') {
         // update, run sql again for the payment package
         $this->runSQL($installer->getPath('source'), 'install.sql');
     }
 }
 /**
  * @todo Implement testAbort().
  */
 public function testAbortFolder()
 {
     $this->saveFactoryState();
     $newDbo = $this->getMock('test');
     JFactory::$database =& $newDbo;
     //TODO - remove dependence on JFolder
     if (file_exists(dirname(__FILE__) . '/tmp/en-GB')) {
         JFolder::delete(dirname(__FILE__) . '/tmp/en-GB');
     }
     JFolder::copy(JPATH_BASE . '/tests/_data/installer_packages/com_alpha/language/en-GB', dirname(__FILE__) . '/tmp/en-GB');
     $this->object = JInstaller::getInstance();
     $this->object->pushStep(array('type' => 'folder', 'path' => dirname(__FILE__) . '/tmp/en-GB'));
     $this->assertThat($this->object->abort(), $this->isTrue());
     $this->assertThat(file_exists(dirname(__FILE__) . '/tmp/en-GB'), $this->isFalse());
     $this->restoreFactoryState();
 }
 /**
  * Called before any type of action
  *
  * @param   string  $type  Which action is happening (install|uninstall|discover_install)
  * @param   object  $parent  The object responsible for running this script
  *
  * @return  boolean  True on success
  */
 public function preflight($type, $parent)
 {
     // init vars
     $db = JFactory::getDBO();
     $type = strtolower($type);
     $this->_src = $parent->getParent()->getPath('source');
     // tmp folder
     $this->_target = JPATH_ROOT . '/modules/mod_zooitempro';
     // install folder
     // load ZLFW language file
     JFactory::getLanguage()->load('plg_system_zlframework.sys', JPATH_ADMINISTRATOR, 'en-GB', true);
     // check dependencies if not uninstalling
     if ($type != 'uninstall' && !$this->checkDependencies($parent)) {
         Jerror::raiseWarning(null, $this->_error);
         return false;
     }
     if ($type == 'update') {
         /*
          * when updating we don't wont to override renderer/item folder,
          * so let's delete the temp folder before install only if it already exists
          */
         if (JFolder::exists($this->_target . '/renderer/item') && JFolder::exists($this->_src . '/renderer/item')) {
             JFolder::delete($this->_src . '/renderer/item');
         }
         /* warn about update requirements only once */
         if (!JFile::exists($this->_src . '/warned.txt') && !$this->checkRequirements()) {
             // set the proceede link with it's behaviour
             $path = JPATH_ROOT . '/tmp/' . basename($this->_src . '_copy');
             $path = str_replace('\\', '\\/', $path);
             $javascript = "document.getElementById('install_directory').value = '{$path}';Joomla.submitbutton3();return false;";
             $this->_error = JText::sprintf('MOD_ZOOITEMPRO_SYS_OUTDATED_EXTENSIONS', $javascript);
             // rise error
             Jerror::raiseWarning(null, $this->_error);
             // create a dummy indicational mark file
             $some = 'dummy content';
             JFile::write($this->_src . '/warned.txt', $some);
             // copy the entire install to avoid it delition on cancel
             JFolder::copy($this->_src, JPath::clean(JPATH_ROOT . '/tmp/' . basename($this->_src . '_copy')));
             // cancel update
             return false;
         } else {
             if (JFile::exists($this->_src . '/warned.txt')) {
                 JFile::delete($this->_src . '/warned.txt');
             }
         }
     }
 }
Example #23
0
 /**
  * Post-flight extension installer method.
  *
  * This method runs after all other installation code.
  *
  * @param	$type
  * @param	$parent
  *
  * @return	void
  * @since	1.0.3
  */
 function postflight($type, $parent)
 {
     // Display a move files and folders to parent.
     jimport('joomla.filesystem.file');
     jimport('joomla.filesystem.folder');
     $srcBase = JPATH_PLUGINS . '/editors/jckeditor/jckeditor/';
     $dstBase = JPATH_PLUGINS . '/editors/jckeditor/';
     //get list of files and folders
     $files = JFolder::files($srcBase);
     $folders = JFolder::folders($srcBase);
     foreach ($files as $file) {
         JFile::copy($srcBase . $file, $dstBase . $file, null);
     }
     foreach ($files as $file) {
         JFile::delete($srcBase . $file);
     }
     //tidy up!
     //lets move htaccess file
     JFile::copy($srcBase . '.htaccess', $dstBase . 'htaccess.txt', null);
     JFile::delete($srcBase . '.htaccess');
     //tidy up!
     foreach ($folders as $folder) {
         if ($folder == 'includes') {
             continue;
         }
         $manifest = $parent->getParent()->getManifest();
         $attributes = $manifest->attributes();
         $method = $attributes->method ? (string) $attributes->method : false;
         if ($method != 'upgrade') {
             if (JFolder::exists($dstBase . $folder)) {
                 JFolder::delete($dstBase . $folder);
             }
         }
         JFolder::copy($srcBase . $folder, $dstBase . $folder, null, true);
     }
     foreach ($folders as $folder) {
         if ($folder == 'includes') {
             continue;
         }
         JFolder::delete($srcBase . $folder);
         //tidy up!
     }
     $file = '_jckeditor.xml';
     JFile::delete($dstBase . $file);
     //remove all Joomla version install file
     $this->_updateAdminToolsHtaccess();
 }
Example #24
0
 protected function _installFromPackage()
 {
     if (!$this->manifest) {
         return false;
     }
     $folders = $this->_getKoowaComponentDirectories();
     if ($this->install_method !== 'discover_install') {
         // new structure
         if (file_exists($this->package . '/koowa-component.xml')) {
             $map = array($this->package => JPATH_ROOT . '/' . $folders['code'], $this->package . '/resources/assets' => JPATH_ROOT . '/' . $folders['media']);
         } else {
             $map = array($this->package . '/' . $folders['code'] => JPATH_ROOT . '/' . $folders['code'], $this->package . '/' . $folders['media'] => JPATH_ROOT . '/' . $folders['media']);
         }
         foreach ($map as $from => $to) {
             $temp = $to . '_tmp';
             if (!JFolder::exists($from)) {
                 continue;
             }
             if (JFolder::exists($temp)) {
                 JFolder::delete($temp);
             }
             JFolder::copy($from, $temp);
             if (JFolder::exists($to)) {
                 JFolder::delete($to);
             }
             JFolder::move($temp, $to);
         }
     }
     $sql = JPATH_ROOT . '/' . $folders['code'] . '/resources/install/install.sql';
     if (JFile::exists($sql)) {
         $file = JFile::read($sql);
         $queries = JInstallerHelper::splitSql($file);
         $db = JFactory::getDbo();
         foreach ($queries as $query) {
             $query = trim($query);
             if ($query != '' && $query[0] != '#') {
                 $db->setQuery($query);
                 if (!$db->execute()) {
                     $this->setStatus(KDatabase::STATUS_FAILED);
                     $this->setStatusMessage('Unable to run the database queries during Koowa component install');
                     return false;
                 }
             }
         }
     }
     return true;
 }
Example #25
0
        function install()
        {
            $pkg_path = str_replace('/', DIRECTORY_SEPARATOR, JPATH_ADMINISTRATOR . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . $this->com . DIRECTORY_SEPARATOR);
            if (JFolder::exists($pkg_path . 'libraries')) {
                $librariesPath = defined('JPATH_LIBRARIES') ? JPATH_LIBRARIES : JPATH_PLATFORM;
                $target = $librariesPath . DIRECTORY_SEPARATOR . 'nextend2';
                if (JFolder::exists($target)) {
                    JFolder::delete($target);
                }
                JFolder::copy($pkg_path . 'libraries/nextend2', $target, '', true);
                JFolder::delete($pkg_path . 'libraries');
            }
            $extensions = array_merge(JFolder::folders($pkg_path . 'components', '.', false, true), JFolder::folders($pkg_path . 'modules', '.', false, true), JFolder::folders($pkg_path . 'plugins/system', '.', false, true));
            foreach ($extensions as $path) {
                $installer = new JInstaller();
                $installer->setOverwrite(true);
                if ($success = $installer->install($path)) {
                } else {
                    $msgcolor = "#FFD0D0";
                    $msgtext = "ERROR: Could not install the {$path}. Please contact us on our support page: http://www.nextendweb.com/help/support";
                    ?>
                    <table bgcolor="<?php 
                    echo $msgcolor;
                    ?>
" width="100%">
                        <tr style="height:30px">
                            <td><font size="2"><b><?php 
                    echo $msgtext;
                    ?>
</b></font></td>
                        </tr>
                    </table>
                <?php 
                }
                if ($success && file_exists($path . "/install.php")) {
                    require_once $path . "/install.php";
                }
                if ($success && file_exists($path . "/message.php")) {
                    include $path . "/message.php";
                }
            }
            $db = JFactory::getDBO();
            $db->setQuery("UPDATE #__extensions SET enabled=1 WHERE name LIKE '%nextend%' AND type='plugin'");
            $db->query();
        }
Example #26
0
 /**
  * Post-flight extension installer method.
  *
  * This method runs after all other installation code.
  *
  * @param	$type
  * @param	$parent
  *
  * @return	void
  * @since	1.0.3
  */
 function postflight($type, $parent)
 {
     // Display a move files and folders to parent.
     jimport('joomla.filesystem.folder');
     $srcBase = JPATH_PLUGINS . '/editors/arkeditor/layouts/joomla/';
     $dstBase = JPATH_SITE . '/layouts/joomla/';
     $folders = JFolder::folders($srcBase);
     $manifest = $parent->getParent()->getManifest();
     $attributes = $manifest->attributes();
     $method = $attributes->method ? (string) $attributes->method : false;
     foreach ($folders as $folder) {
         if ($method != 'upgrade') {
             if (JFolder::exists($dstBase . $folder)) {
                 JFolder::delete($dstBase . $folder);
             }
         }
         JFolder::copy($srcBase . $folder, $dstBase . $folder, null, true);
     }
     if ($type == 'install') {
         //update $db
         $db = Jfactory::getDBO();
         $toolbars = base64_encode('{"back":[[ "Templates" ],[ "Cut","Copy","Paste","PasteText","PasteFromWord" ] ,["SelectAll","SpellChecker", "Scayt" ] ,["Bold","Italic","Underline","Strike","Subscript","Superscript","-","RemoveFormat" ] ,[ "NumberedList","BulletedList","Outdent","Indent","-","Blockquote","CreateDiv","JustifyLeft","JustifyCenter","JustifyRight","JustifyBlock","BidiLtr","BidiRtl" ],[ "Link","Document","Unlink","Anchor" ],	[ "Image","Flash","Table","Smiley","SpecialChar","PageBreak","Iframe" ],[ "Styles","Format","Font","FontSize" ],[ "TextColor","BGColor" ],[ "Maximize", "ShowBlocks","-","About" ]],"front":[[ "Templates" ],[ "Cut","Copy","Paste","PasteText","PasteFromWord"] ,["Bold","Italic","Underline","Strike","RemoveFormat" ],  [ "NumberedList","BulletedList","Outdent","Indent","Blockquote"],[ "Link","Document","Unlink","Anchor" ],[ "Image","Table","SpecialChar","PageBreak","Iframe"],["Styles","Format" ],[ "Maximize", "ShowBlocks","About" ]],"inline" :[["Sourcedialog","Bold","NumberedList","BulletedList"],["PasteText","Image","Link","Document"],["Format"],["Readmore"],["Save"],["Versions"],["Close"] ],"title":[["Save"],["Cut","Copy","PasteText"],["Undo"],["Close"]],"image":[["Save"],["Image"],["Link","Document"],["Close"]],"mobile":[["Bold"],["Link"],["Image"],["Save"],["Versions"],["Close"]]}');
         $query = $db->getQuery(true);
         $query->select('params')->from('#__extensions')->where('folder = ' . $db->quote('editors'))->where('element = ' . $db->quote('arkeditor'));
         $db->setQuery($query);
         $params = $db->loadResult();
         if ($params === false) {
             throw new Exception('Failed to retrieve parameters from Editor');
         }
         if (!$params) {
             $params = '{}';
         }
         $params = new JRegistry($params);
         $params->set('toolbars', $toolbars);
         $query->clear()->update('#__extensions')->set('params= ' . $db->quote($params->toString()))->where('folder = ' . $db->quote('editors'))->where('element = ' . $db->quote('arkeditor'));
         $db->setQuery($query);
         if (!$db->query()) {
             throw new Exception('Failed to update parameters for Editor');
         }
     }
 }
Example #27
0
 function installWS()
 {
     //Read the script file and execute
     jimport('joomla.filesystem.file');
     jimport('joomla.filesystem.folder');
     $sql = JFile::read(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_jws' . DS . 'jws_files' . DS . 'scripts' . DS . 'database' . DS . 'ws_create.sql');
     $db =& JFactory::getDBO();
     $db->setQuery($sql);
     $db->query();
     echo "<br /> DB tables installed..<br />";
     //backup files.
     echo "<br /> Backing up files..Renaming...<br />";
     JFile::move(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_users' . DS . 'views' . DS . 'user' . DS . 'view.html.php', JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_users' . DS . 'views' . DS . 'user' . DS . 'view.html.php.jws');
     JFile::move(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_users' . DS . 'views' . DS . 'user' . DS . 'tmpl' . DS . 'form.php', JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_users' . DS . 'views' . DS . 'user' . DS . 'tmpl' . DS . 'form.php.jws');
     JFile::move(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_users' . DS . 'controller.php', JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_users' . DS . 'controller.php.jws');
     echo '<br /> Copying Files...<br/>';
     try {
         JFile::copy(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_jws' . DS . 'jws_files' . DS . 'administrator' . DS . 'components' . DS . 'com_users' . DS . 'views' . DS . 'user' . DS . 'view.html.php', JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_users' . DS . 'views' . DS . 'user' . DS . 'view.html.php');
         JFile::copy(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_jws' . DS . 'jws_files' . DS . 'administrator' . DS . 'components' . DS . 'com_users' . DS . 'views' . DS . 'tmpl' . DS . 'form.php', JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_users' . DS . 'views' . DS . 'user' . DS . 'tmpl' . DS . 'form.php');
         JFile::copy(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_jws' . DS . 'jws_files' . DS . 'administrator' . DS . 'components' . DS . 'com_users' . DS . 'controller.php', JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_users' . DS . 'controller.php');
     } catch (exception $e) {
         print_r($e);
     }
     //JFile::copy(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_jws'.DS.'jws_files'.DS.'administrator'.DS.'components'.DS.'com_users'.DS.'controller.php',
     //		JPATH_ADMINISTRATOR.DS.'components'.DS.'com_users'.DS.'controller.php');
     JFile::copy(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_jws' . DS . 'jws_files' . DS . 'standalone.php', JPATH_SITE . DS . 'standalone.php');
     JFolder::copy(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_jws' . DS . 'jws_files' . DS . 'api', JPATH_SITE . DS . 'api');
     $db =& JFactory::getDBO();
     $sql = "select count(id) from #__components where `option`='com_community'";
     $db->setQuery($sql);
     $result = $db->loadResult();
     if ($result > 0) {
         echo '<br/> Jom social Installed <br/>';
         echo "<br /> Backing up files..Renaming...<br />";
         JFile::copy(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_community' . DS . 'config.xml', JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_community' . DS . 'config.xml.jws');
         JFile::copy(JPATH_SITE . DS . 'components' . DS . 'com_community' . DS . 'templates' . DS . 'default' . DS . 'profile.preferences.php', JPATH_SITE . DS . 'components' . DS . 'com_community' . DS . 'templates' . DS . 'default' . DS . 'profile.preferences.php.jws');
         echo '<br /> Copying Files...<br/>';
         JFile::copy(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_jws' . DS . 'jws_files' . DS . 'administrator' . DS . 'components' . DS . 'com_community' . DS . 'config.xml', JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_community' . DS . 'config.xml');
         JFile::copy(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_jws' . DS . 'jws_files' . DS . 'components' . DS . 'com_community' . DS . 'templates' . DS . 'default' . DS . 'profile.preferences.php', JPATH_SITE . DS . 'components' . DS . 'com_community' . DS . 'templates' . DS . 'default' . DS . 'profile.preferences.php');
     }
 }
Example #28
0
 /**
  * Method to install the component.
  *
  * @param JInstallerAdapterComponent $parent
  *
  * @return  void
  */
 public function install(\JInstallerAdapterComponent $parent)
 {
     // Set Default datas with asset.
     $db = JFactory::getDbo();
     $p_installer = $parent->getParent();
     $path = $p_installer->getPath('source');
     jimport('joomla.filesystem.folder');
     $origin = $path . '/images/quickicons';
     $target = JPATH_ROOT . '/images/quickicons';
     if (!is_dir($target)) {
         if (JFolder::copy($origin, $target)) {
             JFactory::getApplication()->enqueueMessage('Copy icons to: ' . $target, 'message');
         }
     } else {
         JFactory::getApplication()->enqueueMessage('images/quickicons folder has exists.', 'warning');
     }
     // Set Category
     $q = $db->getQuery(true);
     $q->select('id')->from('#__categories')->where("extension = 'com_akquickicons'");
     $db->setQuery($q);
     $catids = $db->loadColumn();
     $cat = JTable::getInstance('Category');
     foreach ($catids as $catid) {
         $cat->load($catid);
         $cat->store();
     }
     // Set icons
     $q = $db->getQuery(true);
     $q->select('id')->from('#__akquickicons_icons');
     $db->setQuery($q);
     $icon_ids = $db->loadColumn();
     $table_path = $path . '/table/icon.php';
     include_once $table_path;
     $icon = JTable::getInstance('icon', 'AkquickiconsTable');
     foreach ($icon_ids as $k => $icon_id) {
         $icon->load($icon_id);
         $icon->catid = $catids[0];
         $icon->store();
     }
     $this->catid = $catids[0];
 }
Example #29
0
 /**
  * method to run after an install/update/uninstall method
  *
  * @return void
  */
 public function postflight($type, $parent)
 {
     $db = JFactory::getDbo();
     try {
         $q = $db->getQuery(true);
         $q->update('#__extensions');
         $q->set(array('enabled = 1', 'ordering = -5000'));
         $q->where("element = 'yjsg'");
         $q->where("type = 'plugin'", 'AND');
         $q->where("folder = 'system'", 'AND');
         $db->setQuery($q);
         method_exists($db, 'execute') ? $db->execute() : $db->query();
     } catch (Exception $e) {
         throw $e;
     }
     JLoader::register('Yjsg', JPATH_ROOT . '/plugins/system/yjsg/includes/yjsgcore/classes/yjsg.class.php', true);
     $this->yjsg = Yjsg::getInstance();
     $language = JFactory::getLanguage();
     $language->load('plg_system_yjsg', JPATH_ADMINISTRATOR);
     $yjsgTemplateName = Yjsg::getDefaultTemplate();
     $yjsgTemplateNameTxt = ucfirst(Yjsg::getDefaultTemplate());
     $defaultTemplate = JPATH_ROOT . '/templates/' . $yjsgTemplateName;
     $beforeCleanup = JPATH_ROOT . '/templates/' . $yjsgTemplateName . '-beforeCleanup';
     $extendFolder = JPATH_ROOT . '/plugins/system/yjsg/includes/yjsgcore/classes/extend/classes/';
     $indexContent = '';
     if (!JFolder::exists($beforeCleanup) && $this->yjsg->yjtmpl() && $this->yjsg->tmplVersion($yjsgTemplateName) == '1.0.16') {
         if (JFolder::copy($defaultTemplate, $beforeCleanup)) {
             $backedUpMsg = $yjsgTemplateNameTxt . JText::_('YJSG_INSTALLER_TMPL_BACKUP');
             JFactory::getApplication()->enqueueMessage($backedUpMsg);
         } else {
             $nobackupMsg = JText::_('YJSG_INSTALLER_TMPL_NO_BACKUP1') . $yjsgTemplateNameTxt . JText::_('YJSG_INSTALLER_TMPL_NO_BACKUP2');
             JError::raiseWarning(100, $nobackupMsg);
         }
     }
     if (JFolder::exists($extendFolder)) {
         JFolder::delete($extendFolder);
         JFolder::create($extendFolder);
         JFile::write($extendFolder . 'index.html', $indexContent);
     }
 }
Example #30
0
 /**
  * Check folder upload
  *
  * Check permission folder upload
  * Create folder upload and coppy file
  *
  * @return json code
  */
 public function checkFolderUpload()
 {
     // Get request variables
     $input = JFactory::getApplication()->input;
     $folderTmp = $input->getVar('folder_tmp', '', 'post', 'string');
     $folderOld = $input->getVar('folder_old', '', 'post', 'string');
     if (!$folderTmp) {
         echo json_encode(array('success' => false, 'message' => JText::_('JSN_UNIFORM_MESSAGE_ERRO_FIELD_EMPTY')));
         jexit();
     }
     $folderTmp = $folderTmp . '/jsnuniform_uploads/';
     $folderOld = $folderOld . '/jsnuniform_uploads/';
     $folderUpload = JPATH_ROOT . '/' . $folderTmp;
     $folderOldUpload = JPATH_ROOT . '/' . $folderOld;
     $folderTmpUpload = JSN_UNIFORM_FOLDER_TMP . DS . md5(date("F j, Y, g:i a") . rand(10000, 999999));
     if (!JFolder::create(JPath::clean($folderTmpUpload), 0777)) {
         $this->errorFolderUpload = JText::sprintf('JSN_UNIFORM_SAMPLE_DATA_FOLDER_TMP_IS_UNWRITE');
         echo json_encode(array('success' => false, 'message' => $this->errorFolderUpload));
         jexit();
     } elseif (JFolder::exists($folderOldUpload) && $folderTmp != $folderOld) {
         JFolder::copy(JPath::clean($folderOldUpload), JPath::clean($folderTmpUpload), '', true, true);
     }
     if (!JFolder::exists(JPath::clean($folderUpload))) {
         if (!JFolder::create(JPath::clean($folderUpload), 0777)) {
             $this->errorFolderUpload = JText::sprintf('JSN_UNIFORM_FOLDER_MUST_HAVE_WRITABLE_PERMISSION', JPath::clean($folderUpload));
             echo json_encode(array('success' => false, 'message' => $this->errorFolderUpload));
             jexit();
         }
     } elseif (!@is_writable(JPath::clean($folderUpload))) {
         $this->errorFolderUpload = JText::sprintf('JSN_UNIFORM_FOLDER_MUST_HAVE_WRITABLE_PERMISSION', JPath::clean($folderUpload));
         echo json_encode(array('success' => false, 'message' => $this->errorFolderUpload));
         jexit();
     }
     if (!empty($folderOld) && JFolder::exists($folderOldUpload) && $folderTmp != $folderOld) {
         JFolder::copy(JPath::clean($folderTmpUpload), JPath::clean($folderUpload), '', true, true);
         //JFolder::delete($folderTmpUpload);
     }
     echo json_encode(array('success' => true, 'message' => JText::_('JSN_UNIFORM_FOLDER_IS_DONE')));
     jexit();
 }