-
Notifications
You must be signed in to change notification settings - Fork 1
/
pnuserapi.php
executable file
·166 lines (145 loc) · 5.17 KB
/
pnuserapi.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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
<?php
/**
* FormExpress : Build forms for Zikula through a web interface
*
* @copyright (c) 2002 Stutchbury Limited, 2011 Chris Candreva
* @Version $Id$
* @license GNU/GPL - http://www.gnu.org/copyleft/gpl.html
* @package FormExpress
*
*
* Origianally written by Philip Fletcher for PostNuke
* Updated for Zikula API by Christopher X. Candreva
*
* LICENSE
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License (GPL)
* 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.
*
* To read the license please visit http: *www.gnu.org/copyleft/gpl.html
* ----------------------------------------------------------------------
* Purpose of file: FormExpress User API
* ----------------------------------------------------------------------
*/
/**
* get all Forms
* @returns array
* @return array of items, or false on failure
*/
function FormExpress_userapi_getall($args)
{
// Security check - important to do this as early as possible
if (!SecurityUtil::checkPermission ('FormExpress::', '::', ACCESS_ADD)) {
return LogUtil::registerPermissionError();
}
// Security check for entire function
if (!pnSecAuthAction(0, 'FormExpress::', '::', ACCESS_READ)) {
return array();
}
// Security check for each item
$permFilter = array('component_left' => 'FormExpress',
'component_middle' => '',
'component_right' => '',
'instance_left' => 'form_name',
'instance_middle' => '',
'instance_right' => 'form_id',
'level' => ACCESS_READ);
$formObj = DBUtil::SelectObjectArray('FormExpress','','form_name',-1,-1,'',$permFilter);
return $formObj;
}
/**
* get a specific item
* @param $args['form_id'] id of example item to get
* @returns array
* @return item array, or false on failure
*/
function FormExpress_userapi_get($args)
{
// Check for passed form_id
if ( $args['form_id'] ) {
$form_id = $args['form_id'];
} else {
pnSessionSetVar('errormsg', __("Missing formid in items_getall"));
return false;
}
// $table = pnDBGetTables();
// Security check for each item
$permFilter = array('component_left' => 'FormExpress',
'component_middle' => '',
'component_right' => '',
'instance_left' => 'form_name',
'instance_middle' => '',
'instance_right' => 'form_id',
'level' => ACCESS_READ);
$formObj = DBUtil::selectObjectById('FormExpress', $form_id, 'form_id', null, $permFilter);
// Return the item array
return $formObj;
}
/**
* utility function to count the number of items held by this module
* @returns integer
* @return number of items held by this module
*/
/* This appears to not be used, so I will comment it out for now.
function FormExpress_userapi_countitems()
{
return DBUtil::selectObjectCount('FormExpress');
}
*
*/
/**
* get all example items
* @returns array
* @return array of items, or false on failure
*/
function FormExpress_userapi_items_getall($args)
{
// Check for passed form_id
if ( $args['form_id'] ) {
$form_id = $args['form_id'];
} else {
pnSessionSetVar('errormsg', __("Missing formid in items_getall"));
return false;
}
if (isset($args['status'])) {
$status = $args['status'];
}
// Security check - important to do this as early as possible
if (!SecurityUtil::checkPermission ('FormExpress::', '::', ACCESS_ADD)) {
return LogUtil::registerPermissionError();
}
$table = pnDBGetTables();
$FormExpressItemcolumn = &$table['FormExpressItem_column'];
// Retrieve all items with the passed form_id
$where = 'WHERE ' . $FormExpressItemcolumn[form_id] . '=' . $form_id;
// If a status was passed we add that as a WHERE clause
if (isset($status)) {
$where .= " AND $FormExpressItemcolumn[active] = ".(($status == 'inactive') ? 0 : 1 );
}
// Security check for each item
$permFilter = array('component_left' => 'FormExpress',
'component_middle' => '',
'component_right' => '',
'instance_left' => 'item_name',
'instance_middle' => '',
'instance_right' => $form_id,
'level' => ACCESS_READ);
$items = DBUtil::selectObjectArray(
'FormExpressItem',
$where,
"ORDER BY $FormExpressItemcolumn[sequence]" , -1, -1, '',
$permFilter
);
return $items;
}
function FormExpress_userapi_getvar($name='') {
return 'Hello World (dynamic function)';
}
?>