コード例 #1
0
 public function actionComment($cid)
 {
     $idu = Yii::$app->user->getId();
     $uid = new components\UserId($idu);
     $comment = PostsService::getCommentById($cid);
     $nothing = $comment->getAuthor();
     $commentOwner = $nothing->getId();
     //die(var_dump($commentOwner));
     if (!Yii::$app->user->can('admin')) {
         if ($commentOwner != $idu) {
             return $this->redirect('/intouch/accessdenied');
         }
     }
     if (Yii::$app->request->isPost) {
         try {
             $id = Yii::$app->request->post('comment_id');
             $comment = PostsService::getCommentById($id);
             $comment->changeContent(Yii::$app->request->post('inputContent'));
             PostsService::saveComment($comment);
         } catch (exception $e) {
         }
         EventService::createEvent(components\EEvent::ACCOUNT_INFO_CHANGED(), $uid);
         Yii::$app->session->setFlash('success', 'Comment\'s been Succesfuly Updated');
         return $this->redirect('/profile');
     }
     return $this->render('comment', ['comment' => $comment]);
 }
コード例 #2
0
								<?php 
$lastDate = (new DateTime())->format("Y-m-d");
foreach ($timeline as $event) {
    $dateChanged = $event->getEventDate("Y-m-d") != $lastDate;
    $userConnected = $event->getEventOwner();
    $userConnectedDefault = true;
    $content = "Unknown Event Type";
    $icon = "fa-exclamation-triangle";
    $color = "bg-red";
    switch ($event->getEventType()) {
        case \common\components\EEvent::ACCOUNT_CREATE():
            $icon = "fa-user-plus";
            $color = "bg-green";
            $content = "<a href='/user/" . $userConnected->getUsername() . "'>" . Yii::t('app', 'You') . "</a>&nbsp\n\t\t\t\t\t\t\t\t                " . Yii::t('app', 'have created an account');
            break;
        case \common\components\EEvent::ACCOUNT_INFO_CHANGED():
            $icon = "fa-user";
            $color = "bg-aqua";
            $content = "<a href='/user/ " . $userConnected->getUsername() . "'>" . Yii::t('app', 'You') . "</a>&nbsp" . Yii::t('app', 'have changed your account details');
            break;
        case \common\components\EEvent::ACCOUNT_PASSWORD_CHANGED():
            $icon = "fa-user-secret";
            $color = "bg-yellow";
            $content = "<a href='/user/" . $userConnected->getUsername() . "'>" . Yii::t('app', 'You') . "</a>&nbsp" . Yii::t('app', 'have changed your password');
            break;
        case \common\components\EEvent::ACCOUNT_PASSWORD_RESET():
            $icon = "fa-user-md";
            $color = "bg-red";
            $content = "<a href='/user/" . $userConnected->getUsername() . "'>" . Yii::t('app', 'You') . "</a>&nbsp" . Yii::t('app', 'have reset your password');
            break;
        case \common\components\EEvent::COMMENT_CREATE():
コード例 #3
0
 public function actionAboutedit()
 {
     $id = Yii::$app->user->getId();
     $uid = new components\UserId($id);
     ////////////////////////////
     $loggedUser = $uid->getUser();
     if (Yii::$app->request->isPost) {
         $loggedUser->setCity(Yii::$app->request->post('inputLocation'));
         $loggedUser->setEducation(Yii::$app->request->post('inputEducation'));
         $loggedUser->setAbout(Yii::$app->request->post('inputNotes'));
         try {
             $bdate = Yii::$app->request->post('inputDate');
             if (strtotime($bdate) - time() > 0) {
                 Yii::$app->session->setFlash('error', 'Hello! It\'s date from future!');
                 return $this->redirect('/profile/aboutedit');
             }
             $loggedUser->setBirthDate(new \DateTime($bdate));
             UserService::saveUser($loggedUser);
         } catch (\common\components\exceptions\InvalidDateException $e) {
             Yii::$app->session->setFlash('error', 'Invalid date');
             return $this->redirect('/profile/aboutedit');
         }
         EventService::createEvent(components\EEvent::ACCOUNT_INFO_CHANGED(), $uid);
         Yii::$app->session->setFlash('success', 'Profile\'s been Succesfuly Updated');
         return $this->redirect('/profile');
     }
     $this->getUserData();
     // refresh
     return $this->render('aboutEdit', []);
 }