mirror of https://gitee.com/karson/fastadmin.git
新增dataLimitFieldAutoFill属性
新增管理员的selectpage接口 新增前台Auth的ucenter同步登录注册登出接口 新增前台User控制器的ucenter插件判断 优化Sms::notice发送通知的方法 优化common-search回调事件pull/34/head
parent
46f67fc974
commit
5f80d65e27
|
|
@ -1251,7 +1251,6 @@ EOD;
|
|||
{
|
||||
$html .= ", searchList: " . $searchList;
|
||||
}
|
||||
echo $datatype, "\n";
|
||||
if (in_array($datatype, ['date', 'datetime']) || $formatter === 'datetime')
|
||||
{
|
||||
$html .= ", operate:'RANGE', addclass:'datetimerange'";
|
||||
|
|
|
|||
|
|
@ -61,6 +61,11 @@ class Admin extends Backend
|
|||
{
|
||||
if ($this->request->isAjax())
|
||||
{
|
||||
//如果发送的来源是Selectpage,则转发到Selectpage
|
||||
if ($this->request->request('pkey_name'))
|
||||
{
|
||||
return $this->selectpage();
|
||||
}
|
||||
$childrenGroupIds = $this->childrenGroupIds;
|
||||
$groupName = AuthGroup::where('id', 'in', $childrenGroupIds)
|
||||
->column('id,name');
|
||||
|
|
@ -246,4 +251,13 @@ class Admin extends Backend
|
|||
$this->error();
|
||||
}
|
||||
|
||||
/**
|
||||
* 下拉搜索
|
||||
*/
|
||||
protected function selectpage()
|
||||
{
|
||||
$this->dataLimit = 'auth';
|
||||
return parent::selectpage();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -78,14 +78,7 @@ trait Backend
|
|||
$params = $this->request->post("row/a");
|
||||
if ($params)
|
||||
{
|
||||
/*
|
||||
* 已经弃用,如果为了兼容老版可取消注释
|
||||
foreach ($params as $k => &$v)
|
||||
{
|
||||
$v = is_array($v) ? implode(',', $v) : $v;
|
||||
}
|
||||
*/
|
||||
if ($this->dataLimit)
|
||||
if ($this->dataLimit && $this->dataLimitFieldAutoFill)
|
||||
{
|
||||
$params[$this->dataLimitField] = $this->auth->id;
|
||||
}
|
||||
|
|
@ -139,13 +132,6 @@ trait Backend
|
|||
$params = $this->request->post("row/a");
|
||||
if ($params)
|
||||
{
|
||||
/*
|
||||
* 已经弃用,如果为了兼容老版可取消注释
|
||||
foreach ($params as $k => &$v)
|
||||
{
|
||||
$v = is_array($v) ? implode(',', $v) : $v;
|
||||
}
|
||||
*/
|
||||
try
|
||||
{
|
||||
//是否采用模型验证
|
||||
|
|
|
|||
|
|
@ -61,6 +61,11 @@ class Backend extends Controller
|
|||
* 数据限制字段
|
||||
*/
|
||||
protected $dataLimitField = 'admin_id';
|
||||
|
||||
/**
|
||||
* 数据限制开启时自动填充限制字段值
|
||||
*/
|
||||
protected $dataLimitFieldAutoFill = true;
|
||||
|
||||
/**
|
||||
* 是否开启Validate验证
|
||||
|
|
|
|||
|
|
@ -174,6 +174,23 @@ class Auth
|
|||
$params['password'] = $this->getEncryptPassword($password, $params['salt']);
|
||||
$params = array_merge($params, $extend);
|
||||
|
||||
////////////////同步到Ucenter////////////////
|
||||
if (defined('UC_STATUS') && UC_STATUS)
|
||||
{
|
||||
$uc = new \addons\ucenter\library\client\Client();
|
||||
$user_id = $uc->uc_user_register($username, $password, $email);
|
||||
// 如果小于0则说明发生错误
|
||||
if ($user_id <= 0)
|
||||
{
|
||||
$this->setError($user_id > -4 ? 'Username is incorrect' : 'Email is incorrect');
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
$params['id'] = $user_id;
|
||||
}
|
||||
}
|
||||
|
||||
//账号注册时需要开启事务,避免出现垃圾数据
|
||||
Db::startTrans();
|
||||
try
|
||||
|
|
@ -299,9 +316,22 @@ class Auth
|
|||
$user = User::get($user_id);
|
||||
if ($user)
|
||||
{
|
||||
////////////////同步到Ucenter////////////////
|
||||
if (defined('UC_STATUS') && UC_STATUS)
|
||||
{
|
||||
$uc = new \addons\ucenter\library\client\Client();
|
||||
$re = $uc->uc_user_login($this->user->id, $this->user->password . '#split#' . $this->user->salt, 3);
|
||||
// 如果小于0则说明发生错误
|
||||
if ($re <= 0)
|
||||
{
|
||||
$this->setError('Username or password is incorrect');
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
$ip = request()->ip();
|
||||
$time = time();
|
||||
|
||||
|
||||
//判断连续登录和最大连续登录
|
||||
if ($user->logintime < \fast\Date::unixtime('day'))
|
||||
{
|
||||
|
|
@ -320,7 +350,7 @@ class Auth
|
|||
|
||||
$this->_token = Random::uuid();
|
||||
Token::set($this->_token, $user->id);
|
||||
|
||||
|
||||
$this->_logined = TRUE;
|
||||
|
||||
//登录成功的事件
|
||||
|
|
@ -454,6 +484,19 @@ class Auth
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
////////////////同步到Ucenter////////////////
|
||||
if (defined('UC_STATUS') && UC_STATUS)
|
||||
{
|
||||
$uc = new \addons\ucenter\library\client\Client();
|
||||
$re = $uc->uc_user_delete($user['id']);
|
||||
// 如果小于0则说明发生错误
|
||||
if ($re <= 0)
|
||||
{
|
||||
$this->setError('Account is locked');
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
// 调用事务删除账号
|
||||
$result = Db::transaction(function($db) use($user_id) {
|
||||
// 删除会员
|
||||
|
|
|
|||
|
|
@ -64,11 +64,18 @@ class Sms
|
|||
/**
|
||||
* 发送通知
|
||||
*
|
||||
* @param array $params 参数
|
||||
* @param mixed $mobile 手机号,多个以,分隔
|
||||
* @param string $msg 消息内容
|
||||
* @param string $template 消息模板
|
||||
* @return boolean
|
||||
*/
|
||||
public static function notice($params = [])
|
||||
public static function notice($mobile, $msg = '', $template = NULL)
|
||||
{
|
||||
$params = [
|
||||
'mobile' => $mobile,
|
||||
'msg' => $msg,
|
||||
'template' => $template
|
||||
];
|
||||
$result = Hook::listen('sms_notice', $params, null, true);
|
||||
return $result ? TRUE : FALSE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,6 +23,12 @@ class User extends Frontend
|
|||
parent::_initialize();
|
||||
$auth = $this->auth;
|
||||
|
||||
$ucenter = get_addon_info('ucenter');
|
||||
if ($ucenter && $ucenter['state'])
|
||||
{
|
||||
include ADDON_PATH . 'ucenter' . DS . 'uc.php';
|
||||
}
|
||||
|
||||
//监听注册登录注销的事件
|
||||
Hook::add('user_login_successed', function($user) use($auth) {
|
||||
Cookie::set('uid', $user->id);
|
||||
|
|
@ -109,8 +115,7 @@ class User extends Frontend
|
|||
$uc = new \addons\ucenter\library\client\Client();
|
||||
$synchtml = $uc->uc_user_synregister($this->auth->id, $password);
|
||||
}
|
||||
$referer = Cookie::get('referer_url');
|
||||
$this->success(__('Sign up successful') . $synchtml, $referer);
|
||||
$this->success(__('Sign up successful') . $synchtml, $url);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -96,6 +96,7 @@ return [
|
|||
'Donation' => '捐赠',
|
||||
'Forum' => '社区',
|
||||
'Docs' => '文档',
|
||||
'Please login first' => '请登录后再操作',
|
||||
'Send verification code' => '发磅验证码',
|
||||
'Redirect now' => '立即跳转',
|
||||
'Operation completed' => '操作成功!',
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ return [
|
|||
'Account can not be empty' => '账户不能为空',
|
||||
'Username or password is incorrect' => '用户名或密码不正确',
|
||||
'You are not logged in' => '你当前还未登录',
|
||||
'You\'ve logged in, do not login again' => '你已经存在,请不要重复登录',
|
||||
'You\'ve logged in, do not login again' => '你已经登录,请不要重复登录',
|
||||
'Profile' => '个人资料',
|
||||
'Old password' => '旧密码',
|
||||
'New password' => '新密码',
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
<div class="user-section login-section">
|
||||
<div class="logon-tab clearfix"> <a href="{:url('user/login')}">{:__('Sign in')}</a> <a class="active">{:__('Sign up')}</a> </div>
|
||||
<div class="login-main">
|
||||
<form name="form1" id="login-form" class="form-vertical" method="POST" action="">
|
||||
<form name="form1" id="register-form" class="form-vertical" method="POST" action="">
|
||||
<input type="hidden" name="invite_user_id" value="0" />
|
||||
<div class="form-group">
|
||||
<label class="control-label required">{:__('Email')}<span class="text-success"></span></label>
|
||||
|
|
@ -21,7 +21,7 @@
|
|||
<div class="form-group">
|
||||
<label class="control-label">{:__('Password')}</label>
|
||||
<div class="controls">
|
||||
<input type="password" id="repassword" name="repassword" required class="form-control input-lg" placeholder="{:__('Password must be 6 to 30 characters')}">
|
||||
<input type="password" id="password" name="password" required class="form-control input-lg" placeholder="{:__('Password must be 6 to 30 characters')}">
|
||||
<p class="help-block"></p>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -261,8 +261,9 @@
|
|||
var getQueryParams = function (params, searchQuery, removeempty) {
|
||||
params.filter = typeof params.filter === 'Object' ? params.filter : (params.filter ? JSON.parse(params.filter) : {});
|
||||
params.op = typeof params.op === 'Object' ? params.op : (params.op ? JSON.parse(params.op) : {});
|
||||
params.filter = $.extend(params.filter, searchQuery.filter);
|
||||
params.op = $.extend(params.op, searchQuery.op);
|
||||
|
||||
params.filter = $.extend({}, params.filter, searchQuery.filter);
|
||||
params.op = $.extend({}, params.op, searchQuery.op);
|
||||
//移除empty的值
|
||||
if (removeempty) {
|
||||
$.each(params.filter, function (i, j) {
|
||||
|
|
@ -366,12 +367,10 @@
|
|||
$("form", that.$commonsearch).trigger("submit");
|
||||
}
|
||||
});
|
||||
var searchQuery = getSearchQuery(that, true);
|
||||
var queryParams = that.options.queryParams;
|
||||
//匹配默认搜索值
|
||||
this.options.queryParams = function (params) {
|
||||
var params = getQueryParams(queryParams(params), searchQuery);
|
||||
return params;
|
||||
return queryParams(getQueryParams(params, getSearchQuery(this, true)));
|
||||
};
|
||||
this.trigger('post-common-search', that);
|
||||
|
||||
|
|
@ -379,13 +378,9 @@
|
|||
|
||||
BootstrapTable.prototype.onCommonSearch = function () {
|
||||
var searchQuery = getSearchQuery(this);
|
||||
var params = getQueryParams(this.options.queryParams({}), searchQuery, true);
|
||||
this.trigger('common-search', this, params, searchQuery);
|
||||
this.trigger('common-search', this, searchQuery);
|
||||
this.options.pageNumber = 1;
|
||||
this.options.queryParams = function (options) {
|
||||
return $.extend({}, options, params);
|
||||
};
|
||||
this.refresh({query: params});
|
||||
this.refresh({});
|
||||
};
|
||||
|
||||
BootstrapTable.prototype.load = function (data) {
|
||||
|
|
|
|||
|
|
@ -9346,8 +9346,9 @@ return d.keepInvalid=a,l},l.datepickerInput=function(a){if(0===arguments.length)
|
|||
var getQueryParams = function (params, searchQuery, removeempty) {
|
||||
params.filter = typeof params.filter === 'Object' ? params.filter : (params.filter ? JSON.parse(params.filter) : {});
|
||||
params.op = typeof params.op === 'Object' ? params.op : (params.op ? JSON.parse(params.op) : {});
|
||||
params.filter = $.extend(params.filter, searchQuery.filter);
|
||||
params.op = $.extend(params.op, searchQuery.op);
|
||||
|
||||
params.filter = $.extend({}, params.filter, searchQuery.filter);
|
||||
params.op = $.extend({}, params.op, searchQuery.op);
|
||||
//移除empty的值
|
||||
if (removeempty) {
|
||||
$.each(params.filter, function (i, j) {
|
||||
|
|
@ -9451,12 +9452,10 @@ return d.keepInvalid=a,l},l.datepickerInput=function(a){if(0===arguments.length)
|
|||
$("form", that.$commonsearch).trigger("submit");
|
||||
}
|
||||
});
|
||||
var searchQuery = getSearchQuery(that, true);
|
||||
var queryParams = that.options.queryParams;
|
||||
//匹配默认搜索值
|
||||
this.options.queryParams = function (params) {
|
||||
var params = getQueryParams(queryParams(params), searchQuery);
|
||||
return params;
|
||||
return queryParams(getQueryParams(params, getSearchQuery(this, true)));
|
||||
};
|
||||
this.trigger('post-common-search', that);
|
||||
|
||||
|
|
@ -9464,13 +9463,9 @@ return d.keepInvalid=a,l},l.datepickerInput=function(a){if(0===arguments.length)
|
|||
|
||||
BootstrapTable.prototype.onCommonSearch = function () {
|
||||
var searchQuery = getSearchQuery(this);
|
||||
var params = getQueryParams(this.options.queryParams({}), searchQuery, true);
|
||||
this.trigger('common-search', this, params, searchQuery);
|
||||
this.trigger('common-search', this, searchQuery);
|
||||
this.options.pageNumber = 1;
|
||||
this.options.queryParams = function (options) {
|
||||
return $.extend({}, options, params);
|
||||
};
|
||||
this.refresh({query: params});
|
||||
this.refresh({});
|
||||
};
|
||||
|
||||
BootstrapTable.prototype.load = function (data) {
|
||||
|
|
@ -9810,7 +9805,7 @@ define('table',['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstr
|
|||
require(['dragsort'], function () {
|
||||
//绑定拖动排序
|
||||
$("tbody", table).dragsort({
|
||||
itemSelector: 'tr',
|
||||
itemSelector: 'tr:visible',
|
||||
dragSelector: "a.btn-dragsort",
|
||||
dragEnd: function () {
|
||||
var data = table.bootstrapTable('getData');
|
||||
|
|
@ -14501,7 +14496,7 @@ define("addtabs", function(){});
|
|||
} else {
|
||||
data = returnData;
|
||||
}
|
||||
self.afterInit(self, data.list);
|
||||
self.afterInit(self, typeof data.rows !== 'undefined' ? data.rows : (typeof data.list !== 'undefined' ? data.list : []));
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
self.ajaxErrorNotify(self, errorThrown);
|
||||
|
|
@ -15135,7 +15130,7 @@ define("addtabs", function(){});
|
|||
|
||||
//数据结构处理
|
||||
var json = {};
|
||||
json.originalResult = data.list;
|
||||
json.originalResult = typeof data.rows !== 'undefined' ? data.rows : (typeof data.list !== 'undefined' ? data.list : []);
|
||||
json.cnt_whole = typeof data.total !== 'undefined' ? data.total : (typeof data.totalRow !== 'undefined' ? data.totalRow : data.list.length);
|
||||
|
||||
json.candidate = [];
|
||||
|
|
|
|||
Loading…
Reference in New Issue