Seite 1 von 1

Privmsg-Addon User Note 1.3

Verfasst: 18.12.2004 16:10
von jörg gierth
Hier ei kleine Anleitung zum Einbau der User Notes
in die Privaten-Nachrichten:

Code: Alles auswählen

#
#-----[ OPEN ]------------------------------------------
#
privmsg.php

#
#-----[ FIND ]------------------------------------------
#

// ----------
// Start main

#
#-----[ BEFORE, ADD ]------------------------------------------
#
// User Notes MOD
if ( !in_array($HTTP_POST_VARS['add_note_id'], array(-1,0)) && $board_config['disable_notes'] == FALSE && $board_config['import_notes'] != -1 && ($board_config['import_notes'] == 0 || ($board_config['import_notes'] == 2 && $userdata['user_level'] == MOD || $userdata['user_level'] == ADMIN) || ($board_config['import_notes'] == 1 && $userdata['user_level'] == ADMIN)) )
{
	$sql = "SELECT note, bbcode_uid
		FROM " . NOTES_TABLE . "
		WHERE user_id = '" . $userdata['user_id'] . "'
		AND id = '" . $HTTP_POST_VARS['add_note_id'] . "';";
	if ( !($result = $db->sql_query($sql)) )
	{
		message_die(GENERAL_ERROR, "Couldn't obtain note information.", "", __LINE__, __FILE__, $sql);
	}
	$row = $db->sql_fetchrow($result);

	if ( $row['bbcode_uid'] != '' )
	{
		$row['note'] = preg_replace('/\:(([a-z0-9]:)?)' . $row['bbcode_uid'] . '/s', '', $row['note']);
	}

	$HTTP_POST_VARS['message'] = ( mysql_num_rows($result) == "1" ) ? $HTTP_POST_VARS['message'] . "\n" . $row['note'] : $HTTP_POST_VARS['message'];
}


#
#-----[ FIND ]------------------------------------------
#

	$privmsg_subject = str_replace('"', '"', $privmsg_subject);

$template->assign_vars(array(

#
#-----[ Replace with]------------------------------------------
#

   $privmsg_subject = str_replace('"', '"', $privmsg_subject); 

// User Notes MOD
if ( $board_config['disable_notes'] == FALSE && $board_config['import_notes'] != -1 && ($board_config['import_notes'] == 0 || ($board_config['import_notes'] == 2 && $userdata['user_level'] == MOD || $userdata['user_level'] == ADMIN) || ($board_config['import_notes'] == 1 && $userdata['user_level'] == ADMIN)) )
{
	$sql = "SELECT id, title
		FROM " . NOTES_TABLE . "
		WHERE user_id = '" . $userdata['user_id'] . "'
		ORDER BY id " . $userdata['user_notes_sort'] . ";";
	if ( !($result = $db->sql_query($sql)) )
	{
		message_die(GENERAL_ERROR, "Couldn't obtain notes list.", "", __LINE__, __FILE__, $sql);
	}
	$notes_import = "\n\t\t\t  <select name=\"add_note_id\">\n\t\t\t    <option value=\"-1\" selected=\"selected\">" . $lang['Select_note'] . "</option>";
	while ( $row = $db->sql_fetchrow($result) )
	{
		$notes_import_options .=  "\n\t\t\t    <option value=\"" . $row['id'] . "\">" . $row['title'] . "</option>";
	}
	if ( $notes_import_options != '' )
	{
		$notes_import .= "\n\t\t\t    <option value=\"-1\">&nbsp;</option>";
		$notes_import .= "\n\t\t\t    <option value=\"-1\">----------------</option>";
		$notes_import .= $notes_import_options;
	}
	$notes_import .= "\n\t\t\t  </select>";
	$template->assign_block_vars('switch_notes_import', array());
}

//
// Output the data to the template
//
$template->assign_vars(array(
	'L_NOTES_IMPORT' => $lang['Import_note'],
	'L_NOTES_GO' => $lang['Import_note_go'],
	'S_NOTES_IMPORT' => $notes_import,

so das war es schon.

Gruß Jörg