From 1cc99b4ef9a2f980a1866a693f05fcfcbd991620 Mon Sep 17 00:00:00 2001 From: james Date: Wed, 31 Oct 2007 20:00:23 +0000 Subject: [PATCH] Add document manager, and update tableeditor to allow setting of a downloadlink for documents --- admin/documentdownloader.php | 34 +++++++++++++++++++++++ admin/documents.php | 53 ++++++++++++++++++++++++++++++++++++ admin/index.php | 1 + db/db.code.version.txt | 2 +- db/db.update.54.sql | 8 ++++++ tableeditor.class.php | 21 ++++++++++---- 6 files changed, 113 insertions(+), 6 deletions(-) create mode 100644 admin/documentdownloader.php create mode 100644 admin/documents.php create mode 100644 db/db.update.54.sql diff --git a/admin/documentdownloader.php b/admin/documentdownloader.php new file mode 100644 index 0000000..c2912a2 --- /dev/null +++ b/admin/documentdownloader.php @@ -0,0 +1,34 @@ + + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public + License as published by the Free Software Foundation, version 2. + + 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. + + You should have received a copy of the GNU General Public License + along with this program; see the file COPYING. If not, write to + the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ +?> +filename"))); + header("Content-disposition: inline; filename=$r->filename"); + header("Content-length: ".filesize("../data/documents/$r->filename")); + readfile("../data/documents/$r->filename"); + } +?> diff --git a/admin/documents.php b/admin/documents.php new file mode 100644 index 0000000..8d08359 --- /dev/null +++ b/admin/documents.php @@ -0,0 +1,53 @@ + + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public + License as published by the Free Software Foundation, version 2. + + 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. + + You should have received a copy of the GNU General Public License + along with this program; see the file COPYING. If not, write to + the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ +?> +"Date", + "title"=>"Document Title", + "sel_category"=>"Category", + "filename"=>"Filename", + ) + ); + + $editor->setPrimaryKey("id"); + $editor->setUploadPath("../data/documents"); + $editor->setDefaultSortField("sel_category,date"); + $editor->setRecordType("Document"); + $editor->setFieldDefaultValue("date",date("Y-m-d")); + $editor->setDownloadLink("documentdownloader.php"); + $editor->execute(); + + send_footer(); +?> diff --git a/admin/index.php b/admin/index.php index 807aef7..42e7e23 100644 --- a/admin/index.php +++ b/admin/index.php @@ -39,6 +39,7 @@ if($config['tours_enable'] == 'yes') { echo "".i18n("Tour Management")."
"; } + echo "".i18n("Internal Document Management")."
"; echo "
"; echo "".i18n("Enter Winning Projects")."
"; echo "".i18n("One-Click CWSF Registration")."
"; diff --git a/db/db.code.version.txt b/db/db.code.version.txt index 59343b0..fb1e7bc 100644 --- a/db/db.code.version.txt +++ b/db/db.code.version.txt @@ -1 +1 @@ -53 +54 diff --git a/db/db.update.54.sql b/db/db.update.54.sql new file mode 100644 index 0000000..df212dc --- /dev/null +++ b/db/db.update.54.sql @@ -0,0 +1,8 @@ +CREATE TABLE `documents` ( + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT , + `date` DATE NOT NULL , + `title` VARCHAR( 128 ) NOT NULL , + `sel_category` VARCHAR( 128 ) NOT NULL , + `filename` VARCHAR( 128 ) DEFAULT NULL , + PRIMARY KEY ( `id` ) +) TYPE = MYISAM ; diff --git a/tableeditor.class.php b/tableeditor.class.php index 52ea8a8..80975da 100644 --- a/tableeditor.class.php +++ b/tableeditor.class.php @@ -302,6 +302,10 @@ class TableEditor { $this->uploadPath=$p; } + function setDownloadLink($l) + { + $this->downloadLink=$l; + } function setYearSelectRange($min,$max) { @@ -1110,14 +1114,21 @@ class TableEditor else if(substr($f,0,8)=="filename" && $this->uploadPath) { echo ""; - //only show a link to the file if the upload path is inside the document root - if(strstr(realpath($this->uploadPath),$_SERVER['DOCUMENT_ROOT']) && file_exists($this->uploadPath."/".$editdata[$f])) - { - echo "uploadPath}/{$r->$f}\">{$r->$f}"; + if($this->downloadLink) { + $pk=$this->primaryKey; + echo "downloadLink}?{$pk}={$r->$pk}\">{$r->$f}"; } else { - echo $r->$f; + //only show a link to the file if the upload path is inside the document root + if(strstr(realpath($this->uploadPath),$_SERVER['DOCUMENT_ROOT']) && file_exists($this->uploadPath."/".$editdata[$f])) + { + echo "uploadPath}/{$r->$f}\">{$r->$f}"; + } + else + { + echo $r->$f; + } } echo ""; }