mail import,
new team photos
This commit is contained in:
parent
c3e22231da
commit
53e4435df0
@ -4,6 +4,99 @@ function init_saimod_mail_overview() {
|
|||||||
$('#tabs_mail li a').each(function(){
|
$('#tabs_mail li a').each(function(){
|
||||||
$(this).removeClass('active');});
|
$(this).removeClass('active');});
|
||||||
$('#menu_mail_overview').addClass('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() {
|
function init_saimod_mail_contacts() {
|
||||||
|
|||||||
216
saimod_mail.php
216
saimod_mail.php
@ -6,6 +6,10 @@ class saimod_mail extends \SYSTEM\SAI\sai_module{
|
|||||||
const EMAIL_LIST_NEWSLETTER = 2;
|
const EMAIL_LIST_NEWSLETTER = 2;
|
||||||
const EMAIL_LIST_PROTOTYPE = 3;
|
const EMAIL_LIST_PROTOTYPE = 3;
|
||||||
const EMAIL_LIST_ALPHA = 4;
|
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_CONTACT = 10;
|
||||||
const EMAIL_WEBSITE_BUGREPORT = 11;
|
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);
|
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><td.*>(.*) (.*)<\/td>/mU';
|
||||||
|
$regex_mail = '/E-Mail des Kunden:<\/th><td.+>(.*)<\/td>/mU';
|
||||||
|
|
||||||
|
$first_name = null;
|
||||||
|
$last_name = null;
|
||||||
|
$email = null;
|
||||||
|
|
||||||
|
preg_match_all($regex_name, $body, $matches, \PREG_SET_ORDER);
|
||||||
|
if($matches){
|
||||||
|
$first_name = $matches[0][1];
|
||||||
|
$last_name = $matches[0][2];
|
||||||
|
}
|
||||||
|
preg_match_all($regex_mail, $body, $matches, \PREG_SET_ORDER);
|
||||||
|
if($matches){
|
||||||
|
$email = $matches[0][1];
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!$email){
|
||||||
|
$regex_single = '/<span.+>Diese E-Mail bestätigt den Erhalt einer Spende über €.+ von (.*) (.*) \(<a href="mailto:(.*)\?/mU';
|
||||||
|
preg_match_all($regex_single, $body, $matches, \PREG_SET_ORDER);
|
||||||
|
if($matches){
|
||||||
|
$first_name = $matches[0][1];
|
||||||
|
$last_name = $matches[0][2];
|
||||||
|
$email = $matches[0][3];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if($email){
|
||||||
|
$result['match'] += 1;
|
||||||
|
$contact = \SQL\CONTACT_SELECT::Q1(array($email));
|
||||||
|
if($contact){
|
||||||
|
$is_subscribed = \SQL\ISSUBSCRIBED::Q1(array($email,self::EMAIL_LIST_EMAIL_PAYPAL))['count'] == 1;
|
||||||
|
if(!$is_subscribed){
|
||||||
|
\SQL\CONTACT_UPDATE::QI(array($contact['sex'],$first_name,$last_name,$email));
|
||||||
|
\SQL\SUBSCRIBE::QI(array($email,self::EMAIL_LIST_NEWSLETTER));
|
||||||
|
\SQL\SUBSCRIBE::QI(array($email,self::EMAIL_LIST_EMAIL_PAYPAL));
|
||||||
|
$result['mod'] += 1;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
\SQL\CONTACT_INSERT::QI(array($email,null,$first_name,$last_name));
|
||||||
|
\SQL\SUBSCRIBE::QI(array($email,self::EMAIL_LIST_NEWSLETTER));
|
||||||
|
\SQL\SUBSCRIBE::QI(array($email,self::EMAIL_LIST_EMAIL_PAYPAL));
|
||||||
|
$result['new'] += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$i--;
|
||||||
|
}
|
||||||
|
imap_close($imap);
|
||||||
|
|
||||||
|
return \SYSTEM\LOG\JsonResult::toString($result);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function sai_mod__SAI_saimod_mail_action_import_pr(){
|
||||||
|
$account = \SYSTEM\CONFIG\config::get(\config_ids::DEMOCRACY_EMAIL_CONTACT);
|
||||||
|
$connection_string = '{'.$account['imap'].'}';
|
||||||
|
$folder = 'INBOX.2 - Public Relations';
|
||||||
|
$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;
|
||||||
|
while($i > 0){
|
||||||
|
$first_name = $last_name = '';
|
||||||
|
$header = imap_headerinfo($imap, $i);
|
||||||
|
$from = $header->from[0];
|
||||||
|
if(isset($from->personal)){
|
||||||
|
$personal = explode(' ', imap_utf8($from->personal));
|
||||||
|
$first_name = $personal[0];
|
||||||
|
$last_name = count($personal) > 1 ? $personal[1] : null;
|
||||||
|
}
|
||||||
|
$email = $from->mailbox.'@'.$from->host;
|
||||||
|
|
||||||
|
$result['match'] += 1;
|
||||||
|
$contact = \SQL\CONTACT_SELECT::Q1(array($email));
|
||||||
|
if($contact){
|
||||||
|
$is_subscribed = \SQL\ISSUBSCRIBED::Q1(array($email,self::EMAIL_LIST_EMAIL_PR))['count'] == 1;
|
||||||
|
if(!$is_subscribed){
|
||||||
|
\SQL\CONTACT_UPDATE::QI(array($contact['sex'],$first_name,$last_name,$email));
|
||||||
|
\SQL\SUBSCRIBE::QI(array($email,self::EMAIL_LIST_NEWSLETTER));
|
||||||
|
\SQL\SUBSCRIBE::QI(array($email,self::EMAIL_LIST_EMAIL_PR));
|
||||||
|
$result['mod'] += 1;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
\SQL\CONTACT_INSERT::QI(array($email,null,$first_name,$last_name));
|
||||||
|
\SQL\SUBSCRIBE::QI(array($email,self::EMAIL_LIST_NEWSLETTER));
|
||||||
|
\SQL\SUBSCRIBE::QI(array($email,self::EMAIL_LIST_EMAIL_PR));
|
||||||
|
$result['new'] += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
$i--;
|
||||||
|
}
|
||||||
|
|
||||||
|
imap_close($imap);
|
||||||
|
|
||||||
|
return \SYSTEM\LOG\JsonResult::toString($result);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function sai_mod__SAI_saimod_mail_action_import_contact(){
|
||||||
|
$account = \SYSTEM\CONFIG\config::get(\config_ids::DEMOCRACY_EMAIL_CONTACT);
|
||||||
|
$connection_string = '{'.$account['imap'].'}';
|
||||||
|
$folder = 'INBOX.1 - Kontakte + Kommunikation';
|
||||||
|
$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;
|
||||||
|
while($i > 0){
|
||||||
|
$first_name = $last_name = '';
|
||||||
|
$header = imap_headerinfo($imap, $i);
|
||||||
|
$from = $header->from[0];
|
||||||
|
if(isset($from->personal)){
|
||||||
|
$personal = explode(' ', imap_utf8($from->personal));
|
||||||
|
$first_name = $personal[0];
|
||||||
|
$last_name = count($personal) > 1 ? $personal[1] : null;
|
||||||
|
}
|
||||||
|
$email = $from->mailbox.'@'.$from->host;
|
||||||
|
|
||||||
|
$result['match'] += 1;
|
||||||
|
$contact = \SQL\CONTACT_SELECT::Q1(array($email));
|
||||||
|
if($contact){
|
||||||
|
$is_subscribed = \SQL\ISSUBSCRIBED::Q1(array($email,self::EMAIL_LIST_EMAIL_CONTACT))['count'] == 1;
|
||||||
|
if(!$is_subscribed){
|
||||||
|
\SQL\CONTACT_UPDATE::QI(array($contact['sex'],$first_name,$last_name,$email));
|
||||||
|
\SQL\SUBSCRIBE::QI(array($email,self::EMAIL_LIST_NEWSLETTER));
|
||||||
|
\SQL\SUBSCRIBE::QI(array($email,self::EMAIL_LIST_EMAIL_CONTACT));
|
||||||
|
$result['mod'] += 1;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
\SQL\CONTACT_INSERT::QI(array($email,null,$first_name,$last_name));
|
||||||
|
\SQL\SUBSCRIBE::QI(array($email,self::EMAIL_LIST_NEWSLETTER));
|
||||||
|
\SQL\SUBSCRIBE::QI(array($email,self::EMAIL_LIST_EMAIL_CONTACT));
|
||||||
|
$result['new'] += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
$i--;
|
||||||
|
}
|
||||||
|
|
||||||
|
imap_close($imap);
|
||||||
|
|
||||||
|
return \SYSTEM\LOG\JsonResult::toString($result);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function sai_mod__SAI_saimod_mail_action_import_volunteers(){
|
||||||
|
$account = \SYSTEM\CONFIG\config::get(\config_ids::DEMOCRACY_EMAIL_CONTACT);
|
||||||
|
$connection_string = '{'.$account['imap'].'}';
|
||||||
|
$folder = 'INBOX.3 - Volunteers + Kooperationen';
|
||||||
|
$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;
|
||||||
|
while($i > 0){
|
||||||
|
$first_name = $last_name = '';
|
||||||
|
$header = imap_headerinfo($imap, $i);
|
||||||
|
$from = $header->from[0];
|
||||||
|
if(isset($from->personal)){
|
||||||
|
$personal = explode(' ', imap_utf8($from->personal));
|
||||||
|
$first_name = $personal[0];
|
||||||
|
$last_name = count($personal) > 1 ? $personal[1] : null;
|
||||||
|
}
|
||||||
|
$email = $from->mailbox.'@'.$from->host;
|
||||||
|
|
||||||
|
$result['match'] += 1;
|
||||||
|
$contact = \SQL\CONTACT_SELECT::Q1(array($email));
|
||||||
|
if($contact){
|
||||||
|
$is_subscribed = \SQL\ISSUBSCRIBED::Q1(array($email,self::EMAIL_LIST_EMAIL_VOLUNTEERS))['count'] == 1;
|
||||||
|
if(!$is_subscribed){
|
||||||
|
\SQL\CONTACT_UPDATE::QI(array($contact['sex'],$first_name,$last_name,$email));
|
||||||
|
\SQL\SUBSCRIBE::QI(array($email,self::EMAIL_LIST_NEWSLETTER));
|
||||||
|
\SQL\SUBSCRIBE::QI(array($email,self::EMAIL_LIST_EMAIL_VOLUNTEERS));
|
||||||
|
$result['mod'] += 1;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
\SQL\CONTACT_INSERT::QI(array($email,null,$first_name,$last_name));
|
||||||
|
\SQL\SUBSCRIBE::QI(array($email,self::EMAIL_LIST_NEWSLETTER));
|
||||||
|
\SQL\SUBSCRIBE::QI(array($email,self::EMAIL_LIST_EMAIL_VOLUNTEERS));
|
||||||
|
$result['new'] += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
$i--;
|
||||||
|
}
|
||||||
|
|
||||||
|
imap_close($imap);
|
||||||
|
|
||||||
|
return \SYSTEM\LOG\JsonResult::toString($result);
|
||||||
|
}
|
||||||
|
|
||||||
public static function sai_mod__SAI_saimod_mail_action_overview(){
|
public static function sai_mod__SAI_saimod_mail_action_overview(){
|
||||||
$vars = array();
|
$vars = array();
|
||||||
return \SYSTEM\PAGE\replace::replaceFile((new \PSAI('saimod_mail/tpl/saimod_mail_overview.tpl'))->SERVERPATH(),$vars);
|
return \SYSTEM\PAGE\replace::replaceFile((new \PSAI('saimod_mail/tpl/saimod_mail_overview.tpl'))->SERVERPATH(),$vars);
|
||||||
|
|||||||
9
sql/ISSUBSCRIBED.php
Normal file
9
sql/ISSUBSCRIBED.php
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<?php
|
||||||
|
namespace SQL;
|
||||||
|
|
||||||
|
class ISSUBSCRIBED extends \SYSTEM\DB\QP {
|
||||||
|
public static function get_class(){return \get_class();}
|
||||||
|
public static function mysql(){return
|
||||||
|
'SELECT COUNT(*) AS count FROM contact_email_list WHERE email = ? AND list = ?;';
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -2,6 +2,10 @@ INSERT IGNORE INTO email_list (`id`,`name`,`system_lock`) VALUES (1,'Test Liste'
|
|||||||
INSERT IGNORE INTO email_list (`id`,`name`,`system_lock`) VALUES (2,'Newsletter',1);
|
INSERT IGNORE INTO email_list (`id`,`name`,`system_lock`) VALUES (2,'Newsletter',1);
|
||||||
INSERT IGNORE INTO email_list (`id`,`name`,`system_lock`) VALUES (3,'Prototype',1);
|
INSERT IGNORE INTO email_list (`id`,`name`,`system_lock`) VALUES (3,'Prototype',1);
|
||||||
INSERT IGNORE INTO email_list (`id`,`name`,`system_lock`) VALUES (4,'Alpha',1);
|
INSERT IGNORE INTO email_list (`id`,`name`,`system_lock`) VALUES (4,'Alpha',1);
|
||||||
|
INSERT IGNORE INTO email_list (`id`,`name`,`system_lock`) VALUES (5,'Email: Paypal',1);
|
||||||
|
INSERT IGNORE INTO email_list (`id`,`name`,`system_lock`) VALUES (6,'Email: Volunteers',1);
|
||||||
|
INSERT IGNORE INTO email_list (`id`,`name`,`system_lock`) VALUES (7,'Email: Contact',1);
|
||||||
|
INSERT IGNORE INTO email_list (`id`,`name`,`system_lock`) VALUES (8,'Email: PR',1);
|
||||||
|
|
||||||
INSERT IGNORE INTO email (`id`,`name`,`sender`,`subject`,`template_text`,`template_html`,`system_lock`) VALUES (1,'Mail Test','Testing | DEMOCRACY <contact@democracy-deutschland.de>','${emoji_mobile} DEMOCRACY Mail Test',1,2,NULL);
|
INSERT IGNORE INTO email (`id`,`name`,`sender`,`subject`,`template_text`,`template_html`,`system_lock`) VALUES (1,'Mail Test','Testing | DEMOCRACY <contact@democracy-deutschland.de>','${emoji_mobile} DEMOCRACY Mail Test',1,2,NULL);
|
||||||
INSERT IGNORE INTO email_template (`id`,`type`,`name`,`value`,`system_lock`) VALUES (1,0,'Mail Test Text','Use this Mail for testing',NULL);
|
INSERT IGNORE INTO email_template (`id`,`type`,`name`,`value`,`system_lock`) VALUES (1,0,'Mail Test Text','Use this Mail for testing',NULL);
|
||||||
|
|||||||
@ -0,0 +1,9 @@
|
|||||||
|
<div style="padding: 10px">
|
||||||
|
<button class="btn btn-success" id="import_contact">Import Contact</button>
|
||||||
|
<button class="btn btn-success" id="import_pr">Import PR</button>
|
||||||
|
<button class="btn btn-success" id="import_paypal">Import Paypal</button>
|
||||||
|
<button class="btn btn-success" id="import_volunteers">Import Volunteers</button>
|
||||||
|
</div>
|
||||||
|
<div style="padding: 10px">
|
||||||
|
<textarea style="width: 100%; height: 250px;" id="import_result">Result</textarea>
|
||||||
|
</div>
|
||||||
Loading…
x
Reference in New Issue
Block a user