Пример #1
0
 public function init()
 {
     parent::init();
     RbacAsset::register($this->view);
     $pid = 5874;
     $this->tabs = SystemConfig::GetArrayValue("THIRDMENU", $pid, "USER");
 }
Пример #2
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');
 }
Пример #3
0
 /**
  * 重新排序
  * @param $cfg_name string 配置名
  * @param $id int 主键 
  * @param $new_order int 所期望的新序号
  * @param $old_order int 老的序号
  */
 public static function setNewOrder($cfg_name, $id, $new_order, $old_order = '')
 {
     $item = SystemConfig::GetById($id);
     $old_order = $item['cfg_order'];
     if ($new_order == $old_order) {
         return false;
     } else {
         if ($new_order < $old_order) {
             //向上 序号变小
             $sql_1 = "update {{" . self::$_tableName . "}} set cfg_order=case when cfg_order>={$new_order} and cfg_order<{$old_order} then cfg_order+1 else cfg_order end where cfg_name='{$cfg_name}';";
         } else {
             //向下  序号变大
             $sql_1 = "update {{" . self::$_tableName . "}} set cfg_order=case when cfg_order>={$new_order}  then cfg_order+1 when cfg_order>{$old_order} and {$old_order}>0 then cfg_order-1 else cfg_order end where cfg_name='{$cfg_name}';";
         }
         //var_dump($sql_1);
         Yii::$app->db->createCommand($sql_1)->execute();
         //防止order相同的同时被修改成期望值
         $sql_2 = "update {{" . self::$_tableName . "}} set cfg_order={$new_order} where id={$id}";
         //var_dump($sql_2);
         Yii::$app->db->createCommand($sql_2)->execute();
     }
 }
Пример #4
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;
 }
Пример #5
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;
 }