I want to give comments made by Moderators (manager users, &canmoderate) a different css class. By default comments are given jot-row or jot-row-alt. Also, if you (the one viewing) made a comment it’s been given jot-row-me, and if the comment was made by the same user that created the page/news item it gets the class jot-row-author.
I’ve been sniffing about in the jot.class.inc file on where to add that, and found this function:
// Templating
function getChunkRowClass($count,$userid) {
$rowstyle = ($count%2) ? "jot-row-alt" : "";
if ( $this->config["user"]["id"] == $userid && ($userid != 0)) {
$rowstyle .= " jot-row-me";
} elseif ( $this->config["authorid"] == $userid && ($userid != 0) ) {
$rowstyle .= " jot-row-author";
}
return $rowstyle;
}
So now I want it to set $rowstyle to jot-row-mod... but I’m still new at the whole PHP thing, and I can’t think of how to add the elseif for it... I’m pretty sure I’ll also have to add a new line for jot-row-mod in this part of the run function:
// CSS Settings (basic)
$this->config["css"]["include"] = !is_null($this->Get("css")) ? intval($this->Get("css")) : 1;
$this->config["css"]["file"] = !is_null($this->Get("cssFile")) ? $this->Get("cssFile") : "assets/snippets/jot/templates/jot.css";
$this->config["css"]["rowalt"] = !is_null($this->Get("cssRowAlt")) ? $this->Get("cssAltRow") : "jot-row-alt";
$this->config["css"]["rowme"] = !is_null($this->Get("cssRowMe")) ? $this->Get("cssRowMe") : "jot-row-me";
$this->config["css"]["rowauthor"] = !is_null($this->Get("cssRowAuthor")) ? $this->Get("cssRowAuthor") : "jot-row-author";
My guess would be adding the following would settle that part:
$this->config["css"]["rowmod"] = !is_null($this->Get("cssRowMod")) ? $this->Get("cssRowMod") : "jot-row-mod";
(Even I can copy/paste and edit a few references

)
I found this in the Run function also:
$this->config["permissions"]["moderate"] = !is_null($this->Get("canmoderate")) ? explode(",",$this->Get("canmoderate")):array();
so my thought was I could use that for the elseif to determine if someone’s a moderator, yes or no.
I’d need to find if the users name exists in the groups that can moderate.... Found another function that reads the names/ids of a group:
function getMembersOfWebGroup($groupNames=array()) {
global $modx;
$usrIDs = array();
$tbl = $modx->getFullTableName("webgroup_names");
$tbl2 = $modx->getFullTableName("web_groups");
$sql = "SELECT distinct wg.webuser
FROM $tbl wgn
INNER JOIN $tbl2 wg ON wg.webgroup=wgn.id AND wgn.name IN ('" . implode("','",$groupNames) . "')";
$usrRows = $modx->db->getColumn("webuser", $sql);
foreach ($usrRows as $k => $v) $usrIDs[] = intval($v);
return $usrIDs;
}
So this is what I came up with to be added in the first code I quoted in this post:
<....>
$modsareinhere = $this->getMembersOfWebGroup($this->Get("canmoderate"));
elseif (strpos($modsareinhere,$userid) && ($userid != 0)) {
$rowstyle .= " jot-row-mod";
}
<...>
Can you help me get this right? I admit I didn’t test this yet... but with my knowledge of PHP I doubt I can get it right in one go anyway ^_^
Any general or specific feedback is much appreciated!