summaryrefslogtreecommitdiff
path: root/admin/send.php
blob: 98a8b6272d7b4f3013f6da6f7806132af34002eb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php

// $Header: /cvsroot/bitweaver/_bit_newsletters/admin/send.php,v 1.5 2005/12/11 06:34:19 spiderr Exp $

// Copyright (c) 2002-2003, Luis Argerich, Garland Foster, Eduardo Polidor, et. al.
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.

// Initialization
require_once( '../../bit_setup_inc.php' );
include_once( NEWSLETTERS_PKG_PATH.'nl_lib.php' );
include_once( UTIL_PKG_PATH.'htmlMimeMail.php' );

$gBitSystem->verifyPackage( 'newsletters' );

require_once( NEWSLETTERS_PKG_PATH.'lookup_newsletter_edition_inc.php' );

if (isset($_REQUEST["template_id"]) && $_REQUEST["template_id"] > 0) {
	$template_data = $tikilib->get_template($_REQUEST["template_id"]);

	$_REQUEST['edit'] = $template_data["content"];
	$_REQUEST["preview"] = 1;
}

$gBitSmarty->assign('preview', 'n');
$gBitSmarty->assign('presend', 'n');
$gBitSmarty->assign('emited', 'n');

if (isset($_REQUEST["send"])) {
	$subscribers = $nllib->get_subscribers($_REQUEST["nl_id"]);

	$mail = new htmlMimeMail();
	$mail->setFrom('noreply@noreply.com');
	$mail->setSubject($_REQUEST['title']);
	$sent = 0;

	foreach ($subscribers as $email) {
		$to_array = array();

		$to_array[] = $email;
		if ($nl_info["unsub_msg"] = 'y') {
			$unsubmsg = $nllib->get_unsub_msg($_REQUEST["nl_id"], $email);
		} else {
			$unsubmsg = ' ';
		}
		$mail->setHeadCharset("utf-8");
		$mail->setTextCharset("utf-8");
		$mail->setHtmlCharset("utf-8");
		$mail->setFrom($sender_email);
		$mail->setHTML($_REQUEST['edit'] . $unsubmsg, strip_tags($_REQUEST['edit']));

		if ($mail->send($to_array, 'mail'))
			$sent++;
	}

	$gBitSmarty->assign('sent', $sent);
	$gBitSmarty->assign('emited', 'y');
	$nllib->replace_edition($_REQUEST["nl_id"], $_REQUEST['title'], $_REQUEST['edit'], $sent);
}

$listHash = array();
$editions = $gContent->getList( $listHash );
$gBitSmarty->assign_by_ref( 'editionList', $editions );
$gBitSmarty->assign( 'listInfo', $listHash );

if( $gBitSystem->isFeatureActive( 'tiki_p_use_content_templates' ) ) {
	$templates = $tikilib->list_templates('newsletters', 0, -1, 'name_asc', '');
	$gBitSmarty->assign_by_ref('templates', $templates["data"]);
}

// Display the template
$gBitSystem->display( 'bitpackage:newsletters/send_newsletters.tpl');

?>