6
6
use FormTools \Core ;
7
7
use PDO ;
8
8
9
+
9
10
class ExportGroups
10
11
{
11
12
/**
12
13
* Returns all information about an export type group.
13
14
*
14
15
* @param integer $export_group_id
15
16
*/
16
- public function getExportGroup ($ export_group_id )
17
+ public static function getExportGroup ($ export_group_id )
17
18
{
18
19
$ db = Core::$ db ;
19
20
20
21
$ db ->query ("
21
22
SELECT *
22
- FROM {PREFUX }module_export_groups
23
+ FROM {PREFIX }module_export_groups
23
24
WHERE export_group_id = :export_group_id
24
25
" );
25
26
$ db ->bind ("export_group_id " , $ export_group_id );
@@ -61,7 +62,7 @@ public static function getExportGroups()
61
62
62
63
$ infohash = array ();
63
64
foreach ($ results as $ field ) {
64
- $ field ["num_export_types " ] = ExportGroups ::getNumExportTypes ($ field ["export_group_id " ]);
65
+ $ field ["num_export_types " ] = ExportTypes ::getNumExportTypes ($ field ["export_group_id " ]);
65
66
$ infohash [] = $ field ;
66
67
}
67
68
@@ -74,34 +75,51 @@ public static function getExportGroups()
74
75
*
75
76
* @param array $info
76
77
*/
77
- public function addExportGroup ($ info )
78
+ public static function addExportGroup ($ info, $ L )
78
79
{
79
80
$ db = Core::$ db ;
80
- // $L;
81
+
82
+ $ info = array_merge (array (
83
+ "access_type " => "public " ,
84
+ "form_view_mapping " => "all " ,
85
+ "forms_and_views " => null ,
86
+ "visibility " => "show " ,
87
+ "popup_height " => null ,
88
+ "popup_width " => null ,
89
+ "action " => "new_window " ,
90
+ "headers " => ""
91
+ ), $ info );
81
92
82
93
// get the next highest order count
83
94
$ db ->query ("SELECT count(*) FROM {PREFIX}module_export_groups " );
84
95
$ db ->execute ();
85
96
$ order = $ db ->fetch (PDO ::FETCH_COLUMN ) + 1 ;
86
97
87
98
// define the default options
88
-
89
99
$ db ->query ("
90
- INSERT INTO {PREFIX}module_export_groups (group_name, access_type, visibility, icon, action, action_button_text, list_order)
91
- VALUES (:group_name, :access_type, :visibility, :icon, :action, :action_button_text, :order)
100
+ INSERT INTO {PREFIX}module_export_groups (group_name, access_type, form_view_mapping, forms_and_views,
101
+ visibility, icon, action, action_button_text, popup_height, popup_width, headers, smarty_template, list_order)
102
+ VALUES (:group_name, :access_type, :form_view_mapping, :forms_and_views, :visibility,
103
+ :icon, :action, :action_button_text, :popup_height, :popup_width, :headers, :smarty_template, :list_order)
92
104
" );
93
105
$ db ->bindAll (array (
94
106
"group_name " => $ info ["group_name " ],
95
- "access_type " => "admin " ,
107
+ "access_type " => $ info ["access_type " ],
108
+ "form_view_mapping " => $ info ["form_view_mapping " ],
109
+ "forms_and_views " => $ info ["forms_and_views " ],
96
110
"visibility " => $ info ["visibility " ],
97
111
"icon " => $ info ["icon " ],
98
- "action " => "new_window " ,
99
- "action_button_text " => "{ \$LANG.word_display} " ,
100
- "order " => $ order
112
+ "action " => $ info ["action " ],
113
+ "action_button_text " => $ info ["action_button_text " ],
114
+ "popup_height " => $ info ["popup_height " ],
115
+ "popup_width " => $ info ["popup_width " ],
116
+ "headers " => $ info ["headers " ],
117
+ "smarty_template " => $ info ["smarty_template " ],
118
+ "list_order " => $ order
101
119
));
102
120
$ db ->execute ();
103
121
104
- return array (true , $ L ["notify_export_group_added " ]);
122
+ return array (true , $ L ["notify_export_group_added " ], $ db -> getInsertId () );
105
123
}
106
124
107
125
@@ -111,7 +129,7 @@ public function addExportGroup($info)
111
129
* @param array $info
112
130
* @return array
113
131
*/
114
- public function updateExportGroup ($ info )
132
+ public static function updateExportGroup ($ info )
115
133
{
116
134
$ db = Core::$ db ;
117
135
@@ -146,7 +164,7 @@ public function updateExportGroup($info)
146
164
}
147
165
148
166
149
- public function exp_update_export_group_permissions ($ info )
167
+ public static function updateExportGroupPermissions ($ info )
150
168
{
151
169
$ db = Core::$ db ;
152
170
@@ -205,9 +223,9 @@ public function exp_update_export_group_permissions($info)
205
223
*
206
224
* @param integer $export_group_id
207
225
*/
208
- public function deleteExportGroup ($ export_group_id )
226
+ public static function deleteExportGroup ($ export_group_id, $ L )
209
227
{
210
- // $L
228
+ $ db = Core:: $ db ;
211
229
212
230
$ db ->query ("DELETE FROM {PREFIX}module_export_groups WHERE export_group_id = :export_group_id " );
213
231
$ db ->bind ("export_group_id " , $ export_group_id );
@@ -232,7 +250,7 @@ public function deleteExportGroup($export_group_id)
232
250
* This can be called after deleting an export group, or whenever is needed to ensure that the
233
251
* order of the export groups are consistent, accurate & don't have any gaps.
234
252
*/
235
- public function checkExportGroupOrder ()
253
+ public static function checkExportGroupOrder ()
236
254
{
237
255
$ db = Core::$ db ;
238
256
@@ -255,6 +273,7 @@ public function checkExportGroupOrder()
255
273
"list_order " => $ order ,
256
274
"export_group_id " => $ export_group_id
257
275
));
276
+ $ db ->execute ();
258
277
$ order ++;
259
278
}
260
279
}
@@ -266,20 +285,18 @@ public function checkExportGroupOrder()
266
285
*
267
286
* @param array $info
268
287
*/
269
- public function reorderExportGroups ($ info )
288
+ public static function reorderExportGroups ($ info, $ L )
270
289
{
271
290
$ db = Core::$ db ;
272
291
273
- // $L
274
-
275
292
$ sortable_id = $ info ["sortable_id " ];
276
293
$ export_group_ids = explode (", " , $ info ["{$ sortable_id }_sortable__rows " ]);
277
294
278
295
$ order = 1 ;
279
296
foreach ($ export_group_ids as $ export_group_id ) {
280
297
$ db ->query ("
281
298
UPDATE {PREFIX}module_export_groups
282
- SET list_order = :order
299
+ SET list_order = :list_order
283
300
WHERE export_group_id = :export_group_id
284
301
" );
285
302
$ db ->bindAll (array (
@@ -302,7 +319,7 @@ public function reorderExportGroups($info)
302
319
* @return array prev_id => the previous export group ID (or empty string)
303
320
* next_id => the next export group ID (or empty string)
304
321
*/
305
- public function getExportGroupPrevNextLinks ($ export_group_id )
322
+ public static function getExportGroupPrevNextLinks ($ export_group_id )
306
323
{
307
324
$ db = Core::$ db ;
308
325
@@ -333,7 +350,7 @@ public function getExportGroupPrevNextLinks($export_group_id)
333
350
}
334
351
335
352
336
- public function deserializedExportGroupMapping ($ str )
353
+ public static function deserializedExportGroupMapping ($ str )
337
354
{
338
355
$ form_ids = array ();
339
356
$ view_ids = array ();
0 commit comments