Selaa lähdekoodia

create sample
生成示例项目

star7th 5 vuotta sitten
vanhempi
commit
6d449c5338
1 muutettua tiedostoa jossa 28 lisäystä ja 2 poistoa
  1. 28 2
      server/Application/Api/Controller/UserController.class.php

+ 28 - 2
server/Application/Api/Controller/UserController.class.php

@@ -29,7 +29,10 @@ class UserController extends BaseController {
                 if ($new_uid) {
 
                     $create_sample = D("Options")->get("create_sample") ;
-                    if ($create_sample !== '0' && C("DEFAULT_LANG") == 'zh-cn' ) {
+                    //获取后台的语言设置
+                    //这是个历史包袱。因为安装的时候语言设置没有写到API模块的配置下,所以只能读文件读取Home模快的配置文件
+                    $config = file_get_contents("./Application/Home/Conf/config.php");
+                    if ($create_sample !== '0' && strstr($config, "'zh-cn',") ) {
                         //导入示例项目
                         $this->_importSample($new_uid);
                     }
@@ -108,8 +111,11 @@ class UserController extends BaseController {
             $ret = D("User")->checkLdapLogin($username,$password);
         }
         if ($ret) {
+            //获取后台的语言设置
+            //这是个历史包袱。因为安装的时候语言设置没有写到API模块的配置下,所以只能读文件读取Home模快的配置文件
+            $config = file_get_contents("./Application/Home/Conf/config.php");
 
-            if (D("Item")->count() < 1 && C("DEFAULT_LANG") == 'zh-cn' ) {
+            if (D("Item")->count() < 1 && strstr($config, "'zh-cn',") ) {
                 //如果项目表是空的,则生成系统示例项目
                 $this->_importSample(1);
             }
@@ -151,6 +157,16 @@ class UserController extends BaseController {
         }
         
         if ($ret) {
+            
+            //获取后台的语言设置
+            //这是个历史包袱。因为安装的时候语言设置没有写到API模块的配置下,所以只能读文件读取Home模快的配置文件
+            $config = file_get_contents("./Application/Home/Conf/config.php");
+
+            if (D("Item")->count() < 1 && strstr($config, "'zh-cn',") ) {
+                //如果项目表是空的,则生成系统示例项目
+                $this->_importSample(1);
+            }
+
           unset($ret['password']);
           session("login_user" , $ret );
           D("User")->setLastTime($ret['uid']);
@@ -195,6 +211,16 @@ class UserController extends BaseController {
             if ( ! D("User")->isExist($username) ) {
                 $new_uid = D("User")->register($username,$password);
                 if ($new_uid) {
+
+                    $create_sample = D("Options")->get("create_sample") ;
+                    //获取后台的语言设置
+                    //这是个历史包袱。因为安装的时候语言设置没有写到API模块的配置下,所以只能读文件读取Home模快的配置文件
+                    $config = file_get_contents("./Application/Home/Conf/config.php");
+                    if ($create_sample !== '0' && strstr($config, "'zh-cn',") ) {
+                        //导入示例项目
+                        $this->_importSample($new_uid);
+                    }
+
                     //设置自动登录
                     $ret = D("User")->where("uid = '$new_uid' ")->find() ;
                     unset($ret['password']);