-
Notifications
You must be signed in to change notification settings - Fork 0
/
upd.threadedcomments.php
148 lines (112 loc) · 5.15 KB
/
upd.threadedcomments.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
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
<?php
/*
=====================================================
Threaded Comments
-----------------------------------------------------
http://www.intoeetive.com/
-----------------------------------------------------
Copyright (c) 2011-2016 Yuri Salimovskiy
=====================================================
*/
if ( ! defined('BASEPATH'))
{
exit('Invalid file request');
}
require_once PATH_THIRD.'threadedcomments/config.php';
class Threadedcomments_upd {
var $version = THREADEDCOMMENTS_ADDON_VERSION;
function __construct() {
}
function install() {
ee()->load->dbforge();
//----------------------------------------
// EXP_MODULES
// The settings column, Ellislab should have put this one in long ago.
// No need for a seperate preferences table for each module.
//----------------------------------------
if (ee()->db->field_exists('settings', 'modules') == FALSE)
{
ee()->dbforge->add_column('modules', array('settings' => array('type' => 'TEXT') ) );
}
if (ee()->db->field_exists('parent_id', 'comments') == FALSE)
{
ee()->dbforge->add_column('comments', array('parent_id' => array('type' => 'INT', 'default' => '0') ) );
}
if (ee()->db->field_exists('root_id', 'comments') == FALSE)
{
ee()->dbforge->add_column('comments', array('root_id' => array('type' => 'INT', 'default' => '0') ) );
}
if (ee()->db->field_exists('level', 'comments') == FALSE)
{
ee()->dbforge->add_column('comments', array('level' => array('type' => 'INT', 'default' => '0') ) );
}
$fields = array(
'subscription_id' => array('type' => 'int' , 'constraint' => '10', 'unsigned' => TRUE, 'auto_increment' => TRUE),
'entry_id' => array('type' => 'int' , 'constraint' => '10', 'unsigned' => TRUE),
'member_id' => array('type' => 'int' , 'constraint' => '10', 'default' => 0),
'thread_id' => array('type' => 'int' , 'constraint' => '10', 'default' => 0),
'email' => array('type' => 'varchar', 'constraint' => '75'),
'subscription_date' => array('type' => 'varchar', 'constraint' => '10'),
'notification_sent' => array('type' => 'char' , 'constraint' => '1', 'default' => 'n'),
'hash' => array('type' => 'varchar', 'constraint' => '15')
);
ee()->dbforge->add_field($fields);
ee()->dbforge->add_key('subscription_id', TRUE);
ee()->dbforge->add_key(array('entry_id', 'member_id', 'thread_id'));
ee()->dbforge->create_table('threadedcomments_subscriptions');
$settings = array();
$data = array( 'module_name' => 'Threadedcomments' , 'module_version' => $this->version, 'has_cp_backend' => 'y', 'settings'=> serialize($settings) );
ee()->db->insert('modules', $data);
$data = array(
'class' => 'Threadedcomments' ,
'method' => 'delete_thread_notification'
);
ee()->db->insert('actions', $data);
return TRUE;
}
function uninstall()
{
ee()->load->dbforge();
ee()->db->select('module_id');
$query = ee()->db->get_where('modules', array('module_name' => 'Threadedcomments'));
ee()->db->where('module_id', $query->row('module_id'));
ee()->db->delete(version_compare(APP_VER, '6.0', '>=') ? 'module_member_roles' : 'module_member_groups');
ee()->db->where('module_name', 'Threadedcomments');
ee()->db->delete('modules');
ee()->db->where('class', 'Threadedcomments');
ee()->db->delete('actions');
ee()->dbforge->drop_table('threadedcomments_subscriptions');
return TRUE;
}
function update($current='')
{
if (version_compare($current, '3.0.0', '<'))
{
$data = array('has_cp_backend' => 'y');
ee()->db->where('module_name', 'Threadedcomments');
ee()->db->update('modules', $data);
$fields = array(
'subscription_id' => array('type' => 'int' , 'constraint' => '10', 'unsigned' => TRUE, 'auto_increment' => TRUE),
'entry_id' => array('type' => 'int' , 'constraint' => '10', 'unsigned' => TRUE),
'member_id' => array('type' => 'int' , 'constraint' => '10', 'default' => 0),
'thread_id' => array('type' => 'int' , 'constraint' => '10', 'default' => 0),
'email' => array('type' => 'varchar', 'constraint' => '75'),
'subscription_date' => array('type' => 'varchar', 'constraint' => '10'),
'notification_sent' => array('type' => 'char' , 'constraint' => '1', 'default' => 'n'),
'hash' => array('type' => 'varchar', 'constraint' => '15')
);
ee()->dbforge->add_field($fields);
ee()->dbforge->add_key('subscription_id', TRUE);
ee()->dbforge->add_key(array('entry_id', 'member_id', 'thread_id'));
ee()->dbforge->create_table('threadedcomments_subscriptions');
$data = array(
'class' => 'Threadedcomments' ,
'method' => 'delete_thread_notification'
);
ee()->db->insert('actions', $data);
}
return TRUE;
}
}
/* END */
?>