paristemi
[ class tree: paristemi ] [ index: paristemi ] [ all elements ]

Source for file feedback.php

Documentation is available at feedback.php

  1. <?php
  2. /**
  3. * <b>Feedback Form</b><br />
  4. * HTML based form for contacting people or ministries.
  5. * Accepts HTTP Get parameters for selecting ministry or person.
  6. * @author Kristen O'Brien <kristen_paristemi-com>
  7. * @copyright Copyright 2004, Kristen O'Brien
  8. * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  9. * @link http://www.paristemi.com Paristemi Main Site
  10. * @package paristemi
  11. * @subpackage paristemi_business_logic
  12. * @since Build 0.3
  13. * @version Build 0.7
  14. * @filesource
  15. */
  16. /**
  17. * Include the constants file and all of the files in the include list
  18. */
  19. if(ltrim(dirname($_SERVER['SCRIPT_FILENAME'])) == "" || !file_exists($_SERVER['DOCUMENT_ROOT']."/constants.php")) {
  20. if(!file_exists("../constants.php")) { require_once("../public_html/constants.php"); }
  21. else { require_once("../constants.php"); }
  22. }
  23. else { require_once($_SERVER['DOCUMENT_ROOT']."/constants.php"); }
  24. foreach($INCLUDE_LIST as $includefile) { require_once $includefile; }
  25.  
  26. $db = new Database();
  27. $db_contact = $db->GetClass('contact');
  28. $smarty = UtilSmarty::createSmarty();
  29.  
  30. require_once $HTTP_DOCUMENT_ROOT.$INCLUDE_PATH.$HEADER.
  31. "?pagetitle=".str_replace(" ","%20",htmlentities($S_CONTACT." ".$S_FORM)).
  32. "&pagedesc=".str_replace(" ","%20",htmlentities($CHURCH_NAME." ".$S_DESC_CONTACT));
  33.  
  34. $smarty->assign('heading',$S_CONTACT." ".$CHURCH_NAME);
  35. if(count($HTTP_POST_VARS) > 0) {
  36. $subject="";$toemail="";$fromemail="";$message="";$location="";$personname="";$toname="";
  37. if(isset($HTTP_POST_VARS['Subject'])) {
  38. $subject = "Feedback Form: ".stripslashes($HTTP_POST_VARS['Subject']);}
  39. if(isset($HTTP_POST_VARS['Name'])) { $personname = stripslashes($HTTP_POST_VARS['Name']); }
  40. if(isset($HTTP_POST_VARS['ToEmail'])) {$toemail = $HTTP_POST_VARS['ToEmail'];}
  41. if(isset($HTTP_POST_VARS['FromEmail'])) {$fromemail = $HTTP_POST_VARS['FromEmail'];}
  42. if(isset($HTTP_POST_VARS['Message'])) {$message = stripslashes($HTTP_POST_VARS['Message']);}
  43. if(isset($HTTP_POST_VARS['Location'])) {$location = stripslashes($HTTP_POST_VARS['Location']);}
  44. if(isset($HTTP_POST_VARS['ToName'])) {$toname = stripslashes($HTTP_POST_VARS['ToName']);}
  45. $message = $S_FROM.": ".$personname."\r\n\r\n".$S_TO.": ".$toname."\r\n\r\n".
  46. $message."\r\n\r\n".$S_LOCATION.": ".$location;
  47. if(substr($toemail,0,1) == 'C') {
  48. $contactperson = $db_contact->GetContactData(substr($toemail,1));
  49. $toemail = $contactperson->Email;
  50. }
  51. else { $toemail = $FEEDBACK_EMAILS[$toemail]; }
  52. if( mail($toemail, $subject, $message,
  53. "From: ".$fromemail."\r\n"
  54. ."Reply-To: ".$fromemail."\r\n"
  55. ."X-Mailer: PHP/" . phpversion())) {
  56. $smarty->assign('notice',$N_MSG_SENT_TO." ".$toname.", ".$S_THANK_YOU."!");
  57. $smarty->assign('returnlink',array('LinkPath'=>$HTTP_DOCUMENT_ROOT,
  58. 'LinkText'=>$S_RETURN_SITE));
  59. }
  60. else {
  61. $smarty->assign('error',$E_MAIL_SEND);
  62. $smarty->assign('returnlink',array('LinkPath'=>$HTTP_DOCUMENT_ROOT.$FEEDBACK_FILE,
  63. 'LinkText'=>$S_RETURN_FORM));
  64. }
  65. }
  66. else {
  67. $smarty->assign('formname',"feedback");
  68. $smarty->assign('formaction',$FEEDBACK_FILE);
  69. $textinputs = array();
  70. $textinputs[] = array('heading'=>$S_FORM_SUBJECT,'name'=>"Subject");
  71. $textinputs[] = array('heading'=>$S_FORM_NAME,'name'=>"Name");
  72. $textinputs[] = array('heading'=>$S_FORM_EMAIL,'name'=>"FromEmail");
  73. $textinputs[] = array('heading'=>$S_FORM_LOCATION,'name'=>"Location");
  74. $smarty->assign('textinputs',$textinputs);
  75. if(isset($HTTP_GET_VARS['feedbackname'])) {
  76. $smarty->assign('toptext',array('heading'=>$S_FORM_SEND_TO.": ",'text'=>$HTTP_GET_VARS['feedbackname']));
  77. $smarty->assign('hiddeninputs',array(
  78. array('name'=>"ToEmail",'value'=>$FEEDBACK_LIST[$HTTP_GET_VARS['feedbackname']]),
  79. array('name'=>"ToName",'value'=>$HTTP_GET_VARS['feedbackname'])));
  80. }
  81. else if(isset($HTTP_GET_VARS['id'])) {
  82. $fname = "";
  83. $contact = $db_contact->GetContactData($HTTP_GET_VARS['id']);
  84. if($contact->ShowMainTitle) { $fname .= $contact->Title." "; }
  85. if($contact->ShowMainFirstName) { $fname .= $contact->First." "; }
  86. if($contact->ShowMainLastName) { $fname .= $contact->Last; }
  87. $fname = trim($fname);
  88. $smarty->assign('toptext',array('heading'=>$S_FORM_SEND_TO.": ",'text'=>$fname));
  89. $smarty->assign('hiddeninputs',array(
  90. array('name'=>"ToEmail",'value'=>"C".$contact->ID),
  91. array('name'=>"ToName",'value'=>$fname)));
  92. }
  93. else {
  94. $fname = $S_GENERAL_INFORMATION;
  95. $ministries =& $db_contact->GetFormContactData($GLOBALS['CONTACT_TITLE_ORDER'],0);
  96. $people =& $db_contact->GetFormContactData($GLOBALS['CONTACT_TITLE_ORDER'],1);
  97. $ministrylist = array();
  98. foreach($ministries as $value) {
  99. $full_name = "";
  100. if($value->ShowMainTitle) { $full_name .= $value->Title." "; }
  101. if($value->ShowMainFirstName) { $full_name .= $value->First." "; }
  102. if($value->ShowMainLastName) { $full_name .= $value->Last; }
  103. $full_name = trim($full_name);
  104. $ministrylist[$full_name] = 'C'.$value->ID;
  105. }
  106. $peoplelist = array();
  107. foreach($people as $person) {
  108. $full_name = "";
  109. if($person->ShowMainTitle) { $full_name .= $person->Title." "; }
  110. if($person->ShowMainFirstName) { $full_name .= $person->First." "; }
  111. if($person->ShowMainLastName) { $full_name .= $person->Last; }
  112. $full_name = trim($full_name);
  113. $peoplelist[$full_name] = 'C'.$person->ID;
  114. }
  115. $ministrytop = array($FEEDBACK_MIN_DELIM=>"0");
  116. $peopletop = array($FEEDBACK_PEOPLE_DELIM=>"0");
  117. $formcontacts = array_merge($FEEDBACK_LIST,$ministrylist);
  118. ksort($formcontacts);
  119. $formcontacts = array_merge($ministrytop,$formcontacts,$peopletop,$peoplelist);
  120. $prevcontact = "";
  121. $options = array();
  122. foreach($formcontacts as $ftopic => $femail) {
  123. if(strcmp($ftopic,$prevcontact) != 0) {
  124. if(strcasecmp($fname,$ftopic) == 0) { $selected = "yes"; }
  125. else { $selected = "no"; }
  126. $options[] = array('value'=>$femail,'selected'=>$selected,'text'=>$ftopic);
  127. $prevcontact = $ftopic;
  128. }
  129. }
  130. $smarty->assign('selectareas',array(array('heading'=>$S_FORM_SEND_TO,
  131. 'items'=>array(array('name'=>"ToEmail",'options'=>$options)))));
  132. }
  133. $smarty->assign('textboxes',array(array(
  134. 'heading'=>$S_FORM_MESSAGE,'name'=>"Message",'cols'=>"60",'rows'=>"15")));
  135. $smarty->assign('formnote',$N_MSG_WAIT);
  136. $smarty->assign('resetname',$S_FORM_RESET);
  137. $smarty->assign('submitname',$S_FORM_SUBMIT);
  138. }
  139. UtilSmarty::displaySectionPage($smarty,"no");
  140. ?>
  141. <?php require_once $SERVER_DIRECTORY.$INCLUDE_PATH.$FOOTER; ?>

Documentation generated on Mon, 10 May 2004 12:09:41 -0700 by phpDocumentor 1.3.0RC3