osTicket / osTicket-1.7

osTicket-1.7
GNU General Public License v2.0
232 stars 178 forks source link

class.mailparse.php function parsePriority #108

Open olondono opened 12 years ago

olondono commented 12 years ago

Some WebMail not use the tag "X-Priority:" to define an email as urgent, there are two tags that also define the priority, "X-MSMail-Priority" and "X-MSMail-Priority:", modify the function such a way to verify these other tags, if you find it interesting:

function parsePriority($header=null){

    $priority=0;
    if($header && ($begin=strpos($header, 'X-Priority: '))!==false){
        $begin+=strlen('X-Priority: ');
        $xpriority=substr($header, $begin, (strpos($header, "\n", $begin)?strpos($header, "\n", $begin):strlen($header)) - $begin);
        switch ($xpriority){
            case "5 (Lowest)":
                $priority=1;
                break;
            case "1 (Highest)":
                $priority=3;
                break;
            default:
                $priority=2;
        }
    }elseif($header && ($begin=strpos($header, 'X-MSMail-Priority: '))!==false){
        $begin+=strlen('X-MSMail-Priority: ');
        $xpriority=substr($header, $begin, (strpos($header, "\n", $begin)?strpos($header, "\n", $begin):strlen($header)) - $begin);
        switch ($xpriority){
            case "Low":
                $priority=1;
                break;
            case "High":
                $priority=3;
                break;
            default:
                $priority=2;
        }
    }elseif($header && ($begin=strpos($header, 'Importance: '))!==false){
        $begin+=strlen('Importance: ');
        $xpriority=substr($header, $begin, (strpos($header, "\n", $begin)?strpos($header, "\n", $begin):strlen($header)) - $begin);
        switch ($xpriority){
            case "Low":
                $priority=1;
                break;
            case "High":
                $priority=3;
                break;
            default:
                $priority=2;
        }
    }
    echo $priority;
    return $priority;
}
protich commented 12 years ago

Google translate:

Some WebMail not use the tag "X-Priority:" to define an email as urgent, there are two tags that also define the priority, "X-MSMail-Priority" and "X-MSMail-Priority:", modify the function such a way to verify these other tags, if you find it interesting: