Commit cd27b0a9a182d16e835bb5947d4e619669d3e571

Authored by nbm
1 parent b0acd4d5

Give KTFolderAction a makeover, making it analogous to KTDocumentAction


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@4078 c91229c3-7414-0410-bfa2-8a42b809f60b
lib/actions/folderaction.inc.php
... ... @@ -2,7 +2,7 @@
2 2  
3 3 require_once(KT_LIB_DIR . '/actions/actionregistry.inc.php');
4 4  
5   -class KTFolderAction {
  5 +class KTFolderAction extends KTStandardDispatcher {
6 6 var $sName;
7 7 var $sDescription;
8 8 var $sDisplayName;
... ... @@ -13,11 +13,26 @@ class KTFolderAction {
13 13 var $_bDisabled;
14 14 var $_sDisabledText = null;
15 15  
16   - function KTFolderAction($oFolder, $oUser) {
  16 + var $sSection = "view_details";
  17 + var $aBreadcrumbs = array(
  18 + array('action' => 'browse', 'name' => 'Browse'),
  19 + );
  20 +
  21 + function KTFolderAction($oFolder = null, $oUser = null) {
17 22 $this->oFolder = $oFolder;
18 23 $this->oUser = $oUser;
  24 + parent::KTStandardDispatcher();
  25 + }
  26 +
  27 + function setFolder(&$oFolder) {
  28 + $this->oFolder =& $oFolder;
19 29 }
20 30  
  31 + function setUser(&$oUser) {
  32 + $this->oUser =& $oUser;
  33 + }
  34 +
  35 +
21 36 function _show() {
22 37 if (is_null($this->_sShowPermission)) {
23 38 return true;
... ... @@ -48,7 +63,7 @@ class KTFolderAction {
48 63 }
49 64  
50 65 function getURL() {
51   - return sprintf("/plugin.php/%s?fFolderID=%d", $this->sName, $this->oFolder->getID());
  66 + return sprintf("/action.php/%s?fFolderId=%d", $this->sName, $this->oFolder->getID());
52 67 }
53 68  
54 69 function getInfo() {
... ... @@ -66,9 +81,48 @@ class KTFolderAction {
66 81 return $this->customiseInfo($aInfo);
67 82 }
68 83  
  84 + function getName() {
  85 + return $this->sName;
  86 + }
  87 +
  88 + function getDisplayName() {
  89 + return $this->sDisplayName;
  90 + }
  91 +
  92 + function getDescription() {
  93 + return $this->sDescription;
  94 + }
  95 +
69 96 function customiseInfo($aInfo) {
70 97 return $aInfo;
71 98 }
  99 +
  100 + function check() {
  101 + $this->oFolder =& $this->oValidator->validateFolder($_REQUEST['fFolderId']);
  102 +
  103 + if (!is_null($this->_sShowPermission)) {
  104 + $oPermission =& KTPermission::getByName($this->_sShowPermission);
  105 + if (!PEAR::isError($oPermission)) {
  106 + $res = KTPermissionUtil::userHasPermissionOnItem($this->oUser, $oPermission, $this->oFolder);
  107 + if (!$res) {
  108 + return false;
  109 + }
  110 + }
  111 + }
  112 + $aOptions = array(
  113 + "final" => false,
  114 + "documentaction" => "viewDocument",
  115 + "folderaction" => "browse",
  116 + );
  117 + $this->aBreadcrumbs = array_merge($this->aBreadcrumbs,
  118 + KTBrowseUtil::breadcrumbsForFolder($this->oFolder, $aOptions));
  119 + return true;
  120 + }
  121 +
  122 + function do_main() {
  123 + return "Dispatcher component of action not implemented.";
  124 + }
  125 +
72 126 }
73 127  
74 128 class KTFolderActionUtil {
... ...