diff --git a/lib/documentmanagement/documentutil.inc.php b/lib/documentmanagement/documentutil.inc.php index 82d51df..d3111a1 100644 --- a/lib/documentmanagement/documentutil.inc.php +++ b/lib/documentmanagement/documentutil.inc.php @@ -254,15 +254,15 @@ class KTDocumentUtil { 'folderid' => $oFolder->getID(), 'creatorid' => $oUser->getID(), 'documenttypeid' => $iDocumentTypeId, - )); + )); $oUploadChannel->sendMessage(new KTUploadGenericMessage(_kt('Storing contents'))); $res = KTDocumentUtil::storeContents($oDocument, '', $aOptions); if (PEAR::isError($res)) { if (!PEAR::isError($oDocument)) { - $oDocument->delete(); + $oDocument->delete(); } - return $res; + return $res; } if (is_null($aMetadata)) { @@ -707,7 +707,7 @@ class KTDocumentUtil { $oKTConfig =& KTConfig::getSingleton(); $sBasedir = $oKTConfig->get('urls/tmpDirectory'); - $sFilename = (isset($aOptions['temp_file'])) ? $aOptions['temp_file'] : tempnam($sBasedir, 'kt_storecontents'); + $sFilename = (isset($aOptions['temp_file'])) ? $aOptions['temp_file'] : ''; // $oOutputFile = new KTFSFileLike($sFilename); // $res = KTFileLikeUtil::copy_contents($oContents, $oOutputFile); @@ -717,6 +717,10 @@ class KTDocumentUtil { // return PEAR::raiseError(sprintf(_kt("Couldn't store contents: %s"), $res->getMessage())); // } + if(empty($sFilename)){ + return PEAR::raiseError(sprintf(_kt("Couldn't store contents: %s"), _kt('The uploaded file does not exist.'))); + } + $sType = KTMime::getMimeTypeFromFile($sFilename); $iMimeTypeId = KTMime::getMimeTypeID($sType, $oDocument->getFileName()); $oDocument->setMimeTypeId($iMimeTypeId); diff --git a/lib/groups/GroupUtil.php b/lib/groups/GroupUtil.php index 42b9aeb..f592a86 100644 --- a/lib/groups/GroupUtil.php +++ b/lib/groups/GroupUtil.php @@ -309,7 +309,7 @@ class GroupUtil { global $default; $sTable = $default->users_groups_table; - $sQuery = "SELECT count(*) AS cnt FROM $sTable WHERE user_id = ? AND group_id IN (?)"; + $sQuery = "SELECT COUNT(group_id) AS cnt FROM $sTable WHERE user_id = ? AND group_id IN (?)"; $aParams = array($iUserId, $sGroupIds); $res = DBUtil::getOneResult(array($sQuery, $aParams)); diff --git a/lib/security/Permission.inc b/lib/security/Permission.inc index 44f7d6c..85c1299 100644 --- a/lib/security/Permission.inc +++ b/lib/security/Permission.inc @@ -59,6 +59,14 @@ class Permission { return false; } + if ($oDocument->getIsCheckedOut()) + { + if ($oDocument->getCheckedOutUserID() != $_SESSION["userID"]) + { + return false; + } + } + $oUser = User::get($_SESSION["userID"]); $oPermission = KTPermission::getByName('ktcore.permissions.write'); diff --git a/plugins/ktcore/folder/Permissions.php b/plugins/ktcore/folder/Permissions.php index 6ec4063..9a4ed11 100644 --- a/plugins/ktcore/folder/Permissions.php +++ b/plugins/ktcore/folder/Permissions.php @@ -456,29 +456,55 @@ class KTFolderPermissionsAction extends KTFolderAction { $aFoo = $_REQUEST['foo']; $aPermissions = KTPermission::getList(); - + + //------------------- + //This section is used to make sure that a user doesn't disable the admin groups + //Manage security permission or the Manage Security permission of a group they + //are currently a member of. + // Check which groups have permission to manage security - $aNewGroups = $aFoo[4]['group']; + $aNewGroups = (isset($aFoo[4]['group']) ? $aFoo[4]['group'] : array()); $aNewRoles = (isset($aFoo[4]['role']) ? $aFoo[4]['role'] : array()); - - // Ensure the user is not removing his/her own permission to update the folder permissions (manage security) - if(!in_array(-3, $aNewRoles)){ - $iUserId = $this->oUser->getId(); - if(!GroupUtil::checkUserInGroups($iUserId, $aNewGroups)){ - // If user no longer has permission, return an error. - $this->addErrorMessage(_kt('The selected permissions cannot be updated. You will no longer have permission to manage security on this folder.')); - $this->redirectTo('edit', 'fFolderId=' . $this->oFolder->getId()); - exit(0); - } + + $iUserId = $this->oUser->getId(); + + //Check that they aren't removing the sys admin Manage Security permission + //1 in this case is the admin group. + if(!in_array('1', $aNewGroups)) + { + $this->addErrorMessage(_kt('You cannot remove the Manage Security permission from the System Administrators Group')); + $this->redirectTo('edit', 'fFolderId=' . $this->oFolder->getId()); + exit(0); } - - + + + //Check that they aren't removing the Manage Security permission from a group + //They are a member of. + if(!GroupUtil::checkUserInGroups($iUserId, array(1))) + { + //Ensure the user is not removing his/her own permission to update the folder permissions (manage security) + if(!in_array(-3, $aNewRoles)) + { + + if(!GroupUtil::checkUserInGroups($iUserId, $aNewGroups)) + { + // If user no longer has permission, return an error. + $this->addErrorMessage(_kt('You cannot remove the Manage Security permission from a group you belong to.')); + $this->redirectTo('edit', 'fFolderId=' . $this->oFolder->getId()); + exit(0); + } + + } + } + //----------------- + + require_once(KT_LIB_DIR . '/documentmanagement/observers.inc.php'); $oPO = KTPermissionObject::get($this->oFolder->getPermissionObjectId()); foreach ($aPermissions as $oPermission) { $iPermId = $oPermission->getId(); - + $aAllowed = KTUtil::arrayGet($aFoo, $iPermId, array()); KTPermissionUtil::setPermissionForId($oPermission, $oPO, $aAllowed); } diff --git a/plugins/search2/reporting/templates/indexerrors.smarty b/plugins/search2/reporting/templates/indexerrors.smarty index d0cc6cf..bf1694b 100644 --- a/plugins/search2/reporting/templates/indexerrors.smarty +++ b/plugins/search2/reporting/templates/indexerrors.smarty @@ -34,7 +34,7 @@ {foreach key=key from=$index_errors item=indexError} - {$indexError.filename|truncate:40:'...'} + {$indexError.filename|truncate:40:'...'} {if $indexError.extractor}{$indexError.extractor}{else}

{i18n}n/a{/i18n}

{/if} {$indexError.indexdate} diff --git a/search2/indexing/indexerCore.inc.php b/search2/indexing/indexerCore.inc.php index 91a86e6..0d99ab1 100644 --- a/search2/indexing/indexerCore.inc.php +++ b/search2/indexing/indexerCore.inc.php @@ -475,10 +475,21 @@ abstract class Indexer * @param string $document * @param string $what */ - public static function index($document, $what='C') + public static function index($document, $what='A') { global $default; + if (is_numeric($document)) + { + $document = Document::get($document+0); + } + + if (PEAR::isError($document)) + { + $default->log->error("index: Could not index document: " .$document->getMessage()); + return; + } + $document_id = $document->getId(); $userid=$_SESSION['userID']; if (empty($userid)) $userid=1; @@ -601,7 +612,8 @@ abstract class Indexer $this->generalHookCache = array(); $this->mimeHookCache = array(); - $dir = opendir($this->hookPath); + + $dir = opendir(SearchHelper::correctPath($this->hookPath)); while (($file = readdir($dir)) !== false) { if (substr($file,-12) == 'Hook.inc.php') @@ -1361,7 +1373,8 @@ abstract class Indexer global $default; $diagnoses = array(); - $dir = opendir($path); + + $dir = opendir(SearchHelper::correctPath($path)); $extlen = - strlen($extension); while (($file = readdir($dir)) !== false) @@ -1433,7 +1446,7 @@ abstract class Indexer { $this->clearExtractors(); } - $dir = opendir($this->extractorPath); + $dir = opendir(SearchHelper::correctPath($this->extractorPath)); while (($file = readdir($dir)) !== false) { if (substr($file,-17) == 'Extractor.inc.php') diff --git a/search2/search/bin/search2graphviz.php b/search2/search/bin/search2graphviz.php new file mode 100644 index 0000000..d2fe464 --- /dev/null +++ b/search2/search/bin/search2graphviz.php @@ -0,0 +1,101 @@ +. + * + * 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 + * 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. + * Contributor( s): ______________________________________ + * + */ + +$curdir = getcwd(); +chdir(dirname(__FILE__)); +require_once(realpath('../../../config/dmsDefaults.php')); + +$expr = ''; + +$filename = 'search2graphviz.jpg'; +$verbose = false; +if ($argc > 0) +{ + foreach($argv as $arg) + { + if (strpos($arg, '=') === false) + { + $expr = $arg; + continue; + } + list($param, $value) = explode('=', $arg); + + switch (strtolower($param)) + { + case 'verbose': + $verbose=true; + break; + case 'output': + $filename = $value; + if ($verbose) print "* output = $value\n"; + break; + case 'user': + $username = $value; + if ($verbose) print "* User = $value\n"; + break; + case 'pass': + $password = $value; + if ($verbose) print "* User = $value\n"; + break; + case 'help': + print "Usage: search2graphviz.php [verbose] output=filename 'search criteria'\n"; + exit; + } + } +} + +if ($verbose) print _kt('Visgraph search expression') . "...\n"; + +try +{ + $expr = parseExpression($expr); + + $expr->toVizGraph(array('tofile'=>$filename)); + + if ($verbose) + { + print _kt("Done.") . "\n"; + } + +} +catch(Exception $e) +{ + print $e->getMessage(); +} + +?> \ No newline at end of file diff --git a/search2/search/expr.inc.php b/search2/search/expr.inc.php index 0b47c8d..0f7efdd 100644 --- a/search2/search/expr.inc.php +++ b/search2/search/expr.inc.php @@ -273,18 +273,21 @@ class Expr $ext = pathinfo($filename, PATHINFO_EXTENSION); $base = substr($filename, 0, -strlen($ext)-1); - $dotfile="$path/$base.$ext"; - $jpgfile="$path/$base.jpg"; + $curdir = getcwd(); + chdir($_ENV['PWD']); + $dotfile="$base.$ext"; + $jpgfile="$base.jpg"; $fp = fopen($dotfile,'wt'); fwrite($fp, $str); fclose($fp); - system("dot -Tjpg -o$jpgfile $dotfile"); + system("dot -Tjpg -o$jpgfile $dotfile 2>1 >/dev/null "); if (isset($options['view']) && $options['view']) { system("eog $jpgfile"); } + chdir($curdir); } return $str; diff --git a/search2/search/fieldRegistry.inc.php b/search2/search/fieldRegistry.inc.php index e240372..1ef4d44 100644 --- a/search2/search/fieldRegistry.inc.php +++ b/search2/search/fieldRegistry.inc.php @@ -223,7 +223,7 @@ class ExprFieldRegistry { $this->fields = array(); - $dir = opendir($this->path); + $dir = opendir(SearchHelper::correctPath($this->path)); while (($file = readdir($dir)) !== false) { if (substr($file,-13) == 'Field.inc.php') diff --git a/search2/search/search.inc.php b/search2/search/search.inc.php index 65c79f5..84e7f5d 100644 --- a/search2/search/search.inc.php +++ b/search2/search/search.inc.php @@ -62,6 +62,18 @@ function search_alias_compare($a, $b) class SearchHelper { + public static function correctPath($path) + { + if (OS_WINDOWS) + { + return str_replace('/','\\', $path); + } + else + { + return str_replace('\\','/', $path); + } + } + public static function checkOpenOfficeAvailablity() { $config =& KTConfig::getSingleton();