Platform
3.1
PHP API documentation
Main Page
Related Pages
Namespaces
Data Structures
Files
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Pages
onefam_gettreefamily.php
Go to the documentation of this file.
1
<?php
2
/*
3
* @author Anakeen
4
* @license http://creativecommons.org/licenses/by-nc-sa/2.0/fr/ Anakeen - licence CC
5
* @package FDL
6
*/
7
/**
8
* Retrieve search from onefam
9
*
10
* @author Anakeen 2009
11
* @license http://creativecommons.org/licenses/by-nc-sa/2.0/fr/ Anakeen - licence CC
12
* @package FDL
13
* @subpackage
14
*/
15
/**
16
*/
17
18
include_once (
"FDL/Class.Dir.php"
);
19
include_once (
"FDL/Class.SearchDoc.php"
);
20
/**
21
* Retrieve search from onefam
22
*
23
* @param Action &$action current action
24
* @global appid Http var : application name
25
*/
26
function
onefam_gettreefamily
(&
$action
)
27
{
28
$out
=
onefam_getDataTreeFamily
(
$action
);
29
30
$action
->lay->noparse =
true
;
// no need to parse after - increase performances
31
$action
->lay->template = json_encode(
$out
);
32
}
33
34
function
onefam_getDataTreeFamily
(&
$action
)
35
{
36
37
$dbaccess
=
$action
->GetParam(
"FREEDOM_DB"
);
38
39
$tfs = array();
40
41
$mids = explode(
","
,
$action
->getParam(
"ONEFAM_MIDS"
));
42
43
foreach
($mids as $fid) {
44
if
($fid) {
45
$cdoc =
new_Doc
(
$dbaccess
, $fid);
46
if
($cdoc->isAlive() && $cdoc->control(
'view'
) ==
""
) {
47
$fs =
getFamilySearches
(
$dbaccess
, $fid);
48
if
($fs) $tfs[] = $fs;
49
}
50
}
51
}
52
$utfs = array();
53
54
$umids = explode(
","
,
$action
->getParam(
"ONEFAM_IDS"
));
55
56
foreach
($umids as $fid) {
57
if
($fid && ($fs =
getFamilySearches
(
$dbaccess
, $fid))) $utfs[] = $fs;
58
}
59
60
$out
= array(
61
"application"
=> array(
62
"name"
=>
$action
->parent->name,
63
"label"
=> _(
$action
->parent->description)
64
) ,
65
"user"
=> $utfs,
66
"admin"
=> $tfs
67
);
68
return
$out
;
69
}
70
function
getFamilySearches
(
$dbaccess
, $fid)
71
{
72
$fam = new_doc(
$dbaccess
, $fid);
73
74
if
($fam->isAlive()) {
75
$to
[
"info"
] = array(
76
"id"
=> $fam->id,
77
"title"
=> $fam->getTitle() ,
78
"icon"
=> $fam->getIcon()
79
);
80
81
$s
=
new
SearchDoc
(
$dbaccess
,
"SEARCH"
);
82
$s->addFilter(
"owner="
. $fam->userid);
83
$s->addFilter(
"se_famid='"
. $fam->id .
"'"
);
84
$s->setObjectReturn();
85
$s->setDebugMode();
86
$t
= $s->search();
87
while
($v = $s->nextDoc()) {
88
89
$to
[
"userSearches"
][] = array(
90
"id"
=> $v->id,
91
"icon"
=> $v->getIcon() ,
92
"title"
=> $v->getTitle()
93
);
94
}
95
96
$s =
new
SearchDoc
(
$dbaccess
,
"SEARCH"
);
97
$s->dirid = $fam->dfldid;
98
$s->setObjectReturn();
99
$s->setDebugMode();
100
$t
= $s->search();
101
while
($v = $s->nextDoc()) {
102
103
$to
[
"adminSearches"
][$fid] = array(
104
"id"
=> $v->id,
105
"icon"
=> $v->getIcon() ,
106
"title"
=> $v->getTitle()
107
);
108
}
109
110
if
($fam->wid > 0) {
111
$w = new_doc(
$dbaccess
, $fam->wid);
112
if
($w->isAlive()) {
113
114
foreach
($w->getStates() as
$c
) {
115
$to
[
"workflow"
][
$c
] = array(
116
"state"
=>
$c
,
117
"label"
=> _(
$c
) ,
118
"activity"
=> $w->getActivity(
$c
) ,
119
"color"
=> $w->getColor(
$c
)
120
);
121
}
122
}
123
}
124
125
return
$to
;
126
}
else
return
null;
127
}
128
?>
← centre documentaire
© anakeen
- published under
CC License
-
Dynacase