From 2fc47d242b78b178bd2c9f49d3cac9fd7b0a2a87 Mon Sep 17 00:00:00 2001 From: woooowen Date: Thu, 13 Nov 2014 16:27:33 +0800 Subject: [PATCH 1/3] remove admin error information --- TT/protected/controllers/AdminController.php | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/TT/protected/controllers/AdminController.php b/TT/protected/controllers/AdminController.php index b208944..2292b68 100644 --- a/TT/protected/controllers/AdminController.php +++ b/TT/protected/controllers/AdminController.php @@ -15,7 +15,6 @@ class AdminController extends Controller{ */ public function actionAdd(){ if(Yii::app()->request->isPostRequest){ - $oldadmin = IMAdmin::model()->find(array( 'order' => 'id DESC', 'limit' => 1, @@ -27,17 +26,17 @@ public function actionAdd(){ $oldadmin->pwd = md5($data['newpwd1']); $oldadmin->updated = time(); if($oldadmin->update()){ - $this->showAlert('success','操作成功'); - $this->getAdminCache(); - }else{ - $this->showAlert('fail','操作失败'); - echo $admin->getErrors(); - } + $this->showAlert('success','操作成功'); + $this->getAdminCache(); + }else{ + $this->showAlert('fail','操作失败'); + //echo $admin->getErrors(); + } }else{ - $this->showAlert('fail','2次密码不一致'); + $this->showAlert('fail','2次密码不一致'); } }else{ - $this->showAlert('fail','原始密码错误'); + $this->showAlert('fail','原始密码错误'); } } From 1df1d56e00fbfdb12a6ff4d9b44e32114be5a279 Mon Sep 17 00:00:00 2001 From: woooowen Date: Thu, 13 Nov 2014 16:52:37 +0800 Subject: [PATCH 2/3] :( fix some litter problem --- TT/protected/controllers/AjaxController.php | 4 +-- TT/protected/controllers/ConfigController.php | 26 ++++++----------- TT/protected/controllers/DepartController.php | 14 ++++------ TT/protected/controllers/GroupController.php | 28 +++++++++---------- TT/protected/controllers/UserController.php | 3 +- 5 files changed, 31 insertions(+), 44 deletions(-) diff --git a/TT/protected/controllers/AjaxController.php b/TT/protected/controllers/AjaxController.php index 7a09d3f..8785e5d 100644 --- a/TT/protected/controllers/AjaxController.php +++ b/TT/protected/controllers/AjaxController.php @@ -18,8 +18,8 @@ public function actionLogin(){ if(!$adminInfo){ $this->getAdminCache(); } - $admin['uname'] = $adminInfo[0]['uname']; - $admin['pwd'] = $adminInfo[0]['pwd']; + $admin['uname'] = reset($adminInfo)['uname']; + $admin['pwd'] = reset($adminInfo)['pwd']; $uname = trim(Yii::app()->request->getPost('uname')); $pwd = md5(trim(Yii::app()->request->getPost('pwd'))); if($admin['uname'] == $uname && $admin['pwd'] == $pwd){ diff --git a/TT/protected/controllers/ConfigController.php b/TT/protected/controllers/ConfigController.php index 97a69e4..2808681 100644 --- a/TT/protected/controllers/ConfigController.php +++ b/TT/protected/controllers/ConfigController.php @@ -27,19 +27,12 @@ public function actionAdd(){ if(empty($oldconfig)){ $config = new IMConfig(); $config->attributes = $data; - if($config->save()){ - echo ''; - }else{ - echo ''; - } - + $config->save(); + $this->showAlert('success','添加成功'); }else{ $oldconfig->attributes = $data; - if($oldconfig->update()){ - echo ''; - }else{ - echo ''; - } + $oldconfig->update(); + $this->showAlert('success','添加成功'); } } $this->render('add',array( @@ -83,12 +76,11 @@ public function actionDel($id){ if(empty($id)) return; - $count = IMDepartment::model()->deleteByPk($id); if($count > 0){ - echo ''; + $this->showAlert('success','删除成功'); }else{ - echo ''; + $this->showAlert('fail','删除失败'); } } @@ -111,7 +103,7 @@ public function actionEdit($id){ $time = time(); $depart->updated = $time; if($depart->update()){ - echo ''; + $this->showAlert('success','删除成功'); $departs = IMDepartment::model()->findAll(array( 'condition' => 'status = 0', )); @@ -127,7 +119,7 @@ public function actionEdit($id){ if(!empty($cache)) Yii::app()->cache->set('cache_depart',$cache); }else{ - echo ''; + $this->showAlert('fail','删除失败'); } } $users = Yii::app()->cache->get('cache_user'); @@ -154,4 +146,4 @@ public function actionJson(){ } - } \ No newline at end of file + } diff --git a/TT/protected/controllers/DepartController.php b/TT/protected/controllers/DepartController.php index 5aae76c..f3733fa 100644 --- a/TT/protected/controllers/DepartController.php +++ b/TT/protected/controllers/DepartController.php @@ -16,11 +16,10 @@ class DepartController extends Controller{ public function actionAdd(){ if(Yii::app()->request->isPostRequest){ - + $time = time(); $depart = new IMDepartment(); $data = Yii::app()->request->getPost('data'); $depart->attributes = $data; - $time = time(); $depart->created = $time; $depart->updated = $depart->created; @@ -57,10 +56,10 @@ public function actionList($page = 1){ $pager->currentPage = 1; $list = IMDepartment::model()->findAll(array( - 'condition' => 'status = 0', - 'order' => 'id DESC', - 'offset' => $pager->getCurrentPage()*$pager->getPageSize(), - 'limit' => $pager->pageSize, + 'condition' => 'status = 0', + 'order' => 'id DESC', + 'offset' => $pager->getCurrentPage() * $pager->getPageSize(), + 'limit' => $pager->pageSize, )); foreach($list as $v){ @@ -84,10 +83,9 @@ public function actionEdit($id){ $depart = IMDepartment::model()->findByPk($id); if(Yii::app()->request->isPostRequest){ - + $time = time(); $data = Yii::app()->request->getPost('data'); $depart->attributes = $data; - $time = time(); $depart->updated = $time; if($depart->update()){ $this->showAlert('success','修改成功'); diff --git a/TT/protected/controllers/GroupController.php b/TT/protected/controllers/GroupController.php index e69751a..ed73617 100644 --- a/TT/protected/controllers/GroupController.php +++ b/TT/protected/controllers/GroupController.php @@ -17,19 +17,17 @@ public function actionAdd(){ if(Yii::app()->request->isPostRequest){ - $data = Yii::app()->request->getPost('data'); - $file = $this->image(); - //事务处理 - $transaction = Yii::app ()->db->beginTransaction (); - try{ - $group = new IMGroup(); - $group->attributes = $data; - if($_FILES['data']['tmp_name']['mod_avatar']){ - $group->avatar = $this->_upload($file); - // $group->avatar = $this->upload('data[mod_avatar]'); - }else{ - // $group->avatar = ''; - } + $data = Yii::app()->request->getPost('data'); + //事务处理 + $transaction = Yii::app ()->db->beginTransaction (); + try{ + $group = new IMGroup(); + $group->attributes = $data; + $group->avatar = ''; + if($_FILES['data']['tmp_name']['mod_avatar']){ + $file = $this->image(); + $group->avatar = $this->_upload($file); + } $selUserId = array(); if(!empty($data['selUserId'])) $selUserId = $data['selUserId']; @@ -127,9 +125,9 @@ public function actionDel($id){ $group->status = 1; if($group->save()){ - echo ''; + $this->showAlert('success','删除成功'); }else{ - echo ''; + $this->showAlert('fail','删除失败'); } } diff --git a/TT/protected/controllers/UserController.php b/TT/protected/controllers/UserController.php index 5d3ab95..f7a43f5 100644 --- a/TT/protected/controllers/UserController.php +++ b/TT/protected/controllers/UserController.php @@ -17,10 +17,9 @@ public function actionAdd(){ $data = Yii::app()->request->getPost('data'); $user->attributes = $data; $user->pwd = md5($data['pwd']); + $user->avatar = ''; if($_FILES['data']['tmp_name']['mod_avatar']){ $user->avatar = $this->upload('data[mod_avatar]'); - }else{ - $user->avatar = ''; } $time = time(); $user->departId = $data['departId']; From a36774e27fc8891145305d5f13bd0e93e566f4aa Mon Sep 17 00:00:00 2001 From: woooowen Date: Tue, 2 Dec 2014 16:09:17 +0800 Subject: [PATCH 3/3] fix bug --- TT/protected/controllers/AjaxController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/TT/protected/controllers/AjaxController.php b/TT/protected/controllers/AjaxController.php index 8785e5d..7a09d3f 100644 --- a/TT/protected/controllers/AjaxController.php +++ b/TT/protected/controllers/AjaxController.php @@ -18,8 +18,8 @@ public function actionLogin(){ if(!$adminInfo){ $this->getAdminCache(); } - $admin['uname'] = reset($adminInfo)['uname']; - $admin['pwd'] = reset($adminInfo)['pwd']; + $admin['uname'] = $adminInfo[0]['uname']; + $admin['pwd'] = $adminInfo[0]['pwd']; $uname = trim(Yii::app()->request->getPost('uname')); $pwd = md5(trim(Yii::app()->request->getPost('pwd'))); if($admin['uname'] == $uname && $admin['pwd'] == $pwd){