diff --git a/js/saimod_mail.js b/js/saimod_mail.js index 4a6cee1..e10786a 100644 --- a/js/saimod_mail.js +++ b/js/saimod_mail.js @@ -4,6 +4,99 @@ function init_saimod_mail_overview() { $('#tabs_mail li a').each(function(){ $(this).removeClass('active');}); $('#menu_mail_overview').addClass('active'); + + $('#import_contact').click(function(){ + $.ajax({ + async: true, + url: this.endpoint, + type: 'POST', + dataType: 'JSON', + data: { + sai_mod: '.SAI.saimod_mail', + action: 'import_contact', + }, + success: function(data){ + if(data.status){ + $('#import_result').val(JSON.stringify(data)); + } else { + alert('Something happend - try again!'); + } + }, + error: function(){ + alert('Something happend - try again!'); + } + }); + }); + + $('#import_pr').click(function(){ + $.ajax({ + async: true, + url: this.endpoint, + type: 'POST', + dataType: 'JSON', + data: { + sai_mod: '.SAI.saimod_mail', + action: 'import_pr', + }, + success: function(data){ + if(data.status){ + $('#import_result').val(JSON.stringify(data)); + } else { + alert('Something happend - try again!'); + } + }, + error: function(){ + alert('Something happend - try again!'); + } + }); + }); + + $('#import_paypal').click(function(){ + $.ajax({ + async: true, + url: this.endpoint, + type: 'POST', + dataType: 'JSON', + data: { + sai_mod: '.SAI.saimod_mail', + action: 'import_paypal', + }, + success: function(data){ + if(data.status){ + $('#import_result').val(JSON.stringify(data)); + } else { + alert('Something happend - try again!'); + } + }, + error: function(){ + alert('Something happend - try again!'); + } + }); + }); + + $('#import_volunteers').click(function(){ + $.ajax({ + async: true, + url: this.endpoint, + type: 'POST', + dataType: 'JSON', + data: { + sai_mod: '.SAI.saimod_mail', + action: 'import_volunteers', + }, + success: function(data){ + if(data.status){ + $('#import_result').val(JSON.stringify(data)); + } else { + alert('Something happend - try again!'); + } + }, + error: function(){ + alert('Something happend - try again!'); + } + }); + }); + }; function init_saimod_mail_contacts() { diff --git a/saimod_mail.php b/saimod_mail.php index f381340..e3709e2 100644 --- a/saimod_mail.php +++ b/saimod_mail.php @@ -6,6 +6,10 @@ class saimod_mail extends \SYSTEM\SAI\sai_module{ const EMAIL_LIST_NEWSLETTER = 2; const EMAIL_LIST_PROTOTYPE = 3; const EMAIL_LIST_ALPHA = 4; + const EMAIL_LIST_EMAIL_PAYPAL = 5; + const EMAIL_LIST_EMAIL_VOLUNTEERS = 6; + const EMAIL_LIST_EMAIL_CONTACT = 7; + const EMAIL_LIST_EMAIL_PR = 8; const EMAIL_WEBSITE_CONTACT = 10; const EMAIL_WEBSITE_BUGREPORT = 11; @@ -151,6 +155,218 @@ class saimod_mail extends \SYSTEM\SAI\sai_module{ return \SYSTEM\PAGE\replace::replaceFile((new \PSAI('saimod_mail/tpl/saimod_mail.tpl'))->SERVERPATH(),$vars); } + public static function sai_mod__SAI_saimod_mail_action_import_paypal(){ + $account = \SYSTEM\CONFIG\config::get(\config_ids::DEMOCRACY_EMAIL_CONTACT); + $connection_string = '{'.$account['imap'].'}'; + $folder = 'INBOX.4 - Paypal'; + $imap = imap_open ( $connection_string.$folder, $account['username'], $account['password']); + $check = imap_check($imap); + + $result = ['count' => 0, 'new' => 0, 'mod' => 0, 'match' => 0]; + + $i = $check->Nmsgs; + $result['count'] = $i; + // Paypal + while($i > 0){ + $body = imap_body($imap, $i); + $b64 = imap_base64($body); + if($b64){ + $body = $b64; + } + + $regex_name = '/Name des Kunden:<\/th>