Changeset 12609 for extensions/Subscribe_to_comments
- Timestamp:
- Nov 12, 2011, 12:03:29 PM (12 years ago)
- Location:
- extensions/Subscribe_to_comments
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/Subscribe_to_comments/include/functions.inc.php
r12607 r12609 98 98 99 99 // check email 100 if ( is_a_guest() and empty($email) )100 if ( ( is_a_guest() or empty($user['email']) ) and empty($email) ) 101 101 { 102 102 return false; … … 175 175 176 176 // check email 177 if ( is_a_guest() and empty($email) )177 if ( ( is_a_guest() or empty($user['email']) ) and empty($email) ) 178 178 { 179 179 return false; -
extensions/Subscribe_to_comments/include/subscribe_to_comments.inc.php
r12607 r12609 130 130 $infos = $array = array(); 131 131 132 if (isset($_POST['stc_ check_stdl']))132 if (isset($_POST['stc_submit'])) 133 133 { 134 134 $return = subscribe_to_comments($picture['current']['id'], @$_POST['stc_mail_stdl'], 'image'); … … 171 171 } 172 172 173 function stc_on_picture_prefilter($ template, &$smarty)173 function stc_on_picture_prefilter($content, &$smarty) 174 174 { 175 175 global $user, $picture; 176 176 177 // if registered user w e check if already subscribed177 // if registered user with mail we check if already subscribed 178 178 $subscribed = false; 179 if ( !is_a_guest())179 if ( !is_a_guest() and !empty($user['email']) ) 180 180 { 181 181 $query = ' … … 194 194 195 195 ## subscribe at any moment ## 196 $search [1] = '{if isset($comment_add)}';197 198 $replace [1] = $search[1].'196 $search = '#\<\/div\>(.{0,5})\{\/if\}(.{0,5})\{\*comments\*\}#is'; 197 198 $replace = ' 199 199 <form method="post" action="{$comment_add.F_ACTION}" class="filter" id="stc_standalone"> 200 200 <fieldset>'; … … 202 202 if ($subscribed) 203 203 { 204 $replace [1].= '204 $replace.= ' 205 205 {\'You are currently subscribed to comments of this picture.\'|@translate} 206 206 <a href="'.add_url_params($picture['current']['url'], array('stc_unsubscribe'=>'1')).'">{\'Unsubscribe\'|@translate}'; … … 208 208 else 209 209 { 210 $replace[1].= ' 211 <label><a href="#" id="stc_check_stdl">{\'Subscribe to new comments\'|@translate}</a> <input type="checkbox" name="stc_check_stdl" value="1" style="display:none;"></label>'; 212 213 // form for guests 214 if (is_a_guest()) 215 { 216 $replace[1].= ' 217 <label style="display:none;">{\'Email address\'|@translate} <input type="text" name="stc_mail_stdl"></label> 218 <label style="display:none;"><input type="submit" id="stc_submit" value="{\'Submit\'|@translate}"></label> 210 $replace.= ' 211 <legend>{\'Subscribe without commenting\'|@translate}</legend>'; 212 if ( is_a_guest() or empty($user['email']) ) // email input for guest or users without mail 213 { 214 $replace.= ' 215 <label>{\'Email address\'|@translate} <input type="text" name="stc_mail_stdl"></label> 216 <label><input type="submit" name="stc_submit" value="{\'Submit\'|@translate}"></label>'; 217 } 218 else 219 { 220 $replace.= ' 221 <label><input type="submit" name="stc_submit" value="{\'Subscribe\'|@translate}"></label>'; 222 } 223 } 224 225 $replace.= ' 226 </fieldset> 227 </form> 228 </div> 229 {/if}{*comments*}'; 230 231 $content = preg_replace($search, $replace, $content); 232 233 234 ## subscribe while add a comment ## 235 $search = '<input type="submit" value="{\'Submit\'|@translate}">'; 236 $replace = null; 237 238 if (!$subscribed) 239 { 240 $replace.= ' 241 <label>{\'Notify me of followup comments\'|@translate} <input type="checkbox" name="stc_check" value="1"></label>'; 242 } 243 if ( is_a_guest() or empty($user['email']) ) 244 { 245 $replace.= ' 246 <label id="stc_mail" style="display:none;">{\'Email address\'|@translate} <input type="text" name="stc_mail"></label> 219 247 {footer_script require="jquery"}{literal} 220 248 jQuery(document).ready(function() { 221 $("a#stc_check_stdl").click(function() { 222 $("input[name=stc_check_stdl]").prop("checked", true); 223 $("#stc_standalone label").toggle(); 224 return false; 249 $("input[name=stc_check]").change(function() { 250 if ($(this).is(":checked")) $("#stc_mail").css("display", ""); 251 else $("#stc_mail").css("display", "none"); 225 252 }); 226 253 }); 227 254 {/literal}{/footer_script}'; 228 } 229 // simple link for registered users 230 else 231 { 232 $replace[1].= ' 233 {footer_script require="jquery"}{literal} 234 jQuery(document).ready(function() { 235 $("a#stc_check_stdl").click(function() { 236 $("input[name=stc_check_stdl]").prop("checked", true); 237 $(this).parents("form#stc_standalone").submit(); 238 return false; 239 }); 240 }); 241 {/literal}{/footer_script}'; 242 } 243 } 244 245 $replace[1].= ' 246 </fieldset> 247 </form>'; 248 249 250 ## subscribe while add a comment ## 251 $search[0] = '<input type="submit" value="{\'Submit\'|@translate}">'; 252 $replace[0] = null; 253 254 if (!$subscribed) 255 { 256 $replace[0].= ' 257 <label>{\'Subscribe to new comments\'|@translate} <input type="checkbox" name="stc_check" value="1"></label>'; 258 } 259 if (is_a_guest()) 260 { 261 $replace[0].= ' 262 <label id="stc_mail" style="display:none;">{\'Email address\'|@translate} <input type="text" name="stc_mail"></label> 263 {footer_script require="jquery"}{literal} 264 jQuery(document).ready(function() { 265 $("input[name=stc_check]").change(function() { 266 if ($(this).is(":checked")) $("#stc_mail").css("display", ""); 267 else $("#stc_mail").css("display", "none"); 268 }); 269 }); 270 {/literal}{/footer_script}'; 271 } 272 $replace[0].= $search[0]; 273 274 return str_replace($search, $replace, $template); 255 } 256 $replace.= $search; 257 258 $content = str_replace($search, $replace, $content); 259 260 return $content; 275 261 } 276 262 … … 294 280 } 295 281 296 if (isset($_POST['stc_ check_stdl']))282 if (isset($_POST['stc_submit'])) 297 283 { 298 284 $return = subscribe_to_comments($page['category']['id'], @$_POST['stc_mail_stdl'], 'category'); … … 337 323 } 338 324 339 function stc_on_album_prefilter($ template, &$smarty)325 function stc_on_album_prefilter($content, &$smarty) 340 326 { 341 327 global $user, $page; … … 343 329 // if registered user we check if already subscribed 344 330 $subscribed = false; 345 if ( !is_a_guest())331 if ( !is_a_guest() and !empty($user['email']) ) 346 332 { 347 333 $query = ' … … 360 346 361 347 ## subscribe at any moment ## 362 $search [1] = '{if isset($comment_add)}';363 364 $replace [1] = $search[1].'348 $search = '#\<\/div\>(.{0,5})\{\/if\}(.{0,5})\{\*comments\*\}#is'; 349 350 $replace = ' 365 351 <form method="post" action="{$comment_add.F_ACTION}" class="filter" id="stc_standalone"> 366 352 <fieldset>'; 367 353 368 // if registered user we check if already subscribed369 354 if ($subscribed) 370 355 { … … 374 359 $element_url = make_index_url($url_params); 375 360 376 $replace [1].= '361 $replace.= ' 377 362 {\'You are currently subscribed to comments of this album.\'|@translate} 378 363 <a href="'.add_url_params($element_url, array('stc_unsubscribe'=>'1')).'">{\'Unsubscribe\'|@translate}'; … … 380 365 else 381 366 { 382 $replace[1].= ' 383 <label><a href="#" id="stc_check_stdl">{\'Subscribe to new comments\'|@translate}</a> <input type="checkbox" name="stc_check_stdl" value="1" style="display:none;"></label>'; 384 385 // form for guests 386 if (is_a_guest()) 387 { 388 $replace[1].= ' 389 <label style="display:none;">{\'Email address\'|@translate} <input type="text" name="stc_mail_stdl"></label> 390 <label style="display:none;"><input type="submit" id="stc_submit" value="{\'Submit\'|@translate}"></label> 367 $replace.= ' 368 <legend>{\'Subscribe without commenting\'|@translate}</legend>'; 369 if ( is_a_guest() or empty($user['email']) ) // email input for guest or users without mail 370 { 371 $replace.= ' 372 <label>{\'Email address\'|@translate} <input type="text" name="stc_mail_stdl"></label> 373 <label><input type="submit" name="stc_submit" value="{\'Submit\'|@translate}"></label>'; 374 } 375 else 376 { 377 $replace.= ' 378 <label><input type="submit" name="stc_submit" value="{\'Subscribe\'|@translate}"></label>'; 379 } 380 } 381 382 $replace.= ' 383 </fieldset> 384 </form> 385 </div> 386 {/if}{*comments*}'; 387 388 $content = preg_replace($search, $replace, $content); 389 390 391 ## subscribe while add a comment ## 392 $search = '<input type="submit" value="{\'Submit\'|@translate}">'; 393 $replace = null; 394 395 if (!$subscribed) 396 { 397 $replace.= ' 398 <label>{\'Notify me of followup comments\'|@translate} <input type="checkbox" name="stc_check" value="1"></label>'; 399 } 400 if ( is_a_guest() or empty($user['email']) ) 401 { 402 $replace.= ' 403 <label id="stc_mail" style="display:none;">{\'Email address\'|@translate} <input type="text" name="stc_mail"></label> 391 404 {footer_script require="jquery"}{literal} 392 405 jQuery(document).ready(function() { 393 $("a#stc_check_stdl").click(function() { 394 $("input[name=stc_check_stdl]").prop("checked", true); 395 $("#stc_standalone label").toggle(); 396 return false; 406 $("input[name=stc_check]").change(function() { 407 if ($(this).is(":checked")) $("#stc_mail").css("display", ""); 408 else $("#stc_mail").css("display", "none"); 397 409 }); 398 410 }); 399 411 {/literal}{/footer_script}'; 400 } 401 // simple link for registered users 402 else 403 { 404 $replace[1].= ' 405 {footer_script require="jquery"}{literal} 406 jQuery(document).ready(function() { 407 $("a#stc_check_stdl").click(function() { 408 $("input[name=stc_check_stdl]").prop("checked", true); 409 $(this).parents("form#stc_standalone").submit(); 410 return false; 411 }); 412 }); 413 {/literal}{/footer_script}'; 414 } 415 } 416 417 $replace[1].= ' 418 </fieldset> 419 </form>'; 420 421 422 ## subscribe while add a comment ## 423 $search[0] = '<input type="submit" value="{\'Submit\'|@translate}">'; 424 $replace[0] = null; 425 426 if (!$subscribed) 427 { 428 $replace[0].= ' 429 <label>{\'Subscribe to new comments\'|@translate} <input type="checkbox" name="stc_check" value="1"></label>'; 430 } 431 if (is_a_guest()) 432 { 433 $replace[0].= ' 434 <label id="stc_mail" style="display:none;">{\'Email address\'|@translate} <input type="text" name="stc_mail"></label> 435 {footer_script require="jquery"}{literal} 436 jQuery(document).ready(function() { 437 $("input[name=stc_check]").change(function() { 438 if ($(this).is(":checked")) $("#stc_mail").css("display", ""); 439 else $("#stc_mail").css("display", "none"); 440 }); 441 }); 442 {/literal}{/footer_script}'; 443 } 444 $replace[0].= $search[0]; 445 446 return str_replace($search, $replace, $template); 412 } 413 $replace.= $search; 414 415 $content = str_replace($search, $replace, $content); 416 417 return $content; 447 418 } 448 419 … … 453 424 function stc_profile_link() 454 425 { 455 global $template; 456 457 $template->set_prefilter('profile_content', 'stc_profile_link_prefilter'); 426 global $template, $user; 427 428 if (!empty($user['email'])) 429 { 430 $template->set_prefilter('profile_content', 'stc_profile_link_prefilter'); 431 } 458 432 } 459 433 -
extensions/Subscribe_to_comments/language/en_UK/plugin.lang.php
r12607 r12609 9 9 $lang['You are currently subscribed to comments of this album.'] = 'You are currently subscribed to comments of this album.'; 10 10 $lang['Unsubscribe'] = 'Unsubscribe'; 11 $lang['Subscribe to new comments'] = 'Subscribe to new comments'; 11 $lang['Subscribe'] = 'Subscribe'; 12 $lang['Subscribe without commenting'] = 'Subscribe without commenting'; 13 $lang['Notify me of followup comments'] = 'Notify me of followup comments'; 12 14 $lang['Invalid email adress.'] = 'Invalid email adress.'; 13 15 $lang['Your subscribtion has been validated, thanks you.'] = 'Your subscribtion has been validated, thanks you.'; -
extensions/Subscribe_to_comments/language/fr_FR/plugin.lang.php
r12607 r12609 9 9 $lang['You are currently subscribed to comments of this album.'] = 'Vous êtes actuellement inscrit aux commentaires de cet album.'; 10 10 $lang['Unsubscribe'] = 'Se désinscrire'; 11 $lang['Subscribe to new comments'] = 'S\'inscrire aux nouveaux commentaires'; 11 $lang['Subscribe'] = 'S\'inscrire'; 12 $lang['Subscribe without commenting'] = 'S\'inscrire sans commenter'; 13 $lang['Notify me of followup comments'] = 'Me notifier des nouveaux commentaires'; 12 14 $lang['Invalid email adress.'] = 'Adress email invalide.'; 13 15 $lang['Your subscribtion has been validated, thanks you.'] = 'Votre inscription a été validée, merci.';
Note: See TracChangeset
for help on using the changeset viewer.