1
0
Fork 0
mirror of https://github.com/Oreolek/ifhub.club.git synced 2024-07-02 22:45:02 +03:00
ifhub.club/application/classes/actions/ActionMy.class.php

120 lines
4 KiB
PHP
Raw Normal View History

<?php
2014-10-08 08:20:29 +03:00
/*
* LiveStreet CMS
* Copyright © 2013 OOO "ЛС-СОФТ"
*
* ------------------------------------------------------
*
* Official site: www.livestreetcms.com
* Contact e-mail: office@livestreetcms.com
*
* GNU General Public License, version 2:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*
* ------------------------------------------------------
*
* @link http://www.livestreetcms.com
* @copyright 2013 OOO "ЛС-СОФТ"
* @author Maxim Mzhelskiy <rus.engine@gmail.com>
*
*/
2008-09-21 09:36:57 +03:00
/**
* Экшен обработки УРЛа вида /my/
* Оставлен только для редиректов со старых УРЛ на новые
2008-09-21 09:36:57 +03:00
*
2014-10-08 08:20:29 +03:00
* @package application.actions
* @since 1.0
2008-09-21 09:36:57 +03:00
*/
class ActionMy extends Action
{
/**
* Объект юзера чей профиль мы смотрим
*
* @var ModuleUser_EntityUser|null
*/
protected $oUserProfile = null;
/**
* Инициализация
*/
public function Init()
{
}
/**
* Регистрируем евенты
*/
protected function RegisterEvent()
{
$this->AddEventPreg('/^.+$/i', '/^(page([1-9]\d{0,5}))?$/i', 'EventTopics');
$this->AddEventPreg('/^.+$/i', '/^blog$/i', '/^(page([1-9]\d{0,5}))?$/i', 'EventTopics');
$this->AddEventPreg('/^.+$/i', '/^comment$/i', '/^(page([1-9]\d{0,5}))?$/i', 'EventComments');
}
/**********************************************************************************
************************ РЕАЛИЗАЦИЯ ЭКШЕНА ***************************************
**********************************************************************************
*/
/**
* Выводит список топиков которые написал юзер
* Перенаправляет на профиль пользователя
*
*/
protected function EventTopics()
{
/**
* Получаем логин из УРЛа
*/
$sUserLogin = $this->sCurrentEvent;
/**
* Проверяем есть ли такой юзер
*/
if (!($this->oUserProfile = $this->User_GetUserByLogin($sUserLogin))) {
return parent::EventNotFound();
}
/**
* Передан ли номер страницы
*/
if ($this->GetParamEventMatch(0, 0) == 'blog') {
$iPage = $this->GetParamEventMatch(1, 2) ? $this->GetParamEventMatch(1, 2) : 1;
} else {
$iPage = $this->GetParamEventMatch(0, 2) ? $this->GetParamEventMatch(0, 2) : 1;
}
/**
* Выполняем редирект на новый URL, в новых версиях LS экшен "my" будет удален
*/
$sPage = $iPage == 1 ? '' : "page{$iPage}/";
Router::Location($this->oUserProfile->getUserWebPath() . 'created/topics/' . $sPage);
}
/**
* Выводит список комментариев которые написал юзер
* Перенаправляет на профиль пользователя
*
*/
protected function EventComments()
{
/**
* Получаем логин из УРЛа
*/
$sUserLogin = $this->sCurrentEvent;
/**
* Проверяем есть ли такой юзер
*/
if (!($this->oUserProfile = $this->User_GetUserByLogin($sUserLogin))) {
return parent::EventNotFound();
}
/**
* Передан ли номер страницы
*/
$iPage = $this->GetParamEventMatch(1, 2) ? $this->GetParamEventMatch(1, 2) : 1;
/**
* Выполняем редирект на новый URL, в новых версиях LS экшен "my" будет удален
*/
$sPage = $iPage == 1 ? '' : "page{$iPage}/";
Router::Location($this->oUserProfile->getUserWebPath() . 'created/comments/' . $sPage);
}
}