PageRenderTime 43ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/wwwroot/phpbb/phpbb/notification/type/topic_in_queue.php

https://github.com/spring/spring-website
PHP | 152 lines | 64 code | 21 blank | 67 comment | 4 complexity | 7fb3f656b5de28e4bac301d5122e0c42 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1, Apache-2.0, LGPL-3.0, BSD-3-Clause
  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. namespace phpbb\notification\type;
  14. /**
  15. * Topic in queue notifications class
  16. * This class handles notifications for topics when they are put in the moderation queue (for moderators)
  17. */
  18. class topic_in_queue extends \phpbb\notification\type\topic
  19. {
  20. /**
  21. * Get notification type name
  22. *
  23. * @return string
  24. */
  25. public function get_type()
  26. {
  27. return 'notification.type.topic_in_queue';
  28. }
  29. /**
  30. * Language key used to output the text
  31. *
  32. * @var string
  33. */
  34. protected $language_key = 'NOTIFICATION_TOPIC_IN_QUEUE';
  35. /**
  36. * Notification option data (for outputting to the user)
  37. *
  38. * @var bool|array False if the service should use it's default data
  39. * Array of data (including keys 'id', 'lang', and 'group')
  40. */
  41. public static $notification_option = array(
  42. 'id' => 'notification.type.needs_approval',
  43. 'lang' => 'NOTIFICATION_TYPE_IN_MODERATION_QUEUE',
  44. 'group' => 'NOTIFICATION_GROUP_MODERATION',
  45. );
  46. /**
  47. * Permission to check for (in find_users_for_notification)
  48. *
  49. * @var string Permission name
  50. */
  51. protected $permission = 'm_approve';
  52. /**
  53. * Is available
  54. */
  55. public function is_available()
  56. {
  57. $has_permission = $this->auth->acl_getf($this->permission, true);
  58. return (!empty($has_permission));
  59. }
  60. /**
  61. * Find the users who want to receive notifications
  62. *
  63. * @param array $topic Data from the topic
  64. * @param array $options Options for finding users for notification
  65. *
  66. * @return array
  67. */
  68. public function find_users_for_notification($topic, $options = array())
  69. {
  70. $options = array_merge(array(
  71. 'ignore_users' => array(),
  72. ), $options);
  73. // 0 is for global moderator permissions
  74. $auth_approve = $this->auth->acl_get_list(false, 'm_approve', array($topic['forum_id'], 0));
  75. if (empty($auth_approve))
  76. {
  77. return array();
  78. }
  79. $has_permission = array();
  80. if (isset($auth_approve[$topic['forum_id']][$this->permission]))
  81. {
  82. $has_permission = $auth_approve[$topic['forum_id']][$this->permission];
  83. }
  84. if (isset($auth_approve[0][$this->permission]))
  85. {
  86. $has_permission = array_unique(array_merge($has_permission, $auth_approve[0][$this->permission]));
  87. }
  88. sort($has_permission);
  89. $auth_read = $this->auth->acl_get_list($has_permission, 'f_read', $topic['forum_id']);
  90. if (empty($auth_read))
  91. {
  92. return array();
  93. }
  94. return $this->check_user_notification_options($auth_read[$topic['forum_id']]['f_read'], array_merge($options, array(
  95. 'item_type' => self::$notification_option['id'],
  96. )));
  97. }
  98. /**
  99. * Get the url to this item
  100. *
  101. * @return string URL
  102. */
  103. public function get_url()
  104. {
  105. return append_sid($this->phpbb_root_path . 'mcp.' . $this->php_ext, "i=queue&amp;mode=approve_details&amp;f={$this->item_parent_id}&amp;t={$this->item_id}");
  106. }
  107. /**
  108. * Function for preparing the data for insertion in an SQL query
  109. * (The service handles insertion)
  110. *
  111. * @param array $topic Data from submit_post
  112. * @param array $pre_create_data Data from pre_create_insert_array()
  113. *
  114. * @return array Array of data ready to be inserted into the database
  115. */
  116. public function create_insert_array($topic, $pre_create_data = array())
  117. {
  118. $data = parent::create_insert_array($topic, $pre_create_data);
  119. $this->notification_time = $data['notification_time'] = time();
  120. return $data;
  121. }
  122. /**
  123. * Get email template
  124. *
  125. * @return string|bool
  126. */
  127. public function get_email_template()
  128. {
  129. return 'topic_in_queue';
  130. }
  131. }