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

部分变量初始化 #12

Open
wants to merge 1 commit 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
35 changes: 19 additions & 16 deletions TT/protected/components/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ public function getDepartCache(){
$departs = IMDepartment::model()->findAll(array(
'condition' => 'status = 0',
));
$cache = array();
foreach($departs as $k => $v){
$cache[$k]['id'] = $v->id;
$cache[$k]['title'] = $v->title;
Expand All @@ -161,6 +162,7 @@ public function getUserCache(){
$users = IMUsers::model()->findAll(array(
'condition' => 'status = 0',
));
$cache = array();
foreach($users as $k => $v){
$cache[$k]['userId'] = $v->id;
$cache[$k]['title'] = $v->title;
Expand All @@ -178,22 +180,23 @@ public function getAdminCache(){
$adminInfo = IMAdmin::model()->findAll(array(
'condition' => 'status = 0',
));
if(empty($adminInfo)){
$adminInfo = new IMAdmin();
$adminInfo->uname = Yii::app()->params['defaultAdminUname'];
$adminInfo->pwd = md5(Yii::app()->params['defaultAdminPwd']);
$adminInfo->status = 0;
$adminInfo->created = time();
if($adminInfo->save()){
$cache['id'] = $adminInfo->id;
$cache['uname'] = $adminInfo->uname;
$cache['pwd'] = $adminInfo->pwd;

if(!empty($cache))
Yii::app()->cache->set('cache_admininfo',$cache);
return $cache;
}
}
$cache = array();
if(empty($adminInfo)){
$adminInfo = new IMAdmin();
$adminInfo->uname = Yii::app()->params['defaultAdminUname'];
$adminInfo->pwd = md5(Yii::app()->params['defaultAdminPwd']);
$adminInfo->status = 0;
$adminInfo->created = time();
if($adminInfo->save()){
$cache['id'] = $adminInfo->id;
$cache['uname'] = $adminInfo->uname;
$cache['pwd'] = $adminInfo->pwd;

if(!empty($cache))
Yii::app()->cache->set('cache_admininfo',$cache);
return $cache;
}
}
foreach($adminInfo as $k => $v){
$cache[$k]['id'] = $v->id;
$cache[$k]['uname'] = $v->uname;
Expand Down
1 change: 1 addition & 0 deletions TT/protected/controllers/ConfigController.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public function actionList($page = 1){
$count = IMDepartment::model()->count();
$pager = new CPagination($count);
$pager->pageSize = Yii::app()->params['perPage'];
$data = array();
if(empty($page))
$pager->currentPage = 1;

Expand Down
1 change: 1 addition & 0 deletions TT/protected/controllers/DepartController.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public function actionList($page = 1){
));
$pager = new CPagination($count);
$pager->pageSize = Yii::app()->params['perPage'];
$data = array();
if(empty($page))
$pager->currentPage = 1;

Expand Down
2 changes: 1 addition & 1 deletion TT/protected/controllers/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function actionList($page = 1){
));
$pager = new CPagination($count);
$pager->pageSize = Yii::app()->params['perPage'];

$data = array();
if(empty($page))
$pager->currentPage = 1;

Expand Down