aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/acl_selectors.php7
-rw-r--r--include/attach.php125
-rw-r--r--include/channel.php14
-rw-r--r--include/conversation.php17
-rwxr-xr-xinclude/dba/dba_driver.php2
-rw-r--r--include/features.php17
-rw-r--r--include/help.php9
-rwxr-xr-xinclude/items.php65
-rw-r--r--include/photos.php3
-rwxr-xr-xinclude/plugin.php12
-rw-r--r--include/widgets.php4
-rw-r--r--include/zot.php21
12 files changed, 250 insertions, 46 deletions
diff --git a/include/acl_selectors.php b/include/acl_selectors.php
index 9bee942e2..362776b44 100644
--- a/include/acl_selectors.php
+++ b/include/acl_selectors.php
@@ -148,11 +148,6 @@ function populate_acl($defaults = null,$show_jotnets = true, $emptyACL_descripti
array_walk($deny_cid,'fixacl');
array_walk($deny_gid,'fixacl');
}
-
- $jotnets = '';
- if($show_jotnets) {
- call_hooks('jot_networks', $jotnets);
- }
$r = q("SELECT id, hash, gname FROM groups WHERE deleted = 0 AND uid = %d ORDER BY gname ASC",
intval(local_channel())
@@ -181,8 +176,6 @@ function populate_acl($defaults = null,$show_jotnets = true, $emptyACL_descripti
'$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'),
'$aclModalDesc' => $dialog_description,
'$aclModalDismiss' => t('Close'),
diff --git a/include/attach.php b/include/attach.php
index 172840b96..ae7d71dc7 100644
--- a/include/attach.php
+++ b/include/attach.php
@@ -1994,3 +1994,128 @@ function get_filename_by_cloudname($cloudname, $channel, $storepath) {
}
return null;
}
+
+/**
+ * attach_move()
+ * This function performs an in place directory-to-directory move of a stored attachment or photo.
+ * The data is physically moved in the store/nickname storage location and the paths adjusted
+ * in the attach structure (and if applicable the photo table). The new 'album name' is recorded
+ * for photos and will show up immediately there.
+ * This takes a channel_id, attach.hash of the file to move (this is the same as a photo resource_id), and
+ * the attach.hash of the new parent folder, which must already exist. If $new_folder_hash is blank or empty,
+ * the file is relocated to the root of the channel's storage area.
+ *
+ * @fixme: this operation is currently not synced to clones !!
+ */
+
+function attach_move($channel_id,$resource_id,$new_folder_hash) {
+
+ $c = channelx_by_n($channel_id);
+ if(! $c)
+ return false;
+
+ $r = q("select * from attach where hash = '%s' and uid = %d limit 1",
+ dbesc($resource_id),
+ intval($channel_id)
+ );
+ if(! $r)
+ return false;
+
+ $oldstorepath = $r[0]['content'];
+
+ if($new_folder_hash) {
+ $n = q("select * from attach where hash = '%s' and uid = %d limit 1",
+ dbesc($new_folder_hash),
+ intval($channel_id)
+ );
+ if(! $n)
+ return;
+ $newdirname = $n[0]['filename'];
+ $newstorepath = $n[0]['content'] . '/' . $resource_id;
+ }
+ else {
+ $newstorepath = 'store/' . $c['channel_address'] . '/' . $resource_id;
+ }
+
+ rename($oldstorepath,$newstorepath);
+
+ // duplicate detection. If 'overwrite' is specified, return false because we can't yet do that.
+
+ $filename = $r[0]['filename'];
+
+ $s = q("select filename, id, hash, filesize from attach where filename = '%s' and folder = '%s' ",
+ dbesc($filename),
+ dbesc($new_folder_hash)
+ );
+
+ if($s) {
+ $overwrite = get_pconfig($channel_id,'system','overwrite_dup_files');
+ if($overwrite) {
+ // @fixme
+ return;
+ }
+ else {
+ if(strpos($filename,'.') !== false) {
+ $basename = substr($filename,0,strrpos($filename,'.'));
+ $ext = substr($filename,strrpos($filename,'.'));
+ }
+ else {
+ $basename = $filename;
+ $ext = '';
+ }
+
+ $v = q("select filename from attach where ( filename = '%s' OR filename like '%s' ) and folder = '%s' ",
+ dbesc($basename . $ext),
+ dbesc($basename . '(%)' . $ext),
+ dbesc($new_folder_hash)
+ );
+
+ if($v) {
+ $x = 1;
+
+ do {
+ $found = false;
+ foreach($v as $vv) {
+ if($vv['filename'] === $basename . '(' . $x . ')' . $ext) {
+ $found = true;
+ break;
+ }
+ }
+ if($found)
+ $x++;
+ }
+ while($found);
+ $filename = $basename . '(' . $x . ')' . $ext;
+ }
+ else
+ $filename = $basename . $ext;
+ }
+ }
+
+ $t = q("update attach set content = '%s', folder = '%s', filename = '%s' where id = %d",
+ dbesc($newstorepath),
+ dbesc($new_folder_hash),
+ dbesc($filename),
+ intval($r[0]['id'])
+ );
+
+ if($r[0]['is_photo']) {
+ $t = q("update photo set album = '%s', filename = '%s' where resource_id = '%s' and uid = %d",
+ dbesc($newdirname),
+ dbesc($filename),
+ dbesc($resource_id),
+ intval($channel_id)
+ );
+
+ $t = q("update photo set content = '%s' where resource_id = '%s' and uid = %d and imgscale = 0",
+ dbesc($newstorepath),
+ dbesc($resource_id),
+ intval($channel_id)
+ );
+ }
+
+ return true;
+
+}
+
+
diff --git a/include/channel.php b/include/channel.php
index 1179697a4..2c892dbb9 100644
--- a/include/channel.php
+++ b/include/channel.php
@@ -1103,8 +1103,8 @@ function profile_sidebar($profile, $block = 0, $show_connect = true, $zcard = fa
require_once('include/widgets.php');
- if(! feature_enabled($profile['uid'],'hide_rating'))
- $z = widget_rating(array('target' => $profile['channel_hash']));
+// if(! feature_enabled($profile['uid'],'hide_rating'))
+ $z = widget_rating(array('target' => $profile['channel_hash']));
$o .= replace_macros($tpl, array(
'$zcard' => $zcard,
@@ -1381,6 +1381,11 @@ function zid($s,$address = '') {
if (! strlen($s) || strpos($s,'zid='))
return $s;
+ $m = parse_url($s);
+ $fragment = ((array_key_exists('fragment',$m) && $m['fragment']) ? $m['fragment'] : false);
+ if($fragment !== false)
+ $s = str_replace('#' . $fragment,'',$s);
+
$has_params = ((strpos($s,'?')) ? true : false);
$num_slashes = substr_count($s, '/');
if (! $has_params)
@@ -1401,6 +1406,11 @@ function zid($s,$address = '') {
else
$zurl = $s;
+ // put fragment at the end
+
+ if($fragment)
+ $zurl .= '#' . $fragment;
+
$arr = array('url' => $s, 'zid' => urlencode($myaddr), 'result' => $zurl);
call_hooks('zid', $arr);
diff --git a/include/conversation.php b/include/conversation.php
index 7d1473fe2..2e056b620 100644
--- a/include/conversation.php
+++ b/include/conversation.php
@@ -941,12 +941,9 @@ function item_photo_menu($item){
$clean_url = normalise_link($item['author-link']);
}
- $poco_rating = get_config('system','poco_rating_enable');
- // if unset default to enabled
- if($poco_rating === false)
- $poco_rating = true;
+ $rating_enabled = get_config('system','rating_enabled');
- $ratings_url = (($poco_rating) ? z_root() . '/ratings/' . urlencode($item['author_xchan']) : '');
+ $ratings_url = (($rating_enabled) ? z_root() . '/ratings/' . urlencode($item['author_xchan']) : '');
$post_menu = Array(
t("View Source") => $vsrc_link,
@@ -1200,8 +1197,6 @@ function status_editor($a, $x, $popup = false) {
$tpl = get_markup_template('jot.tpl');
- $jotplugins = '';
-
$preview = t('Preview');
if(x($x, 'hide_preview'))
$preview = '';
@@ -1218,8 +1213,14 @@ function status_editor($a, $x, $popup = false) {
if(! $cipher)
$cipher = 'aes256';
+ $jotplugins = '';
call_hooks('jot_tool', $jotplugins);
+ $jotnets = '';
+ if(x($x,'jotnets')) {
+ call_hooks('jot_networks', $jotnets);
+ }
+
$o .= replace_macros($tpl, array(
'$return_path' => ((x($x, 'return_path')) ? $x['return_path'] : App::$query_string),
'$action' => z_root() . '/item',
@@ -1276,6 +1277,8 @@ function status_editor($a, $x, $popup = false) {
'$preview' => $preview,
'$source' => ((x($x, 'source')) ? $x['source'] : ''),
'$jotplugins' => $jotplugins,
+ '$jotnets' => $jotnets,
+ '$jotnets_label' => t('Other networks and post services'),
'$defexpire' => $defexpire,
'$feature_expire' => $feature_expire,
'$expires' => t('Set expiration date'),
diff --git a/include/dba/dba_driver.php b/include/dba/dba_driver.php
index f6091f6e1..7225a9be2 100755
--- a/include/dba/dba_driver.php
+++ b/include/dba/dba_driver.php
@@ -62,6 +62,8 @@ class DBA {
if(is_object(self::$dba) && self::$dba->connected) {
+ if($server === 'localhost')
+ $port = $set_port;
$dns = ((self::$dbtype == DBTYPE_POSTGRES) ? 'postgres' : 'mysql')
. ':host=' . $server . (is_null($port) ? '' : ';port=' . $port)
. ';dbname=' . $db;
diff --git a/include/features.php b/include/features.php
index 356de35a2..4e86b7881 100644
--- a/include/features.php
+++ b/include/features.php
@@ -55,21 +55,18 @@ function get_features($filtered = true) {
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('wiki', t('Wiki'), t('Provide a wiki for your channel'),(($server_role === 'basic') ? false : true),get_config('feature_lock','wiki')),
- array('hide_rating', t('Hide Rating'), t('Hide the rating buttons on your channel and profile pages. Note: People can still rate you somewhere else.'),false,get_config('feature_lock','hide_rating')),
+// array('hide_rating', t('Hide Rating'), t('Hide the rating buttons on your channel and profile pages. Note: People can still rate you somewhere else.'),false,get_config('feature_lock','hide_rating')),
array('private_notes', t('Private Notes'), t('Enables a tool to store notes and reminders (note: not encrypted)'),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('ajaxchat', t('Access Controlled Chatrooms'), t('Provide chatrooms and chat services with access control.'),true,get_config('feature_lock','ajaxchat')),
array('smart_birthdays', t('Smart Birthdays'), t('Make birthday events timezone aware in case your friends are scattered across the planet.'),true,get_config('feature_lock','smart_birthdays')),
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'),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')),
@@ -106,6 +103,18 @@ function get_features($filtered = true) {
),
);
+
+
+ if(\Zotlabs\Lib\System::get_server_role() === 'pro') {
+ $arr['general'][] = [
+ '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')
+ ];
+ }
+
// removed any locked features and remove the entire category if this makes it empty
if($filtered) {
diff --git a/include/help.php b/include/help.php
index 7f57f3334..4bcc09670 100644
--- a/include/help.php
+++ b/include/help.php
@@ -40,8 +40,13 @@ function search_doc_files($s) {
$r = fetch_post_tags($r,true);
for($x = 0; $x < count($r); $x ++) {
-
- $r[$x]['text'] = $r[$x]['body'];
+ $position = stripos($r[$x]['body'], $s);
+ $dislen = 300;
+ $start = $position-floor($dislen/2);
+ if ( $start < 0) {
+ $start = 0;
+ }
+ $r[$x]['text'] = substr($r[$x]['body'], $start, $dislen);
$r[$x]['rank'] = 0;
if($r[$x]['term']) {
diff --git a/include/items.php b/include/items.php
index 0373dcb0d..53a7b7927 100755
--- a/include/items.php
+++ b/include/items.php
@@ -113,6 +113,26 @@ function collect_recipients($item, &$private_envelope) {
// if($policy === 'pub')
// $recipients[] = $sys['xchan_hash'];
}
+
+ // Add the authors of any posts in this thread, if they are known to us.
+ // This is specifically designed to forward wall-to-wall posts to the original author,
+ // in case they aren't a connection but have permission to write on our wall.
+ // This is important for issue tracker channels. It should be a no-op for most channels.
+ // Whether or not they will accept the delivery is not determined here, but should
+ // be taken into account by zot:process_delivery()
+
+ $r = q("select author_xchan from item where parent = %d",
+ intval($item['parent'])
+ );
+ if($r) {
+ foreach($r as $rv) {
+ if(! in_array($rv['author_xchan'],$recipients)) {
+ $recipients[] = $rv['author_xchan'];
+ }
+ }
+ }
+
+
}
// This is a somewhat expensive operation but important.
@@ -695,8 +715,9 @@ function get_item_elements($x,$allow_code = false) {
// hub and verify that they are legit - or else we're going to toss the post. We only need to do this
// once, and after that your hub knows them. Sure some info is in the post, but it's only a transit identifier
// and not enough info to be able to look you up from your hash - which is the only thing stored with the post.
-
- if(($xchan_hash = import_author_xchan($x['author'])) !== false)
+
+ $xchan_hash = import_author_xchan($x['author']);
+ if($xchan_hash)
$arr['author_xchan'] = $xchan_hash;
else
return array();
@@ -705,7 +726,8 @@ function get_item_elements($x,$allow_code = false) {
if($arr['author_xchan'] === make_xchan_hash($x['owner']['guid'],$x['owner']['guid_sig']))
$arr['owner_xchan'] = $arr['author_xchan'];
else {
- if(($xchan_hash = import_author_xchan($x['owner'])) !== false)
+ $xchan_hash = import_author_xchan($x['owner']);
+ if($xchan_hash)
$arr['owner_xchan'] = $xchan_hash;
else
return array();
@@ -1166,7 +1188,7 @@ function encode_item_xchan($xchan) {
$ret['name'] = $xchan['xchan_name'];
$ret['address'] = $xchan['xchan_addr'];
- $ret['url'] = (($xchan['hubloc_url']) ? $xchan['hubloc_url'] : $xchan['xchan_url']);
+ $ret['url'] = $xchan['xchan_url'];
$ret['network'] = $xchan['xchan_network'];
$ret['photo'] = array('mimetype' => $xchan['xchan_photo_mimetype'], 'src' => $xchan['xchan_photo_m']);
$ret['guid'] = $xchan['xchan_guid'];
@@ -1625,8 +1647,21 @@ function item_store($arr, $allow_exec = false, $deliver = true) {
$arr['commented'] = ((x($arr,'commented') !== false) ? datetime_convert('UTC','UTC',$arr['commented']) : datetime_convert());
$arr['comments_closed'] = ((x($arr,'comments_closed') !== false) ? datetime_convert('UTC','UTC',$arr['comments_closed']) : NULL_DATE);
- $arr['received'] = datetime_convert();
- $arr['changed'] = datetime_convert();
+ if($deliver) {
+ $arr['received'] = datetime_convert();
+ $arr['changed'] = datetime_convert();
+ }
+ else {
+
+ // When deliver flag is false, we are *probably* performing an import or bulk migration.
+ // If one updates the changed timestamp it will be made available to zotfeed and delivery
+ // will still take place through backdoor methods. Since these fields are rarely used
+ // otherwise, just preserve the original timestamp.
+
+ $arr['received'] = ((x($arr,'received') !== false) ? datetime_convert('UTC','UTC',$arr['received']) : datetime_convert());
+ $arr['changed'] = ((x($arr,'changed') !== false) ? datetime_convert('UTC','UTC',$arr['changed']) : datetime_convert());
+ }
+
$arr['location'] = ((x($arr,'location')) ? notags(trim($arr['location'])) : '');
$arr['coord'] = ((x($arr,'coord')) ? notags(trim($arr['coord'])) : '');
$arr['parent_mid'] = ((x($arr,'parent_mid')) ? notags(trim($arr['parent_mid'])) : '');
@@ -2033,8 +2068,22 @@ function item_store_update($arr,$allow_exec = false, $deliver = true) {
$arr['comments_closed'] = $orig[0]['comments_closed'];
$arr['commented'] = $orig[0]['commented'];
- $arr['received'] = datetime_convert();
- $arr['changed'] = datetime_convert();
+
+ if($deliver) {
+ $arr['received'] = datetime_convert();
+ $arr['changed'] = datetime_convert();
+ }
+ else {
+
+ // When deliver flag is false, we are *probably* performing an import or bulk migration.
+ // If one updates the changed timestamp it will be made available to zotfeed and delivery
+ // will still take place through backdoor methods. Since these fields are rarely used
+ // otherwise, just preserve the original timestamp.
+
+ $arr['received'] = $orig[0]['received'];
+ $arr['changed'] = $orig[0]['changed'];
+ }
+
$arr['route'] = ((array_key_exists('route',$arr)) ? trim($arr['route']) : $orig[0]['route']);
$arr['diaspora_meta'] = ((x($arr,'diaspora_meta')) ? $arr['diaspora_meta'] : $orig[0]['diaspora_meta']);
$arr['location'] = ((x($arr,'location')) ? notags(trim($arr['location'])) : $orig[0]['location']);
diff --git a/include/photos.php b/include/photos.php
index d14c12d84..a3018816c 100644
--- a/include/photos.php
+++ b/include/photos.php
@@ -588,6 +588,8 @@ function photos_album_rename($channel_id, $oldname, $newname) {
);
}
+
+
/**
* @brief
*
@@ -713,6 +715,7 @@ function profile_photo_set_profile_perms($uid, $profileid = 0) {
if($profileid) {
$r = q("SELECT photo, profile_guid, id, is_default, uid
FROM profile WHERE uid = %d and ( profile.id = %d OR profile.profile_guid = '%s') LIMIT 1",
+ intval($uid),
intval($profileid),
dbesc($profileid)
);
diff --git a/include/plugin.php b/include/plugin.php
index cb206d944..663d17959 100755
--- a/include/plugin.php
+++ b/include/plugin.php
@@ -404,6 +404,18 @@ function check_plugin_versions($info) {
return false;
}
}
+ if(array_key_exists('serverroles',$info)) {
+ $role = \Zotlabs\Lib\System::get_server_role();
+ if(! (
+ stristr($info['serverroles'],'*')
+ || stristr($info['serverroles'],'any')
+ || stristr($info['serverroles'],$role))) {
+ logger('serverrole limit: ' . $info['name'],LOGGER_NORMAL,LOG_WARNING);
+ return false;
+
+ }
+ }
+
if(array_key_exists('requires',$info)) {
$arr = explode(',',$info['requires']);
diff --git a/include/widgets.php b/include/widgets.php
index 68db74703..765cb4d42 100644
--- a/include/widgets.php
+++ b/include/widgets.php
@@ -1286,8 +1286,8 @@ function widget_random_block($arr) {
function widget_rating($arr) {
- $poco_rating = get_config('system','poco_rating_enable');
- if((! $poco_rating) && ($poco_rating !== false)) {
+ $rating_enabled = get_config('system','rating_enabled');
+ if(! $rating_enabled) {
return;
}
diff --git a/include/zot.php b/include/zot.php
index 01b29f74b..6187e8a61 100644
--- a/include/zot.php
+++ b/include/zot.php
@@ -3708,6 +3708,8 @@ function zotinfo($arr) {
}
}
+ $ztarget_hash = (($ztarget && $zsig) ? make_xchan_hash($ztarget,$zsig) : '' );
+
$r = null;
if(strlen($zhash)) {
@@ -3785,18 +3787,12 @@ function zotinfo($arr) {
}
else {
// check if it has characteristics of a public forum based on custom permissions.
- $t = q("select * from abconfig where abconfig.cat = 'my_perms' and abconfig.chan = %d and abconfig.xchan = '%s' and abconfig.k in ('tag_deliver', 'send_stream') ",
- intval($e['channel_id']),
- dbesc($e['channel_hash'])
- );
-
- $ch = 0;
-
- if($t) {
- foreach($t as $tt) {
- if($tt['k'] == 'tag_deliver' && $tt['v'] == 1)
+ $m = \Zotlabs\Access\Permissions::FilledAutoperms($e['channel_id']);
+ if($m) {
+ foreach($m as $k => $v) {
+ if($k == 'tag_deliver' && intval($v) == 1)
$ch ++;
- if($tt['k'] == 'send_stream' && $tt['v'] == 0)
+ if($k == 'send_stream' && intval($v) == 0)
$ch ++;
}
if($ch == 2)
@@ -3889,9 +3885,6 @@ function zotinfo($arr) {
$ret['follow_url'] = z_root() . '/follow?f=&url=%s';
- $ztarget_hash = (($ztarget && $zsig)
- ? make_xchan_hash($ztarget,$zsig)
- : '' );
$permissions = get_all_perms($e['channel_id'],$ztarget_hash,false);