diff --git a/lib/documentmanagement/MDTree.inc b/lib/documentmanagement/MDTree.inc index 1925cd3..7477be9 100644 --- a/lib/documentmanagement/MDTree.inc +++ b/lib/documentmanagement/MDTree.inc @@ -5,32 +5,32 @@ * KnowledgeTree Open Source Edition * Document Management Made Simple * Copyright (C) 2004 - 2008 The Jam Warehouse Software (Pty) Limited - * + * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License version 3 as published by the * Free Software Foundation. - * + * * 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. If not, see . - * + * * You can contact The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place, * Blake Street, Observatory, 7925 South Africa. or email info@knowledgetree.com. - * + * * The interactive user interfaces in modified source and object code versions * of this program must display Appropriate Legal Notices, as required under * Section 5 of the GNU General Public License version 3. - * + * * In accordance with Section 7(b) of the GNU General Public License version 3, * these Appropriate Legal Notices must retain the display of the "Powered by - * KnowledgeTree" logo and retain the original copyright notice. If the display of the + * KnowledgeTree" logo and retain the original copyright notice. If the display of the * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices - * must display the words "Powered by KnowledgeTree" and retain the original - * copyright notice. + * must display the words "Powered by KnowledgeTree" and retain the original + * copyright notice. * Contributor( s): ______________________________________ * */ @@ -44,7 +44,7 @@ require_once(KT_LIB_DIR . "/util/sanitize.inc"); class MDTreeNode extends KTEntity { /** boilerplate DB code. */ /** primary key */ - var $iId = -1; + var $iId = -1; var $iFieldId; var $sName; var $iParentNode; @@ -81,7 +81,7 @@ class MDTreeNode extends KTEntity { } -/* simple class to encapsulate tree-as-a-whole behaviour. +/* simple class to encapsulate tree-as-a-whole behaviour. NBM - should this move, be refactored? It certainly doesn't belong in the DB, since its just an aggregate utility. */ @@ -100,11 +100,11 @@ class MDTree { $this->contents = null; $this->mapnodes = null; $this->root = null; - $this->lookups = null; + $this->lookups = null; $this->field_id = null; } - /* function buildForField + /* function buildForField * * build a tree for a particular field instance. * sets contents, so we can edit "stuff". @@ -112,7 +112,7 @@ class MDTree { function buildForField($iFieldId) { global $default; - // before we start, we need to check that + // before we start, we need to check that // the specified field exists and is organised into a tree. $organisedField =& DocumentField::get($iFieldId); if (PEAR::isError($organisedField) || ($organisedField === false)) { @@ -182,8 +182,8 @@ class MDTree { } $leafArray = null; - if (!array_key_exists("leaves", $target_set)) { - $target_set["leaves"] = array($lookup_value->getId()); + if (!array_key_exists("leaves", $target_set)) { + $target_set["leaves"] = array($lookup_value->getId()); } else { @@ -193,14 +193,14 @@ class MDTree { $this->lookups[$lookup_value->getId()] = $lookup_value; - } + } $this->root =& $this->contents[0]; $default->log->debug("MDTree::buildForField done: " . print_r($this, true)); - + } // handle deleting subtrees - function deleteNode($iNode) { + function deleteNode($iNode) { $stack = array(); array_push($stack, $iNode); while (count($stack) != 0) @@ -215,7 +215,7 @@ class MDTree { $this->lookups[$leaf]->setTreeParent(0); $this->lookups[$leaf]->update(); $this->contents[0]["leaves"][] = $leaf; - } + } } else array_push($stack, $value); } @@ -225,7 +225,7 @@ class MDTree { $iParent = $this->mapnodes[$iNode]->getParentNode(); foreach ($this->contents[$iParent] as $index => $val) if ($iNode === $val) unset($this->contents[$iParent][$index]); - } + } // add a node to the mapping after the fact (e.g. created later in the process.) function addNode($oNode) { @@ -244,7 +244,7 @@ class MDTree { $oNewParent = $this->mapnodes[$destination_parent_id]; // we will have failed by here if its bogus. //$default->log->debug('MDTree::reparentKeyword '.print_r($oNewParent, true)); - + // if its 0 or NULL, we reparent to null. if (($oNewParent === null) or ($desintation_parent_id === 0)) { $new_home = 0; @@ -256,19 +256,19 @@ class MDTree { if (!empty($this->contents[$oldparent])) { $KWIndex = array_search($lookup_id, $this->contents[$oldParent]["leaves"]); unset($this->contents[$oldParent]["leaves"][$KWIndex]); - + } $this->contents[$new_home]["leaves"][] = $oKeyword->getId(); $oKeyword->update(); - } - + } + // STUB FUNCTIONS: need to be filled in. - + // REALLY need to deprecate this, but how? function render($bEditable) { return null; } // render using a template (with edit / buttons.) FIXME build a widget / renderer. - + /* ----------------------- EVIL HACK -------------------------- * @@ -307,7 +307,7 @@ class MDTree { } $treeStr .= ''; return $treeStr; - + } // I can't seem to do recursion in smarty, and recursive templates seems a bad solution. @@ -348,7 +348,8 @@ class MDTree { if ($leaf === $this->activevalue) { $is_selected=' checked="checked"'; } - $treeStr .= '
  • ' . $treeToRender->lookups[$leaf]->getName() .''; + $sValue = htmlentities($treeToRender->lookups[$leaf]->getName()); + $treeStr .= '
  • ' . $sValue .''; $treeStr .= '
  • '; } } @@ -357,9 +358,9 @@ class MDTree { //$treeStr .= ''; return $treeStr; - + } - + // again, not pretty. set a particular item as "active" function setActiveItem($sMetadataMatch) { // also need to: diff --git a/lib/users/User.inc b/lib/users/User.inc index 8ab6ebe..91eba61 100644 --- a/lib/users/User.inc +++ b/lib/users/User.inc @@ -323,10 +323,19 @@ class User extends KTEntity { * @return Array array of User objects, false otherwise and set $_SESSION["errorMessage"] */ function getList($sWhereClause = null, $aOptions = null) { - if(!is_array($aOptions)) $aOptions = array($aOptions); - $aOptions['orderby'] = KTUtil::arrayGet($aOptions, 'orderby', 'name'); - //if disabled = 2 then the user is deleted - $sWhereClause = 'disabled != \'2\''; + if(!is_array($aOptions)) $aOptions = array($aOptions); + $aOptions['orderby'] = KTUtil::arrayGet($aOptions, 'orderby', 'name'); + + // don't include deleted users: disabled = 2 + if(!empty($sWhereClause)){ + if(strpos(strtolower($sWhereClause), 'where ') === false){ + $sWhereClause = '('.$sWhereClause.')'; + } + $sWhereClause .= ' AND disabled != 2'; + }else{ + $sWhereClause = 'disabled != 2'; + } + return KTEntityUtil::getList2('User', $sWhereClause, $aOptions); } diff --git a/search2/indexing/extractorCore.inc.php b/search2/indexing/extractorCore.inc.php index 0a19fb2..7acafcf 100644 --- a/search2/indexing/extractorCore.inc.php +++ b/search2/indexing/extractorCore.inc.php @@ -370,7 +370,7 @@ abstract class ExternalDocumentExtractor extends DocumentExtractor $script_name = $script_prefix . '.bat'; $script = "rem This is an auto generated file. \n"; - $script .= $cmd . ' 2> ' . $script_out . "\r\n"; + $script .= $cmd . ' 2> "' . $script_out . "\"\r\n"; } else { @@ -378,7 +378,7 @@ abstract class ExternalDocumentExtractor extends DocumentExtractor $script = "#!/bin/sh\n"; $script .= "# This is an auto generated file. \n"; - $script .= $cmd . ' 2> ' . $script_out . "\n"; + $script .= $cmd . ' 2> "' . $script_out . "\"\n"; $script .= "exit $?\n"; } diff --git a/search2/indexing/extractors/OpenXmlTextExtractor.inc.php b/search2/indexing/extractors/OpenXmlTextExtractor.inc.php index 6176d75..cb01a12 100644 --- a/search2/indexing/extractors/OpenXmlTextExtractor.inc.php +++ b/search2/indexing/extractors/OpenXmlTextExtractor.inc.php @@ -43,7 +43,7 @@ class OpenXmlTextExtractor extends ExternalDocumentExtractor $config = KTConfig::getSingleton(); $this->unzip = KTUtil::findCommand("import/unzip", 'unzip'); - $this->unzip_params = $config->get('extractorParameters/unzip', '\'{source}\' \'{part}\' -d \'{target_dir}\''); + $this->unzip_params = $config->get('extractorParameters/unzip', '"{source}" "{part}" -d "{target_dir}"'); parent::__construct(); } diff --git a/search2/indexing/extractors/PDFExtractor.inc.php b/search2/indexing/extractors/PDFExtractor.inc.php index 39cbc79..6d9b83a 100644 --- a/search2/indexing/extractors/PDFExtractor.inc.php +++ b/search2/indexing/extractors/PDFExtractor.inc.php @@ -41,7 +41,7 @@ class PDFExtractor extends ApplicationExtractor public function __construct() { $config = KTConfig::getSingleton(); - $params = $config->get('extractorParameters/pdftotext', '-nopgbrk -enc UTF-8 \'{source}\' \'{target}\''); + $params = $config->get('extractorParameters/pdftotext', '-nopgbrk -enc UTF-8 "{source}" "{target}"'); parent::__construct('externalBinary','pdftotext','pdftotext',_kt('PDF Text Extractor'),$params); } diff --git a/search2/indexing/extractors/PSExtractor.inc.php b/search2/indexing/extractors/PSExtractor.inc.php index 66bfbff..f64104a 100644 --- a/search2/indexing/extractors/PSExtractor.inc.php +++ b/search2/indexing/extractors/PSExtractor.inc.php @@ -41,7 +41,7 @@ class PSExtractor extends ApplicationExtractor public function __construct() { $config = KTConfig::getSingleton(); - $params = $config->get('extractorParameters/pstotext', '\'{source}\' > \'{target}\''); + $params = $config->get('extractorParameters/pstotext', '"{source}" > "{target}"'); parent::__construct('externalBinary','pstotext','pstotext',_kt('PostScript Text Extractor'), $params); } diff --git a/templates/kt3/fields/lookup.smarty b/templates/kt3/fields/lookup.smarty index 28b7283..5b4dbe2 100644 --- a/templates/kt3/fields/lookup.smarty +++ b/templates/kt3/fields/lookup.smarty @@ -13,7 +13,7 @@ diff --git a/templates/ktcore/forms/widgets/selection.smarty b/templates/ktcore/forms/widgets/selection.smarty index 8b85705..3465c59 100644 --- a/templates/ktcore/forms/widgets/selection.smarty +++ b/templates/ktcore/forms/widgets/selection.smarty @@ -1,16 +1,16 @@ {if empty($vocab)}
    {$context->sEmptyMessage}
    {else} - {/if} diff --git a/thirdparty/pear/File/Archive/Writer/Files.php b/thirdparty/pear/File/Archive/Writer/Files.php index 501fbb6..b2ceaf5 100644 --- a/thirdparty/pear/File/Archive/Writer/Files.php +++ b/thirdparty/pear/File/Archive/Writer/Files.php @@ -1,250 +1,250 @@ - - * @copyright 1997-2005 The PHP Group - * @license http://www.gnu.org/copyleft/lesser.html LGPL - * @version CVS: $Id: Files.php,v 1.21 2005/06/18 23:08:16 vincentlascaux Exp $ - * @link http://pear.php.net/package/File_Archive - */ - -require_once "File/Archive/Writer.php"; - -/** - * Writer to files - */ -class File_Archive_Writer_Files extends File_Archive_Writer -{ - /** - * @var Object Handle to the file where the data are currently written - * @access private - */ - var $handle = null; - var $basePath; - var $stat = array(); - var $filename; - - function File_Archive_Writer_Files($base = '') - { - if ($base === null || $base == '') { - $this->basePath = ''; - } else { - if (substr($base, -1) == '/') { - $this->basePath = $base; - } else { - $this->basePath = $base.'/'; - } - } - } - - function getFilename($filename) - { - return $this->basePath.$filename; - } - - /** - * Ensure that $pathname exists, or create it if it does not - * @access private - */ - function mkdirr($pathname) - { - // Check if directory already exists - if (is_dir($pathname) || empty($pathname)) { - return; - } - - // Ensure a file does not already exist with the same name - if (is_file($pathname)) { - return PEAR::raiseError( - "File $pathname exists, unable to create directory" - ); - } - - // Crawl up the directory tree - $next_pathname = substr( - $pathname, - 0, strrpos($pathname, "/")); - $error = $this->mkdirr($next_pathname); - if (PEAR::isError($error)) { - return $error; - } - if (!@mkdir($pathname)) { - return PEAR::raiseError("Unable to create directory $pathname"); - } - } - - /** - * Open a file for writing from a given position - * - * @param string $filename The name of the file to open - * @param int $pos the initial position in the file - * @param $stat the stats of the file - */ - function openFile($filename, $pos = 0) - { - $this->close(); - - $this->handle = fopen($filename, 'r+'); - $this->stat = array(); - $this->filename = $filename; - - if (!is_resource($this->handle)) { - return PEAR::raiseError("Unable to open file $filename"); - } - - if ($pos > 0) { - if (fseek($this->handle, $pos) == -1) { - fread($this->handle, $pos); - } - } - } - - /** - * Open a file for appending after having removed a block of data from it - * See File_Archive_Reader::makeWriterRemoveBlocks - */ - function openFileRemoveBlock($filename, $pos, $blocks) - { - $error = $this->openFile($filename, $pos); - if (PEAR::isError($error)) { - return $error; - } - - if (!empty($blocks)) { - //This will be used to read the initial file - //The data, with the unusefull block removed will be written to $this->handle - $read = fopen($filename, 'r'); - if ($pos > 0) { - if (fseek($this->handle, $pos) == -1) { - fread($this->handle, $pos); - } - } - - $keep = false; - $data = ''; - foreach ($blocks as $length) { - if ($keep) { - while ($length > 0 && - ($data = fread($read, min($length, 8192))) != '') { - $length -= strlen($data); - fwrite($this->handle, $data); - } - } else { - fseek($read, $length, SEEK_CUR); - } - $keep = !$keep; - } - if ($keep) { - while(!feof($this->handle)) { - fwrite($this->handle, fread($read, 8196)); - } - } - - fclose($read); - } - - ftruncate($this->handle, ftell($this->handle)); - } - - - /** - * @see File_Archive_Writer::newFile() - */ - function newFile($filename, $stat = array(), $mime = "application/octet-stream") - { - $this->close(); - $this->stat = $stat; - $this->filename = $this->getFilename($filename); - - $pos = strrpos($this->filename, "/"); - if ($pos !== false) { - $error = $this->mkdirr(substr($this->filename, 0, $pos)); - if (PEAR::isError($error)) { - return $error; - } - } - $this->handle = @fopen($this->filename, "w"); - if (!is_resource($this->handle)) { - return PEAR::raiseError("Unable to write to file $filename"); - } - } - /** - * @see File_Archive_Writer::writeData() - */ - function writeData($data) { fwrite($this->handle, $data); } - /** - * @see File_Archive_Writer::newFromTempFile() - */ - function newFromTempFile($tmpfile, $filename, $stat = array(), $mime = "application/octet-stream") - { - $this->filename = filename; - $complete = $this->getFilename($filename); - $pos = strrpos($complete, "/"); - if ($pos !== false) { - $error = $this->mkdirr(substr($complete, 0, $pos)); - if (PEAR::isError($error)) { - return $error; - } - } - - if ((file_exists($complete) && !@unlink($complete)) || - !@rename($tmpfile, $complete)) { - return parent::newFromTempFile($tmpfile, $filename, $stat, $mime); - } - } - - - /** - * @see File_Archive_Writer::close() - */ - function close() - { - if ($this->handle !== null) { - fclose($this->handle); - $this->handle = null; - - if (isset($this->stat[9])) { - if (isset($this->stat[8])) { - touch($this->filename, $this->stat[9], $this->stat[8]); - } else { - touch($this->filename, $this->stat[9]); - } - } else if (isset($this->stat[8])) { - touch($this->filename, time(), $this->stat[8]); - } - - if (isset($this->stat[2])) { - chmod($this->filename, $this->stat[2]); - } - if (isset($this->stat[5])) { - chgrp($this->filename, $this->stat[5]); - } - if (isset($this->stat[4])) { - chown($this->filename, $this->stat[4]); - } - } - } -} - + + * @copyright 1997-2005 The PHP Group + * @license http://www.gnu.org/copyleft/lesser.html LGPL + * @version CVS: $Id: Files.php,v 1.21 2005/06/18 23:08:16 vincentlascaux Exp $ + * @link http://pear.php.net/package/File_Archive + */ + +require_once "File/Archive/Writer.php"; + +/** + * Writer to files + */ +class File_Archive_Writer_Files extends File_Archive_Writer +{ + /** + * @var Object Handle to the file where the data are currently written + * @access private + */ + var $handle = null; + var $basePath; + var $stat = array(); + var $filename; + + function File_Archive_Writer_Files($base = '') + { + if ($base === null || $base == '') { + $this->basePath = ''; + } else { + if (substr($base, -1) == '/') { + $this->basePath = $base; + } else { + $this->basePath = $base.'/'; + } + } + } + + function getFilename($filename) + { + return $this->basePath.$filename; + } + + /** + * Ensure that $pathname exists, or create it if it does not + * @access private + */ + function mkdirr($pathname) + { + // Check if directory already exists + if (is_dir($pathname) || empty($pathname)) { + return; + } + + // Ensure a file does not already exist with the same name + if (is_file($pathname)) { + return PEAR::raiseError( + "File $pathname exists, unable to create directory" + ); + } + + // Crawl up the directory tree + $next_pathname = substr( + $pathname, + 0, strrpos($pathname, "/")); + $error = $this->mkdirr($next_pathname); + if (PEAR::isError($error)) { + return $error; + } + if (!@mkdir($pathname)) { + return PEAR::raiseError("Unable to create directory $pathname"); + } + } + + /** + * Open a file for writing from a given position + * + * @param string $filename The name of the file to open + * @param int $pos the initial position in the file + * @param $stat the stats of the file + */ + function openFile($filename, $pos = 0) + { + $this->close(); + + $this->handle = fopen($filename, 'r+'); + $this->stat = array(); + $this->filename = $filename; + + if (!is_resource($this->handle)) { + return PEAR::raiseError("Unable to open file $filename"); + } + + if ($pos > 0) { + if (fseek($this->handle, $pos) == -1) { + fread($this->handle, $pos); + } + } + } + + /** + * Open a file for appending after having removed a block of data from it + * See File_Archive_Reader::makeWriterRemoveBlocks + */ + function openFileRemoveBlock($filename, $pos, $blocks) + { + $error = $this->openFile($filename, $pos); + if (PEAR::isError($error)) { + return $error; + } + + if (!empty($blocks)) { + //This will be used to read the initial file + //The data, with the unusefull block removed will be written to $this->handle + $read = fopen($filename, 'r'); + if ($pos > 0) { + if (fseek($this->handle, $pos) == -1) { + fread($this->handle, $pos); + } + } + + $keep = false; + $data = ''; + foreach ($blocks as $length) { + if ($keep) { + while ($length > 0 && + ($data = fread($read, min($length, 8192))) != '') { + $length -= strlen($data); + fwrite($this->handle, $data); + } + } else { + fseek($read, $length, SEEK_CUR); + } + $keep = !$keep; + } + if ($keep) { + while(!feof($this->handle)) { + fwrite($this->handle, fread($read, 8196)); + } + } + + fclose($read); + } + + ftruncate($this->handle, ftell($this->handle)); + } + + + /** + * @see File_Archive_Writer::newFile() + */ + function newFile($filename, $stat = array(), $mime = "application/octet-stream") + { + $this->close(); + $this->stat = $stat; + $this->filename = $this->getFilename($filename); + + $pos = strrpos($this->filename, "/"); + if ($pos !== false) { + $error = $this->mkdirr(substr($this->filename, 0, $pos)); + if (PEAR::isError($error)) { + return $error; + } + } + $this->handle = @fopen($this->filename, "w"); + if (!is_resource($this->handle)) { + return PEAR::raiseError("Unable to write to file $filename"); + } + } + /** + * @see File_Archive_Writer::writeData() + */ + function writeData($data) { fwrite($this->handle, $data); } + /** + * @see File_Archive_Writer::newFromTempFile() + */ + function newFromTempFile($tmpfile, $filename, $stat = array(), $mime = "application/octet-stream") + { + $this->filename = filename; + $complete = $this->getFilename($filename); + $pos = strrpos($complete, "/"); + if ($pos !== false) { + $error = $this->mkdirr(substr($complete, 0, $pos)); + if (PEAR::isError($error)) { + return $error; + } + } + + if ((file_exists($complete) && !@unlink($complete)) || + !@rename($tmpfile, $complete)) { + return parent::newFromTempFile($tmpfile, $filename, $stat, $mime); + } + } + + + /** + * @see File_Archive_Writer::close() + */ + function close() + { + if ($this->handle !== null) { + fclose($this->handle); + $this->handle = null; + + if (isset($this->stat[9])) { + if (isset($this->stat[8])) { + touch($this->filename, $this->stat[9], $this->stat[8]); + } else { + touch($this->filename, $this->stat[9]); + } + } else if (isset($this->stat[8])) { + touch($this->filename, time(), $this->stat[8]); + } + + if (isset($this->stat[2])) { + @chmod($this->filename, $this->stat[2]); + } + if (isset($this->stat[5])) { + @chgrp($this->filename, $this->stat[5]); + } + if (isset($this->stat[4])) { + @chown($this->filename, $this->stat[4]); + } + } + } +} + ?> \ No newline at end of file