Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Добавил опции приватности пользователя #1423

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
50 changes: 29 additions & 21 deletions system/controllers/users/actions/profile.php
Expand Up @@ -117,41 +117,49 @@ private function getSystemFields($profile) {

// Если включена опция "просмотр даты регистрации"
if (!empty($this->options['show_reg_data'])) {

$fields['date_reg'] = [
'title' => LANG_USERS_PROFILE_REGDATE,
'text' => string_date_age_max($profile['date_reg'], true)
];
// Проверяем настройки приватности (последний визит)
if(cmsUser::getInstance()->isPrivacyAllowed($profile, 'users_show_reg_data')) {
$fields['date_reg'] = [
'title' => LANG_USERS_PROFILE_REGDATE,
'text' => string_date_age_max($profile['date_reg'], true)
];
}
}

// Если включена опция "показать последний визит пользователя"
if (!empty($this->options['show_last_visit'])) {
// Если пользователь не в сети
if (!$profile['is_online']) {
$fields['date_log'] = [
'title' => LANG_USERS_PROFILE_LOGDATE,
'text' => string_date_age_max($profile['date_log'], true)
];
// Проверяем настройки приватности (последний визит)
if(cmsUser::getInstance()->isPrivacyAllowed($profile, 'users_show_last_visit')) {
$fields['date_log'] = [
'title' => LANG_USERS_PROFILE_LOGDATE,
'text' => string_date_age_max($profile['date_log'], true)
];
}
}
}

// Если включена опция "показывать группы пользователя"
if (!empty($this->options['show_user_groups'])) {

// Получаем группы пользователя
$groups = $this->model->getGroups();
// Проверяем настройки приватности (группы пользователя)
if(cmsUser::getInstance()->isPrivacyAllowed($profile, 'users_show_user_groups')) {
// Получаем группы пользователя
$groups = $this->model->getGroups();

$groups_title = [];
$groups_title = [];

// Заполняем массив именами групп
foreach ($profile['groups'] as $group_id) {
$groups_title[] = $groups[$group_id]['title'];
}
// Заполняем массив именами групп
foreach ($profile['groups'] as $group_id) {
$groups_title[] = $groups[$group_id]['title'];
}

$fields['groups'] = [
'title' => LANG_GROUPS,
'text' => implode(', ', $groups_title)
];
$fields['groups'] = [
'title' => LANG_GROUPS,
'text' => implode(', ', $groups_title)
];
}
}

if ($profile['inviter_id'] && !empty($profile['inviter_nickname'])) {
Expand Down Expand Up @@ -292,4 +300,4 @@ private function getToolButtons($profile) {

}

}
}
42 changes: 33 additions & 9 deletions system/controllers/users/hooks/user_privacy_types.php
Expand Up @@ -2,20 +2,44 @@

class onUsersUserPrivacyTypes extends cmsAction {

public function run(){
public function run() {

$types = array();
$types = [];

$types['users_profile_view'] = array(
$types['users_profile_view'] = [
'title' => LANG_USERS_PRIVACY_PROFILE_VIEW,
'options' => array('', 'anyone', 'friends')
);
'options' => ['', 'anyone', 'friends']
];

if(!empty($this->options['is_friends_on'])){
$types['users_friendship'] = array(
if(!empty($this->options['is_friends_on'])) {
$types['users_friendship'] = [
'title' => LANG_USERS_PRIVACY_FRIENDSHIP,
'options' => array('', 'anyone')
);
'options' => ['', 'anyone']
];
}

//Если в админке включена опция "Показывать дату регистрации пользователя"
if(!empty($this->options['show_reg_data'])) {
$types['users_show_reg_data'] = [
'title' => LANG_USERS_PRIVACY_SHOW_REG_DATA,
'options' => ['', 'anyone', 'friends']
];
}

//Если в админке включена опция "Показывать последний визит пользователя"
if(!empty($this->options['show_last_visit'])) {
$types['users_show_last_visit'] = [
'title' => LANG_USERS_PRIVACY_SHOW_LAST_VISIT,
'options' => ['', 'anyone', 'friends']
];
}

//Если в админке включена опция "Показывать группы пользователя"
if(!empty($this->options['show_user_groups'])) {
$types['users_show_user_groups'] = [
'title' => LANG_USERS_PRIVACY_SHOW_USER_GROUPS,
'options' => ['', 'anyone', 'friends']
];
}

return $types;
Expand Down
5 changes: 4 additions & 1 deletion system/languages/ru/controllers/users/users.php
Expand Up @@ -142,8 +142,11 @@
define('LANG_USERS_NOTIFY_FRIEND_ACCEPT', 'Уведомлять об одобренных запросах дружбы');
define('LANG_USERS_NOTIFY_FRIEND_DELETE', 'Уведомлять о прекращении дружбы');

define('LANG_USERS_PRIVACY_FRIENDSHIP', 'Кто может отправлять мне запросы дружбы?');
define('LANG_USERS_PRIVACY_FRIENDSHIP', 'Кто может отправлять вам запросы дружбы?');
define('LANG_USERS_PRIVACY_PROFILE_VIEW', 'Кто может просматривать ваш профиль?');
define('LANG_USERS_PRIVACY_SHOW_REG_DATA', 'Кто может видеть вашу дату регистрации?');
define('LANG_USERS_PRIVACY_SHOW_LAST_VISIT', 'Кто может видеть ваш последний визит?');
define('LANG_USERS_PRIVACY_SHOW_USER_GROUPS', 'Кто может видеть ваши группы?');
define('LANG_USERS_PRIVACY_PROFILE_WALL', 'Кто может писать на вашей стене?');
define('LANG_USERS_PRIVACY_PROFILE_WALL_REPLY', 'Кто может комментировать записи на стене?');
define('LANG_USERS_PRIVACY_PROFILE_CTYPE', 'Кто может просматривать список ваших %s?');
Expand Down