+ public function modify_one_email_redirect($email, $redirect)
+ {
+ foreach ($this->emails as &$mail) {
+ if ($mail->email == $email) {
+ $mail->set_rewrite($redirect);
+ check_redirect($this);
+ return;
+ }
+ }
+ }
+
+ // function clean_errors() {{{2
+
+ public function clean_errors($email)
+ {
+ foreach ($this->emails as &$mail) {
+ if ($mail->email == $email) {
+ check_redirect($this);
+ return $mail->clean_errors();
+ }
+ }
+ return false;
+ }
+
+ // function disable() {{{2
+
+ public function disable()
+ {
+ XDB::execute("UPDATE emails
+ SET flags = 'disable'
+ WHERE flags = 'active' AND uid = {?}", $this->user->id);
+ foreach ($this->emails as &$mail) {
+ if ($mail->active && $mail->has_disable()) {
+ $mail->disabled = true;
+ $mail->active = false;
+ }
+ }
+ check_redirect($this);
+ }
+
+ // function enable() {{{2
+
+ public function enable()
+ {
+ XDB::execute("UPDATE emails
+ SET flags = 'active'
+ WHERE flags = 'disable' AND uid = {?}", $this->user->id);
+ foreach ($this->emails as &$mail) {
+ if ($mail->disabled) {
+ $mail->active = true;
+ $mail->disabled = false;
+ }
+ check_redirect($this);
+ }
+ }
+
+ // 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 && strstr($mail->email, '@') !== false) {
+ 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);
+ break;
+ }
+ }
+ }
+ }
+ return $mails;
+ }
+
+ // function active_emails() {{{2
+
+ public function active_emails()
+ {
+ $emails = array();
+ foreach ($this->emails as $mail) {
+ if ($mail->active) {
+ $emails[] = $mail;
+ }
+ }
+ return $emails;
+ }
+
+ // function get_uid() {{{2
+
+ public function get_uid()
+ {
+ return $this->user->id();
+ }
+}