From f5867097f4ae7f5811abc96e5dc879576d497b32 Mon Sep 17 00:00:00 2001 From: "chencongzhi520@gmail.com" Date: Thu, 11 Apr 2013 07:15:43 +0000 Subject: [PATCH] * finish task#1323. --- module/user/control.php | 6 +++++- module/user/model.php | 13 ++++++++++++- module/user/view/edit.html.php | 11 +++++++++++ 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/module/user/control.php b/module/user/control.php index d861068327..ad2e823648 100644 --- a/module/user/control.php +++ b/module/user/control.php @@ -347,12 +347,16 @@ 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 = $this->user->getById($userID); + $this->view->user = $user; $this->view->depts = $this->dept->getOptionMenu(); + $this->view->groups = $this->loadModel('group')->getPairs(); $this->display(); } diff --git a/module/user/model.php b/module/user/model.php index 659a482c6d..eeb472af40 100644 --- a/module/user/model.php +++ b/module/user/model.php @@ -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') + ->remove('password1, password2, groups') ->specialChars('msn,qq,yahoo,gtalk,wangwang,mobile,phone,address,zipcode') ->get(); @@ -341,6 +341,17 @@ 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(); + } + } } /** diff --git a/module/user/view/edit.html.php b/module/user/view/edit.html.php index a209fbf3d8..08bd3dd668 100644 --- a/module/user/view/edit.html.php +++ b/module/user/view/edit.html.php @@ -27,6 +27,17 @@ user->realname;?> realname, "class='text-3'");?> + + user->group;?> + + $groupName) + { + echo html::checkbox('groups', array($groupID => $groupName), in_array($groupID, $user->group) ? $groupID : ''); + } + ?> + + user->role;?> user->roleList, $user->role, "class='select-3'");?>