Cache class rewritten to better convention
[mailer.git] / inc / functions.php
index 66324337f68d134e09d79940aba79f6620e04568..d5a4f20347509cd0f2b2833ad90ad51290228827 100644 (file)
@@ -1139,8 +1139,20 @@ function ADD_SELECTION($type, $DEFAULT, $prefix="", $id="0") {
                // Get current year
                $YEAR = date('Y', time());
 
+               // Use configured min age or fixed?
+               if (GET_EXT_VERSION("other") >= "0.2.1") {
+                       // Configured
+                       $startYear = $YEAR - $_CONFIG['min_age'];
+               } else {
+                       // Fixed 16 years
+                       $startYear = $YEAR - 16;
+               }
+
+               // Calculate earliest year (100 years old people can still enter Internet???)
+               $minYear = $YEAR - 100;
+
                // Check if the default value is larger than minimum and bigger than actual year
-               if (($DEFAULT > 1930) && ($DEFAULT >= $YEAR)) {
+               if (($DEFAULT > $minYear) && ($DEFAULT >= $YEAR)) {
                        for ($idx = $YEAR; $idx < ($YEAR + 11); $idx++) {
                                $OUT .= "<OPTION value=\"".$idx."\"";
                                if ($DEFAULT == $idx) $OUT .= " selected=\"selected\"";
@@ -1148,20 +1160,28 @@ function ADD_SELECTION($type, $DEFAULT, $prefix="", $id="0") {
                        } // END - for
                } elseif ($DEFAULT == -1) {
                        // Current year minus 1
-                       for ($idx = 2003; $idx <= ($YEAR + 1); $idx++)
+                       for ($idx = $startYear; $idx <= ($YEAR + 1); $idx++)
                        {
                                $OUT .= "<OPTION value=\"".$idx."\">".$idx."</OPTION>\n";
                        }
                } else {
                        // Get current year and subtract the configured minimum age
-                       $OUT .= "<OPTION value=\"1929\">&lt;1930</OPTION>\n";
-                       $YEAR = date('Y', time()) - $_CONFIG['min_age'];
-                       for ($idx = 1930; $idx <= $YEAR; $idx++)
-                       {
+                       $OUT .= "<OPTION value=\"".($minYear - 1)."\">&lt;".$minYear."</OPTION>\n";
+                       // Calculate earliest year depending on extension version
+                       if (GET_EXT_VERSION("other") >= "0.2.1") {
+                               // Use configured minimum age
+                               $YEAR = date('Y', time()) - $_CONFIG['min_age'];
+                       } else {
+                               // Use fixed 16 years age
+                               $YEAR = date('Y', time()) - 16;
+                       }
+
+                       // Construct year selection list
+                       for ($idx = $minYear; $idx <= $YEAR; $idx++) {
                                $OUT .= "<OPTION value=\"".$idx."\"";
                                if ($DEFAULT == $idx) $OUT .= " selected=\"selected\"";
                                $OUT .= ">".$idx."</OPTION>\n";
-                       }
+                       } // END - for
                }
                break;
 
@@ -1172,7 +1192,7 @@ function ADD_SELECTION($type, $DEFAULT, $prefix="", $id="0") {
                        $OUT .= "<OPTION value=\"".$idx."\"";
                        if ($DEFAULT == $idx) $OUT .= " selected=\"selected\"";
                        $OUT .= ">".$idx."</OPTION>\n";
-               }
+               } // END - for
                break;
 
        case "hour":
@@ -1181,7 +1201,7 @@ function ADD_SELECTION($type, $DEFAULT, $prefix="", $id="0") {
                        $OUT .= "<OPTION value=\"".$idx."\"";
                        if ($DEFAULT == $idx) $OUT .= " selected=\"selected\"";
                        $OUT .= ">".$idx."</OPTION>\n";
-               }
+               } // END - for
                break;
 
        case "yn":
@@ -2602,9 +2622,9 @@ function REBUILD_CACHE ($cache, $inc="") {
        // Shall I remove the cache file?
        if ((EXT_IS_ACTIVE("cache")) && (is_object($cacheInstance))) {
                // Rebuild cache
-               if ($cacheInstance->cache_file($cache)) {
+               if ($cacheInstance->loadCacheFile($cache)) {
                        // Destroy it
-                       $cacheInstance->cache_destroy();
+                       $cacheInstance->destroyCacheFile();
                } // END - if
 
                // Include file given?