aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/phpbb/notification
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/phpbb/notification')
-rw-r--r--phpBB/phpbb/notification/manager.php33
-rw-r--r--phpBB/phpbb/notification/method/board.php2
-rw-r--r--phpBB/phpbb/notification/method/email.php2
-rw-r--r--phpBB/phpbb/notification/method/messenger_base.php4
-rw-r--r--phpBB/phpbb/notification/type/admin_activate_user.php2
-rw-r--r--phpBB/phpbb/notification/type/pm.php2
-rw-r--r--phpBB/phpbb/notification/type/post.php10
-rw-r--r--phpBB/phpbb/notification/type/report_pm.php13
-rw-r--r--phpBB/phpbb/notification/type/topic.php2
9 files changed, 31 insertions, 39 deletions
diff --git a/phpBB/phpbb/notification/manager.php b/phpBB/phpbb/notification/manager.php
index 1cd7e5bc9a..52c650df5d 100644
--- a/phpBB/phpbb/notification/manager.php
+++ b/phpBB/phpbb/notification/manager.php
@@ -339,7 +339,7 @@ class manager
}
}
- if (!sizeof($notify_users))
+ if (!count($notify_users))
{
return;
}
@@ -899,32 +899,19 @@ class manager
*/
public function get_notification_type_id($notification_type_name)
{
- $notification_type_ids = $this->cache->get('notification_type_ids');
-
- $this->db->sql_transaction('begin');
-
- if ($notification_type_ids === false)
+ $sql = 'SELECT notification_type_id, notification_type_name
+ FROM ' . $this->notification_types_table;
+ $result = $this->db->sql_query($sql, 604800); // cache for one week
+ while ($row = $this->db->sql_fetchrow($result))
{
- $notification_type_ids = array();
-
- $sql = 'SELECT notification_type_id, notification_type_name
- FROM ' . $this->notification_types_table;
- $result = $this->db->sql_query($sql);
- while ($row = $this->db->sql_fetchrow($result))
- {
- $notification_type_ids[$row['notification_type_name']] = (int) $row['notification_type_id'];
- }
- $this->db->sql_freeresult($result);
-
- $this->cache->put('notification_type_ids', $notification_type_ids);
+ $notification_type_ids[$row['notification_type_name']] = (int) $row['notification_type_id'];
}
+ $this->db->sql_freeresult($result);
if (!isset($notification_type_ids[$notification_type_name]))
{
if (!isset($this->notification_types[$notification_type_name]) && !isset($this->notification_types['notification.type.' . $notification_type_name]))
{
- $this->db->sql_transaction('rollback');
-
throw new \phpbb\notification\exception('NOTIFICATION_TYPE_NOT_EXIST', array($notification_type_name));
}
@@ -934,13 +921,13 @@ class manager
));
$this->db->sql_query($sql);
+ // expose new notification type ID for this request
$notification_type_ids[$notification_type_name] = (int) $this->db->sql_nextid();
- $this->cache->put('notification_type_ids', $notification_type_ids);
+ // destroy cache, we have a new addition which we have to to load next time
+ $this->cache->destroy('sql', $this->notification_types_table);
}
- $this->db->sql_transaction('commit');
-
return $notification_type_ids[$notification_type_name];
}
diff --git a/phpBB/phpbb/notification/method/board.php b/phpBB/phpbb/notification/method/board.php
index 931b252daa..faa53576e0 100644
--- a/phpBB/phpbb/notification/method/board.php
+++ b/phpBB/phpbb/notification/method/board.php
@@ -394,6 +394,6 @@ class board extends \phpbb\notification\method\base
WHERE notification_type_id = ' . (int) $notification_type_id;
$this->db->sql_query($sql);
- $this->cache->destroy('notification_type_ids');
+ $this->cache->destroy('sql', $this->notification_types_table);
}
}
diff --git a/phpBB/phpbb/notification/method/email.php b/phpBB/phpbb/notification/method/email.php
index 56dd1e9367..6376d13dc7 100644
--- a/phpBB/phpbb/notification/method/email.php
+++ b/phpBB/phpbb/notification/method/email.php
@@ -65,7 +65,7 @@ class email extends \phpbb\notification\method\messenger_base
*/
public function is_available(type_interface $notification_type = null)
{
- return parent::is_available($notification_type) && $this->config['email_enable'] && $this->user->data['user_email'];
+ return parent::is_available($notification_type) && $this->config['email_enable'] && !empty($this->user->data['user_email']);
}
/**
diff --git a/phpBB/phpbb/notification/method/messenger_base.php b/phpBB/phpbb/notification/method/messenger_base.php
index 32e79aa936..f82017b70e 100644
--- a/phpBB/phpbb/notification/method/messenger_base.php
+++ b/phpBB/phpbb/notification/method/messenger_base.php
@@ -87,7 +87,7 @@ abstract class messenger_base extends \phpbb\notification\method\base
$banned_users = phpbb_get_banned_user_ids($user_ids);
// Load all the users we need
- $this->user_loader->load_users($user_ids);
+ $this->user_loader->load_users(array_diff($user_ids, $banned_users), array(USER_IGNORE));
// Load the messenger
if (!class_exists('messenger'))
@@ -107,7 +107,7 @@ abstract class messenger_base extends \phpbb\notification\method\base
$user = $this->user_loader->get_user($notification->user_id);
- if ($user['user_type'] == USER_IGNORE || ($user['user_type'] == USER_INACTIVE && $user['user_inactive_reason'] == INACTIVE_MANUAL) || in_array($notification->user_id, $banned_users))
+ if ($user['user_type'] == USER_INACTIVE && $user['user_inactive_reason'] == INACTIVE_MANUAL)
{
continue;
}
diff --git a/phpBB/phpbb/notification/type/admin_activate_user.php b/phpBB/phpbb/notification/type/admin_activate_user.php
index 9f2ae857ef..78c10ac36a 100644
--- a/phpBB/phpbb/notification/type/admin_activate_user.php
+++ b/phpBB/phpbb/notification/type/admin_activate_user.php
@@ -175,7 +175,7 @@ class admin_activate_user extends \phpbb\notification\type\base
/**
* {@inheritdoc}
*/
- public function create_insert_array($user, $pre_create_data)
+ public function create_insert_array($user, $pre_create_data = array())
{
$this->set_data('user_actkey', $user['user_actkey']);
$this->notification_time = $user['user_regdate'];
diff --git a/phpBB/phpbb/notification/type/pm.php b/phpBB/phpbb/notification/type/pm.php
index 8fb9172911..c51586afb9 100644
--- a/phpBB/phpbb/notification/type/pm.php
+++ b/phpBB/phpbb/notification/type/pm.php
@@ -99,7 +99,7 @@ class pm extends \phpbb\notification\type\base
'ignore_users' => array(),
), $options);
- if (!sizeof($pm['recipients']))
+ if (!count($pm['recipients']))
{
return array();
}
diff --git a/phpBB/phpbb/notification/type/post.php b/phpBB/phpbb/notification/type/post.php
index 03221e7c7a..254f4c07b3 100644
--- a/phpBB/phpbb/notification/type/post.php
+++ b/phpBB/phpbb/notification/type/post.php
@@ -202,9 +202,9 @@ class post extends \phpbb\notification\type\base
'username' => $this->get_data('post_username'),
)), $responders);
- $responders_cnt = sizeof($responders);
+ $responders_cnt = count($responders);
$responders = $this->trim_user_ary($responders);
- $trimmed_responders_cnt = $responders_cnt - sizeof($responders);
+ $trimmed_responders_cnt = $responders_cnt - count($responders);
foreach ($responders as $responder)
{
@@ -337,7 +337,7 @@ class post extends \phpbb\notification\type\base
*/
public function trim_user_ary($users)
{
- if (sizeof($users) > 4)
+ if (count($users) > 4)
{
array_splice($users, 3);
}
@@ -357,7 +357,7 @@ class post extends \phpbb\notification\type\base
*/
public function pre_create_insert_array($post, $notify_users)
{
- if (!sizeof($notify_users) || !$this->inherit_read_status)
+ if (!count($notify_users) || !$this->inherit_read_status)
{
return array();
}
@@ -426,7 +426,7 @@ class post extends \phpbb\notification\type\base
// Do not add more than 25 responders,
// we trim the username list to "a, b, c and x others" anyway
// so there is no use to add all of them anyway.
- if (sizeof($responders) > 25)
+ if (count($responders) > 25)
{
return array();
}
diff --git a/phpBB/phpbb/notification/type/report_pm.php b/phpBB/phpbb/notification/type/report_pm.php
index 7e53ffb3ca..444f98270d 100644
--- a/phpBB/phpbb/notification/type/report_pm.php
+++ b/phpBB/phpbb/notification/type/report_pm.php
@@ -142,13 +142,16 @@ class report_pm extends \phpbb\notification\type\pm
*/
public function get_email_template_variables()
{
- $user_data = $this->user_loader->get_user($this->get_data('reporter_id'));
+ $user_data = $this->user_loader->get_user($this->get_data('from_user_id'));
return array(
'AUTHOR_NAME' => htmlspecialchars_decode($user_data['username']),
'SUBJECT' => htmlspecialchars_decode(censor_text($this->get_data('message_subject'))),
- 'U_VIEW_REPORT' => generate_board_url() . "mcp.{$this->php_ext}?r={$this->item_parent_id}&i=pm_reports&mode=pm_report_details",
+ /** @deprecated 3.2.6-RC1 (to be removed in 4.0.0) use {SUBJECT} instead in report_pm.txt */
+ 'TOPIC_TITLE' => htmlspecialchars_decode(censor_text($this->get_data('message_subject'))),
+
+ 'U_VIEW_REPORT' => generate_board_url() . "/mcp.{$this->php_ext}?r={$this->item_parent_id}&i=pm_reports&mode=pm_report_details",
);
}
@@ -236,8 +239,10 @@ class report_pm extends \phpbb\notification\type\pm
*/
public function users_to_query()
{
- return array($this->get_data('reporter_id'));
- }
+ return array(
+ $this->get_data('from_user_id'),
+ $this->get_data('reporter_id'),
+ ); }
/**
* {@inheritdoc}
diff --git a/phpBB/phpbb/notification/type/topic.php b/phpBB/phpbb/notification/type/topic.php
index 671c34fe96..5c42afa8c8 100644
--- a/phpBB/phpbb/notification/type/topic.php
+++ b/phpBB/phpbb/notification/type/topic.php
@@ -261,7 +261,7 @@ class topic extends \phpbb\notification\type\base
*/
public function pre_create_insert_array($post, $notify_users)
{
- if (!sizeof($notify_users) || !$this->inherit_read_status)
+ if (!count($notify_users) || !$this->inherit_read_status)
{
return array();
}