diff --git a/assets/CodeMirrorButtonsAsset.php b/assets/CodeMirrorButtonsAsset.php index 5ab95a3..6d9c100 100644 --- a/assets/CodeMirrorButtonsAsset.php +++ b/assets/CodeMirrorButtonsAsset.php @@ -4,6 +4,9 @@ use yii\web\AssetBundle; +/** + * CodeMirrorButtonsAsset is for buttons plugin for CodeMirror + */ class CodeMirrorButtonsAsset extends AssetBundle { public $sourcePath = '@bower/codemirror-buttons'; diff --git a/commands/RbacController.php b/commands/RbacController.php index 28164fe..a56d0c8 100644 --- a/commands/RbacController.php +++ b/commands/RbacController.php @@ -11,7 +11,7 @@ class RbacController extends Controller { public function actionInit() { - if (!$this->confirm("Are you sure? It will re-create permissions tree.")) { + if (!$this->confirm('Are you sure? It will re-create permissions tree.')) { return self::EXIT_CODE_NORMAL; } diff --git a/components/UserPermissions.php b/components/UserPermissions.php index dda32dd..986f540 100644 --- a/components/UserPermissions.php +++ b/components/UserPermissions.php @@ -5,14 +5,20 @@ use app\models\News; -use app\models\Project; use app\models\User; +/** + * UserPermissions contains various methods to check what user can do + */ class UserPermissions { const ADMIN_NEWS = 'adminNews'; const ADMIN_USERS = 'adminUsers'; + /** + * Checks if user can admin news + * @return bool + */ public static function canAdminNews() { if (\Yii::$app->user->isGuest) { @@ -26,6 +32,11 @@ public static function canAdminNews() return false; } + /** + * Checks if user can edit particular news + * @param News $news + * @return bool + */ public static function canEditNews(News $news) { if (\Yii::$app->user->isGuest) { @@ -44,6 +55,10 @@ public static function canEditNews(News $news) return false; } + /** + * Checks if user can admin other users + * @return bool + */ public static function canAdminUsers() { if (\Yii::$app->user->isGuest) { @@ -57,6 +72,11 @@ public static function canAdminUsers() return false; } + /** + * Checks if user can edit profile + * @param User $user + * @return bool + */ public static function canEditUser(User $user) { if (\Yii::$app->user->isGuest) { diff --git a/controllers/CommentController.php b/controllers/CommentController.php index c0227be..214a8ba 100644 --- a/controllers/CommentController.php +++ b/controllers/CommentController.php @@ -8,6 +8,9 @@ use yii\web\Controller; use yii\web\NotFoundHttpException; +/** + * CommentController + */ class CommentController extends Controller { /** @@ -30,6 +33,9 @@ public function behaviors() ]; } + /** + * @return string + */ public function actionIndex() { $query = Comment::find()->orderBy('id DESC'); @@ -43,6 +49,10 @@ public function actionIndex() ]); } + /** + * @param int $id + * @return \yii\web\Response + */ public function actionDelete($id) { $this->findModel($id)->delete(); diff --git a/controllers/NewsController.php b/controllers/NewsController.php index 222d422..a0d7bab 100644 --- a/controllers/NewsController.php +++ b/controllers/NewsController.php @@ -21,8 +21,14 @@ use yii\web\NotFoundHttpException; use yii\filters\VerbFilter; +/** + * NewsController + */ class NewsController extends Controller { + /** + * @inheritdoc + */ public function behaviors() { return [ @@ -51,6 +57,9 @@ public function behaviors() ]; } + /** + * @return string + */ public function actionIndex() { $dataProvider = new ActiveDataProvider([ @@ -63,6 +72,9 @@ public function actionIndex() ]); } + /** + * @return string + */ public function actionSuggest() { $model = new News([ @@ -115,6 +127,10 @@ public function actionRss() $feed->render(); } + /** + * @param int $status + * @return string + */ public function actionAdmin($status) { $query = News::find()->orderBy('created_at DESC'); @@ -131,6 +147,11 @@ public function actionAdmin($status) ]); } + /** + * @param int $id + * @return string|\yii\web\Response + * @throws ForbiddenHttpException + */ public function actionUpdate($id) { $model = $this->findModel($id); @@ -152,6 +173,10 @@ public function actionUpdate($id) ]); } + /** + * @param int $id + * @return \yii\web\Response + */ public function actionDelete($id) { $this->findModel($id)->delete(); @@ -160,6 +185,10 @@ public function actionDelete($id) } + /** + * @param int $id + * @return string|\yii\web\Response + */ public function actionView($id) { $news = $this->findModel($id); @@ -177,6 +206,10 @@ public function actionView($id) ]); } + /** + * @param News $news + * @param Comment $comment + */ private function notifyAboutComment(News $news, Comment $comment) { $users = []; @@ -199,6 +232,11 @@ private function notifyAboutComment(News $news, Comment $comment) } } + /** + * @param int $id + * @return null|News + * @throws NotFoundHttpException + */ protected function findModel($id) { if (($model = News::findOne($id)) !== null) { diff --git a/controllers/SiteController.php b/controllers/SiteController.php index a4adc17..a0da96a 100644 --- a/controllers/SiteController.php +++ b/controllers/SiteController.php @@ -3,21 +3,21 @@ namespace app\controllers; use app\components\AuthHandler; -use app\models\Auth; use app\models\PasswordResetRequestForm; use app\models\ResetPasswordForm; use app\models\SignupForm; -use app\models\User; use Yii; use yii\authclient\ClientInterface; use yii\base\InvalidParamException; use yii\filters\AccessControl; -use yii\helpers\ArrayHelper; use yii\web\BadRequestHttpException; use yii\web\Controller; use yii\filters\VerbFilter; use app\models\LoginForm; +/** + * SiteController + */ class SiteController extends Controller { /** @@ -79,6 +79,9 @@ public function onAuthSuccess($client) (new AuthHandler($client))->handle(); } + /** + * @return string + */ public function actionLogin() { if (!\Yii::$app->user->isGuest) { @@ -88,13 +91,15 @@ public function actionLogin() $model = new LoginForm(); if ($model->load(Yii::$app->request->post()) && $model->login()) { return $this->goBack(); - } else { - return $this->render('login', [ - 'model' => $model, - ]); } + return $this->render('login', [ + 'model' => $model, + ]); } + /** + * @return \yii\web\Response + */ public function actionLogout() { Yii::$app->user->logout(); @@ -102,17 +107,23 @@ public function actionLogout() return $this->goHome(); } + /** + * @return string + */ public function actionAbout() { return $this->render('about'); } + /** + * @return string|\yii\web\Response + */ public function actionSignup() { $model = new SignupForm(); if ($model->load(Yii::$app->request->post())) { if ($user = $model->signup()) { - if (Yii::$app->getUser()->login($user, 3600 * 24 * 30)) { + if (Yii::$app->getUser()->login($user, Yii::$app->params['user.rememberMeDuration'])) { return $this->goHome(); } } @@ -123,6 +134,9 @@ public function actionSignup() ]); } + /** + * @return string|\yii\web\Response + */ public function actionRequestPasswordReset() { $model = new PasswordResetRequestForm(); @@ -131,9 +145,8 @@ public function actionRequestPasswordReset() Yii::$app->getSession()->setFlash('success', 'Check your email for further instructions.'); return $this->goHome(); - } else { - Yii::$app->getSession()->setFlash('error', 'Sorry, we are unable to reset password for email provided.'); } + Yii::$app->getSession()->setFlash('error', 'Sorry, we are unable to reset password for email provided.'); } return $this->render('requestPasswordResetToken', [ @@ -141,6 +154,11 @@ public function actionRequestPasswordReset() ]); } + /** + * @param string $token + * @return string|\yii\web\Response + * @throws BadRequestHttpException + */ public function actionResetPassword($token) { try {