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}
{i18n}n/a{/i18n}
{/if}