Commit 9075f5e49016d7f089f7ccdcf239d901c3ef3517
1 parent
0255ac66
- fix for IE icons
- archived documents now get browsed for restoration. git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@4689 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
5 changed files
with
149 additions
and
75 deletions
lib/browse/BrowseColumns.inc.php
| @@ -224,6 +224,14 @@ class UserColumn extends BrowseColumn { | @@ -224,6 +224,14 @@ class UserColumn extends BrowseColumn { | ||
| 224 | // use the _name_ parameter + _f_ + id to create a non-clashing checkbox. | 224 | // use the _name_ parameter + _f_ + id to create a non-clashing checkbox. |
| 225 | 225 | ||
| 226 | class SelectionColumn extends BrowseColumn { | 226 | class SelectionColumn extends BrowseColumn { |
| 227 | + var $show_documents; | ||
| 228 | + var $show_folders; | ||
| 229 | + | ||
| 230 | + function SelectionColumn ($sLabel, $sName, $bShowFolders = true, $bShowDocs = true) { | ||
| 231 | + $this->show_documents = $bShowDocs; | ||
| 232 | + $this->show_folders = $bShowFolders; | ||
| 233 | + parent::BrowseColumn($sLabel, $sName); | ||
| 234 | + } | ||
| 227 | 235 | ||
| 228 | function renderHeader($sReturnURL) { | 236 | function renderHeader($sReturnURL) { |
| 229 | // FIXME clean up access to oPage. | 237 | // FIXME clean up access to oPage. |
| @@ -234,26 +242,27 @@ class SelectionColumn extends BrowseColumn { | @@ -234,26 +242,27 @@ class SelectionColumn extends BrowseColumn { | ||
| 234 | 242 | ||
| 235 | } | 243 | } |
| 236 | 244 | ||
| 237 | - // use inline, since its just too heavy to even _think_ about using smarty. | 245 | + // only include the _f or _d IF WE HAVE THE OTHER TYPE. |
| 238 | function renderData($aDataRow) { | 246 | function renderData($aDataRow) { |
| 239 | $localname = $this->name; | 247 | $localname = $this->name; |
| 240 | - if ($aDataRow["type"] === "folder") { $localname .= "_f[]"; $v = $aDataRow["folderid"]; } | ||
| 241 | - else { $localname .= "_d[]"; $v = $aDataRow["docid"]; } | 248 | + |
| 249 | + if (($aDataRow["type"] === "folder") && ($this->show_folders)) { | ||
| 250 | + if ($this->show_documents) { | ||
| 251 | + $localname .= "_f[]"; | ||
| 252 | + } | ||
| 253 | + $v = $aDataRow["folderid"]; | ||
| 254 | + } else if (($aDataRow["type"] === "document") && $this->show_documents) { | ||
| 255 | + if ($this->show_folders) { | ||
| 256 | + $localname .= "_d[]"; | ||
| 257 | + } | ||
| 258 | + $v = $aDataRow["docid"]; | ||
| 259 | + } else { | ||
| 260 | + return ' '; | ||
| 261 | + } | ||
| 242 | 262 | ||
| 243 | return '<input type="checkbox" name="' . $localname . '" onactivate="activateRow(this)" value="' . $v . '"/>'; | 263 | return '<input type="checkbox" name="' . $localname . '" onactivate="activateRow(this)" value="' . $v . '"/>'; |
| 244 | } | 264 | } |
| 245 | 265 | ||
| 246 | - function _mimeHelper($iMimeTypeId) { | ||
| 247 | - // FIXME lazy cache this. | ||
| 248 | - $sQuery = 'SELECT icon_path FROM mime_types WHERE id = ?'; | ||
| 249 | - $res = DBUtil::getOneResult(array($sQuery, array($iMimeTypeId))); | ||
| 250 | - | ||
| 251 | - if ($res[0] !== null) { | ||
| 252 | - return $res[0]; | ||
| 253 | - } else { | ||
| 254 | - return 'unspecified_type'; | ||
| 255 | - } | ||
| 256 | - } | ||
| 257 | } | 266 | } |
| 258 | 267 | ||
| 259 | 268 |
lib/browse/PartialQuery.inc.php
| @@ -365,4 +365,45 @@ class FolderBrowseQuery extends BrowseQuery { | @@ -365,4 +365,45 @@ class FolderBrowseQuery extends BrowseQuery { | ||
| 365 | } | 365 | } |
| 366 | } | 366 | } |
| 367 | 367 | ||
| 368 | +class ArchivedBrowseQuery extends BrowseQuery { | ||
| 369 | + function _getDocumentQuery($aOptions = null) { | ||
| 370 | + $oUser = User::get($_SESSION['userID']); | ||
| 371 | + $res = KTSearchUtil::permissionToSQL($oUser, $this->sPermissionName); | ||
| 372 | + if (PEAR::isError($res)) { | ||
| 373 | + return $res; | ||
| 374 | + } | ||
| 375 | + list($sPermissionString, $aPermissionParams, $sPermissionJoin) = $res; | ||
| 376 | + $aPotentialWhere = array($sPermissionString, 'D.folder_id = ?', 'D.status_id = ' . ARCHIVED); | ||
| 377 | + $aWhere = array(); | ||
| 378 | + foreach ($aPotentialWhere as $sWhere) { | ||
| 379 | + if (empty($sWhere)) { | ||
| 380 | + continue; | ||
| 381 | + } | ||
| 382 | + if ($sWhere == "()") { | ||
| 383 | + continue; | ||
| 384 | + } | ||
| 385 | + $aWhere[] = $sWhere; | ||
| 386 | + } | ||
| 387 | + $sWhere = ""; | ||
| 388 | + if ($aWhere) { | ||
| 389 | + $sWhere = "\tWHERE " . join(" AND ", $aWhere); | ||
| 390 | + } | ||
| 391 | + | ||
| 392 | + $sSelect = KTUtil::arrayGet($aOptions, 'select', 'D.id'); | ||
| 393 | + | ||
| 394 | + $sQuery = sprintf("SELECT %s FROM %s AS D | ||
| 395 | + LEFT JOIN %s AS DM ON D.metadata_version_id = DM.id | ||
| 396 | + LEFT JOIN %s AS DC ON DM.content_version_id = DC.id | ||
| 397 | + %s %s", | ||
| 398 | + $sSelect, KTUtil::getTableName("documents"), | ||
| 399 | + KTUtil::getTableName("document_metadata_version"), | ||
| 400 | + KTUtil::getTableName("document_content_version"), | ||
| 401 | + $sPermissionJoin, $sWhere); | ||
| 402 | + $aParams = array(); | ||
| 403 | + $aParams = array_merge($aParams, $aPermissionParams); | ||
| 404 | + $aParams[] = $this->folder_id; | ||
| 405 | + return array($sQuery, $aParams); | ||
| 406 | + } | ||
| 407 | +} | ||
| 408 | + | ||
| 368 | ?> | 409 | ?> |
plugins/ktcore/admin/archivedDocuments.php
| @@ -9,27 +9,102 @@ require_once(KT_LIB_DIR . '/documentmanagement/DocumentTransaction.inc'); | @@ -9,27 +9,102 @@ require_once(KT_LIB_DIR . '/documentmanagement/DocumentTransaction.inc'); | ||
| 9 | require_once(KT_LIB_DIR . "/widgets/fieldWidgets.php"); | 9 | require_once(KT_LIB_DIR . "/widgets/fieldWidgets.php"); |
| 10 | require_once(KT_LIB_DIR . "/templating/kt3template.inc.php"); | 10 | require_once(KT_LIB_DIR . "/templating/kt3template.inc.php"); |
| 11 | 11 | ||
| 12 | +require_once(KT_LIB_DIR . "/browse/DocumentCollection.inc.php"); | ||
| 13 | +require_once(KT_LIB_DIR . "/browse/BrowseColumns.inc.php"); | ||
| 14 | +require_once(KT_LIB_DIR . "/browse/PartialQuery.inc.php"); | ||
| 15 | +require_once(KT_LIB_DIR . "/browse/browseutil.inc.php"); | ||
| 16 | + | ||
| 12 | require_once(KT_LIB_DIR . "/documentmanagement/PhysicalDocumentManager.inc"); | 17 | require_once(KT_LIB_DIR . "/documentmanagement/PhysicalDocumentManager.inc"); |
| 13 | 18 | ||
| 14 | // FIXME chain in a notification alert for un-archival requests. | 19 | // FIXME chain in a notification alert for un-archival requests. |
| 20 | +class KTArchiveTitle extends TitleColumn { | ||
| 21 | + | ||
| 22 | + function renderDocumentLink($aDataRow) { | ||
| 23 | + $outStr .= $aDataRow["document"]->getName(); | ||
| 24 | + return $outStr; | ||
| 25 | + } | ||
| 26 | + | ||
| 27 | + function buildFolderLink($aDataRow) { | ||
| 28 | + $baseurl = KTUtil::arrayGet($this->aOptions, "folderurl", ""); | ||
| 29 | + $kt_path_info = KTUtil::arrayGet($_REQUEST, 'kt_path_info'); | ||
| 30 | + if (empty($kt_path_info)) { | ||
| 31 | + return sprintf('%s?fFolderId=%d', $baseurl, $aDataRow["folder"]->getId()); | ||
| 32 | + } else { | ||
| 33 | + return sprintf('%s?kt_path_info=%s&fFolderId=%d', $baseurl, $kt_path_info, $aDataRow["folder"]->getId()); | ||
| 34 | + } | ||
| 35 | + } | ||
| 36 | +} | ||
| 15 | 37 | ||
| 16 | class ArchivedDocumentsDispatcher extends KTAdminDispatcher { | 38 | class ArchivedDocumentsDispatcher extends KTAdminDispatcher { |
| 17 | 39 | ||
| 18 | function do_main () { | 40 | function do_main () { |
| 19 | $this->aBreadcrumbs[] = array('url' => $_SERVER['PHP_SELF'], 'name' => _('Archived Documents')); | 41 | $this->aBreadcrumbs[] = array('url' => $_SERVER['PHP_SELF'], 'name' => _('Archived Documents')); |
| 20 | 42 | ||
| 21 | - $this->oPage->setBreadcrumbDetails(_('list')); | 43 | + $this->oPage->setBreadcrumbDetails(_('browse')); |
| 44 | + | ||
| 45 | + $oFolder = Folder::get(KTUtil::arrayGet($_REQUEST, 'fFolderId', 1)); | ||
| 46 | + if (PEAR::isError($oFolder)) { | ||
| 47 | + $this->errorRedirectToMain(_('Invalid folder selected.')); | ||
| 48 | + exit(0); | ||
| 49 | + } | ||
| 22 | 50 | ||
| 23 | - $aDocuments =& Document::getList("status_id=" . ARCHIVED); | 51 | + // Setup the collection for move display. |
| 24 | 52 | ||
| 53 | + $collection = new DocumentCollection(); | ||
| 25 | 54 | ||
| 26 | - $oTemplating =& KTTemplating::getSingleton(); | ||
| 27 | - $oTemplate = $oTemplating->loadTemplate('ktcore/document/admin/archivedlist'); | ||
| 28 | - $oTemplate->setData(array( | ||
| 29 | - 'context' => $this, | ||
| 30 | - 'documents' => $aDocuments, | ||
| 31 | - )); | ||
| 32 | - return $oTemplate; | 55 | + $collection->addColumn(new SelectionColumn("Select","selected_docs[]", false, true)); |
| 56 | + $collection->addColumn(new KTArchiveTitle("Archive Documents","title")); | ||
| 57 | + | ||
| 58 | + $qObj = new ArchivedBrowseQuery($oFolder->getId()); | ||
| 59 | + $collection->setQueryObject($qObj); | ||
| 60 | + | ||
| 61 | + $batchPage = (int) KTUtil::arrayGet($_REQUEST, "page", 0); | ||
| 62 | + $batchSize = 20; | ||
| 63 | + | ||
| 64 | + $resultURL = sprintf("?fFolderId=%d&action=browse", $sMoveCode, $oFolder->getId()); | ||
| 65 | + $collection->setBatching($resultURL, $batchPage, $batchSize); | ||
| 66 | + | ||
| 67 | + // ordering. (direction and column) | ||
| 68 | + $displayOrder = KTUtil::arrayGet($_REQUEST, 'sort_order', "asc"); | ||
| 69 | + if ($displayOrder !== "asc") { $displayOrder = "desc"; } | ||
| 70 | + $displayControl = KTUtil::arrayGet($_REQUEST, 'sort_on', "title"); | ||
| 71 | + | ||
| 72 | + $collection->setSorting($displayControl, $displayOrder); | ||
| 73 | + | ||
| 74 | + $collection->getResults(); | ||
| 75 | + | ||
| 76 | + $aBreadcrumbs = array(); | ||
| 77 | + $folder_path_names = $oFolder->getPathArray(); | ||
| 78 | + $folder_path_ids = explode(',', $oFolder->getParentFolderIds()); | ||
| 79 | + if ($folder_path_ids[0] == 0) { | ||
| 80 | + $folder_path_ids = array(); | ||
| 81 | + } | ||
| 82 | + $folder_path_ids[] = $oFolder->getId(); | ||
| 83 | + | ||
| 84 | + foreach (range(0, count($folder_path_ids) - 1) as $index) { | ||
| 85 | + $id = $folder_path_ids[$index]; | ||
| 86 | + $url = sprintf("?fFolderId=%d", $sMoveCode, $id); | ||
| 87 | + $aBreadcrumbs[] = array("url" => $url, "name" => $folder_path_names[$index]); | ||
| 88 | + } | ||
| 89 | + | ||
| 90 | + $oTemplating = new KTTemplating; | ||
| 91 | + $oTemplate = $oTemplating->loadTemplate("ktcore/document/admin/archivebrowse"); | ||
| 92 | + $aTemplateData = array( | ||
| 93 | + "context" => $this, | ||
| 94 | + 'folder' => $oFolder, | ||
| 95 | + 'breadcrumbs' => $aBreadcrumbs, | ||
| 96 | + 'collection' => $collection, | ||
| 97 | + 'collection_breadcrumbs' => $aBreadcrumbs, | ||
| 98 | + ); | ||
| 99 | + | ||
| 100 | + return $oTemplate->render($aTemplateData); | ||
| 101 | + } | ||
| 102 | + | ||
| 103 | + /* | ||
| 104 | + * Provide for "archived" browsing. | ||
| 105 | + */ | ||
| 106 | + function do_browse() { | ||
| 107 | + | ||
| 33 | } | 108 | } |
| 34 | 109 | ||
| 35 | function do_confirm_restore() { | 110 | function do_confirm_restore() { |
resources/css/kt-ie-icons.css
| @@ -6,11 +6,6 @@ | @@ -6,11 +6,6 @@ | ||
| 6 | .ktAction.ktEdit { background: transparent url(../../thirdparty/icon-theme/16x16/actions/document-properties.gif) top left no-repeat; } | 6 | .ktAction.ktEdit { background: transparent url(../../thirdparty/icon-theme/16x16/actions/document-properties.gif) top left no-repeat; } |
| 7 | .ktAction.ktAddUser { background: transparent url(../../thirdparty/icon-theme/16x16/actions/contact-new.gif) top left no-repeat; } | 7 | .ktAction.ktAddUser { background: transparent url(../../thirdparty/icon-theme/16x16/actions/contact-new.gif) top left no-repeat; } |
| 8 | .ktAction.ktAddGroup { background: transparent url(../../thirdparty/icon-theme/16x16/actions/contact-new.gif) top left no-repeat; } | 8 | .ktAction.ktAddGroup { background: transparent url(../../thirdparty/icon-theme/16x16/actions/contact-new.gif) top left no-repeat; } |
| 9 | - | ||
| 10 | -.contenttype { | ||
| 11 | - margin-right: 0; | ||
| 12 | -} | ||
| 13 | - | ||
| 14 | .contenttype.office { background-image: url(../../resources/mimetypes/office.gif); } | 9 | .contenttype.office { background-image: url(../../resources/mimetypes/office.gif); } |
| 15 | .contenttype.word { background-image: url(../../resources/mimetypes/word.gif); } | 10 | .contenttype.word { background-image: url(../../resources/mimetypes/word.gif); } |
| 16 | .contenttype.excel { background-image: url(../../resources/mimetypes/excel.gif); } | 11 | .contenttype.excel { background-image: url(../../resources/mimetypes/excel.gif); } |
templates/ktcore/document/admin/archivedlist.smarty
No preview for this file type