Merge pull request #6541 from annando/mentions
Display mentioned users and in the comment box by default
This commit is contained in:
commit
8d84f33f15
7 changed files with 37 additions and 7 deletions
|
@ -559,10 +559,10 @@ class Item extends BaseObject
|
||||||
|
|
||||||
$fields['permissionset'] = ['allow_cid', 'allow_gid', 'deny_cid', 'deny_gid'];
|
$fields['permissionset'] = ['allow_cid', 'allow_gid', 'deny_cid', 'deny_gid'];
|
||||||
|
|
||||||
$fields['author'] = ['url' => 'author-link', 'name' => 'author-name',
|
$fields['author'] = ['url' => 'author-link', 'name' => 'author-name', 'addr' => 'author-addr',
|
||||||
'thumb' => 'author-avatar', 'nick' => 'author-nick', 'network' => 'author-network'];
|
'thumb' => 'author-avatar', 'nick' => 'author-nick', 'network' => 'author-network'];
|
||||||
|
|
||||||
$fields['owner'] = ['url' => 'owner-link', 'name' => 'owner-name',
|
$fields['owner'] = ['url' => 'owner-link', 'name' => 'owner-name', 'addr' => 'owner-addr',
|
||||||
'thumb' => 'owner-avatar', 'nick' => 'owner-nick', 'network' => 'owner-network'];
|
'thumb' => 'owner-avatar', 'nick' => 'owner-nick', 'network' => 'owner-network'];
|
||||||
|
|
||||||
$fields['contact'] = ['url' => 'contact-link', 'name' => 'contact-name', 'thumb' => 'contact-avatar',
|
$fields['contact'] = ['url' => 'contact-link', 'name' => 'contact-name', 'thumb' => 'contact-avatar',
|
||||||
|
|
|
@ -768,6 +768,33 @@ class Post extends BaseObject
|
||||||
return $this->comment_box_template;
|
return $this->comment_box_template;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get default text for the comment box
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
private function getDefaultText()
|
||||||
|
{
|
||||||
|
$item = Item::selectFirst(['author-addr'], ['id' => $this->getId()]);
|
||||||
|
if (!DBA::isResult($item) || empty($item['author-addr'])) {
|
||||||
|
// Should not happen
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
$text = '@' . $item['author-addr'] . ' ';
|
||||||
|
|
||||||
|
$terms = Term::tagArrayFromItemId($this->getId(), TERM_MENTION);
|
||||||
|
|
||||||
|
foreach ($terms as $term) {
|
||||||
|
$profile = Contact::getDetailsByURL($term['url']);
|
||||||
|
if (!empty($profile['addr']) && !strstr($text, $profile['addr'])) {
|
||||||
|
$text .= '@' . $profile['addr'] . ' ';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $text;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the comment box
|
* Get the comment box
|
||||||
*
|
*
|
||||||
|
@ -804,6 +831,8 @@ class Post extends BaseObject
|
||||||
$uid = $conv->getProfileOwner();
|
$uid = $conv->getProfileOwner();
|
||||||
$parent_uid = $this->getDataValue('uid');
|
$parent_uid = $this->getDataValue('uid');
|
||||||
|
|
||||||
|
$default_text = $this->getDefaultText();
|
||||||
|
|
||||||
if (!is_null($parent_uid) && ($uid != $parent_uid)) {
|
if (!is_null($parent_uid) && ($uid != $parent_uid)) {
|
||||||
$uid = $parent_uid;
|
$uid = $parent_uid;
|
||||||
}
|
}
|
||||||
|
@ -817,6 +846,7 @@ class Post extends BaseObject
|
||||||
'$id' => $this->getId(),
|
'$id' => $this->getId(),
|
||||||
'$parent' => $this->getId(),
|
'$parent' => $this->getId(),
|
||||||
'$qcomment' => $qcomment,
|
'$qcomment' => $qcomment,
|
||||||
|
'$default' => $default_text,
|
||||||
'$profile_uid' => $uid,
|
'$profile_uid' => $uid,
|
||||||
'$mylink' => $a->removeBaseURL($a->contact['url']),
|
'$mylink' => $a->removeBaseURL($a->contact['url']),
|
||||||
'$mytitle' => L10n::t('This is you'),
|
'$mytitle' => L10n::t('This is you'),
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
<a class="comment-edit-photo-link" href="{{$mylink}}" title="{{$mytitle}}"><img class="my-comment-photo" src="{{$myphoto}}" alt="{{$mytitle}}" title="{{$mytitle}}" /></a>
|
<a class="comment-edit-photo-link" href="{{$mylink}}" title="{{$mytitle}}"><img class="my-comment-photo" src="{{$myphoto}}" alt="{{$mytitle}}" title="{{$mytitle}}" /></a>
|
||||||
</div>
|
</div>
|
||||||
<div class="comment-edit-photo-end"></div>
|
<div class="comment-edit-photo-end"></div>
|
||||||
<textarea id="comment-edit-text-{{$id}}" class="comment-edit-text-empty" name="body" placeholder="{{$comment}}" onFocus="commentOpen(this,{{$id}});" onBlur="commentClose(this,{{$id}});"></textarea>
|
<textarea id="comment-edit-text-{{$id}}" class="comment-edit-text-empty" name="body" placeholder="{{$comment}}" onFocus="commentOpen(this,{{$id}});" onBlur="commentClose(this,{{$id}});">{{$default}}</textarea>
|
||||||
{{if $qcomment}}
|
{{if $qcomment}}
|
||||||
<select id="qcomment-select-{{$id}}" name="qcomment-{{$id}}" class="qcomment" onchange="qCommentInsert(this,{{$id}});" >
|
<select id="qcomment-select-{{$id}}" name="qcomment-{{$id}}" class="qcomment" onchange="qCommentInsert(this,{{$id}});" >
|
||||||
<option value=""></option>
|
<option value=""></option>
|
||||||
|
|
|
@ -44,7 +44,7 @@
|
||||||
data-role="insert-formatting" data-bbcode="video" data-id="{{$id}}"></a></li>
|
data-role="insert-formatting" data-bbcode="video" data-id="{{$id}}"></a></li>
|
||||||
</ul>
|
</ul>
|
||||||
<div class="comment-edit-bb-end"></div>
|
<div class="comment-edit-bb-end"></div>
|
||||||
<textarea id="comment-edit-text-{{$id}}" class="comment-edit-text-empty" name="body" placeholder="{{$comment}}" onFocus="commentOpen(this,{{$id}});cmtBbOpen(this, {{$id}});" onBlur="commentClose(this,{{$id}});cmtBbClose(this,{{$id}});"></textarea>
|
<textarea id="comment-edit-text-{{$id}}" class="comment-edit-text-empty" name="body" placeholder="{{$comment}}" onFocus="commentOpen(this,{{$id}});cmtBbOpen(this, {{$id}});" onBlur="commentClose(this,{{$id}});cmtBbClose(this,{{$id}});">{{$default}}</textarea>
|
||||||
{{if $qcomment}}
|
{{if $qcomment}}
|
||||||
<select id="qcomment-select-{{$id}}" name="qcomment-{{$id}}" class="qcomment" onchange="qCommentInsert(this,{{$id}});">
|
<select id="qcomment-select-{{$id}}" name="qcomment-{{$id}}" class="qcomment" onchange="qCommentInsert(this,{{$id}});">
|
||||||
<option value=""></option>
|
<option value=""></option>
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
<input type="hidden" name="post_id_random" value="{{$rand_num}}" />
|
<input type="hidden" name="post_id_random" value="{{$rand_num}}" />
|
||||||
|
|
||||||
<div class="bb form-group">
|
<div class="bb form-group">
|
||||||
<textarea id="comment-edit-text-{{$id}}" class="comment-edit-text-empty form-control text-autosize" name="body" placeholder="{{$comment}}" onFocus="commentOpenUI(this,{{$id}});"></textarea>
|
<textarea id="comment-edit-text-{{$id}}" class="comment-edit-text-empty form-control text-autosize" name="body" placeholder="{{$comment}}" onFocus="commentOpenUI(this,{{$id}});">{{$default}}</textarea>
|
||||||
</div>
|
</div>
|
||||||
{{if $qcomment}}
|
{{if $qcomment}}
|
||||||
<select id="qcomment-select-{{$id}}" name="qcomment-{{$id}}" class="qcomment" onchange="qCommentInsert(this,{{$id}});">
|
<select id="qcomment-select-{{$id}}" name="qcomment-{{$id}}" class="qcomment" onchange="qCommentInsert(this,{{$id}});">
|
||||||
|
|
|
@ -42,7 +42,7 @@
|
||||||
class="comment-edit-text-empty"
|
class="comment-edit-text-empty"
|
||||||
name="body"
|
name="body"
|
||||||
placeholder="{{$comment}}"
|
placeholder="{{$comment}}"
|
||||||
onFocus="commentOpen(this,{{$id}}) && cmtBbOpen({{$id}});"></textarea>
|
onFocus="commentOpen(this,{{$id}}) && cmtBbOpen({{$id}});">{{$default}}</textarea>
|
||||||
{{if $qcomment}}
|
{{if $qcomment}}
|
||||||
<select id="qcomment-select-{{$id}}" name="qcomment-{{$id}}" class="qcomment" onchange="qCommentInsert(this,{{$id}});">
|
<select id="qcomment-select-{{$id}}" name="qcomment-{{$id}}" class="qcomment" onchange="qCommentInsert(this,{{$id}});">
|
||||||
<option value=""></option>
|
<option value=""></option>
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
<a class="comment-edit-photo-link" href="{{$mylink}}" title="{{$mytitle}}"><img class="my-comment-photo" src="{{$myphoto}}" alt="{{$mytitle}}" title="{{$mytitle}}" /></a>
|
<a class="comment-edit-photo-link" href="{{$mylink}}" title="{{$mytitle}}"><img class="my-comment-photo" src="{{$myphoto}}" alt="{{$mytitle}}" title="{{$mytitle}}" /></a>
|
||||||
</div>
|
</div>
|
||||||
<div class="comment-edit-photo-end"></div>
|
<div class="comment-edit-photo-end"></div>
|
||||||
<textarea id="comment-edit-text-{{$id}}" class="comment-edit-text-empty" name="body" placeholder="{{$comment}}" onFocus="commentOpen(this,{{$id}});"></textarea>
|
<textarea id="comment-edit-text-{{$id}}" class="comment-edit-text-empty" name="body" placeholder="{{$comment}}" onFocus="commentOpen(this,{{$id}});">{{$default}}</textarea>
|
||||||
{{if $qcomment}}
|
{{if $qcomment}}
|
||||||
<select id="qcomment-select-{{$id}}" name="qcomment-{{$id}}" class="qcomment" onchange="qCommentInsert(this,{{$id}});">
|
<select id="qcomment-select-{{$id}}" name="qcomment-{{$id}}" class="qcomment" onchange="qCommentInsert(this,{{$id}});">
|
||||||
<option value=""></option>
|
<option value=""></option>
|
||||||
|
|
Loading…
Reference in a new issue