Merge branch 'develop' into seeddms-5.1.x

This commit is contained in:
Uwe Steinmann 2016-04-18 20:56:09 +02:00
commit 6ad8c5a10f
14 changed files with 165 additions and 109 deletions

View File

@ -39,13 +39,21 @@ class SeedDMS_Download_Mgr {
*/
protected $items;
/**
* @var array $extracols list of arrays with extra columns per item
* @access protected
*/
protected $extracols;
function __construct($tmpdir = '') {
$this->tmpdir = $tmpdir;
$this->items = array();
$this->extracols = array();
}
public function addItem($item) { /* {{{ */
public function addItem($item, $extracols) { /* {{{ */
$this->items[$item->getID()] = $item;
$this->extracols[$item->getID()] = $extracols;
} /* }}} */
public function createToc($file) { /* {{{ */
@ -113,9 +121,9 @@ class SeedDMS_Download_Mgr {
$sheet->setCellValueByColumnAndRow($tcol++, $l, getReviewStatusText($r["status"]));
$l++;
}
$col = $tcol;
$l--;
}
$col += 4;
if($approvalStatus) {
foreach ($approvalStatus as $r) {
switch ($r["type"]) {
@ -144,9 +152,13 @@ class SeedDMS_Download_Mgr {
$sheet->setCellValueByColumnAndRow($tcol++, $k, getApprovalStatusText($r["status"]));
$k++;
}
$col = $tcol;
$k--;
}
$col += 4;
if(isset($this->extracols[$item->getID()]) && $this->extracols[$item->getID()]) {
foreach($this->extracols[$item->getID()] as $column)
$sheet->setCellValueByColumnAndRow($col++, $i, $column);
}
$i = max($l, $k);
$i++;
}

View File

@ -33,7 +33,7 @@ if (!$user->isAdmin()) {
if($settings->_backupDir && file_exists($settings->_backupDir))
$basedir = $settings->_backupDir;
else
$basedir = $setting->_contentDir;
$basedir = $settings->_contentDir;
$v = new SeedDMS_Version;
$dump_name = $basedir.date('Y-m-d\TH:i:s')."_".$v->_number.".sql";

View File

@ -27,6 +27,10 @@ include("../inc/inc.Language.php");
include("../inc/inc.ClassUI.php");
include("../inc/inc.Authentication.php");
$tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME']));
$view = UI::factory($theme, $tmp[1], array('dms'=>$dms, 'user'=>$user));
$accessop = new SeedDMS_AccessOperation($dms, $user, $settings);
if (!isset($_GET["folderid"]) || !is_numeric($_GET["folderid"]) || intval($_GET["folderid"])<1) {
UI::exitError(getMLText("folder_title", array("foldername" => getMLText("invalid_folder_id"))),getMLText("invalid_folder_id"));
}
@ -60,8 +64,6 @@ if($settings->_libraryFolder) {
$libfolder = null;
}
$tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME']));
$view = UI::factory($theme, $tmp[1], array('dms'=>$dms, 'user'=>$user));
if($view) {
$view->setParam('folder', $folder);
$view->setParam('strictformcheck', $settings->_strictFormCheck);
@ -75,6 +77,7 @@ if($view) {
$view->setParam('presetexpiration', $settings->_presetExpirationDate);
$view->setParam('sortusersinlist', $settings->_sortUsersInList);
$view->setParam('orderby', $settings->_sortFoldersDefault);
$view->setParam('accessobject', $accessop);
$view($_GET);
exit;
}

View File

@ -28,6 +28,10 @@ include("../inc/inc.DBInit.php");
include("../inc/inc.ClassUI.php");
include("../inc/inc.Authentication.php");
$tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME']));
$view = UI::factory($theme, $tmp[1], array('dms'=>$dms, 'user'=>$user));
$accessop = new SeedDMS_AccessOperation($dms, $user, $settings);
if (!isset($_GET["folderid"]) || !is_numeric($_GET["folderid"]) || intval($_GET["folderid"])<1) {
UI::exitError(getMLText("folder_title", array("foldername" => getMLText("invalid_folder_id"))),getMLText("invalid_folder_id"));
}
@ -40,12 +44,11 @@ if ($folder->getAccessMode($user) < M_READWRITE) {
UI::exitError(getMLText("folder_title", array("foldername" => htmlspecialchars($folder->getName()))),getMLText("access_denied"));
}
$tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME']));
$view = UI::factory($theme, $tmp[1], array('dms'=>$dms, 'user'=>$user));
if($view) {
$view->setParam('folder', $folder);
$view->setParam('strictformcheck', $settings->_strictFormCheck);
$view->setParam('orderby', $settings->_sortFoldersDefault);
$view->setParam('accessobject', $accessop);
$view($_GET);
exit;
}

View File

@ -25,6 +25,10 @@ include("../inc/inc.ClassUI.php");
include("../inc/inc.Calendar.php");
include("../inc/inc.Authentication.php");
$tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME']));
$view = UI::factory($theme, $tmp[1], array('dms'=>$dms, 'user'=>$user));
$accessop = new SeedDMS_AccessOperation($dms, $user, $settings);
if ($user->isGuest()) {
UI::exitError(getMLText("edit_event"),getMLText("access_denied"));
}
@ -42,11 +46,10 @@ if (($user->getID()!=$event["userID"])&&(!$user->isAdmin())){
UI::exitError(getMLText("edit_event"),getMLText("access_denied"));
}
$tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME']));
$view = UI::factory($theme, $tmp[1], array('dms'=>$dms, 'user'=>$user));
if($view) {
$view->setParam('event', $event);
$view->setParam('strictformcheck', $settings->_strictFormCheck);
$view->setParam('accessobject', $accessop);
$view($_GET);
exit;
}

View File

@ -26,6 +26,10 @@ include("../inc/inc.DBInit.php");
include("../inc/inc.ClassUI.php");
include("../inc/inc.Authentication.php");
$tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME']));
$view = UI::factory($theme, $tmp[1], array('dms'=>$dms, 'user'=>$user));
$accessop = new SeedDMS_AccessOperation($dms, $user, $settings);
if (!isset($_GET["folderid"]) || !is_numeric($_GET["folderid"]) || intval($_GET["folderid"])<1) {
UI::exitError(getMLText("folder_title", array("foldername" => getMLText("invalid_folder_id"))),getMLText("invalid_folder_id"));
}
@ -41,14 +45,13 @@ if ($folder->getAccessMode($user) < M_READWRITE) {
$attrdefs = $dms->getAllAttributeDefinitions(array(SeedDMS_Core_AttributeDefinition::objtype_folder, SeedDMS_Core_AttributeDefinition::objtype_all));
$tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME']));
$view = UI::factory($theme, $tmp[1], array('dms'=>$dms, 'user'=>$user));
if($view) {
$view->setParam('folder', $folder);
$view->setParam('attrdefs', $attrdefs);
$view->setParam('strictformcheck', $settings->_strictFormCheck);
$view->setParam('rootfolderid', $settings->_rootFolderID);
$view->setParam('orderby', $settings->_sortFoldersDefault);
$view->setParam('accessobject', $accessop);
$view($_GET);
exit;
}

View File

@ -27,6 +27,10 @@ include("../inc/inc.DBInit.php");
include("../inc/inc.ClassUI.php");
include("../inc/inc.Authentication.php");
$tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME']));
$view = UI::factory($theme, $tmp[1], array('dms'=>$dms, 'user'=>$user));
$accessop = new SeedDMS_AccessOperation($dms, $user, $settings);
if (!isset($_GET["folderid"]) || !is_numeric($_GET["folderid"]) || intval($_GET["folderid"])<1) {
UI::exitError(getMLText("folder_title", array("foldername" => getMLText("invalid_folder_id"))),getMLText("invalid_folder_id"));
}
@ -43,13 +47,12 @@ if ($folder->getAccessMode($user) < M_ALL) {
$allUsers = $dms->getAllUsers();
$allGroups = $dms->getAllGroups();
$tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME']));
$view = UI::factory($theme, $tmp[1], array('dms'=>$dms, 'user'=>$user));
if($view) {
$view->setParam('folder', $folder);
$view->setParam('allusers', $allUsers);
$view->setParam('allgroups', $allGroups);
$view->setParam('rootfolderid', $settings->_rootFolderID);
$view->setParam('accessobject', $accessop);
$view($_GET);
exit;
}

View File

@ -29,6 +29,7 @@ include("../inc/inc.Authentication.php");
$tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME']));
$view = UI::factory($theme, $tmp[1], array('dms'=>$dms, 'user'=>$user));
$accessop = new SeedDMS_AccessOperation($dms, $user, $settings);
if (!isset($_GET["folderid"]) || !is_numeric($_GET["folderid"]) || intval($_GET["folderid"])<1) {
UI::exitError(getMLText("folder_title", array("foldername" => getMLText("invalid_folder_id"))),getMLText("invalid_folder_id"));
@ -51,6 +52,7 @@ if($view) {
$view->setParam('allusers', $allUsers);
$view->setParam('allgroups', $allGroups);
$view->setParam('strictformcheck', $settings->_strictFormCheck);
$view->setParam('accessobject', $accessop);
$view($_GET);
exit;
}

View File

@ -27,6 +27,10 @@ include("../inc/inc.DBInit.php");
include("../inc/inc.ClassUI.php");
include("../inc/inc.Authentication.php");
$tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME']));
$view = UI::factory($theme, $tmp[1], array('dms'=>$dms, 'user'=>$user));
$accessop = new SeedDMS_AccessOperation($dms, $user, $settings);
if (!isset($_GET["folderid"]) || !is_numeric($_GET["folderid"]) || intval($_GET["folderid"])<1) {
UI::exitError(getMLText("folder_title", array("foldername" => getMLText("invalid_folder_id"))),getMLText("invalid_folder_id"));
}
@ -62,11 +66,10 @@ if(isset($_GET['targetid']) && $_GET['targetid']) {
$target = null;
}
$tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME']));
$view = UI::factory($theme, $tmp[1], array('dms'=>$dms, 'user'=>$user));
if($view) {
$view->setParam('folder', $folder);
$view->setParam('target', $target);
$view->setParam('accessobject', $accessop);
$view($_GET);
exit;
}

View File

@ -26,6 +26,10 @@ include("../inc/inc.DBInit.php");
include("../inc/inc.ClassUI.php");
include("../inc/inc.Authentication.php");
$tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME']));
$view = UI::factory($theme, $tmp[1], array('dms'=>$dms, 'user'=>$user));
$accessop = new SeedDMS_AccessOperation($dms, $user, $settings);
if (!isset($_GET["folderid"]) || !is_numeric($_GET["folderid"]) || intval($_GET["folderid"])<1) {
UI::exitError(getMLText("folder_title", array("foldername" => getMLText("invalid_folder_id"))),getMLText("invalid_folder_id"));
}
@ -44,10 +48,9 @@ if ($folder->getAccessMode($user) < M_ALL) {
UI::exitError(getMLText("folder_title", array("foldername" => htmlspecialchars($folder->getName()))),getMLText("access_denied"));
}
$tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME']));
$view = UI::factory($theme, $tmp[1], array('dms'=>$dms, 'user'=>$user));
if($view) {
$view->setParam('folder', $folder);
$view->setParam('accessobject', $accessop);
$view($_GET);
exit;
}

View File

@ -360,7 +360,7 @@ if(isset($_GET["fullsearch"]) && $_GET["fullsearch"] && $settings->_enableFullSe
$pageNumber = (int) $_GET["pg"];
}
elseif (!strcasecmp($_GET["pg"], "all")) {
// $limit = 0;
$pageNumber = "all";
}
}
@ -393,59 +393,28 @@ if(isset($_GET["fullsearch"]) && $_GET["fullsearch"] && $settings->_enableFullSe
}
}
}
if(isset($_GET['export']) && $_GET['export']) {
include("../inc/inc.ClassDownloadMgr.php");
$downmgr = new SeedDMS_Download_Mgr();
foreach($entries as $entry) {
if(get_class($entry) == $dms->getClassname('document')) {
$downmgr->addItem($entry->getLatestContent());
}
}
$filename = tempnam('/tmp', '');
if(isset($_GET['includecontent']) && $_GET['includecontent']) {
$downmgr->createArchive($filename);
header("Content-Transfer-Encoding: binary");
header("Content-Length: " . filesize($filename));
header("Content-Disposition: attachment; filename=\"export-" .date('Y-m-d') . ".zip\"");
header("Content-Type: application/zip");
header("Cache-Control: must-revalidate");
} else {
$downmgr->createToc($filename);
header("Content-Transfer-Encoding: binary");
header("Content-Length: " . filesize($filename));
header("Content-Disposition: attachment; filename=\"export-" .date('Y-m-d') . ".xls\"");
header("Content-Type: application/vnd.ms-excel");
header("Cache-Control: must-revalidate");
}
readfile($filename);
unlink($filename);
exit;
}
$totalPages = (int) (count($entries)/$limit);
if(count($entries)%$limit)
$totalPages++;
if (!isset($_GET["pg"]) || strcasecmp($_GET["pg"], "all"))
$entries = array_slice($entries, ($pageNumber-1)*$limit, $limit);
// }}}
}
// -------------- Output results --------------------------------------------
if(count($entries) == 1) {
$entry = $entries[0];
if(get_class($entry) == $dms->getClassname('document')) {
header('Location: ../out/out.ViewDocument.php?documentid='.$entry->getID());
exit;
} elseif(get_class($entry) == $dms->getClassname('folder')) {
header('Location: ../out/out.ViewFolder.php?folderid='.$entry->getID());
exit;
}
} else {
$tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME']));
$view = UI::factory($theme, $tmp[1], array('dms'=>$dms, 'user'=>$user, 'query'=>$query, 'searchhits'=>$entries, 'totalpages'=>$totalPages, 'pagenumber'=>$pageNumber, 'searchtime'=>$searchTime, 'urlparams'=>$_GET, 'cachedir'=>$settings->_cacheDir));
$view = UI::factory($theme, $tmp[1], array('dms'=>$dms, 'user'=>$user));
$accessop = new SeedDMS_AccessOperation($dms, $user, $settings);
if($view) {
$view->setParam('accessobject', $accessop);
$view->setParam('query', $query);
$view->setParam('searchhits', $entries);
$view->setParam('totalpages', $totalPages);
$view->setParam('pagenumber', $pageNumber);
$view->setParam('limit', $limit);
$view->setParam('searchtime', $searchTime);
$view->setParam('urlparams', $_GET);
$view->setParam('cachedir', $settings->_cacheDir);
$view->setParam('totaldocs', $dcount /*resArr['totalDocs']*/);
$view->setParam('totalfolders', $fcount /*resArr['totalFolders']*/);
$view->setParam('fullsearch', (isset($_GET["fullsearch"]) && $_GET["fullsearch"] && $settings->_enableFullSearch) ? true : false);
@ -478,5 +447,4 @@ if(count($entries) == 1) {
$view($_GET);
exit;
}
}
?>

View File

@ -25,16 +25,19 @@ include("../inc/inc.DBInit.php");
include("../inc/inc.ClassUI.php");
include("../inc/inc.Authentication.php");
$tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME']));
$view = UI::factory($theme, $tmp[1], array('dms'=>$dms, 'user'=>$user));
$accessop = new SeedDMS_AccessOperation($dms, $user, $settings);
if ($user->isGuest()) {
UI::exitError(getMLText("edit_default_keywords"),getMLText("access_denied"));
}
$categories = $dms->getAllUserKeywordCategories($user->getID());
$tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME']));
$view = UI::factory($theme, $tmp[1], array('dms'=>$dms, 'user'=>$user));
if($view) {
$view->setParam('categories', $categories);
$view->setParam('accessobject', $accessop);
$view($_GET);
exit;
}

View File

@ -25,6 +25,9 @@ include("../inc/inc.ClassUI.php");
include("../inc/inc.Calendar.php");
include("../inc/inc.Authentication.php");
$tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME']));
$view = UI::factory($theme, $tmp[1], array('dms'=>$dms, 'user'=>$user));
$accessop = new SeedDMS_AccessOperation($dms, $user, $settings);
if (!isset($_GET["id"])){
UI::exitError(getMLText("event_details"),getMLText("error_occured"));
}
@ -34,10 +37,9 @@ if (is_bool($event)&&!$event){
UI::exitError(getMLText("event_details"),getMLText("error_occured"));
}
$tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME']));
$view = UI::factory($theme, $tmp[1], array('dms'=>$dms, 'user'=>$user));
if($view) {
$view->setParam('event', $event);
$view->setParam('accessobject', $accessop);
$view($_GET);
exit;
}

View File

@ -49,18 +49,60 @@ class SeedDMS_View_Search extends SeedDMS_Bootstrap_Style {
function js() { /* {{{ */
header('Content-Type: application/javascript');
?>
$(document).ready( function() {
$('#export').on('click', function(e) {
e.preventDefault();
window.location.href = $(this).attr('href')+'&includecontent='+($('#includecontent').prop('checked') ? '1' : '0');
});
});
<?php
$this->printFolderChooserJs("form1");
$this->printDeleteFolderButtonJs();
$this->printDeleteDocumentButtonJs();
} /* }}} */
function export() { /* {{{ */
$dms = $this->params['dms'];
$user = $this->params['user'];
$entries = $this->params['searchhits'];
include("../inc/inc.ClassDownloadMgr.php");
$downmgr = new SeedDMS_Download_Mgr();
foreach($entries as $entry) {
if(get_class($entry) == $dms->getClassname('document')) {
$extracols = $this->callHook('extraDownloadColumns', $entry);
$downmgr->addItem($entry->getLatestContent(), $extracols);
}
}
$filename = tempnam('/tmp', '');
if(isset($_GET['includecontent']) && $_GET['includecontent']) {
$downmgr->createArchive($filename);
header("Content-Transfer-Encoding: binary");
header("Content-Length: " . filesize($filename));
header("Content-Disposition: attachment; filename=\"export-" .date('Y-m-d') . ".zip\"");
header("Content-Type: application/zip");
header("Cache-Control: must-revalidate");
} else {
$downmgr->createToc($filename);
header("Content-Transfer-Encoding: binary");
header("Content-Length: " . filesize($filename));
header("Content-Disposition: attachment; filename=\"export-" .date('Y-m-d') . ".xls\"");
header("Content-Type: application/vnd.ms-excel");
header("Cache-Control: must-revalidate");
}
readfile($filename);
unlink($filename);
} /* }}} */
function show() { /* {{{ */
$dms = $this->params['dms'];
$user = $this->params['user'];
$fullsearch = $this->params['fullsearch'];
$totaldocs = $this->params['totaldocs'];
$totalfolders = $this->params['totalfolders'];
$limit = $this->params['limit'];
$attrdefs = $this->params['attrdefs'];
$allCats = $this->params['allcategories'];
$allUsers = $this->params['allusers'];
@ -92,6 +134,20 @@ class SeedDMS_View_Search extends SeedDMS_Bootstrap_Style {
$previewconverters = $this->params['previewconverters'];
$timeout = $this->params['timeout'];
if(count($entries) == 1) {
$entry = $entries[0];
if(get_class($entry) == $dms->getClassname('document')) {
header('Location: ../out/out.ViewDocument.php?documentid='.$entry->getID());
exit;
} elseif(get_class($entry) == $dms->getClassname('folder')) {
header('Location: ../out/out.ViewFolder.php?folderid='.$entry->getID());
exit;
}
}
if ($pageNumber != 'all')
$entries = array_slice($entries, ($pageNumber-1)*$limit, $limit);
$this->htmlAddHeader('<script type="text/javascript" src="../styles/'.$this->theme.'/bootbox/bootbox.min.js"></script>'."\n", 'js');
$this->htmlStartPage(getMLText("search_results"));
@ -249,17 +305,9 @@ class SeedDMS_View_Search extends SeedDMS_Bootstrap_Style {
<td><?= getMLText('content') ?></td><td><label class="checkbox inline"><input id="includecontent" type="checkbox" name="includecontent" value="1"> <?php printMLText("include_content"); ?></label></td>
</tr>
<tr>
<td></td><td><a id="export" class="btn" href="<?= $_SERVER['REQUEST_URI']."&export=1" ?>"><i class="icon-download"></i> Export</a></td>
<td></td><td><a id="export" class="btn" href="<?= $_SERVER['REQUEST_URI']."&action=export" ?>"><i class="icon-download"></i> Export</a></td>
</tr>
</table>
<script>
$(document).ready( function() {
$('#export').on('click', function(e) {
e.preventDefault();
window.location.href = $(this).attr('href')+'&includecontent='+($('#includecontent').prop('checked') ? '1' : '0');
});
});
</script>
</div>
</div>
</div>