Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

ezbulkmail/admin/mailedit.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: mailedit.php 9832 2003-06-03 06:49:02Z jhe $
5 //
6 // Created on: <23-Oct-2000 17:53:46 bf>
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( "ezbulkmail/classes/ezbulkmailcategory.php" );
28 // include_once( "ezbulkmail/classes/ezbulkmailtemplate.php" );
29 // include_once( "ezbulkmail/classes/ezbulkmail.php" );
30
31 // include_once( "classes/INIFile.php" );
32 // include_once( "classes/eztemplate.php" );
33 // include_once( "classes/ezlocale.php" );
34 // include_once( "ezuser/classes/ezuser.php" );
35 // include_once( "classes/ezhttptool.php" );
36
37
38 if ( isset( $Cancel ) )
39 {
40 eZHTTPTool::header( "Location: /bulkmail/mailedit" );
41 exit();
42 }
43
44 if ( isset( $Preview ) )
45 {
46 $MailID = save_mail();
47 if ( !isset( $error ) )
48 {
49 eZHTTPTool::header( "Location: /bulkmail/preview/$MailID" );
50 exit();
51 }
52 }
53
54 if ( isset( $Save ) )
55 {
56 $MailID = save_mail();
57 }
58
59 if ( isset( $Send ) )
60 {
61 $MailID = save_mail();
62 if ( !isset( $error ) )
63 {
64 eZHTTPTool::header( "Location: /bulkmail/send/$MailID" );
65 exit();
66 }
67 }
68
69 $ini =& eZINI::instance( 'site.ini' );
70 $Language = $ini->variable( "eZBulkMailMain", "Language" );
71 $templateID = 0;
72
73 $t = new eZTemplate( "kernel/ezbulkmail/admin/" . $ini->variable( "eZBulkMailMain", "AdminTemplateDir" ),
74 "kernel/ezbulkmail/admin/intl/", $Language, "mailedit.php" );
75 $t->setAllStrings();
76
77 $t->set_file( array(
78 "mail_edit_page_tpl" => "mailedit.tpl"
79 ) );
80
81 $t->set_block( "mail_edit_page_tpl", "template_item_tpl", "template_item" );
82 $t->set_block( "mail_edit_page_tpl", "multiple_value_tpl", "multiple_value" );
83 $t->set_block( "mail_edit_page_tpl", "error_message_tpl", "error_message" );
84 $t->set_var( "multiple_value", "" );
85 $t->set_var( "template_item", "" );
86 $t->set_var( "error_message", "" );
87
88 $t->set_var( "site_style", $siteDesign );
89 $t->set_var( "from_value", "" );
90 $t->set_var( "from_name_value", "" );
91 $t->set_var( "subject_value", "" );
92 $t->set_var( "mail_body", "" );
93 $t->set_var( "current_mail_id", "" );
94
96 if ( $MailID == 0 )
97 {
98 // put signature stuff here...
99 }
100 $useDefaults = $ini->variable( "eZBulkMailMain", "UseBulkmailSenderDefaults" );
101
102 if ( $useDefaults == "enabled" && empty( $From ) && empty( $FromName ) )
103 {
104 $t->set_var( "from_value", $ini->variable( "eZBulkMailMain", "BulkmailSenderAddress" ) );
105 $t->set_var( "from_name_value", $ini->variable( "eZBulkMailMain", "BulkmailSenderName" ) );
106 }
107 else
108 {
109 $user =& eZUser::currentUser();
110 if ( empty( $From ) )
111 $t->set_var( "from_value", $user->email() );
112 else
113 $t->set_var( "from_value", $From );
114
115 if ( empty( $FromName ) )
116 $t->set_var( "from_name_value", $user->name() );
117 else
118 $t->set_var( "from_name_value", $FromName );
119 }
120 $categoryArrayID = array();
122 if ( $MailID != 0 )
123 {
124 $t->set_var( "current_mail_id", $MailID );
125
126 $mail = new eZBulkMail( $MailID );
127
128 if ( $mail->sender() != "" )
129 $t->set_var( "from_value", $mail->sender() );
130 $t->set_var( "subject_value", $mail->subject() );
131 $t->set_var( "mail_body", $mail->body() );
132
133 $categoryArrayID = $mail->categories( false );
134 $templateID = $mail->template( false );
135 }
136
138 $categories = eZBulkMailCategory::getAll();
139 foreach ( $categories as $category )
140 {
141 $t->set_var( "category_id", $category->id() );
142 $t->set_var( "category_name", $category->name() );
143
144 if ( in_array( $category->id(), $categoryArrayID ) )
145 $t->set_var( "multiple_selected", "selected" );
146 else
147 $t->set_var( "multiple_selected", "" );
148
149 $t->parse( "multiple_value", "multiple_value_tpl", true );
150 }
151 $templates = eZBulkMailTemplate::getAll();
152 foreach ( $templates as $template )
153 {
154 $t->set_var( "template_id", $template->id() );
155 $t->set_var( "template_name", $template->name() );
156 $t->set_var( "selected", "" );
157 if ( $templateID == $template->id() )
158 $t->set_var( "selected", "selected" );
159 else
160 $t->set_var( "selected", "" );
161
162 $t->parse( "template_item", "template_item_tpl", true );
163 }
164
166 if( isset( $error ) )
167 $t->parse( "error_message", "error_message_tpl", false );
168
169 $t->pparse( "output", "mail_edit_page_tpl" );
170
171 /*********************** FUNCTIONS ***************************************/
172
173 /*
174 Saves the mail and returns the ID of the saved mail.
175 */
176 function save_mail()
177 {
178 global $ini, $CategoryArrayID, $TemplateID, $To, $FromName, $From, $Subject, $MailBody, $MailID, $error;// instead of passing them as arguments..
179
180 if( $MailID == 0 )
181 {
182 $mail = new eZBulkMail();
183 $mail->setOwner( eZUser::currentUser() );
184 }
185 else
186 {
187 $mail = new eZBulkMail( $MailID );
188 }
189
190 $mail->setSender( $From ); // from NAME
191 $mail->setFromName( $FromName ); // from NAME
192
193 $mail->setSubject( $Subject );
194 $mail->setBodyText( $MailBody );
195
196 $mail->setIsDraft( true );
197
198 $mail->store();
199 if( $TemplateID != -1 )
200 $mail->useTemplate( $TemplateID );
201
202 $mail->addToCategory( false );
203 if( count( $CategoryArrayID ) > 0 )
204 {
205 foreach( $CategoryArrayID as $categoryItemID )
206 {
207 $mail->addToCategory( $categoryItemID );
208 }
209 }
210 else
211 $error = "No categories set";
212
213 return $mail->id();
214 }
215
216 ?>
$category
if( $Action=="Edit") $category
Definition: adedit.php:378
eZBulkMailTemplate\getAll
static getAll()
Definition: ezbulkmailtemplate.php:145
eZBulkMail
Definition: ezbulkmail.php:46
eZHTTPTool\header
static header( $string)
Definition: ezhttptool.php:96
eZTemplate
Definition: eztemplate.php:107
eZUser\currentUser
static & currentUser()
Definition: ezuser.php:896
$error
$error
Definition: ezarticle/admin/categoryedit.php:51
$t
$t
Definition: ezbulkmail/admin/mailedit.php:73
save_mail
save_mail()
Definition: ezbulkmail/admin/mailedit.php:176
$categories
if( $MailID !=0) $categories
Definition: ezbulkmail/admin/mailedit.php:138
$useDefaults
if( $MailID==0) $useDefaults
Definition: ezbulkmail/admin/mailedit.php:100
$templateID
$templateID
Definition: ezbulkmail/admin/mailedit.php:71
$Language
$Language
Definition: ezbulkmail/admin/mailedit.php:70
$ini
if(isset( $Cancel)) if(isset( $Preview)) if(isset( $Save)) if(isset( $Send)) $ini
Definition: ezbulkmail/admin/mailedit.php:69
$categoryArrayID
$categoryArrayID
Definition: ezbulkmail/admin/mailedit.php:120
$templates
foreach( $categories as $category) $templates
Definition: ezbulkmail/admin/mailedit.php:151
$mail
$mail
Definition: ezbulkmail/admin/maillist.php:61
$Subject
$Subject
Definition: ezmessage/user/messageedit.php:117
$Preview
$Preview
Definition: ezmessage/user/messageedit.php:121
exit
exit
Definition: folder.php:81
$user
$user
Definition: user/adlist.php:39
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.