/
upd.rest.php
149 lines (125 loc) · 3.23 KB
/
upd.rest.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
149
<?php defined('BASEPATH') or exit('No direct script access allowed');
/**
* REST Add-on
*
* @package ExpressionEngine 2
* @subpackage Third Party
* @category Modules
* @author Phil Sturgeon
* @link http://devot-ee.com/add-ons/rest/
*/
class Rest_upd
{
public $module_name = 'REST';
public $version = '1.6.2';
public function __construct($switch = TRUE)
{
$this->EE =& get_instance();
}
/**
* Installer for the REST module
*/
public function install()
{
$this->EE->db->insert('modules', array(
'module_name' => $this->module_name,
'module_version' => $this->version,
'has_cp_backend' => 'y'
));
$this->EE->load->dbforge();
// time to make a table
$this->EE->dbforge->add_field('id');
$this->EE->dbforge->add_field(array(
'name' => array(
'type' => 'VARCHAR',
'constraint' => 255,
'null' => FALSE
),
'url' => array(
'type' => 'VARCHAR',
'constraint' => 255,
'null' => FALSE
),
'verb' => array(
'type' => 'VARCHAR',
'constraint' => 6,
'null' => FALSE
),
'format' => array(
'type' => 'VARCHAR',
'constraint' => 50,
'null' => FALSE
),
'record_type' => array(
'type' => 'CHAR',
'constraint' => 1,
'default' => 'm',
'null' => FALSE
),
'params' => array(
'type' => 'TEXT',
'null' => FALSE
),
'site_id' => array(
'type' => 'INT',
'constraint' => 11,
'default' => 1,
'null' => FALSE
)
));
$this->EE->dbforge->create_table('rest_requests');
// Add an example request
$this->EE->db->query("
INSERT INTO `exp_rest_requests` (`id`, `name`, `url`, `verb`, `format`, `params`, `site_id`) VALUES
(NULL, 'twitter_timeline', 'http://api.twitter.com/1/statuses/user_timeline.json', 'get', 'json', 'screen_name=philsturgeon', 1);");
return TRUE;
}
/**
* Uninstall the REST module
*/
public function uninstall()
{
$this->EE->load->dbforge();
$this->EE->db->select('module_id');
$query = $this->EE->db->get_where('modules', array('module_name' => $this->module_name));
$this->EE->db->where('module_id', $query->row('module_id'));
$this->EE->db->delete('module_member_groups');
$this->EE->db->where('module_name', $this->module_name);
$this->EE->db->delete('modules');
$this->EE->db->where('class', $this->module_name);
$this->EE->db->delete('actions');
$this->EE->db->where('class', $this->module_name.'_mcp');
$this->EE->db->delete('actions');
$this->EE->dbforge->drop_table('rest_requests');
return TRUE;
}
/**
* Update the module
*
* @param $current current version number
* @return boolean indicating whether or not the module was updated
*/
public function update($current = '')
{
if ($current == '' OR $current == $this->version)
{
return FALSE;
}
$this->EE->load->dbforge();
if ($current <= '1.5.3')
{
$this->EE->dbforge->add_column('rest_requests', array(
'record_type' => array(
'type' => 'char',
'constraint' => 11,
'default' => 'm',
'null' => FALSE,
)
));
$this->EE->db->set('site_id', config_item('site_id'));
$this->EE->db->update('rest_requests');
}
}
}
/* End of file upd.rest.php */
/* Location: ./system/expressionengine/third_party/rating/upd.rest.php */