forked from pellcorp/opendb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathitem_listing_conf.php
113 lines (94 loc) · 4.05 KB
/
item_listing_conf.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<?php
/*
OpenDb Media Collector Database
Copyright (C) 2001,2013 by Jason Pell
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
include_once("./lib/item_type_group.php");
include_once("./lib/item_type.php");
function fetch_item_listing_conf_rs() {
$query = "SELECT id, s_item_type, s_item_type_group FROM s_item_listing_conf";
$result = db_query ( $query );
return db_result_or_false($result);
}
function fetch_s_item_listing_column_conf_rs($silc_id) {
$query = 'SELECT column_no, column_type, s_field_type, s_attribute_type, override_prompt, orderby_support_ind, orderby_datatype, orderby_sort_order, orderby_default_ind, printable_support_ind ' . 'FROM s_item_listing_column_conf ' . 'WHERE silc_id = ' . $silc_id . ' ' . 'ORDER BY column_no';
$result = db_query ( $query );
return db_result_or_false($result);
}
function fetch_s_item_listing_conf_id($s_item_type_group, $s_item_type) {
if ($s_item_type_group == NULL)
$s_item_type_group = '*';
if ($s_item_type == NULL)
$s_item_type = '*';
$query = "SELECT id FROM s_item_listing_conf WHERE s_item_type_group = '$s_item_type_group' AND s_item_type = '$s_item_type'";
$result = db_query ( $query );
return db_result_single_lookup($result, 'id');
}
function is_exists_s_item_listing_column_conf($silc_id, $s_item_type_group = NULL, $s_item_type = NULL) {
if (! is_numeric ( $silc_id ))
$silc_id = fetch_s_item_listing_conf_id ( $s_item_type_group, $s_item_type );
if (is_numeric ( $silc_id )) {
$query = "SELECT 'x' FROM s_item_listing_column_conf WHERE silc_id = $silc_id";
$result = db_query ( $query );
return db_result_has_rows($result);
}
return FALSE;
}
/**
This function is to be called from listings.php, for either a s_item_type_group or
s_item_type. if s_item_type is defined, thats used first, otherwise we rely on
s_item_type_group
*/
function get_s_item_listing_column_conf_rs($s_item_type_group, $s_item_type) {
$silc_id = NULL;
if (strlen ( $s_item_type ) > 0 && $s_item_type != '*' && is_exists_item_type ( $s_item_type )) {
$silc_id = fetch_s_item_listing_conf_id ( NULL, $s_item_type );
} else if (strlen ( $s_item_type_group ) > 0 && $s_item_type_group != '*' && is_exists_item_type_group ( $s_item_type_group )) {
$silc_id = fetch_s_item_listing_conf_id ( $s_item_type_group, NULL );
}
if (! is_numeric ( $silc_id )) {
// get the default
$silc_id = fetch_s_item_listing_conf_id ( NULL, NULL );
}
if (is_exists_s_item_listing_column_conf ( $silc_id )) {
$results = fetch_s_item_listing_column_conf_rs ( $silc_id );
if ($results) {
while ( $item_listing_column_conf_r = db_fetch_assoc ( $results ) ) {
// special indicator that this column is an item listings configuration column and should be
// left in the listings page even if exact match on this column is being performed.
$item_listing_column_conf_r ['item_listing_conf_ind'] = 'Y';
$item_listing_column_conf_rs [] = $item_listing_column_conf_r;
}
db_free_result ( $results );
}
return $item_listing_column_conf_rs;
} else {
return array (
array (
'column_type' => 's_field_type',
's_field_type' => 'TITLE' ),
array (
'column_type' => 'action_links' ),
array (
'column_type' => 's_field_type',
's_field_type' => 'OWNER' ),
array (
'column_type' => 's_field_type',
's_field_type' => 'STATUSTYPE' ),
array (
'column_type' => 's_field_type',
's_field_type' => 'CATEGORY' ) );
}
}
?>