/** * Update an existing User model. If update is successful, the browser * will be redirected to the 'view' page. * * @param string $id * @return mixed */ public function actionUpdate($id) { SystemEvent::GetAdminMenu(); // set up user and profile $user = $this->findModel($id); $user->setScenario("admin"); $profile = $user->profile; $old_role = $user->role; // load post data and validate $post = Yii::$app->request->post(); if ($user->load($post) && $user->validate() && $profile->load($post) && $profile->validate()) { $user->save(false); $profile->setUser($user->id)->save(false); //删除授权 Yii::$app->authManager->revoke(Yii::$app->authManager->getRole($old_role), $user->id); //更新授权 Yii::$app->authManager->assign(Yii::$app->authManager->getRole($user->role), $user->id); return $this->redirect(['view', 'id' => $user->id]); } // render return $this->render('update', ['user' => $user, 'profile' => $profile]); }
/** * Profile */ public function actionProfile() { SystemEvent::GetAdminMenu(); /** @var \app\modules\user\models\Profile $profile */ // set up profile and load post data $profile = Yii::$app->user->identity->profile; $loadedPost = $profile->load(Yii::$app->request->post()); // validate for ajax request if ($loadedPost && Yii::$app->request->isAjax) { Yii::$app->response->format = Response::FORMAT_JSON; return ActiveForm::validate($profile); } // validate for normal request if ($loadedPost && $profile->validate()) { $profile->save(false); Yii::$app->session->setFlash("Profile-success", Yii::t("user", "Profile updated")); return $this->refresh(); } // render return $this->render("profile", ['profile' => $profile]); }
public function actionDownloadPlugin() { SystemEvent::GetAdminMenu(); $result['status'] = 0; $url = $this->getParam('url'); $boss = SystemConfig::Get('SYSTEM_BOSS_DOMAIN', NULL, 'USER'); $method = $this->getParam('method'); if ($boss) { $bossUrl = $boss[0]['cfg_value']; $local = $this->_download($bossUrl, $url); if ($local) { $count = $this->_unzip($local, $method); if (is_integer($count)) { $result['status'] = 1; if ('add' == $method) { $result['msg'] = '下载插件成功'; } elseif ("update" == $method) { $result['msg'] = '更新插件成功'; } } else { $result['msg'] = $count; } } else { $result['msg'] = '与boss系统通信失败,请检查boss系统网址配置和服务器网络状况!'; } } else { $result['msg'] = '您还没有配置BOSS系统地址!'; } echo json_encode($result); die; }
public function actionMain() { SystemEvent::GetAdminMenu(); return $this->render('main'); }