if (!--$limit) {
             if (!@unlink(COMMUNITY_MAIL_LIST_MEMBERS_LOCK)) {
                 application_log("error", "Unable to delete mail-list member lock file: " . COMMUNITY_MAIL_LIST_MEMBERS_LOCK);
             }
             exit;
         }
     }
 }
 $community_id = 0;
 $query = "\tSELECT a.* FROM `community_mailing_list_members` AS a\n\t\t\t\t\t\t\t\t\t\tJOIN `community_mailing_lists` AS b\n\t\t\t\t\t\t\t\t\t\tON a.`community_id` = b.`community_id`\n\t\t\t\t\t\t\t\t\t\tWHERE a.`list_administrator` = '-1'\n\t\t\t\t\t\t\t\t\t\tAND a.`member_active` = '1'\n\t\t\t\t\t\t\t\t\t\tAND b.`list_type` != 'inactive'\n\t\t\t\t\t\t\t\t\t\tORDER BY a.`community_id` ASC";
 if ($members = $db->GetAll($query)) {
     foreach ($members as $member) {
         if ($community_id != (int) $member["community_id"]) {
             $community_id = (int) $member["community_id"];
             $list = new MailingList($community_id);
             $list->fetch_current_list();
             $current_users = array_merge($list->current_owners, $list->current_members);
         }
         echo "Demote: " . $member["email"] . " -> " . $community_id . "<br/>";
         if (in_array($member["email"], $current_users)) {
             try {
                 $list->remove($member["email"]);
                 $list->add($member["email"]);
                 $list->base_edit_member($member["proxy_id"], "0", "1");
             } catch (Exception $e) {
                 echo $e->getMessage();
                 if ($e->getCode() == "502") {
                     exit;
                 }
                 application_log("notice", "An issue was encountered while attempting to demote a user's email [" . $member["email"] . "] to owner on a community [" . $community_id . "] mailing list. The server said: " . $e->getCode() . " - " . $e->getMessage());
             }
         }
     } else {
         if ($community_member["member_active"]) {
             $PROCESSED_MAIL_LIST_MEMBER["community_id"] = $community_member["community_id"];
             $PROCESSED_MAIL_LIST_MEMBER["proxy_id"] = $community_member["proxy_id"];
             $PROCESSED_MAIL_LIST_MEMBER["email"] = $community_member["email"];
             $PROCESSED_MAIL_LIST_MEMBER["member_active"] = 0;
             $PROCESSED_MAIL_LIST_MEMBER["list_administrator"] = $community_member["member_acl"] ? 1 : 0;
             if (!$db->AutoExecute("`community_mailing_list_members`", $PROCESSED_MAIL_LIST_MEMBER, "INSERT")) {
                 application_log("error", "Unable to insert new `community_mailing_list_members` record. DB said: " . $db->ErrorMsg());
             }
         }
     }
 }
 $google_list = new MailingList($list["community_id"]);
 $google_list->fetch_current_list();
 $google_list_members = $google_list->current_members;
 $google_list_owners = $google_list->current_owners;
 $query = "SELECT * FROM `community_mailing_list_members`\n                                    WHERE `community_id` = " . $db->qstr($list["community_id"]);
 $local_list_members = $db->GetAll($query);
 if ($local_list_members) {
     foreach ($local_list_members as $member) {
         $add_member = false;
         $set_owner = false;
         $PROCESSED_MAIL_LIST_MEMBER = array();
         $PROCESSED_MAIL_LIST_MEMBER["community_id"] = $member["community_id"];
         $PROCESSED_MAIL_LIST_MEMBER["proxy_id"] = $member["proxy_id"];
         $PROCESSED_MAIL_LIST_MEMBER["email"] = $member["email"];
         $PROCESSED_MAIL_LIST_MEMBER["member_active"] = $member["member_active"];
         $PROCESSED_MAIL_LIST_MEMBER["list_administrator"] = $member["list_administrator"];
         if ($member["member_active"] == 1) {