move chat from feature to apps
This commit is contained in:
parent
a1d5ce3716
commit
56f88f2e30
@ -303,7 +303,7 @@ class Apps {
|
|||||||
'Admin' => t('Site Admin'),
|
'Admin' => t('Site Admin'),
|
||||||
'Report Bug' => t('Report Bug'),
|
'Report Bug' => t('Report Bug'),
|
||||||
'View Bookmarks' => t('View Bookmarks'),
|
'View Bookmarks' => t('View Bookmarks'),
|
||||||
'My Chatrooms' => t('My Chatrooms'),
|
'Chatrooms' => t('Chatrooms'),
|
||||||
'Connections' => t('Connections'),
|
'Connections' => t('Connections'),
|
||||||
'Remote Diagnostics' => t('Remote Diagnostics'),
|
'Remote Diagnostics' => t('Remote Diagnostics'),
|
||||||
'Suggest Channels' => t('Suggest Channels'),
|
'Suggest Channels' => t('Suggest Channels'),
|
||||||
|
@ -50,8 +50,8 @@ class Apps extends \Zotlabs\Web\Controller {
|
|||||||
'$title' => (($available) ? t('Available Apps') : t('Installed Apps')),
|
'$title' => (($available) ? t('Available Apps') : t('Installed Apps')),
|
||||||
'$apps' => $apps,
|
'$apps' => $apps,
|
||||||
'$authed' => ((local_channel()) ? true : false),
|
'$authed' => ((local_channel()) ? true : false),
|
||||||
'$manage' => (($available) ? '' : t('Manage apps')),
|
'$manage' => (($available) ? '' : t('Manage Apps')),
|
||||||
'$create' => (($mode == 'edit') ? t('Create new app') : '')
|
'$create' => (($mode == 'edit') ? t('Create Custom App') : '')
|
||||||
));
|
));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,12 +2,18 @@
|
|||||||
|
|
||||||
namespace Zotlabs\Module;
|
namespace Zotlabs\Module;
|
||||||
|
|
||||||
|
use App;
|
||||||
|
use Zotlabs\Lib\Apps;
|
||||||
|
use Zotlabs\Web\Controller;
|
||||||
|
use Zotlabs\Lib\Chatroom;
|
||||||
|
use Zotlabs\Access\AccessList;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
require_once('include/bookmarks.php');
|
require_once('include/bookmarks.php');
|
||||||
|
|
||||||
use \Zotlabs\Lib as Zlib;
|
class Chat extends Controller {
|
||||||
|
|
||||||
class Chat extends \Zotlabs\Web\Controller {
|
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
|
|
||||||
@ -16,7 +22,7 @@ class Chat extends \Zotlabs\Web\Controller {
|
|||||||
$which = argv(1);
|
$which = argv(1);
|
||||||
if(! $which) {
|
if(! $which) {
|
||||||
if(local_channel()) {
|
if(local_channel()) {
|
||||||
$channel = \App::get_channel();
|
$channel = App::get_channel();
|
||||||
if($channel && $channel['channel_address'])
|
if($channel && $channel['channel_address'])
|
||||||
$which = $channel['channel_address'];
|
$which = $channel['channel_address'];
|
||||||
}
|
}
|
||||||
@ -27,7 +33,7 @@ class Chat extends \Zotlabs\Web\Controller {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$profile = 0;
|
$profile = 0;
|
||||||
$channel = \App::get_channel();
|
$channel = App::get_channel();
|
||||||
|
|
||||||
if((local_channel()) && (argc() > 2) && (argv(2) === 'view')) {
|
if((local_channel()) && (argc() > 2) && (argv(2) === 'view')) {
|
||||||
$which = $channel['channel_address'];
|
$which = $channel['channel_address'];
|
||||||
@ -49,16 +55,16 @@ class Chat extends \Zotlabs\Web\Controller {
|
|||||||
if((! $room) || (! local_channel()))
|
if((! $room) || (! local_channel()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
$channel = \App::get_channel();
|
$channel = App::get_channel();
|
||||||
|
|
||||||
|
|
||||||
if($_POST['action'] === 'drop') {
|
if($_POST['action'] === 'drop') {
|
||||||
logger('delete chatroom');
|
logger('delete chatroom');
|
||||||
Zlib\Chatroom::destroy($channel,array('cr_name' => $room));
|
Chatroom::destroy($channel,array('cr_name' => $room));
|
||||||
goaway(z_root() . '/chat/' . $channel['channel_address']);
|
goaway(z_root() . '/chat/' . $channel['channel_address']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$acl = new \Zotlabs\Access\AccessList($channel);
|
$acl = new AccessList($channel);
|
||||||
$acl->set_from_array($_REQUEST);
|
$acl->set_from_array($_REQUEST);
|
||||||
|
|
||||||
$arr = $acl->get();
|
$arr = $acl->get();
|
||||||
@ -67,7 +73,7 @@ class Chat extends \Zotlabs\Web\Controller {
|
|||||||
if(intval($arr['expire']) < 0)
|
if(intval($arr['expire']) < 0)
|
||||||
$arr['expire'] = 0;
|
$arr['expire'] = 0;
|
||||||
|
|
||||||
Zlib\Chatroom::create($channel,$arr);
|
Chatroom::create($channel,$arr);
|
||||||
|
|
||||||
$x = q("select * from chatroom where cr_name = '%s' and cr_uid = %d limit 1",
|
$x = q("select * from chatroom where cr_name = '%s' and cr_uid = %d limit 1",
|
||||||
dbesc($room),
|
dbesc($room),
|
||||||
@ -89,25 +95,34 @@ class Chat extends \Zotlabs\Web\Controller {
|
|||||||
|
|
||||||
function get() {
|
function get() {
|
||||||
|
|
||||||
if(local_channel()) {
|
if(! Apps::system_app_installed(App::$profile_uid, 'Chatrooms')) {
|
||||||
$channel = \App::get_channel();
|
//Do not display any associated widgets at this point
|
||||||
nav_set_selected('My Chatrooms');
|
App::$pdl = '';
|
||||||
|
|
||||||
|
$o = '<b>Chatrooms App (Not Installed):</b><br>';
|
||||||
|
$o .= t('Access Controlled Chatrooms');
|
||||||
|
return $o;
|
||||||
}
|
}
|
||||||
|
|
||||||
$ob = \App::get_observer();
|
if(local_channel()) {
|
||||||
|
$channel = App::get_channel();
|
||||||
|
nav_set_selected('Chatrooms');
|
||||||
|
}
|
||||||
|
|
||||||
|
$ob = App::get_observer();
|
||||||
$observer = get_observer_hash();
|
$observer = get_observer_hash();
|
||||||
if(! $observer) {
|
if(! $observer) {
|
||||||
notice( t('Permission denied.') . EOL);
|
notice( t('Permission denied.') . EOL);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(! perm_is_allowed(\App::$profile['profile_uid'],$observer,'chat')) {
|
if(! perm_is_allowed(App::$profile['profile_uid'],$observer,'chat')) {
|
||||||
notice( t('Permission denied.') . EOL);
|
notice( t('Permission denied.') . EOL);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((argc() > 3) && intval(argv(2)) && (argv(3) === 'leave')) {
|
if((argc() > 3) && intval(argv(2)) && (argv(3) === 'leave')) {
|
||||||
Zlib\Chatroom::leave($observer,argv(2),$_SERVER['REMOTE_ADDR']);
|
Chatroom::leave($observer,argv(2),$_SERVER['REMOTE_ADDR']);
|
||||||
goaway(z_root() . '/channel/' . argv(1));
|
goaway(z_root() . '/channel/' . argv(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -160,16 +175,16 @@ class Chat extends \Zotlabs\Web\Controller {
|
|||||||
$room_id = intval(argv(2));
|
$room_id = intval(argv(2));
|
||||||
$bookmark_link = get_bookmark_link($ob);
|
$bookmark_link = get_bookmark_link($ob);
|
||||||
|
|
||||||
$x = Zlib\Chatroom::enter($observer,$room_id,'online',$_SERVER['REMOTE_ADDR']);
|
$x = Chatroom::enter($observer,$room_id,'online',$_SERVER['REMOTE_ADDR']);
|
||||||
if(! $x)
|
if(! $x)
|
||||||
return;
|
return;
|
||||||
$x = q("select * from chatroom where cr_id = %d and cr_uid = %d $sql_extra limit 1",
|
$x = q("select * from chatroom where cr_id = %d and cr_uid = %d $sql_extra limit 1",
|
||||||
intval($room_id),
|
intval($room_id),
|
||||||
intval(\App::$profile['profile_uid'])
|
intval(App::$profile['profile_uid'])
|
||||||
);
|
);
|
||||||
|
|
||||||
if($x) {
|
if($x) {
|
||||||
$acl = new \Zotlabs\Access\AccessList(false);
|
$acl = new AccessList(false);
|
||||||
$acl->set($x[0]);
|
$acl->set($x[0]);
|
||||||
|
|
||||||
$private = $acl->is_private();
|
$private = $acl->is_private();
|
||||||
@ -209,17 +224,11 @@ class Chat extends \Zotlabs\Web\Controller {
|
|||||||
return $o;
|
return $o;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
require_once('include/conversation.php');
|
require_once('include/conversation.php');
|
||||||
|
|
||||||
$o = '';
|
$o = '';
|
||||||
|
|
||||||
if(! feature_enabled(\App::$profile['profile_uid'],'ajaxchat')) {
|
$acl = new AccessList($channel);
|
||||||
notice( t('Feature disabled.') . EOL);
|
|
||||||
return $o;
|
|
||||||
}
|
|
||||||
|
|
||||||
$acl = new \Zotlabs\Access\AccessList($channel);
|
|
||||||
$channel_acl = $acl->get();
|
$channel_acl = $acl->get();
|
||||||
|
|
||||||
$lockstate = (($channel_acl['allow_cid'] || $channel_acl['allow_gid'] || $channel_acl['deny_cid'] || $channel_acl['deny_gid']) ? 'lock' : 'unlock');
|
$lockstate = (($channel_acl['allow_cid'] || $channel_acl['allow_gid'] || $channel_acl['deny_cid'] || $channel_acl['deny_gid']) ? 'lock' : 'unlock');
|
||||||
@ -243,17 +252,17 @@ class Chat extends \Zotlabs\Web\Controller {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
$rooms = Zlib\Chatroom::roomlist(\App::$profile['profile_uid']);
|
$rooms = Chatroom::roomlist(App::$profile['profile_uid']);
|
||||||
|
|
||||||
$o .= replace_macros(get_markup_template('chatrooms.tpl'), array(
|
$o .= replace_macros(get_markup_template('chatrooms.tpl'), array(
|
||||||
'$header' => sprintf( t('%1$s\'s Chatrooms'), \App::$profile['fullname']),
|
'$header' => sprintf( t('%1$s\'s Chatrooms'), App::$profile['fullname']),
|
||||||
'$name' => t('Name'),
|
'$name' => t('Name'),
|
||||||
'$baseurl' => z_root(),
|
'$baseurl' => z_root(),
|
||||||
'$nickname' => \App::$profile['channel_address'],
|
'$nickname' => App::$profile['channel_address'],
|
||||||
'$rooms' => $rooms,
|
'$rooms' => $rooms,
|
||||||
'$norooms' => t('No chatrooms available'),
|
'$norooms' => t('No chatrooms available'),
|
||||||
'$newroom' => t('Create New'),
|
'$newroom' => t('Create New'),
|
||||||
'$is_owner' => ((local_channel() && local_channel() == \App::$profile['profile_uid']) ? 1 : 0),
|
'$is_owner' => ((local_channel() && local_channel() == App::$profile['profile_uid']) ? 1 : 0),
|
||||||
'$chatroom_new' => $chatroom_new,
|
'$chatroom_new' => $chatroom_new,
|
||||||
'$expire' => t('Expiration'),
|
'$expire' => t('Expiration'),
|
||||||
'$expire_unit' => t('min') //minutes
|
'$expire_unit' => t('min') //minutes
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
version: 1
|
version: 1.1
|
||||||
url: $baseurl/chat/$nick
|
url: $baseurl/chat/$nick
|
||||||
requires: local_channel, ajaxchat
|
requires: local_channel
|
||||||
name: My Chatrooms
|
name: Chatrooms
|
||||||
photo: icon:comments-o
|
photo: icon:comments-o
|
||||||
categories: Productivity
|
categories: Productivity
|
||||||
|
@ -118,16 +118,6 @@ function get_features($filtered = true, $level = (-1)) {
|
|||||||
feature_level('photo_location',2),
|
feature_level('photo_location',2),
|
||||||
],
|
],
|
||||||
|
|
||||||
[
|
|
||||||
'ajaxchat',
|
|
||||||
t('Access Controlled Chatrooms'),
|
|
||||||
t('Provide chatrooms and chat services with access control.'),
|
|
||||||
true,
|
|
||||||
get_config('feature_lock','ajaxchat'),
|
|
||||||
feature_level('ajaxchat',1),
|
|
||||||
],
|
|
||||||
|
|
||||||
|
|
||||||
[
|
[
|
||||||
'smart_birthdays',
|
'smart_birthdays',
|
||||||
t('Smart Birthdays'),
|
t('Smart Birthdays'),
|
||||||
|
@ -417,7 +417,7 @@ function channel_apps($is_owner = false, $nickname = null) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ($p['chat'] && feature_enabled($uid,'ajaxchat')) {
|
if ($p['chat'] && Apps::system_app_installed($uid,'Chatrooms')) {
|
||||||
$has_chats = Chatroom::list_count($uid);
|
$has_chats = Chatroom::list_count($uid);
|
||||||
if ($has_chats) {
|
if ($has_chats) {
|
||||||
$tabs[] = [
|
$tabs[] = [
|
||||||
|
Reference in New Issue
Block a user