public function getLastData() { $updatepass = CRequest::param("updatepass"); if ($updatepass) { if (\Yii::$app->user->identity->username == "admin") { #如果是demo,则不允许修改密码。 if (CConfig::param("is_demo")) { echo json_encode(["statusCode" => "300", "message" => "demo是为了让大家看,admin账户不允许修改密码,请自己添加账户"]); exit; } } $AdminUserResetPassword = new AdminUserResetPassword(); $AdminUserResetPassword->attributes = $updatepass; if ($AdminUserResetPassword->validate()) { $AdminUserResetPassword->updatePassword(); echo json_encode(["statusCode" => "200", "message" => 'Update Password Success']); } else { $errors = $AdminUserResetPassword->errors; echo json_encode(["statusCode" => "300", "message" => CModel::getErrorStr($errors)]); } exit; } $adminUser = \Yii::$app->user->identity; $current_account = $adminUser->username; $editUrl = CUrl::getUrl("fecadmin/myaccount/index"); return ['current_account' => $current_account, 'editUrl' => $editUrl]; }
public function actionIndex() { if (CRequest::param("method") == 'reflush') { $this->getBlock()->reflush(); } $data = $this->getBlock()->getLastData(); return $this->render($this->action->id, $data); }
public function getTableTbodyHtml($data) { $fileds = $this->getTableFieldArr(); $str .= ''; $csrfString = \fec\helpers\CRequest::getCsrfString(); foreach ($data as $one) { $str .= '<tr target="sid_user" rel="' . $one[$this->_paramKey] . '">'; $str .= '<td><input name="' . $this->_paramKey . 's" value="' . $one[$this->_paramKey] . '" type="checkbox"></td>'; foreach ($fileds as $field) { $orderField = $field['orderField']; $display = $field['display']; $val = $one[$orderField]; $originVal = $one[$orderField]; if ($val) { if (isset($field['display']) && !empty($field['display'])) { $display = $field['display']; $val = $display[$val] ? $display[$val] : $val; } if (isset($field['convert']) && !empty($field['convert'])) { $convert = $field['convert']; foreach ($convert as $origin => $to) { if (strstr($origin, 'date')) { if ($to == 'date') { $val = date('Y-m-d', strtotime($val)); } else { if ($to == 'datetime') { $val = date('Y-m-d H:i:s', strtotime($val)); } else { if ($to == 'int') { $val = strtotime($val); } } } } else { if ($origin == 'int') { if ($to == 'date') { $val = date('Y-m-d', $val); } else { if ($to == 'datetime') { $val = date('Y-m-d H:i:s', $val); } else { if ($to == 'int') { $val = $val; } } } } } } } } $str .= '<td><span title=' . $originVal . '>' . $val . '</span></td>'; } $str .= '</tr>'; } return $str; }
public function getLastData() { $updatepass = CRequest::param("updatepass"); if ($updatepass) { $AdminUserResetPassword = new AdminUserResetPassword(); $AdminUserResetPassword->attributes = $updatepass; if ($AdminUserResetPassword->validate()) { $AdminUserResetPassword->updatePassword(); echo json_encode(["statusCode" => "200", "message" => 'Update Password Success']); } else { $errors = $AdminUserResetPassword->errors; echo json_encode(["statusCode" => "300", "message" => CModel::getErrorStr($errors)]); } exit; } $adminUser = \Yii::$app->user->identity; $current_account = $adminUser->username; $editUrl = CUrl::getUrl("fecadmin/account/index"); return ['current_account' => $current_account, 'editUrl' => $editUrl]; }
public function actionIndex() { $isGuest = Yii::$app->user->isGuest; //echo $isGuest;exit; if (!$isGuest) { $this->redirect("/", 200); } $errors = ''; $loginParam = \fec\helpers\CRequest::param('login'); if ($loginParam) { //echo 1;exit; $AdminUserLogin = new AdminUserLogin(); $AdminUserLogin->attributes = $loginParam; if ($AdminUserLogin->login()) { $this->redirect("/", 200); } else { $errors = CModel::getErrorStr($AdminUserLogin->errors); } } $this->layout = "login.php"; return $this->render('index', ['error' => $errors]); }
echo CRequest::getCsrfInputHtml(); ?> <?php echo $pagerForm; ?> </form> <div class="pageHeader"> <form rel="pagerForm" onsubmit="return navTabSearch(this);" action="<?php echo \fec\helpers\CUrl::getCurrentUrl(); ?> " method="post"> <?php echo CRequest::getCsrfInputHtml(); ?> <div class="searchBar"> <?php echo $searchBar; ?> </div> </form> </div> <div class="pageContent"> <div class="panelBar"> <?php //echo $editBar; ?> </div> <div class="panelBar">
public function delete() { //$request_param = CRequest::param(); //$this->_param = $request_param; //$this->initParam(); if ($role_id = CRequest::param($this->_paramKey)) { $model = AdminRole::findOne([$this->_paramKey => $role_id]); if ($model->role_id) { $innerTransaction = Yii::$app->db->beginTransaction(); try { $model->delete(); # 删除这个role 对应的所有关联的菜单 AdminRoleMenu::deleteAll(['role_id' => $role_id]); $innerTransaction->commit(); } catch (Exception $e) { $innerTransaction->rollBack(); } echo json_encode(["statusCode" => "200", "message" => 'Delete Success!']); exit; } else { echo json_encode(["statusCode" => "300", "message" => "role_id => {$role_id} , is not exist"]); exit; } } else { if ($ids = CRequest::param($this->_paramKey . 's')) { $id_arr = explode(",", $ids); $innerTransaction = Yii::$app->db->beginTransaction(); try { AdminRole::deleteAll(['in', 'role_id', $id_arr]); # 删除这个role 对应的所有关联的菜单 AdminRoleMenu::deleteAll(['in', 'role_id', $id_arr]); $innerTransaction->commit(); } catch (Exception $e) { $innerTransaction->rollBack(); } echo json_encode(["statusCode" => "200", "message" => "{$ids} Delete Success!"]); exit; } } echo json_encode(["statusCode" => "300", "message" => "role_id or ids Param is not Exist!"]); exit; }
public function reflush() { $cacheStr = CRequest::param("ids"); $cacheArr = explode(",", $cacheStr); foreach ($cacheArr as $cacheType) { $cacheType = trim($cacheType); if ($cacheType == all_cache) { CCache::flushAll(); } } echo json_encode(array("statusCode" => "200", "message" => "reflush cache success")); exit; }
public function delete() { //$request_param = CRequest::param(); //$this->_param = $request_param; //$this->initParam(); # admin 用户不能删除 if ($id = CRequest::param('id')) { $model = AdminConfig::findOne(['id' => $id]); if ($model->id) { $model->delete(); echo json_encode(["statusCode" => "200", "message" => 'Delete Success!']); exit; } else { echo json_encode(["statusCode" => "300", "message" => "id => {$id} , is not exist"]); exit; } } else { if ($ids = CRequest::param('ids')) { $id_arr = explode(",", $ids); AdminConfig::deleteAll(['in', 'id', $id_arr]); echo json_encode(["statusCode" => "200", "message" => "{$ids} Delete Success!"]); exit; } } echo json_encode(["statusCode" => "300", "message" => "id or ids Param is not Exist!"]); exit; }
public function delete() { //$request_param = CRequest::param(); //$this->_param = $request_param; //$this->initParam(); # admin 用户不能删除 if ($id = CRequest::param('id')) { $model = AdminUserForm::findOne(['id' => $id]); if ($model->id) { # 不允许删除admin if ($model->username == 'admin') { echo json_encode(["statusCode" => "300", "message" => 'You can not delete Admin User!']); exit; } $innerTransaction = Yii::$app->db->beginTransaction(); try { $model->delete(); AdminUserRole::deleteAll(['user_id' => $model->id]); $innerTransaction->commit(); } catch (Exception $e) { $innerTransaction->rollBack(); echo json_encode(["statusCode" => "300", "message" => 'Delete Fail !']); exit; } echo json_encode(["statusCode" => "200", "message" => 'Delete Success!']); exit; } else { echo json_encode(["statusCode" => "300", "message" => "id => {$id} , is not exist"]); exit; } } else { if ($ids = CRequest::param('ids')) { $id_arr = explode(",", $ids); # 不允许删除admin $adminUser = AdminUserForm::findOne(['username' => 'admin']); $adminUserId = $adminUser->id; if (in_array($adminUserId, $id_arr)) { echo json_encode(["statusCode" => "300", "message" => 'You can not delete Admin User!']); exit; } $innerTransaction = Yii::$app->db->beginTransaction(); try { AdminUserForm::deleteAll(['in', 'id', $id_arr]); AdminUserRole::deleteAll(['in', 'user_id', $id_arr]); $innerTransaction->commit(); } catch (Exception $e) { $innerTransaction->rollBack(); echo json_encode(["statusCode" => "300", "message" => 'Delete All Fail !']); exit; } echo json_encode(["statusCode" => "200", "message" => "{$ids} Delete Success!"]); exit; } } echo json_encode(["statusCode" => "300", "message" => "id or ids Param is not Exist!"]); exit; }
public function getTableTbodyHtml($data) { $fileds = $this->getTableFieldArr(); $str .= ''; $csrfString = \fec\helpers\CRequest::getCsrfString(); foreach ($data as $one) { $str .= '<tr target="sid_user" rel="' . $one[$this->_paramKey] . '">'; $str .= '<td><input name="' . $this->_paramKey . 's" value="' . $one[$this->_paramKey] . '" type="checkbox"></td>'; foreach ($fileds as $field) { $orderField = $field['orderField']; $display = $field['display']; $val = $one[$orderField]; if ($val) { if (isset($field['display']) && !empty($field['display'])) { $display = $field['display']; $val = $display[$val] ? $display[$val] : $val; } if (isset($field['convert']) && !empty($field['convert'])) { $convert = $field['convert']; foreach ($convert as $origin => $to) { if (strstr($origin, 'date')) { if ($to == 'date') { $val = date('Y-m-d', strtotime($val)); } else { if ($to == 'datetime') { $val = date('Y-m-d H:i:s', strtotime($val)); } else { if ($to == 'int') { $val = strtotime($val); } } } } else { if ($origin == 'int') { if ($to == 'date') { $val = date('Y-m-d', $val); } else { if ($to == 'datetime') { $val = date('Y-m-d H:i:s', $val); } else { if ($to == 'int') { $val = $val; } } } } } } } } $str .= '<td>' . $val . '</td>'; } $str .= '<td> <a title="编辑" target="dialog" class="btnEdit" mask="true" drawable="true" width="1000" height="580" href="' . $this->_editUrl . '?' . $this->_paramKey . '=' . $one[$this->_paramKey] . '" >编辑</a> <a title="删除" target="ajaxTodo" href="' . $this->_deleteUrl . '?' . $csrfString . '&' . $this->_paramKey . '=' . $one[$this->_paramKey] . '" class="btnDel">删除</a> </td>'; $str .= '</tr>'; } return $str; }
public function deleteMenu() { $id = CRequest::param("id"); if (!$id) { echo json_encode(["statusCode" => "300", "message" => "id can not empty"]); exit; } else { $one = AdminMenu::find()->where(" id = " . $id . " AND can_delete = 2 ")->one(); //echo $one->id; if ($one->id) { $ids = $this->getMenuAllChildId($id); $ids[] = $id; # 1. 删除当前分类对应的所有子分类 # 2. 删除在menu_id 对应到权限中的所有menu_id $innerTransaction = Yii::$app->db->beginTransaction(); try { AdminRoleMenu::deleteAll(['in', 'menu_id', $ids]); $idsStr = implode(",", $ids); $one->deleteAll(" id in (" . $idsStr . ") AND can_delete = 2"); $innerTransaction->commit(); echo json_encode(["statusCode" => "200", "message" => "delete menu success! MENU NAME:" . $one->name]); } catch (Exception $e) { $innerTransaction->rollBack(); } exit; } else { echo json_encode(["statusCode" => "300", "message" => "the menu can not delete"]); exit; } } }
public function getTableTbodyHtml($data) { $fileds = $this->getTableFieldArr(); $str .= ''; $csrfString = \fec\helpers\CRequest::getCsrfString(); foreach ($data as $one) { $str .= '<tr target="sid_user" rel="' . $one[$this->_paramKey] . '">'; foreach ($fileds as $field) { $orderField = $field['orderField']; $display = $field['display']; $val = $one[$orderField]; if ($val) { if (isset($field['display']) && !empty($field['display'])) { $display = $field['display']; $val = $display[$val] ? $display[$val] : $val; } if (isset($field['convert']) && !empty($field['convert'])) { $convert = $field['convert']; foreach ($convert as $origin => $to) { if (strstr($origin, 'mongodate')) { if (isset($val->sec)) { $timestramp = $val->sec; if ($to == 'date') { $val = date('Y-m-d', $timestramp); } else { if ($to == 'datetime') { $val = date('Y-m-d H:i:s', $timestramp); } else { if ($to == 'int') { $val = $timestramp; } } } } } else { if (strstr($origin, 'date')) { if ($to == 'date') { $val = date('Y-m-d', strtotime($val)); } else { if ($to == 'datetime') { $val = date('Y-m-d H:i:s', strtotime($val)); } else { if ($to == 'int') { $val = strtotime($val); } } } } else { if ($origin == 'int') { if ($to == 'date') { $val = date('Y-m-d', $val); } else { if ($to == 'datetime') { $val = date('Y-m-d H:i:s', $val); } else { if ($to == 'int') { $val = $val; } } } } else { if ($origin == 'string') { if ($to == 'img') { $t_width = isset($field['img_width']) ? $field['img_width'] : '100'; $t_height = isset($field['img_height']) ? $field['img_height'] : '100'; $val = '<img style="width:' . $t_width . 'px;height:' . $t_height . 'px" src="' . $val . '" />'; } } } } } } } } $str .= '<td>' . $val . '</td>'; } $str .= '</tr>'; } return $str; }
public function delete() { //$request_param = CRequest::param(); //$this->_param = $request_param; //$this->initParam(); # admin 用户不能删除 if ($id = CRequest::param('id')) { $model = AdminUserForm::findOne(['id' => $id]); if ($model->id) { # 不允许删除admin if ($model->username == 'admin') { echo json_encode(["statusCode" => "300", "message" => 'You can not delete Admin User!']); exit; } $model->delete(); echo json_encode(["statusCode" => "200", "message" => 'Delete Success!']); exit; } else { echo json_encode(["statusCode" => "300", "message" => "id => {$id} , is not exist"]); exit; } } else { if ($ids = CRequest::param('ids')) { $id_arr = explode(",", $ids); # 不允许删除admin $adminUser = AdminUserForm::findOne(['username' => 'admin']); $adminUserId = $adminUser->id; if (in_array($adminUserId, $id_arr)) { echo json_encode(["statusCode" => "300", "message" => 'You can not delete Admin User!']); exit; } AdminUserForm::deleteAll(['in', 'id', $id_arr]); echo json_encode(["statusCode" => "200", "message" => "{$ids} Delete Success!"]); exit; } } echo json_encode(["statusCode" => "300", "message" => "id or ids Param is not Exist!"]); exit; }