Commit 5edc0caa81f334900e110041d4838d722ea7bf4e
1 parent
e6ac28f9
Bryn Divey 2006-04-07 Fixed add user form to not display login credentials
Bryn Divey 2006-04-07 Added lists of fieldsets used to documents, and do... Bryn Divey 2006-04-07 Added max_str_len to dispatcher validation. Added ... Bryn Divey 2006-03-30 Fixed folder duplicate bug git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@5267 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
11 changed files
with
307 additions
and
192 deletions
config/config.ini
| ... | ... | @@ -140,7 +140,12 @@ uiUrl = ${rootUrl}/presentation/lookAndFeel/knowledgeTree |
| 140 | 140 | [session] |
| 141 | 141 | ; session timeout (in seconds) |
| 142 | 142 | sessionTimeout = 1200 |
| 143 | -allowAnonymousLogin = true | |
| 143 | + | |
| 144 | +; by default, do not auto-login users as anonymous. | |
| 145 | +; set this to true if you UNDERSTAND the security system that KT | |
| 146 | +; uses, and have sensibly applied the roles "Everyone" and "Authenticated Users". | |
| 147 | +allowAnonymousLogin = false | |
| 148 | + | |
| 144 | 149 | ; Set to true to force sessions to come from the same IP address |
| 145 | 150 | ; ipTracking = false |
| 146 | 151 | ... | ... |
edit.php
| ... | ... | @@ -128,9 +128,9 @@ class KTEditDocumentDispatcher extends KTStandardDispatcher { |
| 128 | 128 | exit(0); |
| 129 | 129 | } |
| 130 | 130 | |
| 131 | - function do_selectType() { | |
| 131 | + function do_selectType() { | |
| 132 | 132 | |
| 133 | - $document_id = KTUtil::arrayGet($_REQUEST, 'fDocumentId'); | |
| 133 | + $document_id = KTUtil::arrayGet($_REQUEST, 'fDocumentId'); | |
| 134 | 134 | if (empty($document_id)) { |
| 135 | 135 | $this->errorPage(_kt("No document specified for editing.")); |
| 136 | 136 | } |
| ... | ... | @@ -139,14 +139,14 @@ class KTEditDocumentDispatcher extends KTStandardDispatcher { |
| 139 | 139 | $this->errorPage(_kt("Invalid Document.")); |
| 140 | 140 | } |
| 141 | 141 | |
| 142 | - $this->oDocument = $oDocument; | |
| 143 | - $this->addPortlets("Edit"); | |
| 144 | - $this->addBreadcrumbs(); | |
| 145 | - $this->oPage->setBreadcrumbDetails(_kt('Change Document Type')); | |
| 146 | - | |
| 147 | - $aDocTypes = DocumentType::getList(); | |
| 148 | - | |
| 149 | - | |
| 142 | + $this->oDocument = $oDocument; | |
| 143 | + $this->addPortlets("Edit"); | |
| 144 | + $this->addBreadcrumbs(); | |
| 145 | + $this->oPage->setBreadcrumbDetails(_kt('Change Document Type')); | |
| 146 | + | |
| 147 | + $aDocTypes = DocumentType::getList(); | |
| 148 | + | |
| 149 | + | |
| 150 | 150 | $aDocTypes = array(); |
| 151 | 151 | foreach (DocumentType::getList() as $oDocumentType) { |
| 152 | 152 | if(!$oDocumentType->getDisabled()) { |
| ... | ... | @@ -154,47 +154,47 @@ class KTEditDocumentDispatcher extends KTStandardDispatcher { |
| 154 | 154 | } |
| 155 | 155 | } |
| 156 | 156 | |
| 157 | - $oDocumentType = DocumentType::get($oDocument->getDocumentTypeID()); | |
| 158 | - | |
| 159 | - $oTemplating =& KTTemplating::getSingleton(); | |
| 157 | + $oDocumentType = DocumentType::get($oDocument->getDocumentTypeID()); | |
| 158 | + | |
| 159 | + $oTemplating =& KTTemplating::getSingleton(); | |
| 160 | 160 | $oTemplate =& $oTemplating->loadTemplate("ktcore/document/change_type"); |
| 161 | 161 | $aTemplateData = array( |
| 162 | 162 | 'context' => $this, |
| 163 | 163 | 'document' => $oDocument, |
| 164 | - 'document_type' => $oDocumentType, | |
| 165 | - 'doctypes' => $aDocTypes, | |
| 166 | - ); | |
| 164 | + 'document_type' => $oDocumentType, | |
| 165 | + 'doctypes' => $aDocTypes, | |
| 166 | + ); | |
| 167 | 167 | $oTemplate->setData($aTemplateData); |
| 168 | 168 | return $oTemplate->render(); |
| 169 | - } | |
| 169 | + } | |
| 170 | 170 | |
| 171 | - function do_changeType() { | |
| 172 | - // FIXME this could do with more postTriggers, etc. | |
| 173 | - | |
| 174 | - /* The basic procedure is: | |
| 175 | - * | |
| 176 | - * 1. find out what fieldsets we _have_ | |
| 177 | - * 2. find out what fieldsets we _should_ have. | |
| 178 | - * 3. actively delete fieldsets we need to lose. | |
| 179 | - * 4. run the edit script. | |
| 180 | - */ | |
| 181 | - $newType = KTUtil::arrayGet($_REQUEST, 'fDocType'); | |
| 182 | - $oType = DocumentType::get($newType); | |
| 183 | - if (PEAR::isError($oType) || ($oType == false)) { | |
| 184 | - $this->errorRedirectToMain(_kt("Invalid type selected.")); | |
| 185 | - } | |
| 186 | - | |
| 187 | - $_SESSION['KTInfoMessage'][] = _kt('Document Type Changed. Please review the information below, and update as appropriate.'); | |
| 188 | - | |
| 189 | - $_REQUEST['setType'] = $newType; | |
| 190 | - | |
| 191 | - return $this->do_main($newType); | |
| 171 | + function do_changeType() { | |
| 172 | + // FIXME this could do with more postTriggers, etc. | |
| 173 | + | |
| 174 | + /* The basic procedure is: | |
| 175 | + * | |
| 176 | + * 1. find out what fieldsets we _have_ | |
| 177 | + * 2. find out what fieldsets we _should_ have. | |
| 178 | + * 3. actively delete fieldsets we need to lose. | |
| 179 | + * 4. run the edit script. | |
| 180 | + */ | |
| 181 | + $newType = KTUtil::arrayGet($_REQUEST, 'fDocType'); | |
| 182 | + $oType = DocumentType::get($newType); | |
| 183 | + if (PEAR::isError($oType) || ($oType == false)) { | |
| 184 | + $this->errorRedirectToMain(_kt("Invalid type selected.")); | |
| 185 | + } | |
| 186 | + | |
| 187 | + $_SESSION['KTInfoMessage'][] = _kt('Document Type Changed. Please review the information below, and update as appropriate.'); | |
| 188 | + $_REQUEST['setType'] = $newType; | |
| 189 | + | |
| 190 | + return $this->do_main($newType); | |
| 192 | 191 | } |
| 193 | 192 | |
| 194 | - // "standard document editing" | |
| 195 | - function do_main($newType=false) { | |
| 196 | - $this->oPage->setBreadcrumbDetails("edit"); | |
| 197 | 193 | |
| 194 | + // "standard document editing" | |
| 195 | + function do_main($newType=false) { | |
| 196 | + $this->oPage->setBreadcrumbDetails("edit"); | |
| 197 | + | |
| 198 | 198 | $document_id = KTUtil::arrayGet($_REQUEST, 'fDocumentId'); |
| 199 | 199 | if (empty($document_id)) { |
| 200 | 200 | $this->errorPage(_kt("No document specified for editing.")); |
| ... | ... | @@ -263,12 +263,13 @@ class KTEditDocumentDispatcher extends KTStandardDispatcher { |
| 263 | 263 | return $oTemplate->render(); |
| 264 | 264 | } |
| 265 | 265 | |
| 266 | - function do_update() { | |
| 266 | + function do_update() { | |
| 267 | 267 | $document_id = KTUtil::arrayGet($_REQUEST, 'fDocumentId'); |
| 268 | 268 | if (empty($document_id)) { |
| 269 | 269 | $this->errorPage(_kt("No document specified for editing.")); |
| 270 | 270 | } |
| 271 | - $oDocument = Document::get($document_id); | |
| 271 | + | |
| 272 | + $oDocument = Document::get($document_id); | |
| 272 | 273 | if (PEAR::isError($oDocument)) { |
| 273 | 274 | $this->errorPage(_kt("Invalid Document.")); |
| 274 | 275 | } |
| ... | ... | @@ -276,20 +277,21 @@ class KTEditDocumentDispatcher extends KTStandardDispatcher { |
| 276 | 277 | $aErrorOptions = array( |
| 277 | 278 | 'redirect_to' => array('main', sprintf('fDocumentId=%d', $oDocument->getId())), |
| 278 | 279 | 'message' => _kt('No name given'), |
| 280 | + 'max_str_len' => 200, | |
| 279 | 281 | ); |
| 282 | + | |
| 280 | 283 | $title = KTUtil::arrayGet($_REQUEST, 'generic_title'); |
| 281 | - $title = $this->oValidator->validateString($title, | |
| 282 | - $aErrorOptions); | |
| 284 | + $title = $this->oValidator->validateString($title, $aErrorOptions); | |
| 283 | 285 | |
| 284 | - $newType = KTUtil::arrayGet($_REQUEST, 'newType'); | |
| 285 | - if ($newType !== null) { | |
| 286 | - $oDT = DocumentType::get($newType); | |
| 287 | - if (PEAR::isError($oDT) || ($oDT == false)) { | |
| 288 | - $this->errorRedirectToMain(_kt('Invalid document type specified for change.')); | |
| 289 | - } | |
| 290 | - } else { | |
| 291 | - $oDT = null; | |
| 292 | - } | |
| 286 | + $newType = KTUtil::arrayGet($_REQUEST, 'newType'); | |
| 287 | + if ($newType !== null) { | |
| 288 | + $oDT = DocumentType::get($newType); | |
| 289 | + if (PEAR::isError($oDT) || ($oDT == false)) { | |
| 290 | + $this->errorRedirectToMain(_kt('Invalid document type specified for change.')); | |
| 291 | + } | |
| 292 | + } else { | |
| 293 | + $oDT = null; | |
| 294 | + } | |
| 293 | 295 | |
| 294 | 296 | $this->oDocument = $oDocument; |
| 295 | 297 | $this->oFolder = Folder::get($oDocument->getFolderId()); // FIXME do we need to check that this is valid? |
| ... | ... | @@ -317,115 +319,116 @@ class KTEditDocumentDispatcher extends KTStandardDispatcher { |
| 317 | 319 | } |
| 318 | 320 | |
| 319 | 321 | // erk. we need all the items that the document _does_ need, _and_ what they have, |
| 320 | - // _and_ what they don't ... | |
| 322 | + // _and_ what they don't ... | |
| 321 | 323 | // we want to grab all the md for this doc, since its faster that way. |
| 322 | - $current_md =& DocumentFieldLink::getByDocument($document_id); | |
| 323 | - | |
| 324 | - // to get all fields, we merge repeatedly from KTFieldset::get | |
| 325 | - | |
| 326 | - $field_values = array(); | |
| 327 | - foreach ($fieldsets as $oFieldSet) { | |
| 328 | - $fields =& $oFieldSet->getFields(); | |
| 329 | - | |
| 330 | - // FIXME this doesn't handle multi-fieldset fields - are they possible/meaningful? | |
| 331 | - foreach ($fields as $oField) { | |
| 332 | - $field_values[$oField->getID()] = array($oField, null); | |
| 333 | - } | |
| 334 | - } | |
| 324 | + $current_md =& DocumentFieldLink::getByDocument($document_id); | |
| 325 | + | |
| 326 | + // to get all fields, we merge repeatedly from KTFieldset::get | |
| 327 | + | |
| 328 | + $field_values = array(); | |
| 329 | + foreach ($fieldsets as $oFieldSet) { | |
| 330 | + $fields =& $oFieldSet->getFields(); | |
| 331 | + | |
| 332 | + // FIXME this doesn't handle multi-fieldset fields - are they possible/meaningful? | |
| 333 | + foreach ($fields as $oField) { | |
| 334 | + $field_values[$oField->getID()] = array($oField, null); | |
| 335 | + } | |
| 336 | + } | |
| 335 | 337 | |
| 336 | 338 | |
| 337 | - foreach ($current_md as $oFieldLink) { | |
| 339 | + foreach ($current_md as $oFieldLink) { | |
| 338 | 340 | $field_values[$oFieldLink->getDocumentFieldID()][1] = $oFieldLink->getValue(); |
| 339 | - } | |
| 340 | - | |
| 341 | - // now, we need the full set of items that this document could contain. | |
| 342 | - | |
| 343 | - // FIXME this DOES NOT WORK for date items. | |
| 344 | - // FIXME that's fine - we don't use range items here... | |
| 345 | - $expect_vals = KTUtil::arrayGet($_REQUEST,'kt_core_fieldsets_expect'); | |
| 346 | - | |
| 347 | - foreach ($field_values as $key => $val) { | |
| 348 | - $newVal = KTUtil::arrayGet($_REQUEST, 'metadata_' . $key, null); | |
| 349 | - $wantVal = KTUtil::arrayGet($expect_vals, 'metadata_' . $key, false); | |
| 350 | - | |
| 351 | - // FIXME this leaves no way to check if someone has actually removed the item. | |
| 352 | - // FIXME we probably want to _not_ set anything that could be set ... but then how do you | |
| 353 | - // FIXME know about managed values ... | |
| 354 | - | |
| 355 | - if ($newVal !== null) { | |
| 356 | - $field_values[$key][1] = $newVal; // need the items themselves. | |
| 357 | - } else if ($wantVal !== false) { | |
| 358 | - // we sent it out, delete it. | |
| 359 | - | |
| 360 | - unset($field_values[$key]); | |
| 361 | - } | |
| 362 | - } | |
| 363 | - | |
| 364 | - | |
| 365 | - // finally, we need to pass through and remove null entries (sigh) | |
| 366 | - // FIXME alternatively we could build a new set, but that might break stuff? | |
| 341 | + } | |
| 342 | + | |
| 343 | + | |
| 344 | + // now, we need the full set of items that this document could contain. | |
| 345 | + | |
| 346 | + // FIXME this DOES NOT WORK for date items. | |
| 347 | + // FIXME that's fine - we don't use range items here... | |
| 348 | + $expect_vals = KTUtil::arrayGet($_REQUEST,'kt_core_fieldsets_expect'); | |
| 349 | + | |
| 350 | + foreach ($field_values as $key => $val) { | |
| 351 | + $newVal = KTUtil::arrayGet($_REQUEST, 'metadata_' . $key, null); | |
| 352 | + $wantVal = KTUtil::arrayGet($expect_vals, 'metadata_' . $key, false); | |
| 353 | + | |
| 354 | + // FIXME this leaves no way to check if someone has actually removed the item. | |
| 355 | + // FIXME we probably want to _not_ set anything that could be set ... but then how do you | |
| 356 | + // FIXME know about managed values ... | |
| 357 | + | |
| 358 | + if ($newVal !== null) { | |
| 359 | + $field_values[$key][1] = $newVal; // need the items themselves. | |
| 360 | + } else if ($wantVal !== false) { | |
| 361 | + // we sent it out, delete it. | |
| 362 | + | |
| 363 | + unset($field_values[$key]); | |
| 364 | + } | |
| 365 | + } | |
| 367 | 366 | |
| 368 | - $final_values = array(); | |
| 369 | - foreach ($field_values as $aMDPack) { | |
| 370 | - if ($aMDPack[1] !== null) { | |
| 371 | - $final_values[] = $aMDPack; | |
| 372 | - } | |
| 367 | + | |
| 368 | + // finally, we need to pass through and remove null entries (sigh) | |
| 369 | + // FIXME alternatively we could build a new set, but that might break stuff? | |
| 370 | + | |
| 371 | + $final_values = array(); | |
| 372 | + foreach ($field_values as $aMDPack) { | |
| 373 | + if ($aMDPack[1] !== null) { | |
| 374 | + $final_values[] = $aMDPack; | |
| 375 | + } | |
| 376 | + } | |
| 377 | + $field_values = $final_values; | |
| 378 | + | |
| 379 | + // FIXME handle md versions. | |
| 380 | + //return '<pre>' . print_r($field_values, true) . '</pre>'; | |
| 381 | + $this->startTransaction(); | |
| 382 | + $iPreviousMetadataVersionId = $oDocument->getMetadataVersionId(); | |
| 383 | + $oDocument->startNewMetadataVersion($this->oUser); | |
| 384 | + if (PEAR::isError($res)) { | |
| 385 | + $this->errorRedirectToMain('Unable to create a metadata version of the document.'); | |
| 386 | + } | |
| 387 | + | |
| 388 | + $oDocument->setName($title); | |
| 389 | + $oDocument->setLastModifiedDate(getCurrentDateTime()); | |
| 390 | + $oDocument->setModifiedUserId($this->oUser->getId()); | |
| 391 | + | |
| 392 | + // FIXME refactor this into documentutil. | |
| 393 | + // document type changing semantics | |
| 394 | + if ($newType != null) { | |
| 395 | + $oldType = DocumentType::get($oDocument->getDocumentTypeID()); | |
| 396 | + $oDocument->setDocumentTypeID($newType); | |
| 397 | + | |
| 398 | + // we need to find fieldsets that _were_ in the old one, and _delete_ those. | |
| 399 | + $for_delete = array(); | |
| 400 | + | |
| 401 | + $oldFieldsets = KTFieldset::getForDocumentType($oldType); | |
| 402 | + $newFieldsets = KTFieldset::getForDocumentType($newType); | |
| 403 | + | |
| 404 | + // prune from MDPack. | |
| 405 | + foreach ($oldFieldsets as $oFieldset) { | |
| 406 | + $old_fields = $oFieldset->getFields(); | |
| 407 | + foreach ($old_fields as $oField) { | |
| 408 | + $for_delete[$oField->getId()] = 1; | |
| 373 | 409 | } |
| 374 | - $field_values = $final_values; | |
| 375 | - | |
| 376 | - // FIXME handle md versions. | |
| 377 | - //return '<pre>' . print_r($field_values, true) . '</pre>'; | |
| 378 | - $this->startTransaction(); | |
| 379 | - $iPreviousMetadataVersionId = $oDocument->getMetadataVersionId(); | |
| 380 | - $oDocument->startNewMetadataVersion($this->oUser); | |
| 381 | - if (PEAR::isError($res)) { | |
| 382 | - $this->errorRedirectToMain('Unable to create a metadata version of the document.'); | |
| 410 | + } | |
| 411 | + | |
| 412 | + foreach ($newFieldsets as $oFieldset) { | |
| 413 | + $new_fields = $oFieldset->getFields(); | |
| 414 | + foreach ($new_fields as $oField) { | |
| 415 | + unset($for_delete[$oField->getId()]); | |
| 383 | 416 | } |
| 384 | - | |
| 385 | - $oDocument->setName($title); | |
| 386 | - $oDocument->setLastModifiedDate(getCurrentDateTime()); | |
| 387 | - $oDocument->setModifiedUserId($this->oUser->getId()); | |
| 388 | - | |
| 389 | - // FIXME refactor this into documentutil. | |
| 390 | - // document type changing semantics | |
| 391 | - if ($newType != null) { | |
| 392 | - $oldType = DocumentType::get($oDocument->getDocumentTypeID()); | |
| 393 | - $oDocument->setDocumentTypeID($newType); | |
| 394 | - | |
| 395 | - // we need to find fieldsets that _were_ in the old one, and _delete_ those. | |
| 396 | - $for_delete = array(); | |
| 397 | - | |
| 398 | - $oldFieldsets = KTFieldset::getForDocumentType($oldType); | |
| 399 | - $newFieldsets = KTFieldset::getForDocumentType($newType); | |
| 400 | - | |
| 401 | - // prune from MDPack. | |
| 402 | - foreach ($oldFieldsets as $oFieldset) { | |
| 403 | - $old_fields = $oFieldset->getFields(); | |
| 404 | - foreach ($old_fields as $oField) { | |
| 405 | - $for_delete[$oField->getId()] = 1; | |
| 406 | - } | |
| 407 | - } | |
| 408 | - | |
| 409 | - foreach ($newFieldsets as $oFieldset) { | |
| 410 | - $new_fields = $oFieldset->getFields(); | |
| 411 | - foreach ($new_fields as $oField) { | |
| 412 | - unset($for_delete[$oField->getId()]); | |
| 413 | - } | |
| 414 | - } | |
| 415 | - | |
| 416 | - $newPack = array(); | |
| 417 | - foreach ($field_values as $MDPack) { | |
| 418 | - if (!array_key_exists($MDPack[0]->getId(), $for_delete)) { | |
| 419 | - $newPack[] = $MDPack; | |
| 420 | - } | |
| 421 | - } | |
| 422 | - $field_values = $newPack; | |
| 423 | - | |
| 424 | - | |
| 425 | - //var_dump($field_values); | |
| 426 | - //exit(0); | |
| 417 | + } | |
| 418 | + | |
| 419 | + $newPack = array(); | |
| 420 | + foreach ($field_values as $MDPack) { | |
| 421 | + if (!array_key_exists($MDPack[0]->getId(), $for_delete)) { | |
| 422 | + $newPack[] = $MDPack; | |
| 427 | 423 | } |
| 428 | - | |
| 424 | + } | |
| 425 | + $field_values = $newPack; | |
| 426 | + | |
| 427 | + | |
| 428 | + //var_dump($field_values); | |
| 429 | + //exit(0); | |
| 430 | + } | |
| 431 | + | |
| 429 | 432 | $oDocumentTransaction = & new DocumentTransaction($oDocument, 'update metadata.', 'ktcore.transactions.update'); |
| 430 | 433 | |
| 431 | 434 | $res = $oDocumentTransaction->create(); | ... | ... |
lib/documentmanagement/DocumentType.inc
| ... | ... | @@ -112,7 +112,7 @@ class DocumentType extends KTEntity { |
| 112 | 112 | function _fieldValues () { |
| 113 | 113 | return array( |
| 114 | 114 | 'name' => $this->sName, |
| 115 | - 'disabled' => $this->bDisabled, | |
| 115 | + 'disabled' => $this->bDisabled, | |
| 116 | 116 | ); |
| 117 | 117 | } |
| 118 | 118 | |
| ... | ... | @@ -148,6 +148,16 @@ class DocumentType extends KTEntity { |
| 148 | 148 | } |
| 149 | 149 | return false; |
| 150 | 150 | } |
| 151 | + | |
| 152 | + /* | |
| 153 | + Get the fieldsets associated with this document type. | |
| 154 | + Simplifies listing associated fieldsets in doctypes displays. | |
| 155 | + */ | |
| 156 | + | |
| 157 | + function &getFieldsets() { | |
| 158 | + return KTFieldset::getForDocumentType($this); | |
| 159 | + } | |
| 160 | + | |
| 151 | 161 | |
| 152 | 162 | /** |
| 153 | 163 | * Static function. | ... | ... |
lib/metadata/fieldset.inc.php
| ... | ... | @@ -99,23 +99,59 @@ class KTFieldset extends KTEntity { |
| 99 | 99 | "bIsSystem" => "is_system", |
| 100 | 100 | ); |
| 101 | 101 | |
| 102 | - // returns TRUE if all children are lookup enabled, false otherwise. | |
| 103 | - function canBeMadeConditional() { | |
| 104 | - if ($this->getIsConditional()) { | |
| 105 | - return false; | |
| 106 | - } | |
| 107 | - | |
| 108 | - // DEBUG | |
| 109 | - return false; | |
| 102 | + // returns TRUE if all children are lookup enabled, false otherwise. | |
| 103 | + function canBeMadeConditional() { | |
| 104 | + if ($this->getIsConditional()) { | |
| 105 | + return false; | |
| 110 | 106 | } |
| 107 | + | |
| 108 | + // DEBUG | |
| 109 | + return false; | |
| 110 | + } | |
| 111 | 111 | |
| 112 | 112 | function _table () { |
| 113 | 113 | return KTUtil::getTableName('fieldsets'); |
| 114 | 114 | } |
| 115 | 115 | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + /* | |
| 121 | + * get document types using this field | |
| 122 | + * for listing displays | |
| 123 | + */ | |
| 124 | + function &getDocumentTypesUsing($aOptions = null) { | |
| 125 | + $bIds = KTUtil::arrayGet($aOptions, 'ids'); | |
| 126 | + | |
| 127 | + $sTable = KTUtil::getTableName('document_type_fieldsets'); | |
| 128 | + | |
| 129 | + $aQuery = array( | |
| 130 | + "SELECT document_type_id FROM $sTable WHERE fieldset_id = ?", | |
| 131 | + array($this->getId()), | |
| 132 | + ); | |
| 133 | + $aIds = DBUtil::getResultArrayKey($aQuery, 'document_type_id'); | |
| 134 | + | |
| 135 | + if ($bIds) { | |
| 136 | + return $aIds; | |
| 137 | + } | |
| 138 | + | |
| 139 | + $aRet = array(); | |
| 140 | + foreach ($aIds as $iID) { | |
| 141 | + $aRet[] =& call_user_func(array('DocumentType', 'get'), $iID); | |
| 142 | + } | |
| 143 | + return $aRet; | |
| 144 | + } | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 116 | 152 | // Static function |
| 117 | 153 | function &get($iId) { return KTEntityUtil::get('KTFieldset', $iId); } |
| 118 | - function &getList($sWhereClause = null) { return KTEntityUtil::getList2('KTFieldset', $sWhereClause); } | |
| 154 | + function &getList($sWhereClause = null) { return KTEntityUtil::getList2('KTFieldset', $sWhereClause); } | |
| 119 | 155 | function &createFromArray($aOptions) { return KTEntityUtil::createFromArray('KTFieldset', $aOptions); } |
| 120 | 156 | |
| 121 | 157 | function &getNonGenericFieldsets($aOptions = null) { |
| ... | ... | @@ -127,10 +163,11 @@ class KTFieldset extends KTEntity { |
| 127 | 163 | ), $aOptions); |
| 128 | 164 | } |
| 129 | 165 | |
| 130 | - function &getGenericFieldsets($aOptions = null) { | |
| 131 | - $aOptions = KTUtil::meldOptions($aOptions, array( | |
| 132 | - 'multi' => true, | |
| 133 | - )); | |
| 166 | + function &getGenericFieldsets($aOptions = null) { | |
| 167 | + $aOptions = KTUtil::meldOptions( | |
| 168 | + $aOptions, | |
| 169 | + array('multi' => true,) | |
| 170 | + ); | |
| 134 | 171 | return KTEntityUtil::getByDict('KTFieldset', array( |
| 135 | 172 | 'is_generic' => true, |
| 136 | 173 | ), $aOptions); | ... | ... |
lib/validation/dispatchervalidation.inc.php
| ... | ... | @@ -210,6 +210,15 @@ class KTDispatcherValidation { |
| 210 | 210 | 'message', _kt("An empty string was given")); |
| 211 | 211 | $this->handleError($aOptions); |
| 212 | 212 | } |
| 213 | + | |
| 214 | + $iMaxlen = (int)KTUtil::arrayGet($aOptions, 'max_str_len', false); | |
| 215 | + if($iMaxlen !== false && $iMaxlen !== 0 && strlen($sString) > $iMaxlen) { | |
| 216 | + $aOptions['message'] = KTUtil::arrayGet($aOptions, | |
| 217 | + 'max_str_len_message', | |
| 218 | + _kt("The string is too long: the maximum length in characters is ") . $iMaxlen); | |
| 219 | + $this->handleError($aOptions); | |
| 220 | + } | |
| 221 | + | |
| 213 | 222 | return $sString; |
| 214 | 223 | } |
| 215 | 224 | |
| ... | ... | @@ -357,8 +366,7 @@ class KTDispatcherValidation { |
| 357 | 366 | function validateEntityName($sEntityTypeName, $sName, $aOptions = null) { |
| 358 | 367 | $aOptions['message'] = KTUtil::arrayGet($aOptions, 'empty_message', _kt("No name was given for this item")); |
| 359 | 368 | |
| 360 | - // FIXME BD: don't you mean $sName = $this->validateString ... | |
| 361 | - $this->validateString($sName, $aOptions); | |
| 369 | + $sName = $this->validateString($sName, $aOptions); | |
| 362 | 370 | $aOptions['message'] = KTUtil::arrayGet($aOptions, 'duplicate_message', _kt("An item with this name already exists")); |
| 363 | 371 | return $this->validateDuplicateName($sEntityTypeName, $sName, $aOptions); |
| 364 | 372 | } | ... | ... |
plugins/ktcore/KTFolderActions.php
| ... | ... | @@ -69,6 +69,11 @@ class KTFolderAddFolderAction extends KTFolderAction { |
| 69 | 69 | $sFolderName = KTUtil::arrayGet($_REQUEST, 'name'); |
| 70 | 70 | $aErrorOptions['defaultmessage'] = _kt("No name given"); |
| 71 | 71 | $sFolderName = $this->oValidator->validateString($sFolderName, $aErrorOptions); |
| 72 | + | |
| 73 | + if(KTFolderUtil::exists($this->oFolder, $sFolderName)) { | |
| 74 | + $this->errorRedirectToMain(_kt('A folder with that name already exists.'), $aErrorOptions['redirect_to'][1]); | |
| 75 | + exit(0); | |
| 76 | + } | |
| 72 | 77 | |
| 73 | 78 | $this->startTransaction(); |
| 74 | 79 | ... | ... |
plugins/ktcore/admin/userManagement.php
| ... | ... | @@ -89,7 +89,7 @@ class KTUserAdminDispatcher extends KTAdminDispatcher { |
| 89 | 89 | function do_addUser() { |
| 90 | 90 | $this->aBreadcrumbs[] = array('url' => $_SERVER['PHP_SELF'], 'name' => _kt('User Management')); |
| 91 | 91 | $this->oPage->setBreadcrumbDetails(_kt('add a new user')); |
| 92 | - $this->oPage->setTitle(_kt("Modify User Details")); | |
| 92 | + $this->oPage->setTitle(_kt("Add New User")); | |
| 93 | 93 | |
| 94 | 94 | $name = KTUtil::arrayGet($_REQUEST, 'name'); |
| 95 | 95 | $show_all = KTUtil::arrayGet($_REQUEST, 'show_all', false); |
| ... | ... | @@ -110,7 +110,7 @@ class KTUserAdminDispatcher extends KTAdminDispatcher { |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | $add_fields = array(); |
| 113 | - $add_fields[] = new KTStringWidget(_kt('Username'), _kt('The username the user will enter to gain access to KnowledgeTree. e.g. <strong>jsmith</strong>'), 'username', null, $this->oPage, true, null, null, $aOptions); | |
| 113 | + $add_fields[] = new KTStringWidget(_kt('Username'), _kt('The username the user will enter to gain access to KnowledgeTree. e.g. <strong>jsmith</strong>'), 'newusername', null, $this->oPage, true, null, null, $aOptions); | |
| 114 | 114 | $add_fields[] = new KTStringWidget(_kt('Name'), _kt('The full name of the user. This is shown in reports and listings. e.g. <strong>John Smith</strong>'), 'name', null, $this->oPage, true, null, null, $aOptions); |
| 115 | 115 | $add_fields[] = new KTStringWidget(_kt('Email Address'), _kt('The email address of the user. Notifications and alerts are mailed to this address if <strong>email notifications</strong> is set below. e.g. <strong>jsmith@acme.com</strong>'), 'email_address', null, $this->oPage, false, null, null, $aOptions); |
| 116 | 116 | $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 <strong>Dashboard</strong>"), 'email_notifications', true, $this->oPage, false, null, null, $aOptions); |
| ... | ... | @@ -142,7 +142,7 @@ class KTUserAdminDispatcher extends KTAdminDispatcher { |
| 142 | 142 | $this->aBreadcrumbs[] = array('url' => KTUtil::addQueryStringSelf('action=addUser'), 'name' => _kt('add a new user')); |
| 143 | 143 | $oProvider->aBreadcrumbs = $this->aBreadcrumbs; |
| 144 | 144 | $oProvider->oPage->setBreadcrumbDetails($oSource->getName()); |
| 145 | - $oProvider->oPage->setTitle(_kt("Modify User Details")); | |
| 145 | + $oProvider->oPage->setTitle(_kt("Add New User")); | |
| 146 | 146 | |
| 147 | 147 | $oProvider->dispatch(); |
| 148 | 148 | exit(0); |
| ... | ... | @@ -164,7 +164,7 @@ class KTUserAdminDispatcher extends KTAdminDispatcher { |
| 164 | 164 | $this->aBreadcrumbs[] = array('name' => $oUser->getName()); |
| 165 | 165 | |
| 166 | 166 | $edit_fields = array(); |
| 167 | - $edit_fields[] = new KTStringWidget(_kt('Username'), _kt('The username the user will enter to gain access to KnowledgeTree. e.g. <strong>jsmith</strong>'), 'username', $oUser->getUsername(), $this->oPage, true); | |
| 167 | + $edit_fields[] = new KTStringWidget(_kt('Username'), _kt('The username the user will enter to gain access to KnowledgeTree. e.g. <strong>jsmith</strong>'), 'newusername', $oUser->getUsername(), $this->oPage, true); | |
| 168 | 168 | $edit_fields[] = new KTStringWidget(_kt('Name'), _kt('The full name of the user. This is shown in reports and listings. e.g. <strong>John Smith</strong>'), 'name', $oUser->getName(), $this->oPage, true); |
| 169 | 169 | $edit_fields[] = new KTStringWidget(_kt('Email Address'), _kt('The email address of the user. Notifications and alerts are mailed to this address if <strong>email notifications</strong> is set below. e.g. <strong>jsmith@acme.com</strong>'), 'email_address', $oUser->getEmail(), $this->oPage, false); |
| 170 | 170 | $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 <strong>Dashboard</strong>'), 'email_notifications', $oUser->getEmailNotification(), $this->oPage, false); |
| ... | ... | @@ -351,7 +351,7 @@ class KTUserAdminDispatcher extends KTAdminDispatcher { |
| 351 | 351 | ); |
| 352 | 352 | |
| 353 | 353 | $username = $this->oValidator->validateString( |
| 354 | - KTUtil::arrayGet($_REQUEST, 'username'), | |
| 354 | + KTUtil::arrayGet($_REQUEST, 'newusername'), | |
| 355 | 355 | KTUtil::meldOptions($aErrorOptions, array('message' => _kt("You must provide a username"))) |
| 356 | 356 | ); |
| 357 | 357 | |
| ... | ... | @@ -404,7 +404,7 @@ class KTUserAdminDispatcher extends KTAdminDispatcher { |
| 404 | 404 | |
| 405 | 405 | $name = KTUtil::arrayGet($_REQUEST, 'name'); |
| 406 | 406 | if (empty($name)) { $this->errorRedirectTo('addUser', _kt('You must specify a name for the user.')); } |
| 407 | - $username = KTUtil::arrayGet($_REQUEST, 'username'); | |
| 407 | + $username = KTUtil::arrayGet($_REQUEST, 'newusername'); | |
| 408 | 408 | if (empty($name)) { $this->errorRedirectTo('addUser', _kt('You must specify a new username.')); } |
| 409 | 409 | // FIXME check for non-clashing usernames. |
| 410 | 410 | ... | ... |
plugins/ktcore/folder/Rename.php
| ... | ... | @@ -64,20 +64,32 @@ class KTFolderRenameAction extends KTFolderAction { |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | function do_rename() { |
| 67 | - $sName = KTUtil::arrayGet($_REQUEST, 'foldername'); | |
| 68 | - $aOptions = array( | |
| 67 | + $aErrorOptions = array( | |
| 69 | 68 | 'redirect_to' => array('', sprintf('fFolderId=%d', $this->oFolder->getId())), |
| 70 | - 'message' => _kt("No folder name given"), | |
| 71 | 69 | ); |
| 72 | - $this->oValidator->validateString($sName, $aOptions); | |
| 70 | + $sFolderName = KTUtil::arrayGet($_REQUEST, 'foldername'); | |
| 71 | + $aErrorOptions['defaultmessage'] = _kt("No folder name given"); | |
| 72 | + $sFolderName = $this->oValidator->validateString($sFolderName, $aErrorOptions); | |
| 73 | + | |
| 74 | + $oParentFolder =& Folder::get($this->oFolder->iParentID); | |
| 75 | + if(PEAR::isError($oParentFolder)) { | |
| 76 | + $this->errorRedirectToMain(_kt('Unable to retrieve parent folder.'), $aErrorOptions['redirect_to'][1]); | |
| 77 | + exit(0); | |
| 78 | + } | |
| 79 | + | |
| 80 | + if(KTFolderUtil::exists($oParentFolder, $sFolderName)) { | |
| 81 | + $this->errorRedirectToMain(_kt('A folder with that name already exists.'), $aErrorOptions['redirect_to'][1]); | |
| 82 | + exit(0); | |
| 83 | + } | |
| 84 | + | |
| 85 | + $res = KTFolderUtil::rename($this->oFolder, $sFolderName, $this->oUser); | |
| 73 | 86 | |
| 74 | - $res = KTFolderUtil::rename($this->oFolder, $sName, $this->oUser); | |
| 75 | 87 | if (PEAR::isError($res)) { |
| 76 | 88 | $_SESSION['KTErrorMessage'][] = $res->getMessage(); |
| 77 | 89 | redirect(KTBrowseUtil::getUrlForFolder($this->oFolder)); |
| 78 | 90 | exit(0); |
| 79 | 91 | } else { |
| 80 | - $_SESSION['KTInfoMessage'][] = sprintf(_kt('Folder "%s" renamed to "%s".'), $this->oFolder->getName(), $sName); | |
| 92 | + $_SESSION['KTInfoMessage'][] = sprintf(_kt('Folder "%s" renamed to "%s".'), $this->oFolder->getName(), $sFolderName); | |
| 81 | 93 | } |
| 82 | 94 | |
| 83 | 95 | $this->commitTransaction(); | ... | ... |
plugins/ktcore/folder/addDocument.php
| ... | ... | @@ -115,6 +115,7 @@ class KTFolderAddDocumentAction extends KTFolderAction { |
| 115 | 115 | |
| 116 | 116 | $aErrorOptions = array( |
| 117 | 117 | 'redirect_to' => array('main', sprintf('fFolderId=%d', $this->oFolder->getId())), |
| 118 | + 'max_str_len' => 200, | |
| 118 | 119 | ); |
| 119 | 120 | |
| 120 | 121 | $aFile = $this->oValidator->validateFile($_FILES['file'], $aErrorOptions); | ... | ... |
templates/ktcore/documenttypes/list.smarty
| ... | ... | @@ -31,8 +31,9 @@ system.{/i18n}</p> |
| 31 | 31 | |
| 32 | 32 | <thead> |
| 33 | 33 | <tr> |
| 34 | - <th colspan="3">{i18n}Document Type{/i18n}</th> | |
| 35 | - <th>{i18n}Fieldsets{/i18n}</th> | |
| 34 | + <th>{i18n}Document Type{/i18n}</th> | |
| 35 | + <th>{i18n}Associated Fieldsets{/i18n}</th> | |
| 36 | + <th colspan="2"> </th> | |
| 36 | 37 | </tr> |
| 37 | 38 | </thead> |
| 38 | 39 | |
| ... | ... | @@ -43,9 +44,25 @@ system.{/i18n}</p> |
| 43 | 44 | |
| 44 | 45 | <td> |
| 45 | 46 | { $oDocumentType->getName() } |
| 46 | - </a> | |
| 47 | 47 | </td> |
| 48 | 48 | |
| 49 | + <td> | |
| 50 | +{assign var="aFieldsets" value=$oDocumentType->getFieldsets()} | |
| 51 | +{if $aFieldsets} | |
| 52 | + | |
| 53 | +{foreach from=$aFieldsets item=oFieldset name=fieldsets} | |
| 54 | + | |
| 55 | + {capture assign=fsid}{$oFieldset->getId()}{/capture} | |
| 56 | +<a href="{ktLink base="admin.php" subpath="/documents/fieldmanagement" query="action=edit&fFieldsetId=`$fsid`"}">{$oFieldset->getName()}</a>{if (!$smarty.foreach.fieldsets.last)}, {/if} | |
| 57 | + | |
| 58 | +{/foreach} | |
| 59 | + | |
| 60 | +{else} | |
| 61 | +— | |
| 62 | +{/if} | |
| 63 | + </td> | |
| 64 | + | |
| 65 | + | |
| 49 | 66 | <td> |
| 50 | 67 | <a class="ktAction ktEdit" href="{addQS}action=edit&fDocumentTypeId={$oDocumentType->getId()}{/addQS}">{i18n}Edit{/i18n}</a> |
| 51 | 68 | </td> | ... | ... |
templates/ktcore/metadata/listFieldsets.smarty
| ... | ... | @@ -9,12 +9,12 @@ |
| 9 | 9 | <thead> |
| 10 | 10 | <tr> |
| 11 | 11 | <th>{i18n}Name{/i18n}</th> |
| 12 | - <th class="centered">{i18n}Is Generic{/i18n}</th> | |
| 13 | - <th class="centered">{i18n}Is System{/i18n}</th> | |
| 12 | + <th class="centered">{i18n}Generic{/i18n}</th> | |
| 13 | + <th class="centered">{i18n}System{/i18n}</th> | |
| 14 | 14 | <th>{i18n}Fields{/i18n}</th> |
| 15 | - <th>{i18n}Edit{/i18n}</th> | |
| 16 | - <th>{i18n}Delete{/i18n}</th> | |
| 17 | - <th>{i18n}Document Types using this Fieldset{/i18n}</th> | |
| 15 | + <th>{i18n}Document Types{/i18n}</th> | |
| 16 | + <th>{i18n}Edit{/i18n}</th> | |
| 17 | + <th>{i18n}Delete{/i18n}</th> | |
| 18 | 18 | </tr> |
| 19 | 19 | </thead> |
| 20 | 20 | <tbody> |
| ... | ... | @@ -50,6 +50,23 @@ |
| 50 | 50 | — |
| 51 | 51 | {/if} |
| 52 | 52 | </td> |
| 53 | + | |
| 54 | + <td> | |
| 55 | +{assign var="aDocumentTypes" value=$oFieldset->getDocumentTypesUsing()} | |
| 56 | +{if $aDocumentTypes} | |
| 57 | + | |
| 58 | +{foreach from=$aDocumentTypes item=oDocumentType name=doctypes} | |
| 59 | + | |
| 60 | + {capture assign=docid}{$oDocumentType->getId()}{/capture} | |
| 61 | +<a href="{ktLink base="admin.php" subpath="/documents/typemanagement" query="action=edit&fDocumentTypeId=`$docid`"}">{$oDocumentType->getName()}</a>{if (!$smarty.foreach.doctypes.last)}, {/if} | |
| 62 | + | |
| 63 | +{/foreach} | |
| 64 | + | |
| 65 | +{else} | |
| 66 | +— | |
| 67 | +{/if} | |
| 68 | + </td> | |
| 69 | + | |
| 53 | 70 | <td> |
| 54 | 71 | <a href="{addQS}action=edit&fFieldsetId={$oFieldset->getId()}{/addQS}" class="ktAction ktEdit">{i18n}Edit{/i18n}</a> |
| 55 | 72 | </td> | ... | ... |