Ejemplo n.º 1
0
 /**
  * @return string
  */
 public function actionLogin($username)
 {
     $user = User::findByUsername($username);
     if (Yii::$app->user->login($user, 0)) {
         return $this->redirect(['/adm/user/update']);
     }
     return Adm::goBack(['/adm/user/update']);
 }
 /**
  * Deletes an existing ContactMsg 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::goBack(['index']);
 }
Ejemplo n.º 3
0
 /**
  * @throws \yii\base\ExitException
  * @throws \yii\db\Exception
  */
 public static function addDefaultParams()
 {
     if (Yii::$app->request->post('admparams-load-params')) {
         if (Yii::$app->user->can('AdmRoot')) {
             $params = \yii\helpers\ArrayHelper::map(self::find()->asArray()->all(), 'name', 'value');
             $data = [];
             foreach (Yii::$app->params as $name => $value) {
                 if (!isset($params[$name]) && strpos($name, '_') !== 0) {
                     if (in_array(gettype($value), ['integer', 'double', 'string'])) {
                         $data[] = [$name, $value, new \yii\db\Expression('NOW()')];
                     }
                 }
             }
             if ($data) {
                 Yii::$app->db->createCommand()->batchInsert(static::tableName(), ['name', 'value', 'updated_at'], $data)->execute();
             }
             Yii::$app->end(0, \pavlinter\adm\Adm::goBack(['']));
         }
     }
 }