From 50b3f83354ae493d4eda65579d3b0d9a6d932cc0 Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Wed, 12 Nov 2008 13:59:08 -0700 Subject: [PATCH] Fix mimeIdArithmetic(). --- framework/Mime/lib/Horde/Mime.php | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/framework/Mime/lib/Horde/Mime.php b/framework/Mime/lib/Horde/Mime.php index 76adec0c0..e0e3e75e3 100644 --- a/framework/Mime/lib/Horde/Mime.php +++ b/framework/Mime/lib/Horde/Mime.php @@ -461,11 +461,9 @@ class Horde_Mime { $pos = strrpos($id, '.'); - /* Check for moving beyond the top of the message. */ - if (is_null($pos) && - ($id == '0') && - in_array($action, array('prev', 'up'))) { - return null; + /* Check the boundary case (ID = 0). */ + if (($pos === false) && ($id == '0')) { + return in_array($action, array('prev', 'up')) ? null : 1; } switch ($action) { @@ -475,13 +473,13 @@ class Horde_Mime case 'next': case 'prev': - $id = is_null($pos) + $id = ($pos === false) ? intval($id) + (($action == 'next') ? 1 : -1) : substr_replace($id, intval(substr($id, $pos + 1)) + (($action == 'next') ? 1 : -1), $pos + 1); break; case 'up': - $id = is_null($pos) + $id = ($pos === false) ? 0 : substr($id, 0, $pos); break; -- 2.11.0