Commit be8f7020ac61c61f0c01196cab45a10b9900c004
1 parent
4b0338e9
- cleanup checkin, delete
- make move use new form ui. git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@5837 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
4 changed files
with
201 additions
and
146 deletions
plugins/ktcore/KTDocumentActions.php
| @@ -407,69 +407,109 @@ class KTDocumentCheckInAction extends KTDocumentAction { | @@ -407,69 +407,109 @@ class KTDocumentCheckInAction extends KTDocumentAction { | ||
| 407 | return true; | 407 | return true; |
| 408 | } | 408 | } |
| 409 | 409 | ||
| 410 | + | ||
| 411 | + function form_main() { | ||
| 412 | + $oForm = new KTForm; | ||
| 413 | + $oForm->setOptions(array( | ||
| 414 | + 'label' => _kt("Checkin Document"), | ||
| 415 | + 'action' => 'checkin', | ||
| 416 | + 'fail_action' => 'main', | ||
| 417 | + 'cancel_url' => KTBrowseUtil::getUrlForDocument($this->oDocument), | ||
| 418 | + 'submit_label' => _kt("Checkin"), | ||
| 419 | + 'context' => &$this, | ||
| 420 | + 'file_upload' => true, // otherwise the post is not received. | ||
| 421 | + )); | ||
| 422 | + $oForm->setWidgets(array( | ||
| 423 | + array('ktcore.widgets.file', array( | ||
| 424 | + 'label' => _kt("File"), | ||
| 425 | + 'description' => sprintf(_kt('Please specify the file you wish to upload. Unless you also indicate that you are changing its filename (see "Force Original Filename" below), this will need to be called <strong>%s</strong>'), $this->oDocument->getFilename()), | ||
| 426 | + 'name' => 'file', | ||
| 427 | + 'basename' => 'file', | ||
| 428 | + 'required' => true, | ||
| 429 | + )), | ||
| 430 | + array('ktcore.widgets.reason', array( | ||
| 431 | + 'label' => _kt("Reason"), | ||
| 432 | + 'description' => _kt("Please specify why you are cancelling this document's checked-out status. Please bear in mind that you can use a maximum of <strong>250</strong> characters."), | ||
| 433 | + 'name' => 'reason', | ||
| 434 | + )), | ||
| 435 | + array('ktcore.widgets.boolean',array( | ||
| 436 | + 'label' => _kt('Force Original Filename'), | ||
| 437 | + 'description' => sprintf(_kt('If this is checked, the uploaded document must have the same filename as the original: <strong>%s</strong>'), $this->oDocument->getFilename()), | ||
| 438 | + 'name' => 'forcefilename', | ||
| 439 | + 'value' => true, | ||
| 440 | + )), | ||
| 441 | + )); | ||
| 442 | + $oForm->setValidators(array( | ||
| 443 | + array('ktcore.validators.string', array( | ||
| 444 | + 'test' => 'reason', | ||
| 445 | + 'max_length' => 250, | ||
| 446 | + 'output' => 'reason', | ||
| 447 | + )), | ||
| 448 | + array('ktcore.validators.file', array( | ||
| 449 | + 'test' => 'file', | ||
| 450 | + 'output' => 'file', | ||
| 451 | + )), | ||
| 452 | + array('ktcore.validators.boolean', array( | ||
| 453 | + 'test' => 'forcefilename', | ||
| 454 | + 'output' => 'forcefilename', | ||
| 455 | + )), | ||
| 456 | + )); | ||
| 457 | + | ||
| 458 | + return $oForm; | ||
| 459 | + } | ||
| 460 | + | ||
| 461 | + | ||
| 410 | function do_main() { | 462 | function do_main() { |
| 411 | $this->oPage->setBreadcrumbDetails("checkin"); | 463 | $this->oPage->setBreadcrumbDetails("checkin"); |
| 412 | $oTemplate =& $this->oValidator->validateTemplate('ktcore/action/checkin'); | 464 | $oTemplate =& $this->oValidator->validateTemplate('ktcore/action/checkin'); |
| 413 | 465 | ||
| 414 | - $sReason = KTUtil::arrayGet($_REQUEST, 'reason', ""); | ||
| 415 | - $checkin_fields = array(); | ||
| 416 | - $checkin_fields[] = new KTFileUploadWidget(_kt('File'), _kt('The updated document.'), 'file', "", $this->oPage, true); | ||
| 417 | - $checkin_fields[] = new KTStringWidget(_kt('Reason'), _kt('Describe the changes made to the document.'), 'reason', $sReason, $this->oPage, true); | ||
| 418 | - $checkin_fields[] = new KTCheckboxWidget(_kt('Force Original Filename'), _kt('If this is checked, the uploaded document must have the same filename as the original.'), 'forcefilename', '1', $this->oPage, true); | 466 | + $oForm = $this->form_main(); |
| 419 | 467 | ||
| 420 | $oTemplate->setData(array( | 468 | $oTemplate->setData(array( |
| 421 | 'context' => &$this, | 469 | 'context' => &$this, |
| 422 | - 'checkin_fields' => $checkin_fields, | 470 | + 'form' => $oForm, |
| 423 | )); | 471 | )); |
| 424 | return $oTemplate->render(); | 472 | return $oTemplate->render(); |
| 425 | } | 473 | } |
| 426 | 474 | ||
| 427 | function do_checkin() { | 475 | function do_checkin() { |
| 428 | - $sReason = KTUtil::arrayGet($_REQUEST, 'reason'); | ||
| 429 | - $aOptions = array( | ||
| 430 | - 'message' => _kt('You must supply a reason.'), | ||
| 431 | - 'redirect_to' => array('main', sprintf('fDocumentId=%d', $this->oDocument->getId())), | ||
| 432 | - ); | ||
| 433 | - $sReason = $this->oValidator->notEmpty($sReason, $aOptions); | ||
| 434 | - | ||
| 435 | - $bForceFilename = KTUtil::arrayGet($_REQUEST, 'forcefilename'); | ||
| 436 | - | ||
| 437 | - // make sure the user actually selected a file first | ||
| 438 | - if (strlen($_FILES['file']['name']) == 0) { | ||
| 439 | - $this->errorRedirectToMain(_kt("No file was uploaded"), 'fDocumentId=' . $this->oDocument->getId() . '&reason=' . $sReason); | 476 | + $oForm = $this->form_main(); |
| 477 | + $res = $oForm->validate(); | ||
| 478 | + $data = $res['results']; | ||
| 479 | + | ||
| 480 | + $extra_errors = array(); | ||
| 481 | + | ||
| 482 | + if ($data['forcefilename'] && ($data['file']['name'] != $this->oDocument->getFilename())) { | ||
| 483 | + $extra_errors['file'] = sprintf(_kt('The file you uploaded was not called "%s". If you wish to change the filename, please set "Force Original Filename" below to false. '), $this->oDocument->getFilename()); | ||
| 440 | } | 484 | } |
| 485 | + | ||
| 486 | + if (!empty($res['errors']) || !empty($extra_errors)) { | ||
| 487 | + return $oForm->handleError(null, $extra_errors); | ||
| 488 | + } | ||
| 489 | + | ||
| 490 | + $sReason = $data['reason']; | ||
| 491 | + | ||
| 492 | + $sCurrentFilename = $this->oDocument->getFileName(); | ||
| 493 | + $sNewFilename = $data['file']['name']; | ||
| 441 | 494 | ||
| 442 | - // and that the filename matches | ||
| 443 | - global $default; | ||
| 444 | - | ||
| 445 | - $sCurrentFilename = $this->oDocument->getFileName(); | ||
| 446 | - $sNewFilename = $_FILES['file']['name']; | ||
| 447 | - | ||
| 448 | - $default->log->info("checkInDocumentBL.php uploaded filename=" . $sNewFilename . "; current filename=" . $sCurrentFilename); | ||
| 449 | - | ||
| 450 | - | ||
| 451 | - $aOptions = array(); | ||
| 452 | - | ||
| 453 | - if ($this->oDocument->getFileName() != $_FILES['file']['name']) { | ||
| 454 | - if($bForceFilename) { | ||
| 455 | - $this->errorRedirectToMain(_kt("The file name of the uploaded file does not match the file name of the document in the system"), 'fDocumentId=' . $this->oDocument->getId() . '&reason=' . $sReason); | ||
| 456 | - } else { | ||
| 457 | - $aOptions['newfilename'] = $sNewFilename; | ||
| 458 | - } | ||
| 459 | - } | ||
| 460 | - | 495 | + $aOptions = array(); |
| 461 | 496 | ||
| 462 | - $res = KTDocumentUtil::checkin($this->oDocument, $_FILES['file']['tmp_name'], $sReason, $this->oUser, $aOptions); | 497 | + if ($sCurrentFilename != $sNewFilename) { |
| 498 | + $aOptions['newfilename'] = $sNewFilename; | ||
| 499 | + } | ||
| 500 | + | ||
| 501 | + $res = KTDocumentUtil::checkin($this->oDocument, $data['file']['tmp_name'], $sReason, $this->oUser, $aOptions); | ||
| 463 | if (PEAR::isError($res)) { | 502 | if (PEAR::isError($res)) { |
| 464 | $this->errorRedirectToMain(_kt("An error occurred while trying to check in the document"), 'fDocumentId=' . $this->oDocument->getId() . '&reason=' . $sReason); | 503 | $this->errorRedirectToMain(_kt("An error occurred while trying to check in the document"), 'fDocumentId=' . $this->oDocument->getId() . '&reason=' . $sReason); |
| 465 | } | 504 | } |
| 466 | - redirect("$default->rootUrl/control.php?action=viewDocument&fDocumentID=" . $this->oDocument->getID()); | 505 | + redirect(KTBrowseUtil::getUrlForDocument($this->oDocument)); |
| 506 | + exit(0); | ||
| 467 | } | 507 | } |
| 468 | } | 508 | } |
| 469 | // }}} | 509 | // }}} |
| 470 | 510 | ||
| 471 | 511 | ||
| 472 | -// {{{ KTDocumentCheckInAction | 512 | +// {{{ KTDocumentCancelCheckOutAction |
| 473 | class KTDocumentCancelCheckOutAction extends KTDocumentAction { | 513 | class KTDocumentCancelCheckOutAction extends KTDocumentAction { |
| 474 | var $sName = 'ktcore.actions.document.cancelcheckout'; | 514 | var $sName = 'ktcore.actions.document.cancelcheckout'; |
| 475 | 515 | ||
| @@ -490,7 +530,7 @@ class KTDocumentCancelCheckOutAction extends KTDocumentAction { | @@ -490,7 +530,7 @@ class KTDocumentCancelCheckOutAction extends KTDocumentAction { | ||
| 490 | if (KTBrowseUtil::inAdminMode($this->oUser, $oFolder)) { | 530 | if (KTBrowseUtil::inAdminMode($this->oUser, $oFolder)) { |
| 491 | $this->bAdminMode = true; | 531 | $this->bAdminMode = true; |
| 492 | return parent::getInfo(); | 532 | return parent::getInfo(); |
| 493 | - } | 533 | + } |
| 494 | } else if ($this->bInAdminMode == true) { | 534 | } else if ($this->bInAdminMode == true) { |
| 495 | return parent::getInfo(); | 535 | return parent::getInfo(); |
| 496 | } | 536 | } |
| @@ -500,8 +540,6 @@ class KTDocumentCancelCheckOutAction extends KTDocumentAction { | @@ -500,8 +540,6 @@ class KTDocumentCancelCheckOutAction extends KTDocumentAction { | ||
| 500 | return parent::getInfo(); | 540 | return parent::getInfo(); |
| 501 | } | 541 | } |
| 502 | 542 | ||
| 503 | - | ||
| 504 | - | ||
| 505 | function check() { | 543 | function check() { |
| 506 | $res = parent::check(); | 544 | $res = parent::check(); |
| 507 | 545 | ||
| @@ -519,7 +557,7 @@ class KTDocumentCancelCheckOutAction extends KTDocumentAction { | @@ -519,7 +557,7 @@ class KTDocumentCancelCheckOutAction extends KTDocumentAction { | ||
| 519 | if (KTBrowseUtil::inAdminMode($this->oUser, $oFolder)) { | 557 | if (KTBrowseUtil::inAdminMode($this->oUser, $oFolder)) { |
| 520 | $this->bAdminMode = true; | 558 | $this->bAdminMode = true; |
| 521 | return true; | 559 | return true; |
| 522 | - } | 560 | + } |
| 523 | } else if ($this->bInAdminMode == true) { | 561 | } else if ($this->bInAdminMode == true) { |
| 524 | return true; | 562 | return true; |
| 525 | } | 563 | } |
| @@ -637,35 +675,66 @@ class KTDocumentDeleteAction extends KTDocumentAction { | @@ -637,35 +675,66 @@ class KTDocumentDeleteAction extends KTDocumentAction { | ||
| 637 | return true; | 675 | return true; |
| 638 | } | 676 | } |
| 639 | 677 | ||
| 678 | + | ||
| 679 | + function form_main() { | ||
| 680 | + $oForm = new KTForm; | ||
| 681 | + $oForm->setOptions(array( | ||
| 682 | + 'label' => _kt("Delete Document"), | ||
| 683 | + 'action' => 'delete', | ||
| 684 | + 'fail_action' => 'main', | ||
| 685 | + 'cancel_url' => KTBrowseUtil::getUrlForDocument($this->oDocument), | ||
| 686 | + 'submit_label' => _kt("Delete Document"), | ||
| 687 | + 'context' => &$this, | ||
| 688 | + )); | ||
| 689 | + $oForm->setWidgets(array( | ||
| 690 | + array('ktcore.widgets.reason', array( | ||
| 691 | + 'label' => _kt("Reason"), | ||
| 692 | + 'description' => _kt("Please specify why you are deleting this document. Please bear in mind that you can use a maximum of <strong>250</strong> characters."), | ||
| 693 | + 'name' => 'reason', | ||
| 694 | + )), | ||
| 695 | + )); | ||
| 696 | + $oForm->setValidators(array( | ||
| 697 | + array('ktcore.validators.string', array( | ||
| 698 | + 'test' => 'reason', | ||
| 699 | + 'max_length' => 250, | ||
| 700 | + 'output' => 'reason', | ||
| 701 | + )), | ||
| 702 | + )); | ||
| 703 | + | ||
| 704 | + return $oForm; | ||
| 705 | + } | ||
| 706 | + | ||
| 640 | function do_main() { | 707 | function do_main() { |
| 641 | - $this->oPage->setBreadcrumbDetails("delete"); | 708 | + $this->oPage->setBreadcrumbDetails("Delete"); |
| 642 | $oTemplate =& $this->oValidator->validateTemplate('ktcore/action/delete'); | 709 | $oTemplate =& $this->oValidator->validateTemplate('ktcore/action/delete'); |
| 643 | - $delete_fields = array(); | ||
| 644 | - $delete_fields[] = new KTStringWidget(_kt('Reason'), _kt('The reason for this document to be removed.'), 'reason', "", $this->oPage, true); | 710 | + |
| 711 | + $oForm = $this->form_main(); | ||
| 645 | 712 | ||
| 646 | $oTemplate->setData(array( | 713 | $oTemplate->setData(array( |
| 647 | 'context' => &$this, | 714 | 'context' => &$this, |
| 648 | - 'delete_fields' => $delete_fields, | 715 | + 'form' => $oForm, |
| 649 | )); | 716 | )); |
| 650 | return $oTemplate->render(); | 717 | return $oTemplate->render(); |
| 651 | } | 718 | } |
| 652 | 719 | ||
| 653 | function do_delete() { | 720 | function do_delete() { |
| 654 | - global $default; | ||
| 655 | - $sReason = KTUtil::arrayGet($_REQUEST, 'reason'); | ||
| 656 | - $this->oValidator->validateString($sReason, | ||
| 657 | - array('redirect_to' => array('', sprintf('fDocumentId=%d', $this->oDocument->getId())))); | 721 | + $oForm = $this->form_main(); |
| 722 | + $res = $oForm->validate(); | ||
| 723 | + $data = $res['results']; | ||
| 724 | + if (!empty($res['errors'])) { | ||
| 725 | + return $oForm->handleError(); | ||
| 726 | + } | ||
| 727 | + | ||
| 728 | + $sReason = $data['reason']; | ||
| 658 | 729 | ||
| 659 | $fFolderId = $this->oDocument->getFolderId(); | 730 | $fFolderId = $this->oDocument->getFolderId(); |
| 660 | $res = KTDocumentUtil::delete($this->oDocument, $sReason); | 731 | $res = KTDocumentUtil::delete($this->oDocument, $sReason); |
| 661 | if (PEAR::isError($res)) { | 732 | if (PEAR::isError($res)) { |
| 662 | - $_SESSION['KTErrorMessage'][] = $res->getMessage(); | ||
| 663 | - controllerRedirect('viewDocument',sprintf('fDocumentId=%d', $this->oDocument->getId())); | ||
| 664 | - } else { | ||
| 665 | - $_SESSION['KTInfoMessage'][] = sprintf(_kt('Document "%s" Deleted.'),$this->oDocument->getName()); | ||
| 666 | - } | ||
| 667 | - | ||
| 668 | - | 733 | + $this->errorRedirectToMain(sprintf(_kt("Unexpected failure deleting document: %s"), $res->getMessage())); |
| 734 | + } | ||
| 735 | + | ||
| 736 | + $_SESSION['KTInfoMessage'][] = sprintf(_kt('Document "%s" Deleted.'),$this->oDocument->getName()); | ||
| 737 | + | ||
| 669 | controllerRedirect('browse', 'fFolderId=' . $fFolderId); | 738 | controllerRedirect('browse', 'fFolderId=' . $fFolderId); |
| 670 | exit(0); | 739 | exit(0); |
| 671 | } | 740 | } |
| @@ -711,6 +780,7 @@ class KTDocumentMoveAction extends KTDocumentAction { | @@ -711,6 +780,7 @@ class KTDocumentMoveAction extends KTDocumentAction { | ||
| 711 | controllerRedirect('viewDocument', 'fDocumentId=' . $this->oDocument->getId()); | 780 | controllerRedirect('viewDocument', 'fDocumentId=' . $this->oDocument->getId()); |
| 712 | exit(0); | 781 | exit(0); |
| 713 | } | 782 | } |
| 783 | + $this->persistParams(array('fFolderId')); | ||
| 714 | $iFolderId = KTUtil::arrayGet($_REQUEST, 'fFolderId', $this->oDocument->getFolderId()); | 784 | $iFolderId = KTUtil::arrayGet($_REQUEST, 'fFolderId', $this->oDocument->getFolderId()); |
| 715 | $this->oFolder = $this->oValidator->validateFolder($iFolderId); | 785 | $this->oFolder = $this->oValidator->validateFolder($iFolderId); |
| 716 | $this->oDocumentFolder = $this->oValidator->validateFolder($this->oDocument->getFolderId()); | 786 | $this->oDocumentFolder = $this->oValidator->validateFolder($this->oDocument->getFolderId()); |
| @@ -770,43 +840,71 @@ class KTDocumentMoveAction extends KTDocumentAction { | @@ -770,43 +840,71 @@ class KTDocumentMoveAction extends KTDocumentAction { | ||
| 770 | return $oTemplate->render(); | 840 | return $oTemplate->render(); |
| 771 | } | 841 | } |
| 772 | 842 | ||
| 843 | + function form_move() { | ||
| 844 | + $oForm = new KTForm; | ||
| 845 | + $oForm->setOptions(array( | ||
| 846 | + 'label' => _kt("Move Document"), | ||
| 847 | + 'action' => 'move_final', | ||
| 848 | + 'fail_action' => 'move', | ||
| 849 | + 'cancel_url' => KTBrowseUtil::getUrlForDocument($this->oDocument), | ||
| 850 | + 'submit_label' => _kt("Move Document"), | ||
| 851 | + 'context' => &$this, | ||
| 852 | + )); | ||
| 853 | + $oForm->setWidgets(array( | ||
| 854 | + array('ktcore.widgets.reason', array( | ||
| 855 | + 'label' => _kt("Reason"), | ||
| 856 | + 'description' => _kt("Please specify why you are moving this document. Please bear in mind that you can use a maximum of <strong>250</strong> characters."), | ||
| 857 | + 'name' => 'reason', | ||
| 858 | + )), | ||
| 859 | + )); | ||
| 860 | + $oForm->setValidators(array( | ||
| 861 | + array('ktcore.validators.string', array( | ||
| 862 | + 'test' => 'reason', | ||
| 863 | + 'max_length' => 250, | ||
| 864 | + 'output' => 'reason', | ||
| 865 | + )), | ||
| 866 | + )); | ||
| 867 | + | ||
| 868 | + return $oForm; | ||
| 869 | + } | ||
| 870 | + | ||
| 773 | function do_move() { | 871 | function do_move() { |
| 774 | - $this->oPage->setBreadcrumbDetails(_kt("move")); | 872 | + $this->persistParams(array('fFolderId')); |
| 873 | + | ||
| 874 | + $this->oPage->setBreadcrumbDetails(_kt("Move")); | ||
| 775 | $oTemplate =& $this->oValidator->validateTemplate('ktcore/action/move_final'); | 875 | $oTemplate =& $this->oValidator->validateTemplate('ktcore/action/move_final'); |
| 776 | 876 | ||
| 777 | - if($this->oDocument->getFolderId() === $this->oFolder->getId()) { | ||
| 778 | - $this->errorRedirectTo('main', _kt("The document was already in this folder"), sprintf("fDocumentId=%d&fFolderId=%d", $this->oDocument->getId(), $this->oFolder->getId())); | ||
| 779 | - exit(0); | ||
| 780 | - } | ||
| 781 | - | ||
| 782 | - | ||
| 783 | - $sFolderPath = join(" » ", $this->oFolder->getPathArray()); | ||
| 784 | - $aNames = $this->oDocumentFolder->getPathArray(); | ||
| 785 | - $aNames[] = $this->oDocument->getName(); | ||
| 786 | - $sDocumentName = join(" » ", $aNames); | ||
| 787 | - | ||
| 788 | - $move_fields = array(); | ||
| 789 | - $move_fields[] = new KTStaticTextWidget(_kt('Document to move'), '', 'fDocumentId', $sDocumentName, $this->oPage, false); | ||
| 790 | - $move_fields[] = new KTStaticTextWidget(_kt('Target folder'), '', 'fFolderId', $sFolderPath, $this->oPage, false); | ||
| 791 | - $move_fields[] = new KTStringWidget(_kt('Reason'), _kt('The reason for this document to be moved.'), 'reason', "", $this->oPage, true); | 877 | + if($this->oDocument->getFolderId() === $this->oFolder->getId()) { |
| 878 | + $this->errorRedirectTo('main', _kt("The document was already in this folder"), sprintf("fDocumentId=%d&fFolderId=%d", $this->oDocument->getId(), $this->oFolder->getId())); | ||
| 879 | + exit(0); | ||
| 880 | + } | ||
| 881 | + | ||
| 882 | + $oForm = $this->form_move(); | ||
| 883 | + | ||
| 884 | + //$sFolderPath = join(" » ", $this->oFolder->getPathArray()); | ||
| 885 | + //$aNames = $this->oDocumentFolder->getPathArray(); | ||
| 886 | + //$aNames[] = $this->oDocument->getName(); | ||
| 887 | + //$sDocumentName = join(" » ", $aNames); | ||
| 792 | 888 | ||
| 793 | $oTemplate->setData(array( | 889 | $oTemplate->setData(array( |
| 794 | 'context' => &$this, | 890 | 'context' => &$this, |
| 795 | - 'move_fields' => $move_fields, | 891 | + 'form' => $oForm, |
| 796 | )); | 892 | )); |
| 797 | return $oTemplate->render(); | 893 | return $oTemplate->render(); |
| 798 | } | 894 | } |
| 799 | 895 | ||
| 800 | function do_move_final() { | 896 | function do_move_final() { |
| 801 | - $sReason = KTUtil::arrayGet($_REQUEST, 'reason'); | ||
| 802 | - $aOptions = array( | ||
| 803 | - 'message' => _kt("No reason given"), | ||
| 804 | - 'redirect_to' => array('move', sprintf('fDocumentId=%d&fFolderId=%d', $this->oDocument->getId(), $this->oFolder->getId())), | ||
| 805 | - ); | ||
| 806 | - $this->oValidator->notEmpty($sReason, $aOptions); | 897 | + $oForm = $this->form_move(); |
| 898 | + $res = $oForm->validate(); | ||
| 899 | + $data = $res['results']; | ||
| 900 | + if (!empty($res['errors'])) { | ||
| 901 | + return $oForm->handleError(); | ||
| 902 | + } | ||
| 903 | + | ||
| 904 | + $sReason = $data['reason']; | ||
| 807 | 905 | ||
| 808 | if (!Permission::userHasFolderWritePermission($this->oFolder)) { | 906 | if (!Permission::userHasFolderWritePermission($this->oFolder)) { |
| 809 | - $this->errorRedirectTo("main", _kt("You do not have permission to move a document to this location"), sprintf("fDocumentId=%d&fFolderId=%d", $this->oDocument->getId(), $this->oFolder->getId())); | 907 | + $this->errorRedirectToMain(_kt("You do not have permission to move a document to this location")); |
| 810 | exit(0); | 908 | exit(0); |
| 811 | } | 909 | } |
| 812 | 910 | ||
| @@ -823,19 +921,22 @@ class KTDocumentMoveAction extends KTDocumentAction { | @@ -823,19 +921,22 @@ class KTDocumentMoveAction extends KTDocumentAction { | ||
| 823 | 921 | ||
| 824 | //put the document in the new folder | 922 | //put the document in the new folder |
| 825 | $this->oDocument->setFolderID($this->oFolder->getId()); | 923 | $this->oDocument->setFolderID($this->oFolder->getId()); |
| 826 | - if (!$this->oDocument->update(true)) { | ||
| 827 | - $this->errorRedirectTo("main", _kt("There was a problem updating the document's location in the database"), sprintf("fDocumentId=%d&fFolderId=%d", $this->oDocument->getId(), $this->oFolder->getId())); | 924 | + $res = $this->oDocument->update(); |
| 925 | + if (PEAR::isError($res) || ($res === false)) { | ||
| 926 | + $this->errorRedirectToMain(_kt("There was a problem updating the document's location in the database")); | ||
| 828 | } | 927 | } |
| 829 | 928 | ||
| 830 | 929 | ||
| 831 | //move the document on the file system | 930 | //move the document on the file system |
| 832 | $oStorage =& KTStorageManagerUtil::getSingleton(); | 931 | $oStorage =& KTStorageManagerUtil::getSingleton(); |
| 833 | - if (!$oStorage->moveDocument($this->oDocument, $this->oDocumentFolder, $this->oFolder)) { | ||
| 834 | - $this->oDocument->setFolderID($this->oDocumentFolder->getId()); | ||
| 835 | - $this->oDocument->update(true); | ||
| 836 | - $this->errorRedirectTo("move", _kt("There was a problem updating the document's location in the repository storage"), sprintf("fDocumentId=%d&fFolderId=%d", $this->oDocument->getId(), $this->oFolder->getId())); | 932 | + $res = $oStorage->moveDocument($this->oDocument, $this->oDocumentFolder, $this->oFolder); |
| 933 | + if (PEAR::isError($res) || ($res === false)) { | ||
| 934 | + $this->oDocument->setFolderID($oOriginalFolder->getId()); | ||
| 935 | + $this->oDocument->update(); | ||
| 936 | + $this->errorRedirectToMain(_kt("There was a problem updating the document's location in the repository storage")); | ||
| 837 | } | 937 | } |
| 838 | 938 | ||
| 939 | + | ||
| 839 | $sMoveMessage = sprintf("Moved from %s/%s to %s/%s: %s", | 940 | $sMoveMessage = sprintf("Moved from %s/%s to %s/%s: %s", |
| 840 | $this->oDocumentFolder->getFullPath(), | 941 | $this->oDocumentFolder->getFullPath(), |
| 841 | $this->oDocumentFolder->getName(), | 942 | $this->oDocumentFolder->getName(), |
| @@ -868,7 +969,7 @@ class KTDocumentMoveAction extends KTDocumentAction { | @@ -868,7 +969,7 @@ class KTDocumentMoveAction extends KTDocumentAction { | ||
| 868 | } | 969 | } |
| 869 | } | 970 | } |
| 870 | 971 | ||
| 871 | - controllerRedirect('viewDocument', 'fDocumentId=' . $this->oDocument->getId()); | 972 | + redirect(KTBrowseUtil::getUrlForDocument($this->oDocument)); |
| 872 | exit(0); | 973 | exit(0); |
| 873 | } | 974 | } |
| 874 | } | 975 | } |
templates/ktcore/action/checkin.smarty
| 1 | +<h2>{i18n arg_docname=$context->oDocument->getName()}Checkin Document: #docname#{/i18n}</h2> | ||
| 2 | + | ||
| 1 | <p class="descriptiveText">{i18n}Checking in a document updates the document | 3 | <p class="descriptiveText">{i18n}Checking in a document updates the document |
| 2 | and allows others to make changes to the document and its metadata.{/i18n}</p> | 4 | and allows others to make changes to the document and its metadata.{/i18n}</p> |
| 3 | 5 | ||
| 4 | -{assign var=iDocumentId value=$context->oDocument->getId()} | ||
| 5 | <p class="descriptiveText">{i18n}If you do not | 6 | <p class="descriptiveText">{i18n}If you do not |
| 6 | intend to change the document, or you do not wish to prevent others from | 7 | intend to change the document, or you do not wish to prevent others from |
| 7 | changing the document, you should rather use the action menu to <strong>cancel this checkout</strong>.{/i18n}</p> | 8 | changing the document, you should rather use the action menu to <strong>cancel this checkout</strong>.{/i18n}</p> |
| 8 | 9 | ||
| 9 | -<form method="POST" action="{$smarty.server.PHP_SELF}" enctype="multipart/form-data"> | ||
| 10 | -<fieldset><legend>{i18n}Checkin{/i18n}</legend> | ||
| 11 | -<input type="hidden" name="action" value="checkin" /> | ||
| 12 | -<input type="hidden" name="fDocumentId" value="{$iDocumentId}" /> | ||
| 13 | -{foreach from=$checkin_fields item=oWidget } | ||
| 14 | - {$oWidget->render()} | ||
| 15 | -{/foreach} | ||
| 16 | -<div class="form_actions"> | ||
| 17 | -<input type="submit" name="submit" value="{i18n}Checkin{/i18n}" /> | ||
| 18 | -</div> | ||
| 19 | -</fieldset> | ||
| 20 | -</form> | 10 | +{$form->render()} |
templates/ktcore/action/delete.smarty
| 1 | +<h2>{i18n arg_docname=$context->oDocument->getName()}Delete Document: #docname#{/i18n}</h2> | ||
| 2 | + | ||
| 1 | <p class="descriptiveText">{i18n}Deleting a document marks it as no longer | 3 | <p class="descriptiveText">{i18n}Deleting a document marks it as no longer |
| 2 | being displayed. The document management system does not remove the | 4 | being displayed. The document management system does not remove the |
| 3 | document entirely, and it can be restored at a later stage.{/i18n}</p> | 5 | document entirely, and it can be restored at a later stage.{/i18n}</p> |
| 4 | 6 | ||
| 5 | -{assign var=iDocumentId value=$context->oDocument->getId()} | ||
| 6 | -{capture assign=link} | ||
| 7 | -{"viewDocument"|generateControllerUrl:"fDocumentId=$iDocumentId"} | ||
| 8 | -{/capture} | ||
| 9 | -<p class="descriptiveText">{i18n arg_link=$link}If you do not intend to delete this document, you should | ||
| 10 | -<a href="#link#">cancel the deletion</a>.{/i18n}</p> | ||
| 11 | - | ||
| 12 | -<form method="POST" action="{$smarty.server.PHP_SELF}"> | ||
| 13 | -<fieldset><legend>{i18n}Delete{/i18n}</legend> | ||
| 14 | -<input type="hidden" name="action" value="delete" /> | ||
| 15 | -<input type="hidden" name="fDocumentId" value="{$iDocumentId}" /> | ||
| 16 | -{foreach from=$delete_fields item=oWidget } | ||
| 17 | - {$oWidget->render()} | ||
| 18 | -{/foreach} | ||
| 19 | -<div class="form_actions"> | ||
| 20 | -<input type="submit" name="submit" value="{i18n}Delete{/i18n}" /> | ||
| 21 | -</div> | ||
| 22 | -</fieldset> | ||
| 23 | -</form> | 7 | +{$form->render()} |
templates/ktcore/action/move_final.smarty
| 1 | -<p class="descriptiveText">{i18n}Moving a document relocates the document | ||
| 2 | -within the document repository.{/i18n}</p> | ||
| 3 | - | ||
| 4 | -{assign var=iDocumentId value=$context->oDocument->getId()} | ||
| 5 | -{capture assign=link} | ||
| 6 | -{"viewDocument"|generateControllerUrl:"fDocumentId=$iDocumentId"} | ||
| 7 | -{/capture} | ||
| 8 | -<p class="descriptiveText">{i18n arg_link=$link}If you do not intend to | ||
| 9 | -move this document, you should <a href="#link#">cancel the | ||
| 10 | -move</a>.{/i18n}</p> | 1 | +<h2>{i18n arg_docname=$context->oDocument->getName()}Checkin Document: #docname#{/i18n}</h2> |
| 11 | 2 | ||
| 12 | -<form method="POST" action="{$smarty.server.PHP_SELF}"> | ||
| 13 | -<fieldset><legend>{i18n}Move{/i18n}</legend> | ||
| 14 | -<input type="hidden" name="action" value="move_final" /> | ||
| 15 | -<input type="hidden" name="fDocumentId" value="{$iDocumentId}" /> | ||
| 16 | -<input type="hidden" name="fFolderId" value="{$context->oFolder->getId()}" /> | ||
| 17 | -{foreach from=$move_fields item=oWidget } | ||
| 18 | - {$oWidget->render()} | ||
| 19 | -{/foreach} | 3 | +<p class="descriptiveText">{i18n}Moving a document relocates the document |
| 4 | +within the DMS.{/i18n}</p> | ||
| 20 | 5 | ||
| 21 | -<div class="form_actions"> | ||
| 22 | -<input type="submit" name="submit[move]" value="{i18n}Move{/i18n}" /> | ||
| 23 | -<input type="submit" name="submit[cancel]" value="{i18n}Cancel{/i18n}" /> | ||
| 24 | -</div> | ||
| 25 | -</fieldset> | ||
| 26 | -</form> | 6 | +{$form->render()} |