From 7f237058a7f0f9be67c0a190f4d57eeec6fa56f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E5=8A=BC?= Date: Fri, 21 Nov 2014 15:13:53 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=A0=E5=85=A5=E6=9B=B4=E6=96=B0=E5=92=8C?= =?UTF-8?q?=E5=90=8C=E6=AD=A5=EF=BC=8C=E5=9B=9E=E7=BB=99=E5=89=8D=E7=AB=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/controllers/ProjectsController.php | 25 +++++++++++++++---- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/publisher/app/controllers/ProjectsController.php b/publisher/app/controllers/ProjectsController.php index 3d321e5..38cee1f 100644 --- a/publisher/app/controllers/ProjectsController.php +++ b/publisher/app/controllers/ProjectsController.php @@ -96,11 +96,26 @@ public function dopublish() { //TODO 根据用户权限判断 $id = intval(Input::get('id')); - $version = trim(Input::get('version')); - - //project version - //servers - + $project = Project::find($id); + if(!$id || !$project) + { + return Response::json(array("result"=>false,'msg' => '项目不存在')); + } + $version = trim(Input::get('project_select_version')); + if(!preg_match('/^\w+$/i', $version)) + { + return Response::json(array("result"=>false,'msg' => '请选择正确的版本')); + } + $task_ids = array('upd_prj' => '' ,'sync_svr' => array()); + $task_ids['upd_prj'] = Task::create('update',Auth::id(),array('project_id'=>$id,"version"=>$version)); + $servers_id = Input::get('publish_box'); + $servers = Server::whereIn("id",$servers_id)->get(); + foreach ($servers as $key => $value) { + if($value->project_id != $id) //检查服务器是不是属于project + continue; + $task_ids['sync_svr'][$value->id] = Task::create('rsync',Auth::id(),array('server_id'=>$value->id),$task_ids['upd_prj']); + } + return Response::json(array("result"=>true,'msg' => '','tasks' => $task_ids)); } public function getSrclog()