Merge branch 'dev' of https://github.com/redmatrix/hubzilla into dev_merge

This commit is contained in:
zotlabs 2017-06-11 16:25:14 -07:00
commit f28fa0ab5a
9 changed files with 453 additions and 444 deletions

View File

@ -23,9 +23,16 @@ class Mail extends \Zotlabs\Web\Controller {
$rstr = ((x($_REQUEST,'messagerecip')) ? notags(trim($_REQUEST['messagerecip'])) : ''); $rstr = ((x($_REQUEST,'messagerecip')) ? notags(trim($_REQUEST['messagerecip'])) : '');
$preview = ((x($_REQUEST,'preview')) ? intval($_REQUEST['preview']) : 0); $preview = ((x($_REQUEST,'preview')) ? intval($_REQUEST['preview']) : 0);
$expires = ((x($_REQUEST,'expires')) ? datetime_convert(date_default_timezone_get(),'UTC', $_REQUEST['expires']) : NULL_DATE); $expires = ((x($_REQUEST,'expires')) ? datetime_convert(date_default_timezone_get(),'UTC', $_REQUEST['expires']) : NULL_DATE);
$raw = ((x($_REQUEST,'raw')) ? intval($_REQUEST['raw']) : 0);
$mimetype = ((x($_REQUEST,'mimetype')) ? notags(trim($_REQUEST['mimetype'])) : 'text/bbcode');
if($preview) { if($preview) {
if($raw) {
$body = mail_prepare_binary(['id' => 'M0']);
echo json_encode(['preview' => $body]);
}
else {
$body = cleanup_bbcode($body); $body = cleanup_bbcode($body);
$results = linkify_tags($a, $body, local_channel()); $results = linkify_tags($a, $body, local_channel());
@ -46,8 +53,9 @@ class Mail extends \Zotlabs\Web\Controller {
} }
$body = trim(str_replace($match[1],'',$body)); $body = trim(str_replace($match[1],'',$body));
} }
}
echo json_encode(['preview' => zidify_links(smilies(bbcode($body)))]); echo json_encode(['preview' => zidify_links(smilies(bbcode($body)))]);
}
}
killme(); killme();
} }
@ -102,35 +110,9 @@ class Mail extends \Zotlabs\Web\Controller {
} }
} }
// if(feature_enabled(local_channel(),'richtext')) {
// $body = fix_mce_lf($body);
// }
require_once('include/text.php'); require_once('include/text.php');
linkify_tags($a, $body, local_channel()); linkify_tags($a, $body, local_channel());
// I don't think this is used any more.
if($preview) {
$mail = [
'mailbox' => 'outbox',
'id' => 0,
'mid' => 'M0',
'from_name' => $channel['xchan_name'],
'from_url' => $channel['xchan_url'],
'from_photo' => $channel['xchan_photo_s'],
'subject' => zidify_links(smilies(bbcode($subject))),
'body' => zidify_links(smilies(bbcode($body))),
'attachments' => '',
'can_recall' => false,
'is_recalled' => '',
'date' => datetime_convert('UTC',date_default_timezone_get(),$message['created'], 'c')
];
echo replace_macros(get_markup_template('mail_conv.tpl'), [ '$mail' => $mail ] );
killme();
}
if(! $recipient) { if(! $recipient) {
notice('No recipient found.'); notice('No recipient found.');
@ -141,7 +123,7 @@ class Mail extends \Zotlabs\Web\Controller {
// We have a local_channel, let send_message use the session channel and save a lookup // We have a local_channel, let send_message use the session channel and save a lookup
$ret = send_message(0, $recipient, $body, $subject, $replyto, $expires); $ret = send_message(0, $recipient, $body, $subject, $replyto, $expires, $mimetype, $raw);
if($ret['success']) { if($ret['success']) {
xchan_mail_query($ret['mail']); xchan_mail_query($ret['mail']);

View File

@ -353,14 +353,6 @@ function localize_item(&$item){
} }
*/ */
// if item body was obscured and we changed it, re-obscure it
// FIXME - we need a better filter than just the string 'data'; try and
// match the fact that it's json encoded
if(intval($item['item_obscured'])
&& strlen($item['body']) && (! strpos($item['body'],'data'))) {
$item['body'] = z_obscure($item['body']);
}
} }

View File

@ -1359,6 +1359,8 @@ function encode_mail($item,$extended = false) {
$x['body'] = $item['body']; $x['body'] = $item['body'];
$x['from'] = encode_item_xchan($item['from']); $x['from'] = encode_item_xchan($item['from']);
$x['to'] = encode_item_xchan($item['to']); $x['to'] = encode_item_xchan($item['to']);
$x['raw'] = $item['mail_raw'];
$x['mimetype'] = $item['mail_mimetype'];
if($item['attach']) if($item['attach'])
$x['attach'] = json_decode($item['attach'],true); $x['attach'] = json_decode($item['attach'],true);
@ -1392,9 +1394,16 @@ function get_mail_elements($x) {
$arr = array(); $arr = array();
if(intval($x['raw'])) {
$arr['mail_raw'] = intval($x['raw']);
$arr['body'] = $x['body'];
}
else {
$arr['body'] = (($x['body']) ? htmlspecialchars($x['body'], ENT_COMPAT,'UTF-8',false) : ''); $arr['body'] = (($x['body']) ? htmlspecialchars($x['body'], ENT_COMPAT,'UTF-8',false) : '');
$arr['title'] = (($x['title'])? htmlspecialchars($x['title'],ENT_COMPAT,'UTF-8',false) : ''); }
$arr['title'] = (($x['title'])? htmlspecialchars($x['title'],ENT_COMPAT,'UTF-8',false) : '');
$arr['mail_mimetype'] = (($x['mimetype']) ? htmlspecialchars($x['mimetype'],ENT_COMPAT,'UTF-8',false) : 'text/bbcode');
$arr['conv_guid'] = (($x['conv_guid'])? htmlspecialchars($x['conv_guid'],ENT_COMPAT,'UTF-8',false) : ''); $arr['conv_guid'] = (($x['conv_guid'])? htmlspecialchars($x['conv_guid'],ENT_COMPAT,'UTF-8',false) : '');
$arr['created'] = datetime_convert('UTC','UTC',$x['created']); $arr['created'] = datetime_convert('UTC','UTC',$x['created']);
@ -3032,8 +3041,10 @@ function mail_store($arr) {
$arr['body'] = ((x($arr,'body')) ? trim($arr['body']) : ''); $arr['body'] = ((x($arr,'body')) ? trim($arr['body']) : '');
$arr['sig'] = ((x($arr,'sig')) ? trim($arr['sig']) : ''); $arr['sig'] = ((x($arr,'sig')) ? trim($arr['sig']) : '');
$arr['conv_guid'] = ((x($arr,'conv_guid')) ? trim($arr['conv_guid']) : ''); $arr['conv_guid'] = ((x($arr,'conv_guid')) ? trim($arr['conv_guid']) : '');
$arr['mail_mimetype'] = ((x($arr,'mail_mimetype')) ? trim($arr['mail_mimetype']) : 'text/bbcode');
$arr['mail_flags'] = ((x($arr,'mail_flags')) ? intval($arr['mail_flags']) : 0 ); $arr['mail_flags'] = ((x($arr,'mail_flags')) ? intval($arr['mail_flags']) : 0 );
$arr['mail_raw'] = ((x($arr,'mail_raw')) ? intval($arr['mail_raw']) : 0 );
if(! $arr['parent_mid']) { if(! $arr['parent_mid']) {
logger('mail_store: missing parent'); logger('mail_store: missing parent');
@ -4350,10 +4361,7 @@ function sync_an_item($channel_id,$item_id) {
if($r) { if($r) {
xchan_query($r); xchan_query($r);
$sync_item = fetch_post_tags($r); $sync_item = fetch_post_tags($r);
$rid = q("select * from item_id where iid = %d", build_sync_packet($channel_d,array('item' => array(encode_item($sync_item[0],true))));
intval($item_id)
);
build_sync_packet($channel_d,array('item' => array(encode_item($sync_item[0],true)),'item_id' => $rid));
} }
} }

View File

@ -5,10 +5,20 @@
require_once('include/crypto.php'); require_once('include/crypto.php');
require_once('include/attach.php'); require_once('include/attach.php');
function mail_prepare_binary($item) {
return replace_macros(get_markup_template('item_binary.tpl'), [
'$download' => t('Download binary/encrypted content'),
'$url' => z_root() . '/mail/' . $item['id'] . '/download'
]);
}
// send a private message // send a private message
function send_message($uid = 0, $recipient = '', $body = '', $subject = '', $replyto = '', $expires = NULL_DATE) { function send_message($uid = 0, $recipient = '', $body = '', $subject = '', $replyto = '', $expires = NULL_DATE, $mimetype = 'text/bbcode', $raw = false) {
$ret = array('success' => false); $ret = array('success' => false);
$is_reply = false; $is_reply = false;
@ -192,8 +202,8 @@ function send_message($uid = 0, $recipient = '', $body = '', $subject = '', $rep
$sig = ''; // placeholder $sig = ''; // placeholder
$mimetype = ''; //placeholder $mimetype = ''; //placeholder
$r = q("INSERT INTO mail ( account_id, conv_guid, mail_obscured, channel_id, from_xchan, to_xchan, mail_mimetype, title, body, sig, attach, mid, parent_mid, created, expires, mail_isreply ) $r = q("INSERT INTO mail ( account_id, conv_guid, mail_obscured, channel_id, from_xchan, to_xchan, mail_mimetype, title, body, sig, attach, mid, parent_mid, created, expires, mail_isreply, mail_raw )
VALUES ( %d, '%s', %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d )", VALUES ( %d, '%s', %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d )",
intval($channel['channel_account_id']), intval($channel['channel_account_id']),
dbesc($conv_guid), dbesc($conv_guid),
intval(1), intval(1),
@ -209,7 +219,8 @@ function send_message($uid = 0, $recipient = '', $body = '', $subject = '', $rep
dbesc($replyto), dbesc($replyto),
dbesc(datetime_convert()), dbesc(datetime_convert()),
dbescdate($expires), dbescdate($expires),
intval($is_reply) intval($is_reply),
intval($raw)
); );
// verify the save // verify the save

View File

@ -1562,7 +1562,12 @@ function prepare_body(&$item,$attach = false) {
} }
} }
if($item['item_obscured']) {
$s .= prepare_binary($item);
}
else {
$s .= prepare_text($item['body'],$item['mimetype'], false); $s .= prepare_text($item['body'],$item['mimetype'], false);
}
$event = (($item['obj_type'] === ACTIVITY_OBJ_EVENT) ? format_event_obj($item['obj']) : false); $event = (($item['obj_type'] === ACTIVITY_OBJ_EVENT) ? format_event_obj($item['obj']) : false);
@ -1625,6 +1630,17 @@ function prepare_body(&$item,$attach = false) {
return $prep_arr; return $prep_arr;
} }
function prepare_binary($item) {
return replace_macros(get_markup_template('item_binary.tpl'), [
'$download' => t('Download binary/encrypted content'),
'$url' => z_root() . '/viewsrc/' . $item['id'] . '/download'
]);
}
/** /**
* @brief Given a text string, convert from bbcode to html and add smilie icons. * @brief Given a text string, convert from bbcode to html and add smilie icons.
* *
@ -2897,7 +2913,7 @@ function pdl_selector($uid, $current='') {
$sql_extra = item_permissions_sql($uid); $sql_extra = item_permissions_sql($uid);
$r = q("select iconfig.*, mid from item_id left join item on iconfig.iid = item.id $r = q("select iconfig.*, mid from iconfig left join item on iconfig.iid = item.id
where item.uid = %d and iconfig.cat = 'system' and iconfig.k = 'PDL' $sql_extra order by v asc", where item.uid = %d and iconfig.cat = 'system' and iconfig.k = 'PDL' $sql_extra order by v asc",
intval($uid) intval($uid)
); );

File diff suppressed because it is too large Load Diff

View File

@ -84,9 +84,9 @@
</div> </div>
{{/if}} {{/if}}
<div class="p-2 clearfix wall-item-tools"> <div class="p-2 clearfix wall-item-tools">
<div class="wall-item-tools-right pull-right"> <div class="float-right wall-item-tools-right">
{{if $item.toplevel && $item.emojis && $item.reactions}} {{if $item.toplevel && $item.emojis && $item.reactions}}
<div class="btn-group dropdown"> <div class="btn-group">
<button type="button" class="btn btn-outline-secondary btn-sm dropdown-toggle" data-toggle="dropdown" id="wall-item-react-{{$item.id}}"> <button type="button" class="btn btn-outline-secondary btn-sm dropdown-toggle" data-toggle="dropdown" id="wall-item-react-{{$item.id}}">
<i class="fa fa-smile-o"></i> <i class="fa fa-smile-o"></i>
</button> </button>
@ -97,7 +97,7 @@
</div> </div>
</div> </div>
{{/if}} {{/if}}
<div class="btn-group dropdown"> <div class="btn-group">
{{if $item.like}} {{if $item.like}}
<button type="button" title="{{$item.like.0}}" class="btn btn-outline-secondary btn-sm" onclick="dolike({{$item.id}},'like'); return false;"> <button type="button" title="{{$item.like.0}}" class="btn btn-outline-secondary btn-sm" onclick="dolike({{$item.id}},'like'); return false;">
<i class="fa fa-thumbs-o-up{{if $item.my_responses.like}} ivoted{{/if}}" ></i> <i class="fa fa-thumbs-o-up{{if $item.my_responses.like}} ivoted{{/if}}" ></i>
@ -109,11 +109,11 @@
</button> </button>
{{/if}} {{/if}}
{{if $item.isevent}} {{if $item.isevent}}
<div class="btn-group dropdown"> <div class="btn-group">
<button type="button" class="btn btn-outline-secondary btn-sm dropdown-toggle" data-toggle="dropdown" id="wall-item-attend-menu-{{$item.id}}" title="{{$item.attend_title}}"> <button type="button" class="btn btn-outline-secondary btn-sm dropdown-toggle" data-toggle="dropdown" id="wall-item-attend-menu-{{$item.id}}" title="{{$item.attend_title}}">
<i class="fa fa-calendar-check-o"></i> <i class="fa fa-calendar-check-o"></i>
</button> </button>
<div class="dropdown-menu"> <div class="dropdown-menu dropdown-menu-right">
<a class="dropdown-item" href="#" title="{{$item.attend.0}}" onclick="itemAddToCal({{$item.id}}); dolike({{$item.id}},'attendyes'); return false;"> <a class="dropdown-item" href="#" title="{{$item.attend.0}}" onclick="itemAddToCal({{$item.id}}); dolike({{$item.id}},'attendyes'); return false;">
<i class="item-act-list fa fa-check{{if $item.my_responses.attend}} ivoted{{/if}}" ></i> {{$item.attend.0}} <i class="item-act-list fa fa-check{{if $item.my_responses.attend}} ivoted{{/if}}" ></i> {{$item.attend.0}}
</a> </a>
@ -127,11 +127,11 @@
</div> </div>
{{/if}} {{/if}}
{{if $item.canvote}} {{if $item.canvote}}
<div class="btn-group dropdown"> <div class="btn-group">
<button type="button" class="btn btn-outline-secondary btn-sm dropdown-toggle" data-toggle="dropdown" id="wall-item-consensus-menu-{{$item.id}}" title="{{$item.vote_title}}"> <button type="button" class="btn btn-outline-secondary btn-sm dropdown-toggle" data-toggle="dropdown" id="wall-item-consensus-menu-{{$item.id}}" title="{{$item.vote_title}}">
<i class="fa fa-check-square-o"></i> <i class="fa fa-check-square-o"></i>
</button> </button>
<div class="dropdown-menu" role="menu" aria-labelledby="wall-item-consensus-menu-{{$item.id}}"> <div class="dropdown-menu dropdown-menu-right" role="menu" aria-labelledby="wall-item-consensus-menu-{{$item.id}}">
<a class="dropdown-item" href="#" title="{{$item.conlabels.0}}" onclick="dolike({{$item.id}},'agree'); return false;"> <a class="dropdown-item" href="#" title="{{$item.conlabels.0}}" onclick="dolike({{$item.id}},'agree'); return false;">
<i class="item-act-list fa fa-check{{if $item.my_responses.agree}} ivoted{{/if}}" ></i> {{$item.conlabels.0}} <i class="item-act-list fa fa-check{{if $item.my_responses.agree}} ivoted{{/if}}" ></i> {{$item.conlabels.0}}
</a> </a>
@ -144,6 +144,7 @@
</div> </div>
</div> </div>
{{/if}} {{/if}}
<div class="btn-group">
<button type="button" class="btn btn-outline-secondary btn-sm dropdown-toggle" data-toggle="dropdown" id="wall-item-menu-{{$item.id}}"> <button type="button" class="btn btn-outline-secondary btn-sm dropdown-toggle" data-toggle="dropdown" id="wall-item-menu-{{$item.id}}">
<i class="fa fa-cog"></i> <i class="fa fa-cog"></i>
</button> </button>
@ -192,6 +193,7 @@
</div> </div>
</div> </div>
</div> </div>
</div>
<div id="like-rotator-{{$item.id}}" class="like-rotator"></div> <div id="like-rotator-{{$item.id}}" class="like-rotator"></div>
{{if $item.responses || $item.attachments}} {{if $item.responses || $item.attachments}}

View File

@ -84,9 +84,9 @@
</div> </div>
{{/if}} {{/if}}
<div class="p-2 clearfix wall-item-tools"> <div class="p-2 clearfix wall-item-tools">
<div class="wall-item-tools-right pull-right"> <div class="float-right wall-item-tools-right">
{{if $item.toplevel && $item.emojis && $item.reactions}} {{if $item.toplevel && $item.emojis && $item.reactions}}
<div class="btn-group dropdown"> <div class="btn-group">
<button type="button" class="btn btn-outline-secondary btn-sm dropdown-toggle" data-toggle="dropdown" id="wall-item-react-{{$item.id}}"> <button type="button" class="btn btn-outline-secondary btn-sm dropdown-toggle" data-toggle="dropdown" id="wall-item-react-{{$item.id}}">
<i class="fa fa-smile-o"></i> <i class="fa fa-smile-o"></i>
</button> </button>
@ -97,7 +97,7 @@
</div> </div>
</div> </div>
{{/if}} {{/if}}
<div class="btn-group dropdown"> <div class="btn-group">
{{if $item.like}} {{if $item.like}}
<button type="button" title="{{$item.like.0}}" class="btn btn-outline-secondary btn-sm" onclick="dolike({{$item.id}},'like'); return false;"> <button type="button" title="{{$item.like.0}}" class="btn btn-outline-secondary btn-sm" onclick="dolike({{$item.id}},'like'); return false;">
<i class="fa fa-thumbs-o-up{{if $item.my_responses.like}} ivoted{{/if}}" ></i> <i class="fa fa-thumbs-o-up{{if $item.my_responses.like}} ivoted{{/if}}" ></i>
@ -109,7 +109,7 @@
</button> </button>
{{/if}} {{/if}}
{{if $item.isevent}} {{if $item.isevent}}
<div class="btn-group dropdown"> <div class="btn-group">
<button type="button" class="btn btn-outline-secondary btn-sm dropdown-toggle" data-toggle="dropdown" id="wall-item-attend-menu-{{$item.id}}" title="{{$item.attend_title}}"> <button type="button" class="btn btn-outline-secondary btn-sm dropdown-toggle" data-toggle="dropdown" id="wall-item-attend-menu-{{$item.id}}" title="{{$item.attend_title}}">
<i class="fa fa-calendar-check-o"></i> <i class="fa fa-calendar-check-o"></i>
</button> </button>
@ -127,7 +127,7 @@
</div> </div>
{{/if}} {{/if}}
{{if $item.canvote}} {{if $item.canvote}}
<div class="btn-group dropdown"> <div class="btn-group">
<button type="button" class="btn btn-outline-secondary btn-sm dropdown-toggle" data-toggle="dropdown" id="wall-item-consensus-menu-{{$item.id}}" title="{{$item.vote_title}}"> <button type="button" class="btn btn-outline-secondary btn-sm dropdown-toggle" data-toggle="dropdown" id="wall-item-consensus-menu-{{$item.id}}" title="{{$item.vote_title}}">
<i class="fa fa-check-square-o"></i> <i class="fa fa-check-square-o"></i>
</button> </button>
@ -144,6 +144,7 @@
</div> </div>
</div> </div>
{{/if}} {{/if}}
<div class="btn-group">
<button type="button" class="btn btn-outline-secondary btn-sm dropdown-toggle" data-toggle="dropdown" id="wall-item-menu-{{$item.id}}"> <button type="button" class="btn btn-outline-secondary btn-sm dropdown-toggle" data-toggle="dropdown" id="wall-item-menu-{{$item.id}}">
<i class="fa fa-cog"></i> <i class="fa fa-cog"></i>
</button> </button>
@ -192,6 +193,7 @@
</div> </div>
</div> </div>
</div> </div>
</div>
<div id="like-rotator-{{$item.id}}" class="like-rotator"></div> <div id="like-rotator-{{$item.id}}" class="like-rotator"></div>
<div class="wall-item-tools-left{{if $item.unseen_comments || $item.like_count || $item.dislike_count || $item.attachments}} btn-group{{/if}}"> <div class="wall-item-tools-left{{if $item.unseen_comments || $item.like_count || $item.dislike_count || $item.attachments}} btn-group{{/if}}">
{{if $item.attachments}} {{if $item.attachments}}

3
view/tpl/item_binary.tpl Normal file
View File

@ -0,0 +1,3 @@
<p>
<center><a class="zrl" href="{{$url}}"><button class="btn btn-warning fakelink">{{$download}}</button></a></center>
</p>