Click here to Skip to main content
16,022,060 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
In the below function, I am getting php errors complaining about undefined variable: winmailDat.

Code appears to work, but I'm trying to clean it up - I think I haven't defined it?

if ($show_attach_container) {
        $description .= '<tr><td colspan=2> <fieldset>
        <legend class="'.$attach_toggle_cls.'" onclick="og.toggle(\'mv_attachments\',this)">' . lang('attachments') . '</legend>
        <div id="mv_attachments" style="'.$attach_div_style.'">
        <table>';
        foreach($attachments as $att) {
            if (!array_var($att, 'hide')) {
                $size = $att['size'];//format_filesize(strlen($att["Data"]));
                $fName = str_starts_with($att["FileName"], "=?") ? iconv_mime_decode($att["FileName"], 0, "UTF-8") : utf8_safe($att["FileName"]);
                if (trim($fName) == "" && strlen($att["FileName"]) > 0) $fName = utf8_encode($att["FileName"]);
                $description .= '<tr><td style="padding-right: 10px">';

                $ext = get_file_extension($fName);
                $fileType = FileTypes::getByExtension($ext);
                $icon = $fileType instanceof FileType ? $fileType->getIcon() : "unknown.png";

                $att_id = $c;
                $inside_attachment = trim(array_var($att, 'inside_attachment', ""));
                if ($inside_attachment != "") {
                    $att_id = $inside_attachment;
                }
                $download_url = get_url('mail', 'download_attachment', array('email_id' => $email->getId(), 'attachment_id' => $att_id));
                include_once ROOT . "/library/browser/Browser.php";
                if (Browser::instance()->getBrowser() == Browser::BROWSER_IE) {
                    $download_url = "javascript:location.href = '$download_url';";
                }

                $description .= '<img src="' . get_image_url("filetypes/" . $icon) .'"></td>
                <td><div id="att-link-container-'.$c.'">
                    <a target="_self" href="' . $download_url . '&fileAttachName='.$fName.'&winmailtype='.$winmailDat.'" class="download-attachment-link">' . clean($fName) . " ($size)" . '</a>
                </div></td></tr>';
            }
            $c++;
        }
        $description .= '</table></div></fieldset></td></tr>';
    }


What I have tried:

I'm unsure how to define this variable properly, and would appreciate any assistance.
Posted

1 solution

You need to create the variable somewhere, and initialise it to contain whatever you expect to be added at the point you are using it. That is in the anchor line:
PHP
<a target="_self" href="' . $download_url . '&fileAttachName='.$fName.'&winmailtype='.$winmailDat.'" class="download-attachment-link">' . clean($fName) . " ($size)" . '</a>

So it looks like it should be some type definition that is used by the link to define the winmailtype parameter in the URL.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900