[ 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 * Topic feed for a specific topic 18 * 19 * This will give you the last {$this->num_items} posts made within this topic. 20 */ 21 class topic extends \phpbb\feed\post_base 22 { 23 var $topic_id = 0; 24 var $forum_id = 0; 25 var $topic_data = array(); 26 27 /** 28 * Set the Topic ID 29 * 30 * @param int $topic_id Topic ID 31 * @return \phpbb\feed\topic 32 */ 33 public function set_topic_id($topic_id) 34 { 35 $this->topic_id = (int) $topic_id; 36 37 return $this; 38 } 39 40 function open() 41 { 42 $sql = 'SELECT f.forum_options, f.forum_password, t.topic_id, t.forum_id, t.topic_visibility, t.topic_title, t.topic_time, t.topic_views, t.topic_posts_approved, t.topic_type 43 FROM ' . TOPICS_TABLE . ' t 44 LEFT JOIN ' . FORUMS_TABLE . ' f 45 ON (f.forum_id = t.forum_id) 46 WHERE t.topic_id = ' . $this->topic_id; 47 $result = $this->db->sql_query($sql); 48 $this->topic_data = $this->db->sql_fetchrow($result); 49 $this->db->sql_freeresult($result); 50 51 if (empty($this->topic_data)) 52 { 53 trigger_error('NO_TOPIC'); 54 } 55 56 $this->forum_id = (int) $this->topic_data['forum_id']; 57 58 // Make sure topic is either approved or user authed 59 if ($this->topic_data['topic_visibility'] != ITEM_APPROVED && !$this->auth->acl_get('m_approve', $this->forum_id)) 60 { 61 trigger_error('SORRY_AUTH_READ'); 62 } 63 64 // Make sure forum is not excluded from feed 65 if (phpbb_optionget(FORUM_OPTION_FEED_EXCLUDE, $this->topic_data['forum_options'])) 66 { 67 trigger_error('NO_FEED'); 68 } 69 70 // Make sure we can read this forum 71 if (!$this->auth->acl_get('f_read', $this->forum_id)) 72 { 73 trigger_error('SORRY_AUTH_READ'); 74 } 75 76 // Make sure forum is not passworded or user is authed 77 if ($this->topic_data['forum_password']) 78 { 79 $forum_ids_passworded = $this->get_passworded_forums(); 80 81 if (isset($forum_ids_passworded[$this->forum_id])) 82 { 83 trigger_error('SORRY_AUTH_READ'); 84 } 85 86 unset($forum_ids_passworded); 87 } 88 89 parent::open(); 90 } 91 92 function get_sql() 93 { 94 parent::fetch_attachments(); 95 96 $this->sql = array( 97 'SELECT' => 'p.post_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, ' . 98 'u.username, u.user_id', 99 'FROM' => array( 100 POSTS_TABLE => 'p', 101 USERS_TABLE => 'u', 102 ), 103 'WHERE' => 'p.topic_id = ' . $this->topic_id . ' 104 AND ' . $this->content_visibility->get_visibility_sql('post', $this->forum_id, 'p.') . ' 105 AND p.poster_id = u.user_id', 106 'ORDER_BY' => 'p.post_time DESC, p.post_id DESC', 107 ); 108 109 return true; 110 } 111 112 function adjust_item(&$item_row, &$row) 113 { 114 parent::adjust_item($item_row, $row); 115 116 $item_row['forum_id'] = $this->forum_id; 117 } 118 119 function get_item() 120 { 121 return ($row = parent::get_item()) ? array_merge($this->topic_data, $row) : $row; 122 } 123 }
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 |