Re: Как закрыть тему для гостей
Добавлено: 29.10.2017 18:59
скачать русский перевод, моды, скины и стили для phpBB, phpBB3
https://www.phpbbguru.net/community/
Код: Выделить всё
class listener implements EventSubscriberInterface
{
/**
* Constructor
*
* @param \phpbb\config\config $config Config object
*/
public function __construct( \phpbb\user $user )
{
$this->user = $user;
}
static public function getSubscribedEvents()
{
return array(
'core.viewforum_get_topic_ids_data' => 'forbidden_topic',
);
}
public function forbidden_topic()
{
if (!$this->user->data['is_registered'])
{
$sql_ary = $event['sql_ary'];
$sql_ary['WHERE'] .= ' AND t.topic_id <> 49';
$event['sql_ary'] = $sql_ary;
}
}
}
public function forbidden_topic($event)
Она возвращает элемент массива
$event
обратно в код движка. В строке
Код: Выделить всё
$event['sql_ary'] = $sql_ary;
composer.json
составили? (Он в теме не мелькал)Нет, но объявлятся должна так
Код: Выделить всё
public function forbidden_topic($event)
Ну, грубо говоря, не возвращает, а переназначает.
Код: Выделить всё
<?php
/**
*
* @package phpBB Extension -
* @copyright (c) 2017 Anton Charov
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
namespace Anton\forbiddentopic\event;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
/**
* Event listener
*/
class listener implements EventSubscriberInterface
{
/**
* Assign functions defined in this class to event listeners in the core
*
* @return array
* @static
* @access public
*/
static public function getSubscribedEvents()
{
return array(
'core.viewforum_get_topic_ids_data' => 'forbidden_topic',
);
}
/** @var \phpbb\template\template */
protected $template;
//** @var string phpbb_root_path */
protected $phpbb_root_path;
/**
* Constructor
*/
public function __construct(\phpbb\user $user)
{
$this->user = $user;
}
public function forbidden_topic($event)
{
if (!$this->user->data['is_registered'])
{
$sql_ary = $event['sql_ary'];
$sql_ary['WHERE'] .= ' AND t.topic_id <> 49';
$event['sql_ary'] = $sql_ary;
}
}
}
Всё в нижнем регистре должно быть.
Код: Выделить всё
/** @var \phpbb\template\template */
protected $template;
//** @var string phpbb_root_path */
protected $phpbb_root_path;
Код: Выделить всё
protected $user;
Код: Выделить всё
"php": ">=5.3.3,"
Код: Выделить всё
"php": ">=5.3.3",