Ejemplo n.º 1
0
 /**
  * MainEditPageModel constructor.
  * @param $title
  * @param bool $isRequest
  */
 public function __construct($title, $isRequest = false)
 {
     parent::__construct($title);
     if ($isRequest) {
         $this->id = $_REQUEST['Id'];
         $this->pageTitle = $_REQUEST['Title'];
         $this->metaKeywords = $_REQUEST['MetaKeywords'];
         $this->metaDescription = $_REQUEST['MetaDescription'];
         $this->body = $_REQUEST['Body'];
         $this->feedbackType = $_REQUEST['FeedbackType'];
         $this->menuView = isset($_REQUEST['MenuView']);
         $this->menuIndex = $_REQUEST['MenuIndex'];
         $this->homePageWidget = isset($_REQUEST['HomePageWidget']);
         $this->homePageWidgetIndex = $_REQUEST['HomePageWidgetIndex'];
         $this->homePageCarousel = isset($_REQUEST['HomePageCarousel']);
         $this->homePageCarouselIndex = $_REQUEST['HomePageCarouselIndex'];
         $this->hasPage = isset($_REQUEST['HasPage']);
         $this->parentId = $_REQUEST['ParentId'] == '' ? null : $_REQUEST['ParentId'];
         $this->userId = Authentication::getUserEntity()->id;
         if ($this->menuView && $this->pageTitle == '') {
             $this->pageTitleValidation = Language::$TITLE_CAN_NOT_BE_EMPTY[Config::$LANGUAGE];
             $this->validation = false;
         }
         if (!$this->menuView && $this->body == '') {
             $this->bodyValidation = Language::$BODY_CAN_NOT_BE_EMPTY[Config::$LANGUAGE];
             $this->validation = false;
         }
     }
 }
Ejemplo n.º 2
0
    public function content($model)
    {
        ?>
        <!-- START CONTENT -->
        <?php 
        if (Config::$VISIBLE_LOGIN) {
            ?>
        <?php 
            if ($model->isAuthenticated) {
                ?>
            <form action="/account/logoff" class="navbar-right" id="logoutForm" method="post">
                <input type="hidden" name="Url" value="<?php 
                echo Authentication::getReturnUrl();
                ?>
"/>
                <ul class="nav navbar-nav navbar-right">
                    <li>
                        <a href="/manage/index"><?php 
                echo Language::$HELLO[Config::$LANGUAGE] . ' ' . $model->authenticatedUserEntity->email;
                ?>
                            !</a></li>
                    <li>
                        <a href="javascript:document.getElementById('logoutForm').submit()"><?php 
                echo Language::$LOG_OFF[Config::$LANGUAGE];
                ?>
</a>
                    </li>
                </ul>
            </form>
        <?php 
            } else {
                ?>
            <ul class="nav navbar-nav navbar-right">
                <li><a href="/account/register<?php 
                echo Authentication::getReturnUrl();
                ?>
"
                       id="registerLink"><?php 
                echo Language::$REGISTER[Config::$LANGUAGE];
                ?>
</a></li>
                <li><a href="/account/login<?php 
                echo Authentication::getReturnUrl();
                ?>
"
                       id="loginLink"><?php 
                echo Language::$LOG_IN[Config::$LANGUAGE];
                ?>
</a></li>
            </ul>
        <?php 
            }
            ?>
    <?php 
        }
        ?>
        <!-- END CONTENT -->
    <?php 
    }
Ejemplo n.º 3
0
 /**
  * @param $roleNames
  * @return bool
  */
 public static function hasRoles($roleNames)
 {
     $hasRoles = false;
     if (Authentication::isAuthenticated()) {
         $userEntity = Authentication::getUserEntity();
         for ($i = 0; $i < count($roleNames); $i++) {
             if (in_array($roleNames[$i], $userEntity->roleNames)) {
                 $hasRoles = true;
             }
         }
     }
     return $hasRoles;
 }
Ejemplo n.º 4
0
 /**
  * Controller constructor.
  * @param bool $isAuthenticated
  * @param null $roleNames
  */
 public function __construct($isAuthenticated = false, $roleNames = null)
 {
     Browsing::setBrowsingId();
     PageMenu::setPageMenu();
     if (Authentication::isAuthenticated()) {
         Authentication::setUserEntity();
         if ($roleNames != null && !Authentication::hasRoles($roleNames)) {
             $this->redirectToUrlFromAction('main', 'no-access');
         }
     } else {
         Authentication::unsetUserEntity();
         if ($isAuthenticated) {
             $this->redirectToUrlFromAction('account', 'login');
         }
     }
 }
Ejemplo n.º 5
0
 /**
  * POST: /manage/delete
  */
 public function deletePost()
 {
     $model = new ManageDeleteModel(Language::$DELETE_ACCOUNT[Config::$LANGUAGE], true);
     if ($model->validation) {
         $userDAO = new UserDAO();
         $errorMessage = $userDAO->passwordVerify($model->authenticatedUserEntity->id, $model->password, $model->authenticatedUserEntity->passwordHash, $model->authenticatedUserEntity->lockoutEnabled, $model->authenticatedUserEntity->lockoutEndDate, $model->authenticatedUserEntity->accessFailedCount);
         if ($errorMessage == '') {
             $userDAO->delete($model->authenticatedUserEntity->id);
             Authentication::signOut();
             parent::redirectToUrlFromAction('main', 'index');
         }
         $model->passwordValidation = Language::$INVALID_PASSWORD[Config::$LANGUAGE] . " {$errorMessage}";
         $model->validation = false;
     }
     parent::view(new Delete(), $model);
 }
Ejemplo n.º 6
0
    public function content($model)
    {
        ?>
    <!-- START CONTENT -->
    <div class="row">
      <ol class="breadcrumb">
        <li><a href="/"><?php 
        echo Language::$HOME_PAGE[Config::$LANGUAGE];
        ?>
</a></li>
        <li class="active"><?php 
        echo $model->title;
        ?>
</li>
      </ol>
      <h2><span class="fa fa-cogs"></span> <?php 
        echo $model->title;
        ?>
.</h2>
      <p>
      <ul>
        <?php 
        if (Authentication::hasRoles(array('admin'))) {
            ?>
          <li><a href="/admin/users"><span class="glyphicon glyphicon-user"></span>&nbsp;&nbsp;<?php 
            echo Language::$USERS[Config::$LANGUAGE];
            ?>
</a></li>
          <li><a href="/file/index"><span class="glyphicon glyphicon-folder-open"></span>&nbsp;&nbsp;<?php 
            echo Language::$FILES[Config::$LANGUAGE];
            ?>
</a></li>
        <?php 
        }
        ?>
        <li><a href="/main/create-page"><span class="glyphicon glyphicon-file"></span>&nbsp;&nbsp;<?php 
        echo Language::$ADDED_PAGE[Config::$LANGUAGE];
        ?>
</a></li>
      </ul>
      </p>
    </div>
    <!-- END CONTENT -->
  <?php 
    }
Ejemplo n.º 7
0
    public function content($model)
    {
        ?>
        <!-- START CONTENT -->
        <?php 
        if (Authentication::hasRoles(array('manager', 'admin'))) {
            ?>
        <li><a title="<?php 
            echo Language::$ADMIN_PANEL[Config::$LANGUAGE];
            ?>
" href="/admin/index"><span
                    class="fa fa-cogs"></span></a></li>
    <?php 
        }
        ?>
        <!-- END CONTENT -->
    <?php 
    }
Ejemplo n.º 8
0
    public function content($model)
    {
        ?>
    <!-- START CONTENT -->
    <div class="row">
      <?php 
        if (count($model->pagesForCarousel) > 0) {
            ?>
        <div id="myCarousel" class="carousel slide" data-ride="carousel" data-interval="6000">
          <ol class="carousel-indicators">
            <?php 
            for ($i = 0; $i < count($model->pagesForCarousel); $i++) {
                ?>
              <li data-target="#myCarousel" data-slide-to="<?php 
                echo $i;
                ?>
" <?php 
                echo $i == 0 ? 'class="active"' : '';
                ?>
></li>
            <?php 
            }
            ?>
          </ol>
          <div class="carousel-inner" role="listbox">
            <?php 
            for ($i = 0; $i < count($model->pagesForCarousel); $i++) {
                ?>
              <div class="item <?php 
                echo $i == 0 ? ' active' : '';
                ?>
">
                <div class="jumbotron">
                  <?php 
                if (Authentication::hasRoles(array('manager', 'admin'))) {
                    ?>
                    <div class="edit alert alert-warning">
                      <a class="edit" title="<?php 
                    echo Language::$EDIT_PAGE[Config::$LANGUAGE];
                    ?>
" href="/main/edit-page/<?php 
                    echo $model->pagesForCarousel[$i]->id;
                    ?>
">
                        <span class="glyphicon glyphicon-pencil"></span>
                      </a>
                      &nbsp;&nbsp;
                      <a class="delete" title="<?php 
                    echo Language::$DELETE_PAGE[Config::$LANGUAGE];
                    ?>
" href="/main/delete-page/<?php 
                    echo $model->pagesForCarousel[$i]->id;
                    ?>
" onclick="return confirm('<?php 
                    echo Language::$ARE_YOU_SURE[Config::$LANGUAGE];
                    ?>
');">
                        <span class="glyphicon glyphicon-remove"></span>
                      </a>
                    </div>
                  <?php 
                }
                ?>
                  <?php 
                if ($model->pagesForCarousel[$i]->hasPage) {
                    ?>
                    <?php 
                    if ($model->pagesForCarousel[$i]->title != '') {
                        ?>
                      <h2><a href="/main/page/<?php 
                        echo $model->pagesForCarousel[$i]->id;
                        ?>
"><?php 
                        echo $model->pagesForCarousel[$i]->title;
                        ?>
</a></h2>
                      <p><?php 
                        echo substr(strip_tags($model->pagesForCarousel[$i]->body), 0, 200);
                        ?>
...</p>
                      <p><a href="/main/page/<?php 
                        echo $model->pagesForCarousel[$i]->id;
                        ?>
" class="btn btn-default"><?php 
                        echo Language::$LEARN_MORE[Config::$LANGUAGE];
                        ?>
 &raquo;</a></p>
                    <?php 
                    }
                    ?>
                  <?php 
                } else {
                    ?>
                    <?php 
                    if ($model->pagesForCarousel[$i]->title != '') {
                        ?>
                      <h2><?php 
                        echo $model->pagesForCarousel[$i]->title;
                        ?>
</h2>
                      <?php 
                        echo $model->pagesForCarousel[$i]->body;
                        ?>
                    <?php 
                    }
                    ?>
                  <?php 
                }
                ?>
                </div>
              </div>
            <?php 
            }
            ?>
          </div>
        </div>
      <?php 
        }
        ?>
    </div>
    <?php 
        for ($i = 0; $i < count($model->pagesForWidget); $i++) {
            ?>
      <?php 
            if ($i % 3 == 0) {
                ?>
        <div class="row">
      <?php 
            }
            ?>
      <div class="col-md-4">
        <?php 
            if (Authentication::hasRoles(array('manager', 'admin'))) {
                ?>
          <div class="edit alert alert-warning">
            <a class="edit" title="<?php 
                echo Language::$EDIT_PAGE[Config::$LANGUAGE];
                ?>
" href="/main/edit-page/<?php 
                echo $model->pagesForWidget[$i]->id;
                ?>
">
              <span class="glyphicon glyphicon-pencil"></span>
            </a>
            &nbsp;&nbsp;
            <a class="delete" title="<?php 
                echo Language::$DELETE_PAGE[Config::$LANGUAGE];
                ?>
" href="/main/delete-page/<?php 
                echo $model->pagesForWidget[$i]->id;
                ?>
" onclick="return confirm('<?php 
                echo Language::$ARE_YOU_SURE[Config::$LANGUAGE];
                ?>
');">
              <span class="glyphicon glyphicon-remove"></span>
            </a>
          </div>
        <?php 
            }
            ?>
        <?php 
            if ($model->pagesForWidget[$i]->hasPage) {
                ?>
          <?php 
                if ($model->pagesForWidget[$i]->title != '') {
                    ?>
            <h2><a href="/main/page/<?php 
                    echo $model->pagesForWidget[$i]->id;
                    ?>
"><?php 
                    echo $model->pagesForWidget[$i]->title;
                    ?>
</a></h2>
            <p><?php 
                    echo substr(strip_tags($model->pagesForWidget[$i]->body), 0, 200);
                    ?>
...</p>
            <p><a href="/main/page/<?php 
                    echo $model->pagesForWidget[$i]->id;
                    ?>
" class="btn btn-default"><?php 
                    echo Language::$LEARN_MORE[Config::$LANGUAGE];
                    ?>
 &raquo;</a></p>
          <?php 
                }
                ?>
        <?php 
            } else {
                ?>
          <?php 
                if ($model->pagesForWidget[$i]->title != '') {
                    ?>
            <h2><?php 
                    echo $model->pagesForWidget[$i]->title;
                    ?>
</h2>
            <?php 
                    echo $model->pagesForWidget[$i]->body;
                    ?>
          <?php 
                }
                ?>
        <?php 
            }
            ?>
      </div>
      <?php 
            if ($i % 3 == 2 || $i + 1 == count($model->pagesForWidget)) {
                ?>
        </div>
      <?php 
            }
            ?>
    <?php 
        }
        ?>
    <!-- END CONTENT -->
  <?php 
    }
Ejemplo n.º 9
0
    public function content($model)
    {
        ?>
    <!-- START CONTENT -->
    <div class="row">
      <ol class="breadcrumb">
        <li><a href="/"><?php 
        echo Language::$HOME_PAGE[Config::$LANGUAGE];
        ?>
</a></li>
        <li class="active"><?php 
        echo $model->title;
        ?>
</li>
      </ol>
      <h2><?php 
        echo $model->title;
        ?>
.</h2>
      <form action="/account/login" class="form-horizontal" method="post" role="form">
        <h4><?php 
        echo Language::$USE_ACCOUNT_LOGIN[Config::$LANGUAGE];
        ?>
</h4>
        <hr />
        <input type="hidden" name="Url" value="<?php 
        echo $model->url;
        ?>
" />
        <div class="validation-summary-valid text-danger" data-valmsg-summary="true">
          <?php 
        if (!$model->validation) {
            ?>
            <ul>
              <?php 
            if ($model->emailValidation != '') {
                ?>
                <li><?php 
                echo $model->emailValidation;
                ?>
</li>
              <?php 
            }
            ?>
              <?php 
            if ($model->passwordValidation != '') {
                ?>
                <li><?php 
                echo $model->passwordValidation;
                ?>
</li>
              <?php 
            }
            ?>
            </ul>
          <?php 
        }
        ?>
        </div>
        <div class="form-group">
          <label class="col-md-2 control-label" for="Email">Email</label>
          <div class="col-md-10">
            <input class="form-control" id="Email" name="Email" type="text" value="<?php 
        echo $model->email;
        ?>
" />
          </div>
        </div>
        <div class="form-group">
          <label class="col-md-2 control-label" for="Password"><?php 
        echo Language::$PASSWORD[Config::$LANGUAGE];
        ?>
</label>
          <div class="col-md-10">
            <input class="form-control" id="Password" name="Password" type="password" value="<?php 
        echo $model->password;
        ?>
" />
          </div>
        </div>
        <div class="form-group">
          <div class="col-md-offset-2 col-md-10">
            <div class="checkbox">
              <input id="RememberMe" name="RememberMe" type="checkbox" <?php 
        if ($model->rememberMe) {
            echo 'checked="checked"';
        }
        ?>
 />
              <label for="RememberMe"><?php 
        echo Language::$REMEMBER_ME[Config::$LANGUAGE];
        ?>
</label>
            </div>
          </div>
        </div>
        <div class="form-group">
          <div class="col-md-offset-2 col-md-10">
            <input type="submit" value="<?php 
        echo Language::$LOG_IN[Config::$LANGUAGE];
        ?>
" class="btn btn-default" />
          </div>
        </div>
        <p>
          <a href="/account/register<?php 
        echo Authentication::getReturnUrl();
        ?>
"><?php 
        echo Language::$REGISTER_NEW_USER[Config::$LANGUAGE];
        ?>
</a>
        </p>
        <?php 
        if (Config::$SMTP) {
            ?>
          <p>
            <a href="/account/forgot-password"><?php 
            echo Language::$FORGOT_PASSWORD[Config::$LANGUAGE];
            ?>
</a>
          </p>
        <?php 
        }
        ?>
      </form>
    </div>
    <!-- END CONTENT -->
  <?php 
    }
Ejemplo n.º 10
0
    public function content($model)
    {
        ?>
        <!-- START CONTENT -->
        <?php 
        foreach ($model->pageMenu as $pageMenu) {
            ?>
        <?php 
            if (count($pageMenu->childPages) > 0 || !$pageMenu->hasPage && Authentication::hasRoles(array('manager', 'admin'))) {
                ?>
            <li class="dropdown pointer"><a class="dropdown-toggle"
                                            data-toggle="dropdown"><?php 
                echo $pageMenu->title;
                ?>
 <b
                        class="caret"></b></a>
                <ul class="dropdown-menu">
                    <?php 
                if ($pageMenu->hasPage) {
                    ?>
                        <li><a href="/main/page/<?php 
                    echo $pageMenu->id;
                    ?>
"><?php 
                    echo $pageMenu->title;
                    ?>
</a></li>
                    <?php 
                }
                ?>
                    <?php 
                if (!$pageMenu->hasPage && Authentication::hasRoles(array('manager', 'admin'))) {
                    ?>
                        <li style="text-align: right;">
                            <a style="display: inline"
                               title="<?php 
                    echo Language::$ADDED_SUB_PAGE[Config::$LANGUAGE];
                    ?>
"
                               href="/main/create-page/<?php 
                    echo $pageMenu->id;
                    ?>
">
                                <span class="glyphicon glyphicon-plus"></span>
                            </a>
                            <a style="display: inline" title="<?php 
                    echo Language::$EDIT_PAGE[Config::$LANGUAGE];
                    ?>
"
                               href="/main/edit-page/<?php 
                    echo $pageMenu->id;
                    ?>
">
                                <span class="glyphicon glyphicon-pencil"></span>
                            </a>
                            <a style="display: inline" title="<?php 
                    echo Language::$DELETE_PAGE[Config::$LANGUAGE];
                    ?>
"
                               href="/main/delete-page/<?php 
                    echo $pageMenu->id;
                    ?>
"
                               onclick="return confirm('<?php 
                    echo Language::$ARE_YOU_SURE[Config::$LANGUAGE];
                    ?>
');">
                                <span class='glyphicon glyphicon-remove'></span>
                            </a>
                        </li>
                    <?php 
                }
                ?>
                    <?php 
                foreach ($pageMenu->childPages as $child_page) {
                    ?>
                        <li><a href="/main/page/<?php 
                    echo $child_page->id;
                    ?>
"><?php 
                    echo $child_page->title;
                    ?>
</a>
                        </li>
                    <?php 
                }
                ?>
                </ul>
            </li>
        <?php 
            } else {
                ?>
            <li><a href="/main/page/<?php 
                echo $pageMenu->id;
                ?>
"><?php 
                echo $pageMenu->title;
                ?>
</a></li>
        <?php 
            }
            ?>
    <?php 
        }
        ?>
        <!-- END CONTENT -->
    <?php 
    }
Ejemplo n.º 11
0
    public function content($model)
    {
        ?>
    <!-- START CONTENT -->
    <div class="row">
      <ol class="breadcrumb">
        <li><a href="/"><?php 
        echo Language::$HOME_PAGE[Config::$LANGUAGE];
        ?>
</a></li>
        <?php 
        foreach ($model->parentPages as $page) {
            ?>
          <li><a href="/main/page/<?php 
            echo $page->id;
            ?>
"><?php 
            echo $page->title;
            ?>
</a></li>
        <?php 
        }
        ?>
        <li class="active"><?php 
        echo $model->title;
        ?>
</li>
      </ol>
      <?php 
        if (Authentication::hasRoles(array('manager', 'admin'))) {
            ?>
        <div class='edit alert alert-warning'>
          <a href="/main/create_page/<?php 
            echo $model->id;
            ?>
">
            <span class="fa fa-files-o"></span> <?php 
            echo Language::$ADDED_SUB_PAGE[Config::$LANGUAGE];
            ?>
          </a>
          <br/>
          <a class="edit" href="/main/edit-page/<?php 
            echo $model->id;
            ?>
">
            <span class="glyphicon glyphicon-pencil"></span> <?php 
            echo Language::$EDIT_PAGE[Config::$LANGUAGE];
            ?>
          </a>
          <br/>
          <a class="delete" href="/main/delete-page/<?php 
            echo $model->id;
            ?>
" onclick="return confirm('<?php 
            echo Language::$ARE_YOU_SURE[Config::$LANGUAGE];
            ?>
');">
            <span class="glyphicon glyphicon-remove"></span> <?php 
            echo Language::$DELETE_PAGE[Config::$LANGUAGE];
            ?>
          </a>
        </div>
      <?php 
        }
        ?>
      <h2><?php 
        echo $model->title;
        ?>
.</h2>
      <?php 
        echo $model->body;
        ?>
      <?php 
        if (count($model->childPages) > 0) {
            ?>
        <hr />
        <ul>
          <?php 
            foreach ($model->childPages as $page) {
                ?>
            <li><a href="/main/page/<?php 
                echo $page->id;
                ?>
"><?php 
                echo $page->title;
                ?>
</a></li>
          <?php 
            }
            ?>
        </ul>
      <?php 
        }
        ?>
    </div>
    <?php 
        if ($model->feedbackType == PageEntity::$FEEDBACK_EMAIL) {
            ?>
      <div class="row">
        <form action="/main/send-email" id="emailForm" class="form-horizontal" method="post">
          <input type="hidden" name="Id" id="Id" value="<?php 
            echo $model->id;
            ?>
" />
          <hr />
          <h4><span class="glyphicon glyphicon-envelope"></span> <?php 
            echo Language::$WRITE_TO_US[Config::$LANGUAGE];
            ?>
</h4>
          <hr />
          <div class="form-group">
            <label class="col-md-2 control-label" for="Subject"><?php 
            echo Language::$EMAIL_SUBJECT[Config::$LANGUAGE];
            ?>
</label>
            <div class="col-md-10">
              <input type="text" class="form-control width_full" name="Subject" id="Subject" />
            </div>
          </div>
          <div class="form-group">
            <label class="col-md-2 control-label" for="Body"><?php 
            echo Language::$EMAIL_BODY[Config::$LANGUAGE];
            ?>
</label>
            <div class="col-md-10">
              <textarea class="form-control width_full" style="height: 200px;" id="Body" name="Body"></textarea>
            </div>
          </div>
          <div class="form-group">
            <div class="col-md-offset-2 col-md-10">
              <input type="submit" class="btn btn-default" onclick="return confirm();" value="<?php 
            echo Language::$SEND[Config::$LANGUAGE];
            ?>
" />
            </div>
          </div>
        </form>
      </div>
    <?php 
        }
        ?>
    <?php 
        if ($model->feedbackType == PageEntity::$FEEDBACK_COMMENTS_ALL || $model->feedbackType == PageEntity::$FEEDBACK_COMMENTS_AUTH || $model->feedbackType == PageEntity::$FEEDBACK_COMMENTS_CAPTCHA) {
            ?>
      <div class="row">
        <h3><?php 
            echo Language::$COMMENTS[Config::$LANGUAGE] . ' (' . count($model->commentsOnPage) . ')';
            ?>
</h3>
        <?php 
            echo CommentOnPageHelper::getComments($model->commentsOnPage, $model->feedbackType);
            ?>
      </div>
    <?php 
        }
        ?>
    <!-- END CONTENT -->
  <?php 
    }
Ejemplo n.º 12
0
 /**
  * @param $args
  * GET: /admin/delete-user
  */
 public function deleteUser($args)
 {
     if (!Authentication::hasRoles(array('admin'))) {
         parent::redirectToUrlFromAction('admin', 'no-access');
     }
     (new UserDAO())->delete($args[0]);
     parent::redirectToUrlFromAction('admin', 'users');
 }
Ejemplo n.º 13
0
 /**
  * POST: /account/logoff
  */
 public function logoffPost()
 {
     Authentication::signOut();
     $args = explode('/', $_REQUEST['Url']);
     unset($args[0]);
     parent::redirectToUrlFromArray($args);
 }
Ejemplo n.º 14
0
    /**
     * @param $pageId
     * @param $feedbackType
     */
    public static function getScriptForComments($pageId, $feedbackType)
    {
        ?>
        <?php 
        if ($feedbackType != PageEntity::$FEEDBACK_COMMENTS_AUTH || Authentication::isAuthenticated()) {
            ?>
        <script type="text/javascript">
            $('#answer_0').focus();
            function showDivAnswer(commentId) {
                $('div.div_answer').each(function () {
                    $(this).hide();
                });
                $('a.a_answer').each(function () {
                    $(this).prop('disabled', false);
                });
                $('#div_answer_' + commentId).show();
                $('#a_answer_' + commentId).prop('disabled', true);
                $('#answer_' + commentId).focus();
            }
            function submitComment(textAreaId, commentId) {
                var body = $('#' + textAreaId).val();
                var captcha = $('#input_captcha_' + commentId).val();
                $.ajax({
                    method: 'POST',
                    url: '/main/create-comment',
                    data: {PageId: <?php 
            echo $pageId;
            ?>
, CommentId: commentId, Body: body, Captcha: captcha}
                }).done(function (data) {
                    if (data == 'captcha') {
                        alert('<?php 
            echo Language::$ERROR_CAPTCHA[Config::$LANGUAGE];
            ?>
');
                        $('#input_captcha_' + commentId).val('');
                        $('#input_captcha_' + commentId).focus();
                    }
                    else if (commentId == 0) {
                        $('#li_0').before(data);
                    }
                    else {
                        $('#ul_' + commentId).append(data);
                    }
                    if (data != 'captcha') {
                        $('div.div_answer').each(function () {
                            $(this).hide();
                        });
                        $('a.a_answer').each(function () {
                            $(this).prop('disabled', false);
                        });
                        $('#' + textAreaId).val('');
                        $('#answer_0').focus();
                    }
                    refresh(commentId);
                });
            }

            function deleteComment(commentId) {
                if (confirm('<?php 
            echo Language::$ARE_YOU_SURE[Config::$LANGUAGE];
            ?>
')) {
                    $.ajax({
                        method: 'POST',
                        url: '/main/delete-comment',
                        data: {CommentId: commentId}
                    }).done(function (data) {
                        if (data == 'success') {
                            $('#li_' + commentId).remove();
                        }
                    });
                }
            }
            function refresh(id) {
                var captcha = document.getElementById('captcha_' + id);
                captcha.src = '/misc/captcha/' + id + '?v=' + Math.random();
            }
        </script>
    <?php 
        }
        ?>
    <?php 
    }
Ejemplo n.º 15
0
 /**
  * POST: /main/delete-comment
  */
 public function deleteCommentPost()
 {
     $commentId = $_REQUEST['CommentId'];
     $commentOnPageDAO = new CommentOnPageDAO();
     $comment = $commentOnPageDAO->getCommentOnPage($commentId);
     if (Authentication::isAuthenticated() && (Authentication::getUserEntity()->id == $comment->userId || Authentication::hasRoles(array('manager', 'admin')))) {
         $commentOnPageDAO->delete($commentId);
         echo 'success';
     }
 }