mirror of
https://github.com/bs-community/blessing-skin-server.git
synced 2024-12-09 06:00:31 +08:00
add menu item for importing data from v2
This commit is contained in:
parent
86d82931bb
commit
ab4c72184a
@ -190,11 +190,21 @@ class Closet
|
||||
return ! Texture::where('tid', $tid)->isEmpty();
|
||||
}
|
||||
|
||||
private function save()
|
||||
/**
|
||||
* Set textures string manually.
|
||||
*
|
||||
* @param string $textures
|
||||
*/
|
||||
public function setTextures($textures)
|
||||
{
|
||||
return $this->db->where('uid', $this->uid)->update(['textures' => $textures]);;
|
||||
}
|
||||
|
||||
public function save()
|
||||
{
|
||||
if (empty($this->items_modified)) return;
|
||||
|
||||
$this->db->where('uid', $this->uid)->update(['textures' => json_encode($this->textures)]);
|
||||
return $this->setTextures(json_encode($this->textures));
|
||||
}
|
||||
|
||||
public function __destruct()
|
||||
|
@ -23,6 +23,7 @@ $menu['admin'] = array(
|
||||
['title' => 'general.customize', 'link' => 'admin/customize', 'icon' => 'fa-paint-brush'],
|
||||
['title' => 'general.score-options', 'link' => 'admin/score', 'icon' => 'fa-credit-card'],
|
||||
['title' => 'general.options', 'link' => 'admin/options', 'icon' => 'fa-cog'],
|
||||
['title' => 'general.import-v2', 'link' => 'setup/migrations', 'icon' => 'fa-undo'],
|
||||
['title' => 'general.check-update', 'link' => 'admin/update', 'icon' => 'fa-arrow-up']
|
||||
);
|
||||
|
||||
|
@ -18,6 +18,7 @@ user-manage: User Manage
|
||||
generate-config: Generate Config
|
||||
customize: Customize
|
||||
options: Options
|
||||
import-v2: Import Data
|
||||
score-options: Score Options
|
||||
check-update: Check Update
|
||||
download-update: Download Updates
|
||||
|
@ -18,6 +18,7 @@ user-manage: 用户管理
|
||||
generate-config: 配置生成
|
||||
customize: 个性化
|
||||
options: 站点配置
|
||||
import-v2: 导入数据
|
||||
score-options: 积分配置
|
||||
check-update: 检查更新
|
||||
download-update: 下载更新
|
||||
|
@ -3,12 +3,12 @@
|
||||
* @Author: printempw
|
||||
* @Date: 2016-08-18 17:46:19
|
||||
* @Last Modified by: printempw
|
||||
* @Last Modified time: 2016-09-14 19:44:05
|
||||
* @Last Modified time: 2016-10-16 20:23:12
|
||||
*/
|
||||
|
||||
use App\Models\UserModel;
|
||||
use App\Models\PlayerModel;
|
||||
use App\Models\ClosetModel;
|
||||
use App\Models\Player;
|
||||
use App\Models\Closet;
|
||||
use App\Models\Texture;
|
||||
|
||||
if (!defined('BASE_DIR')) exit('Permission denied.');
|
||||
@ -45,7 +45,7 @@ for ($i = 0; $i <= $steps; $i++) {
|
||||
// compile patterns
|
||||
$name = str_replace('{username}', $row['username'], $_POST['texture_name_pattern']);
|
||||
|
||||
if (PlayerModel::where('player_name', $row['username'])->get()->isEmpty()) {
|
||||
if (Player::where('player_name', $row['username'])->get()->isEmpty()) {
|
||||
$user = new UserModel;
|
||||
|
||||
$user->email = '';
|
||||
@ -96,17 +96,14 @@ for ($i = 0; $i <= $steps; $i++) {
|
||||
}
|
||||
}
|
||||
|
||||
$p = new PlayerModel;
|
||||
$p = new Player;
|
||||
|
||||
$p->uid = $user->uid;
|
||||
$p->player_name = $row['username'];
|
||||
$p->preference = $row['preference'];
|
||||
$p->last_modified = $row['last_modified'] ? : Utils::getTimeFormatted();
|
||||
|
||||
$c = new ClosetModel;
|
||||
|
||||
$c->uid = $user->uid;
|
||||
$c->textures = '';
|
||||
$c = new Closet($user->uid);
|
||||
|
||||
$items = [];
|
||||
|
||||
@ -121,10 +118,7 @@ for ($i = 0; $i <= $steps; $i++) {
|
||||
);
|
||||
}
|
||||
|
||||
$c->textures = json_encode($items);
|
||||
|
||||
$p->save();
|
||||
$c->save();
|
||||
$c->setTextures(json_encode($items));
|
||||
|
||||
$user_imported++;
|
||||
// echo $row['username']." saved. <br />";
|
||||
|
Loading…
Reference in New Issue
Block a user