[*] BO : #PSFV-94 - added AdminLogsController and changed initX() functions to return their result

This commit is contained in:
tDidierjean committed 2011-10-21 13:40:41 +00:00
1 parent b9cf3b3afb
commit 2dd023e92d
16 files changed
+105 -61

No files matched your search

@@ -0,0 +1,44 @@
{*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision$
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*}
{if $list}
<fieldset>
<legend>{l s='Severity levels'}</legend>
<p>{l s='Meaning of severity levels:'}</p>
<ol>
<li style="color: green;">{l s='Informative only'}</li>
<li style="color: orange;">{l s='Warning'}</li>
<li style="color: orange;">{l s='Error'}</li>
<li style="color: red;">{l s='Major issue (crash)'}</li>
</ol>
</fieldset>
{/if}
{$list}
<br />
<h2>{l s='Logs by e-mail'}</h2>
{$options}
+10 -12
View File
@@ -659,8 +659,8 @@ class AdminControllerCore extends Controller
*/ */
public function displayForm($firstCall = true) public function displayForm($firstCall = true)
{ {
$this->initForm();
$content = ''; $content = '';
$content .= $this->initForm();
$allow_employee_form_lang = Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') ? Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') : 0; $allow_employee_form_lang = Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') ? Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') : 0;
if ($allow_employee_form_lang && !$this->context->cookie->employee_form_lang) if ($allow_employee_form_lang && !$this->context->cookie->employee_form_lang)
@@ -781,7 +781,6 @@ class AdminControllerCore extends Controller
{ {
$this->context->smarty->assign('display_header',$this->display_header); $this->context->smarty->assign('display_header',$this->display_header);
$this->context->smarty->assign('display_footer',$this->display_footer); $this->context->smarty->assign('display_footer',$this->display_footer);
$this->context->smarty->assign('content', $this->content);
$this->context->smarty->assign('meta_title', $this->meta_title); $this->context->smarty->assign('meta_title', $this->meta_title);
// Template override // Template override
@@ -1030,17 +1029,18 @@ class AdminControllerCore extends Controller
{ {
if (!($this->object = $this->loadObject(true))) if (!($this->object = $this->loadObject(true)))
return; return;
$this->initForm(); $content .= $this->initForm();
} }
else if ($this->display != 'view') else if ($this->display != 'view')
{ {
$this->initList(); $content .= $this->initList();
$this->initOptions(); $content .= $this->initOptions();
} }
$this->context->smarty->assign(array( $this->context->smarty->assign(array(
'table' => $this->table, 'table' => $this->table,
'current' => self::$currentIndex, 'current' => self::$currentIndex,
'token' => $this->token, 'token' => $this->token,
'content', $this->content
)); ));
} }
@@ -1073,7 +1073,8 @@ class AdminControllerCore extends Controller
return false; return false;
$this->getList($this->context->language->id); $this->getList($this->context->language->id);
if (!($this->_list && is_array($this->_list))) // Empty list is ok
if (!is_array($this->_list))
return false; return false;
$helper = new HelperList(); $helper = new HelperList();
@@ -1110,7 +1111,7 @@ class AdminControllerCore extends Controller
// For each action, try to add the corresponding skip elements list // For each action, try to add the corresponding skip elements list
$helper->list_skip_actions = $this->list_skip_actions; $helper->list_skip_actions = $this->list_skip_actions;
$this->content .= $helper->generateList($this->_list, $this->fieldsDisplay); return $helper->generateList($this->_list, $this->fieldsDisplay);
} }
/** /**
@@ -1142,11 +1143,8 @@ class AdminControllerCore extends Controller
$this->context->smarty->assign('back', Tools::safeOutput(Tools::getValue(self::$currentIndex.'&token='.$this->token))); $this->context->smarty->assign('back', Tools::safeOutput(Tools::getValue(self::$currentIndex.'&token='.$this->token)));
} }
$this->content .= $helper->generateForm($this->fields_form); return $helper->generateForm($this->fields_form);
} }
// TODO delete when all forms use the helper
// else
// $this->content .= $this->displayForm();
} }
/** /**
@@ -1164,7 +1162,7 @@ class AdminControllerCore extends Controller
$helper->token = $this->token; $helper->token = $this->token;
$helper->table = $this->table; $helper->table = $this->table;
$helper->currentIndex = self::$currentIndex; $helper->currentIndex = self::$currentIndex;
$this->content .= $helper->generateOptions($this->options); return $helper->generateOptions($this->options);
} }
} }
@@ -72,7 +72,7 @@ class AdminAddressesControllerCore extends AdminController
foreach ($countries AS $country) foreach ($countries AS $country)
$this->countriesArray[$country['id_country']] = $country['name']; $this->countriesArray[$country['id_country']] = $country['name'];
parent::initList(); return parent::initList();
} }
public function initForm() public function initForm()
@@ -272,7 +272,7 @@ class AdminAddressesControllerCore extends AdminController
// merge address format with the rest of the form // merge address format with the rest of the form
array_splice($this->fields_form['input'], 3, 0, $temp_fields); array_splice($this->fields_form['input'], 3, 0, $temp_fields);
parent::initForm(); return parent::initForm();
} }
public function postProcess() public function postProcess()
+1 -1
View File
@@ -89,7 +89,7 @@ class AdminAliasesControllerCore extends AdminController
$this->fields_value = array('alias' => $this->object->getAliases()); $this->fields_value = array('alias' => $this->object->getAliases());
parent::initForm(); return parent::initForm();
} }
public function postProcess() public function postProcess()
@@ -136,7 +136,7 @@ class AdminCarriersControllerCore extends AdminController
$this->_join = 'LEFT JOIN `'._DB_PREFIX_.'carrier_lang` b ON a.id_carrier = b.id_carrier'; $this->_join = 'LEFT JOIN `'._DB_PREFIX_.'carrier_lang` b ON a.id_carrier = b.id_carrier';
$this->_where = 'AND b.id_lang = '.$this->context->language->id; $this->_where = 'AND b.id_lang = '.$this->context->language->id;
parent::initList(); return parent::initList();
} }
public function initForm() public function initForm()
@@ -357,7 +357,7 @@ class AdminCarriersControllerCore extends AdminController
'class' => 'button' 'class' => 'button'
); );
parent::initForm(); return parent::initForm();
} }
public function postProcess() public function postProcess()
@@ -111,7 +111,7 @@ class AdminContactsControllerCore extends AdminController
) )
); );
parent::initForm(); return parent::initForm();
} }
} }
@@ -116,7 +116,7 @@ class AdminCountriesControllerCore extends AdminController
$this->_select = 'z.`name` AS zone'; $this->_select = 'z.`name` AS zone';
$this->_join = 'LEFT JOIN `'._DB_PREFIX_.'zone` z ON (z.`id_zone` = a.`id_zone`)'; $this->_join = 'LEFT JOIN `'._DB_PREFIX_.'zone` z ON (z.`id_zone` = a.`id_zone`)';
parent::initList(); return parent::initList();
} }
public function initForm() public function initForm()
@@ -353,7 +353,7 @@ class AdminCountriesControllerCore extends AdminController
'class' => 'button' 'class' => 'button'
); );
parent::initForm(); return parent::initForm();
} }
public function postProcess() public function postProcess()
@@ -102,7 +102,7 @@ class AdminEmployeesControllerCore extends AdminController
$this->_join = 'LEFT JOIN `'._DB_PREFIX_.'profile` p ON a.`id_profile` = p.`id_profile` $this->_join = 'LEFT JOIN `'._DB_PREFIX_.'profile` p ON a.`id_profile` = p.`id_profile`
LEFT JOIN `'._DB_PREFIX_.'profile_lang` pl ON (pl.`id_profile` = p.`id_profile` AND pl.`id_lang` = '.(int)$this->context->language->id.')'; LEFT JOIN `'._DB_PREFIX_.'profile_lang` pl ON (pl.`id_profile` = p.`id_profile` AND pl.`id_lang` = '.(int)$this->context->language->id.')';
parent::initList(); return parent::initList();
} }
public function initForm() public function initForm()
@@ -293,7 +293,7 @@ class AdminEmployeesControllerCore extends AdminController
$this->fields_value['shop'][$row['id_shop']][] = $row[$this->identifier]; $this->fields_value['shop'][$row['id_shop']][] = $row[$this->identifier];
} }
parent::initForm(); return parent::initForm();
} }
protected function _childValidation() protected function _childValidation()
+1 -1
View File
@@ -167,7 +167,7 @@ class AdminGendersController extends AdminController
'image' => $obj->getImage() 'image' => $obj->getImage()
); );
parent::initForm(); return parent::initForm();
} }
public function displayGenderType($value, $tr) public function displayGenderType($value, $tr)
@@ -172,7 +172,7 @@ class AdminGroupShopControllerCore extends AdminController
'defaultGroup' => Shop::getInstance(Configuration::get('PS_SHOP_DEFAULT'))->getGroupID() 'defaultGroup' => Shop::getInstance(Configuration::get('PS_SHOP_DEFAULT'))->getGroupID()
)); ));
parent::initForm(); return parent::initForm();
$import_data = array( $import_data = array(
'attribute_group' => $this->l('Attribute groups'), 'attribute_group' => $this->l('Attribute groups'),
@@ -25,30 +25,29 @@
* International Registered Trademark & Property of PrestaShop SA * International Registered Trademark & Property of PrestaShop SA
*/ */
include_once(_PS_ADMIN_DIR_.'/../classes/AdminTab.php'); class AdminLogsControllerCore extends AdminController
class AdminLogs extends AdminTab
{ {
public function __construct() public function __construct()
{ {
$this->table = 'log'; $this->table = 'log';
$this->className = 'Logger'; $this->className = 'Logger';
$this->lang = false; $this->lang = false;
$this->edit = false;
$this->delete = true;
$this->noLink = true; $this->noLink = true;
$this->view = false;
$this->addRowAction('delete');
$this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?')));
$this->fieldsDisplay = array( $this->fieldsDisplay = array(
'id_log' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25), 'id_log' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25),
'severity' => array('title' => $this->l('Severity (1-4)'), 'align' => 'center', 'width' => 50), 'severity' => array('title' => $this->l('Severity (1-4)'), 'align' => 'center', 'width' => 50),
'message' => array('title' => $this->l('Message'), 'width' => 377), 'message' => array('title' => $this->l('Message'), 'width' => 377),
'object_type' => array('title' => $this->l('Object type'), 'width' => 75), 'object_type' => array('title' => $this->l('Object type'), 'width' => 75),
'object_id' => array('title' => $this->l('Object ID'), 'width' => 50), 'object_id' => array('title' => $this->l('Object ID'), 'width' => 50),
'error_code' => array('title' => $this->l('Error code'), 'width' => 75, 'prefix' => '0x'), 'error_code' => array('title' => $this->l('Error code'), 'width' => 75, 'prefix' => '0x'),
'date_add' => array('title' => $this->l('Date'), 'width' => 35, 'align' => 'right', 'type' => 'datetime')); 'date_add' => array('title' => $this->l('Date'), 'width' => 35, 'align' => 'right', 'type' => 'datetime')
);
$this->optionsList = array( $this->options = array(
'general' => array( 'general' => array(
'title' => $this->l('Logs by e-mail'), 'title' => $this->l('Logs by e-mail'),
'fields' => array( 'fields' => array(
@@ -60,28 +59,27 @@ class AdminLogs extends AdminTab
'size' => 5 'size' => 5
), ),
), ),
'submit' => array()
), ),
); );
parent::__construct(); parent::__construct();
} }
public function displayListHeader($token = NULL) /**
* Assign smarty variables for all default views, list and form, then call other init functions
*/
public function initContent()
{ {
echo ' $this->context->smarty->assign(array(
<fieldset> 'table' => $this->table,
<legend>'.$this->l('Severity levels').'</legend> 'current' => self::$currentIndex,
<p>'.$this->l('Here\'s the meaning of severity levels:').'</p> 'token' => $this->token,
<ol> 'list' => $this->initList(),
<li style="color: green;">'.$this->l('Informative only').'</li> 'options' => $this->initOptions()
<li style="color: orange;">'.$this->l('Warning').'</li> ));
<li style="color: orange;">'.$this->l('Error').'</li>
<li style="color: red;">'.$this->l('Major issue (crash)').'</li>
</ol>
</fieldset>';
parent::displayListHeader();
} }
} }
?> ?>
@@ -1527,7 +1527,7 @@ if (false)
$languages = Language::getLanguages(false); $languages = Language::getLanguages(false);
$defaultLanguage = (int)(Configuration::get('PS_LANG_DEFAULT')); $defaultLanguage = (int)(Configuration::get('PS_LANG_DEFAULT'));
$product = new Product((int)(Tools::getValue('id_product'))); $product = new Product((int)(Tools::getValue('id_product')));
$this->initForm(); $content .= $this->initForm();
return $this->{'initForm'.$this->action}($product, $languages, $defaultLanguage); return $this->{'initForm'.$this->action}($product, $languages, $defaultLanguage);
} }
} }
@@ -1707,7 +1707,6 @@ if (false)
public function initForm() public function initForm()
{ {
parent::initForm();
$this->addJqueryUI('ui.datepicker'); $this->addJqueryUI('ui.datepicker');
$this->context->smarty->assign('pos_select', (($tab = Tools::getValue('tabs')) ? $tab : '0')); $this->context->smarty->assign('pos_select', (($tab = Tools::getValue('tabs')) ? $tab : '0'));
$this->context->smarty->assign('token',$this->token); $this->context->smarty->assign('token',$this->token);
@@ -1719,6 +1718,7 @@ if (false)
if (!($obj = $this->loadObject(true))) if (!($obj = $this->loadObject(true)))
throw new Exception('object not loaded'); throw new Exception('object not loaded');
$this->_displayDraftWarning($obj->active); $this->_displayDraftWarning($obj->active);
return parent::initForm();
} }
public function displayForm($isMainTab = true) public function displayForm($isMainTab = true)
@@ -1754,7 +1754,7 @@ if (false)
$action = $this->action; $action = $this->action;
if (empty($action) || !method_exists($this,'initForm'.$action)) if (empty($action) || !method_exists($this,'initForm'.$action))
$action = 'informations'; $action = 'informations';
$this->initForm(); $content .= $this->initForm();
$this->{'initForm'.$action}($obj, null); $this->{'initForm'.$action}($obj, null);
/* Tabs */ /* Tabs */
/* /*
+2 -2
View File
@@ -63,7 +63,7 @@ class AdminShopUrlControllerCore extends AdminController
$this->_select = 's.name AS shop_name, CONCAT(a.physical_uri, a.virtual_uri) AS uri'; $this->_select = 's.name AS shop_name, CONCAT(a.physical_uri, a.virtual_uri) AS uri';
$this->_join = 'LEFT JOIN `'._DB_PREFIX_.'shop` s ON (s.id_shop = a.id_shop)'; $this->_join = 'LEFT JOIN `'._DB_PREFIX_.'shop` s ON (s.id_shop = a.id_shop)';
parent::initList(); return parent::initList();
} }
public function initForm() public function initForm()
@@ -194,7 +194,7 @@ class AdminShopUrlControllerCore extends AdminController
'physical_uri' => Validate::isLoadedObject($obj) ? $this->getFieldValue($obj, 'physical_uri') : $current_shop->physical_uri 'physical_uri' => Validate::isLoadedObject($obj) ? $this->getFieldValue($obj, 'physical_uri') : $current_shop->physical_uri
); );
parent::initForm(); return parent::initForm();
} }
public function postProcess() public function postProcess()
+2 -2
View File
@@ -59,7 +59,7 @@ class AdminStatesControllerCore extends AdminController
$this->_select = 'z.`name` AS zone'; $this->_select = 'z.`name` AS zone';
$this->_join = 'LEFT JOIN `'._DB_PREFIX_.'zone` z ON (z.`id_zone` = a.`id_zone`)'; $this->_join = 'LEFT JOIN `'._DB_PREFIX_.'zone` z ON (z.`id_zone` = a.`id_zone`)';
parent::initList(); return parent::initList();
} }
public function initForm() public function initForm()
@@ -143,7 +143,7 @@ class AdminStatesControllerCore extends AdminController
) )
); );
parent::initForm(); return parent::initForm();
} }
public function postProcess() public function postProcess()
+2 -2
View File
@@ -126,7 +126,7 @@ class AdminStoresControllerCore extends AdminController
LEFT JOIN `'._DB_PREFIX_.'state` st LEFT JOIN `'._DB_PREFIX_.'state` st
ON (st.`id_state` = a.`id_state`)'; ON (st.`id_state` = a.`id_state`)';
parent::initList(); return parent::initList();
} }
public function initForm() public function initForm()
@@ -291,7 +291,7 @@ class AdminStoresControllerCore extends AdminController
'hours' => isset($hours_unserialized) ? $hours_unserialized : false 'hours' => isset($hours_unserialized) ? $hours_unserialized : false
); );
parent::initForm(); return parent::initForm();
} }
public function postProcess() public function postProcess()
@@ -79,6 +79,8 @@ class AdminWarehousesControllerCore extends AdminController
$this->_join = 'LEFT JOIN `'._DB_PREFIX_.'employee` e ON (e.id_employee = a.id_employee) $this->_join = 'LEFT JOIN `'._DB_PREFIX_.'employee` e ON (e.id_employee = a.id_employee)
LEFT JOIN `'._DB_PREFIX_.'address` ad ON (ad.id_address = a.id_address) LEFT JOIN `'._DB_PREFIX_.'address` ad ON (ad.id_address = a.id_address)
LEFT JOIN `'._DB_PREFIX_.'country` c ON (c.id_country = ad.id_country)'; LEFT JOIN `'._DB_PREFIX_.'country` c ON (c.id_country = ad.id_country)';
return parent::initList();
} }
public function initForm() public function initForm()
@@ -262,6 +264,8 @@ class AdminWarehousesControllerCore extends AdminController
'class' => 'button' 'class' => 'button'
) )
); );
return parent::initForm();
} }
public function postProcess() public function postProcess()