mirror of
				https://git.code.sf.net/p/seeddms/code
				synced 2025-10-31 13:18:06 +00:00 
			
		
		
		
	add SeedDMS_Core_Folder::reorderDocuments()
This commit is contained in:
		
							parent
							
								
									9c715a7071
								
							
						
					
					
						commit
						b2fd46dac0
					
				|  | @ -2068,6 +2068,40 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object { | |||
| 		return $resArr[0]; | ||||
| 	} /* }}} */ | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Reorder documents of folder | ||||
| 	 * | ||||
| 	 * Fix the sequence numbers of all documents in the folder, by assigning new | ||||
| 	 * numbers starting from 1 incrementing by 1. This can be necessary if sequence | ||||
| 	 * numbers are not unique which makes manual reordering for documents with | ||||
| 	 * identical sequence numbers impossible. | ||||
| 	 * | ||||
| 	 * @return bool false in case of an error, otherwise true | ||||
| 	 */ | ||||
| 	function reorderDocuments() { /* {{{ */ | ||||
| 		$db = $this->_dms->getDB(); | ||||
| 
 | ||||
| 		$queryStr = "SELECT `id` FROM `tblDocuments` WHERE `folder` = " . (int) $this->_id; | ||||
| 		$resArr = $db->getResultArray($queryStr); | ||||
| 		if (is_bool($resArr) && $resArr == false) | ||||
| 			return false; | ||||
| 
 | ||||
| 		$db->startTransaction(); | ||||
| 		$no = 1.0; | ||||
| 		foreach($resArr as $doc) { | ||||
| 			$queryStr = "UPDATE `tblDocuments` SET `sequence` = " . $no . " WHERE `id` = ". $doc['id']; | ||||
| 			if (!$db->getResult($queryStr)) { | ||||
| 				$db->rollbackTransaction(); | ||||
| 				return false; | ||||
| 			} | ||||
| 			$no += 1.0; | ||||
| 		} | ||||
| 		$db->commitTransaction(); | ||||
| 
 | ||||
| 		return true; | ||||
| 	} /* }}} */ | ||||
| 
 | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| ?>
 | ||||
|  |  | |||
|  | @ -29,7 +29,7 @@ | |||
| - SeedDMS_Core_DMS::createPasswordRequest() creates a cryptographically secure hash | ||||
| - fix sql error when deleting a folder attribute | ||||
| - add SeedDMS_Core_Attribute::getParsedValue() and use it in SeedDMS_Core_Object::getAttributeValue() | ||||
| - add SeedDMS_Core_DMS::getDuplicateSequenceNo() | ||||
| - add SeedDMS_Core_DMS::getDuplicateSequenceNo() and SeedDMS_Core_Folder::reorderDocuments() | ||||
|  </notes> | ||||
|  <contents> | ||||
|   <dir baseinstalldir="SeedDMS" name="/"> | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Uwe Steinmann
						Uwe Steinmann