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

This commit is contained in:
Mario Vavti 2018-08-24 14:44:45 +02:00
commit f036c25dca
5 changed files with 88 additions and 46 deletions

View File

@ -51,6 +51,8 @@ class Articles extends \Zotlabs\Web\Controller {
$sql_extra2 .= protect_sprintf(term_item_parent_query(\App::$profile['profile_uid'],'item', $category, TERM_CATEGORY)); $sql_extra2 .= protect_sprintf(term_item_parent_query(\App::$profile['profile_uid'],'item', $category, TERM_CATEGORY));
} }
$datequery = ((x($_GET,'dend') && is_a_date_arg($_GET['dend'])) ? notags($_GET['dend']) : '');
$datequery2 = ((x($_GET,'dbegin') && is_a_date_arg($_GET['dbegin'])) ? notags($_GET['dbegin']) : '');
$which = argv(1); $which = argv(1);
@ -143,10 +145,21 @@ class Articles extends \Zotlabs\Web\Controller {
$sql_item = "and item.id = " . intval($r[0]['iid']) . " "; $sql_item = "and item.id = " . intval($r[0]['iid']) . " ";
} }
} }
if($datequery) {
$sql_extra2 .= protect_sprintf(sprintf(" AND item.created <= '%s' ", dbesc(datetime_convert(date_default_timezone_get(),'',$datequery))));
$order = 'post';
}
if($datequery2) {
$sql_extra2 .= protect_sprintf(sprintf(" AND item.created >= '%s' ", dbesc(datetime_convert(date_default_timezone_get(),'',$datequery2))));
}
if($datequery || $datequery2) {
$sql_extra2 .= " and item.item_thread_top != 0 ";
}
$r = q("select * from item $r = q("select * from item
where item.uid = %d and item_type = %d where item.uid = %d and item_type = %d
$sql_extra $sql_item order by item.created desc $pager_sql", $sql_extra $sql_extra2 $sql_item order by item.created desc $pager_sql",
intval($owner), intval($owner),
intval(ITEM_TYPE_ARTICLE) intval(ITEM_TYPE_ARTICLE)
); );

View File

@ -22,12 +22,12 @@ class Archive {
return ''; return '';
$wall = ((array_key_exists('wall', $arr)) ? intval($arr['wall']) : 0); $wall = ((array_key_exists('wall', $arr)) ? intval($arr['wall']) : 0);
$wall = ((array_key_exists('articles', $arr)) ? 2 : $wall);
$style = ((array_key_exists('style', $arr)) ? $arr['style'] : 'select'); $style = ((array_key_exists('style', $arr)) ? $arr['style'] : 'select');
$showend = ((get_pconfig($uid,'system','archive_show_end_date')) ? true : false); $showend = ((get_pconfig($uid,'system','archive_show_end_date')) ? true : false);
$mindate = get_pconfig($uid,'system','archive_mindate'); $mindate = get_pconfig($uid,'system','archive_mindate');
$visible_years = get_pconfig($uid,'system','archive_visible_years'); $visible_years = get_pconfig($uid,'system','archive_visible_years',5);
if(! $visible_years)
$visible_years = 5;
$url = z_root() . '/' . \App::$cmd; $url = z_root() . '/' . \App::$cmd;

View File

@ -4,6 +4,13 @@
* @brief Channel related functions. * @brief Channel related functions.
*/ */
use Zotlabs\Access\PermissionRoles;
use Zotlabs\Access\PermissionLimits;
use Zotlabs\Access\Permissions;
use Zotlabs\Daemon\Master;
use Zotlabs\Lib\System;
use Zotlabs\Render\Comanche;
require_once('include/zot.php'); require_once('include/zot.php');
require_once('include/crypto.php'); require_once('include/crypto.php');
require_once('include/menu.php'); require_once('include/menu.php');
@ -236,7 +243,7 @@ function create_identity($arr) {
$role_permissions = null; $role_permissions = null;
if(array_key_exists('permissions_role',$arr) && $arr['permissions_role']) { if(array_key_exists('permissions_role',$arr) && $arr['permissions_role']) {
$role_permissions = \Zotlabs\Access\PermissionRoles::role_perms($arr['permissions_role']); $role_permissions = PermissionRoles::role_perms($arr['permissions_role']);
} }
if($role_permissions && array_key_exists('directory_publish',$role_permissions)) if($role_permissions && array_key_exists('directory_publish',$role_permissions))
@ -307,7 +314,7 @@ function create_identity($arr) {
$perm_limits = site_default_perms(); $perm_limits = site_default_perms();
foreach($perm_limits as $p => $v) foreach($perm_limits as $p => $v)
\Zotlabs\Access\PermissionLimits::Set($r[0]['channel_id'],$p,$v); PermissionLimits::Set($r[0]['channel_id'],$p,$v);
if($role_permissions && array_key_exists('perms_auto',$role_permissions)) if($role_permissions && array_key_exists('perms_auto',$role_permissions))
set_pconfig($r[0]['channel_id'],'system','autoperms',intval($role_permissions['perms_auto'])); set_pconfig($r[0]['channel_id'],'system','autoperms',intval($role_permissions['perms_auto']));
@ -383,7 +390,7 @@ function create_identity($arr) {
$myperms = ((array_key_exists('perms_connect',$role_permissions)) ? $role_permissions['perms_connect'] : array()); $myperms = ((array_key_exists('perms_connect',$role_permissions)) ? $role_permissions['perms_connect'] : array());
} }
else { else {
$x = \Zotlabs\Access\PermissionRoles::role_perms('social'); $x = PermissionRoles::role_perms('social');
$myperms = $x['perms_connect']; $myperms = $x['perms_connect'];
} }
@ -399,7 +406,7 @@ function create_identity($arr) {
] ]
); );
$x = \Zotlabs\Access\Permissions::FilledPerms($myperms); $x = Permissions::FilledPerms($myperms);
foreach($x as $k => $v) { foreach($x as $k => $v) {
set_abconfig($newuid,$hash,'my_perms',$k,$v); set_abconfig($newuid,$hash,'my_perms',$k,$v);
} }
@ -416,7 +423,7 @@ function create_identity($arr) {
$autoperms = intval($role_permissions['perms_auto']); $autoperms = intval($role_permissions['perms_auto']);
set_pconfig($newuid,'system','autoperms',$autoperms); set_pconfig($newuid,'system','autoperms',$autoperms);
if($autoperms) { if($autoperms) {
$x = \Zotlabs\Access\Permissions::FilledPerms($role_permissions['perms_connect']); $x = Permissions::FilledPerms($role_permissions['perms_connect']);
foreach($x as $k => $v) { foreach($x as $k => $v) {
set_pconfig($newuid,'autoperms',$k,$v); set_pconfig($newuid,'autoperms',$k,$v);
} }
@ -482,7 +489,7 @@ function create_identity($arr) {
*/ */
call_hooks('create_identity', $newuid); call_hooks('create_identity', $newuid);
Zotlabs\Daemon\Master::Summon(array('Directory', $ret['channel']['channel_id'])); Master::Summon(array('Directory', $ret['channel']['channel_id']));
} }
$ret['success'] = true; $ret['success'] = true;
@ -583,7 +590,7 @@ function change_channel_keys($channel) {
xchan_change_key($oldxchan,$newxchan,$stored); xchan_change_key($oldxchan,$newxchan,$stored);
Zotlabs\Daemon\Master::Summon(array('Notifier', 'keychange', $channel['channel_id'])); Master::Summon([ 'Notifier', 'keychange', $channel['channel_id'] ]);
$ret['success'] = true; $ret['success'] = true;
return $ret; return $ret;
@ -666,7 +673,7 @@ function channel_change_address($channel,$new_address) {
} }
} }
Zotlabs\Daemon\Master::Summon(array('Notifier', 'refresh_all', $channel['channel_id'])); Master::Summon(array('Notifier', 'refresh_all', $channel['channel_id']));
$ret['success'] = true; $ret['success'] = true;
return $ret; return $ret;
@ -759,7 +766,7 @@ function identity_basic_export($channel_id, $sections = null) {
'project' => PLATFORM_NAME, 'project' => PLATFORM_NAME,
'version' => STD_VERSION, 'version' => STD_VERSION,
'database' => DB_UPDATE_VERSION, 'database' => DB_UPDATE_VERSION,
'server_role' => Zotlabs\Lib\System::get_server_role() 'server_role' => System::get_server_role()
]; ];
/* /*
@ -1425,7 +1432,7 @@ function profile_sidebar($profile, $block = 0, $show_connect = true, $zcard = fa
} }
$menublock = get_pconfig($profile['uid'],'system','channel_menublock'); $menublock = get_pconfig($profile['uid'],'system','channel_menublock');
if ($menublock && (! $block)) { if ($menublock && (! $block)) {
$comanche = new Zotlabs\Render\Comanche(); $comanche = new Comanche();
$channel_menu .= $comanche->block($menublock); $channel_menu .= $comanche->block($menublock);
} }
@ -1701,7 +1708,7 @@ function zid_init() {
dbesc($tmp_str) dbesc($tmp_str)
); );
if(! $r) { if(! $r) {
Zotlabs\Daemon\Master::Summon(array('Gprobe',bin2hex($tmp_str))); Master::Summon(array('Gprobe',bin2hex($tmp_str)));
} }
if($r && remote_channel() && remote_channel() === $r[0]['hubloc_hash']) if($r && remote_channel() && remote_channel() === $r[0]['hubloc_hash'])
return; return;
@ -1907,7 +1914,7 @@ function is_public_profile() {
$channel = App::get_channel(); $channel = App::get_channel();
if($channel) { if($channel) {
$perm = \Zotlabs\Access\PermissionLimits::Get($channel['channel_id'],'view_profile'); $perm = PermissionLimits::Get($channel['channel_id'],'view_profile');
if($perm == PERMS_PUBLIC) if($perm == PERMS_PUBLIC)
return true; return true;
} }
@ -2545,7 +2552,7 @@ function channel_remove($channel_id, $local = true, $unset_session = false) {
dbesc($channel['channel_hash']) dbesc($channel['channel_hash'])
); );
Zotlabs\Daemon\Master::Summon(array('Notifier','purge_all',$channel_id)); Master::Summon(array('Notifier','purge_all',$channel_id));
} }
@ -2658,7 +2665,7 @@ function channel_remove($channel_id, $local = true, $unset_session = false) {
@rrmdir($f); @rrmdir($f);
} }
Zotlabs\Daemon\Master::Summon(array('Directory',$channel_id)); Master::Summon([ 'Directory', $channel_id ]);
if($channel_id == local_channel() && $unset_session) { if($channel_id == local_channel() && $unset_session) {
App::$session->nuke(); App::$session->nuke();

View File

@ -4,7 +4,13 @@
* @brief Items related functions. * @brief Items related functions.
*/ */
use Zotlabs\Lib as Zlib; use Zotlabs\Lib\Enotify;
use Zotlabs\Lib\MarkdownSoap;
use Zotlabs\Lib\MessageFilter;
use Zotlabs\Lib\IConfig;
use Zotlabs\Access\PermissionLimits;
use Zotlabs\Access\AccessList;
use Zotlabs\Daemon\Master;
require_once('include/bbcode.php'); require_once('include/bbcode.php');
require_once('include/oembed.php'); require_once('include/oembed.php');
@ -379,7 +385,7 @@ function post_activity_item($arr, $allow_code = false, $deliver = true) {
return $ret; return $ret;
} }
$arr['public_policy'] = ((array_key_exists('public_policy',$arr)) ? escape_tags($arr['public_policy']) : map_scope(\Zotlabs\Access\PermissionLimits::Get($channel['channel_id'],'view_stream'),true)); $arr['public_policy'] = ((array_key_exists('public_policy',$arr)) ? escape_tags($arr['public_policy']) : map_scope(PermissionLimits::Get($channel['channel_id'],'view_stream'),true));
if($arr['public_policy']) if($arr['public_policy'])
$arr['item_private'] = 1; $arr['item_private'] = 1;
@ -407,7 +413,7 @@ function post_activity_item($arr, $allow_code = false, $deliver = true) {
$arr['deny_gid'] = $channel['channel_deny_gid']; $arr['deny_gid'] = $channel['channel_deny_gid'];
} }
$arr['comment_policy'] = map_scope(\Zotlabs\Access\PermissionLimits::Get($channel['channel_id'],'post_comments')); $arr['comment_policy'] = map_scope(PermissionLimits::Get($channel['channel_id'],'post_comments'));
if ((! $arr['plink']) && (intval($arr['item_thread_top']))) { if ((! $arr['plink']) && (intval($arr['item_thread_top']))) {
$arr['plink'] = substr(z_root() . '/channel/' . $channel['channel_address'] . '/?f=&mid=' . urlencode($arr['mid']),0,190); $arr['plink'] = substr(z_root() . '/channel/' . $channel['channel_address'] . '/?f=&mid=' . urlencode($arr['mid']),0,190);
@ -446,7 +452,7 @@ function post_activity_item($arr, $allow_code = false, $deliver = true) {
} }
if($post_id && $deliver) { if($post_id && $deliver) {
Zotlabs\Daemon\Master::Summon(array('Notifier','activity',$post_id)); Master::Summon([ 'Notifier','activity',$post_id ]);
} }
$ret['success'] = true; $ret['success'] = true;
@ -744,7 +750,7 @@ function get_item_elements($x,$allow_code = false) {
// was generated on the escaped content. // was generated on the escaped content.
if($arr['mimetype'] === 'text/markdown') if($arr['mimetype'] === 'text/markdown')
$arr['body'] = \Zotlabs\Lib\MarkdownSoap::unescape($arr['body']); $arr['body'] = MarkdownSoap::unescape($arr['body']);
if(array_key_exists('revision',$x)) { if(array_key_exists('revision',$x)) {
@ -1003,7 +1009,7 @@ function encode_item($item,$mirror = false) {
); );
if($r) if($r)
$comment_scope = \Zotlabs\Access\PermissionLimits::Get($item['uid'],'post_comments'); $comment_scope = PermissionLimits::Get($item['uid'],'post_comments');
else else
$comment_scope = 0; $comment_scope = 0;
@ -2439,7 +2445,7 @@ function send_status_notifications($post_id,$item) {
return; return;
Zlib\Enotify::submit(array( Enotify::submit(array(
'type' => NOTIFY_COMMENT, 'type' => NOTIFY_COMMENT,
'from_xchan' => $item['author_xchan'], 'from_xchan' => $item['author_xchan'],
'to_xchan' => $r[0]['channel_hash'], 'to_xchan' => $r[0]['channel_hash'],
@ -2532,7 +2538,7 @@ function tag_deliver($uid, $item_id) {
$verb = urldecode(substr($item['verb'],strpos($item['verb'],'#')+1)); $verb = urldecode(substr($item['verb'],strpos($item['verb'],'#')+1));
if($poke_notify) { if($poke_notify) {
Zlib\Enotify::submit(array( Enotify::submit(array(
'to_xchan' => $u[0]['channel_hash'], 'to_xchan' => $u[0]['channel_hash'],
'from_xchan' => $item['author_xchan'], 'from_xchan' => $item['author_xchan'],
'type' => NOTIFY_POKE, 'type' => NOTIFY_POKE,
@ -2686,7 +2692,7 @@ function tag_deliver($uid, $item_id) {
* Kill two birds with one stone. As long as we're here, send a mention notification. * Kill two birds with one stone. As long as we're here, send a mention notification.
*/ */
Zlib\Enotify::submit(array( Enotify::submit(array(
'to_xchan' => $u[0]['channel_hash'], 'to_xchan' => $u[0]['channel_hash'],
'from_xchan' => $item['author_xchan'], 'from_xchan' => $item['author_xchan'],
'type' => NOTIFY_TAGSELF, 'type' => NOTIFY_TAGSELF,
@ -2988,7 +2994,7 @@ function start_delivery_chain($channel, $item, $item_id, $parent) {
$private = (($channel['channel_allow_cid'] || $channel['channel_allow_gid'] $private = (($channel['channel_allow_cid'] || $channel['channel_allow_gid']
|| $channel['channel_deny_cid'] || $channel['channel_deny_gid']) ? 1 : 0); || $channel['channel_deny_cid'] || $channel['channel_deny_gid']) ? 1 : 0);
$new_public_policy = map_scope(\Zotlabs\Access\PermissionLimits::Get($channel['channel_id'],'view_stream'),true); $new_public_policy = map_scope(PermissionLimits::Get($channel['channel_id'],'view_stream'),true);
if((! $private) && $new_public_policy) if((! $private) && $new_public_policy)
$private = 1; $private = 1;
@ -3031,7 +3037,7 @@ function start_delivery_chain($channel, $item, $item_id, $parent) {
dbesc($channel['channel_deny_gid']), dbesc($channel['channel_deny_gid']),
intval($private), intval($private),
dbesc($new_public_policy), dbesc($new_public_policy),
dbesc(map_scope(\Zotlabs\Access\PermissionLimits::Get($channel['channel_id'],'post_comments'))), dbesc(map_scope(PermissionLimits::Get($channel['channel_id'],'post_comments'))),
dbesc($title), dbesc($title),
dbesc($body), dbesc($body),
intval($item_wall), intval($item_wall),
@ -3040,7 +3046,7 @@ function start_delivery_chain($channel, $item, $item_id, $parent) {
); );
if($r) if($r)
Zotlabs\Daemon\Master::Summon(array('Notifier','tgroup',$item_id)); Master::Summon([ 'Notifier','tgroup',$item_id ]);
else { else {
logger('start_delivery_chain: failed to update item'); logger('start_delivery_chain: failed to update item');
// reset the source xchan to prevent loops // reset the source xchan to prevent loops
@ -3105,7 +3111,7 @@ function check_item_source($uid, $item) {
return true; return true;
} }
if (\Zotlabs\Lib\MessageFilter::evaluate($item, $r[0]['src_patt'], EMPTY_STR)) { if (MessageFilter::evaluate($item, $r[0]['src_patt'], EMPTY_STR)) {
logger('source: text filter success'); logger('source: text filter success');
return true; return true;
} }
@ -3128,7 +3134,7 @@ function post_is_importable($item,$abook) {
if(! ($abook['abook_incl'] || $abook['abook_excl'])) if(! ($abook['abook_incl'] || $abook['abook_excl']))
return true; return true;
return \Zotlabs\Lib\MessageFilter::evaluate($item,$abook['abook_incl'],$abook['abook_excl']); return MessageFilter::evaluate($item,$abook['abook_incl'],$abook['abook_excl']);
} }
@ -3264,7 +3270,7 @@ function mail_store($arr) {
'otype' => 'mail' 'otype' => 'mail'
); );
Zlib\Enotify::submit($notif_params); Enotify::submit($notif_params);
} }
if($arr['conv_guid']) { if($arr['conv_guid']) {
@ -3547,8 +3553,9 @@ function drop_items($items,$interactive = false,$stage = DROPITEM_NORMAL,$force
// multiple threads may have been deleted, send an expire notification // multiple threads may have been deleted, send an expire notification
if($uid) if($uid) {
Zotlabs\Daemon\Master::Summon(array('Notifier','expire',$uid)); Master::Summon([ 'Notifier','expire',$uid ]);
}
} }
@ -3656,8 +3663,9 @@ function drop_item($id,$interactive = true,$stage = DROPITEM_NORMAL,$force = fal
// We'll rely on the undocumented behaviour that DROPITEM_PHASE1 is (hopefully) only // We'll rely on the undocumented behaviour that DROPITEM_PHASE1 is (hopefully) only
// set if we know we're going to send delete notifications out to others. // set if we know we're going to send delete notifications out to others.
if((intval($item['item_wall']) && ($stage != DROPITEM_PHASE2)) || ($stage == DROPITEM_PHASE1)) if((intval($item['item_wall']) && ($stage != DROPITEM_PHASE2)) || ($stage == DROPITEM_PHASE1)) {
Zotlabs\Daemon\Master::Summon(array('Notifier','drop',$notify_id)); Master::Summon([ 'Notifier','drop',$notify_id ]);
}
goaway(z_root() . '/' . $_SESSION['return_url']); goaway(z_root() . '/' . $_SESSION['return_url']);
} }
@ -3781,21 +3789,34 @@ function delete_item_lowlevel($item, $stage = DROPITEM_NORMAL, $force = false) {
* @brief Return the first post date. * @brief Return the first post date.
* *
* @param int $uid * @param int $uid
* @param boolean $wall (optional) default false * @param boolean $wall (optional) no longer used
* @return string|boolean date string, otherwise false * @return string|boolean date string, otherwise false
*/ */
function first_post_date($uid, $wall = false) { function first_post_date($uid, $wall = false) {
$wall_sql = (($wall) ? " and item_wall = 1 " : "" ); $sql_extra = '';
$item_normal = item_normal();
switch(App::$module) {
case 'articles':
$sql_extra .= " and item_type = 7 ";
$item_normal = " and item.item_hidden = 0 and item.item_type = 7 and item.item_deleted = 0
and item.item_unpublished = 0 and item.item_delayed = 0 and item.item_pending_remove = 0
and item.item_blocked = 0 ";
break;
case 'channel':
$sql_extra = " and item_wall = 1 ";
default:
$item_normal = item_normal();
break;
}
$r = q("select id, created from item $r = q("select id, created from item
where uid = %d and id = parent $item_normal $wall_sql where uid = %d and id = parent $item_normal $sql_extra
order by created asc limit 1", order by created asc limit 1",
intval($uid) intval($uid)
); );
if($r) { if($r) {
// logger('first_post_date: ' . $r[0]['id'] . ' ' . $r[0]['created'], LOGGER_DATA);
return substr(datetime_convert('',date_default_timezone_get(),$r[0]['created']),0,10); return substr(datetime_convert('',date_default_timezone_get(),$r[0]['created']),0,10);
} }
@ -4393,7 +4414,7 @@ function update_remote_id($channel,$post_id,$webpage,$pagetitle,$namespace,$remo
// sixteen bytes of the mid - which makes the link portable and not quite as daunting // sixteen bytes of the mid - which makes the link portable and not quite as daunting
// as the entire mid. If it were the post_id the link would be less portable. // as the entire mid. If it were the post_id the link would be less portable.
\Zotlabs\Lib\IConfig::Set( IConfig::Set(
intval($post_id), intval($post_id),
'system', 'system',
$page_type, $page_type,
@ -4526,7 +4547,7 @@ function send_profile_photo_activity($channel,$photo,$profile) {
$arr['body'] = sprintf($t,$channel['channel_name'],$ptext) . "\n\n" . $ltext; $arr['body'] = sprintf($t,$channel['channel_name'],$ptext) . "\n\n" . $ltext;
$acl = new Zotlabs\Access\AccessList($channel); $acl = new AccessList($channel);
$x = $acl->get(); $x = $acl->get();
$arr['allow_cid'] = $x['allow_cid']; $arr['allow_cid'] = $x['allow_cid'];
@ -4757,7 +4778,7 @@ function item_create_edit_activity($post) {
} }
} }
\Zotlabs\Daemon\Master::Summon(array('Notifier', 'edit_activity', $post_id)); Master::Summon([ 'Notifier', 'edit_activity', $post_id ]);
} }
/** /**

View File

@ -1,4 +1,5 @@
[region=aside] [region=aside]
[widget=archive][var=articles]1[/var][/widget]
[widget=categories][var=articles]1[/var][/widget] [widget=categories][var=articles]1[/var][/widget]
[widget=tasklist][/widget] [widget=tasklist][/widget]
[widget=notes][/widget] [widget=notes][/widget]