This is something that my users required, so I built the functionality with the following code.

I have a module called MYSITE (not really, but you get the idea) that I do small modifications to for my site. In that module I put the following code:

function MYSITE_get_forum_moderators($tid) {
  $moderators = array();
  $acl_id = db_result(db_query("SELECT acl_id from {acl} WHERE module = 'forum_access' && name = %d", $tid));
  $query = db_query("SELECT u.uid, u.name FROM {users} u INNER JOIN {acl_user} a ON u.uid = a.uid WHERE a.acl_id = %d", $acl_id);
  $i = 0;
  while($account = db_fetch_object($query)) {
    $moderators[$i] = l($account->name, "users/".$account->name);
    $i++;
  }
  return $moderators;
}

Now you have a function that goes and gets all of the moderators for a given $tid and returns an array of links to that users profile.

In the file advf-forum-list.tpl.php now all you have to do is place the moderator information. In the else section of this conditional ( if ($forum->is_container): ) I put the following code below the description section.

<?php if ($moderators = MYSITE_get_forum_moderators($child_id)): ?>
  <div class="moderators"><?php print t("Moderators: ").implode(", ",$moderators); ?></div>
<?php endif; ?>

Thats it... Enjoy...

Comments

swill’s picture

A slight modification. On my site I do not allow Anonymous users to view profiles, because of this I do not want them to see a link, just the name of the moderator. I have modified the function slightly to do a check if there is a user logged in and then generate the array appropriately...

Cheers...

function MYSITE_get_forum_moderators($tid) {
  global $user;
  $moderators = array();
  $acl_id = db_result(db_query("SELECT acl_id from {acl} WHERE module = 'forum_access' && name = %d", $tid));
  $query = db_query("SELECT u.uid, u.name FROM {users} u INNER JOIN {acl_user} a ON u.uid = a.uid WHERE a.acl_id = %d", $acl_id);
  $i = 0;
	if ($user->uid) { // show moderators as links cause I am logged in...
	  while($account = db_fetch_object($query)) {
	    $moderators[$i] = l($account->name, "users/".$account->name);
	    $i++;
	  }
	} else { // just show the moderator names...
	  while($account = db_fetch_object($query)) {
	    $moderators[$i] = $account->name;
	    $i++;
	  }
	}
  return $moderators;
}
Michelle’s picture

Component: Code » Contrib integration

I need to dig in this more but, just based on your comment, I would change that to use theme_username which already takes care of the access control unless there's some reason why you didn't do that?

Duping #303541: Add list of forum moderators in favor of this one since it has code. Also, for reference, #109924: List moderators in forums listing in the forum access queue.

Do you have any idea if this code works with the D6 version of forum access?

Michelle

swill’s picture

The reason I did not use theme_username is because i am ignorant. haha... I did not realize that function existed. That is a much better solution obviously, so here is the updated function:

function MYSITE_get_forum_moderators($tid) {
  $moderators = array();
  $acl_id = db_result(db_query("SELECT acl_id from {acl} WHERE module = 'forum_access' && name = %d", $tid));
  $query = db_query("SELECT u.uid, u.name FROM {users} u INNER JOIN {acl_user} a ON u.uid = a.uid WHERE a.acl_id = %d", $acl_id);
  $i = 0;
  while($account = db_fetch_object($query)) {
    $moderators[$i] = theme_username($account);
    $i++;
  }
  return $moderators;
}

In regards to D6, I do not know... I do not have any forums running in D6 yet. If someone could test that it would be appreciated...

aharown07’s picture

I think I might be interested in using this but I'm not clear on what it does. Does it just list moderators assigned to each forum? What caught my eye was "access moderators" because I'm looking now for a way to make all new "authenticated users" go to a queue and wait for approval by someone before they can post in the forums.
Does this do that?

Edit: just realized moderation of new accounts is built in if you use that setting... just hadn't looked in the right place.

I'd still like to know what what his hack here does though!

Michelle’s picture

This is to list the moderators on the forum listing.

Michelle

aharown07’s picture

Tks, Michelle.

Michelle’s picture

Status: Active » Postponed

This is going to wait for 2.x

Michelle

Michelle’s picture

Status: Postponed » Active

Un postponing because #109924: List moderators in forums listing makes this a trivial add.

Michelle

Michelle’s picture

Status: Active » Postponed

Actually... That's a D6 only feature on FA's end and I want the 1.0 of both branches to be the same. Re-postponing but it will likely be one of the first things to go into 2.x.

Michelle

Michelle’s picture

Version: 5.x-1.x-dev » 6.x-2.x-dev
Status: Postponed » Active
Michelle’s picture

Component: Contrib integration » Styles
Status: Active » Closed (won't fix)

Will be using the new moderation module instead. Will file a new issue when that is ready.

Michelle

Elin Yordanov’s picture

Hey, thanks for the script. I have adjusted it for Drupal 7 version. If anyone needs it for Drupal 7, here is my code:

function MYMODULE_get_forum_moderators($tid) {
  $moderators = array();
  
  $acl_id = db_query("SELECT acl_id FROM {acl} WHERE module = 'forum_access' && number = :number", array(':number' => $tid))
      ->fetchField();
  $query = db_query("SELECT u.uid FROM {users} u INNER JOIN {acl_user} a ON u.uid = a.uid WHERE a.acl_id = :acl_id", array(':acl_id' => $acl_id));

  foreach ($query as $i => $account) {
    $moderators[$i] = user_load($account->uid);
  }

  return $moderators;
}

I also changed it a little bit, so that it returns not only the user name, but the complete user object, so that I can access all user fields.