Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
New Discussions
NickE
New
New Discussions
0
Comments
All Discussions : New Discussions
is there any way to get rid of All Discussions so the heading of the page is just:
New Discussions
P.S. I did not test it in real situations, but my home local tests were good. So this code must be checked before publication in add-on.
if($Context->SelfUrl == 'index.php' && ForceIncomingString('View', '') == 'NewDiscussions' && $Context->Session->User->UserID) { $Context->AddToDelegate('DiscussionManager', 'PostGetDiscussionBuilder', 'NewDiscussionsBuilder'); $Context->AddToDelegate('DiscussionManager', 'PreGetDiscussionCount', 'NewDiscussionsCounter'); $Context->AddToDelegate('DiscussionGrid', 'Constructor', 'NewDiscussionsConstructor'); if(ND_ADD_TAB) $Context->AddToDelegate('Menu', 'PreRender', 'NewDiscussionsSetTab'); function NewDiscussionsBuilder(&$D) { $s = &$D->DelegateParameters['SqlBuilder']; $s->AddWhere('t', 'CountComments', 'utw', 'CountComments', '>', 'and', '', 0, 1); $s->AddWhere('', '', 'utw', 'CountComments', '', 'or', 'ISNULL', 0, 0); // last date in discussion (NOT include Whispers date) > history date $s->AddWhere('t', 'DateLastActive', 'utw', 'LastViewed', '>', 'or', '', 0, 0); // if user can view all whispers if ($D->Context->Session->User->Permission('PERMISSION_VIEW_ALL_WHISPERS')) { // then count comments + total whisper count of a theme > history count comments $s->AddWhere('', 't.CountComments+t.TotalWhisperCount', '', 'utw.CountComments', '>', 'or', '', 0, 0); // else } else { // all incoming + all outcoming whispers + count comments (CountComments DOES NOT include Whispers) > history count comments $s->AddWhere('', 'tuwf.CountWhispers+tuwt.CountWhispers+t.CountComments', 'utw', 'CountComments', '>', 'or', '', 0, 0); } $s->EndWhereGroup(); //echo $s->GetSelect(); } function NewDiscussionsCounter(&$D) { $D->DelegateParameters['SqlBuilder']->AddJoin( 'UserDiscussionWatch', 'utw', 'DiscussionID', 't', 'DiscussionID', 'left join', ' and utw.'.$D->Context->DatabaseColumns['UserDiscussionWatch']['UserID'].' = '. $D->Context->Session->UserID ); if (!$D->Context->Session->User->Permission('PERMISSION_VIEW_ALL_WHISPERS')) { $D->DelegateParameters['SqlBuilder']->AddJoin( 'DiscussionUserWhisperFrom', 'tuwf', 'DiscussionID', 't', 'DiscussionID', 'left join', ' and tuwf.'.$D->Context->DatabaseColumns['DiscussionUserWhisperFrom']['LastUserID'].' = '. $D->Context->Session->UserID ); $D->DelegateParameters['SqlBuilder']->AddJoin( 'DiscussionUserWhisperTo', 'tuwt', 'DiscussionID', 't', 'DiscussionID', 'left join', ' and tuwt.'.$D->Context->DatabaseColumns['DiscussionUserWhisperTo']['LastUserID'].' = '. $D->Context->Session->UserID ); } NewDiscussionsBuilder($D); } function NewDiscussionsConstructor(&$F) { $F->Context->PageTitle .= ' : '.$F->Context->GetDefinition('NewDiscussions'); } function NewDiscussionsSetTab(&$F) { $F->CurrentTab = 'new_discussions'; } }