PageRenderTime 41ms CodeModel.GetById 12ms RepoModel.GetById 1ms app.codeStats 0ms

/prestashop/_/controllers/admin/AdminPreferencesController.php

https://gitlab.com/A.Julien/sendstockbymail-module-prestashop
PHP | 246 lines | 202 code | 10 blank | 34 comment | 4 complexity | df655df094e6f3798d619c894393d728 MD5 | raw file
  1. <?php
  2. /*
  3. * 2007-2016 PrestaShop
  4. *
  5. * NOTICE OF LICENSE
  6. *
  7. * This source file is subject to the Open Software License (OSL 3.0)
  8. * that is bundled with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://opensource.org/licenses/osl-3.0.php
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@prestashop.com so we can send you a copy immediately.
  14. *
  15. * DISCLAIMER
  16. *
  17. * Do not edit or add to this file if you wish to upgrade PrestaShop to newer
  18. * versions in the future. If you wish to customize PrestaShop for your
  19. * needs please refer to http://www.prestashop.com for more information.
  20. *
  21. * @author PrestaShop SA <contact@prestashop.com>
  22. * @copyright 2007-2016 PrestaShop SA
  23. * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
  24. * International Registered Trademark & Property of PrestaShop SA
  25. */
  26. /**
  27. * @property Configuration $object
  28. */
  29. class AdminPreferencesControllerCore extends AdminController
  30. {
  31. public function __construct()
  32. {
  33. $this->bootstrap = true;
  34. $this->context = Context::getContext();
  35. $this->className = 'Configuration';
  36. $this->table = 'configuration';
  37. // Prevent classes which extend AdminPreferences to load useless data
  38. if (get_class($this) == 'AdminPreferencesController') {
  39. $round_mode = array(
  40. array(
  41. 'value' => PS_ROUND_HALF_UP,
  42. 'name' => $this->l('Round up away from zero, when it is half way there (recommended)')
  43. ),
  44. array(
  45. 'value' => PS_ROUND_HALF_DOWN,
  46. 'name' => $this->l('Round down towards zero, when it is half way there')
  47. ),
  48. array(
  49. 'value' => PS_ROUND_HALF_EVEN,
  50. 'name' => $this->l('Round towards the next even value')
  51. ),
  52. array(
  53. 'value' => PS_ROUND_HALF_ODD,
  54. 'name' => $this->l('Round towards the next odd value')
  55. ),
  56. array(
  57. 'value' => PS_ROUND_UP,
  58. 'name' => $this->l('Round up to the nearest value')
  59. ),
  60. array(
  61. 'value' => PS_ROUND_DOWN,
  62. 'name' => $this->l('Round down to the nearest value')
  63. ),
  64. );
  65. $activities1 = array(
  66. 0 => $this->l('-- Please choose your main activity --'),
  67. 2 => $this->l('Animals and Pets'),
  68. 3 => $this->l('Art and Culture'),
  69. 4 => $this->l('Babies'),
  70. 5 => $this->l('Beauty and Personal Care'),
  71. 6 => $this->l('Cars'),
  72. 7 => $this->l('Computer Hardware and Software'),
  73. 8 => $this->l('Download'),
  74. 9 => $this->l('Fashion and accessories'),
  75. 10 => $this->l('Flowers, Gifts and Crafts'),
  76. 11 => $this->l('Food and beverage'),
  77. 12 => $this->l('HiFi, Photo and Video'),
  78. 13 => $this->l('Home and Garden'),
  79. 14 => $this->l('Home Appliances'),
  80. 15 => $this->l('Jewelry'),
  81. 1 => $this->l('Lingerie and Adult'),
  82. 16 => $this->l('Mobile and Telecom'),
  83. 17 => $this->l('Services'),
  84. 18 => $this->l('Shoes and accessories'),
  85. 19 => $this->l('Sport and Entertainment'),
  86. 20 => $this->l('Travel')
  87. );
  88. $activities2 = array();
  89. foreach ($activities1 as $value => $name) {
  90. $activities2[] = array('value' => $value, 'name' => $name);
  91. }
  92. $fields = array(
  93. 'PS_SSL_ENABLED' => array(
  94. 'title' => $this->l('Enable SSL'),
  95. 'desc' => $this->l('If you own an SSL certificate for your shop\'s domain name, you can activate SSL encryption (https://) for customer account identification and order processing.'),
  96. 'hint' => $this->l('If you want to enable SSL on all the pages of your shop, activate the "Enable on all the pages" option below.'),
  97. 'validation' => 'isBool',
  98. 'cast' => 'intval',
  99. 'type' => 'bool',
  100. 'default' => '0'
  101. ),
  102. );
  103. $fields['PS_SSL_ENABLED_EVERYWHERE'] = array(
  104. 'title' => $this->l('Enable SSL on all pages'),
  105. 'desc' => $this->l('When enabled, all the pages of your shop will be SSL-secured.'),
  106. 'validation' => 'isBool',
  107. 'cast' => 'intval',
  108. 'type' => 'bool',
  109. 'default' => '0',
  110. 'disabled' => (Tools::getValue('PS_SSL_ENABLED', Configuration::get('PS_SSL_ENABLED'))) ? false : true
  111. );
  112. $fields = array_merge($fields, array(
  113. 'PS_TOKEN_ENABLE' => array(
  114. 'title' => $this->l('Increase front office security'),
  115. 'desc' => $this->l('Enable or disable token in the Front Office to improve PrestaShop\'s security.'),
  116. 'validation' => 'isBool',
  117. 'cast' => 'intval',
  118. 'type' => 'bool',
  119. 'default' => '0',
  120. 'visibility' => Shop::CONTEXT_ALL
  121. ),
  122. 'PS_ALLOW_HTML_IFRAME' => array(
  123. 'title' => $this->l('Allow iframes on HTML fields'),
  124. 'desc' => $this->l('Allow iframes on text fields like product description. We recommend that you leave this option disabled.'),
  125. 'validation' => 'isBool',
  126. 'cast' => 'intval',
  127. 'type' => 'bool',
  128. 'default' => '0'
  129. ),
  130. 'PS_USE_HTMLPURIFIER' => array(
  131. 'title' => $this->l('Use HTMLPurifier Library'),
  132. 'desc' => $this->l('Clean the HTML content on text fields. We recommend that you leave this option enabled.'),
  133. 'validation' => 'isBool',
  134. 'cast' => 'intval',
  135. 'type' => 'bool',
  136. 'default' => '0'
  137. ),
  138. 'PS_PRICE_ROUND_MODE' => array(
  139. 'title' => $this->l('Round mode'),
  140. 'desc' => $this->l('You can choose among 6 different ways of rounding prices. "Round up away from zero ..." is the recommended behavior.'),
  141. 'validation' => 'isInt',
  142. 'cast' => 'intval',
  143. 'type' => 'select',
  144. 'list' => $round_mode,
  145. 'identifier' => 'value'
  146. ),
  147. 'PS_ROUND_TYPE' => array(
  148. 'title' => $this->l('Round type'),
  149. 'desc' => $this->l('You can choose when to round prices: either on each item, each line or the total (of an invoice, for example).'),
  150. 'cast' => 'intval',
  151. 'type' => 'select',
  152. 'list' => array(
  153. array(
  154. 'name' => $this->l('Round on each item'),
  155. 'id' => Order::ROUND_ITEM
  156. ),
  157. array(
  158. 'name' => $this->l('Round on each line'),
  159. 'id' => Order::ROUND_LINE
  160. ),
  161. array(
  162. 'name' => $this->l('Round on the total'),
  163. 'id' => Order::ROUND_TOTAL
  164. ),
  165. ),
  166. 'identifier' => 'id'
  167. ),
  168. 'PS_PRICE_DISPLAY_PRECISION' => array(
  169. 'title' => $this->l('Number of decimals'),
  170. 'desc' => $this->l('Choose how many decimals you want to display'),
  171. 'validation' => 'isUnsignedInt',
  172. 'cast' => 'intval',
  173. 'type' => 'text',
  174. 'class' => 'fixed-width-xxl'
  175. ),
  176. 'PS_DISPLAY_SUPPLIERS' => array(
  177. 'title' => $this->l('Display suppliers and manufacturers'),
  178. 'desc' => $this->l('Enable suppliers and manufacturers pages on your front office even when their respective modules are disabled.'),
  179. 'validation' => 'isBool',
  180. 'cast' => 'intval',
  181. 'type' => 'bool'
  182. ),
  183. 'PS_DISPLAY_BEST_SELLERS' => array(
  184. 'title' => $this->l('Display best sellers'),
  185. 'desc' => $this->l('Enable best sellers page on your front office even when its respective module is disabled.'),
  186. 'validation' => 'isBool',
  187. 'cast' => 'intval',
  188. 'type' => 'bool'
  189. ),
  190. 'PS_MULTISHOP_FEATURE_ACTIVE' => array(
  191. 'title' => $this->l('Enable Multistore'),
  192. 'desc' => $this->l('The multistore feature allows you to manage several e-shops with one Back Office. If this feature is enabled, a "Multistore" page will be available in the "Advanced Parameters" menu.'),
  193. 'validation' => 'isBool',
  194. 'cast' => 'intval',
  195. 'type' => 'bool',
  196. 'visibility' => Shop::CONTEXT_ALL
  197. ),
  198. 'PS_SHOP_ACTIVITY' => array(
  199. 'title' => $this->l('Main Shop Activity'),
  200. 'validation' => 'isInt',
  201. 'cast' => 'intval',
  202. 'type' => 'select',
  203. 'list' => $activities2,
  204. 'identifier' => 'value'
  205. ),
  206. ));
  207. // No HTTPS activation if you haven't already.
  208. if (!Tools::usingSecureMode() && !Configuration::get('PS_SSL_ENABLED')) {
  209. $fields['PS_SSL_ENABLED']['type'] = 'disabled';
  210. $fields['PS_SSL_ENABLED']['disabled'] = '<a class="btn btn-link" href="https://'.Tools::getShopDomainSsl().Tools::safeOutput($_SERVER['REQUEST_URI']).'">'.
  211. $this->l('Please click here to check if your shop supports HTTPS.').'</a>';
  212. }
  213. $this->fields_options = array(
  214. 'general' => array(
  215. 'title' => $this->l('General'),
  216. 'icon' => 'icon-cogs',
  217. 'fields' => $fields,
  218. 'submit' => array('title' => $this->l('Save')),
  219. ),
  220. );
  221. }
  222. parent::__construct();
  223. }
  224. /**
  225. * Enable / disable multishop menu if multishop feature is activated
  226. *
  227. * @param string $value
  228. */
  229. public function updateOptionPsMultishopFeatureActive($value)
  230. {
  231. Configuration::updateValue('PS_MULTISHOP_FEATURE_ACTIVE', $value);
  232. $tab = Tab::getInstanceFromClassName('AdminShopGroup');
  233. $tab->active = (bool)Configuration::get('PS_MULTISHOP_FEATURE_ACTIVE');
  234. $tab->update();
  235. }
  236. }