-
Notifications
You must be signed in to change notification settings - Fork 0
/
pninit.php
158 lines (134 loc) · 5.09 KB
/
pninit.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
<?php
/**
* FEproc - Mail template backend module for FormExpress for
* Zikula Content Management System
*
* @copyrightt (C) 2002 by Jason Judge, 2011 Chris Candreva
* @Version $Id: tables.php 84 2011-05-27 18:19:28Z ccandreva $
* @license GNU/GPL - http://www.gnu.org/copyleft/gpl.html
* @package FEproc
*
*
* 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
* ----------------------------------------------------------------------
* Original Author of file: Jason Judge.
* Based on template by Jim MacDonald.
* Current Maintainer of file: Chris Candreva <[email protected]>
* ----------------------------------------------------------------------
*
*/
/**
* initialise the module
* This function is only ever called once during the lifetime of a particular
* module instance
*/
function feproc_init()
{
// Get datbase setup.
list($dbconn) = pnDBGetConn();
$pntable = pnDBGetTables();
/////////////////////
// Handlers table.
if ( !DBUtil::createTable('feproc_handlers')) return false;
if ( !DBUtil::createTable('feproc_workflow')) return false;
// There are no module variables at this stage. There is ample scope to
// make much of the behaviour of this module configurable.
pnModSetVar('FEproc', 'itemsperpage', 30);
pnModSetVar('FEproc', 'removeunmatched', 0);
pnModSetVar('FEproc', 'sessiontimeout', 0);
pnModSetVar('FEproc', 'shareformitems', 1);
pnModSetVar('FEproc', 'tracestack', 0);
pnModSetVar('FEproc', 'attrstringlen', 200);
pnModSetVar('FEproc', 'attrstringsize', 64);
pnModSetVar('FEproc', 'attrtextrows', 6);
pnModSetVar('FEproc', 'attrtextcols', 40);
//pnModSetVar('FEproc', 'attrtextsize', 0);
// Initialisation successful
return true;
}
/**
* upgrade the module from an old version
* This function can be called multiple times
*/
function feproc_upgrade($oldversion)
{
// Version number is A.B.C[.D] where:-
// A - major version (significant functionality changes.
// B - minor version (data or database changes)
// C - bugfix version (changes to scripts only - database compatible)
// D - [optional] very minor maintenance release.
// Only the major and minor versions are checked for an upgrade.
$dataversion = preg_replace('/^([0-9]+\.[0-9]+)\..*/', '$1', $oldversion);
// Get datbase setup.
$pntable = pnDBGetTables();
// Upgrade dependent on old version number
switch($dataversion) {
case "0.1":
// Create new module variables.
pnModSetVar('FEproc', 'removeunmatched', 0);
pnModSetVar('FEproc', 'sessiontimeout', 0);
pnModSetVar('FEproc', 'shareformitems', 1);
pnModSetVar('FEproc', 'tracestack', 0);
pnModSetVar('FEproc', 'attrstringlen', 200);
pnModSetVar('FEproc', 'attrstringsize', 64);
pnModSetVar('FEproc', 'attrtextrows', 6);
pnModSetVar('FEproc', 'attrtextcols', 40);
// For upgrade to 0.3
case "0.2":
// Add the new 'starting stage indicator' to the workflow table
// to support multiple starting stages.
DBUtil::changeTable('feproc_workflow');
// Get a list of starting stages.
$startingstages = DBUtil::selectFieldArray('feproc_workflow', 'successid',
"WHERE type='set' AND successid > 0'");
// If there are starting stages, then update their flags.
if (count($startingstages) > 0)
{
$obj = array();
foreach ($startingstages as $stage) {
$obj[] = array('id' => $stage, 'startstage' => 2);
}
DBUTil::updateObjectArray($obj, 'feproc_workflow');
}
// For upgrade to 0.4
// case "0.3":
}
// Update successful
return true;
}
/**
* delete the module
* This function is only ever called once during the lifetime of a particular
* module instance.
*/
function feproc_delete()
{
// Drop the tables.
DBUtil::dropTable('feproc_handlers');
DBUtil::dropTable('feproc_workflow');
// Delete any module variables
pnModDelVar('FEproc', 'itemsperpage');
pnModDelVar('FEproc', 'removeunmatched');
pnModDelVar('FEproc', 'sessiontimeout');
pnModDelVar('FEproc', 'shareformitems');
pnModDelVar('FEproc', 'tracestack');
pnModDelVar('FEproc', 'attrstringlen');
pnModDelVar('FEproc', 'attrstringsize');
pnModDelVar('FEproc', 'attrtextrows');
pnModDelVar('FEproc', 'attrtextcols');
// Deletion successful
return true;
}
?>