|
我们为了满足开发者对组件模块的需求,特在放置了一个函数来为开发者提供升级 脚本需求:
那么我们现在来看下他的完整代码:
- function CheckModule($plugname, $infiles) {
- if (!check_developer($plugname)) {
- haoteam_validator($plugname . '.plugin', 0, array('check', 'install', 'upgrade', 'vars.func'));
- }
- $dir = DISCUZ_ROOT . 'source/plugin/' . $plugname . '/install';
- if (!isset($infiles))
- $infiles = array('install_import_module');
- $file = FileLists($dir, $infiles);
- if (is_array($file)) {
- foreach ($file as $value) {
- if (file_exists($value))
- require_once $value;
- if ($piaobo_upgrade)
- @unlink($value);
- }
- }else {
- if (file_exists($file))
- require_once $file;
- if ($piaobo_upgrade)
- @unlink($file);
- }
- }
复制代码 这段代码说明我们的组件升级脚本必须放置在install目录中文件名必须含有同时我们在install文件夹下放置了案例代码:- source\admincp\drk_tool\install\install_import_module.php
复制代码
大致书写代码为:- <?php
- /*
- * CopyRight : [Discuz!] (C)2001-2099 HaoTeam Inc.
- * Document : install_xx.php
- * Created on : 2014-3-20,19:54:48
- * Author : 51漂泊(51piaobo) www.51piaobo.com $
- * Remarks :安装时存在模块的
- * Description: This is NOT a freeware, use is subject to license terms.
- * 这即使是一个免费软件,使用时也请遵守许可证条款,得到当时人书面许可。
- * 未经书面许可,不得翻版,翻版必究;版权归属51漂泊;
- */
- if (!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
- exit('Access Denied');
- }
- global $_G;
- //Start 创建数据表
- /*
- $table = DB::table('piaobo_im_task');
- if (!check_table_is_exist($table)) {
- $table_tmp = str_ireplace($_G['config']['db'][1]['tablepre'], '', $table);
- $tmp = explode('_', $table);
- if ($_G['config']['db'][1]['tablepre'] == $tmp[0])
- $table_tmp = $tmp[0] . $table_tmp;
- require_once DISCUZ_ROOT . 'source/plugin/' . $pname . '/install/install_' . $table_tmp . '.php';
- if ($piaobo_install)
- @unlink(DISCUZ_ROOT . 'source/plugin/' . $pname . '/install/install_' . $table_tmp . '.php');
- }
- loadcache($pname . '_tables');
- $tbs = $_G['cache'][$pname . '_tables'];
- array_push($tbs, $table);
- savecache($pname . '_tables', $tbs);
- */
- //End 创建数据表
- //Start 导入数据
- /*
- $table = DB::table('piaobo_im_nav');
- $sql1 = <<< EOF
- INSERT INTO `$table` (`id`,`parentid`,`name`,`keyword`,`path`,`type`,`available`,`displayorder`,`exp`,`isextcredit`,`extcredit`) VALUES ('33','8', '手机归属查询', 'SJ', 'SJ', '3', '1', '8', '~SJ 15800000000', 0, 0);
- EOF;
- runquery($sql1);
- */
- //End 导入数据
- //Start 导入模块
- /*
- $sql = C::t('common_plugin')->fetch_by_identifier($plugin['identifier']);
- $modules = dunserialize($sql['modules']);
- $module = array('name'=>'bulletin',
- 'param'=>'',
- 'menu'=>'@全体',
- 'url'=>'',
- 'type'=>3,
- 'adminid'=>0,
- 'displayorder'=>8,
- 'navtitle'=>'',
- 'navicon'=>'',
- 'navsubname'=>'',
- 'navsuburl'=>''
- );
- array_push($modules,$module);
- C::t('common_plugin')->update($pluginid,$modules);
- */
- //End 导入模块
- //Start 导入参数
- /*
- C::t('common_pluginvar')->insert(array('pluginid',
- 'displayorder',
- 'title',
- 'description',
- 'variable',
- 'type',
- 'value',
- 'extra'
- ));
- */
- //End 导入参数
- ?>
复制代码
|
|