当前位置: 首页>>代码示例>>PHP>>正文


PHP cmsUser::isAllowed方法代码示例

本文整理汇总了PHP中cmsUser::isAllowed方法的典型用法代码示例。如果您正苦于以下问题:PHP cmsUser::isAllowed方法的具体用法?PHP cmsUser::isAllowed怎么用?PHP cmsUser::isAllowed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cmsUser的用法示例。


在下文中一共展示了cmsUser::isAllowed方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: run

 public function run()
 {
     if (!$this->request->isAjax()) {
         cmsCore::error404();
     }
     if (!cmsUser::isAllowed('comments', 'delete')) {
         cmsCore::error404();
     }
     $comment = $this->model->getComment((int) $this->request->get('id'));
     // Проверяем
     if (!$comment) {
         cmsTemplate::getInstance()->renderJSON($result = array('error' => true, 'message' => LANG_ERROR));
     }
     $user = cmsUser::getInstance();
     if (!cmsUser::isAllowed('comments', 'delete', 'all') && !cmsUser::isAllowed('comments', 'delete', 'full_delete')) {
         if (cmsUser::isAllowed('comments', 'delete', 'own') && $comment['user']['id'] != $user->id) {
             cmsTemplate::getInstance()->renderJSON(array('error' => true, 'message' => LANG_ERROR));
         }
     }
     // проверяем, есть ли дети комментария
     $is_comment_child = $this->model->getItemByField('comments', 'parent_id', $comment['id']);
     $this->model->deleteComment($comment['id'], !$is_comment_child && cmsUser::isAllowed('comments', 'delete', 'full_delete', true));
     if (cmsUser::isAllowed('comments', 'delete', 'full_delete')) {
         cmsEventsManager::hook('comments_after_delete', $comment['id']);
     } else {
         cmsEventsManager::hook('comments_after_hide', $comment['id']);
     }
     cmsTemplate::getInstance()->renderJSON(array('error' => false, 'message' => LANG_COMMENT_DELETED));
 }
开发者ID:pin-git,项目名称:icms2,代码行数:29,代码来源:delete.php

示例2: run

 public function run()
 {
     // Получаем название типа контента и сам тип
     $ctype = $this->model->getContentTypeByName($this->request->get('ctype_name', ''));
     if (!$ctype) {
         cmsCore::error404();
     }
     // проверяем наличие доступа
     if (!cmsUser::isAllowed($ctype['name'], 'delete_cat')) {
         cmsCore::error404();
     }
     $category = $this->model->getCategory($ctype['name'], $this->request->get('id', 0));
     if (!$category) {
         cmsCore::error404();
     }
     if (sizeof($category['path']) > 1) {
         $path = array_values($category['path']);
         $parent = $path[sizeof($category['path']) - 2];
     }
     $this->model->deleteCategory($ctype['name'], $category['id'], true);
     $back_url = $this->request->get('back', '');
     if ($back_url) {
         $this->redirect($back_url);
     } else {
         if ($ctype['options']['list_on']) {
             if (isset($parent)) {
                 $this->redirectTo($ctype['name'], $parent['slug']);
             } else {
                 $this->redirectTo($ctype['name']);
             }
         } else {
             $this->redirectToHome();
         }
     }
 }
开发者ID:Val-Git,项目名称:icms2,代码行数:35,代码来源:category_delete.php

示例3: run

 public function run($group)
 {
     if (!cmsUser::isAllowed('groups', 'delete')) {
         cmsCore::error404();
     }
     if (!cmsUser::isAllowed('groups', 'delete', 'all') && $group['owner_id'] != $this->cms_user->id) {
         cmsCore::error404();
     }
     if ($this->request->has('submit')) {
         // подтвержение получено
         $csrf_token = $this->request->get('csrf_token', '');
         $is_delete_content = $this->request->get('is_delete_content', 0);
         if (!cmsForm::validateCSRFToken($csrf_token)) {
             cmsCore::error404();
         }
         list($group, $is_delete_content) = cmsEventsManager::hook('group_before_delete', array($group, $is_delete_content));
         $this->model->removeContentFromGroup($group['id'], $is_delete_content);
         $this->model->deleteGroup($group);
         cmsUser::addSessionMessage(sprintf(LANG_GROUPS_DELETED, $group['title']));
         $this->redirectToAction('');
     } else {
         // спрашиваем подтверждение
         return $this->cms_template->render('group_delete', array('user' => $this->cms_user, 'group' => $group));
     }
 }
开发者ID:Val-Git,项目名称:icms2,代码行数:25,代码来源:group_delete.php

示例4: run

 public function run($data)
 {
     list($ctype, $album, $fields) = $data;
     $is_allow = $album['is_public'] || $album['user_id'] == $this->cms_user->id || $this->cms_user->is_admin;
     if ($is_allow && cmsUser::isAllowed($ctype['name'], 'add')) {
         $this->cms_template->addToolButton(array('class' => 'images', 'title' => LANG_PHOTOS_UPLOAD, 'href' => href_to($this->name, 'upload', $album['id'])));
     }
     $album['filter_panel'] = array('ordering' => modelPhotos::getOrderList(), 'types' => !empty($this->options['types']) ? array('' => LANG_PHOTOS_ALL) + $this->options['types'] : array(), 'orientation' => modelPhotos::getOrientationList(), 'width' => '', 'height' => '');
     $album['filter_values'] = array('ordering' => $this->cms_core->request->get('ordering', $this->options['ordering']), 'types' => $this->cms_core->request->get('types', ''), 'orientation' => $this->cms_core->request->get('orientation', ''), 'width' => $this->cms_core->request->get('width', 0) ?: '', 'height' => $this->cms_core->request->get('height', 0) ?: '');
     $album['url_params'] = array_filter($album['filter_values']);
     $album['filter_selected'] = $album['url_params'];
     if ($album['filter_selected']['ordering'] == $this->options['ordering']) {
         unset($album['filter_selected']['ordering']);
     }
     if (!in_array($album['filter_values']['ordering'], array_keys($album['filter_panel']['ordering']))) {
         $album['filter_values']['ordering'] = 'date_pub';
     }
     if ($album['filter_values']['types'] && !in_array($album['filter_values']['types'], array_keys($album['filter_panel']['types']))) {
         $album['filter_values']['types'] = '';
     }
     if ($album['filter_values']['orientation'] && !in_array($album['filter_values']['orientation'], array_keys($album['filter_panel']['orientation']))) {
         $album['filter_values']['orientation'] = '';
     }
     $album['base_url'] = href_to($ctype['name'], $album['slug'] . '.html') . '?' . http_build_query($album['url_params']);
     foreach ($album['filter_selected'] as $key => $value) {
         if (isset($album['filter_panel'][$key][$value])) {
             $title[] = $album['filter_panel'][$key][$value];
         }
     }
     if (!empty($title)) {
         $album['title'] .= ' — ' . mb_strtolower(implode(', ', $title));
         $album['seo_desc'] .= ' ' . $album['title'];
     }
     return array($ctype, $album, $fields);
 }
开发者ID:Val-Git,项目名称:icms2,代码行数:35,代码来源:content_albums_before_item.php

示例5: run

 public function run()
 {
     if (!$this->request->isAjax()) {
         cmsCore::error404();
     }
     $comment_id = $this->request->get('comment_id');
     $score = $this->request->get('score');
     // Проверяем валидность
     $is_valid = is_numeric($comment_id) && in_array($score, array(-1, 1));
     $template = cmsTemplate::getInstance();
     if (!$is_valid) {
         $template->renderJSON(array('error' => true));
     }
     $user = cmsUser::getInstance();
     $is_can_rate = cmsUser::isAllowed('comments', 'rate');
     if (!$is_can_rate) {
         $template->renderJSON(array('error' => true));
     }
     $is_voted = $this->model->isUserVoted($comment_id, $user->id);
     if ($is_voted) {
         $template->renderJSON(array('error' => true));
     }
     $comment = $this->model->getComment($comment_id);
     if ($comment['user_id'] == $user->id) {
         $template->renderJSON(array('error' => true));
     }
     $success = $this->model->rateComment($comment_id, $user->id, $score);
     $template->renderJSON(array('error' => !$success));
 }
开发者ID:asphix,项目名称:icms2,代码行数:29,代码来源:rate.php

示例6: run

 public function run()
 {
     $camera = urldecode($this->request->get('name', ''));
     if (!$camera) {
         cmsCore::error404();
     }
     if (cmsUser::isAllowed('albums', 'view_all')) {
         $this->model->disablePrivacyFilter();
     }
     $this->model->filterEqual('camera', $camera);
     $page = $this->request->get('photo_page', 1);
     $perpage = empty($this->options['limit']) ? 16 : $this->options['limit'];
     $this->model->limitPagePlus($page, $perpage);
     $this->model->orderBy($this->options['ordering'], 'desc');
     $photos = $this->getPhotosList();
     if (!$photos) {
         cmsCore::error404();
     }
     if ($photos && count($photos) > $perpage) {
         $has_next = true;
         array_pop($photos);
     } else {
         $has_next = false;
     }
     $ctype = cmsCore::getModel('content')->getContentTypeByName('albums');
     $this->cms_template->render('camera', array('page_title' => sprintf(LANG_PHOTOS_CAMERA_TITLE, $camera), 'ctype' => $ctype, 'page' => $page, 'row_height' => $this->getRowHeight(), 'user' => $this->cms_user, 'item' => array('id' => 0, 'user_id' => 0, 'url_params' => array('camera' => $camera), 'base_url' => href_to('photos', 'camera-' . urlencode($camera))), 'item_type' => 'camera', 'photos' => $photos, 'is_owner' => cmsUser::isAllowed('albums', 'delete', 'all'), 'has_next' => $has_next, 'hooks_html' => cmsEventsManager::hookAll('photo_camera_html', $camera), 'preset_small' => $this->options['preset_small']));
 }
开发者ID:Val-Git,项目名称:icms2,代码行数:27,代码来源:camera.php

示例7: run

 public function run()
 {
     if (!$this->request->isAjax()) {
         cmsCore::error404();
     }
     if (!cmsUser::isAllowed('comments', 'delete')) {
         cmsCore::error404();
     }
     $comment_id = $this->request->get('id');
     // Проверяем валидность
     $is_valid = is_numeric($comment_id);
     if (!$is_valid) {
         $result = array('error' => true, 'message' => LANG_ERROR);
         cmsTemplate::getInstance()->renderJSON($result);
     }
     $user = cmsUser::getInstance();
     $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_ERROR);
             cmsTemplate::getInstance()->renderJSON($result);
         }
     }
     $this->model->deleteComment($comment_id);
     $result = array('error' => false, 'message' => LANG_COMMENT_DELETED);
     cmsTemplate::getInstance()->renderJSON($result);
 }
开发者ID:rookees,项目名称:icms2,代码行数:27,代码来源:delete.php

示例8: run

 public function run()
 {
     if (!$this->request->isAjax()) {
         cmsCore::error404();
     }
     if (!cmsUser::isAllowed('comments', 'edit')) {
         cmsCore::error404();
     }
     $comment_id = $this->request->get('id');
     // Проверяем валидность
     $is_valid = is_numeric($comment_id);
     if (!$is_valid) {
         $result = array('error' => true, 'message' => LANG_ERROR);
         cmsTemplate::getInstance()->renderJSON($result);
     }
     $user = cmsUser::getInstance();
     $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_ERROR);
             cmsTemplate::getInstance()->renderJSON($result);
         }
     }
     // Формируем и возвращаем результат
     $result = array('error' => $comment ? false : true, 'id' => $comment_id, 'html' => $comment ? string_strip_br($comment['content']) : false);
     cmsTemplate::getInstance()->renderJSON($result);
 }
开发者ID:asphix,项目名称:icms2,代码行数:27,代码来源:get.php

示例9: run

 public function run()
 {
     $cat_id = $this->getOption('category_id');
     $ctype_id = $this->getOption('ctype_id');
     $dataset_id = $this->getOption('dataset');
     $image_field = $this->getOption('image_field');
     $big_image_field = $this->getOption('big_image_field');
     $big_image_preset = $this->getOption('big_image_preset');
     $teaser_fields = $this->getOption('teaser_field');
     $limit = $this->getOption('limit', 10);
     $delay = $this->getOption('delay', 5);
     $teaser_len = $this->getOption('teaser_len', 100);
     $model = cmsCore::getModel('content');
     $ctype = $model->getContentType($ctype_id);
     if (!$ctype) {
         return false;
     }
     if ($cat_id) {
         $category = $model->getCategory($ctype['name'], $cat_id);
     } else {
         $category = false;
     }
     if ($dataset_id) {
         $dataset = $model->getContentDataset($dataset_id);
         if ($dataset) {
             $model->applyDatasetFilters($dataset);
         } else {
             $dataset_id = false;
         }
     }
     if ($category) {
         $model->filterCategory($ctype['name'], $category, true);
     }
     // Приватность
     // флаг показа только названий
     $hide_except_title = !empty($ctype['options']['privacy_type']) && $ctype['options']['privacy_type'] == 'show_title';
     // Сначала проверяем настройки типа контента
     if (!empty($ctype['options']['privacy_type']) && in_array($ctype['options']['privacy_type'], array('show_title', 'show_all'), true)) {
         $model->disablePrivacyFilter();
         if ($ctype['options']['privacy_type'] != 'show_title') {
             $hide_except_title = false;
         }
     }
     // А потом, если разрешено правами доступа, отключаем фильтр приватности
     if (cmsUser::isAllowed($ctype['name'], 'view_all')) {
         $model->disablePrivacyFilter();
         $hide_except_title = false;
     }
     // Скрываем записи из скрытых родителей (приватных групп и т.п.)
     $model->filterHiddenParents();
     list($ctype, $model) = cmsEventsManager::hook('content_list_filter', array($ctype, $model));
     list($ctype, $model) = cmsEventsManager::hook("content_{$ctype['name']}_list_filter", array($ctype, $model));
     $items = $model->limit($limit)->getContentItems($ctype['name']);
     if (!$items) {
         return false;
     }
     list($ctype, $items) = cmsEventsManager::hook("content_before_list", array($ctype, $items));
     list($ctype, $items) = cmsEventsManager::hook("content_{$ctype['name']}_before_list", array($ctype, $items));
     return array('ctype' => $ctype, 'teaser_len' => $teaser_len, 'hide_except_title' => $hide_except_title, 'delay' => $delay, 'image_field' => $image_field, 'big_image_field' => $big_image_field, 'big_image_preset' => $big_image_preset, 'teaser_field' => $teaser_fields, 'items' => $items);
 }
开发者ID:dgolovanev,项目名称:icms2,代码行数:60,代码来源:widget.php

示例10: run

 public function run($photo_id = null)
 {
     if (!$this->request->isAjax()) {
         cmsCore::error404();
     }
     if (!$photo_id) {
         $photo_id = $this->request->get('id');
         if (!$photo_id) {
             cmsCore::error404();
         }
     }
     $photo = $this->model->getPhoto($photo_id);
     $success = true;
     // проверяем наличие доступа
     $user = cmsUser::getInstance();
     if (!cmsUser::isAllowed('albums', 'edit')) {
         $success = false;
     }
     if (!cmsUser::isAllowed('albums', 'edit', 'all') && $photo['user_id'] != $user->id) {
         $success = false;
     }
     if (!$success) {
         cmsTemplate::getInstance()->renderJSON(array('success' => false));
     }
     $album = cmsCore::getModel('content')->getContentItem('albums', $photo['album_id']);
     $this->model->deletePhoto($photo_id);
     $this->model->setRandomAlbumCoverImage($photo['album_id']);
     cmsTemplate::getInstance()->renderJSON(array('success' => true, 'album_url' => href_to('albums', $album['slug'] . '.html')));
 }
开发者ID:asphix,项目名称:icms2,代码行数:29,代码来源:delete.php

示例11: renderPhotosList

 public function renderPhotosList($item, $item_type, $page, $perpage = false, $show_next = true)
 {
     $perpage = $perpage ? $perpage : (empty($this->options['limit']) ? 16 : $this->options['limit']);
     if (!$this->model->order_by) {
         $this->model->orderBy($this->options['ordering'], 'desc');
     }
     if ($show_next) {
         // получаем на одну страницу больше
         $this->model->limitPagePlus($page, $perpage);
     } else {
         $this->model->limit($perpage);
     }
     $photos = $this->getPhotosList($item['id'], $item_type);
     if (!$photos && $page > 1) {
         cmsCore::error404();
     }
     if ($show_next && $photos && count($photos) > $perpage) {
         $has_next = true;
         array_pop($photos);
     } else {
         $has_next = false;
     }
     $is_owner = cmsUser::isAllowed('albums', 'delete', 'all') || cmsUser::isAllowed('albums', 'delete', 'own') && $item['user_id'] == $this->cms_user->id;
     $tpl_data = array('row_height' => $this->getRowHeight(), 'user' => $this->cms_user, 'item' => $item, 'photos' => $photos, 'page' => $page, 'has_next' => $has_next, 'is_owner' => $is_owner, 'item_type' => $item_type, 'preset_small' => $this->options['preset_small']);
     if (!$this->request->isAjax()) {
         return $this->cms_template->renderInternal($this, 'album', $tpl_data);
     } else {
         $this->halt($this->cms_template->renderInternal($this, 'photos', $tpl_data));
     }
 }
开发者ID:Val-Git,项目名称:icms2,代码行数:30,代码来源:frontend.php

示例12: run

 public function run($profile_id)
 {
     if (!cmsUser::isLogged()) {
         cmsCore::error404();
     }
     if (!$this->request->isAjax()) {
         cmsCore::error404();
     }
     $user = cmsUser::getInstance();
     $direction = $this->request->get('direction');
     $comment = $this->request->get('comment');
     //
     // Проверяем валидность
     //
     $is_valid = $user->is_logged && cmsUser::isAllowed('users', 'vote_karma') && is_numeric($profile_id) && $user->id != $profile_id && in_array($direction, array('up', 'down')) && (!$this->options['is_karma_comments'] || $comment);
     if (!$is_valid) {
         $result = array('error' => true, 'message' => LANG_ERROR);
         cmsTemplate::getInstance()->renderJSON($result);
     }
     $profile = $this->model->getUser($profile_id);
     if (!$profile || !$this->model->isUserCanVoteKarma($user->id, $profile_id, $this->options['karma_time'])) {
         $result = array('error' => true, 'message' => LANG_ERROR);
         cmsTemplate::getInstance()->renderJSON($result);
     }
     //
     // Сохраняем оценку
     //
     $vote = array('user_id' => $user->id, 'profile_id' => $profile_id, 'points' => $direction == 'up' ? 1 : -1, 'comment' => $comment);
     $vote_id = $this->model->addKarmaVote($vote);
     $value = $profile['karma'] + $vote['points'];
     $result = array('error' => $vote_id ? false : true, 'value' => html_signed_num($value), 'css_class' => html_signed_class($value));
     cmsTemplate::getInstance()->renderJSON($result);
 }
开发者ID:asphix,项目名称:icms2,代码行数:33,代码来源:karma_vote.php

示例13: run

 public function run()
 {
     if (!$this->request->isAjax()) {
         cmsCore::error404();
     }
     $comment_id = $this->request->get('comment_id', 0);
     $score = $this->request->get('score', '');
     // Проверяем валидность
     $is_valid = is_numeric($comment_id) && in_array($score, array(-1, 1));
     if (!$is_valid) {
         $this->cms_template->renderJSON(array('error' => true));
     }
     $is_can_rate = cmsUser::isAllowed('comments', 'rate');
     if (!$is_can_rate) {
         $this->cms_template->renderJSON(array('error' => true));
     }
     $is_voted = $this->model->isUserVoted($comment_id, $this->cms_user->id);
     if ($is_voted) {
         $this->cms_template->renderJSON(array('error' => true));
     }
     $comment = $this->model->getComment($comment_id);
     if ($comment['user_id'] == $this->cms_user->id) {
         $this->cms_template->renderJSON(array('error' => true));
     }
     $success = $this->model->rateComment($comment_id, $this->cms_user->id, $score);
     if ($success && $comment['user_id'] && !empty($this->options['update_user_rating'])) {
         $rating = $this->model->getItemById('{users}', $comment['user_id']);
         $this->model->update('{users}', $comment['user_id'], array('rating' => $rating['rating'] + $score));
     }
     cmsCore::getController('activity')->addEntry($this->name, 'vote.comment', array('is_private' => (int) $comment['is_private'], 'subject_title' => $comment['target_title'], 'subject_id' => $comment_id, 'subject_url' => $comment['target_url'] . '#comment_' . $comment['id']));
     $this->cms_template->renderJSON(array('error' => !$success));
 }
开发者ID:Val-Git,项目名称:icms2,代码行数:32,代码来源:rate.php

示例14: run

 public function run()
 {
     if (!$this->request->isAjax()) {
         cmsCore::error404();
     }
     $photo_id = $this->request->get('id');
     $new_title = $this->request->get('title');
     if (!$photo_id || !$new_title) {
         cmsCore::error404();
     }
     $photo = $this->model->getPhoto($photo_id);
     $success = true;
     // проверяем наличие доступа
     $user = cmsUser::getInstance();
     if (!cmsUser::isAllowed('albums', 'edit')) {
         $success = false;
     }
     if (!cmsUser::isAllowed('albums', 'edit', 'all') && $photo['user_id'] != $user->id) {
         $success = false;
     }
     if (!$success) {
         cmsTemplate::getInstance()->renderJSON(array('success' => false));
     }
     $this->model->renamePhoto($photo_id, $new_title);
     cmsTemplate::getInstance()->renderJSON(array('success' => true));
 }
开发者ID:asphix,项目名称:icms2,代码行数:26,代码来源:rename.php

示例15: run

 public function run()
 {
     if (!$this->request->isAjax()) {
         cmsCore::error404();
     }
     if (!cmsUser::isAllowed('comments', 'is_moderator')) {
         return $this->cms_template->renderJSON(array('error' => true, 'message' => LANG_COMMENT_ERROR));
     }
     $comment_id = $this->request->get('id', 0);
     if (!$comment_id) {
         return $this->cms_template->renderJSON(array('error' => true, 'message' => LANG_COMMENT_ERROR));
     }
     $comment = $this->model->getComment($comment_id);
     if (!$comment) {
         return $this->cms_template->renderJSON(array('error' => true, 'message' => LANG_COMMENT_ERROR));
     }
     $this->model->approveComment($comment['id']);
     // Уведомляем модель целевого контента об изменении количества комментариев
     $comments_count = $this->model->filterCommentTarget($comment['target_controller'], $comment['target_subject'], $comment['target_id'])->getCommentsCount();
     $this->model->resetFilters();
     cmsCore::getModel($comment['target_controller'])->updateCommentsCount($comment['target_subject'], $comment['target_id'], $comments_count);
     $parent_comment = $comment['parent_id'] ? $this->model->getComment($comment['parent_id']) : false;
     // Уведомляем подписчиков
     $this->notifySubscribers($comment, $parent_comment);
     // Уведомляем об ответе на комментарий
     if ($parent_comment) {
         $this->notifyParent($comment, $parent_comment);
     }
     $comment = cmsEventsManager::hook('comment_after_add', $comment);
     return $this->cms_template->renderJSON(array('error' => false, 'message' => '', 'id' => $comment['id'], 'parent_id' => $comment['parent_id'], 'level' => $comment['level'], 'html' => cmsEventsManager::hook('parse_text', $comment['content_html'])));
 }
开发者ID:Val-Git,项目名称:icms2,代码行数:31,代码来源:approve.php


注:本文中的cmsUser::isAllowed方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。