新增标题重复验证方法
This commit is contained in:
@@ -393,4 +393,75 @@ class Article
|
|||||||
return json_encode(['status' => 1,'msg' => 'success']);
|
return json_encode(['status' => 1,'msg' => 'success']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 验证标题是否重复
|
||||||
|
*/
|
||||||
|
public function checkTitle($aParam = []){
|
||||||
|
//文章ID
|
||||||
|
$iArticleId = empty($aParam['article_id']) ? 0 : $aParam['article_id'];
|
||||||
|
//文章标题
|
||||||
|
$sTitle = empty($aParam['title']) ? '' : $aParam['title'];
|
||||||
|
if(empty($sTitle)){
|
||||||
|
return ['status' => 2,'msg' => 'The article title is empty'];
|
||||||
|
}
|
||||||
|
//作者ID
|
||||||
|
$iUserId = empty($aParam['user_id']) ? 0 : $aParam['user_id'];
|
||||||
|
//查询标题是否存在
|
||||||
|
$aWhere = ['title' => trim($sTitle)];
|
||||||
|
$aArticle = Db::name('article')->field('article_id,user_id,state,accept_sn')->where($aWhere)->order('article_id asc')->select();
|
||||||
|
if(empty($aArticle)){
|
||||||
|
return ['status' => 1,'msg' => 'No articles with relevant titles found'];
|
||||||
|
}
|
||||||
|
|
||||||
|
//处理数据
|
||||||
|
$aFlag = [];
|
||||||
|
$iDraftId = 0;
|
||||||
|
foreach ($aArticle as $key => $value) {
|
||||||
|
if(!empty($iArticleId) && $value['article_id'] == $iArticleId){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
//稿件提交者
|
||||||
|
$iArticleUserId = empty($value['user_id']) ? 0 : $value['user_id'];
|
||||||
|
//稿件状态
|
||||||
|
$iState = empty($value['state']) ? '' : $value['state'];
|
||||||
|
//稿号
|
||||||
|
$sAcceptSn = empty($value['accept_sn']) ? '' : $value['accept_sn'];
|
||||||
|
if($iState == 3 && stripos($sAcceptSn, 'Draft') === 0){//自己删除草稿箱稿件
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if($iArticleUserId != $iUserId){//与其他作者的文章标题重名
|
||||||
|
$aFlag[] = 2;
|
||||||
|
break;
|
||||||
|
}else{
|
||||||
|
if($iState == 3){//编辑已拒绝文章
|
||||||
|
$aFlag[] = 3;
|
||||||
|
break;
|
||||||
|
}elseif($iState == -1){//其他状态
|
||||||
|
$aFlag[] = 4;
|
||||||
|
$iDraftId = $value['article_id'];
|
||||||
|
}else{
|
||||||
|
$aFlag[] = 5;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//返回数据
|
||||||
|
$aFlag = empty($aFlag) ? [] : array_unique($aFlag);
|
||||||
|
$sMsg = '';
|
||||||
|
if(empty($aFlag)){
|
||||||
|
return ['status' => 1,'msg' => 'Enter the data processing flow'];
|
||||||
|
}
|
||||||
|
if(in_array(2, $aFlag) || in_array(5, $aFlag)){
|
||||||
|
$sMsg = 'Please note that the manuscript with the same title is already under processing. Do not submit it again.';
|
||||||
|
return ['status' => 20,'msg' => $sMsg];
|
||||||
|
}elseif(in_array(3, $aFlag)){
|
||||||
|
$sMsg = 'Please note that the manuscript with the same title has already been rejected. For more details, please contact the journal.';
|
||||||
|
return ['status' => 21,'msg' => $sMsg];
|
||||||
|
}elseif(in_array(4, $aFlag)){
|
||||||
|
$sMsg = 'Please notice that the manuscript with the same title is already in the draft status. please click here';
|
||||||
|
return ['status' => 22,'msg' => $sMsg,'draft_id' => $iDraftId];
|
||||||
|
}else{
|
||||||
|
return ['status' => 1,'msg' => 'Enter the data processing flow'];
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user