public function edit($id) { if (IS_POST) { $this->Admin->save(array('id' => I('post.id'), 'email' => I('post.email'), 'phone' => I('post.phone'), 'group_name' => implode(',', I('post.group_name')))); $this->redirect('all'); exit; } $admin = $this->Admin->getById($id); $this->assign('adminGroup', explode(',', $admin['group_name'])); $this->assign('role', $admin); $this->assign('accessGroup', $this->_getAccessGroup()); $this->display('add'); }
public function updatePassword() { $admin = $this->Admin->getById(session('admin.id')); if (IS_POST) { if (md5(I('post.old_password')) !== $admin['password']) { // echo error('原密码错误');die; $this->error('原密码错误', '', 1); } if (empty(I('post.password'))) { $this->error('密码不能为空'); } if (I('post.password') !== I('post.re_password')) { $this->error('两次密码不一致'); } $this->Admin->save(array('id' => session('admin.id'), 'password' => md5(I('post.password')))); $this->success('修改密码成功', U('Admin/Admin/logout')); exit; } $this->assign('admin', $admin); $this->display('updatePassword'); }