- <?php
- /**
- * <b>Feedback Form</b><br />
- * HTML based form for contacting people or ministries.
- * Accepts HTTP Get parameters for selecting ministry or person.
- * @author Kristen O'Brien <kristen_paristemi-com>
- * @copyright Copyright 2004, Kristen O'Brien
- * @license http://opensource.org/licenses/gpl-license.php GNU Public License
- * @link http://www.paristemi.com Paristemi Main Site
- * @package paristemi
- * @subpackage paristemi_business_logic
- * @since Build 0.3
- * @version Build 0.7
- * @filesource
- */
- /**
- * Include the constants file and all of the files in the include list
- */
- if(ltrim(dirname($_SERVER['SCRIPT_FILENAME'])) == "" || !file_exists($_SERVER['DOCUMENT_ROOT']."/constants.php")) {
- if(!file_exists("../constants.php")) { require_once("../public_html/constants.php"); }
- else { require_once("../constants.php"); }
- }
- else { require_once($_SERVER['DOCUMENT_ROOT']."/constants.php"); }
- foreach($INCLUDE_LIST as $includefile) { require_once $includefile; }
-
- $db = new Database();
- $db_contact = $db->GetClass('contact');
- $smarty = UtilSmarty::createSmarty();
-
- require_once $HTTP_DOCUMENT_ROOT.$INCLUDE_PATH.$HEADER.
- "?pagetitle=".str_replace(" ","%20",htmlentities($S_CONTACT." ".$S_FORM)).
- "&pagedesc=".str_replace(" ","%20",htmlentities($CHURCH_NAME." ".$S_DESC_CONTACT));
-
- $smarty->assign('heading',$S_CONTACT." ".$CHURCH_NAME);
-
- if(count($HTTP_POST_VARS) > 0) {
- $subject="";$toemail="";$fromemail="";$message="";$location="";$personname="";$toname="";
- if(isset($HTTP_POST_VARS['Subject'])) {
- $subject = "Feedback Form: ".stripslashes($HTTP_POST_VARS['Subject']);}
- if(isset($HTTP_POST_VARS['Name'])) { $personname = stripslashes($HTTP_POST_VARS['Name']); }
- if(isset($HTTP_POST_VARS['ToEmail'])) {$toemail = $HTTP_POST_VARS['ToEmail'];}
- if(isset($HTTP_POST_VARS['FromEmail'])) {$fromemail = $HTTP_POST_VARS['FromEmail'];}
- if(isset($HTTP_POST_VARS['Message'])) {$message = stripslashes($HTTP_POST_VARS['Message']);}
- if(isset($HTTP_POST_VARS['Location'])) {$location = stripslashes($HTTP_POST_VARS['Location']);}
- if(isset($HTTP_POST_VARS['ToName'])) {$toname = stripslashes($HTTP_POST_VARS['ToName']);}
- $message = $S_FROM.": ".$personname."\r\n\r\n".$S_TO.": ".$toname."\r\n\r\n".
- $message."\r\n\r\n".$S_LOCATION.": ".$location;
- if(substr($toemail,0,1) == 'C') {
- $contactperson = $db_contact->GetContactData(substr($toemail,1));
- $toemail = $contactperson->Email;
- }
- else { $toemail = $FEEDBACK_EMAILS[$toemail]; }
- if( mail($toemail, $subject, $message,
- "From: ".$fromemail."\r\n"
- ."Reply-To: ".$fromemail."\r\n"
- ."X-Mailer: PHP/" . phpversion())) {
- $smarty->assign('notice',$N_MSG_SENT_TO." ".$toname.", ".$S_THANK_YOU."!");
- $smarty->assign('returnlink',array('LinkPath'=>$HTTP_DOCUMENT_ROOT,
- 'LinkText'=>$S_RETURN_SITE));
- }
- else {
- $smarty->assign('error',$E_MAIL_SEND);
- $smarty->assign('returnlink',array('LinkPath'=>$HTTP_DOCUMENT_ROOT.$FEEDBACK_FILE,
- 'LinkText'=>$S_RETURN_FORM));
- }
- }
- else {
- $smarty->assign('formname',"feedback");
- $smarty->assign('formaction',$FEEDBACK_FILE);
- $textinputs = array();
- $textinputs[] = array('heading'=>$S_FORM_SUBJECT,'name'=>"Subject");
- $textinputs[] = array('heading'=>$S_FORM_NAME,'name'=>"Name");
- $textinputs[] = array('heading'=>$S_FORM_EMAIL,'name'=>"FromEmail");
- $textinputs[] = array('heading'=>$S_FORM_LOCATION,'name'=>"Location");
- $smarty->assign('textinputs',$textinputs);
-
- if(isset($HTTP_GET_VARS['feedbackname'])) {
- $smarty->assign('toptext',array('heading'=>$S_FORM_SEND_TO.": ",'text'=>$HTTP_GET_VARS['feedbackname']));
- $smarty->assign('hiddeninputs',array(
- array('name'=>"ToEmail",'value'=>$FEEDBACK_LIST[$HTTP_GET_VARS['feedbackname']]),
- array('name'=>"ToName",'value'=>$HTTP_GET_VARS['feedbackname'])));
- }
- else if(isset($HTTP_GET_VARS['id'])) {
- $fname = "";
- $contact = $db_contact->GetContactData($HTTP_GET_VARS['id']);
- if($contact->ShowMainTitle) { $fname .= $contact->Title." "; }
- if($contact->ShowMainFirstName) { $fname .= $contact->First." "; }
- if($contact->ShowMainLastName) { $fname .= $contact->Last; }
- $fname = trim($fname);
- $smarty->assign('toptext',array('heading'=>$S_FORM_SEND_TO.": ",'text'=>$fname));
- $smarty->assign('hiddeninputs',array(
- array('name'=>"ToEmail",'value'=>"C".$contact->ID),
- array('name'=>"ToName",'value'=>$fname)));
- }
- else {
- $fname = $S_GENERAL_INFORMATION;
- $ministries =& $db_contact->GetFormContactData($GLOBALS['CONTACT_TITLE_ORDER'],0);
- $people =& $db_contact->GetFormContactData($GLOBALS['CONTACT_TITLE_ORDER'],1);
- $ministrylist = array();
- foreach($ministries as $value) {
- $full_name = "";
- if($value->ShowMainTitle) { $full_name .= $value->Title." "; }
- if($value->ShowMainFirstName) { $full_name .= $value->First." "; }
- if($value->ShowMainLastName) { $full_name .= $value->Last; }
- $full_name = trim($full_name);
- $ministrylist[$full_name] = 'C'.$value->ID;
- }
- $peoplelist = array();
- foreach($people as $person) {
- $full_name = "";
- if($person->ShowMainTitle) { $full_name .= $person->Title." "; }
- if($person->ShowMainFirstName) { $full_name .= $person->First." "; }
- if($person->ShowMainLastName) { $full_name .= $person->Last; }
- $full_name = trim($full_name);
- $peoplelist[$full_name] = 'C'.$person->ID;
- }
- $ministrytop = array($FEEDBACK_MIN_DELIM=>"0");
- $peopletop = array($FEEDBACK_PEOPLE_DELIM=>"0");
- $formcontacts = array_merge($FEEDBACK_LIST,$ministrylist);
- ksort($formcontacts);
- $formcontacts = array_merge($ministrytop,$formcontacts,$peopletop,$peoplelist);
- $prevcontact = "";
- $options = array();
- foreach($formcontacts as $ftopic => $femail) {
- if(strcmp($ftopic,$prevcontact) != 0) {
- if(strcasecmp($fname,$ftopic) == 0) { $selected = "yes"; }
- else { $selected = "no"; }
- $options[] = array('value'=>$femail,'selected'=>$selected,'text'=>$ftopic);
- $prevcontact = $ftopic;
- }
- }
- $smarty->assign('selectareas',array(array('heading'=>$S_FORM_SEND_TO,
- 'items'=>array(array('name'=>"ToEmail",'options'=>$options)))));
- }
- $smarty->assign('textboxes',array(array(
- 'heading'=>$S_FORM_MESSAGE,'name'=>"Message",'cols'=>"60",'rows'=>"15")));
- $smarty->assign('formnote',$N_MSG_WAIT);
- $smarty->assign('resetname',$S_FORM_RESET);
- $smarty->assign('submitname',$S_FORM_SUBMIT);
- }
- UtilSmarty::displaySectionPage($smarty,"no");
- ?>
- <?php require_once $SERVER_DIRECTORY.$INCLUDE_PATH.$FOOTER; ?>