[ Index ] |
|
Code source de SPIP Agora 1.4 |
1 <?php 2 /***************************************************** 3 * This file is part of Agora, web based content management system. 4 * 5 * Agora is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation; version 2 of the License. 8 * 9 * Agora is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details (file "COPYING"). 13 * 14 * Copyright © Arnaud Martin, Antoine Pitrou et Philippe Rivière. 15 * List of authors detailed in "copyright_fr.html" file. 16 * E-mail : agora@sig.premier-ministre.gouv.fr 17 * Web site : http://www.agora.gouv.fr 18 *****************************************************/ 19 /* 20 -------------Ajout Clever Age abstraction BD--------- 21 */ 22 require_once(dirname(__FILE__). "/../../../ecrire/include/bd/inc_subscriber_factory.php"); 23 24 require_once(dirname(__FILE__). "/../../../ecrire/include/bd/inc_newsletter_factory.php"); 25 require_once(dirname(__FILE__). "/../../../ecrire/inc_version.php"); 26 /* 27 ----------------fin zone d'ajout--------------------- 28 */ 29 if (isset($_GET['id']) && $_GET['id'] != '') { 30 $subscriberMetier = &recuperer_instance_subscriber(); 31 $data = $subscriberMetier->getDataForLsrId($_GET['id']); 32 33 if (PEAR::isError($data)) { 34 die($data->getMessage()); 35 } 36 if ($data) { 37 // Désinscription à cette liste demandée 38 $newsletterMetier = &recuperer_instance_newsletter(); 39 $loadOK = $newsletterMetier->load($data['lst_id']); 40 41 if (PEAR::isError($loadOK)) { 42 die($loadOK->getMessage()); 43 } 44 45 $mySubscriber = &recuperer_instance_subscriber(); 46 $loadOK = $mySubscriber->load($data['sub_id']); 47 48 if (PEAR::isError($loadOK)) { 49 die($loadOK->getMessage()); 50 } 51 52 if (!$mySubscriber->isPending($newsletterMetier)) { 53 $actionId = md5('unsubscribe#' . $data['lst_id']. '#' . $data['sub_id']. '#' . time()); 54 $pendOK = $mySubscriber->suspend($newsletterMetier, 'unsubscribe', time(), $actionId); 55 if (PEAR::isError($pendOK)) { 56 die($pendOK->getMessage()); 57 } 58 } 59 else { 60 require_once(dirname(__FILE__). "/../ecrire/include/bd/inc_subscriber_pending_factory.php"); 61 $pendingAction = &recuperer_instance_subscriber_pending(); 62 $pendingAction->loadLstSub($data['lst_id'], $data['sub_id']); 63 $actionId = $pendingAction->getPndActionId(); 64 } 65 66 // Composition du message de demande de confirmation 67 if (lire_meta('CM_BASE_TEMPLATE')) { 68 $squel = lire_meta('CM_BASE_TEMPLATE'); 69 } 70 else { 71 $squel = 'newsletter.php'; 72 } 73 74 $URL_SITE_SPIP = lire_meta('adresse_site'); 75 76 // rajout d'un / éventuellement 77 if (substr($URL_SITE_SPIP, strlen($URL_SITE_SPIP) - 1, 1) != '/') 78 $URL_SITE_SPIP .= '/'; 79 80 $subject = ((int)$newsletterMetier->getSubjectTag() == 1 ? '[' . $newsletterMetier->getName(). '] ' : ''). $newsletterMetier->getUnsubscribeSubject(); 81 $template = array(); 82 $template['#ADDRESS#'] = $mySubscriber->getEmail(); 83 $template['#FORMAT#'] = ($data['lsr_mode'] == 1 ? 'HTML' : 'texte'); 84 $template['#URL#'] = $URL_SITE_SPIP . $squel . '?id=' . $actionId . '&typeAction=do'; // pour se réinscrire ? 85 $template['#UNSUBSCRIBE#'] = $URL_SITE_SPIP . $squel . '?id=' . $actionId . '&typeAction=rm'; // pour se désinscrire 86 //$template['#URL#'] = lire_meta('CM_BASE_URL').'/'.$GLOBALS['SCRIPT_NAME'].'?id='.$actionId.'&typeAction=do'; 87 //$template['#UNSUBSCRIBE#'] = lire_meta('CM_BASE_URL').'/'.$GLOBALS['SCRIPT_NAME'].'?id='.$actionId.'&typeAction=rm'; 88 $message = $newsletterMetier->getUnsubscribeText(); 89 90 while (list($from, $to) = each($template)) { 91 $message = str_replace($from, $to, $message); 92 } 93 94 // Envoi du message 95 mail($mySubscriber->getEmail(), $subject, $message, 'From: ' . lire_meta('CM_MAIL_FROM')); 96 $cm_sub = 'unsub_ask'; 97 //echo '<p>Désinscription de la liste '.$mySubscriber->getEmail().' demandée. Vous allez recevoir un message demandant confirmation.</p>'; 98 // redirection 99 //header ('Location: '.$URL_SITE_SPIP.$squel.'?typeAction=unsubscribe_ask'); 100 } 101 else { 102 // TBI 103 //echo '<p>Aucune inscription ne correspond à ce paramètre.</p>'; 104 $cm_sub = 'user_unknown'; 105 } 106 107 /* 108 if ($data = $db->getRow("SELECT * FROM ".CM_TABLE_PREFIX."_lists_subscribers WHERE lsr_id = '".$_GET['id']."'")) { 109 // Désinscription à cette liste demandée 110 $actionId = md5('unsubscribe#'.$data['lst_id'].'#'.$data['sub_id'].'#'.time()); 111 if ($db->getOne("SELECT COUNT(*) FROM ".CM_TABLE_PREFIX."_pending WHERE lst_id = ".$data['lst_id']." AND sub_id = ".$data['sub_id']) == 0) { 112 $db->query("INSERT INTO ".CM_TABLE_PREFIX."_pending (lst_id, sub_id, pnd_action, pnd_action_date, pnd_action_id) VALUES (".$data['lst_id'].", ".$data['sub_id'].", 'unsubscribe', ".time().", '".$actionId."')"); 113 } 114 115 // Composition du message de demande de confirmation 116 $recipient = $db->getRow("SELECT * FROM ".CM_TABLE_PREFIX."_subscribers WHERE sub_id=".$data['sub_id']); 117 $list = $db->getRow("SELECT * FROM ".CM_TABLE_PREFIX."_lists WHERE lst_id=".$data['lst_id']); 118 $subject = ((int)$list['lst_subject_tag'] == 1 ? '['.$list['lst_name'].'] ' : '').$list['lst_unsubscribe_subject']; 119 $template = array(); 120 $template['#ADDRESS#'] = $recipient['sub_email']; 121 $template['#FORMAT#'] = ($data['lsr_mode'] == 1 ? 'HTML' : 'texte'); 122 $template['#URL#'] = CM_BASE_URL.'do.php?id='.$actionId; 123 $template['#UNSUBSCRIBE#'] = CM_BASE_URL.'rm.php?id='.$_GET['id']; 124 $message = $list['lst_unsubscribe_text']; 125 while (list($from, $to) = each($template)) { 126 $message = str_replace($from, $to, $message); 127 } 128 // Envoi du message 129 mail($recipient['sub_email'], $subject, $message, 'From: '.CM_MAIL_FROM); 130 echo '<p>Désinscription de la liste '.$list['lst_name'].' demandée. Vous allez recevoir un message demandant confirmation.</p>'; 131 } else { 132 echo '<p>Aucune inscription ne correspond à ce paramètre.</p>'; 133 } 134 */ 135 } 136 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sat Feb 24 14:40:03 2007 | par Balluche grâce à PHPXref 0.7 |