User.php 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810
  1. <?php
  2. namespace app\index\controller;
  3. use addons\wechat\model\WechatCaptcha;
  4. use app\admin\model\Admin;
  5. use app\admin\model\cms\AuthorManuscript;
  6. use app\admin\model\cms\Channel;
  7. use app\admin\model\cms\Comments;
  8. use app\admin\model\cms\InviteReviewer;
  9. use app\admin\model\cms\Participate;
  10. use app\admin\model\EmailContent;
  11. use app\common\controller\Frontend;
  12. use app\common\library\Ems;
  13. use app\common\library\Sms;
  14. use app\common\model\Attachment;
  15. use app\common\model\UserRoleContent;
  16. use app\common\model\UserRoleLog;
  17. use think\Config;
  18. use think\Cookie;
  19. use think\Hook;
  20. use think\Session;
  21. use think\Validate;
  22. /**
  23. * 会员中心
  24. */
  25. class User extends Frontend
  26. {
  27. protected $layout = 'default';
  28. protected $noNeedLogin = ['login', 'register', 'third', 'jump'];
  29. protected $noNeedRight = ['*'];
  30. public function _initialize()
  31. {
  32. parent::_initialize();
  33. $auth = $this->auth;
  34. if (!Config::get('fastadmin.usercenter')) {
  35. $this->error(__('User center already closed'), '/');
  36. }
  37. //监听注册登录退出的事件
  38. Hook::add('user_login_successed', function ($user) use ($auth) {
  39. $expire = input('post.keeplogin') ? 30 * 86400 : 0;
  40. Cookie::set('uid', $user->id, $expire);
  41. Cookie::set('token', $auth->getToken(), $expire);
  42. });
  43. Hook::add('user_register_successed', function ($user) use ($auth) {
  44. Cookie::set('uid', $user->id);
  45. Cookie::set('token', $auth->getToken());
  46. });
  47. Hook::add('user_delete_successed', function ($user) use ($auth) {
  48. Cookie::delete('uid');
  49. Cookie::delete('token');
  50. });
  51. Hook::add('user_logout_successed', function ($user) use ($auth) {
  52. Cookie::delete('uid');
  53. Cookie::delete('token');
  54. });
  55. }
  56. /**
  57. * 会员中心
  58. */
  59. public function index()
  60. {
  61. $this->view->assign('title', __('User center'));
  62. return $this->view->fetch();
  63. }
  64. /**
  65. * 注册会员
  66. */
  67. public function register()
  68. {
  69. $url = $this->request->request('url', '', 'trim');
  70. if ($this->auth->id) {
  71. $this->success('You\'ve logged in, do not login again', $url ? $url : url('user/index'));
  72. }
  73. if ($this->request->isPost()) {
  74. $username = $this->request->post('username');
  75. $password = $this->request->post('password');
  76. $password_confirm = $this->request->post('password_confirm');
  77. // 判断密码是否一致
  78. if ($password != $password_confirm) {
  79. $this->error('Inconsistent password input', null, ['token' => $this->request->token()]);
  80. }
  81. $email = $this->request->post('email');
  82. $mobile = $this->request->post('mobile', '');
  83. $token = $this->request->post('__token__');
  84. $rule = [
  85. 'username' => 'require|length:3,30',
  86. 'password' => 'require|length:6,30',
  87. '__token__' => 'require|token',
  88. ];
  89. $msg = [
  90. 'username.require' => 'Username can not be empty',
  91. 'username.length' => 'Username must be 3 to 30 characters',
  92. 'password.require' => 'Password can not be empty',
  93. 'password.length' => 'Password must be 6 to 30 characters',
  94. ];
  95. $data = [
  96. 'username' => $username,
  97. 'password' => $password,
  98. 'email' => $email,
  99. 'mobile' => $mobile,
  100. '__token__' => $token,
  101. ];
  102. $validate = new Validate($rule, $msg);
  103. $result = $validate->check($data);
  104. if (!$result) {
  105. $this->error($validate->getError(), null, ['token' => $this->request->token()]);
  106. }
  107. if ($this->auth->register($username, $password)) {
  108. $this->success('Registration successful, please go to the corresponding email to check and verify', $url ? $url : url('user/login'));
  109. } else {
  110. $this->error($this->auth->getError(), null, ['token' => $this->request->token()]);
  111. }
  112. }
  113. //判断来源
  114. $referer = $this->request->server('HTTP_REFERER');
  115. if (!$url && (strtolower(parse_url($referer, PHP_URL_HOST)) == strtolower($this->request->host()))
  116. && !preg_match("/(user\/login|user\/register|user\/logout)/i", $referer)) {
  117. $url = $referer;
  118. }
  119. $this->view->assign('url', $url);
  120. $this->view->assign('title', 'Register');
  121. return $this->view->fetch();
  122. }
  123. /**
  124. * 会员登录
  125. */
  126. public function login()
  127. {
  128. $url = $this->request->request('url', '', 'trim');
  129. if ($this->auth->id) {
  130. $this->success('You\'ve logged in, do not login again', $url ? $url : url('user/index'));
  131. }
  132. if ($this->request->isPost()) {
  133. $account = $this->request->post('account');
  134. $password = $this->request->post('password');
  135. $keeplogin = (int)$this->request->post('keeplogin');
  136. $token = $this->request->post('__token__');
  137. $rule = [
  138. 'account' => 'require|length:3,50',
  139. 'password' => 'require|length:6,30',
  140. '__token__' => 'require|token',
  141. ];
  142. $msg = [
  143. 'account.require' => 'Account can not be empty',
  144. 'account.length' => 'Account must be 3 to 50 characters',
  145. 'password.require' => 'Password can not be empty',
  146. 'password.length' => 'Password must be 6 to 30 characters',
  147. ];
  148. $data = [
  149. 'account' => $account,
  150. 'password' => $password,
  151. '__token__' => $token,
  152. ];
  153. $validate = new Validate($rule, $msg);
  154. $result = $validate->check($data);
  155. if (!$result) {
  156. $this->error(__($validate->getError()), null, ['token' => $this->request->token()]);
  157. return false;
  158. }
  159. if ($this->auth->login($account, $password)) {
  160. // $this->success('Logged in successful', $url ? $url : url('user/index'));
  161. $this->success('Logged in successful', url('/'));
  162. } else {
  163. $this->error($this->auth->getError(), null, ['token' => $this->request->token()]);
  164. }
  165. }
  166. //判断来源
  167. $referer = $this->request->server('HTTP_REFERER');
  168. if (!$url && (strtolower(parse_url($referer, PHP_URL_HOST)) == strtolower($this->request->host()))
  169. && !preg_match("/(user\/login|user\/register|user\/logout)/i", $referer)) {
  170. $url = $referer;
  171. }
  172. $this->view->assign('url', $url);
  173. $this->view->assign('title', __('Login'));
  174. return $this->view->fetch();
  175. }
  176. /**
  177. * 退出登录
  178. */
  179. public function logout()
  180. {
  181. if ($this->request->isPost()) {
  182. $this->token();
  183. //退出本站
  184. $this->auth->logout();
  185. // $this->success(__('Logout successful'), url('user/index'));
  186. // $this->success('Logout successful', url('/'));
  187. $this->redirect(url('user/jump'));
  188. }
  189. $html = "<form id='logout_submit' name='logout_submit' action='' method='post'>" . token() . "<input type='submit' value='ok' style='display:none;'></form>";
  190. $html .= "<script>document.forms['logout_submit'].submit();</script>";
  191. return $html;
  192. }
  193. /**
  194. * 退出登录
  195. *
  196. * @return string
  197. * @throws \think\Exception
  198. */
  199. public function jump()
  200. {
  201. $this->view->assign('title', 'Logout out');
  202. return $this->view->fetch();
  203. }
  204. /**
  205. * 个人信息
  206. */
  207. public function profile()
  208. {
  209. $this->view->assign('title', __('Profile'));
  210. return $this->view->fetch();
  211. }
  212. /**
  213. * 修改密码
  214. */
  215. public function changepwd()
  216. {
  217. if ($this->request->isPost()) {
  218. $oldpassword = $this->request->post("oldpassword");
  219. $newpassword = $this->request->post("newpassword");
  220. $renewpassword = $this->request->post("renewpassword");
  221. $token = $this->request->post('__token__');
  222. $rule = [
  223. 'oldpassword' => 'require|regex:\S{6,30}',
  224. 'newpassword' => 'require|regex:\S{6,30}',
  225. 'renewpassword' => 'require|regex:\S{6,30}|confirm:newpassword',
  226. '__token__' => 'token',
  227. ];
  228. $msg = [
  229. 'renewpassword.confirm' => __('Password and confirm password don\'t match')
  230. ];
  231. $data = [
  232. 'oldpassword' => $oldpassword,
  233. 'newpassword' => $newpassword,
  234. 'renewpassword' => $renewpassword,
  235. '__token__' => $token,
  236. ];
  237. $field = [
  238. 'oldpassword' => __('Old password'),
  239. 'newpassword' => __('New password'),
  240. 'renewpassword' => __('Renew password')
  241. ];
  242. $validate = new Validate($rule, $msg, $field);
  243. $result = $validate->check($data);
  244. if (!$result) {
  245. $this->error(__($validate->getError()), null, ['token' => $this->request->token()]);
  246. return false;
  247. }
  248. $ret = $this->auth->changepwd($newpassword, $oldpassword);
  249. if ($ret) {
  250. $this->success(__('Reset password successful'), url('user/login'));
  251. } else {
  252. $this->error($this->auth->getError(), null, ['token' => $this->request->token()]);
  253. }
  254. }
  255. $this->view->assign('title', __('Change password'));
  256. return $this->view->fetch();
  257. }
  258. public function attachment()
  259. {
  260. //设置过滤方法
  261. $this->request->filter(['strip_tags']);
  262. if ($this->request->isAjax()) {
  263. $mimetypeQuery = [];
  264. $where = [];
  265. $filter = $this->request->request('filter');
  266. $filterArr = (array)json_decode($filter, true);
  267. if (isset($filterArr['mimetype']) && preg_match("/(\/|\,|\*)/", $filterArr['mimetype'])) {
  268. $this->request->get(['filter' => json_encode(array_diff_key($filterArr, ['mimetype' => '']))]);
  269. $mimetypeQuery = function ($query) use ($filterArr) {
  270. $mimetypeArr = array_filter(explode(',', $filterArr['mimetype']));
  271. foreach ($mimetypeArr as $index => $item) {
  272. $query->whereOr('mimetype', 'like', '%' . str_replace("/*", "/", $item) . '%');
  273. }
  274. };
  275. } elseif (isset($filterArr['mimetype'])) {
  276. $where['mimetype'] = ['like', '%' . $filterArr['mimetype'] . '%'];
  277. }
  278. if (isset($filterArr['filename'])) {
  279. $where['filename'] = ['like', '%' . $filterArr['filename'] . '%'];
  280. }
  281. if (isset($filterArr['createtime'])) {
  282. $timeArr = explode(' - ', $filterArr['createtime']);
  283. $where['createtime'] = ['between', [strtotime($timeArr[0]), strtotime($timeArr[1])]];
  284. }
  285. $search = $this->request->get('search');
  286. if ($search) {
  287. $where['filename'] = ['like', '%' . $search . '%'];
  288. }
  289. $model = new Attachment();
  290. $offset = $this->request->get("offset", 0);
  291. $limit = $this->request->get("limit", 0);
  292. $total = $model
  293. ->where($where)
  294. ->where($mimetypeQuery)
  295. ->where('user_id', $this->auth->id)
  296. ->order("id", "DESC")
  297. ->count();
  298. $list = $model
  299. ->where($where)
  300. ->where($mimetypeQuery)
  301. ->where('user_id', $this->auth->id)
  302. ->order("id", "DESC")
  303. ->limit($offset, $limit)
  304. ->select();
  305. $cdnurl = preg_replace("/\/(\w+)\.php$/i", '', $this->request->root());
  306. foreach ($list as $k => &$v) {
  307. $v['fullurl'] = ($v['storage'] == 'local' ? $cdnurl : $this->view->config['upload']['cdnurl']) . $v['url'];
  308. }
  309. unset($v);
  310. $result = array("total" => $total, "rows" => $list);
  311. return json($result);
  312. }
  313. $mimetype = $this->request->get('mimetype', '');
  314. $mimetype = substr($mimetype, -1) === '/' ? $mimetype . '*' : $mimetype;
  315. $this->view->assign('mimetype', $mimetype);
  316. $this->view->assign("mimetypeList", \app\common\model\Attachment::getMimetypeList());
  317. return $this->view->fetch();
  318. }
  319. /**
  320. * 我的个人主页
  321. */
  322. public function homepage()
  323. {
  324. $this->view->assign('title', 'My Personal Homepage');
  325. return $this->view->fetch();
  326. }
  327. /**
  328. * 我得邮箱页
  329. */
  330. public function inbox()
  331. {
  332. // 获取当前用户的邮箱内容信息
  333. $email_contents = EmailContent::where(['email' => $this->auth->email])->paginate();
  334. foreach ($email_contents as $content) {
  335. $content['user'] = \app\admin\model\User::where(['id' => $content['user_id']])->find();
  336. if ($content['type'] == 'admin') {
  337. $content['user'] = Admin::where(['id' => $content['user_id']])->find();
  338. }
  339. $content['createtime'] = date('Y-m-d', $content['createtime']);
  340. if ($content['status'] == 'normal') {
  341. $content['status'] = 'READ';
  342. } else {
  343. $content['status'] = 'Unread';
  344. }
  345. }
  346. $this->view->assign('list', $email_contents);
  347. $this->view->assign('title', 'INBOX');
  348. return $this->view->fetch();
  349. }
  350. /**
  351. * 我的未读邮件页
  352. */
  353. public function unread()
  354. {
  355. // 获取当前用户的邮箱内容信息
  356. $email_contents = EmailContent::where(['email' => $this->auth->email, 'status' => 'hidden'])->paginate();
  357. foreach ($email_contents as $content) {
  358. $content['user'] = \app\admin\model\User::where(['id' => $content['user_id']])->find();
  359. if ($content['type'] == 'admin') {
  360. $content['user'] = Admin::where(['id' => $content['user_id']])->find();
  361. }
  362. $content['createtime'] = date('Y-m-d', $content['createtime']);
  363. $content['status'] = 'Unread';
  364. }
  365. $this->view->assign('list', $email_contents);
  366. $this->view->assign('title', 'Unread');
  367. return $this->view->fetch();
  368. }
  369. /**
  370. * 提交手稿
  371. */
  372. public function submit_manuscript($id = null)
  373. {
  374. $row = [
  375. 'id' => '',
  376. 'manuscript_zip' => '',
  377. 'manuscript_pdf' => '',
  378. 'cover_letter' => '',
  379. 'graphical_abstract' => '',
  380. 'non_material' => '',
  381. 'is_copyright' => '',
  382. 'copyright_files' => '',
  383. 'image' => '',
  384. 'journal' => '',
  385. 'article_type' => '',
  386. 'title' => '',
  387. 'abstract' => '',
  388. 'keywords' => '',
  389. 'number_page' => '',
  390. 'is_funding' => '',
  391. 'funding_content' => '',
  392. 'is_interest' => '',
  393. 'interest_content' => '',
  394. 'statement_type' => '',
  395. 'article_one' => '',
  396. 'article_two' => '',
  397. 'article_three' => '',
  398. 'country' => '',
  399. 'affiliation' => '',
  400. 'name' => '',
  401. 'invoice_email' => '',
  402. 'order_email' => '',
  403. 'address' => '',
  404. 'zip_code' => '',
  405. 'city' => '',
  406. 'telephone' => '',
  407. 'fax' => '',
  408. 'vat' => '',
  409. ];
  410. $id = $this->request->param('id');
  411. if ($id) {
  412. $row = AuthorManuscript::where(['id' => $id])->find();
  413. $row->author_content = json_decode($row->author_content, true);
  414. $row->review_content = json_decode($row->review_content, true);
  415. }
  416. $this->view->assign('row', $row);
  417. $this->view->assign('title', 'Submit Manuscript');
  418. return $this->view->fetch();
  419. }
  420. /**
  421. * 手稿状态
  422. */
  423. public function display_submitted()
  424. {
  425. // 构建分页参数
  426. $limit = $this->request->param('limit', 10);
  427. $status = $this->request->param('status', 'All');
  428. $where = [];
  429. if ($status != 'All') {
  430. $where = ['status' => $status];
  431. }
  432. // 查询当前用户手稿
  433. $manuscripts = AuthorManuscript::where(['user_id' => $this->auth->id])
  434. ->where($where)
  435. ->field('id,title,image,createtime,journal')
  436. ->order('createtime', 'DESC')
  437. ->paginate($limit);
  438. foreach ($manuscripts as $manuscript) {
  439. $manuscript['journal'] = Channel::where(['id' => $manuscript['journal']])->value('name');
  440. }
  441. if ($this->request->isAjax()) {
  442. $keyword = $this->request->param('keyword');
  443. $manuscripts = AuthorManuscript::where(['user_id' => $this->auth->id, 'title' => ['like', '%'. $keyword .'%'], 'status' => $status])
  444. ->field('id,title,image,createtime,journal')
  445. ->order('createtime', 'DESC')
  446. ->paginate($limit);
  447. foreach ($manuscripts as $manuscript) {
  448. $manuscript['createtime'] = date('Y-m-d', $manuscript['createtime']);
  449. $manuscript['journal'] = Channel::where(['id' => $manuscript['journal']])->value('name');
  450. }
  451. $this->success('', '', $manuscripts);
  452. }
  453. $this->view->assign('status', $status);
  454. $this->view->assign('list', $manuscripts);
  455. $this->view->assign('title', 'Dispaly Submitted');
  456. return $this->view->fetch();
  457. }
  458. /**
  459. * 审核人信息
  460. */
  461. public function reviewer_information()
  462. {
  463. $user_role_count = UserRoleLog::where(['user_id' => $this->auth->id, 'type' => 'review', 'is_adopt' => ['in', ['review', 'fault']]])->count();
  464. $user_content = UserRoleContent::where(['user_id' => $this->auth->id, 'type' => 'review'])->find();
  465. if (empty($user_content)) {
  466. $user_content['field'] = '';
  467. $user_content['degree'] = '';
  468. $user_content['affiliation'] = '';
  469. $user_content['publication'] = '';
  470. $user_content['orcid'] = '';
  471. $user_content['homepage'] = '';
  472. $user_content['review_journal'] = '';
  473. $user_content['interested_journal'] = '';
  474. $user_content['resume'] = '';
  475. $user_content['journal_ids'] = '';
  476. }
  477. $this->view->assign('row', $user_content);
  478. $this->view->assign('user_role_count', $user_role_count);
  479. $this->view->assign('title', 'Reviewer Information');
  480. return $this->view->fetch();
  481. }
  482. /**
  483. * 审阅的手稿
  484. */
  485. public function show_reviewed_manuscripts()
  486. {
  487. $limit = $this->request->param('limit', 10);
  488. $status = $this->request->param('status', '');
  489. $where = ['status' => $status];
  490. // 查询当前用户手稿
  491. $manuscripts = AuthorManuscript::whereRaw("FIND_IN_SET(". $this->auth->id .", `reviewer_ids`)")
  492. ->where($where)
  493. ->field('id,title,image,createtime,journal')
  494. ->order('createtime', 'DESC')
  495. ->paginate($limit);
  496. foreach ($manuscripts as $manuscript) {
  497. $manuscript['journal'] = Channel::where(['id' => $manuscript['journal']])->value('name');
  498. }
  499. if ($this->request->isAjax()) {
  500. $keyword = $this->request->param('keyword');
  501. $manuscripts = AuthorManuscript::where(['title' => ['like', '%'. $keyword .'%'], 'status' => $status])
  502. ->whereRaw("FIND_IN_SET(". $this->auth->id .", `reviewer_ids`)")
  503. ->field('id,title,image,createtime,journal')
  504. ->order('createtime', 'DESC')
  505. ->paginate($limit);
  506. foreach ($manuscripts as $manuscript) {
  507. $manuscript['createtime'] = date('Y-m-d', $manuscript['createtime']);
  508. $manuscript['journal'] = Channel::where(['id' => $manuscript['journal']])->value('name');
  509. }
  510. $this->success('', '', $manuscripts);
  511. }
  512. $this->view->assign('status', $status);
  513. $this->view->assign('list', $manuscripts);
  514. $this->view->assign('title', 'Show Reviewed Manuscripts');
  515. return $this->view->fetch();
  516. }
  517. /**
  518. * 手稿详情
  519. */
  520. public function article_details($id = null)
  521. {
  522. $id = $this->request->param('id');
  523. $type = $this->request->param('type');
  524. $status = $this->request->param('status', 'reviewer_details');
  525. $row = AuthorManuscript::where(['id' => $id])->find();
  526. $row['review_content'] = json_decode($row['review_content'], true);
  527. if ($row) {
  528. $row['keywords'] = explode(',', $row['keywords']);
  529. }
  530. // 判断是审稿人还是编辑,如果是编辑则可以看到全部意见
  531. $comments = Comments::where(['manuscript_id' => $row['id']])->select();
  532. if ($type == 'reviewer') {
  533. $comments = Comments::where(['manuscript_id' => $row['id'], 'type' => 'reviewer'])->select();
  534. }
  535. if ($type == 'editor') {
  536. $reviewers = InviteReviewer::where(['manuscript_id' => $row['id']])->select();
  537. // 邀请的审稿人信息
  538. if ($status == 'reviewer_details') {
  539. foreach ($reviewers as $reviewer) {
  540. $reviewer_role = UserRoleContent::where(['id' => $reviewer['role_id']])->find();
  541. if ($reviewer_role) {
  542. // 查询审稿人提交意见信息
  543. $reviewer_comment = Comments::where(['user_id' => $reviewer_role['user_id'], 'manuscript_id' => $row['id']])
  544. ->order('createtime', 'DESC')
  545. ->find();
  546. $reviewer_user = \app\admin\model\User::where(['id' => $reviewer_role['user_id']])->find();
  547. }
  548. $reviewer['nickname'] = $reviewer_user['nickname'];
  549. $reviewer['invited_time'] = date('Y-m-d', $reviewer['createtime']);
  550. $reviewer['reply_time'] = date('Y-m-d', $reviewer_comment['createtime'] ?? '');
  551. $reviewer['submission_time'] = date('Y-m-d', $reviewer_comment['createtime'] ?? '');
  552. $reviewer['status'] = $reviewer_comment['recommendation'] ?? '';
  553. }
  554. }
  555. // 审稿人信息
  556. if ($status == 'reviewer_suggestion') {
  557. foreach ($reviewers as $reviewer) {
  558. $reviewer_role = UserRoleContent::where(['id' => $reviewer['role_id']])->find();
  559. if ($reviewer_role) {
  560. // 查询审稿人提交意见数量
  561. $reviewer_comment_num = Comments::where(['user_id' => $reviewer_role['user_id'], 'manuscript_id' => $row['id']])
  562. ->count();
  563. $reviewer_user = \app\admin\model\User::where(['id' => $reviewer_role['user_id']])->find();
  564. }
  565. $reviewer['nickname'] = $reviewer_user['nickname'];
  566. $reviewer['affiliation'] = $reviewer_role['affiliation'];
  567. $reviewer['comment_num'] = $reviewer_comment_num;
  568. }
  569. }
  570. // 审稿人意见信息
  571. if ($status == 'review_report') {
  572. foreach ($reviewers as $reviewer) {
  573. $reviewer_role = UserRoleContent::where(['id' => $reviewer['role_id']])->find();
  574. if ($reviewer_role) {
  575. // 查询审稿人提交意见信息
  576. $reviewer_comment = Comments::where(['user_id' => $reviewer_role['user_id'], 'manuscript_id' => $row['id']])
  577. ->order('createtime', 'DESC')
  578. ->find();
  579. $reviewer_user = \app\admin\model\User::where(['id' => $reviewer_role['user_id']])->find();
  580. }
  581. $reviewer['nickname'] = $reviewer_user['nickname'];
  582. $reviewer['recommendation'] = $reviewer_comment['recommendation'];
  583. $reviewer['comment'] = $reviewer_comment['comments'];
  584. $reviewer['createtime'] = date('Y-m-d', $reviewer_comment['createtime']);
  585. }
  586. }
  587. $row['reviewer'] = $reviewers;
  588. }
  589. $row['comments'] = $comments ?? [];
  590. $this->view->assign('status', $status);
  591. $this->view->assign('row', $row);
  592. $this->view->assign('type', $type);
  593. $this->view->assign('title', 'Article Details');
  594. return $this->view->fetch();
  595. }
  596. /**
  597. * 审稿页面
  598. */
  599. public function conduct_review($id = null)
  600. {
  601. $id = $this->request->param('id');
  602. $type = $this->request->param('type');
  603. $row = Comments::where(['manuscript_id' => $id, 'type' => $type])->find();
  604. $this->view->assign('row', $row);
  605. $this->view->assign('id', $id);
  606. $this->view->assign('type', $type);
  607. $this->view->assign('title', 'Conduct Review');
  608. return $this->view->fetch();
  609. }
  610. /**
  611. * 申请创建特刊
  612. */
  613. public function special_issue()
  614. {
  615. $this->view->assign('title', 'Apply to creat a special issue');
  616. return $this->view->fetch();
  617. }
  618. /**
  619. * 申请成为编辑
  620. */
  621. public function become_an_editor()
  622. {
  623. $user_content = UserRoleContent::where(['user_id' => $this->auth->id, 'type' => 'editor'])->find();
  624. if (empty($user_content)) {
  625. $user_content['degree'] = '';
  626. $user_content['affiliation'] = '';
  627. $user_content['publication'] = '';
  628. $user_content['orcid'] = '';
  629. $user_content['homepage'] = '';
  630. $user_content['review_journal'] = '';
  631. $user_content['interested_journal'] = '';
  632. $user_content['resume'] = '';
  633. $user_content['journal_ids'] = '';
  634. }
  635. $this->view->assign('row', $user_content);
  636. $this->view->assign('title', 'Apply to become an editor');
  637. return $this->view->fetch();
  638. }
  639. /**
  640. * 编辑手稿
  641. */
  642. public function editing_manuscripts()
  643. {
  644. $limit = $this->request->param('limit', 10);
  645. $type = $this->request->param('type');
  646. $status = $this->request->param('status', 'all');
  647. $where = [];
  648. if ($status != 'all') {
  649. $where = ['status' => $status];
  650. }
  651. // 查询当前用户手稿
  652. $manuscripts = AuthorManuscript::whereRaw("FIND_IN_SET(". $this->auth->id .", `editor_ids`)")
  653. ->where($where)
  654. ->field('id,title,image,createtime,journal')
  655. ->order('createtime', 'DESC')
  656. ->paginate($limit);
  657. foreach ($manuscripts as $manuscript) {
  658. $manuscript['journal'] = Channel::where(['id' => $manuscript['journal']])->value('name');
  659. }
  660. if ($this->request->isAjax()) {
  661. $keyword = $this->request->param('keyword');
  662. $manuscripts = AuthorManuscript::where(['title' => ['like', '%'. $keyword .'%']])->whereRaw("FIND_IN_SET(". $this->auth->id .", `editor_ids`)")->field('id,title,image,createtime')->order('createtime', 'DESC')->paginate($limit);
  663. foreach ($manuscripts as $manuscript) {
  664. $manuscript['createtime'] = date('Y-m-d', $manuscript['createtime']);
  665. }
  666. $this->success('', '', $manuscripts);
  667. }
  668. $this->view->assign('status', $status);
  669. $this->view->assign('type', $type);
  670. $this->view->assign('list', $manuscripts);
  671. $this->view->assign('title', 'Editing Manuscripts');
  672. return $this->view->fetch();
  673. }
  674. /**
  675. * 提交处理意见
  676. */
  677. public function handing_suggestions()
  678. {
  679. $id = $this->request->param('id');
  680. $type = $this->request->param('type');
  681. $row = Comments::where(['manuscript_id' => $id, 'type' => $type, 'user_id' => $this->auth->id])->find();
  682. if (empty($row)) {
  683. $row['is_interest'] = '';
  684. }
  685. $this->view->assign('row', $row);
  686. $this->view->assign('id', $id);
  687. $this->view->assign('type', $type);
  688. $this->view->assign('title', 'Submit Handing Suggestions');
  689. return $this->view->fetch();
  690. }
  691. /**
  692. * 邀请审稿人
  693. */
  694. public function invite_reviewers()
  695. {
  696. $id = $this->request->param('id');
  697. // 构建分页参数
  698. $limit = $this->request->param('limit', 10);
  699. // 获取审稿人信息
  700. $review_id_arr = \app\common\model\User::where(['is_review' => 'correct'])->column('id');
  701. // $list = UserRoleContent::with(['user'])->where(['user_id' => ['in', $review_id_arr], 'type' => 'review'])->paginate($limit);
  702. $list = UserRoleContent::with(['user'])->where(['user_id' => ['in', $review_id_arr], 'type' => 'review'])->select();
  703. foreach ($list as $value) {
  704. $channel_name_arr = Channel::where(['id' => ['in', explode(',', $value['journal_ids'])]])->column('name');
  705. $value['journal'] = implode(',', $channel_name_arr);
  706. }
  707. $this->view->assign('id', $id);
  708. $this->view->assign('list', $list);
  709. $this->view->assign('title', 'Invite Reviewers');
  710. return $this->view->fetch();
  711. }
  712. /**
  713. * 获取审稿人列表
  714. *
  715. * @return void
  716. * @throws \think\exception\DbException
  717. */
  718. public function getReviewerList()
  719. {
  720. // 构建分页参数
  721. $limit = $this->request->param('limit', 10);
  722. // 获取审稿人信息
  723. $review_id_arr = \app\common\model\User::where(['is_review' => 'correct'])->column('id');
  724. $data = UserRoleContent::with(['user'])->where(['user_id' => ['in', $review_id_arr], 'type' => 'review'])->paginate($limit);
  725. // 返回表格数据和分页信息
  726. $this->success('', '', $data);
  727. }
  728. /**
  729. * 提交会议
  730. *
  731. * @return string
  732. * @throws \think\Exception
  733. */
  734. public function submit_conference()
  735. {
  736. $this->view->assign('title', 'Submit Conference');
  737. return $this->view->fetch();
  738. }
  739. /**
  740. * 参加会议
  741. *
  742. * @return string
  743. * @throws \think\Exception
  744. */
  745. public function conference_participate()
  746. {
  747. $param = $this->request->param();
  748. $id = $param['id'];
  749. $row = Participate::where(['id' => $id])->find();
  750. $this->view->assign('id', $id);
  751. $this->view->assign('row', $row);
  752. $this->view->assign('title', 'Submit Conference');
  753. return $this->view->fetch();
  754. }
  755. }