// Add a message when a shop is created to indicate that the user should create an URL for this shop + fix some bugs
This commit is contained in:
@@ -71,9 +71,10 @@ echo '
|
||||
<div id="header_infos"><span>
|
||||
<a id="header_shopname" href="index.php"><span>'.Configuration::get('PS_SHOP_NAME').'</span></a><br />
|
||||
'.Tools::substr($employee->firstname, 0, 1).'. '.htmlentities($employee->lastname, ENT_COMPAT, 'UTF-8').'
|
||||
[ <a href="index.php?logout" id="header_logout"><span>'.translate('logout').'</span></a> ]
|
||||
- <a href="'.__PS_BASE_URI__.'" id="header_foaccess" target="_blank" title="'.translate('View my shop').'"><span>'.translate('View my shop').'</span></a>
|
||||
- <a href="index.php?tab=AdminEmployees&id_employee='.(int)$cookie->id_employee.'&updateemployee&token='.Tools::getAdminTokenLite('AdminEmployees').'" style="font-size: 10px;"><img src="../img/admin/employee.gif" alt="" /> '.translate('My preferences').'</a>
|
||||
[ <a href="index.php?logout" id="header_logout"><span>'.translate('logout').'</span></a> ]';
|
||||
if (Context::getContext()->shop->getBaseURI())
|
||||
echo '- <a href="'.Context::getContext()->shop->getBaseURI().'" id="header_foaccess" target="_blank" title="'.translate('View my shop').'"><span>'.translate('View my shop').'</span></a>';
|
||||
echo ' - <a href="index.php?tab=AdminEmployees&id_employee='.(int)$cookie->id_employee.'&updateemployee&token='.Tools::getAdminTokenLite('AdminEmployees').'" style="font-size: 10px;"><img src="../img/admin/employee.gif" alt="" /> '.translate('My preferences').'</a>
|
||||
</span></div>
|
||||
<div id="header_search">
|
||||
<form method="post" action="index.php?tab=AdminSearch&token='.Tools::getAdminTokenLite('AdminSearch').'">
|
||||
|
||||
@@ -60,38 +60,53 @@ class AdminShop extends AdminTab
|
||||
);
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
|
||||
public function afterAdd($newShop)
|
||||
{
|
||||
if (Tools::getValue('useImportData') && ($importData = Tools::getValue('importData')) && is_array($importData))
|
||||
$newShop->copyShopData((int)Tools::getValue('importFromShop'), $importData);
|
||||
}
|
||||
|
||||
|
||||
public function postProcess()
|
||||
{
|
||||
if (Tools::isSubmit('delete'.$this->table) OR ((Tools::isSubmit('status') OR Tools::isSubmit('status'.$this->table)) && $this->loadObject()->active))
|
||||
if ((Tools::isSubmit('status') || Tools::isSubmit('status'.$this->table) || (Tools::isSubmit('submitAdd'.$this->table) && Tools::getValue($this->identifier) && !Tools::getValue('active'))) && $this->loadObject() && $this->loadObject()->active)
|
||||
{
|
||||
if (Shop::getTotalShops() == 1)
|
||||
{
|
||||
$this->_errors[] = Tools::displayError('You cannot delete or disable the last shop.');
|
||||
return false;
|
||||
}
|
||||
if (Tools::getValue('id_shop') == Configuration::get('PS_SHOP_DEFAULT'))
|
||||
$this->_errors[] = Tools::displayError('You cannot disable the default shop.');
|
||||
else if (Shop::getTotalShops() == 1)
|
||||
$this->_errors[] = Tools::displayError('You cannot disable the last shop.');
|
||||
}
|
||||
|
||||
if ($this->_errors)
|
||||
return false;
|
||||
return parent::postProcess();
|
||||
}
|
||||
|
||||
|
||||
public function displayConf()
|
||||
{
|
||||
if ($conf = Tools::getValue('conf'))
|
||||
{
|
||||
if ($conf == 3)
|
||||
echo '
|
||||
<div class="conf">
|
||||
<img src="../img/admin/ok2.png" alt="" /> <a href="index.php?tab=AdminShopUrl&addshop_url&token='.Tools::getAdminToken('AdminShopUrl'.Tab::getIdFromClassName('AdminShopUrl').(int)$this->context->employee->id).'">'.$this->l('Your store has been successfully created. To make your store accessible on front office, you must create a URL for your store by clicking on this text.').'</a>
|
||||
</div>';
|
||||
else
|
||||
parent::displayConf();
|
||||
}
|
||||
}
|
||||
|
||||
public function displayForm($isMainTab = true)
|
||||
{
|
||||
parent::displayForm($isMainTab);
|
||||
|
||||
|
||||
if (!($obj = $this->loadObject(true)))
|
||||
return;
|
||||
|
||||
$disabled = '';
|
||||
if (Shop::getTotalShops() > 1 && $obj->id)
|
||||
$disabled = 'disabled="disabled"';
|
||||
|
||||
|
||||
|
||||
echo '
|
||||
<form action="'.self::$currentIndex.'&submitAdd'.$this->table.'=1&token='.$this->token.'" method="post">
|
||||
'.($obj->id ? '<input type="hidden" name="id_'.$this->table.'" value="'.$obj->id.'" />' : '').'
|
||||
@@ -134,7 +149,7 @@ class AdminShop extends AdminTab
|
||||
<label class="t" for="active_off"> <img src="../img/admin/disabled.gif" alt="'.$this->l('Disabled').'" title="'.$this->l('Disabled').'" /></label>
|
||||
<p>'.$this->l('Enable or disable shop').'</p>
|
||||
</div>';
|
||||
|
||||
|
||||
// Theme list
|
||||
echo '<label for="id_theme">'.$this->l('Theme').'</label>
|
||||
<div class="margin-form">';
|
||||
@@ -148,7 +163,6 @@ class AdminShop extends AdminTab
|
||||
echo '</div>';
|
||||
}
|
||||
echo '</div><div class="clear"></div>';
|
||||
|
||||
|
||||
echo '<div class="margin-form">
|
||||
<input type="submit" value="'.$this->l(' Save ').'" name="submitAdd'.$this->table.'" class="button" />
|
||||
@@ -183,7 +197,7 @@ class AdminShop extends AdminTab
|
||||
'store' => $this->l('Stores'),
|
||||
'zone' => $this->l('Zones'),
|
||||
);
|
||||
|
||||
|
||||
echo '<fieldset><legend>'.$this->l('Import data from another shop').'</legend>';
|
||||
echo '<label>'.$this->l('Import data from another shop').'</label>';
|
||||
echo '<div class="margin-form">';
|
||||
@@ -211,7 +225,7 @@ class AdminShop extends AdminTab
|
||||
|
||||
echo '</form>';
|
||||
}
|
||||
|
||||
|
||||
protected function displayAddButton()
|
||||
{
|
||||
echo '<br /><a href="'.self::$currentIndex.'&add'.$this->table.'&token='.$this->token.'"><img src="../img/admin/add.gif" border="0" /> '.$this->l('Add new shop').'</a><br /><br />';
|
||||
|
||||
@@ -197,19 +197,20 @@ abstract class AdminTabCore
|
||||
|
||||
$this->id = Tab::getCurrentTabId();
|
||||
$this->_conf = array(
|
||||
1 => $this->l('Deletion successful'), 2 => $this->l('Selection successfully deleted'),
|
||||
3 => $this->l('Creation successful'), 4 => $this->l('Update successful'),
|
||||
5 => $this->l('Status update successful'), 6 => $this->l('Settings update successful'),
|
||||
7 => $this->l('Image successfully deleted'), 8 => $this->l('Module downloaded successfully'),
|
||||
9 => $this->l('Thumbnails successfully regenerated'), 10 => $this->l('Message sent to the customer'),
|
||||
11 => $this->l('Comment added'), 12 => $this->l('Module installed successfully'),
|
||||
13 => $this->l('Module uninstalled successfully'), 14 => $this->l('Language successfully copied'),
|
||||
15 => $this->l('Translations successfully added'), 16 => $this->l('Module transplanted successfully to hook'),
|
||||
17 => $this->l('Module removed successfully from hook'), 18 => $this->l('Upload successful'),
|
||||
19 => $this->l('Duplication completed successfully'), 20 => $this->l('Translation added successfully but the language has not been created'),
|
||||
21 => $this->l('Module reset successfully'), 22 => $this->l('Module deleted successfully'),
|
||||
23 => $this->l('Localization pack imported successfully'), 24 => $this->l('Refund Successful'),
|
||||
25 => $this->l('Images successfully moved'));
|
||||
1 => $this->l('Deletion successful'), 2 => $this->l('Selection successfully deleted'),
|
||||
3 => $this->l('Creation successful'), 4 => $this->l('Update successful'),
|
||||
5 => $this->l('Status update successful'), 6 => $this->l('Settings update successful'),
|
||||
7 => $this->l('Image successfully deleted'), 8 => $this->l('Module downloaded successfully'),
|
||||
9 => $this->l('Thumbnails successfully regenerated'), 10 => $this->l('Message sent to the customer'),
|
||||
11 => $this->l('Comment added'), 12 => $this->l('Module installed successfully'),
|
||||
13 => $this->l('Module uninstalled successfully'), 14 => $this->l('Language successfully copied'),
|
||||
15 => $this->l('Translations successfully added'), 16 => $this->l('Module transplanted successfully to hook'),
|
||||
17 => $this->l('Module removed successfully from hook'), 18 => $this->l('Upload successful'),
|
||||
19 => $this->l('Duplication completed successfully'), 20 => $this->l('Translation added successfully but the language has not been created'),
|
||||
21 => $this->l('Module reset successfully'), 22 => $this->l('Module deleted successfully'),
|
||||
23 => $this->l('Localization pack imported successfully'), 24 => $this->l('Refund Successful'),
|
||||
25 => $this->l('Images successfully moved'),
|
||||
);
|
||||
if (!$this->identifier) $this->identifier = 'id_'.$this->table;
|
||||
if (!$this->_defaultOrderBy) $this->_defaultOrderBy = $this->identifier;
|
||||
$className = get_class($this);
|
||||
|
||||
@@ -146,6 +146,10 @@ class ConfigurationCore extends ObjectModel
|
||||
$langID = (int)$langID;
|
||||
if (!isset(self::$_CONF[$langID]))
|
||||
$langID = 0;
|
||||
|
||||
// If conf if not initialized, try manual query
|
||||
if (!self::$_CONF)
|
||||
return Db::getInstance()->getValue('SELECT `value` FROM '._DB_PREFIX_.'configuration WHERE `name` = \''.pSQL($key).'\'');
|
||||
|
||||
if ($shopID && Configuration::hasKey($key, $langID, null, $shopID))
|
||||
return self::$_CONF[$langID]['shop'][$shopID][$key];
|
||||
|
||||
@@ -138,7 +138,7 @@ class ShopCore extends ObjectModel
|
||||
AND su.main = 1';
|
||||
if (!$row = Db::getInstance()->getRow($sql))
|
||||
return ;
|
||||
|
||||
|
||||
$this->theme_name = $row['name'];
|
||||
$this->physical_uri = $row['physical_uri'];
|
||||
$this->virtual_uri = $row['virtual_uri'];
|
||||
@@ -218,7 +218,7 @@ class ShopCore extends ObjectModel
|
||||
AND s.active = 1
|
||||
AND s.deleted = 0
|
||||
ORDER BY LENGTH(uri) DESC';
|
||||
|
||||
|
||||
$id_shop = '';
|
||||
if ($results = Db::getInstance()->executeS($sql))
|
||||
foreach ($results as $row)
|
||||
@@ -233,8 +233,17 @@ class ShopCore extends ObjectModel
|
||||
|
||||
// Get instance of found shop
|
||||
$shop = new Shop($id_shop);
|
||||
if (!Validate::isLoadedObject($shop))
|
||||
$shop = new Shop(1);
|
||||
if (!Validate::isLoadedObject($shop) || !$shop->active)
|
||||
{
|
||||
// No shop found ... too bad, let's redirect to default shop
|
||||
$defaultShop = new Shop(Configuration::get('PS_SHOP_DEFAULT'));
|
||||
if (!$defaultShop)
|
||||
// Hmm there is something really bad in your Prestashop !
|
||||
die('Shop not found');
|
||||
$url = 'http://'.$defaultShop->domain.$defaultShop->getBaseURI().ltrim($_SERVER['SCRIPT_NAME'], '/').'?'.$_SERVER['QUERY_STRING'];
|
||||
header('location: '.$url);
|
||||
exit;
|
||||
}
|
||||
return $shop;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user