+ // function cleanErrors() {{{2
+
+ public function cleanErrors($email)
+ {
+ foreach ($this->emails as &$mail) {
+ if ($mail->email == $email) {
+ return $mail->cleanErrors($this->uid);
+ }
+ }
+ return false;
+ }
+
+ // function disable() {{{2
+
+ public function disable()
+ {
+ XDB::execute("UPDATE emails
+ SET flags = 'disable'
+ WHERE flags = 'active' AND uid = {?}", $this->uid);
+ foreach ($this->emails as &$mail) {
+ if ($mail->active) {
+ $mail->disabled = true;
+ $mail->active = false;
+ }
+ }
+ }
+
+ // function enable() {{{2
+
+ public function enable()
+ {
+ XDB::execute("UPDATE emails
+ SET flags = 'active'
+ WHERE flags = 'disable' AND uid = {?}", $this->uid);
+ foreach ($this->emails as &$mail) {
+ if ($mail->disabled) {
+ $mail->active = true;
+ $mail->disabled = false;
+ }
+ }
+ }
+
+ // function get_broken_mx() {{{2
+
+ public function get_broken_mx()
+ {
+ $res = XDB::query("SELECT host, text
+ FROM mx_watch
+ WHERE state != 'ok'");
+ if (!$res->numRows()) {
+ return array();
+ }
+ $mxs = $res->fetchAllAssoc();
+ $mails = array();
+ foreach ($this->emails as &$mail) {
+ if ($mail->active) {
+ list(,$domain) = explode('@', $mail->email);
+ getmxrr($domain, $lcl_mxs);
+ if (empty($lcl_mxs)) {
+ $lcl_mxs = array($domain);
+ }
+ $broken = false;
+ foreach ($mxs as &$mx) {
+ foreach ($lcl_mxs as $lcl) {
+ if (fnmatch($mx['host'], $lcl)) {
+ $broken = $mx['text'];
+ break;
+ }
+ }
+ if ($broken) {
+ $mails[] = array('mail' => $mail->email, 'text' => $broken);
+ }
+ }
+ }
+ }
+ return $mails;
+ }
+}