Add Horde_Mime::isChild()
authorMichael M Slusarz <slusarz@curecanti.org>
Mon, 9 Nov 2009 20:42:37 +0000 (13:42 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Tue, 10 Nov 2009 16:51:23 +0000 (09:51 -0700)
framework/Mime/lib/Horde/Mime.php

index 9f9afce..211a229 100644 (file)
@@ -669,6 +669,20 @@ class Horde_Mime
     }
 
     /**
+     * Determines if a given MIME ID lives underneath a base ID.
+     *
+     * @param string $base  The base MIME ID.
+     * @param string $id    The MIME ID to query.
+     *
+     * @return boolean  Whether $id lives underneath $base.
+     */
+    static public function isChild($base, $id)
+    {
+        return ((($base == 0) && ($id != 0)) ||
+                strpos(strval($id), strval($base)) === 0);
+    }
+
+    /**
      * Scans $input for uuencoded data and converts it to unencoded data.
      *
      * @param string $input  The input data