* finish task#1323.

This commit is contained in:
chencongzhi520@gmail.com
2013-04-15 01:32:52 +00:00
parent 921a09eef0
commit 63ef3df46b
9 changed files with 96 additions and 33 deletions

View File

@@ -1 +1,2 @@
.icon-green-user-unlock {padding:2px 8px; background:url(theme/default/images/main/zt-icons.png) -20px -460px;}
.icon-green-user-unlock {padding:2px 8px; background:url(theme/default/images/main/zt-icons.png) -20px -460px;}
.icon-green-user-editGroup{padding:2px 8px; background:url(theme/default/images/main/zt-icons.png) -60px -460px;}

View File

@@ -61,7 +61,8 @@ js::set('deptID', $deptID);
<td><?php echo $user->visits;?></td>
<td class='a-left'>
<?php
common::printIcon('user', 'edit', "userID=$user->id&from=company", '', 'list');
common::printIcon('user', 'edit', "userID=$user->id&from=company", '', 'list');
common::printIcon('user', 'editGroup', "userID=$user->account", '', 'list');
if(strpos($this->app->company->admins, ",{$this->app->user->account},") === false or $this->app->user->account != $user->account) common::printIcon('user', 'delete', "userID=$user->id", '', 'list', '', "hiddenwin");
if((strtotime(date('Y-m-d H:i:s')) - strtotime($user->locked)) < $this->config->user->lockMinutes * 60)
{

View File

@@ -524,6 +524,7 @@ $lang->resource->user->create = 'create';
$lang->resource->user->batchCreate = 'batchCreate';
$lang->resource->user->view = 'view';
$lang->resource->user->edit = 'edit';
$lang->resource->user->editGroup = 'editGroup';
$lang->resource->user->unlock = 'unlock';
$lang->resource->user->delete = 'delete';
$lang->resource->user->todo = 'todo';

View File

@@ -347,16 +347,12 @@ class user extends control
die(js::locate($this->createLink('company', 'browse'), 'parent'));
}
$user = $this->user->getById($userID);
$user->group = $this->dao->select('`group`')->from(TABLE_USERGROUP)->where('account')->eq($user->account)->fetchPairs();
$title = $this->lang->company->common . $this->lang->colon . $this->lang->user->edit;
$position[] = $this->lang->user->edit;
$this->view->title = $title;
$this->view->position = $position;
$this->view->user = $user;
$this->view->user = $this->user->getById($userID);
$this->view->depts = $this->dept->getOptionMenu();
$this->view->groups = $this->loadModel('group')->getPairs();
$this->display();
}
@@ -414,6 +410,29 @@ class user extends control
}
}
/**
* Edit user's group.
*
* @param string $account
* @access public
* @return void
*/
public function editGroup($account)
{
if(!empty($_POST))
{
$this->user->updateGroup($account);
if(dao::isError()) die(js::error(dao::getError()));
die(js::locate($this->createLink('company', 'browse'), 'parent'));
}
$this->view->title = $this->lang->company->common . $this->lang->colon . $this->lang->user->editGroup;
$this->view->position[] = $this->lang->user->editGroup;
$this->view->userGroups = $this->dao->select('`group`')->from(TABLE_USERGROUP)->where('account')->eq($account)->fetchPairs();
$this->view->groups = $this->loadModel('group')->getList($this->app->company->id);
$this->display();
}
/**
* Unlock a user.
*

View File

@@ -48,6 +48,7 @@ $lang->user->batchCreate = "Batch add user";
$lang->user->read = "Info";
$lang->user->edit = "Edit";
$lang->user->batchEdit = "Batch Edit";
$lang->user->editGroup = "Edit Group";
$lang->user->unlock = "Unlock";
$lang->user->update = "Upgrade";
$lang->user->delete = "Delete";
@@ -78,7 +79,6 @@ $lang->user->story = 'Story';
$lang->user->team = 'Team';
$lang->user->dynamic = 'Dynamic';
$lang->user->ajaxGetUser = 'AJAX:get users';
$lang->user->editProfile = 'Edit profile';
$lang->user->errorDeny = "Sorry, you can't access the <b>%s</b> module's <b>%s</b> feature";
$lang->user->loginFailed = "Login failed, please check your account and password.";

View File

@@ -48,13 +48,14 @@ $lang->user->batchCreate = "批量添加用户";
$lang->user->read = "查看用户";
$lang->user->edit = "编辑用户";
$lang->user->batchEdit = "批量编辑";
$lang->user->editGroup = "编辑用户分组";
$lang->user->unlock = "解锁用户";
$lang->user->update = "编辑用户";
$lang->user->delete = "删除用户";
$lang->user->browse = "浏览用户";
$lang->user->login = "用户登录";
$lang->user->userView = "人员视图";
$lang->user->editProfile = "修改个人信息";
$lang->user->editProfile = "修改档案";
$lang->user->editPassword = "修改密码";
$lang->user->manageContacts = '维护联系人';
$lang->user->deleteContacts = '删除联系人';
@@ -78,7 +79,6 @@ $lang->user->story = '需求';
$lang->user->team = '团队';
$lang->user->dynamic = '动态';
$lang->user->ajaxGetUser = '接口:获得用户';
$lang->user->editProfile = '修改信息';
$lang->user->errorDeny = "抱歉,您无权访问『<b>%s</b>』模块的『<b>%s</b>』功能。请联系管理员获取权限。点击后退返回上页。";
$lang->user->loginFailed = "登录失败,请检查您的用户名或密码是否填写正确。";

View File

@@ -317,7 +317,7 @@ class userModel extends model
$user = fixer::input('post')
->setDefault('join', '0000-00-00')
->setIF($this->post->password1 != false, 'password', md5($this->post->password1))
->remove('password1, password2, groups')
->remove('password1, password2')
->specialChars('msn,qq,yahoo,gtalk,wangwang,mobile,phone,address,zipcode')
->get();
@@ -341,17 +341,6 @@ class userModel extends model
if(!dao::isError()) $this->app->user->account = $this->post->account;
}
}
$this->dao->delete()->from(TABLE_USERGROUP)->where('account')->eq($this->post->account)->exec();
if($this->post->groups)
{
foreach($this->post->groups as $groupID)
{
$data->account = $this->post->account;
$data->group = $groupID;
$this->dao->insert(TABLE_USERGROUP)->data($data)->exec();
}
}
}
/**
@@ -405,6 +394,27 @@ class userModel extends model
}
}
/**
* Update user's group.
*
* @param string $account
* @access public
* @return void
*/
public function updateGroup($account)
{
$this->dao->delete()->from(TABLE_USERGROUP)->where('account')->eq($account)->exec();
if($this->post->groups)
{
foreach($this->post->groups as $groupID)
{
$data->account = $account;
$data->group = $groupID;
$this->dao->insert(TABLE_USERGROUP)->data($data)->exec();
}
}
}
/**
* Update password
*

View File

@@ -27,17 +27,6 @@
<th class='rowhead'><?php echo $lang->user->realname;?></th>
<td><?php echo html::input('realname', $user->realname, "class='text-3'");?></td>
</tr>
<tr>
<th class='rowhead'><?php echo $lang->user->group;?></th>
<td>
<?php
foreach($groups as $groupID => $groupName)
{
echo html::checkbox('groups', array($groupID => $groupName), in_array($groupID, $user->group) ? $groupID : '');
}
?>
</td>
</tr>
<tr>
<th class='rowhead'><?php echo $lang->user->role;?></th>
<td><?php echo html::select('role', $lang->user->roleList, $user->role, "class='select-3'");?></td>

View File

@@ -0,0 +1,42 @@
<?php
/**
* The edit group view of user module of ZenTaoPMS.
*
* @copyright Copyright 2009-2013 青岛易软天创网络科技有限公司 (QingDao Nature Easy Soft Network Technology Co,LTD www.cnezsoft.com)
* @license LGPL (http://www.gnu.org/licenses/lgpl.html)
* @author Congzhi Chen <congzhi@chen.com>
* @package user
* @version $Id: edit.html.php 4644 2013-04-11 07:15:43Z chencongzhi520@gmail.com $
* @link http://www.zentao.net
*/
?>
<?php include '../../common/view/header.html.php';?>
<?php include '../../common/view/tablesorter.html.php';?>
<form method='post' target='hiddenwin'>
<table align='center' class='table-1 tablesorter'>
<caption class='caption-tl pb-10px'>
<div class='f-left'><?php echo $lang->user->editGroup;?></div>
<div class='f-right'><?php common::printIcon('group', 'create');?></div>
</caption>
<thead>
<tr class='colhead'>
<th class='w-id'><?php echo $lang->group->id;?></th>
<th class='w-100px'><?php echo $lang->group->name;?></th>
<th><?php echo $lang->group->desc;?></th>
</tr>
</thead>
<tbody>
<?php foreach($groups as $group):?>
<tr class='a-left'>
<td class='strong'> <?php echo html::checkbox('groups', array($group->id => $group->id), in_array($group->id, $userGroups) ? $group->id : '', "class='ml-10px'");?></td>
<td class='a-center'><?php echo $group->name;?></td>
<td class='a-left'> <?php echo $group->desc;?></td>
</tr>
<?php endforeach;?>
</tbody>
<tfoot>
<tr><td colspan='4' class='a-center'><?php echo html::submitButton() . html::gobackButton();?></td></tr>
</tfoot>
</table>
</form>
<?php include '../../common/view/footer.html.php';?>