MyBB Hacks

Full Version: MyMood on User Profile...
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
I would pay if I had money.... but I don't have so I need to find free solutions.
The author won't help me because he isn't online anymore.. But I posted in the MyBB plugins support, hope someone help me... This would be great.

So far I have edited the mood.php to this one:

PHP Code:
<?php
/**
* Plugin Name: MyMood
* Plugin Author: Hamid Nozari & jnd52
* Plugin Website: http://www.shceg.com
* Plugin Forum: http://forum.shceg.com
* Plugin Version: 1.0
* Plugin Mybb Compatibility: 1.4.x
* Plugin Description: This will show user mood for current day.
**/

$plugins->add_hook("member_profile_end","mood_profile",1);
$plugins->add_hook('global_start', 'mood_link');
$plugins->add_hook("postbit", "mood");


function mood_info()
{
	return array(
		'name'			=> 'MyMood',
		'description'	=> 'This will show user mood for current day.',
		'website'		=> 'http://www.shceg.com',
		'author'		=> 'Hamid Nozari & jnd52',
		'authorsite'	=> 'http://www.shceg.com',
		'version'		=> '1.0 Beta',
		'guid'        	=> '309c48c6d3a2c338663dd8d8ec6abe58'
	);
}

function mood_activate()
{
	global $db;
	
	if(!$db->field_exists("mood","users"))
	$db->query("ALTER TABLE ".TABLE_PREFIX."users ADD `mood` INT NOT NULL DEFAULT 0");

	$templatearray = array(
		"tid" => "0",
		"title" => "mood_postbit",
		"template" => "<br><span class=\"smalltext\">{\$lang->mood_mood}: {\$post[\'mood\']}<br /></span>",
		"sid" => "-1",
		);
		
	$db->insert_query("templates", $templatearray);
	
		$templatearray = array(
		"tid" => "0",
		"title" => "mood_change",
		"template" => "
		<html>
		<head>
		<title>{\$mybb->settings[\'bbname\']} - {\$lang->mood_mood}</title>
		{\$headerinclude}
		</head>
		<body>
		<table border=\"0\" cellspacing=\"{\$theme[\'borderwidth\']}\" cellpadding=\"{\$theme[\'tablespace\']}\" class=\"tborder\" width=\"100%\">
		<tr>
			<td class=\"trow1\" align=\"center\">
				<form name=\"form\" action=\"\$_SERVER[PHP_SELF]\" method=\"post\">
		
					\$mood_change

					<input type=\"submit\" name=\"change\" value=\"{\$lang->mood_changebutton}\" />
				</form>
			</td>
		</tr>
		</table>
		</body>
		</html>
		",
		"sid" => "-1",
		);
		
	$db->insert_query("templates", $templatearray);
	
	//Add MyMood link to members welcome block
	require MYBB_ROOT.'/inc/adminfunctions_templates.php';
	find_replace_templatesets('header_welcomeblock_member', '#{\$lang->welcome_open_buddy_list}</a>#', "{\$lang->welcome_open_buddy_list}</a>{\$mood_link}");

		$mood_setting_1 = array(
		"sid"			=> "NULL",
		"name"			=> "enablemood",
		"title"			=> "Enable MyMood System?",
		"description"	=> "Turn the system on and off",
		"optionscode"	=> "yesno",
		"value"			=> "1",
		"disporder"		=> "1",
		"gid"			=> intval($gid),
	);
	
		$mood_setting_2 = array(
		"sid"			=> "NULL",
		"name"			=> "mood_on_profile",
		"title"			=> "Show MyMood on Profile?",
		"description"	=> "If yes, a box will show with the user mood on profile.",
		"optionscode"	=> "yesno",
		"value"			=> "1",
		"disporder"		=> "1",
		"gid"			=> intval($gid),
	);	

		$db->insert_query("settings", $mood_setting_1);
		$db->insert_query("settings", $mood_setting_2);
		rebuild_settings();

	$mood_template = array(
		"title"		=> 'global_profile_mood',
		"template"	=> "<tr>
	<td class=\"trow1\"><strong>MyMood</strong></td>
	<td class=\"trow1\">{\$mood}</td>
</tr>",
		"sid"		=> -1,
		"version"	=> 120,
		"status"	=> '',
		"dateline"	=> 1134703642,
	);
	$db->insert_query('templates', $mood_template);
	find_replace_templatesets("member_profile", '#{\$reputation}#', "{\$reputation}\n{\$mood_box}\n");
	
}

function mood_deactivate()
{
	global $db;
	
	if($db->field_exists("mood","users"))
	$db->query("ALTER TABLE ".TABLE_PREFIX."users DROP mood");
	
	$db->delete_query("templates","title='mood_postbit'");
	$db->delete_query("templates","title='mood_change'");
	$db->delete_query("templates","title='mood_profile'");
	$db->delete_query("templates","title='global_profile_mood'");
	
	require MYBB_ROOT.'/inc/adminfunctions_templates.php';
	find_replace_templatesets('header_welcomeblock_member', '#{\$mood_link}#', '', 0);
}

function mood_profile()
{
	global $mybb,$db,$templates,$mood_box,$memprofile,$lang;
	//Make sure it's enabled, and that they want them shown on profile.
	if ($mybb->settings['enablemood'] == '1' AND $mybb->settings['mood_on_profile'] == 1)
	{
		$getMood = $db->simple_select("users","mood","uid={$puid['uid']}");
		while ($mood_key = $db->fetch_array($getMood);
		{
		$mood.="<img src='.$dir.$image_name.'.gif alt="'.$image_name.'"> &nbsp;";
		}
			eval("\$mood_box = \"".$templates->get('global_profile_mood')."\";");
	}
}

function mood($post)
{
	global $db, $mybb, $lang, $templates, $theme;
	
	$lang->set_language($mybb->settings['bblanguage']);
	$lang->load("mood");

	//Open mood image dir and get images name
	$dir = $theme['imgdir'].'/mood/';
	
	if (!is_dir($dir))
	{
		print $dir . $lang->mood_notfound;
		return;
	}
		
	$dh = opendir($dir);

	$i=1;
	$mood = array();
	$mood = array(0 => $lang->mood_none);
	while (($file = readdir($dh)) !== false)
	{
		if($file != '.' && $file != '..' && !is_dir($dh.$file)) 
		{
			$mood+= array($i => substr($file,0,-4));
	    	$i++;
		}
	}
	
	closedir($dh);
	//Close mood images dir/////////////////
	
	$mood = str_replace(" ", " ", $mood); 
	
	//Get users mood images and put in postbit
	$query = $db->simple_select("posts","uid","pid={$post['pid']}");
	$puid = $db->fetch_array($query);
	
	$query = $db->simple_select("users","mood","uid={$puid['uid']}");
	$mood_key = $db->fetch_array($query);
	
	if ($mood_key['mood']!=0)
	{
		$image_name = $mood[$mood_key['mood']];
		$post['mood']=null;
		$post['mood'].= ' '.'<img src='.$dir.$image_name.'.gif alt="'.$image_name.'">';
	}
	else 
	{
		$post['mood']= ' '.$lang->mood_none;
	}
	
	eval("\$post['mood'] = \"".$templates->get("mood_postbit")."\";");
	$post['user_details'].=$post['mood'];
}

function mood_link()
{
	global $mybb, $lang, $mood_link;

	$lang->set_language($mybb->settings['bblanguage']);
	$lang->load('mood');
	
	$mood_link = " | <b><a href=\"#\" onClick=\"MyBB.popupWindow('mood.php', 'MyMood', 300, 200);\">".$lang->mood_mood."</a></b>";
}
?>


But it didn't show up in the plugins list... :/
I'm sure I did something wrong...

You can try to "duplicate" the mood function code, and edit it.

Actually, we can use Custom Profile Fields and Template Conditional plugin to create a simple "Mood" system for our forum. We can display it in several pages in our forum.

Here is in profile:
http://www.14.mynie.co.cc/member.php?act...http://www.14.mynie.co.cc/member.php?action=profile&uid=

And in postbit:
http://www.14.mynie.co.cc/showthread.php?tid=143
The last user in the thread has no Mood (doesn't select any Mood).
Good one...
Could you tell me how to do it the way you posted?
It is not using a plugin. I'm using Custom Profile Fields and conditional in template (can use Template Conditional plugin) for that.
Ok. But how you did it? How did you make it show on profile and postbit?
I have added one profile field with the options:

Code:
Happy
Sad
Love


What would be the TC to make the Happy appear as one image (happy.png)..?

I will create a tutorial for this later, so, maybe other MyBB Hacks members can use it too.
Thank you RateU. Smile
thats cool, rateu
I managed to create the code...
Custom Profile Fields:

Code:
Happy
Sad
Love


Then I created the Profile code:

Code:
<tr>
<td class="trow2"><strong>My Mood:</strong></td>
<td class="trow2">
<if $mybb->user['fid10'] == '' then>
No Mood Selected.
</if>
<if $mybb->user['fid10'] == 'Happy' then>
<img src="{$mybb->settings['bburl']}/Happy.gif" alt="I'm Happy"  />
</if>
<if $mybb->user['fid10'] == 'Sad' then>
<img src="{$mybb->settings['bburl']}/Sad.gif" alt="I'm Sad"  />
</if>
<if $mybb->user['fid10'] == 'Love' then>
<img src="{$mybb->settings['bburl']}/In-Love.gif" alt="I'm in Love"  />
</if>
</td>
</tr>


But... If I change my mood.. It will change the mood for everyone... :/

$mybb->user is the currently logged in user.

I think it's $memprofile or similar for the user you're looking at.
Pages: 1 2 3
Reference URL's