mirror of
https://github.com/openvk/openvk
synced 2024-12-23 00:51:03 +03:00
Messenger: Allow sending messages not only to friends and add a privacy setting to customize this
Closes #91
This commit is contained in:
parent
126abe3bbb
commit
e5c650e351
8 changed files with 21 additions and 4 deletions
|
@ -372,6 +372,7 @@ class User extends RowModel
|
|||
"friends.read",
|
||||
"friends.add",
|
||||
"wall.write",
|
||||
"messages.write",
|
||||
],
|
||||
])->get($id);
|
||||
}
|
||||
|
@ -756,6 +757,7 @@ class User extends RowModel
|
|||
"friends.read",
|
||||
"friends.add",
|
||||
"wall.write",
|
||||
"messages.write",
|
||||
],
|
||||
])->set($id, $status)->toInteger());
|
||||
}
|
||||
|
|
|
@ -124,7 +124,7 @@ final class MessengerPresenter extends OpenVKPresenter
|
|||
}
|
||||
|
||||
$sel = $this->getCorrespondent($sel);
|
||||
if($sel->getId() !== $this->user->id && $sel->getSubscriptionStatus($this->user->identity) !== 3)
|
||||
if($sel->getId() !== $this->user->id && !$sel->getPrivacyPermission('messages.write', $this->user->identity))
|
||||
exit(header("HTTP/1.1 403 Forbidden"));
|
||||
|
||||
$cor = new Correspondence($this->user->identity, $sel);
|
||||
|
|
|
@ -329,6 +329,7 @@ final class UserPresenter extends OpenVKPresenter
|
|||
"friends.read",
|
||||
"friends.add",
|
||||
"wall.write",
|
||||
"messages.write",
|
||||
];
|
||||
foreach($settings as $setting) {
|
||||
$input = $this->postParam(str_replace(".", "_", $setting));
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="messenger-app--input">
|
||||
{if $correspondent->getId() === $thisUser->getId() || ($correspondent->getSubscriptionStatus($thisUser) === 3)}
|
||||
{if $correspondent->getId() === $thisUser->getId() || $correspondent->getPrivacyPermission('messages.write', $thisUser)}
|
||||
<img class="ava" src="{$thisUser->getAvatarUrl()}" alt="{$thisUser->getCanonicalName()}" />
|
||||
<div class="messenger-app--input---messagebox">
|
||||
<textarea
|
||||
|
@ -54,7 +54,7 @@
|
|||
</div>
|
||||
<img class="ava" src="{$correspondent->getAvatarUrl()}" alt="{$correspondent->getCanonicalName()}" />
|
||||
{else}
|
||||
<div class="blocked" data-localized-text="Вы не можете писать сообщения {$correspondent->getCanonicalName()}, так как его нет в вашем списке друзей."></div>
|
||||
<div class="blocked" data-localized-text="Вы не можете писать сообщения {$correspondent->getCanonicalName()} из-за его настроек приватности."></div>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -316,6 +316,18 @@
|
|||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width="120" valign="top">
|
||||
<span class="nobold">{_privacy_setting_write_messages}</span>
|
||||
</td>
|
||||
<td>
|
||||
<select name="messages.write", style="width: 164px;">
|
||||
<option value="2" {if $user->getPrivacySetting('messages.write') == 2}selected{/if}>{_privacy_value_anybody}</option>
|
||||
<option value="1" {if $user->getPrivacySetting('messages.write') == 1}selected{/if}>{_privacy_value_friends}</option>
|
||||
<option value="0" {if $user->getPrivacySetting('messages.write') == 0}selected{/if}>{_privacy_value_nobody}</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
|
||||
|
|
|
@ -92,6 +92,7 @@
|
|||
{/if}
|
||||
|
||||
<a n:if="OPENVK_ROOT_CONF['openvk']['preferences']['commerce'] && $user->getGiftCount() == 0" href="/gifts?act=pick&user={$user->getId()}" class="profile_link">{_send_gift}</a>
|
||||
<a n:if="$user->getPrivacyPermission('messages.write', $thisUser)" href="/im?sel={$user->getId()}" class="profile_link">{_"send_message"}</a>
|
||||
|
||||
{var subStatus = $user->getSubscriptionStatus($thisUser)}
|
||||
{if $subStatus === 0}
|
||||
|
@ -116,7 +117,6 @@
|
|||
<input type="submit" class="profile_link" value="{_"friends_reject"}" />
|
||||
</form>
|
||||
{elseif $subStatus === 3}
|
||||
<a href="/im?sel={$user->getId()}" class="profile_link">{_"send_message"}</a>
|
||||
<form action="/setSub/user" method="post" class="profile_link_form">
|
||||
<input type="hidden" name="act" value="rem" />
|
||||
<input type="hidden" name="id" value="{$user->getId()}" />
|
||||
|
|
|
@ -384,6 +384,7 @@
|
|||
"privacy_setting_see_friends" = "Who can see my friends";
|
||||
"privacy_setting_add_to_friends" = "Who can add me to friends";
|
||||
"privacy_setting_write_wall" = "Who can publish post on my wall";
|
||||
"privacy_setting_write_messages" = "Who can write messages to me";
|
||||
"privacy_value_anybody" = "Anybody";
|
||||
"privacy_value_anybody_dative" = "Anybody";
|
||||
"privacy_value_users" = "OpenVK users";
|
||||
|
|
|
@ -404,6 +404,7 @@
|
|||
"privacy_setting_see_friends" = "Кому видно моих друзей";
|
||||
"privacy_setting_add_to_friends" = "Кто может называть меня другом";
|
||||
"privacy_setting_write_wall" = "Кто может писать у меня на стене";
|
||||
"privacy_setting_write_messages" = "Кто может писать мне сообщения";
|
||||
"privacy_value_anybody" = "Все желающие";
|
||||
"privacy_value_anybody_dative" = "Всем желающим";
|
||||
"privacy_value_users" = "Пользователям OpenVK";
|
||||
|
|
Loading…
Reference in a new issue