forked from netcommons/NetCommons2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUpdate.class.php
More file actions
149 lines (143 loc) · 4.21 KB
/
Update.class.php
File metadata and controls
149 lines (143 loc) · 4.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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
<?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 Policy_Update extends Action
{
//使用コンポーネントを受け取るため
var $dbObject = null;
function execute()
{
$sql = "SELECT item_id "
. "FROM {items} "
. "WHERE tag_name = ?";
$inputs = array(
'password'
);
$items = $this->dbObject->execute($sql, $inputs);
if ($items === false) {
return false;
}
$itemId = $items[0]['item_id'];
$sql = "SELECT user_authority_id, "
. "under_public_flag, "
. "self_public_flag, "
. "over_public_flag "
. "FROM {items_authorities_link} "
. "WHERE item_id = ? "
. "AND (under_public_flag = ? "
. "OR self_public_flag = ? "
. "OR over_public_flag = ?)";
$inputs = array(
$itemId,
USER_PUBLIC,
USER_PUBLIC,
USER_PUBLIC
);
$itemAuthorities = $this->dbObject->execute($sql, $inputs);
if ($itemAuthorities === false) {
return false;
}
foreach ($itemAuthorities as $itemAuthority) {
$updateStatements = array();
if ($itemAuthority['under_public_flag'] == USER_PUBLIC) {
$updateStatements['under_public_flag'] = USER_NO_PUBLIC;
}
if ($itemAuthority['self_public_flag'] == USER_PUBLIC) {
$updateStatements['self_public_flag'] = USER_NO_PUBLIC;
}
if ($itemAuthority['over_public_flag'] == USER_PUBLIC) {
$updateStatements['over_public_flag'] = USER_NO_PUBLIC;
}
$whereStatements = array(
'item_id' => $itemId,
'user_authority_id' => $itemAuthority['user_authority_id'],
);
if (!$this->dbObject->updateExecute('items_authorities_link', $updateStatements, $whereStatements, true)) {
return false;
}
}
$sql = "SELECT item_id "
. "FROM {items} "
. "WHERE tag_name = ?";
$inputs = array(
'handle'
);
$items = $this->dbObject->execute($sql, $inputs);
if ($items === false) {
return false;
}
$itemId = $items[0]['item_id'];
$sql = "SELECT user_authority_id, "
. "under_public_flag, "
. "self_public_flag, "
. "over_public_flag "
. "FROM {items_authorities_link} "
. "WHERE item_id = ? "
. "AND (under_public_flag = ? "
. "OR self_public_flag = ? "
. "OR over_public_flag = ?)";
$inputs = array(
$itemId,
USER_NO_PUBLIC,
USER_NO_PUBLIC,
USER_NO_PUBLIC
);
$itemAuthorities = $this->dbObject->execute($sql, $inputs);
if ($itemAuthorities === false) {
return false;
}
foreach ($itemAuthorities as $itemAuthority) {
$updateStatements = array();
if ($itemAuthority['under_public_flag'] == USER_NO_PUBLIC) {
$updateStatements['under_public_flag'] = USER_PUBLIC;
}
if ($itemAuthority['self_public_flag'] == USER_NO_PUBLIC) {
$updateStatements['self_public_flag'] = USER_PUBLIC;
}
if ($itemAuthority['over_public_flag'] == USER_NO_PUBLIC) {
$updateStatements['over_public_flag'] = USER_PUBLIC;
}
$whereStatements = array(
'item_id' => $itemId,
'user_authority_id' => $itemAuthority['user_authority_id'],
);
if (!$this->dbObject->updateExecute('items_authorities_link', $updateStatements, $whereStatements, true)) {
return false;
}
}
$sql = "SELECT item_id "
. "FROM {items_authorities_link} "
. "WHERE user_authority_id = ? "
. "AND under_public_flag = ? ";
$inputs = array(
_AUTH_GENERAL,
USER_EDIT
);
$itemAuthorities = $this->dbObject->execute($sql, $inputs);
if ($itemAuthorities === false) {
return false;
}
$updateStatements = array(
'under_public_flag' => USER_PUBLIC
);
foreach ($itemAuthorities as $itemAuthority) {
$whereStatements = array(
'item_id' => $itemAuthority['item_id'],
'user_authority_id' => _AUTH_GENERAL,
);
if (!$this->dbObject->updateExecute('items_authorities_link', $updateStatements, $whereStatements, true)) {
return false;
}
}
return true;
}
}
?>