forked from benthebear/Semantic-Weblog
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsemanticweblog.api.inc
executable file
·72 lines (64 loc) · 2.71 KB
/
semanticweblog.api.inc
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
<?php
// $Id$
/* Author: Benjamin Birkenhake <[email protected]>*/
/**
* @file:
* This file contains all functions which are meant to be used outside of the module in other modules or themes
*
* @todo: Add function for the genealogy (parents, grantparents, children, grandchildren) for a given termid
*
*
*/
/**
* History
*
* 2009 12 30 [ben]: Created this file
*/
/**
* This function get's all Associations in which a give Term is the first member (upwards)
*
* @param termid integer The ID of the given Term
* @return associations array An Array with all necessary Information of the Associations.
* @see semanticweblog_term_get_foreign_associations(), semanticweblog_term_get_all_associations()
*/
function semanticweblog_api_term_get_own_associations($termid){
$result = db_query("SELECT * FROM {semanticweblog_associations} WHERE member1tid = %d ", $termid);
$raw_associations = semanticweblog_association_result2items($result);
return semanticweblog_types_and_associations2array($raw_associations);
}
/**
* This function get's all Associations in which a give Term is the second member (downwards)
*
* @param termid integer The ID of the given Term
* @return associations array An Array with all necessary Information of the Associations.
* @see semanticweblog_term_get_own_associations(), semanticweblog_term_get_all_associations()
*/
function semanticweblog_api_term_get_foreign_associations($termid){
$result = db_query("SELECT * FROM {semanticweblog_associations} WHERE member2tid = %d", $termid);
$raw_associations = semanticweblog_association_result2items($result);
return semanticweblog_types_and_associations2array($raw_associations);
}
/**
* This function get's all Associations in which a give Term is a member
*
* @param termid integer The ID of the given Term
* @return associations array An Array with all necessary Information of the Associations.
* @see semanticweblog_term_get_own_associations(), semanticweblog_term_get_foreign_associations()
*/
function semanticweblog_api_term_get_all_associations($termid){
$result = db_query("SELECT * FROM {semanticweblog_associations} WHERE member1tid = %d or member2tid = %d", $termid, $termid);
$raw_associations = semanticweblog_association_result2items($result);
return semanticweblog_types_and_associations2array($raw_associations);
}
/**
* This function simply checks if any associations exists for the given term
*
* @param termid integer The ID of the given Term
* @return bool
*/
function semanticweblog_api_check_associations($termid){
$result = db_query("SELECT aid FROM {semanticweblog_associations} WHERE member1tid = %d or member2tid = %d LIMIT 1", $termid, $termid);
$data = db_fetch_array($result);
if ($data) { return TRUE; }
else { return FALSE; }
}