/
core_category_API.php
52 lines (48 loc) · 1.61 KB
/
core_category_API.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
# Mantis - a php based bugtracking system
# Copyright (C) 2000 - 2002 Kenzaburo Ito - kenito@300baud.org
# This program is distributed under the terms and conditions of the GPL
# See the files README and LICENSE for details
###########################################################################
# Category API
###########################################################################
# --------------------
# checks to see if the category is a duplicate
# we do it this way because each different project can have the same category names
function is_duplicate_category( $p_project_id, $p_category ) {
global $g_mantis_project_category_table;
$query = "SELECT COUNT(*)
FROM $g_mantis_project_category_table
WHERE project_id='$p_project_id' AND
category='$p_category'";
$result = db_query( $query );
$category_count = db_result( $result, 0, 0 );
if ( $category_count > 0 ) {
return true;
} else {
return false;
}
}
# --------------------
# return all categories for the specified project id
function category_get_all( $p_project_id ) {
global $g_mantis_project_category_table;
$query = "SELECT category
FROM $g_mantis_project_category_table
WHERE project_id='$p_project_id'
ORDER BY category";
return db_query( $query );
}
# --------------------
function category_add( $p_project_id, $p_category ) {
global $g_mantis_project_category_table;
# insert category
$query = "INSERT
INTO $g_mantis_project_category_table
( project_id, category )
VALUES
( '$p_project_id', '$p_category' )";
return db_query( $query );
}
# --------------------
?>