PageRenderTime 53ms CodeModel.GetById 26ms RepoModel.GetById 0ms app.codeStats 0ms

/app/code/Ecart/Log/sql/0.1.1.php

https://code.google.com/p/ecartcommerce/
PHP | 125 lines | 80 code | 19 blank | 26 comment | 0 complexity | 15863c3200fcb38de2138fca8d6bf41f MD5 | raw file
Possible License(s): GPL-3.0, LGPL-2.1
  1. <?php
  2. /**
  3. * Ecart
  4. *
  5. * This file is part of Ecart.
  6. *
  7. * Ecart is free software: you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation, either version 3 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * Ecart is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with Ecart. If not, see <http://www.gnu.org/licenses/>.
  19. *
  20. * @category Ecart
  21. * @package Ecart_Account
  22. * @copyright Copyright 2008-2009 E-Cart LLC
  23. * @license GNU Public License V3.0
  24. */
  25. class Ecart_Log_Upgrade_0_1_1 extends Ecart_Core_Model_Migration_Abstract
  26. {
  27. protected $_version = '0.1.1';
  28. protected $_info = 'install';
  29. public function up()
  30. {
  31. $installer = Ecart::single('install/installer');
  32. $installer->run("
  33. -- DROP TABLE IF EXISTS `{$installer->getTable('log_url')}`;
  34. CREATE TABLE IF NOT EXISTS `{$installer->getTable('log_url')}` (
  35. `url_id` int(11) NOT NULL,
  36. `visitor_id` int(11) NOT NULL,
  37. `visit_at` datetime default NULL,
  38. `site_id` smallint(9) NOT NULL,
  39. PRIMARY KEY (`url_id`,`visitor_id`)
  40. ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
  41. -- DROP TABLE IF EXISTS `{$installer->getTable('log_url_info')}`;
  42. CREATE TABLE IF NOT EXISTS `{$installer->getTable('log_url_info')}` (
  43. `id` mediumint(7) NOT NULL auto_increment,
  44. `url` varchar(255) default NULL,
  45. `refer` varchar(255) default NULL,
  46. PRIMARY KEY (`id`)
  47. ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;
  48. -- DROP TABLE IF EXISTS `{$installer->getTable('log_visitor')}`;
  49. CREATE TABLE IF NOT EXISTS `{$installer->getTable('log_visitor')}` (
  50. `id` mediumint(7) unsigned NOT NULL auto_increment,
  51. `session_id` char(32) default NULL,
  52. `customer_id` int(11) default NULL,
  53. `last_url_id` int(11) default NULL,
  54. `last_visit_at` datetime default NULL,
  55. `site_id` smallint(9) NOT NULL,
  56. PRIMARY KEY (`id`),
  57. UNIQUE KEY `UNQ_LOG_VISITOR` (`session_id`,`customer_id`)
  58. ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;
  59. -- DROP TABLE IF EXISTS `{$installer->getTable('log_visitor_info')}`;
  60. CREATE TABLE IF NOT EXISTS `{$installer->getTable('log_visitor_info')}` (
  61. `visitor_id` int(11) NOT NULL,
  62. `http_refer` varchar(255) default NULL,
  63. `user_agent` varchar(255) default NULL,
  64. `http_accept_charset` varchar(128) default NULL,
  65. `http_accept_language` varchar(128) default NULL,
  66. `server_addr` varchar(128) default NULL,
  67. `remote_addr` varchar(128) default NULL,
  68. PRIMARY KEY (`visitor_id`),
  69. KEY `fk_log_visitor_info_log_visitor` (`visitor_id`)
  70. ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
  71. ");
  72. Ecart::single('core/config_field')
  73. ->add('log', 'Log', null, null, array('translation_module' => 'Ecart_Log'))
  74. ->add('log/main/enabled', 'Log/General/Enabled', 1, 'bool')
  75. ->add('log/main/php', 'Php log', '/var/logs/php.log', 'string', 'Path relative to ECART_ROOT')
  76. ->add('log/main/payment', 'Payment log', '/var/logs/payment.log', 'string', 'Path relative to ECART_ROOT')
  77. ->add('log/main/shipping', 'Shipping log', '/var/logs/shipping.log', 'string', 'Path relative to ECART_ROOT');
  78. Ecart::single('admin/menu')
  79. ->add('Catalog', null, 20, 'Ecart_Catalog')
  80. ->add('Catalog->Reports', null, 60, 'Ecart_Admin')
  81. ->add('Catalog->Reports->Pageviews', 'log', 20, 'Ecart_Admin');
  82. Ecart::single('admin/acl_resource')
  83. ->add('admin/log', 'Log Pageviws')
  84. ->add("admin/log/index")
  85. ->add("admin/log/list");
  86. Ecart::single('core/page')
  87. ->add('account/*/*');
  88. }
  89. public function down()
  90. {
  91. $installer = Ecart::single('install/installer');
  92. $installer->run("
  93. DROP TABLE IF EXISTS `{$installer->getTable('log_url')}`;
  94. DROP TABLE IF EXISTS `{$installer->getTable('log_url_info')}`;
  95. DROP TABLE IF EXISTS `{$installer->getTable('log_visitor')}`;
  96. DROP TABLE IF EXISTS `{$installer->getTable('log_visitor_info')}`;
  97. ");
  98. Ecart::single('core/config_field')->remove('log/main/enabled');
  99. Ecart::single('core/config_value')->remove('log/main/enabled');
  100. Ecart::single('admin/menu')->remove('Catalog->Reports->Pageviews');
  101. Ecart::single('admin/acl_resource')->remove('admin/log');
  102. //Ecart::single('core/template_box')
  103. // ->remove('Ecart_Log_Visitor')
  104. // ->remove('Ecart_Log_Customer');
  105. }
  106. }