aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/channel.php8
-rw-r--r--include/connections.php6
-rw-r--r--include/conversation.php5
-rw-r--r--include/features.php26
-rw-r--r--include/import.php4
-rwxr-xr-xinclude/items.php10
-rw-r--r--include/network.php1
-rwxr-xr-xinclude/plugin.php63
-rw-r--r--include/taxonomy.php16
-rw-r--r--include/text.php2
-rw-r--r--include/zot.php11
11 files changed, 121 insertions, 31 deletions
diff --git a/include/channel.php b/include/channel.php
index 4a87ef602..5f87e587c 100644
--- a/include/channel.php
+++ b/include/channel.php
@@ -2725,7 +2725,7 @@ function anon_identity_init($reqvars) {
$hash = hash('md5',$anon_email);
- $x = q("select * from xchan where xchan_guid = '%s' and xchan_hash = '%s' and xchan_network = 'unknown' limit 1",
+ $x = q("select * from xchan where xchan_guid = '%s' and xchan_hash = '%s' and xchan_network = 'anon' limit 1",
dbesc($anon_email),
dbesc($hash)
);
@@ -2736,19 +2736,19 @@ function anon_identity_init($reqvars) {
'xchan_hash' => $hash,
'xchan_name' => $anon_name,
'xchan_url' => $anon_url,
- 'xchan_network' => 'unknown',
+ 'xchan_network' => 'anon',
'xchan_name_date' => datetime_convert()
]);
- $x = q("select * from xchan where xchan_guid = '%s' and xchan_hash = '%s' and xchan_network = 'unknown' limit 1",
+ $x = q("select * from xchan where xchan_guid = '%s' and xchan_hash = '%s' and xchan_network = 'anon' limit 1",
dbesc($anon_email),
dbesc($hash)
);
$photo = z_root() . '/' . get_default_profile_photo(300);
$photos = import_xchan_photo($photo,$hash);
- $r = q("update xchan set xchan_photo_date = '%s', xchan_photo_l = '%s', xchan_photo_m = '%s', xchan_photo_s = '%s', xchan_photo_mimetype = '%s' where xchan_guid = '%s' and xchan_hash = '%s' and xchan_network = 'unknown' ",
+ $r = q("update xchan set xchan_photo_date = '%s', xchan_photo_l = '%s', xchan_photo_m = '%s', xchan_photo_s = '%s', xchan_photo_mimetype = '%s' where xchan_guid = '%s' and xchan_hash = '%s' and xchan_network = 'anon' ",
dbesc(datetime_convert()),
dbesc($photos[0]),
dbesc($photos[1]),
diff --git a/include/connections.php b/include/connections.php
index 8d1b9e07f..e5bf07d96 100644
--- a/include/connections.php
+++ b/include/connections.php
@@ -110,6 +110,12 @@ function vcard_from_xchan($xchan, $observer = null, $mode = '') {
$connect = t('Connect');
}
+ // don't provide a connect button for transient or one-way identities
+
+ if(in_array($xchan['xchan_network'],['rss','anon','unknown']) || strpos($xchan['xchan_addr'],'guest:') === 0) {
+ $connect = false;
+ }
+
if(array_key_exists('channel_id',$xchan))
App::$profile_uid = $xchan['channel_id'];
diff --git a/include/conversation.php b/include/conversation.php
index ce0467770..3834d9866 100644
--- a/include/conversation.php
+++ b/include/conversation.php
@@ -1301,7 +1301,9 @@ function status_editor($a, $x, $popup = false) {
$id_select = '';
$webpage = ((x($x,'webpage')) ? $x['webpage'] : '');
-
+
+ $feature_auto_save_draft = ((feature_enabled($x['profile_uid'], 'auto_save_draft')) ? "true" : "false");
+
$tpl = get_markup_template('jot-header.tpl');
App::$page['htmlhead'] .= replace_macros($tpl, array(
@@ -1323,6 +1325,7 @@ function status_editor($a, $x, $popup = false) {
'$modalerroralbum' => t('Error getting album'),
'$nocomment_enabled' => t('Comments enabled'),
'$nocomment_disabled' => t('Comments disabled'),
+ '$auto_save_draft' => $feature_auto_save_draft,
));
$tpl = get_markup_template('jot.tpl');
diff --git a/include/features.php b/include/features.php
index 5481c37a4..c865f6754 100644
--- a/include/features.php
+++ b/include/features.php
@@ -44,7 +44,7 @@ function feature_level($feature,$def) {
return $def;
}
-function get_features($filtered = true) {
+function get_features($filtered = true, $level = (-1)) {
$account = \App::get_account();
@@ -246,14 +246,23 @@ function get_features($filtered = true) {
[
'oauth_clients',
- t('OAuth Clients'),
- t('Manage authenticatication tokens for mobile and remote apps.'),
+ t('OAuth1 Clients'),
+ t('Manage OAuth1 authenticatication tokens for mobile and remote apps.'),
false,
get_config('feature_lock','oauth_clients'),
feature_level('oauth_clients',1),
],
[
+ 'oauth2_clients',
+ t('OAuth2 Clients'),
+ t('Manage OAuth2 authenticatication tokens for mobile and remote apps.'),
+ false,
+ get_config('feature_lock','oauth2_clients'),
+ feature_level('oauth2_clients',1),
+ ],
+
+ [
'access_tokens',
t('Access Tokens'),
t('Create access tokens so that non-members can access private content.'),
@@ -341,6 +350,15 @@ function get_features($filtered = true) {
feature_level('suppress_duplicates',1),
],
+ [
+ 'auto_save_draft',
+ t('Auto-save drafts of posts and comments'),
+ t('Automatically saves post and comment drafts in local browser storage to help prevent accidental loss of compositions'),
+ true,
+ get_config('feature_lock','auto_save_draft'),
+ feature_level('auto_save_draft',1),
+ ],
+
],
// Network Tools
@@ -490,7 +508,7 @@ function get_features($filtered = true) {
$arr = $x['features'];
- $techlevel = get_account_techlevel();
+ $techlevel = (($level >= 0) ? $level : get_account_techlevel());
// removed any locked features and remove the entire category if this makes it empty
diff --git a/include/import.php b/include/import.php
index d8b7030b6..0d3fb8c32 100644
--- a/include/import.php
+++ b/include/import.php
@@ -99,7 +99,7 @@ function import_channel($channel, $account_id, $seize) {
}
if($clean) {
- create_table_from_array('channel',$clean);
+ channel_store_lowlevel($clean);
}
$r = q("select * from channel where channel_account_id = %d and channel_guid = '%s' limit 1",
@@ -180,7 +180,7 @@ function import_profiles($channel, $profiles) {
$profile['thumb'] = z_root() . '/photo/' . basename($profile['thumb']);
}
- create_table_from_array('profile', $profile);
+ profile_store_lowlevel($profile);
}
}
}
diff --git a/include/items.php b/include/items.php
index 6ddab9bf8..8bc4595b6 100755
--- a/include/items.php
+++ b/include/items.php
@@ -3504,11 +3504,14 @@ function item_getfeedattach($item) {
}
-function item_expire($uid,$days) {
+function item_expire($uid,$days,$comment_days = 7) {
if((! $uid) || ($days < 1))
return;
+ if(! $comment_days)
+ $comment_days = 7;
+
// $expire_network_only = save your own wall posts
// and just expire conversations started by others
// do not enable this until we can pass bulk delete messages through zot
@@ -3527,6 +3530,7 @@ function item_expire($uid,$days) {
$r = q("SELECT id FROM item
WHERE uid = %d
AND created < %s - INTERVAL %s
+ AND commented < %s - INTERVAL %s
AND item_retained = 0
AND item_thread_top = 1
AND resource_type = ''
@@ -3534,7 +3538,9 @@ function item_expire($uid,$days) {
$sql_extra $item_normal LIMIT $expire_limit ",
intval($uid),
db_utcnow(),
- db_quoteinterval(intval($days).' DAY')
+ db_quoteinterval(intval($days) . ' DAY'),
+ db_utcnow(),
+ db_quoteinterval(intval($comment_days) . ' DAY')
);
if(! $r)
diff --git a/include/network.php b/include/network.php
index a49e5920d..db9a7d00a 100644
--- a/include/network.php
+++ b/include/network.php
@@ -1607,6 +1607,7 @@ function get_site_info() {
'register_policy' => $register_policy[get_config('system','register_policy')],
'invitation_only' => (bool) intval(get_config('system','invitation_only')),
'directory_mode' => $directory_mode[get_config('system','directory_mode')],
+ 'directory_server' => get_config('system','directory_server'),
'language' => get_config('system','language'),
'rss_connections' => (bool) intval(get_config('system','feed_contacts')),
'expiration' => $site_expire,
diff --git a/include/plugin.php b/include/plugin.php
index 62d443ab8..4545e1e8d 100755
--- a/include/plugin.php
+++ b/include/plugin.php
@@ -7,6 +7,27 @@
/**
+ * @brief Handle errors in plugin calls
+ *
+ * @param string $plugin name of the addon
+ * @param string $error_text text of error
+ * @param bool $uninstall uninstall plugin
+ */
+function handleerrors_plugin($plugin,$notice,$log,$uninstall=false){
+ logger("Addons: [" . $plugin . "] Error: ".$log, LOGGER_ERROR);
+ if ($notice != '') {
+ notice("[" . $plugin . "] Error: ".$notice, LOGGER_ERROR);
+ }
+
+ if ($uninstall) {
+ $idx = array_search($plugin, \App::$plugins);
+ unset(\App::$plugins[$idx]);
+ uninstall_plugin($plugin);
+ set_config("system","addon", implode(", ",\App::$plugins));
+ }
+}
+
+/**
* @brief Unloads an addon.
*
* @param string $plugin name of the addon
@@ -17,7 +38,11 @@ function unload_plugin($plugin){
@include_once('addon/' . $plugin . '/' . $plugin . '.php');
if(function_exists($plugin . '_unload')) {
$func = $plugin . '_unload';
- $func();
+ try {
+ $func();
+ } catch (Exception $e) {
+ handleerrors_plugin($plugin,"Unable to unload.",$e->getMessage());
+ }
}
}
@@ -38,7 +63,11 @@ function uninstall_plugin($plugin) {
@include_once('addon/' . $plugin . '/' . $plugin . '.php');
if(function_exists($plugin . '_uninstall')) {
$func = $plugin . '_uninstall';
- $func();
+ try {
+ $func();
+ } catch (Exception $e) {
+ handleerrors_plugin($plugin,"Unable to uninstall.","Unable to run _uninstall : ".$e->getMessage());
+ }
}
q("DELETE FROM addon WHERE aname = '%s' ",
@@ -64,7 +93,12 @@ function install_plugin($plugin) {
@include_once('addon/' . $plugin . '/' . $plugin . '.php');
if(function_exists($plugin . '_install')) {
$func = $plugin . '_install';
- $func();
+ try {
+ $func();
+ } catch (Exception $e) {
+ handleerrors_plugin($plugin,"Install failed.","Install failed : ".$e->getMessage());
+ return;
+ }
}
$plugin_admin = (function_exists($plugin . '_plugin_admin') ? 1 : 0);
@@ -94,7 +128,12 @@ function load_plugin($plugin) {
@include_once('addon/' . $plugin . '/' . $plugin . '.php');
if(function_exists($plugin . '_load')) {
$func = $plugin . '_load';
- $func();
+ try {
+ $func();
+ } catch (Exception $e) {
+ handleerrors_plugin($plugin,"Unable to load.","FAILED loading : ".$e->getMessage(),true);
+ return;
+ }
// we can add the following with the previous SQL
// once most site tables have been updated.
@@ -108,7 +147,7 @@ function load_plugin($plugin) {
return true;
}
else {
- logger("Addons: FAILED loading " . $plugin);
+ logger("Addons: FAILED loading " . $plugin . " (missing _load function)");
return false;
}
}
@@ -160,11 +199,21 @@ function reload_plugins() {
if(function_exists($pl . '_unload')) {
$func = $pl . '_unload';
- $func();
+ try {
+ $func();
+ } catch (Exception $e) {
+ handleerrors_plugin($plugin,"","UNLOAD FAILED (uninstalling) : ".$e->getMessage(),true);
+ continue;
+ }
}
if(function_exists($pl . '_load')) {
$func = $pl . '_load';
- $func();
+ try {
+ $func();
+ } catch (Exception $e) {
+ handleerrors_plugin($plugin,"","LOAD FAILED (uninstalling): ".$e->getMessage(),true);
+ continue;
+ }
}
q("UPDATE addon SET tstamp = %d WHERE id = %d",
intval($t),
diff --git a/include/taxonomy.php b/include/taxonomy.php
index 4a3818096..d9bf3ecc4 100644
--- a/include/taxonomy.php
+++ b/include/taxonomy.php
@@ -212,8 +212,9 @@ function card_tagadelic($uid, $count = 0, $authors = '', $owner = '', $flags = 0
if(! perm_is_allowed($uid,get_observer_hash(),'view_pages'))
return array();
+ $item_normal = " and item.item_hidden = 0 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 and item.obj_type != 'http://purl.org/zot/activity/file' ";
- $item_normal = item_normal();
$sql_options = item_permissions_sql($uid);
$count = intval($count);
@@ -236,15 +237,16 @@ function card_tagadelic($uid, $count = 0, $authors = '', $owner = '', $flags = 0
// Fetch tags
+
$r = q("select term, count(term) as total from term left join item on term.oid = item.id
where term.uid = %d and term.ttype = %d
- and otype = %d and item_type = %d and item_private = 0
+ and otype = %d and item_type = %d
$sql_options $item_normal
group by term order by total desc %s",
intval($uid),
intval($type),
intval(TERM_OBJ_POST),
- intval($restrict),
+ intval(ITEM_TYPE_CARD),
((intval($count)) ? "limit $count" : '')
);
@@ -263,7 +265,9 @@ function article_tagadelic($uid, $count = 0, $authors = '', $owner = '', $flags
return array();
- $item_normal = item_normal();
+ $item_normal = " and item.item_hidden = 0 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 and item.obj_type != 'http://purl.org/zot/activity/file' ";
+
$sql_options = item_permissions_sql($uid);
$count = intval($count);
@@ -288,13 +292,13 @@ function article_tagadelic($uid, $count = 0, $authors = '', $owner = '', $flags
// Fetch tags
$r = q("select term, count(term) as total from term left join item on term.oid = item.id
where term.uid = %d and term.ttype = %d
- and otype = %d and item_type = %d and item_private = 0
+ and otype = %d and item_type = %d
$sql_options $item_normal
group by term order by total desc %s",
intval($uid),
intval($type),
intval(TERM_OBJ_POST),
- intval($restrict),
+ intval(ITEM_TYPE_ARTICLE),
((intval($count)) ? "limit $count" : '')
);
diff --git a/include/text.php b/include/text.php
index 255d02c7c..13c4bb819 100644
--- a/include/text.php
+++ b/include/text.php
@@ -2251,7 +2251,7 @@ function xchan_query(&$items, $abook = true, $effective_uid = 0) {
$chans = q("select xchan.*,hubloc.* from xchan left join hubloc on hubloc_hash = xchan_hash
where xchan_hash in (" . protect_sprintf(implode(',', $arr)) . ") and hubloc_primary = 1");
}
- $xchans = q("select * from xchan where xchan_hash in (" . protect_sprintf(implode(',',$arr)) . ") and xchan_network in ('rss','unknown')");
+ $xchans = q("select * from xchan where xchan_hash in (" . protect_sprintf(implode(',',$arr)) . ") and xchan_network in ('rss','unknown', 'anon')");
if(! $chans)
$chans = $xchans;
else
diff --git a/include/zot.php b/include/zot.php
index 25ea9b8fb..2ad43f0e5 100644
--- a/include/zot.php
+++ b/include/zot.php
@@ -3855,11 +3855,14 @@ function process_channel_sync_delivery($sender, $arr, $deliveries) {
intval($channel['channel_id'])
);
if(! $x) {
- q("insert into profile ( profile_guid, aid, uid ) values ('%s', %d, %d)",
- dbesc($profile['profile_guid']),
- intval($channel['channel_account_id']),
- intval($channel['channel_id'])
+ profile_store_lowlevel(
+ [
+ 'aid' => $channel['channel_account_id'],
+ 'uid' => $channel['channel_id'],
+ 'profile_guid' => $profile['profile_guid'],
+ ]
);
+
$x = q("select * from profile where profile_guid = '%s' and uid = %d limit 1",
dbesc($profile['profile_guid']),
intval($channel['channel_id'])