diff --git a/admin-dev/tabs/AdminMessages.php b/admin-dev/tabs/AdminMessages.php deleted file mode 100644 index 208d93afa..000000000 --- a/admin-dev/tabs/AdminMessages.php +++ /dev/null @@ -1,170 +0,0 @@ - -* @copyright 2007-2011 PrestaShop SA -* @version Release: $Revision: 7310 $ -* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -class AdminMessages extends AdminTab -{ - public function __construct() - { - $this->table = 'order'; - $this->className = 'Order'; - $this->view = 'noActionColumn'; - $this->colorOnBackground = true; - $this->context = Context::getContext(); - $start = 0; - $this->_defaultOrderBy = 'date_add'; - - /* Manage default params values */ - if (empty($limit)) - $limit = ((!isset($this->context->cookie->{$this->table.'_pagination'})) ? $this->_pagination[0] : $limit = $this->context->cookie->{$this->table.'_pagination'}); - - if (!Validate::isTableOrIdentifier($this->table)) - die (Tools::displayError('Table name is invalid:').' "'.$this->table.'"'); - - if (empty($orderBy)) - $orderBy = Tools::getValue($this->table.'Orderby', $this->_defaultOrderBy); - elseif ($orderBy == 'id_order') - $orderBy = 'm.id_order'; - - if (empty($orderWay)) - $orderWay = Tools::getValue($this->table.'Orderway', 'ASC'); - - $limit = (int)(Tools::getValue('pagination', $limit)); - $this->context->cookie->{$this->table.'_pagination'} = $limit; - - /* Check params validity */ - if (!Validate::isOrderBy($orderBy) OR !Validate::isOrderWay($orderWay) - OR !is_numeric($start) OR !is_numeric($limit)) - die(Tools::displayError('get list params is not valid')); - - if ($orderBy == 'id_order') - $orderBy = 'm.id_order'; - - /* Determine offset from current page */ - if ((isset($_POST['submitFilter'.$this->table]) OR - isset($_POST['submitFilter'.$this->table.'_x']) OR - isset($_POST['submitFilter'.$this->table.'_y'])) AND - !empty($_POST['submitFilter'.$this->table]) AND - is_numeric($_POST['submitFilter'.$this->table])) - $start = (int)($_POST['submitFilter'.$this->table] - 1) * $limit; - - $this->_list = Db::getInstance()->executeS(' - SELECT SQL_CALC_FOUND_ROWS m.id_message, m.id_cart, m.id_employee, IF(m.id_order > 0, m.id_order, \'--\') id_order, m.message, m.private, m.date_add, CONCAT(LEFT(c.`firstname`, 1), \'. \', c.`lastname`) AS customer, - c.id_customer, count(m.id_message) nb_messages, (SELECT message FROM '._DB_PREFIX_.'message WHERE id_order = m.id_order ORDER BY date_add DESC LIMIT 1) last_message, - (SELECT COUNT(m2.id_message) FROM '._DB_PREFIX_.'message m2 WHERE 1 AND m2.id_customer != 0 AND m2.id_order = m.id_order AND m2.id_message NOT IN - (SELECT mr2.id_message FROM '._DB_PREFIX_.'message_readed mr2 WHERE mr2.id_employee = '.(int)$this->context->employee->id.') GROUP BY m2.id_order) nb_messages_not_read_by_me - FROM '._DB_PREFIX_.'message m - LEFT JOIN '._DB_PREFIX_.'orders o ON (o.id_order = m.id_order) - LEFT JOIN '._DB_PREFIX_.'customer c ON (c.id_customer = m.id_customer) - GROUP BY m.id_order - ORDER BY '.(isset($orderBy) ? pSQL($orderBy) : 'date_add') .' '.(isset($orderWay) ? pSQL($orderWay) : 'DESC').' - LIMIT '.(int)($start).','.(int)($limit)); - $this->_listTotal = Db::getInstance()->getValue('SELECT FOUND_ROWS()'); - - $this->fieldsDisplay = array( - 'id_order' => array('title' => $this->l('Order ID'), 'align' => 'center', 'width' => 30), - 'id_customer' => array('title' => $this->l('Customer ID'), 'align' => 'center', 'width' => 30), - 'customer' => array('title' => $this->l('Customer'), 'width' => 100, 'filter_key' => 'customer', 'tmpTableFilter' => true), - 'last_message' => array('title' => $this->l('Last message'), 'width' => 400, 'orderby' => false), - 'nb_messages_not_read_by_me' => array('title' => $this->l('Unread message(s)'), 'width' =>30, 'align' => 'center'), - 'nb_messages' => array('title' => $this->l('Number of messages'), 'width' => 30, 'align' => 'center')); - - parent::__construct(); - } - - public function display() - { - if (isset($_GET['ajax']) && !empty($_GET['id_cart'])) - { - ob_clean(); - - $messages = Message::getMessagesByCartId(Tools::getValue('id_cart'), true); - - echo ' - -
'.$this->l('This customer has not finalized their order, however here are their messages:').'
'; - - foreach ($messages AS $message) - { - echo ' -| '.$this->l('Cart ID:').' | -'.(int)$message['id_cart'].' | -
| '.$this->l('Customer ID:').' | -'.(int)$message['id_customer'].' | -
| '.$this->l('Date:').' | -'.Tools::displayDate($message['date_add'], $this->context->language->id, true).' | -
'.$this->l('Message:').' '.Tools::htmlentitiesUTF8($message['message']).'
-
'.
- Tools::displayError('Cannot display this message because the customer has not finalized their order.').'
';
-
- echo '
-
-
- ';
-
- $this->displayList();
- $this->displayOptionsList();
- }
- }
-}
\ No newline at end of file
diff --git a/admin-dev/tabs/AdminUpgrade.php b/admin-dev/tabs/AdminUpgrade.php
deleted file mode 100644
index f6bd55a46..000000000
--- a/admin-dev/tabs/AdminUpgrade.php
+++ /dev/null
@@ -1,1876 +0,0 @@
-
-* @copyright 2007-2011 PrestaShop SA
-* @version Release: $Revision$
-* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
-* International Registered Trademark & Property of PrestaShop SA
-*/
-
-require_once(_PS_ADMIN_DIR_.'/tabs/AdminPreferences.php');
-
-class AdminUpgrade extends AdminPreferences
-{
- public $ajax = false;
- public $nextResponseType = 'json'; // json, xml
- public $next = 'N/A';
-
- /**
- * set to false if the current step is a loop
- *
- * @var boolean
- */
- public $stepDone = true;
- public $error ='0';
- public $nextDesc = '.';
- public $nextParams = array();
- public $nextQuickInfo = array();
- public $currentParams = array();
- public $autoupgradePath = '';
- /**
- * autoupgradeDir
- *
- * @var string directory relative to admin dir
- */
- public $autoupgradeDir = 'autoupgrade';
- public $latestRootDir = '';
- public $prodRootDir = '';
- public $rootWritable = false;
- public $svnDir = 'svn';
- public $destDownloadFilename = 'prestashop.zip';
- public $toUpgradeFileList = array();
- public $backupFileList = array();
- public $sampleFileList = array();
- private $backupIgnoreFiles = array();
- private $backupIgnoreAbsoluteFiles = array();
- private $excludeFilesFromUpgrade = array();
- private $excludeAbsoluteFilesFromUpgrade = array();
-
-/**
- * int loopBackupFiles : if your server has a low memory size, lower this value
- * @TODO remove the static, add a const, and use it like this : min(AdminUpgrade::DEFAULT_LOOP_ADD_FILE_TO_ZIP,Configuration::get('LOOP_ADD_FILE_TO_ZIP');
- */
- public static $loopBackupFiles = 1000;
-/**
- * int loopUpgradeFiles : if your server has a low memory size, lower this value
- */
- public static $loopUpgradeFiles = 1000;
-/**
- * intloopRemoveSamples : if your server has a low memory size, lower this value
- */
- public static $loopRemoveSamples = 1000;
-
-// public static $skipAction = array('unzip'=>'listSampleFiles');
- public static $skipAction;
- public $useSvn;
-
- protected $_includeContainer = false;
-
- public function __construct()
- {
- Tools::displayAsDeprecated();
- @set_time_limit(0);
- @ini_set('max_execution_time', '0');
-
- $this->init();
- parent::__construct();
- }
-
- /**
- * _setFields function to set fields (only when we need it).
- *
- * @return void
- */
- private function _setFields()
- {
- $this->_fieldsAutoUpgrade['PS_AUTOUP_DONT_SAVE_IMAGES'] = array(
- 'title' => $this->l('Don\'t save images'), 'cast' => 'intval', 'validation' => 'isBool',
- 'type' => 'bool', 'desc'=>$this->l('You can exclude the image directory from backup if you already saved it by another method (not recommended)'),
- );
-
- $this->_fieldsAutoUpgrade['PS_AUTOUP_KEEP_DEFAULT_THEME'] = array(
- 'title' => $this->l('Keep theme "prestashop"'), 'cast' => 'intval', 'validation' => 'isBool',
- 'type' => 'bool', 'desc'=>$this->l('If you have customized PrestaShop default theme, you can protect it from upgrade (not recommended)'),
- );
-
- $this->_fieldsAutoUpgrade['PS_AUTOUP_KEEP_TRAD'] = array(
- 'title' => $this->l('Keep translations'), 'cast' => 'intval', 'validation' => 'isBool',
- 'type' => 'bool', 'desc'=>$this->l('If set too yes, you will keep all your translations'),
- );
- // allow manual mode only for dev
- if (defined('_PS_MODE_DEV_') AND _PS_MODE_DEV_)
- $this->_fieldsAutoUpgrade['PS_AUTOUP_MANUAL_MODE'] = array(
- 'title' => $this->l('Manual mode'), 'cast' => 'intval', 'validation' => 'isBool',
- 'type' => 'bool', 'desc'=>$this->l('Check this if you want to stop after each step'),
- );
-
- if (defined('_PS_ALLOW_UPGRADE_UNSTABLE_') AND _PS_ALLOW_UPGRADE_UNSTABLE_ AND function_exists('svn_checkout'))
- {
- $this->_fieldsAutoUpgrade['PS_AUTOUP_USE_SVN'] = array(
- 'title' => $this->l('Use Subversion'), 'cast' => 'intval', 'validation' => 'isBool',
- 'type' => 'bool', 'desc' => $this->l('check this if you want to use unstable svn instead of official release'),
- );
- }
- }
-
- /**
- * isUpgradeAllowed checks if all server configuration is valid for upgrade
- *
- * @return void
- */
- public function isUpgradeAllowed()
- {
- $allowed = (ConfigurationTest::test_fopen() && $this->rootWritable);
-
- if (!defined('_PS_MODE_DEV_') OR !_PS_MODE_DEV_)
- $allowed &= $this->upgrader->autoupgrade;
-
- return $allowed;
- }
-
- /**
- * init to build informations we need
- *
- * @return void
- */
- public function init()
- {
- // For later use, let's set up prodRootDir and adminDir
- // This way it will be easier to upgrade a different path if needed
- $this->prodRootDir = _PS_ROOT_DIR_;
- $this->adminDir = _PS_ADMIN_DIR_;
-
- // test writable recursively
- if (ConfigurationTest::test_dir($this->prodRootDir,true))
- $this->rootWritable = true;
-
- // checkPSVersion will be not
- $this->upgrader = new Upgrader(true);
- $this->upgrader->checkPSVersion();
- // If you have defined this somewhere, you know what you do
- if (defined('_PS_ALLOW_UPGRADE_UNSTABLE_') AND _PS_ALLOW_UPGRADE_UNSTABLE_ AND function_exists('svn_checkout'))
- {
- $this->useSvn = Configuration::get('PS_AUTOUP_USE_SVN');
- }
- else
- $this->useSvn = false;
-
- // from $_POST or $_GET
- $this->action = Tools::getValue('action');
- $this->currentParams = Tools::getValue('params');
-
- // If not exists in this sessions, "create"
- // session handling : from current to next params
- if (isset($this->currentParams['removeList']))
- $this->nextParams['removeList'] = $this->currentParams['removeList'];
-
- if (isset($this->currentParams['filesToUpgrade']))
- $this->nextParams['filesToUpgrade'] = $this->currentParams['filesToUpgrade'];
-
- $this->backupDbFilename = Configuration::get('UPGRADER_BACKUPDB_FILENAME');
- if(!file_exists($this->backupDbFilename))
- {
- $this->backupDbFilename = '';
- Configuration::updateValue('UPGRADER_BACKUPDB_FILENAME','');
- }
- $this->backupFilesFilename = Configuration::get('UPGRADER_BACKUPFILES_FILENAME');
- if(!file_exists($this->backupFilesFilename))
- {
- $this->backupFilesFilename = '';
- Configuration::updateValue('UPGRADER_BACKUPFILES_FILENAME','');
- }
-
-
- $this->autoupgradePath = $this->adminDir.DIRECTORY_SEPARATOR.$this->autoupgradeDir;
-
- if (!file_exists($this->autoupgradePath))
- if (!@mkdir($this->autoupgradePath,0777))
- $this->_errors[] = Tools::displayError(sprintf($this->l('unable to create directory %s'),$this->autoupgradePath));
-
- $latest = $this->autoupgradePath.DIRECTORY_SEPARATOR.'latest';
- if (!file_exists($latest))
- if (!@mkdir($latest,0777))
- $this->_errors[] = Tools::displayError(sprintf($this->l('unable to create directory %s'),$latest));
-
- $this->latestRootDir = $latest.DIRECTORY_SEPARATOR.'prestashop';
- $this->adminDir = str_replace($this->prodRootDir,'',$this->adminDir);
- // @TODO future option
- // $this->testRootDir = $this->autoupgradePath.DIRECTORY_SEPARATOR.'test';
-
- /* optional skips */
- $this->dontBackupImages = Configuration::get('PS_AUTOUP_DONT_SAVE_IMAGES');
- $this->keepDefaultTheme = Configuration::get('PS_AUTOUP_KEEP_DEFAULT_THEME');
- $this->keepTrad = Configuration::get('PS_AUTOUP_KEEP_TRAD');
- $this->manualMode = Configuration::get('PS_AUTOUP_MANUAL_MODE');
- // We can add any file or directory in the exclude dir : theses files will be not removed or overwritten
- // @TODO cache should be ignored recursively, but we have to reconstruct it after upgrade
- // - compiled from smarty
- // - .svn
- $this->backupIgnoreAbsoluteFiles[] = "/tools/smarty_v2/compile";
- $this->backupIgnoreAbsoluteFiles[] = "/tools/smarty_v2/cache";
- $this->backupIgnoreAbsoluteFiles[] = "/tools/smarty/compile";
- $this->backupIgnoreAbsoluteFiles[] = "/tools/smarty/cache";
-
- $this->excludeFilesFromUpgrade[] = '.';
- $this->excludeFilesFromUpgrade[] = '..';
- $this->excludeFilesFromUpgrade[] = '.svn';
- $this->excludeFilesFromUpgrade[] = 'install';
- $this->excludeFilesFromUpgrade[] = 'settings.inc.php';
- $this->excludeFilesFromUpgrade[] = 'autoupgrade';
- $this->backupIgnoreFiles[] = '.';
- $this->backupIgnoreFiles[] = '..';
- $this->backupIgnoreFiles[] = '.svn';
- $this->backupIgnoreFiles[] = 'autoupgrade';
-
- if ($this->dontBackupImages)
- $this->backupIgnoreAbsoluteFiles[] = "/img";
-
-
- if ($this->keepDefaultTheme)
- $this->excludeAbsoluteFilesFromUpgrade[] = "/themes/prestashop";
-
- if ($this->keepTrad)
- $this->excludeFilesFromUpgrade[] = "translations";
- }
-
- /**
- * getFilePath return the path to the zipfile containing prestashop.
- *
- * @return void
- */
- private function getFilePath()
- {
- return $this->autoupgradePath.DIRECTORY_SEPARATOR.$this->destDownloadFilename;
- }
-
- public function postProcess()
- {
- $this->_setFields();
-
- if (!empty($_POST))
- $this->_postConfig($this->_fieldsAutoUpgrade);
- }
-
- public function ajaxProcessUpgradeComplete()
- {
- $this->nextDesc = $this->l('Upgrade process done. Congratulations ! You can now reactive your shop.');
- $this->next = '';
- }
-
- public function ajaxProcessUpgradeNow()
- {
- $this->nextDesc = $this->l('Starting upgrade ...');
- $this->next = 'desactiveShop';
- }
- public function ajaxProcessSvnExport()
- {
- if ($this->useSvn)
- {
- // first of all, delete the content of the latest root dir just in case
- if (is_dir($this->latestRootDir))
- Tools::deleteDirectory($this->latestRootDir, false);
-
- if (!file_exists($this->latestRootDir))
- {
- @mkdir($this->latestRootDir);
- }
-
- if (svn_export($this->autoupgradePath . DIRECTORY_SEPARATOR . $this->svnDir, $this->latestRootDir))
- {
-
- // export means svn means install-dev and admin-dev.
- // let's rename admin to the correct admin dir
- // and rename install-dev to install
- $adminDir = str_replace($this->prodRootDir, '', $this->adminDir);
- rename($this->latestRootDir.DIRECTORY_SEPARATOR.'install-dev', $this->latestRootDir.DIRECTORY_SEPARATOR.'install');
- rename($this->latestRootDir.DIRECTORY_SEPARATOR.'admin-dev', $this->latestRootDir.DIRECTORY_SEPARATOR.$adminDir);
-
- // Unsetting to force listing
- unset($this->nextParams['removeList']);
- $this->next = "removeSamples";
- $this->nextDesc = $this->l('Export svn complete. removing sample files...');
- return true;
- }
- else
- {
- $this->next = 'error';
- $this->nextDesc = $this->l('error when svn export ');
- }
- }
- }
-
- public function ajaxProcessUnzip(){
- // @TODO : not require_once like that.
- $filepath = $this->getFilePath();
- $destExtract = $this->autoupgradePath.DIRECTORY_SEPARATOR.'latest';
- if (file_exists($destExtract))
- Tools::deletedirectory($destExtract);
-
- if (Tools::ZipExtract($filepath,$destExtract))
- {
- $adminDir = str_replace($this->prodRootDir, '', $this->adminDir);
- rename($this->latestRootDir.DIRECTORY_SEPARATOR.'admin', $this->latestRootDir.DIRECTORY_SEPARATOR.$adminDir);
- // Unsetting to force listing
- unset($this->nextParams['removeList']);
- $this->next = "removeSamples";
- $this->nextDesc = $this->l('Extract complete. removing sample files...');
- return true;
- }
- else{
- $this->next = "error";
- $this->nextDesc = sprintf($this->l('unable to extract %1$s into %2$s ...'),$filepath,$destExtract);
- return true;
- }
- }
-
-
- /**
- * _listSampleFiles will make a recursive call to scandir() function
- * and list all file which match to the $fileext suffixe (this can be an extension or whole filename)
- *
- * @TODO maybe $regex instead of $fileext ?
- * @param string $dir directory to look in
- * @param string $fileext suffixe filename
- * @return void
- */
- private function _listSampleFiles($dir, $fileext = '.jpg'){
- $res = true;
- $dir = rtrim($dir,'/').DIRECTORY_SEPARATOR;
-
- $toDel = scandir($dir);
- // copied (and kind of) adapted from AdminImages.php
- foreach ($toDel AS $file)
- {
- if ($file!='.' AND $file != '..' AND $file != '.svn')
- {
-
- if (preg_match('#'.preg_quote($fileext,'#').'$#i',$file))
- {
- $this->sampleFileList[] = $dir.$file;
- }
- else if (is_dir($dir.$file))
- {
- $res &= $this->_listSampleFiles($dir.$file);
- }
- }
- }
- return $res;
- }
-
- public function _listBackupFiles($dir)
- {
- $allFiles = scandir($dir);
- foreach ($allFiles as $file)
- {
- $fullPath = $dir.DIRECTORY_SEPARATOR.$file;
-
- if (!$this->_skipFile($file, $fullPath,'backup'))
- {
- if (is_dir($fullPath))
- $this->_listBackupFiles($fullPath);
- else
- $this->backupFileList[] = $fullPath;
- }
- else
- $this->backupIgnoreFiles[] = $fullPath;
-
- }
- }
-
- public function _listFilesToUpgrade($dir)
- {
- $allFiles = scandir($dir);
- foreach ($allFiles as $file)
- {
- $fullPath = $dir.DIRECTORY_SEPARATOR.$file;
-
- if (!$this->_skipFile($file, $fullPath, "upgrade"))
- {
- if (is_dir($fullPath))
- {
- // if is_dir, we will create it :)e it :)
- $this->toUpgradeFileList[] = $fullPath;
- if (strpos($dir.DIRECTORY_SEPARATOR.$file, 'install') === false)
- {
- $this->_listFilesToUpgrade($fullPath);
- }
- }
- else
- $this->toUpgradeFileList[] = $fullPath;
- }
- }
-
- $this->nextParams['filesToUpgrade'] = $this->toUpgradeFileList;
- }
-
- public function ajaxProcessDesactiveShop()
- {
- $this->ShopActiveValue = Configuration::get('PS_SHOP_ENABLE');
- Configuration::updateValue('PS_SHOP_ENABLE',0);
- if ($this->useSvn)
- {
- $this->next = 'svnCheckout';
- $this->nextDesc = $this->l('switching to svn checkout (useSvn set to true)');
- }
- else
- {
- $this->next = 'download';
- $this->nextDesc = $this->l('Shop deactivated. Now downloading (this can takes some times )...');
- }
- }
-
- public function ajaxProcessUpgradeFiles(){
- // @TODO :
- $this->nextParams = $this->currentParams;
- if (!isset($this->nextParams['filesToUpgrade']))
- $this->_listFilesToUpgrade($this->latestRootDir);
-
- // later we could choose between _PS_ROOT_DIR_ or _PS_TEST_DIR_
- $this->destUpgradePath = $this->prodRootDir;
-
- // upgrade files one by one like for the backup
- // with a 1000 loop because it's funny
- // @TODO :
- // foreach files in latest, copy
- $this->next = 'upgradeFiles';
- if (!is_array($this->nextParams['filesToUpgrade']))
- {
- error($this->nextParams);
- $this->next = 'error';
- $this->nextDesc = $this->l('filesToUpgrade is not an array');
- $this->nextQuickInfo[] = $this->l('filesToUpgrade is not an array');
- return false;
- }
-
- // @TODO : does not upgrade files in modules, translations if they have not a correct md5 (or crc32, or whatever) from previous version
- for ($i=0;$i'.$this->l('Your current configuration indicate you want to upgrade your system from the unstable development branch, with no version number. If you upgrade, you will not be able to follow the official release process anymore').'.
-'.$this->l('upgrade complete. Please check your front-office (try to make an order, check theme)').'
") - .show("slow"); - $("#dbCreateResultCheck") - .hide("slow"); - - // difference with the original function - ret = {next:"upgradeComplete",nextParams:{typeResult:"json"},status:"ok"}; - - } - else - { - $("#dbResultCheck") - .addClass("fail") - .removeClass("ok") - .html(txtError[parseInt(ret.getAttribute("error"))]) - .show("slow"); - $("#dbCreateResultCheck") - .hide("slow"); - - // propose rollback if there is an error - if (confirm(txtError[parseInt(ret.getAttribute("error"))]+"\r\n\r\n'.$this->l('Do you want to rollback ?').'")) - ret = {next:"rollback",nextParams:{typeResult:"json"},status:"error"}; - } - - return ret -}; - -/** - * afterBackupDb display the button - * - */ -function afterBackupDb() -{ - $("#restoreDbContainer").html("restoreDb '.$this->l('click to restore database').'"); - prepareNextButton("#restoreDb",{}); -} - -function afterRestoreDb() -{ - $("#restoreDbContainer").html(""); -} - -function afterRestoreFiles() -{ - $("#restoreFilesContainer").html(""); -} - -function afterBackupFiles() -{ - $("#restoreFilesContainer").html("