예제 #1
0
 public static function GetAdminMenu()
 {
     //获取主菜单
     Yii::$app->params['MAINMENU'] = SystemConfig::Get("MAINMENU", null, 'USER');
     //获取子菜单
     $submenus = array();
     foreach (Yii::$app->params['MAINMENU'] as $i => $menu) {
         if (!self::CheckAccessMenu($menu['cfg_value'])) {
             unset(Yii::$app->params['MAINMENU'][$i]);
         }
         $submenu = SystemConfig::GetArrayValue("SUBMENU", $menu['id'], 'USER');
         if (!empty($submenu)) {
             foreach ($submenu as $url => $label) {
                 if (!self::CheckAccessMenu($url)) {
                     unset($submenu[$url]);
                 }
             }
             if (!empty($submenu)) {
                 $submenus[$menu['id']] = $submenu;
             }
             if (!isset($submenus[$menu['id']]) || empty($submenus[$menu['id']])) {
                 unset(Yii::$app->params['MAINMENU'][$i]);
             }
         }
     }
     Yii::$app->params['SUBMENU'] = $submenus;
     //获取ICONS
     Yii::$app->params['ICONS'] = SystemConfig::GetArrayValue("ICONS", null, 'USER');
 }
예제 #2
0
 /**
  * 更新插件
  */
 public static function update($pluginid)
 {
     $data = array('status' => self::STATUS_ERROR, 'msg' => '未知错误');
     $updateDir = self::GetPluginPath($pluginid) . "/update/";
     $configRaw = self::GetPluginConfig($pluginid, false, $updateDir);
     $config = $configRaw['config'];
     if ($config) {
         //更新config
         $oldVersionRows = SystemConfig::Get(strtoupper("PLUGIN_{$pluginid}_VERSION"), null, "USER");
         $oldVersionRow = array_shift($oldVersionRows);
         $oldVersion = !empty($oldVersionRow) ? floatval($oldVersionRow['cfg_value']) : 0;
         $newVersion = floatval($config['version']);
         if ($newVersion > $oldVersion) {
             try {
                 //更新配置文件
                 $conffile = $updateDir . "config.php";
                 $destconffile = self::GetPluginPath($pluginid) . "/config.php";
                 if (is_file($conffile)) {
                     copy($conffile, $destconffile);
                 }
                 //更新lib和views
                 $libDir = $updateDir . "lib";
                 $viewsDir = $updateDir . "views";
                 if (is_dir($viewsDir)) {
                     FileHelper::copyDirectory($viewsDir, self::GetPluginPath($pluginid) . "/views");
                 }
                 if (is_dir($libDir)) {
                     FileHelper::copyDirectory($libDir, self::GetPluginPath($pluginid) . "/lib");
                 }
             } catch (ErrorException $e) {
                 return ['status' => self::STATUS_ERROR, 'msg' => "更新失败,没有权限移动升级文件,请修正权限"];
             }
             $data['status'] = self::STATUS_SUCCESS;
             $data['msg'] = "更新完成!";
             if (!$config['onlyupdatefiles']) {
                 //卸载 只删除数据库中菜单的配置
                 self::unsetup($pluginid);
                 //更新配置
                 $_data = self::setup($pluginid);
                 if (!$_data['status']) {
                     $data['msg'] .= ' ' . $_data['msg'];
                 }
             } else {
                 //更新数据库的插件版本号
                 if ($oldVersionRow) {
                     $id = isset($oldVersionRow['id']) ? $oldVersionRow['id'] : 0;
                     if ($id > 0) {
                         $params = $oldVersionRow;
                         $params['cfg_value'] = $newVersion;
                         SystemConfig::Update($id, $params);
                     }
                 }
             }
             //删除升级目录
             FileHelper::removeDirectory($updateDir);
         } else {
             $data['msg'] = '更新失败,版本号低于当前版本,禁止更新操作!';
         }
     } else {
         $data['msg'] = '更新失败,配置文件有误!';
     }
     return $data;
 }
예제 #3
0
 public function actionDownloadPlugin()
 {
     SystemEvent::GetAdminMenu();
     $result['status'] = 0;
     $url = $this->getParam('url');
     $boss = SystemConfig::Get('SYSTEM_BOSS_DOMAIN', NULL, 'USER');
     $method = $this->getParam('method');
     if ($boss) {
         $bossUrl = $boss[0]['cfg_value'];
         $local = $this->_download($bossUrl, $url);
         if ($local) {
             $count = $this->_unzip($local, $method);
             if (is_integer($count)) {
                 $result['status'] = 1;
                 if ('add' == $method) {
                     $result['msg'] = '下载插件成功';
                 } elseif ("update" == $method) {
                     $result['msg'] = '更新插件成功';
                 }
             } else {
                 $result['msg'] = $count;
             }
         } else {
             $result['msg'] = '与boss系统通信失败,请检查boss系统网址配置和服务器网络状况!';
         }
     } else {
         $result['msg'] = '您还没有配置BOSS系统地址!';
     }
     echo json_encode($result);
     die;
 }