This repository was archived by the owner on Apr 3, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathdev_docs_setup_model.php
More file actions
173 lines (146 loc) · 4.25 KB
/
dev_docs_setup_model.php
File metadata and controls
173 lines (146 loc) · 4.25 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
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* Dev Docs Setup Model
*
* Database transactions required for installing, uninstalling
* and saving settings for the Dev Docs add-on
*
* @package Dev Docs
* @author Focus Lab, LLC <dev@focuslabllc.com>
* @copyright Copyright (c) 2011 Focus Lab, LLC
* @link https://github.com/focuslabllc/dev_docs.ee_addon
* @license MIT http://opensource.org/licenses/mit-license.php
*/
class Dev_docs_setup_model {
/**
* @var object the EE "superobject"
*/
private $_EE;
/**
* Constructor
*
* @access public
* @author Erik Reagan <erik@focuslabllc.com>
* @return void
*/
public function __construct()
{
$this->_EE =& get_instance();
$this->_EE->load->dbforge();
}
// End function __construct()
/**
* Insert module into db
*
* This installs the module & actions
*
* @param array Module data
* @param mixed Multi-dimensional array of action install data or FALSE
* @access public
* @author Erik Reagan <erik@focuslabllc.com>
* @return void
*/
public function insert_module($mod_data, $action_array = FALSE)
{
$this->_EE->db->insert('modules', $mod_data);
// Actions
if ($action_array)
{
foreach ($action_array as $action) {
$this->_EE->db->insert('actions', $action);
}
}
}
// End function insert_module()
/**
* Create tables
*
* Use DB forge to create our new table
*
* @access public
* @author Erik Reagan <erik@focuslabllc.com>
* @return void
*/
public function create_dd_tables()
{
if ($this->_EE->db->table_exists('dd_doc_sections') && $this->_EE->db->table_exists('dd_settings'))
{
return;
}
if ( ! $this->_EE->db->table_exists('dd_doc_sections'))
{
$table1_fields = array(
'id' => array('type' => 'INT', 'constraint' => '10', 'unsigned' => TRUE, 'auto_increment' => TRUE),
'heading' => array('type' => 'VARCHAR', 'constraint' => '255'),
'short_name' => array('type' => 'VARCHAR', 'constraint' => '255'),
'content' => array('type' => 'TEXT')
);
$this->_EE->dbforge->add_field($table1_fields);
$this->_EE->dbforge->add_key('id', TRUE);
$this->_EE->dbforge->create_table('dd_doc_sections');
}
if ( ! $this->_EE->db->table_exists('dd_settings'))
{
$table2_fields = array(
'key' => array('type' => 'VARCHAR', 'constraint' => '255'),
'value' => array('type' => 'TEXT'),
'is_serialized' => array('type' => 'INT', 'constraint' => '1', 'default' => '0')
);
$this->_EE->dbforge->add_field($table2_fields);
$this->_EE->dbforge->create_table('dd_settings');
}
}
// End function create_dd_table()
/**
* Delete module from db
*
* This deletes the module & actions
*
* @param array Module data
* @param mixed Multi-dimensional array of action install data or FALSE
* @access public
* @author Erik Reagan <erik@focuslabllc.com>
* @return void
*/
public function delete_module()
{
$this->_EE->db->select('module_id');
$query = $this->_EE->db->get_where('modules', array('module_name' => 'Dev_docs'));
$this->_EE->db->where('module_id', $query->row('module_id'))
->delete('module_member_groups');
$this->_EE->db->where('module_name', 'Dev_docs')
->delete('modules');
$this->_EE->db->where('class', 'Dev_docs_mcp')
->delete('actions');
}
// End function delete_module()
/**
* Drop database tables
*
* Use DB forge to drop our custom tables
*
* @access public
* @author Erik Reagan <erik@focuslabllc.com>
* @return void
*/
public function drop_dd_tables()
{
// deprecated table
if ($this->_EE->db->table_exists('dd_dev_docs'))
{
$this->_EE->dbforge->drop_table('dd_dev_docs');
}
if ($this->_EE->db->table_exists('dd_settings'))
{
$this->_EE->dbforge->drop_table('dd_settings');
}
if ($this->_EE->db->table_exists('dd_doc_sections'))
{
$this->_EE->dbforge->drop_table('dd_doc_sections');
}
}
// End function drop_dd_tables()
}
// End class Dev_docs_setup_model
/* End of file dev_docs_setup_model.php */
/* Location: ./system/expressionengine/third_party/dev_docs/models/dev_docs_setup_model.php */