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

Source for file subscribe.php

Documentation is available at subscribe.php

  1. <?php
  2. /**
  3. * <b>Subscribe/Unsubscribe : Mailing List Section</b><br />
  4. * Allows a user to subscribe or unsubscribe from mailing list(s).
  5. * @author Kristen O'Brien <kristen_paristemi-com>
  6. * @copyright Copyright 2004, Kristen O'Brien
  7. * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  8. * @link http://www.paristemi.com Paristemi Main Site
  9. * @package paristemi
  10. * @subpackage paristemi_business_logic
  11. * @since Build 0.5
  12. * @version Build 0.7
  13. * @filesource
  14. */
  15. /**
  16. * Include the constants file and all of the files in the include list
  17. */
  18. if(ltrim(dirname($_SERVER['SCRIPT_FILENAME'])) == "" || !file_exists($_SERVER['DOCUMENT_ROOT']."/constants.php")) {
  19. if(!file_exists("../constants.php")) { require_once("../public_html/constants.php"); }
  20. else { require_once("../constants.php"); }
  21. }
  22. else { require_once($_SERVER['DOCUMENT_ROOT']."/constants.php"); }
  23. foreach($INCLUDE_LIST as $includefile) { require_once $includefile; }
  24. $db = new Database();
  25. $db_ml = $db->GetClass('mailinglist');
  26. $smarty = UtilSmarty::createSmarty();
  27. $type="";$id=null;$email="";$approve="";$printtype = "";
  28. if(count($HTTP_POST_VARS) > 0) {
  29. if(isset($HTTP_POST_VARS['Type'])) {$type = $HTTP_POST_VARS['Type'];}
  30. if(isset($HTTP_POST_VARS['Email'])) {$email = $HTTP_POST_VARS['Email'];}
  31. if(isset($HTTP_POST_VARS['ID'])) {$id = $HTTP_POST_VARS['ID'];}
  32. }
  33. else if(getenv("QUERY_STRING")) {
  34. if(isset($HTTP_GET_VARS['id'])) {$id = $HTTP_GET_VARS['id'];}
  35. if(isset($HTTP_GET_VARS['type'])) {$type = $HTTP_GET_VARS['type'];}
  36. if(isset($HTTP_GET_VARS['approve'])) {$approve = $HTTP_GET_VARS['approve'];}
  37. if(isset($HTTP_GET_VARS['email'])) {$email = $HTTP_GET_VARS['email'];}
  38. }
  39. switch($type) {
  40. case 'Subscribe' : $printtype = $S_SUBSCRIBE; break;
  41. case 'Unsubscribe' : $printtype = $S_UNSUBSCRIBE; break;
  42. }
  43. if($type != "") { $pagesubtitle = $type; }
  44. else { $pagesubtitle = $S_SUBSCRIBE." ".$S_AND." ".$S_UNSUBSCRIBE; }
  45. require_once $HTTP_DOCUMENT_ROOT.$INCLUDE_PATH.$HEADER.
  46. "?pagetitle=".str_replace(" ","%20",htmlentities($S_MAILING_LISTS)).
  47. "&pagesubtitle=".str_replace(" ","%20",htmlentities($pagesubtitle)).
  48. "&pagedesc=".str_replace(" ","%20",htmlentities($CHURCH_NAME." ".$S_DESC_MAILING_LISTS));
  49.  
  50. $sidesection['Title'] = $S_MAILING_LISTS;
  51. $sidesection['Links'] = array(array(
  52. 'LinkPath'=>$HTTP_DOCUMENT_ROOT.$MAILING_LIST_DIR.$ML_SUBSCRIBE_FILE."?type=Subscribe",
  53. 'LinkText'=>$S_SUBSCRIBE), array(
  54. 'LinkPath'=>$HTTP_DOCUMENT_ROOT.$MAILING_LIST_DIR.$ML_SUBSCRIBE_FILE."?type=Unsubscribe",
  55. 'LinkText'=>$S_UNSUBSCRIBE), array(
  56. 'LinkPath'=>$HTTP_DOCUMENT_ROOT.$MAILING_LIST_DIR. $ML_ADMIN_FILE,
  57. 'LinkText'=>$S_ADMIN." ".$S_LOGIN));
  58. $smarty->assign('sidesections',array($sidesection));
  59. if(count($HTTP_POST_VARS) > 0) {
  60. if($id != null && $email != "" && $type != "") {
  61. $mailtitle = $CHURCH_NAME." ".$S_MAILING_LIST." ".$printtype;
  62. $ids = array();
  63. $idsarstr = implode(",",$id);
  64. foreach($id as $iditem) {
  65. $item = $db_ml->GetMailingListData($iditem);
  66. $ids[] = $item->Name; }
  67. $idsstring = implode(", ",$ids);
  68. $firsttext = $S_MSG_ML_REQUEST.$S_MSG_FOOTER."\r\n\r\n";
  69. $lasttext = $S_MAILING_LISTS.": ".$idsstring;
  70. $headers = "From: ".$FOOTER_CONTACT."\r\n"
  71. ."Reply-To: ".$FOOTER_CONTACT."\r\n"
  72. ."X-Mailer: PHP/" . phpversion();
  73. $mllink = $HTTP_DOCUMENT_ROOT.$MAILING_LIST_DIR.$ML_SUBSCRIBE_FILE.
  74. "?email=".$email."&type=".$type."&id=".$idsarstr."&approve=yes\r\n\r\n";
  75. $sent = mail($email,$mailtitle,
  76. $firsttext.$mllink.$lasttext,$headers);
  77. if($sent) {
  78. $smarty->assign('heading',$N_ML_MSG_SENT_HEAD);
  79. $smarty->assign('notice',$N_MSG_SENT_TO." ".$email." ".$N_ML_MSG_SENT_SUB.": ".$idsstring);
  80. $smarty->assign('returnlink',array('LinkPath'=>$HTTP_DOCUMENT_ROOT,'LinkText'=>$S_RETURN_SITE));
  81. }
  82. else if(!$sent) {
  83. $smarty->assign('heading',$E_ML_MSG_NOT_SENT_HEAD);
  84. $smarty->assign('error',$E_FILL_FORM_COMPLETE);
  85. $smarty->assign('returnlink',array(
  86. 'LinkPath'=>$HTTP_DOCUMENT_ROOT.$MAILING_LIST_DIR.$ML_SUBSCRIBE_FILE."?type=".$type,
  87. 'LinkText'=>$S_RETURN_FORM));
  88. }
  89. }
  90. else {
  91. $smarty->assign('heading',$E_ML_MSG_NOT_SENT_HEAD);
  92. $smarty->assign('error',$E_FILL_FORM_COMPLETE);
  93. $smarty->assign('returnlink',array(
  94. 'LinkPath'=>$HTTP_DOCUMENT_ROOT.$MAILING_LIST_DIR.$ML_SUBSCRIBE_FILE."?type=".$type,
  95. 'LinkText'=>$S_RETURN_FORM));
  96. }
  97. }
  98. else if(getenv("QUERY_STRING")) {
  99. $idarr = explode(",",$id);
  100. if($approve == "yes" && $email != "" && $idarr != "") {;
  101. foreach($idarr as $iditem) {
  102. $result = false; $exists = false;
  103. if($type == "Subscribe") {
  104. $tempml = $db_ml->GetMailingListData($iditem);
  105. if(strpos($tempml->Emails,$email) === false) {
  106. $result = $db_ml->AddEmailInMailingList($email,$iditem);
  107. }
  108. else { $exists = true; }
  109. }
  110. else if($type == "Unsubscribe") {
  111. $result = $db_ml->RemoveEmailInMailingList($email,$iditem); }
  112. if(!$result && !$exists) {
  113. $smarty->assign('heading',$E_ML_NOT_UNSUBSCRIBE_HEAD);
  114. $smarty->assign('error',$E_FILL_FORM_COMPLETE);
  115. $smarty->assign('returnlink',array(
  116. 'LinkPath'=>$HTTP_DOCUMENT_ROOT.$MAILING_LIST_DIR.$ML_SUBSCRIBE_FILE."?type=".$type,
  117. 'LinkText'=>$S_RETURN_FORM));
  118. break;
  119. }
  120. if($exists) {
  121. $smarty->assign('heading',$E_ML_EMAIL_EXISTS_HEAD);
  122. $smarty->assign('error',$E_ML_EMAIL_EXISTS);
  123. $smarty->assign('returnlink',array(
  124. 'LinkPath'=>$HTTP_DOCUMENT_ROOT.$MAILING_LIST_DIR.$MAILING_LIST_FILE,
  125. 'LinkText'=>$S_RETURN_TO." ".$S_MAILING_LISTS));
  126. break;
  127. }
  128. }
  129. if($result) {
  130. $listelements = array();
  131. $smarty->assign('heading',$N_ML_SUCCESS_HEAD);
  132. switch($type) {
  133. case 'Subscribe' : $smarty->assign('notice',$N_ML_SUCCESS_SUB.":"); break;
  134. case 'Unsubscribe' : $smarty->assign('notice',$N_ML_SUCCESS_UNS.":"); break;
  135. }
  136. foreach($idarr as $iditem) {
  137. $item = $db_ml->GetMailingListData($iditem);
  138. $listelements[] = array('Title'=>$item->Name);
  139. }
  140. $smarty->assign('listelements',$listelements);
  141. }
  142. }
  143. else if($type != null) {
  144. $smarty->assign('heading',$S_MAILING_LISTS." ".$printtype);
  145. $smarty->assign('bottomnote',$S_FORM_WAIT_NOTE." ".$S_FORM_ML);
  146. $mls = $db_ml->GetPublicMailingLists();
  147. if($mls != null) {
  148. $smarty->assign('formname','subscribe');
  149. $smarty->assign('formaction',$ML_SUBSCRIBE_FILE);
  150. $smarty->assign('hiddeninputs',array(array('name'=>'Type','value'=>$type)));
  151. $smarty->assign('checkboxtitle',$S_MAILING_LISTS.':');
  152. $checkboxes = array();
  153. foreach ($mls as $item) {
  154. if($id == $item->ID) { $checked = "yes"; }
  155. else { $checked = "no"; }
  156. $checkboxes[] = array('name'=>'ID[]','value'=>$item->ID,'checked'=>$checked,'Title'=>$item->Name);
  157. }
  158. $smarty->assign('checkboxes',$checkboxes);
  159. $smarty->assign('textinputs',array(array('name'=>'Email','heading'=>$S_FORM_EMAIL)));
  160. $smarty->assign('submitname',$printtype);
  161. }
  162. else {
  163. $smarty->assign('heading',$S_MAILING_LISTS);
  164. $smarty->assign('notice',$N_ML_NONE);
  165. }
  166. }
  167. }
  168. else { $smarty->assign('introstatements',array('Title'=>$S_MAILING_LISTS,'Text'=>$MAILING_LIST_INTRO)); }
  169. UtilSmarty::displaySectionPage($smarty);
  170. ?>
  171. <?php require_once $SERVER_DIRECTORY.$INCLUDE_PATH.$FOOTER; ?>

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