[ Index ] |
|
Code source de b2evolution 2.1.0-beta |
1 <?php 2 /** 3 * This file updates the current user's subscriptions! 4 * 5 * This file is part of the evoCore framework - {@link http://evocore.net/} 6 * See also {@link http://sourceforge.net/projects/evocms/}. 7 * 8 * @copyright (c)2003-2007 by Francois PLANQUE - {@link http://fplanque.net/} 9 * 10 * {@internal License choice 11 * - If you have received this file as part of a package, please find the license.txt file in 12 * the same folder or the closest folder above for complete license terms. 13 * - If you have received this file individually (e-g: from http://evocms.cvs.sourceforge.net/) 14 * then you must choose one of the following licenses before using the file: 15 * - GNU General Public License 2 (GPL) - http://www.opensource.org/licenses/gpl-license.php 16 * - Mozilla Public License 1.1 (MPL) - http://www.opensource.org/licenses/mozilla1.1.php 17 * }} 18 * 19 * {@internal Open Source relicensing agreement: 20 * }} 21 * 22 * @package htsrv 23 * 24 * {@internal Below is a list of authors who have contributed to design/coding of this file: }} 25 * @author fplanque: Francois PLANQUE 26 * 27 * @todo integrate it into the skins to avoid ugly die() on error and confusing redirect on success. 28 * 29 * @version $Id: subs_update.php,v 1.21 2007/04/26 00:11:14 fplanque Exp $ 30 */ 31 32 /** 33 * Initialize everything: 34 */ 35 require_once dirname(__FILE__).'/../conf/_config.php'; 36 37 require_once $inc_path.'_main.inc.php'; 38 39 // Getting GET or POST parameters: 40 param( 'checkuser_id', 'integer', true ); 41 param( 'newuser_email', 'string', true ); 42 param( 'newuser_notify', 'integer', 0 ); 43 param( 'subs_blog_IDs', 'string', true ); 44 45 /** 46 * Basic security checks: 47 */ 48 if( ! is_logged_in() ) 49 { // must be logged in! 50 bad_request_die( T_('You are not logged in.') ); 51 } 52 53 if( $checkuser_id != $current_User->ID ) 54 { // Can only edit your own profile 55 bad_request_die( 'You are not logged in under the same account you are trying to modify.' ); 56 } 57 58 if( $demo_mode && ($current_User->login == 'demouser') ) 59 { 60 bad_request_die( 'Demo mode: you can\'t edit the demouser profile!<br />[<a href="javascript:history.go(-1)">' 61 . T_('Back to profile') . '</a>]' ); 62 } 63 64 /** 65 * Additional checks: 66 */ 67 profile_check_params( array( 'email' => array($newuser_email, 'newuser_email') ) ); 68 69 70 if( $Messages->count( 'error' ) ) 71 { 72 // TODO: dh> display errors with the form itself 73 header( 'Content-type: text/html; charset='.$io_charset ); 74 $Messages->display( T_('Cannot update profile. Please correct the following errors:'), 75 '[<a href="javascript:history.go(-1)">' . T_('Back to profile') . '</a>]' ); 76 debug_info(); 77 exit; 78 } 79 80 81 // Do the profile update: 82 $current_User->set_email( $newuser_email ); 83 $current_User->set( 'notify', $newuser_notify ); 84 85 $current_User->dbupdate(); 86 87 88 // Work the blogs: 89 $subscription_values = array(); 90 $unsubscribed = array(); 91 $subs_blog_IDs = explode( ',', $subs_blog_IDs ); 92 foreach( $subs_blog_IDs as $loop_blog_ID ) 93 { 94 // Make sure no dirty hack is coming in here: 95 $loop_blog_ID = intval( $loop_blog_ID ); 96 97 // Get checkbox values: 98 $sub_items = param( 'sub_items_'.$loop_blog_ID, 'integer', 0 ); 99 $sub_comments = param( 'sub_comments_'.$loop_blog_ID, 'integer', 0 ); 100 101 if( $sub_items || $sub_comments ) 102 { // We have a subscription for this blog 103 $subscription_values[] = "( $loop_blog_ID, $current_User->ID, $sub_items, $sub_comments )"; 104 } 105 else 106 { // No subscription here: 107 $unsubscribed[] = $loop_blog_ID; 108 } 109 } 110 111 // Note: we do not check if subscriptions are allowed here, but we check at the time we're about to send something 112 if( count($subscription_values) ) 113 { // We need to record values: 114 $DB->query( 'REPLACE INTO T_subscriptions( sub_coll_ID, sub_user_ID, sub_items, sub_comments ) 115 VALUES '.implode( ', ', $subscription_values ) ); 116 } 117 118 if( count($unsubscribed) ) 119 { // We need to make sure some values are cleared: 120 $DB->query( 'DELETE FROM T_subscriptions 121 WHERE sub_user_ID = '.$current_User->ID.' 122 AND sub_coll_ID IN ('.implode( ', ', $unsubscribed ).')' ); 123 } 124 125 126 $Messages->add( T_('Your profile & subscriptions have been updated.'), 'success' ); 127 128 129 header_nocache(); 130 // redirect Will save $Messages into Session: 131 header_redirect(); 132 133 /* 134 * $Log: subs_update.php,v $ 135 * Revision 1.21 2007/04/26 00:11:14 fplanque 136 * (c) 2007 137 * 138 * Revision 1.20 2007/01/27 19:57:12 blueyed 139 * Use param_error() in profile_check_params() 140 * 141 * Revision 1.19 2007/01/27 19:53:17 blueyed 142 * Fixed charset when displaying errors 143 * 144 * Revision 1.18 2006/12/16 01:30:46 fplanque 145 * Setting to allow/disable email subscriptions on a per blog basis 146 * 147 * Revision 1.17 2006/12/16 00:38:48 fplanque 148 * Cleaned up subscription db handling 149 * 150 * Revision 1.16 2006/11/26 02:30:38 fplanque 151 * doc / todo 152 * 153 * Revision 1.15 2006/11/24 18:27:22 blueyed 154 * Fixed link to b2evo CVS browsing interface in file docblocks 155 * 156 * Revision 1.14 2006/11/24 18:06:02 blueyed 157 * Handle saving of $Messages centrally in header_redirect() 158 * 159 * Revision 1.13 2006/06/19 20:59:37 fplanque 160 * noone should die anonymously... 161 * 162 * Revision 1.12 2006/04/22 02:36:38 blueyed 163 * Validate users on registration through email link (+cleanup around it) 164 * 165 * Revision 1.11 2006/04/20 12:15:32 fplanque 166 * no message 167 * 168 * Revision 1.10 2006/04/19 23:50:39 blueyed 169 * Normalized Messages handling (error displaying and transport in Session) 170 * 171 * Revision 1.9 2006/04/19 20:13:48 fplanque 172 * do not restrict to :// (does not catch subdomains, not even www.) 173 * 174 * Revision 1.8 2006/04/11 21:22:25 fplanque 175 * partial cleanup 176 * 177 */ 178 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Thu Nov 29 23:58:50 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |