public function getAuthRedirectUrl($value) { $url = href_to_home(); $user_id = cmsUser::sessionGet('user:id'); if (!$user_id) { return $url; } $back_url = $this->getBackURL(); if (strpos($back_url, href_to('auth', 'login')) !== false) { $back_url = $url; } switch ($value) { case 'none': $url = $back_url; break; case 'index': $url = href_to_home(); break; case 'profile': $url = href_to('users', $user_id); break; case 'profileedit': $url = href_to('users', $user_id, 'edit'); break; } return $url; }
public function run($data) { list($ctype, $album, $fields) = $data; $is_allow = $album['is_public'] || $album['user_id'] == $this->cms_user->id || $this->cms_user->is_admin; if ($is_allow && cmsUser::isAllowed($ctype['name'], 'add')) { $this->cms_template->addToolButton(array('class' => 'images', 'title' => LANG_PHOTOS_UPLOAD, 'href' => href_to($this->name, 'upload', $album['id']))); } $album['filter_panel'] = array('ordering' => modelPhotos::getOrderList(), 'types' => !empty($this->options['types']) ? array('' => LANG_PHOTOS_ALL) + $this->options['types'] : array(), 'orientation' => modelPhotos::getOrientationList(), 'width' => '', 'height' => ''); $album['filter_values'] = array('ordering' => $this->cms_core->request->get('ordering', $this->options['ordering']), 'types' => $this->cms_core->request->get('types', ''), 'orientation' => $this->cms_core->request->get('orientation', ''), 'width' => $this->cms_core->request->get('width', 0) ?: '', 'height' => $this->cms_core->request->get('height', 0) ?: ''); $album['url_params'] = array_filter($album['filter_values']); $album['filter_selected'] = $album['url_params']; if ($album['filter_selected']['ordering'] == $this->options['ordering']) { unset($album['filter_selected']['ordering']); } if (!in_array($album['filter_values']['ordering'], array_keys($album['filter_panel']['ordering']))) { $album['filter_values']['ordering'] = 'date_pub'; } if ($album['filter_values']['types'] && !in_array($album['filter_values']['types'], array_keys($album['filter_panel']['types']))) { $album['filter_values']['types'] = ''; } if ($album['filter_values']['orientation'] && !in_array($album['filter_values']['orientation'], array_keys($album['filter_panel']['orientation']))) { $album['filter_values']['orientation'] = ''; } $album['base_url'] = href_to($ctype['name'], $album['slug'] . '.html') . '?' . http_build_query($album['url_params']); foreach ($album['filter_selected'] as $key => $value) { if (isset($album['filter_panel'][$key][$value])) { $title[] = $album['filter_panel'][$key][$value]; } } if (!empty($title)) { $album['title'] .= ' — ' . mb_strtolower(implode(', ', $title)); $album['seo_desc'] .= ' ' . $album['title']; } return array($ctype, $album, $fields); }
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); }
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 grid_tags($controller) { $options = array('order_by' => 'tag', 'order_to' => 'asc'); $columns = array('tag' => array('title' => LANG_TAGS_TAG, 'href' => href_to($controller->root_url, 'edit', array('{id}')), 'filter' => 'like'), 'frequency' => array('title' => LANG_TAGS_TAG_FREQUENCY)); $actions = array(array('title' => LANG_VIEW, 'class' => 'view', 'href' => href_to('tags', 'search') . "?q={tag}"), array('title' => LANG_EDIT, 'class' => 'edit', 'href' => href_to($controller->root_url, 'edit', array('{id}'))), array('title' => LANG_DELETE, 'class' => 'delete', 'href' => href_to($controller->root_url, 'delete', array('{id}')), 'confirm' => LANG_TAGS_TAG_DELETE_CONFIRM)); return array('options' => $options, 'columns' => $columns, 'actions' => $actions); }
function grid_menu_items($controller) { $options = array('is_auto_init' => false, 'is_sortable' => false, 'is_filter' => false, 'is_pagination' => false, 'is_draggable' => true, 'order_by' => 'ordering', 'order_to' => 'asc', 'show_id' => false); $columns = array('id' => array('title' => 'id', 'width' => 30), 'title' => array('title' => LANG_CP_MENU_ITEM_TITLE, 'width' => 200, 'href' => href_to($controller->name, 'menu', array('item_edit', '{id}'))), 'url' => array('title' => LANG_CP_MENU_ITEM_URL)); $actions = array(array('title' => LANG_EDIT, 'class' => 'edit', 'href' => href_to($controller->name, 'menu', array('item_edit', '{id}'))), array('title' => LANG_DELETE, 'class' => 'delete', 'href' => href_to($controller->name, 'menu', array('item_delete', '{id}')), 'confirm' => LANG_CP_MENU_ITEM_DELETE_CONFIRM)); return array('options' => $options, 'columns' => $columns, 'actions' => $actions); }
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)); }
function grid_log($controller) { $options = array('order_by' => 'id', 'order_to' => 'asc'); $columns = array('id' => array('title' => 'id', 'width' => 20), 'orfo' => array('title' => 'Текст ошибки', 'width' => 300, 'href' => '{url}'), 'comment' => array('title' => 'Комментарий', 'width' => 300), 'date' => array('title' => 'Дата', 'width' => 120), 'author' => array('title' => 'Автор', 'width' => 100)); $actions = array(array('title' => LANG_DELETE, 'class' => 'delete', 'href' => href_to($controller->root_url, 'delete', '{id}'), 'confirm' => LANG_COMPLAINTS_CP_FORM_DELETE_CONFIRM)); return array('options' => $options, 'columns' => $columns, 'actions' => $actions); }
public function run($data) { $ctype_name = $data['ctype_name']; $item = $data['item']; $this->addEntry('content', "add.{$ctype_name}", array('user_id' => $item['user_id'], 'subject_title' => $item['title'], 'subject_id' => $item['id'], 'subject_url' => href_to($ctype_name, $item['slug'] . '.html'), 'is_private' => isset($item['is_private']) ? $item['is_private'] : 0, 'group_id' => isset($item['parent_id']) ? $item['parent_id'] : null, 'is_parent_hidden' => $item['is_parent_hidden'], 'is_pub' => $item['is_pub'])); return $data; }
function grid_feeds($controller) { $options = array('order_by' => 'title', 'order_to' => 'asc'); $columns = array('title' => array('title' => LANG_RSS_FEED_TITLE, 'href' => href_to($controller->root_url, 'edit', array('{id}')), 'filter' => 'like'), 'is_enabled' => array('title' => LANG_IS_ENABLED, 'flag' => true, 'width' => 60), 'is_cache' => array('title' => LANG_RSS_FEED_IS_CACHE, 'flag' => true, 'width' => 60)); $actions = array(array('title' => LANG_VIEW, 'class' => 'rss', 'href' => href_to('rss', 'feed', '{ctype_name}')), array('title' => LANG_EDIT, 'class' => 'edit', 'href' => href_to($controller->root_url, 'edit', array('{id}')))); return array('options' => $options, 'columns' => $columns, 'actions' => $actions); }
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($id) { if (!$id) { cmsCore::error404(); } $users_model = cmsCore::getModel('users'); $group = $users_model->getGroup($id); if (!$group) { cmsCore::error404(); } $form = $this->getForm('users_group', array('edit')); $is_submitted = $this->request->has('submit'); if ($is_submitted) { $group = $form->parse($this->request, $is_submitted); $errors = $form->validate($this, $group); if (!$errors) { $users_model->updateGroup($id, $group); $this->redirectToAction('users'); } if ($errors) { cmsUser::addSessionMessage(LANG_FORM_ERRORS, 'error'); } } $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', array('do' => 'edit', 'group' => $group, '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'))) { cmsCore::error404(); } if (!in_array($date, array('all', 'w', 'm', 'y'))) { 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)); }
function grid_comments_list($controller) { $options = array('is_sortable' => true, 'is_filter' => true, 'is_pagination' => true, 'is_draggable' => false, 'order_by' => 'date_pub', 'order_to' => 'desc', 'show_id' => true); $columns = array('id' => array('title' => 'id', 'width' => 30), 'date_pub' => array('title' => LANG_DATE, 'width' => 110, 'handler' => function ($value, $item) { return html_date($value, true); }, 'filter' => 'date'), 'target_id' => array('title' => LANG_COMMENTS_TEXT, 'handler' => function ($value, $row) use($controller) { return '<a title="' . LANG_COMMENTS_EDIT_TEXT . '" class="ajax-modal comment_text_edit" href="' . href_to($controller->root_url, 'text_edit', array($row['id'])) . '">' . string_short($row['content_html'], 350) . '</a>'; }), 'user_id' => array('title' => LANG_AUTHOR, 'width' => 180, 'handler' => function ($value, $row) { if ($row['user_id']) { $v = '<a target="_blank" href="' . href_to('users', $row['user_id']) . '">' . $row['user_nickname'] . '</a>'; } else { $v = '<span class="guest_name">' . $row['author_name'] . '</span>'; if (!empty($row['author_email'])) { $v .= '<span>, ' . $row['author_email'] . '</span>'; } } return $v; }), 'author_url' => array('title' => LANG_COMMENTS_IP, 'width' => 120, 'filter' => 'like', 'handler' => function ($value) { if ($value) { return '<a href="#" class="ajaxlink filter_ip tooltip" title="' . LANG_CP_USER_FIND_BYIP . '">' . $value . '</a> <a class="view_target tooltip" href="https://apps.db.ripe.net/search/query.html?searchtext=' . $value . '#resultsAnchor" target="_blank" title="' . LANG_CP_USER_RIPE_SEARCH . '"></a>'; } return ''; }), 'rating' => array('title' => LANG_RATING, 'width' => 50, 'handler' => function ($value, $row) { return '<span class="' . html_signed_class($value) . '">' . html_signed_num($value) . '</span>'; }, 'filter' => 'exact'), 'is_deleted' => array('title' => LANG_COMMENTS_IS_DELETED, 'flag' => 'flag_lock', 'flag_toggle' => href_to($controller->root_url, 'toggle_item', array('{id}', 'comments', 'is_deleted')), 'width' => 50, 'filter' => 'exact'), 'is_approved' => array('title' => LANG_MODERATION, 'flag' => true, 'width' => 50, 'filter' => 'exact', 'handler' => function ($value, $item) { if (!$item['is_approved']) { return '<div class="flag_trigger flag_off"><span><a class="approve_comment" title="' . LANG_COMMENTS_APPROVE . '" href="#" data-approve-url="' . href_to('comments', 'approve') . '?id=' . $item['id'] . '"></a></span></div>'; } return '<div class="flag_trigger flag_on"></div>'; }), 'is_private' => array('title' => LANG_COMMENTS_IS_PRIVATE, 'flag' => true, 'width' => 50, 'filter' => 'exact')); $actions = array(array('title' => LANG_COMMENTS_VIEW, 'class' => 'view tooltip', 'href' => href_to('{target_url}', '#comment_{id}')), array('title' => LANG_DELETE, 'class' => 'delete', 'href' => href_to($controller->root_url, 'comments_delete', array('{id}')), 'confirm' => LANG_COMMENTS_DELETE_CONFIRM)); return array('options' => $options, 'columns' => $columns, 'actions' => $actions); }
function grid_regions($controller) { $options = array('is_sortable' => true, 'is_filter' => true, 'is_pagination' => true, 'is_draggable' => false, 'order_by' => 'name', 'order_to' => 'asc', 'show_id' => true); $columns = array('id' => array('title' => 'ID', 'width' => 20, 'filter' => 'exact'), 'name' => array('title' => LANG_TITLE, 'href' => href_to($controller->root_url, 'cities', array('{id}', '{country_id}')), 'filter' => 'like', 'editable' => array('table' => 'geo_regions'))); $actions = array(array('title' => LANG_EDIT, 'class' => 'edit', 'href' => href_to($controller->root_url, 'region', array('{country_id}', '{id}'))), array('title' => LANG_DELETE, 'class' => 'delete', 'href' => href_to($controller->root_url, 'delete', array('region', '{id}')), 'confirm' => LANG_GEO_DELETE_REGION)); return array('options' => $options, 'columns' => $columns, 'actions' => $actions); }
function grid_vocabularies($controller) { $options = array('is_sortable' => false, 'is_filter' => false, 'is_pagination' => false, 'is_draggable' => false, 'order_by' => 'id', 'order_to' => 'asc', 'show_id' => true); $columns = array('id' => array('title' => 'id', 'width' => 30), 'title' => array('title' => LANG_TAXONOMY_VOCABULARY_TITLE, 'href' => href_to($controller->root_url, 'vocabulary_edit', array('{id}')))); $actions = array(array('title' => LANG_EDIT, 'class' => 'edit', 'href' => href_to($controller->root_url, 'vocabulary_edit', array('{id}'))), array('title' => LANG_DELETE, 'class' => 'delete', 'href' => href_to($controller->root_url, 'vocabulary_delete', array('{id}')), 'confirm' => LANG_TAXONOMY_VOCABULARY_DEL_CONFIRM)); return array('options' => $options, 'columns' => $columns, 'actions' => $actions); }
function grid_tabs($controller) { $options = array('is_sortable' => false, 'is_filter' => false, 'is_pagination' => false, 'is_draggable' => true, 'order_by' => 'ordering', 'order_to' => 'asc', 'show_id' => false); $columns = array('id' => array('title' => 'id', 'width' => 30), 'title' => array('title' => LANG_CP_TAB_TITLE, 'href' => href_to($controller->root_url, 'tabs_edit', array('{id}')), 'editable' => array('table' => '{users}_tabs')), 'name' => array('title' => LANG_SYSTEM_NAME, 'width' => 150), 'is_active' => array('title' => LANG_SHOW, 'flag' => true, 'width' => 60, 'flag_toggle' => href_to($controller->root_url, 'toggle_item', array('{id}', '{users}_tabs', 'is_active')))); $actions = array(array('title' => LANG_EDIT, 'class' => 'edit', 'href' => href_to($controller->root_url, 'tabs_edit', array('{id}')))); return array('options' => $options, 'columns' => $columns, 'actions' => $actions); }
function grid_ctype_datasets($controller) { $options = array('is_sortable' => false, 'is_filter' => false, 'is_pagination' => false, 'is_draggable' => true, 'order_by' => 'ordering', 'order_to' => 'asc', 'show_id' => false); $columns = array('id' => array('title' => 'id', 'width' => 30), 'title' => array('title' => LANG_CP_DATASET_TITLE, 'href' => href_to($controller->name, 'ctypes', array('datasets_edit', '{ctype_id}', '{id}')), 'editable' => array('table' => 'content_datasets')), 'name' => array('title' => LANG_SYSTEM_NAME, 'width' => 150), 'is_visible' => array('title' => LANG_PUBLICATION, 'flag' => true, 'flag_toggle' => href_to($controller->name, 'ctypes', array('datasets_toggle', '{id}')), 'width' => 90)); $actions = array(array('title' => LANG_EDIT, 'class' => 'edit', 'href' => href_to($controller->name, 'ctypes', array('datasets_edit', '{ctype_id}', '{id}'))), array('title' => LANG_DELETE, 'class' => 'delete', 'href' => href_to($controller->name, 'ctypes', array('datasets_delete', '{id}')), 'confirm' => LANG_CP_DATASET_DELETE_CONFIRM)); return array('options' => $options, 'columns' => $columns, 'actions' => $actions); }
public function run($user) { // Если пользователь отключил уведомления о новых комментариях // через личные сообщения, то выходим if (empty($user['notify_options']['comments_new'])) { return $user; } if (!in_array($user['notify_options']['comments_new'], array('pm', 'both'))) { return $user; } // Если новых комментариев на отслеживаемых страницах не появлялось // то тоже выходим $counts = $this->model->getTrackedNewCounts($user['id'], $user['date_log']); if (!$counts) { return $user; } $messenger = cmsCore::getController('messages'); $messenger->addRecipient($user['id']); foreach ($counts as $data) { $spellcount = html_spellcount($data['count'], LANG_NEW_COMMENT1, LANG_NEW_COMMENT2, LANG_NEW_COMMENT10); $notice = array('content' => sprintf(LANG_COMMENTS_TRACKED_NEW, $data['target_title'], $spellcount), 'actions' => array('view' => array('title' => LANG_SHOW, 'href' => href_to($data['target_url']) . '?new_comments#comments'), 'stop' => array('title' => LANG_COMMENTS_TRACK_STOP, 'controller' => $this->name, 'action' => 'track_stop', 'params' => array($data['target_controller'], $data['target_subject'], $data['target_id'])))); $messenger->sendNoticePM($notice, 'comments_new'); } return $user; }
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 getProfileMenu($profile) { $menu = array(array('title' => LANG_USERS_PROFILE_INDEX, 'url' => href_to($this->name, $profile['id']), 'url_mask' => href_to($this->name, $profile['id']))); $this->tabs = $this->model->getUsersProfilesTabs(true, 'name'); $this->tabs_controllers = array(); if ($this->tabs) { foreach ($this->tabs as $tab) { $default_tab_info = array('title' => $tab['title'], 'url' => href_to($this->name, $profile['id'], $tab['name'])); if (!$this->isControllerEnabled($tab['controller'])) { continue; } if (empty($this->tabs_controllers[$tab['controller']])) { $controller = cmsCore::getController($tab['controller'], $this->request); } else { $controller = $this->tabs_controllers[$tab['controller']]; } $tab_info = $controller->runHook('user_tab_info', array('profile' => $profile, 'tab_name' => $tab['name'])); if ($tab_info == false) { continue; } else { if ($tab_info === true) { $tab_info = $default_tab_info; } else { $tab_info = array_merge($default_tab_info, $tab_info); } } $menu[] = $tab_info; $this->tabs_controllers[$tab['controller']] = $controller; } } return $menu; }
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($data) { $viewable = $data['viewable']; $item = $data['item']; $is_moderator = !empty($data['is_moderator']); if (!$viewable) { return $data; } if (!$item['parent_type'] == 'group') { return $data; } if (!$this->cms_user->is_logged) { $data['viewable'] = false; return $data; } $membership = $this->model->getMembership($item['parent_id'], $this->cms_user->id) || $this->cms_user->is_admin || $is_moderator; if ($membership === false) { $group = $this->model->getGroup($item['parent_id']); if ($group) { $data['access_text'] = sprintf(LANG_GROUPS_CTYPE_ACCESS, href_to('groups', $group['id']), $group['title']); $data['access_redirect_url'] = href_to('groups', $group['id']); $data['viewable'] = false; return $data; } } return $data; }
function grid_countries($controller) { $options = array('is_sortable' => true, 'is_filter' => true, 'is_pagination' => true, 'is_draggable' => true, 'order_by' => 'ordering', 'order_to' => 'asc', 'show_id' => true); $columns = array('id' => array('title' => 'ID', 'width' => 20, 'filter' => 'exact'), 'name' => array('title' => LANG_TITLE, 'href' => href_to($controller->root_url, 'regions', array('{id}')), 'filter' => 'like', 'editable' => array('table' => 'geo_countries')), 'alpha2' => array('title' => LANG_GEO_ALPHA2, 'width' => 250, 'filter' => 'like', 'editable' => array('table' => 'geo_countries')), 'ordering' => array('title' => LANG_GEO_POSITION, 'width' => 60)); $actions = array(array('title' => LANG_EDIT, 'class' => 'edit', 'href' => href_to($controller->root_url, 'country', array('{id}'))), array('title' => LANG_DELETE, 'class' => 'delete', 'href' => href_to($controller->root_url, 'delete', array('country', '{id}')), 'confirm' => LANG_GEO_DELETE_COUNTRY)); return array('options' => $options, 'columns' => $columns, 'actions' => $actions); }
public function run($data) { list($ctype, $items) = $data; if (cmsUser::isAllowed($ctype['name'], 'add')) { cmsTemplate::getInstance()->addToolButton(array('class' => 'images', 'title' => LANG_PHOTOS_UPLOAD, 'href' => href_to($this->name, 'upload'))); } return $data; }
function grid_ctypes($controller) { $columns = array('id' => array('title' => 'id', 'width' => 30, 'filter' => 'exact'), 'title' => array('title' => LANG_TITLE, 'width' => 150, 'href' => href_to($controller->name, 'ctypes', array('edit', '{id}')), 'filter' => 'like'), 'name' => array('title' => LANG_SYSTEM_NAME, 'width' => 150, 'filter' => 'like'), 'description' => array('title' => LANG_DESCRIPTION, 'filter' => 'like')); $actions = array(array('title' => LANG_EDIT, 'class' => 'edit', 'href' => href_to($controller->name, 'ctypes', array('edit', '{id}'))), array('title' => LANG_CP_CTYPE_LABELS, 'class' => 'labels', 'href' => href_to($controller->name, 'ctypes', array('labels', '{id}'))), array('title' => LANG_CP_CTYPE_FIELDS, 'class' => 'fields', 'href' => href_to($controller->name, 'ctypes', array('fields', '{id}'))), array('title' => LANG_CP_CTYPE_PERMISSIONS, 'class' => 'permissions', 'href' => href_to($controller->name, 'ctypes', array('perms', '{id}'))), array('title' => LANG_CP_CTYPE_DATASETS, 'class' => 'filter', 'href' => href_to($controller->name, 'ctypes', array('datasets', '{id}'))), array('title' => LANG_MODERATORS, 'class' => 'user', 'href' => href_to($controller->name, 'ctypes', array('moderators', '{id}'))), array('title' => LANG_DELETE, 'class' => 'delete', 'href' => href_to($controller->name, 'ctypes', array('delete', '{id}')), 'confirm' => LANG_CP_CTYPE_DELETE_CONFIRM, 'handler' => function ($row) { return !$row['is_fixed']; })); return array('columns' => $columns, 'actions' => $actions); }
public function run($group) { $activity_controller = cmsCore::getController('activity', $this->request); $activity_controller->model->filterEqual('group_id', $group['id']); $page_url = href_to($this->name, $group['id'], 'activity'); $html = $activity_controller->renderActivityList($page_url); return cmsTemplate::getInstance()->render('group_activity', array('user' => $this->cms_user, 'group' => $group, 'html' => $html)); }
public function run($data) { $ctype_name = $data['ctype_name']; $item = $data['item']; // обновляем запись в ленте активности $this->updateEntry('content', "add.{$ctype_name}", $item['id'], array('subject_title' => $item['title'], 'subject_id' => $item['id'], 'subject_url' => href_to($ctype_name, $item['slug'] . '.html'), 'is_private' => isset($item['is_private']) ? $item['is_private'] : 0, 'is_pub' => $item['is_pub'])); return $data; }
public function run($ctype_id, $category_id = 1) { $content_model = cmsCore::getModel('content'); $ctype = $content_model->getContentType($ctype_id); $params = $category_id > 1 ? array($category_id) : false; $url = href_to($ctype['name'], 'add', $params) . '?back=' . href_to($this->name, 'content'); $this->redirect($url); }
public function run($profile, $tab_name) { $user = cmsUser::getInstance(); $template = cmsTemplate::getInstance(); $this->model->filterByMember($profile['id']); $page_url = href_to('users', $profile['id'], 'groups'); $list_html = $this->renderGroupsList($page_url, 'popular'); return $template->renderInternal($this, 'profile_tab', array('user' => $user, 'profile' => $profile, 'html' => $list_html)); }