Code: Select all
* Get the HTML formatted reference of the notification
*
* @return string
*/
public function get_reference()
{
return censor_text($this->get_data('post_subject'));
}
Code: Select all
* Get the HTML formatted reference of the notification
*
* @return string
*/
public function get_reference()
{
return censor_text($this->get_data('post_subject'));
}
Code: Select all
* Get the HTML formatted reference of the notification
*
* @return string
*/
public function get_reference()
{
return censor_text(utf8_normalize_nfc($this->get_data('post_subject')));
}
thanks for the help, but it didn't workViolaF wrote: ↑Thu Nov 05, 2020 8:58 pmTry:
Code: Select all
* Get the HTML formatted reference of the notification * * @return string */ public function get_reference() { return censor_text(utf8_normalize_nfc($this->get_data('post_subject'))); }
notification_data
field in phpbb_notifications
table (phpbb_ prefix
may vary) in the database?Code: Select all
a:4:{s:12:"requester_id";i:36823;s:7:"user_id";i:28027;s:8:"topic_id";i:23473;s:12:"post_subject";s:45:"Desafios para a pr??tica da leitura no Brasil";}
Code: Select all
<?php
public function get_type()
{
return 'notification.type.pontuacao';
}
/**
* Notification option data (for outputting to the user)
*
* @var bool|array False if the service should use it's default data
* Array of data (including keys 'id', 'lang', and 'group')
*/
public static $notification_option = array(
'lang' => 'NOTIFICACAO_PAINEL_TITULO',
);
/** @var \phpbb\user_loader */
protected $user_loader;
/** @var \phpbb\config\config */
protected $config;
public function set_config(\phpbb\config\config $config)
{
$this->config = $config;
}
public function set_user_loader(\phpbb\user_loader $user_loader)
{
$this->user_loader = $user_loader;
}
/**
* Is this type available to the current user (defines whether or not it will be shown in the UCP Edit notification options)
*
* @return bool True/False whether or not this is available to the user
*/
public function is_available()
{
return true;
}
/**
* Get the id of the liker
*
* @param array $data The data for the like
* @return int
*/
public static function get_item_id($data)
{
return $data['topic_id'];
}
/**
* Get the id of the parent
*
* @param array $data The data for the like
* @return int
*/
public static function get_item_parent_id($data)
{
return isset($data['topic_id']) ? $data['topic_id'] : 0;
}
/**
* Find the users who will receive notifications
*
* @param array $data The data for the like
*
* @return array
*/
public function find_users_for_notification($data, $options = array())
{
$options = array_merge(array(
'ignore_users' => array(),
), $options);
$users = array(
$data['user_id'] => 0,
);
$this->user_loader->load_users(array_keys($users));
return $this->check_user_notification_options(array_keys($users), $options);
}
/**
* Get the user's avatar
*/
public function get_avatar()
{
return $this->user_loader->get_avatar($this->get_data('requester_id'), false, true);
}
/**
* Get the HTML formatted title of this notification
*
* @return string
*/
public function get_title()
{
$username = $this->user_loader->get_username($this->get_data('requester_id'), 'no_profile');
return $this->language->lang('NOTIFICACAO_PONTUACAO', $username);
}
/**
* Get the HTML formatted reference of the notification
*
* @return string
*/
public function get_reference()
{
return censor_text($this->get_data('post_subject'));
}
/**
* Get email template
*
* @return string|bool
*/
public function get_email_template()
{
return '@red1000_pontuacao/pontuacao_mail';
}
/**
* Get email template variables
*
* @return array
*/
public function get_email_template_variables()
{
return [
'PONTUADOR_NAME' => $this->user_loader->get_username($this->get_data('requester_id'), 'username'),
'AUTOR_NAME' => $this->user_loader->get_username($this->get_data('user_id'), 'username'),
'TOPIC_TITLE' => $this->get_data('post_subject'),
'U_LINK_TO_TOPIC' => generate_board_url() . '/viewtopic.' . $this->php_ext . '?t=' . $this->get_data('topic_id'),
'U_LINK_NOTIFICACOES' => generate_board_url() . '/ucp.' . $this->php_ext . '?i=ucp_notifications&mode=notification_options'
];
}
/**
* Get the url to this item
*
* @return string URL
*/
public function get_url()
{
return append_sid($this->phpbb_root_path . 'viewtopic.' . $this->php_ext, "t=". $this->get_data('topic_id'));
}
/**
* Users needed to query before this notification can be displayed
*
* @return array Array of user_ids
*/
public function users_to_query()
{
return array($this->get_data('requester_id'));
}
/**
* Function for preparing the data for insertion in an SQL query
* (The service handles insertion)
*
* @param array $data The data for the updated rules
* @param array $pre_create_data Data from pre_create_insert_array()
*
* @return array Array of data ready to be inserted into the database
*/
public function create_insert_array($data, $pre_create_data = array())
{
$this->set_data('requester_id', $data['requester_id']);
$this->set_data('user_id', $data['user_id']);
$this->set_data('topic_id', $data['topic_id']);
$this->set_data('post_subject', $data['post_subject']);
parent::create_insert_array($data, $pre_create_data);
}
}
Code: Select all
class mainnotificacao
{
/**
* Constructor
*
* @param \phpbb\config\config $config Config object
* @param \phpbb\db\driver\driver $db Database object
* @param \phpbb\request\request $request Request object
* @param \phpbb\template\template $template Template object
* @param \phpbb\user $user User object
* @param Container $phpbb_container
* @param string $root_path phpBB root path
* @param string $php_ext phpEx
* @access public
*/
public function __construct(\phpbb\config\config $config, \phpbb\db\driver\driver_interface $db, \phpbb\request\request $request, \phpbb\template\template $template, \phpbb\user $user, Container $phpbb_container, $root_path, $php_ext)
{
$this->config = $config;
$this->db = $db;
$this->request = $request;
$this->template = $template;
$this->user = $user;
$this->phpbb_container = $phpbb_container;
$this->root_path = $root_path;
$this->php_ext = $php_ext;
}
/**
* Main notification function
* @param type Type of notification (add/confirm)
* @param post_id Post ID
* @param poster_user User to notify
* @param liker_user User that trigered the action
*/
public function notify($type, $topic_id, $post_subject, $author_user_id, $pontuador_user)
{
$notification_data = array(
'topic_id' => (int) $topic_id,
'post_subject' => $post_subject,
'user_id' => (int) $author_user_id,
'requester_id' => (int) $pontuador_user,
);
//$this->test($notification_data);
$phpbb_notifications = $this->phpbb_container->get('notification_manager');
if ($notification_data['requester_id'] != $notification_data['user_id'])
{
switch ($type)
{
case 'add':
$phpbb_notifications->add_notifications('notification.type.pontuacao', $notification_data);
break;
case 'remove':
$notifications = $phpbb_notifications->get_item_type_class('notification.type.pontuacao');
$phpbb_notifications->delete_notifications('notification.type.pontuacao', $notifications->get_item_id($notification_data));
break;
}
}
}
}
public function notify($type, $topic_id, $post_subject, $author_user_id, $pontuador_user)
is being called from / its arguments are coming from? Especially the code where $post_subject
is initialized.Code: Select all
$forum_subject = $this->request->variable('subject', 'Tópico');
true
.
Code: Select all
$forum_subject = $this->request->variable('subject', 'Tópico', true);