Commit 64ea047dc16b6ca72ca23784bf48e7e7560ef1e4

Authored by nbm
1 parent d242a94a

Whitespace cleanup.


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@3090 c91229c3-7414-0410-bfa2-8a42b809f60b
presentation/lookAndFeel/knowledgeTree/store.inc
... ... @@ -10,12 +10,12 @@
10 10 * it under the terms of the GNU General Public License as published by
11 11 * the Free Software Foundation; either version 2 of the License, or
12 12 * (at your option) any later version.
13   - *
  13 + *
14 14 * This program is distributed in the hope that it will be useful,
15 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 17 * GNU General Public License for more details.
18   - *
  18 + *
19 19 * You should have received a copy of the GNU General Public License
20 20 * along with this program; if not, write to the Free Software
21 21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
... ... @@ -23,16 +23,16 @@
23 23 * @version $Revision$
24 24 * @author Rob Cherry, Jam Warehouse (Pty) Ltd, South Africa
25 25 */
26   -
  26 +
27 27 function constructQuery($aKeys, $aSuppliedValues = null) {
28   - global $default;
29   -
30   - $aQuery = array();
31   - for ($i = 0; $i < count($aKeys); $i++) {
32   - $sRowStart = $aKeys[$i];
33   - $pos = strncasecmp("unique_start", $sRowStart, 12);
34   -
35   - if ($pos == 0) {
  28 + global $default;
  29 +
  30 + $aQuery = array();
  31 + for ($i = 0; $i < count($aKeys); $i++) {
  32 + $sRowStart = $aKeys[$i];
  33 + $pos = strncasecmp("unique_start", $sRowStart, 12);
  34 +
  35 + if ($pos == 0) {
36 36 $sRandomString = substr($sRowStart, 13);
37 37 if (!array_key_exists("pelfq_" . $sRandomString . "_tn", $_SESSION)) {
38 38 print "Hack attempt! Session data not set up for store.\n";
... ... @@ -46,169 +46,169 @@ function constructQuery($aKeys, $aSuppliedValues = null) {
46 46 print "Hack attempt! Session data not set up for store.\n";
47 47 return false;
48 48 }
49   -
  49 +
50 50 $aColumns = array();
51   - $aValues = array();
52   - $aTypes = array();
53   -
54   - // $iPrimaryKey = $_POST[$aKeys[++$i]];
55   - // $sTableName = $_POST[$aKeys[++$i]];
  51 + $aValues = array();
  52 + $aTypes = array();
  53 +
  54 + // $iPrimaryKey = $_POST[$aKeys[++$i]];
  55 + // $sTableName = $_POST[$aKeys[++$i]];
56 56 $iPrimaryKey = $_SESSION["pelfq_" . $sRandomString . "_id"];
57 57 $sTableName = $_SESSION["pelfq_" . $sRandomString . "_tn"];
58 58 $aColumnNames = $_SESSION["pelfq_" . $sRandomString . "_columns"];
59   -
60   - $i++;
61   - $iColumnCount = 0;
62   -
63   - //get all the values for the table
64   - while ((strncasecmp("unique_end", $sRowStart, 10) != 0) && ($i <= count($aKeys))) {
65   - $aColumns[$iColumnCount] = $_POST[$aKeys[$i]];
  59 +
  60 + $i++;
  61 + $iColumnCount = 0;
  62 +
  63 + //get all the values for the table
  64 + while ((strncasecmp("unique_end", $sRowStart, 10) != 0) && ($i <= count($aKeys))) {
  65 + $aColumns[$iColumnCount] = $_POST[$aKeys[$i]];
66 66 if (!in_array($aColumns[$iColumnCount], $aColumnNames)) {
67 67 print "Hack attempt! $aColumns[$iColumnCount] is not in "; var_dump($aColumnNames);
68 68 return false;
69 69 }
70   - $aTypes[$iColumnCount]= $_POST[$aKeys[++$i]];
71   -
72   - switch ($aTypes[$iColumnCount]) {
73   - case 0:
74   - //id's
75   - $aValues[$iColumnCount] = $_POST[$aKeys[++$i]];
76   - break;
77   - case 1:
78   - //normal text
79   - $aValues[$iColumnCount] = $_POST[$aKeys[++$i]];
80   - break;
81   - case 2:
82   - //uncheck checkboxes don't generate any name/value pairs
83   - //so if the next key doesn't contain the word "value" and it's type
84   - //is checkbox, then we have an unchecked check box
85   - if (strpos($aKeys[$i + 1], "value") === false) {
86   - $aValues[$iColumnCount] = false;
87   - } else {
88   - $i++;
89   - $aValues[$iColumnCount] = true;
90   - }
91   - //check box
92   - break;
93   - case 3:
94   - //drop down
95   - case 4:
96   - // user supplied values
97   - $aValues[$iColumnCount] = $_POST[$aKeys[++$i]];
98   - break;
99   - }
100   -
101   - $sRowStart = $aKeys[++$i];
102   - $iColumnCount++;
103   - }
  70 + $aTypes[$iColumnCount]= $_POST[$aKeys[++$i]];
  71 +
  72 + switch ($aTypes[$iColumnCount]) {
  73 + case 0:
  74 + //id's
  75 + $aValues[$iColumnCount] = $_POST[$aKeys[++$i]];
  76 + break;
  77 + case 1:
  78 + //normal text
  79 + $aValues[$iColumnCount] = $_POST[$aKeys[++$i]];
  80 + break;
  81 + case 2:
  82 + //uncheck checkboxes don't generate any name/value pairs
  83 + //so if the next key doesn't contain the word "value" and it's type
  84 + //is checkbox, then we have an unchecked check box
  85 + if (strpos($aKeys[$i + 1], "value") === false) {
  86 + $aValues[$iColumnCount] = false;
  87 + } else {
  88 + $i++;
  89 + $aValues[$iColumnCount] = true;
  90 + }
  91 + //check box
  92 + break;
  93 + case 3:
  94 + //drop down
  95 + case 4:
  96 + // user supplied values
  97 + $aValues[$iColumnCount] = $_POST[$aKeys[++$i]];
  98 + break;
  99 + }
  100 +
  101 + $sRowStart = $aKeys[++$i];
  102 + $iColumnCount++;
  103 + }
  104 +
  105 + if ($iPrimaryKey < 0) {
  106 + //perform an insert
  107 + $sQuery = "INSERT INTO $sTableName (";
  108 + for ($j = 0; $j < count($aColumns) - 1; $j++) {
  109 + $sQuery .= $aColumns[$j] . ", ";
  110 + }
  111 + $sQuery .= $aColumns[count($aColumns) -1] . ") VALUES (";
104 112  
105   - if ($iPrimaryKey < 0) {
106   - //perform an insert
107   - $sQuery = "INSERT INTO $sTableName (";
108   - for ($j = 0; $j < count($aColumns) - 1; $j++) {
109   - $sQuery .= $aColumns[$j] . ", ";
110   - }
111   - $sQuery .= $aColumns[count($aColumns) -1] . ") VALUES (";
112   -
113   - for ($j = 0; $j < count($aColumns) - 1; $j++) {
114   - switch ($aTypes[$j]) {
115   - case 0 :
116   - $sQuery .= $aValues[$j] . ", ";
117   - break;
118   - case 1:
119   - //text
120   - $sQuery .= "'" . $aValues[$j] . "', ";
121   - break;
122   - case 2:
123   - //boolean
124   - $sQuery .= $aValues[$j] . ", ";
125   - break;
126   - case 3:
127   - //drop down list
128   - $sQuery .= $aValues[$j] . ", ";
129   - break;
130   - case 4:
131   - // user supplied values
132   - $sQuery .= $aSuppliedValues[$aColumns[$j]] . ", ";
133   - break;
134   - default:
135   - break;
136   - }
137   - }
138   - switch ($aTypes[count($aColumns) - 1]) {
139   - case 0:
140   - //id
141   - $sQuery .= $aValues[count($aColumns) - 1] . ") ";
142   - break;
143   - case 1:
144   - //text
145   - $sQuery .= "'" . $aValues[count($aColumns) - 1] . "') ";
146   - break;
147   - case 2:
148   - //boolean
149   - $sQuery .= ($aValues[count($aColumns) - 1] ? 1 : 0) . ") ";
150   - break;
151   - case 3:
152   - //drop down list
153   - $sQuery .= $aValues[count($aColumns) - 1] . ") ";
154   - break;
155   - case 4:
156   - // user supplied values
157   - $sQuery .= $aSuppliedValues[$aColumns[count($aColumns) - 1]] . ", ";
158   - break;
159   - default:
160   - break;
161   - }
162   - // add query to array
163   - $aQuery[] = $sQuery;
164   - } else {
165   - //perform an update
166   - $sQuery = "UPDATE $sTableName SET ";
167   - for ($j = 0; $j < count($aColumns) -1; $j++) {
168   - $sQuery .= $aColumns[$j] . " = ";
169   - switch ($aTypes[$j]) {
170   - case 0:
171   - //id
172   - $sQuery .= $aValues[$j] . ", ";
173   - break;
174   - case 1:
175   - $sQuery .= "'" . $aValues[$j] . "', ";
176   - break;
177   - case 2:
178   - $sQuery .= ($aValues[$j] ? 1 : 0) . ", ";
179   - break;
180   - case 3:
181   - $sQuery .= $aValues[$j] . ", ";
182   - break;
183   - default:
184   - break;
185   - }
186   -
187   - }
188   - $sQuery .= $aColumns[count($aTypes) -1] . " = ";
189   - switch ($aTypes[count($aTypes) -1]) {
190   - case 0:
191   - //id
192   - $sQuery .= $aValues[count($aTypes) -1] . " ";
193   - break;
194   - case 1:
195   - $sQuery .= "'" . $aValues[count($aTypes) -1] . "' ";
196   - break;
197   - case 2:
198   - $sQuery .= ($aValues[count($aTypes) -1] ? 1 : 0) . " ";
199   - break;
200   - case 3:
201   - $sQuery .= $aValues[count($aTypes) -1] . " ";
202   - break;
203   - default:
204   - break;
205   - }
206   - $sQuery .= "WHERE id = $iPrimaryKey";
207   - // add query to array
208   - $aQuery[] = $sQuery;
209   - }
210   - }
211   - }
212   - return $aQuery;
  113 + for ($j = 0; $j < count($aColumns) - 1; $j++) {
  114 + switch ($aTypes[$j]) {
  115 + case 0 :
  116 + $sQuery .= $aValues[$j] . ", ";
  117 + break;
  118 + case 1:
  119 + //text
  120 + $sQuery .= "'" . $aValues[$j] . "', ";
  121 + break;
  122 + case 2:
  123 + //boolean
  124 + $sQuery .= $aValues[$j] . ", ";
  125 + break;
  126 + case 3:
  127 + //drop down list
  128 + $sQuery .= $aValues[$j] . ", ";
  129 + break;
  130 + case 4:
  131 + // user supplied values
  132 + $sQuery .= $aSuppliedValues[$aColumns[$j]] . ", ";
  133 + break;
  134 + default:
  135 + break;
  136 + }
  137 + }
  138 + switch ($aTypes[count($aColumns) - 1]) {
  139 + case 0:
  140 + //id
  141 + $sQuery .= $aValues[count($aColumns) - 1] . ") ";
  142 + break;
  143 + case 1:
  144 + //text
  145 + $sQuery .= "'" . $aValues[count($aColumns) - 1] . "') ";
  146 + break;
  147 + case 2:
  148 + //boolean
  149 + $sQuery .= ($aValues[count($aColumns) - 1] ? 1 : 0) . ") ";
  150 + break;
  151 + case 3:
  152 + //drop down list
  153 + $sQuery .= $aValues[count($aColumns) - 1] . ") ";
  154 + break;
  155 + case 4:
  156 + // user supplied values
  157 + $sQuery .= $aSuppliedValues[$aColumns[count($aColumns) - 1]] . ", ";
  158 + break;
  159 + default:
  160 + break;
  161 + }
  162 + // add query to array
  163 + $aQuery[] = $sQuery;
  164 + } else {
  165 + //perform an update
  166 + $sQuery = "UPDATE $sTableName SET ";
  167 + for ($j = 0; $j < count($aColumns) -1; $j++) {
  168 + $sQuery .= $aColumns[$j] . " = ";
  169 + switch ($aTypes[$j]) {
  170 + case 0:
  171 + //id
  172 + $sQuery .= $aValues[$j] . ", ";
  173 + break;
  174 + case 1:
  175 + $sQuery .= "'" . $aValues[$j] . "', ";
  176 + break;
  177 + case 2:
  178 + $sQuery .= ($aValues[$j] ? 1 : 0) . ", ";
  179 + break;
  180 + case 3:
  181 + $sQuery .= $aValues[$j] . ", ";
  182 + break;
  183 + default:
  184 + break;
  185 + }
  186 +
  187 + }
  188 + $sQuery .= $aColumns[count($aTypes) -1] . " = ";
  189 + switch ($aTypes[count($aTypes) -1]) {
  190 + case 0:
  191 + //id
  192 + $sQuery .= $aValues[count($aTypes) -1] . " ";
  193 + break;
  194 + case 1:
  195 + $sQuery .= "'" . $aValues[count($aTypes) -1] . "' ";
  196 + break;
  197 + case 2:
  198 + $sQuery .= ($aValues[count($aTypes) -1] ? 1 : 0) . " ";
  199 + break;
  200 + case 3:
  201 + $sQuery .= $aValues[count($aTypes) -1] . " ";
  202 + break;
  203 + default:
  204 + break;
  205 + }
  206 + $sQuery .= "WHERE id = $iPrimaryKey";
  207 + // add query to array
  208 + $aQuery[] = $sQuery;
  209 + }
  210 + }
  211 + }
  212 + return $aQuery;
213 213 }
214 214 ?>
... ...