Ejemplo n.º 1
0
 public function run($user)
 {
     // Если пользователь отключил уведомления о новых комментариях
     // через личные сообщения, то выходим
     if (empty($user['notify_options']['comments_new'])) {
         return $user;
     }
     if (!in_array($user['notify_options']['comments_new'], array('pm', 'both'))) {
         return $user;
     }
     // Если новых комментариев на отслеживаемых страницах не появлялось
     // то тоже выходим
     $counts = $this->model->getTrackedNewCounts($user['id'], $user['date_log']);
     if (!$counts) {
         return $user;
     }
     $messenger = cmsCore::getController('messages');
     $messenger->addRecipient($user['id']);
     foreach ($counts as $data) {
         $spellcount = html_spellcount($data['count'], LANG_NEW_COMMENT1, LANG_NEW_COMMENT2, LANG_NEW_COMMENT10);
         $notice = array('content' => sprintf(LANG_COMMENTS_TRACKED_NEW, $data['target_title'], $spellcount), 'actions' => array('view' => array('title' => LANG_SHOW, 'href' => href_to($data['target_url']) . '?new_comments#comments'), 'stop' => array('title' => LANG_COMMENTS_TRACK_STOP, 'controller' => $this->name, 'action' => 'track_stop', 'params' => array($data['target_controller'], $data['target_subject'], $data['target_id']))));
         $messenger->sendNoticePM($notice, 'comments_new');
     }
     return $user;
 }
Ejemplo n.º 2
0
 public function run($id)
 {
     $comment = $this->model->getComment($id);
     if (!$comment) {
         cmsCore::error404();
     }
     $delete_count = $this->model->deleteComment($comment['id'], true);
     // обновляем количество
     $comments_count = $this->model->filterEqual('target_controller', $comment['target_controller'])->filterEqual('target_subject', $comment['target_subject'])->filterEqual('target_id', $comment['target_id'])->getCommentsCount();
     cmsCore::getModel($comment['target_controller'])->updateCommentsCount($comment['target_subject'], $comment['target_id'], $comments_count);
     cmsEventsManager::hook('comments_after_delete', $comment['id']);
     cmsUser::addSessionMessage(html_spellcount($delete_count, LANG_COMMENT1, LANG_COMMENT2, LANG_COMMENT10) . LANG_COMMENTS_DELETED, 'success');
     $this->redirectToAction('comments_list');
 }
Ejemplo n.º 3
0
 public function getNativeComments()
 {
     if (cmsUser::isAllowed('comments', 'is_moderator')) {
         $this->model->disableApprovedFilter();
     }
     $comments = $this->model->filterCommentTarget($this->target_controller, $this->target_subject, $this->target_id)->getComments();
     $comments = cmsEventsManager::hook('comments_before_list', $comments);
     $is_tracking = $this->model->filterCommentTarget($this->target_controller, $this->target_subject, $this->target_id)->getTracking($this->cms_user->id);
     $is_highlight_new = $this->request->hasInQuery('new_comments');
     if ($is_highlight_new && !$this->cms_user->is_logged) {
         $is_highlight_new = false;
     }
     $csrf_token_seed = implode('/', array($this->target_controller, $this->target_subject, $this->target_id));
     return array('name' => 'icms', 'title' => $comments ? html_spellcount(sizeof($comments), LANG_COMMENT1, LANG_COMMENT2, LANG_COMMENT10) : LANG_COMMENTS, 'html' => $this->cms_template->renderInternal($this, 'list', array('user' => $this->cms_user, 'target_controller' => $this->target_controller, 'target_subject' => $this->target_subject, 'target_id' => $this->target_id, 'target_user_id' => $this->target_user_id, 'is_tracking' => $is_tracking, 'is_highlight_new' => $is_highlight_new, 'comments' => $comments, 'csrf_token_seed' => $csrf_token_seed, 'is_can_rate' => cmsUser::isAllowed('comments', 'rate'))));
 }
Ejemplo n.º 4
0
/**
 * Выводит максимальную разницу между переданной датой и текущим временем
 * в виде читабельной строки со склонением
 *
 * Пример вывода: "3 дня"
 *
 * @param string $date
 * @param bool $is_add_back Добавлять к строке слово "назад"?
 * @return string
 */
function string_date_age_max($date, $is_add_back = false)
{
    if (!$date) {
        return;
    }
    $diff = real_date_diff($date);
    $diff_str = '';
    if ($diff[0]) {
        $diff_str = html_spellcount($diff[0], LANG_YEAR1, LANG_YEAR2, LANG_YEAR10);
    } else {
        if ($diff[1]) {
            $diff_str = html_spellcount($diff[1], LANG_MONTH1, LANG_MONTH2, LANG_MONTH10);
        } else {
            if ($diff[2]) {
                $diff_str = html_spellcount($diff[2], LANG_DAY1, LANG_DAY2, LANG_DAY10);
            } else {
                if ($diff[3]) {
                    $diff_str = html_spellcount($diff[3], LANG_HOUR1, LANG_HOUR2, LANG_HOUR10);
                } else {
                    if ($diff[4]) {
                        $diff_str = html_spellcount($diff[4], LANG_MINUTE1, LANG_MINUTE2, LANG_MINUTE10);
                    }
                }
            }
        }
    }
    if (!$diff_str) {
        return LANG_JUST_NOW;
    } else {
        return $is_add_back ? sprintf(LANG_DATE_AGO, $diff_str) : $diff_str;
    }
}
Ejemplo n.º 5
0
// Шаблон списка комментариев и формы добавления //
?>

<?php 
$this->addJS('templates/default/js/jquery-scroll.js');
$this->addJS('templates/default/js/comments.js');
$is_guests_allowed = !empty($this->controller->options['is_guests']);
?>

<div id="comments_widget">

    <div class="title">
        <a name="comments"></a>
        <h2><?php 
echo $comments ? html_spellcount(sizeof($comments), LANG_COMMENT1, LANG_COMMENT2, LANG_COMMENT10) : LANG_COMMENTS;
?>
</h2>
        <?php 
if ($user->is_logged) {
    ?>
            <div class="track">
                <input type="checkbox" id="is_track" name="is_track" value="1" <?php 
    if ($is_tracking) {
        ?>
checked="checked"<?php 
    }
    ?>
 />
                <label for="is_track"><?php 
    echo LANG_COMMENTS_TRACK;
Ejemplo n.º 6
0
 public function run()
 {
     if (!$this->request->isAjax()) {
         cmsCore::error404();
     }
     $action = $this->request->get('action');
     $user = cmsUser::getInstance();
     $is_guests_allowed = !empty($this->options['is_guests']);
     $is_guest = $is_guests_allowed && !$user->is_logged;
     $is_user_allowed = $user->is_logged && cmsUser::isAllowed('comments', 'add') || $is_guests_allowed;
     $is_karma_allowed = $user->is_logged && !cmsUser::isPermittedLimitHigher('comments', 'karma', $user->karma) || $is_guests_allowed;
     $is_add_allowed = $is_user_allowed && $is_karma_allowed;
     if ($action == 'add' && !$is_add_allowed) {
         cmsCore::error404();
     }
     if ($action == 'update' && !cmsUser::isAllowed('comments', 'edit')) {
         cmsCore::error404();
     }
     $template = cmsTemplate::getInstance();
     $csrf_token = $this->request->get('csrf_token');
     $target_controller = $this->request->get('tc');
     $target_subject = $this->request->get('ts');
     $target_id = $this->request->get('ti');
     $target_user_id = $this->request->get('tud');
     $parent_id = $this->request->get('parent_id');
     $comment_id = $this->request->get('id');
     $content = $this->request->get('content');
     if ($is_guest) {
         $author_name = $this->request->get('author_name');
         $author_email = $this->request->get('author_email');
         if (!$author_name) {
             $template->renderJSON(array('error' => true, 'message' => LANG_COMMENT_ERROR_NAME, 'html' => false));
         }
         if ($author_email && !preg_match("/^([a-zA-Z0-9\\._-]+)@([a-zA-Z0-9\\._-]+)\\.([a-zA-Z]{2,4})\$/i", $author_email)) {
             $template->renderJSON(array('error' => true, 'message' => LANG_COMMENT_ERROR_EMAIL, 'html' => false));
         }
         if (!empty($this->options['restricted_ips'])) {
             if (string_in_mask_list($user->ip, $this->options['restricted_ips'])) {
                 $template->renderJSON(array('error' => true, 'message' => LANG_COMMENT_ERROR_IP, 'html' => false));
             }
         }
         if (!empty($this->options['guest_ip_delay'])) {
             $last_comment_time = $this->model->getGuestLastCommentTime($user->ip);
             $now_time = time();
             $minutes_passed = ($now_time - $last_comment_time) / 60;
             if ($minutes_passed < $this->options['guest_ip_delay']) {
                 $spellcount = html_spellcount($this->options['guest_ip_delay'], LANG_MINUTE1, LANG_MINUTE2, LANG_MINUTE10);
                 $template->renderJSON(array('error' => true, 'message' => sprintf(LANG_COMMENT_ERROR_TIME, $spellcount), 'html' => false));
             }
         }
     }
     // Проверяем валидность
     $is_valid = $this->validate_sysname($target_controller) === true && $this->validate_sysname($target_subject) === true && is_numeric($target_id) && is_numeric($parent_id) && (!$comment_id || is_numeric($comment_id)) && cmsForm::validateCSRFToken($csrf_token, false) && in_array($action, array('add', 'preview', 'update'));
     if (!$is_valid) {
         $result = array('error' => true, 'message' => LANG_COMMENT_ERROR);
         $template->renderJSON($result);
     }
     // Типографируем текст
     $content_html = cmsEventsManager::hook('html_filter', $content);
     if (!$content_html) {
         $result = array('error' => false, 'message' => false, 'html' => false);
         $template->renderJSON($result);
     }
     //
     // Превью комментария
     //
     if ($action == 'preview') {
         $result = array('error' => false, 'html' => $content_html);
         $template->renderJSON($result);
     }
     //
     // Редактирование комментария
     //
     if ($action == 'update') {
         $comment = $this->model->getComment($comment_id);
         if (!cmsUser::isAllowed('comments', 'edit', 'all')) {
             if (cmsUser::isAllowed('comments', 'edit', 'own') && $comment['user']['id'] != $user->id) {
                 $result = array('error' => true, 'message' => LANG_COMMENT_ERROR);
                 $template->renderJSON($result);
             }
         }
         $this->model->updateCommentContent($comment_id, $content, $content_html);
         $comment_html = $content_html;
     }
     //
     // Добавление комментария
     //
     if ($action == 'add') {
         // Собираем данные комментария
         $comment = array('user_id' => $user->id, 'parent_id' => $parent_id, 'target_controller' => $target_controller, 'target_subject' => $target_subject, 'target_id' => $target_id, 'content' => $content, 'content_html' => $content_html, 'author_url' => $user->ip);
         if ($is_guest) {
             $comment['author_name'] = $author_name;
             $comment['author_email'] = $author_email;
         }
         // Получаем модель целевого контроллера
         $target_model = cmsCore::getModel($target_controller);
         // Получаем URL и заголовок комментируемой страницы
         $target_info = $target_model->getTargetItemInfo($target_subject, $target_id);
         if ($target_info) {
             $comment['target_url'] = $target_info['url'];
             $comment['target_title'] = $target_info['title'];
             $comment['is_private'] = empty($target_info['is_private']) ? false : $target_info['is_private'];
             // Сохраняем комментарий
             $comment_id = $this->model->addComment($comment);
         }
         if ($comment_id) {
             // Получаем и рендерим добавленный комментарий
             $comment = $this->model->getComment($comment_id);
             $comment_html = $template->render('comment', array('comments' => array($comment), 'target_user_id' => $target_user_id, 'user' => $user), new cmsRequest(array(), cmsRequest::CTX_INTERNAL));
             // Уведомляем модель целевого контента об изменении количества комментариев
             $comments_count = $this->model->filterEqual('target_controller', $target_controller)->filterEqual('target_subject', $target_subject)->filterEqual('target_id', $target_id)->getCommentsCount();
             $target_model->updateCommentsCount($target_subject, $target_id, $comments_count);
             $parent_comment = $parent_id ? $this->model->getComment($parent_id) : false;
             // Уведомляем подписчиков
             $this->notifySubscribers($comment, $parent_comment);
             // Уведомляем об ответе на комментарий
             if ($parent_comment) {
                 $this->notifyParent($comment, $parent_comment);
             }
         }
     }
     // Формируем и возвращаем результат
     $result = array('error' => $comment_id ? false : true, 'message' => $comment_id ? LANG_COMMENT_SUCCESS : LANG_COMMENT_ERROR, 'id' => $comment_id, 'parent_id' => isset($comment['parent_id']) ? $comment['parent_id'] : 0, 'level' => isset($comment['level']) ? $comment['level'] : 0, 'html' => isset($comment_html) ? $comment_html : false);
     $template->renderJSON($result);
 }
Ejemplo n.º 7
0
                ?>
                                <a href="<?php 
                echo $this->href_to($profile['id']) . "?wid={$profile['status']['wall_entry_id']}&reply=1";
                ?>
"><?php 
                echo LANG_REPLY;
                ?>
</a>
                            <?php 
            } else {
                ?>
                                <a href="<?php 
                echo $this->href_to($profile['id']) . "?wid={$profile['status']['wall_entry_id']}";
                ?>
"><?php 
                echo html_spellcount($profile['status']['replies_count'], LANG_REPLY_SPELLCOUNT);
                ?>
</a>
                            <?php 
            }
            ?>
                        </span>
                    <?php 
        }
        ?>
                    <?php 
        if ($profile['id'] == $user->id) {
            ?>
                        <span class="delete">
                            <a href="#delete-status" onclick="return icms.users.deleteStatus(this)" data-url="<?php 
            echo $this->href_to('status_delete', $profile['id']);
Ejemplo n.º 8
0
 private function buildPhotoDetails($photo, $album, $ctype)
 {
     $first_img = current($photo['image']);
     $details = array(array('name' => LANG_PHOTOS_FORMAT, 'value' => strtoupper(pathinfo($first_img, PATHINFO_EXTENSION))), array('name' => LANG_PHOTOS_SIZE, 'value' => $photo['width'] . '×' . $photo['height']));
     if ($photo['date_photo']) {
         $details[] = array('name' => LANG_PHOTOS_DATE, 'value' => html_date_time($photo['date_photo']));
     }
     if (!empty($this->options['types'][$photo['type']])) {
         $details[] = array('name' => LANG_PHOTOS_O_TYPE1, 'value' => $this->options['types'][$photo['type']]);
     }
     $details[] = array('name' => LANG_PHOTOS_ALBUM, 'value' => $album['title'], 'link' => href_to($ctype['name'], $album['slug']) . '.html');
     $details[] = array('name' => LANG_HITS, 'value' => html_spellcount($photo['hits_count'], LANG_HITS_SPELL));
     $details[] = array('name' => LANG_PHOTOS_DOWNLOADS, 'value' => $photo['downloads_count']);
     list($details, $photo, $album, $ctype) = cmsEventsManager::hook('build_photo_details', array($details, $photo, $album, $ctype));
     return $details;
 }
Ejemplo n.º 9
0
            html(LANG_GROUP_IS_CLOSED_ICON);
            ?>
"></span>
                    <?php 
        }
        ?>
                </div>

                <div class="actions">

                    <?php 
        if ($dataset_name == 'popular') {
            ?>

                        <?php 
            echo $group['members_count'] ? html_spellcount($group['members_count'], LANG_GROUPS_MEMBERS_SPELLCOUNT) : '&mdash;';
            ?>

                    <?php 
        } elseif ($dataset_name == 'rating') {
            ?>

                        <span class="rate_value rating" title="<?php 
            echo LANG_RATING;
            ?>
"><?php 
            echo $group['rating'];
            ?>
</span>

                    <?php 
Ejemplo n.º 10
0
    foreach ($items as $item) {
        ?>

            <?php 
        $item['ctype'] = $ctype;
        ?>

            <div class="tile <?php 
        echo $ctype['name'];
        ?>
_list_item">

                <div class="photo">
                    <div class="note">
                        <?php 
        echo html_spellcount($item['photos_count'], LANG_PHOTOS_PHOTO_SPELLCOUNT);
        ?>
						<?php 
        if ($item['is_public']) {
            ?>
							/ <span><?php 
            echo LANG_PHOTOS_PUBLIC_ALBUM;
            ?>
</span>
						<?php 
        }
        ?>
                    </div>
                    <a href="<?php 
        echo href_to($ctype['name'], $item['slug'] . '.html');
        ?>
Ejemplo n.º 11
0
                        <?php 
                echo $fields['date_pub']['html'];
                ?>
                    <?php 
            }
            ?>
                </span>
            <?php 
        }
        ?>
            <?php 
        if (!empty($ctype['options']['hits_on']) && $item['hits_count']) {
            ?>
                <span class="album_hits">
                    <?php 
            echo html_spellcount($item['hits_count'], LANG_HITS_SPELL);
            ?>
                </span>
            <?php 
        }
        ?>
            <?php 
        if ($item['parent_id']) {
            ?>
                <a href="<?php 
            echo rel_to_href($item['parent_url']);
            ?>
"><?php 
            html($item['parent_title']);
            ?>
</a>
Ejemplo n.º 12
0
    <?php 
}
?>

    <div class="loading block" style="display:none">
        <?php 
echo LANG_LOADING;
?>
    </div>

    <script type="text/javascript">
        <?php 
echo $this->getLangJS('LANG_SELECT_UPLOAD', 'LANG_DROP_TO_UPLOAD', 'LANG_CANCEL', 'LANG_ERROR');
?>
        var LANG_UPLOAD_ERR_MAX_IMAGES = '<?php 
echo sprintf(LANG_PARSER_IMAGE_MAX_COUNT_HINT, html_spellcount($max_photos, LANG_PARSER_IMAGE_SPELL));
?>
';
        <?php 
if ($max_photos && $images && count($images)) {
    ?>
            icms.images.uploaded_count = <?php 
    echo count($images);
    ?>
;
        <?php 
}
?>
        icms.images.createUploader('<?php 
echo $name;
?>
Ejemplo n.º 13
0
    ?>
    <div class="links<?php 
    if ($entry['replies_count']) {
        ?>
 has_replies<?php 
    }
    ?>
">
        <?php 
    if ($entry['replies_count']) {
        ?>
            <a href="#wall-replies" class="get_replies" onclick="return icms.wall.replies(<?php 
        echo $entry['id'];
        ?>
)"><?php 
        echo html_spellcount($entry['replies_count'], LANG_REPLY_SPELLCOUNT);
        ?>
</a>
        <?php 
    }
    ?>
        <?php 
    if ($is_can_add) {
        ?>
            <a href="#wall-reply" class="reply" onclick="return icms.wall.add(<?php 
        echo $entry['id'];
        ?>
)"><?php 
        echo LANG_REPLY;
        ?>
</a>
Ejemplo n.º 14
0
        echo $this->href_to($profile['id']);
        ?>
"><?php 
        html($profile['nickname']);
        ?>
</a>
                </div>

                <div class="actions">

                    <?php 
        if ($dataset_name == 'popular') {
            ?>

                        <?php 
            echo $profile['friends_count'] ? html_spellcount($profile['friends_count'], LANG_USERS_FRIENDS_SPELLCOUNT) : '&mdash;';
            ?>

                    <?php 
        } elseif ($dataset_name == 'rating') {
            ?>

                        <span class="rate_value karma <?php 
            echo html_signed_class($profile['karma']);
            ?>
" title="<?php 
            echo LANG_KARMA;
            ?>
"><?php 
            echo html_signed_num($profile['karma']);
            ?>
Ejemplo n.º 15
0
?>
"><?php 
html($group['owner_nickname']);
?>
</a>
                </li>
                <li>
                    <strong><?php 
echo LANG_GROUP_INFO_MEMBERS;
?>
:</strong>
                    <a href="<?php 
echo $this->href_to($group['id'], 'members');
?>
"><?php 
echo html_spellcount($group['members_count'], LANG_GROUPS_MEMBERS_SPELLCOUNT);
?>
</a>
                </li>

            </ul>

        </div>

    </div>

    <div id="right_column" class="column">

        <div id="information" class="content_item block">

            <div class="group_description">
Ejemplo n.º 16
0
<?php

$this->setPageTitle(LANG_USERS_MY_INVITES);
$this->addBreadcrumb(LANG_USERS, href_to('users'));
$this->addBreadcrumb($profile['nickname'], href_to('users', $id));
$this->addBreadcrumb(LANG_USERS_MY_INVITES);
$this->addToolButton(array('class' => 'cancel', 'title' => LANG_CANCEL, 'href' => href_to('users', $id)));
?>

<h1><?php 
echo LANG_USERS_MY_INVITES;
?>
</h1>

<p><?php 
printf(LANG_USERS_INVITES_COUNT, html_spellcount($profile['invites_count'], LANG_USERS_INVITES_SPELLCOUNT));
?>
</p>

<?php 
$this->renderForm($form, $input, array('action' => '', 'method' => 'post', 'toolbar' => false, 'submit' => array('title' => LANG_SEND)), $errors);