From 491f93d4665e569fae91f4569b09b64886d1c721 Mon Sep 17 00:00:00 2001 From: Arslan Hassan Date: Mon, 1 Feb 2010 12:06:13 +0000 Subject: [PATCH] ADDED : Unscriptions FIXED : PM order --- upload/ajax.php | 18 +++++++++ upload/edit_account.php | 13 ++++++ upload/includes/classes/pm.class.php | 8 ++-- upload/includes/classes/user.class.php | 24 +++++++++++ .../blocks/view_channel/channel_left.html | 8 +++- .../styles/cbv2new/layout/edit_account.html | 40 +++++++++++++++++++ 6 files changed, 106 insertions(+), 5 deletions(-) diff --git a/upload/ajax.php b/upload/ajax.php index c0cf33a7..7d13de6a 100644 --- a/upload/ajax.php +++ b/upload/ajax.php @@ -203,6 +203,24 @@ if(!empty($mode)) } break; + case 'unsubscribe_user': + { + $subscribe_to = mysql_clean($_POST['subscribe_to']); + $userquery->unsubscribe_user($subscribe_to); + if(msg()) + { + $msg = msg_list(); + $msg = '
'.$msg[0].'
'; + } + if(error()) + { + $msg = error_list(); + $msg = '
'.$msg[0].'
'; + } + echo $msg; + } + break; + case 'add_friend': { diff --git a/upload/edit_account.php b/upload/edit_account.php index 2b178724..952f0196 100644 --- a/upload/edit_account.php +++ b/upload/edit_account.php @@ -81,6 +81,19 @@ switch($mode) assign('mode','ban_users'); } break; + + case 'subscriptions': + { + //Removing subscription + if(isset($_GET['delete_subs'])) + { + $sid = mysql_clean($_GET['delete_subs']); + $userquery->unsubscribe_user($sid); + } + assign('mode','subs'); + assign('subs',$userquery->get_user_subscriptions(userid())); + } + break; } diff --git a/upload/includes/classes/pm.class.php b/upload/includes/classes/pm.class.php index edf49949..f23f9376 100644 --- a/upload/includes/classes/pm.class.php +++ b/upload/includes/classes/pm.class.php @@ -302,7 +302,7 @@ class cb_pm global $db; if(!$uid) $uid = userid(); - $result = $db->select($this->tbl.',users',$this->tbl.'.*,users.userid,users.username'," message_id='$mid' AND message_to LIKE '%#$uid#%' AND userid=".$this->tbl.".message_from"); + $result = $db->select($this->tbl.',users',$this->tbl.'.*,users.userid,users.username'," message_id='$mid' AND message_to LIKE '%#$uid#%' AND userid=".$this->tbl.".message_from",NULL," date_added DESC "); if($db->num_rows>0) { @@ -363,7 +363,7 @@ class cb_pm }else{ $result = $db->select($this->tbl.',users',$this->tbl.'.*,users.username AS message_from_user ', $this->tbl.".message_to LIKE '%#$uid#%' AND users.userid = ".$this->tbl.".message_from - AND ".$this->tbl.".message_box ='in' AND message_type='pm'"); + AND ".$this->tbl.".message_box ='in' AND message_type='pm'",NULL," date_added DESC"); } } break; @@ -377,7 +377,7 @@ class cb_pm }else{ $result = $db->select($this->tbl.',users',$this->tbl.'.*,users.username AS message_from_user ', $this->tbl.".message_from = '$uid' AND users.userid = ".$this->tbl.".message_from - AND ".$this->tbl.".message_box ='out'"); + AND ".$this->tbl.".message_box ='out'",NULL," date_added DESC"); //One More Query Need To be executed to get username of recievers @@ -429,7 +429,7 @@ class cb_pm }else{ $result = $db->select($this->tbl.',users',$this->tbl.'.*,users.username AS message_from_user ', $this->tbl.".message_to LIKE '%#$uid#' AND users.userid = ".$this->tbl.".message_from - AND ".$this->tbl.".message_box ='in' AND message_type='notification'"); + AND ".$this->tbl.".message_box ='in' AND message_type='notification'",NULL," date_added DESC"); } } } diff --git a/upload/includes/classes/user.class.php b/upload/includes/classes/user.class.php index 8c1f4893..bb70a1d3 100644 --- a/upload/includes/classes/user.class.php +++ b/upload/includes/classes/user.class.php @@ -1131,6 +1131,9 @@ class userquery extends CBCategory{ if(!$user) $user = userid(); global $db; + + if(!$user) + return false; $result = $db->select($this->dbtbl['subtbl'],"*"," subscribed_to='$to' AND userid='$user'"); if($db->num_rows>0) return $result; @@ -1138,6 +1141,25 @@ class userquery extends CBCategory{ return false; } + /** + * Function used to remove user subscription + */ + function remove_subscription($subid,$uid=NULL) + { + global $db; + if(!$uid) + $uid = userid(); + if($this->is_subscribed($subid,$uid)) + { + $db->execute("DELETE FROM ".$this->dbtbl['subtbl']." WHERE userid='$uid' AND subscribed_to='$subid'"); + e("You have unsubscribed sucessfully","m"); + return true; + }else + e("You are not subscribed"); + + return false; + }function unsubscribe_user($subid,$uid=NULL){ return $this->remove_subscription($subid,$uid); } + /** * Function used to get user subscibers @@ -1180,6 +1202,8 @@ class userquery extends CBCategory{ } + + /** * Function used to reset user password * it has two steps diff --git a/upload/styles/cbv2new/layout/blocks/view_channel/channel_left.html b/upload/styles/cbv2new/layout/blocks/view_channel/channel_left.html index cacd4512..f07442ca 100644 --- a/upload/styles/cbv2new/layout/blocks/view_channel/channel_left.html +++ b/upload/styles/cbv2new/layout/blocks/view_channel/channel_left.html @@ -4,7 +4,13 @@
{$u.username}
+ + {if !$userquery->is_subscribed($u.userid)} {lang code='subscribe'}
+ {else} + {lang code='unsubscribe'}
+ {/if} + {assign var='channel_action_links' value=$userquery->get_channel_action_links($u)}