$Form->hidden_ctrl(); $Form->hidden('action', 'update'); $Form->hidden('tab', 'features'); $Form->hidden('blog', $edited_Blog->ID); $Form->begin_fieldset(T_('Post list') . get_manual_link('item-list-features')); $Form->select_input_array('orderby', $edited_Blog->get_setting('orderby'), get_available_sort_options(), T_('Order by'), T_('Default ordering of posts.')); $Form->select_input_array('orderdir', $edited_Blog->get_setting('orderdir'), array('ASC' => T_('Ascending'), 'DESC' => T_('Descending')), T_('Direction')); $Form->radio('what_to_show', $edited_Blog->get_setting('what_to_show'), array(array('days', T_('days')), array('posts', T_('posts'))), T_('Display unit'), false, T_('Do you want to restrict on the number of days or the number of posts?')); $Form->text('posts_per_page', $edited_Blog->get_setting('posts_per_page'), 4, T_('Posts/Days per page'), T_('How many days or posts do you want to display on the home page?'), 4); $Form->radio('timestamp_min', $edited_Blog->get_setting('timestamp_min'), array(array('yes', T_('yes')), array('no', T_('no')), array('duration', T_('only the last'))), T_('Show past posts'), true); $Form->duration_input('timestamp_min_duration', $edited_Blog->get_setting('timestamp_min_duration'), ''); $Form->radio('timestamp_max', $edited_Blog->get_setting('timestamp_max'), array(array('yes', T_('yes')), array('no', T_('no')), array('duration', T_('only the next'))), T_('Show future posts'), true); $Form->duration_input('timestamp_max_duration', $edited_Blog->get_setting('timestamp_max_duration'), ''); $Form->end_fieldset(); $Form->begin_fieldset(T_('Post options') . get_manual_link('blog_features_settings')); $Form->select_input_array('default_post_status', $edited_Blog->get_setting('default_post_status'), get_visibility_statuses('notes-string'), T_('Default status'), T_('Default status for new posts')); $Form->radio('require_title', $edited_Blog->get_setting('require_title'), array(array('required', T_('Always'), T_('The blogger must provide a title')), array('optional', T_('Optional'), T_('The blogger can leave the title field empty')), array('none', T_('Never'), T_('No title field'))), T_('Post titles'), true); $Form->checkbox('allow_html_post', $edited_Blog->get_setting('allow_html_post'), T_('Allow HTML'), T_('Check to allow HTML in posts.') . ' (' . T_('HTML code will pass several sanitization filters.') . ')'); $Form->radio('enable_goto_blog', $edited_Blog->get_setting('enable_goto_blog'), array(array('no', T_('No'), T_('Check this to view list of the posts.')), array('blog', T_('View home page'), T_('Check this to automatically view the blog after publishing a post.')), array('post', T_('View new post'), T_('Check this to automatically view the post page.'))), T_('View blog after publishing'), true); $Form->radio('editing_goto_blog', $edited_Blog->get_setting('editing_goto_blog'), array(array('no', T_('No'), T_('Check this to view list of the posts.')), array('blog', T_('View home page'), T_('Check this to automatically view the blog after editing a post.')), array('post', T_('View edited post'), T_('Check this to automatically view the post page.'))), T_('View blog after editing'), true); // FP> TODO: // -post_url always('required')|optional|never // -multilingual: true|false or better yet: provide a list to narrow down the active locales // -tags always('required')|optional|never $Form->radio('post_categories', $edited_Blog->get_setting('post_categories'), array(array('one_cat_post', T_('Allow only one category per post')), array('multiple_cat_post', T_('Allow multiple categories per post')), array('main_extra_cat_post', T_('Allow one main + several extra categories')), array('no_cat_post', T_('Don\'t allow category selections'), T_('(Main cat will be assigned automatically)'))), T_('Post category options'), true); $Form->radio('post_navigation', $edited_Blog->get_setting('post_navigation'), array(array('same_blog', T_('same blog')), array('same_category', T_('same category')), array('same_author', T_('same author'))), T_('Default post by post navigation should stay in'), true, T_('Skins may override this setting!')); $location_options = array(array('optional', T_('Optional')), array('required', T_('Required')), array('hidden', T_('Hidden'))); $Form->radio('location_country', $edited_Blog->get_setting('location_country'), $location_options, T_('Country')); $Form->radio('location_region', $edited_Blog->get_setting('location_region'), $location_options, T_('Region')); $Form->radio('location_subregion', $edited_Blog->get_setting('location_subregion'), $location_options, T_('Sub-region')); $Form->radio('location_city', $edited_Blog->get_setting('location_city'), $location_options, T_('City'));
/** * Generate a title for the current list, depending on its filtering params * * @todo cleanup some displays * @todo implement HMS part of YMDHMS * * @return array List of titles to display, which are escaped for HTML display * (dh> only checked this for 'authors'/?authors=, where the output was not escaped) */ function get_filter_titles($ignore = array(), $params = array()) { global $month, $disp_detail; $params = array_merge(array('category_text' => T_('Category') . ': ', 'categories_text' => T_('Categories') . ': ', 'categories_nor_text' => T_('All but '), 'tag_text' => T_('Tag') . ': ', 'tags_text' => T_('Tags') . ': ', 'author_text' => T_('Author') . ': ', 'authors_text' => T_('Authors') . ': ', 'authors_nor_text' => T_('All authors except') . ': ', 'visibility_text' => T_('Visibility') . ': ', 'keyword_text' => T_('Keyword') . ': ', 'keywords_text' => T_('Keywords') . ': ', 'keywords_exact_text' => T_('Exact match') . ' ', 'status_text' => T_('Status') . ': ', 'statuses_text' => T_('Statuses') . ': ', 'archives_text' => T_('Archives for') . ': ', 'assignes_text' => T_('Assigned to') . ': ', 'group_mask' => '$group_title$$filter_items$', 'filter_mask' => '"$filter_name$"', 'filter_mask_nogroup' => '"$filter_name$"', 'before_items' => '', 'after_items' => '', 'separator_and' => ' ' . T_('and') . ' ', 'separator_or' => ' ' . T_('or') . ' ', 'separator_nor' => ' ' . T_('or') . ' ', 'separator_comma' => ', ', 'display_category' => true, 'display_archive' => true, 'display_keyword' => true, 'display_tag' => true, 'display_author' => true, 'display_assignee' => true, 'display_locale' => true, 'display_status' => true, 'display_visibility' => true, 'display_time' => true, 'display_limit' => true), $params); if (empty($this->filters)) { // Filters have no been set before, we'll use the default filterset: // echo ' setting default filterset '; $this->set_filters($this->default_filters); } $title_array = array(); if ($this->single_post) { // We have requested a specific post: // Should be in first position $Item =& $this->get_by_idx(0); if (is_null($Item)) { $title_array[] = T_('Invalid request'); } else { $title_array[] = $Item->get_titletag(); } return $title_array; } // Check if the filter mask has an icon to clear the filter item $clear_icon = strpos($params['filter_mask'], '$clear_icon$') !== false; $filter_classes = array('green'); $filter_class_i = 0; if (strpos($params['filter_mask'], '$filter_class$') !== false) { // Initialize array with available classes for filter items $filter_classes = array('green', 'yellow', 'orange', 'red', 'magenta', 'blue'); } // CATEGORIES: if ($params['display_category']) { if (!empty($this->filters['cat_array'])) { // We have requested specific categories... $cat_names = array(); $ChapterCache =& get_ChapterCache(); $catsel_param = get_param('catsel'); foreach ($this->filters['cat_array'] as $cat_ID) { if (($tmp_Chapter =& $ChapterCache->get_by_ID($cat_ID, false)) !== false) { // It is almost never meaningful to die over an invalid cat when generating title $cat_clear_url = regenerate_url((empty($catsel_param) ? 'cat=' : 'catsel=') . $cat_ID); if ($disp_detail == 'posts-subcat' || $disp_detail == 'posts-cat') { // Remove category url from $ReqPath when we use the cat url instead of cat ID $cat_clear_url = str_replace('/' . $tmp_Chapter->get_url_path(), '', $cat_clear_url); } $cat_clear_icon = $clear_icon ? action_icon(T_('Remove this filter'), 'remove', $cat_clear_url) : ''; $cat_names[] = str_replace(array('$group_title$', '$filter_name$', '$clear_icon$', '$filter_class$'), array($params['category_text'], $tmp_Chapter->name, $cat_clear_icon, $filter_classes[$filter_class_i]), $params['filter_mask']); } } $filter_class_i++; if ($this->filters['cat_modifier'] == '*') { // Categories with "AND" condition $cat_names_string = implode($params['separator_and'], $cat_names); } elseif ($this->filters['cat_modifier'] == '-') { // Categories with "NOR" condition $cat_names_string = implode($params['separator_nor'], $cat_names); } else { // Categories with "OR" condition $cat_names_string = implode($params['separator_or'], $cat_names); } if (!empty($cat_names_string)) { if ($this->filters['cat_modifier'] == '-') { // Categories with "NOR" condition $cat_names_string = $params['categories_nor_text'] . $cat_names_string; $params['category_text'] = $params['categories_text']; } $title_array['cats'] = str_replace(array('$group_title$', '$filter_items$'), count($this->filters['cat_array']) > 1 ? array($params['categories_text'], $params['before_items'] . $cat_names_string . $params['after_items']) : array($params['category_text'], $cat_names_string), $params['group_mask']); } } } // ARCHIVE TIMESLOT: if ($params['display_archive']) { if (!empty($this->filters['ymdhms'])) { // We have asked for a specific timeframe: $my_year = substr($this->filters['ymdhms'], 0, 4); if (strlen($this->filters['ymdhms']) > 4) { // We have requested a month too: $my_month = T_($month[substr($this->filters['ymdhms'], 4, 2)]); } else { $my_month = ''; } // Requested a day? $my_day = substr($this->filters['ymdhms'], 6, 2); $arch = $my_month . ' ' . $my_year; if (!empty($my_day)) { // We also want to display a day $arch .= ', ' . $my_day; } if (!empty($this->filters['week']) || $this->filters['week'] === 0) { // We also want to display a week number $arch .= ', ' . T_('week') . ' ' . $this->filters['week']; } $filter_class_i = $filter_class_i > count($filter_classes) - 1 ? 0 : $filter_class_i; $arch_clear_icon = $clear_icon ? action_icon(T_('Remove this filter'), 'remove', regenerate_url($this->param_prefix . 'm')) : ''; $arch = str_replace(array('$group_title$', '$filter_name$', '$clear_icon$', '$filter_class$'), array($params['archives_text'], $arch, $arch_clear_icon, $filter_classes[$filter_class_i]), $params['filter_mask']); $title_array['ymdhms'] = str_replace(array('$group_title$', '$filter_items$'), array($params['archives_text'], $arch), $params['group_mask']); $filter_class_i++; } } // KEYWORDS: if ($params['display_keyword']) { if (!empty($this->filters['keywords'])) { if ($this->filters['phrase'] == 'OR' || $this->filters['phrase'] == 'AND') { // Search by each keyword $keywords = trim(preg_replace('/("|, *)/', ' ', $this->filters['keywords'])); $keywords = explode(' ', $keywords); } else { // Exact match (Single keyword) $keywords = array($this->filters['keywords']); } $filter_class_i = $filter_class_i > count($filter_classes) - 1 ? 0 : $filter_class_i; $keyword_names = array(); foreach ($keywords as $keyword) { $word_clear_icon = $clear_icon ? action_icon(T_('Remove this filter'), 'remove', regenerate_url($this->param_prefix . 's=' . $keyword)) : ''; $keyword_names[] = str_replace(array('$group_title$', '$filter_name$', '$clear_icon$', '$filter_class$'), array($params['keyword_text'], $keyword, $word_clear_icon, $filter_classes[$filter_class_i]), $params['filter_mask']); } $filter_class_i++; $keywords = ($this->filters['exact'] ? $params['keywords_exact_text'] : '') . implode($this->filters['phrase'] == 'OR' ? $params['separator_or'] : $params['separator_and'], $keyword_names); $title_array[] = str_replace(array('$group_title$', '$filter_items$'), count($keyword_names) > 1 ? array($params['keywords_text'], $params['before_items'] . $keywords . $params['after_items']) : array($params['keyword_text'], $keywords), $params['group_mask']); } } // TAGS: if ($params['display_tag']) { if (!empty($this->filters['tags'])) { $tags = explode(',', $this->filters['tags']); $tag_names = array(); $filter_class_i = $filter_class_i > count($filter_classes) - 1 ? 0 : $filter_class_i; foreach ($tags as $tag) { $tag_clear_url = regenerate_url($this->param_prefix . 'tag=' . $tag); if ($disp_detail == 'posts-tag') { // Remove tag url from $ReqPath when we use tag url instead of tag ID $tag_clear_url = str_replace('/' . $tag . ':', '', $tag_clear_url); } $tag_clear_icon = $clear_icon ? action_icon(T_('Remove this filter'), 'remove', $tag_clear_url) : ''; $tag_names[] = str_replace(array('$group_title$', '$filter_name$', '$clear_icon$', '$filter_class$'), array($params['tag_text'], $tag, $tag_clear_icon, $filter_classes[$filter_class_i]), $params['filter_mask']); } $filter_class_i++; $tags = implode($params['separator_comma'], $tag_names); $title_array[] = str_replace(array('$group_title$', '$filter_items$'), count($tag_names) > 1 ? array($params['tags_text'], $params['before_items'] . $tags . $params['after_items']) : array($params['tag_text'], $tags), $params['group_mask']); } } // AUTHORS: if ($params['display_author']) { if (!empty($this->filters['authors']) || !empty($this->filters['authors_login'])) { $authors = trim($this->filters['authors'] . ',' . get_users_IDs_by_logins($this->filters['authors_login']), ','); $exclude_authors = false; if (substr($authors, 0, 1) == '-') { // Authors are excluded $authors = substr($authors, 1); $exclude_authors = true; } $authors = preg_split('~\\s*,\\s*~', $authors, -1, PREG_SPLIT_NO_EMPTY); $author_names = array(); if ($authors) { $UserCache =& get_UserCache(); $filter_class_i = $filter_class_i > count($filter_classes) - 1 ? 0 : $filter_class_i; foreach ($authors as $author_ID) { if ($tmp_User = $UserCache->get_by_ID($author_ID, false, false)) { $user_clear_icon = $clear_icon ? action_icon(T_('Remove this filter'), 'remove', regenerate_url($this->param_prefix . 'author=' . $author_ID)) : ''; $author_names[] = str_replace(array('$group_title$', '$filter_name$', '$clear_icon$', '$filter_class$'), array($params['author_text'], $tmp_User->get('login'), $user_clear_icon, $filter_classes[$filter_class_i]), $params['filter_mask']); } } $filter_class_i++; } if (count($author_names) > 0) { // Display info of filter by authors if ($exclude_authors) { // Exclude authors $author_names_string = $params['authors_nor_text'] . implode($params['separator_nor'], $author_names); } else { // Filter by authors $author_names_string = implode($params['separator_comma'], $author_names); } $title_array[] = str_replace(array('$group_title$', '$filter_items$'), count($author_names) > 1 ? array($params['authors_text'], $params['before_items'] . $author_names_string . $params['after_items']) : array($params['author_text'], $author_names_string), $params['group_mask']); } } } // ASSIGNEES: if ($params['display_assignee']) { if (!empty($this->filters['assignees']) || !empty($this->filters['assignees_login'])) { $filter_class_i = $filter_class_i > count($filter_classes) - 1 ? 0 : $filter_class_i; if ($this->filters['assignees'] == '-') { $user_clear_icon = $clear_icon ? action_icon(T_('Remove this filter'), 'remove', regenerate_url($this->param_prefix . 'assgn')) : ''; $title_array[] = str_replace(array('$filter_name$', '$clear_icon$', '$filter_class$'), array(T_('Not assigned'), $user_clear_icon, $filter_classes[$filter_class_i]), $params['filter_mask_nogroup']); } else { $assignees = trim($this->filters['assignees'] . ',' . get_users_IDs_by_logins($this->filters['assignees_login']), ','); $assignees = preg_split('~\\s*,\\s*~', $assignees, -1, PREG_SPLIT_NO_EMPTY); $assignees_names = array(); if ($assignees) { $UserCache =& get_UserCache(); foreach ($assignees as $user_ID) { if ($tmp_User =& $UserCache->get_by_ID($user_ID, false, false)) { $user_clear_icon = $clear_icon ? action_icon(T_('Remove this filter'), 'remove', regenerate_url($this->param_prefix . 'assgn=' . $user_ID)) : ''; $assignees_names[] = str_replace(array('$group_title$', '$filter_name$', '$clear_icon$', '$filter_class$'), array($params['assignes_text'], $tmp_User->get_identity_link(array('link_text' => 'name')), $user_clear_icon, $filter_classes[$filter_class_i]), $params['filter_mask']); } } } $title_array[] = str_replace(array('$group_title$', '$filter_items$'), count($assignees_names) > 1 ? array($params['assignes_text'], $params['before_items'] . implode($params['separator_comma'], $assignees_names) . $params['after_items']) : array($params['assignes_text'], implode($params['separator_comma'], $assignees_names)), $params['group_mask']); } $filter_class_i++; } } // LOCALE: if ($params['display_locale']) { if ($this->filters['lc'] != 'all') { $filter_class_i = $filter_class_i > count($filter_classes) - 1 ? 0 : $filter_class_i; $user_clear_icon = $clear_icon ? action_icon(T_('Remove this filter'), 'remove', regenerate_url($this->param_prefix . 'lc')) : ''; $loc = str_replace(array('$group_title$', '$filter_name$', '$clear_icon$', '$filter_class$'), array(T_('Locale') . ': ', $this->filters['lc'], $user_clear_icon, $filter_classes[$filter_class_i]), $params['filter_mask']); $title_array[] = str_replace(array('$group_title$', '$filter_items$'), array(T_('Locale') . ': ', $loc), $params['group_mask']); $filter_class_i++; } } // EXTRA STATUSES: if ($params['display_status']) { if (!empty($this->filters['statuses'])) { $filter_class_i = $filter_class_i > count($filter_classes) - 1 ? 0 : $filter_class_i; if ($this->filters['statuses'] == '-') { $status_clear_icon = $clear_icon ? action_icon(T_('Remove this filter'), 'remove', regenerate_url($this->param_prefix . 'status=-')) : ''; $title_array[] = str_replace(array('$filter_name$', '$clear_icon$', '$filter_class$'), array(T_('Without status'), $status_clear_icon, $filter_classes[$filter_class_i]), $params['filter_mask_nogroup']); } else { $status_IDs = explode(',', $this->filters['statuses']); $ItemStatusCache =& get_ItemStatusCache(); $statuses = array(); foreach ($status_IDs as $status_ID) { if ($ItemStatus =& $ItemStatusCache->get_by_ID($status_ID)) { $status_clear_icon = $clear_icon ? action_icon(T_('Remove this filter'), 'remove', regenerate_url($this->param_prefix . 'status=' . $status_ID)) : ''; $statuses[] = str_replace(array('$group_title$', '$filter_name$', '$clear_icon$', '$filter_class$'), array($params['status_text'], $ItemStatus->get_name(), $status_clear_icon, $filter_classes[$filter_class_i]), $params['filter_mask']); } } $title_array[] = str_replace(array('$group_title$', '$filter_items$'), count($statuses) > 1 ? array($params['statuses_text'], $params['before_items'] . implode($params['separator_comma'], $statuses) . $params['after_items']) : array($params['status_text'], implode($params['separator_comma'], $statuses)), $params['group_mask']); } $filter_class_i++; } } // VISIBILITY (SHOW STATUSES): if ($params['display_visibility']) { if (!in_array('visibility', $ignore)) { $post_statuses = get_visibility_statuses(); if (count($this->filters['visibility_array']) != count($post_statuses)) { // Display it only when visibility filter is changed $status_titles = array(); $filter_class_i = $filter_class_i > count($filter_classes) - 1 ? 0 : $filter_class_i; foreach ($this->filters['visibility_array'] as $status) { $vis_clear_icon = $clear_icon ? action_icon(T_('Remove this filter'), 'remove', regenerate_url($this->param_prefix . 'show_statuses=' . $status)) : ''; $status_titles[] = str_replace(array('$group_title$', '$filter_name$', '$clear_icon$', '$filter_class$'), array($params['visibility_text'], $post_statuses[$status], $vis_clear_icon, $filter_classes[$filter_class_i]), $params['filter_mask']); } $filter_class_i++; $title_array[] = str_replace(array('$group_title$', '$filter_items$'), count($status_titles) > 1 ? array($params['visibility_text'], $params['before_items'] . implode($params['separator_comma'], $status_titles) . $params['after_items']) : array($params['visibility_text'], implode($params['separator_comma'], $status_titles)), $params['group_mask']); } } } if ($params['display_time']) { // START AT: if (!empty($this->filters['ymdhms_min']) || !empty($this->filters['ts_min'])) { $filter_class_i = $filter_class_i > count($filter_classes) - 1 ? 0 : $filter_class_i; if (!empty($this->filters['ymdhms_min'])) { $time_clear_icon = $clear_icon ? action_icon(T_('Remove this filter'), 'remove', regenerate_url($this->param_prefix . 'dstart')) : ''; $title_array['ts_min'] = str_replace(array('$group_title$', '$filter_name$', '$clear_icon$', '$filter_class$'), array(T_('Start at') . ': ', date2mysql($this->filters['ymdhms_min']), $time_clear_icon, $filter_classes[$filter_class_i]), $params['filter_mask']); } else { if ($this->filters['ts_min'] == 'now') { $time_clear_icon = $clear_icon ? action_icon(T_('Remove this filter'), 'remove', regenerate_url($this->param_prefix . 'show_future')) : ''; $title_array['ts_min'] = str_replace(array('$filter_name$', '$clear_icon$', '$filter_class$'), array(T_('Hide past'), $time_clear_icon, $filter_classes[$filter_class_i]), $params['filter_mask_nogroup']); } else { $time_clear_icon = $clear_icon ? action_icon(T_('Remove this filter'), 'remove', regenerate_url($this->param_prefix . 'show_future')) : ''; $title_array['ts_min'] = str_replace(array('$group_title$', '$filter_name$', '$clear_icon$', '$filter_class$'), array(T_('Start at') . ': ', date2mysql($this->filters['ts_min']), $time_clear_icon, $filter_classes[$filter_class_i]), $params['filter_mask']); } } $filter_class_i++; } // STOP AT: if (!empty($this->filters['ymdhms_max']) || !empty($this->filters['ts_max'])) { $filter_class_i = $filter_class_i > count($filter_classes) - 1 ? 0 : $filter_class_i; if (!empty($this->filters['ymdhms_max'])) { $time_clear_icon = $clear_icon ? action_icon(T_('Remove this filter'), 'remove', regenerate_url($this->param_prefix . 'dstop')) : ''; $title_array['ts_max'] = str_replace(array('$group_title$', '$filter_name$', '$clear_icon$', '$filter_class$'), array(T_('Stop at') . ': ', date2mysql($this->filters['ymdhms_max']), $time_clear_icon, $filter_classes[$filter_class_i]), $params['filter_mask']); } else { if ($this->filters['ts_max'] == 'now') { if (!in_array('hide_future', $ignore)) { $time_clear_icon = $clear_icon ? action_icon(T_('Remove this filter'), 'remove', regenerate_url($this->param_prefix . 'show_past')) : ''; $title_array['ts_max'] = str_replace(array('$filter_name$', '$clear_icon$', '$filter_class$'), array(T_('Hide future'), $time_clear_icon, $filter_classes[$filter_class_i]), $params['filter_mask_nogroup']); } } else { $time_clear_icon = $clear_icon ? action_icon(T_('Remove this filter'), 'remove', regenerate_url($this->param_prefix . 'show_past')) : ''; $title_array['ts_max'] = str_replace(array('$group_title$', '$filter_name$', '$clear_icon$', '$filter_class$'), array(T_('Stop at') . ': ', date2mysql($this->filters['ts_max']), $time_clear_icon, $filter_classes[$filter_class_i]), $params['filter_mask']); } } $filter_class_i++; } } // LIMIT TO: if ($params['display_limit']) { if ($this->single_post) { // Single post: no paging required! } elseif (!empty($this->filters['ymdhms'])) { // no restriction if we request a month... some permalinks may point to the archive! } elseif ($this->filters['unit'] == 'posts' || $this->filters['unit'] == 'all') { // We're going to page, so there's no real limit here... } elseif ($this->filters['unit'] == 'days') { // We are going to limit to x days: // echo 'LIMIT DAYS '; $filter_class_i = $filter_class_i > count($filter_classes) - 1 ? 0 : $filter_class_i; if (empty($this->filters['ymdhms_min'])) { // We have no start date, we'll display the last x days: if (!empty($this->filters['keywords']) || !empty($this->filters['cat_array']) || !empty($this->filters['authors'])) { // We are in DAYS mode but we can't restrict on these! (TODO: ?) } else { // We are going to limit to LAST x days: // TODO: rename 'posts' to 'limit' $unit_clear_icon = $clear_icon ? action_icon(T_('Remove this filter'), 'remove', regenerate_url($this->param_prefix . 'unit')) : ''; $title_array['posts'] = str_replace(array('$filter_name$', '$clear_icon$', '$filter_class$'), array(sprintf(T_('Limited to last %d days'), $this->limit), $unit_clear_icon, $filter_classes[$filter_class_i]), $params['filter_mask_nogroup']); } } else { // We have a start date, we'll display x days starting from that point: $unit_clear_icon = $clear_icon ? action_icon(T_('Remove this filter'), 'remove', regenerate_url($this->param_prefix . 'unit')) : ''; $title_array['posts'] = str_replace(array('$filter_name$', '$clear_icon$', '$filter_class$'), array(sprintf(T_('Limited to %d days'), $this->limit), $unit_clear_icon, $filter_classes[$filter_class_i]), $params['filter_mask_nogroup']); } $filter_class_i++; } else { debug_die('Unhandled LIMITING mode in ItemList:' . $this->filters['unit'] . ' (paged mode is obsolete)'); } } return $title_array; }
/** * Template function: display all statuses and only one is visible by css class name * * Statuses: * - published * - community * - protected * - review * - private * - draft */ function statuses() { $statuses = get_visibility_statuses('', array('deprecated', 'redirected', 'trash')); foreach ($statuses as $status => $title) { echo get_styled_status($status, $title); } }
/** * Generate a title for the current list, depending on its filtering params * * @todo cleanup some displays * @todo implement HMS part of YMDHMS * * @return array List of titles to display, which are escaped for HTML display * (dh> only checked this for 'authors'/?authors=, where the output was not escaped) */ function get_filter_titles($ignore = array(), $params = array()) { global $month; $params = array_merge(array('category_text' => T_('Category') . ': ', 'categories_text' => T_('Categories') . ': ', 'tags_text' => T_('Tags') . ': '), $params); if (empty($this->filters)) { // Filters have no been set before, we'll use the default filterset: // echo ' setting default filterset '; $this->set_filters($this->default_filters); } $title_array = array(); if ($this->single_post) { // We have requested a specific post: // Should be in first position $Item =& $this->get_by_idx(0); if (is_null($Item)) { $title_array[] = T_('Invalid request'); } else { $title_array[] = $Item->get_titletag(); } return $title_array; } // CATEGORIES: if (!empty($this->filters['cat_array'])) { // We have requested specific categories... $cat_names = array(); $ChapterCache =& get_ChapterCache(); foreach ($this->filters['cat_array'] as $cat_ID) { if (($my_Chapter =& $ChapterCache->get_by_ID($cat_ID, false)) !== false) { // It is almost never meaningful to die over an invalid cat when generating title $cat_names[] = $my_Chapter->name; } } if ($this->filters['cat_modifier'] == '*') { $cat_names_string = implode(' + ', $cat_names); } else { $cat_names_string = implode(', ', $cat_names); } if (!empty($cat_names_string)) { if ($this->filters['cat_modifier'] == '-') { $cat_names_string = T_('All but ') . ' ' . $cat_names_string; $title_array['cats'] = $params['categories_text'] . $cat_names_string; } else { if (count($this->filters['cat_array']) > 1) { $title_array['cats'] = $params['categories_text'] . $cat_names_string; } else { $title_array['cats'] = $params['category_text'] . $cat_names_string; } } } } // ARCHIVE TIMESLOT: if (!empty($this->filters['ymdhms'])) { // We have asked for a specific timeframe: $my_year = substr($this->filters['ymdhms'], 0, 4); if (strlen($this->filters['ymdhms']) > 4) { // We have requested a month too: $my_month = T_($month[substr($this->filters['ymdhms'], 4, 2)]); } else { $my_month = ''; } // Requested a day? $my_day = substr($this->filters['ymdhms'], 6, 2); $arch = T_('Archives for') . ': ' . $my_month . ' ' . $my_year; if (!empty($my_day)) { // We also want to display a day $arch .= ', ' . $my_day; } if (!empty($this->filters['week']) || $this->filters['week'] === 0) { // We also want to display a week number $arch .= ', ' . T_('week') . ' ' . $this->filters['week']; } $title_array['ymdhms'] = $arch; } // KEYWORDS: if (!empty($this->filters['keywords'])) { $title_array['keywords'] = T_('Keyword(s)') . ': ' . $this->filters['keywords']; } // TAGS: if (!empty($this->filters['tags'])) { $title_array[] = $params['tags_text'] . $this->filters['tags']; } // AUTHORS: if (!empty($this->filters['authors']) || !empty($this->filters['authors_login'])) { $authors = trim($this->filters['authors'] . ',' . get_users_IDs_by_logins($this->filters['authors_login']), ','); $authors = preg_split('~\\s*,\\s*~', $authors, -1, PREG_SPLIT_NO_EMPTY); $author_names = array(); if ($authors) { $UserCache =& get_UserCache(); foreach ($authors as $author_ID) { if ($tmp_User = $UserCache->get_by_ID($author_ID, false, false)) { $author_names[] = $tmp_User->get_identity_link(array('link_text' => 'login')); } } } $title_array[] = T_('Author(s)') . ': ' . implode(', ', $author_names); } // ASSIGNEES: if (!empty($this->filters['assignees']) || !empty($this->filters['assignees_login'])) { if ($this->filters['assignees'] == '-') { $title_array[] = T_('Not assigned'); } else { $assignees = trim($this->filters['assignees'] . ',' . get_users_IDs_by_logins($this->filters['assignees_login']), ','); $assignees = preg_split('~\\s*,\\s*~', $assignees, -1, PREG_SPLIT_NO_EMPTY); $assignees_names = array(); if ($assignees) { $UserCache =& get_UserCache(); foreach ($assignees as $user_ID) { if ($tmp_User =& $UserCache->get_by_ID($user_ID, false, false)) { $assignees_names[] = $tmp_User->get_identity_link(array('link_text' => 'login')); } } } $title_array[] = T_('Assigned to') . ': ' . implode(', ', $assignees_names); } } // LOCALE: if ($this->filters['lc'] != 'all') { $title_array[] = T_('Locale') . ': ' . $this->filters['lc']; } // EXTRA STATUSES: if (!empty($this->filters['statuses'])) { if ($this->filters['statuses'] == '-') { $title_array[] = T_('Without status'); } else { $title_array[] = T_('Status(es)') . ': ' . $this->filters['statuses']; } } // SHOW STATUSES if (count($this->filters['visibility_array']) < 5 && !in_array('visibility', $ignore)) { $post_statuses = get_visibility_statuses(); $status_titles = array(); foreach ($this->filters['visibility_array'] as $status) { $status_titles[] = $post_statuses[$status]; } $title_array[] = T_('Visibility') . ': ' . implode(', ', $status_titles); } // START AT if (!empty($this->filters['ymdhms_min'])) { $title_array['ymdhms_min'] = T_('Start at') . ': ' . $this->filters['ymdhms_min']; } if (!empty($this->filters['ts_min'])) { if ($this->filters['ts_min'] == 'now') { $title_array['ts_min'] = T_('Hide past'); } else { $title_array['ts_min'] = T_('Start at') . ': ' . $this->filters['ts_min']; } } // STOP AT if (!empty($this->filters['ymdhms_max'])) { $title_array['ymdhms_max'] = T_('Stop at') . ': ' . $this->filters['ymdhms_max']; } if (!empty($this->filters['ts_max'])) { if ($this->filters['ts_max'] == 'now') { if (!in_array('hide_future', $ignore)) { $title_array['ts_max'] = T_('Hide future'); } } else { $title_array['ts_max'] = T_('Stop at') . ': ' . $this->filters['ts_max']; } } // LIMIT TO if ($this->single_post) { // Single post: no paging required! } elseif (!empty($this->filters['ymdhms'])) { // no restriction if we request a month... some permalinks may point to the archive! } elseif ($this->filters['unit'] == 'posts' || $this->filters['unit'] == 'all') { // We're going to page, so there's no real limit here... } elseif ($this->filters['unit'] == 'days') { // We are going to limit to x days: // echo 'LIMIT DAYS '; if (empty($this->filters['ymdhms_min'])) { // We have no start date, we'll display the last x days: if (!empty($this->filters['keywords']) || !empty($this->filters['cat_array']) || !empty($this->filters['authors'])) { // We are in DAYS mode but we can't restrict on these! (TODO: ?) } else { // We are going to limit to LAST x days: // TODO: rename 'posts' to 'limit' $title_array['posts'] = sprintf(T_('Limited to %d last days'), $this->limit); } } else { // We have a start date, we'll display x days starting from that point: $title_array['posts'] = sprintf(T_('Limited to %d days'), $this->limit); } } else { debug_die('Unhandled LIMITING mode in ItemList:' . $this->filters['unit'] . ' (paged mode is obsolete)'); } return $title_array; }
/** * Initialize list mode; Several actions need this. */ function init_list_mode() { global $tab, $Blog, $UserSettings, $ItemList, $AdminUI, $posttypes_perms; // set default itemslist param prefix $items_list_param_prefix = 'items_'; if (param('p', 'integer', NULL) || param('title', 'string', NULL)) { // Single post requested, do not filter any post types. If the user // has clicked a post link on the dashboard and previously has selected // a tab which would filter this post, it wouldn't be displayed now. $tab = 'full'; // in case of single item view params prefix must be empty $items_list_param_prefix = NULL; } else { // Store/retrieve preferred tab from UserSettings: $UserSettings->param_Request('tab', 'pref_browse_tab', 'string', NULL, true, true); } /* * Init list of posts to display: */ load_class('items/model/_itemlist.class.php', 'ItemList2'); if (!empty($tab) && !empty($items_list_param_prefix)) { // Use different param prefix for each tab $items_list_param_prefix .= substr($tab, 0, 7) . '_'; } // Create empty List: $ItemList = new ItemList2($Blog, NULL, NULL, $UserSettings->get('results_per_page'), 'ItemCache', $items_list_param_prefix, $tab); // COPY (func) $ItemList->set_default_filters(array('visibility_array' => get_visibility_statuses('keys'))); if ($Blog->get_setting('orderby') == 'RAND') { // Do not display random posts in backoffice for easy management $ItemList->set_default_filters(array('orderby' => 'datemodified')); } switch ($tab) { case 'full': $ItemList->set_default_filters(array('types' => NULL)); // $AdminUI->breadcrumbpath_add( T_('All items'), '?ctrl=items&blog=$blog$&tab='.$tab.'&filter=restore' ); // require colorbox js require_js_helper('colorbox'); break; case 'manual': if ($Blog->get('type') != 'manual') { // Display this tab only for manual blogs global $admin_url; header_redirect($admin_url . '?ctrl=items&blog=' . $Blog->ID . '&tab=list&filter=restore'); } $AdminUI->breadcrumbpath_add(T_('Manual Pages'), '?ctrl=items&blog=$blog$&tab=' . $tab . '&filter=restore'); break; case 'list': // Nothing special $AdminUI->breadcrumbpath_add(T_('Regular posts'), '?ctrl=items&blog=$blog$&tab=' . $tab . '&filter=restore'); break; case 'pages': $ItemList->set_default_filters(array('types' => implode(',', $posttypes_perms['page']))); $AdminUI->breadcrumbpath_add(T_('Pages'), '?ctrl=items&blog=$blog$&tab=' . $tab . '&filter=restore'); break; case 'intros': $ItemList->set_default_filters(array('types' => implode(',', $posttypes_perms['intro']))); $AdminUI->breadcrumbpath_add(T_('Intro posts'), '?ctrl=items&blog=$blog$&tab=' . $tab . '&filter=restore'); break; case 'podcasts': $ItemList->set_default_filters(array('types' => implode(',', $posttypes_perms['podcast']))); $AdminUI->breadcrumbpath_add(T_('Podcasts'), '?ctrl=items&blog=$blog$&tab=' . $tab . '&filter=restore'); break; case 'links': $ItemList->set_default_filters(array('types' => '3000')); $AdminUI->breadcrumbpath_add(T_('Links'), '?ctrl=items&blog=$blog$&tab=' . $tab . '&filter=restore'); break; case 'ads': $ItemList->set_default_filters(array('types' => '4000')); $AdminUI->breadcrumbpath_add(T_('Advertisements'), '?ctrl=items&blog=$blog$&tab=' . $tab . '&filter=restore'); break; case 'tracker': // In tracker mode, we want a different default sort: $ItemList->set_default_filters(array('orderby' => 'priority', 'order' => 'ASC')); break; default: // Delete the pref_browse_tab setting so that the default // (full) gets used the next time the user wants to browse // a blog and we don't run into the same error again. $UserSettings->delete('pref_browse_tab'); $UserSettings->dbupdate(); debug_die('Unknown filterset [' . $tab . ']'); } // Init filter params: if (!$ItemList->load_from_Request()) { // If we could not init a filterset from request // typically happens when we could no fall back to previously saved filterset... // echo ' no filterset!'; } }
/** * Generate a title for the current list, depending on its filtering params * * @return array List of titles to display, which are escaped for HTML display */ function get_filter_titles($ignore = array(), $params = array()) { $title_array = array(); if (empty($this->filters)) { // Filters have no been set before, we'll use the default filterset $this->set_filters($this->default_filters); } if (isset($this->filters['statuses'])) { $visibility_statuses = get_visibility_statuses('', array('redirected')); $visibility_array = array(); foreach ($this->filters['statuses'] as $status) { $visibility_array[] = $visibility_statuses[$status]; } $title_array['statuses'] = T_('Visibility') . ': ' . implode(', ', $visibility_array); } if (!empty($this->filters['keywords'])) { $title_array['keywords'] = T_('Keywords') . ': ' . $this->filters['keywords']; } return $title_array; }
unset($edited_IPRange); forget_param('iprange_ID'); $Messages->add(sprintf(T_('Requested «%s» object does not exist any longer.'), T_('IP Range')), 'error'); } } switch ($action) { case 'ban': // only an action if further "actions" given // Check that this action request is not a CSRF hacked request: $Session->assert_received_crumb('antispam'); // Check permission: $current_User->check_perm('spamblacklist', 'edit', true); // TODO: This should become different for 'edit'/'add' perm level - check for 'add' here. $keyword = utf8_substr($keyword, 0, 80); param('delhits', 'integer', 0); $all_statuses = get_visibility_statuses('keys', array('trash', 'redirected')); $delstatuses = array(); foreach ($all_statuses as $status) { // collect which comments should be delteded if (param('del' . $status, 'integer', 0)) { // matching comments with this status should be deleted $delstatuses[] = $status; } } $delcomments = count($delstatuses); param('blacklist_locally', 'integer', 0); param('report', 'integer', 0); // Check if the string is too short, // it has to be a minimum of 5 characters to avoid being too generic if (utf8_strlen($keyword) < 5) { $Messages->add(sprintf(T_('The keyword «%s» is too short, it has to be a minimum of 5 characters!'), htmlspecialchars($keyword)), 'error');
/** * Generic comments/trackbacks/pingbacks counting * * @todo check this in a multiblog page... * @todo This should support visibility: at least in the default front office (_feedback.php), there should only the number of visible comments/trackbacks get used ({@link Item::feedback_link()}). * * @param integer * @param string what to count * @param mixed string or array to count comments with this/these status(es) * @param boolean set true to count expired comments, leave on false otherwise */ function generic_ctp_number($post_id, $mode = 'comments', $status = 'published', $count_expired = false, $filter_by_perm = true) { global $DB, $debug, $postdata, $cache_ctp_number, $preview, $servertimenow, $blog; if ($preview) { // we are in preview mode, no comments yet! return 0; } $show_statuses = is_admin_page() ? get_visibility_statuses('keys', array('trash', 'redirected')) : get_inskin_statuses(); $filter_index = $filter_by_perm ? 0 : 1; if (!isset($cache_ctp_number) || !isset($cache_ctp_number[$filter_index][$post_id])) { // we need a query to count comments $count_SQL = new SQL(); $count_SQL->SELECT('comment_post_ID, comment_type, comment_status, COUNT(*) AS type_count'); $count_SQL->FROM('T_comments'); $count_SQL->GROUP_BY('comment_post_ID, comment_type, comment_status'); if (!empty($blog)) { $count_SQL->WHERE(statuses_where_clause($show_statuses, 'comment_', $blog, 'blog_comment!', $filter_by_perm)); } if (!$count_expired) { $count_SQL->FROM_add('LEFT JOIN T_items__item_settings as expiry_setting ON comment_post_ID = iset_item_ID AND iset_name = "post_expiry_delay"'); $count_SQL->WHERE_and('expiry_setting.iset_value IS NULL OR expiry_setting.iset_value = "" OR TIMESTAMPDIFF(SECOND, comment_date, ' . $DB->quote(date2mysql($servertimenow)) . ') < expiry_setting.iset_value'); } } // init statuses count array $statuses_array = array('published' => 0, 'community' => 0, 'protected' => 0, 'private' => 0, 'review' => 0, 'draft' => 0, 'deprecated' => 0, 'trash' => 0, 'total' => 0); /* * Make sure cache is loaded for current display list: */ if (!isset($cache_ctp_number) || !isset($cache_ctp_number[$filter_index])) { global $postIDlist, $postIDarray; // if( $debug ) echo "LOADING generic_ctp_number CACHE for posts: $postIDlist<br />"; if (!empty($postIDlist)) { foreach ($postIDarray as $tmp_post_id) { // Initializes each post to nocount! $cache_ctp_number[$filter_index][$tmp_post_id] = array('comments' => $statuses_array, 'trackbacks' => $statuses_array, 'pingbacks' => $statuses_array, 'feedbacks' => $statuses_array); } $countall_SQL = $count_SQL; $countall_SQL->WHERE_and('comment_post_ID IN (' . $postIDlist . ')'); foreach ($DB->get_results($countall_SQL->get()) as $row) { // detail by status, tyep and post: $cache_ctp_number[$filter_index][$row->comment_post_ID][$row->comment_type . 's'][$row->comment_status] = $row->type_count; // Total for type on post: $cache_ctp_number[$filter_index][$row->comment_post_ID][$row->comment_type . 's']['total'] += $row->type_count; // Total for status on post: $cache_ctp_number[$filter_index][$row->comment_post_ID]['feedbacks'][$row->comment_status] += $row->type_count; // Total for post: $cache_ctp_number[$filter_index][$row->comment_post_ID]['feedbacks']['total'] += $row->type_count; } } } /* else { echo "cache set"; }*/ if (!isset($cache_ctp_number[$filter_index][$post_id])) { // this should be extremely rare... // echo "CACHE not set for $post_id"; // Initializes post to nocount! $cache_ctp_number[$filter_index][intval($post_id)] = array('comments' => $statuses_array, 'trackbacks' => $statuses_array, 'pingbacks' => $statuses_array, 'feedbacks' => $statuses_array); $count_SQL->WHERE_and('comment_post_ID = ' . intval($post_id)); foreach ($DB->get_results($count_SQL->get()) as $row) { // detail by status, type and post: $cache_ctp_number[$filter_index][$row->comment_post_ID][$row->comment_type . 's'][$row->comment_status] = $row->type_count; // Total for type on post: $cache_ctp_number[$filter_index][$row->comment_post_ID][$row->comment_type . 's']['total'] += $row->type_count; // Total for status on post: $cache_ctp_number[$filter_index][$row->comment_post_ID]['feedbacks'][$row->comment_status] += $row->type_count; // Total for post: $cache_ctp_number[$filter_index][$row->comment_post_ID]['feedbacks']['total'] += $row->type_count; } } if ($mode != 'comments' && $mode != 'trackbacks' && $mode != 'pingbacks') { $mode = 'feedbacks'; } if (is_array($status)) { // $status is an array and probably contains more then one visibility status $result = 0; foreach ($status as $one_status) { if (isset($cache_ctp_number[$filter_index][$post_id][$mode][$one_status])) { $result = $result + $cache_ctp_number[$filter_index][$post_id][$mode][$one_status]; } } } elseif (isset($cache_ctp_number[$filter_index][$post_id][$mode][$status])) { // $status is a string with one visibility status $result = $cache_ctp_number[$filter_index][$post_id][$mode][$status]; } else { // $status is not recognized return total feedback number $result = $cache_ctp_number[$filter_index][$post_id][$mode]['total']; } // pre_dump( $cache_ctp_number[$filter_index][$post_id] ); return $result; }
/** * Get a member param by its name * * @param mixed Name of parameter * @return mixed Value of parameter */ function get($parname) { switch ($parname) { case 't_author': // Text: author $this->get_creator_User(); return $this->creator_User->get('preferredname'); case 't_assigned_to': // Text: assignee if (!$this->get_assigned_User()) { return ''; } return $this->assigned_User->get('preferredname'); case 't_status': // Text status: $post_statuses = get_visibility_statuses(); return $post_statuses[$this->status]; case 't_extra_status': $ItemStatusCache =& get_ItemStatusCache(); if (!($Element =& $ItemStatusCache->get_by_ID($this->pst_ID, true, false))) { // No status: return ''; } return $Element->get_name(); case 't_type': // Post type (name): if (empty($this->ityp_ID)) { return ''; } $ItemTypeCache =& get_ItemTypeCache(); $type_Element =& $ItemTypeCache->get_by_ID($this->ityp_ID); return $type_Element->get_name(); case 't_priority': return $this->priorities[$this->priority]; case 'pingsdone': // Deprecated by fp 2006-08-21 return $this->post_notifications_status == 'finished'; case 'excerpt': return $this->get_excerpt2(); } return parent::get($parname); }
/** * Compare two visibility status in the point of public level * * @param string first_status * @param string second_status * @return integer * 0 if the two statuses have the same public level * 1 if the first status has higher public level * -1 if it first status has lower public level */ function compare_visibility_status($first_status, $second_status) { $status_index = get_visibility_statuses('ordered-index', array()); if (!isset($status_index[$first_status]) || !isset($status_index[$second_status])) { // At least one of the given statuses doesn't exist debug_die('Invalid status given to compare!'); } $first_status_index = $status_index[$first_status]; $second_status_index = $status_index[$second_status]; if ($first_status_index == $second_status_index) { // The two status public level is equal, but note this doesn't mean that the two status must be same! return 0; } return $first_status_index > $second_status_index ? 1 : -1; }
if ($perm_blog_admin) { // Only admin can set this setting to 'Public' $status_options['published'] .= ' [' . T_('Admin') . ']'; } else { // Remove published status for non-admin users unset($status_options['published']); } } // put this on feedback details container, this way it won't be displayed if comment posting is not allowed echo '<div class="feedback_details_container">'; $Form->select_input_array('new_feedback_status', $edited_Blog->get_setting('new_feedback_status'), $status_options, T_('New feedback status'), $newstatus_warning . T_('Logged in users will get the highest possible status allowed by their permissions. Plugins may also override this default.')); echo '</div>'; // Moderation statuses setting $not_moderation_statuses = array_diff(get_visibility_statuses('keys', NULL), get_visibility_statuses('moderation')); // Get moderation statuses with status text $moderation_statuses = get_visibility_statuses('', $not_moderation_statuses); $blog_moderation_statuses = $edited_Blog->get_setting('moderation_statuses'); $checklist_options = array(); foreach ($moderation_statuses as $status => $status_text) { // Add a checklist option for each possible modeartion status $is_checked = strpos($blog_moderation_statuses, $status) !== false; $checklist_options[] = array('notif_' . $status, 1, $status_text, $is_checked); } $Form->checklist($checklist_options, 'moderation_statuses', T_('Comment moderation reminder statuses'), false, false, array('note' => 'Comments with the selected statuses will be notified on the "Send reminders about comments awaiting moderation" scheduled job.')); $Form->radio('comment_quick_moderation', $edited_Blog->get_setting('comment_quick_moderation'), array(array('never', T_('Never')), array('expire', T_('Links expire on first edit action')), array('always', T_('Always available'))), T_('Comment quick moderation'), true); $Form->end_fieldset(); $Form->begin_fieldset(T_('RSS/Atom feeds')); $Form->radio('comment_feed_content', $edited_Blog->get_setting('comment_feed_content'), array(array('none', T_('No feeds')), array('excerpt', T_('Comment excerpts')), array('normal', T_('Standard comment contents'))), T_('Comment feed contents'), true, T_('How much content do you want to make available in comment feeds?')); $Form->text('comments_per_feed', $edited_Blog->get_setting('comments_per_feed'), 4, T_('Comments in feeds'), T_('How many of the latest comments do you want to include in RSS & Atom feeds?'), 4); $Form->end_fieldset(); $Form->begin_fieldset(T_('Subscriptions'));
$AdminUI->append_path_level('comments'); if (empty($tab3)) { $tab3 = 'fullview'; } $AdminUI->set_path('collections', 'comments', $tab3); $comments_list_param_prefix = 'cmnt_'; if (!empty($tab3)) { // Use different param prefix for each tab $comments_list_param_prefix .= $tab3 . '_'; } /* * List of comments to display: */ $CommentList = new CommentList2($Blog, NULL, 'CommentCache', $comments_list_param_prefix, $tab3); // Filter list: $CommentList->set_default_filters(array('statuses' => get_visibility_statuses('keys', array('redirected', 'trash')), 'order' => 'DESC')); $CommentList->load_from_Request(); /** * Mass delete comments */ param('mass_type', 'string', ''); if ($action == 'mass_delete' && !empty($mass_type)) { // Check that this action request is not a CSRF hacked request: $Session->assert_received_crumb('comment'); // Init the comment list query, but don't execute it $CommentList->query_init(); // Set sql query to get deletable comment ids $deletable_comments_query = 'SELECT DISTINCT ' . $CommentList->Cache->dbIDname . ' ' . $CommentList->CommentQuery->get_from() . $CommentList->CommentQuery->get_where(); // Set an action param to display a correct template $process_action = $action; unset($_POST['actionArray']);
/** * Get buttons to change item type * * @param object Item * @param integer Index of the row on page * @return string */ function item_row_status($Item, $index) { global $current_User, $AdminUI, $Blog, $admin_url; if (empty($Blog)) { // global Blog object is not set, e.g. back-office User activity tab $Item->load_Blog(); $blog_ID = $Item->Blog->ID; } else { $blog_ID = $Blog->ID; } // Get those statuses which are not allowed for the current User to create posts in this blog $exclude_statuses = array_merge(get_restricted_statuses($blog_ID, 'blog_post!', 'create'), array('trash')); // Get allowed visibility statuses $status_options = get_visibility_statuses('', $exclude_statuses); if (is_logged_in() && $current_User->check_perm('item_post!CURSTATUS', 'edit', false, $Item) && isset($AdminUI, $AdminUI->skin_name) && $AdminUI->skin_name == 'bootstrap') { // Use dropdown for bootstrap skin and if current user can edit this post $status_icon_options = get_visibility_statuses('icons', $exclude_statuses); $r = '<div class="btn-group ' . ($index > 5 ? 'dropup' : 'dropdown') . ' post_status_dropdown">' . '<button type="button" class="btn btn-sm btn-status-' . $Item->status . ' dropdown-toggle" data-toggle="dropdown" aria-expanded="false" id="post_status_dropdown">' . '<span>' . $status_options[$Item->status] . '</span>' . ' <span class="caret"></span></button>' . '<ul class="dropdown-menu" role="menu" aria-labelledby="post_status_dropdown">'; foreach ($status_options as $status_key => $status_title) { $r .= '<li rel="' . $status_key . '" role="presentation"><a href="' . $admin_url . '?ctrl=items&blog=' . $blog_ID . '&action=update_status&post_ID=' . $Item->ID . '&status=' . $status_key . '&' . url_crumb('item') . '" role="menuitem" tabindex="-1">' . $status_icon_options[$status_key] . ' <span>' . $status_title . '</span></a></li>'; } $r .= '</ul>' . '</div>'; } else { // Display only status badge when user has no permission to edit this post and for chicago skin $r = $Item->get_format_status(array('template' => '<span class="note status_$status$"><span>$status_title$</span></span>')); } return $r; }
} if ($user_has_cat_perms) { // Field to create a new category if current user has the rights $categories[] = array('value' => 'new', 'label' => T_('New') . ':', 'suffix' => '<input type="text" id="new_categories[' . $post_counter . ']" name="new_categories[' . $post_counter . ']" class="form_text_input" maxlength="255" size="25" />'); } $Form->radio_input('category[' . $post_counter . ']', $selected_category_ID, $categories, T_('Category'), array('suffix' => '<br />')); // Clear last option to create a new for next item with other $post_counter array_pop($categories); $Form->info(T_('Post content'), '<img src="' . $fm_FileRoot->ads_url . urldecode($item) . '" width="200" />'); $Form->end_fieldset(); $post_counter++; } $edited_Item = NULL; $visibility_statuses = get_visibility_statuses('notes-string', array(), true, $blog); if (empty($visibility_statuses)) { $visibility_statuses = get_visibility_statuses('notes-string'); if (isset($visibility_statuses[$Blog->get_setting('default_post_status')])) { // Current user can create a post only with default status $Form->info(T_('Status of new posts'), $visibility_statuses[$Blog->get_setting('default_post_status')]); } } else { // Display a list with the post statuses $Form->select_input_array('post_status', $Blog->get_setting('default_post_status'), $visibility_statuses, T_('Status of new posts')); } $Form->end_form(array(array('submit', 'actionArray[make_posts_from_files]', T_('Make posts'), 'ActionButton'))); ?> <script type="text/javascript"> jQuery( 'input[id^=new_categories]' ).focus( function() { var num = jQuery( this ).attr( 'id' ).replace( /new_categories\[(\d+)\]/gi, '$1' ); jQuery( 'input[name=category\\[' + num + '\\]]' ).attr( 'checked', 'checked' );
/** * Display CommentList with the given filters * * @param integer Blog ID * @param integer Item ID * @param array Status filters * @param integer Limit * @param array Comments IDs string to exclude from the list * @param string Filterset name * @param string Expiry status: 'all', 'active', 'expired' */ function echo_item_comments($blog_ID, $item_ID, $statuses = NULL, $currentpage = 1, $limit = 20, $comment_IDs = array(), $filterset_name = '', $expiry_status = 'active') { global $inc_path, $status_list, $Blog, $admin_url; $BlogCache =& get_BlogCache(); $Blog =& $BlogCache->get_by_ID($blog_ID, false, false); global $CommentList; $CommentList = new CommentList2($Blog, $limit, 'CommentCache', '', $filterset_name); $exlude_ID_list = NULL; if (!empty($comment_IDs)) { $exlude_ID_list = '-' . implode(",", $comment_IDs); } if (empty($statuses)) { $statuses = get_visibility_statuses('keys', array('redirected', 'trash')); } if ($expiry_status == 'all') { // Display all comments $expiry_statuses = array('active', 'expired'); } else { // Display active or expired comments $expiry_statuses = array($expiry_status); } // if item_ID == -1 then don't use item filter! display all comments from current blog if ($item_ID == -1) { $item_ID = NULL; } // set redirect_to if ($item_ID != null) { // redirect to the items full view param('redirect_to', 'url', url_add_param($admin_url, 'ctrl=items&blog=' . $blog_ID . '&p=' . $item_ID, '&')); param('item_id', 'integer', $item_ID); param('currentpage', 'integer', $currentpage); if (count($statuses) == 1) { $show_comments = $statuses[0]; } else { $show_comments = 'all'; } param('comments_number', 'integer', generic_ctp_number($item_ID, 'comments', $show_comments)); // Filter list: $CommentList->set_filters(array('types' => array('comment', 'trackback', 'pingback'), 'statuses' => $statuses, 'expiry_statuses' => $expiry_statuses, 'comment_ID_list' => $exlude_ID_list, 'post_ID' => $item_ID, 'order' => 'ASC', 'comments' => $limit, 'page' => $currentpage)); } else { // redirect to the comments full view param('redirect_to', 'url', url_add_param($admin_url, 'ctrl=comments&blog=' . $blog_ID . '&filter=restore', '&')); // this is an ajax call we always have to restore the filterst (we can set filters only without ajax call) $CommentList->set_filters(array('types' => array('comment', 'trackback', 'pingback'))); $CommentList->restore_filterset(); } // Get ready for display (runs the query): $CommentList->display_init(); $CommentList->display_if_empty(array('before' => '<div class="bComment"><p>', 'after' => '</p></div>', 'msg_empty' => T_('No feedback for this post yet...'))); // display comments require $inc_path . 'comments/views/_comment_list.inc.php'; }
$comment_date_input = $Form->date_input('comment_issue_date', $edited_Comment->date, ''); $comment_date_input .= $Form->time_input('comment_issue_time', $edited_Comment->date, ''); $Form->switch_template_parts($disp_params['edit_form_params']); $Form->info(T_('Comment date'), $comment_date_input, ''); } if ($comment_Item->can_rate() || !empty($edited_Comment->rating)) { // Rating is editable $edit_form_params = $disp_params['edit_form_params']; $before_rating = $edit_form_params['fieldstart'] . $edit_form_params['labelstart'] . T_('Rating') . $edit_form_params['labelend'] . $edit_form_params['inputstart']; $after_rating = $edit_form_params['inputend'] . $edit_form_params['fieldend']; $edited_Comment->rating_input(array('before' => $before_rating, 'after' => $after_rating)); } // Get those statuses which are not allowed for the current User to create comments in this blog $exclude_statuses = array_merge(get_restricted_statuses($Blog->ID, 'blog_comment!', 'edit'), array('redirected', 'trash')); // Get allowed visibility statuses $sharing_options = get_visibility_statuses('radio-options', $exclude_statuses); if (count($sharing_options) == 1) { // Only one visibility status is available, don't show radio but set hidden field $Form->hidden('comment_status', $sharing_options[0][0]); } else { // Display visibiliy options $Form->radio('comment_status', $edited_Comment->status, $sharing_options, T_('Visibility'), true); } // Display renderers $comment_renderer_checkboxes = $edited_Comment->renderer_checkboxes(NULL, false); if (!empty($comment_renderer_checkboxes)) { $Form->info(T_('Text Renderers'), $comment_renderer_checkboxes); } // Display comment attachments $LinkOwner = new LinkComment($edited_Comment); if ($LinkOwner->count_links()) {
<?php $Form->end_fieldset(); } // ####################### PLUGIN FIELDSETS ######################### $Plugins->trigger_event('AdminDisplayItemFormFieldset', array('Form' => &$Form, 'Item' => &$edited_Item, 'edit_layout' => 'expert')); if ($current_User->check_perm('meta_comment', 'view', false, $edited_Item)) { // ####################### META COMMENTS ######################### $currentpage = param('currentpage', 'integer', 1); $total_comments_number = generic_ctp_number($edited_Item->ID, 'metas', 'total'); param('comments_number', 'integer', $total_comments_number); param('comment_type', 'string', 'meta'); $Form->begin_fieldset(T_('Meta comments') . get_manual_link('meta-comments-panel') . ($total_comments_number > 0 ? ' <span class="badge badge-important">' . $total_comments_number . '</span>' : ''), array('id' => 'itemform_meta_cmnt', 'fold' => true, 'deny_fold' => $total_comments_number > 0)); global $CommentList, $UserSettings; $CommentList = new CommentList2($Blog); // Filter list: $CommentList->set_filters(array('types' => array('meta'), 'statuses' => get_visibility_statuses('keys', array('redirected', 'trash')), 'order' => 'DESC', 'post_ID' => $edited_Item->ID, 'comments' => $UserSettings->get('results_per_page'), 'page' => $currentpage, 'expiry_statuses' => array('active'))); $CommentList->query(); // comments_container value shows, current Item ID echo '<div class="evo_content_block">'; echo '<div id="comments_container" value="' . $edited_Item->ID . '">'; // display comments $CommentList->display_if_empty(array('before' => '<div class="bComment"><p>', 'after' => '</p></div>', 'msg_empty' => T_('No feedback for this post yet...'))); require $inc_path . 'comments/views/_comment_list.inc.php'; echo '</div>'; // comments_container div echo '</div>'; if ($current_User->check_perm('meta_comment', 'add', false, $edited_Item)) { // Display a link to add new meta comment if current user has a permission echo action_icon(T_('Add meta comment') . '...', 'new', $admin_url . '?ctrl=items&p=' . $edited_Item->ID . '&comment_type=meta&blog=' . $Blog->ID . '#comments', T_('Add meta comment') . ' »', 3, 4); } // Load JS functions to work with meta comments:
/** * Restrict to specific statuses * * @param string List of statuses to restrict to (must have been previously validated) * @param boolean Filter by user permission. Set to false to select each comment with the correspondong visibily statuses even if current User has no permission to view them. */ function where_statuses($show_statuses, $filter_by_perm = true) { global $DB; if (empty($show_statuses)) { // initialize if emty $show_statuses = get_visibility_statuses('keys', array('trash', 'redirected')); } $this->show_statuses = $show_statuses; if ($filter_by_perm) { // show not published comments corresponding to the given blog perms // When Blog is empty we must set blog param to 0, this way we will check all blogs $blog = empty($this->Blog) ? 0 : $this->Blog->ID; $this->WHERE_and(statuses_where_clause($this->show_statuses, $this->dbprefix, $blog, 'blog_comment!', true, $this->author)); } else { $list = ''; $sep = ''; foreach ($show_statuses as $status) { $list .= $sep . $DB->quote($status); $sep = ','; } $this->WHERE_and($this->dbprefix . 'status IN (' . $list . ')'); } }
<?php /** * This file implements the Item history details view * * This file is part of the b2evolution/evocms project - {@link http://b2evolution.net/}. * See also {@link https://github.com/b2evolution/b2evolution}. * * @license GNU GPL v2 - {@link http://b2evolution.net/about/gnu-gpl-license} * * @copyright (c)2003-2015 by Francois Planque - {@link http://fplanque.com/}. * * @package admin */ if (!defined('EVO_MAIN_INIT')) { die('Please, do not access this page directly.'); } global $edited_Item, $Revision; $post_statuses = get_visibility_statuses(); $Form = new Form(NULL, 'history', 'post', 'compact'); $Form->global_icon(T_('Cancel viewing!'), 'close', regenerate_url('action', 'action=history')); $Form->begin_form('fform', sprintf(T_('Revision #%s for: %s'), $Revision->iver_ID == 0 ? '(' . T_('Current version') . ')' : $Revision->iver_ID, $edited_Item->get_title())); $Form->info(T_('Date'), mysql2localedatetime($Revision->iver_edit_datetime, 'Y-m-d', 'H:i:s')); $iver_editor_user_link = get_user_identity_link(NULL, $Revision->iver_edit_user_ID); $Form->info(T_('User'), empty($iver_editor_user_link) ? T_('(deleted user)') : $iver_editor_user_link); $Form->info(T_('Status'), $post_statuses[$Revision->iver_status]); $Form->info(T_('Note'), $Revision->iver_ID > 0 ? T_('Archived version') : T_('Current version')); $Form->info(T_('Title'), $Revision->iver_title); $Form->info(T_('Content'), $Revision->iver_content); $Form->end_form();
/** * Check if the user has the given role in any blog * * @param string role name, available values ( post_owner, moderator ) * @return mixed NULL if the given roll name is not defined or there are no blogs, true if the user is super admin, 0 if the user doesn't have the given role, positive number otherwise */ function check_role($rolename) { global $DB; if ($this->check_perm('blogs', 'editall')) { // if user has global editall blogs permission then it has any kind of role in all blogs return true; } switch ($rolename) { case 'post_owner': // User is considerated as a post owner, if already has at least one post, or he has right to create posts if ($this->get_num_posts() > 0) { // User already has at least one post return true; } $role_conditions = array('perm_poststatuses' => array('IS NOT NULL', '<> ""')); break; case 'member': // User has member role if is member of at least one blog $role_conditions = array('ismember' => array('IS NOT NULL', '<> 0')); break; case 'comment_editor': // User has permission to edit some other users comments at least in one status $role_conditions = array('perm_edit_cmt' => array('IS NOT NULL', '<> "no"', '<> "own"'), 'perm_cmtstatuses' => array('IS NOT NULL', '<> 0')); break; case 'comment_moderator': // set comment moderator perm names $edit_perm_name = 'perm_edit_cmt'; $statuses_perm_name = 'perm_cmtstatuses'; case 'post_moderator': if ($rolename == 'post_moderator') { // set post moderator perm names $edit_perm_name = 'perm_edit'; $statuses_perm_name = 'perm_poststatuses'; } // User is a moderator if has moderator permission at least in one blog // A moderator must have permissions to create post/comment with at least two statuses from moderation statuses + published status $check_statuses = get_visibility_statuses('moderation'); // Create addition of statuses perm values $perms_value = get_status_permvalue('published'); foreach ($check_statuses as $status) { $perms_value = $perms_value + get_status_permvalue($status); } // Check if user has permission to edit other comments than his own and has create permission on at least two statuses defined above $role_conditions = array($edit_perm_name => array('IS NOT NULL', '<> "no"', '<> "own"'), $statuses_perm_name => array('IS NOT NULL', 'BIT_COUNT( $perm_field$ & ' . $perms_value . ' ) > 1')); break; default: // roll with the given roll name is not defined return NULL; } $where_clause = ''; $perm_prefixes = array('bloguser_', 'bloggroup_'); foreach ($perm_prefixes as $prefix) { // Check requred perms on blogusers and bloggroups as well $where_part = ''; foreach ($role_conditions as $perm_name => $conditions) { // Go through each required permission $perm_field = $prefix . $perm_name; foreach ($conditions as $condition) { // Check all defined conditions and join with 'AND' operator if (strpos($condition, '$perm_field$') !== false) { // The $perm_filed must be replaced in the middle of the condition $where_part .= '( ' . str_replace('$perm_field$', $perm_field, $condition) . ' ) AND '; } else { // The $perm_filed must be added into the beginning of the condition $where_part .= '( ' . $perm_field . ' ' . $condition . ' ) AND '; } } } // Remove the last ' AND ' from the end of this where clause part $where_part = substr($where_part, 0, strlen($where_part) - 5); // Add the created conditions to the final where clause $where_clause .= '( ' . $where_part . ' )'; if ($prefix != 'bloggroup_') { // 'bloggroup_' perm check is the last, but everywhere else we need an 'OR' operator $where_clause .= ' OR '; } } // Count blog ids where this user has the required permissions for the given role $SQL = new SQL(); $SQL->SELECT('count( blog_ID )'); $SQL->FROM('T_blogs'); $SQL->FROM_add('LEFT JOIN T_coll_user_perms ON (blog_advanced_perms <> 0 AND blog_ID = bloguser_blog_ID AND bloguser_user_ID = ' . $this->ID . ' )'); $SQL->FROM_add('LEFT JOIN T_coll_group_perms ON (blog_advanced_perms <> 0 AND blog_ID = bloggroup_blog_ID AND bloggroup_group_ID = ' . $this->grp_ID . ' )'); $SQL->WHERE('blog_owner_user_ID = ' . $this->ID); $SQL->WHERE_or($where_clause); return $DB->get_var($SQL->get(), 0, NULL, 'Check user role in all blogs'); }
/** * Load items by the given categories or collection ID * After the Items are loaded create a map of loaded items by categories * * @param array of category ids * @param integer collection ID * @return boolean true if load items was required and it was loaded successfully, false otherwise */ function load_by_categories($cat_array, $coll_ID) { global $DB, $posttypes_specialtypes; if (empty($cat_array) && empty($coll_ID)) { // Nothing to load return false; } // In case of an empty cat_array param, use categoriesfrom the given collection if (empty($cat_array)) { // Get all categories from the given subset $ChapterCache =& get_ChapterCache(); $subset_chapters = $ChapterCache->get_chapters_by_subset($coll_ID); $cat_array = array(); foreach ($subset_chapters as $Chapter) { $cat_array[] = $Chapter->ID; } } // Check which category is not loaded $not_loaded_cat_ids = array(); foreach ($cat_array as $cat_ID) { if (!isset($this->items_by_cat_map[$cat_ID])) { // This category is not loaded $not_loaded_cat_ids[] = $cat_ID; // Initialize items_by_cat_map for this cat_ID $this->items_by_cat_map[$cat_ID] = array('items' => array(), 'sorted' => false); } } if (empty($not_loaded_cat_ids)) { // Requested categories items are all loaded return false; } // Query to load all Items from the given categories $sql = 'SELECT postcat_cat_ID as cat_ID, postcat_post_ID as post_ID FROM T_postcats WHERE postcat_cat_ID IN ( ' . implode(', ', $not_loaded_cat_ids) . ' ) ORDER BY postcat_post_ID'; $cat_posts = $DB->get_results($sql, ARRAY_A, 'Get all category post ids pair by category'); // Initialize $Blog from coll_ID $BlogCache =& get_BlogCache(); $Blog = $BlogCache->get_by_ID($coll_ID); $visibility_statuses = is_admin_page() ? get_visibility_statuses('keys', array('trash')) : get_inskin_statuses($coll_ID, 'post'); // Create ItemQuery for loading visible items $ItemQuery = new ItemQuery($this->dbtablename, $this->dbprefix, $this->dbIDname); // Set filters what to select $ItemQuery->SELECT($this->dbtablename . '.*'); $ItemQuery->where_chapter2($Blog, $not_loaded_cat_ids, ""); $ItemQuery->where_visibility($visibility_statuses); $ItemQuery->where_datestart(NULL, NULL, NULL, NULL, $Blog->get_timestamp_min(), $Blog->get_timestamp_max()); $ItemQuery->where_types('-' . implode(',', $posttypes_specialtypes)); // Clear previous items from the cache and load by the defined SQL $this->clear(true); $this->load_by_sql($ItemQuery); foreach ($cat_posts as $row) { // Iterate through the post - cat pairs and fill the map if (empty($this->cache[$row['post_ID']])) { // The Item was not loaded because it does not correspond to the defined filters continue; } // Add to the map $this->items_by_cat_map[$row['cat_ID']]['items'][] = $this->get_by_ID($row['post_ID']); } }
/** * Get post status label from DB value * * @param string Status value * @return string Status label */ function iver_status_label($iver_status) { $statuses = get_visibility_statuses(); return isset($statuses[$iver_status]) ? $statuses[$iver_status] : $iver_status; }
} } $posts_awaiting_moderation_content = ob_get_contents(); ob_clean(); if (!empty($posts_awaiting_moderation_content)) { echo '<div class="items_container evo_content_block">'; echo $posts_awaiting_moderation_content; echo '</div>'; } /* * RECENTLY EDITED */ // Create empty List: $ItemList = new ItemList2($Blog, NULL, NULL); // Filter list: $ItemList->set_filters(array('visibility_array' => get_visibility_statuses('keys', array('trash')), 'orderby' => 'datemodified', 'order' => 'DESC', 'posts' => 5)); // Get ready for display (runs the query): $ItemList->display_init(); if ($ItemList->result_num_rows) { // We have recent edits $nb_blocks_displayed++; if ($current_User->check_perm('blog_post_statuses', 'edit', false, $Blog->ID)) { // We have permission to add a post with at least one status: $block_item_Widget->global_icon(T_('Write a new post...'), 'new', '?ctrl=items&action=new&blog=' . $Blog->ID, T_('New post') . ' »', 3, 4, array('class' => 'action_icon btn-primary')); } echo '<div class="items_container evo_content_block">'; $block_item_Widget->title = T_('Recently edited'); $block_item_Widget->disp_template_replaced('block_start'); while ($Item =& $ItemList->get_item()) { echo '<div class="dashboard_post dashboard_post_' . ($ItemList->current_idx % 2 ? 'even' : 'odd') . '" lang="' . $Item->get('locale') . '">'; // We don't switch locales in the backoffice, since we use the user pref anyway
/** * Load data from Request form fields. * * @param array groups of params to load * @return boolean true if loaded data seems valid. */ function load_from_Request($groups = array()) { global $Messages, $default_locale, $DB; /** * @var User */ global $current_User; // Load collection settings and clear update cascade array $this->load_CollectionSettings(); $this->CollectionSettings->clear_update_cascade(); if (param('blog_name', 'string', NULL) !== NULL) { // General params: $this->set_from_Request('name'); $this->set('shortname', param('blog_shortname', 'string', true)); $this->set('locale', param('blog_locale', 'string', $default_locale)); } if (param('archive_links', 'string', NULL) !== NULL) { // Archive link type: $this->set_setting('archive_links', get_param('archive_links')); $this->set_setting('archive_posts_per_page', param('archive_posts_per_page', 'integer', NULL), true); } if (param('chapter_links', 'string', NULL) !== NULL) { // Chapter link type: $this->set_setting('chapter_links', get_param('chapter_links')); } if (param('category_prefix', 'string', NULL) !== NULL) { $category_prefix = get_param('category_prefix'); if (!preg_match('|^([A-Za-z0-9\\-_]+(/[A-Za-z0-9\\-_]+)*)?$|', $category_prefix)) { param_error('category_prefix', T_('Invalid category prefix.')); } $this->set_setting('category_prefix', $category_prefix); } if (param('atom_redirect', 'string', NULL) !== NULL) { param_check_url('atom_redirect', 'commenting'); $this->set_setting('atom_redirect', get_param('atom_redirect')); param('rss2_redirect', 'string', NULL); param_check_url('rss2_redirect', 'commenting'); $this->set_setting('rss2_redirect', get_param('rss2_redirect')); } if (param('image_size', 'string', NULL) !== NULL) { $this->set_setting('image_size', get_param('image_size')); } if (param('tag_links', 'string', NULL) !== NULL) { // Tag page link type: $this->set_setting('tag_links', get_param('tag_links')); } if (param('tag_prefix', 'string', NULL) !== NULL) { $tag_prefix = get_param('tag_prefix'); if (!preg_match('|^([A-Za-z0-9\\-_]+(/[A-Za-z0-9\\-_]+)*)?$|', $tag_prefix)) { param_error('tag_prefix', T_('Invalid tag prefix.')); } $this->set_setting('tag_prefix', $tag_prefix); } // Default to "tag", if "prefix-only" is used, but no tag_prefix was provided. if (get_param('tag_links') == 'prefix-only' && !strlen(param('tag_prefix', 'string', NULL))) { $this->set_setting('tag_prefix', 'tag'); } // Use rel="tag" attribute? (checkbox) $this->set_setting('tag_rel_attib', param('tag_rel_attib', 'integer', 0)); if (param('chapter_content', 'string', NULL) !== NULL) { // What kind of content on chapter pages? $this->set_setting('chapter_content', get_param('chapter_content')); } if (param('tag_content', 'string', NULL) !== NULL) { // What kind of content on tags pages? $this->set_setting('tag_content', get_param('tag_content')); } if (param('archive_content', 'string', NULL) !== NULL) { // What kind of content on archive pages? $this->set_setting('archive_content', get_param('archive_content')); } if (param('filtered_content', 'string', NULL) !== NULL) { // What kind of content on filtered pages? $this->set_setting('filtered_content', get_param('filtered_content')); } if (param('main_content', 'string', NULL) !== NULL) { // What kind of content on main pages? $this->set_setting('main_content', get_param('main_content')); } // Chapter posts per page: $this->set_setting('chapter_posts_per_page', param('chapter_posts_per_page', 'integer', NULL), true); // Tag posts per page: $this->set_setting('tag_posts_per_page', param('tag_posts_per_page', 'integer', NULL), true); if (param('single_links', 'string', NULL) !== NULL) { // Single post link type: $this->set_setting('single_links', get_param('single_links')); } if (param('slug_limit', 'integer', NULL) !== NULL) { // Limit slug length: $this->set_setting('slug_limit', get_param('slug_limit')); } if (param('normal_skin_ID', 'integer', NULL) !== NULL) { // Default blog: $this->set_setting('normal_skin_ID', get_param('normal_skin_ID')); } if (param('mobile_skin_ID', 'integer', NULL) !== NULL) { // Default blog: $this->set_setting('mobile_skin_ID', get_param('mobile_skin_ID')); } if (param('tablet_skin_ID', 'integer', NULL) !== NULL) { // Default blog: $this->set_setting('tablet_skin_ID', get_param('tablet_skin_ID')); } if (param('archives_sort_order', 'string', NULL) !== NULL) { $this->set_setting('archives_sort_order', param('archives_sort_order', 'string', false)); } if (param('feed_content', 'string', NULL) !== NULL) { // How much content in feeds? $this->set_setting('feed_content', get_param('feed_content')); param_integer_range('posts_per_feed', 1, 9999, T_('Items per feed must be between %d and %d.')); $this->set_setting('posts_per_feed', get_param('posts_per_feed')); } if (param('comment_feed_content', 'string', NULL) !== NULL) { // How much content in comment feeds? $this->set_setting('comment_feed_content', get_param('comment_feed_content')); param_integer_range('comments_per_feed', 1, 9999, T_('Comments per feed must be between %d and %d.')); $this->set_setting('comments_per_feed', get_param('comments_per_feed')); } if (param('require_title', 'string', NULL) !== NULL) { // Title for items required? $this->set_setting('require_title', get_param('require_title')); } if (param('blog_description', 'string', NULL) !== NULL) { // Description: $this->set_from_Request('shortdesc', 'blog_description'); } if (param('blog_keywords', 'string', NULL) !== NULL) { // Keywords: $this->set_from_Request('keywords'); } if (param('blog_tagline', 'html', NULL) !== NULL) { // HTML tagline: param_check_html('blog_tagline', T_('Invalid tagline')); $this->set('tagline', get_param('blog_tagline')); } if (param('blog_longdesc', 'html', NULL) !== NULL) { // HTML long description: param_check_html('blog_longdesc', T_('Invalid long description')); $this->set('longdesc', get_param('blog_longdesc')); } if (param('blog_footer_text', 'html', NULL) !== NULL) { // Blog footer: param_check_html('blog_footer_text', T_('Invalid blog footer')); $this->set_setting('blog_footer_text', get_param('blog_footer_text')); } if (param('single_item_footer_text', 'html', NULL) !== NULL) { // Blog footer: param_check_html('single_item_footer_text', T_('Invalid single post footer')); $this->set_setting('single_item_footer_text', get_param('single_item_footer_text')); } if (param('xml_item_footer_text', 'html', NULL) !== NULL) { // Blog footer: param_check_html('xml_item_footer_text', T_('Invalid RSS footer')); $this->set_setting('xml_item_footer_text', get_param('xml_item_footer_text')); } if (param('blog_notes', 'html', NULL) !== NULL) { // HTML notes: param_check_html('blog_notes', T_('Invalid Blog Notes')); $this->set('notes', get_param('blog_notes')); param_integer_range('max_footer_credits', 0, 3, T_('Max credits must be between %d and %d.')); $this->set_setting('max_footer_credits', get_param('max_footer_credits')); } if (in_array('pings', $groups)) { // we want to load the ping checkboxes: $blog_ping_plugins = param('blog_ping_plugins', 'array/string', array()); $blog_ping_plugins = array_unique($blog_ping_plugins); $this->set_setting('ping_plugins', implode(',', $blog_ping_plugins)); } if (in_array('authors', $groups)) { // we want to load the multiple authors params $this->set('advanced_perms', param('advanced_perms', 'integer', 0)); $this->set_setting('use_workflow', param('blog_use_workflow', 'integer', 0)); } if (in_array('features', $groups)) { // we want to load the workflow checkboxes: $this->set_setting('allow_html_post', param('allow_html_post', 'integer', 0)); $this->set_setting('enable_goto_blog', param('enable_goto_blog', 'string', NULL)); $this->set_setting('editing_goto_blog', param('editing_goto_blog', 'string', NULL)); $this->set_setting('default_post_status', param('default_post_status', 'string', NULL)); $this->set_setting('post_categories', param('post_categories', 'string', NULL)); $this->set_setting('post_navigation', param('post_navigation', 'string', NULL)); // Show x days or x posts?: $this->set_setting('what_to_show', param('what_to_show', 'string', '')); param_integer_range('posts_per_page', 1, 9999, T_('Items/days per page must be between %d and %d.')); $this->set_setting('posts_per_page', get_param('posts_per_page')); $this->set_setting('orderby', param('orderby', 'string', true)); $this->set_setting('orderdir', param('orderdir', 'string', true)); // Time frame $this->set_setting('timestamp_min', param('timestamp_min', 'string', '')); $this->set_setting('timestamp_min_duration', param_duration('timestamp_min_duration')); $this->set_setting('timestamp_max', param('timestamp_max', 'string', '')); $this->set_setting('timestamp_max_duration', param_duration('timestamp_max_duration')); // Location $location_country = param('location_country', 'string', 'hidden'); $location_region = param('location_region', 'string', 'hidden'); $location_subregion = param('location_subregion', 'string', 'hidden'); $location_city = param('location_city', 'string', 'hidden'); if ($location_city == 'required') { // If city is required - all location fields also are required $location_country = $location_region = $location_subregion = 'required'; } else { if ($location_subregion == 'required') { // If subregion is required - country & region fields also are required $location_country = $location_region = 'required'; } else { if ($location_region == 'required') { // If region is required - country field also is required $location_country = 'required'; } } } $this->set_setting('location_country', $location_country); $this->set_setting('location_region', $location_region); $this->set_setting('location_subregion', $location_subregion); $this->set_setting('location_city', $location_city); // Set to show Latitude & Longitude params for this blog items $this->set_setting('show_location_coordinates', param('show_location_coordinates', 'integer', 0)); // Load custom double & varchar fields $custom_field_names = array(); $this->load_custom_fields('double', $update_cascade_query, $custom_field_names); $this->load_custom_fields('varchar', $update_cascade_query, $custom_field_names); if (!empty($update_cascade_query)) { // Some custom fields were deleted and these fields must be deleted from the item settings table also. Add required query. $this->CollectionSettings->add_update_cascade($update_cascade_query); } // call modules update_collection_features on this blog modules_call_method('update_collection_features', array('edited_Blog' => &$this)); } if (in_array('comments', $groups)) { // we want to load the workflow checkboxes: // load moderation statuses $moderation_statuses = get_visibility_statuses('moderation'); $blog_moderation_statuses = array(); foreach ($moderation_statuses as $status) { if (param('notif_' . $status, 'integer', 0)) { $blog_moderation_statuses[] = $status; } } $this->set_setting('moderation_statuses', implode(',', $blog_moderation_statuses)); $this->set_setting('comment_quick_moderation', param('comment_quick_moderation', 'string', 'expire')); $this->set_setting('allow_item_subscriptions', param('allow_item_subscriptions', 'integer', 0)); $this->set_setting('comments_detect_email', param('comments_detect_email', 'integer', 0)); $this->set_setting('comments_register', param('comments_register', 'integer', 0)); } if (in_array('other', $groups)) { // we want to load the workflow checkboxes: $this->set_setting('enable_sitemaps', param('enable_sitemaps', 'integer', 0)); $this->set_setting('allow_subscriptions', param('allow_subscriptions', 'integer', 0)); $this->set_setting('allow_item_subscriptions', param('allow_item_subscriptions', 'integer', 0)); // Public blog list $this->set('in_bloglist', param('blog_in_bloglist', 'integer', 0)); $this->set_setting('image_size_user_list', param('image_size_user_list', 'string')); $this->set_setting('image_size_messaging', param('image_size_messaging', 'string')); $this->set_setting('archive_mode', param('archive_mode', 'string', true)); } if (param('allow_comments', 'string', NULL) !== NULL) { // Feedback options: $this->set_setting('allow_comments', param('allow_comments', 'string', 'any')); $this->set_setting('allow_view_comments', param('allow_view_comments', 'string', 'any')); $new_feedback_status = param('new_feedback_status', 'string', 'draft'); if ($new_feedback_status != $this->get_setting('new_feedback_status') && ($new_feedback_status != 'published' || $current_User->check_perm('blog_admin', 'edit', false, $this->ID))) { // Only admin can set this setting to 'Public' $this->set_setting('new_feedback_status', $new_feedback_status); } $this->set_setting('disable_comments_bypost', param('disable_comments_bypost', 'string', '0')); $this->set_setting('allow_anon_url', param('allow_anon_url', 'string', '0')); $this->set_setting('allow_html_comment', param('allow_html_comment', 'string', '0')); $this->set_setting('allow_attachments', param('allow_attachments', 'string', 'registered')); $this->set_setting('max_attachments', param('max_attachments', 'integer', '')); $this->set_setting('allow_rating_items', param('allow_rating_items', 'string', 'never')); $this->set_setting('rating_question', param('rating_question', 'text')); $this->set_setting('allow_rating_comment_helpfulness', param('allow_rating_comment_helpfulness', 'string', '0')); $blog_allowtrackbacks = param('blog_allowtrackbacks', 'integer', 0); if ($blog_allowtrackbacks != $this->get('allowtrackbacks') && ($blog_allowtrackbacks == 0 || $current_User->check_perm('blog_admin', 'edit', false, $this->ID))) { // Only admin can turn ON this setting $this->set('allowtrackbacks', $blog_allowtrackbacks); } $this->set_setting('comments_orderdir', param('comments_orderdir', '/^(?:ASC|DESC)$/', 'ASC')); // call modules update_collection_comments on this blog modules_call_method('update_collection_comments', array('edited_Blog' => &$this)); $threaded_comments = param('threaded_comments', 'integer', 0); $this->set_setting('threaded_comments', $threaded_comments); $this->set_setting('paged_comments', $threaded_comments ? 0 : param('paged_comments', 'integer', 0)); param_integer_range('comments_per_page', 1, 9999, T_('Comments per page must be between %d and %d.')); $this->set_setting('comments_per_page', get_param('comments_per_page')); $this->set_setting('comments_avatars', param('comments_avatars', 'integer', 0)); $this->set_setting('comments_latest', param('comments_latest', 'integer', 0)); } if (in_array('seo', $groups)) { // we want to load the workflow checkboxes: $this->set_setting('canonical_homepage', param('canonical_homepage', 'integer', 0)); $this->set_setting('relcanonical_homepage', param('relcanonical_homepage', 'integer', 0)); $this->set_setting('canonical_item_urls', param('canonical_item_urls', 'integer', 0)); $this->set_setting('relcanonical_item_urls', param('relcanonical_item_urls', 'integer', 0)); $this->set_setting('canonical_archive_urls', param('canonical_archive_urls', 'integer', 0)); $this->set_setting('relcanonical_archive_urls', param('relcanonical_archive_urls', 'integer', 0)); $this->set_setting('canonical_cat_urls', param('canonical_cat_urls', 'integer', 0)); $this->set_setting('relcanonical_cat_urls', param('relcanonical_cat_urls', 'integer', 0)); $this->set_setting('canonical_tag_urls', param('canonical_tag_urls', 'integer', 0)); $this->set_setting('relcanonical_tag_urls', param('relcanonical_tag_urls', 'integer', 0)); $this->set_setting('default_noindex', param('default_noindex', 'integer', 0)); $this->set_setting('paged_noindex', param('paged_noindex', 'integer', 0)); $this->set_setting('paged_nofollowto', param('paged_nofollowto', 'integer', 0)); $this->set_setting('archive_noindex', param('archive_noindex', 'integer', 0)); $this->set_setting('archive_nofollowto', param('archive_nofollowto', 'integer', 0)); $this->set_setting('chapter_noindex', param('chapter_noindex', 'integer', 0)); $this->set_setting('tag_noindex', param('tag_noindex', 'integer', 0)); $this->set_setting('filtered_noindex', param('filtered_noindex', 'integer', 0)); $this->set_setting('arcdir_noindex', param('arcdir_noindex', 'integer', 0)); $this->set_setting('catdir_noindex', param('catdir_noindex', 'integer', 0)); $this->set_setting('feedback-popup_noindex', param('feedback-popup_noindex', 'integer', 0)); $this->set_setting('msgform_noindex', param('msgform_noindex', 'integer', 0)); $this->set_setting('special_noindex', param('special_noindex', 'integer', 0)); $this->set_setting('title_link_type', param('title_link_type', 'string', '')); $this->set_setting('permalinks', param('permalinks', 'string', '')); $this->set_setting('404_response', param('404_response', 'string', '')); $this->set_setting('help_link', param('help_link', 'string', '')); $this->set_setting('excerpts_meta_description', param('excerpts_meta_description', 'integer', 0)); $this->set_setting('categories_meta_description', param('categories_meta_description', 'integer', 0)); $this->set_setting('tags_meta_keywords', param('tags_meta_keywords', 'integer', 0)); } /* * ADVANCED ADMIN SETTINGS */ if ($current_User->check_perm('blog_admin', 'edit', false, $this->ID)) { // We have permission to edit advanced admin settings: if (in_array('cache', $groups)) { // we want to load the cache params: $this->set_setting('ajax_form_enabled', param('ajax_form_enabled', 'integer', 0)); $this->set_setting('ajax_form_loggedin_enabled', param('ajax_form_loggedin_enabled', 'integer', 0)); $this->set_setting('cache_enabled_widgets', param('cache_enabled_widgets', 'integer', 0)); } if (in_array('styles', $groups)) { // we want to load the styles params: $this->set('allowblogcss', param('blog_allowblogcss', 'integer', 0)); $this->set('allowusercss', param('blog_allowusercss', 'integer', 0)); } if (in_array('login', $groups)) { // we want to load the login params: $this->set_setting('in_skin_login', param('in_skin_login', 'integer', 0)); $this->set_setting('in_skin_editing', param('in_skin_editing', 'integer', 0)); } if (param('blog_head_includes', 'html', NULL) !== NULL) { // HTML header includes: param_check_html('blog_head_includes', T_('Invalid Custom meta section')); $this->set_setting('head_includes', get_param('blog_head_includes')); } if (param('blog_footer_includes', 'html', NULL) !== NULL) { // HTML header includes: param_check_html('blog_footer_includes', T_('Invalid Custom javascript section')); $this->set_setting('footer_includes', get_param('blog_footer_includes')); } if (param('owner_login', 'string', NULL) !== NULL) { // Permissions: $UserCache =& get_UserCache(); $owner_User =& $UserCache->get_by_login(get_param('owner_login')); if (empty($owner_User)) { param_error('owner_login', sprintf(T_('User «%s» does not exist!'), get_param('owner_login'))); } else { $this->set('owner_user_ID', $owner_User->ID); $this->owner_User =& $owner_User; } } if (($blog_urlname = param('blog_urlname', 'string', NULL)) !== NULL) { // check urlname if (param_check_not_empty('blog_urlname', T_('You must provide an URL blog name!'))) { if (!preg_match('|^[A-Za-z0-9\\-]+$|', $blog_urlname)) { param_error('blog_urlname', sprintf(T_('The url name %s is invalid.'), "«{$blog_urlname}»")); $blog_urlname = NULL; } if (isset($blog_urlname) && $DB->get_var('SELECT COUNT(*) FROM T_blogs WHERE blog_urlname = ' . $DB->quote($blog_urlname) . ' AND blog_ID <> ' . $this->ID)) { // urlname is already in use param_error('blog_urlname', sprintf(T_('The URL name %s is already in use by another blog. Please choose another name.'), "«{$blog_urlname}»")); $blog_urlname = NULL; } if (isset($blog_urlname)) { $this->set_from_Request('urlname'); } } } if (($access_type = param('blog_access_type', 'string', NULL)) !== NULL) { // Blog URL parameters: $this->set('access_type', $access_type); if ($access_type == 'absolute') { $blog_siteurl = param('blog_siteurl_absolute', 'string', true); if (preg_match('#^https?://[^/]+/.*#', $blog_siteurl, $matches)) { // It looks like valid absolute URL, so we may update the blog siteurl $this->set('siteurl', $blog_siteurl); } else { // It is not valid absolute URL, don't update the blog 'siteurl' to avoid errors $Messages->add(T_('Blog Folder URL') . ': ' . sprintf(T_('%s is an invalid absolute URL'), '«' . htmlspecialchars($blog_siteurl) . '»') . ' ' . T_('You must provide an absolute URL (starting with <code>http://</code> or <code>https://</code>) and it must contain at least one \'/\' sign after the domain name!'), 'error'); } } elseif ($access_type == 'relative') { // relative siteurl $blog_siteurl = param('blog_siteurl_relative', 'string', true); if (preg_match('#^https?://#', $blog_siteurl)) { $Messages->add(T_('Blog Folder URL') . ': ' . T_('You must provide a relative URL (without <code>http://</code> or <code>https://</code>)!'), 'error'); } $this->set('siteurl', $blog_siteurl); } else { $this->set('siteurl', ''); } } if (param('aggregate_coll_IDs', 'string', NULL) !== NULL) { // Aggregate list: (can be '*') $aggregate_coll_IDs = get_param('aggregate_coll_IDs'); if ($aggregate_coll_IDs != '*') { // Sanitize the string $aggregate_coll_IDs = sanitize_id_list($aggregate_coll_IDs); } // fp> TODO: check perms on each aggregated blog (if changed) // fp> TODO: better interface if ($aggregate_coll_IDs != '*' && !preg_match('#^([0-9]+(,[0-9]+)*)?$#', $aggregate_coll_IDs)) { param_error('aggregate_coll_IDs', T_('Invalid aggregate blog ID list!')); } $this->set_setting('aggregate_coll_IDs', $aggregate_coll_IDs); } if (param('blog_media_location', 'string', NULL) !== NULL) { // Media files location: $this->set_from_Request('media_location'); $this->set_media_subdir(param('blog_media_subdir', 'string', '')); $this->set_media_fullpath(param('blog_media_fullpath', 'string', '')); $this->set_media_url(param('blog_media_url', 'string', '')); // check params switch ($this->get('media_location')) { case 'custom': // custom path and URL global $demo_mode, $media_path; if ($this->get('media_fullpath') == '') { param_error('blog_media_fullpath', T_('Media dir location') . ': ' . T_('You must provide the full path of the media directory.')); } if (!preg_match('#^https?://#', $this->get('media_url'))) { param_error('blog_media_url', T_('Media dir location') . ': ' . T_('You must provide an absolute URL (starting with <code>http://</code> or <code>https://</code>)!')); } if ($demo_mode) { $canonical_fullpath = get_canonical_path($this->get('media_fullpath')); if (!$canonical_fullpath || strpos($canonical_fullpath, $media_path) !== 0) { param_error('blog_media_fullpath', T_('Media dir location') . ': in demo mode the path must be inside of $media_path.'); } } break; case 'subdir': global $media_path; if ($this->get('media_subdir') == '') { param_error('blog_media_subdir', T_('Media dir location') . ': ' . T_('You must provide the media subdirectory.')); } else { // Test if it's below $media_path (subdir!) $canonical_path = get_canonical_path($media_path . $this->get('media_subdir')); if (!$canonical_path || strpos($canonical_path, $media_path) !== 0) { param_error('blog_media_subdir', T_('Media dir location') . ': ' . sprintf(T_('Invalid subdirectory «%s».'), format_to_output($this->get('media_subdir')))); } else { // Validate if it's a valid directory name: $subdir = no_trailing_slash(substr($canonical_path, strlen($media_path))); if ($error = validate_dirname($subdir)) { param_error('blog_media_subdir', T_('Media dir location') . ': ' . $error); } } } break; } } } return !param_errors_detected(); }
$blog_comments = $moderator_comments; } else { // This moderator user may have different permission on different blogs, collect the comments corresponding to the perms foreach ($moderators[$moderator_ID] as $blog_ID => $perms) { if (!isset($comments_map[$blog_ID])) { // this blog doesn't contains comments awaiting moderation which statuses corresponds to this blog moderation statutes continue; } $cmt_count = 0; foreach ($comments_map[$blog_ID] as $status => $content) { $status_perm_value = get_status_permvalue($status); if ($perms['perm_statuses'] & $status_perm_value) { // User has permission to edit comments with this status // TODO asimo> Here probably we should also check if user is able to deprecate/recycle the comment. // Check if User has permission to raise comment status $ordered_statuses = get_visibility_statuses('ordered-index'); $raise_status_allowed = false; $current_status_found = false; foreach ($ordered_statuses as $ordered_status => $order_index) { if ($ordered_status == $status) { $current_status_found = true; } elseif ($current_status_found && $order_index !== 0) { // This is a higher status then the currently checked status $ordered_status_perm_value = get_status_permvalue($ordered_status); if ($perms['perm_statuses'] & $ordered_status_perm_value) { // User has permission to a higher status, so the comment status can be raised $raise_status_allowed = true; break; } } }
if (!defined('EVO_MAIN_INIT')) { die('Please, do not access this page directly.'); } global $blogs_list, $delete_bankruptcy_blogs, $bankruptcy_blogs_IDs, $comment_status; $Form = new Form(); $Form->add_crumb('antispam'); $Form->hidden_ctrl(); $Form->hidden('tab3', 'tools'); $Form->hidden('tool', 'bankruptcy'); $Form->begin_form('fform', T_('Declare comment spam bankruptcy...')); if (isset($delete_bankruptcy_blogs) && $delete_bankruptcy_blogs) { $Form->begin_fieldset(T_('Deleting log')); antispam_bankruptcy_delete($bankruptcy_blogs_IDs, $comment_status); $Form->end_fieldset(); } $visibility_statuses = get_visibility_statuses('', array()); $Form->begin_fieldset(T_('Filter comments by status')); $Form->select_input_array('comment_status', $comment_status, $visibility_statuses, T_('Look at comments with status'), ''); $Form->buttons(array(array('submit', 'actionArray[bankruptcy_filter]', T_('Filter')))); $Form->end_fieldset(); $Form->begin_fieldset(T_('Select blogs')); $blogs_list = antispam_bankruptcy_blogs($comment_status); if (empty($blogs_list)) { // No blogs echo '<p>' . sprintf(T_('No comments found with status %s...'), $visibility_statuses[$comment_status]) . '</p>'; } else { // Print blogs list foreach ($blogs_list as $blog) { echo '<p><input type="checkbox" name="bankruptcy_blogs[]" value="' . $blog->blog_ID . '" id="bankruptcy_blog_' . $blog->blog_ID . '" /> '; echo '<label for="bankruptcy_blog_' . $blog->blog_ID . '">' . $blog->blog_name . ' (' . sprintf(T_('<b>%s</b> comments with status %s'), $blog->comments_count, $visibility_statuses[$comment_status]) . ')</label></p>'; }
// Set admin skin, used for buttons, @see button_class() global $current_User, $UserSettings, $is_admin_page, $adminskins_path; $admin_skin = $UserSettings->get('admin_skin', $current_User->ID); $is_admin_page = true; require_once $adminskins_path . $admin_skin . '/_adminUI.class.php'; $AdminUI = new AdminUI(); } $statuses = param('statuses', 'string', NULL); $item_ID = param('itemid', 'integer'); $currentpage = param('currentpage', 'integer', 1); if (strlen($statuses) > 2) { $statuses = substr($statuses, 1, strlen($statuses) - 2); } $status_list = explode(',', $statuses); if ($status_list == NULL) { $status_list = get_visibility_statuses('keys', array('redirected', 'trash')); } // In case of comments_fullview we must set a filterset name to be abble to restore filterset. // If $moderation is not NULL, then this requests came from the comments_fullview // TODO: asimo> This should be handled with a better solution $filterset_name = $item_ID > 0 ? '' : 'fullview'; echo_item_comments($blog, $item_ID, $status_list, $currentpage, $limit, array(), $filterset_name, $expiry_status); } elseif ($request_from == 'front') { // AJAX request goes from frontoffice // Send new current status as ajax response echo $edited_Comment->status; // Also send the statuses which will be after raising/lowering of a status by current user $comment_raise_status = $edited_Comment->get_next_status(true, $edited_Comment->status); $comment_lower_status = $edited_Comment->get_next_status(false, $edited_Comment->status); echo ':' . ($comment_raise_status ? $comment_raise_status[0] : ''); echo ':' . ($comment_lower_status ? $comment_lower_status[0] : '');
$include_emptyurl = ${$pp . 'include_emptyurl'}; $author_IP = ${$pp . 'author_IP'}; load_funcs('skins/_skin.funcs.php'); $Widget = new Widget(); $template = $AdminUI->get_template('side_item'); $Widget->title = T_('Filters'); echo $Widget->replace_vars($template['block_start']); $Form = new Form(NULL, 'comment_filter_form', 'get', 'none'); $Form->begin_form(''); $Form->hidden_ctrl(); $Form->hidden('tab3', $tab3); $Form->submit(array('submit', T_('Search'), 'search', '', 'float:right')); echo '<fieldset>'; echo '<legend>' . T_('Comments to show') . '</legend>'; $exclude_statuses = array_merge(get_restricted_statuses($Blog->ID, 'blog_comment!'), array('redirected')); $statuses = get_visibility_statuses('notes-array', $exclude_statuses); foreach ($statuses as $status_key => $status_name) { // show statuses ?> <input type="checkbox" name="<?php echo $pp; ?> show_statuses[]" value="<?php echo $status_key; ?> " id="sh_<?php echo $status_key; ?> " class="checkbox" <?php if (in_array($status_key, $show_statuses)) { echo 'checked="checked" ';
</td> <?php } ?> </tr> </table> <?php } ?> <?php if (!empty($legend_statuses) && is_logged_in()) { // Display legend for items statuses $legend_statuses = array_unique($legend_statuses); $statuses = get_visibility_statuses('', array('deprecated', 'redirected', 'trash')); $statuses_titles = get_visibility_statuses('legend-titles'); ?> <ul class="bPosts bForums legend"> <?php foreach ($statuses_titles as $status => $title) { if (in_array($status, $legend_statuses)) { // Only statuses that exist on the page ?> <li> <a href="<?php echo get_manual_url('visibility-statuses'); ?> " target="_blank"><span class="note status_<?php echo $status; ?> "><span><?php
/** * Initialize list mode; Several actions need this. */ function init_list_mode() { global $tab, $tab_type, $Blog, $UserSettings, $ItemList, $AdminUI; // set default itemslist param prefix $items_list_param_prefix = 'items_'; if (param('p', 'integer', NULL) || param('title', 'string', NULL)) { // Single post requested, do not filter any post types. If the user // has clicked a post link on the dashboard and previously has selected // a tab which would filter this post, it wouldn't be displayed now. $tab = 'full'; // in case of single item view params prefix must be empty $items_list_param_prefix = NULL; } else { // Store/retrieve preferred tab from UserSettings: $UserSettings->param_Request('tab', 'pref_browse_tab', 'string', NULL, true, true); $UserSettings->param_Request('tab_type', 'pref_browse_tab_type', 'string', NULL, true, true); } if ($tab == 'tracker' && !$Blog->get_setting('use_workflow')) { // Display workflow view only if it is enabled global $Messages; $Messages->add(T_('Workflow feature has not been enabled for this collection.'), 'note'); $tab = 'full'; } /* * Init list of posts to display: */ load_class('items/model/_itemlist.class.php', 'ItemList2'); if (!empty($tab) && !empty($items_list_param_prefix)) { // Use different param prefix for each tab $items_list_param_prefix .= substr($tab, 0, 7) . '_'; //.utf8_strtolower( $tab_type ).'_'; } // Set different filterset name for each different tab and tab_type $filterset_name = $tab == 'type' ? $tab . '_' . utf8_strtolower($tab_type) : $tab; // Create empty List: $ItemList = new ItemList2($Blog, NULL, NULL, $UserSettings->get('results_per_page'), 'ItemCache', $items_list_param_prefix, $filterset_name); // COPY (func) $ItemList->set_default_filters(array('visibility_array' => get_visibility_statuses('keys'))); if ($Blog->get_setting('orderby') == 'RAND') { // Do not display random posts in backoffice for easy management $ItemList->set_default_filters(array('orderby' => 'datemodified')); } switch ($tab) { case 'full': $ItemList->set_default_filters(array('types' => NULL)); // $AdminUI->breadcrumbpath_add( T_('All items'), '?ctrl=items&blog=$blog$&tab='.$tab.'&filter=restore' ); // require colorbox js require_js_helper('colorbox'); $AdminUI->breadcrumbpath_add(T_('All'), '?ctrl=items&blog=$blog$&tab=full&filter=restore'); break; case 'manual': if ($Blog->get('type') != 'manual') { // Display this tab only for manual blogs global $admin_url; header_redirect($admin_url . '?ctrl=items&blog=' . $Blog->ID . '&tab=type&tab_type=posts&filter=restore'); } global $ReqURI, $blog; init_field_editor_js(array('action_url' => $ReqURI . '&blog=' . $blog . '&order_action=update&order_data=')); $AdminUI->breadcrumbpath_add(T_('Manual view'), '?ctrl=items&blog=$blog$&tab=' . $tab . '&filter=restore'); break; case 'type': // Filter a posts list by type $ItemList->set_default_filters(array('types' => get_item_types_by_tab($tab_type))); $AdminUI->breadcrumbpath_add(T_($tab_type), '?ctrl=items&blog=$blog$&tab=' . $tab . '&tab_type=' . urlencode($tab_type) . '&filter=restore'); break; case 'tracker': // In tracker mode, we want a different default sort: $ItemList->set_default_filters(array('orderby' => 'priority', 'order' => 'ASC')); $AdminUI->breadcrumbpath_add(T_('Workflow view'), '?ctrl=items&blog=$blog$&tab=tracker&filter=restore'); $AdminUI->set_page_manual_link('workflow-features'); // JS to edit priority of items from list view require_js('jquery/jquery.jeditable.js', 'rsc_url'); break; default: // Delete the pref_browse_tab setting so that the default // (full) gets used the next time the user wants to browse // a blog and we don't run into the same error again. $UserSettings->delete('pref_browse_tab'); $UserSettings->dbupdate(); debug_die('Unknown filterset [' . $tab . ']'); } // Init filter params: if (!$ItemList->load_from_Request()) { // If we could not init a filterset from request // typically happens when we could no fall back to previously saved filterset... // echo ' no filterset!'; } }