forked from netcommons/NetCommons2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAction.class.php
More file actions
146 lines (134 loc) · 3.74 KB
/
Action.class.php
File metadata and controls
146 lines (134 loc) · 3.74 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
<?php
/**
* ConfigActionクラス
*
* @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 Config_Action {
/**
* @var DBオブジェクトを保持
*
* @access private
*/
var $_db = null;
/**
* コンストラクター
*
* @access public
*/
function Config_Action() {
$container =& DIContainerFactory::getContainer();
$this->_db =& $container->getComponent("DbObject");
}
/**
* ConfigValue登録処理
* @return boolean true or false
* @access public
**/
function insConfigValue($conf_modid, $conf_name, $conf_value)
{
$regs = array();
if (preg_match("/^([^\[\]>]+)(\[([0-9]*)\])?$/", $conf_name, $regs)) {
$conf_name = $regs[1];
}
$conf_catid = isset($regs[3]) ? intval($regs[3]) : 0;
$params = array(
"conf_modid" =>$conf_modid,
"conf_catid" =>$conf_catid,
"conf_name" =>$conf_name,
"conf_value" =>$conf_value
);
$result = $this->_db->insertExecute("config", $params, true, "conf_id");
if($result === false) {
return false;
}
return true;
}
/**
* ConfigValue更新処理
* @return boolean true or false
* @access public
**/
function updConfigValue($conf_modid, $conf_name, $conf_value, $conf_catid=_MAIN_CONF_CATID)
{
$container =& DIContainerFactory::getContainer();
$session =& $container->getComponent("Session");
$configView =& $container->getComponent("configView");
$lang_items = explode(',', _MULTI_LANG_CONFIG_ITEMS);
$session_lang = $session->getParameter('_lang');
$config_lang =& $configView->getConfigByConfname(_SYS_CONF_MODID, 'language');
if(in_array($conf_name, $lang_items) && $configView->isMultiLanguage) {
$result = $this->_db->updateExecute('config_language', array('conf_value' => $conf_value), array('lang_dirname' => $session_lang,'conf_name' => $conf_name));
if($result === false) return false;
}
if(!$configView->isMultiLanguage || !in_array($conf_name, $lang_items) || $config_lang['conf_value'] == $session_lang) {
$params = array(
"conf_catid" => $conf_catid,
"conf_value" => $conf_value
);
$where_params = array(
"conf_modid" => $conf_modid,
"conf_name" => $conf_name
);
$result = $this->_db->updateExecute("config", $params, $where_params, true);
if ($result === false) {
return $result;
}
}
return true;
}
/**
* Config更新処理
* @param array $params
* @param array $where_params
* @return boolean
* @access public
*/
function updConfig($params=array(), $where_params=array(), $footer_flag = true)
{
$result = $this->_db->updateExecute("config", $params, $where_params, $footer_flag);
if ($result === false) {
return false;
}
return true;
}
/**
* ConfigValue削除処理
* @return boolean true or false
* @access public
**/
function delConfigValueByModid($conf_modid)
{
$params = array(
"conf_modid" => $conf_modid
);
$result = $this->_db->deleteExecute("config", $params);
if ($result === false) {
return $result;
}
return true;
}
/**
* ConfigValue削除処理
* @return boolean true or false
* @access public
**/
function delConfigValue($conf_modid, $conf_name)
{
$params = array(
"conf_modid" => $conf_modid,
"conf_name" => $conf_name
);
$result = $this->_db->deleteExecute("config", $params);
if ($result === false) {
return $result;
}
return true;
}
}
?>