mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-13 14:58:52 +00:00
Merge pull request #3076 from marc1706/ticket/12703
[ticket/12703] Only query database for subscription types once * marc1706/ticket/12703: [ticket/12703] Only query database for subscription types once
This commit is contained in:
commit
bb4f65d743
1 changed files with 26 additions and 20 deletions
|
@ -23,6 +23,9 @@ class manager
|
||||||
/** @var array */
|
/** @var array */
|
||||||
protected $notification_types;
|
protected $notification_types;
|
||||||
|
|
||||||
|
/** @var array */
|
||||||
|
protected $subscription_types;
|
||||||
|
|
||||||
/** @var array */
|
/** @var array */
|
||||||
protected $notification_methods;
|
protected $notification_methods;
|
||||||
|
|
||||||
|
@ -524,33 +527,36 @@ class manager
|
||||||
*/
|
*/
|
||||||
public function get_subscription_types()
|
public function get_subscription_types()
|
||||||
{
|
{
|
||||||
$subscription_types = array();
|
if ($this->subscription_types === null)
|
||||||
|
|
||||||
foreach ($this->notification_types as $type_name => $data)
|
|
||||||
{
|
{
|
||||||
$type = $this->get_item_type_class($type_name);
|
$this->subscription_types = array();
|
||||||
|
|
||||||
if ($type instanceof \phpbb\notification\type\type_interface && $type->is_available())
|
foreach ($this->notification_types as $type_name => $data)
|
||||||
{
|
{
|
||||||
$options = array_merge(array(
|
$type = $this->get_item_type_class($type_name);
|
||||||
'id' => $type->get_type(),
|
|
||||||
'lang' => 'NOTIFICATION_TYPE_' . strtoupper($type->get_type()),
|
|
||||||
'group' => 'NOTIFICATION_GROUP_MISCELLANEOUS',
|
|
||||||
), (($type::$notification_option !== false) ? $type::$notification_option : array()));
|
|
||||||
|
|
||||||
$subscription_types[$options['group']][$options['id']] = $options;
|
if ($type instanceof \phpbb\notification\type\type_interface && $type->is_available())
|
||||||
|
{
|
||||||
|
$options = array_merge(array(
|
||||||
|
'id' => $type->get_type(),
|
||||||
|
'lang' => 'NOTIFICATION_TYPE_' . strtoupper($type->get_type()),
|
||||||
|
'group' => 'NOTIFICATION_GROUP_MISCELLANEOUS',
|
||||||
|
), (($type::$notification_option !== false) ? $type::$notification_option : array()));
|
||||||
|
|
||||||
|
$this->subscription_types[$options['group']][$options['id']] = $options;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Move Miscellaneous to the very last section
|
||||||
|
if (isset($this->subscription_types['NOTIFICATION_GROUP_MISCELLANEOUS']))
|
||||||
|
{
|
||||||
|
$miscellaneous = $this->subscription_types['NOTIFICATION_GROUP_MISCELLANEOUS'];
|
||||||
|
unset($this->subscription_types['NOTIFICATION_GROUP_MISCELLANEOUS']);
|
||||||
|
$this->subscription_types['NOTIFICATION_GROUP_MISCELLANEOUS'] = $miscellaneous;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Move Miscellaneous to the very last section
|
return $this->subscription_types;
|
||||||
if (isset($subscription_types['NOTIFICATION_GROUP_MISCELLANEOUS']))
|
|
||||||
{
|
|
||||||
$miscellaneous = $subscription_types['NOTIFICATION_GROUP_MISCELLANEOUS'];
|
|
||||||
unset($subscription_types['NOTIFICATION_GROUP_MISCELLANEOUS']);
|
|
||||||
$subscription_types['NOTIFICATION_GROUP_MISCELLANEOUS'] = $miscellaneous;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $subscription_types;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Reference in a new issue