2005-03-02 18:47:19 +00:00
< ?
/*
This file is part of the 'Science Fair In A Box' project
SFIAB Website : http :// www . sfiab . ca
Copyright ( C ) 2005 Sci - Tech Ontario Inc < info @ scitechontario . org >
Copyright ( C ) 2005 James Grant < james @ lightbox . org >
This program is free software ; you can redistribute it and / or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation , version 2.
This program is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the GNU
General Public License for more details .
You should have received a copy of the GNU General Public License
along with this program ; see the file COPYING . If not , write to
the Free Software Foundation , Inc . , 59 Temple Place - Suite 330 ,
Boston , MA 02111 - 1307 , USA .
*/
?>
< ?
2009-10-14 03:25:47 +00:00
require_once ( " ../common.inc.php " );
2007-11-21 17:02:09 +00:00
require_once ( " ../user.inc.php " );
2007-11-18 23:50:23 +00:00
user_auth_required ( 'committee' , 'admin' );
2009-10-14 03:25:47 +00:00
/* dialog_choose
* select : comm_dialog_choose_select ( emails_id )
* cancel : comm_dialog_choose_cancel () */
switch ( $_GET [ 'action' ]) {
case 'dialog_choose_load' :
$emails_id = intval ( $_GET [ 'emails_id' ]);
$q = mysql_query ( " SELECT * FROM emails WHERE id=' $emails_id ' " );
$e = mysql_fetch_assoc ( $q );
?>
< table class = " editor " >
< tr >< td class = " label " style = " width:15% " >< ? = i18n ( 'Name' ) ?> :</td><td class="input"><?=$e['name']?></td></tr>
< tr >< td class = " label " >< ? = i18n ( 'Subject' ) ?> :</td><td class="input"><?=$e['subject']?></td></tr>
< tr >< td class = " label " >< ? = i18n ( 'From Address' ) ?> :</td><td class="input"><?=$e['from']?></td></tr>
< tr >< td ></ td >< td >
< div style = " border:1px solid black; overflow:auto; height=300px; " >< ? = $e [ 'bodyhtml' ] ?> </div>
</ td ></ tr ></ table >
< ?
exit ;
case 'dialog_choose' :
?>
< div id = " comm_dialog_choose " title = " Select a Communication " style = " display: none " >
< h4 >< ? = i18n ( " Select a Communication " ) ?> :</h4>
< form id = " choose " onchange = " dialog_choose_change() " onkeypress = " dialog_choose_change() " >
< table style = " width:100% " >< tr >< td >
< select id = " comm_dialog_choose_emails_id " >
< option value = " -1 " >-- < ? = i18n ( 'Choose a Communication' ) ?> --</option>
< ?
$type = mysql_real_escape_string ( $_GET [ 'type' ]);
$q = mysql_query ( " SELECT * FROM emails WHERE type=' $type ' " );
while ( $e = mysql_fetch_assoc ( $q )) {
echo " <option value= \" { $e [ 'id' ] } \" > { $e [ 'name' ] } </option> " ;
}
?>
</ select >
</ td >< td style = " text-align:right " >
< input class = " comm_dialog_choose_email_button " disabled = " disabled " type = " submit " value = " <?=i18n('Choose')?> " >
< input class = " comm_dialog_choose_cancel_button " type = " submit " value = " <?=i18n('Cancel')?> " >
</ td ></ tr ></ table >
< hr />
< div id = " comm_dialog_choose_info " ></ div >
< hr />
< input class = " comm_dialog_choose_email_button " disabled = " disabled " type = " submit " value = " <?=i18n('Choose')?> " >
< input class = " comm_dialog_choose_cancel_button " type = " submit " value = " <?=i18n('Cancel')?> " >
</ form >
</ div >
< script type = " text/javascript " >
2009-10-14 04:56:28 +00:00
var comm_dialog_choose_selected = - 1 ;
2009-10-14 03:25:47 +00:00
$ ( " .comm_dialog_choose_email_button " ) . click ( function () {
var sel = $ ( " #comm_dialog_choose_emails_id " ) . val ();
2009-10-14 04:56:28 +00:00
comm_dialog_choose_selected = sel ;
2009-10-14 03:25:47 +00:00
$ ( '#comm_dialog_choose' ) . dialog ( " close " );
return false ;
});
$ ( " .comm_dialog_choose_cancel_button " ) . click ( function () {
$ ( '#comm_dialog_choose' ) . dialog ( " close " );
return false ;
});
function dialog_choose_change ()
{
var sel = $ ( " #comm_dialog_choose_emails_id " ) . val ();
$ ( " #comm_dialog_choose_info " ) . html ( " Loading... " );
$ ( " #comm_dialog_choose_info " ) . load ( " <?= $config['SFIABDIRECTORY'] ?>/admin/communication.php?action=dialog_choose_load&emails_id= " + sel );
if ( sel == - 1 ) {
$ ( " .comm_dialog_choose_email_button " ) . attr ( 'disabled' , 'disabled' );
} else {
$ ( " .comm_dialog_choose_email_button " ) . removeAttr ( 'disabled' );
}
return false ;
}
$ ( " #comm_dialog_choose " ) . dialog ({
2009-10-14 04:56:28 +00:00
bgiframe : true , autoOpen : true ,
2009-10-14 03:25:47 +00:00
modal : true , resizable : false ,
draggable : false ,
2009-10-14 04:56:28 +00:00
width : 700 , //(document.documentElement.clientWidth * 0.8);
height : ( document . documentElement . clientHeight * 0.8 ),
2009-10-14 03:25:47 +00:00
close : function () {
$ ( this ) . dialog ( 'destroy' );
$ ( '#comm_dialog_choose' ) . remove ();
2009-10-14 04:56:28 +00:00
/* Run callbacks */
if ( comm_dialog_choose_selected != - 1 ) {
if ( typeof ( comm_dialog_choose_select ) == 'function' ) {
comm_dialog_choose_select ( comm_dialog_choose_selected );
}
} else {
if ( typeof ( comm_dialog_choose_cancel ) == 'function' ) {
comm_dialog_choose_cancel ();
}
2009-10-14 03:25:47 +00:00
}
2009-10-14 04:56:28 +00:00
}
2009-10-14 03:25:47 +00:00
});
</ script >
< ?
exit ;
case 'email_save' :
print_r ( $_POST );
$id = intval ( $_POST [ 'emails_id' ]);
2009-10-15 21:58:51 +00:00
$name = mysql_real_escape_string ( stripslashes ( $_POST [ 'name' ]));
$description = mysql_real_escape_string ( stripslashes ( $_POST [ 'description' ]));
$from = mysql_real_escape_string ( stripslashes ( $_POST [ 'from' ]));
$subject = mysql_real_escape_string ( stripslashes ( $_POST [ 'subject' ]));
$bodyhtml = mysql_real_escape_string ( stripslashes ( $_POST [ 'bodyhtml' ]));
2009-10-14 03:25:47 +00:00
$type = mysql_real_escape_string ( $_POST [ 'type' ]);
2009-10-14 04:56:28 +00:00
$key = mysql_real_escape_string ( $_POST [ 'key' ]);
$fcid = mysql_real_escape_string ( $_POST [ 'fcid' ]);
2009-10-14 03:25:47 +00:00
if ( $id == 0 ) {
2009-10-14 04:56:28 +00:00
mysql_query ( " INSERT INTO emails(type,val) VALUES(' $type ',' $key ') " );
2009-10-14 03:25:47 +00:00
echo mysql_error ();
$id = mysql_insert_id ();
}
2009-10-14 04:56:28 +00:00
/* Allow the fundraising campaigns id to be NULL, it'll never be 0 */
$fcstr = ( $fcid == 0 ) ? 'NULL' : " ' $fcid ' " ;
2009-10-14 03:25:47 +00:00
mysql_query ( " UPDATE emails SET name=' $name ',description=' $description ',
2009-10-14 04:56:28 +00:00
`from` = '$from' , subject = '$subject' , bodyhtml = '$bodyhtml' ,
fundraising_campaigns_id = $fcstr
2009-10-14 03:25:47 +00:00
WHERE id = '$id' " );
echo mysql_error ();
happy_ ( " Email Saved " );
exit ;
case 'dialog_edit' :
2009-10-14 04:56:28 +00:00
2009-10-14 03:25:47 +00:00
if ( array_key_exists ( 'id' , $_GET )) {
$id = intval ( $_GET [ 'id' ]);
2009-10-14 04:56:28 +00:00
$cloneid = 0 ;
} else if ( array_key_exists ( 'cloneid' , $_GET )) {
$id = intval ( $_GET [ 'cloneid' ]);
$clone_id = $id ;
2009-10-14 03:25:47 +00:00
} else {
2009-10-14 04:56:28 +00:00
/* new email, set defaults which may be specified */
$id = 0 ;
$key = htmlspecialchars ( $_GET [ 'key' ]);
if ( array_key_exists ( 'fundraising_campaigns_id' , $_GET )) {
$fcid = intval ( $_GET [ 'fundraising_campaigns_id' ]);
$type = 'fundraising' ;
} else {
$fcid = 0 ;
$type = ( array_key_exists ( 'type' , $_GET )) ? $_GET [ 'type' ] : 'user' ;
}
2009-10-14 03:25:47 +00:00
}
2009-10-14 04:56:28 +00:00
if ( $id ) {
$q = mysql_query ( " SELECT * FROM emails WHERE id=' $id ' " );
2009-10-14 03:25:47 +00:00
if ( mysql_num_rows ( $q ) != 1 ) {
echo " Ambiguous edit " ;
exit ;
}
$e = mysql_fetch_assoc ( $q );
2009-10-14 04:56:28 +00:00
/* If we ' re supposed to clone it , load it then zero out the
* id so we make a new record on save , and override the key */
if ( $clone_id ) {
$e [ 'id' ] = 0 ;
$e [ 'val' ] = $_GET [ 'key' ];
$e [ 'fundraising_campaigns_id' ] = $_GET [ 'fundraising_campaigns_id' ];
}
2009-10-14 03:25:47 +00:00
$emails_id = $e [ 'id' ];
$name = htmlspecialchars ( $e [ 'name' ]);
2009-10-14 04:56:28 +00:00
$key = htmlspecialchars ( $e [ 'val' ]);
2009-10-14 03:25:47 +00:00
$description = htmlspecialchars ( $e [ 'description' ]);
$from = htmlspecialchars ( $e [ 'from' ]);
$subject = htmlspecialchars ( $e [ 'subject' ]);
$body = $e [ 'body' ];
$bodyhtml = $e [ 'bodyhtml' ];
2009-10-14 04:56:28 +00:00
$fcid = intval ( $e [ 'fundraising_campaigns_id' ]);
2009-10-14 03:25:47 +00:00
if ( $bodyhtml == '' ) $bodyhtml = $body ;
}
?>
< div id = " comm_dialog_edit " title = " Edit a Communication " style = " display: none " >
< br />
< form id = " comm_dialog_edit_form " >
2009-10-14 04:57:22 +00:00
< ? /* ="fcid=$fcid, key=$key, type=$type"*/ ?>
2009-10-14 03:25:47 +00:00
< input type = " hidden " name = " emails_id " value = " <?= $emails_id ?> " />
< input type = " hidden " name = " type " value = " <?= $type ?> " />
2009-10-14 04:56:28 +00:00
< input type = " hidden " name = " key " value = " <?= $key ?> " />
< input type = " hidden " name = " fcid " value = " <?= $fcid ?> " />
2009-10-14 03:25:47 +00:00
< table class = " editor " style = " width:95% " >< tr >
< td class = " label " >< ? = i18n ( " Email Name " ) ?> :</td>
< td class = " input " >< input type = " text " name = " name " size = " 60 " value = " <?= $name ?> " /></ td >
</ tr >< tr >
< td class = " label " >< ? = i18n ( " Description " ) ?> :</td>
< td class = " input " >< input type = " text " name = " description " size = " 60 " value = " <?= $description ?> " /></ td >
</ tr >< tr >
< tr >< td colspan = " 2 " >< hr /></ td >
</ tr >< tr >
< td class = " label " >< ? = i18n ( " Email Subject " ) ?> :</td>
< td class = " input " >< input type = " text " name = " subject " size = " 60 " value = " <?= $subject ?> " /></ td >
</ tr >< tr >
< td class = " label " >< ? = i18n ( " From Address " ) ?> :</td>
< td class = " input " >< input type = " text " name = " from " size = " 60 " value = " <?= $from ?> " /></ td >
</ tr >< tr >
2009-10-14 19:48:40 +00:00
< td colspan = " 2 " class = " input " >
2009-10-15 07:11:43 +00:00
< table width = " 100% " >< tr >< td width = " 85% " >
< div id = " fck " >
2009-10-15 21:58:51 +00:00
< textarea id = " bodyhtml " name = " bodyhtml " rows = 6 cols = 80 >< ? = $bodyhtml ?> </textarea>
2009-10-15 07:11:43 +00:00
</ div >
2009-10-14 19:48:40 +00:00
</ td >< td width = " 15% " >
< select name = " insert_field " size = " 20 " style = " height:300 " >
< option value = " FAIRNAME " > [ EMAIL ] </ option >
< option value = " FAIRNAME " > [ FAIRNAME ] </ option >
< option value = " FAIRNAME " > [ NAME ] </ option >
< option value = " FAIRNAME " > [ PASSWORD ] </ option >
</ select >
</ td ></ tr ></ table >
2009-10-14 03:25:47 +00:00
</ td >
</ tr ></ table >
< hr />
< div align = " right " >
< input type = " submit " id = " comm_dialog_edit_save_button " value = " <?=i18n('Save')?> " />
< input type = " submit " id = " comm_dialog_edit_cancel_button " value = " <?=i18n('Cancel')?> " />
</ div >
</ form >
</ div >
2009-10-15 07:11:43 +00:00
< script type = " text/javascript " src = " <?= $config['SFIABDIRECTORY'] ?>/fckeditor/fckeditor.js " ></ script >
2009-10-14 03:25:47 +00:00
< script type = " text/javascript " >
2009-10-14 04:56:28 +00:00
var comm_dialog_edit_saved = false ;
2009-10-14 03:25:47 +00:00
$ ( " #comm_dialog_edit_save_button " ) . click ( function () {
2009-10-15 21:58:51 +00:00
var oFCKeditor = FCKeditorAPI . GetInstance ( 'bodyhtml' ) ;
var value = oFCKeditor . GetHTML ();
$ ( '#bodyhtml' ) . val ( value );
2009-10-14 03:25:47 +00:00
$ ( " #debug " ) . load ( " <?= $config['SFIABDIRECTORY'] ?>/admin/communication.php?action=email_save " , $ ( " #comm_dialog_edit_form " ) . serializeArray (),
function () {
2009-10-14 04:56:28 +00:00
comm_dialog_edit_saved = true ;
2009-10-14 03:25:47 +00:00
$ ( '#comm_dialog_edit' ) . dialog ( " close " );
});
return false ;
}
);
$ ( " #comm_dialog_edit_cancel_button " ) . click ( function () {
$ ( '#comm_dialog_edit' ) . dialog ( " close " );
return false ;
}
);
$ ( " #comm_dialog_edit " ) . dialog ({
2009-10-14 04:56:28 +00:00
bgiframe : true , autoOpen : true ,
2009-10-14 03:25:47 +00:00
modal : true , resizable : false ,
draggable : false ,
2009-10-14 04:56:28 +00:00
width : 800 , //(document.documentElement.clientWidth * 0.8);
height : ( document . documentElement . clientHeight * 0.8 ),
2009-10-14 03:25:47 +00:00
close : function () {
$ ( this ) . dialog ( 'destroy' );
$ ( '#comm_dialog_edit' ) . remove ();
2009-10-14 04:56:28 +00:00
/* Run callbacks */
if ( comm_dialog_edit_saved == true ) {
if ( typeof ( comm_dialog_edit_save ) == 'function' ) {
comm_dialog_edit_save ( < ? = $emails_id ?> );
}
} else {
if ( typeof ( comm_dialog_edit_cancel ) == 'function' ) {
comm_dialog_edit_cancel ();
}
}
2009-10-14 03:25:47 +00:00
}
});
2009-10-15 07:11:43 +00:00
var oFCKeditor = new FCKeditor ( 'bodyhtml' ) ;
oFCKeditor . BasePath = " ../fckeditor/ " ;
oFCKeditor . ToolbarSet = 'sfiab' ;
oFCKeditor . Width = " 100% " ;
oFCKeditor . Height = 300 ;
2009-10-15 21:58:51 +00:00
// $('#fck').html(oFCKeditor.CreateHtml());
oFCKeditor . ReplaceTextarea () ;
2009-10-14 03:25:47 +00:00
</ script >
< ?
exit ;
}
2006-03-01 15:59:51 +00:00
include " communication.inc.php " ;
2007-11-18 23:50:23 +00:00
send_header ( " Communication " ,
array ( 'Committee Main' => 'committee_main.php' ,
2008-08-22 20:50:38 +00:00
'Administration' => 'admin/index.php' ),
" communication "
2007-11-18 23:50:23 +00:00
);
2005-03-02 18:47:19 +00:00
echo " <br /> " ;
if ( $_POST [ 'action' ] == " add " )
{
if ( ! $_POST [ 'val' ])
{
echo error ( i18n ( " Email Key is required " ));
$_GET [ 'action' ] = " add " ;
}
else if ( ! $_POST [ 'name' ])
{
echo error ( i18n ( " Email Name is required " ));
$_GET [ 'action' ] = " add " ;
}
else if ( ! $_POST [ 'from' ])
{
echo error ( i18n ( " Email From is required " ));
$_GET [ 'action' ] = " add " ;
}
else
{
mysql_query ( " INSERT INTO emails (val,name,description,`from`,subject,body,type) VALUES ( " .
" ' " . mysql_escape_string ( stripslashes ( $_POST [ 'val' ])) . " ', " .
" ' " . mysql_escape_string ( stripslashes ( $_POST [ 'name' ])) . " ', " .
" ' " . mysql_escape_string ( stripslashes ( $_POST [ 'description' ])) . " ', " .
" ' " . mysql_escape_string ( stripslashes ( $_POST [ 'from' ])) . " ', " .
" ' " . mysql_escape_string ( stripslashes ( $_POST [ 'subject' ])) . " ', " .
" ' " . mysql_escape_string ( stripslashes ( $_POST [ 'body' ])) . " ', " .
" 'user') " );
echo mysql_error ();
echo happy ( i18n ( " Email successfully added " ));
}
}
if ( $_POST [ 'action' ] == " edit " )
{
if ( ! $_POST [ 'name' ])
{
echo error ( i18n ( " Email Name is required " ));
$_GET [ 'action' ] = " edit " ;
$_GET [ 'edit' ] = $_POST [ 'edit' ];
}
else if ( ! $_POST [ 'from' ])
{
echo error ( i18n ( " Email From is required " ));
$_GET [ 'action' ] = " edit " ;
$_GET [ 'edit' ] = $_POST [ 'edit' ];
}
else
{
mysql_query ( " UPDATE emails SET " .
" name=' " . mysql_escape_string ( stripslashes ( $_POST [ 'name' ])) . " ', " .
" description=' " . mysql_escape_string ( stripslashes ( $_POST [ 'description' ])) . " ', " .
" `from`=' " . mysql_escape_string ( stripslashes ( $_POST [ 'from' ])) . " ', " .
" subject=' " . mysql_escape_string ( stripslashes ( $_POST [ 'subject' ])) . " ', " .
" body=' " . mysql_escape_string ( stripslashes ( $_POST [ 'body' ])) . " ' " .
" WHERE id=' " . $_POST [ 'edit' ] . " ' " );
echo mysql_error ();
echo happy ( i18n ( " Email successfully saved " ));
}
}
if ( $_GET [ 'action' ] == " delete " && $_GET [ 'delete' ])
{
mysql_query ( " DELETE FROM emails WHERE id=' " . $_GET [ 'delete' ] . " ' " );
echo happy ( " Email successfully deleted " );
}
if ( $_GET [ 'action' ] == " send " && $_GET [ 'send' ])
{
$q = mysql_query ( " SELECT * FROM emails WHERE id=' " . $_GET [ 'send' ] . " ' " );
$r = mysql_fetch_object ( $q );
echo i18n ( " Please confirm you would like to send the following email, and choose who to send it to " );
echo " <br> " ;
echo " <br> " ;
echo " <form method= \" get \" action= \" communication.php \" > " ;
echo " <table cellspacing=0 cellpadding=3 border=1> " ;
echo " <tr><td><b>From:</b></td><td> " . htmlspecialchars ( $r -> from ) . " </td></tr> " ;
echo " <tr><td><b>To:</b></td><td> " ;
echo " <select name= \" to \" > " ;
echo " <option value= \" \" >Choose Email Recipients</option> " ;
2009-09-18 15:57:35 +00:00
$str = " " ;
2006-03-01 15:59:51 +00:00
foreach ( $mailqueries AS $k => $mq )
{
$tq = mysql_query ( $mq [ 'query' ]);
2009-09-18 15:57:35 +00:00
if ( mysql_error ()) {
echo mysql_error ();
exit ;
}
2006-03-01 15:59:51 +00:00
$num = mysql_num_rows ( $tq );
2009-09-18 15:57:35 +00:00
$str .= " <h2> " . $mq [ 'name' ] . " $num </h2> " ;
while ( $tr = mysql_fetch_object ( $tq )) {
$str .= " [ " . $tr -> uid . " ][ " . $tr -> year . " ] " . $tr -> firstname . " " . $tr -> lastname . " < { $tr -> email } ><br /> " ;
}
2006-03-01 15:59:51 +00:00
echo " <option value= \" $k\ " > " .i18n( $mq['name'] ). " ( " .i18n( " % 1 recipients " ,array( $num ),array( " number " )). " ) </ option > " ;
}
2005-03-02 18:47:19 +00:00
echo " </select> " ;
echo " </td></tr> " ;
echo " <tr><td><b>Date:</b></td><td> " . date ( " r " ) . " </td></tr> " ;
echo " <tr><td><b>Subject:</b></td><td> " . htmlspecialchars ( $r -> subject ) . " </td></tr> " ;
$body = htmlspecialchars ( $r -> body );
echo " <tr><td colspan=2> " . nl2br ( $body ) . " </td></tr> " ;
echo " </table> " ;
2008-07-17 18:33:11 +00:00
if ( ! function_exists ( " exec " )) {
echo " <div class= \" error \" >Sending requires php's exec() function to be available</div> \n " ;
2007-11-16 17:58:59 +00:00
}
else
{
2005-03-02 18:47:19 +00:00
echo " <table border=0 cellspacing=0 cellpadding=30 width= \" 100% \" > " ;
echo " <tr><td align=center> " ;
echo " <input type=hidden name=action value= \" reallysend \" > " ;
echo " <input type=hidden name=reallysend value= \" " . $_GET [ 'send' ] . " \" > " ;
echo " <input type=submit value= \" Yes, Send Email \" > " ;
echo " </form> " ;
echo " </td><td> " ;
echo " <form method=get action= \" communication.php \" > " ;
echo " <input type=submit value= \" No, Do Not Send \" > " ;
echo " </form> " ;
echo " </td></tr> " ;
echo " </table> " ;
2007-11-16 17:58:59 +00:00
}
2009-09-18 15:57:35 +00:00
echo $str ;
2005-03-02 18:47:19 +00:00
}
else if ( $_GET [ 'action' ] == " reallysend " && $_GET [ 'reallysend' ] && $_GET [ 'to' ])
{
if ( file_exists ( " ../data/communication.lock " ))
{
echo error ( " Another email communication is already in progress " );
$lines = file ( " ../data/communication.lock " );
echo " <br> " ;
echo " <a href= \" communication_send_status.php \" >Click here to see the status of the communication sending that is in progress</a> " ;
}
else
{
2007-04-11 22:09:17 +00:00
$to = $_GET [ 'to' ];
2006-03-01 15:59:51 +00:00
if ( array_key_exists ( $to , $mailqueries ))
2005-03-02 18:47:19 +00:00
{
2006-03-01 15:59:51 +00:00
$q = mysql_query ( $mailqueries [ $to ][ 'query' ]);
echo mysql_error ();
$num_subscribed = mysql_num_rows ( $q );
if ( $num_subscribed )
{
$q = mysql_query ( " SELECT * FROM emails WHERE id=' " . $_GET [ 'reallysend' ] . " ' " );
$r = mysql_fetch_object ( $q );
//communcation lock file lines:
// 1: Email ID
// 2: Date it was started
// 3: Subject
// 4: Total Recipients
// 5: _GET['to']
$fp = fopen ( " ../data/communication.lock " , " w " );
fputs ( $fp , $r -> id . " \n " );
fputs ( $fp , date ( " r " ) . " \n " );
fputs ( $fp , $r -> subject . " \n " );
fputs ( $fp , $num_subscribed . " \n " );
fputs ( $fp , $_GET [ 'to' ] . " \n " );
fclose ( $fp );
2008-07-17 18:33:11 +00:00
exec ( " /usr/local/bin/php -q send_communication.php " . $_GET [ 'reallysend' ] . " >/dev/null 2>&1 & " );
2006-03-01 15:59:51 +00:00
echo " <br /> " ;
echo happy ( " Email Communication sending has started! " );
echo " <br> " ;
echo " <a href= \" communication_send_status.php \" >Click here to see the sending progress</a> " ;
}
else
{
echo error ( i18n ( " No recipients " ));
}
2005-03-02 18:47:19 +00:00
}
else
2006-03-01 15:59:51 +00:00
echo error ( i18n ( " Unknown 'to' to send email communication to (%1) " , array ( $_GET [ 'to' ])));
2005-03-02 18:47:19 +00:00
}
}
else if ( $_GET [ 'action' ] == " add " || $_GET [ 'action' ] == " edit " )
{
echo " <form method= \" post \" action= \" communication.php \" > " ;
if ( $_GET [ 'action' ] == " edit " )
{
$q = mysql_query ( " SELECT * FROM emails WHERE id=' " . $_GET [ 'edit' ] . " ' " );
$r = mysql_fetch_object ( $q );
$buttontext = i18n ( " Save Email " );
echo " <input type= \" hidden \" name= \" action \" value= \" edit \" > \n " ;
echo " <input type= \" hidden \" name= \" edit \" value= \" " . $_GET [ 'edit' ] . " \" > \n " ;
echo " <h3> " . i18n ( " Edit Email " ) . " </h3> " ;
$val = $r -> val ;
$name = $r -> name ;
$description = $r -> description ;
$subject = $r -> subject ;
$from = $r -> from ;
$body = $r -> body ;
}
else
{
$buttontext = i18n ( " Add Email " );
echo " <input type= \" hidden \" name= \" action \" value= \" add \" > \n " ;
echo " <h3> " . i18n ( " Add Email " ) . " </h3> " ;
}
if ( $_POST [ 'val' ]) $val = stripslashes ( $_POST [ 'val' ]);
if ( $_POST [ 'name' ]) $name = stripslashes ( $_POST [ 'name' ]);
if ( $_POST [ 'description' ]) $description = stripslashes ( $_POST [ 'description' ]);
if ( $_POST [ 'subject' ]) $subject = stripslashes ( $_POST [ 'subject' ]);
if ( $_POST [ 'from' ]) $from = stripslashes ( $_POST [ 'from' ]);
if ( $_POST [ 'body' ]) $body = stripslashes ( $_POST [ 'body' ]);
2007-10-29 20:21:40 +00:00
if ( ! $from && $config [ 'fairmanageremail' ]) $from = " Fair Manager < " . $config [ 'fairmanageremail' ] . " > " ;
2009-10-14 03:25:47 +00:00
echo " <table class= \" editor \" > " ;
echo " <tr><td style= \" width:10 \ % \" > " . i18n ( " Email Name " ) . " :</td><td><input type= \" text \" name= \" name \" size= \" 60 \" value= \" $name\ " /></ td ></ tr > \n " ;
echo " <tr><td> " . i18n ( " Email Key " ) . " :</td><td> " ;
2005-03-02 18:47:19 +00:00
if ( $r -> type == " system " )
echo $val ;
else
echo " <input type= \" text \" name= \" val \" size= \" 40 \" value= \" $val\ " /> ( must be unique ) " ;
echo " </td></tr> \n " ;
2009-10-14 03:25:47 +00:00
echo " <tr><td> " . i18n ( " Email Description " ) . " :</td><td><input type= \" text \" name= \" description \" size= \" 60 \" value= \" $description\ " /></ td ></ tr > \n " ;
2005-03-02 18:47:19 +00:00
echo " <tr><td colspan= \" 2 \" ><hr /></td></tr> " ;
2009-10-14 03:25:47 +00:00
echo " <tr><td> " . i18n ( " Email Subject " ) . " :</td><td><input type= \" text \" name= \" subject \" size= \" 60 \" value= \" $subject\ " /></ td ></ tr > \n " ;
echo " <tr><td> " . i18n ( " Email From " ) . " :</td><td><input type= \" text \" name= \" from \" size= \" 60 \" value= \" $from\ " /></ td ></ tr > \n " ;
// echo "<tr><td>".i18n("Email Body")."</td><td><textarea name=\"body\" cols=\"80\" rows=\"10\" style=\"font-size: 0.75em\">".htmlspecialchars($body)."</textarea></td></tr>";
echo " <tr><td> " . i18n ( " Email Body " ) . " :</td><td> " ;
require_once ( " ../fckeditor/fckeditor.php " );
$oFCKeditor = new FCKeditor ( " body " ) ;
$oFCKeditor -> BasePath = " ../fckeditor/ " ;
$oFCKeditor -> Value = $body ;
$oFCKeditor -> Width = " 100% " ;
$oFCKeditor -> Height = 300 ;
$oFCKeditor -> Create ();
echo " </td></tr> " ;
2005-03-02 18:47:19 +00:00
echo " <tr><td colspan= \" 2 \" align= \" center \" ><input type= \" submit \" value= \" " . $buttontext . " \" ></td></tr> " ;
echo " </table> " ;
echo " </form> " ;
}
else
{
2007-10-29 20:21:40 +00:00
if ( ! $config [ 'fairmanageremail' ])
echo notice ( i18n ( " Warning: The 'Fair Manager Email' has not been set in SFIAB Configuration / Configuration Variables / Global. Please set it. The 'Fair Manager Email' is the default 'From' address for all emails and without a 'From' address, no emails can be sent! " ));
2005-03-02 18:47:19 +00:00
2007-10-29 20:21:40 +00:00
$q = mysql_query ( " SELECT * FROM emails ORDER BY type,name " );
2005-03-02 18:47:19 +00:00
echo " <A href= \" communication.php?action=add \" >Add New Email</a> " ;
echo " <table class= \" summarytable \" > " ;
echo " <tr> " ;
echo " <th> " . i18n ( " Name " ) . " </th> " ;
echo " <th> " . i18n ( " Type " ) . " </th> " ;
echo " <th> " . i18n ( " Actions " ) . " </th> " ;
echo " </tr> " ;
while ( $r = mysql_fetch_object ( $q ))
{
echo " <tr><td> $r->name </td> " ;
echo " <td> $r->type </td> " ;
echo " <td align= \" center \" > " ;
echo " <a href= \" communication.php?action=edit&edit= $r->id\ " >< img border = \ " 0 \" src= \" " . $config [ 'SFIABDIRECTORY' ] . " /images/16/edit. " . $config [ 'icon_extension' ] . " \" ></a> " ;
//only user emails can be deleted, system ones are required and cannot be removed
if ( $r -> type == " user " )
{
echo " " ;
echo " <a onclick= \" return confirmClick('Are you sure you want to remove email?') \" href= \" communication.php?action=delete&delete= $r->id\ " >< img border = 0 src = \ " " . $config [ 'SFIABDIRECTORY' ] . " /images/16/button_cancel. " . $config [ 'icon_extension' ] . " \" ></a> " ;
echo " " ;
echo " <a href= \" communication.php?action=send&send= $r->id\ " > Send </ a > " ;
}
echo " </td> \n " ;
echo " </tr> " ;
}
echo " </table> " ;
2009-09-18 15:57:35 +00:00
2005-03-02 18:47:19 +00:00
}
send_footer ();
?>