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 (!$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)); }
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 getWidget($title, $target, $permissions = array()) { $user = cmsUser::getInstance(); extract($target); $page = $this->request->get('page', 1); $show_id = $this->request->get('wid'); $go_reply = $this->request->get('reply', 0); $show_reply_id = 0; if ($show_id) { $entry = $this->model->getEntry($show_id); if ($entry) { if ($entry['parent_id'] > 0) { $show_id = $entry['parent_id']; $show_reply_id = $entry['id']; } $page = $this->model->getEntryPageNumber($show_id, $target, self::$perpage); } } $total = $this->model->getEntriesCount($profile_type, $profile_id); $entries = $this->model->getEntries($profile_type, $profile_id, $page); $entries = cmsEventsManager::hook('wall_before_list', $entries); $csrf_token_seed = implode('/', array($profile_type, $profile_id)); $template = cmsTemplate::getInstance(); return $template->renderInternal($this, 'list', array('title' => $title, 'user' => $user, 'controller' => $controller, 'profile_type' => $profile_type, 'profile_id' => $profile_id, 'user' => $user, 'entries' => $entries, 'permissions' => $permissions, 'page' => $page, 'perpage' => wall::$perpage, 'total' => $total, 'max_entries' => $show_id ? 0 : 5, 'csrf_token_seed' => $csrf_token_seed, 'show_id' => $show_id, 'show_reply_id' => $show_reply_id, 'go_reply' => $go_reply)); }
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() { 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); }
private function parseHide($text, $hidden = false) { $inUser = cmsUser::getInstance(); global $_LANG; $pattern = '/\\[hide(?:=?)([0-9]*)\\](.*?)\\[\\/hide\\]/sui'; preg_match($pattern, $text, $matches); if (!$matches) { return $text; } if ($hidden) { $replacement = '<noindex>' . $_LANG['P_HIDE_TEXT_MOD'] . '</noindex>'; } else { if (!$inUser->id) { $replacement = '<noindex><div class="bb_tag_hide">' . $_LANG['P_HIDE_TEXT'] . '</div></noindex>'; } else { if (!$matches[1]) { $replacement = '<div class="bb_tag_hide">${2}</div>'; } elseif ($inUser->rating > $matches[1] || $inUser->is_admin) { $replacement = '<div class="bb_tag_hide">${2}</div>'; } else { $replacement = '<div class="bb_tag_hide">' . sprintf($_LANG['P_HIDE_TEXT_RATING'], cmsCore::spellCount($matches[1], $_LANG['P_ITEM1'], $_LANG['P_ITEM2'], $_LANG['P_ITEM10'])) . '</div>'; } } } return preg_replace($pattern, $replacement, $text); }
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 mod_calendar_eventview($module_id) { $inCore = cmsCore::getInstance(); $inUser = cmsUser::getInstance(); $DB = cmsDatabase::getInstance(); $cfg = $inCore->loadComponentConfig('calendar'); if ($inUser->id != 0 and $cfg['calendar_module'] == "user") { //Запрос к БД $sql = "\r\n\tSELECT cms_events.* ,\r\n\tcms_events_category.tx,\r\n\tcms_events_category.bg\r\n\tFROM cms_events \r\n\tLEFT JOIN cms_events_signup ON cms_events.id=cms_events_signup.event_id \r\n\tLEFT JOIN cms_events_category ON cms_events.category_id = cms_events_category.id\r\n\tWHERE \r\n\tcms_events.start_time > " . time() . " AND \r\n\tcms_events.author_id = " . $inUser->id . " OR \r\n\tcms_events_signup.user_id = " . $inUser->id . " AND \r\n\tcms_events.author_id <> " . $inUser->id . " AND \r\n\tcms_events.start_time > " . time() . " \r\n\tGROUP BY cms_events.id ORDER BY cms_events.start_time ASC LIMIT " . $cfg['calendar_module_count']; } else { $sql = "SELECT cms_events.*,\r\n\t cms_events_category.tx,\r\n\t cms_events_category.bg\r\n\t FROM cms_events\r\n\t LEFT JOIN cms_events_category ON cms_events.category_id = cms_events_category.id\t \r\n\t WHERE cms_events.`type` = 'public' \r\n\t AND cms_events.start_time > " . time() . " \r\n\t ORDER BY cms_events.start_time ASC LIMIT " . $cfg['calendar_module_count']; } $result = $DB->query($sql); if ($DB->error()) { return false; } $events = array(); while ($event = $DB->fetch_assoc($result)) { if ($event['author_id'] == $inUser->id) { $event['time'] == ""; } if ($event['category_id'] == 0) { $event['bg'] = '#C3BCB9'; $event['tx'] = '#000000'; } $events[] = $event; } $smarty = $inCore->initSmarty('modules', 'mod_calendar_eventview.tpl'); $smarty->assign('events', $events); $smarty->display('mod_calendar_eventview.tpl'); return true; }
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'))); }
function mod_actions(array $mod, $cfg) { $inDB = cmsDatabase::getInstance(); $inActions = cmsActions::getInstance(); global $_LANG; if (!isset($cfg['show_target'])) { $cfg['show_target'] = 1; } if (!isset($cfg['limit'])) { $cfg['limit'] = 15; } if (!isset($cfg['show_link'])) { $cfg['show_link'] = 1; } if (!isset($cfg['action_types'])) { echo $_LANG['MODULE_NOT_CONFIGURED']; return true; } if (!$cfg['show_target']) { $inActions->showTargets(false); } $inActions->onlySelectedTypes($cfg['action_types']); $inDB->limitIs($cfg['limit']); $actions = $inActions->getActionsLog(); if (!$actions) { return false; } cmsPage::initTemplate('modules', $cfg['tpl'])->assign('actions', $actions)->assign('cfg', $cfg)->assign('user_id', cmsUser::getInstance()->id)->display($cfg['tpl']); return true; }
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 store($value, $is_submitted, $old_value = null) { $config = cmsConfig::getInstance(); $files_model = cmsCore::getModel('files'); if ($value) { $file = cmsModel::yamlToArray($old_value); $path = $config->upload_path . $file['path']; @unlink($path); $files_model->deleteFile($file['id']); $old_value = null; } $uploader = new cmsUploader(); if (!$uploader->isUploaded($this->name)) { return $old_value; } $allowed_extensions = $this->getOption('extensions'); $max_size_mb = $this->getOption('max_size_mb'); if (!trim($allowed_extensions)) { $allowed_extensions = false; } if (!$max_size_mb) { $max_size_mb = 0; } $result = $uploader->upload($this->name, $allowed_extensions, $max_size_mb * 1048576); if (!$result['success']) { if (!empty($result['path'])) { $uploader->remove($result['path']); } cmsUser::addSessionMessage($result['error'], 'error'); return null; } $file = $files_model->registerFile($result['url'], $result['name']); return array('id' => $file['id'], 'url_key' => $file['url_key'], 'name' => $result['name'], 'size' => $result['size'], 'path' => $result['url']); }
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 actionOptions() { if (empty($this->useDefaultOptionsAction)) { cmsCore::error404(); } $form = $this->getForm('options'); if (!$form) { cmsCore::error404(); } $is_submitted = $this->request->has('submit'); $options = cmsController::loadOptions($this->name); if ($is_submitted) { $options = $form->parse($this->request, $is_submitted); $errors = $form->validate($this, $options); if (!$errors) { cmsUser::addSessionMessage(LANG_CP_SAVE_SUCCESS, 'success'); cmsController::saveOptions($this->name, $options); $this->redirectToAction('options'); } if ($errors) { cmsUser::addSessionMessage(LANG_FORM_ERRORS, 'error'); } } return cmsTemplate::getInstance()->render('backend/options', array('options' => $options, 'form' => $form, 'errors' => isset($errors) ? $errors : false)); }
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); } }
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($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 displayEditor($field_id, $content = '') { $lang = cmsConfig::get('language'); $user = cmsUser::getInstance(); cmsTemplate::getInstance()->addJS('wysiwyg/tinymce/tinymce.min.js'); $dom_id = str_replace(array('[', ']'), array('_', ''), $field_id); echo html_textarea($field_id, $content, array('id' => $dom_id)); ?> <script type="text/javascript" > $(document).ready(function(){ tinymce.init({mode : "exact", elements : "<?php echo $field_id; ?> ", language : "ru", plugins: [ "link image lists media responsivefilemanager " ], relative_urls: false, filemanager_title:"Responsive Filemanager", external_filemanager_path:"/filemanager/", external_plugins: { "filemanager" : "/filemanager/plugin.min.js"}, image_advtab: true, toolbar1: "undo redo | bold italic underline | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | styleselect", toolbar2: "| responsivefilemanager | image | media | link unlink anchor | " }); }); </script> <?php }
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)); }
private function sendInvites($profile, $emails_list) { $user = cmsUser::getInstance(); $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($user->id); $to = array('email' => $email, 'name' => $email); $letter = array('name' => 'users_invite'); $messenger->sendEmail($to, $letter, array('nickname' => $user->nickname, 'code' => $invite['code'], 'page_url' => href_to_abs('auth', 'register') . "?inv={$invite['code']}")); $results['success'][$email] = true; $auth_model->markInviteSended($invite['id'], $user->id, $email); if (sizeof($results['success']) + sizeof($results['failed']) >= $profile['invites_count']) { break; } } return $results; }
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() { $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($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)); }
function mod_user_friend($mod, $cfg) { $inDB = cmsDatabase::getInstance(); $inUser = cmsUser::getInstance(); if (!$inUser->id) { return false; } if ($cfg['view_type'] == 'table') { $sql = "SELECT\r\n CASE\r\n WHEN f.from_id = {$inUser->id}\r\n THEN f.to_id\r\n WHEN f.to_id = {$inUser->id}\r\n THEN f.from_id\r\n END AS user_id, u.login, u.nickname, u.is_deleted, p.imageurl\r\n FROM cms_user_friends f\r\n INNER JOIN cms_online o ON o.user_id = CASE WHEN f.from_id = {$inUser->id} THEN f.to_id WHEN f.to_id = {$inUser->id} THEN f.from_id END\r\n LEFT JOIN cms_users u ON u.id = o.user_id\r\n LEFT JOIN cms_user_profiles p ON p.user_id = u.id\r\n WHERE (from_id = {$inUser->id} OR to_id = {$inUser->id}) AND is_accepted =1 LIMIT " . $cfg['limit']; } else { $sql = "SELECT\r\n CASE\r\n WHEN f.from_id = {$inUser->id}\r\n THEN f.to_id\r\n WHEN f.to_id = {$inUser->id}\r\n THEN f.from_id\r\n END AS user_id, u.login, u.nickname\r\n FROM cms_user_friends f\r\n INNER JOIN cms_online o ON o.user_id = CASE WHEN f.from_id = {$inUser->id} THEN f.to_id WHEN f.to_id = {$inUser->id} THEN f.from_id END\r\n LEFT JOIN cms_users u ON u.id = o.user_id\r\n WHERE (from_id = {$inUser->id} OR to_id = {$inUser->id}) AND is_accepted =1 LIMIT " . $cfg['limit']; } $result = $inDB->query($sql); $total = $inDB->num_rows($result); if ($total) { $friends = array(); while ($friend = $inDB->fetch_assoc($result)) { $friend['avatar'] = $cfg['view_type'] == 'table' ? cmsUser::getUserAvatarUrl($friend['user_id'], 'small', $friend['imageurl'], $friend['is_deleted']) : false; $friend['user_link'] = cmsUser::getProfileLink($friend['login'], $friend['nickname']); $friends[$friend['user_id']] = $friend; } } cmsPage::initTemplate('modules', $cfg['tpl'])->assign('friends', $friends)->assign('total', $total)->assign('cfg', $cfg)->display($cfg['tpl']); return true; }
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)); }
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()); } }
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($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)); }