diff options
author | Nathan Guse <nathaniel.guse@gmail.com> | 2012-10-13 23:24:30 -0500 |
---|---|---|
committer | Nathan Guse <nathaniel.guse@gmail.com> | 2012-10-13 23:24:30 -0500 |
commit | 94ffbb4050b2985ee62be0ecc0c6a244532e43ca (patch) | |
tree | b6682a9080b6cf5c35cee14b10d2f4a42085fe31 | |
parent | cb937841269017d13058208378e4c9ad79718c6e (diff) | |
download | forums-94ffbb4050b2985ee62be0ecc0c6a244532e43ca.tar forums-94ffbb4050b2985ee62be0ecc0c6a244532e43ca.tar.gz forums-94ffbb4050b2985ee62be0ecc0c6a244532e43ca.tar.bz2 forums-94ffbb4050b2985ee62be0ecc0c6a244532e43ca.tar.xz forums-94ffbb4050b2985ee62be0ecc0c6a244532e43ca.zip |
[ticket/11103] Add is_disabled column to notifications table
EXTENSION AUTHORS TAKE NOTE! This is to prevent errors with notifications
from extensions!
Set is_disabled to 1 for all your notifications when your extension is
disabled so they are ignored and do not cause errors.
When your extension is enabled again, set is_disabled to 0 and your
notifications will be working again.
PHPBB3-11103
-rw-r--r-- | phpBB/develop/create_schema_files.php | 2 | ||||
-rw-r--r-- | phpBB/includes/notification/manager.php | 15 | ||||
-rw-r--r-- | phpBB/includes/notification/type/base.php | 5 | ||||
-rw-r--r-- | phpBB/includes/notification/type/bookmark.php | 3 | ||||
-rw-r--r-- | phpBB/includes/notification/type/post.php | 3 | ||||
-rw-r--r-- | phpBB/includes/notification/type/quote.php | 6 | ||||
-rw-r--r-- | phpBB/install/database_update.php | 2 | ||||
-rw-r--r-- | phpBB/install/schemas/firebird_schema.sql | 2 | ||||
-rw-r--r-- | phpBB/install/schemas/mssql_schema.sql | 4 | ||||
-rw-r--r-- | phpBB/install/schemas/mysql_40_schema.sql | 4 | ||||
-rw-r--r-- | phpBB/install/schemas/mysql_41_schema.sql | 4 | ||||
-rw-r--r-- | phpBB/install/schemas/oracle_schema.sql | 3 | ||||
-rw-r--r-- | phpBB/install/schemas/postgres_schema.sql | 2 | ||||
-rw-r--r-- | phpBB/install/schemas/sqlite_schema.sql | 2 |
14 files changed, 45 insertions, 12 deletions
diff --git a/phpBB/develop/create_schema_files.php b/phpBB/develop/create_schema_files.php index a1bef4a85a..69aca10e6c 100644 --- a/phpBB/develop/create_schema_files.php +++ b/phpBB/develop/create_schema_files.php @@ -1303,6 +1303,7 @@ function get_schema_struct() 'item_parent_id' => array('UINT', 0), 'user_id' => array('UINT', 0), 'unread' => array('BOOL', 1), + 'is_disabled' => array('BOOL', 0), 'time' => array('TIMESTAMP', 1), 'data' => array('TEXT_UNI', ''), ), @@ -1314,6 +1315,7 @@ function get_schema_struct() 'user_id' => array('INDEX', 'user_id'), 'time' => array('INDEX', 'time'), 'unread' => array('INDEX', 'unread'), + 'is_disabled' => array('INDEX', 'is_disabled'), ), ); diff --git a/phpBB/includes/notification/manager.php b/phpBB/includes/notification/manager.php index 22fa12967a..16fdae6dd0 100644 --- a/phpBB/includes/notification/manager.php +++ b/phpBB/includes/notification/manager.php @@ -94,7 +94,8 @@ class phpbb_notification_manager $sql = 'SELECT COUNT(*) AS count FROM ' . NOTIFICATIONS_TABLE . ' WHERE user_id = ' . (int) $options['user_id'] . ' - AND unread = 1'; + AND unread = 1 + AND is_disabled = 0'; $result = $this->db->sql_query($sql); $unread_count = (int) $this->db->sql_fetchfield('count', $result); $this->db->sql_freeresult($result); @@ -105,7 +106,8 @@ class phpbb_notification_manager // Get the total number of notifications $sql = 'SELECT COUNT(*) AS count FROM ' . NOTIFICATIONS_TABLE . ' - WHERE user_id = ' . (int) $options['user_id']; + WHERE user_id = ' . (int) $options['user_id'] . ' + AND is_disabled = 0'; $result = $this->db->sql_query($sql); $total_count = (int) $this->db->sql_fetchfield('count', $result); $this->db->sql_freeresult($result); @@ -118,7 +120,8 @@ class phpbb_notification_manager FROM ' . NOTIFICATIONS_TABLE . ' WHERE user_id = ' . (int) $options['user_id'] . (($options['notification_id']) ? ((is_array($options['notification_id'])) ? ' AND ' . $this->db->sql_in_set('notification_id', $options['notification_id']) : ' AND notification_id = ' . (int) $options['notification_id']) : '') . ' - ORDER BY ' . $this->db->sql_escape($options['order_by']) . ' ' . $this->db->sql_escape($options['order_dir']); + AND is_disabled = 0 + ORDER BY ' . $this->db->sql_escape($options['order_by']) . ' ' . $this->db->sql_escape($options['order_dir']); $result = $this->db->sql_query_limit($sql, $options['limit'], $options['start']); while ($row = $this->db->sql_fetchrow($result)) @@ -135,7 +138,8 @@ class phpbb_notification_manager WHERE user_id = ' . (int) $options['user_id'] . ' AND unread = 1 AND ' . $this->db->sql_in_set('notification_id', array_keys($rowset), true) . ' - ORDER BY ' . $this->db->sql_escape($options['order_by']) . ' ' . $this->db->sql_escape($options['order_dir']); + AND is_disabled = 0 + ORDER BY ' . $this->db->sql_escape($options['order_by']) . ' ' . $this->db->sql_escape($options['order_dir']); $result = $this->db->sql_query_limit($sql, $options['limit'], $options['start']); while ($row = $this->db->sql_fetchrow($result)) @@ -344,7 +348,8 @@ class phpbb_notification_manager $sql = 'SELECT user_id FROM ' . NOTIFICATIONS_TABLE . " WHERE item_type = '" . $this->db->sql_escape($item_type) . "' - AND item_id = " . (int) $item_id; + AND item_id = " . (int) $item_id . ' + AND is_disabled = 0'; $result = $this->db->sql_query($sql); while ($row = $this->db->sql_fetchrow($result)) { diff --git a/phpBB/includes/notification/type/base.php b/phpBB/includes/notification/type/base.php index f6b61aee49..3aac8a7dd3 100644 --- a/phpBB/includes/notification/type/base.php +++ b/phpBB/includes/notification/type/base.php @@ -42,9 +42,12 @@ abstract class phpbb_notification_type_base implements phpbb_notification_type_i * Indentification data * item_type * item_id - * item_parent_id // Parent item id (ex: for topic => forum_id, for post => topic_id, etc) + * item_parent_id - Parent item id (ex: for topic => forum_id, for post => topic_id, etc) * user_id * unread + * is_disabled - EXTENSION AUTHORS TAKE NOTE! This is to prevent errors with notifications from extensions! + * - Set is_disabled to 1 for all your notifications when your extension is disabled so they are ignored and do not cause errors. + * - When your extension is enabled again, set is_disabled to 0 and your notifications will be working again. * * time * data (special serialized field that each notification type can use to store stuff) diff --git a/phpBB/includes/notification/type/bookmark.php b/phpBB/includes/notification/type/bookmark.php index 8a23859d05..e5435b5829 100644 --- a/phpBB/includes/notification/type/bookmark.php +++ b/phpBB/includes/notification/type/bookmark.php @@ -113,7 +113,8 @@ class phpbb_notification_type_bookmark extends phpbb_notification_type_post FROM ' . NOTIFICATIONS_TABLE . " WHERE item_type = '" . self::get_item_type() . "' AND item_parent_id = " . (int) self::get_item_parent_id($post) . ' - AND unread = 1'; + AND unread = 1 + AND is_disabled = 0'; $result = $this->db->sql_query($sql); while ($row = $this->db->sql_fetchrow($result)) { diff --git a/phpBB/includes/notification/type/post.php b/phpBB/includes/notification/type/post.php index 76a7846f30..a4792cd7f2 100644 --- a/phpBB/includes/notification/type/post.php +++ b/phpBB/includes/notification/type/post.php @@ -138,7 +138,8 @@ class phpbb_notification_type_post extends phpbb_notification_type_base FROM ' . NOTIFICATIONS_TABLE . " WHERE item_type = '" . self::get_item_type() . "' AND item_parent_id = " . (int) self::get_item_parent_id($post) . ' - AND unread = 1'; + AND unread = 1 + AND is_disabled = 0'; $result = $this->db->sql_query($sql); while ($row = $this->db->sql_fetchrow($result)) { diff --git a/phpBB/includes/notification/type/quote.php b/phpBB/includes/notification/type/quote.php index 34907ef8d6..4d1e637820 100644 --- a/phpBB/includes/notification/type/quote.php +++ b/phpBB/includes/notification/type/quote.php @@ -132,7 +132,8 @@ class phpbb_notification_type_quote extends phpbb_notification_type_post FROM ' . NOTIFICATIONS_TABLE . " WHERE item_type = '" . self::get_item_type() . "' AND item_parent_id = " . (int) self::get_item_parent_id($post) . ' - AND unread = 1'; + AND unread = 1 + AND is_disabled = 0'; $result = $this->db->sql_query($sql); while ($row = $this->db->sql_fetchrow($result)) { @@ -161,7 +162,8 @@ class phpbb_notification_type_quote extends phpbb_notification_type_post $sql = 'SELECT user_id FROM ' . NOTIFICATIONS_TABLE . " WHERE item_type = '" . self::get_item_type() . "' - AND item_id = " . self::get_item_id($post); + AND item_id = " . self::get_item_id($post) . ' + AND is_disabled = 0'; $result = $this->db->sql_query($sql); while ($row = $this->db->sql_fetchrow($result)) { diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 958db6b531..73637122ce 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -1133,6 +1133,7 @@ function database_update_info() 'item_parent_id' => array('UINT', 0), 'user_id' => array('UINT', 0), 'unread' => array('BOOL', 1), + 'is_disabled' => array('BOOL', 0), 'time' => array('TIMESTAMP', 1), 'data' => array('TEXT_UNI', ''), ), @@ -1144,6 +1145,7 @@ function database_update_info() 'user_id' => array('INDEX', 'user_id'), 'time' => array('INDEX', 'time'), 'unread' => array('INDEX', 'unread'), + 'is_disabled' => array('INDEX', 'is_disabled'), ), ), USER_NOTIFICATIONS_TABLE => array( diff --git a/phpBB/install/schemas/firebird_schema.sql b/phpBB/install/schemas/firebird_schema.sql index a122f5818f..1e4ae2e132 100644 --- a/phpBB/install/schemas/firebird_schema.sql +++ b/phpBB/install/schemas/firebird_schema.sql @@ -626,6 +626,7 @@ CREATE TABLE phpbb_notifications ( item_parent_id INTEGER DEFAULT 0 NOT NULL, user_id INTEGER DEFAULT 0 NOT NULL, unread INTEGER DEFAULT 1 NOT NULL, + is_disabled INTEGER DEFAULT 0 NOT NULL, time INTEGER DEFAULT 1 NOT NULL, data BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL );; @@ -638,6 +639,7 @@ CREATE INDEX phpbb_notifications_item_pid ON phpbb_notifications(item_parent_id) CREATE INDEX phpbb_notifications_user_id ON phpbb_notifications(user_id);; CREATE INDEX phpbb_notifications_time ON phpbb_notifications(time);; CREATE INDEX phpbb_notifications_unread ON phpbb_notifications(unread);; +CREATE INDEX phpbb_notifications_is_disabled ON phpbb_notifications(is_disabled);; CREATE GENERATOR phpbb_notifications_gen;; SET GENERATOR phpbb_notifications_gen TO 0;; diff --git a/phpBB/install/schemas/mssql_schema.sql b/phpBB/install/schemas/mssql_schema.sql index d056e4ceb5..5a397743c4 100644 --- a/phpBB/install/schemas/mssql_schema.sql +++ b/phpBB/install/schemas/mssql_schema.sql @@ -761,6 +761,7 @@ CREATE TABLE [phpbb_notifications] ( [item_parent_id] [int] DEFAULT (0) NOT NULL , [user_id] [int] DEFAULT (0) NOT NULL , [unread] [int] DEFAULT (1) NOT NULL , + [is_disabled] [int] DEFAULT (0) NOT NULL , [time] [int] DEFAULT (1) NOT NULL , [data] [varchar] (4000) DEFAULT ('') NOT NULL ) ON [PRIMARY] @@ -791,6 +792,9 @@ GO CREATE INDEX [unread] ON [phpbb_notifications]([unread]) ON [PRIMARY] GO +CREATE INDEX [is_disabled] ON [phpbb_notifications]([is_disabled]) ON [PRIMARY] +GO + /* Table: 'phpbb_poll_options' diff --git a/phpBB/install/schemas/mysql_40_schema.sql b/phpBB/install/schemas/mysql_40_schema.sql index eff9dc46b8..fd7f9a6025 100644 --- a/phpBB/install/schemas/mysql_40_schema.sql +++ b/phpBB/install/schemas/mysql_40_schema.sql @@ -438,6 +438,7 @@ CREATE TABLE phpbb_notifications ( item_parent_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, unread tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, + is_disabled tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, time int(11) UNSIGNED DEFAULT '1' NOT NULL, data blob NOT NULL, PRIMARY KEY (notification_id), @@ -446,7 +447,8 @@ CREATE TABLE phpbb_notifications ( KEY item_pid (item_parent_id), KEY user_id (user_id), KEY time (time), - KEY unread (unread) + KEY unread (unread), + KEY is_disabled (is_disabled) ); diff --git a/phpBB/install/schemas/mysql_41_schema.sql b/phpBB/install/schemas/mysql_41_schema.sql index e7e3018572..8700b46c91 100644 --- a/phpBB/install/schemas/mysql_41_schema.sql +++ b/phpBB/install/schemas/mysql_41_schema.sql @@ -438,6 +438,7 @@ CREATE TABLE phpbb_notifications ( item_parent_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, unread tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, + is_disabled tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, time int(11) UNSIGNED DEFAULT '1' NOT NULL, data text NOT NULL, PRIMARY KEY (notification_id), @@ -446,7 +447,8 @@ CREATE TABLE phpbb_notifications ( KEY item_pid (item_parent_id), KEY user_id (user_id), KEY time (time), - KEY unread (unread) + KEY unread (unread), + KEY is_disabled (is_disabled) ) CHARACTER SET `utf8` COLLATE `utf8_bin`; diff --git a/phpBB/install/schemas/oracle_schema.sql b/phpBB/install/schemas/oracle_schema.sql index 6269cfcdbc..f2f22e2f5e 100644 --- a/phpBB/install/schemas/oracle_schema.sql +++ b/phpBB/install/schemas/oracle_schema.sql @@ -850,6 +850,7 @@ CREATE TABLE phpbb_notifications ( item_parent_id number(8) DEFAULT '0' NOT NULL, user_id number(8) DEFAULT '0' NOT NULL, unread number(1) DEFAULT '1' NOT NULL, + is_disabled number(1) DEFAULT '0' NOT NULL, time number(11) DEFAULT '1' NOT NULL, data clob DEFAULT '' , CONSTRAINT pk_phpbb_notifications PRIMARY KEY (notification_id) @@ -868,6 +869,8 @@ CREATE INDEX phpbb_notifications_time ON phpbb_notifications (time) / CREATE INDEX phpbb_notifications_unread ON phpbb_notifications (unread) / +CREATE INDEX phpbb_notifications_is_disabled ON phpbb_notifications (is_disabled) +/ CREATE SEQUENCE phpbb_notifications_seq / diff --git a/phpBB/install/schemas/postgres_schema.sql b/phpBB/install/schemas/postgres_schema.sql index d8716be70d..ffba657475 100644 --- a/phpBB/install/schemas/postgres_schema.sql +++ b/phpBB/install/schemas/postgres_schema.sql @@ -608,6 +608,7 @@ CREATE TABLE phpbb_notifications ( item_parent_id INT4 DEFAULT '0' NOT NULL CHECK (item_parent_id >= 0), user_id INT4 DEFAULT '0' NOT NULL CHECK (user_id >= 0), unread INT2 DEFAULT '1' NOT NULL CHECK (unread >= 0), + is_disabled INT2 DEFAULT '0' NOT NULL CHECK (is_disabled >= 0), time INT4 DEFAULT '1' NOT NULL CHECK (time >= 0), data varchar(4000) DEFAULT '' NOT NULL, PRIMARY KEY (notification_id) @@ -619,6 +620,7 @@ CREATE INDEX phpbb_notifications_item_pid ON phpbb_notifications (item_parent_id CREATE INDEX phpbb_notifications_user_id ON phpbb_notifications (user_id); CREATE INDEX phpbb_notifications_time ON phpbb_notifications (time); CREATE INDEX phpbb_notifications_unread ON phpbb_notifications (unread); +CREATE INDEX phpbb_notifications_is_disabled ON phpbb_notifications (is_disabled); /* Table: 'phpbb_poll_options' diff --git a/phpBB/install/schemas/sqlite_schema.sql b/phpBB/install/schemas/sqlite_schema.sql index 4cb20b868f..b63569ce3e 100644 --- a/phpBB/install/schemas/sqlite_schema.sql +++ b/phpBB/install/schemas/sqlite_schema.sql @@ -425,6 +425,7 @@ CREATE TABLE phpbb_notifications ( item_parent_id INTEGER UNSIGNED NOT NULL DEFAULT '0', user_id INTEGER UNSIGNED NOT NULL DEFAULT '0', unread INTEGER UNSIGNED NOT NULL DEFAULT '1', + is_disabled INTEGER UNSIGNED NOT NULL DEFAULT '0', time INTEGER UNSIGNED NOT NULL DEFAULT '1', data text(65535) NOT NULL DEFAULT '' ); @@ -435,6 +436,7 @@ CREATE INDEX phpbb_notifications_item_pid ON phpbb_notifications (item_parent_id CREATE INDEX phpbb_notifications_user_id ON phpbb_notifications (user_id); CREATE INDEX phpbb_notifications_time ON phpbb_notifications (time); CREATE INDEX phpbb_notifications_unread ON phpbb_notifications (unread); +CREATE INDEX phpbb_notifications_is_disabled ON phpbb_notifications (is_disabled); # Table: 'phpbb_poll_options' CREATE TABLE phpbb_poll_options ( |