diff --git a/Westdc/Review/Review.php b/Westdc/Review/Review.php index 32afa5d..cc90b88 100644 --- a/Westdc/Review/Review.php +++ b/Westdc/Review/Review.php @@ -347,6 +347,46 @@ class Review extends AbstractEventManager implements ServiceManagerAwareInterfac }//getAdminReviews + /** + * 获取通过评审的元数据 + * @return Sql\Select + */ + public function getReviewed(){ + + $select = new Sql\Select; + + $select->from(['m'=>'mdstatus']); + $select->columns(['id','status','ts_finished']); + + $select->join(["md"=>"metadata"], "md.uuid=m.uuid", ["title","uuid"], $select::JOIN_RIGHT); + $select->join(["u"=>"users"], "u.id=m.userid", ["username","realname"], $select::JOIN_LEFT); + + $select->where("m.status = ".self::REVIEW_STATUS_PUBLISH); + + if(!empty($this->opt->keyword)) + { + $keyword = $this->opt->keyword; + + $tools = $this->serviceManager->get('Tools'); + + if($tools->isUUID($keyword)) { + $select->where("md.uuid = '$keyword'"); + }else{ + $whereSql = function(Sql\Where $where) use ($keyword){ + $where->AND->like('md.title',"%".$keyword."%"); + $where->OR->like('md.title_en',"%".$keyword."%"); + }; + $select->where($whereSql,Sql\Predicate\PredicateSet::OP_AND); + } + + } + + $select->order("m.ts_finished DESC"); + + return $select; + + }//getReviewed(); + /** * 取消评审 * @param $id @@ -480,6 +520,37 @@ class Review extends AbstractEventManager implements ServiceManagerAwareInterfac return false; }//changeAdmin(); + /** + * 重新评审 + * @param $id + * @return bool|string + */ + public function restart($id) + { + if((!is_numeric($id) && !is_array($id))) + return false; + + if(is_numeric($id)) + return $this->changeStatus($id,self::REVIEW_STATUS_EXPERT_ACCEPT); + + if(is_array($id)) + { + try{ + $this->db->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); + $this->db->beginTransaction(); + foreach($id as $item_id){ + $item_id = $item_id+0; + $this->db->exec("UPDATE mdstatus SET status=".self::REVIEW_STATUS_EXPERT_ACCEPT." WHERE id=$item_id"); + } + $this->db->commit(); + return true; + }catch (\Exception $e){ + $this->db->rollBack(); + return $e->getMessage(); + } + } + }//restart() + /** * 更改mdstatus中的status字段 * @param $id