|
@@ -14,6 +14,12 @@ abstract class AbstractRedirect extends AbstractModel
|
|
public static $idAttribute = DBC_ALIASES_ID;
|
|
public static $idAttribute = DBC_ALIASES_ID;
|
|
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * @var ModelCollection
|
|
|
|
+ */
|
|
|
|
+ protected $conflictingUsers = null;
|
|
|
|
+
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* @inheritdoc
|
|
* @inheritdoc
|
|
*/
|
|
*/
|
|
@@ -174,6 +180,56 @@ abstract class AbstractRedirect extends AbstractModel
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * @return ModelCollection
|
|
|
|
+ */
|
|
|
|
+ public function getConflictingUsers()
|
|
|
|
+ {
|
|
|
|
+ if(is_null($this->conflictingUsers)){
|
|
|
|
+ $sources = $this->getSource();
|
|
|
|
+
|
|
|
|
+ if(is_string($sources)){
|
|
|
|
+ $sources = array($sources);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $this->conflictingUsers = new ModelCollection();
|
|
|
|
+ foreach($sources as $source){
|
|
|
|
+ $user = User::findByEmail($source);
|
|
|
|
+ if(!is_null($user)){
|
|
|
|
+ $this->conflictingUsers->add($user);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return $this->conflictingUsers;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * @param string $template
|
|
|
|
+ *
|
|
|
|
+ * @return array|string
|
|
|
|
+ */
|
|
|
|
+ public function getConflictingMarkedSource($template = "<u>%email%</u>")
|
|
|
|
+ {
|
|
|
|
+ $conflictingUsers = $this->getConflictingUsers();
|
|
|
|
+
|
|
|
|
+ $sources = $this->getSource();
|
|
|
|
+
|
|
|
|
+ if(is_string($sources)){
|
|
|
|
+ $sources = array($sources);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ foreach($conflictingUsers as $user){
|
|
|
|
+ if(($key = array_search($user->getEmail(), $sources)) !== false){
|
|
|
|
+ $sources[$key] = str_replace('%email%', $sources[$key], $template);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return $sources;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* @inheritdoc
|
|
* @inheritdoc
|
|
*/
|
|
*/
|