$maxlength) $maxlength = strlen($c["description"]); return $maxlength; } function add_category($desc) { global $cat; if (strlen($desc) == 0) return false; $id = ""; if (count($cat)) foreach ($cat as $c) if ($c["id"] > $id) $id = $c["id"]; $cat[] = array("id" => ++$id, "description" => $desc); return store_category($id); } function modify_category($id, $desc) { global $cat; if (strlen($desc) == 0) return false; if (count($cat)) foreach ($cat as $key => $c) if ($c["id"] == $id) { $cat[$key]["description"] = $desc; return store_category($id); } return false; } function delete_category($id) { global $cat; global $trans; /* check consistance before category deletion */ if (count($trans)) { $t_id = array(); foreach ($trans as $key => $t) if ($t["catid"] == $id) { $trans[$key]["catid"] = 0; $t_id[] = $t["id"]; } if (count($t_id)) store_transaction($t_id); } if (count($cat)) foreach ($cat as $key => $c) if ($c["id"] == $id) { unset($cat[$key]); return store_category($id); } return false; } /* Initialization */ include($lib_dir.$db_type."/category.php"); ?>