Changeset 12600 for extensions/Subscribe_to_comments
- Timestamp:
- Nov 11, 2011, 2:56:45 PM (12 years ago)
- Location:
- extensions/Subscribe_to_comments
- Files:
-
- 3 added
- 9 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
extensions/Subscribe_to_comments/include/functions.inc.php
r12561 r12600 9 9 { 10 10 global $conf, $page, $user; 11 12 if ( empty($comm) or !is_array($comm) ) 13 { 14 trigger_error('send_comment_to_subscribers: undefinided comm', E_USER_WARNING); 15 return false; 16 } 11 17 12 18 $type= isset($comm['category_id']) ? 'category' : 'image'; … … 32 38 if ($type == 'image') 33 39 { 34 // get image infos 35 $query = ' 36 SELECT 37 id, 38 name, 39 file 40 FROM '.IMAGES_TABLE.' 41 WHERE id = '.$comm['image_id'].' 42 ;'; 43 $element = pwg_db_fetch_assoc(pwg_query($query)); 44 45 if (empty($element['name'])) 46 { 47 $element['name'] = get_name_from_file($element['file']); 48 } 49 50 $url_params = array('image_id' => $element['id']); 51 if (!empty($page['category'])) 52 { 53 $url_params['section'] = 'categories'; 54 $url_params['category'] = $page['category']; 55 } 56 57 $element['url'] = make_picture_url($url_params); 40 $element = get_picture_infos($comm['image_id']); 58 41 } 59 42 else if ($type == 'category') 60 43 { 61 // get category infos 62 $query = ' 63 SELECT 64 id, 65 name, 66 permalink 67 FROM '.CATEGORIES_TABLE.' 68 WHERE id = '.$comm['category_id'].' 69 ;'; 70 $element = pwg_db_fetch_assoc(pwg_query($query)); 71 72 $url_params['section'] = 'categories'; 73 $url_params['category'] = $element; 74 75 $element['url'] = make_index_url($url_params); 44 $element = get_category_infos($comm['category_id']); 76 45 } 77 46 … … 101 70 { 102 71 $mail_args['content'] = $generic_content.' 103 <a href="'.make_stc_url('unsubscribe-'.$type, $email, $element['id']).'">Stop receiving notifications for this picture</a><br> 104 <a href="'.make_stc_url('unsubscribe-all', $email).'">Stop receiving all notifications</a><br> 105 '; 106 //<a href="'.make_stc_url('manage', $email).'">Manage my subscribtions</a> 72 <a href="'.make_stc_url('unsubscribe-'.$type, $email, $element['id']).'">Stop receiving notifications</a><br> 73 <a href="'.make_stc_url('manage', $email).'">Manage my subscribtions</a>'; 107 74 pwg_mail($email, $mail_args); 108 75 } … … 120 87 function subscribe_to_comments($element_id, $email, $type='image') 121 88 { 122 global $page, $user, $conf, $template, $picture; 123 124 $infos = $errors = array(); 89 global $page, $conf, $user, $template, $picture; 90 91 if ( empty($element_id) or empty($type) ) 92 { 93 trigger_error('subscribe_to_comment: missing element_id and/or type', E_USER_WARNING); 94 return false; 95 } 96 97 // check email 125 98 if ( is_a_guest() and empty($email) ) 126 99 { 127 array_push($errors, l10n('Invalid email adress, your are not subscribed to comments.')); 128 129 $orig = $template->get_template_vars('errors'); 130 if (empty($orig)) $orig = array(); 131 $template->assign('errors', array_merge($orig, $errors)); 132 133 if ($type == 'category') $template->set_prefilter('index', 'coa_messages'); // here we use a prefilter existing in COA 134 135 return; 100 return false; 136 101 } 137 102 else if (!is_a_guest()) … … 142 107 // don't care if already registered 143 108 $query = ' 144 INSERT I GNORE INTO '.SUBSCRIBE_TO_TABLE.'(109 INSERT INTO '.SUBSCRIBE_TO_TABLE.'( 145 110 email, 146 111 '.$type.'_id, … … 154 119 "'.(is_a_guest() ? "false" : "true").'" 155 120 ) 121 ON DUPLICATE KEY UPDATE 122 registration_date = IF(validated="true", registration_date, NOW()), 123 validated = IF(validated="true", validated, "'.(is_a_guest() ? "false" : "true").'") 156 124 ;'; 157 125 pwg_query($query); 158 126 159 127 // send validation mail 160 if ( is_a_guest() and pwg_db_insert_id() != 0)128 if ( is_a_guest() and pwg_db_changes(null) != 0 ) 161 129 { 162 130 $element_name = ($type == 'image') ? $picture['current']['name'] : $page['category']['name']; … … 178 146 179 147 pwg_mail($email, $mail_args); 180 array_push($infos, l10n('Please check your email inbox to confirm your subscription.')); 181 } 182 // just displat confirmation message 183 else if (pwg_db_insert_id() != 0) 184 { 185 array_push($infos, l10n('You have been added to the list of subscribers for this '.($type=='image' ? 'picture' : 'album').'.')); 186 } 187 188 189 if (!empty($infos)) 190 { 191 $orig = $template->get_template_vars('infos'); 192 if (empty($orig)) $orig = array(); 193 $template->assign('infos', array_merge($orig, $infos)); 194 195 if ($type == 'category') $template->set_prefilter('index', 'coa_messages'); 196 } 197 } 198 148 return 'confirm_mail'; 149 } 150 // just display confirmation message 151 else if (pwg_db_changes(null) != 0) 152 { 153 return true; 154 } 155 } 156 157 /* 158 * remove an email from subscribers list 159 * @param int (image|category)_id 160 * @param string email 161 * @param string type (image|category) 162 */ 163 function un_subscribe_to_comments($element_id, $email, $type='image') 164 { 165 global $template, $user; 166 167 if ( empty($element_id) or empty($type) ) 168 { 169 trigger_error('un_subscribe_to_comment: missing element_id and/or type', E_USER_WARNING); 170 return false; 171 } 172 173 // check email 174 if ( is_a_guest() and empty($email) ) 175 { 176 return false; 177 } 178 else if (!is_a_guest()) 179 { 180 $email = $user['email']; 181 } 182 183 // delete subscription 184 switch ($type) 185 { 186 case 'image' : 187 case 'category' : 188 $where_clause = $type.'_id = '.pwg_db_real_escape_string($element_id); 189 case 'all' : 190 { 191 $query = ' 192 DELETE FROM '.SUBSCRIBE_TO_TABLE.' 193 WHERE 194 email = "'.pwg_db_real_escape_string($email).'" 195 '.(!empty($where_clause) ? 'AND '.$where_clause : null).' 196 ;'; 197 pwg_query($query); 198 199 return true; 200 break; 201 } 202 } 203 204 return false; 205 } 206 207 /* 208 * validate a subscription 209 * @param int (image|category)_id 210 * @param string email 211 * @param string type (image|category) 212 */ 213 function validate_subscriptions($element_id, $email, $type='image') 214 { 215 if ( empty($element_id) or empty($email) or empty($type) ) 216 { 217 trigger_error('validate_subscriptions: missing element_id and/or email and/or type', E_USER_WARNING); 218 return false; 219 } 220 221 switch ($type) 222 { 223 case 'image' : 224 case 'category': 225 $where_clause = $type.'_id = '.pwg_db_real_escape_string($element_id); 226 case 'all' : 227 { 228 $query = ' 229 UPDATE '.SUBSCRIBE_TO_TABLE.' 230 SET validated = "true" 231 WHERE 232 email = "'.pwg_db_real_escape_string($email).'" 233 '.(!empty($where_clause) ? 'AND '.$where_clause : null).' 234 ;'; 235 pwg_query($query); 236 237 if (pwg_db_changes(null) != 0) return true; 238 break; 239 } 240 } 241 242 return false; 243 } 199 244 200 245 /** … … 208 253 if ( empty($action) or empty($email) ) 209 254 { 210 trigger_error('make_stc_url missing action and/or mail', E_USER_WARNING);255 trigger_error('make_stc_url: missing action and/or mail', E_USER_WARNING); 211 256 return null; 212 257 } … … 218 263 'action' => $action, 219 264 'email' => $email, 220 'key' => crypt_value($action.$email, $conf['secret_key']),221 265 ); 222 266 223 267 if (func_num_args() > 2) 224 268 { 225 $url_params['param'] = func_get_arg(2); 226 } 269 $url_params['id'] = func_get_arg(2); 270 } 271 272 $url_params['key'] = crypt_value( 273 $action.$email.(isset($url_params['id'])?$url_params['id']:null), 274 $conf['secret_key'] 275 ); 227 276 228 277 $url = add_url_params( … … 235 284 } 236 285 286 /** 287 * get name and url of a picture 288 * @param int image_id 289 * @return array 290 */ 291 function get_picture_infos($image_id, $absolute=false) 292 { 293 global $page; 294 295 $query = ' 296 SELECT 297 id, 298 name, 299 file 300 FROM '.IMAGES_TABLE.' 301 WHERE id = '.$image_id.' 302 ;'; 303 $element = pwg_db_fetch_assoc(pwg_query($query)); 304 305 if (empty($element['name'])) 306 { 307 $element['name'] = get_name_from_file($element['file']); 308 } 309 310 $url_params = array('image_id' => $element['id']); 311 if ( !empty($page['category']) and !$absolute ) 312 { 313 $url_params['section'] = 'categories'; 314 $url_params['category'] = $page['category']; 315 } 316 $element['url'] = make_picture_url($url_params); 317 318 return $element; 319 } 320 321 /** 322 * get name and url of a category 323 * @param int cat_id 324 * @return array 325 */ 326 function get_category_infos($cat_id) 327 { 328 $query = ' 329 SELECT 330 id, 331 name, 332 permalink 333 FROM '.CATEGORIES_TABLE.' 334 WHERE id = '.$cat_id.' 335 ;'; 336 $element = pwg_db_fetch_assoc(pwg_query($query)); 337 338 $url_params['section'] = 'categories'; 339 $url_params['category'] = $element; 340 $element['url'] = make_index_url($url_params); 341 342 return $element; 343 } 237 344 238 345 /** -
extensions/Subscribe_to_comments/include/subscribe_to_comments.inc.php
r12561 r12600 29 29 function stc_comment_insertion($comm) 30 30 { 31 global $page; 31 global $page, $template; 32 33 $infos = $errors = array(); 32 34 33 35 if ($comm['action'] == 'validate') … … 40 42 if (isset($comm['image_id'])) 41 43 { 42 subscribe_to_comments($comm['image_id'], @$_POST['stc_mail'], 'image');44 $return = subscribe_to_comments($comm['image_id'], @$_POST['stc_mail'], 'image'); 43 45 } 44 46 else if (isset($comm['category_id'])) 45 47 { 46 subscribe_to_comments($comm['category_id'], @$_POST['stc_mail'], 'category'); 47 } 48 } 49 } 50 51 function stc_comment_validation($comm_id, $type='image') 52 { 53 switch ($type) 54 { 55 case 'image': 48 $return = subscribe_to_comments($comm['category_id'], @$_POST['stc_mail'], 'category'); 49 50 } 51 52 if (isset($return)) 53 { 54 if ($return === 'confirm_mail') 55 { 56 array_push($infos, l10n('Please check your email inbox to confirm your subscription.')); 57 } 58 else if ($return === true) 59 { 60 array_push($infos, l10n('You have been added to the list of subscribers for this '.(isset($comm['image_id'])?'picture':'album').'.')); 61 } 62 else 63 { 64 array_push($errors, l10n('Invalid email adress, your are not subscribed to comments.')); 65 } 66 67 // messages management 68 if (!empty($errors)) 69 { 70 $errors_bak = $template->get_template_vars('errors'); 71 if (empty($errors_bak)) $errors_bak = array(); 72 $template->assign('errors', array_merge($errors_bak, $errors)); 73 $template->set_prefilter('index', 'coa_messages'); // here we use a prefilter existing in COA 74 } 75 if (!empty($infos)) 76 { 77 $infos_bak = $template->get_template_vars('infos'); 78 if (empty($infos_bak)) $infos_bak = array(); 79 $template->assign('infos', array_merge($infos_bak, $infos)); 80 $template->set_prefilter('index', 'coa_messages'); 81 } 82 } 83 } 84 } 85 86 function stc_comment_validation($comm_ids, $type='image') 87 { 88 if (!is_array($comm_ids)) $comm_ids = array($comm_ids); 89 90 foreach($comm_ids as $comm_id) 91 { 92 if ($type == 'image') 56 93 { 57 94 $query = ' … … 64 101 WHERE id = '.$comm_id.' 65 102 ;'; 66 break; 67 } 68 69 case 'category': 103 } 104 else if ($type == 'category') 70 105 { 71 106 $query = ' … … 78 113 WHERE id = '.$comm_id.' 79 114 ;'; 80 break; 81 } 82 } 83 84 $comm = pwg_db_fetch_assoc(pwg_query($query)); 85 send_comment_to_subscribers($comm); 115 } 116 117 $comm = pwg_db_fetch_assoc(pwg_query($query)); 118 send_comment_to_subscribers($comm); 119 } 86 120 } 87 121 … … 92 126 function stc_on_picture() 93 127 { 94 global $template, $picture; 128 global $template, $picture, $page; 129 130 $infos = $array = array(); 95 131 96 132 if (isset($_POST['stc_check_stdl'])) 97 133 { 98 subscribe_to_comments($picture['current']['id'], @$_POST['stc_mail_stdl'], 'image'); 134 $return = subscribe_to_comments($picture['current']['id'], @$_POST['stc_mail_stdl'], 'image'); 135 if ($return === 'confirm_mail') 136 { 137 array_push($infos, l10n('Please check your email inbox to confirm your subscription.')); 138 } 139 else if ($return === true) 140 { 141 array_push($infos, l10n('You have been added to the list of subscribers for this picture.')); 142 } 143 else 144 { 145 array_push($errors, l10n('Invalid email adress, your are not subscribed to comments.')); 146 } 147 } 148 else if (isset($_GET['stc_unsubscribe'])) 149 { 150 if (un_subscribe_to_comments($picture['current']['id'], null, 'image')) 151 { 152 array_push($infos, l10n('Successfully unsubscribed your email address from receiving notifications.')); 153 } 154 } 155 156 // messages management 157 if (!empty($errors)) 158 { 159 $errors_bak = $template->get_template_vars('errors'); 160 if (empty($errors_bak)) $errors_bak = array(); 161 $template->assign('errors', array_merge($errors_bak, $errors)); 162 } 163 if (!empty($infos)) 164 { 165 $infos_bak = $template->get_template_vars('infos'); 166 if (empty($infos_bak)) $infos_bak = array(); 167 $template->assign('infos', array_merge($infos_bak, $infos)); 99 168 } 100 169 … … 104 173 function stc_on_picture_prefilter($template, &$smarty) 105 174 { 106 global $user, $picture; 107 108 ## subscribe while add a comment ## 109 $search[0] = '<input type="submit" value="{\'Submit\'|@translate}">'; 110 111 $replace[0] = ' 112 <label>{\'Subscribe to new comments\'|@translate} <input type="checkbox" name="stc_check" value="1"></label>'; 113 if (is_a_guest()) 114 { 115 $replace[0].= ' 116 <label id="stc_mail" style="display:none;">{\'Email address\'|@translate} <input type="text" name="stc_mail"></label> 117 {footer_script require="jquery"}{literal} 118 jQuery(document).ready(function() { 119 $("input[name=stc_check]").change(function() { 120 if ($(this).is(":checked")) $("#stc_mail").css("display", ""); 121 else $("#stc_mail").css("display", "none"); 122 }); 123 }); 124 {/literal}{/footer_script}'; 125 } 126 $replace[0].= $search[0]; 127 175 global $user, $picture; 128 176 129 177 ## subscribe at any moment ## … … 143 191 email = "'.$user['email'].'" 144 192 AND image_id = '.$picture['current']['id'].' 193 AND validated = "true" 145 194 ;'; 146 195 if (pwg_db_num_rows(pwg_query($query))) … … 148 197 $replace[1].= ' 149 198 {\'You are currently subscribed to comments of this picture.\'|@translate} 150 <a href="'. make_stc_url('unsubscribe-image', $user['email'], $picture['current']['id']).'">{\'Unsubscribe\'|@translate}';199 <a href="'.add_url_params($picture['current']['url'], array('stc_unsubscribe'=>'1')).'">{\'Unsubscribe\'|@translate}'; 151 200 $no_form = true; 152 201 } … … 194 243 </form>'; 195 244 196 return str_replace($search, $replace, $template); 197 } 198 199 200 /** 201 * add field and on album page 202 */ 203 function stc_on_album() 204 { 205 global $page, $template, $pwg_loaded_plugins; 206 207 if ( 208 script_basename() != 'index' or !isset($page['section']) or 209 !isset($pwg_loaded_plugins['Comments_on_Albums']) or 210 $page['section'] != 'categories' or !isset($page['category']) 211 ) 212 { 213 return; 214 } 215 216 if (isset($_POST['stc_check_stdl'])) 217 { 218 subscribe_to_comments($page['category']['id'], @$_POST['stc_mail_stdl'], 'category'); 219 } 220 221 $template->set_prefilter('comments_on_albums', 'stc_on_album_prefilter'); 222 } 223 224 function stc_on_album_prefilter($template, &$smarty) 225 { 226 global $user, $page; 227 245 228 246 ## subscribe while add a comment ## 229 247 $search[0] = '<input type="submit" value="{\'Submit\'|@translate}">'; 230 231 $replace[0] = ' 248 $replace[0] = null; 249 250 if (!isset($no_form)) 251 { 252 $replace[0].= ' 232 253 <label>{\'Subscribe to new comments\'|@translate} <input type="checkbox" name="stc_check" value="1"></label>'; 254 } 233 255 if (is_a_guest()) 234 256 { … … 246 268 $replace[0].= $search[0]; 247 269 270 return str_replace($search, $replace, $template); 271 } 272 273 274 /** 275 * add field and on album page 276 */ 277 function stc_on_album() 278 { 279 global $page, $template, $pwg_loaded_plugins; 280 281 $infos = $errors = array(); 282 283 if ( 284 script_basename() != 'index' or !isset($page['section']) or 285 !isset($pwg_loaded_plugins['Comments_on_Albums']) or 286 $page['section'] != 'categories' or !isset($page['category']) 287 ) 288 { 289 return; 290 } 291 292 if (isset($_POST['stc_check_stdl'])) 293 { 294 $return = subscribe_to_comments($page['category']['id'], @$_POST['stc_mail_stdl'], 'category'); 295 if ($return === 'confirm_mail') 296 { 297 array_push($infos, l10n('Please check your email inbox to confirm your subscription.')); 298 } 299 else if ($return === true) 300 { 301 array_push($infos, l10n('You have been added to the list of subscribers for this album.')); 302 } 303 else 304 { 305 array_push($errors, l10n('Invalid email adress, your are not subscribed to comments.')); 306 } 307 } 308 else if (isset($_GET['stc_unsubscribe'])) 309 { 310 if (un_subscribe_to_comments($page['category']['id'], null, 'category')) 311 { 312 array_push($infos, l10n('Successfully unsubscribed your email address from receiving notifications.')); 313 } 314 } 315 316 // messages management 317 if (!empty($errors)) 318 { 319 $errors_bak = $template->get_template_vars('errors'); 320 if (empty($errors_bak)) $errors_bak = array(); 321 $template->assign('errors', array_merge($errors_bak, $errors)); 322 $template->set_prefilter('index', 'coa_messages'); // here we use a prefilter existing in COA 323 } 324 if (!empty($infos)) 325 { 326 $infos_bak = $template->get_template_vars('infos'); 327 if (empty($infos_bak)) $infos_bak = array(); 328 $template->assign('infos', array_merge($infos_bak, $infos)); 329 $template->set_prefilter('index', 'coa_messages'); 330 } 331 332 $template->set_prefilter('comments_on_albums', 'stc_on_album_prefilter'); 333 } 334 335 function stc_on_album_prefilter($template, &$smarty) 336 { 337 global $user, $page; 248 338 249 339 ## subscribe at any moment ## … … 263 353 email = "'.$user['email'].'" 264 354 AND category_id = '.$page['category']['id'].' 355 AND validated = "true" 265 356 ;'; 266 357 if (pwg_db_num_rows(pwg_query($query))) 267 358 { 359 $url_params['section'] = 'categories'; 360 $url_params['category'] = $page['category']; 361 362 $element_url = make_index_url($url_params); 363 268 364 $replace[1].= ' 269 365 {\'You are currently subscribed to comments of this album.\'|@translate} 270 <a href="'. make_stc_url('unsubscribe-category', $user['email'], $page['category']['id']).'">{\'Unsubscribe\'|@translate}';366 <a href="'.add_url_params($element_url, array('stc_unsubscribe'=>'1')).'">{\'Unsubscribe\'|@translate}'; 271 367 $no_form = true; 272 368 } … … 314 410 </form>'; 315 411 412 413 ## subscribe while add a comment ## 414 $search[0] = '<input type="submit" value="{\'Submit\'|@translate}">'; 415 $replace[0] = null; 416 417 if (!isset($no_form)) 418 { 419 $replace[0].= ' 420 <label>{\'Subscribe to new comments\'|@translate} <input type="checkbox" name="stc_check" value="1"></label>'; 421 } 422 if (is_a_guest()) 423 { 424 $replace[0].= ' 425 <label id="stc_mail" style="display:none;">{\'Email address\'|@translate} <input type="text" name="stc_mail"></label> 426 {footer_script require="jquery"}{literal} 427 jQuery(document).ready(function() { 428 $("input[name=stc_check]").change(function() { 429 if ($(this).is(":checked")) $("#stc_mail").css("display", ""); 430 else $("#stc_mail").css("display", "none"); 431 }); 432 }); 433 {/literal}{/footer_script}'; 434 } 435 $replace[0].= $search[0]; 436 316 437 return str_replace($search, $replace, $template); 317 438 } 318 439 440 441 /** 442 * add link to management page for registered users 443 */ 444 function stc_menubar_apply($menu_ref_arr) 445 { 446 global $template; 447 $menu = &$menu_ref_arr[0]; 448 449 if ( !is_a_guest() and ($block = $menu->get_block('mbIdentification')) != null ) 450 { 451 $template->set_prefilter('menubar', 'stc_menubar_apply_prefilter'); 452 } 453 } 454 455 function stc_menubar_apply_prefilter($content, &$smarty) 456 { 457 global $user; 458 459 $search = '{if isset($U_REGISTER)}'; 460 $replace = '<li><a href="'.make_stc_url('manage', $user['email']).'" title="{\'Manage my subscriptions\'|@translate}" rel="nofollow">{\'Manage my subscriptions\'|@translate}</a></li>'; 461 return str_replace($search, $replace.$search, $content); 462 } 319 463 ?> -
extensions/Subscribe_to_comments/include/subscribtions_page.inc.php
r12560 r12600 7 7 8 8 // check input parameters 9 $_GET['verif_key'] = $_GET['action'].$_GET['email'].(isset($_GET['id'])?$_GET['id']:null); 9 10 if ( 10 11 empty($_GET['action']) or empty($_GET['email']) or empty($_GET['key']) 11 or decrypt_value($_GET['key'], $conf['secret_key']) !== $_GET[' action'].$_GET['email']12 or decrypt_value($_GET['key'], $conf['secret_key']) !== $_GET['verif_key'] 12 13 ) 13 14 { 14 set_status_header(403); 15 array_push($errors, l10n('Bad query')); 15 $_GET['action'] = 'hacker'; 16 } 17 else 18 { 19 // sanitize inputs 20 if (isset($_GET['id'])) $_GET['id'] = pwg_db_real_escape_string($_GET['id']); 21 $_GET['email'] = pwg_db_real_escape_string($_GET['email']); 22 23 // unsubscribe 24 if (isset($_POST['unsubscribe'])) 25 { 26 if (un_subscribe_to_comments(!empty($_GET['id'])?$_GET['id']:'N/A', $_GET['email'], $_POST['unsubscribe'])) 27 { 28 array_push($infos, l10n('Successfully unsubscribed your email address from receiving notifications.')); 29 } 30 else 31 { 32 array_push($errors, l10n('Invalid email adress.')); 33 } 34 35 $_GET['action'] = 'manage'; 36 } 37 if (isset($_GET['unsubscribe'])) 38 { 39 $query = ' 40 DELETE FROM '.SUBSCRIBE_TO_TABLE.' 41 WHERE 42 id = '.pwg_db_real_escape_string($_GET['unsubscribe']).' 43 AND email = "'.$_GET['email'].'" 44 ;'; 45 pwg_query($query); 46 47 if (pwg_db_changes(null) != 0) 48 { 49 array_push($infos, l10n('Successfully unsubscribed your email address from receiving notifications.')); 50 } 51 else 52 { 53 array_push($errors, l10n('Invalid email adress.')); 54 } 55 } 56 57 $template->assign('MANAGE_LINK', make_stc_url('manage', $_GET['email'])); 16 58 } 17 59 18 60 switch ($_GET['action']) 19 61 { 20 /* unsubscribe */ 21 case 'unsubscribe-image' : 22 if (empty($where_clause)) $where_clause = 'image_id = '.pwg_db_real_escape_string($_GET['param']); 23 case 'unsubscribe-category': 24 if (empty($where_clause)) $where_clause = 'category_id = '.pwg_db_real_escape_string($_GET['param']); 25 case 'unsubcribe-all' : 62 /* validate */ 63 case 'validate-image' : 26 64 { 27 $query = ' 28 DELETE FROM '.SUBSCRIBE_TO_TABLE.' 29 WHERE 30 email = "'.pwg_db_real_escape_string($_GET['email']).'" 31 '.(!empty($where_clause) ? 'AND '.$where_clause : null).' 32 ;'; 33 pwg_query($query); 65 if (validate_subscriptions($_GET['id'], $_GET['email'], 'image')) 66 { 67 array_push($infos, l10n('Your subscribtion has been validated, thanks you.')); 68 } 69 else 70 { 71 array_push($errors, l10n('Nothing to validate.')); 72 } 34 73 35 array_push($infos, l10n('You have been successfully unsubscribed, good bye.')); 74 $element = get_picture_infos($_GET['id']); 75 76 $template->assign(array( 77 'validate' => 'image', 78 'element' => $element, 79 )); 80 81 break; 82 } 83 case 'validate-category': 84 { 85 if (validate_subscriptions($_GET['id'], $_GET['email'], 'category')) 86 { 87 array_push($infos, l10n('Your subscribtion has been validated, thanks you.')); 88 } 89 else 90 { 91 array_push($errors, l10n('Nothing to validate.')); 92 } 93 94 $element = get_category_infos($_GET['id']); 95 96 $template->assign(array( 97 'validate' => 'category', 98 'element' => $element, 99 )); 36 100 break; 37 101 } 38 102 39 /* validate */ 40 case 'validate-image' : 41 if (empty($where_clause)) $where_clause = 'image_id = '.pwg_db_real_escape_string($_GET['param']); 42 case 'validate-category': 43 if (empty($where_clause)) $where_clause = 'category_id = '.pwg_db_real_escape_string($_GET['param']); 44 case 'validate-all' : 45 { 46 $query = ' 47 UPDATE '.SUBSCRIBE_TO_TABLE.' 48 SET validated = "true" 49 WHERE 50 email = "'.pwg_db_real_escape_string($_GET['email']).'" 51 '.(!empty($where_clause) ? 'AND '.$where_clause : null).' 52 ;'; 53 pwg_query($query); 103 /* unsubscribe */ 104 case 'unsubscribe-image' : 105 { 106 $element = get_picture_infos($_GET['id']); 54 107 55 array_push($infos, l10n('Your subscribtion has been validated, thanks you.')); 108 $template->assign(array( 109 'unsubscribe_form' => 'image', 110 'element' => $element, 111 )); 112 113 break; 114 } 115 case 'unsubscribe-category': 116 { 117 $element = get_category_infos($_GET['id']); 118 119 $template->assign(array( 120 'unsubscribe_form' => 'category', 121 'element' => $element, 122 )); 123 56 124 break; 57 125 } … … 60 128 case 'manage' : 61 129 { 130 $query = ' 131 SELECT * 132 FROM '.SUBSCRIBE_TO_TABLE.' 133 WHERE 134 email = "'.$_GET['email'].'" 135 AND validated = "true" 136 ORDER BY registration_date DESC 137 ;'; 138 $result = pwg_query($query); 139 140 if (pwg_db_num_rows($result) !== 0) 141 { 142 while ($subscription = pwg_db_fetch_assoc($result)) 143 { 144 if (!empty($subscription['image_id'])) 145 { 146 $subscription['infos'] = get_picture_infos($subscription['image_id']); 147 $subscription['type'] = 'image'; 148 } 149 else if (!empty($subscription['category_id'])) 150 { 151 $subscription['infos'] = get_category_infos($subscription['category_id']); 152 $subscription['type'] = 'category'; 153 } 154 $subscription['registration_date'] = format_date($subscription['registration_date'], true); 155 $template->append('subscriptions', $subscription); 156 } 157 } 158 else 159 { 160 $template->assign('subscriptions', 'none'); 161 } 62 162 break; 63 163 } 64 164 65 default:165 case 'hacker' : 66 166 { 67 167 set_status_header(403); … … 69 169 } 70 170 } 171 172 $template->assign(array( 173 'EMAIL' => $_GET['email'], 174 'SUBSCRIBE_TO_PATH' => SUBSCRIBE_TO_PATH, 175 )); 71 176 72 177 $template->assign(array( -
extensions/Subscribe_to_comments/language/en_UK/description.txt
r12560 r12600 1 This plugin allows you to subscribe to comments by mail.1 This plugin allows you to subscribe to comments by email. -
extensions/Subscribe_to_comments/language/en_UK/plugin.lang.php
r12561 r12600 1 1 <?php 2 2 3 $lang['Subscribe to new comments'] = 'Subscribe to new comments'; 3 $lang['Please check your email inbox to confirm your subscription.'] = 'Please check your email inbox to confirm your subscription.'; 4 $lang['You have been added to the list of subscribers for this album.'] = 'You have been added to the list of subscribers for this album.'; 5 $lang['You have been added to the list of subscribers for this picture.'] = 'You have been added to the list of subscribers for this picture.'; 4 6 $lang['Invalid email adress, your are not subscribed to comments.'] = 'Invalid email adress, your are not subscribed to comments.'; 5 $lang['Please check your email inbox to confirm your subscription.'] = 'Please check your email inbox to confirm your subscription.'; 6 $lang['You have been successfully unsubscribed, good bye.'] = 'You have been successfully unsubscribed, good bye.'; 7 $lang['Your subscribtion has been validated, thanks you.'] = 'Your subscribtion has been validated, thanks you.'; 8 $lang['You have been added to the list of subscribers for this picture.'] = 'You have been added to the list of subscribers for this picture.'; 9 $lang['You have been added to the list of subscribers for this album.'] = 'You have been added to the list of subscribers for this album.'; 7 $lang['Successfully unsubscribed your email address from receiving notifications.'] = 'Successfully unsubscribed your email address from receiving notifications.'; 10 8 $lang['You are currently subscribed to comments of this picture.'] = 'You are currently subscribed to comments of this picture.'; 11 9 $lang['You are currently subscribed to comments of this album.'] = 'You are currently subscribed to comments of this album.'; 12 10 $lang['Unsubscribe'] = 'Unsubscribe'; 11 $lang['Subscribe to new comments'] = 'Subscribe to new comments'; 12 $lang['Invalid email adress.'] = 'Invalid email adress.'; 13 $lang['Your subscribtion has been validated, thanks you.'] = 'Your subscribtion has been validated, thanks you.'; 14 $lang['Nothing to validate.'] = 'Nothing to validate.'; 15 $lang['Subscriptions of'] = 'Subscriptions of'; 16 $lang['Unsubscribe from email notification'] = 'Unsubscribe from email notification'; 17 $lang['Only unsubscribe notifications for comments from:'] = 'Only unsubscribe notifications for comments from:'; 18 $lang['Unsubscribe from all email notifications'] = 'Unsubscribe from all email notifications'; 19 $lang['Manage my subscriptions'] = 'Manage my subscriptions'; 20 $lang['Item'] = 'Item'; 21 $lang['Date'] = 'Date'; 22 $lang['You are not subscribed to any comment.'] = 'You are not subscribed to any comment.'; 13 23 14 24 ?> -
extensions/Subscribe_to_comments/language/fr_FR/description.txt
r12560 r12600 1 Ce plugin permet aux visiteurs de recevoir par mail les nouveaux commentaires sur une image.1 Ce plugin permet aux visiteurs de recevoir par email les nouveaux commentaires sur une image. -
extensions/Subscribe_to_comments/language/fr_FR/plugin.lang.php
r12561 r12600 1 1 <?php 2 2 3 $lang['Subscribe to new comments'] = 'S\'inscrire aux nouveaux commentaires'; 4 $lang['Invalid email adress, your are not subscribed to comments.'] = 'Email invalide, vous n\'avez pas été inscrit.'; 5 $lang['Please check your email inbox to confirm your subscription.'] = 'Veuillez consulter votre boite mail pour confirmer votre inscription.'; 6 $lang['You have been successfully unsubscribed, good bye.'] = 'Vous avez été supprimé de la liste de notification, au revoir.'; 7 $lang['Your subscribtion has been validated, thanks you.'] = 'Votre inscription a bien été validée, merci.'; 8 $lang['You have been added to the list of subscribers for this picture.'] = 'Vous avez été ajouté à la liste des inscrits pour les commentaires de cette photo.'; 9 $lang['You have been added to the list of subscribers for this album.'] = 'Vous avez été ajouté à la liste des inscrits pour les commentaires de cet album.'; 3 $lang['Please check your email inbox to confirm your subscription.'] = 'Veillez consulter votre boite mail pour confirmer votre inscription.'; 4 $lang['You have been added to the list of subscribers for this album.'] = 'Vous avez été ajouté à la liste des abonnés pour cet album.'; 5 $lang['You have been added to the list of subscribers for this picture.'] = 'Vous avez été ajouté à la liste des abonnés pour cette photo.'; 6 $lang['Invalid email adress, your are not subscribed to comments.'] = 'Addresse email invalide, vous n\'avez pas été inscrit.'; 7 $lang['Successfully unsubscribed your email address from receiving notifications.'] = 'Inscription aux commentaires annulée avec succès.'; 10 8 $lang['You are currently subscribed to comments of this picture.'] = 'Vous êtes actuellement inscrit aux commentaires de cette photo.'; 11 9 $lang['You are currently subscribed to comments of this album.'] = 'Vous êtes actuellement inscrit aux commentaires de cet album.'; 12 10 $lang['Unsubscribe'] = 'Se désinscrire'; 11 $lang['Subscribe to new comments'] = 'S\'inscrire aux nouveaux commentaires'; 12 $lang['Invalid email adress.'] = 'Adress email invalide.'; 13 $lang['Your subscribtion has been validated, thanks you.'] = 'Votre inscription a été validée, merci.'; 14 $lang['Nothing to validate.'] = 'Rien à valider.'; 15 $lang['Subscriptions of'] = 'Subscriptions of'; 16 $lang['Unsubscribe from email notification'] = 'Se désinscrire de la notification par mail'; 17 $lang['Only unsubscribe notifications for comments from:'] = 'Uniquement se désinscrire de :'; 18 $lang['Unsubscribe from all email notifications'] = 'Ne plus recevoir aucune notification'; 19 $lang['Manage my subscriptions'] = 'Gérer mes abonnements'; 20 $lang['Item'] = 'Objet'; 21 $lang['Date'] = 'Date'; 22 $lang['You are not subscribed to any comment.'] = 'Vous n\'êtes inscrit à aucun commentaire.'; 13 23 14 24 ?> -
extensions/Subscribe_to_comments/main.inc.php
r12561 r12600 3 3 Plugin Name: Subscribe To Comments 4 4 Version: auto 5 Description: This plugin allows you to subscribe to comments by mail.5 Description: This plugin allows you to subscribe to comments by email. 6 6 Plugin URI: http://piwigo.org/ext/extension_view.php?eid=587 7 7 Author: Mistic … … 17 17 define('SUBSCRIBE_TO_TABLE', $prefixeTable . 'subscribe_to_comments'); 18 18 19 include_once(SUBSCRIBE_TO_PATH.'subscribe_to_comments.inc.php');20 19 include_once(SUBSCRIBE_TO_PATH.'include/functions.inc.php'); 20 include_once(SUBSCRIBE_TO_PATH.'include/subscribe_to_comments.inc.php'); 21 21 22 22 load_language('plugin.lang', SUBSCRIBE_TO_PATH); … … 34 34 add_event_handler('loc_end_index', 'stc_load_section'); 35 35 36 // menu link 37 add_event_handler('blockmanager_apply', 'stc_menubar_apply'); 38 36 39 ?> -
extensions/Subscribe_to_comments/maintain.inc.php
r12560 r12600 9 9 pwg_query(' 10 10 CREATE TABLE IF NOT EXISTS `' . $prefixeTable . 'subscribe_to_comments` ( 11 `email` varchar(255) NOT NULL, 12 `image_id` mediumint(8) NOT NULL DEFAULT 0, 13 `category_id` smallint(5) NOT NULL DEFAULT 0, 14 `registration_date` datetime NOT NULL, 15 `validated` enum("true", "false") NOT NULL DEFAULT "false", 16 UNIQUE KEY `UNIQUE` (`mail`, `image_id`, `category_id`) 11 `id` INT( 11 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY , 12 `email` VARCHAR( 255 ) NOT NULL , 13 `image_id` MEDIUMINT( 8 ) UNSIGNED NOT NULL DEFAULT "0", 14 `category_id` SMALLINT( 5 ) UNSIGNED NOT NULL DEFAULT "0", 15 `registration_date` DATETIME NOT NULL, 16 `validated` ENUM( "true", "false" ) NOT NULL DEFAULT "false", 17 UNIQUE KEY `UNIQUE` (`email`, `image_id`, `category_id`) 17 18 ) DEFAULT CHARSET=utf8 18 19 ;'); … … 35 36 36 37 /* delete table and config */ 37 //pwg_query('DROP TABLE `' . $prefixeTable . 'subscribe_to_comments`;');38 pwg_query('DELETE FROM `' . CONFIG_TABLE . '` WHERE param = "Subscribe_to_Comments";');38 pwg_query('DROP TABLE `' . $prefixeTable . 'subscribe_to_comments`;'); 39 // pwg_query('DELETE FROM `' . CONFIG_TABLE . '` WHERE param = "Subscribe_to_Comments";'); 39 40 } 40 41 ?> -
extensions/Subscribe_to_comments/template/subscribtions_page.tpl
r12560 r12600 1 {combine_css path=$SUBSCRIBE_TO_PATH|@cat:'template/style.css'} 2 1 3 {$MENUBAR} 2 4 … … 6 8 <div class="titrePage"> 7 9 <ul class="categoryActions"> 8 {if isset($U_EDIT)}9 <li><a href="{$U_EDIT}" title="{'edit'|@translate}" class="pwg-state-default pwg-button">10 <span class="pwg-icon pwg-icon-category-edit"> </span><span class="pwg-button-text">{'edit'|@translate}</span>11 </a></li>12 {/if}13 10 {if !empty($PLUGIN_INDEX_ACTIONS)}{$PLUGIN_INDEX_ACTIONS}{/if} 14 11 </ul> 15 <h2> Subscriptions</h2>12 <h2>{'Subscriptions of'|@translate} <i>{$EMAIL}</i></h2> 16 13 </div> <!-- titrePage --> 17 14 … … 34 31 </div> 35 32 {/if} 33 34 {if !empty($unsubscribe_form)} 35 <form action="" method="post"> 36 <fieldset> 37 <legend>{'Unsubscribe from email notification'|@translate}</legend> 38 39 <p> 40 <label><input type="radio" name="unsubscribe" value="{$unsubscribe_form}" checked="checked"> {'Only unsubscribe notifications for comments from:'|@translate} <a href="{$element.url}" target="_blank">{$element.name}</a></label> 41 <label><input type="radio" name="unsubscribe" value="all"> {'Unsubscribe from all email notifications'|@translate}</label> 42 <br> 43 <label><input type="submit" value="Unsubscribe notifications for {$EMAIL}"></label> 44 <a href="{$MANAGE_LINK}">{'Manage my subscriptions'|@translate}</a> 45 </p> 46 </fieldset> 47 </form> 48 {/if} 49 50 {if !empty($validate)} 51 <p> 52 {if empty($errors)}<a href="{$element.url}">{'Return to item page'|@translate}</a><br>{/if} 53 <a href="{$MANAGE_LINK}">{'Manage my subscriptions'|@translate}</a> 54 </p> 55 {/if} 56 57 {if !empty($subscriptions) and $subscriptions != 'none'} 58 <form action="{$MANAGE_LINK}" method="post"> 59 <fieldset> 60 <legend>{'Manage my subscriptions'|@translate}</legend> 61 <table class="subscriptions_list"> 62 <tr class="throw"> 63 <th>{'Item'|@translate}</th> 64 <th>{'Date'|@translate}</th> 65 <th>{'Unsubscribe'|@translate}</th> 66 </tr> 67 {foreach from=$subscriptions item=sub name=subs_loop} 68 <tr class="{if $smarty.foreach.subs_loop.index is odd}row1{else}row2{/if}"> 69 <td> 70 {if $sub.type == 'image'} 71 <img src="{$SUBSCRIBE_TO_PATH}template/picture.png" alt="(P)"> 72 {else} 73 <img src="{$SUBSCRIBE_TO_PATH}template/folder_picture.png" alt="(A)"> 74 {/if} 75 <a href="{$sub.infos.url}">{$sub.infos.name}</a> 76 </td> 77 <td>{$sub.registration_date}</td> 78 <td><a href="{$MANAGE_LINK}&unsubscribe={$sub.id}">{'Unsubscribe'|@translate}</a></td> 79 </tr> 80 {/foreach} 81 </table> 82 83 <p> 84 <input type="hidden" name="unsubscribe" value="all"> 85 <input type="submit" value="{'Unsubscribe from all email notifications'|@translate}"> 86 </p> 87 </fieldset> 88 {elseif !empty($subscriptions) and $subscriptions == 'none'} 89 <p> 90 {'You are not subscribed to any comment.'|@translate} 91 </p> 92 {/if} 36 93 37 94 </div> <!-- content -->
Note: See TracChangeset
for help on using the changeset viewer.