aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2014-02-24 21:34:49 -0800
committerfriendica <info@friendica.com>2014-02-24 21:34:49 -0800
commitb1021df485fb6129acda5bba616bac10aea75a45 (patch)
tree718a4771ce1fb86931531226898b0b5d00e4a337
parent51a895471bb1c0a4f4a7a934a8f0dbeab8626fad (diff)
downloadvolse-hubzilla-b1021df485fb6129acda5bba616bac10aea75a45.tar.gz
volse-hubzilla-b1021df485fb6129acda5bba616bac10aea75a45.tar.bz2
volse-hubzilla-b1021df485fb6129acda5bba616bac10aea75a45.zip
provide ability to bookmark chatrooms using rbmark
-rw-r--r--include/bookmarks.php19
-rw-r--r--mod/chat.php16
-rw-r--r--view/tpl/chat.tpl2
3 files changed, 33 insertions, 4 deletions
diff --git a/include/bookmarks.php b/include/bookmarks.php
index 895dedaff..21a775f9a 100644
--- a/include/bookmarks.php
+++ b/include/bookmarks.php
@@ -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 '';
+}
diff --git a/mod/chat.php b/mod/chat.php
index a960f4f37..0f2b94b9d 100644
--- a/mod/chat.php
+++ b/mod/chat.php
@@ -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;
diff --git a/view/tpl/chat.tpl b/view/tpl/chat.tpl
index 51aeb836e..acb7e5bef 100644
--- a/view/tpl/chat.tpl
+++ b/view/tpl/chat.tpl
@@ -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>