MyMood on User Profile...
Skiilz Offline
Member
***
Posts: 198
Joined: Nov 2010
Post: #11
RE: MyMood on User Profile...
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:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
<?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...


[Image: 468x602b.png]
(This post was last modified: 11-22-2010 05:16 AM by Skiilz.)
11-21-2010 11:07 PM
Find all posts by this user Quote this message in a reply

« Next Oldest | Next Newest »

Messages In This Thread
MyMood on User Profile... - Skiilz - 11-21-2010, 02:19 AM
RE: MyMood on User Profile... - Skiilz - 11-21-2010, 11:07 AM
RE: MyMood on User Profile... - leefish - 11-21-2010, 11:40 AM
RE: MyMood on User Profile... - Skiilz - 11-21-2010, 12:15 PM
RE: MyMood on User Profile... - leefish - 11-21-2010, 01:25 PM
RE: MyMood on User Profile... - Skiilz - 11-21-2010, 01:32 PM
RE: MyMood on User Profile... - Imran - 11-21-2010, 09:32 PM
RE: MyMood on User Profile... - Skiilz - 11-21-2010, 10:17 PM
RE: MyMood on User Profile... - Imran - 11-21-2010, 11:00 PM
RE: MyMood on User Profile... - Skiilz - 11-21-2010 11:07 PM
RE: MyMood on User Profile... - RateU - 11-22-2010, 05:12 AM
RE: MyMood on User Profile... - Skiilz - 11-22-2010, 05:18 AM
RE: MyMood on User Profile... - RateU - 11-22-2010, 07:00 AM
RE: MyMood on User Profile... - Skiilz - 11-22-2010, 07:02 AM
RE: MyMood on User Profile... - RateU - 11-22-2010, 07:06 AM
RE: MyMood on User Profile... - Skiilz - 11-22-2010, 07:09 AM
RE: MyMood on User Profile... - 1master1 - 11-22-2010, 07:42 AM
RE: MyMood on User Profile... - Skiilz - 11-22-2010, 09:21 AM
RE: MyMood on User Profile... - Skiilz - 11-22-2010, 09:54 AM

 Standard Tools
Forum Jump: