isInstalled('newsletter')) { return; } if(!USER || !$sql -> db_Select('newsletter', '*', "newsletter_parent='0'")) { // no newsletters defined yet return FALSE; } $newsletterArray = $sql -> db_getList(); $requery = false; include_lan(e_PLUGIN.'newsletter/languages/'.e_LANGUAGE.'.php'); foreach($_POST as $key => $value) { if(strpos($key, 'nlUnsubscribe_') === 0) { $subid = str_replace('nlUnsubscribe_', '', $key); $newsletterArray[$subid]['newsletter_subscribers'] = str_replace(chr(1).USERID, "", $newsletterArray[$subid]['newsletter_subscribers']); $sql -> db_Update('newsletter', "newsletter_subscribers='".$newsletterArray[$subid]['newsletter_subscribers']."' WHERE newsletter_id='".intval($subid)."' "); $requery = true; } else if(strpos($key, 'nlSubscribe_') === 0) { $subid = str_replace("nlSubscribe_", "", $key); $nl_subscriber_array = $newsletterArray[$subid]['newsletter_subscribers']; if (!array_key_exists(USERID, $nl_subscriber_array)) { // prevent double entry of same user id $newsletterArray[$subid]['newsletter_subscribers'] .= chr(1).USERID; $subscribers_list = array_flip(explode(chr(1), $newsletterArray[$subid]['newsletter_subscribers'])); sort($subscribers_list); $new_subscriber_list = implode(chr(1), array_keys($subscribers_list)); if (substr($new_subscriber_list, 0, 1) == '0') { // remove the possible zero caused by function array_flip $new_subscriber_list = substr($new_subscriber_list, 1); } $sql -> db_Update('newsletter', "newsletter_subscribers='".$new_subscriber_list."' WHERE newsletter_id='".intval($subid)."' "); $requery = true; } } } global $tp; if($requery) { if($sql -> db_Select('newsletter', '*', "newsletter_parent='0' ")) { $newsletterArray = $sql -> db_getList(); } } $text = ''; foreach($newsletterArray as $nl) { $text .= "
". $tp -> toHTML($nl['newsletter_title'], TRUE)."
". $tp -> toHTML($nl['newsletter_text'], TRUE)."

"; if(preg_match("#".chr(1).USERID."(".chr(1)."|$)#si", $nl['newsletter_subscribers'])) { $text .= NLLAN_48."

toJS(NLLAN_49)."') \" /> "; } else { $text .= NLLAN_50." ".USEREMAIL." )

toJS(NLLAN_53)."') \" /> "; } $nl_count = $sql -> db_Count('newsletter', "(*)", "WHERE newsletter_parent='".$nl['newsletter_id']."' AND newsletter_flag='1'"); if($nl_count > 0 && USER) { // display issued newsletters $text .= "
".NLLAN_72."

"; } $text .= "

"; } $ns -> tablerender(NLLAN_MENU_CAPTION, $text); ?>