This commit is contained in:
wangjinlei
2021-06-25 15:25:21 +08:00
parent 936978d35c
commit b8a94e91c7
2 changed files with 310 additions and 104 deletions

View File

@@ -800,9 +800,9 @@ class Article extends Controller {
$inset_data['user_id'] = $user_res['user_id'];
$inset_data['journal_id'] = $data['journal'];
$inset_data['editor_id'] = $journal_info['editor_id'];
$inset_data['title'] = $data['title'];
$inset_data['title'] = trim($data['title']);
$inset_data['keywords'] = $data['keyWords'];
$inset_data['fund'] = $data['fund'];
$inset_data['fund'] = trim($data['fund']);
$inset_data['accept_sn'] = getArticleSN($journal_info['abbr'],$data['type']);
$inset_data['type'] = $data['type'];
$inset_data['major_id'] = $data['major'];
@@ -820,14 +820,15 @@ class Article extends Controller {
continue;
}
$i['article_id'] = $res;
$i['firstname'] = $v['firstname'];
$i['lastname'] = $v['lastname'];
$i['company'] = $v['company'];
$i['department'] = $v['department'];
$i['firstname'] = trim($v['firstname']);
$i['lastname'] = trim($v['lastname']);
$i['orcid'] = trim($v['orcid']);
$i['company'] = trim($v['company']);
$i['department'] = trim($v['department']);
$i['author_title'] = $v['title'];
$i['country'] = $v['country'];
$i['email'] = $v['email'];
$i['address'] = $v['address'];
$i['email'] = trim($v['email']);
$i['address'] = trim($v['address']);
$i['is_super'] = $v['isSuper'] == 'true' ? 1 : 0;
$i['is_report'] = $v['isReport'] == 'true'?1:0;
$authors[] = $i;

View File

@@ -41,25 +41,24 @@ class User extends Controller {
public function checkLogin() {
$data = $this->request->post();
//判断是否管理员登录
if ($data['username'] == 'superadmin'||$data['username'] == 'wuxiongzhi2') {
if ($data['username'] == 'superadmin' || $data['username'] == 'wuxiongzhi2') {
$where_admin['account'] = $data['username'];
$where_admin['password'] = md5($data['password']);
$admin_info = $this->admin_obj->where($where_admin)->find();
if($admin_info==null){
return json(['code'=>1]);
}else{
if ($admin_info == null) {
return json(['code' => 1]);
} else {
$up_admin['last_login_time'] = time();
$up_admin['last_login_ip'] = $this->request->ip();
$this->admin_obj->where('admin_id = '.$admin_info['admin_id'])->update($up_admin);
return json(['code'=>0,'userinfo'=>$admin_info]);
$this->admin_obj->where('admin_id = ' . $admin_info['admin_id'])->update($up_admin);
return json(['code' => 0, 'userinfo' => $admin_info]);
}
} else {//用户登录
// $where['account'] = $data['username'];
// $where['password'] = md5($data['password']);
// $user_info = $this->user_obj->where($where)->find();
$user_info = $this->user_obj
->where('account|email',$data['username'])
->where('account|email', $data['username'])
->where('password', md5($data['password']))
->find();
if ($user_info == null) {//登陆失败
@@ -73,15 +72,25 @@ class User extends Controller {
}
}
/**
* 获取orcid
*/
public function checkOrcid() {
$data = $this->request->post();
$account = $data['account'];
$user = $this->user_obj->where('account', $account)->find();
return json(['code' => 0, 'userinfo' => $user]);
}
/**
* 根据account获取用户信息
*/
public function getUserdata() {
$account = $this->request->post('account');
$where['account'] = $account;
if($account=='superadmin'){
if ($account == 'superadmin') {
$res = $this->admin_obj->where($where)->find();
}else{
} else {
$res = $this->user_obj->where($where)->find();
}
if ($res == null) {
@@ -96,7 +105,7 @@ class User extends Controller {
*/
public function register() {
$data = $this->request->post();
//检测是否用户名和密码已经占用
//检测是否用户名和邮箱已经占用
$account = $data['username'];
$email = $data['email'];
$res_once = $this->user_obj->where("account='$account' or email = '$email'")->find();
@@ -120,13 +129,13 @@ class User extends Controller {
$tt = 'Hello,<br><br>';
$tt .= 'Your account has been created. You may check on the status of your manuscript using this submission and tracking system: https://submission.tmrjournals.com<br>';
$tt .= "Username:$account<br>";
$tt .= "Password:".$data['password'].'<br><br>';
$tt .= "Password:" . $data['password'] . '<br><br>';
$tt .= "Many thanks<br>TMR Publishing Group";
// $content = $tt . '<p>Username:' . $account . '<br>Password:' . $data['password'] . '</p>';
sendEmail($email, 'Dear ' . $data['name'], 'TMR', $tt,);
return json($inser_data);
}
// public function tttt(){
// echo 'dsss';
// }
@@ -191,7 +200,7 @@ class User extends Controller {
return json(['code' => 1, 'msg' => '验证码错误']);
}
$res = $this->user_obj
->where('account|email',$data['username'])
->where('account|email', $data['username'])
->find();
if ($res == null) {
return json(['code' => 1, 'msg' => '查无此人']);
@@ -248,73 +257,76 @@ class User extends Controller {
$mbcode = authcode($code);
return $nowcode == $mbcode ? true : false;
}
/**
* 获取审稿人列表
*/
public function getreviewerList(){
public function getreviewerList() {
$data = $this->request->post();
$limit_start = ($data['pageIndex']-1)*$data['pageSize'];
$limit_start = ($data['pageIndex'] - 1) * $data['pageSize'];
$where['t_user.is_reviewer'] = 1;
if($data['journalId']==0){
$subQuery = $this->user_obj->field('user_id')->where('account',$data['username'])->buildSql();
if ($data['journalId'] == 0) {
$subQuery = $this->user_obj->field('user_id')->where('account', $data['username'])->buildSql();
$journals = $this->journal_obj->where("editor_id in $subQuery")->column('journal_id');
$uids = $this->reviewer_to_journal_obj->where('journal_id','in',$journals)->column('reviewer_id');
$where['t_user.user_id'] = ['in',$uids];
}else{
$uids = $this->reviewer_to_journal_obj->where('journal_id',$data['journalId'])->column('reviewer_id');
$where['t_user.user_id'] = ['in',$uids];
$uids = $this->reviewer_to_journal_obj->where('journal_id', 'in', $journals)->column('reviewer_id');
$where['t_user.user_id'] = ['in', $uids];
} else {
$uids = $this->reviewer_to_journal_obj->where('journal_id', $data['journalId'])->column('reviewer_id');
$where['t_user.user_id'] = ['in', $uids];
}
$res = $this->user_obj->field('t_user.*,t_user_reviewer_info.*')->join('t_user_reviewer_info','t_user_reviewer_info.reviewer_id = t_user.user_id','LEFT')->where($where)->limit($limit_start,$data['pageSize'])->select();
$res = $this->user_obj->field('t_user.*,t_user_reviewer_info.*')->join('t_user_reviewer_info', 't_user_reviewer_info.reviewer_id = t_user.user_id', 'LEFT')->where($where)->limit($limit_start, $data['pageSize'])->select();
$total = $this->user_obj->where($where)->count();
if($res){
return json(['code'=>0,'data'=>$res,'total'=>$total]);
}else{
return json(['code'=>1]);
if ($res) {
return json(['code' => 0, 'data' => $res, 'total' => $total]);
} else {
return json(['code' => 1]);
}
}
/**
* 获取审核员申请列表
*/
public function getReviewerApplyList(){
public function getReviewerApplyList() {
$data = $this->request->post();
$limit_start = ($data['pageIndex']-1)*$data['pageSize'];
$limit_start = ($data['pageIndex'] - 1) * $data['pageSize'];
$where['state'] = 0;
if($data['journalId']==0){
$subQuery = $this->user_obj->field('user_id')->where('account',$data['username'])->buildSql();
if ($data['journalId'] == 0) {
$subQuery = $this->user_obj->field('user_id')->where('account', $data['username'])->buildSql();
$journals = $this->journal_obj->where("editor_id in $subQuery")->column('journal_id');
$where['journal_id'] = ['in',$journals];
}else{
$where['journal_id'] = ['in', $journals];
} else {
$where['journal_id'] = $data['journalId'];
}
$res = $this->user_reviewer_obj->where($where)->limit($limit_start,$data['pageSize'])->select();
$res = $this->user_reviewer_obj->where($where)->limit($limit_start, $data['pageSize'])->select();
$count = $this->user_reviewer_obj->where($where)->count();
return json(['total'=>$count,'data'=>$res]);
return json(['total' => $count, 'data' => $res]);
}
/**
* 获取申请详情
*/
public function getApplyDetail(){
public function getApplyDetail() {
$reviewerId = $this->request->post('reviewerId');
$where['t_user_reviewer_apply.reviewer_id'] = $reviewerId;
$res = $this->user_reviewer_obj->field('t_user_reviewer_apply.*,t_journal.title journal,t_reviewer_major.title major_title')->join('t_journal','t_journal.journal_id = t_user_reviewer_apply.journal_id','left')->join('t_reviewer_major','t_user_reviewer_apply.major = t_reviewer_major.major_id','LEFT')->where($where)->find();
if($res){
return json(['code'=>0,'data'=>$res]);
}else{
return json(['code'=>1]);
$res = $this->user_reviewer_obj->field('t_user_reviewer_apply.*,t_journal.title journal,t_reviewer_major.title major_title')->join('t_journal', 't_journal.journal_id = t_user_reviewer_apply.journal_id', 'left')->join('t_reviewer_major', 't_user_reviewer_apply.major = t_reviewer_major.major_id', 'LEFT')->where($where)->find();
if ($res) {
return json(['code' => 0, 'data' => $res]);
} else {
return json(['code' => 1]);
}
}
/**
* 通过审核人
*/
public function reviewerAdopt(){
public function reviewerAdopt() {
$reviewerId = $this->request->post('reviewerId');
$where['reviewer_id'] = $reviewerId;
$apply_info = $this->user_reviewer_obj->where($where)->find();
$journal_info = $this->journal_obj->where('journal_id',$apply_info['journal_id'])->find();
$has_res = $this->user_obj->where('account',$apply_info['name'])->find();
$journal_info = $this->journal_obj->where('journal_id', $apply_info['journal_id'])->find();
$has_res = $this->user_obj->where('account', $apply_info['name'])->find();
Db::startTrans();
if($has_res==null){
if ($has_res == null) {
$insert_data['account'] = $apply_info['name'];
$insert_data['password'] = md5('123456qwe');
$insert_data['email'] = $apply_info['email'];
@@ -333,11 +345,11 @@ class User extends Controller {
$insert_info['field'] = $apply_info['field'];
$insert_info['qualifications'] = $apply_info['qualifications'];
$addinfo_res = $this->user_reviewer_info_obj->insertGetId($insert_info);
$has_res = $this->user_obj->where('account',$apply_info['name'])->find();
}else{
$this->user_obj->where('user_id',$has_res['user_id'])->update(['is_reviewer'=>1]);
$cache_rev = $this->user_reviewer_info_obj->where('reviewer_id',$has_res['user_id'])->find();
if($cache_rev==null){
$has_res = $this->user_obj->where('account', $apply_info['name'])->find();
} else {
$this->user_obj->where('user_id', $has_res['user_id'])->update(['is_reviewer' => 1]);
$cache_rev = $this->user_reviewer_info_obj->where('reviewer_id', $has_res['user_id'])->find();
if ($cache_rev == null) {
$insert_info['reviewer_id'] = $has_res['user_id'];
$insert_info['gender'] = $apply_info['gender'];
$insert_info['technical'] = $apply_info['technical'];
@@ -359,97 +371,290 @@ class User extends Controller {
$insert_rtj['ctime'] = time();
$res = $this->reviewer_to_journal_obj->insert($insert_rtj);
//发送email
$content = "Thank you for registering as a ".$journal_info['title']." reviewer<br/>"
$content = "Thank you for registering as a " . $journal_info['title'] . " reviewer<br/>"
. "At present, you have passed our examination";
$content .= '<p>username:'.$apply_info['name'].'</p>';
$content .= $has_res?'':'<p>password:123456qwe</p>';
sendEmail($apply_info['email'],$journal_info['title'],$journal_info['title'], $content,$journal_info['email'],$journal_info['epassword']);
$update_res = $this->user_reviewer_obj->where($where)->update(['state'=>1]);
if($res && $add_res && $addinfo_res && $update_res){
$content .= '<p>username:' . $apply_info['name'] . '</p>';
$content .= $has_res ? '' : '<p>password:123456qwe</p>';
sendEmail($apply_info['email'], $journal_info['title'], $journal_info['title'], $content, $journal_info['email'], $journal_info['epassword']);
$update_res = $this->user_reviewer_obj->where($where)->update(['state' => 1]);
if ($res && $add_res && $addinfo_res && $update_res) {
Db::commit();
return json(['code'=>0]);
}else{
return json(['code' => 0]);
} else {
Db::rollback();
return json(['code'=>1]);
return json(['code' => 1]);
}
}
/**
* 获取用户消息
*/
public function getUserMsg(){
public function getUserMsg() {
//接收参数
$data = $this->request->post();
$user_info = $this->user_obj->where('account',$data['account'])->find();
$user_info = $this->user_obj->where('account', $data['account'])->find();
//查询msglist
$list = $this->user_msg_obj
->where('user_id',$user_info['user_id'])
->where('state',0)
->where('user_id', $user_info['user_id'])
->where('state', 0)
->order('user_msg_id desc')
->select();
return json($list);
}
/**
* 更改用户消息状态
*/
public function changeMsgState(){
public function changeMsgState() {
//接收参数
$id = $this->request->post('id');
$this->user_msg_obj
->where('user_msg_id',$id)
->update(['state'=>1]);
return json(['code'=>0]);
->where('user_msg_id', $id)
->update(['state' => 1]);
return json(['code' => 0]);
}
/**
* 审核人审查去重
*/
public function checkReviewer(){
public function checkReviewer() {
$username = $this->request->post('username');
$userres = $this->user_obj->where('account',$username)->find();
$applyres= $this->user_reviewer_obj->where("name = '$username' and state <> 2")->find();
if($applyres||$userres){
return json(['code'=>1]);
}else{
return json(['code'=>0]);
$userres = $this->user_obj->where('account', $username)->find();
$applyres = $this->user_reviewer_obj->where("name = '$username' and state <> 2")->find();
if ($applyres || $userres) {
return json(['code' => 1]);
} else {
return json(['code' => 0]);
}
}
/**
* 拒绝审核人
*/
public function reviewerRejec(){
public function reviewerRejec() {
$reviewerId = $this->request->post('reviewerId');
$where['reviewer_id'] = $reviewerId;
$this->user_reviewer_obj->where($where)->update(['state'=>2]);
$this->user_reviewer_obj->where($where)->update(['state' => 2]);
//拒绝审稿人email-》审稿人
return json(['code'=>0]);
return json(['code' => 0]);
}
/**
* 获取专业列表
*/
public function getMajorList(){
public function getMajorList() {
$res = $this->reviewer_major_obj->select();
return json(['code'=>0,'data'=>$res]);
return json(['code' => 0, 'data' => $res]);
}
/**
* 测试发邮件
* orcid登陆
*/
public function test_email() {
$email = '751475802@qq.com';
$title = 'Dear ' . '王金磊';
$tt = config('email_hello');
$content = $tt . '<p>Username:wangjinlei<br>Password:29698073</p>';
$res = sendEmail($email, $title, 'TMR', $content,);
public function OrcidLogin() {
$data = $this->request->post();
$url = 'https://orcid.org/oauth/token';
$param['client_id'] = "APP-PKF0BGRP6DWM6FUB";
$param['client_secret'] = "755a0e59-9282-44d0-afb4-ef9771942bab";
$param['grant_type'] = "authorization_code";
$param['code'] = $data['code'];
$param['redirect_uri'] = "https://submission.tmrjournals.com/orcidLink";
$res = $this->myUrl($url, $param);
$r = json_decode($res);
//确定用户是否存在
$user = $this->user_obj->where('orcid', $r->orcid)->find();
if ($user == null) {
Cache::set($r->orcid, $res, 3600);
}
$re['user'] = $user;
$re['orcid'] = $r->orcid;
return jsonSuccess($re);
}
/**
* 登陆后绑定orcid账号
*/
public function OrcidBinding(){
$data = $this->request->post();
$url = 'https://orcid.org/oauth/token';
$param['client_id'] = "APP-PKF0BGRP6DWM6FUB";
$param['client_secret'] = "755a0e59-9282-44d0-afb4-ef9771942bab";
$param['grant_type'] = "authorization_code";
$param['code'] = $data['code'];
$param['redirect_uri'] = "https://submission.tmrjournals.com/orcidBind";
$res = $this->myUrl($url, $param);
$r = json_decode($res);
$update['orcid'] = $r->orcid;
$update['orcid_code'] = $res;
$this->user_obj->where('account',$data['account'])->update($update);
return jsonSuccess([]);
}
/**
* 绑定orcid到系统内的用户
*/
public function orcidBind() {
$data = $this->request->post();
//确定系统内部有此账户
$serch['account'] = trim($data['username']);
$serch['password'] = md5($data['password']);
$user_info = $this->user_obj->where($serch)->find();
if ($user_info == null) {
return jsonError('The account does not exist or the password is wrong!');
}
$cache = Cache::get($data['orcid']);
if (!$cache) {
return jsonError('To complete the operation within one hour after verification, you have timed out');
}
$orcid_obj = $this->object2array(json_decode($cache));
$update['orcid'] = $orcid_obj['orcid'];
$update['orcid_code'] = $cache;
$this->user_obj->where('user_id', $user_info['user_id'])->update($update);
$new_info = $this->user_obj->where('user_id', $user_info['user_id'])->find();
$re['user'] = $new_info;
return jsonSuccess($re);
}
/**
* 注册绑定orcid至我们的账户
*/
public function orcidRegister() {
$data = $this->request->post();
$cache = Cache::get($data['orcid']);
$res = $this->object2array(json_decode($cache));
$insert['account'] = trim($data['username']);
$insert['password'] = md5($data['password']);
$insert['realname'] = trim($data['name']);
$insert['phone'] = trim($data['phone']);
$insert['email'] = trim($data['email']);
$insert['orcid'] = $res['orcid'];
$insert['orcid_code'] = $cache;
$insert['ctime'] = time();
$id = $this->user_obj->insertGetId($insert);
$user_info = $this->user_obj->where('user_id', $id)->find();
$re['user'] = $user_info;
return jsonSuccess($re);
}
/**
* 获取用户为了绑定orcid
*/
// public function getUserForOrcid(){
// $data = $this->request->post();
// $url = 'https://orcid.org/oauth/token';
// $param['client_id'] = "APP-PKF0BGRP6DWM6FUB";
// $param['client_secret'] = "755a0e59-9282-44d0-afb4-ef9771942bab";
// $param['grant_type'] = "authorization_code";
// $param['code'] = $data['code'];
// $param['redirect_uri'] = "https://www.tmrjournals.com";
// $res = $this->myUrl($url, $param);
// $res1 = json_decode($res);
// $orcidID = $res1->orcid;
// $update['orcid'] = $orcidID;
// $update['orcid_code'] = $res;
// $this->user_obj->where('account',$data['account'])->update($update);
// return json(['code' => 0]);
// }
/**
* 授权码转化成令牌,并存贮
* object(stdClass)#31 (7) {
["access_token"]=>
string(36) "28924261-b2a9-4ed0-952c-e2647843d1ba"
["token_type"]=>
string(6) "bearer"
["refresh_token"]=>
string(36) "ef66ffc7-1004-4d10-abe4-bdede248af47"
["expires_in"]=>
int(631138518)
["scope"]=>
string(13) "/authenticate"
["name"]=>
string(8) "Nuoxi Pi"
["orcid"]=>
string(19) "0000-0003-3278-0964"
}
*/
public function sq_to_lp(){
$url = 'https://orcid.org/oauth/token';
$param['client_id'] = "APP-PKF0BGRP6DWM6FUB";
$param['client_secret'] = "755a0e59-9282-44d0-afb4-ef9771942bab";
$param['grant_type'] = "authorization_code";
$param['code'] = "7wv2wR";
$param['redirect_uri'] = "https://www.tmrjournals.com";
$res = $this->myUrl($url, $param);
$r = json_decode($res);
echo $r->orcid;
}
private function myUrl($url, $param) {
$header = array('Accept: application/json', 'Content-type:application/x-www-form-urlencoded');
$pp = http_build_query($param);
$httph = curl_init($url);
curl_setopt($httph, CURLOPT_AUTOREFERER, true);
curl_setopt($httph, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($httph, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($httph, CURLOPT_RETURNTRANSFER, true);
curl_setopt($httph, CURLOPT_POST, true); //设置为POST方式
curl_setopt($httph, CURLOPT_POSTFIELDS, $pp);
curl_setopt($httph, CURLOPT_HTTPHEADER, $header);
$rst = curl_exec($httph);
curl_close($httph);
return $rst;
}
/**
* 项目转数组
*/
private function object2array($object) {
if (is_object($object)) {
foreach ($object as $key => $value) {
$array[$key] = $value;
}
} else {
$array = $object;
}
return $array;
}
/**
* curl -i -H "Accept: application/vnd.orcid+xml" -H 'Authorization: Bearer dd91868d-d29a-475e-9acb-bd3fdf2f43f4' 'https://api.sandbox.orcid.org/v2.1/0000-0002-9227-8514/education/22423'
*/
public function geturl() {
// $url = "https://api.orcid.org/v3.0/0000-0003-3278-0964/record";
$url = "https://pub.orcid.org/v3.0/expanded-search/?q=0000-0003-3440-7901";
$headerArray = array("Content-type: application/vnd.orcid+json", "Authorization: Bearer 28924261-b2a9-4ed0-952c-e2647843d1ba");
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headerArray);
$output = curl_exec($ch);
$err = curl_error($ch);
curl_close($ch);
$output = json_decode($output, true);
echo '<pre>';
var_dump($res);
var_dump($output);
echo '</pre>';
echo '<pre>';
var_dump($err);
echo '</pre>';
die;
die;
// return $output;
}
}