本文整理汇总了PHP中pavlinter\adm\Adm::redirect方法的典型用法代码示例。如果您正苦于以下问题:PHP Adm::redirect方法的具体用法?PHP Adm::redirect怎么用?PHP Adm::redirect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pavlinter\adm\Adm
的用法示例。
在下文中一共展示了Adm::redirect方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionUpdate
/**
* Updates an existing ContactMsg model.
* If update is successful, the browser will be redirected to the 'view' page.
* @param integer $id
* @return mixed
*/
public function actionUpdate($id)
{
$model = $this->findModel($id);
if ($model->load(Yii::$app->request->post()) && $model->save()) {
Yii::$app->getSession()->setFlash('success', Adm::t('', 'Data successfully changed!'));
return Adm::redirect(['update', 'id' => $model->id]);
}
return $this->render('update', ['model' => $model]);
}
示例2: actionIndex
/**
* @return string
*/
public function actionIndex()
{
$module = Module::getInstance();
/* @var $model \app\modules\admlivechat\models\SettingsForm */
$model = $module->manager->createSettingsForm();
if ($model->load(Yii::$app->request->post()) && $model->validate()) {
if ($model->save()) {
Yii::$app->getSession()->setFlash('success', Adm::t('', 'Data successfully changed!'));
return Adm::redirect(['index']);
}
}
return $this->render('index', ['model' => $model]);
}
示例3: actionUpdate
/**
* Updates an existing Page model.
* If update is successful, the browser will be redirected to the 'view' page.
* @param string $id
* @param null|integer $id_parent
* @return mixed
*/
public function actionUpdate($id, $id_parent = null)
{
$model = $this->findModel($id);
$model->setLangScenario('update-page-lang');
if ($model->loadAll(Yii::$app->request->post()) && $model->validateAll()) {
if ($model->saveAll(false)) {
Yii::$app->getSession()->setFlash('success', Adm::t('', 'Data successfully changed!'));
if (!$id_parent) {
$id_parent = 0;
}
return Adm::redirect(['update', 'id' => $model->id, 'id_parent' => $id_parent]);
}
}
return $this->render('update', ['model' => $model, 'id_parent' => $id_parent]);
}
示例4: actionDelete
/**
* Deletes an existing Params model.
* If deletion is successful, the browser will be redirected to the 'index' page.
* @param integer $id
* @return mixed
*/
public function actionDelete($id)
{
$this->findModel($id)->delete();
Yii::$app->getSession()->setFlash('success', Adm::t('', 'Data successfully removed!'));
return Adm::redirect(['index']);
}
示例5: actionLogout
/**
* @inheritdoc
*/
public function actionLogout()
{
Adm::getInstance()->user->logout(false);
return Adm::redirect(['login']);
}
示例6: actionUpdate
/**
* Updates an existing User model.
* If update is successful, the browser will be redirected to the 'view' page.
* @param null $id
* @return string|\yii\web\Response
* @throws ForbiddenHttpException
* @throws NotFoundHttpException
* @throws \yii\base\InvalidConfigException
*/
public function actionUpdate($id = null)
{
if ($id === null) {
$id = Adm::getInstance()->user->getId();
}
/* @var $model \pavlinter\adm\models\User */
$model = $this->findModel($id);
if (Adm::getInstance()->user->can('Adm-UpdateOwnUser', $model)) {
$model->setScenario('adm-updateOwn');
} elseif (Adm::getInstance()->user->can('AdmRoot')) {
$model->setScenario('adm-update');
} else {
throw new ForbiddenHttpException('Access denied');
}
$dynamicModel = DynamicModel::validateData(['password', 'password2'], [[['password', 'password2'], 'string', 'min' => 6], ['password2', 'compare', 'compareAttribute' => 'password']]);
$post = Yii::$app->request->post();
if ($model->load($post) && $dynamicModel->load($post)) {
if ($model->validate() && $dynamicModel->validate()) {
if (!empty($dynamicModel->password)) {
$model->setPassword($dynamicModel->password);
}
if (!Adm::getInstance()->user->can('Adm-UpdateOwnUser', $model)) {
//AdmRoot
$auth = Yii::$app->authManager;
$roles = Yii::$app->request->post('roles', []);
$auth->revokeAll($model->id);
//remove all assignments
if (in_array('AdmRoot', $roles) || in_array('AdmAdmin', $roles)) {
$model->role = \app\models\User::ROLE_ADM;
} else {
$model->role = \app\models\User::ROLE_USER;
}
foreach ($roles as $role) {
$newRole = $auth->createRole($role);
$auth->assign($newRole, $model->id);
}
}
$model->save(false);
Yii::$app->getSession()->setFlash('success', Adm::t('', 'Data successfully changed!'));
if (Adm::getInstance()->user->can('Adm-UpdateOwnUser', $model)) {
return $this->refresh();
} else {
//AdmRoot
return Adm::redirect(['update', 'id' => $model->id]);
}
}
}
return $this->render('update', ['model' => $model, 'dynamicModel' => $dynamicModel]);
}
示例7: actionTest
/**
* @return \yii\web\Response
*/
public function actionTest()
{
$error = Module::getInstance()->manager->createEmailConfigQuery('eachEmail', function ($email) {
try {
Yii::$app->mailer->compose()->setTo($email)->setFrom(Yii::$app->params['adminEmailName'])->setSubject(Adm::t('adm_email_config', 'Test subject', ['dot' => false]))->setHtmlBody(Adm::t('adm_email_config', 'Test text', ['dot' => false]))->send();
} catch (\Exception $e) {
if ($e instanceof \Swift_RfcComplianceException) {
Yii::$app->getSession()->setFlash('error', Adm::t('adm_email_config', 'Maybe incorrect email address: {error}', ['error' => $e->getMessage(), 'dot' => true]));
} else {
Yii::$app->getSession()->setFlash('error', Adm::t('adm_email_config', 'Error: {error}', ['error' => $e->getMessage(), 'dot' => true]));
}
return true;
}
});
if ($error) {
Yii::$app->getSession()->removeFlash('success');
} else {
Yii::$app->getSession()->setFlash('success', Adm::t('adm_email_config', 'Email sent!', ['dot' => true]));
}
return Adm::redirect(['update']);
}