Commit 660d993ce4b95e30f1dc769d2f8b559b8d6db902

Authored by nbm
1 parent 9ed98afd

Remove the old store mechanism


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@4365 c91229c3-7414-0410-bfa2-8a42b809f60b
lib/visualpatterns/PatternEditableListFromQuery.inc deleted
1 -<?php  
2 -/**  
3 - * $Id$  
4 - *  
5 - * Takes a SQL query, an array of column names and and an array of column types  
6 - * and displays the data in an editable two column list format.  
7 - *  
8 - * Copyright (c) 2003 Jam Warehouse http://www.jamwarehouse.com  
9 - *  
10 - * This program is free software; you can redistribute it and/or modify  
11 - * it under the terms of the GNU General Public License as published by  
12 - * the Free Software Foundation; either version 2 of the License, or  
13 - * (at your option) any later version.  
14 - *  
15 - * This program is distributed in the hope that it will be useful,  
16 - * but WITHOUT ANY WARRANTY; without even the implied warranty of  
17 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the  
18 - * GNU General Public License for more details.  
19 - *  
20 - * You should have received a copy of the GNU General Public License  
21 - * along with this program; if not, write to the Free Software  
22 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA  
23 - *  
24 - * @version $Revision$  
25 - * @author Rob Cherry, Jam Warehouse (Pty) Ltd, South Africa  
26 - * @package lib.visualpatterns  
27 - * @todo implement HyperLinkURL option  
28 - */  
29 -class PatternEditableListFromQuery {  
30 -  
31 - /** SQL query to execute */  
32 - var $sQuery;  
33 - /** table on which to perform store/create */  
34 - var $sTableName;  
35 - /** array of columns to display */  
36 - var $aDisplayColumns;  
37 - /** columns to store */  
38 - var $aStoreColumns;  
39 - /** names of columns to display */  
40 - var $aColumnNames;  
41 - /** array of column types (1 = text, 2 = boolean, 3 = dropdown list) */  
42 - var $aDisplayColumnTypes;  
43 - /** database column types (0 = id, 1 = text, 2 = boolean) */  
44 - var $aDatabaseColumnTypes;  
45 - /** number of rows for text area if text area option is being used */  
46 - var $iTextAreaRows = 6;  
47 - /** number of colums for text area if text area option is being used */  
48 - var $iTextAreaColums = 20;  
49 - /** heading for table */  
50 - var $sTableHeading;  
51 - /** set the table width */  
52 - var $iTableWidth = null;  
53 - /** unique name to prepend to form variables */  
54 - var $sUniqueName;  
55 - /** set the tables to check for display type 3 */  
56 - var $aDropDownListTableNames;  
57 - /** set whether a column is required or not */  
58 - var $aColumnsRequired;  
59 - /** used when type = 4 to tell which meta data field to pick */  
60 - var $aMetaDataFields;  
61 -  
62 - /**  
63 - * Default constructor  
64 - *  
65 - * @param String Query to execute  
66 - * @param  
67 - */  
68 - function PatternEditableListFromQuery($sNewQuery, $sNewTableName, $aNewDisplayColumns, $aNewStoreColumns, $aNewColumnNames, $aNewDisplayColumnTypes, $aNewDatabaseColumnTypes) {  
69 - $this->sQuery = $sNewQuery;  
70 - $this->sTableName = $sNewTableName;  
71 - $this->aDisplayColumns = $aNewDisplayColumns;  
72 - $this->aStoreColumns = $aNewStoreColumns;  
73 - $this->aColumnNames = $aNewColumnNames;  
74 - $this->aDisplayColumnTypes = $aNewDisplayColumnTypes;  
75 - $this->aDatabaseColumnTypes = $aNewDatabaseColumnTypes;  
76 - }  
77 -  
78 - function setUniqueName($sNewValue) {  
79 - $this->sUniqueName = $sNewValue;  
80 - }  
81 -  
82 - function setTableWidth($iNewValue) {  
83 - $this->iTableWidth = $iNewValue;  
84 - }  
85 -  
86 - function setTextAreaRows($iNewValue) {  
87 - $this->iTextAreaRows = $iNewValue;  
88 - }  
89 -  
90 - function setTextAreaDisplayColumns($iNewValue) {  
91 - $this->iTextAreaDisplayColumns = $iNewValue;  
92 - }  
93 -  
94 - function setTableHeading($sNewValue) {  
95 - $this->sTableHeading = $sNewValue;  
96 - }  
97 -  
98 - function setRenderIndividualTableForEachResult($bNewValue) {  
99 - $this->bIndividualTableForEachResult = $bNewValue;  
100 - }  
101 -  
102 - function setDropDownListTableNames($aNewValue) {  
103 - $this->aDropDownListTableNames = $aNewValue;  
104 - }  
105 -  
106 - function setColumnsRequired($aNewValue) {  
107 - $this->aColumnsRequired = $aNewValue;  
108 - }  
109 -  
110 - function setMetaDataFields($aNewValue) {  
111 - $this->aMetaDataFields = $aNewValue;  
112 - }  
113 -  
114 - function & render() {  
115 - global $default;  
116 - $sSectionName = $default->siteMap->getSectionName(substr($_SERVER["PHP_SELF"], strlen($default->rootUrl), strlen($_SERVER["PHP_SELF"])));  
117 - $sTDBGColour = $default->siteMap->getSectionColour($sSectionName, "td");  
118 - //records the columns to generate validation javascript for  
119 - $aValidationColumnNames = array();  
120 -  
121 - $this->sUniqueName .= KTUtil::randomString();  
122 -  
123 - $sql = $default->db;  
124 - $sql->query($this->sQuery);  
125 - if ($sql->next_record()) {;  
126 - $_SESSION["pelfq_" . $this->sUniqueName . "_tn"] = $this->sTableName;  
127 - $_SESSION["pelfq_" . $this->sUniqueName . "_id"] = $sql->f("id");  
128 - $_SESSION["pelfq_" . $this->sUniqueName . "_columns"] = $this->aStoreColumns;  
129 - $_SESSION["pageAccess"][$default->rootUrl . '/presentation/lookAndFeel/knowledgeTree/store.php'] = true;  
130 -  
131 - $sToRender = "";  
132 - $sToRender .= "<table border = 0, cellpadding = 5 " . (isset($this->iTableWidth) ? ", width = $this->iTableWidth" : "") . " >\n";  
133 - $sToRender .= "<input type=\"hidden\" name=\"unique_start_" . $this->sUniqueName . "\" value=\"\" />\n";  
134 - // $sToRender .= "<input type=\"hidden\" name=\"$this->sUniqueName\" value=\"" . $sql->f("id") . "\" />\n";  
135 - // $sToRender .= "<input type=\"hidden\" name=\"" . $this->sUniqueName . "_tn\" value=\"$this->sTableName\" />\n";  
136 -  
137 - if (isset($this->sTableHeading)) {  
138 - $sToRender .= "<caption align=\"top\"><b>$this->sTableHeading</b></caption>\n";  
139 - }  
140 -  
141 - for ($i = 0; $i < count($this->aDisplayColumns); $i++) {  
142 - $sToRender .= "<tr>\n";  
143 - $sToRender .= "<input type=\"hidden\" name=\"" . $this->sUniqueName . "_" . $i . "_tc\" value=\"" . $this->aStoreColumns[$i] . "\" />\n";  
144 - $sToRender .= "<input type=\"hidden\" name=\"" . $this->sUniqueName . "_" . $i . "_type\" value=\"" . $this->aDatabaseColumnTypes[$i] . "\" />\n";  
145 - $sToRender .= "\t<td bgcolor=\"$sTDBGColour\">" . $this->aColumnNames[$i] . "</td>\n";  
146 - switch ($this->aDisplayColumnTypes[$i]) {  
147 - case 1:  
148 - //plain text field  
149 - $sToRender .= "\t<td bgcolor=\"" . getColour($i) . "\"><input type=\"text\" size = \"30\" name=\"" . $this->sUniqueName . "_" . $i . "_value\" value=\"" . $sql->f($this->aDisplayColumns[$i]) . "\"</td>\n";  
150 - break;  
151 - case 2:  
152 - //boolean value  
153 - $sToRender .= "\t<td bgcolor=\"" . getColour($i) . "\"><input type=\"checkbox\" name=\"" . $this->sUniqueName . "_" . $i . "_value\" value=\"1\" " . ($sql->f($this->aDisplayColumns[$i]) ? " CHECKED " : " ") . "/></td>\n";  
154 - break;  
155 - case 3:  
156 - $oPatternListBox = & new PatternListBox($this->aDropDownListTableNames[$i], "name", "id", $this->sUniqueName . "_" . $i . "_value");  
157 - $oPatternListBox->setSelectedValue($sql->f($this->aStoreColumns[$i]));  
158 - $sToRender .= "\t<td bgcolor=\"" . getColour($i) . "\">" . $oPatternListBox->render() . "</td>\t\n";  
159 - break;  
160 - case 4:  
161 - //meta data type  
162 - $oPattern = & new PatternMetaData($this->aMetaDataFields[$i], $this->sUniqueName . "_" . $i . "_value", $sql->f($this->aStoreColumns[$i]));  
163 - $sToRender .= "\t<td bgcolor=\"" . getColour($i) . "\">" . $oPattern->render() . "</td>\t\n";  
164 - default:  
165 - break;  
166 - }  
167 - $sToRender .= "</tr>\n";  
168 -  
169 - //check for required columns  
170 - if (isset($this->aColumnsRequired) &&($this->aColumnsRequired[$i])) {  
171 - $iArrayEntry = count($aValidationColumnNames);  
172 - $aValidationColumnNames[$iArrayEntry]["formName"] = $this->sUniqueName . "_" . $i . "_value";  
173 - $aValidationColumnNames[$iArrayEntry]["displayName"] = $this->aColumnNames[$i];  
174 - }  
175 - }  
176 -  
177 - $sToRender .= "<input type=\"hidden\" name=\"unique_end_" . $this->sUniqueName . "\" value=\"\" />\n";  
178 - $sToRender .= "</table>\n";  
179 - } else {  
180 - $sToRender .= "<tr>\n";  
181 - $sToRender .= "<td colspan=" . count($this->aDisplayColumns) . ">" .  
182 - sprintf(_("No %s data"), (isset($this->sTableHeading) ? "$this->sTableHeading" : "")) .  
183 - "</td>\n";  
184 - $sToRender .= "</tr>\n";  
185 - }  
186 -  
187 - $sToRender .= $this->generateRequiredFieldValidation($aValidationColumnNames);  
188 -  
189 - return $sToRender;  
190 - }  
191 -  
192 - function generateRequiredFieldValidation($aValidationColumnNames) {  
193 - $sToRender .= "\n\n<script language=\"javascript\">\n<!--\n";  
194 - $sToRender .= "function validateForm(theForm) {\n";  
195 - for ($i = 0; $i < count($aValidationColumnNames); $i++) {  
196 - $sToRender .= "\tif (!(validRequired(document.MainForm." . $aValidationColumnNames[$i]["formName"] . ", '" . $aValidationColumnNames[$i]["displayName"] . "'))) {\n";  
197 - $sToRender .= "\t\treturn false;\n\t}\n";  
198 - }  
199 - $sToRender .= "return true;\n}\n";  
200 -  
201 - $sToRender .= "//-->\n</script>\n\n";  
202 -  
203 - return $sToRender;  
204 -  
205 - }  
206 -}  
207 -?>  
presentation/lookAndFeel/knowledgeTree/store.inc deleted
1 -<?php  
2 -/**  
3 - * $Id$  
4 - *  
5 - * Contains the logic for constructing queries from Pattern generated forms.  
6 - *  
7 - * Copyright (c) 2003 Jam Warehouse http://www.jamwarehouse.com  
8 - *  
9 - * This program is free software; you can redistribute it and/or modify  
10 - * it under the terms of the GNU General Public License as published by  
11 - * the Free Software Foundation; either version 2 of the License, or  
12 - * (at your option) any later version.  
13 - *  
14 - * This program is distributed in the hope that it will be useful,  
15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of  
16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the  
17 - * GNU General Public License for more details.  
18 - *  
19 - * You should have received a copy of the GNU General Public License  
20 - * along with this program; if not, write to the Free Software  
21 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA  
22 - *  
23 - * @version $Revision$  
24 - * @author Rob Cherry, Jam Warehouse (Pty) Ltd, South Africa  
25 - */  
26 -  
27 -function constructQuery($aKeys, $aSuppliedValues = null) {  
28 - $aQuery = array();  
29 - $first = true;  
30 - for ($i = 0; $i < count($aKeys); $i++) {  
31 - $sRowStart = $aKeys[$i];  
32 - $pos = strncasecmp("unique_start", $sRowStart, 12);  
33 -  
34 - if ($pos == 0) {  
35 - $sRandomString = substr($sRowStart, 13);  
36 - if (!array_key_exists("pelfq_" . $sRandomString . "_tn", $_SESSION)) {  
37 - print "Hack attempt! Session data not set up for store.\n";  
38 - return false;  
39 - }  
40 - if (!array_key_exists("pelfq_" . $sRandomString . "_id", $_SESSION)) {  
41 - print "Hack attempt! Session data not set up for store.\n";  
42 - return false;  
43 - }  
44 - if (!array_key_exists("pelfq_" . $sRandomString . "_columns", $_SESSION)) {  
45 - print "Hack attempt! Session data not set up for store.\n";  
46 - return false;  
47 - }  
48 -  
49 - $aColumns = array();  
50 - $aValues = array();  
51 - $aTypes = array();  
52 -  
53 - // $iPrimaryKey = $_POST[$aKeys[++$i]];  
54 - // $sTableName = $_POST[$aKeys[++$i]];  
55 - $iPrimaryKey = $_SESSION["pelfq_" . $sRandomString . "_id"];  
56 - $sTableName = $_SESSION["pelfq_" . $sRandomString . "_tn"];  
57 - $aColumnNames = $_SESSION["pelfq_" . $sRandomString . "_columns"];  
58 -  
59 - $i++;  
60 - $iColumnCount = 0;  
61 -  
62 - if ($first === true) {  
63 - $sPreCode = $_SESSION["pelfq_" . $sRandomString . "_code_pre"];  
64 - eval($sPreCode);  
65 - $first = false;  
66 - }  
67 -  
68 - //get all the values for the table  
69 - while ((strncasecmp("unique_end", $sRowStart, 10) != 0) && ($i <= count($aKeys))) {  
70 - //$aColumns[$iColumnCount] = $_POST[$aKeys[$i]];  
71 -  
72 - $sColumnName = $_POST[$aKeys[$i]];  
73 - if (!in_array($sColumnName, $aColumnNames)) {  
74 - print "Hack attempt! $sColumnName is not in "; var_dump($aColumnNames);  
75 - return false;  
76 - }  
77 - // $aTypes[$iColumnCount]= $_POST[$aKeys[++$i]];  
78 -  
79 - $iType = $_POST[$aKeys[++$i]];  
80 -  
81 - switch ($iType) {  
82 - case 2:  
83 - //uncheck checkboxes don't generate any name/value pairs  
84 - //so if the next key doesn't contain the word "value" and it's type  
85 - //is checkbox, then we have an unchecked check box  
86 - if (strpos($aKeys[$i + 1], "value") === false) {  
87 - $mValue = false;  
88 - } else {  
89 - $i++;  
90 - $mValue = true;  
91 - }  
92 - //check box  
93 - break;  
94 - case 4:  
95 - $mValue = $aSuppliedValues[$sColumnName];  
96 - $i++;  
97 - break;  
98 - default:  
99 - $mValue = $_POST[$aKeys[++$i]];  
100 - break;  
101 - }  
102 - $aValues[$sColumnName] = $mValue;  
103 -  
104 - $sRowStart = $aKeys[++$i];  
105 - $iColumnCount++;  
106 - }  
107 -  
108 - if ($iPrimaryKey < 0) {  
109 - //perform an insert  
110 - // add query to array  
111 - $id = DBUtil::autoInsert($sTableName, $aValues);  
112 - } else {  
113 - $res = DBUtil::autoUpdate($sTableName, $aValues, $iPrimaryKey);  
114 - }  
115 - }  
116 - }  
117 - $sPostCode = $_SESSION["pelfq_" . $sRandomString . "_code_post"];  
118 - eval($sPostCode);  
119 - return $aQuery;  
120 -}  
121 -?>  
presentation/lookAndFeel/knowledgeTree/store.php deleted
1 -<?php  
2 -/**  
3 - * $Id$  
4 - *  
5 - * Page used by all editable patterns to actually perform the db insert/updates  
6 - *  
7 - * Expected form variables  
8 - * o fReturnURL  
9 - *  
10 - * Copyright (c) 2003 Jam Warehouse http://www.jamwarehouse.com  
11 - *  
12 - * This program is free software; you can redistribute it and/or modify  
13 - * it under the terms of the GNU General Public License as published by  
14 - * the Free Software Foundation; either version 2 of the License, or  
15 - * (at your option) any later version.  
16 - *  
17 - * This program is distributed in the hope that it will be useful,  
18 - * but WITHOUT ANY WARRANTY; without even the implied warranty of  
19 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the  
20 - * GNU General Public License for more details.  
21 - *  
22 - * You should have received a copy of the GNU General Public License  
23 - * along with this program; if not, write to the Free Software  
24 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA  
25 - *  
26 - * @version $Revision$  
27 - * @author Rob Cherry, Jam Warehouse (Pty) Ltd, South Africa  
28 - */  
29 -  
30 -require_once("../../../config/dmsDefaults.php");  
31 -require_once("$default->fileSystemRoot/lib/documentmanagement/Document.inc");  
32 -require_once("$default->fileSystemRoot/lib/foldermanagement/Folder.inc");  
33 -require_once("store.inc");  
34 -  
35 -KTUtil::extractGPC('fReturnURL');  
36 -  
37 -if (checkSession()) {  
38 - if (count($_POST) > 0) {  
39 - $aKeys = array_keys($_POST);  
40 - $aQueries = constructQuery($aKeys);  
41 -  
42 - //execute the queries  
43 - for ($i=0; $i<count($aQueries); $i++) {  
44 - $sql = $default->db;  
45 - $sql->query($aQueries[$i]);  
46 - }  
47 - $default->log->debug("store.php redirecting to $fReturnURL");  
48 - redirect(strip_tags(urldecode($fReturnURL)));  
49 - }  
50 -}  
51 -  
52 -?>