Skip to content
This repository has been archived by the owner on Apr 24, 2024. It is now read-only.

Commit

Permalink
account settings tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel André Eikeland committed May 10, 2016
1 parent 2fb3a0a commit e73d9eb
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 43 deletions.
4 changes: 2 additions & 2 deletions core/framework/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -947,7 +947,7 @@ public static function getSyntaxValue($syntax)
public static function getNotificationPollInterval()
{
$seconds = self::get(self::SETTING_NOTIFICATION_POLL_INTERVAL);
return $seconds == null ? 10 : $seconds;
return $seconds == null ? 180 : $seconds;

This comment has been minimized.

Copy link
@rvanlaak

rvanlaak May 18, 2016

Contributor

return $seconds ?: 180; to also capture the 0 and false value?

}

public static function getSubscriptionsSettings()
Expand All @@ -958,7 +958,7 @@ public static function getSubscriptionsSettings()
$subscriptionssettings[self::SETTINGS_USER_SUBSCRIBE_CREATED_UPDATED_COMMENTED_ARTICLES] = $i18n->__('Automatically subscribe to article I posted');
$subscriptionssettings[self::SETTINGS_USER_SUBSCRIBE_NEW_ISSUES_MY_PROJECTS] = $i18n->__('Automatically subscribe to new issues that are created in my project(s)');
$subscriptionssettings[self::SETTINGS_USER_SUBSCRIBE_NEW_ARTICLES_MY_PROJECTS] = $i18n->__('Automatically subscribe to new articles that are created in my project(s)');
// $subscriptionssettings[self::SETTINGS_USER_SUBSCRIBE_NEW_ISSUES_MY_PROJECTS_CATEGORY] = $i18n->__('Automatically subscribe to new issues in selected categories');
$subscriptionssettings[self::SETTINGS_USER_SUBSCRIBE_NEW_ISSUES_MY_PROJECTS_CATEGORY] = $i18n->__('Automatically subscribe to new issues in selected categories');
return $subscriptionssettings;
}

Expand Down
16 changes: 11 additions & 5 deletions core/modules/main/templates/myaccount.html.php
Original file line number Diff line number Diff line change
Expand Up @@ -313,10 +313,10 @@
<div id="tab_notificationsettings_pane" style="display: none;">
<form accept-charset="<?php echo \thebuggenie\core\framework\Context::getI18n()->getCharset(); ?>" action="<?php echo make_url('account_save_settings'); ?>" onsubmit="TBG.Main.Profile.updateNotificationSettings('<?php echo make_url('account_save_notificationsettings'); ?>'); return false;" method="post" id="profile_notificationsettings_form">
<h3><?php echo __('Subscriptions'); ?></h3>
<p><?php echo __('Please select when you would like The Bug Genie to subscribe you.'); ?></p>
<p><?php echo __('The Bug Genie can subscribe you to issues, articles and other items in the system, so you can receive notifications when they are updated. Please select when you would like The Bug Genie to subscribe you.'); ?></p>
<table class="padded_table" cellpadding=0 cellspacing=0>
<?php foreach ($subscriptionssettings as $key => $description): ?>
<?php if (in_array($key, [Settings::SETTINGS_USER_SUBSCRIBE_NEW_ISSUES_MY_PROJECTS_CATEGORY, Settings::SETTINGS_USER_NOTIFY_NEW_ISSUES_MY_PROJECTS])) continue; ?>
<?php if (in_array($key, [Settings::SETTINGS_USER_SUBSCRIBE_NEW_ISSUES_MY_PROJECTS_CATEGORY, Settings::SETTINGS_USER_SUBSCRIBE_NEW_ISSUES_MY_PROJECTS])) continue; ?>
<tr>
<td style="width: auto; border-bottom: 1px solid #DDD;"><label for="<?php echo $key; ?>_yes"><?php echo $description ?></label></td>
<?php if ($key == \thebuggenie\core\framework\Settings::SETTINGS_USER_SUBSCRIBE_NEW_ISSUES_MY_PROJECTS_CATEGORY): ?>
Expand Down Expand Up @@ -434,7 +434,7 @@
<td style="text-align: center; border-bottom: 1px solid #DDD;" valign="middle"></td>
<?php else: ?>
<td style="text-align: center; border-bottom: 1px solid #DDD;" valign="middle">
<input type="checkbox" name="core_<?php echo $key; ?>" value="1" id="<?php echo $key; ?>_yes"<?php if ($tbg_user->getNotificationSetting($key, false, 'core')->isOn()): ?> checked<?php endif; ?>>
<input type="checkbox" name="core_<?php echo $key; ?>" value="1" id="<?php echo $key; ?>_yes"<?php if ($tbg_user->getNotificationSetting($key, $key == Settings::SETTINGS_USER_NOTIFY_MENTIONED, 'core')->isOn()) echo ' checked'; ?>>
</td>
<?php \thebuggenie\core\framework\Event::createNew('core', 'account_pane_notificationsettings_cell')->trigger(compact('key')); ?>
<?php endif; ?>
Expand All @@ -444,8 +444,12 @@
<?php $category_key = \thebuggenie\core\framework\Settings::SETTINGS_USER_NOTIFY_NEW_ISSUES_MY_PROJECTS_CATEGORY; ?>
<table class="padded_table" cellpadding="0" cellspacing="0">
<tr>
<td style="width: auto; border-bottom: 1px solid #DDD; vertical-align: middle;"><label for="<?php echo $category_key; ?>_yes"><?= __('Notify to notifications box when issues are created in selected categories') ?></label></td>
<td style="width: auto; border-bottom: 1px solid #DDD; vertical-align: middle;">
<label for="<?php echo $category_key; ?>_yes"><?= __('Notify to notifications box when issues are created in selected categories') ?></label><br>
<?= __('If you want to be notified when an issue is created in a specific category, but do not want to automatically subscribe for updates to these issues, make sure auto-subscriptions are turned off in the "%subscriptions"-section, then use this dropdown to configure notifications.', ['%subscriptions' => __('Subscriptions')]); ?>
</td>
<td style="width: 350px; text-align: right; border-bottom: 1px solid #DDD; vertical-align: middle;">
<label><?= __('Notifications box'); ?></label><br>
<div class="filter interactive_dropdown rightie" data-filterkey="<?php echo $category_key; ?>" data-value="" data-all-value="<?php echo __('None selected'); ?>">
<input type="hidden" name="core_<?= $category_key; ?>" value="<?= join(',', $selected_category_notifications); ?>" id="filter_<?php echo $category_key; ?>_value_input">
<label><?php echo __('Categories'); ?></label>
Expand All @@ -466,10 +470,12 @@
</div>
</div>
</div>
<br>
<?php \thebuggenie\core\framework\Event::createNew('core', 'account_pane_notificationsettings_notification_categories')->trigger(compact('categories')); ?>
</td>
</tr>
</table>
<?php \thebuggenie\core\framework\Event::createNew('core', 'account_pane_notificationsettings_notification_categories')->trigger(compact('categories')); ?>
<?php \thebuggenie\core\framework\Event::createNew('core', 'account_pane_notificationsettings_subscriptions')->trigger(compact('categories')); ?>
<h3><?php echo __('Desktop notifications'); ?></h3>
<p><?php echo __('You can receive desktop notifications based on system actions or your subscriptions. Choose your desktop notification preferences from this section.'); ?></p>
<table class="padded_table desktop-notifications-settings" cellpadding=0 cellspacing=0>
Expand Down
6 changes: 6 additions & 0 deletions modules/mailing/Mailing.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ protected function _addListeners()
framework\Event::listen('core', 'account_pane_notificationsettings_thead', array($this, 'listen_accountNotificationSettingsThead'));
framework\Event::listen('core', 'account_pane_notificationsettings_cell', array($this, 'listen_accountNotificationSettingsCell'));
framework\Event::listen('core', 'account_pane_notificationsettings_notification_categories', array($this, 'listen_accountNotificationSettingsNotificationCategories'));
framework\Event::listen('core', 'account_pane_notificationsettings_subscriptions', array($this, 'listen_accountNotificationSettingsSubscriptions'));
framework\Event::listen('core', 'config.createuser.email', array($this, 'listen_configCreateuserEmail'));
framework\Event::listen('core', 'config.createuser.save', array($this, 'listen_configCreateuserSave'));
framework\Event::listen('core', 'mainActions::myAccount::saveNotificationSettings', array($this, 'listen_accountSaveNotificationSettings'));
Expand Down Expand Up @@ -791,6 +792,11 @@ public function listen_accountNotificationSettingsNotificationCategories(framewo
framework\ActionComponent::includeComponent('mailing/accountsettings_notificationcategories', array('categories' => $event->getParameter('categories')));
}

public function listen_accountNotificationSettingsSubscriptions(framework\Event $event)
{
framework\ActionComponent::includeComponent('mailing/accountsettings_subscriptions');
}

public function listen_configCreateuserEmail(framework\Event $event)
{
framework\ActionComponent::includeComponent('mailing/configcreateuseremail');
Expand Down
7 changes: 6 additions & 1 deletion modules/mailing/templates/_accountsettings_cell.inc.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
<?php

use thebuggenie\core\framework\Settings;

?>
<?php if (array_key_exists($key, $notificationsettings)): ?>
<td style="width: 50px; text-align: center; border-bottom: 1px solid #DDD;" valign="middle">
<input type="checkbox" name="mailing_<?php echo $key; ?>" value="1"<?php if ($tbg_user->getNotificationSetting($key, false, 'mailing')->isOn()): ?> checked<?php endif; ?>>
<input type="checkbox" name="mailing_<?php echo $key; ?>" value="1"<?php if ($tbg_user->getNotificationSetting($key, $key == Settings::SETTINGS_USER_NOTIFY_MENTIONED, 'mailing')->isOn()): ?> checked<?php endif; ?>>
</td>
<?php else: ?>
<td style="text-align: center; border-bottom: 1px solid #DDD;" valign="middle"></td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,24 @@
use thebuggenie\modules\mailing\Mailing;

?>
<table class="padded_table" cellpadding="0" cellspacing="0">
<tr>
<td style="width: auto; border-bottom: 1px solid #DDD; vertical-align: middle;"><label for="<?= $category_key; ?>_yes"><?= __('Notify via email when issues are created in selected categories') ?></label></td>
<td style="width: 350px; text-align: right; border-bottom: 1px solid #DDD; vertical-align: middle;">
<div class="filter interactive_dropdown rightie" data-filterkey="<?= $category_key; ?>" data-value="" data-all-value="<?= __('None selected'); ?>">
<input type="hidden" name="mailing_<?= $category_key; ?>" value="<?= join(',', $selected_category_notifications); ?>" id="filter_<?= $category_key; ?>_value_input">
<label><?= __('Categories'); ?></label>
<span class="value"><?php if (empty($selected_category_notifications)) echo __('None selected'); ?></span>
<div class="interactive_menu">
<h1><?= __('Select which categories to subscribe to'); ?></h1>
<input type="search" class="interactive_menu_filter" placeholder="<?= __('Filter categories'); ?>">
<div class="interactive_values_container">
<ul class="interactive_menu_values">
<?php foreach ($categories as $category_id => $category): ?>
<li data-value="<?= $category_id; ?>" class="filtervalue<?php if (in_array($category_id, $selected_category_notifications)) echo ' selected'; ?>">
<?= image_tag('icon-mono-checked.png', array('class' => 'checked')); ?>
<input type="checkbox" value="<?= $category_id; ?>" name="mailing_<?= $category_key; ?>_<?= $category_id; ?>" data-text="<?= __($category->getName()); ?>" id="mailing_<?= $category_key; ?>_value_<?= $category_id; ?>" <?php if (in_array($category_id, $selected_category_notifications)) echo 'checked'; ?>>
<label for="mailing_<?= $category_key; ?>_value_<?= $category_id; ?>"><?= __($category->getName()); ?></label>
</li>
<?php endforeach; ?>
</ul>
</div>
</div>
</div>
</td>
</tr>
<tr>
<td style="border-bottom: 1px solid #DDD; vertical-align: middle;"><label for="mailing_<?= Mailing::NOTIFY_NOT_WHEN_ACTIVE; ?>_yes"><?= __("Don't send email notification if I'm currently logged in and active") ?></label></td>
<td style="text-align: right; border-bottom: 1px solid #DDD; vertical-align: middle;">
<div style="display: inline-block; width: 50px; text-align: center; padding: 0; margin: 0;">
<input type="checkbox" name="mailing_<?= Mailing::NOTIFY_NOT_WHEN_ACTIVE; ?>" value="1" id="mailing_<?= Mailing::NOTIFY_NOT_WHEN_ACTIVE; ?>_yes"<?php if ($tbg_user->getNotificationSetting(Mailing::NOTIFY_NOT_WHEN_ACTIVE, false, 'mailing')->isOn()): ?> checked<?php endif; ?>>
</div>
</td>
</tr>
</table>
<label><?= __('Email'); ?></label><br>
<div class="filter interactive_dropdown rightie" data-filterkey="<?= $category_key; ?>" data-value="" data-all-value="<?= __('None selected'); ?>">
<input type="hidden" name="mailing_<?= $category_key; ?>" value="<?= join(',', $selected_category_notifications); ?>" id="filter_<?= $category_key; ?>_value_input">
<label><?= __('Categories'); ?></label>
<span class="value"><?php if (empty($selected_category_notifications)) echo __('None selected'); ?></span>
<div class="interactive_menu">
<h1><?= __('Select which categories to subscribe to'); ?></h1>
<input type="search" class="interactive_menu_filter" placeholder="<?= __('Filter categories'); ?>">
<div class="interactive_values_container">
<ul class="interactive_menu_values">
<?php foreach ($categories as $category_id => $category): ?>
<li data-value="<?= $category_id; ?>" class="filtervalue<?php if (in_array($category_id, $selected_category_notifications)) echo ' selected'; ?>">
<?= image_tag('icon-mono-checked.png', array('class' => 'checked')); ?>
<input type="checkbox" value="<?= $category_id; ?>" name="mailing_<?= $category_key; ?>_<?= $category_id; ?>" data-text="<?= __($category->getName()); ?>" id="mailing_<?= $category_key; ?>_value_<?= $category_id; ?>" <?php if (in_array($category_id, $selected_category_notifications)) echo 'checked'; ?>>
<label for="mailing_<?= $category_key; ?>_value_<?= $category_id; ?>"><?= __($category->getName()); ?></label>
</li>
<?php endforeach; ?>
</ul>
</div>
</div>
</div>
15 changes: 15 additions & 0 deletions modules/mailing/templates/_accountsettings_subscriptions.inc.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

use thebuggenie\modules\mailing\Mailing;

?>
<table class="padded_table" cellpadding="0" cellspacing="0">
<tr>
<td style="width: auto; border-bottom: 1px solid #DDD; vertical-align: middle;"><label for="mailing_<?= Mailing::NOTIFY_NOT_WHEN_ACTIVE; ?>_yes"><?= __("Don't send email notification if I'm currently logged in and active") ?></label></td>
<td style="width: 350px; text-align: right; border-bottom: 1px solid #DDD; vertical-align: middle;">
<div style="display: inline-block; width: 50px; text-align: center; padding: 0; margin: 0;">
<input type="checkbox" name="mailing_<?= Mailing::NOTIFY_NOT_WHEN_ACTIVE; ?>" value="1" id="mailing_<?= Mailing::NOTIFY_NOT_WHEN_ACTIVE; ?>_yes"<?php if ($tbg_user->getNotificationSetting(Mailing::NOTIFY_NOT_WHEN_ACTIVE, false, 'mailing')->isOn()): ?> checked<?php endif; ?>>
</div>
</td>
</tr>
</table>

0 comments on commit e73d9eb

Please sign in to comment.