22 include_once (
"Class.QueryDb.php");
23 include_once (
"Class.Application.php");
24 include_once (
"Class.User.php");
25 include_once (
"Class.Acl.php");
26 include_once (
"Class.Permission.php");
27 include_once (
"Class.Domain.php");
28 include_once (
"Lib.Http.php");
29 include_once (
"FDL/freedom_util.php");
44 $aclList =
$q->query(0, 0,
"TABLE", sprintf(
"SELECT id_user, id_application, id_acl FROM permission WHERE computed IS NULL OR computed = FALSE;"));
47 foreach ($aclList as $k => & $el) {
49 if ($app_name === null) {
50 error_log(__CLASS__ .
"::" . __FUNCTION__ .
" " . sprintf(
"Unknown name for application with id '%s'", $el[
'id_application']));
55 if ($acl_name === null) {
56 error_log(__CLASS__ .
"::" . __FUNCTION__ .
" " . sprintf(
"Uknown name for acl with id '%s'", $el[
'id_acl']));
59 if ($el[
'id_acl'] < 0) {
60 $acl_name = sprintf(
"-%s", $acl_name);
64 if ($user_fid === null) {
65 error_log(__CLASS__ .
"::" . __FUNCTION__ .
" " . sprintf(
"Unknown fid for user with wid '%s'", $el[
'id_user']));
70 if ($user_name ==
"") {
71 $user_name = $el[
'id_user'];
74 array_push($aclExport, array(
76 'app_name' => $app_name,
77 'acl_name' => $acl_name
81 $action->lay->setBlockData(
"ACCESS", $aclExport);
83 $tmpfile = tempnam(
getTmpDir() ,
"access");
84 if ($tmpfile ===
false) {
85 $err = sprintf(
"Could not create temporary file!");
86 error_log(__CLASS__ .
"::" . __FUNCTION__ .
" " .
$err);
91 $fp = @fopen($tmpfile,
'x');
93 $err = sprintf(
"Error opening temporary file '%s'", $tmpfile);
94 error_log(__CLASS__ .
"::" . __FUNCTION__ .
" " .
$err);
101 if (
$ret ===
false) {
102 $err = sprintf(
"Error writing to temporary file '%s'", $tmpfile);
103 error_log(__CLASS__ .
"::" . __FUNCTION__ .
" " .
$err);
119 if (is_array($cache) && array_key_exists(
'app', $cache)) {
120 if (array_key_exists(
$id, $cache[
'app'])) {
121 return $cache[
'app'][
$id];
126 $query->addQuery(sprintf(
"id = %s", pg_escape_string(
$id)));
127 $res =
$query->query(0, 0,
"TABLE");
128 if (!is_array($res)) {
132 $name = $res[0][
'name'];
133 if (is_array($cache) && array_key_exists(
'app', $cache)) {
142 if (is_array($cache) && array_key_exists(
'acl', $cache)) {
143 if (array_key_exists(
$id, $cache[
'acl'])) {
144 return $cache[
'acl'][
$id];
149 $query->addQuery(sprintf(
"id = %s", pg_escape_string(abs(
$id))));
150 $res =
$query->query(0, 0,
"TABLE");
151 if (!is_array($res)) {
155 $name = $res[0][
'name'];
156 if (is_array($cache) && array_key_exists(
'acl', $cache)) {
165 if (is_array($cache) && array_key_exists(
'user_fid', $cache)) {
166 if (array_key_exists(
$id, $cache[
'user_fid'])) {
167 return $cache[
'user_fid'][
$id];
172 $query->addQuery(sprintf(
"id = %s", pg_escape_string($wid)));
173 $res =
$query->query(0, 0,
"TABLE");
174 if (!is_array($res)) {
178 $fid = $res[0][
'fid'];
179 if (is_array($cache) && array_key_exists(
'user_fid', $cache)) {
180 $cache[
'user_fid'][$wid] = $fid;