-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathprcustomeropinion.php
More file actions
62 lines (46 loc) · 1.44 KB
/
prcustomeropinion.php
File metadata and controls
62 lines (46 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
require_once _PS_MODULE_DIR_ . 'prcustomeropinion/models/Opinion.php';
/**
*
* @author Alexandre Segura <mex.zktk@gmail.com>
*/
class PrCustomerOpinion extends Module {
public function __construct() {
$this->name = 'prcustomeropinion';
$this->tab = 'front_office_features';
$this->version = 1.0;
$this->author = 'Alexandre Segura';
$this->displayName = $this->l('Customer Opinion');
$this->description = $this->l('Customer Opinion - Example module for PrestaShop 1.5');
parent :: __construct();
}
public function install() {
return parent :: install()
&& $this->resetDb()
&& $this->registerHook('leftColumn')
;
}
private function resetDb() {
$prefix = _DB_PREFIX_;
$engine = _MYSQL_ENGINE_;
$statements = array();
$statements[] = "DROP TABLE IF EXISTS `${prefix}opinion`";
$statements[] = "CREATE TABLE `${prefix}opinion` ("
. '`id_opinion` int(10) unsigned NOT NULL AUTO_INCREMENT,'
. '`id_customer` int(10) unsigned NOT NULL,'
. '`opinion` enum("AVERAGE","GOOD","VERY_GOOD") NOT NULL,'
. '`active` tinyint(1) unsigned DEFAULT "0",'
. 'PRIMARY KEY (`id_opinion`)'
. ") ENGINE=$engine"
;
foreach ($statements as $statement) {
if (!Db :: getInstance()->Execute($statement)) {
return false;
}
}
return true;
}
public function hookDisplayLeftColumn($params) {
return $this->display(__FILE__, 'left-column.tpl');
}
}