本文整理汇总了PHP中cmsCore::jsonOutput方法的典型用法代码示例。如果您正苦于以下问题:PHP cmsCore::jsonOutput方法的具体用法?PHP cmsCore::jsonOutput怎么用?PHP cmsCore::jsonOutput使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cmsCore
的用法示例。
在下文中一共展示了cmsCore::jsonOutput方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: subscribes
function subscribes(){
$inCore = cmsCore::getInstance();
$inUser = cmsUser::getInstance();
$do = $inCore->do;
//========================================================================================================================//
//========================================================================================================================//
if ($do=='view'){
$subscribe = cmsCore::request('subscribe', 'int', 0);
$target = cmsCore::request('target', 'str', '');
$target_id = cmsCore::request('target_id', 'int', 0);
if (!$target_id || !$target){
cmsCore::error404();
}
if ($inUser->id){
cmsUser::subscribe($inUser->id, $target, $target_id, $subscribe);
}
if(cmsCore::isAjax()){
cmsCore::jsonOutput(array('subscribe'=>$subscribe));
} else {
cmsCore::redirectBack();
}
}
}
示例2: polls
function polls()
{
$model = new cms_model_polls();
global $_LANG;
$do = cmsCore::getInstance()->do;
//========================================================================================================================//
//========================================================================================================================//
if ($do == 'view') {
$answer = cmsCore::request('answer', 'str', '');
$poll_id = cmsCore::request('poll_id', 'int');
if (!$answer || !$poll_id) {
if (cmsCore::isAjax()) {
cmsCore::jsonOutput(array('error' => true, 'text' => $_LANG['SELECT_THE_OPTION']));
} else {
cmsCore::error404();
}
}
$poll = $model->getPoll($poll_id);
if (!$poll) {
cmsCore::jsonOutput(array('error' => true, 'text' => ''));
}
if ($model->isUserVoted($poll_id)) {
cmsCore::jsonOutput(array('error' => true, 'text' => ''));
}
if (!cmsUser::checkCsrfToken()) {
cmsCore::halt();
}
$model->votePoll($poll, $answer);
cmsCore::jsonOutput(array('error' => false, 'text' => $_LANG['VOTE_ACCEPTED']));
}
}
示例3: if
}
//Выставляем качество итогового изображения
cmsCore::c('images')->quality = $cfg['imgs_quality'];
$file_name = cmsCore::c('images')->resize('file', true);
if (empty($file_name) && cmsCore::uploadError()) {
cmsCore::jsonOutput(array('error' => cmsCore::uploadError(), 'msg' => ''), false);
} else if (empty($file_name)) {
cmsCore::jsonOutput(array('error' => 'UNKNOWN ERROR', 'msg' => ''), false);
}
if (!$file_name) {
cmsCore::jsonOutput(array('error' => cmsCore::uploadError(), 'msg' => ''), false);
}
$fileurl = $ym .'/'. $d .'/'. $f .'/'. $file_name;
$file_id = cmsCore::registerUploadImages($target_id, $target, $fileurl, $component);
cmsCore::jsonOutput(
array(
'small_src' => '/upload/'. $component .'/small/'. $fileurl,
'medium_src' => '/upload/'. $component .'/medium/'. $fileurl,
'big_src' => '/upload/'. $component .'/big/'. $fileurl,
'id' => $file_id,
'msg' => '/upload/'. $component .'/big/'. $fileurl // Будет удалено в скором времени
),
false
);
示例4:
if(!$club['enabled_blogs']){ cmsCore::halt(); }
$model->initClubMembers($club['id']);
$is_admin = $inUser->is_admin || ($inUser->id == $club['admin_id']);
$is_moder = $model->checkUserRightsInClub('moderator');
if (!$is_admin && !$is_moder) { cmsCore::halt(); }
if(!cmsUser::checkCsrfToken()) { cmsCore::halt(); }
$inBlog->deleteBlogCategory($cat['id']);
cmsCore::addSessionMessage($_LANG['CAT_IS_DELETED'], 'success');
cmsCore::jsonOutput(array('error' => false, 'redirect' => $model->getBlogURL($club['id'])));
}
///////////////////////// ПУБЛИКАЦИЯ ПОСТА /////////////////////////////////////
if ($bdo == 'publishpost'){
if (!cmsCore::isAjax() || !$inUser->id) { return false; }
$post = $inBlog->getPost($post_id);
if (!$post){ cmsCore::halt(); }
$blog = $inBlog->getBlog($post['blog_id']);
if (!$blog) { cmsCore::halt(); }
$club = $model->getClub($blog['user_id']);
if(!$club) { cmsCore::halt(); }
if(!$club['enabled_blogs']){ cmsCore::halt(); }
示例5: cmsTagLine
if ($item) {
$target = $component == 'blog_posts' ? 'blogpost' : $component;
$item['tags'] = cmsTagLine("{$target}", $item_id, false);
}
if (!$item) {
cmsCore::jsonOutput(array('error' => true, 'html' => ' Не получена запись для редактирования!'));
cmsCore::halt();
}
//изображение статьи для формы редактирования статей
if ($component == 'content') {
$item['image'] = file_exists(PATH . '/images/photos/medium/article' . $item['id'] . '.jpg') ? 'article' . $item['id'] . '.jpg' : '';
}
//html-код формы
$html = '';
ob_start();
$smarty = cmsPage::initTemplate('plugins', $template);
$smarty->assign('item', $item);
$smarty->assign('csrf_token', cmsUser::getCsrfToken());
if ($component == 'blog_posts') {
//получаем код панелей bbcode и смайлов
$bb_toolbar = cmsPage::getBBCodeToolbar('message', true, 'blogs', 'blog_post', $item['id']);
$smilies = cmsPage::getSmilesPanel('message');
$smarty->assign('smilies', $smilies);
$smarty->assign('bb_toolbar', $bb_toolbar);
}
$smarty->display($template);
$html = ob_get_clean();
cmsCore::jsonOutput(array('error' => false, 'html' => $html));
?>
示例6: geo
function geo($do)
{
$inUser = cmsUser::getInstance();
$model = new cms_model_geo();
// Определяем местоположение пользователя
$inUser->loadUserGeo();
$do = isset($do) ? $do : cmsCore::getInstance()->do;
$field_id = cmsCore::request('field_id', 'int', 0);
$city_id = cmsCore::strClear(urldecode($_REQUEST['city_id']));
// можно передавать как id города, так и название
//========================================================================================================================//
if ($do == 'view') {
if (!cmsCore::isAjax()) {
cmsCore::error404();
}
$countries = $model->getCountries();
$regions = array();
$cities = array();
$region_id = false;
$country_id = false;
if (!$city_id && $inUser->city) {
$city_id = $inUser->city;
}
if ($city_id) {
$city_parents = $model->getCityParents($city_id);
if ($city_parents) {
$region_id = $city_parents['region_id'];
$country_id = $city_parents['country_id'];
$regions = $model->getRegions($country_id);
$cities = $model->getCities($region_id);
$city_id = $city_parents['id'];
} else {
$city_id = 0;
}
}
cmsPage::initTemplate('components', 'com_geo_view')->assign('field_id', $field_id)->assign('city_id', $city_id)->assign('country_id', $country_id)->assign('region_id', $region_id)->assign('countries', $countries)->assign('regions', $regions)->assign('cities', $cities)->display('com_geo_view.tpl');
}
//========================================================================================================================//
if ($do == 'get') {
if (!cmsCore::isAjax()) {
cmsCore::error404();
}
$type = cmsCore::request('type', 'str', '');
$parent_id = cmsCore::request('parent_id', 'int', 0);
if (!in_array($type, array('regions', 'cities'))) {
cmsCore::error404();
}
if (!$parent_id) {
cmsCore::error404();
}
switch ($type) {
case 'regions':
$items = $model->getRegions($parent_id);
break;
case 'cities':
$items = $model->getCities($parent_id);
break;
default:
$items = array();
}
cmsCore::jsonOutput(array('error' => $items ? false : true, 'items' => $items));
}
}
示例7: forms
function forms()
{
cmsCore::loadClass('form');
$do = cmsCore::getInstance()->do;
global $_LANG;
//========================================================================================================================//
//========================================================================================================================//
if ($do == 'view') {
// Получаем форму
$form = cmsForm::getFormData(cmsCore::request('form_id', 'int'));
if (!$form) {
cmsCore::error404();
}
// Получаем данные полей формы
$form_fields = cmsForm::getFormFields($form['id']);
// Если полей нет, 404
if (!$form_fields) {
cmsCore::error404();
}
$errors = array();
$attachment = array();
// Получаем данные формы
// Если не переданы, назад
$form_input = cmsForm::getFieldsInputValues($form['id']);
if (!$form_input) {
$errors[] = $_LANG['FORM_ERROR'];
}
// Проверяем значения формы
foreach ($form_input['errors'] as $field_error) {
if ($field_error) {
$errors[] = $field_error;
}
}
// проверяем каптчу
if (!cmsPage::checkCaptchaCode()) {
$errors[] = $_LANG['ERR_CAPTCHA'];
}
if ($errors) {
if (cmsCore::isAjax()) {
cmsCore::jsonOutput(array('error' => true, 'text' => end($errors)));
} else {
foreach ($errors as $error) {
cmsCore::addSessionMessage($error, 'error');
}
cmsCore::redirectBack();
}
}
if (!cmsUser::checkCsrfToken()) {
cmsCore::error404();
}
// Подготовим начало письма
$mail_message = '<h3>' . $_LANG['FORM'] . ': ' . $form['title'] . '</h3>';
// Добавляем заполненные поля в письмо
foreach ($form_fields as $field) {
// Значение поля
$value = $form_input['values'][$field['id']];
if (!$value) {
continue;
}
if (is_string($value)) {
$mail_message .= '<h5>' . $field['title'] . '</h5><p>' . $value . '</p>';
} elseif (is_array($value)) {
// если массив, значит к форме прикреплен файл
if ($form['sendto'] == 'mail') {
$attachment[] = !empty($value['url']) ? PATH . $value['url'] : '';
} elseif (!empty($value['url'])) {
$mail_message .= '<h5>' . $field['title'] . '</h5><p><a href="' . $value['url'] . '">' . $value['name'] . '</a></p>';
}
}
}
// Отправляем форму
if ($form['sendto'] == 'mail') {
$emails = explode(',', $form['email']);
if ($emails) {
foreach ($emails as $email) {
cmsCore::mailText(trim($email), cmsConfig::getConfig('sitename') . ': ' . $form['title'], $mail_message, $attachment);
}
}
// удаляем прикрепленные файлы
foreach ($attachment as $attach) {
@unlink($attach);
}
} else {
cmsUser::sendMessage(-2, $form['user_id'], $mail_message);
}
cmsUser::sessionClearAll();
if (cmsCore::isAjax()) {
cmsCore::jsonOutput(array('error' => false, 'text' => $_LANG['FORM_IS_SEND']));
} else {
cmsCore::addSessionMessage($_LANG['FORM_IS_SEND'], 'info');
cmsCore::redirectBack();
}
}
//========================================================================================================================//
}
示例8: blogs
//.........这里部分代码省略.........
cmsCore::addSessionMessage($_LANG['BLOG_CREATED_TEXT'], 'info');
cmsCore::redirect(cmsCore::m('blogs')->getBlogURL($blog_link));
}
}
////////// НАСТРОЙКИ БЛОГА /////////////////////////////////////////////////
if ($inCore->do=='config'){
if(!cmsCore::c('user')->id) { cmsCore::error404(); }
if(!cmsCore::isAjax()) { cmsCore::error404(); }
// получаем блог
$blog = cmsCore::c('blog')->getBlog($id);
if (!$blog) { cmsCore::error404(); }
//Проверяем является пользователь хозяином блога или админом
if ($blog['user_id'] != cmsCore::c('user')->id && !cmsCore::c('user')->is_admin ) { cmsCore::halt(); }
//Если нет запроса на сохранение, показываем форму настроек блога
if (!cmsCore::inRequest('goadd')){
//Получаем список авторов блога
$authors = cmsCore::c('blog')->getBlogAuthors($blog['id']);
cmsPage::initTemplate('components', 'com_blog_config')->
assign('blog', $blog)->
assign('form_action', '/blogs/'.$blog['id'].'/editblog.html')->
assign('authors_list', cmsUser::getAuthorsList($authors))->
assign('users_list', cmsUser::getUsersList(false, $authors))->
assign('is_restrictions', (!cmsCore::c('user')->is_admin && cmsCore::m('blogs')->config['min_karma']))->
assign('cfg', cmsCore::m('blogs')->config)->
assign('is_admin', cmsCore::c('user')->is_admin)->
display();
cmsCore::jsonOutput(array('error' => false, 'html' => ob_get_clean()));
}
//Если пришел запрос на сохранение
if (cmsCore::inRequest('goadd')){
//Получаем настройки
$title = cmsCore::request('title', 'str');
$allow_who = cmsCore::request('allow_who', 'str', 'all');
$ownertype = cmsCore::request('ownertype', 'str', 'single');
$premod = cmsCore::request('premod', 'int', 0);
$forall = cmsCore::request('forall', 'int', 1);
$showcats = cmsCore::request('showcats', 'int', 1);
$authors = cmsCore::request('authorslist', 'array_int', array());
if (cmsCore::m('blogs')->config['seo_user_access'] || cmsCore::c('user')->is_admin) {
$page_title = cmsCore::request('pagetitle', 'str', '');
$meta_keys = cmsCore::request('meta_keys', 'str', '');
$meta_desc = cmsCore::request('meta_desc', 'str', '');
} else {
$page_title = $meta_keys = $meta_desc = '';
}
//Проверяем настройки
if (mb_strlen($title)<5) { $title = $blog['title']; }
//Проверяем ограничения по карме (для смены типа блога)
if (cmsCore::m('blogs')->config['min_karma'] && !cmsCore::c('user')->is_admin){
// если персональный блог
if ($ownertype=='single' && (cmsCore::c('user')->karma < cmsCore::m('blogs')->config['min_karma_private'])){
cmsCore::jsonOutput(array('error' => true, 'text' => $_LANG['BLOG_YOU_NEED'].' <a href="/users/'.cmsCore::c('user')->id.'/karma.html">'.$_LANG['BLOG_KARMS'].'</a> '.$_LANG['FOR_CREATE_PERSON_BLOG'].' — '.cmsCore::m('blogs')->config['min_karma_private'].', '.$_LANG['BLOG_HEAVING'].' — '.cmsCore::c('user')->karma));
}
// если коллективный блог
if ($ownertype=='multi' && (cmsCore::c('user')->karma < cmsCore::m('blogs')->config['min_karma_public'])){
示例9: comments
//.........这里部分代码省略.........
//========================================================================================================================//
// Добавление комментария, форма добавления в addform.php
if ($do == 'add') {
// Только аякс
if (!cmsCore::isAjax()) {
cmsCore::error404();
}
// Очищаем буфер
ob_end_clean();
// Добавлять могут только админы и те, кому разрешено в настройках группы
if (!$model->is_can_add && !$inUser->is_admin) {
cmsCore::error404();
}
// Входные данные
$comment['guestname'] = cmsCore::request('guestname', 'str', '');
$comment['user_id'] = $inUser->id;
if ($model->is_can_bbcode) {
$content = cmsCore::request('content', 'html', '');
$comment['content_bbcode'] = $inDB->escape_string($content);
$content = cmsCore::parseSmiles($content, true);
$comment['content'] = $inDB->escape_string($content);
} else {
$comment['content'] = cmsCore::request('content', 'str', '');
$comment['content_bbcode'] = $comment['content'];
$comment['content'] = str_replace(array('\\r', '\\n'), '<br>', $comment['content']);
}
$comment['parent_id'] = cmsCore::request('parent_id', 'int', 0);
$comment['target'] = cmsCore::request('target', 'str', '');
$comment['target_id'] = cmsCore::request('target_id', 'int', 0);
$comment['ip'] = cmsCore::strClear($_SERVER['REMOTE_ADDR']);
// Проверяем правильность/наличие входных парамеров
// цель комментария
if (!$comment['target'] || !$comment['target_id']) {
cmsCore::jsonOutput(array('error' => true, 'text' => $_LANG['ERR_UNKNOWN_TARGET']));
}
// Имя гостя отсутствует
if (!$comment['guestname'] && !$inUser->id) {
cmsCore::jsonOutput(array('error' => true, 'text' => $_LANG['ERR_USER_NAME']));
}
// Текст комментраия отсутствует
if (!$comment['content']) {
cmsCore::jsonOutput(array('error' => true, 'text' => $_LANG['ERR_COMMENT_TEXT']));
}
// проверяем каптчу
$need_captcha = $model->config['regcap'] ? true : ($inUser->id ? false : true);
if ($need_captcha && !cmsPage::checkCaptchaCode()) {
cmsCore::jsonOutput(array('error' => true, 'is_captcha' => true, 'text' => $_LANG['ERR_CAPTCHA']));
}
// получаем массив со ссылкой и заголовком цели комментария
// для этого:
// 1. узнаем ответственный компонент из cms_comment_targets
$target = $inDB->get_fields('cms_comment_targets', "target='{$comment['target']}'", '*');
if (!$target) {
cmsCore::jsonOutput(array('error' => true, 'text' => $_LANG['ERR_UNKNOWN_TARGET'] . ' #1'));
}
// 2. подключим модель этого компонента
if (cmsCore::loadModel($target['component'])) {
$model_class = 'cms_model_' . $target['component'];
if (class_exists($model_class)) {
$target_model = new $model_class();
}
}
if (!isset($target_model)) {
cmsCore::jsonOutput(array('error' => true, 'text' => $_LANG['ERR_UNKNOWN_TARGET'] . ' #2'));
}
// 3. запросим массив $target_data[link, title] у метода getCommentTarget модели
示例10: cms_model_clubs
include PATH . '/core/ajax/ajax_core.php';
$title = cmsCore::request('title', 'str');
$club_id = cmsCore::request('club_id', 'int');
cmsCore::loadModel('clubs');
$model = new cms_model_clubs();
if (!$title || !$club_id) {
cmsCore::jsonOutput(array('error' => true, 'text' => $_LANG['ALBUM_REQ_TITLE']));
}
$club = $model->getClub($club_id);
if (!($club && $inUser->id) || !$club['published']) {
cmsCore::halt();
}
if (!$club['enabled_photos']) {
cmsCore::halt();
}
// Инициализируем участников клуба
$model->initClubMembers($club['id']);
// права доступа
$is_admin = $inUser->is_admin || $inUser->id == $club['admin_id'];
$is_moder = $model->checkUserRightsInClub('moderator');
$is_member = $model->checkUserRightsInClub('member');
$is_karma_enabled = $inUser->karma >= $club['album_min_karma'] && $is_member ? true : false;
if ($is_admin || $is_moder || $is_karma_enabled) {
$parent_id = $inDB->getNsRootCatId('cms_photo_albums', 'club' . $club['id']);
$album_id = $inDB->addNsCategory('cms_photo_albums', array('parent_id' => $parent_id, 'title' => $title, 'user_id' => $club['id'], 'published' => 1), 'club' . $club['id']);
cmsCore::jsonOutput(array('error' => false, 'album_id' => (string) $album_id));
} elseif (!$is_karma_enabled) {
cmsCore::jsonOutput(array('error' => true, 'text' => '<p><strong>' . $_LANG['NEED_KARMA_ALBUM'] . '</strong></p><p>' . $_LANG['NEEDED'] . ' ' . $club['album_min_karma'] . ', ' . $_LANG['HAVE_ONLY'] . ' ' . $inUser->karma . '.</p><p>' . $_LANG['WANT_SEE'] . ' <a href="/users/' . $inUser->id . '/karma.html">' . $_LANG['HISTORY_YOUR_KARMA'] . '</a>?</p>'));
} else {
cmsCore::halt();
}
示例11: geo
function geo($do=null) {
// Определяем местоположение пользователя
cmsCore::c('user')->loadUserGeo();
$do = isset($do) ? $do : cmsCore::getInstance()->do;
$field_id = cmsCore::request('field_id', 'int', 0);
$city_id = cmsCore::strClear(urldecode(cmsCore::request('city_id', 'html', 0))); // можно передавать как id города, так и название
//========================================================================================================================//
if ($do == 'view'){
if (!cmsCore::isAjax()) { cmsCore::error404(); }
$countries = cmsCore::m('geo')->getCountries();
$regions = array();
$cities = array();
$region_id = false;
// определяем страну
if (isset(cmsCore::c('user')->geo['country'])) {
$country_id = cmsCore::c('db')->get_field('cms_geo_countries', "alpha2 = '". cmsCore::c('user')->geo['country'] ."'", 'id');
} else {
$country_id = false;
}
if (!$city_id && cmsCore::c('user')->city) {
$city_id = cmsCore::c('user')->city;
}
if ($city_id){
$city_parents = cmsCore::m('geo')->getCityParents($city_id);
if($city_parents){
$region_id = $city_parents['region_id'];
$country_id = $city_parents['country_id'];
$regions = cmsCore::m('geo')->getRegions($country_id);
$cities = cmsCore::m('geo')->getCities($region_id);
$city_id = $city_parents['id'];
} else {
$city_id = 0;
}
}
cmsPage::initTemplate('components', 'com_geo_view')->
assign('field_id', $field_id)->
assign('city_id', $city_id)->
assign('country_id', $country_id)->
assign('region_id', $region_id)->
assign('countries', $countries)->
assign('regions', $regions)->
assign('cities', $cities)->
display();
}
//========================================================================================================================//
if ($do == 'get'){
if (!cmsCore::isAjax()) { cmsCore::error404(); }
$type = cmsCore::request('type', 'str', '');
$parent_id = cmsCore::request('parent_id', 'int', 0);
if (!in_array($type, array('regions', 'cities'))) { cmsCore::error404(); }
if (!$parent_id) { cmsCore::error404(); }
switch ( $type ){
case 'regions': $items = cmsCore::m('geo')->getRegions( $parent_id );
break;
case 'cities': $items = cmsCore::m('geo')->getCities( $parent_id );
break;
default: $items = array();
}
cmsCore::jsonOutput(array(
'error' => $items ? false : true,
'items' => $items
));
}
}
示例12:
}
if (!isset($cfg['img_h'])) {
$cfg['img_h'] = 900;
}
// Разрешена ли загрузка
if (!$cfg['img_on']) {
cmsCore::jsonOutput(array('error' => $_LANG['UPLOAD_IMG_IS_DISABLE'], 'msg' => ''), false);
}
// Не превышен ли лимит
if (cmsCore::getTargetCount($target_id) >= $cfg['img_max']) {
cmsCore::jsonOutput(array('error' => $_LANG['UPLOAD_IMG_LIMIT'], 'msg' => ''), false);
}
// Подготавливаем класс загрузки фото
cmsCore::loadClass('upload_photo');
$inUploadPhoto = cmsUploadPhoto::getInstance();
$inUploadPhoto->upload_dir = PATH . '/upload/';
$inUploadPhoto->dir_medium = $component . '/';
$inUploadPhoto->medium_size_w = $cfg['img_w'];
$inUploadPhoto->medium_size_h = $cfg['img_h'];
$inUploadPhoto->is_watermark = $cfg['watermark'];
$inUploadPhoto->only_medium = true;
$inUploadPhoto->input_name = 'attach_img';
// загружаем фото
$file = $inUploadPhoto->uploadPhoto();
if (!$file) {
cmsCore::jsonOutput(array('error' => cmsCore::uploadError(), 'msg' => ''), false);
}
$fileurl = '/upload/' . $component . '/' . $file['filename'];
cmsCore::registerUploadImages($target_id, $target, $fileurl, $component);
cmsCore::jsonOutput(array('error' => '', 'msg' => $fileurl), false);
示例13: blog
function blog()
{
$inCore = cmsCore::getInstance();
$inPage = cmsPage::getInstance();
$inDB = cmsDatabase::getInstance();
$inUser = cmsUser::getInstance();
cmsCore::loadClass('blog');
$inBlog = cmsBlogs::getInstance();
$inBlog->owner = 'site';
global $_LANG;
cmsCore::loadModel('blog');
$model = new cms_model_blog();
define('IS_BILLING', $inCore->isComponentInstalled('billing'));
if (IS_BILLING) {
cmsCore::loadClass('billing');
}
// Проверяем включени ли компонент
if (!$model->config['component_enabled']) {
cmsCore::error404();
}
//Получаем параметры
$id = cmsCore::request('id', 'int', 0);
$post_id = cmsCore::request('post_id', 'int', 0);
$seolink = cmsCore::request('seolink', 'str', '');
$do = cmsCore::request('do', 'str', 'blog');
$page = cmsCore::request('page', 'int', 1);
$cat_id = cmsCore::request('cat_id', 'int', 0);
$ownertype = cmsCore::request('ownertype', 'str', '');
$on_moderate = cmsCore::request('on_moderate', 'int', 0);
$pagetitle = $inCore->menuTitle();
$pagetitle = $pagetitle && $inCore->isMenuIdStrict() ? $pagetitle : $_LANG['RSS_BLOGS'];
$inPage->addPathway($pagetitle, '/blog');
$inPage->setTitle($pagetitle);
$inPage->setDescription($pagetitle);
$blog_id = 25;
////////// НАСТРОЙКИ БЛОГА ////////////////////////////////////////////////////////////////////////////////////////
if ($do == 'config') {
if ($_SERVER['HTTP_X_REQUESTED_WITH'] != 'XMLHttpRequest') {
cmsCore::halt();
}
if (!$inUser->id) {
cmsCore::halt();
}
// получаем блог
$blog = $inBlog->getBlog($id);
if (!$blog) {
cmsCore::error404();
}
//Проверяем является пользователь хозяином блога или админом
if ($blog['user_id'] != $inUser->id && !$inUser->is_admin) {
cmsCore::halt();
}
//Если нет запроса на сохранение, показываем форму настроек блога
if (!cmsCore::inRequest('goadd')) {
//Получаем список авторов блога
$authors = $inBlog->getBlogAuthors($blog['id']);
$smarty = $inCore->initSmarty('components', 'com_blog_config.tpl');
$smarty->assign('blog', $blog);
$smarty->assign('form_action', '/blog/' . $blog['id'] . '/editblog.html');
$smarty->assign('authors_list', cmsUser::getAuthorsList($authors));
$smarty->assign('users_list', cmsUser::getUsersList(false, $authors));
$smarty->assign('is_restrictions', !$inUser->is_admin && $model->config['min_karma']);
$smarty->assign('cfg', $model->config);
$smarty->display('com_blog_config.tpl');
cmsCore::jsonOutput(array('error' => false, 'html' => ob_get_clean()));
}
//Если пришел запрос на сохранение
if (cmsCore::inRequest('goadd')) {
if (!cmsCore::validateForm()) {
cmsCore::halt();
}
//Получаем настройки
$title = cmsCore::request('title', 'str');
$allow_who = cmsCore::request('allow_who', 'str', 'all');
$ownertype = cmsCore::request('ownertype', 'str', 'single');
$premod = cmsCore::request('premod', 'int', 0);
$forall = cmsCore::request('forall', 'int', 1);
$showcats = cmsCore::request('showcats', 'int', 1);
$authors = cmsCore::request('authorslist', 'array_int', array());
//Проверяем настройки
if (mb_strlen($title) < 5) {
$title = $blog['title'];
}
//Проверяем ограничения по карме (для смены типа блога)
if ($model->config['min_karma'] && !$inUser->is_admin) {
// если персональный блог
if ($ownertype == 'single' && $inUser->karma < $model->config['min_karma_private']) {
cmsCore::jsonOutput(array('error' => true, 'text' => $_LANG['BLOG_YOU_NEED'] . ' <a href="/users/' . $inUser->id . '/karma.html">' . $_LANG['BLOG_KARMS'] . '</a> ' . $_LANG['FOR_CREATE_PERSON_BLOG'] . ' — ' . $model->config['min_karma_private'] . ', ' . $_LANG['BLOG_HEAVING'] . ' — ' . $inUser->karma));
}
// если коллективный блог
if ($ownertype == 'multi' && $inUser->karma < $model->config['min_karma_public']) {
cmsCore::jsonOutput(array('error' => true, 'text' => $_LANG['BLOG_YOU_NEED'] . ' <a href="/users/' . $inUser->id . '/karma.html">' . $_LANG['BLOG_KARMS'] . '</a> ' . $_LANG['FOR_CREATE_TEAM_BLOG'] . ' — ' . $model->config['min_karma_public'] . ', ' . $_LANG['BLOG_HEAVING'] . ' — ' . $inUser->karma));
}
}
//сохраняем авторов
$inBlog->updateBlogAuthors($blog['id'], $authors);
//сохраняем настройки блога
$blog['seolink_new'] = $inBlog->updateBlog($blog['id'], array('title' => $title, 'allow_who' => $allow_who, 'showcats' => $showcats, 'ownertype' => $ownertype, 'premod' => $premod, 'forall' => $forall), $model->config['update_seo_link_blog']);
$blog['seolink'] = $blog['seolink_new'] ? $blog['seolink_new'] : $blog['seolink'];
if (stripslashes($title) != $blog['title']) {
//.........这里部分代码省略.........
示例14: cms_model_clubs
cmsCore::halt();
}
cmsCore::loadModel('clubs');
$model = new cms_model_clubs();
$title = cmsCore::request('title', 'str', '');
if (!$title) {
cmsCore::jsonOutput(array('error' => true, 'text' => $_LANG['ALBUM_REQ_TITLE']));
}
// Получаем альбом
$album = $inDB->getNsCategory('cms_photo_albums', cmsCore::request('album_id', 'int', 0), null);
if (!$album) {
cmsCore::halt();
}
// получаем клуб
$club = $model->getClub($album['user_id']);
if (!$club) {
cmsCore::halt();
}
if (!$club['enabled_photos']) {
cmsCore::halt();
}
// Инициализируем участников клуба
$model->initClubMembers($club['id']);
// права доступа
$is_admin = $inUser->is_admin || $inUser->id == $club['admin_id'];
$is_moder = $model->checkUserRightsInClub('moderator');
if ($is_admin || $is_moder) {
$inDB->update('cms_photo_albums', array('title' => $title), $album['id']);
cmsCore::jsonOutput(array('error' => false, 'text' => htmlspecialchars(stripslashes($title))));
}
cmsCore::halt();
示例15: photos
//.........这里部分代码省略.........
}
if (!$inUser->id) {
cmsCore::halt();
}
// получаем фото
$photo = cmsCore::callEvent('GET_PHOTO', $inPhoto->getPhoto($id));
if (!$photo) {
cmsCore::halt();
}
if (mb_strstr($photo['NSDiffer'], 'club')) {
cmsCore::halt();
}
$is_author = $photo['user_id'] == $inUser->id && $inUser->id;
if (!$inUser->is_admin && !$is_author) {
cmsCore::halt();
}
if (cmsCore::inRequest('edit_photo')) {
$mod['title'] = cmsCore::request('title', 'str', '');
$mod['title'] = $mod['title'] ? $mod['title'] : $photo['title'];
$mod['description'] = cmsCore::request('description', 'str', '');
$mod['tags'] = cmsCore::request('tags', 'str', '');
$mod['comments'] = $inUser->is_admin ? cmsCore::request('comments', 'int') : $photo['comments'];
if ($model->config['seo_user_access'] || $inUser->is_admin) {
$mod['pagetitle'] = cmsCore::request('pagetitle', 'str', '');
$mod['meta_keys'] = cmsCore::request('meta_keys', 'str', '');
$mod['meta_desc'] = cmsCore::request('meta_desc', 'str', '');
}
$file = $model->initUploadClass($inDB->getNsCategory('cms_photo_albums', $photo['album_id']))->uploadPhoto($photo['file']);
$mod['file'] = $file['filename'] ? $file['filename'] : $photo['file'];
$inPhoto->updatePhoto($mod, $photo['id']);
$description = '<a href="/photos/photo' . $photo['id'] . '.html" class="act_photo"><img src="/images/photos/small/' . $mod['file'] . '" alt="' . htmlspecialchars(stripslashes($mod['title'])) . '" /></a>';
cmsActions::updateLog('add_photo', array('object' => $mod['title'], 'description' => $description), $photo['id']);
cmsCore::addSessionMessage($_LANG['PHOTO_SAVED'], 'success');
cmsCore::jsonOutput(array('error' => false, 'redirect' => '/photos/photo' . $photo['id'] . '.html'));
} else {
$photo['tags'] = cmsTagLine('photo', $photo['id'], false);
cmsPage::initTemplate('components', 'com_photos_edit')->assign('photo', $photo)->assign('form_action', '/photos/editphoto' . $photo['id'] . '.html')->assign('no_tags', false)->assign('is_admin', $inUser->is_admin)->assign('cfg', $model->config)->display('com_photos_edit.tpl');
cmsCore::jsonOutput(array('error' => false, 'html' => ob_get_clean()));
}
}
/////////////////////////////// PHOTO MOVE /////////////////////////////////////////////////////////////////////////////////////////
if ($do == 'movephoto') {
if ($_SERVER['HTTP_X_REQUESTED_WITH'] != 'XMLHttpRequest') {
cmsCore::halt();
}
if (!$inUser->id) {
cmsCore::halt();
}
$photo = cmsCore::callEvent('GET_PHOTO', $inPhoto->getPhoto($id));
if (!$photo) {
cmsCore::halt();
}
if (mb_strstr($photo['NSDiffer'], 'club')) {
cmsCore::halt();
}
if (!$inUser->is_admin) {
cmsCore::halt();
}
if (!cmsCore::inRequest('move_photo')) {
cmsPage::initTemplate('components', 'com_photos_move')->assign('form_action', '/photos/movephoto' . $photo['id'] . '.html')->assign('html', $inPhoto->getAlbumsOption('', $photo['album_id']))->display('com_photos_move.tpl');
cmsCore::jsonOutput(array('error' => false, 'html' => ob_get_clean()));
} else {
$album = cmsCore::callEvent('GET_PHOTO_ALBUM', $inDB->getNsCategory('cms_photo_albums', cmsCore::request('album_id', 'int')));
if (!$album) {
cmsCore::halt();
}