Skip to content

Commit

Permalink
加入更新和同步,回给前端
Browse files Browse the repository at this point in the history
  • Loading branch information
xsir317 committed Nov 21, 2014
1 parent c09d8fc commit 7f23705
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions publisher/app/controllers/ProjectsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 7f23705

Please sign in to comment.