-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Subscribe Toggle in Notification Dropdown #41
Merged
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
7c3fc16
Add subscribe button to notification dropdown
iMattPro 5abdb49
Fix tests
iMattPro 47fc002
Add template event file
iMattPro 6610224
Subscribe toggle tweaks [ci skip]
iMattPro c4b60d1
Remove redundant code
iMattPro 389d4ef
More removal of redundant code
iMattPro c8a5a26
Merge branch 'main' into sub-anywhere
iMattPro 093b1b1
Merge master
iMattPro 711d709
Fixes
iMattPro 3fa5703
I can’t stop making updates
iMattPro 70d611f
Move generic template files to all styles
iMattPro 9e27f11
Add functional test
iMattPro 0ef563d
Locate theme to all styles as well
iMattPro 772d46c
Add migration to set all users some push notifications
iMattPro bbdbd22
Only 1 result needed for eff inst check
iMattPro e38239f
Ignore bot users and anonymous
iMattPro 2d00c6d
Test some checkboxes after migration
iMattPro 9546447
Also hide subscribe button from notification list page
iMattPro a7907ae
New user’s should have their default wpn set too
iMattPro d642b73
Fix test
iMattPro bb36bfd
Update ru translation [ci skip]
iMattPro 7fcf10d
Responsive stuff
iMattPro File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably limit user types to |
||
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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add
AND notify = 1
as far as we're looking for enabled notification types.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For this I'm just looking to see if it exists yet, because if it does it means it's already been installed and people have started making settings already.