-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #41 from iMattPro/sub-anywhere
Subscribe Toggle in Notification Dropdown
- Loading branch information
Showing
15 changed files
with
207 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
<?php | ||
/** | ||
* | ||
* phpBB Browser Push Notifications. An extension for the phpBB Forum Software package. | ||
* | ||
* @copyright (c) 2024, phpBB Limited <https://www.phpbb.com> | ||
* @license GNU General Public License, version 2 (GPL-2.0) | ||
* | ||
*/ | ||
|
||
namespace phpbb\webpushnotifications\migrations; | ||
|
||
use phpbb\db\migration\migration; | ||
|
||
class update_user_notifications extends migration | ||
{ | ||
/** | ||
* @inheritDoc | ||
*/ | ||
public static function depends_on() | ||
{ | ||
return ['\phpbb\webpushnotifications\migrations\add_webpush']; | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function effectively_installed() | ||
{ | ||
$sql = 'SELECT method | ||
FROM ' . $this->table_prefix . "user_notifications | ||
WHERE method = '" . $this->db->sql_escape('notification.method.phpbb.wpn.webpush') . "'"; | ||
$result = $this->db->sql_query_limit($sql, 1); | ||
$row = $this->db->sql_fetchrow($result); | ||
$this->db->sql_freeresult($result); | ||
|
||
return $row !== false; | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function update_data() | ||
{ | ||
return [ | ||
['custom', [[$this, 'update_notifications']]], | ||
]; | ||
} | ||
|
||
/** | ||
* Add default push notifications for users in chunks | ||
* | ||
* @param $start int Start value for the update | ||
* @return int|true Next start value or true if complete | ||
*/ | ||
public function update_notifications($start) | ||
{ | ||
$start = (int) $start; | ||
$limit = 500; | ||
$updated = 0; | ||
|
||
$sql_ary = []; | ||
|
||
$sql = 'SELECT user_id | ||
FROM ' . $this->table_prefix . 'users | ||
WHERE user_type <> ' . USER_IGNORE . ' | ||
ORDER BY user_id ASC'; | ||
$result = $this->db->sql_query_limit($sql, $limit, $start); | ||
|
||
while ($row = $this->db->sql_fetchrow($result)) | ||
{ | ||
$sql_ary[] = [ | ||
'item_type' => 'notification.type.pm', | ||
'item_id' => 0, | ||
'user_id' => (int) $row['user_id'], | ||
'notify' => 1, | ||
'method' => 'notification.method.phpbb.wpn.webpush', | ||
]; | ||
$sql_ary[] = [ | ||
'item_type' => 'notification.type.quote', | ||
'item_id' => 0, | ||
'user_id' => (int) $row['user_id'], | ||
'notify' => 1, | ||
'method' => 'notification.method.phpbb.wpn.webpush', | ||
]; | ||
$updated++; | ||
} | ||
$this->db->sql_freeresult($result); | ||
|
||
$this->db->sql_multi_insert($this->table_prefix . 'user_notifications', $sql_ary); | ||
|
||
return ($updated === $limit) ? $start + $limit : true; | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
styles/all/template/event/notification_dropdown_footer_after.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{% if NOTIFICATIONS_WEBPUSH_ENABLE and not notification_types|default and not notification_list|default %} | ||
<div class="wpn-notification-dropdown-footer"> | ||
<span class="ellipsis-text">{{ lang('NOTIFY_WEBPUSH_ENABLE_SHORT') ~ lang('COLON') }}</span> | ||
<button id="subscribe_webpush" name="subscribe_webpush"><i class="icon fa-toggle-off fa-fw icon-lightgray"></i><span>{{ lang('NOTIFY_WEBPUSH_SUBSCRIBE') }}</span></button> | ||
<button id="unsubscribe_webpush" name="unsubscribe_webpush" class="hidden"><i class="icon fa-toggle-on fa-fw icon-blue"></i><span>{{ lang('NOTIFY_WEBPUSH_SUBSCRIBED') }}</span></button> | ||
</div> | ||
{% endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{% if NOTIFICATIONS_WEBPUSH_ENABLE %} | ||
{% include '@phpbb_webpushnotifications/ucp_notifications_webpush.html' %} | ||
{% endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
.button[disabled], | ||
.button[disabled]:hover, | ||
.button.disabled, | ||
.button.disabled:hover { | ||
background: #e0e0e0; | ||
border-color: #9e9e9e; | ||
color: #9e9e9e; | ||
} | ||
|
||
.button.hidden { | ||
display: none; | ||
} | ||
|
||
.wpn-notification-dropdown-footer { | ||
font-size: 12px; | ||
white-space: nowrap; | ||
border-top: solid 1px #b9b9b9; | ||
display: flex; | ||
flex-wrap: nowrap; | ||
justify-content: space-between; | ||
padding: 5px 25px; | ||
} | ||
|
||
.wpn-notification-dropdown-footer button:disabled { | ||
opacity: 0.7; | ||
} |
This file was deleted.
Oops, something went wrong.
3 changes: 0 additions & 3 deletions
3
styles/prosilver/template/event/ucp_notifications_form_before.html
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.