aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2014-01-29 21:29:48 -0800
committerfriendica <info@friendica.com>2014-01-29 21:29:48 -0800
commit080928f214c9f83879f1578e05baa6032fa2b7b8 (patch)
treeaa53cc5185c5b1a58f0bb8e30609da6bcdc0b5ad
parent7b609782623d91c2bdf81c04cd801aaae927e9fa (diff)
downloadvolse-hubzilla-080928f214c9f83879f1578e05baa6032fa2b7b8.tar.gz
volse-hubzilla-080928f214c9f83879f1578e05baa6032fa2b7b8.tar.bz2
volse-hubzilla-080928f214c9f83879f1578e05baa6032fa2b7b8.zip
chatroom management front-end stuff
-rw-r--r--include/widgets.php3
-rw-r--r--mod/chat.php73
-rw-r--r--view/js/mod_chat.js16
-rw-r--r--view/js/mod_filestorage.php16
-rw-r--r--view/tpl/chatroom_new.tpl12
5 files changed, 119 insertions, 1 deletions
diff --git a/include/widgets.php b/include/widgets.php
index 400660d11..0151f7c27 100644
--- a/include/widgets.php
+++ b/include/widgets.php
@@ -587,4 +587,5 @@ function widget_chatroom_list($arr) {
'$nickname' => $channel['channel_address'],
'$items' => $r,
));
-} \ No newline at end of file
+}
+
diff --git a/mod/chat.php b/mod/chat.php
index fa3d05364..54fa58092 100644
--- a/mod/chat.php
+++ b/mod/chat.php
@@ -36,6 +36,46 @@ function chat_init(&$a) {
}
+function chat_post(&$a) {
+
+ if($_POST['room_name'])
+ $room = strip_tags(trim($_POST['room_name']));
+
+ if((! $room) || (! local_user()))
+ return;
+
+ $channel = $a->get_channel();
+
+
+ if($_POST['action'] === 'drop') {
+ chatroom_destroy($channel,array('cr_name' => $room));
+ goaway(z_root() . '/chat/' . $channel['channel_address']);
+ }
+
+
+ $arr = array('name' => $room);
+ $arr['allow_gid'] = perms2str($_REQUEST['group_allow']);
+ $arr['allow_cid'] = perms2str($_REQUEST['contact_allow']);
+ $arr['deny_gid'] = perms2str($_REQUEST['group_deny']);
+ $arr['deny_cid'] = perms2str($_REQUEST['contact_deny']);
+
+ chatroom_create($channel,$arr);
+
+ $x = q("select cr_id from chatroom where cr_name = '%s' and cr_uid = %d limit 1",
+ dbesc($room),
+ intval(local_user())
+ );
+
+ if($x)
+ goaway(z_root() . '/chat/' . $channel['channel_address'] . '/' . $x[0]['cr_id']);
+
+ // that failed. Try again perhaps?
+
+ goaway(z_root() . '/chat/' . $channel['channel_address'] . '/new');
+
+
+}
+
function chat_content(&$a) {
@@ -62,11 +102,44 @@ function chat_content(&$a) {
if(! $x)
return;
$o = replace_macros(get_markup_template('chat.tpl'),array(
+ '$room_name' => '', // should we get this from the API?
'$room_id' => $room_id,
'$submit' => t('Submit')
));
return $o;
}
+
+
+
+
+
+ if(local_user() && argc() > 2 && argv(2) === 'new') {
+
+
+ $channel = $a->get_channel();
+ $channel_acl = array(
+ 'allow_cid' => $channel['channel_allow_cid'],
+ 'allow_gid' => $channel['channel_allow_gid'],
+ 'deny_cid' => $channel['channel_deny_cid'],
+ 'deny_gid' => $channel['channel_deny_gid']
+ );
+
+ require_once('include/acl_selectors.php');
+
+ $o = replace_macros(get_markup_template('chatroom_new.tpl'),array(
+ '$header' => t('New Chatroom'),
+ '$name' => array('room_name',t('Chatroom Name'),'', ''),
+ '$acl' => populate_acl($channel_acl),
+ '$submit' => t('Submit')
+ ));
+ return $o;
+ }
+
+
+
+
+
+
require_once('include/widgets.php');
return widget_chatroom_list(array());
diff --git a/view/js/mod_chat.js b/view/js/mod_chat.js
new file mode 100644
index 000000000..82957ae44
--- /dev/null
+++ b/view/js/mod_chat.js
@@ -0,0 +1,16 @@
+$(document).ready(function() {
+
+ $('#contact_allow, #contact_deny, #group_allow, #group_deny').change(function() {
+ var selstr;
+ $('#contact_allow option:selected, #contact_deny option:selected, #group_allow option:selected, #group_deny option:selected').each( function() {
+ selstr = $(this).text();
+ $('#jot-perms-icon').removeClass('unlock').addClass('lock');
+ $('#jot-public').hide();
+ });
+ if(selstr == null) {
+ $('#jot-perms-icon').removeClass('lock').addClass('unlock');
+ $('#jot-public').show();
+ }
+
+ }).trigger('change');
+});
diff --git a/view/js/mod_filestorage.php b/view/js/mod_filestorage.php
new file mode 100644
index 000000000..82957ae44
--- /dev/null
+++ b/view/js/mod_filestorage.php
@@ -0,0 +1,16 @@
+$(document).ready(function() {
+
+ $('#contact_allow, #contact_deny, #group_allow, #group_deny').change(function() {
+ var selstr;
+ $('#contact_allow option:selected, #contact_deny option:selected, #group_allow option:selected, #group_deny option:selected').each( function() {
+ selstr = $(this).text();
+ $('#jot-perms-icon').removeClass('unlock').addClass('lock');
+ $('#jot-public').hide();
+ });
+ if(selstr == null) {
+ $('#jot-perms-icon').removeClass('lock').addClass('unlock');
+ $('#jot-public').show();
+ }
+
+ }).trigger('change');
+});
diff --git a/view/tpl/chatroom_new.tpl b/view/tpl/chatroom_new.tpl
new file mode 100644
index 000000000..86eadb132
--- /dev/null
+++ b/view/tpl/chatroom_new.tpl
@@ -0,0 +1,12 @@
+<h1>{{$header}}</h1>
+
+<form action="chat" method="post" >
+{{include file="field_input.tpl" field=$name}}
+<br />
+<br />
+{{$acl}}
+<div class="clear"></div>
+<input type="submit" name="submit" value="{{$submit}}" />
+</form>
+
+