-
Notifications
You must be signed in to change notification settings - Fork 0
/
enable.php
115 lines (95 loc) · 3.13 KB
/
enable.php
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<?php
if (!defined('IN_CMS')) { exit(); }
/*
* Form
*
* The Form plugin is a third-party plugin that lets you create and display forms on your installation of Wolf CMS.
*
* @package Plugins
* @subpackage form
*
* @author Nic Wortel <[email protected]>
* @copyright Nic Wortel, 2012
* @version 0.1.2
*/
Plugin::setAllSettings(array(
'success_message' => '<p>The form has been submitted succesfully.</p>',
'invalid_message' => '<p>The form has not been submitted.</p>',
'error_message' => '<p>An error has ocurred and the email has not been sent. Please try again.</p>',
'copy_message' => '<p>We have recieved your submission. This is a copy of the data you have sent to us.</p>'
), 'form');
$permissions = array(
'form_builder_view',
'form_add',
'form_edit',
'form_delete'
);
foreach ($permissions as $permission) {
$perm = new Permission();
$perm->name = $permission;
$perm->save();
}
$PDO = Record::getConnection();
$driver = strtolower($PDO->getAttribute(Record::ATTR_DRIVER_NAME));
if($driver == 'mysql'){
$sql = "CREATE TABLE IF NOT EXISTS `".TABLE_PREFIX."form` (
`id` int(1) NOT NULL auto_increment,
`name` varchar(255) NOT NULL,
`mail_to` varchar(255) NOT NULL,
`created_on` datetime NOT NULL,
`updated_on` datetime NOT NULL,
`created_by_id` int(1) NOT NULL,
`updated_by_id` int(1) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ;";
$PDO->exec($sql);
$sql = "CREATE TABLE IF NOT EXISTS `".TABLE_PREFIX."form_field` (
`id` int(1) NOT NULL auto_increment,
`label` varchar(255) NOT NULL,
`slug` varchar(255) NOT NULL,
`type` varchar(50) NOT NULL,
`required` tinyint(1) DEFAULT 0,
`form_id` int(1) NOT NULL,
`position` int(1) DEFAULT 0,
PRIMARY KEY (`id`),
KEY `form_id` (`form_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ;";
$PDO->exec($sql);
$sql = "CREATE TABLE IF NOT EXISTS `".TABLE_PREFIX."form_field_option` (
`id` int(1) NOT NULL auto_increment,
`label` varchar(255) NOT NULL,
`slug` varchar(255) NOT NULL,
`field_id` int(1) NOT NULL,
`position` int(1) DEFAULT 0,
PRIMARY KEY (`id`),
KEY `field_id` (`field_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ;";
$PDO->exec($sql);
} elseif($driver == 'sqlite'){
$sql = "CREATE TABLE IF NOT EXISTS `".TABLE_PREFIX."form` (
`id` INTEGER NOT NULL PRIMARY KEY,
`name` varchar(255) NOT NULL,
`mail_to` varchar(255) NOT NULL,
`created_on` datetime NOT NULL,
`updated_on` datetime NOT NULL,
`created_by_id` int(1) NOT NULL,
`updated_by_id` int(1) NOT NULL
);";
$PDO->exec($sql);
$sql = "CREATE TABLE IF NOT EXISTS `".TABLE_PREFIX."form_field` (
`id` INTEGER NOT NULL PRIMARY KEY,
`label` varchar(255) NOT NULL,
`slug` varchar(255) NOT NULL,
`type` varchar(50) NOT NULL,
`required` tinyint(1) DEFAULT 0,
`form_id` int(1) NOT NULL,
`position` int(1) DEFAULT 0 );";
$PDO->exec($sql);
$sql = "CREATE TABLE IF NOT EXISTS `".TABLE_PREFIX."form_field_option` (
`id` INTEGER NOT NULL PRIMARY KEY,
`label` varchar(255) NOT NULL,
`slug` varchar(255) NOT NULL,
`field_id` int(1) NOT NULL,
`position` int(1) DEFAULT 0);";
$PDO->exec($sql);
}