mirror of
				https://git.code.sf.net/p/seeddms/code
				synced 2025-10-31 13:18:06 +00:00 
			
		
		
		
	new batch operation for adding reviewer/approver
This commit is contained in:
		
							parent
							
								
									aa80886ced
								
							
						
					
					
						commit
						e0973e4a21
					
				|  | @ -140,6 +140,8 @@ class Settings { /* {{{ */ | |||
| 	var $_defaultSearchMethod = 'database'; // or 'fulltext'
 | ||||
| 	// suggest search term
 | ||||
| 	var $_suggestTerms = array(); // or 'all', 'title'
 | ||||
| 	// allowed batch operations on search result
 | ||||
| 	var $_batchOperations = array(); // or 'all', 'change_owner', etc.
 | ||||
| 	// jump straight to the document if it is the only hit of a search
 | ||||
| 	var $_showSingleSearchHit = true; | ||||
| 	// contentOffsetDirTo
 | ||||
|  | @ -569,6 +571,8 @@ class Settings { /* {{{ */ | |||
| 		$this->_defaultSearchMethod = strval($tab["defaultSearchMethod"]); | ||||
| 		if(trim(strval($tab["suggestTerms"]))) | ||||
| 			$this->_suggestTerms = explode(',',strval($tab["suggestTerms"])); | ||||
| 		if(trim(strval($tab["batchOperations"]))) | ||||
| 			$this->_batchOperations = explode(',',strval($tab["batchOperations"])); | ||||
| 		$this->_showSingleSearchHit = Settings::boolVal($tab["showSingleSearchHit"]); | ||||
| 		$this->_stopWordsFile = strval($tab["stopWordsFile"]); | ||||
| 		$this->_sortUsersInList = strval($tab["sortUsersInList"]); | ||||
|  | @ -971,6 +975,7 @@ class Settings { /* {{{ */ | |||
|     $this->setXMLAttributValue($node, "fullSearchEngine", $this->_fullSearchEngine); | ||||
|     $this->setXMLAttributValue($node, "defaultSearchMethod", $this->_defaultSearchMethod); | ||||
|     $this->setXMLAttributValue($node, "suggestTerms", implode(',', $this->_suggestTerms)); | ||||
|     $this->setXMLAttributValue($node, "batchOperations", implode(',', $this->_batchOperations)); | ||||
|     $this->setXMLAttributValue($node, "showSingleSearchHit", $this->_showSingleSearchHit); | ||||
|     $this->setXMLAttributValue($node, "expandFolderTree", $this->_expandFolderTree); | ||||
|     $this->setXMLAttributValue($node, "stopWordsFile", $this->_stopWordsFile); | ||||
|  |  | |||
|  | @ -134,6 +134,7 @@ if ($action == "saveSettings") | |||
| 	setStrValue('fullSearchEngine'); | ||||
| 	setStrValue('defaultSearchMethod'); | ||||
| 	setStrValue('suggestTerms'); | ||||
| 	setStrValue('batchOperations'); | ||||
|   setBoolValue("showSingleSearchHit"); | ||||
|   setBoolValue("enableSessionList"); | ||||
|   setBoolValue("enableClipboard"); | ||||
|  |  | |||
|  | @ -57,6 +57,16 @@ if (isset($_GET["newowner"]) && is_numeric($_GET["newowner"]) && $_GET['newowner | |||
| 	$newowner = $dms->getUser((int) $_GET['newowner']); | ||||
| } | ||||
| 
 | ||||
| $newreviewer = null; | ||||
| if (isset($_GET["newreviewer"]) && is_numeric($_GET["newreviewer"]) && $_GET['newreviewer'] > 0) { | ||||
| 	$newreviewer = $dms->getUser((int) $_GET['newreviewer']); | ||||
| } | ||||
| 
 | ||||
| $newapprover = null; | ||||
| if (isset($_GET["newapprover"]) && is_numeric($_GET["newapprover"]) && $_GET['newapprover'] > 0) { | ||||
| 	$newapprover = $dms->getUser((int) $_GET['newapprover']); | ||||
| } | ||||
| 
 | ||||
| $changecategory = null; | ||||
| if (isset($_GET["changecategory"]) && is_numeric($_GET["changecategory"]) && $_GET['changecategory'] > 0) { | ||||
| 	$changecategory = $dms->getDocumentCategory((int) $_GET['changecategory']); | ||||
|  | @ -710,6 +720,8 @@ if($settings->_showSingleSearchHit && count($entries) == 1) { | |||
| 		$view->setParam('includecontent', $includecontent); | ||||
| 		$view->setParam('marks', isset($_GET['marks']) ? $_GET['marks'] : array()); | ||||
| 		$view->setParam('newowner', $newowner); | ||||
| 		$view->setParam('newreviewer', $newreviewer); | ||||
| 		$view->setParam('newapprover', $newapprover); | ||||
| 		$view->setParam('changecategory', $changecategory); | ||||
| 		$view->setParam('removecategory', $removecategory); | ||||
| 		$view->setParam('searchhits', $entries); | ||||
|  |  | |||
|  | @ -107,6 +107,50 @@ $(document).ready( function() { | |||
| 			}); | ||||
| 		} | ||||
| 	}); | ||||
| 
 | ||||
| 	$('body').on('click', 'a.add-reviewer-btn', function(ev){ | ||||
| 		ev.preventDefault(); | ||||
| 		ev.stopPropagation(); | ||||
| console.log('add reviewer '+$('#addreviewer').val()); | ||||
| 		confirmmsg = $(ev.currentTarget).attr('confirmmsg'); | ||||
| 		href = $(ev.currentTarget).attr('href'); | ||||
| 		var url = href+'&newreviewer='+($('#addreviewer').val()); | ||||
| 		var values = {}; | ||||
| 		$('input[name^=\"marks\"]').each(function() { | ||||
| 			if(this.checked) | ||||
| 				values[this.name] = 1; | ||||
| 		}); | ||||
| 		url += '&'+$.param(values); | ||||
| 		if($('#addreviewer').val() && Object.keys(values).length > 0) { | ||||
| 			SeedDMSBox.redirect(url, { | ||||
| 				'message': confirmmsg, | ||||
| 				'cancelLabel': '<?= getMLText("cancel") ?>', | ||||
| 				'confirmLabel': '<i class="fa fa-user"></i> <?= getMLText("batch_add_reviewer") ?>' | ||||
| 			}); | ||||
| 		} | ||||
| 	}); | ||||
| 
 | ||||
| 	$('body').on('click', 'a.add-approver-btn', function(ev){ | ||||
| 		ev.preventDefault(); | ||||
| 		ev.stopPropagation(); | ||||
| console.log('add approver '+$('#addapprover').val()); | ||||
| 		confirmmsg = $(ev.currentTarget).attr('confirmmsg'); | ||||
| 		href = $(ev.currentTarget).attr('href'); | ||||
| 		var url = href+'&newapprover='+($('#addapprover').val()); | ||||
| 		var values = {}; | ||||
| 		$('input[name^=\"marks\"]').each(function() { | ||||
| 			if(this.checked) | ||||
| 				values[this.name] = 1; | ||||
| 		}); | ||||
| 		url += '&'+$.param(values); | ||||
| 		if($('#addapprover').val() && Object.keys(values).length > 0) { | ||||
| 			SeedDMSBox.redirect(url, { | ||||
| 				'message': confirmmsg, | ||||
| 				'cancelLabel': '<?= getMLText("cancel") ?>', | ||||
| 				'confirmLabel': '<i class="fa fa-user"></i> <?= getMLText("batch_add_approver") ?>' | ||||
| 			}); | ||||
| 		} | ||||
| 	}); | ||||
| }); | ||||
| <?php | ||||
| //		$this->printFolderChooserJs("form1");
 | ||||
|  | @ -245,6 +289,58 @@ $(document).ready(function() { | |||
| 		return self::show(); | ||||
| 	} /* }}} */ | ||||
| 
 | ||||
| 	function addreviewer() { /* {{{ */ | ||||
| 		$dms = $this->params['dms']; | ||||
| 		$user = $this->params['user']; | ||||
| 		$entries = $this->params['searchhits']; | ||||
| 		$newreviewer = $this->params['newreviewer']; | ||||
| 		$marks = $this->params['marks']; | ||||
| 
 | ||||
| 		if($newreviewer && $user->isAdmin()) { | ||||
| 			$j = $i = 0; | ||||
| 			foreach($entries as $entry) { | ||||
| 				if($entry->isType('document') && $lc = $entry->getLatestContent()) {  | ||||
| 					if(empty($marks) || !empty($marks['D'.$entry->getId()])) { | ||||
| 						if($lc->addIndReviewer($newreviewer, $user)) { | ||||
| 							$lc->verifyStatus(true, $user); | ||||
| 							$j++; | ||||
| 						} | ||||
| 					} | ||||
| 				} | ||||
| 			} | ||||
| 			$this->setParam('batchmsg', getMLText('batch_add_reviewer_msg', ['count'=>$j, 'name'=>$newreviewer->getFullName()])); | ||||
| 		} else { | ||||
| 		} | ||||
| 
 | ||||
| 		return self::show(); | ||||
| 	} /* }}} */ | ||||
| 
 | ||||
| 	function addapprover() { /* {{{ */ | ||||
| 		$dms = $this->params['dms']; | ||||
| 		$user = $this->params['user']; | ||||
| 		$entries = $this->params['searchhits']; | ||||
| 		$newapprover = $this->params['newapprover']; | ||||
| 		$marks = $this->params['marks']; | ||||
| 
 | ||||
| 		if($newapprover && $user->isAdmin()) { | ||||
| 			$j = $i = 0; | ||||
| 			foreach($entries as $entry) { | ||||
| 				if($entry->isType('document') && $lc = $entry->getLatestContent()) {  | ||||
| 					if(empty($marks) || !empty($marks['D'.$entry->getId()])) { | ||||
| 						if($lc->addIndApprover($newapprover, $user)) { | ||||
| 							$lc->verifyStatus(true, $user); | ||||
| 							$j++; | ||||
| 						} | ||||
| 					} | ||||
| 				} | ||||
| 			} | ||||
| 			$this->setParam('batchmsg', getMLText('batch_add_approver_msg', ['count'=>$j, 'name'=>$newapprover->getFullName()])); | ||||
| 		} else { | ||||
| 		} | ||||
| 
 | ||||
| 		return self::show(); | ||||
| 	} /* }}} */ | ||||
| 
 | ||||
| 	function changecategory() { /* {{{ */ | ||||
| 		$dms = $this->params['dms']; | ||||
| 		$user = $this->params['user']; | ||||
|  | @ -1329,6 +1425,7 @@ $(document).ready(function() { | |||
| 		if($total) | ||||
| 			$this->contentHeading(getMLText('batch_operation')); | ||||
| 		if($totaldocs) { | ||||
| 			if(in_array('export', $settings->_batchOperations)) { | ||||
| 			ob_start(); | ||||
| 			$this->formField( | ||||
| 				getMLText("include_content"), | ||||
|  | @ -1341,12 +1438,15 @@ $(document).ready(function() { | |||
| 				) | ||||
| 			); | ||||
| 			//$this->formSubmit("<i class=\"fa fa-download\"></i> ".getMLText('export'));
 | ||||
| 			print $this->html_link('Search', array_merge($_GET, array('action'=>'export')), array('class'=>'btn btn-primary', 'id'=>'export'), "<i class=\"fa fa-download\"></i> ".getMLText("export"), false, true)."\n"; | ||||
| 			print $this->html_link('Search', array_merge($_GET, array('action'=>'export')), array('class'=>'btn btn-primary', 'id'=>'export'), "<i class=\"fa fa-download\"></i> ".getMLText("batch_export"), false, true)."\n"; | ||||
| 			$content = ob_get_clean(); | ||||
| 			$this->printAccordion(getMLText('export'), $content); | ||||
| 			} | ||||
| 		} | ||||
| 
 | ||||
| 		if($user->isAdmin() && $total) { | ||||
| 		/* All other batch operations are only allowed for admins */ | ||||
| 		if($user->isAdmin()) { | ||||
| 			if($total && in_array('change_owner', $settings->_batchOperations)) { | ||||
| 			ob_start(); | ||||
| 			$users = $dms->getAllUsers(); | ||||
| 			$options = array(); | ||||
|  | @ -1371,7 +1471,61 @@ $(document).ready(function() { | |||
| 
 | ||||
| 			$content = ob_get_clean(); | ||||
| 			$this->printAccordion(getMLText('batch_change_owner'), $content); | ||||
| 			} | ||||
| 
 | ||||
| 			if($totaldocs && in_array('add_reviewer', $settings->_batchOperations)) { | ||||
| 			ob_start(); | ||||
| 			$users = $dms->getAllUsers(); | ||||
| 			$options = array(); | ||||
| 			foreach ($users as $currUser) { | ||||
| 				$options[] = array($currUser->getID(), htmlspecialchars($currUser->getLogin().' - '.$currUser->getFullName()), false, array(array('data-subtitle', htmlspecialchars($currUser->getEmail())))); | ||||
| 			} | ||||
| 			$this->formField( | ||||
| 				null, //getMLText("selection"),
 | ||||
| 				array( | ||||
| 					'element'=>'select', | ||||
| 					'id'=>'addreviewer', | ||||
| 					'class'=>'chzn-select', | ||||
| 					'options'=>$options, | ||||
| 					'allow_empty'=>true, | ||||
| 					'placeholder'=>getMLText('select_users'), | ||||
| 					'attributes'=>array(array('style', 'width: 100%;')) | ||||
| 				) | ||||
| 			); | ||||
| 
 | ||||
| 			print $this->html_link('Search', array_merge($_GET, array('action'=>'addreviewer')), array('class'=>'btn btn-primary add-reviewer-btn mt-4', 'confirmmsg'=>htmlspecialchars(getMLText("confirm_add_reviewer", array ()), ENT_QUOTES)), "<i class=\"fa fa-user\"></i> ".getMLText("batch_add_reviewer"), false, true)."\n"; | ||||
| 
 | ||||
| 			$content = ob_get_clean(); | ||||
| 			$this->printAccordion(getMLText('batch_add_reviewer'), $content); | ||||
| 			} | ||||
| 
 | ||||
| 			if($totaldocs && in_array('add_approver', $settings->_batchOperations)) { | ||||
| 			ob_start(); | ||||
| 			$users = $dms->getAllUsers(); | ||||
| 			$options = array(); | ||||
| 			foreach ($users as $currUser) { | ||||
| 				$options[] = array($currUser->getID(), htmlspecialchars($currUser->getLogin().' - '.$currUser->getFullName()), false, array(array('data-subtitle', htmlspecialchars($currUser->getEmail())))); | ||||
| 			} | ||||
| 			$this->formField( | ||||
| 				null, //getMLText("selection"),
 | ||||
| 				array( | ||||
| 					'element'=>'select', | ||||
| 					'id'=>'addapprover', | ||||
| 					'class'=>'chzn-select', | ||||
| 					'options'=>$options, | ||||
| 					'allow_empty'=>true, | ||||
| 					'placeholder'=>getMLText('select_users'), | ||||
| 					'attributes'=>array(array('style', 'width: 100%;')) | ||||
| 				) | ||||
| 			); | ||||
| 
 | ||||
| 			print $this->html_link('Search', array_merge($_GET, array('action'=>'addapprover')), array('class'=>'btn btn-primary add-approver-btn mt-4', 'confirmmsg'=>htmlspecialchars(getMLText("confirm_add_approver", array ()), ENT_QUOTES)), "<i class=\"fa fa-user\"></i> ".getMLText("batch_add_approver"), false, true)."\n"; | ||||
| 
 | ||||
| 			$content = ob_get_clean(); | ||||
| 			$this->printAccordion(getMLText('batch_add_approver'), $content); | ||||
| 			} | ||||
| 
 | ||||
| 			if($totaldocs && in_array('change_category', $settings->_batchOperations)) { | ||||
| 			ob_start(); | ||||
| 			$cats = $dms->getDocumentCategories(); | ||||
| 			if($cats) { | ||||
|  | @ -1407,6 +1561,7 @@ $(document).ready(function() { | |||
| 				$content = ob_get_clean(); | ||||
| 				$this->printAccordion(getMLText('batch_change_category'), $content); | ||||
| 			} | ||||
| 			} | ||||
| 		} | ||||
| 		// }}}
 | ||||
| 
 | ||||
|  |  | |||
|  | @ -404,6 +404,7 @@ if(($kkk = $this->callHook('getFullSearchEngine')) && is_array($kkk)) | |||
| <?php $this->showConfigOption('settings_defaultSearchMethod', 'defaultSearchMethod', array('database'=>'settings_defaultSearchMethod_valdatabase', 'fulltext'=>'settings_defaultSearchMethod_valfulltext'), false, true); ?>
 | ||||
| <?php $this->showConfigCheckbox('settings_showSingleSearchHit', 'showSingleSearchHit'); ?>
 | ||||
| <?php $this->showConfigOption('settings_suggestTerms', 'suggestTerms', array('title','comment', 'keywords', 'content'), true, true); ?>
 | ||||
| <?php $this->showConfigOption('settings_batchOperations', 'batchOperations', array('export'=>'batch_export', 'change_category'=>'batch_change_category', 'change_owner'=>'batch_change_owner', 'add_reviewer'=>'batch_add_reviewer', 'add_approver'=>'batch_add_approver', 'change_category'=>'batch_change_category'), true, true); ?>
 | ||||
| <?php $this->showConfigText('settings_stopWordsFile', 'stopWordsFile'); ?>
 | ||||
| <?php $this->showConfigCheckbox('settings_enableClipboard', 'enableClipboard'); ?>
 | ||||
| <?php $this->showConfigCheckbox('settings_alwaysShowClipboard', 'alwaysShowClipboard'); ?>
 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Uwe Steinmann
						Uwe Steinmann