@@ -18,7 +18,7 @@ class Service
1818
1919 /**
2020 * 远程下载插件
21- *
21+ *
2222 * @param string $name 插件名称
2323 * @param array $extend 扩展参数
2424 * @return string
@@ -76,7 +76,7 @@ public static function download($name, $extend = [])
7676
7777 /**
7878 * 解压插件
79- *
79+ *
8080 * @param string $name 插件名称
8181 * @return string
8282 * @throws Exception
@@ -105,7 +105,7 @@ public static function unzip($name)
105105
106106 /**
107107 * 检测插件是否完整
108- *
108+ *
109109 * @param string $name 插件名称
110110 * @return boolean
111111 * @throws Exception
@@ -131,7 +131,7 @@ public static function check($name)
131131
132132 /**
133133 * 是否有冲突
134- *
134+ *
135135 * @param string $name 插件名称
136136 * @return boolean
137137 * @throws AddonException
@@ -173,7 +173,7 @@ public static function importsql($name)
173173
174174 /**
175175 * 刷新插件缓存文件
176- *
176+ *
177177 * @return boolean
178178 * @throws Exception
179179 */
@@ -231,7 +231,7 @@ public static function refresh()
231231
232232 /**
233233 * 安装插件
234- *
234+ *
235235 * @param string $name 插件名称
236236 * @param boolean $force 是否覆盖
237237 * @param array $extend 扩展参数
@@ -316,7 +316,7 @@ public static function install($name, $force = false, $extend = [])
316316
317317 /**
318318 * 卸载插件
319- *
319+ *
320320 * @param string $name
321321 * @param boolean $force 是否强制卸载
322322 * @return boolean
@@ -414,6 +414,26 @@ public static function enable($name, $force = false)
414414 }
415415 }
416416
417+
418+ //执行启用脚本
419+ try
420+ {
421+ $ class = get_addon_class ($ name );
422+ if (class_exists ($ class ))
423+ {
424+ $ addon = new $ class ();
425+ if (method_exists ($ class ,"enable " ))
426+ {
427+ $ addon ->enable ();
428+ }
429+ }
430+ }
431+ catch (Exception $ e )
432+ {
433+ throw new Exception ($ e ->getMessage ());
434+ }
435+
436+
417437 $ info = get_addon_info ($ name );
418438 $ info ['state ' ] = 1 ;
419439 unset($ info ['url ' ]);
@@ -431,7 +451,6 @@ public static function disable($name, $force = false)
431451 {
432452 throw new Exception ('Addon not exists ' );
433453 }
434-
435454 if (!$ force )
436455 {
437456 Service::noconflict ($ name );
@@ -460,14 +479,35 @@ public static function disable($name, $force = false)
460479
461480 set_addon_info ($ name , $ info );
462481
482+
483+ // 执行禁用脚本
484+ try
485+ {
486+ $ class = get_addon_class ($ name );
487+ if (class_exists ($ class ))
488+ {
489+ $ addon = new $ class ();
490+
491+ if (method_exists ($ class ,"disable " ))
492+ {
493+ $ addon ->disable ();
494+ }
495+ }
496+ }
497+ catch (Exception $ e )
498+ {
499+ throw new Exception ($ e ->getMessage ());
500+ }
501+
502+
463503 // 刷新
464504 Service::refresh ();
465505 return true ;
466506 }
467507
468508 /**
469509 * 获取插件在全局的文件
470- *
510+ *
471511 * @param string $name
472512 * @return array
473513 */
@@ -486,7 +526,7 @@ public static function getGlobalFiles($name, $onlyconflict = false)
486526 {
487527 //匹配出所有的文件
488528 $ files = new RecursiveIteratorIterator (
489- new RecursiveDirectoryIterator ($ addonDir . $ dir , RecursiveDirectoryIterator::SKIP_DOTS ), RecursiveIteratorIterator::CHILD_FIRST
529+ new RecursiveDirectoryIterator ($ addonDir . $ dir , RecursiveDirectoryIterator::SKIP_DOTS ), RecursiveIteratorIterator::CHILD_FIRST
490530 );
491531
492532 foreach ($ files as $ fileinfo )
0 commit comments