Code Duplication    Length = 20-20 lines in 2 locations

plugins/auto-domain-grab/index.php 2 locations

@@ 31-50 (lines=20) @@
28
	 * @param \RainLoop\Model\Account $oAccount
29
	 * @param array $aImapCredentials
30
	 */
31
	public function FilterImapCredentials($oAccount, &$aImapCredentials)
32
	{
33
		if ($oAccount instanceof \RainLoop\Model\Account && \is_array($aImapCredentials))
34
		{
35
			// Check for mail.$DOMAIN as entered value in RL settings
36
			if (!empty($aImapCredentials['Host']) && 'auto' === $aImapCredentials['Host'])
37
			{
38
				$domain = substr(strrchr($oAccount->Email(), "@"), 1);
39
				$mxhosts = array();
40
				if(getmxrr($domain, $mxhosts) && sizeof($mxhosts) > 0)
41
				{
42
					$aImapCredentials['Host'] = $mxhosts[0];
43
				}
44
				else 
45
				{
46
					$aImapCredentials['Host'] = $this->imap_prefix.$domain;
47
				}
48
			}
49
		}
50
	}
51
52
	/**
53
	 * This function detects the SMTP Host, and if it is set to "auto", replaces it with the MX or email domain.
@@ 58-77 (lines=20) @@
55
	 * @param \RainLoop\Model\Account $oAccount
56
	 * @param array $aSmtpCredentials
57
	 */
58
	public function FilterSmtpCredentials($oAccount, &$aSmtpCredentials)
59
	{
60
		if ($oAccount instanceof \RainLoop\Model\Account && \is_array($aSmtpCredentials))
61
		{
62
			// Check for mail.$DOMAIN as entered value in RL settings
63
			if (!empty($aSmtpCredentials['Host']) && 'auto' === $aSmtpCredentials['Host'])
64
			{
65
				$domain = substr(strrchr($oAccount->Email(), "@"), 1);
66
				$mxhosts = array();
67
				if(getmxrr($domain, $mxhosts) && sizeof($mxhosts) > 0)
68
				{
69
					$aSmtpCredentials['Host'] = $mxhosts[0];
70
				} 
71
				else 
72
				{
73
					$aSmtpCredentials['Host'] = $this->smtp_prefix.$domain;
74
				}
75
			}
76
		}
77
	}
78
}
79