#! /bin/sh

impconf="/opt/msg/horde/imp/config/conf.php"
impmbox="/opt/msg/horde/imp/mailbox.php"

#----------------------------------------------------------------------
if ! grep -q "find_unread" $impconf; then
ed $impconf << END > /dev/null 2>&1
/show_attachments/
a

\$conf['mailbox']['find_unread'] = false; 
.
w
q
END
fi
#----------------------------------------------------------------------
if ! grep -q "find_unread" $impmbox; then
ed $impmbox << END > /dev/null 2>&1
/elseif.*\$prefs->getValue('sortby') != SORTTHREAD) {/
d
.-1a
    } elseif (\$imp['mailbox'] != '**search' &&
		\$prefs->getValue('sortby') != SORTTHREAD &&
		\$conf['mailbox']['find_unread'] ) {
.
w
q
END
fi