/vb/activitystream/view/perm/forum/thread.php

https://gitlab.com/elasa/vb-elasa.ir · PHP · 141 lines · 103 code · 15 blank · 23 comment · 7 complexity · c490786545f94229abaa5dbebc1f859a MD5 · raw file

  1. <?php
  2. /* ======================================================================*\
  3. || #################################################################### ||
  4. || # vBulletin 4.2.2
  5. || # ---------------------------------------------------------------- # ||
  6. || # Copyright ©2000-2013 vBulletin Solutions Inc. All Rights Reserved. ||
  7. || # This file may not be redistributed in whole or significant part. # ||
  8. || # ---------------- VBULLETIN IS NOT FREE SOFTWARE ---------------- # ||
  9. || # http://www.vbulletin.com | http://www.vbulletin.com/license.html # ||
  10. || #################################################################### ||
  11. \*====================================================================== */
  12. class vB_ActivityStream_View_Perm_Forum_Thread extends vB_ActivityStream_View_Perm_Forum_Base
  13. {
  14. public function __construct(&$content, &$vbphrase)
  15. {
  16. $this->requireFirst['vB_ActivityStream_View_Perm_Forum_Post'] = 1;
  17. return parent::__construct($content, $vbphrase);
  18. }
  19. public function group($activity)
  20. {
  21. if (!$this->content['thread'][$activity['contentid']])
  22. {
  23. $this->content['threadid'][$activity['contentid']] = 1;
  24. }
  25. }
  26. public function process()
  27. {
  28. if (!$this->content['threadid'])
  29. {
  30. return true;
  31. }
  32. $threads = vB::$db->query_read_slave("
  33. SELECT
  34. t.threadid, t.title, t.forumid, t.pollid, t.open, t.views, t.visible, t.postuserid, t.postuserid AS userid, t.replycount,
  35. t.postusername, t.prefixid, fp.pagetext
  36. FROM " . TABLE_PREFIX . "thread AS t
  37. INNER JOIN " . TABLE_PREFIX . "post AS fp ON (t.firstpostid = fp.postid)
  38. WHERE
  39. t.threadid IN (" . implode(",", array_keys($this->content['threadid'])) . ")
  40. AND
  41. t.visible <> 2
  42. ");
  43. while ($thread = vB::$db->fetch_array($threads))
  44. {
  45. $this->content['forumid'][$thread['forumid']] = 1;
  46. $this->content['thread'][$thread['threadid']] = $thread;
  47. $this->content['userid'][$thread['postuserid']] = 1;
  48. }
  49. $this->content['threadid'] = array();
  50. }
  51. public function fetchCanView($record)
  52. {
  53. $this->processUsers();
  54. return $this->fetchCanViewThread($record['contentid']);
  55. }
  56. /*
  57. * Register Template
  58. *
  59. * @param string Template Name
  60. * @param array Activity Record
  61. *
  62. * @return string Template
  63. */
  64. public function fetchTemplate($templatename, $activity, $skipgroup = false, $fetchphrase = false)
  65. {
  66. global $show;
  67. $threadinfo =& $this->content['thread'][$activity['contentid']];
  68. $foruminfo =& vB::$vbulletin->forumcache[$threadinfo['forumid']];
  69. $threadinfo['prefix_plain_html'] = htmlspecialchars_uni($this->vbphrase["prefix_{$threadinfo['prefixid']}_title_plain"]);
  70. $threadinfo['prefix_rich'] = $this->vbphrase["prefix_{$threadinfo['prefixid']}_title_rich"];
  71. $activity['postdate'] = vbdate(vB::$vbulletin->options['dateformat'], $activity['dateline'], true);
  72. $activity['posttime'] = vbdate(vB::$vbulletin->options['timeformat'], $activity['dateline']);
  73. $threadinfo['preview'] = strip_quotes($threadinfo['pagetext']);
  74. $threadinfo['preview'] = htmlspecialchars_uni(fetch_censored_text(
  75. fetch_trimmed_title(strip_bbcode($threadinfo['preview'], false, true, true, true),
  76. vb::$vbulletin->options['as_snippet'])
  77. ));
  78. $forumperms = fetch_permissions($threadinfo['forumid']);
  79. $show['threadcontent'] = ($forumperms & vB::$vbulletin->bf_ugp_forumpermissions['canviewthreads']) ? true : false;
  80. $userinfo = $this->fetchUser($activity['userid'], $threadinfo['postusername']);
  81. if ($fetchphrase)
  82. {
  83. if ($threadinfo['pollid'])
  84. {
  85. if ($userinfo['userid'])
  86. {
  87. $phrase = construct_phrase($this->vbphrase['x_started_a_poll_y_in_z'], fetch_seo_url('member', $userinfo), $userinfo['username'], fetch_seo_url('thread', $threadinfo), $threadinfo['prefix_rich'], $threadinfo['title'], fetch_seo_url('forum', $foruminfo), $foruminfo['title']);
  88. }
  89. else
  90. {
  91. $phrase = construct_phrase($this->vbphrase['guest_x_started_a_poll_y_in_z'], $userinfo['username'], fetch_seo_url('thread', $threadinfo), $threadinfo['prefix_rich'], $threadinfo['title'], fetch_seo_url('forum', $foruminfo), $foruminfo['title']);
  92. }
  93. }
  94. else
  95. {
  96. if ($userinfo['userid'])
  97. {
  98. $phrase = construct_phrase($this->vbphrase['x_started_a_thread_y_in_z'], fetch_seo_url('member', $userinfo), $userinfo['username'], fetch_seo_url('thread', $threadinfo), $threadinfo['prefix_rich'], $threadinfo['title'], fetch_seo_url('forum', $foruminfo), $foruminfo['title']);
  99. }
  100. else
  101. {
  102. $phrase = construct_phrase($this->vbphrase['guest_x_started_a_thread_y_in_z'], $userinfo['username'], fetch_seo_url('thread', $threadinfo), $threadinfo['prefix_rich'], $threadinfo['title'], fetch_seo_url('forum', $foruminfo), $foruminfo['title']);
  103. }
  104. }
  105. return array(
  106. 'phrase' => $phrase,
  107. 'userinfo' => $userinfo,
  108. 'activity' => $activity,
  109. );
  110. }
  111. else
  112. {
  113. $templater = vB_Template::create($templatename);
  114. $templater->register('userinfo', $userinfo);
  115. $templater->register('activity', $activity);
  116. $templater->register('threadinfo', $threadinfo);
  117. $templater->register('foruminfo', $foruminfo);
  118. return $templater->render();
  119. }
  120. }
  121. }
  122. /*======================================================================*\
  123. || ####################################################################
  124. || # CVS: $RCSfile$ - $Revision: 57655 $
  125. || ####################################################################
  126. \*======================================================================*/