public function checkCredentials() { # Check login credentials against the DB $sql = ""; $sqlResult = $this->db_main->get_row($sql); if (empty($sqlResult) || !isset($sqlResult)) { $this->errorMsg = "Login credentials were invalid or no matches found."; return false; } if (!empty($sqlResult[1]) && !empty($sqlResult[0])) { require BASE_DIR . "/" . LIB_DIR . "/Security.php"; $sec = new Security($this->db_main, $sqlResult[1], $sqlResult[0]); $moduleAccess = $sec->checkModuleAccess(1, "view"); if (!$moduleAccess || is_array($moduleAccess) && empty($moduleAccess[0])) { $this->errorMsg = $moduleAccess[1]; return false; } } else { $this->errorMsg = "Login credentials were invalid or account does not have sufficient access."; return false; } return $sqlResult[1]; }
/** * Generates new password reset token */ public function generatePasswordResetToken() { $this->password_reset_token = Security::generateRandomKey() . '_' . time(); }
echo Html::encode($this->title); ?> </h1> <?php // echo $this->render('_search', ['model' => $searchModel]); ?> <p> <?php echo Html::a('Create Comentario', ['create'], ['class' => 'btn btn-success']); ?> </p> <?php echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'id', 'nombre', ['attribute' => 'correo', 'value' => function ($searchModel) { return Security::decrypt($searchModel->correo); }], 'comentario', 'estado', ['class' => 'yii\\grid\\ActionColumn', 'template' => '{update} {delete} {aprobar}', 'buttons' => ['aprobar' => function ($url, $model) { if ($model->estado == 0) { return Html::a('<span class="glyphicon glyphicon-thumbs-up"></span>', $url, ['title' => 'aprobar']); } }, 'update' => function ($url, $model) { return Html::a('<span class="glyphicon glyphicon-pencil"></span>', $url, ['title' => 'Actualizar']); }], 'urlCreator' => function ($action, $model, $key, $index) { if ($action === 'aprobar') { return yii\helpers\Url::to(['comentario/aprobar', 'id' => $key]); } elseif ($action == 'update') { return yii\helpers\Url::to(['comentario/update/', 'id' => $key]); } elseif ($action === 'delete') { return yii\helpers\Url::to(['comentario/delete/', 'id' => $key]); } }]]]);
/** * * @return \yii\db\ActiveQuery */ public function getSecurities() { return $this->hasMany(Security::className(), ['domain_id' => 'id']); }
public function actionNoticia($slug) { $categorias = Categoria::find()->all(); $noticia = Noticia::find("seo_slug = :slug", [":slug" => $slug])->one(); $comentario = new Comentario(["scenario" => "comentario"]); if ($comentario->load(Yii::$app->request->post())) { $comentario->estado = '0'; $comentario->noticia_id = $noticia->id; $comentario->fecha = new Expression("NOW()"); $comentario->correo = Security::mcrypt($comentario->correo); if ($comentario->save()) { Yii::$app->session->setFlash('success', 'Gracias por su comentario'); } else { Yii::$app->session->setFlash('error', 'Su comentario no pudo ser registrado'); } return $this->redirect(["/noticia/{$slug}"]); } return $this->render('noticia', ['comentario' => $comentario, 'categorias' => $categorias, 'noticia' => $noticia]); }