Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

masssubscribe.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: masssubscribe.php 8088 2001-10-29 19:10:11Z fh $
5 //
6 // Created on: <14-May-2001 15:02:02 ce>
7 //
8 // This source file is part of Exponential Basic, publishing software.
9 //
10 // Copyright (C) 1999-2001 eZ Systems. All rights reserved.
11 //
12 // This program is free software; you can redistribute it and/or
13 // modify it under the terms of the GNU General Public License
14 // as published by the Free Software Foundation; either version 2
15 // of the License, or (at your option) any later version.
16 //
17 // This program is distributed in the hope that it will be useful,
18 // but WITHOUT ANY WARRANTY; without even the implied warranty of
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 // GNU General Public License for more details.
21 //
22 // You should have received a copy of the GNU General Public License
23 // along with this program; if not, write to the Free Software
24 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, US
25 //
26
27 // include_once( "classes/INIFile.php" );
28 // include_once( "classes/eztemplate.php" );
29 // include_once( "classes/ezhttptool.php" );
30
31 // include_once( "ezbulkmail/classes/ezbulkmailsubscriptionaddress.php" );
32 // include_once( "ezbulkmail/classes/ezbulkmailcategory.php" );
33 // include_once( "ezmail/classes/ezmail.php" );
34
35 $ini =& eZINI::instance( 'site.ini' );
36 $Language = $ini->variable( "eZBulkMailMain", "Language" );
37
38 $t = new eZTemplate( "kernel/ezbulkmail/admin/" . $ini->variable( "eZBulkMailMain", "AdminTemplateDir" ),
39 "kernel/ezbulkmail/admin/intl/", $Language, "masssubscribe.php" );
40
41 $t->setAllStrings();
42
43 $t->set_file( array(
44 "mass_subscribe_page" => "masssubscribe.tpl"
45 ) );
46
47 $t->set_block( "mass_subscribe_page", "new_email_list_tpl", "new_email_list" );
48 $t->set_block( "new_email_list_tpl", "new_email_item_tpl", "new_email_item" );
49
50 $t->set_block( "mass_subscribe_page", "category_item_tpl", "category_item" );
51
52 $t->set_block( "mass_subscribe_page", "email_exists_list_tpl", "email_exists_list" );
53 $t->set_block( "email_exists_list_tpl", "email_exists_item_tpl", "email_exists_item" );
54
55 $t->set_block( "mass_subscribe_page", "not_valid_list_tpl", "not_valid_list" );
56 $t->set_block( "not_valid_list_tpl", "not_valid_item_tpl", "not_valid_item" );
57
58 $t->set_var( "new_email_list", "" );
59 $t->set_var( "email_exists_list", "" );
60 $t->set_var( "not_valid_list", "" );
61
62 $t->set_var( "addresses", isset( $Addresses ) ? $Addresses : false );
63
64 if ( isset ( $OK ) && ( count ( $CategoryArrayID ) > 0 ) )
65 {
66 unset ( $addresses );
67 $addresses = explode( "\n", $Addresses );
68
69 if ( count ( $addresses ) > 0 )
70 {
71 $mailTemplate = new eZTemplate( "kernel/ezbulkmail/admin/" . $ini->variable( "eZBulkMailMain", "TemplateDir" ),
72 "kernel/ezbulkmail/admin/intl", $Language, "sendmail.php" );
73
74 $languageIni = new eZINI( "kernel/ezbulkmail/admin/intl/$Language/sendmail.php.ini" );
75 $mailTemplate->setAllStrings();
76 $mailTemplate->set_file( "send_mail_tpl", "sendmail.tpl" );
77 $mailTemplate->set_block( "send_mail_tpl", "mail_password_tpl", "mail_password" );
78 $mailTemplate->set_var( "mail_password", "" );
79
80 foreach ( $addresses as $address )
81 {
82 $email = trim( $address );
83 if ( eZMail::validate( $email ) )
84 {
85 $bulkMail = (new eZBulkMailSubscriptionAddress())->getByEmail( $email );
86
87 $sendPassword = false;
88 if ( $bulkMail->addressExists ( $email ) == false )
89 {
90 $password = substr( md5( microtime() ), 0, 4 );
91 $bulkMail->setEncryptetPassword( $password );
92 $bulkMail->store();
93 $sendPassword = true;
94 }
95
96
97 foreach( $CategoryArrayID as $CategoryID )
98 {
99 if ( $bulkMail->subscribe( $CategoryID ) )
100 {
101 $category = new eZBulkMailCategory( $CategoryID );
102 $new[] = array( $email, $category->name() );
103 if ( $SendMail == "on" )
104 {
105 $mailTemplate->set_var( "category_name", $category->name() );
106
107 if ( $sendPassword )
108 {
109 $mailTemplate->set_var( "password", $password );
110 $mailTemplate->parse( "mail_password", "mail_password_tpl" );
111 }
112
113 $mail = new eZMail();
114 $mail->setSubject( $languageIni->variable( "strings", "mail_subject" ) );
115 $mail->setTo( $email );
116 $mail->setBody( $mailTemplate->parse( "dummy", "send_mail_tpl" ) );
117 $mail->setFrom( $GlobalSiteIni->variable( "eZBulkMailMain", "BulkmailSenderAddress" ) );
118
119 $mail->send();
120 }
121 }
122 else
123 $exists[] = $email;
124 }
125 }
126 else
127 $notValid[] = $email;
128 }
129 }
130
131 if ( isset( $new ) && count ( $new ) > 0 )
132 {
133 foreach ( $new as $email )
134 {
135 $t->set_var( "new_email", $email[0] );
136 $t->set_var( "new_category", $email[1] );
137 $t->parse( "new_email_item", "new_email_item_tpl", true );
138 }
139 $t->parse( "new_email_list", "new_email_list_tpl", true );
140 }
141
142 if ( isset( $exists ) && count ( $exists ) > 0 )
143 {
144 foreach ( $exists as $email )
145 {
146 $t->set_var( "email_exists", $email );
147 $t->parse( "email_exists_item", "email_exists_item_tpl", true );
148 }
149 $t->parse( "email_exists_list", "email_exists_list_tpl", true );
150 }
151
152 if ( isset( $notValid ) && count ( $notValid ) > 0 )
153 {
154 foreach ( $notValid as $email )
155 {
156 $t->set_var( "not_valid", $email );
157 $t->parse( "not_valid_item", "not_valid_item_tpl", true );
158 }
159 $t->parse( "not_valid_list", "not_valid_list_tpl", true );
160 }
161 }
162
163 $categoryList =& eZBulkMailCategory::getAll();
164
165 if ( count ( $categoryList ) > 0 )
166 {
167 foreach( $categoryList as $category )
168 {
169 $t->set_var( "category_id", $category->id() );
170 $t->set_var( "category_name", $category->name() );
171 $t->parse( "category_item", "category_item_tpl", true );
172 }
173 }
174
175 $t->pparse( "output", "mass_subscribe_page" );
176
177 ?>
$category
if( $Action=="Edit") $category
Definition: adedit.php:378
$CategoryID
$CategoryID
Definition: admin/articleedit.php:53
$address
$address
Definition: checkout.php:588
eZBulkMailSubscriptionAddress
Definition: ezbulkmailsubscriptionaddress.php:40
eZINI
Reads and writes .ini style configuration files.
eZMail
Definition: ezmail.php:57
eZMail\validate
static validate( $address)
Definition: ezmail.php:599
eZTemplate
Definition: eztemplate.php:107
$GlobalSiteIni
$GlobalSiteIni
Definition: ezarticle/xmlrpc/xmlrpcserver.php:33
$mail
$mail
Definition: ezbulkmail/admin/maillist.php:61
$t
$t
Definition: masssubscribe.php:38
$categoryList
if(isset( $OK) &&(count( $CategoryArrayID) > 0)) $categoryList
Definition: masssubscribe.php:163
$Language
$Language
Definition: masssubscribe.php:36
$ini
$ini
Definition: masssubscribe.php:35
$languageIni
$languageIni
Definition: pendinglist.php:43
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.