Added : Rough Add Friend
Added : Friend request in menu bar
This commit is contained in:
parent
17029eaabf
commit
df010dc30e
13 changed files with 187 additions and 21 deletions
|
@ -678,11 +678,46 @@ switch ($mode)
|
||||||
if ($type == 'notifications')
|
if ($type == 'notifications')
|
||||||
$cbfeeds->read_notification($uid);
|
$cbfeeds->read_notification($uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'add_friend':
|
||||||
|
{
|
||||||
|
$friend = $_POST['uid'];
|
||||||
|
$userid = userid();
|
||||||
|
|
||||||
|
if ($userid)
|
||||||
|
{
|
||||||
|
$userquery->add_contact($userid, $friend);
|
||||||
|
|
||||||
|
if (msg())
|
||||||
|
{
|
||||||
|
$msg = msg_list();
|
||||||
|
$msg = $msg[0] ;
|
||||||
|
|
||||||
|
echo json_encode(array('success'=>'ok','msg'=>$msg));
|
||||||
|
}
|
||||||
|
if (error())
|
||||||
|
{
|
||||||
|
$msg = error_list();
|
||||||
|
|
||||||
|
echo json_encode(array('error'=>$msg));
|
||||||
|
}
|
||||||
|
$msg;
|
||||||
|
}else
|
||||||
|
{
|
||||||
|
echo json_encode(array('error'=>lang('You are not logged in')));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
case 'confirm_friend':
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
exit(json_encode(array('err' => array(lang('Invalid request')))));
|
exit(json_encode(array('err' => array(lang('Invalid request')))));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1121,10 +1121,40 @@ class userquery extends CBCategory
|
||||||
{
|
{
|
||||||
global $db;
|
global $db;
|
||||||
|
|
||||||
|
$fields_arr = array(
|
||||||
|
'c' => array(
|
||||||
|
'contact_id','userid','contact_userid','date_added'
|
||||||
|
),
|
||||||
|
'u' => array(
|
||||||
|
'userid','username','email','first_name','last_name','avatar',
|
||||||
|
'avatar_url'
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
$fields = '';
|
||||||
|
foreach($fields_arr as $tbl => $tbl_fields)
|
||||||
|
{
|
||||||
|
foreach($tbl_fields as $tbl_field)
|
||||||
|
{
|
||||||
|
if($fields)
|
||||||
|
$fields .=', ';
|
||||||
|
|
||||||
|
$fields .= $tbl.'.'.$tbl_field;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!$count_only)
|
if (!$count_only)
|
||||||
{
|
{
|
||||||
$result = $db->select(tbl("contacts,users"), tbl("contacts.userid,contacts.confirmed,contacts.request_type ,users.*"), tbl("contacts.contact_userid") . "='$uid' AND " . tbl("users.userid") . "=" . tbl("contacts.userid") . "
|
$query = "SELECT ".$fields." FROM ".tbl('contacts')." AS c ";
|
||||||
AND " . tbl("contacts.confirmed") . "='no' AND " . tbl("contacts") . ".contact_group_id='$group' ");
|
$query .= " LEFT JOIN ".tbl('users')." AS u";
|
||||||
|
$query .= " ON c.userid = u.userid ";
|
||||||
|
$query .= " WHERE c.contact_userid='$uid' ";
|
||||||
|
$query .= " AND c.confirmed='no' AND c.contact_group_id='$group' ";
|
||||||
|
|
||||||
|
|
||||||
|
$result = db_select($query);
|
||||||
|
|
||||||
if ($db->num_rows > 0)
|
if ($db->num_rows > 0)
|
||||||
return $result;
|
return $result;
|
||||||
else
|
else
|
||||||
|
|
|
@ -1332,6 +1332,8 @@ function get_template($file, $type = 'fetch', $layout = true)
|
||||||
'notifications' => 'blocks/notifications/notifications.html',
|
'notifications' => 'blocks/notifications/notifications.html',
|
||||||
'msgs_notifications' => 'blocks/pm/notifications.html',
|
'msgs_notifications' => 'blocks/pm/notifications.html',
|
||||||
'msgs_notifications_block' => 'blocks/pm/notification_block.html',
|
'msgs_notifications_block' => 'blocks/pm/notification_block.html',
|
||||||
|
'friends_notifications' => 'blocks/contacts/notifications.html',
|
||||||
|
'friends_notifications_block' => 'blocks/contacts/notification_block.html',
|
||||||
'topics' => 'blocks/groups/topics.html',
|
'topics' => 'blocks/groups/topics.html',
|
||||||
'share_feed_block' => 'blocks/feed_share_block.html',
|
'share_feed_block' => 'blocks/feed_share_block.html',
|
||||||
'single_feed' => 'blocks/single_feed.html',
|
'single_feed' => 'blocks/single_feed.html',
|
||||||
|
|
|
@ -1,11 +1,7 @@
|
||||||
/**
|
/**
|
||||||
* jQuery.ScrollTo - Easy element scrolling using jQuery.
|
* Copyright (c) 2007-2012 Ariel Flesler - aflesler(at)gmail(dot)com | http://flesler.blogspot.com
|
||||||
* Copyright (c) 2007-2009 Ariel Flesler - aflesler(at)gmail(dot)com | http://flesler.blogspot.com
|
|
||||||
* Dual licensed under MIT and GPL.
|
* Dual licensed under MIT and GPL.
|
||||||
* Date: 5/25/2009
|
|
||||||
* @author Ariel Flesler
|
* @author Ariel Flesler
|
||||||
* @version 1.4.2
|
* @version 1.4.5 BETA
|
||||||
*
|
|
||||||
* http://flesler.blogspot.com/2007/10/jqueryscrollto.html
|
|
||||||
*/
|
*/
|
||||||
;(function(d){var k=d.scrollTo=function(a,i,e){d(window).scrollTo(a,i,e)};k.defaults={axis:'xy',duration:parseFloat(d.fn.jquery)>=1.3?0:1};k.window=function(a){return d(window)._scrollable()};d.fn._scrollable=function(){return this.map(function(){var a=this,i=!a.nodeName||d.inArray(a.nodeName.toLowerCase(),['iframe','#document','html','body'])!=-1;if(!i)return a;var e=(a.contentWindow||a).document||a.ownerDocument||a;return d.browser.safari||e.compatMode=='BackCompat'?e.body:e.documentElement})};d.fn.scrollTo=function(n,j,b){if(typeof j=='object'){b=j;j=0}if(typeof b=='function')b={onAfter:b};if(n=='max')n=9e9;b=d.extend({},k.defaults,b);j=j||b.speed||b.duration;b.queue=b.queue&&b.axis.length>1;if(b.queue)j/=2;b.offset=p(b.offset);b.over=p(b.over);return this._scrollable().each(function(){var q=this,r=d(q),f=n,s,g={},u=r.is('html,body');switch(typeof f){case'number':case'string':if(/^([+-]=)?\d+(\.\d+)?(px|%)?$/.test(f)){f=p(f);break}f=d(f,this);case'object':if(f.is||f.style)s=(f=d(f)).offset()}d.each(b.axis.split(''),function(a,i){var e=i=='x'?'Left':'Top',h=e.toLowerCase(),c='scroll'+e,l=q[c],m=k.max(q,i);if(s){g[c]=s[h]+(u?0:l-r.offset()[h]);if(b.margin){g[c]-=parseInt(f.css('margin'+e))||0;g[c]-=parseInt(f.css('border'+e+'Width'))||0}g[c]+=b.offset[h]||0;if(b.over[h])g[c]+=f[i=='x'?'width':'height']()*b.over[h]}else{var o=f[h];g[c]=o.slice&&o.slice(-1)=='%'?parseFloat(o)/100*m:o}if(/^\d+$/.test(g[c]))g[c]=g[c]<=0?0:Math.min(g[c],m);if(!a&&b.queue){if(l!=g[c])t(b.onAfterFirst);delete g[c]}});t(b.onAfter);function t(a){r.animate(g,j,b.easing,a&&function(){a.call(this,n,b)})}}).end()};k.max=function(a,i){var e=i=='x'?'Width':'Height',h='scroll'+e;if(!d(a).is('html,body'))return a[h]-d(a)[e.toLowerCase()]();var c='client'+e,l=a.ownerDocument.documentElement,m=a.ownerDocument.body;return Math.max(l[h],m[h])-Math.min(l[c],m[c])};function p(a){return typeof a=='object'?a:{top:a,left:a}}})(jQuery);
|
;(function($){var h=$.scrollTo=function(a,b,c){$(window).scrollTo(a,b,c)};h.defaults={axis:'xy',duration:parseFloat($.fn.jquery)>=1.3?0:1,limit:true};h.window=function(a){return $(window)._scrollable()};$.fn._scrollable=function(){return this.map(function(){var a=this,isWin=!a.nodeName||$.inArray(a.nodeName.toLowerCase(),['iframe','#document','html','body'])!=-1;if(!isWin)return a;var b=(a.contentWindow||a).document||a.ownerDocument||a;return/webkit/i.test(navigator.userAgent)||b.compatMode=='BackCompat'?b.body:b.documentElement})};$.fn.scrollTo=function(e,f,g){if(typeof f=='object'){g=f;f=0}if(typeof g=='function')g={onAfter:g};if(e=='max')e=9e9;g=$.extend({},h.defaults,g);f=f||g.duration;g.queue=g.queue&&g.axis.length>1;if(g.queue)f/=2;g.offset=both(g.offset);g.over=both(g.over);return this._scrollable().each(function(){if(e==null)return;var d=this,$elem=$(d),targ=e,toff,attr={},win=$elem.is('html,body');switch(typeof targ){case'number':case'string':if(/^([+-]=?)?\d+(\.\d+)?(px|%)?$/.test(targ)){targ=both(targ);break}targ=$(targ,this);if(!targ.length)return;case'object':if(targ.is||targ.style)toff=(targ=$(targ)).offset()}$.each(g.axis.split(''),function(i,a){var b=a=='x'?'Left':'Top',pos=b.toLowerCase(),key='scroll'+b,old=d[key],max=h.max(d,a);if(toff){attr[key]=toff[pos]+(win?0:old-$elem.offset()[pos]);if(g.margin){attr[key]-=parseInt(targ.css('margin'+b))||0;attr[key]-=parseInt(targ.css('border'+b+'Width'))||0}attr[key]+=g.offset[pos]||0;if(g.over[pos])attr[key]+=targ[a=='x'?'width':'height']()*g.over[pos]}else{var c=targ[pos];attr[key]=c.slice&&c.slice(-1)=='%'?parseFloat(c)/100*max:c}if(g.limit&&/^\d+$/.test(attr[key]))attr[key]=attr[key]<=0?0:Math.min(attr[key],max);if(!i&&g.queue){if(old!=attr[key])animate(g.onAfterFirst);delete attr[key]}});animate(g.onAfter);function animate(a){$elem.animate(attr,f,g.easing,a&&function(){a.call(this,e,g)})}}).end()};h.max=function(a,b){var c=b=='x'?'Width':'Height',scroll='scroll'+c;if(!$(a).is('html,body'))return a[scroll]-$(a)[c.toLowerCase()]();var d='client'+c,html=a.ownerDocument.documentElement,body=a.ownerDocument.body;return Math.max(html[scroll],body[scroll])-Math.min(html[d],body[d])};function both(a){return typeof a=='object'?a:{top:a,left:a}}})(jQuery);
|
|
@ -0,0 +1,17 @@
|
||||||
|
<div id="request-block-{$friend.contact_id}">
|
||||||
|
<div class="notification {if !$last}notification-padding{/if}" >
|
||||||
|
|
||||||
|
<img src="{$userquery->avatar($friend)}" class="notify_avatar"/>
|
||||||
|
<div class="notification_data">
|
||||||
|
<strong>{name($friend)}</strong>
|
||||||
|
<div>{$thread.thread.message}</div>
|
||||||
|
<div class="notification_time">
|
||||||
|
<i class="{get_notify_icon($notification)}"></i> {what_time($friend.date_added,false)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<button class="btn btn-mini btn-confirm" type="button"
|
||||||
|
onclick="window.location=baseurl+'/manage_contacts.php?confirm={$friend.userid}&mode=confirm' ">Confirm</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
23
upload/styles/cbv3/layout/blocks/contacts/notifications.html
Normal file
23
upload/styles/cbv3/layout/blocks/contacts/notifications.html
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
{$friends=$userquery->get_pending_contacts(userid(),0)}
|
||||||
|
{if $friends}
|
||||||
|
<div class="notifications">
|
||||||
|
<div class="notify_title">{lang code='Friends Requests'}</div>
|
||||||
|
<div class="seperator"></div>
|
||||||
|
|
||||||
|
<div class="notifications-container cbv3-scroller">
|
||||||
|
<div id="new_notifications"></div>
|
||||||
|
{foreach $friends as $friend}
|
||||||
|
{if $friend}
|
||||||
|
|
||||||
|
{if $friend@last}{$last=true}{else}{$last=false}{/if}
|
||||||
|
|
||||||
|
{$block=get_template('friends_notifications_block','path')}
|
||||||
|
{include file=$block friend=$friend last=$last}
|
||||||
|
{/if}
|
||||||
|
{/foreach}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="seperator"></div>
|
||||||
|
<div class="all_notifications"><a href="">Show all Messages</a></div>
|
||||||
|
</div>
|
||||||
|
{/if}
|
|
@ -21,6 +21,7 @@
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<button class="btn btn-small btn-subscribe"><i class="icon-user"></i> Subscribe</button>
|
<button class="btn btn-small btn-subscribe"><i class="icon-user"></i> Subscribe</button>
|
||||||
|
<button class="btn btn-small btn-add-friend" data-userid="{$user.userid}"><i class="icon-user"></i> Add friend</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
|
@ -979,3 +979,28 @@ function read_notifications(type,read)
|
||||||
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* add friend function
|
||||||
|
*/
|
||||||
|
function add_friend(fid,obj)
|
||||||
|
{
|
||||||
|
amplify.request('main',
|
||||||
|
{
|
||||||
|
mode : 'add_friend',
|
||||||
|
uid : fid
|
||||||
|
},function(data)
|
||||||
|
{
|
||||||
|
if(data.error)
|
||||||
|
{
|
||||||
|
displayError(data.error);
|
||||||
|
}else
|
||||||
|
{
|
||||||
|
if(obj)
|
||||||
|
{
|
||||||
|
$(obj).text('Requst sent');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
|
@ -206,10 +206,19 @@
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
{/if}
|
{/if}
|
||||||
<li>
|
<li class="dropdown friend-requests-dd">
|
||||||
<a href="#"><span class="icon-user icon-white"></span>
|
<a href="#" class="dropdown-toggle" data-toggle="dropdown"
|
||||||
|
onclick="read_notifications('friends',true);"><span class="icon-user icon-white"></span>
|
||||||
<span class="badge badge-important" id="new_friends_lable">{$new_friends|number_format}</span>
|
<span class="badge badge-important" id="new_friends_lable">{$new_friends|number_format}</span>
|
||||||
</a></li>
|
</a>
|
||||||
|
<ul class="dropdown-menu" role="menu"
|
||||||
|
id="notifications-container">
|
||||||
|
<li>
|
||||||
|
{$template=get_template('friends_notifications','path')}
|
||||||
|
{include file=$template notifications=$notifications}
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
<li class="dropdown">
|
<li class="dropdown">
|
||||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown"
|
<a href="#" class="dropdown-toggle" data-toggle="dropdown"
|
||||||
onclick="read_notifications('msgs',true);"><span class="icon-envelope icon-white"></span>
|
onclick="read_notifications('msgs',true);"><span class="icon-envelope icon-white"></span>
|
||||||
|
|
|
@ -432,6 +432,15 @@
|
||||||
e.stopPropagation()
|
e.stopPropagation()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
$('.friend-requests-dd .dropdown-menu a').on('click', function (e) {
|
||||||
|
e.stopPropagation()
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
$('.btn-add-friend').click(function(){
|
||||||
|
add_friend($(this).attr('data-userid'),this);
|
||||||
|
})
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,15 @@
|
||||||
|
|
||||||
{include_template_file file="blocks/account_left.html"}
|
{include_template_file file="blocks/account_left.html"}
|
||||||
|
|
||||||
|
{if $smarty.get.mid}
|
||||||
|
<script>
|
||||||
|
$(document).ready(function(){
|
||||||
|
//Scroll to message
|
||||||
|
$('#message-{$smarty.get.mid}').scrollTo();
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
{/if}
|
||||||
|
|
||||||
<div class="account-right">
|
<div class="account-right">
|
||||||
{if $mode =='inbox'}
|
{if $mode =='inbox'}
|
||||||
<h2 class="page-header">{lang code='private_messages'} » {lang code='inbox'}</h2>
|
<h2 class="page-header">{lang code='private_messages'} » {lang code='inbox'}</h2>
|
||||||
|
@ -36,9 +45,9 @@
|
||||||
<p class="alert alert-large">{lang code='No conversation selected'}</p>
|
<p class="alert alert-large">{lang code='No conversation selected'}</p>
|
||||||
{else}
|
{else}
|
||||||
|
|
||||||
<div class="msgs_container cbv3-scroller"">
|
<div class="msgs_container cbv3-scroller">
|
||||||
{foreach $messages as $message}
|
{foreach $messages as $message}
|
||||||
<div class="msg_container">
|
<div class="msg_container" id="message-{$message.message_id}">
|
||||||
<div class="msg_author_thumb">
|
<div class="msg_author_thumb">
|
||||||
<img src="{$userquery->avatar($message,small)}" />
|
<img src="{$userquery->avatar($message,small)}" />
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -17,6 +17,10 @@
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 12px; right: 12px;
|
top: 12px; right: 12px;
|
||||||
}
|
}
|
||||||
|
.user-block .btn-add-friend {
|
||||||
|
position: absolute;
|
||||||
|
top: 45px; right: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
.users-list .user-block:last-child {
|
.users-list .user-block:last-child {
|
||||||
margin-bottom: 12px;
|
margin-bottom: 12px;
|
||||||
|
|
|
@ -338,6 +338,12 @@ vertical-align: top; margin-left: 10px; height: 28px; overflow: hidden}
|
||||||
padding: 5px; position: relative;
|
padding: 5px; position: relative;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.notifications .btn-confirm{
|
||||||
|
position: absolute;
|
||||||
|
right: 5px; top: 5px
|
||||||
|
}
|
||||||
|
|
||||||
.notifications .notification-padding{
|
.notifications .notification-padding{
|
||||||
border-bottom: 1px solid #ddd;
|
border-bottom: 1px solid #ddd;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue