aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/acl_selectors.php26
-rw-r--r--include/comanche.php3
-rw-r--r--include/deliver.php3
-rw-r--r--include/features.php106
-rw-r--r--include/follow.php7
-rw-r--r--include/identity.php4
-rw-r--r--include/notifier.php26
-rwxr-xr-xinclude/plugin.php16
-rw-r--r--include/poller.php2
-rw-r--r--include/queue_fn.php28
-rw-r--r--include/text.php26
-rw-r--r--include/widgets.php54
-rw-r--r--include/zot.php64
13 files changed, 225 insertions, 140 deletions
diff --git a/include/acl_selectors.php b/include/acl_selectors.php
index 4d44ec12e..3c8f34321 100644
--- a/include/acl_selectors.php
+++ b/include/acl_selectors.php
@@ -210,10 +210,13 @@ function fixacl(&$item) {
$item = str_replace(array('<','>'),array('',''),$item);
}
-function populate_acl($defaults = null,$show_jotnets = true) {
+function populate_acl($defaults = null,$show_jotnets = true, $showall = '') {
$allow_cid = $allow_gid = $deny_cid = $deny_gid = false;
+ if(! $showall)
+ $showall = t('Visible to your default audience');
+
if(is_array($defaults)) {
$allow_cid = ((strlen($defaults['allow_cid']))
? explode('><', $defaults['allow_cid']) : array() );
@@ -231,22 +234,21 @@ function populate_acl($defaults = null,$show_jotnets = true) {
$jotnets = '';
if($show_jotnets) {
-logger('jot_networks');
call_hooks('jot_networks', $jotnets);
}
$tpl = get_markup_template("acl_selector.tpl");
$o = replace_macros($tpl, array(
- '$showall'=> t("Visible to your default audience"),
- '$show' => t("Show"),
- '$hide' => t("Don't show"),
- '$allowcid' => json_encode($allow_cid),
- '$allowgid' => json_encode($allow_gid),
- '$denycid' => json_encode($deny_cid),
- '$denygid' => json_encode($deny_gid),
- '$jnetModalTitle' => t('Other networks and post services'),
- '$jotnets' => $jotnets,
- '$aclModalTitle' => t('Permissions'),
+ '$showall' => $showall,
+ '$show' => t("Show"),
+ '$hide' => t("Don't show"),
+ '$allowcid' => json_encode($allow_cid),
+ '$allowgid' => json_encode($allow_gid),
+ '$denycid' => json_encode($deny_cid),
+ '$denygid' => json_encode($deny_gid),
+ '$jnetModalTitle' => t('Other networks and post services'),
+ '$jotnets' => $jotnets,
+ '$aclModalTitle' => t('Permissions'),
'$aclModalDismiss' => t('Close')
));
diff --git a/include/comanche.php b/include/comanche.php
index 1537226ca..ca3ad336b 100644
--- a/include/comanche.php
+++ b/include/comanche.php
@@ -287,8 +287,7 @@ function comanche_widget($name, $text) {
if(! function_exists($func)) {
if(file_exists('widget/' . trim($name) . '.php'))
require_once('widget/' . trim($name) . '.php');
- elseif(folder_exists('widget/'. trim($name))
- && (file_exists('widget/' . trim($name) . '/' . trim($name) . '.php')))
+ elseif(file_exists('widget/' . trim($name) . '/' . trim($name) . '.php'))
require_once('widget/' . trim($name) . '/' . trim($name) . '.php');
}
else {
diff --git a/include/deliver.php b/include/deliver.php
index 7ff0fa125..40df543d5 100644
--- a/include/deliver.php
+++ b/include/deliver.php
@@ -31,6 +31,7 @@ function deliver_run($argv, $argc) {
if(($r[0]['outq_posturl'] === z_root() . '/post') && ($r[0]['outq_msg'])) {
logger('deliver: local delivery', LOGGER_DEBUG);
+
// local delivery
// we should probably batch these and save a few delivery processes
@@ -72,7 +73,7 @@ function deliver_run($argv, $argc) {
}
}
- // otherwise it's a remote delivery - call queue_deliver();
+ // otherwise it's a remote delivery - call queue_deliver() with the $immediate flag
queue_deliver($r[0],true);
diff --git a/include/features.php b/include/features.php
index 4e962b00e..3cbbf5b7d 100644
--- a/include/features.php
+++ b/include/features.php
@@ -5,12 +5,19 @@
*/
+
+
+
function feature_enabled($uid,$feature) {
- $x = get_pconfig($uid,'feature',$feature);
+
+ $x = get_config('feature_lock',$feature);
if($x === false) {
- $x = get_config('feature',$feature);
- if($x === false)
- $x = get_feature_default($feature);
+ $x = get_pconfig($uid,'feature',$feature);
+ if($x === false) {
+ $x = get_config('feature',$feature);
+ if($x === false)
+ $x = get_feature_default($feature);
+ }
}
$arr = array('uid' => $uid, 'feature' => $feature, 'enabled' => $x);
call_hooks('feature_enabled',$arr);
@@ -29,66 +36,87 @@ function get_feature_default($feature) {
}
-function get_features() {
+function get_features($filtered = true) {
$arr = array(
// General
'general' => array(
t('General Features'),
-// This is per post, and different from fixed expiration 'expire' which isn't working yet
- array('content_expire', t('Content Expiration'), t('Remove posts/comments and/or private messages at a future time'), false),
- array('multi_profiles', t('Multiple Profiles'), t('Ability to create multiple profiles'), false),
- array('advanced_profiles', t('Advanced Profiles'), t('Additional profile sections and selections'),false),
- array('profile_export', t('Profile Import/Export'), t('Save and load profile details across sites/channels'),false),
- array('webpages', t('Web Pages'), t('Provide managed web pages on your channel'),false),
- array('private_notes', t('Private Notes'), t('Enables a tool to store notes and reminders'),false),
- array('nav_channel_select', t('Navigation Channel Select'), t('Change channels directly from within the navigation dropdown menu'),false),
- array('photo_location', t('Photo Location'), t('If location data is available on uploaded photos, link this to a map.'),false),
-
- array('expert', t('Expert Mode'), t('Enable Expert Mode to provide advanced configuration options'),false),
- array('premium_channel', t('Premium Channel'), t('Allows you to set restrictions and terms on those that connect with your channel'),false),
+ // This is per post, and different from fixed expiration 'expire' which isn't working yet
+ array('content_expire', t('Content Expiration'), t('Remove posts/comments and/or private messages at a future time'), false, get_config('feature_lock','content_expire')),
+ array('multi_profiles', t('Multiple Profiles'), t('Ability to create multiple profiles'), false, get_config('feature_lock','multi_profiles')),
+ array('advanced_profiles', t('Advanced Profiles'), t('Additional profile sections and selections'),false,get_config('feature_lock','advanced_profiles')),
+ array('profile_export', t('Profile Import/Export'), t('Save and load profile details across sites/channels'),false,get_config('feature_lock','profile_export')),
+ array('webpages', t('Web Pages'), t('Provide managed web pages on your channel'),false,get_config('feature_lock','webpages')),
+ array('private_notes', t('Private Notes'), t('Enables a tool to store notes and reminders'),false,get_config('feature_lock','private_notes')),
+ array('nav_channel_select', t('Navigation Channel Select'), t('Change channels directly from within the navigation dropdown menu'),false,get_config('feature_lock','nav_channel_select')),
+ array('photo_location', t('Photo Location'), t('If location data is available on uploaded photos, link this to a map.'),false,get_config('feature_lock','photo_location')),
+
+ array('expert', t('Expert Mode'), t('Enable Expert Mode to provide advanced configuration options'),false,get_config('feature_lock','expert')),
+ array('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')),
),
// Post composition
'composition' => array(
t('Post Composition Features'),
-// array('richtext', t('Richtext Editor'), t('Enable richtext editor'),false),
- array('markdown', t('Use Markdown'), t('Allow use of "Markdown" to format posts'),false),
- array('large_photos', t('Large Photos'), t('Include large (1024px) photo thumbnails in posts. If not enabled, use small (640px) photo thumbnails'),false),
- array('channel_sources', t('Channel Sources'), t('Automatically import channel content from other channels or feeds'),false),
- array('content_encrypt', t('Even More Encryption'), t('Allow optional encryption of content end-to-end with a shared secret key'),false),
- array('consensus_tools', t('Enable Voting Tools'), t('Provide a class of post which others can vote on'),false),
- array('delayed_posting', t('Delayed Posting'), t('Allow posts to be published at a later date'),false),
- array('suppress_duplicates', t('Suppress Duplicate Posts/Comments'), t('Prevent posts with identical content to be published with less than two minutes in between submissions.'),true),
+// array('richtext', t('Richtext Editor'), t('Enable richtext editor'),falseget_config('feature_lock','richtext')),
+ array('markdown', t('Use Markdown'), t('Allow use of "Markdown" to format posts'),false,get_config('feature_lock','markdown')),
+ array('large_photos', t('Large Photos'), t('Include large (1024px) photo thumbnails in posts. If not enabled, use small (640px) photo thumbnails'),false,get_config('feature_lock','large_photos')),
+ array('channel_sources', t('Channel Sources'), t('Automatically import channel content from other channels or feeds'),false,get_config('feature_lock','channel_sources')),
+ array('content_encrypt', t('Even More Encryption'), t('Allow optional encryption of content end-to-end with a shared secret key'),false,get_config('feature_lock','content_encrypt')),
+ array('consensus_tools', t('Enable Voting Tools'), t('Provide a class of post which others can vote on'),false,get_config('feature_lock','consensus_tools')),
+ array('delayed_posting', t('Delayed Posting'), t('Allow posts to be published at a later date'),false,get_config('feature_lock','delayed_posting')),
+ array('suppress_duplicates', t('Suppress Duplicate Posts/Comments'), t('Prevent posts with identical content to be published with less than two minutes in between submissions.'),true,get_config('feature_lock','suppress_duplicates')),
),
// Network Tools
'net_module' => array(
t('Network and Stream Filtering'),
- array('archives', t('Search by Date'), t('Ability to select posts by date ranges'),false),
- array('groups', t('Collections Filter'), t('Enable widget to display Network posts only from selected collections'),false),
- array('savedsearch', t('Saved Searches'), t('Save search terms for re-use'),false),
- array('personal_tab', t('Network Personal Tab'), t('Enable tab to display only Network posts that you\'ve interacted on'),false),
- array('new_tab', t('Network New Tab'), t('Enable tab to display all new Network activity'),false),
- array('affinity', t('Affinity Tool'), t('Filter stream activity by depth of relationships'),false),
- array('connfilter', t('Connection Filtering'), t('Filter incoming posts from connections based on keywords/content')),
- array('suggest', t('Suggest Channels'), t('Show channel suggestions'),false),
+ array('archives', t('Search by Date'), t('Ability to select posts by date ranges'),false,get_config('feature_lock','archives')),
+ array('groups', t('Collections Filter'), t('Enable widget to display Network posts only from selected collections'),false,get_config('feature_lock','groups')),
+ array('savedsearch', t('Saved Searches'), t('Save search terms for re-use'),false,get_config('feature_lock','savedsearch')),
+ array('personal_tab', t('Network Personal Tab'), t('Enable tab to display only Network posts that you\'ve interacted on'),false,get_config('feature_lock','personal_tab')),
+ array('new_tab', t('Network New Tab'), t('Enable tab to display all new Network activity'),false,get_config('feature_lock','new_tab')),
+ array('affinity', t('Affinity Tool'), t('Filter stream activity by depth of relationships'),false,get_config('feature_lock','affinity')),
+ array('connfilter', t('Connection Filtering'), t('Filter incoming posts from connections based on keywords/content'),false,get_config('feature_lock','connfilter')),
+ array('suggest', t('Suggest Channels'), t('Show channel suggestions'),false,get_config('feature_lock','suggest')),
),
// Item tools
'tools' => array(
t('Post/Comment Tools'),
- array('commtag', t('Tagging'), t('Ability to tag existing posts'),false),
- array('categories', t('Post Categories'), t('Add categories to your posts'),false),
- array('filing', t('Saved Folders'), t('Ability to file posts under folders'),false),
- array('dislike', t('Dislike Posts'), t('Ability to dislike posts/comments'),false),
- array('star_posts', t('Star Posts'), t('Ability to mark special posts with a star indicator'),false),
- array('tagadelic', t('Tag Cloud'), t('Provide a personal tag cloud on your channel page'),false),
+ array('commtag', t('Community Tagging'), t('Ability to tag existing posts'),false,get_config('feature_lock','commtag')),
+ array('categories', t('Post Categories'), t('Add categories to your posts'),false,get_config('feature_lock','categories')),
+ array('filing', t('Saved Folders'), t('Ability to file posts under folders'),false,get_config('feature_lock','filing')),
+ array('dislike', t('Dislike Posts'), t('Ability to dislike posts/comments'),false,get_config('feature_lock','dislike')),
+ array('star_posts', t('Star Posts'), t('Ability to mark special posts with a star indicator'),false,get_config('feature_lock','star_posts')),
+ array('tagadelic', t('Tag Cloud'), t('Provide a personal tag cloud on your channel page'),false,get_config('feature_lock','tagedelic')),
),
);
+ // removed any locked features and remove the entire category if this makes it empty
+
+ if($filtered) {
+ foreach($arr as $k => $x) {
+ $has_items = false;
+ for($y = 0; $y < count($arr[$k]); $y ++) {
+ if(is_array($arr[$k][$y])) {
+ if($arr[$k][$y][4] === false) {
+ $has_items = true;
+ }
+ else {
+ unset($arr[$k][$y]);
+ }
+ }
+ }
+ if(! $has_items) {
+ unset($arr[$k]);
+ }
+ }
+ }
+
call_hooks('get_features',$arr);
return $arr;
}
diff --git a/include/follow.php b/include/follow.php
index 97be82da7..5e1146657 100644
--- a/include/follow.php
+++ b/include/follow.php
@@ -122,6 +122,7 @@ function new_contact($uid,$url,$channel,$interactive = false, $confirm = false)
else
$permissions = $j['permissions'];
+
foreach($permissions as $k => $v) {
if($v) {
$their_perms = $their_perms | intval($global_perms[$k][1]);
@@ -167,6 +168,7 @@ function new_contact($uid,$url,$channel,$interactive = false, $confirm = false)
}
}
+
if(! $xchan_hash) {
$result['message'] = t('Channel discovery failed.');
logger('follow: ' . $result['message']);
@@ -202,6 +204,7 @@ function new_contact($uid,$url,$channel,$interactive = false, $confirm = false)
$default_group = $r[0]['channel_default_group'];
}
+
if($is_http) {
@@ -226,6 +229,8 @@ function new_contact($uid,$url,$channel,$interactive = false, $confirm = false)
dbesc($xchan_hash),
intval($uid)
);
+
+
if($r) {
$abook_instance = $r[0]['abook_instance'];
@@ -242,7 +247,6 @@ function new_contact($uid,$url,$channel,$interactive = false, $confirm = false)
);
}
else {
-
$closeness = get_pconfig($uid,'system','new_abook_closeness');
if($closeness === false)
$closeness = 80;
@@ -270,6 +274,7 @@ function new_contact($uid,$url,$channel,$interactive = false, $confirm = false)
dbesc($xchan_hash),
intval($uid)
);
+
if($r) {
$result['abook'] = $r[0];
proc_run('php', 'include/notifier.php', 'permission_create', $result['abook']['abook_id']);
diff --git a/include/identity.php b/include/identity.php
index 98ba26bd8..cfedd243a 100644
--- a/include/identity.php
+++ b/include/identity.php
@@ -178,7 +178,7 @@ function create_identity($arr) {
$ret = array('success' => false);
if(! $arr['account_id']) {
- $ret['message'] = t('No account identifier');
+ $ret['message'] = t('No account identifier');
return $ret;
}
$ret = identity_check_service_class($arr['account_id']);
@@ -352,7 +352,7 @@ function create_identity($arr) {
);
if($role_permissions) {
- $myperms = ((array_key_exists('perms_auto',$role_permissions) && $role_permissions['perms_auto']) ? intval($role_permissions['perms_accept']) : 0);
+ $myperms = ((array_key_exists('perms_accept',$role_permissions)) ? intval($role_permissions['perms_accept']) : 0);
}
else
$myperms = PERMS_R_STREAM|PERMS_R_PROFILE|PERMS_R_PHOTOS|PERMS_R_ABOOK
diff --git a/include/notifier.php b/include/notifier.php
index 50981df9d..32d702cb5 100644
--- a/include/notifier.php
+++ b/include/notifier.php
@@ -188,6 +188,7 @@ function notifier_run($argv, $argc){
$recipients[] = $r[0]['abook_xchan'];
$private = false;
$packet_type = 'refresh';
+ $packet_recips = array(array('guid' => $r[0]['xchan_guid'],'guid_sig' => $r[0]['xchan_guid_sig'],'hash' => $r[0]['xchan_hash']));
}
}
}
@@ -297,7 +298,7 @@ function notifier_run($argv, $argc){
$channel = $s[0];
if($channel['channel_hash'] !== $target_item['author_xchan'] && $channel['channel_hash'] !== $target_item['owner_xchan']) {
- logger("notifier: Sending channel {$channel['channel_hash']} is not owner {$target_item['owner_xchan']} or author {$target_item['author_xchan']}");
+ logger("notifier: Sending channel {$channel['channel_hash']} is not owner {$target_item['owner_xchan']} or author {$target_item['author_xchan']}", LOGGER_NORMAL, LOG_WARNING);
return;
}
@@ -316,7 +317,7 @@ function notifier_run($argv, $argc){
return;
if(strpos($r[0]['postopts'],'nodeliver') !== false) {
- logger('notifier: target item is undeliverable', LOGGER_DEBUG);
+ logger('notifier: target item is undeliverable', LOGGER_DEBUG, LOG_NOTICE);
return;
}
@@ -352,8 +353,8 @@ function notifier_run($argv, $argc){
// $cmd === 'relay' indicates the owner is sending it to the original recipients
// don't allow the item in the relay command to relay to owner under any circumstances, it will loop
- logger('notifier: relay_to_owner: ' . (($relay_to_owner) ? 'true' : 'false'), LOGGER_DATA);
- logger('notifier: top_level_post: ' . (($top_level_post) ? 'true' : 'false'), LOGGER_DATA);
+ logger('notifier: relay_to_owner: ' . (($relay_to_owner) ? 'true' : 'false'), LOGGER_DATA, LOG_DEBUG);
+ logger('notifier: top_level_post: ' . (($top_level_post) ? 'true' : 'false'), LOGGER_DATA, LOG_DEBUG);
// tag_deliver'd post which needs to be sent back to the original author
@@ -395,7 +396,7 @@ function notifier_run($argv, $argc){
// TODO verify this is needed - copied logic from same place in old code
if(intval($target_item['item_deleted']) && (! intval($target_item['item_wall']))) {
- logger('notifier: ignoring delete notification for non-wall item');
+ logger('notifier: ignoring delete notification for non-wall item', LOGGER_NORMAL, LOG_NOTICE);
return;
}
}
@@ -410,13 +411,13 @@ function notifier_run($argv, $argc){
$x = $encoded_item;
$x['title'] = 'private';
$x['body'] = 'private';
- logger('notifier: encoded item: ' . print_r($x,true), LOGGER_DATA);
+ logger('notifier: encoded item: ' . print_r($x,true), LOGGER_DATA, LOG_DEBUG);
stringify_array_elms($recipients);
if(! $recipients)
return;
-// logger('notifier: recipients: ' . print_r($recipients,true));
+// logger('notifier: recipients: ' . print_r($recipients,true), LOGGER_NORMAL, LOG_DEBUG);
$env_recips = (($private) ? array() : null);
@@ -444,7 +445,7 @@ function notifier_run($argv, $argc){
if(($private) && (! $env_recips)) {
// shouldn't happen
- logger('notifier: private message with no envelope recipients.' . print_r($argv,true));
+ logger('notifier: private message with no envelope recipients.' . print_r($argv,true), LOGGER_NORMAL, LOG_NOTICE);
}
logger('notifier: recipients (may be delivered to more if public): ' . print_r($recip_list,true), LOGGER_DEBUG);
@@ -459,7 +460,7 @@ function notifier_run($argv, $argc){
if(! $r) {
- logger('notifier: no hubs');
+ logger('notifier: no hubs', LOGGER_NORMAL, LOG_NOTICE);
return;
}
@@ -482,7 +483,7 @@ function notifier_run($argv, $argc){
foreach($hubs as $hub) {
if(in_array($hub['hubloc_url'],$dead_hubs)) {
- logger('skipping dead hub: ' . $hub['hubloc_url'], LOGGER_DEBUG);
+ logger('skipping dead hub: ' . $hub['hubloc_url'], LOGGER_DEBUG, LOG_INFO);
continue;
}
@@ -502,7 +503,7 @@ function notifier_run($argv, $argc){
}
}
- logger('notifier: will notify/deliver to these hubs: ' . print_r($hublist,true), LOGGER_DEBUG);
+ logger('notifier: will notify/deliver to these hubs: ' . print_r($hublist,true), LOGGER_DEBUG, LOG_DEBUG);
foreach($dhubs as $hub) {
@@ -512,6 +513,7 @@ function notifier_run($argv, $argc){
$narr = array(
'channel' => $channel,
'env_recips' => $env_recips,
+ 'packet_recips' => $packet_recips,
'recipients' => $recipients,
'item' => $item,
'target_item' => $target_item,
@@ -547,7 +549,7 @@ function notifier_run($argv, $argc){
$packet = null;
if($packet_type === 'refresh' || $packet_type === 'purge') {
- $packet = zot_build_packet($channel,$packet_type);
+ $packet = zot_build_packet($channel,$packet_type,(($packet_recips) ? $packet_recips : null));
}
elseif($packet_type === 'request') {
$packet = zot_build_packet($channel,$packet_type,$env_recips,$hub['hubloc_sitekey'],$hash,
diff --git a/include/plugin.php b/include/plugin.php
index 4a35a0170..4da73dfd8 100755
--- a/include/plugin.php
+++ b/include/plugin.php
@@ -313,7 +313,6 @@ function call_hooks($name, &$data = null) {
* * Version: 1.2.3
* * Author: John <profile url>
* * Author: Jane <email>
- * * Compat: Red [(version)], Friendica [(version)]
* *
*\endcode
* @param string $plugin the name of the plugin
@@ -325,8 +324,8 @@ function get_plugin_info($plugin){
'name' => $plugin,
'description' => '',
'author' => array(),
- 'version' => '',
- 'compat' => ''
+ 'maintainer' => array(),
+ 'version' => ''
);
if (!is_file("addon/$plugin/$plugin.php"))
@@ -342,22 +341,23 @@ function get_plugin_info($plugin){
if ($l != ""){
list($k, $v) = array_map("trim", explode(":", $l, 2));
$k = strtolower($k);
- if ($k == 'author'){
+ if ($k == 'author' || $k == 'maintainer'){
$r = preg_match("|([^<]+)<([^>]+)>|", $v, $m);
if ($r) {
- $info['author'][] = array('name' => $m[1], 'link' => $m[2]);
+ $info[$k][] = array('name' => $m[1], 'link' => $m[2]);
} else {
- $info['author'][] = array('name' => $v);
+ $info[$k][] = array('name' => $v);
}
} else {
- if (array_key_exists($k, $info)){
+// if (array_key_exists($k, $info)){
$info[$k] = $v;
- }
+// }
}
}
}
}
+
return $info;
}
diff --git a/include/poller.php b/include/poller.php
index 031fb4533..808b54ee5 100644
--- a/include/poller.php
+++ b/include/poller.php
@@ -205,7 +205,7 @@ function poller_run($argv, $argc){
$keep_reports = intval(get_config('system','expire_delivery_reports'));
if($keep_reports === 0)
- $keep_reports = 30;
+ $keep_reports = 10;
q("delete from dreport where dreport_time < %s - INTERVAL %s",
db_utcnow(),
diff --git a/include/queue_fn.php b/include/queue_fn.php
index 1e53d7488..0708aab56 100644
--- a/include/queue_fn.php
+++ b/include/queue_fn.php
@@ -88,6 +88,7 @@ function queue_deliver($outq, $immediate = false) {
}
}
else {
+
// zot sites should all have a site record, unless they've been dead for as long as
// your site has existed. Since we don't know for sure what these sites are,
// call them unknown
@@ -100,6 +101,11 @@ function queue_deliver($outq, $immediate = false) {
}
}
+ $arr = array('outq' => $outq, 'handled' => false, 'immediate' => $immediate);
+ call_hooks('queue_deliver',$arr);
+ if($arr['handled'])
+ return;
+
// "post" queue driver - used for diaspora and friendica-over-diaspora communications.
if($outq['outq_driver'] === 'post') {
@@ -118,11 +124,31 @@ function queue_deliver($outq, $immediate = false) {
dbesc($outq['outq_hash'])
);
remove_queue_item($outq['outq_hash']);
+
+ // server is responding - see if anything else is going to this destination and is piled up
+ // and try to send some more. We're relying on the fact that delivery_loop() results in an
+ // immediate delivery otherwise we could get into a queue loop.
+
+ if(! $immediate) {
+ $x = q("select outq_hash from outq where outq_posturl = '%s' and outq_delivered = 0",
+ dbesc($outq['outq_posturl'])
+ );
+
+ $piled_up = array();
+ if($x) {
+ foreach($x as $xx) {
+ $piled_up[] = $xx['outq_hash'];
+ }
+ }
+ if($piled_up) {
+ delivery_loop($piled_up);
+ }
+ }
}
else {
logger('deliver: queue post returned ' . $result['return_code']
. ' from ' . $outq['outq_posturl'],LOGGER_DEBUG);
- update_queue_item($argv[$x]);
+ update_queue_item($outq['outq_posturl']);
}
return;
}
diff --git a/include/text.php b/include/text.php
index dd52b16b6..6f7297bb0 100644
--- a/include/text.php
+++ b/include/text.php
@@ -536,9 +536,10 @@ function attribute_contains($attr, $s) {
*
* @param string $msg Message to log
* @param int $level A log level.
+ * @param int $priority - compatible with syslog
*/
-function logger($msg, $level = 0) {
+function logger($msg, $level = LOGGER_NORMAL, $priority = LOG_INFO) {
// turn off logger in install mode
global $a;
global $db;
@@ -559,8 +560,8 @@ function logger($msg, $level = 0) {
$where = basename($stack[0]['file']) . ':' . $stack[0]['line'] . ':' . $stack[1]['function'] . ': ';
}
- $s = datetime_convert() . ':' . session_id() . ' ' . $where . $msg . PHP_EOL;
- $pluginfo = array('filename' => $logfile, 'loglevel' => $level, 'message' => $s,'logged' => false);
+ $s = datetime_convert() . ':' . log_priority_str($priority) . ':' . session_id() . ':' . $where . $msg . PHP_EOL;
+ $pluginfo = array('filename' => $logfile, 'loglevel' => $level, 'message' => $s,'priority' => $priority, 'logged' => false);
call_hooks('logger',$pluginfo);
@@ -568,6 +569,23 @@ function logger($msg, $level = 0) {
@file_put_contents($pluginfo['filename'], $pluginfo['message'], FILE_APPEND);
}
+function log_priority_str($priority) {
+ $parr = array(
+ LOG_EMERG => 'LOG_EMERG',
+ LOG_ALERT => 'LOG_ALERT',
+ LOG_CRIT => 'LOG_CRIT',
+ LOG_ERR => 'LOG_ERR',
+ LOG_WARNING => 'LOG_WARNING',
+ LOG_NOTICE => 'LOG_NOTICE',
+ LOG_INFO => 'LOG_INFO',
+ LOG_DEBUG => 'LOG_DEBUG'
+ );
+
+ if($parr[$priority])
+ return $parr[$priority];
+ return 'LOG_UNDEFINED';
+}
+
/**
* @brief This is a special logging facility for developers.
*
@@ -972,7 +990,7 @@ function get_mood_verbs() {
'tired' => t('tired'),
'perky' => t('perky'),
'angry' => t('angry'),
- 'stupefied' => t('stupified'),
+ 'stupefied' => t('stupefied'),
'puzzled' => t('puzzled'),
'interested' => t('interested'),
'bitter' => t('bitter'),
diff --git a/include/widgets.php b/include/widgets.php
index 4b14d6c94..a7d06d39e 100644
--- a/include/widgets.php
+++ b/include/widgets.php
@@ -493,38 +493,41 @@ function widget_settings_menu($arr) {
'selected' => ((argv(1) === 'channel') ? 'active' : ''),
),
- array(
- 'label' => t('Additional features'),
- 'url' => $a->get_baseurl(true).'/settings/features',
- 'selected' => ((argv(1) === 'features') ? 'active' : ''),
- ),
+ );
- array(
- 'label' => t('Feature/Addon settings'),
- 'url' => $a->get_baseurl(true).'/settings/featured',
- 'selected' => ((argv(1) === 'featured') ? 'active' : ''),
- ),
+ if(get_features()) {
+ $tabs[] = array(
+ 'label' => t('Additional features'),
+ 'url' => $a->get_baseurl(true).'/settings/features',
+ 'selected' => ((argv(1) === 'features') ? 'active' : ''),
+ );
+ }
- array(
- 'label' => t('Display settings'),
- 'url' => $a->get_baseurl(true).'/settings/display',
- 'selected' => ((argv(1) === 'display') ? 'active' : ''),
- ),
+ $tabs[] = array(
+ 'label' => t('Feature/Addon settings'),
+ 'url' => $a->get_baseurl(true).'/settings/featured',
+ 'selected' => ((argv(1) === 'featured') ? 'active' : ''),
+ );
- array(
- 'label' => t('Connected apps'),
- 'url' => $a->get_baseurl(true) . '/settings/oauth',
- 'selected' => ((argv(1) === 'oauth') ? 'active' : ''),
- ),
+ $tabs[] = array(
+ 'label' => t('Display settings'),
+ 'url' => $a->get_baseurl(true).'/settings/display',
+ 'selected' => ((argv(1) === 'display') ? 'active' : ''),
+ );
- array(
- 'label' => t('Export channel'),
- 'url' => $a->get_baseurl(true) . '/uexport',
- 'selected' => ''
- ),
+ $tabs[] = array(
+ 'label' => t('Connected apps'),
+ 'url' => $a->get_baseurl(true) . '/settings/oauth',
+ 'selected' => ((argv(1) === 'oauth') ? 'active' : ''),
+ );
+ $tabs[] = array(
+ 'label' => t('Export channel'),
+ 'url' => $a->get_baseurl(true) . '/uexport',
+ 'selected' => ''
);
+
if($role === false || $role === 'custom') {
$tabs[] = array(
'label' => t('Connection Default Permissions'),
@@ -1214,6 +1217,7 @@ function widget_admin($arr) {
'site' => array(z_root() . '/admin/site/', t('Site'), 'site'),
'users' => array(z_root() . '/admin/users/', t('Accounts'), 'users'),
'channels' => array(z_root() . '/admin/channels/', t('Channels'), 'channels'),
+ 'features' => array(z_root() . '/admin/features/', t('Features'), 'features'),
'plugins' => array(z_root() . '/admin/plugins/', t('Plugins'), 'plugins'),
'themes' => array(z_root() . '/admin/themes/', t('Themes'), 'themes'),
'queue' => array(z_root() . '/admin/queue', t('Inspect queue'), 'queue'),
diff --git a/include/zot.php b/include/zot.php
index 922637bc1..a644bbd06 100644
--- a/include/zot.php
+++ b/include/zot.php
@@ -142,7 +142,7 @@ function zot_build_packet($channel, $type = 'notify', $recipients = null, $remot
$data[$k] = $v;
}
- logger('zot_build_packet: ' . print_r($data,true), LOGGER_DATA);
+ logger('zot_build_packet: ' . print_r($data,true), LOGGER_DATA, LOG_DEBUG);
// Hush-hush ultra top-secret mode
@@ -194,7 +194,7 @@ function zot_finger($webbie, $channel = null, $autofallback = true) {
logger('zot_finger: no address :' . $webbie);
return array('success' => false);
}
- logger('using xchan_addr: ' . $xchan_addr, LOGGER_DATA);
+ logger('using xchan_addr: ' . $xchan_addr, LOGGER_DATA, LOG_DEBUG);
// potential issue here; the xchan_addr points to the primary hub.
// The webbie we were called with may not, so it might not be found
@@ -211,7 +211,7 @@ function zot_finger($webbie, $channel = null, $autofallback = true) {
if ($r[0]['hubloc_network'] && $r[0]['hubloc_network'] !== 'zot') {
logger('zot_finger: alternate network: ' . $webbie);
- logger('url: '.$url.', net: '.var_export($r[0]['hubloc_network'],true), LOGGER_DATA);
+ logger('url: '.$url.', net: '.var_export($r[0]['hubloc_network'],true), LOGGER_DATA, LOG_DEBUG);
return array('success' => false);
}
} else {
@@ -288,9 +288,9 @@ function zot_refresh($them, $channel = null, $force = false) {
return true;
}
- logger('zot_refresh: them: ' . print_r($them,true), LOGGER_DATA);
+ logger('zot_refresh: them: ' . print_r($them,true), LOGGER_DATA, LOG_DEBUG);
if ($channel)
- logger('zot_refresh: channel: ' . print_r($channel,true), LOGGER_DATA);
+ logger('zot_refresh: channel: ' . print_r($channel,true), LOGGER_DATA, LOG_DEBUG);
$url = null;
@@ -353,7 +353,7 @@ function zot_refresh($them, $channel = null, $force = false) {
$result = z_post_url($url . $rhs,$postvars);
- logger('zot_refresh: zot-info: ' . print_r($result,true), LOGGER_DATA);
+ logger('zot_refresh: zot-info: ' . print_r($result,true), LOGGER_DATA, LOG_DEBUG);
if ($result['success']) {
@@ -381,7 +381,7 @@ function zot_refresh($them, $channel = null, $force = false) {
$channel['channel_prvkey']);
if($permissions)
$permissions = json_decode($permissions,true);
- logger('decrypted permissions: ' . print_r($permissions,true), LOGGER_DATA);
+ logger('decrypted permissions: ' . print_r($permissions,true), LOGGER_DATA, LOG_DEBUG);
}
else
$permissions = $j['permissions'];
@@ -614,7 +614,7 @@ function zot_register_hub($arr) {
$x = z_fetch_url($url);
- logger('zot_register_hub: ' . print_r($x,true), LOGGER_DATA);
+ logger('zot_register_hub: ' . print_r($x,true), LOGGER_DATA, LOG_DEBUG);
if($x['success']) {
$record = json_decode($x['body'],true);
@@ -754,8 +754,8 @@ function import_xchan($arr,$ud_flags = UPDATE_FLAGS_UPDATED, $ud_arr = null) {
dbesc($xchan_hash)
);
- logger('import_xchan: update: existing: ' . print_r($r[0],true), LOGGER_DATA);
- logger('import_xchan: update: new: ' . print_r($arr,true), LOGGER_DATA);
+ logger('import_xchan: update: existing: ' . print_r($r[0],true), LOGGER_DATA, LOG_DEBUG);
+ logger('import_xchan: update: new: ' . print_r($arr,true), LOGGER_DATA, LOG_DEBUG);
$what .= 'xchan ';
$changed = true;
}
@@ -955,7 +955,7 @@ function import_xchan($arr,$ud_flags = UPDATE_FLAGS_UPDATED, $ud_arr = null) {
$ret['hash'] = $xchan_hash;
}
- logger('import_xchan: result: ' . print_r($ret,true), LOGGER_DATA);
+ logger('import_xchan: result: ' . print_r($ret,true), LOGGER_DATA, LOG_DEBUG);
return $ret;
}
@@ -980,7 +980,7 @@ function zot_process_response($hub, $arr, $outq) {
if (! $x) {
logger('zot_process_response: No json from ' . $hub);
- logger('zot_process_response: headers: ' . print_r($arr['header'],true), LOGGER_DATA);
+ logger('zot_process_response: headers: ' . print_r($arr['header'],true), LOGGER_DATA, LOG_DEBUG);
}
if(is_array($x) && array_key_exists('delivery_report',$x) && is_array($x['delivery_report'])) {
@@ -1015,7 +1015,7 @@ function zot_process_response($hub, $arr, $outq) {
// async messages remain in the queue until processed.
if(intval($outq['outq_async']))
- queue_set_delivered($outq['outq_hash'],$outq['outq_channel']);
+ remove_queue_item($outq['outq_hash'],$outq['outq_channel']);
logger('zot_process_response: ' . print_r($x,true), LOGGER_DEBUG);
}
@@ -1037,7 +1037,7 @@ function zot_process_response($hub, $arr, $outq) {
*/
function zot_fetch($arr) {
- logger('zot_fetch: ' . print_r($arr,true), LOGGER_DATA);
+ logger('zot_fetch: ' . print_r($arr,true), LOGGER_DATA, LOG_DEBUG);
$url = $arr['sender']['url'] . $arr['callback'];
@@ -1134,7 +1134,7 @@ function zot_import($arr, $sender_url) {
$i['notify'] = json_decode(crypto_unencapsulate($i['notify'],get_config('system','prvkey')),true);
}
- logger('zot_import: notify: ' . print_r($i['notify'],true), LOGGER_DATA);
+ logger('zot_import: notify: ' . print_r($i['notify'],true), LOGGER_DATA, LOG_DEBUG);
$hub = zot_gethub($i['notify']['sender']);
if((! $hub) || ($hub['hubloc_url'] != $sender_url)) {
@@ -1151,7 +1151,7 @@ function zot_import($arr, $sender_url) {
if(array_key_exists('message',$i) && array_key_exists('type',$i['message']) && $i['message']['type'] === 'rating') {
// rating messages are processed only by directory servers
- logger('Rating received: ' . print_r($arr,true), LOGGER_DATA);
+ logger('Rating received: ' . print_r($arr,true), LOGGER_DATA, LOG_DEBUG);
$result = process_rating_delivery($i['notify']['sender'],$i['message']);
continue;
}
@@ -1261,8 +1261,8 @@ function zot_import($arr, $sender_url) {
continue;
}
- logger('Activity received: ' . print_r($arr,true), LOGGER_DATA);
- logger('Activity recipients: ' . print_r($deliveries,true), LOGGER_DATA);
+ logger('Activity received: ' . print_r($arr,true), LOGGER_DATA, LOG_DEBUG);
+ logger('Activity recipients: ' . print_r($deliveries,true), LOGGER_DATA, LOG_DEBUG);
$relay = ((array_key_exists('flags',$i['message']) && in_array('relay',$i['message']['flags'])) ? true : false);
$result = process_delivery($i['notify']['sender'],$arr,$deliveries,$relay,false,$message_request);
@@ -1270,16 +1270,16 @@ function zot_import($arr, $sender_url) {
elseif($i['message']['type'] === 'mail') {
$arr = get_mail_elements($i['message']);
- logger('Mail received: ' . print_r($arr,true), LOGGER_DATA);
- logger('Mail recipients: ' . print_r($deliveries,true), LOGGER_DATA);
+ logger('Mail received: ' . print_r($arr,true), LOGGER_DATA, LOG_DEBUG);
+ logger('Mail recipients: ' . print_r($deliveries,true), LOGGER_DATA, LOG_DEBUG);
$result = process_mail_delivery($i['notify']['sender'],$arr,$deliveries);
}
elseif($i['message']['type'] === 'profile') {
$arr = get_profile_elements($i['message']);
- logger('Profile received: ' . print_r($arr,true), LOGGER_DATA);
- logger('Profile recipients: ' . print_r($deliveries,true), LOGGER_DATA);
+ logger('Profile received: ' . print_r($arr,true), LOGGER_DATA, LOG_DEBUG);
+ logger('Profile recipients: ' . print_r($deliveries,true), LOGGER_DATA, LOG_DEBUG);
$result = process_profile_delivery($i['notify']['sender'],$arr,$deliveries);
}
@@ -1288,16 +1288,16 @@ function zot_import($arr, $sender_url) {
$arr = $i['message'];
- logger('Channel sync received: ' . print_r($arr,true), LOGGER_DATA);
- logger('Channel sync recipients: ' . print_r($deliveries,true), LOGGER_DATA);
+ logger('Channel sync received: ' . print_r($arr,true), LOGGER_DATA, LOG_DEBUG);
+ logger('Channel sync recipients: ' . print_r($deliveries,true), LOGGER_DATA, LOG_DEBUG);
$result = process_channel_sync_delivery($i['notify']['sender'],$arr,$deliveries);
}
elseif($i['message']['type'] === 'location') {
$arr = $i['message'];
- logger('Location message received: ' . print_r($arr,true), LOGGER_DATA);
- logger('Location message recipients: ' . print_r($deliveries,true), LOGGER_DATA);
+ logger('Location message received: ' . print_r($arr,true), LOGGER_DATA, LOG_DEBUG);
+ logger('Location message recipients: ' . print_r($deliveries,true), LOGGER_DATA, LOG_DEBUG);
$result = process_location_delivery($i['notify']['sender'],$arr,$deliveries);
}
@@ -1483,7 +1483,7 @@ function public_recips($msg) {
}
}
- logger('public_recips: ' . print_r($r,true), LOGGER_DATA);
+ logger('public_recips: ' . print_r($r,true), LOGGER_DATA, LOG_DEBUG);
return $r;
}
@@ -1501,7 +1501,7 @@ function public_recips($msg) {
*/
function allowed_public_recips($msg) {
- logger('allowed_public_recips: ' . print_r($msg,true),LOGGER_DATA);
+ logger('allowed_public_recips: ' . print_r($msg,true),LOGGER_DATA, LOG_DEBUG);
if(array_key_exists('public_scope',$msg['message']))
$scope = $msg['message']['public_scope'];
@@ -2873,7 +2873,7 @@ function build_sync_packet($uid = 0, $packet = null, $groups_changed = false) {
logger('build_sync_packet');
if($packet)
- logger('packet: ' . print_r($packet, true),LOGGER_DATA);
+ logger('packet: ' . print_r($packet, true),LOGGER_DATA, LOG_DEBUG);
if(! $uid)
$uid = local_channel();
@@ -2967,7 +2967,7 @@ function build_sync_packet($uid = 0, $packet = null, $groups_changed = false) {
$interval = ((get_config('system','delivery_interval') !== false)
? intval(get_config('system','delivery_interval')) : 2 );
- logger('build_sync_packet: packet: ' . print_r($info,true), LOGGER_DATA);
+ logger('build_sync_packet: packet: ' . print_r($info,true), LOGGER_DATA, LOG_DEBUG);
foreach($synchubs as $hub) {
$hash = random_string();
@@ -3864,7 +3864,7 @@ function zotinfo($arr) {
function check_zotinfo($channel,$locations,&$ret) {
-// logger('locations: ' . print_r($locations,true),LOGGER_DATA);
+// logger('locations: ' . print_r($locations,true),LOGGER_DATA, LOG_DEBUG);
// This function will likely expand as we find more things to detect and fix.
// 1. Because magic-auth is reliant on it, ensure that the system channel has a valid hubloc
@@ -4085,7 +4085,7 @@ function zot_reply_pickup($data) {
$sitekey = $hubsite['hubloc_sitekey'];
- logger('mod_zot: Checking sitekey: ' . $sitekey, LOGGER_DATA);
+ logger('mod_zot: Checking sitekey: ' . $sitekey, LOGGER_DATA, LOG_DEBUG);
if(rsa_verify($data['callback'],base64url_decode($data['callback_sig']),$sitekey)) {
$forgery = false;