-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathUpdate.class.php
More file actions
131 lines (127 loc) · 3.21 KB
/
Update.class.php
File metadata and controls
131 lines (127 loc) · 3.21 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
<?php
/**
* 会員管理アップデートクラス
*
* @package NetCommons.components
* @author Noriko Arai,Ryuji Masukawa
* @copyright 2006-2007 NetCommons Project
* @license http://www.netcommons.org/license.txt NetCommons License
* @project NetCommons Project, supported by National Institute of Informatics
* @access public
*/
class User_Update extends Action
{
//使用コンポーネントを受け取るため
var $db = null;
function execute()
{
$isIndexedItemId = false;
$isIndexedContent = false;
$isFullTextIndexedContent = false;
$sql = "SHOW INDEX "
. "FROM {users_items_link};";
$indexes = $this->db->execute($sql);
if ($indexes === false) {
return false;
}
foreach($indexes as $index) {
if ($index['Key_name'] == 'item_id') {
$isIndexedItemId = true;
}
if ($index['Key_name'] == 'content') {
$isIndexedContent = true;
if ($index['Index_type'] == 'FULLTEXT') {
$isFullTextIndexedContent = true;
}
}
}
if (!$isIndexedItemId) {
$sql = "ALTER TABLE {users_items_link} "
. "ADD INDEX ("
. "`item_id`, "
. "`email_reception_flag`);";
$result = $this->db->execute($sql);
if ($result === false) {
return false;
}
}
if ($isFullTextIndexedContent) {
$sql = "ALTER TABLE {users_items_link} "
. "DROP INDEX `content`;";
$result = $this->db->execute($sql);
if ($result === false) {
return false;
}
$isIndexedContent = false;
}
if (!$isIndexedContent) {
$sql = "ALTER TABLE {users_items_link} "
. "ADD INDEX (`content`(255));";
$result = $this->db->execute($sql);
if ($result === false) {
return false;
}
}
$sql = "SHOW INDEX "
. "FROM {users};";
$indexes = $this->db->execute($sql);
if ($indexes === false) {
return false;
}
$isIndexedLoginId = false;
$isIndexedHandle = false;
$isIndexedActiveFlag = false;
$isIndexedActivateKey = false;
foreach($indexes as $index) {
if ($index['Key_name'] == 'active_flag') {
$isIndexedActiveFlag = true;
}
if ($index['Key_name'] == 'login_id') {
$isIndexedLoginId = true;
}
if ($index['Key_name'] == 'handle') {
$isIndexedHandle = true;
}
if ($index['Key_name'] == 'activate_key') {
$isIndexedActivateKey = true;
}
}
if (!$isIndexedLoginId) {
$sql = "ALTER TABLE {users} "
. "ADD INDEX (`login_id`);";
$result = $this->db->execute($sql);
if ($result === false) {
return false;
}
}
if (!$isIndexedHandle) {
$sql = "ALTER TABLE {users} "
. "ADD INDEX (`handle`);";
$result = $this->db->execute($sql);
if ($result === false) {
return false;
}
}
if (!$isIndexedActiveFlag) {
$sql = "ALTER TABLE {users} "
. "ADD INDEX ("
. "`active_flag`, "
. "`system_flag`, "
. "`role_authority_id`);";
$result = $this->db->execute($sql);
if ($result === false) {
return false;
}
}
if (!$isIndexedActivateKey) {
$sql = "ALTER TABLE {users} "
. "ADD INDEX (`activate_key`);";
$result = $this->db->execute($sql);
if ($result === false) {
return false;
}
}
return true;
}
}
?>