mirror of
https://framagit.org/hubzilla/core.git
synced 2026-06-21 00:52:33 -04:00
provide commentable state and minor cleanup
This commit is contained in:
@@ -114,7 +114,7 @@ class ThreadItem {
|
||||
$locktype = intval($item['item_private']);
|
||||
|
||||
if ($locktype === 2) {
|
||||
$lock = t('Direct message');
|
||||
$lock = t('Private message');
|
||||
}
|
||||
|
||||
// 0 = limited based on public policy
|
||||
@@ -285,14 +285,10 @@ class ThreadItem {
|
||||
if((in_array($item['obj_type'], ['Event', ACTIVITY_OBJ_EVENT])) && $conv->get_profile_owner() == local_channel())
|
||||
$has_event = true;
|
||||
|
||||
$like = [];
|
||||
$dislike = [];
|
||||
$reply_to = [];
|
||||
$reactions_allowed = false;
|
||||
|
||||
if($this->is_commentable() && $observer) {
|
||||
$like = array( t("I like this \x28toggle\x29"), t("like"));
|
||||
$dislike = array( t("I don't like this \x28toggle\x29"), t("dislike"));
|
||||
$reply_to = array( t("Reply to this message"), t("reply"), t("Reply to"));
|
||||
$reactions_allowed = true;
|
||||
}
|
||||
@@ -439,8 +435,6 @@ class ThreadItem {
|
||||
'reactions' => $this->reactions,
|
||||
// Item toolbar buttons
|
||||
'emojis' => (($this->is_toplevel() && $this->is_commentable() && $observer && feature_enabled($conv->get_profile_owner(),'emojis')) ? '1' : ''),
|
||||
'like' => $like,
|
||||
'dislike' => ((feature_enabled($conv->get_profile_owner(),'dislike')) ? $dislike : ''),
|
||||
'reply_to' => ((feature_enabled($conv->get_profile_owner(),'reply_to')) ? $reply_to : ''),
|
||||
'top_hint' => t("Go to previous comment"),
|
||||
'share' => $share,
|
||||
@@ -465,7 +459,7 @@ class ThreadItem {
|
||||
'list_unseen_txt' => $list_unseen_txt,
|
||||
'markseen' => t('Mark all comments seen'),
|
||||
'responses' => $responses,
|
||||
'my_responses' => $my_responses,
|
||||
// 'my_responses' => $my_responses,
|
||||
'modal_dismiss' => t('Close'),
|
||||
'comment' => ($item['item_delayed'] ? '' : $this->get_comment_box()),
|
||||
'comment_hidden' => feature_enabled($conv->get_profile_owner(),'reply_to'),
|
||||
|
||||
@@ -61,8 +61,10 @@ class Request extends Controller
|
||||
|
||||
$ret['result'] = item_activity_xchans($mid, $parent, $verb);
|
||||
|
||||
// TODO: check permission to like
|
||||
if ($observer_hash) {
|
||||
$commentable = $ret['result']['is_commentable'];
|
||||
unset($ret['result']['is_commentable']);
|
||||
|
||||
if ($commentable) {
|
||||
$ret['action'] = (($verb === 'Announce') ? 'jotShare' : 'dolike');
|
||||
$ret['action_label'] = ((find_xchan_in_array($observer_hash, $ret['result'])) ? t('- Remove yours') : t('+ Add yours'));
|
||||
}
|
||||
|
||||
@@ -1540,10 +1540,7 @@ function get_responses($conv_responses,$response_verbs,$ob,$item) {
|
||||
}
|
||||
|
||||
$ret[$v]['count'] = $item[$v . '_count'] ?? 0;
|
||||
$ret[$v]['list'] = ''; // ((isset($conv_responses[$v][$item['mid']])) ? $conv_responses[$v][$item['mid'] . '-l'] : '');
|
||||
$ret[$v]['button'] = get_response_button_text($v, $ret[$v]['count']);
|
||||
$ret[$v]['title'] = $conv_responses[$v]['title'] ?? '';
|
||||
$ret[$v]['modal'] = false; // (($ret[$v]['count'] > MAX_LIKERS) ? true : false);
|
||||
}
|
||||
|
||||
//logger('ret: ' . print_r($ret,true));
|
||||
|
||||
@@ -120,6 +120,10 @@ function collecturls($message) {
|
||||
function html2plain($html, $wraplength = 75, $compact = false)
|
||||
{
|
||||
|
||||
if (!$html) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$message = str_replace("\r", "", $html);
|
||||
|
||||
// mb_convert_encoding() is deprecated
|
||||
|
||||
@@ -5386,12 +5386,12 @@ function item_activity_sql($prefix = 'c') {
|
||||
}
|
||||
|
||||
$sql .= <<<SQL
|
||||
COUNT(CASE $prefix.verb WHEN 'Like' THEN 1 END) AS like_count,
|
||||
COUNT(CASE $prefix.verb WHEN 'Dislike' THEN 1 END) AS dislike_count,
|
||||
COUNT(CASE $prefix.verb WHEN 'Announce' THEN 1 END) AS announce_count,
|
||||
COUNT(CASE $prefix.verb WHEN 'Accept' THEN 1 END) AS attendyes_count,
|
||||
COUNT(CASE $prefix.verb WHEN 'Reject' THEN 1 END) AS attendno_count,
|
||||
COUNT(CASE $prefix.verb WHEN 'TentativeAccept' THEN 1 END) AS attendmaybe_count
|
||||
COUNT(CASE WHEN $prefix.verb = 'Like' $item_normal_c THEN 1 END) AS like_count,
|
||||
COUNT(CASE WHEN $prefix.verb = 'Dislike' $item_normal_c THEN 1 END) AS dislike_count,
|
||||
COUNT(CASE WHEN $prefix.verb = 'Announce' $item_normal_c THEN 1 END) AS announce_count,
|
||||
COUNT(CASE WHEN $prefix.verb = 'Accept' $item_normal_c THEN 1 END) AS attendyes_count,
|
||||
COUNT(CASE WHEN $prefix.verb = 'Reject' $item_normal_c THEN 1 END) AS attendno_count,
|
||||
COUNT(CASE WHEN $prefix.verb = 'TentativeAccept' $item_normal_c THEN 1 END) AS attendmaybe_count
|
||||
SQL;
|
||||
|
||||
return $sql;
|
||||
@@ -5523,6 +5523,10 @@ function item_activity_xchans($mid, $parent, $verb) {
|
||||
$observer_hash = get_observer_hash();
|
||||
$item_normal = item_normal();
|
||||
|
||||
$parent_item = q("SELECT * FROM item WHERE id = %d",
|
||||
intval($parent)
|
||||
);
|
||||
|
||||
if (local_channel()) {
|
||||
$ret = q("SELECT xchan.xchan_hash, xchan.xchan_name as name, xchan.xchan_url as url, xchan.xchan_photo_s as photo FROM item
|
||||
LEFT JOIN xchan ON item.author_xchan = xchan.xchan_hash
|
||||
@@ -5541,12 +5545,7 @@ function item_activity_xchans($mid, $parent, $verb) {
|
||||
}
|
||||
|
||||
if (!$ret) {
|
||||
$x = q("SELECT uid FROM item WHERE id = %d",
|
||||
intval($parent)
|
||||
);
|
||||
|
||||
$item_uid = $x[0]['uid'];
|
||||
|
||||
$item_uid = $parent_item[0]['uid'];
|
||||
$sql_extra = item_permissions_sql($item_uid, $observer_hash);
|
||||
|
||||
$ret = q("SELECT xchan.xchan_hash, xchan.xchan_name as name, xchan.xchan_url as url, xchan.xchan_photo_s as photo FROM item
|
||||
@@ -5564,6 +5563,8 @@ function item_activity_xchans($mid, $parent, $verb) {
|
||||
);
|
||||
}
|
||||
|
||||
$ret['is_commentable'] = can_comment_on_post($observer_hash, $parent_item[0]);
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user