- Timestamp:
- 2013/07/20 16:21:44 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/version-2_13-dev/data/class/plugin/SC_Plugin_Util.php
r22856 r22978 144 144 * 145 145 * @param integer $plugin_id 146 * @param integer $use_type 1=有効のみ 2=無効のみ 3=全て 146 147 * @return array フックポイントの一覧 147 148 */ 148 function getPluginHookPoint($plugin_id )149 function getPluginHookPoint($plugin_id, $use_type = 1) 149 150 { 150 151 $objQuery =& SC_Query_Ex::getSingletonInstance(); … … 152 153 $from = 'dtb_plugin_hookpoint'; 153 154 $where = 'plugin_id = ?'; 154 155 switch ($use_type) { 156 case 1: 157 $where .= ' AND use_flg = true'; 158 break; 159 160 case 2: 161 $where .= ' AND use_flg = false'; 162 break; 163 164 case 3: 165 default: 166 break; 167 } 155 168 return $objQuery->select($cols, $from, $where, array($plugin_id)); 169 } 170 171 /** 172 * プラグインフックポイントを取得する. 173 * 174 * @param integer $use_type 1=有効のみ 2=無効のみ 3=全て 175 * @return array フックポイントの一覧 176 */ 177 function getPluginHookPointList($use_type = 3) 178 { 179 $objQuery =& SC_Query_Ex::getSingletonInstance(); 180 $objQuery->setOrder('hook_point ASC, priority DESC'); 181 $cols = 'dtb_plugin_hookpoint.*, dtb_plugin.priority, dtb_plugin.plugin_name'; 182 $from = 'dtb_plugin_hookpoint LEFT JOIN dtb_plugin USING(plugin_id)'; 183 switch ($use_type) { 184 case 1: 185 $where = 'enable = 1 AND use_flg = true'; 186 break; 187 188 case 2: 189 $where = 'enable = 1 AND use_flg = false'; 190 break; 191 192 case 3: 193 default: 194 $where = ''; 195 break; 196 } 197 return $objQuery->select($cols, $from, $where); 198 //$arrList = array(); 199 //foreach ($arrRet AS $key=>$val) { 200 // $arrList[$val['hook_point']][$val['plugin_id']] = $val; 201 //} 202 //return $arrList; 156 203 } 157 204 … … 183 230 return $arrErr; 184 231 } 232 233 /** 234 * フックポイントのON/OFF変更 235 * 236 * @param intger $plugin_hookpoint_id フックポイントID 237 * @return bolean $use_flg:ture=ON、false=OFF 238 */ 239 function setPluginHookPointChangeUse($plugin_hookpoint_id, $use_flg = false) { 240 $objQuery =& SC_Query_Ex::getSingletonInstance(); 241 $sqlval['use_flg'] = $use_flg; 242 $objQuery->update('dtb_plugin_hookpoint', $sqlval, 'plugin_hookpoint_id = ?', array($plugin_hookpoint_id)); 243 } 244 245 /** 246 * フックポイントで衝突する可能性のあるプラグインを判定.メッセージを返します. 247 * 248 * @param int $plugin_id プラグインID 249 * @return string $conflict_alert_message メッセージ 250 */ 251 function checkConflictPlugin($plugin_id = '') 252 { 253 // フックポイントを取得します. 254 $where = 'T1.hook_point = ? AND NOT T1.plugin_id = ? AND T2.enable = ?'; 255 if ($plugin_id > 0) { 256 $hookPoints = SC_Plugin_Util::getPluginHookPoint($plugin_id, ''); 257 } else { 258 $hookPoints = SC_Plugin_Util::getPluginHookPointList(1); 259 $where .= ' AND T1.use_flg = true'; 260 } 261 262 $conflict_alert_message = ''; 263 $arrConflictPluginName = array(); 264 $arrConflictHookPoint = array(); 265 $objQuery =& SC_Query_Ex::getSingletonInstance(); 266 $objQuery->setGroupBy('T1.hook_point, T1.plugin_id, T2.plugin_name'); 267 $table = 'dtb_plugin_hookpoint AS T1 LEFT JOIN dtb_plugin AS T2 ON T1.plugin_id = T2.plugin_id'; 268 foreach ($hookPoints as $hookPoint) { 269 // 競合するプラグインを取得する, 270 $conflictPlugins = $objQuery->select('T1.hook_point, T1.plugin_id, T2.plugin_name', $table, $where, array($hookPoint['hook_point'], $hookPoint['plugin_id'], PLUGIN_ENABLE_TRUE)); 271 272 // プラグイン名重複を削除する為、専用の配列に格納し直す. 273 foreach ($conflictPlugins as $conflictPlugin) { 274 // プラグイン名が見つからなければ配列に格納 275 if (!in_array($conflictPlugin['plugin_name'], $arrConflictPluginName)) { 276 $arrConflictPluginName[] = $conflictPlugin['plugin_name']; 277 } 278 // プラグイン名が見つからなければ配列に格納 279 if (!in_array($conflictPlugin['hook_point'], $arrConflictHookPoint)) { 280 $arrConflictHookPoint[] = $conflictPlugin['hook_point']; 281 } 282 } 283 } 284 285 if ($plugin_id > 0) { 286 // メッセージをセットします. 287 foreach ($arrConflictPluginName as $conflictPluginName) { 288 $conflict_alert_message .= '* ' . $conflictPluginName . 'と競合する可能性があります。<br/>'; 289 } 290 return $conflict_alert_message; 291 } else { 292 return $arrConflictHookPoint; 293 } 294 } 295 185 296 }
Note: See TracChangeset
for help on using the changeset viewer.