samedi 1 octobre 2016

Module DLE Rapid subscribe to comments

Module DLE Rapid subscribe to comments


Introducing Module DLE Rapid subscribe to comments english version, after installation to subscribe to the comments will be available only when adding a comment. A simple module for the DLE «Quick subscribe to comments" replaces the standard engine algorithm Datalife Engine , so that you can subscribe to comments only by adding a comment. Dle This module complements the functionality and correct this omission.

On based hack / module "Quick subscribe to comments" users will be able to subscribe to messages just in one click. Actually the example of the execution of this button you can look at the author's website.

Installing the Quick subscribe to comments

The engine/ajax folder, create a file with the contents subscribe.php:

<?php
/*
Subscribe to comments
Author: Sander
Website: http://sandev.pro/
*/
@error_reporting ( E_ALL ^ E_WARNING ^ E_NOTICE );
@ini_set ( 'display_errors', true );
@ini_set ( 'html_errors', false );
@ini_set ( 'error_reporting', E_ALL ^ E_WARNING ^ E_NOTICE );

define( 'DATALIFEENGINE', true );
define( 'ROOT_DIR', substr( dirname( __FILE__ ), 0, -12 ) );
define( 'ENGINE_DIR', ROOT_DIR . '/engine' );

include ENGINE_DIR . '/data/config.php';
date_default_timezone_set ( $config['date_adjust'] );

require_once ENGINE_DIR . '/classes/mysql.php';
require_once ENGINE_DIR . '/data/dbconfig.php';
require_once ENGINE_DIR . '/modules/functions.php';
dle_session();
$user_group = get_vars( "usergroup" );
if( ! $user_group ) {
$user_group = array ();
$db->query( "SELECT * FROM " . USERPREFIX . "_usergroups ORDER BY id ASC" );
while ( $row = $db->get_row() ) {
$user_group[$row['id']] = array ();
foreach ( $row as $key => $value ) $user_group[$row['id']][$key] = stripslashes($value);
}
set_vars( "usergroup", $user_group );
$db->free();
}

require_once ENGINE_DIR . '/modules/sitelogin.php';
if(!$is_logged) $member_id['user_group'] = 5;

$post_id = intval($_POST['post_id']);
if($post_id<1) die("{"error":"Undefined news for subscriptions"}");

if(!$user_group[$member_id['user_group']]['allow_subscribe']) die("{"error":"You can not use your subscription"}");

$row = $db->super_query( "SELECT id, allow_comm FROM " . PREFIX . "_post WHERE id = $post_id" );
if(!$row['id']) die("{"error":"Publication can not be found or has been removed"}");
if(!$row['allow_comm']) die("{"error":"Comments on this publication are forbidden"}");

$row = $db->super_query( "SELECT user_id, name, email, hash FROM " . PREFIX . "_subscribe WHERE news_id = $post_id AND user_id = {$member_id['user_id']}" );
if($row['user_id']){
//un-subscribe
$db->query( "DELETE FROM " . PREFIX . "_subscribe WHERE news_id = $post_id AND user_id = {$member_id['user_id']}" );
echo "{"html":"You have successfully unsubscribed. Subscribe again?"}";
}else{
//sign
if(function_exists('openssl_random_pseudo_bytes')) $stronghash = md5(openssl_random_pseudo_bytes(15));
else $stronghash = md5(uniqid( mt_rand(), TRUE ));
$salt = str_shuffle($stronghash);
$s_hash = "";
for($i = 0; $i < 10; $i ++) $s_hash .= $salt{mt_rand( 0, 31 )};
$s_hash = md5($s_hash);
$db->query( "INSERT INTO " . PREFIX . "_subscribe (user_id, name, email, news_id, hash) values ('{$member_id['user_id']}', '{$member_id['name']}', '{$member_id['email']}', '{$post_id}', '{$s_hash}')" );
echo "{"html":"You have successfully subscribed. Unsubscribe?"}";
}


JS code to insert into any pattern connected to the js file

$(document).on('click','.unsubcomm',function(){
ShowLoading();
var $this = $(this);
$.post(dle_root+"engine/ajax/subscribe.php",{post_id:$('#post_id').val()},function(d){
HideLoading();
if(d.error) DLEalert(d.error,"Error");
else $this.html(d.html);
},"json");
});


In addcomments.tpl template file or fullstory.tpl at the desired location to insert the code:

[not-group=5]<span class="unsubcomm">Subscribe to comments</span>[/not-group]
Availability behalf unsubcomm class - is necessary.

If desired, use the buttons Style:
the CSS

.unsubcomm{
display: inline-block;
border: 1px solid #ccc;
padding: 0 20px;
height: 26px;
font: normal 12px/26px Verdana;
-webkit-box-sizing: content-box;
-moz-box-sizing: content-box;
box-sizing: content-box;
cursor: pointer;
color: #555;
background: #e5e5e5 url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAAeCAIAAABi9+OQAAAAI0lEQVQImWP49esXEwMDA9O/f/+YGBgYmP7//4+Vj0ucTHUA3nos7QvvyugAAAAASUVORK5CYII=) repeat-x 0 0;
-webkit-border-radius: 2px;
-moz-border-radius: 2px;
border-radius: 2px;
}
.unsubcomm:hover{
color: #222;
background: #fff url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAAeCAIAAABi9+OQAAAAG0lEQVQImWN49+4dEwMDAxMjIyNZNBMTEzn6AGFhAzKAZ4ckAAAAAElFTkSuQmCC) repeat-x 0 0;
}
.unsubcomm:active{
border-color: #fc0;
}
Source: sandev pro
Regards,
Oleg aka Sander
To support the standard unsubscribe via e-mail. You can put any hash algorithm, but why, Ctrl-> C, Ctrl-> V's easier :) Download dle modules on our portal as a module Quick subscribe to comments for the DLE in the archive

Aucun commentaire:

Enregistrer un commentaire