-
Notifications
You must be signed in to change notification settings - Fork 1
/
SocialModule.php
91 lines (76 loc) · 2.99 KB
/
SocialModule.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
<?php
namespace App\Modules\Social;
use App\Core\Addon\Module\Module;
class SocialModule extends Module {
public $version = '1.0.3';
public function info() {
return array(
'name' => array(
'en' => 'Socialite'
),
'description' => array(
'en' => 'Link user accounts with Twitter, Facebook, Google and many more providers.',
),
'frontend' => true,
'backend' => true,
'menu' => 'utilities',
'skip_xss' => TRUE,
);
}
public function install() {
$this->dbforge->drop_table('authentications', TRUE);
$this->dbforge->drop_table('credentials', TRUE);
$authentications = "
CREATE TABLE " . $this->db->dbprefix('authentications') . " (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`provider` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
`uid` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`access_token` text COLLATE utf8_unicode_ci DEFAULT NULL,
`secret` text COLLATE utf8_unicode_ci DEFAULT NULL,
`created_at` int(11) DEFAULT NULL,
`updated_at` int(11) DEFAULT NULL,
`user_id` int(11) DEFAULT NULL,
`expires` int(12) DEFAULT '0',
`refresh_token` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `unique` (`user_id`,`provider`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
";
$credentials = "
CREATE TABLE " . $this->db->dbprefix('credentials') . " (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`provider` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
`client_key` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`client_secret` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`scope` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`access_token` text COLLATE utf8_unicode_ci DEFAULT NULL,
`secret` text COLLATE utf8_unicode_ci DEFAULT NULL,
`expires` int(12) DEFAULT '0',
`refresh_token` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`uid` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`name` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`is_active` tinyint(1) DEFAULT '1',
PRIMARY KEY (`id`),
UNIQUE KEY `unique` (`provider`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
";
if ($this->db->query($authentications) and $this->db->query($credentials)) {
return true;
}
}
public function uninstall() {
$this->dbforge->drop_table('authentications');
$this->dbforge->drop_table('credentials');
return true;
}
public function upgrade($old_version) {
// Your Upgrade Logic
return TRUE;
}
public function help() {
// Return a string containing help info
// You could include a file and return it here.
return "No documentation has been added for this module.";
}
}
/* End of file details.php */