diff --git a/config/config.ini b/config/config.ini index 7b2a978..ff8ee4e 100644 --- a/config/config.ini +++ b/config/config.ini @@ -140,7 +140,12 @@ uiUrl = ${rootUrl}/presentation/lookAndFeel/knowledgeTree [session] ; session timeout (in seconds) sessionTimeout = 1200 -allowAnonymousLogin = true + +; by default, do not auto-login users as anonymous. +; set this to true if you UNDERSTAND the security system that KT +; uses, and have sensibly applied the roles "Everyone" and "Authenticated Users". +allowAnonymousLogin = false + ; Set to true to force sessions to come from the same IP address ; ipTracking = false diff --git a/edit.php b/edit.php index 0befb16..ef595e1 100644 --- a/edit.php +++ b/edit.php @@ -128,9 +128,9 @@ class KTEditDocumentDispatcher extends KTStandardDispatcher { exit(0); } - function do_selectType() { + function do_selectType() { - $document_id = KTUtil::arrayGet($_REQUEST, 'fDocumentId'); + $document_id = KTUtil::arrayGet($_REQUEST, 'fDocumentId'); if (empty($document_id)) { $this->errorPage(_kt("No document specified for editing.")); } @@ -139,14 +139,14 @@ class KTEditDocumentDispatcher extends KTStandardDispatcher { $this->errorPage(_kt("Invalid Document.")); } - $this->oDocument = $oDocument; - $this->addPortlets("Edit"); - $this->addBreadcrumbs(); - $this->oPage->setBreadcrumbDetails(_kt('Change Document Type')); - - $aDocTypes = DocumentType::getList(); - - + $this->oDocument = $oDocument; + $this->addPortlets("Edit"); + $this->addBreadcrumbs(); + $this->oPage->setBreadcrumbDetails(_kt('Change Document Type')); + + $aDocTypes = DocumentType::getList(); + + $aDocTypes = array(); foreach (DocumentType::getList() as $oDocumentType) { if(!$oDocumentType->getDisabled()) { @@ -154,47 +154,47 @@ class KTEditDocumentDispatcher extends KTStandardDispatcher { } } - $oDocumentType = DocumentType::get($oDocument->getDocumentTypeID()); - - $oTemplating =& KTTemplating::getSingleton(); + $oDocumentType = DocumentType::get($oDocument->getDocumentTypeID()); + + $oTemplating =& KTTemplating::getSingleton(); $oTemplate =& $oTemplating->loadTemplate("ktcore/document/change_type"); $aTemplateData = array( 'context' => $this, 'document' => $oDocument, - 'document_type' => $oDocumentType, - 'doctypes' => $aDocTypes, - ); + 'document_type' => $oDocumentType, + 'doctypes' => $aDocTypes, + ); $oTemplate->setData($aTemplateData); return $oTemplate->render(); - } + } - function do_changeType() { - // FIXME this could do with more postTriggers, etc. - - /* The basic procedure is: - * - * 1. find out what fieldsets we _have_ - * 2. find out what fieldsets we _should_ have. - * 3. actively delete fieldsets we need to lose. - * 4. run the edit script. - */ - $newType = KTUtil::arrayGet($_REQUEST, 'fDocType'); - $oType = DocumentType::get($newType); - if (PEAR::isError($oType) || ($oType == false)) { - $this->errorRedirectToMain(_kt("Invalid type selected.")); - } - - $_SESSION['KTInfoMessage'][] = _kt('Document Type Changed. Please review the information below, and update as appropriate.'); - - $_REQUEST['setType'] = $newType; - - return $this->do_main($newType); + function do_changeType() { + // FIXME this could do with more postTriggers, etc. + + /* The basic procedure is: + * + * 1. find out what fieldsets we _have_ + * 2. find out what fieldsets we _should_ have. + * 3. actively delete fieldsets we need to lose. + * 4. run the edit script. + */ + $newType = KTUtil::arrayGet($_REQUEST, 'fDocType'); + $oType = DocumentType::get($newType); + if (PEAR::isError($oType) || ($oType == false)) { + $this->errorRedirectToMain(_kt("Invalid type selected.")); + } + + $_SESSION['KTInfoMessage'][] = _kt('Document Type Changed. Please review the information below, and update as appropriate.'); + $_REQUEST['setType'] = $newType; + + return $this->do_main($newType); } - // "standard document editing" - function do_main($newType=false) { - $this->oPage->setBreadcrumbDetails("edit"); + // "standard document editing" + function do_main($newType=false) { + $this->oPage->setBreadcrumbDetails("edit"); + $document_id = KTUtil::arrayGet($_REQUEST, 'fDocumentId'); if (empty($document_id)) { $this->errorPage(_kt("No document specified for editing.")); @@ -263,12 +263,13 @@ class KTEditDocumentDispatcher extends KTStandardDispatcher { return $oTemplate->render(); } - function do_update() { + function do_update() { $document_id = KTUtil::arrayGet($_REQUEST, 'fDocumentId'); if (empty($document_id)) { $this->errorPage(_kt("No document specified for editing.")); } - $oDocument = Document::get($document_id); + + $oDocument = Document::get($document_id); if (PEAR::isError($oDocument)) { $this->errorPage(_kt("Invalid Document.")); } @@ -276,20 +277,21 @@ class KTEditDocumentDispatcher extends KTStandardDispatcher { $aErrorOptions = array( 'redirect_to' => array('main', sprintf('fDocumentId=%d', $oDocument->getId())), 'message' => _kt('No name given'), + 'max_str_len' => 200, ); + $title = KTUtil::arrayGet($_REQUEST, 'generic_title'); - $title = $this->oValidator->validateString($title, - $aErrorOptions); + $title = $this->oValidator->validateString($title, $aErrorOptions); - $newType = KTUtil::arrayGet($_REQUEST, 'newType'); - if ($newType !== null) { - $oDT = DocumentType::get($newType); - if (PEAR::isError($oDT) || ($oDT == false)) { - $this->errorRedirectToMain(_kt('Invalid document type specified for change.')); - } - } else { - $oDT = null; - } + $newType = KTUtil::arrayGet($_REQUEST, 'newType'); + if ($newType !== null) { + $oDT = DocumentType::get($newType); + if (PEAR::isError($oDT) || ($oDT == false)) { + $this->errorRedirectToMain(_kt('Invalid document type specified for change.')); + } + } else { + $oDT = null; + } $this->oDocument = $oDocument; $this->oFolder = Folder::get($oDocument->getFolderId()); // FIXME do we need to check that this is valid? @@ -317,115 +319,116 @@ class KTEditDocumentDispatcher extends KTStandardDispatcher { } // erk. we need all the items that the document _does_ need, _and_ what they have, - // _and_ what they don't ... + // _and_ what they don't ... // we want to grab all the md for this doc, since its faster that way. - $current_md =& DocumentFieldLink::getByDocument($document_id); - - // to get all fields, we merge repeatedly from KTFieldset::get - - $field_values = array(); - foreach ($fieldsets as $oFieldSet) { - $fields =& $oFieldSet->getFields(); - - // FIXME this doesn't handle multi-fieldset fields - are they possible/meaningful? - foreach ($fields as $oField) { - $field_values[$oField->getID()] = array($oField, null); - } - } + $current_md =& DocumentFieldLink::getByDocument($document_id); + + // to get all fields, we merge repeatedly from KTFieldset::get + + $field_values = array(); + foreach ($fieldsets as $oFieldSet) { + $fields =& $oFieldSet->getFields(); + + // FIXME this doesn't handle multi-fieldset fields - are they possible/meaningful? + foreach ($fields as $oField) { + $field_values[$oField->getID()] = array($oField, null); + } + } - foreach ($current_md as $oFieldLink) { + foreach ($current_md as $oFieldLink) { $field_values[$oFieldLink->getDocumentFieldID()][1] = $oFieldLink->getValue(); - } - - // now, we need the full set of items that this document could contain. - - // FIXME this DOES NOT WORK for date items. - // FIXME that's fine - we don't use range items here... - $expect_vals = KTUtil::arrayGet($_REQUEST,'kt_core_fieldsets_expect'); - - foreach ($field_values as $key => $val) { - $newVal = KTUtil::arrayGet($_REQUEST, 'metadata_' . $key, null); - $wantVal = KTUtil::arrayGet($expect_vals, 'metadata_' . $key, false); - - // FIXME this leaves no way to check if someone has actually removed the item. - // FIXME we probably want to _not_ set anything that could be set ... but then how do you - // FIXME know about managed values ... - - if ($newVal !== null) { - $field_values[$key][1] = $newVal; // need the items themselves. - } else if ($wantVal !== false) { - // we sent it out, delete it. - - unset($field_values[$key]); - } - } - - - // finally, we need to pass through and remove null entries (sigh) - // FIXME alternatively we could build a new set, but that might break stuff? + } + + + // now, we need the full set of items that this document could contain. + + // FIXME this DOES NOT WORK for date items. + // FIXME that's fine - we don't use range items here... + $expect_vals = KTUtil::arrayGet($_REQUEST,'kt_core_fieldsets_expect'); + + foreach ($field_values as $key => $val) { + $newVal = KTUtil::arrayGet($_REQUEST, 'metadata_' . $key, null); + $wantVal = KTUtil::arrayGet($expect_vals, 'metadata_' . $key, false); + + // FIXME this leaves no way to check if someone has actually removed the item. + // FIXME we probably want to _not_ set anything that could be set ... but then how do you + // FIXME know about managed values ... + + if ($newVal !== null) { + $field_values[$key][1] = $newVal; // need the items themselves. + } else if ($wantVal !== false) { + // we sent it out, delete it. + + unset($field_values[$key]); + } + } - $final_values = array(); - foreach ($field_values as $aMDPack) { - if ($aMDPack[1] !== null) { - $final_values[] = $aMDPack; - } + + // finally, we need to pass through and remove null entries (sigh) + // FIXME alternatively we could build a new set, but that might break stuff? + + $final_values = array(); + foreach ($field_values as $aMDPack) { + if ($aMDPack[1] !== null) { + $final_values[] = $aMDPack; + } + } + $field_values = $final_values; + + // FIXME handle md versions. + //return '
' . print_r($field_values, true) . '
'; + $this->startTransaction(); + $iPreviousMetadataVersionId = $oDocument->getMetadataVersionId(); + $oDocument->startNewMetadataVersion($this->oUser); + if (PEAR::isError($res)) { + $this->errorRedirectToMain('Unable to create a metadata version of the document.'); + } + + $oDocument->setName($title); + $oDocument->setLastModifiedDate(getCurrentDateTime()); + $oDocument->setModifiedUserId($this->oUser->getId()); + + // FIXME refactor this into documentutil. + // document type changing semantics + if ($newType != null) { + $oldType = DocumentType::get($oDocument->getDocumentTypeID()); + $oDocument->setDocumentTypeID($newType); + + // we need to find fieldsets that _were_ in the old one, and _delete_ those. + $for_delete = array(); + + $oldFieldsets = KTFieldset::getForDocumentType($oldType); + $newFieldsets = KTFieldset::getForDocumentType($newType); + + // prune from MDPack. + foreach ($oldFieldsets as $oFieldset) { + $old_fields = $oFieldset->getFields(); + foreach ($old_fields as $oField) { + $for_delete[$oField->getId()] = 1; } - $field_values = $final_values; - - // FIXME handle md versions. - //return '
' . print_r($field_values, true) . '
'; - $this->startTransaction(); - $iPreviousMetadataVersionId = $oDocument->getMetadataVersionId(); - $oDocument->startNewMetadataVersion($this->oUser); - if (PEAR::isError($res)) { - $this->errorRedirectToMain('Unable to create a metadata version of the document.'); + } + + foreach ($newFieldsets as $oFieldset) { + $new_fields = $oFieldset->getFields(); + foreach ($new_fields as $oField) { + unset($for_delete[$oField->getId()]); } - - $oDocument->setName($title); - $oDocument->setLastModifiedDate(getCurrentDateTime()); - $oDocument->setModifiedUserId($this->oUser->getId()); - - // FIXME refactor this into documentutil. - // document type changing semantics - if ($newType != null) { - $oldType = DocumentType::get($oDocument->getDocumentTypeID()); - $oDocument->setDocumentTypeID($newType); - - // we need to find fieldsets that _were_ in the old one, and _delete_ those. - $for_delete = array(); - - $oldFieldsets = KTFieldset::getForDocumentType($oldType); - $newFieldsets = KTFieldset::getForDocumentType($newType); - - // prune from MDPack. - foreach ($oldFieldsets as $oFieldset) { - $old_fields = $oFieldset->getFields(); - foreach ($old_fields as $oField) { - $for_delete[$oField->getId()] = 1; - } - } - - foreach ($newFieldsets as $oFieldset) { - $new_fields = $oFieldset->getFields(); - foreach ($new_fields as $oField) { - unset($for_delete[$oField->getId()]); - } - } - - $newPack = array(); - foreach ($field_values as $MDPack) { - if (!array_key_exists($MDPack[0]->getId(), $for_delete)) { - $newPack[] = $MDPack; - } - } - $field_values = $newPack; - - - //var_dump($field_values); - //exit(0); + } + + $newPack = array(); + foreach ($field_values as $MDPack) { + if (!array_key_exists($MDPack[0]->getId(), $for_delete)) { + $newPack[] = $MDPack; } - + } + $field_values = $newPack; + + + //var_dump($field_values); + //exit(0); + } + $oDocumentTransaction = & new DocumentTransaction($oDocument, 'update metadata.', 'ktcore.transactions.update'); $res = $oDocumentTransaction->create(); diff --git a/lib/documentmanagement/DocumentType.inc b/lib/documentmanagement/DocumentType.inc index 39de6a4..46e8231 100644 --- a/lib/documentmanagement/DocumentType.inc +++ b/lib/documentmanagement/DocumentType.inc @@ -112,7 +112,7 @@ class DocumentType extends KTEntity { function _fieldValues () { return array( 'name' => $this->sName, - 'disabled' => $this->bDisabled, + 'disabled' => $this->bDisabled, ); } @@ -148,6 +148,16 @@ class DocumentType extends KTEntity { } return false; } + + /* + Get the fieldsets associated with this document type. + Simplifies listing associated fieldsets in doctypes displays. + */ + + function &getFieldsets() { + return KTFieldset::getForDocumentType($this); + } + /** * Static function. diff --git a/lib/metadata/fieldset.inc.php b/lib/metadata/fieldset.inc.php index 90601fe..af428fc 100644 --- a/lib/metadata/fieldset.inc.php +++ b/lib/metadata/fieldset.inc.php @@ -99,23 +99,59 @@ class KTFieldset extends KTEntity { "bIsSystem" => "is_system", ); - // returns TRUE if all children are lookup enabled, false otherwise. - function canBeMadeConditional() { - if ($this->getIsConditional()) { - return false; - } - - // DEBUG - return false; + // returns TRUE if all children are lookup enabled, false otherwise. + function canBeMadeConditional() { + if ($this->getIsConditional()) { + return false; } + + // DEBUG + return false; + } function _table () { return KTUtil::getTableName('fieldsets'); } + + + + + /* + * get document types using this field + * for listing displays + */ + function &getDocumentTypesUsing($aOptions = null) { + $bIds = KTUtil::arrayGet($aOptions, 'ids'); + + $sTable = KTUtil::getTableName('document_type_fieldsets'); + + $aQuery = array( + "SELECT document_type_id FROM $sTable WHERE fieldset_id = ?", + array($this->getId()), + ); + $aIds = DBUtil::getResultArrayKey($aQuery, 'document_type_id'); + + if ($bIds) { + return $aIds; + } + + $aRet = array(); + foreach ($aIds as $iID) { + $aRet[] =& call_user_func(array('DocumentType', 'get'), $iID); + } + return $aRet; + } + + + + + + + // Static function function &get($iId) { return KTEntityUtil::get('KTFieldset', $iId); } - function &getList($sWhereClause = null) { return KTEntityUtil::getList2('KTFieldset', $sWhereClause); } + function &getList($sWhereClause = null) { return KTEntityUtil::getList2('KTFieldset', $sWhereClause); } function &createFromArray($aOptions) { return KTEntityUtil::createFromArray('KTFieldset', $aOptions); } function &getNonGenericFieldsets($aOptions = null) { @@ -127,10 +163,11 @@ class KTFieldset extends KTEntity { ), $aOptions); } - function &getGenericFieldsets($aOptions = null) { - $aOptions = KTUtil::meldOptions($aOptions, array( - 'multi' => true, - )); + function &getGenericFieldsets($aOptions = null) { + $aOptions = KTUtil::meldOptions( + $aOptions, + array('multi' => true,) + ); return KTEntityUtil::getByDict('KTFieldset', array( 'is_generic' => true, ), $aOptions); diff --git a/lib/validation/dispatchervalidation.inc.php b/lib/validation/dispatchervalidation.inc.php index 32f27dc..069b801 100644 --- a/lib/validation/dispatchervalidation.inc.php +++ b/lib/validation/dispatchervalidation.inc.php @@ -210,6 +210,15 @@ class KTDispatcherValidation { 'message', _kt("An empty string was given")); $this->handleError($aOptions); } + + $iMaxlen = (int)KTUtil::arrayGet($aOptions, 'max_str_len', false); + if($iMaxlen !== false && $iMaxlen !== 0 && strlen($sString) > $iMaxlen) { + $aOptions['message'] = KTUtil::arrayGet($aOptions, + 'max_str_len_message', + _kt("The string is too long: the maximum length in characters is ") . $iMaxlen); + $this->handleError($aOptions); + } + return $sString; } @@ -357,8 +366,7 @@ class KTDispatcherValidation { function validateEntityName($sEntityTypeName, $sName, $aOptions = null) { $aOptions['message'] = KTUtil::arrayGet($aOptions, 'empty_message', _kt("No name was given for this item")); - // FIXME BD: don't you mean $sName = $this->validateString ... - $this->validateString($sName, $aOptions); + $sName = $this->validateString($sName, $aOptions); $aOptions['message'] = KTUtil::arrayGet($aOptions, 'duplicate_message', _kt("An item with this name already exists")); return $this->validateDuplicateName($sEntityTypeName, $sName, $aOptions); } diff --git a/plugins/ktcore/KTFolderActions.php b/plugins/ktcore/KTFolderActions.php index 2058c92..7b1b305 100644 --- a/plugins/ktcore/KTFolderActions.php +++ b/plugins/ktcore/KTFolderActions.php @@ -69,6 +69,11 @@ class KTFolderAddFolderAction extends KTFolderAction { $sFolderName = KTUtil::arrayGet($_REQUEST, 'name'); $aErrorOptions['defaultmessage'] = _kt("No name given"); $sFolderName = $this->oValidator->validateString($sFolderName, $aErrorOptions); + + if(KTFolderUtil::exists($this->oFolder, $sFolderName)) { + $this->errorRedirectToMain(_kt('A folder with that name already exists.'), $aErrorOptions['redirect_to'][1]); + exit(0); + } $this->startTransaction(); diff --git a/plugins/ktcore/admin/userManagement.php b/plugins/ktcore/admin/userManagement.php index b9da91c..ace3a34 100755 --- a/plugins/ktcore/admin/userManagement.php +++ b/plugins/ktcore/admin/userManagement.php @@ -89,7 +89,7 @@ class KTUserAdminDispatcher extends KTAdminDispatcher { function do_addUser() { $this->aBreadcrumbs[] = array('url' => $_SERVER['PHP_SELF'], 'name' => _kt('User Management')); $this->oPage->setBreadcrumbDetails(_kt('add a new user')); - $this->oPage->setTitle(_kt("Modify User Details")); + $this->oPage->setTitle(_kt("Add New User")); $name = KTUtil::arrayGet($_REQUEST, 'name'); $show_all = KTUtil::arrayGet($_REQUEST, 'show_all', false); @@ -110,7 +110,7 @@ class KTUserAdminDispatcher extends KTAdminDispatcher { } $add_fields = array(); - $add_fields[] = new KTStringWidget(_kt('Username'), _kt('The username the user will enter to gain access to KnowledgeTree. e.g. jsmith'), 'username', null, $this->oPage, true, null, null, $aOptions); + $add_fields[] = new KTStringWidget(_kt('Username'), _kt('The username the user will enter to gain access to KnowledgeTree. e.g. jsmith'), 'newusername', null, $this->oPage, true, null, null, $aOptions); $add_fields[] = new KTStringWidget(_kt('Name'), _kt('The full name of the user. This is shown in reports and listings. e.g. John Smith'), 'name', null, $this->oPage, true, null, null, $aOptions); $add_fields[] = new KTStringWidget(_kt('Email Address'), _kt('The email address of the user. Notifications and alerts are mailed to this address if email notifications is set below. e.g. jsmith@acme.com'), 'email_address', null, $this->oPage, false, null, null, $aOptions); $add_fields[] = new KTCheckboxWidget(_kt('Email Notifications'), _kt("If this is specified then the user will have notifications sent to the email address entered above. If it isn't set, then the user will only see notifications on the Dashboard"), 'email_notifications', true, $this->oPage, false, null, null, $aOptions); @@ -142,7 +142,7 @@ class KTUserAdminDispatcher extends KTAdminDispatcher { $this->aBreadcrumbs[] = array('url' => KTUtil::addQueryStringSelf('action=addUser'), 'name' => _kt('add a new user')); $oProvider->aBreadcrumbs = $this->aBreadcrumbs; $oProvider->oPage->setBreadcrumbDetails($oSource->getName()); - $oProvider->oPage->setTitle(_kt("Modify User Details")); + $oProvider->oPage->setTitle(_kt("Add New User")); $oProvider->dispatch(); exit(0); @@ -164,7 +164,7 @@ class KTUserAdminDispatcher extends KTAdminDispatcher { $this->aBreadcrumbs[] = array('name' => $oUser->getName()); $edit_fields = array(); - $edit_fields[] = new KTStringWidget(_kt('Username'), _kt('The username the user will enter to gain access to KnowledgeTree. e.g. jsmith'), 'username', $oUser->getUsername(), $this->oPage, true); + $edit_fields[] = new KTStringWidget(_kt('Username'), _kt('The username the user will enter to gain access to KnowledgeTree. e.g. jsmith'), 'newusername', $oUser->getUsername(), $this->oPage, true); $edit_fields[] = new KTStringWidget(_kt('Name'), _kt('The full name of the user. This is shown in reports and listings. e.g. John Smith'), 'name', $oUser->getName(), $this->oPage, true); $edit_fields[] = new KTStringWidget(_kt('Email Address'), _kt('The email address of the user. Notifications and alerts are mailed to this address if email notifications is set below. e.g. jsmith@acme.com'), 'email_address', $oUser->getEmail(), $this->oPage, false); $edit_fields[] = new KTCheckboxWidget(_kt('Email Notifications'), _kt('If this is specified then the user will have notifications sent to the email address entered above. If it is not set, then the user will only see notifications on the Dashboard'), 'email_notifications', $oUser->getEmailNotification(), $this->oPage, false); @@ -351,7 +351,7 @@ class KTUserAdminDispatcher extends KTAdminDispatcher { ); $username = $this->oValidator->validateString( - KTUtil::arrayGet($_REQUEST, 'username'), + KTUtil::arrayGet($_REQUEST, 'newusername'), KTUtil::meldOptions($aErrorOptions, array('message' => _kt("You must provide a username"))) ); @@ -404,7 +404,7 @@ class KTUserAdminDispatcher extends KTAdminDispatcher { $name = KTUtil::arrayGet($_REQUEST, 'name'); if (empty($name)) { $this->errorRedirectTo('addUser', _kt('You must specify a name for the user.')); } - $username = KTUtil::arrayGet($_REQUEST, 'username'); + $username = KTUtil::arrayGet($_REQUEST, 'newusername'); if (empty($name)) { $this->errorRedirectTo('addUser', _kt('You must specify a new username.')); } // FIXME check for non-clashing usernames. diff --git a/plugins/ktcore/folder/Rename.php b/plugins/ktcore/folder/Rename.php index 32c0dd3..0f511e7 100644 --- a/plugins/ktcore/folder/Rename.php +++ b/plugins/ktcore/folder/Rename.php @@ -64,20 +64,32 @@ class KTFolderRenameAction extends KTFolderAction { } function do_rename() { - $sName = KTUtil::arrayGet($_REQUEST, 'foldername'); - $aOptions = array( + $aErrorOptions = array( 'redirect_to' => array('', sprintf('fFolderId=%d', $this->oFolder->getId())), - 'message' => _kt("No folder name given"), ); - $this->oValidator->validateString($sName, $aOptions); + $sFolderName = KTUtil::arrayGet($_REQUEST, 'foldername'); + $aErrorOptions['defaultmessage'] = _kt("No folder name given"); + $sFolderName = $this->oValidator->validateString($sFolderName, $aErrorOptions); + + $oParentFolder =& Folder::get($this->oFolder->iParentID); + if(PEAR::isError($oParentFolder)) { + $this->errorRedirectToMain(_kt('Unable to retrieve parent folder.'), $aErrorOptions['redirect_to'][1]); + exit(0); + } + + if(KTFolderUtil::exists($oParentFolder, $sFolderName)) { + $this->errorRedirectToMain(_kt('A folder with that name already exists.'), $aErrorOptions['redirect_to'][1]); + exit(0); + } + + $res = KTFolderUtil::rename($this->oFolder, $sFolderName, $this->oUser); - $res = KTFolderUtil::rename($this->oFolder, $sName, $this->oUser); if (PEAR::isError($res)) { $_SESSION['KTErrorMessage'][] = $res->getMessage(); redirect(KTBrowseUtil::getUrlForFolder($this->oFolder)); exit(0); } else { - $_SESSION['KTInfoMessage'][] = sprintf(_kt('Folder "%s" renamed to "%s".'), $this->oFolder->getName(), $sName); + $_SESSION['KTInfoMessage'][] = sprintf(_kt('Folder "%s" renamed to "%s".'), $this->oFolder->getName(), $sFolderName); } $this->commitTransaction(); diff --git a/plugins/ktcore/folder/addDocument.php b/plugins/ktcore/folder/addDocument.php index 3ef1cfc..1c7afbd 100644 --- a/plugins/ktcore/folder/addDocument.php +++ b/plugins/ktcore/folder/addDocument.php @@ -115,6 +115,7 @@ class KTFolderAddDocumentAction extends KTFolderAction { $aErrorOptions = array( 'redirect_to' => array('main', sprintf('fFolderId=%d', $this->oFolder->getId())), + 'max_str_len' => 200, ); $aFile = $this->oValidator->validateFile($_FILES['file'], $aErrorOptions); diff --git a/templates/ktcore/documenttypes/list.smarty b/templates/ktcore/documenttypes/list.smarty index dd0b86c..32fac8d 100644 --- a/templates/ktcore/documenttypes/list.smarty +++ b/templates/ktcore/documenttypes/list.smarty @@ -31,8 +31,9 @@ system.{/i18n}

- {i18n}Document Type{/i18n} - {i18n}Fieldsets{/i18n} + {i18n}Document Type{/i18n} + {i18n}Associated Fieldsets{/i18n} +   @@ -43,9 +44,25 @@ system.{/i18n}

{ $oDocumentType->getName() } - + +{assign var="aFieldsets" value=$oDocumentType->getFieldsets()} +{if $aFieldsets} + +{foreach from=$aFieldsets item=oFieldset name=fieldsets} + + {capture assign=fsid}{$oFieldset->getId()}{/capture} +{$oFieldset->getName()}{if (!$smarty.foreach.fieldsets.last)}, {/if} + +{/foreach} + +{else} +— +{/if} + + + {i18n}Edit{/i18n} diff --git a/templates/ktcore/metadata/listFieldsets.smarty b/templates/ktcore/metadata/listFieldsets.smarty index 1d3179f..e55f8ec 100644 --- a/templates/ktcore/metadata/listFieldsets.smarty +++ b/templates/ktcore/metadata/listFieldsets.smarty @@ -9,12 +9,12 @@ {i18n}Name{/i18n} - {i18n}Is Generic{/i18n} - {i18n}Is System{/i18n} + {i18n}Generic{/i18n} + {i18n}System{/i18n} {i18n}Fields{/i18n} - {i18n}Edit{/i18n} - {i18n}Delete{/i18n} - {i18n}Document Types using this Fieldset{/i18n} + {i18n}Document Types{/i18n} + {i18n}Edit{/i18n} + {i18n}Delete{/i18n} @@ -50,6 +50,23 @@ — {/if} + + +{assign var="aDocumentTypes" value=$oFieldset->getDocumentTypesUsing()} +{if $aDocumentTypes} + +{foreach from=$aDocumentTypes item=oDocumentType name=doctypes} + + {capture assign=docid}{$oDocumentType->getId()}{/capture} +{$oDocumentType->getName()}{if (!$smarty.foreach.doctypes.last)}, {/if} + +{/foreach} + +{else} +— +{/if} + + {i18n}Edit{/i18n}