Merge remote-tracking branch 'mike/master' into dev

This commit is contained in:
Mario Vavti 2018-01-19 09:16:51 +01:00
commit e9f32ef94e
9 changed files with 98 additions and 89 deletions

View File

@ -90,8 +90,6 @@ class Notifier {
$item_id = $argv[2]; $item_id = $argv[2];
$extra = (($argc > 3) ? $argv[3] : null);
if(! $item_id) if(! $item_id)
return; return;

View File

@ -730,9 +730,6 @@ class ThreadItem {
$observer = $conv->get_observer(); $observer = $conv->get_observer();
$qc = ((local_channel()) ? get_pconfig(local_channel(),'system','qcomment') : null);
$qcomment = (($qc) ? explode("\n",$qc) : null);
$arr = array('comment_buttons' => '','id' => $this->get_id()); $arr = array('comment_buttons' => '','id' => $this->get_id());
call_hooks('comment_buttons',$arr); call_hooks('comment_buttons',$arr);
$comment_buttons = $arr['comment_buttons']; $comment_buttons = $arr['comment_buttons'];
@ -744,7 +741,6 @@ class ThreadItem {
'$type' => (($conv->get_mode() === 'channel') ? 'wall-comment' : 'net-comment'), '$type' => (($conv->get_mode() === 'channel') ? 'wall-comment' : 'net-comment'),
'$id' => $this->get_id(), '$id' => $this->get_id(),
'$parent' => $this->get_id(), '$parent' => $this->get_id(),
'$qcomment' => $qcomment,
'$comment_buttons' => $comment_buttons, '$comment_buttons' => $comment_buttons,
'$profile_uid' => $conv->get_profile_owner(), '$profile_uid' => $conv->get_profile_owner(),
'$mylink' => $observer['xchan_url'], '$mylink' => $observer['xchan_url'],

View File

@ -38,10 +38,9 @@ class Router {
/** /**
* @brief Router constructor. * @brief Router constructor.
* *
* @param[in,out] App &$a
* @throws Exception module not found * @throws Exception module not found
*/ */
function __construct(&$a) { function __construct() {
$module = \App::$module; $module = \App::$module;
$modname = "Zotlabs\\Module\\" . ucfirst($module); $modname = "Zotlabs\\Module\\" . ucfirst($module);
@ -179,9 +178,8 @@ class Router {
/** /**
* @brief * @brief
* *
* @param[in,out] App &$a
*/ */
function Dispatch(&$a) { function Dispatch() {
/** /**
* Call module functions * Call module functions

View File

@ -58,11 +58,10 @@ class WebServer {
if((x($_GET,'zid')) && (! \App::$install)) { if((x($_GET,'zid')) && (! \App::$install)) {
\App::$query_string = strip_zids(\App::$query_string); \App::$query_string = strip_zids(\App::$query_string);
if(! local_channel()) { if(! local_channel()) {
if ($_SESSION['my_address']!=$_GET['zid']) if ($_SESSION['my_address']!=$_GET['zid']) {
{ $_SESSION['my_address'] = $_GET['zid'];
$_SESSION['my_address'] = $_GET['zid']; $_SESSION['authenticated'] = 0;
$_SESSION['authenticated'] = 0; }
}
zid_init(); zid_init();
} }
} }
@ -107,9 +106,43 @@ class WebServer {
check_config(); check_config();
} }
//nav_set_selected('nothing'); $this->create_channel_links();
$Router = new Router($a); $Router = new Router();
$this->initialise_content();
$Router->Dispatch();
$this->set_homebase();
// now that we've been through the module content, see if the page reported
// a permission problem and if so, a 403 response would seem to be in order.
if(is_array($_SESSION['sysmsg']) && stristr(implode("", $_SESSION['sysmsg']), t('Permission denied'))) {
header($_SERVER['SERVER_PROTOCOL'] . ' 403 ' . t('Permission denied.'));
}
call_hooks('page_end', \App::$page['content']);
construct_page();
killme();
}
private function initialise_content() {
/* initialise content region */
if(! x(\App::$page, 'content'))
\App::$page['content'] = '';
call_hooks('page_content_top', \App::$page['content']);
}
private function create_channel_links() {
/* Initialise the Link: response header if this is a channel page. /* Initialise the Link: response header if this is a channel page.
* This cannot be done inside the channel module because some protocol * This cannot be done inside the channel module because some protocol
@ -135,26 +168,17 @@ class WebServer {
\App::$channel_links = $x['channel_links']; \App::$channel_links = $x['channel_links'];
header('Link: ' . \App::get_channel_links()); header('Link: ' . \App::get_channel_links());
} }
}
private function set_homebase() {
/* initialise content region */
if(! x(\App::$page, 'content'))
\App::$page['content'] = '';
call_hooks('page_content_top', \App::$page['content']);
$Router->Dispatch($a);
// If you're just visiting, let javascript take you home // If you're just visiting, let javascript take you home
if(x($_SESSION, 'visitor_home')) { if(x($_SESSION, 'visitor_home')) {
$homebase = $_SESSION['visitor_home']; $homebase = $_SESSION['visitor_home'];
} elseif(local_channel()) { }
elseif(local_channel()) {
$homebase = z_root() . '/channel/' . \App::$channel['channel_address']; $homebase = z_root() . '/channel/' . \App::$channel['channel_address'];
} }
@ -162,17 +186,8 @@ class WebServer {
\App::$page['content'] .= '<script>var homebase = "' . $homebase . '";</script>'; \App::$page['content'] .= '<script>var homebase = "' . $homebase . '";</script>';
} }
// now that we've been through the module content, see if the page reported
// a permission problem and if so, a 403 response would seem to be in order.
if(is_array($_SESSION['sysmsg']) && stristr(implode("", $_SESSION['sysmsg']), t('Permission denied'))) {
header($_SERVER['SERVER_PROTOCOL'] . ' 403 ' . t('Permission denied.'));
}
call_hooks('page_end', \App::$page['content']);
construct_page();
killme();
} }
} }

View File

@ -71,6 +71,8 @@ class Forums {
if($r) if($r)
$r1[$x]['unseen'] = $r[0]['unseen']; $r1[$x]['unseen'] = $r[0]['unseen'];
}
/** /**
* @FIXME * @FIXME
* This SQL makes the counts correct when you get forum posts arriving from different routes/sources * This SQL makes the counts correct when you get forum posts arriving from different routes/sources
@ -79,21 +81,19 @@ class Forums {
* It may make more sense in that query to look for the mention in the body rather than another join, * It may make more sense in that query to look for the mention in the body rather than another join,
* but that makes it very inefficient. * but that makes it very inefficient.
* *
$r = q("select sum(item_unseen) as unseen from item left join term on oid = id where otype = %d and owner_xchan != '%s' and item.uid = %d and url = '%s' and ttype = %d $perms_sql ", * $r = q("select sum(item_unseen) as unseen from item left join term on oid = id where otype = %d and owner_xchan != '%s' and item.uid = %d and url = '%s' and ttype = %d $perms_sql ",
intval(TERM_OBJ_POST), * intval(TERM_OBJ_POST),
dbesc($r1[$x]['xchan_hash']), * dbesc($r1[$x]['xchan_hash']),
intval(local_channel()), * intval(local_channel()),
dbesc($r1[$x]['xchan_url']), * dbesc($r1[$x]['xchan_url']),
intval(TERM_MENTION) * intval(TERM_MENTION)
); * );
if($r) * if($r)
$r1[$x]['unseen'] = ((array_key_exists('unseen',$r1[$x])) ? $r1[$x]['unseen'] + $r[0]['unseen'] : $r[0]['unseen']); * $r1[$x]['unseen'] = ((array_key_exists('unseen',$r1[$x])) ? $r1[$x]['unseen'] + $r[0]['unseen'] : $r[0]['unseen']);
* *
* end @FIXME * end @FIXME
*/ */
}
if($r1) { if($r1) {
$o .= '<div class="widget">'; $o .= '<div class="widget">';
$o .= '<h3>' . t('Forums') . '</h3><ul class="nav nav-pills flex-column">'; $o .= '<h3>' . t('Forums') . '</h3><ul class="nav nav-pills flex-column">';

View File

@ -6,6 +6,8 @@
api_register_func('api/export/basic','api_export_basic', true); api_register_func('api/export/basic','api_export_basic', true);
api_register_func('api/red/channel/export/basic','api_export_basic', true); api_register_func('api/red/channel/export/basic','api_export_basic', true);
api_register_func('api/z/1.0/channel/export/basic','api_export_basic', true); api_register_func('api/z/1.0/channel/export/basic','api_export_basic', true);
api_register_func('api/red/channel/list','api_channel_list', true);
api_register_func('api/z/1.0/channel/list','api_channel_list', true);
api_register_func('api/red/channel/stream','api_channel_stream', true); api_register_func('api/red/channel/stream','api_channel_stream', true);
api_register_func('api/z/1.0/channel/stream','api_channel_stream', true); api_register_func('api/z/1.0/channel/stream','api_channel_stream', true);
api_register_func('api/red/files','api_attach_list', true); api_register_func('api/red/files','api_attach_list', true);
@ -111,9 +113,31 @@
} }
} }
function api_channel_list($type) {
if(api_user() === false) {
logger('api_channel_stream: no user');
return false;
}
$channel = channelx_by_n(api_user());
if(! $channel)
return false;
$ret = [];
$r = q("select channel_address from channel where channel_account_id = %d",
intval($channel['channel_account_id'])
);
if($r) {
foreach($r as $rv) {
$ret[] = $rv['channel_address'];
}
}
json_return_and_die($ret);
}
function api_channel_stream($type) { function api_channel_stream($type) {

View File

@ -190,6 +190,16 @@ function get_features($filtered = true) {
feature_level('event_tz_select',2), feature_level('event_tz_select',2),
], ],
[
'premium_channel',
t('Premium Channel'),
t('Allows you to set restrictions and terms on those that connect with your channel'),
false,
get_config('feature_lock','premium_channel'),
feature_level('premium_channel',4),
],
[ [
'advanced_dirsearch', 'advanced_dirsearch',
t('Advanced Directory Search'), t('Advanced Directory Search'),
@ -438,16 +448,10 @@ function get_features($filtered = true) {
], ],
]; ];
$x = [ 'features' => $arr, ];
call_hooks('get_features',$x);
$arr['general'][] = [ $arr = $x['features'];
'premium_channel',
t('Premium Channel'),
t('Allows you to set restrictions and terms on those that connect with your channel'),
false,
get_config('feature_lock','premium_channel'),
feature_level('premium_channel',4),
];
$techlevel = get_account_techlevel(); $techlevel = get_account_techlevel();
@ -482,7 +486,5 @@ function get_features($filtered = true) {
$narr = $arr; $narr = $arr;
} }
$x = [ 'features' => $narr, 'filtered' => $filtered, 'techlevel' => $techlevel ]; return $narr;
call_hooks('get_features',$x);
return $x['features'];
} }

View File

@ -282,22 +282,6 @@ function viewsrc(id) {
$.colorbox({href: 'viewsrc/' + id, maxWidth: '80%', maxHeight: '80%' }); $.colorbox({href: 'viewsrc/' + id, maxWidth: '80%', maxHeight: '80%' });
} }
function qCommentInsert(obj, id) {
var tmpStr = $("#comment-edit-text-" + id).val();
if(tmpStr == aStr.comment) {
tmpStr = '';
$("#comment-edit-text-" + id).addClass("expanded");
openMenu("comment-edit-submit-wrapper-" + id);
}
var ins = $(obj).val();
ins = ins.replace('&lt;','<');
ins = ins.replace('&gt;','>');
ins = ins.replace('&amp;','&');
ins = ins.replace('&quot;','"');
$("#comment-edit-text-" + id).val(tmpStr + ins);
$(obj).val('');
}
function showHideComments(id) { function showHideComments(id) {
if( $('#collapsed-comments-' + id).is(':visible')) { if( $('#collapsed-comments-' + id).is(':visible')) {
$('#collapsed-comments-' + id + ' .autotime').timeago('dispose'); $('#collapsed-comments-' + id + ' .autotime').timeago('dispose');

View File

@ -19,14 +19,6 @@
</div> </div>
{{/if}} {{/if}}
<textarea id="comment-edit-text-{{$id}}" class="comment-edit-text" placeholder="{{$comment}}" name="body" ondragenter="linkdropper(event);" ondragleave="linkdropexit(event);" ondragover="linkdropper(event);" ondrop="linkdrop(event);" ></textarea> <textarea id="comment-edit-text-{{$id}}" class="comment-edit-text" placeholder="{{$comment}}" name="body" ondragenter="linkdropper(event);" ondragleave="linkdropexit(event);" ondragover="linkdropper(event);" ondrop="linkdrop(event);" ></textarea>
{{if $qcomment}}
<select id="qcomment-select-{{$id}}" name="qcomment-{{$id}}" class="qcomment" onchange="qCommentInsert(this,{{$id}});" >
<option value=""></option>
{{foreach $qcomment as $qc}}
<option value="{{$qc}}">{{$qc}}</option>
{{/foreach}}
</select>
{{/if}}
<div id="comment-tools-{{$id}}" class="pt-2 comment-tools"> <div id="comment-tools-{{$id}}" class="pt-2 comment-tools">
<div id="comment-edit-bb-{{$id}}" class="btn-toolbar pull-left"> <div id="comment-edit-bb-{{$id}}" class="btn-toolbar pull-left">
<div class="btn-group mr-2"> <div class="btn-group mr-2">