/
mcp.recognize.php
67 lines (52 loc) · 1.68 KB
/
mcp.recognize.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
<?php
require_once PATH_THIRD.'recognize/config'.EXT;
class Recognize_mcp {
public function __construct()
{
$this->EE =& get_instance();
$this->EE->load->helper('recognize');
$this->EE->cp->set_variable('cp_page_title', RE_SHORT_NAME);
if ($this->EE->input->get('method'))
{
$this->EE->cp->set_breadcrumb(re_cp_url(), RE_SHORT_NAME);
}
}
public function index()
{
$this->EE->cp->set_right_nav(array('apps' => re_cp_url('list_app')));
return $this->EE->load->view('authorizations/list', array(), TRUE);
}
public function list_app()
{
$this->EE->cp->set_variable('cp_page_title', l('apps'));
$this->EE->cp->set_right_nav(array('add_app' => re_cp_url('add_app')));
$apps = $this->EE->db->get('exp_recognize_apps');
if ($apps->num_rows)
{
return $this->EE->load->view('apps/list', array('apps'=>$apps->result()), TRUE);
}
return $this->EE->load->view('apps/welcome', array(), TRUE);
}
public function add_app()
{
$this->EE->cp->set_breadcrumb(re_cp_url('list_app'), l('apps'));
$this->EE->cp->set_variable('cp_page_title', l('add_app').' - '.RE_SHORT_NAME);
return $this->EE->load->view('apps/add', array(), TRUE);
}
public function post_app()
{
$this->EE->db->insert('exp_recognize_apps', array(
'app_name' => $this->EE->input->post('app_name'),
'app_id' => $this->EE->functions->random('alnum', 8),
'app_secret' => $this->EE->functions->random('sha1', 54)
));
$this->EE->functions->redirect(re_cp_url('list_app'));
}
public function delete_app()
{
$this->EE->db->delete('exp_recognize_apps', array(
'id' => $this->EE->input->get('app_id')
));
$this->EE->functions->redirect(re_cp_url('list_app'));
}
}