Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix some litter problem #11

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions TT/protected/controllers/AdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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','原始密码错误');
}
}

Expand Down
26 changes: 9 additions & 17 deletions TT/protected/controllers/ConfigController.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,12 @@ public function actionAdd(){
if(empty($oldconfig)){
$config = new IMConfig();
$config->attributes = $data;
if($config->save()){
echo '<div class="alert alert-success" role="alert">添加成功</div>';
}else{
echo '<div class="alert alert-danger" role="alert">添加成功</div>';
}

$config->save();
$this->showAlert('success','添加成功');
}else{
$oldconfig->attributes = $data;
if($oldconfig->update()){
echo '<div class="alert alert-success" role="alert">修改成功</div>';
}else{
echo '<div class="alert alert-danger" role="alert">修改成功</div>';
}
$oldconfig->update();
$this->showAlert('success','添加成功');
}
}
$this->render('add',array(
Expand Down Expand Up @@ -83,12 +76,11 @@ public function actionDel($id){
if(empty($id))
return;


$count = IMDepartment::model()->deleteByPk($id);
if($count > 0){
echo '<div class="alert alert-success" role="alert">添加成功</div>';
$this->showAlert('success','删除成功');
}else{
echo '<div class="alert alert-success" role="alert">添加成功</div>';
$this->showAlert('fail','删除失败');
}

}
Expand All @@ -111,7 +103,7 @@ public function actionEdit($id){
$time = time();
$depart->updated = $time;
if($depart->update()){
echo '<div class="alert alert-success" role="alert">修改成功</div>';
$this->showAlert('success','删除成功');
$departs = IMDepartment::model()->findAll(array(
'condition' => 'status = 0',
));
Expand All @@ -127,7 +119,7 @@ public function actionEdit($id){
if(!empty($cache))
Yii::app()->cache->set('cache_depart',$cache);
}else{
echo '<div class="alert alert-danger" role="alert">修改失败</div>';
$this->showAlert('fail','删除失败');
}
}
$users = Yii::app()->cache->get('cache_user');
Expand All @@ -154,4 +146,4 @@ public function actionJson(){
}


}
}
14 changes: 6 additions & 8 deletions TT/protected/controllers/DepartController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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){
Expand All @@ -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','修改成功');
Expand Down
28 changes: 13 additions & 15 deletions TT/protected/controllers/GroupController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
Expand Down Expand Up @@ -127,9 +125,9 @@ public function actionDel($id){
$group->status = 1;

if($group->save()){
echo '<div class="alert alert-success" role="alert">删除成功</div>';
$this->showAlert('success','删除成功');
}else{
echo '<div class="alert alert-success" role="alert">删除失败</div>';
$this->showAlert('fail','删除失败');
}
}

Expand Down
3 changes: 1 addition & 2 deletions TT/protected/controllers/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
Expand Down