1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190:
<?php
if (!defined('SMF'))
die('No direct access...');
function BoardNotify()
{
global $board, $user_info, $context, $smcFunc, $sourcedir;
is_not_guest();
if (empty($board))
fatal_lang_error('no_board', false);
if (isset($_GET['mode']))
{
checkSession('get');
$mode = (int) $_GET['mode'];
$alertPref = $mode <= 1 ? 0 : ($mode == 2 ? 1 : 3);
require_once($sourcedir . '/Subs-Notify.php');
setNotifyPrefs($user_info['id'], array('board_notify_' . $board => $alertPref));
if ($mode > 1)
$smcFunc['db_insert']('ignore',
'{db_prefix}log_notify',
array('id_member' => 'int', 'id_topic' => 'int', 'id_board' => 'int'),
array($user_info['id'], 0, $board),
array('id_member', 'id_topic', 'id_board')
);
else
$smcFunc['db_query']('', '
DELETE FROM {db_prefix}log_notify
WHERE id_member = {int:current_member}
AND id_board = {int:current_board}',
array(
'current_board' => $board,
'current_member' => $user_info['id'],
)
);
}
if (isset($_GET['xml']))
{
$context['xml_data']['errors'] = array(
'identifier' => 'error',
'children' => array(
array(
'value' => 0,
),
),
);
$context['sub_template'] = 'generic_xml';
}
else
redirectexit('board=' . $board . '.' . $_REQUEST['start']);
}
function TopicNotify()
{
global $smcFunc, $user_info, $topic, $sourcedir, $context;
if (!$user_info['is_guest'])
{
checkSession('get');
if (isset($_GET['mode']))
{
$mode = (int) $_GET['mode'];
$alertPref = $mode <= 1 ? 0 : ($mode == 2 ? 1 : 3);
$request = $smcFunc['db_query']('', '
SELECT id_member, id_topic, id_msg, unwatched
FROM {db_prefix}log_topics
WHERE id_member = {int:current_user}
AND id_topic = {int:current_topic}',
array(
'current_user' => $user_info['id'],
'current_topic' => $topic,
)
);
$log = $smcFunc['db_fetch_assoc']($request);
$smcFunc['db_free_result']($request);
if (empty($log))
{
$insert = true;
$log = array(
'id_member' => $user_info['id'],
'id_topic' => $topic,
'id_msg' => 0,
'unwatched' => empty($mode) ? 1 : 0,
);
}
else
{
$insert = false;
$log['unwatched'] = empty($mode) ? 1 : 0;
}
$smcFunc['db_insert']($insert ? 'insert' : 'replace',
'{db_prefix}log_topics',
array(
'id_member' => 'int', 'id_topic' => 'int', 'id_msg' => 'int', 'unwatched' => 'int',
),
$log,
array('id_member', 'id_topic')
);
require_once($sourcedir . '/Subs-Notify.php');
setNotifyPrefs($user_info['id'], array('topic_notify_' . $log['id_topic'] => $alertPref));
if ($mode > 1)
{
$smcFunc['db_insert']('ignore',
'{db_prefix}log_notify',
array('id_member' => 'int', 'id_topic' => 'int', 'id_board' => 'int'),
array($user_info['id'], $log['id_topic'], 0),
array('id_member','id_topic', 'id_board')
);
}
else
$smcFunc['db_query']('', '
DELETE FROM {db_prefix}log_notify
WHERE id_topic = {int:topic}
AND id_member = {int:member}',
array(
'topic' => $log['id_topic'],
'member' => $user_info['id'],
)
);
}
}
if (isset($_GET['xml']))
{
$context['xml_data']['errors'] = array(
'identifier' => 'error',
'children' => array(
array(
'value' => 0,
),
),
);
$context['sub_template'] = 'generic_xml';
}
else
redirectexit('topic=' . $topic . '.' . $_REQUEST['start']);
}
?>