diff --git a/lib/browse/BrowseColumns.inc.php b/lib/browse/BrowseColumns.inc.php index a2a9eaf..c318442 100644 --- a/lib/browse/BrowseColumns.inc.php +++ b/lib/browse/BrowseColumns.inc.php @@ -224,6 +224,14 @@ class UserColumn extends BrowseColumn { // use the _name_ parameter + _f_ + id to create a non-clashing checkbox. class SelectionColumn extends BrowseColumn { + var $show_documents; + var $show_folders; + + function SelectionColumn ($sLabel, $sName, $bShowFolders = true, $bShowDocs = true) { + $this->show_documents = $bShowDocs; + $this->show_folders = $bShowFolders; + parent::BrowseColumn($sLabel, $sName); + } function renderHeader($sReturnURL) { // FIXME clean up access to oPage. @@ -234,26 +242,27 @@ class SelectionColumn extends BrowseColumn { } - // use inline, since its just too heavy to even _think_ about using smarty. + // only include the _f or _d IF WE HAVE THE OTHER TYPE. function renderData($aDataRow) { $localname = $this->name; - if ($aDataRow["type"] === "folder") { $localname .= "_f[]"; $v = $aDataRow["folderid"]; } - else { $localname .= "_d[]"; $v = $aDataRow["docid"]; } + + if (($aDataRow["type"] === "folder") && ($this->show_folders)) { + if ($this->show_documents) { + $localname .= "_f[]"; + } + $v = $aDataRow["folderid"]; + } else if (($aDataRow["type"] === "document") && $this->show_documents) { + if ($this->show_folders) { + $localname .= "_d[]"; + } + $v = $aDataRow["docid"]; + } else { + return ' '; + } return ''; } - function _mimeHelper($iMimeTypeId) { - // FIXME lazy cache this. - $sQuery = 'SELECT icon_path FROM mime_types WHERE id = ?'; - $res = DBUtil::getOneResult(array($sQuery, array($iMimeTypeId))); - - if ($res[0] !== null) { - return $res[0]; - } else { - return 'unspecified_type'; - } - } } diff --git a/lib/browse/PartialQuery.inc.php b/lib/browse/PartialQuery.inc.php index bfa6995..c0f3caa 100644 --- a/lib/browse/PartialQuery.inc.php +++ b/lib/browse/PartialQuery.inc.php @@ -365,4 +365,45 @@ class FolderBrowseQuery extends BrowseQuery { } } +class ArchivedBrowseQuery extends BrowseQuery { + function _getDocumentQuery($aOptions = null) { + $oUser = User::get($_SESSION['userID']); + $res = KTSearchUtil::permissionToSQL($oUser, $this->sPermissionName); + if (PEAR::isError($res)) { + return $res; + } + list($sPermissionString, $aPermissionParams, $sPermissionJoin) = $res; + $aPotentialWhere = array($sPermissionString, 'D.folder_id = ?', 'D.status_id = ' . ARCHIVED); + $aWhere = array(); + foreach ($aPotentialWhere as $sWhere) { + if (empty($sWhere)) { + continue; + } + if ($sWhere == "()") { + continue; + } + $aWhere[] = $sWhere; + } + $sWhere = ""; + if ($aWhere) { + $sWhere = "\tWHERE " . join(" AND ", $aWhere); + } + + $sSelect = KTUtil::arrayGet($aOptions, 'select', 'D.id'); + + $sQuery = sprintf("SELECT %s FROM %s AS D + LEFT JOIN %s AS DM ON D.metadata_version_id = DM.id + LEFT JOIN %s AS DC ON DM.content_version_id = DC.id + %s %s", + $sSelect, KTUtil::getTableName("documents"), + KTUtil::getTableName("document_metadata_version"), + KTUtil::getTableName("document_content_version"), + $sPermissionJoin, $sWhere); + $aParams = array(); + $aParams = array_merge($aParams, $aPermissionParams); + $aParams[] = $this->folder_id; + return array($sQuery, $aParams); + } +} + ?> diff --git a/plugins/ktcore/admin/archivedDocuments.php b/plugins/ktcore/admin/archivedDocuments.php index 73a6dba..ffe5c4a 100755 --- a/plugins/ktcore/admin/archivedDocuments.php +++ b/plugins/ktcore/admin/archivedDocuments.php @@ -9,27 +9,102 @@ require_once(KT_LIB_DIR . '/documentmanagement/DocumentTransaction.inc'); require_once(KT_LIB_DIR . "/widgets/fieldWidgets.php"); require_once(KT_LIB_DIR . "/templating/kt3template.inc.php"); +require_once(KT_LIB_DIR . "/browse/DocumentCollection.inc.php"); +require_once(KT_LIB_DIR . "/browse/BrowseColumns.inc.php"); +require_once(KT_LIB_DIR . "/browse/PartialQuery.inc.php"); +require_once(KT_LIB_DIR . "/browse/browseutil.inc.php"); + require_once(KT_LIB_DIR . "/documentmanagement/PhysicalDocumentManager.inc"); // FIXME chain in a notification alert for un-archival requests. +class KTArchiveTitle extends TitleColumn { + + function renderDocumentLink($aDataRow) { + $outStr .= $aDataRow["document"]->getName(); + return $outStr; + } + + function buildFolderLink($aDataRow) { + $baseurl = KTUtil::arrayGet($this->aOptions, "folderurl", ""); + $kt_path_info = KTUtil::arrayGet($_REQUEST, 'kt_path_info'); + if (empty($kt_path_info)) { + return sprintf('%s?fFolderId=%d', $baseurl, $aDataRow["folder"]->getId()); + } else { + return sprintf('%s?kt_path_info=%s&fFolderId=%d', $baseurl, $kt_path_info, $aDataRow["folder"]->getId()); + } + } +} class ArchivedDocumentsDispatcher extends KTAdminDispatcher { function do_main () { $this->aBreadcrumbs[] = array('url' => $_SERVER['PHP_SELF'], 'name' => _('Archived Documents')); - $this->oPage->setBreadcrumbDetails(_('list')); + $this->oPage->setBreadcrumbDetails(_('browse')); + + $oFolder = Folder::get(KTUtil::arrayGet($_REQUEST, 'fFolderId', 1)); + if (PEAR::isError($oFolder)) { + $this->errorRedirectToMain(_('Invalid folder selected.')); + exit(0); + } - $aDocuments =& Document::getList("status_id=" . ARCHIVED); + // Setup the collection for move display. + $collection = new DocumentCollection(); - $oTemplating =& KTTemplating::getSingleton(); - $oTemplate = $oTemplating->loadTemplate('ktcore/document/admin/archivedlist'); - $oTemplate->setData(array( - 'context' => $this, - 'documents' => $aDocuments, - )); - return $oTemplate; + $collection->addColumn(new SelectionColumn("Select","selected_docs[]", false, true)); + $collection->addColumn(new KTArchiveTitle("Archive Documents","title")); + + $qObj = new ArchivedBrowseQuery($oFolder->getId()); + $collection->setQueryObject($qObj); + + $batchPage = (int) KTUtil::arrayGet($_REQUEST, "page", 0); + $batchSize = 20; + + $resultURL = sprintf("?fFolderId=%d&action=browse", $sMoveCode, $oFolder->getId()); + $collection->setBatching($resultURL, $batchPage, $batchSize); + + // ordering. (direction and column) + $displayOrder = KTUtil::arrayGet($_REQUEST, 'sort_order', "asc"); + if ($displayOrder !== "asc") { $displayOrder = "desc"; } + $displayControl = KTUtil::arrayGet($_REQUEST, 'sort_on', "title"); + + $collection->setSorting($displayControl, $displayOrder); + + $collection->getResults(); + + $aBreadcrumbs = array(); + $folder_path_names = $oFolder->getPathArray(); + $folder_path_ids = explode(',', $oFolder->getParentFolderIds()); + if ($folder_path_ids[0] == 0) { + $folder_path_ids = array(); + } + $folder_path_ids[] = $oFolder->getId(); + + foreach (range(0, count($folder_path_ids) - 1) as $index) { + $id = $folder_path_ids[$index]; + $url = sprintf("?fFolderId=%d", $sMoveCode, $id); + $aBreadcrumbs[] = array("url" => $url, "name" => $folder_path_names[$index]); + } + + $oTemplating = new KTTemplating; + $oTemplate = $oTemplating->loadTemplate("ktcore/document/admin/archivebrowse"); + $aTemplateData = array( + "context" => $this, + 'folder' => $oFolder, + 'breadcrumbs' => $aBreadcrumbs, + 'collection' => $collection, + 'collection_breadcrumbs' => $aBreadcrumbs, + ); + + return $oTemplate->render($aTemplateData); + } + + /* + * Provide for "archived" browsing. + */ + function do_browse() { + } function do_confirm_restore() { diff --git a/resources/css/kt-ie-icons.css b/resources/css/kt-ie-icons.css index 6f40127..0d77361 100644 --- a/resources/css/kt-ie-icons.css +++ b/resources/css/kt-ie-icons.css @@ -6,11 +6,6 @@ .ktAction.ktEdit { background: transparent url(../../thirdparty/icon-theme/16x16/actions/document-properties.gif) top left no-repeat; } .ktAction.ktAddUser { background: transparent url(../../thirdparty/icon-theme/16x16/actions/contact-new.gif) top left no-repeat; } .ktAction.ktAddGroup { background: transparent url(../../thirdparty/icon-theme/16x16/actions/contact-new.gif) top left no-repeat; } - -.contenttype { - margin-right: 0; -} - .contenttype.office { background-image: url(../../resources/mimetypes/office.gif); } .contenttype.word { background-image: url(../../resources/mimetypes/word.gif); } .contenttype.excel { background-image: url(../../resources/mimetypes/excel.gif); } diff --git a/templates/ktcore/document/admin/archivedlist.smarty b/templates/ktcore/document/admin/archivedlist.smarty index 97deafb..0519ecb 100644 --- a/templates/ktcore/document/admin/archivedlist.smarty +++ b/templates/ktcore/document/admin/archivedlist.smarty @@ -1,47 +1 @@ -
{i18n}In order to keep the documents which are visible useful -to end users it is possible to archive old documents. Users who -want to see these old documents need to request their restoration. These requests -will typically be done within the system and will generate a -notification to you.{/i18n} -
- -FIXME this aspect of the UI is unuseable. -KT 2.x had a full-on search here. That's probably _also_ unuseable. Ponder an -improvement (probably notification driven / basic search driven. Even better: allow browse -with LIVE turned off.)
{i18n}No documents are marked as archived.{/i18n}