Support for new packaged extensions system.
[fa-stable.git] / includes / data_checks.inc
index 8e03d5849567ff107b12d1e3029ea537b0750ddb..ff316953030d9c322fea21c2a7e3aced11717340 100644 (file)
@@ -428,6 +428,22 @@ function db_has_quick_entries()
        return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."quick_entries");
 }
 
+function db_has_tags($type)
+{
+       return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."tags WHERE type=$type");
+}
+
+function check_db_has_tags($type, $msg)
+{
+       global $path_to_root;
+    if (!db_has_tags($type)) 
+    {
+       display_error($msg, true);
+       end_page();
+       exit;   
+    }  
+}
+
 function check_empty_result($sql)
 {
        $result = db_query($sql, "could not do check empty query");     
@@ -454,12 +470,13 @@ function check_int($postname, $min=null, $max=null) {
 //
 //     Numeric input check.
 //     Return 1 if number has proper form and is within <min, max> range
+//     Empty/not defined fields are defaulted to $dflt value.
 //
-function check_num($postname, $min=null, $max=null) {
+function check_num($postname, $min=null, $max=null, $dflt=0) {
        if(!isset($_POST[$postname]))
          return 0;
-    $num = input_num($postname);
-    if ($num === false) 
+    $num = input_num($postname, $dflt);
+    if ($num === false || $num === null
          return 0;
     if (isset($min) && ($num<$min)) 
          return 0;