aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/attach.php2
-rw-r--r--include/channel.php60
-rw-r--r--include/conversation.php22
-rw-r--r--include/group.php8
-rwxr-xr-xinclude/items.php304
-rw-r--r--include/message.php5
6 files changed, 207 insertions, 194 deletions
diff --git a/include/attach.php b/include/attach.php
index 179a57a90..2bb57722b 100644
--- a/include/attach.php
+++ b/include/attach.php
@@ -1366,7 +1366,7 @@ function attach_delete($channel_id, $resource, $is_photo = 0) {
return;
}
- $url = get_cloudpath($channel_id, $channel_address, $resource);
+ $url = get_cloud_url($channel_id, $channel_address, $resource);
$object = get_file_activity_object($channel_id, $resource, $url);
// If resource is a directory delete everything in the directory recursive
diff --git a/include/channel.php b/include/channel.php
index 6a6022aba..4f0e8ec6a 100644
--- a/include/channel.php
+++ b/include/channel.php
@@ -2527,19 +2527,43 @@ function channel_remove($channel_id, $local = true, $unset_session = false) {
}
}
+ q("DELETE FROM app WHERE app_channel = %d", intval($channel_id));
+ q("DELETE FROM atoken WHERE atoken_uid = %d", intval($channel_id));
+ q("DELETE FROM chatroom WHERE cr_uid = %d", intval($channel_id));
+ q("DELETE FROM conv WHERE uid = %d", intval($channel_id));
q("DELETE FROM groups WHERE uid = %d", intval($channel_id));
q("DELETE FROM group_member WHERE uid = %d", intval($channel_id));
q("DELETE FROM event WHERE uid = %d", intval($channel_id));
- q("DELETE FROM item WHERE uid = %d", intval($channel_id));
q("DELETE FROM mail WHERE channel_id = %d", intval($channel_id));
+ q("DELETE FROM menu WHERE menu_channel_id = %d", intval($channel_id));
+ q("DELETE FROM menu_item WHERE mitem_channel_id = %d", intval($channel_id));
+
q("DELETE FROM notify WHERE uid = %d", intval($channel_id));
+ q("DELETE FROM obj WHERE obj_channel = %d", intval($channel_id));
+
+
q("DELETE FROM photo WHERE uid = %d", intval($channel_id));
q("DELETE FROM attach WHERE uid = %d", intval($channel_id));
q("DELETE FROM profile WHERE uid = %d", intval($channel_id));
- q("DELETE FROM pconfig WHERE uid = %d", intval($channel_id));
+ q("DELETE FROM src WHERE src_channel_id = %d", intval($channel_id));
+
+ $r = q("select resource_id FROM attach WHERE uid = %d", intval($channel_id));
+ if($r) {
+ foreach($r as $rv) {
+ attach_delete($channel_id,$rv['resource_id']);
+ }
+ }
+
+
+
+ $r = q("select id from item where uid = %d", intval($channel_id));
+ if($r) {
+ foreach($r as $rv) {
+ drop_item($rv['id'],false);
+ }
+ }
- /// @FIXME At this stage we need to remove the file resources located under /store/$nickname
q("delete from abook where abook_xchan = '%s' and abook_self = 1 ",
dbesc($channel['channel_hash'])
@@ -2593,19 +2617,11 @@ function channel_remove($channel_id, $local = true, $unset_session = false) {
}
//remove from file system
- $r = q("select channel_address from channel where channel_id = %d limit 1",
- intval($channel_id)
- );
- if($r) {
- $channel_address = $r[0]['channel_address'] ;
- }
- if($channel_address) {
- $f = 'store/' . $channel_address.'/';
- logger('delete '. $f);
- if(is_dir($f)) {
- @rrmdir($f);
- }
+
+ $f = 'store/' . $channel['channel_address'];
+ if(is_dir($f)) {
+ @rrmdir($f);
}
Zotlabs\Daemon\Master::Summon(array('Directory',$channel_id));
@@ -2616,6 +2632,20 @@ function channel_remove($channel_id, $local = true, $unset_session = false) {
}
}
+// execute this at least a week after removing a channel
+
+function channel_remove_final($channel_id) {
+
+ q("delete from abook where abook_channel = %d", intval($channel_id));
+ q("delete from abconfig where chan = %d", intval($channel_id));
+ q("delete from pconfig where uid = %d", intval($channel_id));
+
+
+}
+
+
+
+
/**
* @brief This checks if a channel is allowed to publish executable code.
*
diff --git a/include/conversation.php b/include/conversation.php
index 0b9df5acd..1cbd9116c 100644
--- a/include/conversation.php
+++ b/include/conversation.php
@@ -573,22 +573,16 @@ function conversation($items, $mode, $update, $page_mode = 'traditional', $prepa
if (! feature_enabled($profile_owner,'multi_delete'))
$page_dropping = false;
- $uploading = true;
-
- if($profile_owner > 0) {
- $owner_channel = channelx_by_n($profile_owner);
- if($owner_channel['channel_allow_cid'] || $owner_channel['channel_allow_gid']
- || $owner_channel['channel_deny_cid'] || $owner_channel['channel_deny_gid']) {
- $uploading = false;
- }
- if(\Zotlabs\Access\PermissionLimits::Get($profile_owner,'view_storage') !== PERMS_PUBLIC) {
- $uploading = false;
+ $uploading = false;
+
+ if(local_channel()) {
+ $cur_channel = App::get_channel();
+ if($cur_channel['channel_allow_cid'] === '' && $cur_channel['channel_allow_gid'] === ''
+ && $cur_channel['channel_deny_cid'] === '' && $cur_channel['channel_deny_gid'] === ''
+ && intval(\Zotlabs\Access\PermissionLimits::Get(local_channel(),'view_storage')) === PERMS_PUBLIC) {
+ $uploading = true;
}
}
- else {
- $uploading = false;
- }
-
$channel = App::get_channel();
$observer = App::get_observer();
diff --git a/include/group.php b/include/group.php
index e0c20b536..03ebf7ee5 100644
--- a/include/group.php
+++ b/include/group.php
@@ -18,10 +18,6 @@ function group_add($uid,$name,$public = 0) {
intval($r)
);
if(($z) && $z[0]['deleted']) {
- /*$r = q("UPDATE groups SET deleted = 0 WHERE uid = %d AND gname = '%s'",
- intval($uid),
- dbesc($name)
- );*/
q('UPDATE groups SET deleted = 0 WHERE id = %d', intval($z[0]['id']));
notice( t('A deleted group with this name was revived. Existing item permissions <strong>may</strong> apply to this group and any future members. If this is not what you intended, please create another group with a different name.') . EOL);
}
@@ -81,11 +77,11 @@ function group_rmv($uid,$name) {
$user_info['channel_default_group'] = '';
$change = true;
}
- if(strpos($user_info['channel_allow_gid'], '<' . $group_id . '>') !== false) {
+ if(strpos($user_info['channel_allow_gid'], '<' . $group_hash . '>') !== false) {
$user_info['channel_allow_gid'] = str_replace('<' . $group_hash . '>', '', $user_info['channel_allow_gid']);
$change = true;
}
- if(strpos($user_info['channel_deny_gid'], '<' . $group_id . '>') !== false) {
+ if(strpos($user_info['channel_deny_gid'], '<' . $group_hash . '>') !== false) {
$user_info['channel_deny_gid'] = str_replace('<' . $group_hash . '>', '', $user_info['channel_deny_gid']);
$change = true;
}
diff --git a/include/items.php b/include/items.php
index 5d592c736..b1b40e977 100755
--- a/include/items.php
+++ b/include/items.php
@@ -2571,148 +2571,149 @@ function tag_deliver($uid, $item_id) {
if($terms)
logger('Post mentions: ' . print_r($terms,true), LOGGER_DATA);
+
+ $max_forums = get_config('system','max_tagged_forums',2);
+ $matched_forums = 0;
+
+
$link = normalise_link($u[0]['xchan_url']);
+
if($terms) {
foreach($terms as $term) {
- if(link_compare($term['url'],$link)) {
- $mention = true;
- break;
+ if(! link_compare($term['url'],$link)) {
+ continue;
}
- }
- }
- if($mention) {
- logger('Mention found for ' . $u[0]['channel_name']);
+ $mention = true;
- $r = q("update item set item_mentionsme = 1 where id = %d",
- intval($item_id)
- );
+ logger('Mention found for ' . $u[0]['channel_name']);
- // At this point we've determined that the person receiving this post was mentioned in it or it is a union.
- // Now let's check if this mention was inside a reshare so we don't spam a forum
- // If it's private we may have to unobscure it momentarily so that we can parse it.
+ $r = q("update item set item_mentionsme = 1 where id = %d",
+ intval($item_id)
+ );
- $body = $item['body'];
+ // At this point we've determined that the person receiving this post was mentioned in it or it is a union.
+ // Now let's check if this mention was inside a reshare so we don't spam a forum
+ // If it's private we may have to unobscure it momentarily so that we can parse it.
- $body = preg_replace('/\[share(.*?)\[\/share\]/','',$body);
+ $body = preg_replace('/\[share(.*?)\[\/share\]/','',$item['body']);
- $tagged = false;
- $plustagged = false;
- $matches = array();
+ $tagged = false;
+ $plustagged = false;
+ $matches = array();
- $pattern = '/[\!@]\!?\[zrl\=' . preg_quote($term['url'],'/') . '\]' . preg_quote($term['term'],'/') . '\[\/zrl\]/';
- if(preg_match($pattern,$body,$matches))
- $tagged = true;
+ $pattern = '/[\!@]\!?\[zrl\=' . preg_quote($term['url'],'/') . '\]' . preg_quote($term['term'],'/') . '\[\/zrl\]/';
+ if(preg_match($pattern,$body,$matches))
+ $tagged = true;
- // original red forum tagging sequence @forumname+
- // standard forum tagging sequence !forumname
+ // original red forum tagging sequence @forumname+
+ // standard forum tagging sequence !forumname
- $pluspattern = '/@\!?\[zrl\=([^\]]*?)\]((?:.(?!\[zrl\=))*?)\+\[\/zrl\]/';
+ $pluspattern = '/@\!?\[zrl\=([^\]]*?)\]((?:.(?!\[zrl\=))*?)\+\[\/zrl\]/';
- $forumpattern = '/\!\!?\[zrl\=([^\]]*?)\]((?:.(?!\[zrl\=))*?)\[\/zrl\]/';
+ $forumpattern = '/\!\!?\[zrl\=([^\]]*?)\]((?:.(?!\[zrl\=))*?)\[\/zrl\]/';
- $found = false;
+ $found = false;
- $max_forums = get_config('system','max_tagged_forums');
- if(! $max_forums)
- $max_forums = 2;
- $matched_forums = 0;
- $matches = array();
+ $matches = array();
- if(preg_match_all($pluspattern,$body,$matches,PREG_SET_ORDER)) {
- foreach($matches as $match) {
- $matched_forums ++;
- if($term['url'] === $match[1] && $term['term'] === $match[2]) {
- if($matched_forums <= $max_forums) {
- $plustagged = true;
- $found = true;
- break;
+ if(preg_match_all($pluspattern,$body,$matches,PREG_SET_ORDER)) {
+ foreach($matches as $match) {
+ $matched_forums ++;
+ if($term['url'] === $match[1] && $term['term'] === $match[2] && intval($term['ttype']) === TERM_MENTION) {
+ if($matched_forums <= $max_forums) {
+ $plustagged = true;
+ $found = true;
+ break;
+ }
+ logger('forum ' . $term['term'] . ' exceeded max_tagged_forums - ignoring');
}
- logger('forum ' . $term['term'] . ' exceeded max_tagged_forums - ignoring');
}
}
- }
- if(preg_match_all($forumpattern,$body,$matches,PREG_SET_ORDER)) {
- foreach($matches as $match) {
- $matched_forums ++;
- if($term['url'] === $match[1] && $term['term'] === $match[2]) {
- if($matched_forums <= $max_forums) {
- $plustagged = true;
- $found = true;
- break;
+ if(preg_match_all($forumpattern,$body,$matches,PREG_SET_ORDER)) {
+ foreach($matches as $match) {
+ $matched_forums ++;
+ if($term['url'] === $match[1] && $term['term'] === $match[2] && intval($term['ttype']) === TERM_FORUM) {
+ if($matched_forums <= $max_forums) {
+ $plustagged = true;
+ $found = true;
+ break;
+ }
+ logger('forum ' . $term['term'] . ' exceeded max_tagged_forums - ignoring');
}
- logger('forum ' . $term['term'] . ' exceeded max_tagged_forums - ignoring');
}
}
- }
- if(! ($tagged || $plustagged)) {
- logger('Mention was in a reshare or exceeded max_tagged_forums - ignoring');
- return;
- }
+ if(! ($tagged || $plustagged)) {
+ logger('Mention was in a reshare or exceeded max_tagged_forums - ignoring');
+ continue;
+ }
- $arr = [
- 'channel_id' => $uid,
- 'item' => $item,
- 'body' => $body
- ];
- /**
- * @hooks tagged
- * Called when a delivery is processed which results in you being tagged.
- * * \e number \b channel_id
- * * \e array \b item
- * * \e string \b body
- */
- call_hooks('tagged', $arr);
+ $arr = [
+ 'channel_id' => $uid,
+ 'item' => $item,
+ 'body' => $body
+ ];
+ /**
+ * @hooks tagged
+ * Called when a delivery is processed which results in you being tagged.
+ * * \e number \b channel_id
+ * * \e array \b item
+ * * \e string \b body
+ */
+ call_hooks('tagged', $arr);
+
+ /*
+ * 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(
+ 'to_xchan' => $u[0]['channel_hash'],
+ 'from_xchan' => $item['author_xchan'],
+ 'type' => NOTIFY_TAGSELF,
+ 'item' => $item,
+ 'link' => $i[0]['llink'],
+ 'verb' => ACTIVITY_TAG,
+ 'otype' => 'item'
+ ));
- Zlib\Enotify::submit(array(
- 'to_xchan' => $u[0]['channel_hash'],
- 'from_xchan' => $item['author_xchan'],
- 'type' => NOTIFY_TAGSELF,
- 'item' => $item,
- 'link' => $i[0]['llink'],
- 'verb' => ACTIVITY_TAG,
- 'otype' => 'item'
- ));
-
- // Just a normal tag?
-
- if(! $plustagged) {
- logger('Not a plus tag', LOGGER_DEBUG);
- return;
- }
+ // Just a normal tag?
- // plustagged - keep going, next check permissions
+ if(! $plustagged) {
+ logger('Not a plus tag', LOGGER_DEBUG);
+ continue;
+ }
- if(! perm_is_allowed($uid,$item['author_xchan'],'tag_deliver')) {
- logger('tag_delivery denied for uid ' . $uid . ' and xchan ' . $item['author_xchan']);
- return;
- }
- }
+ // plustagged - keep going, next check permissions
+
+ if(! perm_is_allowed($uid,$item['author_xchan'],'tag_deliver')) {
+ logger('tag_delivery denied for uid ' . $uid . ' and xchan ' . $item['author_xchan']);
+ continue;
+ }
- if((! $mention) && (! $union)) {
- logger('No mention for ' . $u[0]['channel_name'] . ' and no union.');
- return;
- }
- // tgroup delivery - setup a second delivery chain
- // prevent delivery looping - only proceed
- // if the message originated elsewhere and is a top-level post
+ if((! $mention) && (! $union)) {
+ logger('No mention for ' . $u[0]['channel_name'] . ' and no union.');
+ continue;
+ }
+ // tgroup delivery - setup a second delivery chain
+ // prevent delivery looping - only proceed
+ // if the message originated elsewhere and is a top-level post
- if(intval($item['item_wall']) || intval($item['item_origin']) || (! intval($item['item_thread_top'])) || ($item['id'] != $item['parent'])) {
- logger('Item was local or a comment. rejected.');
- return;
- }
- logger('Creating second delivery chain.');
- start_delivery_chain($u[0],$item,$item_id,null);
+ if(intval($item['item_wall']) || intval($item['item_origin']) || (! intval($item['item_thread_top'])) || ($item['id'] != $item['parent'])) {
+ logger('Item was local or a comment. rejected.');
+ continue;
+ }
+
+ logger('Creating second delivery chain.');
+ start_delivery_chain($u[0],$item,$item_id,null);
+
+ }
+ }
}
/**
@@ -2760,78 +2761,73 @@ function tgroup_check($uid, $item) {
if($terms)
logger('tgroup_check: post mentions: ' . print_r($terms,true), LOGGER_DATA);
+ $max_forums = get_config('system','max_tagged_forums',2);
+ $matched_forums = 0;
+
$link = normalise_link($u[0]['xchan_url']);
if($terms) {
foreach($terms as $term) {
- if(link_compare($term['url'],$link)) {
- $mention = true;
- break;
+ if(! link_compare($term['url'],$link)) {
+ continue;
}
- }
- }
-
- if($mention) {
- logger('tgroup_check: mention found for ' . $u[0]['channel_name']);
- }
- else
- return false;
- // At this point we've determined that the person receiving this post was mentioned in it.
- // Now let's check if this mention was inside a reshare so we don't spam a forum
- // note: $term has been set to the matching term
+ $mention = true;
+ logger('tgroup_check: mention found for ' . $u[0]['channel_name']);
+ // At this point we've determined that the person receiving this post was mentioned in it.
+ // Now let's check if this mention was inside a reshare so we don't spam a forum
+ // note: $term has been set to the matching term
- $body = $item['body'];
- $body = preg_replace('/\[share(.*?)\[\/share\]/','',$body);
+ $body = preg_replace('/\[share(.*?)\[\/share\]/','',$item['body']);
- $pluspattern = '/@\!?\[zrl\=([^\]]*?)\]((?:.(?!\[zrl\=))*?)\+\[\/zrl\]/';
+ $pluspattern = '/@\!?\[zrl\=([^\]]*?)\]((?:.(?!\[zrl\=))*?)\+\[\/zrl\]/';
- $forumpattern = '/\!\!?\[zrl\=([^\]]*?)\]((?:.(?!\[zrl\=))*?)\[\/zrl\]/';
+ $forumpattern = '/\!\!?\[zrl\=([^\]]*?)\]((?:.(?!\[zrl\=))*?)\[\/zrl\]/';
+ $found = false;
- $found = false;
+ $matches = array();
- $max_forums = get_config('system','max_tagged_forums');
- if(! $max_forums)
- $max_forums = 2;
- $matched_forums = 0;
- $matches = array();
-
- if(preg_match_all($pluspattern,$body,$matches,PREG_SET_ORDER)) {
- foreach($matches as $match) {
- $matched_forums ++;
- if($term['url'] === $match[1] && $term['term'] === $match[2]) {
- if($matched_forums <= $max_forums) {
- $found = true;
- break;
+ if(preg_match_all($pluspattern,$body,$matches,PREG_SET_ORDER)) {
+ foreach($matches as $match) {
+ $matched_forums ++;
+ if($term['url'] === $match[1] && $term['term'] === $match[2] && intval($term['ttype']) === TERM_MENTION) {
+ if($matched_forums <= $max_forums) {
+ $found = true;
+ break;
+ }
+ logger('forum ' . $term['term'] . ' exceeded max_tagged_forums - ignoring');
+ }
}
- logger('forum ' . $term['term'] . ' exceeded max_tagged_forums - ignoring');
}
- }
- }
- if(preg_match_all($forumpattern,$body,$matches,PREG_SET_ORDER)) {
- foreach($matches as $match) {
- $matched_forums ++;
- if($term['url'] === $match[1] && $term['term'] === $match[2]) {
- if($matched_forums <= $max_forums) {
- $found = true;
- break;
+ if(preg_match_all($forumpattern,$body,$matches,PREG_SET_ORDER)) {
+ foreach($matches as $match) {
+ $matched_forums ++;
+ if($term['url'] === $match[1] && $term['term'] === $match[2] && intval($term['ttype']) === TERM_FORUM) {
+ if($matched_forums <= $max_forums) {
+ $found = true;
+ break;
+ }
+ logger('forum ' . $term['term'] . ' exceeded max_tagged_forums - ignoring');
+ }
}
- logger('forum ' . $term['term'] . ' exceeded max_tagged_forums - ignoring');
}
+
+ if(! $found) {
+ logger('tgroup_check: mention was in a reshare or exceeded max_tagged_forums - ignoring');
+ continue;
+ }
+
+ return true;
}
}
- if(! $found) {
- logger('tgroup_check: mention was in a reshare or exceeded max_tagged_forums - ignoring');
- return false;
- }
+ return false;
- return true;
}
/**
diff --git a/include/message.php b/include/message.php
index 477c7172c..b57d2e068 100644
--- a/include/message.php
+++ b/include/message.php
@@ -335,12 +335,9 @@ function private_messages_list($uid, $mailbox = '', $start = 0, $numitems = 0) {
case 'combined':
default:
-
- $parents = q("SELECT parent_mid FROM mail WHERE mid = parent_mid AND channel_id = %d ORDER BY created DESC",
+ $parents = q("SELECT mail.parent_mid FROM mail LEFT JOIN conv ON mail.conv_guid = conv.guid WHERE mail.mid = mail.parent_mid AND mail.channel_id = %d ORDER BY conv.updated DESC $limit",
dbesc($local_channel)
);
- //FIXME: We need the latest mail of a thread here. This query throws errors in postgres. We now look for the latest in php until somebody can fix this...
- //$sql = "SELECT * FROM ( SELECT * FROM mail WHERE channel_id = $local_channel ORDER BY created DESC $limit ) AS temp_table GROUP BY parent_mid ORDER BY created DESC";
break;
}