mirror of
				http://git.whoc.org.uk/git/password-manager.git
				synced 2025-10-31 11:27:34 +01:00 
			
		
		
		
	Fix timestamps on records
- update the access and update date when a record is saved - set the creation date when a record is created
This commit is contained in:
		| @@ -375,6 +375,13 @@ error_log("message"); | |||||||
| 					$user = $user->Get($_SESSION["userId"]); | 					$user = $user->Get($_SESSION["userId"]); | ||||||
| 					 | 					 | ||||||
| 					$result["header"] =		$user->header; | 					$result["header"] =		$user->header; | ||||||
|  | 					$records = $user->GetRecordList(); | ||||||
|  | 					foreach ($records as $record) | ||||||
|  | 					{ | ||||||
|  | 						$recordStats["updateDate"] = $record->update_date; | ||||||
|  | 						$recordsStats[$record->reference] = $recordStats; | ||||||
|  | 					} | ||||||
|  | 					$result["recordsStats"] = $recordsStats; | ||||||
| 					$result["statistics"] =	$user->statistics; | 					$result["statistics"] =	$user->statistics; | ||||||
| 					$result["version"] =	$user->version; | 					$result["version"] =	$user->version; | ||||||
|  |  | ||||||
|   | |||||||
| @@ -9,7 +9,7 @@ | |||||||
| 	`data` LONGTEXT NOT NULL, | 	`data` LONGTEXT NOT NULL, | ||||||
| 	`version` VARCHAR(255) NOT NULL, | 	`version` VARCHAR(255) NOT NULL, | ||||||
| 	`creation_date` TIMESTAMP NOT NULL, | 	`creation_date` TIMESTAMP NOT NULL, | ||||||
| 	`update_date` TIMESTAMP NOT NULL, | 	`update_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, | ||||||
| 	`access_date` TIMESTAMP NOT NULL, INDEX(`userid`), PRIMARY KEY  (`recordid`)) ENGINE=MyISAM; | 	`access_date` TIMESTAMP NOT NULL, INDEX(`userid`), PRIMARY KEY  (`recordid`)) ENGINE=MyISAM; | ||||||
| */ | */ | ||||||
|  |  | ||||||
| @@ -126,7 +126,8 @@ class record extends POG_Base | |||||||
| 			$this->data = $this->Unescape($row['data']); | 			$this->data = $this->Unescape($row['data']); | ||||||
| 			$this->version = $this->Unescape($row['version']); | 			$this->version = $this->Unescape($row['version']); | ||||||
| 			$this->creation_date = $row['creation_date']; | 			$this->creation_date = $row['creation_date']; | ||||||
| 			$this->update_date = $row['update_date']; | 			$oDate = strtotime($row['update_date']); | ||||||
|  | 			$this->update_date = date('r', $oDate); | ||||||
| 			$this->access_date = $row['access_date']; | 			$this->access_date = $row['access_date']; | ||||||
| 		} | 		} | ||||||
| 		return $this; | 		return $this; | ||||||
| @@ -218,7 +219,8 @@ class record extends POG_Base | |||||||
| 			$record->data = $this->Unescape($row['data']); | 			$record->data = $this->Unescape($row['data']); | ||||||
| 			$record->version = $this->Unescape($row['version']); | 			$record->version = $this->Unescape($row['version']); | ||||||
| 			$record->creation_date = $row['creation_date']; | 			$record->creation_date = $row['creation_date']; | ||||||
| 			$record->update_date = $row['update_date']; | 			$oDate = strtotime($row['update_date']); | ||||||
|  | 			$record->update_date = date('r', $oDate); | ||||||
| 			$record->access_date = $row['access_date']; | 			$record->access_date = $row['access_date']; | ||||||
| 			$recordList[] = $record; | 			$recordList[] = $record; | ||||||
| 		} | 		} | ||||||
| @@ -233,6 +235,8 @@ class record extends POG_Base | |||||||
| 	function Save($deep = true) | 	function Save($deep = true) | ||||||
| 	{ | 	{ | ||||||
| 		$connection = Database::Connect(); | 		$connection = Database::Connect(); | ||||||
|  | 		$this->update_date = date( 'r'); | ||||||
|  | 		$this->access_date = date( 'r'); | ||||||
| 		$this->pog_query = "select `recordid` from `record` where `recordid`='".$this->recordId."' LIMIT 1"; | 		$this->pog_query = "select `recordid` from `record` where `recordid`='".$this->recordId."' LIMIT 1"; | ||||||
| 		$rows = Database::Query($this->pog_query, $connection); | 		$rows = Database::Query($this->pog_query, $connection); | ||||||
| 		if ($rows > 0) | 		if ($rows > 0) | ||||||
| @@ -281,6 +285,7 @@ class record extends POG_Base | |||||||
| 	function SaveNew($deep = false) | 	function SaveNew($deep = false) | ||||||
| 	{ | 	{ | ||||||
| 		$this->recordId = ''; | 		$this->recordId = ''; | ||||||
|  | 		$this->creation_date = date( 'Y-m-d H:i:s'); | ||||||
| 		return $this->Save($deep); | 		return $this->Save($deep); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| @@ -433,4 +438,4 @@ class record extends POG_Base | |||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| ?> | ?> | ||||||
|   | |||||||
| @@ -256,6 +256,8 @@ class recordversion extends POG_Base | |||||||
| 	function Save() | 	function Save() | ||||||
| 	{ | 	{ | ||||||
| 		$connection = Database::Connect(); | 		$connection = Database::Connect(); | ||||||
|  | 		$this->update_date = date( 'Y-m-d H:i:s'); | ||||||
|  | 		$this->access_date = date( 'Y-m-d H:i:s'); | ||||||
| 		$this->pog_query = "select `recordversionid` from `recordversion` where `recordversionid`='".$this->recordversionId."' LIMIT 1"; | 		$this->pog_query = "select `recordversionid` from `recordversion` where `recordversionid`='".$this->recordversionId."' LIMIT 1"; | ||||||
| 		$rows = Database::Query($this->pog_query, $connection); | 		$rows = Database::Query($this->pog_query, $connection); | ||||||
| 		if ($rows > 0) | 		if ($rows > 0) | ||||||
| @@ -378,4 +380,4 @@ class recordversion extends POG_Base | |||||||
| 		$this->recordId = $record->recordId; | 		$this->recordId = $record->recordId; | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| ?> | ?> | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Josh
					Josh