provide ability to bookmark chatrooms using rbmark

This commit is contained in:
friendica 2014-02-24 21:34:49 -08:00
parent 51a895471b
commit b1021df485
3 changed files with 33 additions and 4 deletions

View File

@ -37,9 +37,13 @@ function bookmark_add($channel,$sender,$taxonomy,$private,$opts = null) {
$iarr['mitem_flags'] |= MENU_ITEM_ZID;
$arr = array();
if(! $menu_name)
if(! $menu_name) {
$arr['menu_name'] = substr($sender['xchan_hash'],0,16) . ' ' . $sender['xchan_name'];
$arr['menu_desc'] = sprintf( t('%1$s\'s bookmarks'), $sender['xchan_name']);
$arr['menu_desc'] = sprintf( t('%1$s\'s bookmarks'), $sender['xchan_name']);
}
else {
$arr['menu_name'] = $arr['menu_desc'] = $menu_name;
}
$arr['menu_flags'] = (($sender['xchan_hash'] === $channel['channel_hash']) ? MENU_BOOKMARK : MENU_SYSTEM|MENU_BOOKMARK);
$arr['menu_channel_id'] = $channel_id;
@ -68,3 +72,14 @@ function bookmark_add($channel,$sender,$taxonomy,$private,$opts = null) {
return $r;
}
function get_bookmark_link($observer) {
if((! $observer) || ($observer['xchan_network'] !== 'zot'))
return '';
$h = @parse_url($observer['xchan_url']);
if($h)
return $h['scheme'] . '://' . $h['host'] . (($h['port']) ? ':' . $h['port'] : '') . '/rbmark?f=';
return '';
}

View File

@ -1,6 +1,7 @@
<?php /** @file */
require_once('include/chat.php');
require_once('include/bookmarks.php');
function chat_init(&$a) {
@ -82,6 +83,7 @@ function chat_content(&$a) {
if(local_user())
$channel = $a->get_channel();
$ob = $a->get_observer();
$observer = get_observer_hash();
if(! $observer) {
notice( t('Permission denied.') . EOL);
@ -144,6 +146,8 @@ function chat_content(&$a) {
if(argc() > 2 && intval(argv(2))) {
$room_id = intval(argv(2));
$bookmark_link = get_bookmark_link($ob);
$x = chatroom_enter($observer,$room_id,'online',$_SERVER['REMOTE_ADDR']);
if(! $x)
return;
@ -152,8 +156,16 @@ function chat_content(&$a) {
intval($a->profile['profile_uid'])
);
if($x) {
$private = ((($x[0]['allow_cid']) || ($x[0]['allow_gid']) || ($x[0]['deny_cid']) || ($x[0]['deny_gid'])) ? true : false);
$room_name = $x[0]['cr_name'];
if($bookmark_link)
$bookmark_link .= '&url=' . z_root() . '/chat/' . argv(1) . '/' . argv(2) . '&title=' . urlencode($x[0]['cr_name']) . (($private) ? '&private=1' : '') . '&ischat=1';
}
else {
notice( t('Room not found') . EOL);
return;
}
$o = replace_macros(get_markup_template('chat.tpl'),array(
'$room_name' => $room_name,
'$room_id' => $room_id,
@ -162,7 +174,9 @@ function chat_content(&$a) {
'$submit' => t('Submit'),
'$leave' => t('Leave Room'),
'$away' => t('I am away right now'),
'$online' => t('I am online')
'$online' => t('I am online'),
'$bookmark_link' => $bookmark_link,
'$bookmark' => t('Bookmark this room')
));
return $o;

View File

@ -17,7 +17,7 @@
<input type="submit" name="submit" value="{{$submit}}" />
</form>
<a href="{{$baseurl}}/chat/{{$nickname}}/{{$room_id}}/leave">{{$leave}}</a> | <a href="{{$baseurl}}/chatsvc?f=&room_id={{$room_id}}&status=away">{{$away}}</a> | <a href="{{$baseurl}}/chatsvc?f=&room_id={{$room_id}}&status=online">{{$online}}</a>
<a href="{{$baseurl}}/chat/{{$nickname}}/{{$room_id}}/leave">{{$leave}}</a> | <a href="{{$baseurl}}/chatsvc?f=&room_id={{$room_id}}&status=away">{{$away}}</a> | <a href="{{$baseurl}}/chatsvc?f=&room_id={{$room_id}}&status=online">{{$online}}</a>{{if $bookmark_link}} | <a href="{{$bookmark_link}}" target="_blank" >{{$bookmark}}</a>{{/if}}
</div>