Merge branch 'master' of git://github.com/thelia/thelia

* 'master' of git://github.com/thelia/thelia:
  Check if store_country has a value
  Fixed double '/' in generated assets URLs
  Add validation for Store configuration
  Use Store contact information
  Call the wrong AdminResources in saveAction
  Action buttons smaller
  Replace company_name and contact_email by store_name & store_email
  Add a new admin page to manage the basic store configurations
  Add routing for Store Configuration
  Add argument Title on Content Loop & Folder Loop
This commit is contained in:
gmorel
2013-11-25 22:43:04 +01:00
20 changed files with 483 additions and 35 deletions

View File

@@ -0,0 +1,105 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
namespace Thelia\Controller\Admin;
use Thelia\Core\Security\Resource\AdminResources;
use Thelia\Core\Security\AccessManager;
use Thelia\Form\ConfigStoreForm;
use Thelia\Log\Tlog;
use Thelia\Model\ConfigQuery;
/**
* Class ConfigStoreController
* @package Thelia\Controller\Admin
* @author Christophe Laffont <claffont@openstudio.fr>
*/
class ConfigStoreController extends BaseAdminController
{
protected function renderTemplate()
{
return $this->render('config-store');
}
public function defaultAction()
{
if (null !== $response = $this->checkAuth(AdminResources::STORE, array(), AccessManager::VIEW)) return $response;
// Hydrate the store configuration form
$configStoreForm = new ConfigStoreForm($this->getRequest(), 'form', array(
'store_name' => ConfigQuery::read("store_name"),
'store_email' => ConfigQuery::read("store_email"),
'store_business_id' => ConfigQuery::read("store_business_id"),
'store_phone' => ConfigQuery::read("store_phone"),
'store_fax' => ConfigQuery::read("store_fax"),
'store_address1' => ConfigQuery::read("store_address1"),
'store_address2' => ConfigQuery::read("store_address2"),
'store_address3' => ConfigQuery::read("store_address3"),
'store_zipcode' => ConfigQuery::read("store_zipcode"),
'store_city' => ConfigQuery::read("store_city"),
'store_country' => ConfigQuery::read("store_country")
));
$this->getParserContext()->addForm($configStoreForm);
return $this->renderTemplate();
}
public function saveAction()
{
if (null !== $response = $this->checkAuth(AdminResources::STORE, array(), AccessManager::UPDATE)) return $response;
$error_msg = false;
$configStoreForm = new ConfigStoreForm($this->getRequest());
try {
$form = $this->validateForm($configStoreForm);
$data = $form->getData();
// Update store
foreach($data as $name => $value) {
if(! in_array($name , array('success_url', 'error_message')))
ConfigQuery::write($name, $value, false);
}
$this->adminLogAppend(AdminResources::STORE, AccessManager::UPDATE, "Store configuration changed");
$this->redirectToRoute('admin.configuration.store.default');
} catch (\Exception $ex) {
$error_msg = $ex->getMessage();
}
$this->setupFormErrorContext(
$this->getTranslator()->trans("Store configuration failed."),
$error_msg,
$configStoreForm,
$ex
);
return $this->renderTemplate();
}
}

View File

@@ -121,7 +121,7 @@ class SystemLogController extends BaseAdminController
public function saveAction()
{
if (null !== $response = $this->checkAuth(AdminResources::LANGUAGE, array(), AccessManager::UPDATE)) return $response;
if (null !== $response = $this->checkAuth(AdminResources::SYSTEM_LOG, array(), AccessManager::UPDATE)) return $response;
$error_msg = false;