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.
Indicating an administrator on the discussions page
There is already an indicator on the comments page that lets users know when a comment's author is an administrator. What I would like to do is add this functionality to the discussions page. If you look at where it says "Started By: kl" under the discussion topic, I would like to add a piece of text or an image there that indicates that I am an administrator (assuming I were an administrator on this board).
In the comments page this is easily accomplished because the $Comment->AuthRoleID attribute is retrieved as part of the row data. In fact, it's built in to Vanilla. Unfortunately in the discussions page no similar AuthRoleID attribute is retrieved. Looking at the code, and at extensions dealing with similar functionality, it appears this will require adding some SQL to the SQLBuilder.
I have not played much yet with the SQL part of Vanilla, so it would take me some time before I could be sure I was writing correct code to do this. Has anyone already done this, or is there an extension that I don't know about that does this? How would you go about adding this feature?
Thanks
0
Comments
GetDiscussionList()
method doesn't retrieve the Role IDs of the users. Here is an extension file that will make those available in the Discussion Object so you can then utilize them in the theme files:<?php /* Extension Name: Discussion List Role Style Extension Url: http://lussumo.com/community/ Description: Adds a class in the discussion list defining the roles of the Original Author and Last Posters. It will take the form of: class="AuthUserRoleID-x LastUserRoleID-x" Version: 1.0 Author: Matthew Pietz Author Url: http://lance-systems.com/ */ if ($Context->SelfUrl == 'index.php') { $Context->AddToDelegate('DiscussionManager', 'PreGetDiscussionList', 'DLRS_InjectRoleSQL'); function DLRS_InjectRoleSQL(&$Manager) { $s =& $Manager->DelegateParameters['SqlBuilder']; // Discussion author Role ID $s->AddSelect('RoleID', 'u', 'AuthUserRoleID'); // Last poster Role ID $s->AddSelect('RoleID', 'lu', 'LastUserRoleID'); } $Context->AddToDelegate('Discussion', 'PostGetPropertiesFromDataSet', 'DLRS_AddToDataSet'); function DLRS_AddToDataSet(&$Discussion) { $DataSet =& $Discussion->DelegateParameters['DataSet']; $Discussion->AuthUserRoleID = @$DataSet['AuthUserRoleID']; $Discussion->LastUserRoleID = @$DataSet['LastUserRoleID']; } }
Then, all you need to do in the
themes/discussion.php
file is add whatever classes you want and select them in your CSS.<?php if ($Context->SelfUrl == 'index.php') { // [Code goes here] }
This is to conform to the "useless load" guideline in the documentation: vanilla:extensions. That will ensure that the code will only be executed when it is needed. Be sure to keep the comments at the top as that is how Vanilla determines if the folder is in fact an extension
EDIT: I modified my first comment to reflect this change.