SMF Development > Bug Reports

sendpm()

(1/2) > >>

Inter:
Hello!

maybe this is a bug?  ???

/Sources/Subs-Post.php
Function sendpm()

I think this code is not needed.
Remove this code:

--- Code: --- // Probably not needed.  /me something should be of the typer.
else
$user_info['name'] = $from['name'];
--- End code ---

For Example:


--- Code: --- sendpm(array('to' => array($member), 'bcc' => array()), 'Notice', 'Message', FALSE, array('id' => 0, 'name' => 'System', 'username' => 'System'));

$smcFunc['db_insert']('insert',
'{db_prefix}...',
array(..., 'poster_name' => 'string-255', ...),
array(..., $user_info['name'], ...),
array(...)
);
--- End code ---

The result was a mistake:
 $user_info['name'] - System
in fact, the user name was different
turns out that the function changes the value of which should not be changed?

Arantor:
It is needed, absolutely.

If you want to override the name of the sender of the PM, use the $from parameter, that's why it's there. If it's null (because it's not supplied), it'll use the previous block of code to get the current user's name.

If it was supplied, $user_info['name'] is overridden with the name supplied in $from.

emanuele:
Thanks for the report.
Yes, I noticed this code a couple of days ago doing something else...ah, the contact form and I'm not sure why it is there.


--- Quote from: Arantor on July 08, 2012, 10:05:17 AM ---If it was supplied, $user_info['name'] is overridden with the name supplied in $from.

--- End quote ---
Yes, that's the first thing I thought, but then this $user_info is never used in the function and that's a bit strange...

I think the original intention was:

--- Code: ---$from['name'] = $from;
--- End code ---
because later on the code looks like:

--- Code: --- $mailsubject = str_replace(array('SUBJECT', 'SENDER'), array($subject, un_htmlspecialchars($from['name'])), $txt['new_pm_subject']);
$mailmessage = str_replace(array('SUBJECT', 'MESSAGE', 'SENDER'), array($subject, $message, un_htmlspecialchars($from['name'])), $txt['pm_email']);

--- End code ---
So, override the "from" nick will result anyway in an undefined index error if I'm not wrong.

Arantor:
*shrug* I've done contact forms in the past and it's worked as expected for me...

emanuele:
yups...

* emanuele should read better the code documentation...

Navigation

[0] Message Index

[#] Next page

Go to full version