Firefox PHP

adjustable user levels

Posted by Davey 
adjustable user levels
January 06, 2008 12:37AM
I want to create a mod that a moderator can use to store data in a custom user profile field. ie:
I've started a challenge forum that involves completing various challenges. When a user completes all chanllenges to get to level 1, a moderator can type a level status in an input box next to the user's post and adjust that user's custom profile field with the new status.

So:
I started by making a custom profile field, mod_userlevel

Then I tried to make a mod with this in it:
if(!defined("PHORUM")) return;

function mod_userlevel($messages){
	GLOBAL $PHORUM;
    foreach ($messages as $messageid => $message) {
        		$author = phorum_user_get($message["user_id"]);
				if (isset($author["mod_userlevel"])) {
					$messages[$messageid]["mod_userlevel"] = $author["mod_userlevel"];
				} else {
					$messages[$messageid]["mod_userlevel"] = "N00B";
				}
			
    }
    return $messages;
}

And tried to change my read.tpl so that it would show in each message for a specific forum:
IF MESSAGES->mod_userlevel}
       {IF MESSAGES->forum_id 9}
            <div class="PhorumReadBodyHead">PbP Rank: {MESSAGES->linked_author} is a <strong>{MESSAGES->mod_userlevel}</strong></div>
             {IF MODERATOR true}<input type="text" name="mod_userlevel" size="30" value="{PROFILE->mod_userlevel}" /><input type="submit" class="PhorumSubmit" value="Submit" />{/IF}
       {/IF}
{/IF}

but I am probably going about this entirely the wrong way, because right now, everyone is a n00b and my submit button doesn't work.
The docs I have for using custom profile fields don't show any php code to reference the custom fields, but only a template change example. I hope someone will explain to me what I need to do to finish this mod.

Re: adjustable user levels
January 06, 2008 11:22AM
It might be easier to do this with groups (already built into the system).
Re: adjustable user levels
January 06, 2008 02:32PM
Well... I've scrapped above code for now and am using the userrank mod twice with variable names changed... one copy of userrank is for standard post-based ranks. The other copy is named userlevel and has variable names changed. It stores custom levels for the specific forum in which I am trying to use these levels. Now I just need to find a way to allow moderators to set these levels in settings.php without accessing admin.php. I will definately figure this out eventually, but if anybody has an idea right now, I would appreciate it.





Edited 1 time(s). Last edit at 01/06/2008 02:34PM by Davey.
Re: adjustable user levels
January 06, 2008 03:49PM
Settings.php is always only available from the admin module configuration interface. It's not a front end interface. So that's probably not the place where you want to be adding stuff for moderators.


Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce
Re: adjustable user levels
January 06, 2008 07:29PM
thanks for the tip... got it to work by putting data similar to form data in settings.php in the actual module.

Re: adjustable user levels
January 07, 2008 05:46PM
I've added an ability for mods to password protect certain threads by typing in a thread id and password into a form.

I found this code in userrank.php for building a userlist dropdown:
    // build a list of users for the dropdown
    $temp = phorum_user_get_list();
    $userlist = array();
    $userlist[-1] = "select a username";
    
    foreach ($temp as $userid => $user) {
        $userlist[$userid] = $user["displayname"];
    }
Is threre a way that I can make a thread list dropdown using something like this, but only showing threads in a specific forum?

Re: adjustable user levels
January 07, 2008 05:58PM
That is quite a different thing. You could look for functions that you could use in list.tpl. But what do you have in mind here? It doesn't scale really well, because the menu will grow, grow and grow and in the end, the pages that have this drop in them will be huge. Doesn't it make more sense to let the moderator navigate to the thread for which to do something needs to be done and offer them a feature there to do so? Otherwise, you might look at phorum_db_get_recent_messages() from the database layer to only show recent threads instead of all of them.


Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce
Sorry, only registered users may post in this forum.

Click here to login