SMF Development > Fixed or Bogus Bugs

2.0.1, attachments removed by the admin

<< < (2/2)

Yoshi:
Why don't ya do both, eh? :P

emanuele:
* emanuele is tired... :(

Yoshi:
* Yoshi2889 isn't at midnight but doesn't feel like writing a patch either ::)
No, really, I dunno how to fix something like that.

emanuele:
It's no so difficult, it is "just" a matter of

--- Code: ---loadLanguae(#forumdefault#);
[do teh job];
loadLanguage(#user's lang#);

--- End code ---
It's more annoying find the relevant code... :P

emanuele:

--- Code: (find) ---function RemoveAttachment()
{
global $modSettings, $txt, $smcFunc;

checkSession('post');

if (!empty($_POST['remove']))
{
$attachments = array();
// There must be a quicker way to pass this safety test??
foreach ($_POST['remove'] as $removeID => $dummy)
$attachments[] = (int) $removeID;

if ($_REQUEST['type'] == 'avatars' && !empty($attachments))
removeAttachments(array('id_attach' => $attachments));
else if (!empty($attachments))
{
$messages = removeAttachments(array('id_attach' => $attachments), 'messages', true);

// And change the message to reflect this.
if (!empty($messages))
$smcFunc['db_query']('', '
UPDATE {db_prefix}messages
SET body = CONCAT(body, {string:deleted_message})
WHERE id_msg IN ({array_int:messages_affected})',
array(
'messages_affected' => $messages,
'deleted_message' => '<br /><br />' . $txt['attachment_delete_admin'],
)
);
}
}

$_GET['sort'] = isset($_GET['sort']) ? $_GET['sort'] : 'date';
redirectexit('action=admin;area=manageattachments;sa=browse;' . $_REQUEST['type'] . ';sort=' . $_GET['sort'] . (isset($_GET['desc']) ? ';desc' : '') . ';start=' . $_REQUEST['start']);
}
--- End code ---


--- Code: (replace with) ---function RemoveAttachment()
{
global $txt, $smcFunc, $language;

checkSession('post');

if (!empty($_POST['remove']))
{
$attachments = array();
// There must be a quicker way to pass this safety test??
foreach ($_POST['remove'] as $removeID => $dummy)
$attachments[] = (int) $removeID;

if ($_REQUEST['type'] == 'avatars' && !empty($attachments))
removeAttachments(array('id_attach' => $attachments));
else if (!empty($attachments))
{
$messages = removeAttachments(array('id_attach' => $attachments), 'messages', true);

// And change the message to reflect this.
if (!empty($messages))
{
loadLanguage('index', $language, true);
$smcFunc['db_query']('', '
UPDATE {db_prefix}messages
SET body = CONCAT(body, {string:deleted_message})
WHERE id_msg IN ({array_int:messages_affected})',
array(
'messages_affected' => $messages,
'deleted_message' => '<br /><br />' . $txt['attachment_delete_admin'],
)
);
loadLanguage('index', $user_info['language'], true);
}
}
}

$_GET['sort'] = isset($_GET['sort']) ? $_GET['sort'] : 'date';
redirectexit('action=admin;area=manageattachments;sa=browse;' . $_REQUEST['type'] . ';sort=' . $_GET['sort'] . (isset($_GET['desc']) ? ';desc' : '') . ';start=' . $_REQUEST['start']);
}
--- End code ---

Navigation

[0] Message Index

[*] Previous page

Go to full version