[ Index ] |
PHP Cross Reference of phpBB-3.1.12-deutsch |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * 4 * This file is part of the phpBB Forum Software package. 5 * 6 * @copyright (c) phpBB Limited <https://www.phpbb.com> 7 * @license GNU General Public License, version 2 (GPL-2.0) 8 * 9 * For full copyright and license information, please see 10 * the docs/CREDITS.txt file. 11 * 12 */ 13 14 namespace phpbb\feed; 15 16 /** 17 * Forum feed 18 * 19 * This will give you the last {$this->num_items} posts made 20 * within a specific forum. 21 */ 22 class forum extends \phpbb\feed\post_base 23 { 24 var $forum_id = 0; 25 var $forum_data = array(); 26 27 /** 28 * Set the Forum ID 29 * 30 * @param int $forum_id Forum ID 31 * @return \phpbb\feed\forum 32 */ 33 public function set_forum_id($forum_id) 34 { 35 $this->forum_id = (int) $forum_id; 36 37 return $this; 38 } 39 40 function open() 41 { 42 // Check if forum exists 43 $sql = 'SELECT forum_id, forum_name, forum_password, forum_type, forum_options 44 FROM ' . FORUMS_TABLE . ' 45 WHERE forum_id = ' . $this->forum_id; 46 $result = $this->db->sql_query($sql); 47 $this->forum_data = $this->db->sql_fetchrow($result); 48 $this->db->sql_freeresult($result); 49 50 if (empty($this->forum_data)) 51 { 52 trigger_error('NO_FORUM'); 53 } 54 55 // Forum needs to be postable 56 if ($this->forum_data['forum_type'] != FORUM_POST) 57 { 58 trigger_error('NO_FEED'); 59 } 60 61 // Make sure forum is not excluded from feed 62 if (phpbb_optionget(FORUM_OPTION_FEED_EXCLUDE, $this->forum_data['forum_options'])) 63 { 64 trigger_error('NO_FEED'); 65 } 66 67 // Make sure we can read this forum 68 if (!$this->auth->acl_get('f_read', $this->forum_id)) 69 { 70 trigger_error('SORRY_AUTH_READ'); 71 } 72 73 // Make sure forum is not passworded or user is authed 74 if ($this->forum_data['forum_password']) 75 { 76 $forum_ids_passworded = $this->get_passworded_forums(); 77 78 if (isset($forum_ids_passworded[$this->forum_id])) 79 { 80 trigger_error('SORRY_AUTH_READ'); 81 } 82 83 unset($forum_ids_passworded); 84 } 85 86 parent::open(); 87 } 88 89 function get_sql() 90 { 91 // Determine topics with recent activity 92 $sql = 'SELECT topic_id, topic_last_post_time 93 FROM ' . TOPICS_TABLE . ' 94 WHERE forum_id = ' . $this->forum_id . ' 95 AND topic_moved_id = 0 96 AND ' . $this->content_visibility->get_visibility_sql('topic', $this->forum_id) . ' 97 ORDER BY topic_last_post_time DESC, topic_last_post_id DESC'; 98 $result = $this->db->sql_query_limit($sql, $this->num_items); 99 100 $topic_ids = array(); 101 $min_post_time = 0; 102 while ($row = $this->db->sql_fetchrow()) 103 { 104 $topic_ids[] = (int) $row['topic_id']; 105 106 $min_post_time = (int) $row['topic_last_post_time']; 107 } 108 $this->db->sql_freeresult($result); 109 110 if (empty($topic_ids)) 111 { 112 return false; 113 } 114 115 parent::fetch_attachments(array(), $topic_ids); 116 117 $this->sql = array( 118 'SELECT' => 'p.post_id, p.topic_id, p.post_time, p.post_edit_time, p.post_visibility, p.post_subject, p.post_text, p.bbcode_bitfield, p.bbcode_uid, p.enable_bbcode, p.enable_smilies, p.enable_magic_url, p.post_attachment, ' . 119 'u.username, u.user_id', 120 'FROM' => array( 121 POSTS_TABLE => 'p', 122 USERS_TABLE => 'u', 123 ), 124 'WHERE' => $this->db->sql_in_set('p.topic_id', $topic_ids) . ' 125 AND ' . $this->content_visibility->get_visibility_sql('post', $this->forum_id, 'p.') . ' 126 AND p.post_time >= ' . $min_post_time . ' 127 AND p.poster_id = u.user_id', 128 'ORDER_BY' => 'p.post_time DESC, p.post_id DESC', 129 ); 130 131 return true; 132 } 133 134 function adjust_item(&$item_row, &$row) 135 { 136 parent::adjust_item($item_row, $row); 137 138 $item_row['title'] = (isset($row['forum_name']) && $row['forum_name'] !== '') ? $row['forum_name'] . ' ' . $this->separator . ' ' . $item_row['title'] : $item_row['title']; 139 $item_row['forum_id'] = $this->forum_id; 140 } 141 142 function get_item() 143 { 144 return ($row = parent::get_item()) ? array_merge($this->forum_data, $row) : $row; 145 } 146 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Jan 11 00:25:41 2018 | Cross-referenced by PHPXref 0.7.1 |