Skip to content

Commit

Permalink
用户edit
Browse files Browse the repository at this point in the history
  • Loading branch information
xsir317 committed Nov 26, 2014
1 parent 770c21c commit 6da31c0
Show file tree
Hide file tree
Showing 3 changed files with 136 additions and 10 deletions.
19 changes: 9 additions & 10 deletions publisher/app/controllers/UsersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function edit()
{
$username = trim(Input::get('username'));
$password = trim(Input::get('password'));
$is_superadmin = trim(Input::get('is_superadmin'));
$is_superadmin = intval(Input::get('is_superadmin'));
$project_ids = Input::get('project');
if($user)
{
Expand Down Expand Up @@ -57,18 +57,17 @@ public function edit()
$user->username = $username;
$user->password = Hash::make($password);
}
$user->is_superadmin = $is_superadmin;
$user->save();
//处理传过来的项目id数组
return Redirect::route('users/index');
//如果不是超级管理员,处理传过来的项目id数组
if(!$user->is_superadmin)
{

}
return Redirect::to('/users/index');
}
}
//当前用户拥有的所有项目
$projects = Project::whereIn('id',Auth::user()->pj_ids())->get();
$prj_list = array();
foreach ($projects as $value) {
$prj_list[$value->id] = $value->title;
}
return View::make('users/edit',array('user'=>$user,'error' => $error));
return View::make('users/edit',array('user'=>$user,'error' => $error,'projects'=>Project::all()));
}

//改密码
Expand Down
61 changes: 61 additions & 0 deletions publisher/app/views/users/edit.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
@extends('layouts.master')
@section('title')
<?php if($user):?> 编辑用户-<?php echo $user->username; ?> <?php else:?> 新增用户-<?php endif;?> @parent @stop
@section('sidebar')
@include('sidebar', array('currpage'=>'users'))
@stop
@section('content')
<?php if($user):?>
{{ Form::model($user, array('url' => '/users/edit' ,'class' => 'uk-form uk-form-horizontal' )) }}
<div class="uk-form-row">
<label class="uk-form-label">用户ID</label>
<div class="uk-form-controls"><?php echo $user->id;?><?php echo Form::hidden('id',$user->id);?></div>
</div>
<div class="uk-form-row">
{{ Form::label('username','用户名',array('class' => 'uk-form-label')) }}
<div class="uk-form-controls">
{{ $user->username }}
</div>
</div>
<?php else: ?>
{{ Form::open(array('url' => '/users/add' ,'class' => 'uk-form uk-form-horizontal' )) }}
<div class="uk-form-row">
{{ Form::label('username','用户名',array('class' => 'uk-form-label')) }}
<div class="uk-form-controls">
{{ Form::text('username') }}
</div>
</div>
<?php endif;?>
<div class="uk-form-row">
{{ Form::label('password','密码',array('class' => 'uk-form-label')) }}
<div class="uk-form-controls">
{{ Form::password('password') }}
</div>
</div>
<div class="uk-form-row">
{{ Form::label('is_superadmin','超级管理员',array('class' => 'uk-form-label')) }}
<div class="uk-form-controls">
{{ Form::checkbox('is_superadmin','1',($user && $user->is_superadmin)) }}
</div>
</div>
<div class="uk-form-row">
{{ Form::label('','项目',array('class' => 'uk-form-label')) }}
<div class="uk-form-controls">
<ul>
<?php foreach($projects as $_row):?>
<li>
{{ Form::checkbox('project[]',$_row->id,($user && in_array($_row->id,$user->pj_ids()))) }} {{ $_row->title }}
</li>
<?php endforeach;?>

</ul>
</div>
</div>
<?php if($error):?>
<div class="uk-alert uk-alert-danger">{{ $error }}</div>
<?php endif;?>
<div class="uk-form-row">
{{ Form::submit('提交',array('class'=>'uk-button uk-button-primary')) }}
</div>
{{ Form::close() }}
@stop
66 changes: 66 additions & 0 deletions publisher/app/views/users/pwd.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
@extends('layouts.master')
@section('title')
<?php if($project):?> 编辑项目-<?php echo $project->title; ?> <?php else:?> 新增项目-<?php endif;?> @parent @stop
@section('sidebar')
@include('sidebar', array('currpage'=>'users'))
@stop
@section('content')
{{ Form::open(array('url' => '/users/password' ,'class' => 'uk-form uk-form-horizontal' )) }}
<div class="uk-form-row">
{{ Form::label('title','项目名',array('class' => 'uk-form-label')) }}
<div class="uk-form-controls">
{{ Form::text('title') }}
</div>
</div>
<div class="uk-form-row">
{{ Form::label('manager','项目管理员',array('class' => 'uk-form-label')) }}
<div class="uk-form-controls">
{{ Form::text('manager') }}
</div>
</div>
<div class="uk-form-row">
{{ Form::label('vcs_type','版本管理工具',array('class' => 'uk-form-label')) }}
<div class="uk-form-controls">
{{ Form::select('vcs_type',Project::$vcs_types) }}
</div>
</div>
<div class="uk-form-row">
{{ Form::label('src_addr','源码地址',array('class' => 'uk-form-label')) }}
<div class="uk-form-controls">
{{ Form::text('src_addr',null,array('class'=>'uk-form-width-large')) }}
</div>
</div>
<div class="uk-form-row">
{{ Form::label('username','账号密码',array('class' => 'uk-form-label')) }}
<div class="uk-form-controls">
{{ Form::text('username') }}&nbsp;{{ Form::text('password') }}
</div>
</div>
<?php if($project):?>
<div class="uk-form-row">
{{ Form::label('current_version','当前版本',array('class' => 'uk-form-label')) }}
<div class="uk-form-controls">
{{ $project->current_version }}
</div>
</div>
<?php endif;?>
<div class="uk-form-row">
{{ Form::label('ignore_files','同步时忽略',array('class' => 'uk-form-label')) }}
<div class="uk-form-controls">
{{ Form::textarea('ignore_files',null,array('rows'=>3)) }}
</div>
</div>
<div class="uk-form-row">
{{ Form::label('comments','备注',array('class' => 'uk-form-label')) }}
<div class="uk-form-controls">
{{ Form::textarea('comments',null,array('rows'=>3)) }}
</div>
</div>
<?php if($error):?>
<div class="uk-alert uk-alert-danger">{{ $error }}</div>
<?php endif;?>
<div class="uk-form-row">
{{ Form::submit('提交',array('class'=>'uk-button uk-button-primary')) }}
</div>
{{ Form::close() }}
@stop

0 comments on commit 6da31c0

Please sign in to comment.