本文整理汇总了PHP中has_category_access函数的典型用法代码示例。如果您正苦于以下问题:PHP has_category_access函数的具体用法?PHP has_category_access怎么用?PHP has_category_access使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了has_category_access函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
/**
* Standard modular run function for RSS hooks.
*
* @param string A list of categories we accept from
* @param TIME Cutoff time, before which we do not show results from
* @param string Prefix that represents the template set we use
* @set RSS_ ATOM_
* @param string The standard format of date to use for the syndication type represented in the prefix
* @param integer The maximum number of entries to return, ordering by date
* @return ?array A pair: The main syndication section, and a title (NULL: error)
*/
function run($_filters, $cutoff, $prefix, $date_string, $max)
{
if (!addon_installed('news')) {
return NULL;
}
if (!has_actual_page_access(get_member(), 'news')) {
return NULL;
}
$filters_1 = ocfilter_to_sqlfragment($_filters, 'p.news_category', 'news_categories', NULL, 'p.news_category', 'id');
// Note that the parameters are fiddled here so that category-set and record-set are the same, yet SQL is returned to deal in an entirely different record-set (entries' record-set)
$filters_2 = ocfilter_to_sqlfragment($_filters, 'd.news_entry_category', 'news_categories', NULL, 'd.news_category', 'id');
// Note that the parameters are fiddled here so that category-set and record-set are the same, yet SQL is returned to deal in an entirely different record-set (entries' record-set)
$filters = '(' . $filters_1 . ' OR ' . $filters_2 . ')';
$rows = $GLOBALS['SITE_DB']->query('SELECT * FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'news p LEFT JOIN ' . get_table_prefix() . 'news_category_entries d ON d.news_entry=p.id WHERE date_and_time>' . strval($cutoff) . (!has_specific_permission(get_member(), 'see_unvalidated') ? ' AND validated=1 ' : '') . ' AND ' . $filters . (can_arbitrary_groupby() ? ' GROUP BY p.id' : '') . ' ORDER BY date_and_time DESC', $max);
$rows = remove_duplicate_rows($rows, 'id');
$_categories = $GLOBALS['SITE_DB']->query_select('news_categories', array('id', 'nc_title'), array('nc_owner' => NULL));
foreach ($_categories as $i => $_category) {
$_categories[$i]['text_original'] = get_translated_text($_category['nc_title']);
}
$categories = collapse_2d_complexity('id', 'text_original', $_categories);
$content = new ocp_tempcode();
foreach ($rows as $row) {
if (has_category_access(get_member(), 'news', strval($row['news_category']))) {
$id = strval($row['id']);
$author = $row['author'];
$news_date = date($date_string, $row['date_and_time']);
$edit_date = is_null($row['edit_date']) ? '' : date($date_string, $row['edit_date']);
$_title = get_translated_tempcode($row['title']);
$news_title = xmlentities($_title->evaluate());
$_summary = get_translated_tempcode($row['news']);
if ($_summary->is_empty()) {
$_summary = get_translated_tempcode($row['news_article']);
}
$summary = xmlentities($_summary->evaluate());
if (!is_null($row['news_article'])) {
$_news = get_translated_tempcode($row['news_article']);
if ($_news->is_empty()) {
$news = '';
} else {
$news = xmlentities($_news->evaluate());
}
} else {
$news = '';
}
if (!array_key_exists($row['news_category'], $categories)) {
$categories[$row['news_category']] = get_translated_text($GLOBALS['SITE_DB']->query_value('news_categories', 'nc_title', array('id' => $row['news_category'])));
}
$category = $categories[$row['news_category']];
$category_raw = strval($row['news_category']);
$view_url = build_url(array('page' => 'news', 'type' => 'view', 'id' => $row['id']), get_module_zone('news'), NULL, false, false, true);
if ($prefix == 'RSS_' && get_option('is_on_comments') == '1' && $row['allow_comments'] >= 1) {
$if_comments = do_template('RSS_ENTRY_COMMENTS', array('_GUID' => 'b4f25f5cf68304f8d402bb06851489d6', 'COMMENT_URL' => $view_url, 'ID' => strval($row['id'])));
} else {
$if_comments = new ocp_tempcode();
}
$content->attach(do_template($prefix . 'ENTRY', array('VIEW_URL' => $view_url, 'SUMMARY' => $summary, 'EDIT_DATE' => $edit_date, 'IF_COMMENTS' => $if_comments, 'TITLE' => $news_title, 'CATEGORY_RAW' => $category_raw, 'CATEGORY' => $category, 'AUTHOR' => $author, 'ID' => $id, 'NEWS' => $news, 'DATE' => $news_date)));
}
}
return array($content, do_lang('NEWS'));
}
示例2: run
/**
* Standard modular run function for attachment hooks. They see if permission to an attachment of an ID relating to this content is present for the current member.
*
* @param ID_TEXT The ID
* @param object The database connection to check on
* @return boolean Whether there is permission
*/
function run($id, $connection)
{
if ($connection->connection_write != $GLOBALS['SITE_DB']->connection_write) {
return false;
}
return has_category_access(get_member(), 'seedy_page', strval($id));
}
示例3: rules_script
/**
* Pop-up some rules.
*/
function rules_script()
{
$id = get_param_integer('id', NULL);
if (is_null($id)) {
require_code('site');
$output = request_page('rules', true);
$title = do_lang_tempcode('RULES');
} else {
if (!has_category_access(get_member(), 'forums', strval($id))) {
warn_exit(do_lang_tempcode('ACCESS_DENIED'));
}
$forum_rows = $GLOBALS['FORUM_DB']->query_select('f_forums', array('*'), array('id' => $id), '', 1);
if (!array_key_exists(0, $forum_rows)) {
warn_exit(do_lang_tempcode('MISSING_RESOURCE'));
}
$forum_row = $forum_rows[0];
require_lang('ocf');
$question = get_translated_tempcode($forum_row['f_intro_question'], $GLOBALS['FORUM_DB']);
$answer = $forum_row['f_intro_answer'];
$output = do_template('OCF_FORUM_INTRO_QUESTION_POPUP', array('_GUID' => '6f2dc12b616219ff982654b73ef979b2', 'QUESTION' => $question, 'ANSWER' => $answer));
$title = $answer == '' ? do_lang_tempcode('FORUM_RULES') : do_lang_tempcode('INTRO_QUESTION');
}
$tpl = do_template('POPUP_HTML_WRAP', array('_GUID' => '26c4dbc7a4737310f089583f1048cb13', 'TITLE' => $title, 'TARGET' => '_top', 'CONTENT' => $output));
$tpl->evaluate_echo();
}
示例4: run
/**
* Standard modular run function.
*
* @param array A map of parameters.
* @return tempcode The result of execution.
*/
function run($map)
{
require_lang('news');
$categories = $GLOBALS['SITE_DB']->query_select('news_categories', array('*'), array('nc_owner' => NULL));
$content = new ocp_tempcode();
$categories2 = array();
foreach ($categories as $category) {
if (has_category_access(get_member(), 'news', strval($category['id']))) {
$join = ' LEFT JOIN ' . get_table_prefix() . 'news_category_entries d ON d.news_entry=p.id';
$count = $GLOBALS['SITE_DB']->query_value_null_ok_full('SELECT COUNT(*) FROM ' . get_table_prefix() . 'news p' . $join . ' WHERE validated=1 AND (news_entry_category=' . strval($category['id']) . ' OR news_category=' . strval($category['id']) . ') ORDER BY date_and_time DESC');
if ($count > 0) {
$category['_nc_title'] = get_translated_text($category['nc_title']);
$categories2[] = $category;
}
}
}
if (count($categories2) == 0) {
global $M_SORT_KEY;
$M_SORT_KEY = '_nc_title';
usort($categories2, 'multi_sort');
foreach ($categories as $category) {
if (has_category_access(get_member(), 'news', strval($category['id']))) {
$categories2[] = $category;
}
}
}
foreach ($categories2 as $category) {
$url = build_url(array('page' => 'news', 'type' => 'misc', 'id' => $category['id']), get_module_zone('news'));
$name = $category['_nc_title'];
$content->attach(do_template('BLOCK_SIDE_NEWS_CATEGORIES_CATEGORY', array('_GUID' => 'fee49cac370ec00fc59d2e9c66b6255a', 'URL' => $url, 'NAME' => $name, 'COUNT' => integer_format($count))));
}
return do_template('BLOCK_SIDE_NEWS_CATEGORIES', array('_GUID' => 'b47a0047247096373e5aa626348c4ebb', 'CONTENT' => $content, 'PRE' => '', 'POST' => ''));
}
示例5: run
/**
* Standard modular run function for RSS hooks.
*
* @param string A list of categories we accept from
* @param TIME Cutoff time, before which we do not show results from
* @param string Prefix that represents the template set we use
* @set RSS_ ATOM_
* @param string The standard format of date to use for the syndication type represented in the prefix
* @param integer The maximum number of entries to return, ordering by date
* @return ?array A pair: The main syndication section, and a title (NULL: error)
*/
function run($_filters, $cutoff, $prefix, $date_string, $max)
{
if (!addon_installed('cedi')) {
return NULL;
}
if (!has_actual_page_access(get_member(), 'cedi')) {
return NULL;
}
$filters = ocfilter_to_sqlfragment($_filters, 'id', 'seedy_children', 'parent_id', 'parent_id', 'child_id');
$content = new ocp_tempcode();
$rows = $GLOBALS['SITE_DB']->query('SELECT * FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'seedy_pages WHERE ' . $filters . ' AND add_date>' . strval((int) $cutoff) . ' ORDER BY add_date DESC', $max);
foreach ($rows as $row) {
$id = strval($row['id']);
if (!has_category_access(get_member(), 'seedy_page', strval($row['id']))) {
continue;
}
$author = '';
$news_date = date($date_string, $row['add_date']);
$edit_date = '';
$news_title = xmlentities(escape_html(get_translated_text($row['title'])));
$_summary = get_translated_tempcode($row['description']);
$summary = xmlentities($_summary->evaluate());
$news = '';
$category = '';
$category_raw = '';
$view_url = build_url(array('page' => 'cedi', 'type' => 'misc', 'id' => $row['id'] == db_get_first_id() ? NULL : $row['id']), get_module_zone('cedi'), NULL, false, false, true);
$if_comments = new ocp_tempcode();
$content->attach(do_template($prefix . 'ENTRY', array('VIEW_URL' => $view_url, 'SUMMARY' => $summary, 'EDIT_DATE' => $edit_date, 'IF_COMMENTS' => $if_comments, 'TITLE' => $news_title, 'CATEGORY_RAW' => $category_raw, 'CATEGORY' => $category, 'AUTHOR' => $author, 'ID' => $id, 'NEWS' => $news, 'DATE' => $news_date)));
}
require_lang('cedi');
return array($content, do_lang('CEDI_PAGES'));
}
示例6: run
/**
* Standard modular run function for RSS hooks.
*
* @param string A list of categories we accept from
* @param TIME Cutoff time, before which we do not show results from
* @param string Prefix that represents the template set we use
* @set RSS_ ATOM_
* @param string The standard format of date to use for the syndication type represented in the prefix
* @param integer The maximum number of entries to return, ordering by date
* @return ?array A pair: The main syndication section, and a title (NULL: error)
*/
function run($_filters, $cutoff, $prefix, $date_string, $max)
{
if (!addon_installed('tickets')) {
return NULL;
}
if (!has_actual_page_access(get_member(), 'tickets')) {
return NULL;
}
if (is_guest()) {
return NULL;
}
require_code('tickets');
require_code('tickets2');
$ticket_types = ocfilter_to_idlist_using_callback($_filters, '', NULL, NULL, NULL, NULL, false);
if (count($ticket_types) != 0) {
$rows = array();
foreach ($ticket_types as $ticket_type) {
if (!has_category_access(get_member(), 'tickets', get_translated_text($ticket_type))) {
continue;
}
$rows = array_merge($rows, get_tickets(get_member(), $ticket_type, false, false, true));
}
} else {
$rows = get_tickets(get_member(), NULL, false, false, true);
}
require_code('feedback');
$content = new ocp_tempcode();
foreach ($rows as $i => $row) {
if ($i == $max) {
break;
}
if ($row['lasttime'] < $cutoff) {
continue;
}
$ticket_id = extract_topic_identifier($row['description']);
$ticket_type = $GLOBALS['SITE_DB']->query_value_null_ok('tickets', 'ticket_type', array('ticket_id' => $ticket_id));
$author = $row['firstusername'];
$date = date($date_string, $row['firsttime']);
$edit_date = date($date_string, $row['lasttime']);
$title = xmlentities($row['firsttitle']);
$summary = xmlentities($row['firstpost']->evaluate());
$category = '';
$category_raw = '';
if (!is_null($ticket_type)) {
$category = get_translated_text($ticket_type);
$category_raw = strval($ticket_type);
}
$view_url = build_url(array('page' => 'tickets', 'type' => 'ticket', 'id' => $ticket_id), get_module_zone('tickets'), NULL, false, false, true);
if ($prefix == 'RSS_' && get_option('is_on_comments') == '1') {
$if_comments = do_template('RSS_ENTRY_COMMENTS', array('_GUID' => 'b4f25f5cf68304f8d402bb06851489d6', 'COMMENT_URL' => $view_url, 'ID' => strval($ticket_id)));
} else {
$if_comments = new ocp_tempcode();
}
$content->attach(do_template($prefix . 'ENTRY', array('VIEW_URL' => $view_url, 'SUMMARY' => $summary, 'EDIT_DATE' => $edit_date, 'IF_COMMENTS' => $if_comments, 'TITLE' => $title, 'CATEGORY_RAW' => $category_raw, 'CATEGORY' => $category, 'AUTHOR' => $author, 'ID' => $ticket_id, 'NEWS' => '', 'DATE' => $date)));
}
require_lang('tickets');
return array($content, do_lang('SUPPORT_TICKETS'));
}
示例7: run
/**
* Standard modular run function for attachment hooks. They see if permission to an attachment of an ID relating to this content is present for the current member.
*
* @param ID_TEXT The ID
* @param object The database connection to check on
* @return boolean Whether there is permission
*/
function run($id, $connection)
{
$info = $connection->query_select('catalogue_entries', array('c_name', 'cc_id'), array('id' => intval($id)), '', 1);
if (!array_key_exists(0, $info)) {
return false;
}
if (!has_category_access(get_member(), 'catalogues_catalogue', $info[0]['c_name'])) {
return false;
}
return get_value('disable_cat_cat_perms') === '1' || has_category_access(get_member(), 'catalogues_category', strval($info[0]['cc_id']));
}
示例8: run
/**
* Standard modular run function for attachment hooks. They see if permission to an attachment of an ID relating to this content is present for the current member.
*
* @param ID_TEXT The ID
* @param object The database connection to check on
* @return boolean Whether there is permission
*/
function run($id, $connection)
{
if ($connection->connection_write != $GLOBALS['SITE_DB']->connection_write) {
return false;
}
$cat_id = $GLOBALS['SITE_DB']->query_value_null_ok('seedy_posts', 'page_id', array('id' => intval($id)));
if (is_null($cat_id)) {
return false;
}
return has_category_access(get_member(), 'seedy_page', strval($cat_id));
}
示例9: create_category_tree
/**
* Standard function to create the standardised category tree
*
* @param ID_TEXT Notification code
* @param ?ID_TEXT The ID of where we're looking under (NULL: N/A)
* @return array Tree structure
*/
function create_category_tree($notification_code, $id)
{
$pagelinks = array();
$types = $GLOBALS['SITE_DB']->query_select('calendar_types', array('id', 't_title'));
foreach ($types as $type) {
if (has_category_access(get_member(), 'calendar', strval($type['id'])) && $type['id'] != db_get_first_id()) {
$pagelinks[] = array('id' => $type['id'], 'title' => get_translated_text($type['t_title']));
}
}
global $M_SORT_KEY;
$M_SORT_KEY = 'title';
usort($pagelinks, 'multi_sort');
return $pagelinks;
}
示例10: run
/**
* Standard modular run function for RSS hooks.
*
* @param string A list of categories we accept from
* @param TIME Cutoff time, before which we do not show results from
* @param string Prefix that represents the template set we use
* @set RSS_ ATOM_
* @param string The standard format of date to use for the syndication type represented in the prefix
* @param integer The maximum number of entries to return, ordering by date
* @return ?array A pair: The main syndication section, and a title (NULL: error)
*/
function run($_filters, $cutoff, $prefix, $date_string, $max)
{
if (!addon_installed('ocf_forum')) {
return NULL;
}
if (get_forum_type() != 'ocf') {
return NULL;
}
if (!has_actual_page_access(get_member(), 'forumview')) {
return NULL;
}
$filters = ocfilter_to_sqlfragment($_filters, 'p_topic_id', 'f_forums', 'f_parent_forum', 'p_cache_forum_id', 'id', true, true, $GLOBALS['FORUM_DB']);
$cutoff = max($cutoff, time() - 60 * 60 * 24 * 60);
if (!is_guest()) {
$filters .= ' AND (p_poster<>' . strval(get_member()) . ')';
}
$rows = $GLOBALS['FORUM_DB']->query('SELECT * FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_posts WHERE p_time>' . strval($cutoff) . (!has_specific_permission(get_member(), 'see_unvalidated') ? ' AND p_validated=1 ' : '') . ' AND ' . $filters . ' ORDER BY p_time DESC,id DESC', $max);
$categories = list_to_map('id', $GLOBALS['FORUM_DB']->query('SELECT id,t_cache_first_title,t_pt_from,t_pt_to FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_topics WHERE t_cache_last_time>' . strval((int) $cutoff)));
$content = new ocp_tempcode();
foreach ($rows as $row) {
if (!array_key_exists($row['p_topic_id'], $categories)) {
continue;
}
$category = $categories[$row['p_topic_id']]['t_cache_first_title'];
if ((!is_null($row['p_cache_forum_id']) || $categories[$row['p_topic_id']]['t_pt_from'] == get_member() || $categories[$row['p_topic_id']]['t_pt_to'] == get_member()) && (is_null($row['p_intended_solely_for']) || $row['p_intended_solely_for'] == get_member()) && has_category_access(get_member(), 'forums', strval($row['p_cache_forum_id']))) {
$id = strval($row['id']);
$author = $row['p_poster_name_if_guest'];
$news_date = date($date_string, $row['p_time']);
$edit_date = is_null($row['p_last_edit_time']) ? '' : date($date_string, $row['p_last_edit_time']);
if ($edit_date == $news_date) {
$edit_date = '';
}
$news_title = xmlentities($row['p_title']);
$_summary = get_translated_tempcode($row['p_post'], $GLOBALS['FORUM_DB']);
$summary = xmlentities($_summary->evaluate());
$news = '';
$category_raw = strval($row['p_topic_id']);
$view_url = build_url(array('page' => 'topicview', 'type' => 'findpost', 'id' => $row['id']), get_module_zone('forumview'), NULL, false, false, true);
if ($prefix == 'RSS_') {
$if_comments = do_template('RSS_ENTRY_COMMENTS', array('_GUID' => 'ed06bc8f174a5427e1789820666fdd81', 'COMMENT_URL' => $view_url, 'ID' => strval($row['p_topic_id'])));
} else {
$if_comments = new ocp_tempcode();
}
$content->attach(do_template($prefix . 'ENTRY', array('VIEW_URL' => $view_url, 'SUMMARY' => $summary, 'EDIT_DATE' => $edit_date, 'IF_COMMENTS' => $if_comments, 'TITLE' => $news_title, 'CATEGORY_RAW' => $category_raw, 'CATEGORY' => $category, 'AUTHOR' => $author, 'ID' => $id, 'NEWS' => $news, 'DATE' => $news_date)));
}
}
require_lang('ocf');
return array($content, do_lang('FORUM_TOPICS'));
}
示例11: run
/**
* Standard modular run function for attachment hooks. They see if permission to an attachment of an ID relating to this content is present for the current member.
*
* @param ID_TEXT The ID
* @param object The database connection to check on
* @return boolean Whether there is permission
*/
function run($id, $connection)
{
$info = $connection->query_select('calendar_events', array('e_submitter', 'e_is_public', 'e_type'), array('id' => intval($id)), '', 1);
if (!array_key_exists(0, $info)) {
return false;
}
if (!has_category_access(get_member(), 'calendar', strval($info[0]['e_type']))) {
return false;
}
if ($info[0]['e_is_public'] == 1) {
return true;
}
if ($info[0]['e_submitter'] == get_member()) {
return true;
}
return false;
}
示例12: run
/**
* Standard modular run function for attachment hooks. They see if permission to an attachment of an ID relating to this content is present for the current member.
*
* @param ID_TEXT The ID
* @param object The database connection to check on
* @return boolean Whether there is permission
*/
function run($id, $connection)
{
if (get_forum_type() != 'ocf') {
return false;
}
// Shouldn't be here, but maybe it's left over somehow
require_code('ocf_forums');
require_code('ocf_topics');
$info = $GLOBALS['FORUM_DB']->query_select('f_posts', array('p_cache_forum_id', 'p_intended_solely_for', 'p_poster', 'p_topic_id'), array('id' => intval($id)), '', 1);
if (!array_key_exists(0, $info)) {
return false;
}
$forum_id = $info[0]['p_cache_forum_id'];
$poster = $info[0]['p_poster'];
$forum_id_parent = is_null($forum_id) ? NULL : $GLOBALS['FORUM_DB']->query_value('f_forums', 'f_parent_forum', array('id' => $forum_id));
$forum_id_parent_parent = is_null($forum_id_parent) ? NULL : $GLOBALS['FORUM_DB']->query_value('f_forums', 'f_parent_forum', array('id' => $forum_id_parent));
$intended_solely_for = $info[0]['p_intended_solely_for'];
if (!is_null($intended_solely_for) && $poster != get_member() && $intended_solely_for != get_member()) {
return false;
}
if (is_null($forum_id)) {
$topic_info = $GLOBALS['FORUM_DB']->query_select('f_topics', array('t_pt_to', 't_pt_from'), array('id' => $info[0]['p_topic_id']), '', 1);
return $topic_info[0]['t_pt_to'] == get_member() || $topic_info[0]['t_pt_from'] == get_member() || ocf_has_special_pt_access($info[0]['p_topic_id']);
}
if (addon_installed('tickets')) {
$tf = get_option('ticket_forum_name', true);
if (!is_null($tf)) {
$forum2 = $GLOBALS['FORUM_DRIVER']->forum_id_from_name($tf);
} else {
$forum2 = NULL;
}
if ($forum2 === $forum_id || $forum2 === $forum_id_parent || $forum2 === $forum_id_parent_parent) {
$title = $GLOBALS['FORUM_DB']->query_value('f_topics', 't_cache_first_title', array('id' => $info[0]['p_topic_id']));
if (substr($title, 0, strlen(strval(get_member())) + 1) == strval(get_member()) . '_') {
return true;
}
require_lang('tickets');
$description = $GLOBALS['FORUM_DB']->query_value('f_topics', 't_description', array('id' => $info[0]['p_topic_id']));
if (substr($description, 0, strlen(do_lang('SUPPORT_TICKET') . ': #' . strval(get_member())) + 1) == do_lang('SUPPORT_TICKET') . ': #' . strval(get_member()) . '_') {
return true;
}
}
}
return has_category_access(get_member(), 'forums', strval($forum_id));
}
示例13: run
/**
* Standard modular run function for RSS hooks.
*
* @param string A list of categories we accept from
* @param TIME Cutoff time, before which we do not show results from
* @param string Prefix that represents the template set we use
* @set RSS_ ATOM_
* @param string The standard format of date to use for the syndication type represented in the prefix
* @param integer The maximum number of entries to return, ordering by date
* @return ?array A pair: The main syndication section, and a title (NULL: error)
*/
function run($_filters, $cutoff, $prefix, $date_string, $max)
{
if (get_forum_type() != 'ocf') {
return NULL;
}
if (!has_actual_page_access(get_member(), 'forumview')) {
return NULL;
}
if (is_guest()) {
return NULL;
}
$condition = 'l_time<t_cache_last_time OR (l_time IS NULL AND t_cache_last_time>' . strval(time() - 60 * 60 * 24 * intval(get_option('post_history_days'))) . ')';
$query = ' FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_topics top LEFT JOIN ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_read_logs l ON (top.id=l.l_topic_id AND l.l_member_id=' . strval((int) get_member()) . ') LEFT JOIN ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'translate t ON ' . db_string_equal_to('language', user_lang()) . ' AND top.t_cache_first_post=t.id WHERE (' . $condition . ') AND t_forum_id IS NOT NULL ' . (!has_specific_permission(get_member(), 'see_unvalidated') ? ' AND t_validated=1 ' : '') . ' ORDER BY t_cache_last_time DESC';
$rows = $GLOBALS['FORUM_DB']->query('SELECT *,top.id AS t_id ' . $query, $max);
$categories = collapse_2d_complexity('id', 'f_name', $GLOBALS['FORUM_DB']->query('SELECT id,f_name FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_forums WHERE f_cache_num_posts>0'));
$content = new ocp_tempcode();
foreach ($rows as $row) {
if ((!is_null($row['t_forum_id']) || $row['t_pt_to'] == get_member()) && has_category_access(get_member(), 'forums', strval($row['t_forum_id']))) {
$id = strval($row['id']);
$author = $row['t_cache_first_username'];
$news_date = date($date_string, $row['t_cache_first_time']);
$edit_date = date($date_string, $row['t_cache_last_time']);
if ($edit_date == $news_date) {
$edit_date = '';
}
$news_title = xmlentities($row['t_cache_first_title']);
$_summary = get_translated_tempcode($row['t_cache_first_post'], $GLOBALS['FORUM_DB']);
$summary = xmlentities($_summary->evaluate());
$news = '';
$category = array_key_exists($row['t_forum_id'], $categories) ? $categories[$row['t_forum_id']] : do_lang('NA');
$category_raw = strval($row['t_forum_id']);
$view_url = build_url(array('page' => 'topicview', 'id' => $row['t_id']), get_module_zone('topicview'));
if ($prefix == 'RSS_') {
$if_comments = do_template('RSS_ENTRY_COMMENTS', array('COMMENT_URL' => $view_url, 'ID' => strval($row['t_id'])));
} else {
$if_comments = new ocp_tempcode();
}
$content->attach(do_template($prefix . 'ENTRY', array('VIEW_URL' => $view_url, 'SUMMARY' => $summary, 'EDIT_DATE' => $edit_date, 'IF_COMMENTS' => $if_comments, 'TITLE' => $news_title, 'CATEGORY_RAW' => $category_raw, 'CATEGORY' => $category, 'AUTHOR' => $author, 'ID' => $id, 'NEWS' => $news, 'DATE' => $news_date)));
}
}
require_lang('ocf');
return array($content, do_lang('TOPICS_UNREAD'));
}
示例14: run
/**
* Standard modular run function for RSS hooks.
*
* @param string A list of categories we accept from
* @param TIME Cutoff time, before which we do not show results from
* @param string Prefix that represents the template set we use
* @set RSS_ ATOM_
* @param string The standard format of date to use for the syndication type represented in the prefix
* @param integer The maximum number of entries to return, ordering by date
* @return ?array A pair: The main syndication section, and a title (NULL: error)
*/
function run($_filters, $cutoff, $prefix, $date_string, $max)
{
if (!addon_installed('ocf_forum')) {
return NULL;
}
if (get_forum_type() != 'ocf') {
return NULL;
}
if (!has_actual_page_access(get_member(), 'forumview')) {
return NULL;
}
$filters = ocfilter_to_sqlfragment($_filters, 't_forum_id', 'f_forums', 'f_parent_forum', 't_forum_id', 'id', true, true, $GLOBALS['FORUM_DB']);
// Note that the parameters are fiddled here so that category-set and record-set are the same, yet SQL is returned to deal in an entirely different record-set (entries' record-set)
$rows = $GLOBALS['FORUM_DB']->query('SELECT * FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_topics WHERE t_cache_last_time>' . strval($cutoff) . (!has_specific_permission(get_member(), 'see_unvalidated') ? ' AND t_validated=1 ' : '') . ' AND ' . $filters . ' ORDER BY t_cache_last_time DESC', $max);
$categories = collapse_2d_complexity('id', 'f_name', $GLOBALS['FORUM_DB']->query('SELECT id,f_name FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_forums WHERE f_cache_num_posts>0'));
$content = new ocp_tempcode();
foreach ($rows as $row) {
if ((!is_null($row['t_forum_id']) || $row['t_pt_to'] == get_member()) && has_category_access(get_member(), 'forums', strval($row['t_forum_id']))) {
$id = strval($row['id']);
$author = $row['t_cache_first_username'];
$news_date = date($date_string, $row['t_cache_first_time']);
$edit_date = date($date_string, $row['t_cache_last_time']);
if ($edit_date == $news_date) {
$edit_date = '';
}
$news_title = xmlentities($row['t_cache_first_title']);
$_summary = get_translated_tempcode($row['t_cache_first_post'], $GLOBALS['FORUM_DB']);
$summary = xmlentities($_summary->evaluate());
$news = '';
$category = array_key_exists($row['t_forum_id'], $categories) ? $categories[$row['t_forum_id']] : do_lang('NA');
$category_raw = strval($row['t_forum_id']);
$view_url = build_url(array('page' => 'topicview', 'id' => $row['id']), get_module_zone('forumview'), NULL, false, false, true);
if ($prefix == 'RSS_') {
$if_comments = do_template('RSS_ENTRY_COMMENTS', array('_GUID' => 'f5dd7ba612b989bba5e2d496da5bf161', 'COMMENT_URL' => $view_url, 'ID' => strval($row['id'])));
} else {
$if_comments = new ocp_tempcode();
}
$content->attach(do_template($prefix . 'ENTRY', array('VIEW_URL' => $view_url, 'SUMMARY' => $summary, 'EDIT_DATE' => $edit_date, 'IF_COMMENTS' => $if_comments, 'TITLE' => $news_title, 'CATEGORY_RAW' => $category_raw, 'CATEGORY' => $category, 'AUTHOR' => $author, 'ID' => $id, 'NEWS' => $news, 'DATE' => $news_date)));
}
}
require_lang('ocf');
return array($content, do_lang('SECTION_FORUMS'));
}
示例15: run
/**
* Standard modular run function for realtime-rain hooks.
*
* @param TIME Start of time range.
* @param TIME End of time range.
* @return array A list of template parameter sets for rendering a 'drop'.
*/
function run($from, $to)
{
$drops = array();
if (get_forum_type() == 'ocf') {
// Member's joining (f_members table)
if (has_actual_page_access(get_member(), 'members')) {
$rows = $GLOBALS['FORUM_DB']->query('SELECT m_ip_address,id AS member_id,m_join_time AS timestamp FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_members WHERE m_join_time BETWEEN ' . strval($from) . ' AND ' . strval($to));
foreach ($rows as $row) {
$timestamp = $row['timestamp'];
$member_id = $row['member_id'];
if (is_guest($member_id)) {
continue;
}
$drops[] = rain_get_special_icons($row['m_ip_address'], $timestamp) + array('TYPE' => 'join', 'FROM_MEMBER_ID' => strval($member_id), 'TO_MEMBER_ID' => NULL, 'TITLE' => do_lang('JOINED') . ': ' . $GLOBALS['FORUM_DRIVER']->get_username($member_id), 'IMAGE' => $GLOBALS['FORUM_DRIVER']->get_member_avatar_url($member_id), 'TIMESTAMP' => strval($timestamp), 'RELATIVE_TIMESTAMP' => strval($timestamp - $from), 'TICKER_TEXT' => NULL, 'URL' => $GLOBALS['FORUM_DRIVER']->member_profile_url($member_id, false, true), 'IS_POSITIVE' => true, 'IS_NEGATIVE' => false, 'FROM_ID' => 'member_' . strval($member_id), 'TO_ID' => NULL, 'GROUP_ID' => NULL);
}
}
// Forum posts (f_posts table)
if (has_actual_page_access(get_member(), 'topicview') && addon_installed('ocf_forum')) {
$rows = $GLOBALS['FORUM_DB']->query('SELECT p_intended_solely_for,id,p_poster AS member_id,p_time AS timestamp,p_cache_forum_id,p_post,p_title,p_ip_address FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_posts WHERE p_time BETWEEN ' . strval($from) . ' AND ' . strval($to));
foreach ($rows as $row) {
if (is_null($row['p_cache_forum_id'])) {
continue;
}
if (!is_null($row['p_intended_solely_for'])) {
continue;
}
if (!has_category_access(get_member(), 'forums', strval($row['p_cache_forum_id']))) {
continue;
}
$timestamp = $row['timestamp'];
$member_id = $row['member_id'];
$ticker_text = strip_comcode(get_translated_text($row['p_post'], $GLOBALS['FORUM_DB']));
$drops[] = rain_get_special_icons($row['p_ip_address'], $timestamp, NULL, $ticker_text) + array('TYPE' => 'post', 'FROM_MEMBER_ID' => strval($member_id), 'TO_MEMBER_ID' => NULL, 'TITLE' => $row['p_title'] == '' ? rain_truncate_for_title(strip_comcode(get_translated_text($row['p_post'], $GLOBALS['FORUM_DB']))) : $row['p_title'], 'IMAGE' => is_guest($member_id) ? rain_get_country_image($row['p_ip_address']) : $GLOBALS['FORUM_DRIVER']->get_member_avatar_url($member_id), 'TIMESTAMP' => strval($timestamp), 'RELATIVE_TIMESTAMP' => strval($timestamp - $from), 'TICKER_TEXT' => $ticker_text, 'URL' => $GLOBALS['FORUM_DRIVER']->post_url($row['id'], $row['p_cache_forum_id']), 'IS_POSITIVE' => false, 'IS_NEGATIVE' => false, 'FROM_ID' => 'member_' . strval($member_id), 'TO_ID' => NULL, 'GROUP_ID' => 'post_' . strval($row['id']));
}
}
}
return $drops;
}