public function process($limitstart = 0) { $folders = $this->getFolders(); $target_folder = isset($folders[$limitstart]) ? $folders[$limitstart] : null; if (!$target_folder) { return true; } $path = str_replace(JPATH_SITE, '', $target_folder); // Check if the target folder exists if (!JFolder::exists($target_folder)) { $this->success = false; $this->log[] = JText::sprintf('COM_PFMIGRATOR_FOLDER_NOT_FOUND', $path); return false; } // Check if the destination folder exists if (JFolder::exists($target_folder . '3')) { if (!JFolder::delete($target_folder . '3')) { $this->success = false; $this->log[] = JText::sprintf('COM_PFMIGRATOR_FOLDER_EXISTS', $path . '3'); return false; } } if (!JFolder::move($target_folder, $target_folder . '3')) { $this->success = false; $this->log[] = JText::sprintf('COM_PFMIGRATOR_FOLDER_RENAME_FAILED', $path); return false; } $this->log[] = JText::sprintf('COM_PFMIGRATOR_RENAME_FOLDER_SUCCESS', $path, $path . '3'); return true; }
public function test(SimpleXMLElement $element, $value, $group = null, Registry $input = null, JForm $form = null) { $app = JFactory::getApplication(); $newPath = trim($value); // $input->set('params.datapath', $newPath); if (!preg_match('#' . $this->regex . '#', $newPath)) { return false; } $plugin = JPluginHelper::getPlugin('system', 'rjuserd'); if ($plugin) { // Get plugin params $pluginParams = new JRegistry($plugin->params); } $oldPath = $pluginParams->get('datapath', false); //echo'<xmp>';var_dump($pluginParams,$element,$value,$group,$input,$form);jexit(); if ($oldPath && $oldPath != $newPath) { jimport('joomla.filesystem.folder'); if (JFolder::move(JPATH_ROOT . '/' . $oldPath, JPATH_ROOT . '/' . $newPath) !== true) { $app->enqueueMessage('Failed to move data from <u>' . $oldPath . '</u> to <u>' . $newPath . '</u>', 'error'); return false; } $app->enqueueMessage('User data were moved from <u>' . $oldPath . '</u> to <u>' . $newPath . '</u>'); } return true; }
function install($adapter) { $installer = $this->installer; $installer->AddSQLFromFile('install.bids.inserts.sql'); jimport('joomla.filesystem.folder'); jimport('joomla.filesystem.file'); JFolder::move(JPATH_SITE . DS . 'components' . DS . 'com_bids' . DS . 'templates-dist', JPATH_SITE . DS . 'components' . DS . 'com_bids' . DS . 'templates'); JFile::move(JPATH_SITE . DS . 'components' . DS . 'com_bids' . DS . 'options.php-dist', JPATH_SITE . DS . 'components' . DS . 'com_bids' . DS . 'options.php'); JFolder::create(JPATH_SITE . DS . 'images' . DS . 'auctions'); $installer->AddMenuItem("Auction Factory MENU", "List Auctions", "list-auctions", "index.php?option=com_bids&task=listauctions", 1); $installer->AddMenuItem("Auction Factory MENU", "Categories", "categories-auctions", "index.php?option=com_bids&task=listcats", 1); $installer->AddMenuItem("Auction Factory MENU", "Search", "search-auctions", "index.php?option=com_bids&task=search", 1); $installer->AddMenuItem("Auction Factory MENU", "New Auction", "post-offer", "index.php?option=com_bids&task=newauction", 2); $installer->AddMenuItem("Auction Factory MENU", "My Auctions", "my-auctions", "index.php?option=com_bids&task=myauctions", 2); $installer->AddMenuItem("Auction Factory MENU", "Watchlist", "watchlist", "index.php?option=com_bids&task=mywatchlist", 2); $installer->AddMenuItem("Auction Factory MENU", "My Bids", "my-bids", "index.php?option=com_bids&task=mybids", 2); $installer->AddMenuItem("Auction Factory MENU", "Profile", "profile-auctions", "index.php?option=com_bids&task=userdetails", 2); $installer->AddCBPlugin('Bids MyAuctions', 'My Auctions', 'bids.myauctions', 'getmyauctionsTab'); $installer->AddCBPlugin('Bids MyBids', 'My Bids', 'bids.mybids', 'getmybidsTab'); $installer->AddCBPlugin('Bids MyRatings', 'My Ratings', 'bids.myratings', 'getmyratingsTab'); $installer->AddCBPlugin('Bids MySettings', 'My Settings', 'bids.mysettings', 'getmysettingsTab'); $installer->AddCBPlugin('Bids MyTaskpad', 'My Taskpad', 'bids.mytaskpad', 'myTaskPad'); $installer->AddCBPlugin('Bids MyWatchlist', 'My Watchlist', 'bids.mywatchlist', 'getmywatchlistTab'); $installer->AddCBPlugin('Bids MyWonBids', 'My Won Bids', 'bids.mywonbids', 'getmywonbidsTab'); $installer->AddMessage("Thank you for purchasing <strong>Auctions Factory</strong>"); $installer->AddMessageFromFile('install.notes.txt'); $installer->AddMessage("Please set up your <strong>Auctions Factory</strong> in the <a href='" . JURI::root() . "administrator/index.php?option=com_bids&task=settingsmanager'>admin panel</a></p>"); $installer->AddMessage("Visit us at <a target='_blank' href='http://www.thefactory.ro'>thefactory.ro</a> to learn about new versions and/or to give us feedback<br>"); $installer->AddMessage("© 2006-" . date('Y') . " thefactory.ro"); $installer->insertDefaultCategory(); $installer->install(); }
/** * @brief Instala la libreria de Amadeus en las librerias del Joomla. */ function installLibrary() { if (isThereLibrary()) { $src = JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_rotator' . DS . 'library' . DS . 'Amadeus'; $dst = JPATH_SITE . DS . 'libraries' . DS . 'Amadeus'; if (JFolder::exists($dst)) { JFolder::delete($dst); } JFolder::move($src, $dst); } }
function _install($file) { $AG_resourceType = JRequest::getVar('AG_resourceType'); // Current resource type $config = JFactory::getConfig(); $tmp_dest = $config->get('tmp_path'); $resourceType = substr($AG_resourceType, 0, strlen($AG_resourceType) - 1); $file_type = "zip"; if (isset($file) && !empty($file['name'])) { //Clean up filename to get rid of strange characters like spaces etc $filename = JFile::makeSafe($file['name']); $ext = strtolower(pathinfo($filename, PATHINFO_EXTENSION)); $src = $file['tmp_name']; $dest = $tmp_dest . DIRECTORY_SEPARATOR . $filename; //First check if the file has the right extension if ($ext == $file_type) { if (JFile::upload($src, $dest)) { if (JArchive::extract($tmp_dest . DIRECTORY_SEPARATOR . $filename, $tmp_dest . DIRECTORY_SEPARATOR . $AG_resourceType)) { JFile::delete($tmp_dest . DIRECTORY_SEPARATOR . $filename); } // TEMPLATE DETAILS PARSING if (JFIle::exists($tmp_dest . DIRECTORY_SEPARATOR . $AG_resourceType . DIRECTORY_SEPARATOR . JFile::stripExt($filename) . DIRECTORY_SEPARATOR . 'details.xml')) { $ag_resourceManager_xml =& JFactory::getXML($tmp_dest . DIRECTORY_SEPARATOR . $AG_resourceType . DIRECTORY_SEPARATOR . JFile::stripExt($filename) . DIRECTORY_SEPARATOR . 'details.xml'); if (isset($ag_resourceManager_xml->type)) { $ag_resourceManager_type = $ag_resourceManager_xml->type; } else { JFolder::delete($tmp_dest . DIRECTORY_SEPARATOR . $AG_resourceType); JFactory::getApplication()->enqueueMessage(JText::_('AG_ZIP_PACKAGE_IS_NOT_VALID_RESOURCE_TYPE') . " " . $filename, 'error'); return; } } else { JFolder::delete($tmp_dest . DIRECTORY_SEPARATOR . $AG_resourceType); JFactory::getApplication()->enqueueMessage(JText::_('AG_ZIP_PACKAGE_IS_NOT_VALID_RESOURCE_TYPE') . " " . $filename, 'error'); return; } if ($ag_resourceManager_type && $ag_resourceManager_type == $resourceType) { $result = JFolder::move($tmp_dest . DIRECTORY_SEPARATOR . $AG_resourceType . DIRECTORY_SEPARATOR . JFile::stripExt($filename), JPATH_SITE . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR . 'content' . DIRECTORY_SEPARATOR . 'admirorgallery' . DIRECTORY_SEPARATOR . 'admirorgallery' . DIRECTORY_SEPARATOR . $AG_resourceType . DIRECTORY_SEPARATOR . JFile::stripExt($filename)); if ($result) { JFactory::getApplication()->enqueueMessage(JText::_('AG_ZIP_PACKAGE_IS_INSTALLED') . " " . $filename, 'message'); } else { JFactory::getApplication()->enqueueMessage(JText::_('AG_CANNOT_MOVED_ITEM') . " " . $result, 'message'); } } else { JFolder::delete($tmp_dest . DIRECTORY_SEPARATOR . $AG_resourceType); JFactory::getApplication()->enqueueMessage(JText::_('AG_ZIP_PACKAGE_IS_NOT_VALID_RESOURCE_TYPE') . " " . $filename, 'error'); } } else { JFactory::getApplication()->enqueueMessage(JText::_('AG_CANNOT_UPLOAD_FILE_TO_TEMP_FOLDER_PLEASE_CHECK_PERMISSIONS'), 'error'); } } else { JFactory::getApplication()->enqueueMessage(JText::_('AG_ONLY_ZIP_ARCHIVES_CAN_BE_INSTALLED'), 'error'); } } }
public function postflight($type, $parent) { //If type is install if ($type == 'install') { //Move library file to Joomla libraries and delete it from plugin JFolder::move(JPATH_SITE . '/plugins/api/easyblog/libraries/simpleschema', JPATH_SITE . '/libraries/simpleschema'); JFolder::delete(JPATH_SITE . '/plugins/api/easyblog/libraries'); //Move helper file to easyblog helpers and delete it from plugin JFile::move(JPATH_SITE . '/plugins/api/easyblog/components/com_easyblog/helpers/simpleschema.php', JPATH_SITE . '/components/com_easyblog/helpers/simpleschema.php'); JFolder::delete(JPATH_SITE . '/plugins/api/easyblog/components'); } return true; }
/** * 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); } }
public function download($version) { JFactory::getLanguage()->load('com_easyblog', JPATH_ROOT . '/administrator'); $ajax = new Ejax(); JFactory::getLanguage()->load('com_easyblog', JPATH_ROOT . '/administrator'); $storage = JPATH_ROOT . '/tmp/foundry'; $storage = $this->getUniqueName($storage); // If folder doesn't exist, create them first. if (!JFolder::exists($storage)) { JFolder::create($storage); } $destination = $storage . '/foundry.zip'; // Get foundry's version $versionFile = JPATH_ROOT . '/media/foundry/3.1/version'; $localVersion = JFile::read($versionFile); // Remove newline from foundry's version $localVersion = trim($localVersion); $connector = EasyBlogHelper::getHelper('Connectors'); $infoServer = EBLOG_UPDATER_SERVER . 'foundry/' . $localVersion . '/info'; $connector->addUrl($infoServer); $connector->addQuery('apikey', EasyBlogHelper::getConfig()->get('apikey')); $connector->setMethod('POST'); $connector->execute(); $result = $connector->getResult($infoServer); if ($result == '#Foundry no updates' || $result == 'Invalid api key provided') { // @TODO: Show nothing to be updated in foundry. } else { // Write the zip file to the path. JFile::write($destination, $result); // Extract foundry zip. JArchive::extract($destination, $storage); // Rename the old foundry folder. $foundryPath = JPATH_ROOT . DIRECTORY_SEPARATOR . 'media' . DIRECTORY_SEPARATOR . 'foundry' . DIRECTORY_SEPARATOR . '3.1'; // Try to delete the foundry path. $deleteState = JFolder::delete($foundryPath); if (!$deleteState) { $ajax->script('$("#result-holder").append("<div>' . JText::_('There was some error deleting the foundry framework due to permission issues.') . '</div>");'); } // Move the new updated foundry to the correct path. $state = JFolder::move($storage . DIRECTORY_SEPARATOR . '3.1', $foundryPath); if (!$state) { $ajax->script('$("#result-holder").append("<div>' . JText::_('There was some error copying the foundry framework over to the media folder.') . '</div>");'); } } $ajax->script('$("#bar-progress").css("width" , "10%");'); $ajax->script('$("#bar-progress #progress-indicator").html("10%");'); $ajax->script('$("#result-holder").append("<div>' . JText::_('Updating Foundry Framework') . '</div>");'); $ajax->script('ejax.load( "updater", "updateEasyBlog" , "' . $version . '");'); $ajax->send(); }
function onAfterK2Save(&$item, $isNew) { jimport('joomla.filesystem.folder'); JLoader::register('SigProHelper', JPATH_ADMINISTRATOR . '/components/com_sigpro/helper.php'); $path = SigProHelper::getPath('k2'); $folder = JRequest::getCmd('sigProFolder'); if ($isNew && $folder && $folder != $item->id && JFolder::exists($path . '/' . $folder)) { JFolder::move($path . '/' . $folder, $path . '/' . $item->id); } if (JFolder::exists($path . '/' . $item->id) && $item->gallery == null) { $item->gallery = '{gallery}' . $item->id . '{/gallery}'; $item->store(); } }
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; }
/** * Copying files * * @param string $type Installation type * @param JInstallerAdapterComponent $parent Installation adapter * * @return bool False if something happens */ public function postflight($type, $parent) { $installationPath = $parent->getParent()->getPath('source'); jimport('joomla.filesystem.folder'); // If the layout folder exists, let's delete them first if (JFolder::exists(JPATH_ROOT . '/layouts/libraries/neno')) { JFolder::delete(JPATH_ROOT . '/layouts/libraries/neno'); } // Moving Layouts JFolder::move($installationPath . '/layouts', JPATH_ROOT . '/layouts/libraries/neno'); // If the media folder exists, let's delete them first if (JFolder::exists(JPATH_ROOT . '/media/neno')) { JFolder::delete(JPATH_ROOT . '/media/neno'); } // Moving media files JFolder::move($installationPath . '/media', JPATH_ROOT . '/media/neno'); return true; }
function preflight($type, $parent) { // WAITING FOR JOOMLA 1.7.x FIX $app = JFactory::getApplication(); $config = JFactory::getConfig(); $tmp_path = $config->get('tmp_path'); $tmp_dir = $app->cck_core_temp_var; $path = $tmp_path . '/' . $tmp_dir; $dest = JPATH_SITE . '/libraries/cck/rendering/variations'; $protected = array('empty'); if ($tmp_dir && JFolder::exists($path)) { $vars = JFolder::folders($path); foreach ($vars as $var) { if (!in_array($var, $protected)) { JFolder::move($path . '/' . $var, $dest . '/' . $var); } } JFolder::delete($path); } // WAITING FOR JOOMLA 1.7.x FIX }
/** * Sanatize positions config file (after renaming or deleting a type) * * @param string $path Path to renderer * @param Type $type The type to sanatize * @param boolean $delete if set to true, type will be removed * * @since 2.0 */ public function sanatizePositionsConfig($path, $type, $delete = false) { // get renderer $renderer = $this->app->renderer->create('item')->addPath($path); // get group $group = $type->getApplication()->getGroup(); // rename folder if special type if ($renderer->pathExists('item' . DIRECTORY_SEPARATOR . $type->id)) { $folder = $path . DIRECTORY_SEPARATOR . $renderer->getFolder() . DIRECTORY_SEPARATOR . 'item' . DIRECTORY_SEPARATOR; if ($delete) { JFolder::delete($folder . $type->id); } else { JFolder::move($folder . $type->id, $folder . $type->identifier); } } // get positions and config $config = $renderer->getConfig('item'); $params = $config->get($group . '.' . $type->id . '.'); if (!$delete) { $config->set($group . '.' . $type->identifier . '.', $params); } $config->remove($group . '.' . $type->id . '.'); $renderer->saveConfig($config, $path . '/renderer/item/positions.config'); }
private function items($id) { $this->response->status = 'Processing Items'; $step = 10; $session = JFactory::getSession(); $db = JFactory::getDbo(); if ($id == 0) { $query = $db->getQuery(true); $query->select('COUNT(*)')->from($db->quoteName('#__k2_v2_items')); $db->setQuery($query); $total = $db->loadResult(); $session->set('k2.upgrade.items.total', $total); $session->set('k2.upgrade.items.processed', 0); } $query = $db->getQuery(true); $query->select('*')->from($db->quoteName('#__k2_v2_items'))->where($db->quoteName('id') . ' > ' . $id)->order($db->quoteName('id')); $db->setQuery($query, 0, $step); $items = $db->loadObjectList(); foreach ($items as $item) { $query = $db->getQuery(true); $query->select($db->quoteName('id'))->from($db->quoteName('#__k2_items'))->where($db->quoteName('alias') . ' = ' . $db->quote($item->alias)); $db->setQuery($query); if ($db->loadResult()) { $item->alias .= '-' . uniqid(); } $data = array(); $data['id'] = ''; $data['title'] = $item->title; $data['alias'] = $item->alias; $data['state'] = $item->trash ? -1 : $item->published; $data['featured'] = $item->featured; $data['access'] = $item->access; $data['catid'] = $item->catid; if ($data['catid'] == 1) { $data['catid'] = 99999; } $data['introtext'] = $item->introtext; $data['fulltext'] = $item->fulltext; $data['ordering'] = $item->ordering; $data['featured_ordering'] = $item->featured_ordering; $data['created'] = $item->created; $data['created_by'] = $item->created_by; $data['created_by_alias'] = $item->created_by_alias; $data['modified'] = $item->modified; $data['modified_by'] = $item->modified_by ? $item->modified_by : $item->created_by; $data['publish_up'] = $item->publish_up; $data['publish_down'] = $item->publish_down; $data['metadata'] = array(); $data['metadata']['description'] = $item->metadesc; $data['metadata']['keywords'] = $item->metakey; $data['metadata']['robots'] = ''; $data['metadata']['author'] = ''; $metadata = new JRegistry($item->metadata); $metadata = $metadata->toArray(); foreach ($metadata as $key => $value) { if ($key == 'robots' || $key == 'author') { $data['metadata'][$key] = $value; } } $data['language'] = $item->language; $model = K2Model::getInstance('Items'); $model->setState('data', $data); if (!$model->save()) { $this->response->errors[] = $model->getError(); $this->response->failed = 1; return; } $lastInsertedId = $model->getState('id'); $image = new stdClass(); $image->caption = $item->image_caption; $image->credits = $item->image_credits; $image->flag = JFile::exists(JPATH_SITE . '/media/k2/items/cache/' . md5('Image' . $item->id) . '_Generic.jpg') ? 1 : 0; $image = json_encode($image); $media = array(); $mediaEntry = new stdClass(); $mediaEntry->url = ''; $mediaEntry->provider = ''; $mediaEntry->id = ''; $mediaEntry->embed = ''; $mediaEntry->caption = $item->video_caption; $mediaEntry->credits = $item->video_credits; $mediaEntry->upload = ''; if (!empty($item->video)) { if (substr($item->video, 0, 1) !== '{') { $mediaEntry->embed = $item->video; } else { if (strpos($item->video, 'remote}')) { preg_match("#}(.*?){/#s", $item->video, $matches); if (substr($matches[1], 0, 4) != 'http') { $mediaEntry->upload = basename($matches[1]); if (JFile::exists(JPATH_SITE . '/media/k2/videos/' . $mediaEntry->upload)) { if (!JFolder::exists(JPATH_SITE . '/media/k2/media')) { JFolder::create(JPATH_SITE . '/media/k2/media'); } if (!JFolder::exists(JPATH_SITE . '/media/k2/media/' . $item->id)) { JFolder::create(JPATH_SITE . '/media/k2/media/' . $item->id); } JFile::move(JPATH_SITE . '/media/k2/videos/' . $mediaEntry->upload, JPATH_SITE . '/media/k2/media/' . $item->id . '/' . $mediaEntry->upload); } } else { $mediaEntry->url = $matches[1]; } } else { preg_match("#}(.*?){/#s", $item->video, $matches); $mediaEntry->id = $matches[1]; $video = substr($item->video, 1); $mediaEntry->provider = substr($video, 0, strpos($video, '}')); } } $media[] = $mediaEntry; } $media = json_encode($media); $tags = array(); $query = $db->getQuery(true); $query->select($db->quoteName('tagId'))->from($db->quoteName('#__k2_tags_xref'))->where($db->quoteName('itemId') . ' = ' . $item->id); $db->setQuery($query); $tagIds = $db->loadColumn(); if (count($tagIds)) { $query = $db->getQuery(true); $query->select($db->quoteName('name') . ',' . $db->quoteName('id'))->from($db->quoteName('#__k2_tags'))->where($db->quoteName('id') . ' IN(' . implode(',', $tagIds) . ')')->where($db->quoteName('state') . ' = 1'); $db->setQuery($query); $tags = $db->loadObjectList(); } $tags = json_encode($tags); $query = $db->getQuery(true); $query->select($db->quoteName('id'))->from($db->quoteName('#__k2_attachments'))->where($db->quoteName('itemId') . ' = ' . $item->id); $db->setQuery($query); $attachments = $db->loadColumn(); $attachments = json_encode($attachments); $galleries = array(); if (strpos($item->gallery, '{gallery') !== false) { $gallery = new stdClass(); preg_match("#}(.*?){/#s", $item->gallery, $matches); $value = $matches[1]; if (strpos($value, 'flickr.com') !== false) { $gallery->url = $value; $gallery->upload = ''; } else { $gallery->url = ''; $tmp = uniqid(); if (JFolder::exists(JPATH_SITE . '/media/k2/galleries/' . $item->id)) { JFolder::move(JPATH_SITE . '/media/k2/galleries/' . $item->id, JPATH_SITE . '/media/k2/galleries/' . $tmp); JFolder::create(JPATH_SITE . '/media/k2/galleries/' . $item->id); JFolder::move(JPATH_SITE . '/media/k2/galleries/' . $tmp, JPATH_SITE . '/media/k2/galleries/' . $item->id . '/' . $tmp); } $gallery->upload = $tmp; } $galleries[] = $gallery; } $galleries = json_encode($galleries); $extraFields = new stdClass(); $itemFields = json_decode($item->extra_fields); if (is_array($itemFields)) { foreach ($itemFields as $itemField) { $query = $db->getQuery(true); $query->select('*')->from($db->quoteName('#__k2_extra_fields'))->where($db->quoteName('id') . ' = ' . $itemField->id); $db->setQuery($query); $field = $db->loadObject(); // No field found, go for the next one if (!$field) { continue; } $entry = new stdClass(); if ($field->type == 'text') { $entry->value = isset($itemField->value) ? $itemField->value : ''; } else { if ($field->type == 'textarea') { $entry->value = isset($itemField->value) ? $itemField->value : ''; } else { if ($field->type == 'date') { $entry->date = isset($itemField->value) ? $itemField->value : ''; } else { if ($field->type == 'image') { $entry->src = isset($itemField->value) ? $itemField->value : ''; $entry->alt = isset($itemField->value) ? $itemField->value : ''; } else { if ($field->type == 'labels') { $entry->value = isset($itemField->value) ? $itemField->value : ''; } else { if ($field->type == 'link') { $entry->text = isset($itemField->value) && is_array($itemField->value) && isset($itemField->value[0]) ? $itemField->value[0] : ''; $entry->url = isset($itemField->value) && is_array($itemField->value) && isset($itemField->value[1]) ? $itemField->value[1] : ''; $entry->target = isset($itemField->value) && is_array($itemField->value) && isset($itemField->value[2]) ? $itemField->value[2] : ''; } else { if ($field->type == 'radio') { $entry->value = ''; $json = json_decode($field->value); if (isset($json->options) && is_array($json->options) && isset($itemField->value) && $itemField->value && isset($json->options[$itemField->value - 1])) { $entry->value = $json->options[$itemField->value - 1]; } } else { if ($field->type == 'select') { $entry->value = ''; $json = json_decode($field->value); if (isset($json->multiple) && $json->multiple) { $entry->value = array(); if (isset($itemField->value) && is_array($itemField->value) && isset($json->options) && is_array($json->options)) { foreach ($itemField->value as $value) { if (isset($json->options[$value - 1])) { $entry->value[] = $json->options[$value - 1]; } } } } else { $entry->value = ''; if (isset($json->options) && is_array($json->options) && isset($itemField->value) && $itemField->value && isset($json->options[$itemField->value - 1])) { $entry->value = $json->options[$itemField->value - 1]; } } } else { if ($field->type == 'csv') { $entry->value = isset($itemField->value) ? json_encode($itemField->value) : ''; } else { if ($field->type == 'header') { $entry->value = isset($itemField->value) ? $itemField->value : ''; } } } } } } } } } } $property = $field->id; $extraFields->{$property} = $entry; } } $extraFields = json_encode($extraFields); $updatedParams = new JRegistry($item->params); $this->updateImageSizeParam($updatedParams, 'itemImgSize', ''); $this->updateImageSizeParam($updatedParams, 'itemRelatedImageSize', ''); $query = $db->getQuery(true); $query->update($db->quoteName('#__k2_items')); $query->set(array($db->quoteName('id') . ' = ' . $item->id, $db->quoteName('ordering') . ' = ' . (int) $item->ordering, $db->quoteName('image') . ' = ' . $db->quote($image), $db->quoteName('media') . ' = ' . $db->quote($media), $db->quoteName('tags') . ' = ' . $db->quote($tags), $db->quoteName('attachments') . ' = ' . $db->quote($attachments), $db->quoteName('galleries') . ' = ' . $db->quote($galleries), $db->quoteName('extra_fields') . ' = ' . $db->quote($extraFields), $db->quoteName('created') . ' = ' . $db->quote($item->created), $db->quoteName('created_by') . ' = ' . $db->quote($item->created_by), $db->quoteName('modified') . ' = ' . $db->quote($item->modified), $db->quoteName('modified_by') . ' = ' . $db->quote($item->modified_by), $db->quoteName('plugins') . ' = ' . $db->quote($item->plugins), $db->quoteName('params') . ' = ' . $db->quote($updatedParams->toString())))->where($db->quoteName('id') . ' = ' . $lastInsertedId); $db->setQuery($query); $db->execute(); // Update auto increment to avoid SQL errors $db->setQuery('ALTER TABLE ' . $db->quoteName('#__k2_items') . ' AUTO_INCREMENT=' . ((int) $item->id + 1)); $db->execute(); $query = $db->getQuery(true); $query->select('COUNT(*)')->from('#__k2_v2_comments')->where($db->quoteName('itemID') . ' = ' . (int) $item->id)->where('published = 1'); $db->setQuery($query); $comments = $db->loadResult(); $query = $db->getQuery(true); $query->update($db->quoteName('#__k2_items_stats')); $query->set($db->quoteName('hits') . ' = ' . (int) $item->hits); $query->set($db->quoteName('comments') . ' = ' . (int) $comments); $query->where($db->quoteName('itemId') . ' = ' . (int) $item->id); $db->setQuery($query); $db->execute(); $this->response->id = $item->id; } $this->response->total = $session->get('k2.upgrade.items.total'); $session->set('k2.upgrade.items.processed', (int) $session->get('k2.upgrade.items.processed') + count($items)); $this->response->processed = $session->get('k2.upgrade.items.processed'); if (count($items) == 0) { $this->response->id = 0; $this->response->type = 'users'; } }
/** * Copy a file. * @param string $files The relative file or comma seperated list of files * @param string $dest The relative path of the destination dir * @return string $error on failure */ public function move($file, $destination) { $result = new WFFileSystemResult(); $src = WFUtility::makePath($this->getBaseDir(), $file); $dest = WFUtility::makePath($this->getBaseDir(), WFUtility::makePath($destination, basename($file))); if ($src != $dest) { // src is a file if (is_file($src)) { $result->type = 'files'; $result->state = JFile::move($src, $dest); } else { if (is_dir($src)) { $result->type = 'folders'; $result->state = JFolder::move($src, $dest); $result->path = $dest; } } } return $result; }
/** * Called on installation * * @param JAdapterInstance $adapter The object responsible for running this script * * @return boolean True on success */ public function install(JAdapterInstance $adapter) { if (!file_exists(implode('/', array(JPATH_ROOT, 'images', 'sobipro')))) { JFolder::create(implode('/', array(JPATH_ROOT, 'images', 'sobipro'))); } if (file_exists(implode('/', array(JPATH_ROOT, 'components', 'com_sobipro', 'tmp', 'SampleData', 'entries')))) { JFolder::move(implode('/', array(JPATH_ROOT, 'components', 'com_sobipro', 'tmp', 'SampleData', 'entries')), implode('/', array(JPATH_ROOT, 'images', 'sobipro', 'entries'))); } if (file_exists(implode('/', array(JPATH_ROOT, 'components', 'com_sobipro', 'usr', 'locale')))) { JFolder::delete(implode('/', array(JPATH_ROOT, 'components', 'com_sobipro', 'usr', 'locale'))); } if (file_exists(implode('/', array(JPATH_ROOT, 'components', 'com_sobipro', 'services', 'installers', 'schemas', 'application.xsd')))) { JFolder::delete(implode('/', array(JPATH_ROOT, 'components', 'com_sobipro', 'services', 'installers', 'schemas', 'application.xsd'))); } if (file_exists(implode('/', array(JPATH_ROOT, 'components', 'com_sobipro', 'media')))) { JFolder::delete(implode('/', array(JPATH_ROOT, 'components', 'com_sobipro', 'media'))); } JFile::move(JPATH_ROOT . '/components/com_sobipro/etc/repos/sobipro_core/repository.1.1.9.xml', JPATH_ROOT . '/components/com_sobipro/etc/repos/sobipro_core/repository.xml'); $db = JFactory::getDBO(); $db->setQuery('SHOW COLUMNS FROM #__sobipro_field_data'); $cols = $db->loadAssocList('Field'); if (!isset($cols['editLimit'])) { $db->setQuery('ALTER TABLE `#__sobipro_field_data` ADD `editLimit` INT( 11 );'); $db->query(); } echo '<iframe src="index.php?option=com_sobipro&task=requirements&init=1&tmpl=component" style="border: 1px solid #e0e0e0; border-radius: 5px; height: 900px; min-width: 1000px; width: 99%; margin-bottom: 50px; padding-left: 10px;"></iframe>'; }
function extractKTemplate() { $app = JFactory::getApplication(); $kunena_app =& JFactory::getApplication(); $option = JRequest::getVar('option', '', '', 'cmd'); jimport('joomla.filesystem.folder'); jimport('joomla.filesystem.file'); jimport('joomla.filesystem.archive'); $tmp = JPATH_ROOT . '/tmp/kinstall/'; $dest = KPATH_SITE . '/template/'; $file = JRequest::getVar('install_package', NULL, 'FILES', 'array'); if (!$file || !is_uploaded_file($file['tmp_name'])) { $app->enqueueMessage(JText::sprintf('COM_KUNENA_A_TEMPLATE_MANAGER_INSTALL_EXTRACT_MISSING', $file['name']), 'notice'); } else { $success = JFile::upload($file['tmp_name'], $tmp . $file['name']); $success = JArchive::extract($tmp . $file['name'], $tmp); if (!$success) { $app->enqueueMessage(JText::sprintf('COM_KUNENA_A_TEMPLATE_MANAGER_INSTALL_EXTRACT_FAILED', $file['name']), 'notice'); } // Delete the tmp install directory if (JFolder::exists($tmp)) { $templates = parseXMLTemplateFiles($tmp); if (!empty($templates)) { foreach ($templates as $template) { // Never overwrite default template if ($template->directory == 'default') { continue; } if (is_dir($dest . $template->directory)) { if (is_file($dest . $template->directory . '/params.ini')) { if (is_file($tmp . $template->directory . '/params.ini')) { JFile::delete($tmp . $template->directory . '/params.ini'); } JFile::move($dest . $template->directory . '/params.ini', $tmp . $template->directory . '/params.ini'); } JFolder::delete($dest . $template->directory); } $error = JFolder::move($tmp . $template->directory, $dest . $template->directory); if ($error !== true) { $app->enqueueMessage(JText::_('COM_KUNENA_A_TEMPLATE_MANAGER_TEMPLATE') . ': ' . $error, 'notice'); } } $retval = JFolder::delete($tmp); $app->enqueueMessage(JText::sprintf('COM_KUNENA_A_TEMPLATE_MANAGER_INSTALL_EXTRACT_SUCCESS', $file['name'])); } else { JError::raiseWarning(100, JText::_('COM_KUNENA_A_TEMPLATE_MANAGER_TEMPLATE_MISSING_FILE')); $retval = false; } } else { JError::raiseWarning(100, JText::_('COM_KUNENA_A_TEMPLATE_MANAGER_TEMPLATE') . ' ' . JText::_('COM_KUNENA_A_TEMPLATE_MANAGER_UNINSTALL') . ': ' . JText::_('COM_KUNENA_A_TEMPLATE_MANAGER_DIR_NOT_EXIST')); $retval = false; } } while (@ob_end_clean()) { } $kunena_app->redirect(JURI::base() . 'index.php?option=' . $option . '&task=showTemplates'); }
/** * Method to physically create or move a directory * * @param array $data The directory data * * @return boolean True on success */ protected function savePhysical($project, $path, $dest = null) { if (!$project) { return false; } if (trim($path) == '') { return false; } $base = PFrepoHelper::getBasePath(); $path_exists = JFolder::exists($base . '/' . $path); // Create new directory? if (empty($dest)) { if ($path_exists) { return true; } return JFolder::create($base . '/' . $path); } $dest_exists = JFolder::exists($base . '/' . $dest); if ($dest == $path) { return true; } // Move existing dir if ($path_exists && !$dest_exists) { return JFolder::move($base . '/' . $path, $base . '/' . $dest); } // Create new dir at destination if (!$path_exists && !$dest_exists) { return JFolder::create($base . '/' . $dest); } return true; }
function _updateDatabase() { if (version_compare(JVERSION, '2.5', '>=') && version_compare(JVERSION, '3.0', '<')) { if (JError::$legacy) { $tmp_legacy = true; } else { $tmp_legacy = false; } JError::$legacy = false; } jimport('joomla.filesystem.file'); if (!file_exists(JPATH_ROOT . "/images/com_adsmanager/")) { JFolder::create(JPATH_ROOT . "/images/com_adsmanager/"); } if (!file_exists(JPATH_ROOT . "/images/com_adsmanager/categories/")) { JFolder::create(JPATH_ROOT . "/images/com_adsmanager/categories/"); } if (!file_exists(JPATH_ROOT . "/images/com_adsmanager/ads/")) { JFolder::create(JPATH_ROOT . "/images/com_adsmanager/ads/"); } if (file_exists(JPATH_ROOT . "/images/com_adsmanager/ads/tmp")) { JFolder::move(JPATH_ROOT . "/images/com_adsmanager/ads/tmp", JPATH_ROOT . "/images/com_adsmanager/ads/waiting"); } if (!file_exists(JPATH_ROOT . "/images/com_adsmanager/ads/waiting")) { JFolder::create(JPATH_ROOT . "/images/com_adsmanager/ads/waiting"); } if (!file_exists(JPATH_ROOT . "/images/com_adsmanager/ads/uploaded")) { JFolder::create(JPATH_ROOT . "/images/com_adsmanager/ads/uploaded"); } if (!file_exists(JPATH_ROOT . "/images/com_adsmanager/ads/tmp")) { JFolder::create(JPATH_ROOT . "/images/com_adsmanager/ads/tmp"); } if (!file_exists(JPATH_ROOT . "/images/com_adsmanager/email/")) { JFolder::create(JPATH_ROOT . "/images/com_adsmanager/email/"); } if (!file_exists(JPATH_ROOT . "/images/com_adsmanager/files/")) { JFolder::create(JPATH_ROOT . "/images/com_adsmanager/files/"); } if (!file_exists(JPATH_ROOT . "/images/com_adsmanager/files/.htaccess")) { $content = "ForceType application/octet-stream"; $content .= "\nHeader set Content-Disposition attachment"; JFile::write(JPATH_ROOT . "/images/com_adsmanager/files/.htaccess", $content); } if (!file_exists(JPATH_ROOT . "/images/com_adsmanager/fields/")) { JFolder::create(JPATH_ROOT . "/images/com_adsmanager/fields/"); } if (!file_exists(JPATH_ROOT . "/images/com_adsmanager/plugins/")) { JFolder::create(JPATH_ROOT . "/images/com_adsmanager/plugins/"); } if (!file_exists(JPATH_ROOT . "/images/com_adsmanager/index.html")) { JFile::copy(JPATH_ROOT . "/components/com_adsmanager/index.html", JPATH_ROOT . "/images/com_adsmanager/index.html"); } if (!file_exists(JPATH_ROOT . "/images/com_adsmanager/categories/index.html")) { JFile::copy(JPATH_ROOT . "/components/com_adsmanager/index.html", JPATH_ROOT . "/images/com_adsmanager/categories/index.html"); } if (!file_exists(JPATH_ROOT . "/images/com_adsmanager/ads/index.html")) { JFile::copy(JPATH_ROOT . "/components/com_adsmanager/index.html", JPATH_ROOT . "/images/com_adsmanager/ads/index.html"); } if (!file_exists(JPATH_ROOT . "/images/com_adsmanager/ads/waiting/index.html")) { JFile::copy(JPATH_ROOT . "/components/com_adsmanager/index.html", JPATH_ROOT . "/images/com_adsmanager/ads/waiting/index.html"); } if (!file_exists(JPATH_ROOT . "/images/com_adsmanager/ads/uploaded/index.html")) { JFile::copy(JPATH_ROOT . "/components/com_adsmanager/index.html", JPATH_ROOT . "/images/com_adsmanager/ads/uploaded/index.html"); } if (!file_exists(JPATH_ROOT . "/images/com_adsmanager/email/index.html")) { JFile::copy(JPATH_ROOT . "/components/com_adsmanager/index.html", JPATH_ROOT . "/images/com_adsmanager/email/index.html"); } if (!file_exists(JPATH_ROOT . "/images/com_adsmanager/files/index.html")) { JFile::copy(JPATH_ROOT . "/components/com_adsmanager/index.html", JPATH_ROOT . "/images/com_adsmanager/files/index.html"); } if (!file_exists(JPATH_ROOT . "/images/com_adsmanager/fields/index.html")) { JFile::copy(JPATH_ROOT . "/components/com_adsmanager/index.html", JPATH_ROOT . "/images/com_adsmanager/fields/index.html"); } if (!file_exists(JPATH_ROOT . "/images/com_adsmanager/plugins/index.html")) { JFile::copy(JPATH_ROOT . "/components/com_adsmanager/index.html", JPATH_ROOT . "/images/com_adsmanager/plugins/index.html"); } $lang = JFactory::getLanguage(); $lang->load("com_adsmanager"); // Schema modification -- BEGIN $db = JFactory::getDBO(); $db->setQuery("CREATE TABLE IF NOT EXISTS `#__adsmanager_searchmodule_config` (\n\t\t\t`id` int(11) NOT NULL AUTO_INCREMENT,\n\t\t\t`params` text NOT NULL,\n\t\t\tPRIMARY KEY (`id`)\n\t);"); try { $result = $db->query(); } catch (Exception $e) { } $db->setQuery("INSERT IGNORE INTO `#__adsmanager_searchmodule_config` (`params`) VALUES ('')"); try { $result = $db->query(); } catch (Exception $e) { } $db->setQuery("SELECT count(*) FROM `#__adsmanager_fields` WHERE 1"); $total = $db->loadResult(); if ($total == 0) { $queries = array(); $queries[] = " INSERT IGNORE INTO `#__adsmanager_columns` (`id`,`name`,`ordering`,`catsid`,`published`) VALUES " . " (2, 'ADSMANAGER_PRICE', 1, 1,1), " . " (3, 'ADSMANAGER_CITY', 2, 1,1), " . " (5, 'ADSMANAGER_STATE', 1, 0,1);"; $queries[] = " UPDATE #__adsmanager_columns SET catsid = ',-1,'"; $queries[] = " INSERT IGNORE INTO `#__adsmanager_field_values` (`fieldvalueid`,`fieldid`,`fieldtitle`,`fieldvalue`,`ordering`,`sys`) VALUES " . " (1, 8, 'ADSMANAGER_KINDOF2', 1, 1, 0), " . " (2, 8, 'ADSMANAGER_KINDOF1', 2, 2, 0), " . " (3, 9, 'ADSMANAGER_STATE_0', 4, 4, 0)," . " (4, 8, 'ADSMANAGER_KINDOFALL', 0, 0, 0)," . " (5, 9, 'ADSMANAGER_STATE_1', 3, 3, 0)," . " (6, 9, 'ADSMANAGER_STATE_3', 1, 1, 0)," . " (7, 9, 'ADSMANAGER_STATE_2', 2, 2, 0)," . " (8, 9, 'ADSMANAGER_STATE_4', 0, 0, 0);"; $queries[] = " INSERT IGNORE INTO `#__adsmanager_fields` (`fieldid`, `name`, `title`, `description`, `type`, `maxlength`, `size`, `required`, `ordering`, `cols`, `rows`, `columnid`, `columnorder`, `pos`, `posorder`, `profile`, `cb_field`, `sort`, `sort_direction`, `published`, `options`) VALUES " . "(1, 'name', 'ADSMANAGER_FORM_NAME', '', 'text', 50, 35, 1, 0, 0, 0, -1, 5, 5, 1, 1, 41, 0, 'DESC', 1, '')," . "(2, 'email', 'ADSMANAGER_FORM_EMAIL', '', 'emailaddress', 50, 35, 1, 1, 0, 0, -1, 10, 5, 4, 1, 50, 0, 'DESC', 1, '')," . "(3, 'ad_city', 'ADSMANAGER_FORM_CITY', '', 'text', 50, 35, 0, 4, 0, 0, 3, 1, 5, 3, 1, 59, 1, 'ASC', 1, '')," . "(4, 'ad_zip', 'ADSMANAGER_FORM_ZIP', '', 'text', 6, 7, 0, 3, 0, 0, -1, 0, 5, 2, 1, -1, 0, 'ASC', 1, '')," . "(5, 'ad_headline', 'ADSMANAGER_FORM_AD_HEADLINE', '', 'text', 60, 35, 1, 5, 0, 0, -1, 0, 1, 1, 0, -1, 0, 'DESC', 1, '')," . "(6, 'ad_text', 'ADSMANAGER_FORM_AD_TEXT', '', 'textarea', 500, 0, 1, 6, 40, 20, -1, 0, 3, 1, 0, -1, 0, 'DESC', 1, '')," . "(7, 'ad_phone', 'ADSMANAGER_FORM_PHONE1', '', 'number', 50, 35, 0, 2, 0, 0, -1, 0, 5, 1, 1, -1, 0, 'DESC', 1, '')," . "(8, 'ad_kindof', 'ADSMANAGER_FORM_KINDOF', '', 'select', 0, 0, 1, 7, 0, 0, 5, 0, 2, 1, 0, -1, 0, 'DESC', 1, '')," . "(9, 'ad_state', 'ADSMANAGER_FORM_STATE', '', 'select', 0, 0, 1, 8, 0, 0, 5, 0, 2, 1, 0, -1, 0, 'DESC', 1, '')," . "(10, 'ad_price', 'ADSMANAGER_FORM_AD_PRICE', '', 'price', 10, 7, 1, 9, 0, 0, 2, 0, 4, 1, 0, -1, 1, 'DESC', 1, '{\"currency_symbol\":\"\\\\u20ac\",\"currency_position\":\"after\",\"currency_number_decimals\":\"2\",\"currency_decimal_separator\":\".\",\"currency_thousands_separator\":\" \"}');"; $queries[] = " UPDATE #__adsmanager_fields SET catsid = ',-1,'"; $queries[] = " INSERT IGNORE INTO `#__adsmanager_positions` (`id`,`name`,`title`) VALUES " . " (1, 'top', 'ADSMANAGER_POSITION_TOP')," . " (2, 'subtitle', 'ADSMANAGER_POSITION_SUBTITLE')," . " (3, 'description', 'ADSMANAGER_POSITION_DESCRIPTION')," . " (4, 'description2', 'ADSMANAGER_POSITION_DESCRIPTION2')," . " (5, 'contact', 'ADSMANAGER_POSITION_CONTACT');"; $queries[] = " ALTER IGNORE TABLE `#__adsmanager_ads` ADD `name` TEXT DEFAULT NULL;"; $queries[] = " ALTER IGNORE TABLE `#__adsmanager_ads` ADD `ad_zip` TEXT DEFAULT NULL;"; $queries[] = " ALTER IGNORE TABLE `#__adsmanager_ads` ADD `ad_city` TEXT DEFAULT NULL;"; $queries[] = " ALTER IGNORE TABLE `#__adsmanager_ads` ADD `ad_phone` TEXT DEFAULT NULL;"; $queries[] = " ALTER IGNORE TABLE `#__adsmanager_ads` ADD `email` TEXT DEFAULT NULL;"; $queries[] = " ALTER IGNORE TABLE `#__adsmanager_ads` ADD `ad_kindof` TEXT DEFAULT NULL;"; $queries[] = " ALTER IGNORE TABLE `#__adsmanager_ads` ADD `ad_headline` TEXT DEFAULT NULL;"; $queries[] = " ALTER IGNORE TABLE `#__adsmanager_ads` ADD `ad_text` TEXT DEFAULT NULL;"; $queries[] = " ALTER IGNORE TABLE `#__adsmanager_ads` CHANGE `ad_state` `ad_state` TEXT DEFAULT NULL;"; $queries[] = " ALTER IGNORE TABLE `#__adsmanager_ads` ADD `ad_price` TEXT DEFAULT NULL;"; $queries[] = "ALTER IGNORE TABLE `#__adsmanager_profile` ADD `name` TEXT DEFAULT NULL;"; $queries[] = "ALTER IGNORE TABLE `#__adsmanager_profile` ADD `ad_zip` TEXT DEFAULT NULL;"; $queries[] = "ALTER IGNORE TABLE `#__adsmanager_profile` ADD `ad_city` TEXT DEFAULT NULL;"; $queries[] = "ALTER IGNORE TABLE `#__adsmanager_profile` ADD `ad_phone` TEXT NOT NULL;"; $queries[] = " INSERT IGNORE INTO `#__adsmanager_categories` (`id`,`parent`,`name`,`published`) VALUES " . " (1, 0,'Category 1', 1)," . " (2, 0,'Category 2', 1)," . " (3, 1,'SubCat1', 1)," . " (4, 1,'SubCat2', 1)," . " (5, 1,'SubCat3', 1)," . " (6, 2,'SubCat4', 1)," . " (7, 2,'SubCat5', 1)," . " (8, 2,'SubCat6', 1);"; foreach ($queries as $query) { $db->setQuery($query); try { $result = $db->query(); } catch (Exception $e) { } } } $queries = array(); $queries[] = "ALTER IGNORE TABLE `#__adsmanager_fields` CHANGE `catsid` `catsid` TEXT NOT NULL;"; $queries[] = "ALTER IGNORE TABLE `#__adsmanager_columns` CHANGE `catsid` `catsid` TEXT NOT NULL;"; $queries[] = "ALTER IGNORE TABLE `#__adsmanager_ads` CHANGE `date_created` `date_created` DATETIME NOT NULL;"; $queries[] = "ALTER IGNORE TABLE `#__adsmanager_config` ADD `bannedwords` TEXT DEFAULT NULL;"; $queries[] = "ALTER IGNORE TABLE `#__adsmanager_config` ADD `replaceword` TEXT DEFAULT NULL;"; $queries[] = "ALTER IGNORE TABLE `#__adsmanager_config` ADD `after_expiration` TEXT DEFAULT NULL;"; $queries[] = "ALTER IGNORE TABLE `#__adsmanager_config` ADD `archive_catid` INT(10) NOT NULL default '1';"; $queries[] = " ALTER IGNORE TABLE `#__adsmanager_ads` ADD `metadata_description` TEXT DEFAULT NULL;"; $queries[] = " ALTER IGNORE TABLE `#__adsmanager_ads` ADD `metadata_keywords` TEXT DEFAULT NULL;"; $queries[] = " ALTER IGNORE TABLE `#__adsmanager_categories` ADD `metadata_description` TEXT DEFAULT NULL;"; $queries[] = " ALTER IGNORE TABLE `#__adsmanager_categories` ADD `metadata_keywords` TEXT DEFAULT NULL;"; $queries[] = " ALTER IGNORE TABLE `#__adsmanager_config` ADD `metadata_mode` TEXT DEFAULT NULL;"; $queries[] = " ALTER IGNORE TABLE `#__adsmanager_config` ADD `autocomplete` tinyint(1) default '1';"; $queries[] = " ALTER IGNORE TABLE `#__adsmanager_config` ADD `jquery` tinyint(1) default '1';"; $queries[] = " ALTER IGNORE TABLE `#__adsmanager_config` ADD `jqueryui` tinyint(1) default '1';"; $queries[] = " ALTER IGNORE TABLE `#__adsmanager_config` ADD `nb_last_cols` int(10) NOT NULL default '3';"; $queries[] = " ALTER IGNORE TABLE `#__adsmanager_config` ADD `nb_last_rows` int(10) NOT NULL default '1';"; $queries[] = " ALTER IGNORE TABLE `#__adsmanager_config` ADD `display_general_menu` tinyint(1) default '1';"; $queries[] = " ALTER IGNORE TABLE `#__adsmanager_config` ADD `display_list_sort` tinyint(1) default '1';"; $queries[] = " ALTER IGNORE TABLE `#__adsmanager_config` ADD `display_list_search` tinyint(1) default '1';"; $queries[] = " ALTER IGNORE TABLE `#__adsmanager_config` ADD `display_inner_pathway` tinyint(1) default '1';"; $queries[] = " ALTER IGNORE TABLE `#__adsmanager_config` ADD `display_front` tinyint(1) default '1';"; $queries[] = " ALTER IGNORE TABLE `#__adsmanager_config` ADD `send_email_on_new_to_user` tinyint(1) default '1';"; $queries[] = " ALTER IGNORE TABLE `#__adsmanager_config` ADD `send_email_on_update_to_user` tinyint(1) default '1';"; $queries[] = " ALTER IGNORE TABLE `#__adsmanager_config` ADD `send_email_on_validation_to_user` tinyint(1) default '1';"; $queries[] = " ALTER IGNORE TABLE `#__adsmanager_config` ADD `send_email_on_expiration_to_user` tinyint(1) default '1';"; $queries[] = " ALTER IGNORE TABLE `#__adsmanager_config` ADD `new_text` TEXT DEFAULT NULL;"; $queries[] = " ALTER IGNORE TABLE `#__adsmanager_config` ADD `update_text` TEXT DEFAULT NULL;"; $queries[] = " ALTER IGNORE TABLE `#__adsmanager_config` ADD `admin_new_text` TEXT DEFAULT NULL;"; $queries[] = " ALTER IGNORE TABLE `#__adsmanager_config` ADD `admin_update_text` TEXT DEFAULT NULL;"; $queries[] = " ALTER IGNORE TABLE `#__adsmanager_config` ADD `waiting_validation_text` TEXT DEFAULT NULL;"; $queries[] = " ALTER IGNORE TABLE `#__adsmanager_config` ADD `validation_text` TEXT DEFAULT NULL;"; $queries[] = " ALTER IGNORE TABLE `#__adsmanager_config` ADD `expiration_text` TEXT DEFAULT NULL;"; $queries[] = " ALTER IGNORE TABLE `#__adsmanager_config` ADD `new_subject` TEXT DEFAULT NULL;"; $queries[] = " ALTER IGNORE TABLE `#__adsmanager_config` ADD `update_subject` TEXT DEFAULT NULL;"; $queries[] = " ALTER IGNORE TABLE `#__adsmanager_config` ADD `admin_new_subject` TEXT DEFAULT NULL;"; $queries[] = " ALTER IGNORE TABLE `#__adsmanager_config` ADD `admin_update_subject` TEXT DEFAULT NULL;"; $queries[] = " ALTER IGNORE TABLE `#__adsmanager_config` ADD `waiting_validation_subject` TEXT DEFAULT NULL;"; $queries[] = " ALTER IGNORE TABLE `#__adsmanager_config` ADD `validation_subject` TEXT DEFAULT NULL;"; $queries[] = " ALTER IGNORE TABLE `#__adsmanager_config` ADD `expiration_subject` TEXT DEFAULT NULL;"; $queries[] = " ALTER IGNORE TABLE `#__adsmanager_config` ADD `recall_subject` TEXT DEFAULT NULL;"; $queries[] = "INSERT IGNORE INTO `#__adsmanager_positions` VALUES (6, 'description3', 'ADSMANAGER_POSITION_DESCRIPTION3');"; $queries[] = " CREATE TABLE IF NOT EXISTS `#__adsmanager_pending_ads` (\n\t `id` int(11) NOT NULL AUTO_INCREMENT,\n\t `userid` int(11) NOT NULL,\n\t `date` date NOT NULL,\n\t `content` text NOT NULL,\n\t `contentid` int(11) NOT NULL,\n\t PRIMARY KEY (`id`)\n\t) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1"; foreach ($queries as $query) { $db->setQuery($query); try { $result = $db->query(); } catch (Exception $e) { } } //We change the type of the show_contact column no matter what $queries = array(); $queries[] = "ALTER IGNORE TABLE `#__adsmanager_config` MODIFY `show_contact` TEXT NULL;"; foreach ($queries as $q) { $db->setQuery($q); try { $result = $db->query(); } catch (Exception $e) { } } $db->setQuery(" SELECT new_subject FROM `#__adsmanager_config` WHERE id=1;"); $new_subject = $db->loadResult(); if ($new_subject == null) { $queries = array(); $queries[] = "UPDATE #__adsmanager_config SET new_subject = " . $db->Quote(JText::_('ADSMANAGER_NEW_SUBJECT_EXAMPLE')); $queries[] = "UPDATE #__adsmanager_config SET update_subject = " . $db->Quote(JText::_('ADSMANAGER_UPDATE_SUBJECT_EXAMPLE')); $queries[] = "UPDATE #__adsmanager_config SET expiration_subject = " . $db->Quote(JText::_('ADSMANAGER_EXPIRATION_SUBJECT_EXAMPLE')); $queries[] = "UPDATE #__adsmanager_config SET recall_subject = " . $db->Quote(JText::_('ADSMANAGER_RECALL_SUBJECT_EXAMPLE')); $queries[] = "UPDATE #__adsmanager_config SET waiting_validation_subject = " . $db->Quote(JText::_('ADSMANAGER_WAITING_VALIDATION_SUBJECT_EXAMPLE')); $queries[] = "UPDATE #__adsmanager_config SET validation_subject = " . $db->Quote(JText::_('ADSMANAGER_VALIDATION_SUBJECT_EXAMPLE')); $queries[] = "UPDATE #__adsmanager_config SET admin_new_subject = " . $db->Quote(JText::_('ADSMANAGER_ADMIN_NEW_SUBJECT_EXAMPLE')); $queries[] = "UPDATE #__adsmanager_config SET admin_update_subject = " . $db->Quote(JText::_('ADSMANAGER_ADMIN_UPDATE_SUBJECT_EXAMPLE')); $queries[] = "UPDATE #__adsmanager_config SET new_text = " . $db->Quote(JText::_('ADSMANAGER_NEW_TEXT_EXAMPLE')); $queries[] = "UPDATE #__adsmanager_config SET update_text = " . $db->Quote(JText::_('ADSMANAGER_UPDATE_TEXT_EXAMPLE')); $queries[] = "UPDATE #__adsmanager_config SET expiration_text = " . $db->Quote(JText::_('ADSMANAGER_EXPIRATION_TEXT_EXAMPLE')); $queries[] = "UPDATE #__adsmanager_config SET recall_text = " . $db->Quote(JText::_('ADSMANAGER_RECALL_TEXT_EXAMPLE')); $queries[] = "UPDATE #__adsmanager_config SET waiting_validation_text = " . $db->Quote(JText::_('ADSMANAGER_WAITING_VALIDATION_TEXT_EXAMPLE')); $queries[] = "UPDATE #__adsmanager_config SET validation_text = " . $db->Quote(JText::_('ADSMANAGER_VALIDATION_TEXT_EXAMPLE')); $queries[] = "UPDATE #__adsmanager_config SET admin_new_text = " . $db->Quote(JText::_('ADSMANAGER_ADMIN_NEW_TEXT_EXAMPLE')); $queries[] = "UPDATE #__adsmanager_config SET admin_update_text = " . $db->Quote(JText::_('ADSMANAGER_ADMIN_UPDATE_TEXT_EXAMPLE')); foreach ($queries as $q) { $db->setQuery($q); try { $result = $db->query(); } catch (Exception $e) { } } } $db->setQuery("SELECT * FROM #__adsmanager_config LIMIT 1"); $config = $db->loadObject(); $db->setQuery("ALTER IGNORE TABLE `#__adsmanager_ads` ADD `images` TEXT;"); try { $result = $db->query(); } catch (Exception $e) { } if ($config == null) { $db->setQuery(" INSERT IGNORE INTO `#__adsmanager_config` (`id`,`version`,`ads_per_page`,`max_image_size`,`max_width`,`max_height`,`max_width_t`,`max_height_t`,`root_allowed`,`nb_images`," . " `show_contact`,`send_email_on_new`,`send_email_on_update`,`auto_publish`,`tag`,`fronttext`,`comprofiler`,`email_display`,`rules_text`," . " `display_expand`,`display_last`,`display_fullname`,`expiration`,`ad_duration`,`recall`,`recall_time`,`recall_text`,`image_display`," . " `cat_max_width`,`cat_max_height`,`cat_max_width_t`,`cat_max_height_t`,`submission_type`,`nb_ads_by_user`,`allow_attachement`," . " `allow_contact_by_pms`, `show_rss` ,`nbcats` ,`show_new`,`nbdays_new`,`show_hot`,`nbhits`,`bannedwords`,`replaceword`,`after_expiration`,`archive_catid`,`metadata_mode`) VALUES " . " (1, '3', 20, 2048000, 400, 300, 150, 100, 1,2," . " 1,1,1,1, 'Juloa.com', '<p align=\"center\"><strong>Welcome to Ads Section.</strong></p><p align=\"left\">The better place to sell or buy</p>',0,0,'Inform the users about the rules here...'," . " 2,1,0,1,30,1,7,'Add This Text to recall message<br />','default'," . " 150,150,30,30,0,-1,0," . " 0,0,1,1,5,1,100,'','****','delete','0','automatic')"); try { $result = $db->query(); } catch (Exception $e) { } } else { $continue = true; while ($continue) { $continue = false; switch ($config->version) { case 15: break; case 14: $queries = array(); $queries[] = "CREATE TABLE IF NOT EXISTS `#__adsmanager_tags` (\n\t\t\t\t\t\t\t\t\ttype varchar(50) default NULL,\n\t\t\t\t\t\t\t\t\tvalue varchar(255) default NULL,\n\t\t\t\t\t\t\t\t\tPRIMARY KEY (`type`,`value`)\n\t\t\t\t\t\t\t\t) DEFAULT CHARACTER SET utf8;"; foreach ($queries as $q) { $db->setQuery($q); try { $result = $db->query(); } catch (Exception $e) { } } $obj = new stdClass(); $obj->id = 1; $obj->version = 15; $db->updateObject('#__adsmanager_config', $obj, 'id'); $config->version = 15; $continue = true; break; case 13: $queries = array(); $queries[] = "ALTER TABLE `#__adsmanager_ads` ENGINE = MYISAM"; foreach ($queries as $q) { $db->setQuery($q); try { $result = $db->query(); } catch (Exception $e) { } } $obj = new stdClass(); $obj->id = 1; $obj->version = 14; $db->updateObject('#__adsmanager_config', $obj, 'id'); $config->version = 14; $continue = true; break; case 12: $queries = array(); $queries[] = "CREATE TABLE IF NOT EXISTS `#__adsmanager_pending_mails` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n `from` varchar(255) NOT NULL,\n `fromname` varchar(255) NOT NULL,\n `recipient` text NOT NULL,\n `created_on` datetime NOT NULL,\n `subject` text NOT NULL,\n `body` text NOT NULL,\n `statut` tinyint(1) NOT NULL default 0,\n PRIMARY KEY (`id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1"; foreach ($queries as $q) { $db->setQuery($q); try { $result = $db->query(); } catch (Exception $e) { } } $obj = new stdClass(); $obj->id = 1; $obj->version = 13; $db->updateObject('#__adsmanager_config', $obj, 'id'); $config->version = 13; $continue = true; break; case 11: $queries = array(); $queries[] = "CREATE TABLE IF NOT EXISTS `#__adsmanager_favorite` (\n `adid` int(10) unsigned NOT NULL ,\n `userid` int(10) unsigned NOT NULL ,\n PRIMARY KEY (`adid`,`userid`)\n ) DEFAULT CHARACTER SET utf8;"; foreach ($queries as $q) { $db->setQuery($q); try { $result = $db->query(); } catch (Exception $e) { } } $obj = new stdClass(); $obj->id = 1; $obj->version = 12; $db->updateObject('#__adsmanager_config', $obj, 'id'); $config->version = 12; $continue = true; break; case 10: $sql = "SELECT show_contact FROM #__adsmanager_config LIMIT 0,1"; $db->setQuery($sql); $result = $db->loadObject(); if ($result->show_contact == 1) { $sql = "SELECT id FROM #__usergroups WHERE title != 'Public'"; $db->setQuery($sql); $results = $db->loadObjectList(); } else { $sql = "SELECT id FROM #__usergroups"; $db->setQuery($sql); $results = $db->loadObjectList(); } $usergroups = array(); foreach ($results as $result) { $usergroups[] = $result->id; } $usergroups = implode(',', $usergroups); $queries = array(); $queries[] = "ALTER IGNORE TABLE `#__adsmanager_config` MODIFY `show_contact` TEXT NULL;"; $queries[] = "UPDATE `#__adsmanager_config` SET `show_contact` = '" . $usergroups . "';"; foreach ($queries as $q) { $db->setQuery($q); try { $result = $db->query(); } catch (Exception $e) { } } $obj = new stdClass(); $obj->id = 1; $obj->version = 11; $db->updateObject('#__adsmanager_config', $obj, 'id'); $config->version = 11; $continue = true; break; case 9: $queries = array(); $queries[] = "ALTER IGNORE TABLE `#__adsmanager_categories` ADD `limitads` INT(11) default '-1';"; $queries[] = "ALTER IGNORE TABLE `#__adsmanager_ads` ADD `publication_date` DATETIME NOT NULL;"; foreach ($queries as $q) { $db->setQuery($q); try { $result = $db->query(); } catch (Exception $e) { } } $obj = new stdClass(); $obj->id = 1; $obj->version = 10; $db->updateObject('#__adsmanager_config', $obj, 'id'); $config->version = 10; $continue = true; break; case 8: $queries = array(); $queries[] = "ALTER IGNORE TABLE `#__adsmanager_categories` ADD `limitads` INT(11) default '-1';"; $queries[] = "ALTER IGNORE TABLE `#__adsmanager_categories` ADD `usergroupsread` TEXT NOT NULL;"; $queries[] = "ALTER IGNORE TABLE `#__adsmanager_categories` ADD `usergroupswrite` TEXT NOT NULL;"; foreach ($queries as $q) { $db->setQuery($q); try { $result = $db->query(); } catch (Exception $e) { } } $obj = new stdClass(); $obj->id = 1; $obj->version = 9; $db->updateObject('#__adsmanager_config', $obj, 'id'); $config->version = 9; $continue = true; break; case 7: $q = "SELECT params FROM #__adsmanager_config"; $db->setQuery($q); $json_params = $db->loadResult(); $params = json_decode($json_params); if ($params == null) { $params = new stdClass(); } if (!isset($params->email_admin) || $params->email_admin == '') { if (version_compare(JVERSION, '3.0.2', '>=')) { $versionJoomla = 1; } else { $versionJoomla = 0; } $config = JFactory::getConfig(); $params->email_admin = $versionJoomla ? $config->get('mailfrom') : $config->getValue('config.mailfrom'); $params->name_admin = $versionJoomla ? $config->get('fromname') : $config->getValue('config.fromname'); $json_params = json_encode($params); $q = "UPDATE #__adsmanager_config\n SET params = " . $db->Quote($json_params); $db->setQuery($q); try { $result = $db->query(); } catch (Exception $e) { } } $obj = new stdClass(); $obj->id = 1; $obj->version = 8; $db->updateObject('#__adsmanager_config', $obj, 'id'); $config->version = 8; $continue = true; break; case 6: $q = "ALTER IGNORE TABLE `#__adsmanager_categories` MODIFY `description` text;"; $db->setQuery($q); try { $result = $db->query(); } catch (Exception $e) { } $obj = new stdClass(); $obj->id = 1; $obj->version = 7; $db->updateObject('#__adsmanager_config', $obj, 'id'); $config->version = 7; $continue = true; break; case 5: $app = JFactory::getApplication(); $db->setQuery("SELECT count(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = '" . $app->getCfg('db') . "' AND TABLE_NAME = '" . $db->getPrefix() . "adsmanager_fieldgmap_conf'"); $count = $db->loadResult(); if ($count > 0) { $db->setQuery("SELECT fieldid,name FROM #__adsmanager_fields WHERE type='gmap'"); $fields = $db->loadObjectList("fieldid"); $queries = array(); foreach ($fields as $field) { $queries[] = "ALTER IGNORE TABLE `#__adsmanager_ads` ADD `" . $field->name . "_lat` FLOAT default NULL;"; $queries[] = "ALTER IGNORE TABLE `#__adsmanager_ads` ADD `" . $field->name . "_lng` FLOAT default NULL;"; $queries[] = "ALTER IGNORE TABLE `#__adsmanager_ads` ADD `" . $field->name . "_zoom` int(10) unsigned default 8;"; $queries[] = "ALTER IGNORE TABLE `#__adsmanager_ads` ADD `" . $field->name . "_hide` int(1) unsigned default 0;"; $queries[] = "ALTER IGNORE TABLE `#__adsmanager_profile` ADD `" . $field->name . "_lat` FLOAT default NULL;"; $queries[] = "ALTER IGNORE TABLE `#__adsmanager_profile` ADD `" . $field->name . "_lng` FLOAT default NULL;"; $queries[] = "ALTER IGNORE TABLE `#__adsmanager_profile` ADD `" . $field->name . "_zoom` int(10) unsigned default 8;"; $queries[] = "ALTER IGNORE TABLE `#__adsmanager_profile` ADD `" . $field->name . "_hide` int(1) unsigned default 0;"; //Patch for an old error in the update file (TEXT instead of FLOAT) $queries[] = "ALTER IGNORE TABLE `#__adsmanager_ads` MODIFY `" . $field->name . "_lat` FLOAT default NULL;"; $queries[] = "ALTER IGNORE TABLE `#__adsmanager_ads` MODIFY `" . $field->name . "_lng` FLOAT default NULL;"; $queries[] = "ALTER IGNORE TABLE `#__adsmanager_ads` MODIFY `" . $field->name . "_zoom` int(10) unsigned default 8;"; $queries[] = "ALTER IGNORE TABLE `#__adsmanager_ads` MODIFY `" . $field->name . "_hide` int(1) unsigned default 0;"; $queries[] = "ALTER IGNORE TABLE `#__adsmanager_profile` MODIFY `" . $field->name . "_lat` FLOAT default NULL;"; $queries[] = "ALTER IGNORE TABLE `#__adsmanager_profile` MODIFY `" . $field->name . "_lng` FLOAT default NULL;"; $queries[] = "ALTER IGNORE TABLE `#__adsmanager_profile` MODIFY `" . $field->name . "_zoom` int(10) unsigned default 8;"; $queries[] = "ALTER IGNORE TABLE `#__adsmanager_profile` MODIFY `" . $field->name . "_hide` int(1) unsigned default 0;"; } foreach ($queries as $q) { $db->setQuery($q); try { $result = $db->query(); } catch (Exception $e) { } } } $obj = new stdClass(); $obj->id = 1; $obj->version = 6; $db->updateObject('#__adsmanager_config', $obj, 'id'); $config->version = 6; $continue = true; break; case 4: $db->setQuery("SELECT id,images FROM `#__adsmanager_ads`"); $ads = $db->loadObjectList("id"); foreach ($ads as $ad) { $images = json_decode($ad->images); $change = 0; if (count($images) > 1) { foreach ($images as $key => $image) { if (!isset($image->medium)) { $images[$key]->medium = $image->thumbnail; $change = 1; } } } if ($change == 1) { $obj = new stdClass(); $obj->id = $ad->id; $obj->images = json_encode($images); $ret = $db->updateObject('#__adsmanager_ads', $obj, 'id'); } } $db->setQuery(" ALTER IGNORE TABLE `#__adsmanager_config` ADD `special` TEXT DEFAULT NULL;"); try { $result = $db->query(); } catch (Exception $e) { } $obj = new stdClass(); $obj->id = 1; $obj->version = 5; $db->updateObject('#__adsmanager_config', $obj, 'id'); $config->version = 5; $continue = true; break; case 3: $db->setQuery(" ALTER IGNORE TABLE `#__adsmanager_config` ADD `params` TEXT DEFAULT NULL;"); try { $result = $db->query(); } catch (Exception $e) { } $db->setQuery(" ALTER IGNORE TABLE `#__adsmanager_fields` ADD `options` TEXT DEFAULT NULL;"); try { $result = $db->query(); } catch (Exception $e) { } $obj = new stdClass(); $obj->id = 1; $obj->version = 4; $db->updateObject('#__adsmanager_config', $obj, 'id'); $config->version = 4; $continue = true; break; case 2: $db->setQuery("ALTER IGNORE TABLE `#__adsmanager_ads` ADD `date_modified` DATETIME;"); try { $result = $db->query(); } catch (Exception $e) { } $db->setQuery("UPDATE `#__adsmanager_ads` SET `date_modified` = `date_created`"); try { $result = $db->query(); } catch (Exception $e) { } $obj = new stdClass(); $obj->id = 1; $obj->version = 3; $db->updateObject('#__adsmanager_config', $obj, 'id'); $config->version = 3; $continue = true; break; default: $db->setQuery("SELECT id,images FROM `#__adsmanager_ads`"); $ads = $db->loadObjectList("id"); $imagefiles = scandir(JPATH_ROOT . "/images/com_adsmanager/ads/"); $lists = array(); sort($imagefiles); foreach ($imagefiles as $imagefile) { if (preg_match("/([0-9]*)[a-z ]*_t.jpg/", $imagefile, $matches)) { $id = $matches[1]; if (!isset($lists[$id])) { $lists[$id] = array(); } $newimg = new stdClass(); $newimg->index = count($lists[$id]) + 1; $newimg->image = str_replace('_t.jpg', '.jpg', $imagefile); $newimg->thumbnail = $imagefile; $newimg->medium = str_replace('_t.jpg', '.jpg', $imagefile); $lists[$id][] = $newimg; } } foreach ($lists as $id => $list) { $obj = new stdClass(); $obj->id = $id; $obj->images = json_encode($list); $ret = $db->updateObject('#__adsmanager_ads', $obj, 'id'); } $app = JFactory::getApplication(); $db->setQuery("SELECT count(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = '" . $app->getCfg('db') . "' AND TABLE_NAME = '" . $db->getPrefix() . "adsmanager_fieldgmap'"); $count = $db->loadResult(); if ($count > 0) { $db->setQuery("SELECT fieldid,name FROM #__adsmanager_fields WHERE type='gmap'"); $fields = $db->loadObjectList("fieldid"); foreach ($fields as $field) { $query = "ALTER IGNORE TABLE `#__adsmanager_ads` ADD `" . $field->name . "_lat` FLOAT default NULL;"; $db->setQuery($query); try { $result = $db->query(); } catch (Exception $e) { } $query = "ALTER IGNORE TABLE `#__adsmanager_ads` ADD `" . $field->name . "_lng` FLOAT default NULL;"; $db->setQuery($query); try { $result = $db->query(); } catch (Exception $e) { } } $db->setQuery("SELECT * FROM #__adsmanager_fieldgmap"); $list = $db->loadObjectList(); $fields = array(); if ($list != null) { foreach ($list as $item) { $name = $fields[$item->fieldid]; $obj = new stdClass(); $obj->id = $item->contentid; $lat = $name . "_lat"; $obj->{$lat} = $item->lat; $lng = $name . "_lng"; $obj->{$lng} = $item->lng; $db->updateObject('#__adsmanager_ads', $obj, 'id'); } } $db->setQuery("DROP TABLE #__adsmanager_fieldgmap"); try { $result = $db->query(); } catch (Exception $e) { } } $app = JFactory::getApplication(); $db->setQuery("SELECT count(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = '" . $app->getCfg('db') . "' AND TABLE_NAME = '" . $db->getPrefix() . "adsmanager_youtube'"); $count = $db->loadResult(); if ($count > 0) { $db->setQuery("SELECT fieldid,name FROM #__adsmanager_fields WHERE type='youtube'"); $fields = $db->loadObjectList("fieldid"); foreach ($fields as $field) { $query = "ALTER IGNORE TABLE `#__adsmanager_ads` ADD `" . $field->name . "` TEXT default NULL;"; $db->setQuery($query); try { $result = $db->query(); } catch (Exception $e) { } } $db->setQuery("SELECT * FROM #__adsmanager_youtube"); $list = $db->loadObjectList(); if ($list != null) { foreach ($list as $item) { $name = @$fields[$item->fieldid]->name; if ($name != null) { $obj = new stdClass(); $obj->id = $item->contentid; $obj->{$name} = $item->key; $db->updateObject('#__adsmanager_ads', $obj, 'id'); } } } $db->setQuery("DROP TABLE #__adsmanager_youtube"); try { $result = $db->query(); } catch (Exception $e) { } } $obj = new stdClass(); $obj->id = 1; $obj->version = 2; $db->updateObject('#__adsmanager_config', $obj, 'id'); $config->version = 2; $continue = true; } } } ?> <center> <table width="100%" border="0"> <tr> <td> Thank you for using AdsManager (Juloa.com)<br/> <p> <em>support@juloa.com</em> </p> </td> <td> <p> <br> <br> <br> </p> </td> </tr> </table> </center> <?php if (version_compare(JVERSION, '2.5', '>=') && version_compare(JVERSION, '3.0', '<')) { JError::$legacy = $tmp_legacy; } return true; }
protected function migrate($row) { $base_path = $this->getUploadPath(); $old_path = $base_path . '/project_' . $row->id; $new_path = JPath::clean($base_path . '/' . $row->alias); // Rename existing path? if (JFolder::exists($old_path)) { if (!JFolder::exists($new_path)) { if (!JFolder::move($old_path, $new_path)) { $this->success = false; $this->log[] = JText::sprintf('COM_PFMIGRATOR_PREPREPO_RENAME_ERROR', $old_path, $new_path); return false; } } } else { // Create repo if (!JFolder::create($new_path)) { $this->success = false; $this->log[] = JText::sprintf('COM_PFMIGRATOR_PREPREPO_CREATE_ERROR', $new_path); return false; } } $data = array(); $data['project_id'] = $row->id; $data['title'] = $row->title; $data['alias'] = $row->alias; $data['created'] = $row->created; $data['created_by'] = $row->created_by; $data['access'] = $row->access; $data['protected'] = 1; $data['parent_id'] = 1; $tbl = JTable::getInstance('Directory', 'PFTable'); if (!$tbl) { $this->success = false; $this->log[] = JText::_('COM_PFMIGRATOR_PREPREPO_TBL_INSTANCE_ERROR'); return false; } $tbl->setLocation($data['parent_id'], 'last-child'); if (!$tbl->bind($data)) { $this->success = false; $this->log[] = $tbl->getError(); return false; } if (!$tbl->check()) { $this->success = false; $this->log[] = $tbl->getError(); return false; } if (!$tbl->store()) { $this->success = false; $this->log[] = $tbl->getError(); return false; } if (!$tbl->rebuildPath($tbl->id)) { $this->success = false; $this->log[] = $tbl->getError(); return false; } if (!$tbl->rebuild($tbl->id, $tbl->lft, $tbl->level, $tbl->path)) { $this->success = false; $this->log[] = $tbl->getError(); return false; } // Set the repo dir in the project settings $registry = new JRegistry(); $registry->loadString($row->attribs); $registry->set('repo_dir', $tbl->id); $query = $this->_db->getQuery(true); $query->update('#__pf_projects')->set('attribs = ' . $this->_db->quote(strval($registry)))->where('id = ' . (int) $row->id); $this->_db->setQuery($query); if (!$this->_db->execute()) { $this->success = false; $this->log[] = $this->_db->getError(); return false; } // Check if the directory id is already occupied $query->clear(); $query->select('id')->from('#__pf_folders_tmp')->where('id = ' . $tbl->id); $this->_db->setQuery($query); $exists = (int) $this->_db->loadResult($tbl->id); if ($exists) { $new_id = $this->getNewId($tbl->id); if (!$new_id) { return false; } $query->clear(); $query->update('#__pf_folders_tmp')->set('id = ' . $new_id)->where('id = ' . $tbl->id); $this->_db->setQuery($query); if (!$this->_db->execute()) { $this->success = false; $this->log[] = $this->_db->getError(); return false; } $query->clear(); $query->update('#__pf_folder_tree_tmp')->set('folder_id = ' . $new_id)->where('folder_id = ' . $tbl->id); $this->_db->setQuery($query); if (!$this->_db->execute()) { $this->success = false; $this->log[] = $this->_db->getError(); return false; } $query->clear(); $query->update('#__pf_folder_tree_tmp')->set('parent_id = ' . $new_id)->where('parent_id = ' . $tbl->id); $this->_db->setQuery($query); if (!$this->_db->execute()) { $this->success = false; $this->log[] = $this->_db->getError(); return false; } $query->clear(); $query->update('#__pf_files_tmp')->set('dir = ' . $new_id)->where('dir = ' . $tbl->id); $this->_db->setQuery($query); if (!$this->_db->execute()) { $this->success = false; $this->log[] = $this->_db->getError(); return false; } $query->clear(); $query->update('#__pf_notes_tmp')->set('dir = ' . $new_id)->where('dir = ' . $tbl->id); $this->_db->setQuery($query); if (!$this->_db->execute()) { $this->success = false; $this->log[] = $this->_db->getError(); return false; } $query->clear(); $query->update('#__pf_task_attachments_tmp')->set('attach_id = ' . $new_id)->where('attach_id = ' . $tbl->id)->where('attach_type = ' . $this->_db->quote('folder')); $this->_db->setQuery($query); if (!$this->_db->execute()) { $this->success = false; $this->log[] = $this->_db->getError(); return false; } } return true; }
function topiciconupload() { $app = JFactory::getApplication (); jimport ( 'joomla.filesystem.folder' ); jimport ( 'joomla.filesystem.file' ); jimport ( 'joomla.filesystem.archive' ); $tmp = JPATH_ROOT . '/tmp/kinstall/'; $dest = JPATH_ROOT . '/media/kunena/topicicons/'; $file = JRequest::getVar ( 'install_package', NULL, 'FILES', 'array' ); if (! JRequest::checkToken ()) { $app->enqueueMessage ( JText::_ ( 'COM_KUNENA_ERROR_TOKEN' ), 'error' ); $app->redirect ( KunenaRoute::_($this->baseurl, false) ); } if (!$file || !is_uploaded_file ( $file ['tmp_name'])) { $app->enqueueMessage ( JText::sprintf('COM_KUNENA_A_TOPICON_MANAGER_INSTALL_EXTRACT_MISSING', $file ['name']), 'notice' ); } else { $success = JFile::upload($file ['tmp_name'], $tmp . $file ['name']); $success = JArchive::extract ( $tmp . $file ['name'], $tmp ); if (! $success) { $app->enqueueMessage ( JText::sprintf('COM_KUNENA_A_TOPICON_MANAGER_INSTALL_EXTRACT_FAILED', $file ['name']), 'notice' ); } // Delete the tmp install directory if (JFolder::exists($tmp)) { $topicicons = $this->parseXMLTopiciconFile($tmp); if (!empty($topicicons)) { // Never overwrite existing topic icon set if (!JFolder::exists($dest.(String)$topicicons->name)) { $error = JFolder::move($tmp, $dest.(String)$topicicons->name); if ($error !== true) $app->enqueueMessage ( JText::_('COM_KUNENA_A_TOPICON_MANAGER_TEMPLATE').': ' . $error, 'notice' ); JFile::delete($dest.(String)$topicicons->name.'/'.$file['name']); if(JFolder::exists ($tmp)) $retval = JFolder::delete($tmp); $app->enqueueMessage ( JText::sprintf('COM_KUNENA_A_TOPICON_MANAGER_INSTALL_EXTRACT_SUCCESS', $file ['name']) ); } } else { JError::raiseWarning(100, JText::_('COM_KUNENA_A_TOPICON_MANAGER_TEMPLATE_MISSING_FILE')); $retval = false; } } else { JError::raiseWarning(100, JText::_('COM_KUNENA_A_TOPICON_MANAGER_TEMPLATE').' '.JText::_('COM_KUNENA_A_TOPICON_MANAGER_UNINSTALL').': '.JText::_('COM_KUNENA_A_TOPICON_MANAGER_DIR_NOT_EXIST')); $retval = false; } } $app->redirect ( KunenaRoute::_($this->baseurl, false) ); }
function onBeforeSaveField(&$field, &$post, &$file, &$item) { if (!in_array($field->field_type, self::$field_types)) { return; } $use_ingroup = $field->parameters->get('use_ingroup', 0); // Check if field has posted data if (empty($post) && !$use_ingroup) { return; } // Make sure posted data is an array $post = !is_array($post) ? array($post) : $post; //echo "<pre>"; print_r($post); // Get configuration $is_importcsv = JRequest::getVar('task') == 'importcsv'; $import_media_folder = JRequest::getVar('import_media_folder'); $image_source = $field->parameters->get('image_source', 0); if ($image_source > 1) { global $fc_folder_mode_err; if (empty($fc_folder_mode_err[$field->id])) { echo __FUNCTION__ . "(): folder-mode: " . $image_source . " not implemented please change image-source mode in image/gallery field with id: " . $field->id; $fc_folder_mode_err[$field->id] = 1; $image_source = 1; } } $unique_tmp_itemid = JRequest::getVar('unique_tmp_itemid', ''); // Set a warning message for overriden/changed files: form.php (frontend) or default.php (backend) if (!$is_importcsv && empty($unique_tmp_itemid)) { $app = JFactory::getApplication(); $app->enqueueMessage('WARNING, field: ' . $field->label . ' requires variable -unique_tmp_itemid- please update your ' . ($app->isSite() ? 'form.php' : 'default.php'), 'warning'); } // Execute once static $initialized = null; static $srcpath_original = ''; if (!$initialized) { $initialized = 1; jimport('joomla.filesystem.folder'); jimport('joomla.filesystem.jpath'); if ($is_importcsv) { $srcpath_original = JPath::clean(JPATH_SITE . DS . $import_media_folder . DS); require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_flexicontent' . DS . 'controllers' . DS . 'filemanager.php'; } } // *********************************************** // Special steps for image field in folder-mode(s) // *********************************************** if ($image_source > 0) { $dir = $field->parameters->get('dir'); $unique_tmp_itemid = JRequest::getVar('unique_tmp_itemid', ''); $destpath = JPath::clean(JPATH_SITE . DS . $dir . DS . 'item_' . $item->id . '_field_' . $field->id . DS); if ($image_source > 1) { } // TODO // Create original images folder if doing CSV import and folder does not exist if ($is_importcsv) { $destpath_original = $destpath . 'original' . DS; if (!JFolder::exists($destpath_original) && !JFolder::create($destpath_original)) { JError::raiseWarning(100, $field->label . ': Error. Unable to create folder: ' . $destpath_original); return false; // Cancel item creation } } else { if ($unique_tmp_itemid && $item->id != $unique_tmp_itemid) { $temppath = JPath::clean(JPATH_SITE . DS . $dir . DS . 'item_' . $unique_tmp_itemid . '_field_' . $field->id . DS); JFolder::move($temppath, $destpath); } } } // ************************************************************************** // Rearrange file array so that file properties are groupped per image number // ************************************************************************** //echo "<pre>"; print_r($file); echo "</pre>"; $files = array(); if ($file) { foreach ($file as $key => $all) { foreach ($all as $i => $val) { $files[$i][$key] = $val; } } } //echo "<pre>"; print_r($files); echo "</pre>"; // ***************************************************************************************** // Reformat the posted data & handle uploading / removing / deleting / replacing image files // ***************************************************************************************** $newpost = array(); $new = 0; foreach ($post as $n => $v) { if (empty($v)) { if ($use_ingroup) { // empty value for group $newpost[$new] = array('originalname' => ''); $new++; } continue; } // support for basic CSV import / export if ($is_importcsv && !is_array($v)) { if (@unserialize($v) !== false || $v === 'b:0;') { // support for exported serialized data) $v = unserialize($v); } else { $v = array('originalname' => $v); } } // Add system message if upload error $err_code = isset($files[$n]['error']) ? $files[$n]['error'] : false; if ($err_code && $err_code != UPLOAD_ERR_NO_FILE) { $err_msg = array(UPLOAD_ERR_INI_SIZE => 'The uploaded file exceeds the upload_max_filesize directive in php.ini', UPLOAD_ERR_INI_SIZE => 'The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form', UPLOAD_ERR_PARTIAL => 'The uploaded file was only partially uploaded', UPLOAD_ERR_NO_FILE => 'No file was uploaded', UPLOAD_ERR_NO_TMP_DIR => 'Missing a temporary folder', UPLOAD_ERR_CANT_WRITE => 'Failed to write file to disk', UPLOAD_ERR_EXTENSION => 'A PHP extension stopped the file upload'); JFactory::getApplication()->enqueueMessage("FILE FIELD: " . $err_msg[$err_code], 'warning'); continue; } // Handle uploading a new original file $new_file = $err_code === 0; $new_file_uploaded = null; if ($new_file) { $new_file_uploaded = $this->uploadOriginalFile($field, $v, $files[$n]); } else { if ($is_importcsv && $import_media_folder) { $filename = basename($v['originalname']); $sub_folder = dirname($v['originalname']); $sub_folder = $sub_folder && $sub_folder != '.' ? DS . $sub_folder : ''; if ($image_source) { $srcfilepath = JPath::clean($srcpath_original . $v['originalname']); $destfilepath = JPath::clean($destpath_original . $filename); if (JFile::exists($srcfilepath)) { $result = JFile::copy($srcfilepath, $destfilepath); if ($result && JPath::canChmod($destfilepath)) { chmod($destfilepath, 0644); } } $v['originalname'] = $filename; // make sure filename is without subfolder } else { $fman = new FlexicontentControllerFilemanager(); JRequest::setVar('return-url', null, 'post'); JRequest::setVar('file-dir-path', DS . $import_media_folder . $sub_folder, 'post'); JRequest::setVar('file-filter-re', preg_quote($filename), 'post'); JRequest::setVar('secure', 1, 'post'); JRequest::setVar('keep', 1, 'post'); $file_ids = $fman->addlocal(); reset($file_ids); // Reset array to point to first element $v['originalname'] = key($file_ids); // The (first) key of file_ids array is the cleaned up filename } } } // Defaut values for unset required properties of values $v['originalname'] = isset($v['originalname']) ? $v['originalname'] : ''; $v['existingname'] = isset($v['existingname']) ? $v['existingname'] : ''; $v['delete'] = isset($v['delete']) ? $v['delete'] : false; $v['remove'] = isset($v['remove']) ? $v['remove'] : false; if ($v['originalname'] || $v['existingname']) { //echo $v['originalname'] ." ". $v['existingname'] ."<br>"; // (b) Handle removing image assignment OR deleting the image file if ($v['originalname']) { if ($v['delete'] == 1 || $new_file_uploaded && !$field->parameters->get('existing_imgs', 1)) { // Try to clean unused values (this is forced to YES if existing image list is disabled) $filename = $v['delete'] == 1 ? $v['originalname'] : $v['delete']; // we may submit filename for deletion via 'delete' form field $canDeleteImage = $this->canDeleteImage($field, $filename, $item); // security concern check if value is in use if ($canDeleteImage) { $this->removeOriginalFile($field, $filename); //JFactory::getApplication()->enqueueMessage($field->label . ' ['.$n.'] : ' . 'Deleted image file: '.$filename.' from server storage'); } else { if ($v['delete'] == 1) { JFactory::getApplication()->enqueueMessage($field->label . ' [' . $n . '] : ' . 'Cannot delete image file: ' . $filename . ' from server storage, it is in use'); } } } elseif ($v['remove'] && $v['existingname']) { JFactory::getApplication()->enqueueMessage($field->label . ' [' . $n . '] : ' . 'Removed image assignment of file: ' . $filename . ' from the field'); } } // Need to clear 'delete' if not, to allow saving new value, we use 'delete' to post the auto-saved clear text $v['delete'] = $v['delete'] == 1 ? $v['delete'] : false; // (c) Handle replacing image with a new existing image if ($v['existingname']) { $v['originalname'] = $v['existingname']; $v['existingname'] = ''; } else { if ($v['delete'] || $v['remove']) { $v = ''; } } } else { // No original file posted discard current image row $v = ''; } // Add image entry to a new array skipping empty image entries if ($v) { $newpost[$new] = $v; $new++; } } $post = $newpost; // Serialize multi-property data before storing them into the DB foreach ($post as $i => $v) { $post[$i] = serialize($v); } }
/** * _renameFolder * @param string $folder * @return boolean */ protected function _renameFolder($existingName, $newName, $path) { if (JFolder::exists($path)) { } else { JFactory::getApplication()->enqueueMessage(JText::_('PLG_SYSTEM_FOLDER_NOT_FOUND') . ' ' . $path, 'error'); return false; } if (JFolder::exists($path . '/' . $existingName)) { } else { JFactory::getApplication()->enqueueMessage(JText::_('PLG_SYSTEM_FOLDER_NOT_FOUND') . ' ' . $path . $existingName, 'error'); return false; } $results = JFolder::move($existingName, $newName, $path); if ($results == false) { JFactory::getApplication()->enqueueMessage(JText::_('PLG_SYSTEM_RENAME_FOLDER_FAILED') . ' ' . $path . $existingName, 'error'); return false; } return true; }
/** * save a edited category * * @param int $cid id of category */ function Joom_SaveEditCategory(&$cid) { $config = Joom_getConfig(); $mainframe =& JFactory::getApplication('administrator'); $database =& JFactory::getDBO(); jimport('joomla.filesystem.folder'); $row = new mosCatgs($database); //read category from DB $row->load($cid); //read old parent assignment $parentold = $row->parent; //read old title $catnameold = $row->name; //get new values if (!$row->bind($_POST)) { echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n"; exit; } if (get_magic_quotes_gpc()) { $row->name = stripslashes($row->name); $row->description = stripslashes($row->description); } if (intval($row->owner) == 0) { $row->owner = null; } //make the new category title safe if ($catnameold != $row->name) { JFilterOutput::objectHTMLSafe($row->name); $catname = $row->name; $catnamemodif = true; } else { $catname = $catnameold; $catnamemodif = false; } //move the category folder, if parent assignment or category name changed if ($parentold != $row->parent || $catnamemodif == true) { //save old path $catpathold = $row->catpath; $parentpathnew = Joom_GetCatPath($row->parent); //Joom_FixFilename() convert/remove special chars except the underscore //affects only catpath $catname = Joom_FixFilename($catname); $catpathnew = $parentpathnew . $catname . '_' . $row->cid; $cat_originalpathold = JPath::clean(JPATH_ROOT . DS . $config->jg_pathoriginalimages . $catpathold); $cat_picturepathold = JPath::clean(JPATH_ROOT . DS . $config->jg_pathimages . $catpathold); $cat_thumbnailpathold = JPath::clean(JPATH_ROOT . DS . $config->jg_paththumbs . $catpathold); $cat_originalpathnew = JPath::clean(JPATH_ROOT . DS . $config->jg_pathoriginalimages . $catpathnew); $cat_picturepathnew = JPath::clean(JPATH_ROOT . DS . $config->jg_pathimages . $catpathnew); $cat_thumbnailpathnew = JPath::clean(JPATH_ROOT . DS . $config->jg_paththumbs . $catpathnew); //move folders //actualize catpath in DB $row->catpath = $catpathnew; //TODO error messages JFolder::move($cat_originalpathold, $cat_originalpathnew); JFolder::move($cat_picturepathold, $cat_picturepathnew); JFolder::move($cat_thumbnailpathold, $cat_thumbnailpathnew); //if parent category changes, modify catpath of all subcategories in DB $rowid = $row->cid; Joom_UpdateNewCatpath($rowid, $catpathold, $catpathnew); } if (!$row->store(true)) { echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n"; exit; } // redirect to category manager //TODO aha: message $mainframe->redirect('index.php?option=' . _JOOM_OPTION . '&act=categories'); }
/** * Rename a folder. * @param string $src The relative path of the source file * @param string $dest The name of the new folder * @return array $error */ function folderRename($src, $dest) { jimport('joomla.filesystem.folder'); $src = Utils::makePath($this->getBaseDir(), rawurldecode($src)); $dir = dirname($src); $dest = Utils::makePath($dir, $dest); if (!JFolder::move($src, $dest)) { $this->_result['error'] = JText::_('Rename Folder Error'); } else { $this->_result = $this->fireEvent('onFolderRename'); } return $this->returnResult(); }
public function backupTemplate($templateName) { $templatesPath = JPATH_ROOT . '/components/com_community/templates/'; $templatePath = $templatesPath . $templateName . '/'; if (JFolder::exists($templatePath)) { $backups = JFolder::folders($templatesPath, '^' . $templateName . '_bak[0-9]'); $newIndex = 0; foreach ($backups as $backup) { $currentIndex = str_replace($templateName . '_bak', '', $backup); $newIndex = max($newIndex, $currentIndex); } $newIndex += 1; $templateBackupPath = $templatesPath . $templateName . '_bak' . $newIndex . '/'; JFolder::move($templatePath, $templateBackupPath); } }
/** * Installs a new theme * * @since 1.0 * @access public * @param string * @return */ public function install($file) { $source = $file['tmp_name']; $fileName = md5($file['name'] . Foundry::date()->toMySQL()); $fileExtension = '_themes_install.zip'; $destination = JPATH_ROOT . '/tmp/' . $fileName . $fileExtension; // Upload the zip archive $state = JFile::upload($source, $destination); if (!$state) { $this->setError(JText::_('COM_EASYBLOG_THEMES_INSTALLER_ERROR_COPY_FROM_PHP')); return false; } // Extract the zip $extracted = dirname($destination) . '/' . $fileName . '_themes_install'; $state = JArchive::extract($destination, $extracted); // Once it is extracted, delete the zip file JFile::delete($destination); // Get the configuration file. $manifest = $extracted . '/config/template.json'; $manifest = JFile::read($manifest); // Get the theme object $theme = json_decode($manifest); // Move it to the appropriate folder $themeDestination = EBLOG_THEMES . '/' . strtolower($theme->element); $exists = JFolder::exists($themeDestination); // If folder exists, overwrite it. For now, just throw an error. if ($exists) { // Delete teh etracted folder JFolder::delete($extracted); $this->setError(JText::sprintf('COM_EASYBLOG_THEMES_INSTALLER_ERROR_SAME_THEME_FOLDER_EXISTS', $theme->element)); return false; } // Move extracted folder $state = JFolder::move($extracted, $themeDestination); if (!$state) { // Delete the etracted folder JFolder::delete($extracted); $this->setError(JText::_('COM_EASYBLOG_THEMES_INSTALLER_ERROR_MOVING_FOLDER_TO_THEMES_FOLDER')); return false; } return true; }
public function preflight($route, JAdapterInstance $adapter) { if ($route == 'install' || $route == 'discover_install' || $route == 'update') { // Install the modules and plugins. $src = $adapter->getParent()->getPath('source'); $manifest = $adapter->getParent()->manifest; $plugins = $manifest->xpath('plugins/plugin'); if (count($plugins)) { foreach ($plugins as $plugin) { $name = (string) $plugin->attributes()->plugin; $group = (string) $plugin->attributes()->group; $this->i_status->plugins[] = array('name' => $name, 'group' => $group, 'result' => $this->installPlugin($name, $group, $src)); } } $modules = $manifest->xpath('modules/module'); if (count($modules)) { foreach ($modules as $module) { $name = (string) $module->attributes()->module; $client = (string) $module->attributes()->client; $this->i_status->modules[] = array('name' => $name, 'client' => $client, 'result' => $this->installModule($name, $client, $src)); } } if (JFolder::exists(JPATH_ROOT . DS . 'components' . DS . 'com_cobalt')) { if (JFolder::exists($src . DS . 'media' . DS . 'com_jvrelatives' . DS . 'temp' . DS . 'com_cobalt' . DS . 'fields' . DS . 'jvrelatives')) { try { // delete jvrelatives field in cobalt if it exists already if (JFolder::exists(JPATH_ROOT . DS . 'components' . DS . 'com_cobalt' . DS . 'fields' . DS . 'jvrelatives')) { JFolder::delete(JPATH_ROOT . DS . 'components' . DS . 'com_cobalt' . DS . 'fields' . DS . 'jvrelatives'); } // Move the cobalt field from media to cobalt fields folder $ret = JFolder::move($src . DS . 'media' . DS . 'com_jvrelatives' . DS . 'temp' . DS . 'com_cobalt' . DS . 'fields' . DS . 'jvrelatives', JPATH_ROOT . DS . 'components' . DS . 'com_cobalt' . DS . 'fields' . DS . 'jvrelatives'); if ($ret) { $this->i_status->files[0] = array('name' => 'cobalt field', 'result' => 1); } else { throw new Exception($ret); } } catch (Exception $ex) { $this->i_status->files[0] = array('name' => 'cobalt field', 'result' => 0); } } } if (!JFile::exists(JPATH_ROOT . DS . 'images' . DS . 'jvrel_thumbnail.gif')) { JFile::copy($src . DS . 'media' . DS . 'com_jvrelatives' . DS . 'assets' . DS . 'images' . DS . 'thumbnail.gif', JPATH_ROOT . DS . 'images' . DS . 'jvrel_thumbnail.gif'); } } return true; }
protected function _saveDocumentPath(KModelEntityInterface $entity) { if (!$this->isModified('document_path')) { return; } $translator = $this->getObject('translator'); $from = $entity->path; $fullpath = $entity->fullpath; $path = rtrim($this->document_path, '\\/'); if ($from === $path) { return; } if ($path === 'joomlatools-files') { $this->getObject('response')->addMessage($translator->translate('joomlatools-files is a special folder used for other DOCman features. You can only use a subfolder of it to store your files'), 'error'); return; } if (!preg_match('#^[0-9A-Za-z:_\\-\\\\/\\.]+$#', $path)) { $this->getObject('response')->addMessage($translator->translate('Document path can only contain letters, numbers, dash or underscore'), 'error'); return; } $db = JFactory::getDBO(); $query = sprintf("SELECT COUNT(*) FROM #__menu WHERE path = %s", $db->quote($path)); if ($db->setQuery($query)->loadResult()) { $this->getObject('response')->addMessage($translator->translate('A menu item on your site uses this path as its alias. In order to ensure that your site works correctly, the document path was left unchanged.'), 'error'); return; } $entity->path = $path; if ($entity->save()) { jimport('joomla.filesystem.folder'); jimport('joomla.filesystem.file'); $parent = dirname($entity->fullpath); if (!JFolder::exists($parent)) { JFolder::create($parent); } if (JFolder::move($fullpath, $entity->fullpath) !== true) { $this->getObject('response')->addMessage($translator->translate('Changes are saved but you should move existing files manually from folder "{from}" to "{to}" at your site root in order to make existing files visible.', array('from' => $from, 'to' => $path)), 'warning'); } if (!JFile::exists($entity->fullpath . '/.htaccess')) { $buffer = 'DENY FROM ALL'; JFile::write($entity->fullpath . '/.htaccess', $buffer); } if (!JFile::exists($entity->fullpath . '/web.config')) { $buffer = '<?xml version="1.0" encoding="utf-8" ?> <system.webServer> <security> <authorization> <remove users="*" roles="" verbs="" /> <add accessType="Allow" roles="Administrators" /> </authorization> </security> </system.webServer>'; JFile::write($entity->fullpath . '/web.config', $buffer); } } }
protected function _sanatizePositionsConfig($path, $type) { // get renderer $renderer = new ItemRenderer(); $renderer->addPath($path); // rename folder if special type if ($renderer->pathExists('item' . DIRECTORY_SEPARATOR . $type->id)) { $folder = $path . DIRECTORY_SEPARATOR . $renderer->getFolder() . DIRECTORY_SEPARATOR . 'item' . DIRECTORY_SEPARATOR; JFolder::move($folder . $type->id, $folder . $type->identifier); } // get positions and config $config = $renderer->getConfig('item'); $params = $config->get($this->group . '.' . $type->id . '.'); $config->set($this->group . '.' . $type->identifier . '.', $params); $config->remove($this->group . '.' . $type->id . '.'); $renderer->saveConfig($config, $path . '/renderer/item/positions.config'); }