Recent Topics

1 Feb 26, 2008 19:04    

My b2evolution Version: Not Entered

I'm looking to make private messages in my blog. I am using 2.4.

Here's what I'm looking for:
I have a blog that I use for updating my employees on an intranet. Our supervisors have posting rights and our operators can make moderated comments. I'd like the supervisors to be able to select an agent name from a dropdown list. The selection will fill in a text box with the user's current private message, which can then be edited and saved by the supervisor.

I added a new column to one of my tables in my b2evo database.
DB > b2
Table > evo_users
Column > user_message

I have been surfing through php manuals like crazy trying to figure out how i can reference this new column based on the user who is currently logged in.

I have a switch based on group ID which determines if the user has the dropdown list or simply the message itself.

Any ideas on how to get this completed would be great.

Thanks,
Brandon

2 Feb 28, 2008 21:58

So with my extra field in the database i figured out how to do it. now i know for sure this is not the best or easiest way to do this, but this is what works and it's pretty stable.

if( !empty( $current_User ) )
{
if( $current_User->level > 1 ) { $userlevel = 1; }
else { $userlevel = 2; }
}
switch( $userlevel )
{
     case 1:
	echo '<li class="widget_core_coll_category_list"><h2>Personal Message</h2>';
	$result = mysql_query("SELECT user_message FROM evo_users WHERE user_ID='$current_User->ID'");
	$row = mysql_fetch_array($result);
	echo '<textarea readonly cols="20" rows="10">', $row['user_message'], '</textarea></li>';

	echo '<li class="widget_core_coll_category_list"><h2>Edit Messages</h2>';
	echo '<form name="msgMessage" method="POST" action="msgaction.php"><select name="usertoedit" id="usertoedit">';
 	$result = mysql_query("SELECT * FROM evo_users ORDER BY user_login");
	$before = '<option value="';
	$after = '">';

	while($row = mysql_fetch_array($result))
  	{
  	echo $before ;
	echo $row['user_login'];
	echo $after ;
	echo $row['user_login'];
	echo '</option>';
	echo "\r\n";
  	}
	echo '</select><br><input type="submit" name="choose" value="Choose"></form></li>';

     break;
     case 2:
	echo '<li class="widget_core_coll_category_list"><h2>Personal Message</h2>';
	$result = mysql_query("SELECT user_message FROM evo_users WHERE user_ID='$current_User->ID'");
	$row = mysql_fetch_array($result);
	echo '<textarea readonly cols="20" rows="10">', $row['user_message'], '</textarea></li>';
     break;
     default:
}

then i have msgactionphp with an editable textarea so you can change the message which in turn runs to msgupdate.php which sets the message in the database and returns to the blog.

3 Feb 28, 2008 22:47

Is this something that might be better as a plugin? You can create tables with a plugin that will not be at-risk when b2evolution upgrades and changes details about the db that you are taking advantage of is what I'm thinking.

4 Feb 29, 2008 20:36

most likely. i used b2evo a long time ago, but i just started to use it for the company at which i work. i'm not too worried about upgrading, but if i decide to play with b2 tables on my personal blog, i'll definitely consider that.


Form is loading...