Modified:subscribe unsubscribe button made real time on view channel
This commit is contained in:
parent
c53adcf218
commit
50de9a2aa5
6 changed files with 129 additions and 7 deletions
|
@ -530,16 +530,26 @@ if(!empty($mode))
|
||||||
case 'subscribe_user':
|
case 'subscribe_user':
|
||||||
{
|
{
|
||||||
$subscribe_to = mysql_clean($_POST['subscribe_to']);
|
$subscribe_to = mysql_clean($_POST['subscribe_to']);
|
||||||
|
$username = username();
|
||||||
|
$mailId = $userquery->get_user_details($subscribe_to,false,true);
|
||||||
$userquery->subscribe_user($subscribe_to);
|
$userquery->subscribe_user($subscribe_to);
|
||||||
if(msg())
|
if(msg())
|
||||||
{
|
{
|
||||||
$msg = msg_list();
|
$msg = msg_list();
|
||||||
$msg = '<div class="msg">'.$msg[0].'</div>';
|
$msg['msg'] = $msg[0]; unset($msg[0]);
|
||||||
|
$msg['typ'] = 'msg';
|
||||||
|
if(!userid()) $msg['severity'] = 2;
|
||||||
|
else $msg['severity'] = 1;
|
||||||
|
$msg = json_encode($msg);
|
||||||
}
|
}
|
||||||
if(error())
|
if(error())
|
||||||
{
|
{
|
||||||
$msg = error_list();
|
$msg = error_list();
|
||||||
$msg = '<div class="error">'.$msg[0].'</div>';
|
$msg['msg'] = $msg[0]; unset($msg[0]);
|
||||||
|
$msg['typ'] = 'err';
|
||||||
|
if(!userid()) $msg['severity'] = 2;
|
||||||
|
else $msg['severity'] = 1;
|
||||||
|
$msg = json_encode($msg);
|
||||||
}
|
}
|
||||||
echo $msg;
|
echo $msg;
|
||||||
}
|
}
|
||||||
|
@ -563,6 +573,18 @@ if(!empty($mode))
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'get_subscribers_count':
|
||||||
|
$userid = $_POST['userid'];
|
||||||
|
if(isset($userid) ) {
|
||||||
|
$sub_count = $userquery->get_user_subscribers($userid,true);
|
||||||
|
echo json_encode(array("subscriber_count"=>$sub_count));
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
echo json_encode(array("msg"=>"Userid is empty"));
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
|
||||||
case 'add_friend':
|
case 'add_friend':
|
||||||
{
|
{
|
||||||
|
|
|
@ -1080,7 +1080,7 @@ ALTER TABLE `{tbl_prefix}user_levels_permissions` ADD `photos_moderation` ENUM(
|
||||||
ADD `collection_moderation` ENUM( 'yes', 'no' ) NOT NULL DEFAULT 'no' AFTER `photos_moderation` ,
|
ADD `collection_moderation` ENUM( 'yes', 'no' ) NOT NULL DEFAULT 'no' AFTER `photos_moderation` ,
|
||||||
ADD `plugins_moderation` ENUM( 'yes', 'no' ) NOT NULL DEFAULT 'no' AFTER `collection_moderation` ,
|
ADD `plugins_moderation` ENUM( 'yes', 'no' ) NOT NULL DEFAULT 'no' AFTER `collection_moderation` ,
|
||||||
ADD `tool_box` ENUM( 'yes', 'no' ) NOT NULL DEFAULT 'no' AFTER `plugins_moderation` ,
|
ADD `tool_box` ENUM( 'yes', 'no' ) NOT NULL DEFAULT 'no' AFTER `plugins_moderation` ,
|
||||||
ADD `plugins_perms` varchar(20) NOT NULL DEFAULT 'none' AFTER `tool_box` ;
|
ADD `plugins_perms` text NOT NULL AFTER `tool_box` ;
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS `{tbl_prefix}mass_emails` (
|
CREATE TABLE IF NOT EXISTS `{tbl_prefix}mass_emails` (
|
||||||
`id` int(255) NOT NULL AUTO_INCREMENT,
|
`id` int(255) NOT NULL AUTO_INCREMENT,
|
||||||
|
|
|
@ -46,3 +46,5 @@ INSERT INTO `{tbl_prefix}config` (`configid`, `name`, `value`) VALUES ('', 'play
|
||||||
-- UPDATE `{tbl_prefix}config` SET value = '3' WHERE name = 'index_featured';
|
-- UPDATE `{tbl_prefix}config` SET value = '3' WHERE name = 'index_featured';
|
||||||
-- Reply email template added
|
-- Reply email template added
|
||||||
INSERT INTO `{tbl_prefix}email_templates` (`email_template_id`, `email_template_name`, `email_template_code`, `email_template_subject`, `email_template`, `email_template_allowed_tags`) VALUES ('', 'User Reply Email', 'user_reply_email', '[{website_title}] {username} made reply on your comment', '{username} has replied on your comment\r\n"{comment}"\r\n\r\n<a href="{obj_link}">{obj_link}</a>\r\n\r\n{website_title} team', '');
|
INSERT INTO `{tbl_prefix}email_templates` (`email_template_id`, `email_template_name`, `email_template_code`, `email_template_subject`, `email_template`, `email_template_allowed_tags`) VALUES ('', 'User Reply Email', 'user_reply_email', '[{website_title}] {username} made reply on your comment', '{username} has replied on your comment\r\n"{comment}"\r\n\r\n<a href="{obj_link}">{obj_link}</a>\r\n\r\n{website_title} team', '');
|
||||||
|
-- Changing schema for plugin prems 4.0
|
||||||
|
ALTER TABLE `{tbl_prefix}user_levels_permissions` MODIFY COLUMN `plugins_perms` text NOT NULL;
|
|
@ -2246,6 +2246,96 @@
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.unsubscribeToChannel = function(user,type){
|
||||||
|
curObj = this;
|
||||||
|
var elems = document.getElementsByClassName("unsubs_"+user);
|
||||||
|
if(elems.length>0){
|
||||||
|
Array.prototype.forEach.call(elems, function(el) {
|
||||||
|
el.disabled = true;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
$.post(page, {mode : type,subscribe_to : user},function(data){
|
||||||
|
if(!data){
|
||||||
|
alert("No data");
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
curObj.showMeTheMsg(data);
|
||||||
|
// for view channels
|
||||||
|
var els = document.getElementsByClassName("unsubs_"+user);
|
||||||
|
if(els.length>0){
|
||||||
|
Array.prototype.forEach.call(els, function(el) {
|
||||||
|
el.innerHTML="Subscribe";
|
||||||
|
el.setAttribute("onclick","_cb.subscribeToChannelNew("+user+",'subscribe_user');");
|
||||||
|
el.id = "subs_"+user;
|
||||||
|
el.disabled = false;
|
||||||
|
curObj.updateSubscribersCount(user);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},'text');
|
||||||
|
};
|
||||||
|
|
||||||
|
this.subscribeToChannelNew = function(user,type){
|
||||||
|
var curObj = this;
|
||||||
|
|
||||||
|
var elems = document.getElementsByClassName("subs_"+user);
|
||||||
|
if(elems.length>0){
|
||||||
|
Array.prototype.forEach.call(elems, function(el) {
|
||||||
|
el.disabled = true;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
$.post(page, { mode : type,subscribe_to : user },function(data){
|
||||||
|
if(!data){
|
||||||
|
alert("No data");
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
data = JSON.parse(data);
|
||||||
|
if(data.typ == 'err')
|
||||||
|
curObj.showMeTheMsg('<div class="error">'+data.msg+'</div>');
|
||||||
|
else
|
||||||
|
curObj.showMeTheMsg('<div class="msg">'+data.msg+'</div>');
|
||||||
|
|
||||||
|
if(data.severity<2){
|
||||||
|
// for channels page
|
||||||
|
var els = document.getElementsByClassName("subs_"+user);
|
||||||
|
if(els.length>0){
|
||||||
|
Array.prototype.forEach.call(els, function(el) {
|
||||||
|
el.innerHTML="Unsubscribe";
|
||||||
|
el.setAttribute("onclick","_cb.unsubscribeToChannel("+user+",'unsubscribe_user');");
|
||||||
|
el.id = "unsubs_"+user;
|
||||||
|
el.disabled = false;
|
||||||
|
curObj.updateSubscribersCount(user);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
var els = document.getElementsByClassName("subs_"+user);
|
||||||
|
Array.prototype.forEach.call(els, function(el) {
|
||||||
|
el.disabled = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},'text');
|
||||||
|
};
|
||||||
|
|
||||||
|
this.updateSubscribersCount = function(userid){
|
||||||
|
var curObj = this;
|
||||||
|
$.post(page,
|
||||||
|
{
|
||||||
|
mode : 'get_subscribers_count',
|
||||||
|
userid : userid
|
||||||
|
},
|
||||||
|
function(data)
|
||||||
|
{
|
||||||
|
if(!data)
|
||||||
|
alert("No data");
|
||||||
|
else
|
||||||
|
{
|
||||||
|
subsObj = JSON.parse(data);
|
||||||
|
$("#user_subscribers_"+userid).html(subsObj.subscriber_count);
|
||||||
|
}
|
||||||
|
},'text');
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
window._cb = new _cb();
|
window._cb = new _cb();
|
||||||
|
|
2
upload/js/clipbucket.min.js
vendored
2
upload/js/clipbucket.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -28,7 +28,7 @@
|
||||||
<i class="icon-views"></i>{prettyNum($user.profile_hits)} <span>{lang code='views'}</span>
|
<i class="icon-views"></i>{prettyNum($user.profile_hits)} <span>{lang code='views'}</span>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<i class="icon-subscribers"></i>{prettyNum($user.subscribers)} <span>{if $user.subscribers <= 1}{lang code='Subscriber'}{else}{lang code='Subscribers'}{/if}</span>
|
<i class="icon-subscribers"></i><span id="user_subscribers_{$user.userid}">{prettyNum($user.subscribers)}</span> <span>{lang code='Subscribers'}</span>
|
||||||
|
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
@ -70,7 +70,15 @@
|
||||||
<a href="{$baseurl}/private_message.php?mode=new_msg&to={$user.username}" class="btn btn-default">
|
<a href="{$baseurl}/private_message.php?mode=new_msg&to={$user.username}" class="btn btn-default">
|
||||||
{lang code="user_send_message"}
|
{lang code="user_send_message"}
|
||||||
</a>
|
</a>
|
||||||
<button id="subscribe_channel" class="btn btn-default">{lang code="subscribe"}</button>
|
{if $userquery->is_subscribed($user.userid,userid())}
|
||||||
|
<button class="btn btn-default subs_{$user.userid} unsubs_{$user.userid}" onclick="_cb.unsubscribeToChannel({$user.userid},'unsubscribe_user');">
|
||||||
|
{lang code="unsubscribe"}
|
||||||
|
</button>
|
||||||
|
{else}
|
||||||
|
<button class="btn btn-default subs_{$user.userid} unsubs_{$user.userid}" onclick="_cb.subscribeToChannelNew({$user.userid},'subscribe_user');">
|
||||||
|
{lang code="subscribe"}
|
||||||
|
</button>
|
||||||
|
{/if}
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Add table
Reference in a new issue