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)); }
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)); }
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)); }
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)); }
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)); }
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)); }
public function run($profile) { // проверяем наличие доступа if ($profile['id'] != $this->cms_user->id) { cmsCore::error404(); } // Форма отправлена? $is_submitted = $this->request->has('submit'); if (!$is_submitted && !$profile['invites_count']) { cmsCore::error404(); } $form = new cmsForm(); $fieldset_id = $form->addFieldset(); if ($profile['invites_count'] > 1) { $form->addField($fieldset_id, new fieldText('emails', array('title' => LANG_USERS_INVITES_EMAILS, 'hint' => LANG_USERS_INVITES_EMAILS_HINT, 'rules' => array(array('required'))))); } if ($profile['invites_count'] == 1) { $form->addField($fieldset_id, new fieldString('emails', array('title' => LANG_USERS_INVITES_EMAIL, 'rules' => array(array('required'), array('email'))))); } $input = array(); if ($is_submitted) { // Парсим форму и получаем поля записи $input = $form->parse($this->request, $is_submitted); // Проверям правильность заполнения $errors = $form->validate($this, $input); if (!$errors) { $results = $this->sendInvites($profile, $input['emails']); return $this->cms_template->render('profile_invites_results', array('id' => $profile['id'], 'profile' => $profile, 'results' => $results)); } if ($errors) { cmsUser::addSessionMessage(LANG_FORM_ERRORS, 'error'); } } return $this->cms_template->render('profile_invites', array('id' => $profile['id'], 'profile' => $profile, 'form' => $form, 'input' => $input, 'errors' => isset($errors) ? $errors : false)); }
public function run($ctype_name) { $values = $this->request->get('value'); if (!$values || !$ctype_name) { cmsCore::error404(); } $content_model = cmsCore::getModel('content'); $ctype = $content_model->getContentTypeByName($ctype_name); if (!$ctype) { cmsCore::error404(); } $rules = cmsPermissions::getRulesList('content'); list($ctype, $rules, $values) = cmsEventsManager::hook('content_perms', array($ctype, $rules, $values)); list($ctype, $rules, $values) = cmsEventsManager::hook("content_{$ctype['name']}_perms", array($ctype, $rules, $values)); $users_model = cmsCore::getModel('users'); $groups = $users_model->getGroups(false); // перебираем правила foreach ($rules as $rule) { // если для этого правила вообще ничего нет, // то присваиваем null if (empty($values[$rule['id']])) { $values[$rule['id']] = null; continue; } // перебираем группы, заменяем на нуллы // значения отсутствующих правил foreach ($groups as $group) { if (empty($values[$rule['id']][$group['id']])) { $values[$rule['id']][$group['id']] = null; } } } cmsPermissions::savePermissions($ctype_name, $values); $this->redirectBack(); }
function f_pages(&$text) { if (mb_strpos($text, 'pagebreak') === false) { return true; } $seolink = urldecode(cmsCore::request('seolink', 'str', '')); $seolink = preg_replace('/[^a-zа-я-яёіїєґА-ЯЁІЇЄҐ0-9_\\/\\-]/ui', '', $seolink); if (!$seolink) { return true; } $regex = '/{(pagebreak)\\s*(.*?)}/iu'; $pages = preg_split($regex, $text); $n = count($pages); if ($n <= 1) { return true; } else { $page = cmsCore::request('page', 'int', 1); $text = $pages[$page - 1]; if (!$text) { cmsCore::error404(); } cmsCore::loadModel('content'); $text .= cmsPage::getPagebar($n, $page, 1, cms_model_content::getArticleURL(null, $seolink, '%page%')); return true; } }
public function run($template_name) { $template = new cmsTemplate($template_name); if (!$template->hasOptions()) { cmsCore::error404(); } $form = $template->getOptionsForm(); $options = $template->getOptions(); if ($this->request->has('submit')) { // Парсим форму и получаем поля записи $options = $form->parse($this->request, true, $options); // Проверям правильность заполнения $errors = $form->validate($this, $options); if (!$errors) { if ($template->saveOptions($options)) { cmsUser::addSessionMessage(LANG_CP_SAVE_SUCCESS, 'success'); } else { cmsUser::addSessionMessage(LANG_CP_SETTINGS_TPL_NOT_WRITABLE, 'error'); } $this->redirectToAction('settings'); } if ($errors) { cmsUser::addSessionMessage(LANG_FORM_ERRORS, 'error'); } } return $this->cms_template->render('settings_theme', array('template_name' => $template_name, 'options' => $options, 'form' => $form, 'errors' => isset($errors) ? $errors : false)); }
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); }
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); }
public function run($pass_token) { if (!$pass_token) { cmsCore::error404(); } $users_model = cmsCore::getModel('users'); $profile = $users_model->getUserByPassToken($pass_token); if (!$profile) { cmsCore::error404(); } $form = $this->getForm('reset'); $is_submitted = $this->request->has('submit'); if ($is_submitted) { $profile = array_merge($profile, $form->parse($this->request, $is_submitted)); $errors = $form->validate($this, $profile); if (!$errors) { $result = $users_model->updateUser($profile['id'], $profile); if ($result['success']) { cmsUser::addSessionMessage(LANG_PASS_CHANGED, 'success'); $users_model->clearUserPassToken($profile['id']); $this->redirectTo('users', $profile['id']); } else { $errors = $result['errors']; } } if ($errors) { cmsUser::addSessionMessage(LANG_FORM_ERRORS, 'error'); } } return cmsTemplate::getInstance()->render('reset', array('profile' => $profile, 'form' => $form, 'errors' => isset($errors) ? $errors : false)); }
public function run($ctype_name = false) { $query = $this->request->get('q', false); $type = $this->request->get('type', 'words'); $date = $this->request->get('date', 'all'); $page = $this->request->get('page', 1); if (!in_array($type, array('words', 'exact'), true)) { cmsCore::error404(); } if (!in_array($date, array('all', 'w', 'm', 'y'), true)) { cmsCore::error404(); } if (!is_numeric($page)) { cmsCore::error404(); } if ($this->request->has('q')) { if (!$query) { $this->redirectToAction(''); } $results = $this->search($query, $type, $date, $ctype_name, $page); if ($results && !$ctype_name) { $ctype_name = $results[0]['name']; $page_url = href_to($this->name); } else { $page_url = href_to($this->name, 'index', $ctype_name); } } return cmsTemplate::getInstance()->render('index', array('query' => $query, 'type' => $type, 'date' => $date, 'ctype_name' => $ctype_name, 'page' => $page, 'perpage' => $this->options['perpage'], 'results' => isset($results) ? $results : false, 'page_url' => isset($page_url) ? $page_url : false)); }
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(); }
public function run() { $user = cmsUser::getInstance(); $id = $this->request->get('id', 0); if (!$id) { cmsCore::error404(); } $folder = $this->model->getContentFolder($id); if (!$folder) { cmsCore::error404(); } if ($folder['user_id'] != $user->id && !$user->is_admin) { cmsCore::error404(); } $ctype = $this->model->getContentType($folder['ctype_id']); $form = $this->getForm('folder'); // Форма отправлена? $is_submitted = $this->request->has('submit'); if ($is_submitted) { // Парсим форму и получаем поля записи $updated_folder = $form->parse($this->request, $is_submitted); // Проверям правильность заполнения $errors = $form->validate($this, $updated_folder); if (!$errors) { // Обновляем папку и редиректим на ее просмотр $this->model->updateContentFolder($id, $updated_folder); $this->redirect(href_to('users', $folder['user_id'], array('content', $ctype['name'], $folder['id']))); } if ($errors) { cmsUser::addSessionMessage(LANG_FORM_ERRORS, 'error'); } } return cmsTemplate::getInstance()->render('folder_form', array('ctype' => $ctype, 'folder' => $folder, 'form' => $form, 'errors' => isset($errors) ? $errors : false)); }
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)); } }
public function run() { if (!$this->request->isAjax()) { cmsCore::error404(); } $ctype_name = $this->request->get('ctype_name', ''); $category_id = $this->request->get('category_id', 0); $item_id = $this->request->get('item_id', 0); if (!$ctype_name || !$category_id) { cmsCore::error404(); } $ctype = $this->model->getContentTypeByName($ctype_name); if (!$ctype) { cmsCore::error404(); } $template = cmsTemplate::getInstance(); $props = $this->model->getContentProps($ctype['name'], $category_id); if (!$props) { $template->renderJSON(array('success' => false, 'html' => '')); } $values = $item_id ? $this->model->getPropsValues($ctype['name'], $item_id) : array(); $fields = $this->getPropsFields($props); $props_html = $template->render('item_props_fields', array('props' => $props, 'fields' => $fields, 'values' => $values), new cmsRequest(array(), cmsRequest::CTX_INTERNAL)); $template->renderJSON(array('success' => true, 'html' => $props_html)); }
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)); }
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'))); }
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); }
public function run() { if (!$this->request->isAjax()) { cmsCore::error404(); } $orfo = $this->request->get('orfo'); $url = $this->request->get('url'); $comment = $this->request->get('comment', false); $author = !cmsUser::isLogged() ? cmsUser::getIp() : cmsUser::get('nickname'); $form = $this->getForm('orfo'); $is_submitted = $this->request->has('submit'); if ($is_submitted) { $data = $form->parse($this->request, $is_submitted); $data['date'] = date('Y-m-d H:i:s'); $errors = $form->validate($this, $data); dump($errors); if (!$errors) { $this->model->addComplaints($data); $messenger = cmsCore::getController('messages'); $messenger->addRecipient(1); $notice = array('content' => sprintf(LANG_COMPLAINTS_ADD_NOTICE, $url, $orfo), 'options' => array('is_closeable' => true)); $messenger->ignoreNotifyOptions()->sendNoticePM($notice, 'complaints_add'); } cmsTemplate::getInstance()->renderJSON(array('errors' => false, 'callback' => 'formSuccess')); } $data = array('orfo' => $orfo, 'url' => $url, 'author' => $author, 'comment' => $comment); return cmsTemplate::getInstance()->render('orfo', array('form' => $form, 'data' => $data)); }
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($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)); }
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)); }
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)); }
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)); }
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'])); }
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(); }
public function run($tab = 'all') { $user = cmsUser::getInstance(); $dataset_name = false; $datasets = $this->getDatasets(); if ($tab && isset($datasets[$tab])) { $dataset_name = $tab; $dataset = $datasets[$tab]; if (isset($dataset['filter']) && is_callable($dataset['filter'])) { $this->model = $dataset['filter']($this->model, $dataset); } } else { if ($tab) { cmsCore::error404(); } } // Сортировка if ($dataset_name) { $this->model->orderBy($datasets[$dataset_name]['order'][0], $datasets[$dataset_name]['order'][1]); } // Формируем базовые URL для страниц $page_url = array('base' => href_to($this->name, $dataset_name ? 'index/' . $dataset_name : ''), 'first' => href_to($this->name, $dataset_name ? 'index/' . $dataset_name : '')); // Получаем HTML списка записей $profiles_list_html = $this->renderProfilesList($page_url, $dataset_name); return cmsTemplate::getInstance()->render('index', array('datasets' => $datasets, 'dataset_name' => $dataset_name, 'dataset' => $dataset, 'user' => $user, 'profiles_list_html' => $profiles_list_html), $this->request); }