diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/ItemObject.php | 4 | ||||
-rw-r--r-- | include/conversation.php | 16 | ||||
-rw-r--r-- | include/follow.php | 5 | ||||
-rw-r--r-- | include/identity.php | 15 | ||||
-rwxr-xr-x | include/items.php | 10 | ||||
-rw-r--r-- | include/message.php | 49 | ||||
-rw-r--r-- | include/permissions.php | 35 |
7 files changed, 125 insertions, 9 deletions
diff --git a/include/ItemObject.php b/include/ItemObject.php index 8c8c0ee2a..22b191e79 100644 --- a/include/ItemObject.php +++ b/include/ItemObject.php @@ -39,10 +39,10 @@ class Item extends BaseObject { foreach($data['children'] as $item) { /* - * Only add thos that will be displayed + * Only add those that will be displayed */ - if(! visible_activity($item)) { + if((! visible_activity($item)) || array_key_exists('author_blocked',$item)) { continue; } diff --git a/include/conversation.php b/include/conversation.php index 6d551a5c9..9dab5931b 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -137,7 +137,7 @@ function localize_item(&$item){ case ACTIVITY_OBJ_NOTE: default: $post_type = t('status'); - if($obj['id'] != $item['mid']) + if($obj['mid'] != $obj['parent_mid']) $post_type = t('comment'); break; } @@ -712,6 +712,8 @@ function conversation(&$a, $items, $mode, $update, $page_mode = 'traditional') { $threads = array(); foreach($items as $item) { + // Check for any blocked authors + if($arr_blocked) { $blocked = false; foreach($arr_blocked as $b) { @@ -724,6 +726,18 @@ function conversation(&$a, $items, $mode, $update, $page_mode = 'traditional') { continue; } + // Check all the kids too + + if($arr_blocked && $item['children']) { + for($d = 0; $d < count($item['children']); $d ++) { + foreach($arr_blocked as $b) { + if(($b) && ($item['children'][$d]['author_xchan'] == $b)) + $item['children'][$d]['author_blocked'] = true; + } + } + } + + // Can we put this after the visibility check? like_puller($a,$item,$alike,'like'); diff --git a/include/follow.php b/include/follow.php index 6b192234c..ce550b07f 100644 --- a/include/follow.php +++ b/include/follow.php @@ -145,12 +145,13 @@ function new_contact($uid,$url,$channel,$interactive = false) { ); } else { - $r = q("insert into abook ( abook_account, abook_channel, abook_xchan, abook_their_perms, abook_created, abook_updated ) - values( %d, %d, '%s', %d, '%s', '%s' ) ", + $r = q("insert into abook ( abook_account, abook_channel, abook_xchan, abook_their_perms, abook_my_perms, abook_created, abook_updated ) + values( %d, %d, '%s', %d, %d, '%s', '%s' ) ", intval($aid), intval($uid), dbesc($xchan_hash), intval($their_perms), + intval(PERMS_W_STREAM|PERMS_W_MAIL), dbesc(datetime_convert()), dbesc(datetime_convert()) ); diff --git a/include/identity.php b/include/identity.php index 99b90cc8b..5f210c456 100644 --- a/include/identity.php +++ b/include/identity.php @@ -115,11 +115,19 @@ function create_identity($arr) { if(array_key_exists('primary', $arr)) $primary = intval($arr['primary']); + $perms_sql = ''; + + $defperms = site_default_perms(); + $global_perms = get_perms(); + foreach($defperms as $p => $v) { + $perms_keys .= ', ' . $global_perms[$p][0]; + $perms_vals .= ', ' . intval($v); + } $r = q("insert into channel ( channel_account_id, channel_primary, channel_name, channel_address, channel_guid, channel_guid_sig, - channel_hash, channel_prvkey, channel_pubkey, channel_pageflags ) - values ( %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d ) ", + channel_hash, channel_prvkey, channel_pubkey, channel_pageflags $perms_keys ) + values ( %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d $perms_vals ) ", intval($arr['account_id']), intval($primary), @@ -133,6 +141,9 @@ function create_identity($arr) { intval($pageflags) ); + + + $r = q("select * from channel where channel_account_id = %d and channel_guid = '%s' limit 1", intval($arr['account_id']), diff --git a/include/items.php b/include/items.php index ba0867562..10bdcb38f 100755 --- a/include/items.php +++ b/include/items.php @@ -840,6 +840,9 @@ function encode_mail($item) { $x['from'] = encode_item_xchan($item['from']); $x['to'] = encode_item_xchan($item['to']); + if($item['attach']) + $x['attach'] = json_decode_plus($item['attach']); + $x['flags'] = array(); if($item['mail_flags'] & MAIL_RECALLED) { @@ -885,6 +888,9 @@ function get_mail_elements($x) { $arr['mid'] = (($x['message_id']) ? htmlentities($x['message_id'], ENT_COMPAT,'UTF-8',false) : ''); $arr['parent_mid'] = (($x['message_parent']) ? htmlentities($x['message_parent'], ENT_COMPAT,'UTF-8',false) : ''); + if($x['attach']) + $arr['attach'] = activity_sanitise($x['attach']); + if(import_author_xchan($x['from'])) $arr['from_xchan'] = base64url_encode(hash('whirlpool',$x['from']['guid'] . $x['from']['guid_sig'], true)); @@ -2202,6 +2208,9 @@ function mail_store($arr) { if((strpos($arr['body'],'<') !== false) || (strpos($arr['body'],'>') !== false)) $arr['body'] = escape_tags($arr['body']); + if(array_key_exists('attach',$arr) && is_array($arr['attach'])) + $arr['attach'] = json_encode($arr['attach']); + $arr['account_id'] = ((x($arr,'account_id')) ? intval($arr['account_id']) : 0); $arr['mid'] = ((x($arr,'mid')) ? notags(trim($arr['mid'])) : random_string()); $arr['from_xchan'] = ((x($arr,'from_xchan')) ? notags(trim($arr['from_xchan'])) : ''); @@ -2210,6 +2219,7 @@ function mail_store($arr) { $arr['title'] = ((x($arr,'title')) ? notags(trim($arr['title'])) : ''); $arr['parent_mid'] = ((x($arr,'parent_mid')) ? notags(trim($arr['parent_mid'])) : ''); $arr['body'] = ((x($arr,'body')) ? trim($arr['body']) : ''); + $arr['mail_flags'] = ((x($arr,'mail_flags')) ? intval($arr['mail_flags']) : 0 ); diff --git a/include/message.php b/include/message.php index fc0d5f2b3..e54a6cd83 100644 --- a/include/message.php +++ b/include/message.php @@ -3,6 +3,7 @@ /* Private Message backend API */ require_once('include/crypto.php'); +require_once('include/attach.php'); // send a private message @@ -74,14 +75,44 @@ function send_message($uid = 0, $recipient='', $body='', $subject='', $replyto=' if(preg_match_all("/\[img\](.*?)\[\/img\]/",$body,$match)) $images = $match[1]; + $match = false; + + if(preg_match_all("/\[attachment\](.*?)\[\/attachment\]/",$body,$match)) + $attaches = $match[1]; + + $attachments = ''; + + if(preg_match_all('/(\[attachment\](.*?)\[\/attachment\])/',$body,$match)) { + $attachments = array(); + foreach($match[2] as $mtch) { + $hash = substr($mtch,0,strpos($mtch,',')); + $rev = intval(substr($mtch,strpos($mtch,','))); + $r = attach_by_hash_nodata($hash,$rev); + if($r['success']) { + $attachments[] = array( + 'href' => $a->get_baseurl() . '/attach/' . $r['data']['hash'], + 'length' => $r['data']['filesize'], + 'type' => $r['data']['filetype'], + 'title' => urlencode($r['data']['filename']), + 'revision' => $r['data']['revision'] + ); + } + $body = str_replace($match[1],'',$body); + } + } + + $jattach = (($attachments) ? json_encode($attachments) : ''); + $key = get_config('system','pubkey'); if($subject) $subject = json_encode(aes_encapsulate($subject,$key)); if($body) $body = json_encode(aes_encapsulate($body,$key)); - $r = q("INSERT INTO mail ( account_id, mail_flags, channel_id, from_xchan, to_xchan, title, body, mid, parent_mid, created ) - VALUES ( %d, %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s' )", + + + $r = q("INSERT INTO mail ( account_id, mail_flags, channel_id, from_xchan, to_xchan, title, body, attach, mid, parent_mid, created ) + VALUES ( %d, %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' )", intval($channel['channel_account_id']), intval(MAIL_OBSCURED), intval($channel['channel_id']), @@ -89,6 +120,7 @@ function send_message($uid = 0, $recipient='', $body='', $subject='', $replyto=' dbesc($recipient), dbesc($subject), dbesc($body), + dbesc($jattach), dbesc($mid), dbesc($replyto), dbesc(datetime_convert()) @@ -122,6 +154,19 @@ function send_message($uid = 0, $recipient='', $body='', $subject='', $replyto=' } } + if($attaches) { + foreach($attaches as $attach) { + $hash = substr($attach,0,strpos($attach,',')); + $rev = intval(substr($attach,strpos($attach,','))); + attach_store($channel,$observer_hash,$options = 'update', array( + 'hash' => $hash, + 'revision' => $rev, + 'allow_cid' => '<' . $recipient . '>', + + )); + } + } + proc_run('php','include/notifier.php','mail',$post_id); $ret['success'] = true; diff --git a/include/permissions.php b/include/permissions.php index e7f50ceeb..bf50ebdd1 100644 --- a/include/permissions.php +++ b/include/permissions.php @@ -328,3 +328,38 @@ function check_list_permissions($uid,$arr,$perm) { return($result); } + + +function site_default_perms() { + + $typical = array( + 'view_stream' => PERMS_PUBLIC, + 'view_profile' => PERMS_PUBLIC, + 'view_photos' => PERMS_PUBLIC, + 'view_contacts' => PERMS_PUBLIC, + 'view_storage' => PERMS_PUBLIC, + 'view_pages' => PERMS_PUBLIC, + 'send_stream' => PERMS_SPECIFIC, + 'post_wall' => PERMS_SPECIFIC, + 'post_comments' => PERMS_SPECIFIC, + 'post_mail' => PERMS_SPECIFIC, + 'post_photos' => 0, + 'tag_deliver' => PERMS_SPECIFIC, + 'chat' => PERMS_SPECIFIC, + 'write_storage' => 0, + 'write_pages' => 0, + 'delegate' => 0, + ); + + + $global_perms = get_perms(); + $ret = array(); + + foreach($global_perms as $perm => $v) { + $x = get_config('default_perms',$perm); + if($x === false) + $x = $typical[$perm]; + $ret[$perm] = $x; + } + return $ret; +} |