Модернизация профиля: Часть 1. Скрываем профиль от посторонних
28
в процессе модернизации своего профиля реализовал несколько фишечек.
По заявка фишка номер раз: Скрываем профиль от посторонних глаз.
идем в phpmyadmin
1) в таблице prefix_user создаем поле user_profile_closed с типом enum('all','friend','none') не Null и значением по умолчанию all
2) classes/modules/user/entity/User.entity.class.php
добавляем
3) classes/modules/user/mapper/User.mapper.class.php
после
вставить
после
вставить
4) classes/action/ActionSettings.class.php
в событие
добавляем
5) classes/actions/ActionProfile.class.php
вот тут начинается самая странная вщщь для меня :)
в Init() добавляем
(возможно это коряво и неправильно, не могу сказать)
далее, ищем по тексту
и заменяем на
6) templates/skin/.../actions/ActionSettings/profile.tpl
вставить
7) templates/skin/.../actions/ActionProfile/whois.tpl
после
вставить
ну и перед
вставить
8)…
9) PROFIT
ну вот вроде бы и все должно работать. вопросы, предложения и ошибки прошу в комментарии.
По заявка фишка номер раз: Скрываем профиль от посторонних глаз.
идем в phpmyadmin
1) в таблице prefix_user создаем поле user_profile_closed с типом enum('all','friend','none') не Null и значением по умолчанию all
2) classes/modules/user/entity/User.entity.class.php
добавляем
public function setProfileClosed($data) {
$this->_aData['user_profile_closed']=$data;
public function getProfileClosed() {
return $this->_aData['user_profile_closed'];3) classes/modules/user/mapper/User.mapper.class.php
после
user_activate = ? , вставить
user_profile_closed = ? ,после
$oUser->getActivate(),вставить
$oUser->getProfileClosed(),4) classes/action/ActionSettings.class.php
в событие
protected function EventProfile() {добавляем
/**
* Проверяем закрыт ли профиль
*/
if (in_array(getRequest('profile_closed'),array('all','friend','none'))) {
$this->oUserCurrent->setProfileClosed(getRequest('profile_closed'));
} else {
$this->oUserCurrent->setProfileClosed('all');
}5) classes/actions/ActionProfile.class.php
вот тут начинается самая странная вщщь для меня :)
в Init() добавляем
$this->oUserCurrent=$this->User_GetUserCurrent();(возможно это коряво и неправильно, не могу сказать)
далее, ищем по тексту
$aUsersFrend=$this->User_GetUsersFrend($this->oUserProfile->getId());и заменяем на
$aFriendProfile=0;
$aUsersFrend=$this->User_GetUsersFrend($this->oUserProfile->getId());
foreach ($aUsersFrend as $oUser) {
if(!$this->oUserCurrent){
$aFriendProfile=0;}
else{
if ($this->oUserCurrent->getId() == $oUser->getId() or $this->oUserCurrent->getId() == $this->oUserProfile->getId()){
$aFriendProfile=1; }
}
}
$this->Viewer_Assign('aFriendProfile',$aFriendProfile);6) templates/skin/.../actions/ActionSettings/profile.tpl
вставить
<p><label for="">ПОказывать ваш профиль:</label>
<label for=""><input type="radio" name="profile_closed" id="profile_closed_a" value="all" {if $oUserCurrent->getProfileClosed()=='all'}checked{/if} class="radio" /> — Всем</label>
<label for=""><input type="radio" name="profile_closed" id="profile_closed_f" value="friend" {if $oUserCurrent->getProfileClosed()=='friend'}checked{/if} class="radio" /> — Друзьям</label>
<label for=""><input type="radio" name="profile_closed" id="profile_closed_n" value="none" {if $oUserCurrent->getProfileClosed()=='none'}checked{/if} class="radio" /> — Никому</label></p>
7) templates/skin/.../actions/ActionProfile/whois.tpl
после
{include file='header.tpl' menu="profile"}вставить
{if $oUserProfile->getProfileClosed() == 'none' and $oUserCurrent && $oUserCurrent->getId() != $oUserProfile->getId() }
Пользователь предпочел скрыть свой профиль
{elseif $oUserProfile->getProfileClosed() == 'friend' and $aFriendProfile == 0}
Пользователь предпочел открыть свой профиль только для друзей
{else}ну и перед
{include file='footer.tpl'}вставить
{/if}8)…
9) PROFIT
ну вот вроде бы и все должно работать. вопросы, предложения и ошибки прошу в комментарии.
- +4
- 14 июня 2009, 19:58
- randomtoy
такая вот ошибка вылезла при открытии профиля, когда я сохранил чтобы он был виден только мне и вышел из логина своего
Fatal error: Uncaught exception 'Exception' with message 'The module has no required method: User->GetUsersFrend()' in /home/users1/n/neosashadesign/domains/metroboy.ru/engine/classes/Engine.class.php:329 Stack trace: #0 /home/users1/n/neosashadesign/domains/metroboy.ru/engine/classes/Action.class.php(298): Engine->_CallModule('User_GetUsersFr...', Array) #1 /home/users1/n/neosashadesign/domains/metroboy.ru/classes/actions/ActionProfile.class.php(154): Action->__call('User_GetUsersFr...', Array) #2 /home/users1/n/neosashadesign/domains/metroboy.ru/classes/actions/ActionProfile.class.php(154): ActionProfile->User_GetUsersFrend('1') #3 /home/users1/n/neosashadesign/domains/metroboy.ru/engine/classes/Action.class.php(104) : eval()'d code(1): ActionProfile->EventWhois() #4 /home/users1/n/neosashadesign/domains/metroboy.ru/engine/classes/Action.class.php(104): eval() #5 /home/users1/n/neosashadesign/domains/metroboy.ru/engine/classes/Router.class.php(206): Action->ExecEvent() #6 /home/users1/n/neosashadesign/domains/metroboy.r in /home/users1/n/neosashadesign/domains/metroboy.ru/engine/classes/Engine.class.php on line 329
Спасибо.
Но при установки в none, гости всё равно видят профиль, только friend скрывает.
Что нужно подправить в 7 шаге?
Но при установки в none, гости всё равно видят профиль, только friend скрывает.
Что нужно подправить в 7 шаге?
Сам себе отвечу (нашел таки время, хотя решение нашел почти сразу):
Этот код вставляется в templates/skin/.../actions/ActionProfile/whois.tpl — разрешается просмотр профиля только для друзей, себя и администраторов или всем.
Просто смысла прятать профиль и от друзей не вижу.
{if $oUserProfile->getProfileClosed() == 'friend' and $aFriendProfile == 0 and (!$oUserCurrent || (!$oUserCurrent->isAdministrator() && $oUserCurrent->getId() != $oUserProfile->getId()))}
<div class="profile-user"><p class="nickname">Пользователь {$oUserProfile->getLogin()} показывает свои персональные данные только друзьям!</div>
{else}Этот код вставляется в templates/skin/.../actions/ActionProfile/whois.tpl — разрешается просмотр профиля только для друзей, себя и администраторов или всем.
Просто смысла прятать профиль и от друзей не вижу.
Комментарии (6)
RSS свернуть / развернуть