ReviewService 中添加修改管理员的操作函数

This commit is contained in:
Li Jianxuan 2015-02-03 19:02:23 +08:00
parent 60e3d2e97a
commit 42cdb3e726
1 changed files with 39 additions and 1 deletions

View File

@ -37,6 +37,8 @@ class Review extends AbstractEventManager implements ServiceManagerAwareInterfac
private function init(){
$dbService = $this->serviceManager->get('Db');
/** @var \PDO $this->db */
$this->db = $dbService->getPdo();
unset($dbService);
@ -254,13 +256,49 @@ class Review extends AbstractEventManager implements ServiceManagerAwareInterfac
return true;
}
/**
* 更改管理员
* @param $id array|int 可以输入数组
* @param $user_id int : 不能输入数组
* @return bool|string
*/
public function changeAdmin($id,$user_id)
{
if((!is_numeric($id) && !is_array($id)) || !is_numeric($user_id))
return false;
if(is_numeric($id)){
return $this->db->exec("UPDATE mdstatus SET userid=$user_id WHERE id=$id");
}
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 userid=$user_id WHERE id=$item_id");
}
$this->db->commit();
return true;
}catch (\Exception $e){
$this->db->rollBack();
return $e->getMessage();
}
}
return false;
}//changeAdmin();
/**
* 更改mdstatus中的status字段
* @param $id
* @param $status
* @return bool
*/
function changeStatus($id,$status){
protected function changeStatus($id,$status){
$statusValues = array(
self::REVIEW_STATUS_CANCELED, //取消评审
self::REVIEW_STATUS_DEFAULT, //初始状态