Gazelle/classes/notificationsmanagerview.class.php

159 lines
5.7 KiB
PHP
Raw Normal View History

2013-08-28 23:08:41 +00:00
<?
class NotificationsManagerView {
private static $Settings;
2013-10-07 08:01:03 +00:00
public static function load_js() {
2013-10-17 08:00:50 +00:00
$JSIncludes = array(
'noty/noty.js',
'noty/layouts/bottomRight.js',
'noty/themes/default.js',
'user_notifications.js');
foreach ($JSIncludes as $JSInclude) {
$Path = STATIC_SERVER."functions/$JSInclude";
2013-10-07 08:01:03 +00:00
?>
2013-10-17 08:00:50 +00:00
<script src="<?=$Path?>?v=<?=filemtime(SERVER_ROOT."/$Path")?>" type="text/javascript"></script>
2013-08-28 23:08:41 +00:00
<?
2013-10-17 08:00:50 +00:00
}
2013-08-28 23:08:41 +00:00
}
2014-01-20 08:01:21 +00:00
private static function render_push_settings() {
$PushService = self::$Settings['PushService'];
$PushOptions = unserialize(self::$Settings['PushOptions']);
2014-03-31 08:01:19 +00:00
if (empty($PushOptions['PushDevice'])) {
$PushOptions['PushDevice'] = '';
}
2014-01-20 08:01:21 +00:00
?>
<tr>
<td class="label"><strong>Push notifications</strong></td>
<td>
<select name="pushservice" id="pushservice">
<option value="0"<? if (empty($PushService)) { ?> selected="selected"<? } ?>>Disable push notifications</option>
<option value="1"<? if ($PushService == 1) { ?> selected="selected"<? } ?>>Notify My Android</option>
<option value="2"<? if ($PushService == 2) { ?> selected="selected"<? } ?>>Prowl</option>
<!-- No option 3, notifo died. -->
<option value="4"<? if ($PushService == 4) { ?> selected="selected"<? } ?>>Super Toasty</option>
<option value="5"<? if ($PushService == 5) { ?> selected="selected"<? } ?>>Pushover</option>
2014-03-31 08:01:19 +00:00
<option value="6"<? if ($PushService == 6) { ?> selected="selected"<? } ?>>PushBullet</option>
2014-01-20 08:01:21 +00:00
</select>
<div id="pushsettings" style="display: none;">
<label id="pushservice_title" for="pushkey">API key</label>
<input type="text" size="50" name="pushkey" id="pushkey" value="<?=display_str($PushOptions['PushKey'])?>" />
2014-03-31 08:01:19 +00:00
<label class="pushdeviceid" id="pushservice_device" for="pushdevice">Device ID</label>
<select class="pushdeviceid" name="pushdevice" id="pushdevice">
<option value="<?= display_str($PushOptions['PushDevice'])?>" selected="selected"><?= display_str($PushOptions['PushDevice'])?></option>
</select>
2014-01-20 08:01:21 +00:00
<br />
<a href="user.php?action=take_push&amp;push=1&amp;userid=<?=G::$LoggedUser['ID']?>&amp;auth=<?=G::$LoggedUser['AuthKey']?>" class="brackets">Test push</a>
<a href="wiki.php?action=article&amp;id=1017" class="brackets">View wiki guide</a>
</div>
</td>
</tr>
<? }
2013-08-28 23:08:41 +00:00
public static function render_settings($Settings) {
self::$Settings = $Settings;
2014-01-20 08:01:21 +00:00
if (check_perms("users_mod") || G::$LoggedUser['ExtraClasses'][DELTA_TEAM]) {
self::render_push_settings();
}
2013-08-28 23:08:41 +00:00
?>
<tr>
2013-10-07 08:01:03 +00:00
<td class="label">
2013-08-28 23:08:41 +00:00
<strong>News announcements</strong>
</td>
<td>
<? self::render_checkbox(NotificationsManager::NEWS); ?>
</td>
</tr>
<tr>
2013-10-07 08:01:03 +00:00
<td class="label">
2013-08-28 23:08:41 +00:00
<strong>Blog announcements</strong>
</td>
<td>
<? self::render_checkbox(NotificationsManager::BLOG); ?>
</td>
</tr>
<tr>
2013-10-07 08:01:03 +00:00
<td class="label">
2013-08-28 23:08:41 +00:00
<strong>Inbox messages</strong>
</td>
<td>
<? self::render_checkbox(NotificationsManager::INBOX, true); ?>
</td>
</tr>
<tr>
<td class="label tooltip" title="Enabling this will give you a notification when you receive a new private message from a member of the <?=SITE_NAME?> staff.">
<strong>Staff messages</strong>
</td>
<td>
2014-01-20 08:01:21 +00:00
<? self::render_checkbox(NotificationsManager::STAFFPM, false, false); ?>
2013-08-28 23:08:41 +00:00
</td>
</tr>
<tr>
2013-10-07 08:01:03 +00:00
<td class="label">
2013-08-28 23:08:41 +00:00
<strong>Thread subscriptions</strong>
</td>
<td>
2014-01-20 08:01:21 +00:00
<? self::render_checkbox(NotificationsManager::SUBSCRIPTIONS, false, false); ?>
2013-08-28 23:08:41 +00:00
</td>
</tr>
<tr>
<td class="label tooltip" title="Enabling this will give you a notification whenever someone quotes you in the forums.">
<strong>Quote notifications</strong>
</td>
<td>
<? self::render_checkbox(NotificationsManager::QUOTES); ?>
</td>
</tr>
<? if (check_perms('site_torrents_notify')) { ?>
<tr>
<td class="label tooltip" title="Enabling this will give you a notification when the torrent notification filters you have established are triggered.">
<strong>Torrent notifications</strong>
</td>
<td>
2014-01-20 08:01:21 +00:00
<? self::render_checkbox(NotificationsManager::TORRENTS, true, false); ?>
2013-08-28 23:08:41 +00:00
</td>
</tr>
<? } ?>
2014-01-20 08:01:21 +00:00
2013-08-28 23:08:41 +00:00
<tr>
<td class="label tooltip" title="Enabling this will give you a notification when a torrent is added to a collage you are subscribed to.">
<strong>Collage subscriptions</strong>
</td>
<td>
2014-01-20 08:01:21 +00:00
<? self::render_checkbox(NotificationsManager::COLLAGES. false, false); ?>
2013-08-28 23:08:41 +00:00
</td>
</tr>
2014-01-20 08:01:21 +00:00
<? }
2013-08-28 23:08:41 +00:00
2014-01-20 08:01:21 +00:00
private static function render_checkbox($Name, $Traditional = false, $Push = true) {
2013-08-28 23:08:41 +00:00
$Checked = self::$Settings[$Name];
2014-01-20 08:01:21 +00:00
$PopupChecked = $Checked == NotificationsManager::OPT_POPUP || $Checked == NotificationsManager::OPT_POPUP_PUSH || !isset($Checked) ? ' checked="checked"' : '';
$TraditionalChecked = $Checked == NotificationsManager::OPT_TRADITIONAL || $Checked == NotificationsManager::OPT_TRADITIONAL_PUSH ? ' checked="checked"' : '';
$PushChecked = $Checked == NotificationsManager::OPT_TRADITIONAL_PUSH || $Checked == NotificationsManager::OPT_POPUP_PUSH || $Checked == NotificationsManager::OPT_PUSH ? ' checked="checked"' : '';
2013-08-28 23:08:41 +00:00
?>
2014-01-20 08:01:21 +00:00
<label>
<input type="checkbox" name="notifications_<?=$Name?>_popup" id="notifications_<?=$Name?>_popup"<?=$PopupChecked?> />
Pop-up
</label>
<? if ($Traditional) { ?>
<label>
<input type="checkbox" name="notifications_<?=$Name?>_traditional" id="notifications_<?=$Name?>_traditional"<?=$TraditionalChecked?> />
Traditional
</label>
<? }
if ($Push && (check_perms("users_mod") || G::$LoggedUser['ExtraClasses'][DELTA_TEAM])) { ?>
<label>
<input type="checkbox" name="notifications_<?=$Name?>_push" id="notifications_<?=$Name?>_push"<?=$PushChecked?> />
Push
</label>
<? }
2013-08-28 23:08:41 +00:00
}
public static function format_traditional($Contents) {
2013-10-17 08:00:50 +00:00
return "<a href=\"$Contents[url]\">$Contents[message]</a>";
2013-08-28 23:08:41 +00:00
}
2014-01-20 08:01:21 +00:00
2013-08-28 23:08:41 +00:00
}