Explorar o código

Add a feature to add only unique shares

Before, it was possible to have different shares of the same type with the same information.
Now, even if you try to input identical shares, only the first one is kept. Of course, the verification is simple, so for instance if you input two shares to the same shaarli instance with different names, they are kept.

See #614
Alexis Degrugillier %!s(int64=11) %!d(string=hai) anos
pai
achega
ce239f83c4
Modificáronse 1 ficheiros con 6 adicións e 1 borrados
  1. 6 1
      app/Models/Configuration.php

+ 6 - 1
app/Models/Configuration.php

@@ -212,6 +212,7 @@ class FreshRSS_Configuration {
 	}
 	}
 	public function _sharing ($values) {
 	public function _sharing ($values) {
 		$this->data['sharing'] = array();
 		$this->data['sharing'] = array();
+		$unique = array();
 		foreach ($values as $value) {
 		foreach ($values as $value) {
 			if (!is_array($value)) {
 			if (!is_array($value)) {
 				continue;
 				continue;
@@ -237,7 +238,11 @@ class FreshRSS_Configuration {
 				$value['name'] = $value['type'];
 				$value['name'] = $value['type'];
 			}
 			}
 
 
-			$this->data['sharing'][] = $value;
+			$json_value = json_encode($value);
+			if (!in_array($json_value, $unique)) {
+				$unique[] = $json_value;
+				$this->data['sharing'][] = $value;
+			}
 		}
 		}
 	}
 	}
 	public function _queries ($values) {
 	public function _queries ($values) {