Beispiel #1
0
function search_faq($query, $look) {
    global $_LANG;

    $sql = "SELECT con.*, cat.title cat_title, cat.id cat_id
                    FROM cms_faq_quests con
                    INNER JOIN cms_faq_cats cat ON cat.id = con.category_id AND cat.published = 1
                    WHERE MATCH(con.quest, con.answer) AGAINST ('". $query ."' IN BOOLEAN MODE) AND con.published = 1 LIMIT 100";

    $result = cmsCore::c('db')->query($sql);

    if (cmsCore::c('db')->num_rows($result)) {
        cmsCore::loadLanguage('components/faq');

        while($item = cmsCore::c('db')->fetch_assoc($result)) {
            $result_array = array(
                'link' => '/faq/quest'. $item['id'] .'.html',
                'place' => $_LANG['FAQ'] .' → '. $item['cat_title'],
                'placelink' => '/faq/'. $item['cat_id'],
                'description' => cmsCore::m('search')->getProposalWithSearchWord($item['answer']),
                'title' => mb_substr($item['quest'], 0, 70) .'...',
                'pubdate' => $item['pubdate']
            );
            
            cmsCore::m('search')->addResult($result_array);			
        }
    }

    return;
}
Beispiel #2
0
 public function run()
 {
     if (!$this->request->isAjax()) {
         cmsCore::error404();
     }
     if (!$this->cms_user->is_logged) {
         return $this->cms_template->renderJSON(array('error' => true));
     }
     if (cmsUser::isPermittedLimitHigher('comments', 'karma', $this->cms_user->karma)) {
         return $this->cms_template->renderJSON(array('error' => true));
     }
     $target_controller = $this->request->get('tc', '');
     $target_subject = $this->request->get('ts', '');
     $target_id = $this->request->get('ti', 0);
     $is_track = $this->request->get('is_track', 0);
     if (!$target_controller || !$target_subject || !$target_id) {
         return $this->cms_template->renderJSON(array('error' => true));
     }
     $is_valid = $this->validate_sysname($target_controller) === true && $this->validate_sysname($target_subject) === true && is_numeric($target_id) && is_numeric($is_track);
     if (!$is_valid) {
         return $this->cms_template->renderJSON(array('error' => true));
     }
     $success = $this->model->filterEqual('target_controller', $target_controller)->filterEqual('target_subject', $target_subject)->filterEqual('target_id', $target_id)->toggleTracking($is_track, $this->cms_user->id, $target_controller, $target_subject, $target_id);
     return $this->cms_template->renderJSON(array('error' => !$success));
 }
Beispiel #3
0
 public function run($id)
 {
     if (!$id) {
         cmsCore::error404();
     }
     $form = $this->getForm('preset', array('edit'));
     $is_submitted = $this->request->has('submit');
     $preset = $original_preset = $this->model->getPreset($id);
     if ($preset['is_internal']) {
         $form->removeFieldset('basic');
     }
     if ($is_submitted) {
         $preset = $form->parse($this->request, $is_submitted);
         $errors = $form->validate($this, $preset);
         if (!$errors) {
             $this->model->updatePreset($id, $preset);
             $this->createDefaultImages(array_merge($original_preset, $preset));
             $this->redirectToAction('presets');
         }
         if ($errors) {
             cmsUser::addSessionMessage(LANG_FORM_ERRORS, 'error');
         }
     }
     return cmsTemplate::getInstance()->render('backend/preset', array('do' => 'edit', 'preset' => $preset, 'form' => $form, 'errors' => isset($errors) ? $errors : false));
 }
Beispiel #4
0
 public function run()
 {
     if (!$this->options['is_reg_invites']) {
         return false;
     }
     if (!$this->options['is_invites']) {
         return false;
     }
     $period = $this->options['invites_period'];
     $qty = $this->options['invites_qty'];
     $min_karma = $this->options['invites_min_karma'];
     $min_rating = $this->options['invites_min_rating'];
     $min_days = $this->options['invites_min_days'];
     $users_model = cmsCore::getModel('users');
     $users_model->filterIsNull('is_locked');
     $users_model->filterStart()->filterDateOlder('date_invites', $period)->filterOr()->filterIsNull('date_invites')->filterEnd();
     $users_model->filterGtEqual('karma', $min_karma);
     $users_model->filterGtEqual('rating', $min_rating);
     $users_model->filterDateOlder('date_reg', $min_days);
     $users = $users_model->getUsers();
     if (!$users) {
         return false;
     }
     foreach ($users as $user) {
         $this->model->addInvites($user['id'], $qty);
     }
 }
Beispiel #5
0
function f_banners(&$text)
{
    $phrase = 'БАННЕР';
    if (mb_strpos($text, $phrase) === false) {
        return true;
    }
    if (!cmsCore::getInstance()->isComponentEnable('banners')) {
        return true;
    }
    $regex = '/{(' . $phrase . '=)\\s*(.*?)}/i';
    $matches = array();
    preg_match_all($regex, $text, $matches, PREG_SET_ORDER);
    if (!$matches) {
        return true;
    }
    cmsCore::loadModel('banners');
    foreach ($matches as $elm) {
        $elm[0] = str_replace('{', '', $elm[0]);
        $elm[0] = str_replace('}', '', $elm[0]);
        mb_parse_str($elm[0], $args);
        $position = @$args[$phrase];
        if ($position) {
            $output = cms_model_banners::getBannerHTML($position);
        } else {
            $output = '';
        }
        $text = str_replace('{' . $phrase . '=' . $position . '}', $output, $text);
    }
    return true;
}
Beispiel #6
0
 public function run($profile)
 {
     $user = cmsUser::getInstance();
     // проверяем наличие доступа
     if ($profile['id'] != $user->id && !$user->is_admin) {
         cmsCore::error404();
     }
     $template = cmsTemplate::getInstance();
     if (!$template->hasProfileThemesOptions()) {
         cmsCore::error404();
     }
     $form = $template->getProfileOptionsForm();
     // Форма отправлена?
     $is_submitted = $this->request->has('submit');
     $theme = $profile['theme'];
     if ($is_submitted) {
         // Парсим форму и получаем поля записи
         $theme = array_merge($theme, $form->parse($this->request, $is_submitted, $theme));
         // Проверям правильность заполнения
         $errors = $form->validate($this, $theme);
         if (!$errors) {
             // Обновляем профиль и редиректим на его просмотр
             $this->model->updateUserTheme($profile['id'], $theme);
             $this->redirectTo('users', $profile['id']);
         }
         if ($errors) {
             cmsUser::addSessionMessage(LANG_FORM_ERRORS, 'error');
         }
     }
     return $template->render('profile_edit_theme', array('id' => $profile['id'], 'profile' => $profile, 'form' => $form, 'errors' => isset($errors) ? $errors : false));
 }
Beispiel #7
0
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']));
    }
}
 public function run()
 {
     $new_values = $this->request->get('value', array());
     $group_id = $this->request->get('group_id', 0);
     if (!$new_values || !$group_id) {
         cmsCore::error404();
     }
     $controllers = cmsPermissions::getControllersWithRules();
     $owners = array();
     foreach ($controllers as $controller_name) {
         $controller = cmsCore::getController($controller_name);
         $subjects = $controller->getPermissionsSubjects();
         $rules = cmsPermissions::getRulesList($controller_name);
         $values = array();
         foreach ($subjects as $subject) {
             $values[$subject['name']] = cmsPermissions::getPermissions($subject['name']);
         }
         $owners[$controller_name] = array('subjects' => $subjects, 'rules' => $rules, 'values' => $values);
     }
     foreach ($owners as $controller_name => $controller) {
         foreach ($controller['subjects'] as $subject) {
             $formatted_values = array();
             foreach ($controller['rules'] as $rule) {
                 $value = isset($new_values[$rule['id']][$subject['name']]) ? $new_values[$rule['id']][$subject['name']] : null;
                 $formatted_values[$rule['id']][$group_id] = $value;
             }
             cmsPermissions::savePermissions($subject['name'], $formatted_values);
         }
     }
     cmsUser::addSessionMessage(LANG_CP_PERMISSIONS_SUCCESS, 'success');
     $this->redirectBack();
 }
Beispiel #9
0
function applet_filters()
{
    global $_LANG;
    global $adminAccess;
    if (!cmsUser::isAdminCan('admin/plugins', $adminAccess)) {
        cpAccessDenied();
    }
    if (!cmsUser::isAdminCan('admin/filters', $adminAccess)) {
        cpAccessDenied();
    }
    $GLOBALS['cp_page_title'] = $_LANG['AD_FILTERS'];
    cpAddPathway($_LANG['AD_FILTERS'], 'index.php?view=filters');
    $do = cmsCore::request('do', 'str', 'list');
    $id = cmsCore::request('id', 'int', -1);
    if ($do == 'hide') {
        dbHide('cms_filters', $id);
        echo '1';
        exit;
    }
    if ($do == 'show') {
        dbShow('cms_filters', $id);
        echo '1';
        exit;
    }
    if ($do == 'list') {
        $fields[] = array('title' => 'id', 'field' => 'id', 'width' => '30');
        $fields[] = array('title' => $_LANG['TITLE'], 'field' => 'title', 'width' => '250');
        $fields[] = array('title' => $_LANG['DESCRIPTION'], 'field' => 'description', 'width' => '');
        $fields[] = array('title' => $_LANG['AD_ENABLE'], 'field' => 'published', 'width' => '100');
        $actions = array();
        cpListTable('cms_filters', $fields, $actions);
    }
}
Beispiel #10
0
 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']));
 }
Beispiel #11
0
function applet_filters() {
    global $_LANG;
    
    global $adminAccess;
    
    if (!cmsUser::isAdminCan('admin/plugins', $adminAccess)) { cpAccessDenied(); }
    if (!cmsUser::isAdminCan('admin/filters', $adminAccess)) { cpAccessDenied(); }
    
    cmsCore::c('page')->setTitle($_LANG['AD_FILTERS']);
    cpAddPathway($_LANG['AD_FILTERS'], 'index.php?view=filters');

    $do = cmsCore::request('do', 'str', 'list');
    $id = cmsCore::request('id', 'int', -1);

    if ($do == 'hide') {
        cmsCore::c('db')->setFlag('cms_filters', $id, 'published', '0');
        cmsCore::halt('1');
    }

    if ($do == 'show') {
        cmsCore::c('db')->setFlag('cms_filters', $id, 'published', '1');
        cmsCore::halt('1');
    }

    if ($do == 'list') {
        $fields = array(
            array( 'title' =>  'id', 'field' => 'id', 'width' => '40' ),
            array( 'title' => $_LANG['TITLE'], 'field' => 'title', 'width' => '250' ),
            array( 'title' => $_LANG['DESCRIPTION'], 'field' => 'description', 'width' => '' ),
            array( 'title' => $_LANG['AD_ENABLE'], 'field' => 'published', 'width' => '100' )
        );

        cpListTable('cms_filters', $fields, array());
    }
}
Beispiel #12
0
 public function run($id)
 {
     if (!$id) {
         cmsCore::error404();
     }
     $users_model = cmsCore::getModel('users');
     $group = $users_model->getGroup($id);
     if (!$group) {
         cmsCore::error404();
     }
     $controllers = cmsPermissions::getControllersWithRules();
     $owners = array();
     foreach ($controllers as $controller_name) {
         $controller = cmsCore::getController($controller_name);
         $subjects = $controller->getPermissionsSubjects();
         $rules = cmsPermissions::getRulesList($controller_name);
         $values = array();
         foreach ($subjects as $subject) {
             $values[$subject['name']] = cmsPermissions::getPermissions($subject['name']);
         }
         $owners[$controller_name] = array('subjects' => $subjects, 'rules' => $rules, 'values' => $values);
     }
     $template = cmsTemplate::getInstance();
     $template->setMenuItems('users_group', array(array('title' => LANG_CONFIG, 'url' => href_to($this->name, 'users', array('group_edit', $id))), array('title' => LANG_PERMISSIONS, 'url' => href_to($this->name, 'users', array('group_perms', $id)))));
     return $template->render('users_group_perms', array('group' => $group, 'owners' => $owners));
 }
function mod_pogoda_current($mod, $cfg)
{
    $inCore = cmsCore::getInstance();
    //Загрузка настроек компонента
    $component = $inCore->loadComponentConfig('pogoda');
    $component["name_en"] = $component["name_en"] ? $component["name_en"] . '_' : '';
    // Проверяем включен ли компонент и установлен ли city_id
    if (!$component['component_enabled'] || !$component['city_id']) {
        return false;
    }
    cmsCore::loadModel('pogoda');
    $model = new cms_model_pogoda();
    $model->setTable('current');
    $dbWeather = $model->getWeather();
    $xml = simplexml_load_string($dbWeather["xml"]);
    if (!$xml) {
        return true;
    }
    $current = array();
    $current["temperature"] = round($xml->temperature["value"]) . ' °C';
    $current["weather"]["value"] = $xml->weather["value"];
    $current["weather"]["icon"] = $xml->weather["icon"];
    cmsPage::initTemplate('modules', $cfg['tpl'])->assign('current', $current)->display($cfg['tpl']);
    return true;
}
Beispiel #14
0
 public function run($id = false)
 {
     if (!$id) {
         cmsCore::error404();
     }
     $widgets_model = cmsCore::getModel('widgets');
     cmsCore::loadAllControllersLanguages();
     $page = $widgets_model->getPage($id);
     if (!$page) {
         cmsCore::error404();
     }
     $form = $this->getForm('widgets_page');
     if (!$page['is_custom']) {
         $form->removeField('title', 'title');
     }
     $is_submitted = $this->request->has('submit');
     if ($is_submitted) {
         $page = $form->parse($this->request, $is_submitted);
         $errors = $form->validate($this, $page);
         if (!$errors) {
             $widgets_model->updatePage($id, $page);
             $this->redirectToAction('widgets');
         }
         if ($errors) {
             cmsUser::addSessionMessage(LANG_FORM_ERRORS, 'error');
         }
     }
     return cmsTemplate::getInstance()->render('widgets_page', array('do' => 'edit', 'page' => $page, 'form' => $form, 'errors' => isset($errors) ? $errors : false));
 }
Beispiel #15
0
 public function run()
 {
     if (!$this->request->isAjax()) {
         cmsCore::error404();
     }
     $template = cmsTemplate::getInstance();
     $entry_id = $this->request->get('id');
     // Проверяем валидность
     $is_valid = is_numeric($entry_id);
     if (!$is_valid) {
         $result = array('error' => true, 'message' => LANG_ERROR);
         $template->renderJSON($result);
     }
     $user = cmsUser::getInstance();
     $entry = $this->model->getEntry($entry_id);
     $replies = $this->model->getReplies($entry_id);
     if (!$replies) {
         $result = array('error' => true, 'message' => LANG_ERROR);
         $template->renderJSON($result);
     }
     $permissions = array('add' => $user->is_logged, 'delete' => $user->is_admin || $user->id == $entry['profile_id']);
     $html = $template->renderInternal($this, 'entry', array('entries' => $replies, 'user' => $user, 'permissions' => $permissions));
     // Формируем и возвращаем результат
     $result = array('error' => false, 'html' => $html);
     $template->renderJSON($result);
 }
Beispiel #16
0
 public function run()
 {
     if (!$this->request->isAjax()) {
         cmsCore::error404();
     }
     if (!$this->options['is_show']) {
         cmsCore::error404();
     }
     // Получаем параметры
     $target_controller = $this->request->get('controller');
     $target_subject = $this->request->get('subject');
     $target_id = $this->request->get('id');
     // Флаг что нужно вывести только голый список
     $is_list_only = $this->request->get('is_list_only');
     $page = $this->request->get('page', 1);
     $perpage = 10;
     $template = cmsTemplate::getInstance();
     $this->model->filterVotes($target_controller, $target_subject, $target_id)->orderBy('id', 'desc')->limitPage($page, $perpage);
     $total = $this->model->getVotesCount();
     $votes = $this->model->getVotes();
     $pages = ceil($total / $perpage);
     if ($is_list_only) {
         $template->render('info_list', array('votes' => $votes));
     }
     if (!$is_list_only) {
         $template->render('info', array('target_controller' => $target_controller, 'target_subject' => $target_subject, 'target_id' => $target_id, 'votes' => $votes, 'page' => $page, 'pages' => $pages, 'perpage' => $perpage));
     }
 }
Beispiel #17
0
function mod_actions($mod, $cfg) {
    global $_LANG;
    
    if (!isset($cfg['action_types'])) {
        echo $_LANG['MODULE_NOT_CONFIGURED'];
        return true;
    }
    
    $cfg = array_merge(
        array(
            'show_target' => 1,
            'limit' => 15,
            'show_link' => 1
        ),
        $cfg
    );
    
    if (!$cfg['show_target']) {
        cmsCore::c('actions')->showTargets(false);
    }

    cmsCore::c('actions')->onlySelectedTypes($cfg['action_types']);
    cmsCore::c('db')->limitIs($cfg['limit']);
    
    $actions = cmsCore::c('actions')->getActionsLog();
    if (!$actions) { return false; }

    cmsPage::initTemplate('modules', $cfg['tpl'])->
        assign('actions', $actions)->
        assign('cfg', $cfg)->
        assign('user_id', cmsCore::c('user')->id)->
        display();

    return true;
}
Beispiel #18
0
function mod_latest_faq($module_id, $cfg)
{
    $inDB = cmsDatabase::getInstance();
    if (!isset($cfg['newscount'])) {
        $cfg['newscount'] = 2;
    }
    if (!isset($cfg['cat_id'])) {
        $cfg['cat_id'] = 0;
    }
    if (!isset($cfg['maxlen'])) {
        $cfg['maxlen'] = 120;
    }
    if ($cfg['cat_id']) {
        $catsql = 'AND category_id = ' . $cfg['cat_id'];
    } else {
        $catsql = '';
    }
    $sql = "SELECT *\n            FROM cms_faq_quests\n            WHERE published = 1 " . $catsql . "\n            ORDER BY pubdate DESC\n            LIMIT " . $cfg['newscount'];
    $result = $inDB->query($sql);
    $faq = array();
    if ($inDB->num_rows($result)) {
        while ($con = $inDB->fetch_assoc($result)) {
            $con['date'] = cmsCore::dateFormat($con['pubdate']);
            $con['href'] = '/faq/quest' . $con['id'] . '.html';
            $faq[] = $con;
        }
    }
    cmsPage::initTemplate('modules', 'mod_latest_faq')->assign('faq', $faq)->assign('cfg', $cfg)->display('mod_latest_faq.tpl');
    return true;
}
Beispiel #19
0
 public function __construct()
 {
     cmsCore::loadClass('page');
     $this->inCore = cmsCore::getInstance();
     $this->inDB = cmsDatabase::getInstance();
     $this->inPage = cmsPage::getInstance();
 }
Beispiel #20
0
 public function run($table = null, $item_id = null)
 {
     header('X-Frame-Options: DENY');
     if (!$this->request->isAjax()) {
         cmsCore::error404();
     }
     if (!$item_id || !$table || !is_numeric($item_id) || $this->validate_regexp('/^([a-z0-9\\_{}]*)$/', urldecode($table)) !== true) {
         $this->cms_template->renderJSON(array('error' => LANG_ERROR));
     }
     $data = $this->request->get('data', array());
     if (!$data) {
         $this->cms_template->renderJSON(array('error' => LANG_ERROR));
     }
     $i = $this->model->getItemByField($table, 'id', $item_id);
     if (!$i) {
         $this->cms_template->renderJSON(array('error' => LANG_ERROR));
     }
     foreach ($data as $field => $value) {
         if (!array_key_exists($field, $i)) {
             unset($data[$field]);
         } else {
             $_data[$field] = htmlspecialchars($value);
         }
     }
     if (empty($data)) {
         $this->cms_template->renderJSON(array('error' => LANG_ERROR));
     }
     $this->model->update($table, $item_id, $data);
     $this->cms_template->renderJSON(array('error' => false, 'values' => $_data));
 }
Beispiel #21
0
 public function run($ctype_id)
 {
     if (!$ctype_id) {
         cmsCore::error404();
     }
     $content_model = cmsCore::getModel('content');
     $ctype = $content_model->getContentType($ctype_id);
     if (!$ctype) {
         cmsCore::error404();
     }
     $form = $this->getForm('ctypes_dataset', array('add', $ctype['id']));
     $is_submitted = $this->request->has('submit');
     $fields = $content_model->getContentFields($ctype['name']);
     $dataset = array('sorting' => array(array('by' => 'date_pub', 'to' => 'desc')));
     if ($is_submitted) {
         $dataset = $form->parse($this->request, $is_submitted);
         $dataset['filters'] = $this->request->get('filters');
         $dataset['sorting'] = $this->request->get('sorting');
         $errors = $form->validate($this, $dataset);
         if (!$errors) {
             $dataset_id = $content_model->addContentDataset($dataset, $ctype);
             if ($dataset_id) {
                 cmsUser::addSessionMessage(sprintf(LANG_CP_DATASET_CREATED, $dataset['title']), 'success');
             }
             $this->redirectToAction('ctypes', array('datasets', $ctype['id']));
         }
         if ($errors) {
             cmsUser::addSessionMessage(LANG_FORM_ERRORS, 'error');
         }
     }
     return cmsTemplate::getInstance()->render('ctypes_dataset', array('do' => 'add', 'ctype' => $ctype, 'dataset' => $dataset, 'fields' => $fields, 'form' => $form, 'errors' => isset($errors) ? $errors : false));
 }
Beispiel #22
0
function mod_forum($mod, $cfg)
{
    $inDB = cmsDatabase::getInstance();
    $default_cfg = array('shownum' => 4, 'cat_id' => 0, 'forum_id' => 0, 'subs' => 0, 'show_hidden' => 0, 'show_pinned' => 0, 'showtext' => 1, 'showforum' => 0, 'order' => 'pubdate');
    $cfg = array_merge($default_cfg, $cfg);
    cmsCore::loadModel('forum');
    $model = new cms_model_forum();
    $inDB->addJoin('INNER JOIN cms_forums f ON f.id = t.forum_id');
    $inDB->addSelect('f.title as forum_title');
    if ($cfg['cat_id']) {
        $model->whereForumCatIs($cfg['cat_id']);
    }
    if ($cfg['forum_id']) {
        if ($cfg['subs']) {
            $forum = $model->getForum($cfg['forum_id']);
            if (!$forum) {
                return false;
            }
            $model->whereThisAndNestedForum($forum['NSLeft'], $forum['NSRight']);
        } else {
            $model->whereForumIs($cfg['forum_id']);
        }
    }
    if (!$cfg['show_hidden']) {
        $model->wherePublicThreads();
    }
    if ($cfg['show_pinned']) {
        $model->wherePinnedThreads();
    }
    $inDB->orderBy('t.' . $cfg['order'], 'DESC');
    $inDB->limit($cfg['shownum']);
    $threads = $model->getThreads();
    cmsPage::initTemplate('modules', $cfg['tpl'])->assign('threads', $threads)->assign('cfg', $cfg)->display($cfg['tpl']);
    return true;
}
Beispiel #23
0
 public function run($tag_id)
 {
     if (!$tag_id) {
         cmsCore::error404();
     }
     $tags_model = cmsCore::getModel('tags');
     $form = $this->getForm('tag');
     $is_submitted = $this->request->has('submit');
     $tag = $tags_model->getTag($tag_id);
     $original_tag = $tag['tag'];
     if ($is_submitted) {
         $tag = $form->parse($this->request, $is_submitted);
         $errors = $form->validate($this, $tag);
         if ($original_tag == $tag['tag']) {
             $this->redirectToAction();
         }
         if (!$errors) {
             $duplicate_id = $tags_model->getTagId($tag['tag']);
             if (!$duplicate_id) {
                 $tags_model->updateTag($tag_id, $tag);
             }
             if ($duplicate_id) {
                 $tags_model->mergeTags($tag_id, $duplicate_id);
                 cmsUser::addSessionMessage(sprintf(LANG_TAGS_MERGED, $original_tag, $tag['tag']), 'success');
             }
             $this->redirectToAction();
         }
         if ($errors) {
             cmsUser::addSessionMessage(LANG_FORM_ERRORS, 'error');
         }
     }
     return cmsTemplate::getInstance()->render('backend/tag', array('do' => 'edit', 'tag' => $tag, 'form' => $form, 'errors' => isset($errors) ? $errors : false));
 }
Beispiel #24
0
 public function run($profile)
 {
     // проверяем наличие доступа
     if ($profile['id'] != $this->cms_user->id && !$this->cms_user->is_admin) {
         cmsCore::error404();
     }
     $form = $this->getForm('password');
     $is_submitted = $this->request->has('submit');
     $data = array();
     if ($is_submitted) {
         cmsCore::loadControllerLanguage('auth');
         $data = $form->parse($this->request, $is_submitted);
         $errors = $form->validate($this, $data);
         if (!$errors) {
             $password_hash = md5(md5($data['password']) . $this->cms_user->password_salt);
             if ($password_hash != $this->cms_user->password) {
                 $errors = array('password' => LANG_OLD_PASS_INCORRECT);
             }
         }
         if (!$errors) {
             $profile = array_merge($profile, $data);
             $result = $this->model->updateUser($profile['id'], $profile);
             if ($result['success']) {
                 cmsUser::addSessionMessage(LANG_PASS_CHANGED, 'success');
                 $this->redirectTo('users', $profile['id']);
             } else {
                 $errors = $result['errors'];
             }
         }
         if ($errors) {
             cmsUser::addSessionMessage(LANG_FORM_ERRORS, 'error');
         }
     }
     return $this->cms_template->render('profile_edit_password', array('id' => $profile['id'], 'profile' => $profile, 'data' => $data, 'form' => $form, 'errors' => isset($errors) ? $errors : false));
 }
Beispiel #25
0
function mod_dt_newsslider($module_id, $cfg)
{
    $inDB = cmsDatabase::getInstance();
    cmsCore::loadModel('content');
    $model = new cms_model_content();
    if (!isset($cfg['cat_id'])) {
        $cfg['cat_id'] = 1;
    }
    if ($cfg['cat_id']) {
        if (!$cfg['subs']) {
            $model->whereCatIs($cfg['cat_id']);
        } else {
            $rootcat = $inDB->getNsCategory('cms_category', $cfg['cat_id']);
            if (!$rootcat) {
                return false;
            }
            $model->whereThisAndNestedCats($rootcat['NSLeft'], $rootcat['NSRight']);
        }
    }
    $inDB->orderBy('con.ordering', 'ASC');
    $inDB->limit($cfg['newscount']);
    $slider_list = $model->getArticlesList();
    if (!$slider_list) {
        return false;
    }
    cmsPage::initTemplate('modules', 'mod_dt_newsslider')->assign('slider', $slider_list)->assign('cfg', $cfg)->assign('module_id', $module_id)->display('mod_dt_newsslider.tpl');
    return true;
}
Beispiel #26
0
function mod_category($mod, $cfg)
{
    $inDB = cmsDatabase::getInstance();
    cmsCore::loadModel('content');
    $model = new cms_model_content();
    if (!isset($cfg['category_id'])) {
        $cfg['category_id'] = 0;
    }
    if (!isset($cfg['show_subcats'])) {
        $cfg['show_subcats'] = 1;
    }
    if (!isset($cfg['expand_all'])) {
        $cfg['expand_all'] = 1;
    }
    $rootcat = $inDB->getNsCategory('cms_category', $cfg['category_id']);
    if (!$rootcat) {
        return false;
    }
    $subcats_list = $model->getSubCats($rootcat['id'], $cfg['show_subcats'], $rootcat['NSLeft'], $rootcat['NSRight']);
    if (!$subcats_list) {
        return false;
    }
    $current_seolink = urldecode(cmsCore::request('seolink', 'str', ''));
    cmsPage::initTemplate('modules', $cfg['tpl'])->assign('cfg', $cfg)->assign('current_seolink', $current_seolink)->assign('subcats_list', $subcats_list)->display($cfg['tpl']);
    return true;
}
Beispiel #27
0
 public function run($ctype_name = false)
 {
     $user = cmsUser::getInstance();
     $template = cmsTemplate::getInstance();
     $counts = $this->model->getTasksCounts($user->id);
     $is_moderator = $this->model->isUserModerator($user->id);
     if (!$is_moderator) {
         cmsCore::error404();
     }
     if (!$counts) {
         return $template->render('empty');
     }
     $is_index = false;
     $ctypes_list = array_keys($counts);
     if (!$ctype_name) {
         $ctype_name = $ctypes_list[0];
         $is_index = true;
     }
     $content_controller = cmsCore::getController('content');
     $ctypes = $content_controller->model->filterIn('name', $ctypes_list)->getContentTypesFiltered();
     $ctypes = array_collection_to_list($ctypes, 'name', 'title');
     $ctype = $content_controller->model->getContentTypeByName($ctype_name);
     $content_controller->model->filterByModeratorTask($user->id, $ctype_name);
     $page_url = $is_index ? href_to($this->name) : href_to($this->name, $ctype_name);
     $content_controller->model->disableApprovedFilter();
     $list_html = $content_controller->renderItemsList($ctype, $page_url, true);
     return $template->render('index', array('is_index' => $is_index, 'counts' => $counts, 'ctype' => $ctype, 'ctypes' => $ctypes, 'ctype_name' => $ctype_name, 'list_html' => $list_html, 'user' => $user));
 }
Beispiel #28
0
 private function sendInvites($profile, $emails_list)
 {
     $results = array('success' => array(), 'failed' => array());
     $emails = string_explode_list($emails_list);
     $auth_controller = cmsCore::getController('auth');
     $auth_model = cmsCore::getModel('auth');
     $messenger = cmsCore::getController('messages');
     foreach ($emails as $email) {
         if ($this->validate_email($email) !== true) {
             $results['failed'][$email] = ERR_VALIDATE_EMAIL;
             continue;
         }
         if ($this->model->getUserByEmail($email)) {
             $results['failed'][$email] = LANG_REG_EMAIL_EXISTS;
             continue;
         }
         if (!$auth_controller->isEmailAllowed($email)) {
             $results['failed'][$email] = LANG_AUTH_RESTRICTED_EMAILS;
             continue;
         }
         $invite = $auth_model->getNextInvite($this->cms_user->id);
         $to = array('email' => $email, 'name' => $email);
         $letter = array('name' => 'users_invite');
         $messenger->sendEmail($to, $letter, array('nickname' => $this->cms_user->nickname, 'code' => $invite['code'], 'page_url' => href_to_abs('auth', 'register') . "?inv={$invite['code']}"));
         $results['success'][$email] = true;
         $auth_model->markInviteSended($invite['id'], $this->cms_user->id, $email);
         if (sizeof($results['success']) + sizeof($results['failed']) >= $profile['invites_count']) {
             break;
         }
     }
     return $results;
 }
Beispiel #29
0
 public function run($group_id = false)
 {
     if (!$this->request->isAjax()) {
         cmsCore::error404();
     }
     $grid = $this->loadDataGrid('users');
     $users_model = cmsCore::getModel('users');
     $users_model->setPerPage(admin::perpage);
     $filter = array();
     $filter_str = $this->request->get('filter');
     $filter_str = cmsUser::getUPSActual('admin.grid_filter.users', $filter_str);
     if ($filter_str) {
         $content_model = cmsCore::getModel('content')->setTablePrefix('');
         parse_str($filter_str, $filter);
         $users_model->applyGridFilter($grid, $filter);
         if (!empty($filter['advanced_filter'])) {
             parse_str($filter['advanced_filter'], $dataset_filters);
             $users_model->applyDatasetFilters($dataset_filters);
         }
     }
     if ($group_id) {
         $users_model->filterGroup($group_id);
     }
     $total = $users_model->getUsersCount();
     $perpage = isset($filter['perpage']) ? $filter['perpage'] : admin::perpage;
     $pages = ceil($total / $perpage);
     $users = $users_model->getUsers();
     cmsTemplate::getInstance()->renderGridRowsJSON($grid, $users, $total, $pages);
     $this->halt();
 }
Beispiel #30
0
 public function processUpload($album_id)
 {
     $config = cmsConfig::getInstance();
     $uploader = new cmsUploader();
     $result = $uploader->upload('qqfile');
     if (!$result['success']) {
         cmsTemplate::getInstance()->renderJSON($result);
         $this->halt();
     }
     $preset = array('width' => 600, 'height' => 460, 'is_square' => false, 'is_watermark' => false);
     if (!empty($this->options['preset'])) {
         $preset = cmsCore::getModel('images')->getPresetByName($this->options['preset']);
     }
     $result['paths'] = array('big' => $uploader->resizeImage($result['path'], array('width' => $preset['width'], 'height' => $preset['height'], 'square' => $preset['is_square'])), 'normal' => $uploader->resizeImage($result['path'], array('width' => 160, 'height' => 160, 'square' => true)), 'small' => $uploader->resizeImage($result['path'], array('width' => 64, 'height' => 64, 'square' => true)), 'original' => $result['url']);
     if ($preset['is_watermark'] && !empty($preset['wm_image'])) {
         $images_controller = cmsCore::getController('images');
         $images_controller->addWatermark($result['paths']['big'], $preset['wm_image']['original'], $preset['wm_origin'], $preset['wm_margin']);
     }
     $result['filename'] = basename($result['path']);
     if (empty($this->options['is_origs'])) {
         @unlink($result['path']);
         unset($result['paths']['original']);
     }
     unset($result['path']);
     $result['url'] = $config->upload_host . '/' . $result['paths']['small'];
     $result['id'] = $this->model->addPhoto($album_id, $result['paths']);
     cmsTemplate::getInstance()->renderJSON($result);
     $this->halt();
 }