mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-30 21:40:43 +02:00
[ticket/12990] Use the full services name for the notification's types
PHPBB3-12990
This commit is contained in:
@@ -0,0 +1,117 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpbb\db\migration\data\v310;
|
||||
|
||||
class notifications_use_full_name extends \phpbb\db\migration\migration
|
||||
{
|
||||
private $notification_types = array(
|
||||
'admin_activate_user',
|
||||
'approve_post',
|
||||
'approve_topic',
|
||||
'bookmark',
|
||||
'disapprove_post',
|
||||
'disapprove_topic',
|
||||
'group_request',
|
||||
'group_request_approved',
|
||||
'pm',
|
||||
'post',
|
||||
'post_in_queue',
|
||||
'quote',
|
||||
'report_pm',
|
||||
'report_pm_closed',
|
||||
'report_post',
|
||||
'report_post_closed',
|
||||
'topic',
|
||||
'topic_in_queue');
|
||||
|
||||
private $notification_methods = array(
|
||||
'email',
|
||||
'jabber',
|
||||
);
|
||||
|
||||
static public function depends_on()
|
||||
{
|
||||
return array('\phpbb\db\migration\data\v310\rc3');
|
||||
}
|
||||
|
||||
public function update_data()
|
||||
{
|
||||
return array(
|
||||
array('custom', array(array($this, 'update_notifications_name'))),
|
||||
array('custom', array(array($this, 'update_notifications_method_name'))),
|
||||
);
|
||||
}
|
||||
|
||||
public function revert_data()
|
||||
{
|
||||
return array(
|
||||
array('custom', array(array($this, 'revert_notifications_name'))),
|
||||
array('custom', array(array($this, 'revert_notifications_method_name'))),
|
||||
);
|
||||
}
|
||||
|
||||
public function update_notifications_method_name()
|
||||
{
|
||||
foreach ($this->notification_methods as $notification_method)
|
||||
{
|
||||
$sql = 'UPDATE ' . USER_NOTIFICATIONS_TABLE . "
|
||||
SET method = 'notification.method.${notification_method}'
|
||||
WHERE method = '${notification_method}'";
|
||||
$this->db->sql_query($sql);
|
||||
}
|
||||
}
|
||||
|
||||
public function revert_notifications_method_name()
|
||||
{
|
||||
foreach ($this->notification_methods as $notification_method)
|
||||
{
|
||||
$sql = 'UPDATE ' . USER_NOTIFICATIONS_TABLE . "
|
||||
SET method = '${notification_method}'
|
||||
WHERE method = 'notification.method.${notification_method}'";
|
||||
$this->db->sql_query($sql);
|
||||
}
|
||||
}
|
||||
|
||||
public function update_notifications_name()
|
||||
{
|
||||
foreach ($this->notification_types as $notification_type)
|
||||
{
|
||||
$sql = 'UPDATE ' . NOTIFICATION_TYPES_TABLE . "
|
||||
SET notification_type_name = 'notification.type.${notification_type}'
|
||||
WHERE notification_type_name = '${notification_type}'";
|
||||
$this->db->sql_query($sql);
|
||||
|
||||
$sql = 'UPDATE ' . USER_NOTIFICATIONS_TABLE . "
|
||||
SET item_type = 'notification.type.${notification_type}'
|
||||
WHERE item_type = '${notification_type}'";
|
||||
$this->db->sql_query($sql);
|
||||
}
|
||||
}
|
||||
|
||||
public function revert_notifications_name()
|
||||
{
|
||||
foreach ($this->notification_types as $notification_type)
|
||||
{
|
||||
$sql = 'UPDATE ' . NOTIFICATION_TYPES_TABLE . "
|
||||
SET notification_type_name = '${notification_type}'
|
||||
WHERE notification_type_name = 'notification.type.${notification_type}'";
|
||||
$this->db->sql_query($sql);
|
||||
|
||||
$sql = 'UPDATE ' . USER_NOTIFICATIONS_TABLE . "
|
||||
SET item_type = '${notification_type}'
|
||||
WHERE item_type = 'notification.type.${notification_type}'";
|
||||
$this->db->sql_query($sql);
|
||||
}
|
||||
}
|
||||
}
|
@@ -570,7 +570,7 @@ class manager
|
||||
{
|
||||
$subscription_methods[$method_name] = array(
|
||||
'id' => $method->get_type(),
|
||||
'lang' => 'NOTIFICATION_METHOD_' . strtoupper($method->get_type()),
|
||||
'lang' => str_replace('.', '_', strtoupper($method->get_type())),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -851,8 +851,6 @@ class manager
|
||||
*/
|
||||
public function get_item_type_class($notification_type_name, $data = array())
|
||||
{
|
||||
$notification_type_name = (strpos($notification_type_name, 'notification.type.') === 0) ? $notification_type_name : 'notification.type.' . $notification_type_name;
|
||||
|
||||
$item = $this->load_object($notification_type_name);
|
||||
|
||||
$item->set_initial_data($data);
|
||||
@@ -865,8 +863,6 @@ class manager
|
||||
*/
|
||||
public function get_method_class($method_name)
|
||||
{
|
||||
$method_name = (strpos($method_name, 'notification.method.') === 0) ? $method_name : 'notification.method.' . $method_name;
|
||||
|
||||
return $this->load_object($method_name);
|
||||
}
|
||||
|
||||
|
@@ -27,7 +27,7 @@ class email extends \phpbb\notification\method\messenger_base
|
||||
*/
|
||||
public function get_type()
|
||||
{
|
||||
return 'email';
|
||||
return 'notification.method.email';
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -27,7 +27,7 @@ class jabber extends \phpbb\notification\method\messenger_base
|
||||
*/
|
||||
public function get_type()
|
||||
{
|
||||
return 'jabber';
|
||||
return 'notification.method.jabber';
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -25,7 +25,7 @@ class admin_activate_user extends \phpbb\notification\type\base
|
||||
*/
|
||||
public function get_type()
|
||||
{
|
||||
return 'admin_activate_user';
|
||||
return 'notification.type.admin_activate_user';
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -27,7 +27,7 @@ class approve_post extends \phpbb\notification\type\post
|
||||
*/
|
||||
public function get_type()
|
||||
{
|
||||
return 'approve_post';
|
||||
return 'notification.type.approve_post';
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -27,7 +27,7 @@ class approve_topic extends \phpbb\notification\type\topic
|
||||
*/
|
||||
public function get_type()
|
||||
{
|
||||
return 'approve_topic';
|
||||
return 'notification.type.approve_topic';
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -27,7 +27,7 @@ class bookmark extends \phpbb\notification\type\post
|
||||
*/
|
||||
public function get_type()
|
||||
{
|
||||
return 'bookmark';
|
||||
return 'notification.type.bookmark';
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -27,7 +27,7 @@ class disapprove_post extends \phpbb\notification\type\approve_post
|
||||
*/
|
||||
public function get_type()
|
||||
{
|
||||
return 'disapprove_post';
|
||||
return 'notification.type.disapprove_post';
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -27,7 +27,7 @@ class disapprove_topic extends \phpbb\notification\type\approve_topic
|
||||
*/
|
||||
public function get_type()
|
||||
{
|
||||
return 'disapprove_topic';
|
||||
return 'notification.type.disapprove_topic';
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -20,7 +20,7 @@ class group_request extends \phpbb\notification\type\base
|
||||
*/
|
||||
public function get_type()
|
||||
{
|
||||
return 'group_request';
|
||||
return 'notification.type.group_request';
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -20,7 +20,7 @@ class group_request_approved extends \phpbb\notification\type\base
|
||||
*/
|
||||
public function get_type()
|
||||
{
|
||||
return 'group_request_approved';
|
||||
return 'notification.type.group_request_approved';
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -27,7 +27,7 @@ class pm extends \phpbb\notification\type\base
|
||||
*/
|
||||
public function get_type()
|
||||
{
|
||||
return 'pm';
|
||||
return 'notification.type.pm';
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -27,7 +27,7 @@ class post extends \phpbb\notification\type\base
|
||||
*/
|
||||
public function get_type()
|
||||
{
|
||||
return 'post';
|
||||
return 'notification.type.post';
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -27,7 +27,7 @@ class post_in_queue extends \phpbb\notification\type\post
|
||||
*/
|
||||
public function get_type()
|
||||
{
|
||||
return 'post_in_queue';
|
||||
return 'notification.type.post_in_queue';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -44,7 +44,7 @@ class post_in_queue extends \phpbb\notification\type\post
|
||||
* Array of data (including keys 'id', 'lang', and 'group')
|
||||
*/
|
||||
public static $notification_option = array(
|
||||
'id' => 'needs_approval',
|
||||
'id' => 'notification.type.needs_approval',
|
||||
'lang' => 'NOTIFICATION_TYPE_IN_MODERATION_QUEUE',
|
||||
'group' => 'NOTIFICATION_GROUP_MODERATION',
|
||||
);
|
||||
|
@@ -27,7 +27,7 @@ class quote extends \phpbb\notification\type\post
|
||||
*/
|
||||
public function get_type()
|
||||
{
|
||||
return 'quote';
|
||||
return 'notification.type.quote';
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -27,7 +27,7 @@ class report_pm extends \phpbb\notification\type\pm
|
||||
*/
|
||||
public function get_type()
|
||||
{
|
||||
return 'report_pm';
|
||||
return 'notification.type.report_pm';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -61,7 +61,7 @@ class report_pm extends \phpbb\notification\type\pm
|
||||
* Array of data (including keys 'id', 'lang', and 'group')
|
||||
*/
|
||||
public static $notification_option = array(
|
||||
'id' => 'report',
|
||||
'id' => 'notification.type.report',
|
||||
'lang' => 'NOTIFICATION_TYPE_REPORT',
|
||||
'group' => 'NOTIFICATION_GROUP_MODERATION',
|
||||
);
|
||||
|
@@ -27,7 +27,7 @@ class report_pm_closed extends \phpbb\notification\type\pm
|
||||
*/
|
||||
public function get_type()
|
||||
{
|
||||
return 'report_pm_closed';
|
||||
return 'notification.type.report_pm_closed';
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -26,7 +26,7 @@ class report_post extends \phpbb\notification\type\post_in_queue
|
||||
*/
|
||||
public function get_type()
|
||||
{
|
||||
return 'report_post';
|
||||
return 'notification.type.report_post';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -67,7 +67,7 @@ class report_post extends \phpbb\notification\type\post_in_queue
|
||||
* Array of data (including keys 'id' and 'lang')
|
||||
*/
|
||||
public static $notification_option = array(
|
||||
'id' => 'report',
|
||||
'id' => 'notification.type.report',
|
||||
'lang' => 'NOTIFICATION_TYPE_REPORT',
|
||||
'group' => 'NOTIFICATION_GROUP_MODERATION',
|
||||
);
|
||||
|
@@ -27,7 +27,7 @@ class report_post_closed extends \phpbb\notification\type\post
|
||||
*/
|
||||
public function get_type()
|
||||
{
|
||||
return 'report_post_closed';
|
||||
return 'notification.type.report_post_closed';
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -27,7 +27,7 @@ class topic extends \phpbb\notification\type\base
|
||||
*/
|
||||
public function get_type()
|
||||
{
|
||||
return 'topic';
|
||||
return 'notification.type.topic';
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -27,7 +27,7 @@ class topic_in_queue extends \phpbb\notification\type\topic
|
||||
*/
|
||||
public function get_type()
|
||||
{
|
||||
return 'topic_in_queue';
|
||||
return 'notification.type.topic_in_queue';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -44,7 +44,7 @@ class topic_in_queue extends \phpbb\notification\type\topic
|
||||
* Array of data (including keys 'id', 'lang', and 'group')
|
||||
*/
|
||||
public static $notification_option = array(
|
||||
'id' => 'needs_approval',
|
||||
'id' => 'notification.type.needs_approval',
|
||||
'lang' => 'NOTIFICATION_TYPE_IN_MODERATION_QUEUE',
|
||||
'group' => 'NOTIFICATION_GROUP_MODERATION',
|
||||
);
|
||||
|
Reference in New Issue
Block a user