PDA

View Full Version : How to add username var to thread title for VB Garage?


cTak
03-16-2011, 01:59 AM
I use the modification VB Pro Garage Timeslips (https://vborg.vbsupport.ru/showthread.php?t=236888).

When a user adds a new vehicle to their garage, a new post is automatically made in a certian forum.

You can customize the title, and the body, of this post. By default they are as follows:

Title: A new vehicle has been created in the garage!
Body: {username} has created a new vehicle in the garage. Go check out their {vehicle}!

I want to use the {username} variable in the title as well, to make the title look like this.

{username} added their {vehicle} to their garage. , but the variables do not work.
It shows up like this:
https://vborg.vbsupport.ru/attachment.php?attachmentid=127476&stc=1&d=1300244337

Anyone know how to make this work?

cTak
03-16-2011, 02:02 AM
I believe I've tracked it down to this code from the file garage_func_var.php

I need to add the {username} var to the $title somehow, just like the $pagetext has the str_replace of {username}

Anyone help me out with what coding is needed to make this work?

$threaddm =& datamanager_init('Thread_FirstPost', $vbulletin, ERRTYPE_ARRAY, 'threadpost');

$allowsmilie = '1';
$visible = '1';
$forumid = $vbulletin->options[garage_post_forum];
$userid = $vbulletin->options[garage_post_user];

$title = addslashes($vbulletin->options[garage_post_subject]);

$vehicle_link = get_gar_veh_link($return_var, $vbphrase, $vbulletin, $garage_seo_rules);
$veh_name = get_display_vehicle($return_var);

$new_veh_user_link = get_gar_user_link($data[userid], $vbphrase, $vbulletin, $garage_seo_rules);
$new_veh_user = htmlspecialchars_uni(fetch_userinfo($data[userid]));

$full_user_link = '' . $new_veh_user[username] . ' (' . $new_veh_user_link . ')';

$full_veh_link = '' . $veh_name . ' (' . $vehicle_link . ')';

$foruminfo = fetch_foruminfo($forumid);
$threadinfo = array();
$user = htmlspecialchars_uni( fetch_userinfo($userid) );

if (!$user[username])
{
$userid = '1';
}

$pagetext = str_replace('{username}', $full_user_link, $vbulletin->options[garage_post_text]);
$pagetext = str_replace('{vehicle}', $full_veh_link, $pagetext);

$pagetext = str_replace('{username}', $full_user_link, $vbulletin->options[garage_post_subject]);
$pagetext = str_replace('{vehicle}', $full_veh_link, $pagetext);

cTak
03-16-2011, 02:04 AM
Note:
"garage_post_subject" is "{username} added their {vehicle} to their garage" from the database

"garage_post_text" is "{username} has created a new vehicle in the garage. Go check out their {vehicle}!" from the database as well

HMBeaty
03-16-2011, 02:05 AM
This should help you out a bit. From one of my old modifications.....
// Check to see if create new thread is enabled
if ($vbulletin->options['usml_staffapp_createthread'] == 1)
{
// Make a new thread
require_once(DIR . '/includes/functions_newpost.php');

$forumid = intval($vbulletin->options['usml_staffapp_forumid']);
$user_id = $vbulletin->userinfo['userid'];
$username = $vbulletin->userinfo['username'];

$target_foruminfo = fetch_foruminfo($forumid);
$newpost = array(
'userid' => $user_id,
'username' => $username,
'message' => $message2,
'title' => 'Staff Application: ' . $vbulletin->GPC['username'],
'poststarttime' => time(),
'emailupdate' => 0
);

build_new_post('thread', $target_foruminfo, array(), array(), $newpost, $errors);

// Check if any errors during post
if (sizeof($errors) > 0)
{
// Post of new thread failed !
$error_info = construct_errors($errors);
//echo $error_info;
// do anything you want here - likely to redirect !
// ...
}

// Fix forums counters
build_forum_counters($forumid);
}