1
0
mirror of https://github.com/e107inc/e107.git synced 2025-07-25 17:01:43 +02:00

Issue #784 Forum: Thread tracking - enable/disable functioning correctly. Actual notification requires work.

This commit is contained in:
Cameron
2016-01-31 14:39:41 -08:00
parent edf00641d2
commit fadc6eeb44
5 changed files with 114 additions and 20 deletions

View File

@@ -57,6 +57,10 @@ $(document).ready(function()
var alertType = 'info';
}
if(d.status == 'error')
{
alertType = 'danger';
}
// http://nijikokun.github.io/bootstrap-notify/
@@ -82,7 +86,16 @@ $(document).ready(function()
{
location.reload();
return;
}
}
if(action == 'track')
{
if(d.html != false)
{
$('#'+ insert).html(d.html);
// alert(d.html);
}
}
if(action == 'quickreply' && d.status == 'ok' )
{
@@ -359,8 +372,63 @@ class e107forum
exit;
}
/**
* Process Tracking Enable/disable
*/
public function ajaxTrack()
{
$ret = array();
$ret['status'] = 'error';
$threadID = intval($_POST['thread']);
if(!USER || empty($threadID))
{
exit;
}
$sql = e107::getDb();
if($sql->select('forum_track', '*', "track_userid=".USERID." AND track_thread=".$threadID))
{
if($this->track('del', USERID, $threadID))
{
$ret['html'] = IMAGE_untrack;
$ret['msg'] = "You are no longer tracking this thread."; //TODO LAN
$ret['status'] = 'ok';
}
else
{
$ret['msg'] = 'There was a problem disabling the tracking.'; //TODO LAN
$ret['status'] = 'error';
}
}
else
{
if($this->track('add', USERID, $threadID))
{
$ret['msg'] = "You are now tracking this thread. "; //TODO LAN
$ret['html'] = IMAGE_track;
$ret['status'] = 'ok';
}
else
{
$ret['html'] = IMAGE_untrack;
$ret['msg'] = "There was a problem."; //TODO LAN
$ret['status'] = 'error';
}
}
echo json_encode($ret);
exit;
}
public function ajaxModerate()
@@ -1536,7 +1604,6 @@ class e107forum
function track($which, $uid, $threadId, $force=false)
{
$e107 = e107::getInstance();
$sql = e107::getDb();
if ($this->prefs->get('track') != 1 && !$force) { return false; }

View File

@@ -69,15 +69,25 @@ if(vartrue($_GET['id']) && isset($_GET['dl']))
exit;
}
if(e_AJAX_REQUEST && varset($_POST['action']) == 'quickreply')
if(e_AJAX_REQUEST)
{
$forum->ajaxQuickReply();
}
if(e_AJAX_REQUEST && MODERATOR) // see javascript above.
{
$forum->ajaxModerate();
if(varset($_POST['action']) == 'quickreply')
{
$forum->ajaxQuickReply();
}
if(varset($_POST['action']) == 'track')
{
$forum->ajaxTrack();
}
if(MODERATOR)
{
$forum->ajaxModerate();
}
}
if (isset($_GET['last']))
{
@@ -91,11 +101,15 @@ if(isset($_GET['f']) && $_GET['f'] == 'post')
$thread->init();
/*
if(isset($_POST['track_toggle']))
{
$thread->toggle_track();
exit;
}
}*/
if(!empty($_GET['f']))
{
@@ -251,11 +265,15 @@ $tVars->NEXTPREV .= "<a class='btn btn-default btn-sm btn-small' href='" . $e107
if ($forum->prefs->get('track') && USER)
{
$img = ($thread->threadInfo['track_userid'] ? IMAGE_track : IMAGE_untrack);
/*
$url = $e107->url->create('forum/thread/view', array('id' => $thread->threadId), 'encode=0'); // encoding could break AJAX call
//FIXME
/*$tVars->TRACK .= "
$url = e107::url('forum','index');
$tVars->TRACK .= "
<span id='forum-track-trigger-container'>
<a class='btn btn-default btn-sm btn-small' href='{$url}' id='forum-track-trigger'>{$img}</a>
<a class='btn btn-default btn-sm btn-small e-ajax' data-target='forum-track-trigger' href='{$url}' id='forum-track-trigger'>{$img}</a>
</span>
<script type='text/javascript'>
e107.runOnLoad(function(){
@@ -273,6 +291,9 @@ if ($forum->prefs->get('track') && USER)
</script>
";*/
$tVars->TRACK = "<a id='forum-track-button' href='#' title=\"".LAN_FORUM_3040."\" data-token='".e_TOKEN."' data-forum-insert='forum-track-button' data-forum-post='".$thread->threadInfo['thread_forum_id']."' data-forum-thread='".$thread->threadInfo['thread_id']."' data-forum-action='track' name='track' class='e-tip btn btn-default' >".$img."</a>
";
}
@@ -754,7 +775,7 @@ class e107ForumThread
$this->noInc = false;
}
/*
function toggle_track()
{
@@ -778,6 +799,7 @@ class e107ForumThread
exit();
}
}
*/
/**
* @return bool|null|string|void

View File

@@ -214,7 +214,7 @@ define("LAN_FORUM_3026", "Post topic as"); // LAN_400 (p)
define("LAN_FORUM_3028", "Add Poll"); // new // poll - partly in e107_plugins/poll/poll_class.php
define("LAN_FORUM_3038", "Normal"); // LAN_1
define("LAN_FORUM_3039", "Deactivate emoticons for this post"); // LAN_FORUMPOST_EMOTES
define("LAN_FORUM_3040", "Enable email tracking (email sent when reply is posted)"); // LAN_380
define("LAN_FORUM_3040", "Enable/disable email tracking (email sent when reply is posted)"); // LAN_380
// missing 41-21
// forum_posted_template

View File

@@ -32,6 +32,9 @@ define('IMAGE_announce', $tp->toGlyph('fa-bullhorn', 'size=2x'));
define('IMAGE_announce_small', $tp->toGlyph('fa-bullhorn'));
define('IMAGE_closed_small', $tp->toGlyph('fa-lock'));
define('IMAGE_closed', $tp->toGlyph('fa-lock', 'size=2x'));
define('IMAGE_track', $tp->toGlyph('fa-bell'));
define('IMAGE_untrack', $tp->toGlyph('fa-bell-o'));
} else {
@@ -54,6 +57,9 @@ define('IMAGE_announce_small', '<img src="'.img_path('announce_small.png').'"
define('IMAGE_closed_small', '<img src="'.img_path('closed_small.png').'" alt="'.LAN_FORUM_1014.'" title="'.LAN_FORUM_1014.'" />');
define('IMAGE_closed', '<img src="'.img_path('closed.png').'" alt="'.LAN_FORUM_1014.'" title="'.LAN_FORUM_1014.'" />');
define('IMAGE_track', '<img src="'.img_path('track.png').'" alt="'.LAN_FORUM_4009.'" title="'.LAN_FORUM_4009.'" class="icon S16 action" />');
define('IMAGE_untrack', '<img src="'.img_path('untrack.png').'" alt="'.LAN_FORUM_4010.'" title="'.LAN_FORUM_4010.'" class="icon S16 action" />');
}
// User info
@@ -65,8 +71,7 @@ define('IMAGE_profile', '<img src="'.img_path('profile.png').'" alt="'.LAN_FORUM
define('IMAGE_pm', '<img src="'.img_path('pm.png').'" alt="'.LAN_FORUM_4008.'" title="'.LAN_FORUM_4008.'" class="icon S16 action" />');
define('IMAGE_edit', '<img src="'.img_path('edit.png').'" alt="'.LAN_EDIT.'" title="'.LAN_EDIT.'" class="icon S16 action" />');
define('IMAGE_quote', '<img src="'.img_path('quote.png').'" alt="'.LAN_FORUM_2041.'" title="'.LAN_FORUM_2041.'" class="icon S16 action" />');
define('IMAGE_track', '<img src="'.img_path('track.png').'" alt="'.LAN_FORUM_4009.'" title="'.LAN_FORUM_4009.'" class="icon S16 action" />');
define('IMAGE_untrack', '<img src="'.img_path('untrack.png').'" alt="'.LAN_FORUM_4010.'" title="'.LAN_FORUM_4010.'" class="icon S16 action" />');
define('IMAGE_admin_edit', '<img src="'.img_path('admin_edit.png').'" alt="'.LAN_EDIT.'" title="'.LAN_EDIT.'" class="icon S16 action" />');
define('IMAGE_admin_move', '<img src="'.img_path('admin_move.png').'" alt="'.LAN_FORUM_2042.'" title="'.LAN_FORUM_2042.'" class="icon S16 action" />');
define('IMAGE_admin_split', '<img src="'.img_path('admin_split.png').'" alt="'.LAN_FORUM_2043.'" title="'.LAN_FORUM_2043.'" class="icon S16 action" />');

View File

@@ -317,7 +317,7 @@ $FORUM_VIEWTOPIC_TEMPLATE['start'] = "
</div>
<div class='row row-fluid'>
<div class='col-md-9 span9 pull-left'><h3>{THREADNAME}</h3></div><div class='col-md-3 span3 pull-right right text-right' style='padding-top:10px'>{BUTTONSX}</div>
<div class='col-md-9 span9 pull-left'><h3>{THREADNAME}</h3></div><div class='col-md-3 span3 pull-right right text-right' style='padding-top:10px'>{TRACK} {BUTTONSX}</div>
</div>
{MESSAGE}