作者:WarriorMachine
项目:warriormachines-phpb
/**
* Constructor
*
* @param \phpbb\event\dispatcher_interface $phpbb_dispatcher Event dispatcher
* @param \phpbb\user $user User Object
*/
public function __construct(\phpbb\event\dispatcher_interface $phpbb_dispatcher, \phpbb\user $user)
{
$this->dispatcher = $phpbb_dispatcher;
$this->user = $user;
$categories = $this->categories;
$types = $this->types;
$permissions = $this->permissions;
/**
* Allows to specify additional permission categories, types and permissions
*
* @event core.permissions
* @var array types Array with permission types (a_, u_, m_, etc.)
* @var array categories Array with permission categories (pm, post, settings, misc, etc.)
* @var array permissions Array with permissions. Each Permission has the following layout:
* '<type><permission>' => array(
* 'lang' => 'Language Key with a Short description', // Optional, if not set,
* // the permissions identifier '<type><permission>' is used with
* // all uppercase.
* 'cat' => 'Identifier of the category, the permission should be displayed in',
* ),
* Example:
* 'u_viewprofile' => array(
* 'lang' => 'ACL_U_VIEWPROFILE',
* 'cat' => 'profile',
* ),
* @since 3.1.0-a1
*/
$vars = array('types', 'categories', 'permissions');
extract($phpbb_dispatcher->trigger_event('core.permissions', compact($vars)));
$this->categories = $categories;
$this->types = $types;
$this->permissions = $permissions;
}
作者:WarriorMachine
项目:warriormachines-phpb
/**
* Generate the debug output string
*
* @param \phpbb\db\driver\driver_interface $db Database connection
* @param \phpbb\config\config $config Config object
* @param \phpbb\auth\auth $auth Auth object
* @param \phpbb\user $user User object
* @param \phpbb\event\dispatcher_interface $phpbb_dispatcher Event dispatcher
* @return string
*/
function phpbb_generate_debug_output(\phpbb\db\driver\driver_interface $db, \phpbb\config\config $config, \phpbb\auth\auth $auth, \phpbb\user $user, \phpbb\event\dispatcher_interface $phpbb_dispatcher)
{
$debug_info = array();
// Output page creation time
if (defined('PHPBB_DISPLAY_LOAD_TIME')) {
if (isset($GLOBALS['starttime'])) {
$totaltime = microtime(true) - $GLOBALS['starttime'];
$debug_info[] = sprintf('<abbr title="SQL time: %.3fs / PHP time: %.3fs">Time: %.3fs</abbr>', $db->get_sql_time(), $totaltime - $db->get_sql_time(), $totaltime);
}
$debug_info[] = sprintf('<abbr title="Cached: %d">Queries: %d</abbr>', $db->sql_num_queries(true), $db->sql_num_queries());
$memory_usage = memory_get_peak_usage();
if ($memory_usage) {
$memory_usage = get_formatted_filesize($memory_usage);
$debug_info[] = 'Peak Memory Usage: ' . $memory_usage;
}
}
if (defined('DEBUG')) {
$debug_info[] = 'GZIP: ' . ($config['gzip_compress'] && @extension_loaded('zlib') ? 'On' : 'Off');
if ($user->load) {
$debug_info[] = 'Load: ' . $user->load;
}
if ($auth->acl_get('a_')) {
$debug_info[] = '<a href="' . build_url() . '&explain=1">SQL Explain</a>';
}
}
/**
* Modify debug output information
*
* @event core.phpbb_generate_debug_output
* @var array debug_info Array of strings with debug information
*
* @since 3.1.0-RC3
*/
$vars = array('debug_info');
extract($phpbb_dispatcher->trigger_event('core.phpbb_generate_debug_output', compact($vars)));
return implode(' | ', $debug_info);
}
作者:MrAdde
项目:phpb
/**
* Controller for /help/{mode} routes
*
* @param string $mode
* @return \Symfony\Component\HttpFoundation\Response A Symfony Response object
* @throws http_exception when the $mode is not known by any extension
*/
public function handle($mode)
{
switch ($mode) {
case 'faq':
case 'bbcode':
$page_title = $mode === 'faq' ? $this->user->lang['FAQ_EXPLAIN'] : $this->user->lang['BBCODE_GUIDE'];
$this->user->add_lang($mode, false, true);
break;
default:
$page_title = $this->user->lang['FAQ_EXPLAIN'];
$ext_name = $lang_file = '';
/**
* You can use this event display a custom help page
*
* @event core.faq_mode_validation
* @var string page_title Title of the page
* @var string mode FAQ that is going to be displayed
* @var string lang_file Language file containing the help data
* @var string ext_name Vendor and extension name where the help
* language file can be loaded from
* @since 3.1.4-RC1
*/
$vars = array('page_title', 'mode', 'lang_file', 'ext_name');
extract($this->dispatcher->trigger_event('core.faq_mode_validation', compact($vars)));
if ($ext_name === '' || $lang_file === '') {
throw new http_exception(404, 'Not Found');
}
$this->user->add_lang($lang_file, false, true, $ext_name);
break;
}
$this->template->assign_vars(array('L_FAQ_TITLE' => $page_title, 'S_IN_FAQ' => true));
$this->assign_to_template($this->user->help);
make_jumpbox(append_sid("{$this->root_path}viewforum.{$this->php_ext}"));
return $this->helper->render('faq_body.html', $page_title);
}
作者:bruninoi
项目:phpb
/**
* {@inheritdoc}
*/
public function parse($text)
{
$parser = $this;
/**
* Modify a text before it is parsed
*
* @event core.text_formatter_s9e_parse_before
* @var \phpbb\textformatter\s9e\parser parser This parser service
* @var string text The original text
* @since 3.2.0-a1
*/
$vars = array('parser', 'text');
extract($this->dispatcher->trigger_event('core.text_formatter_s9e_parse_before', compact($vars)));
$xml = $this->parser->parse($text);
/**
* Modify a parsed text in its XML form
*
* @event core.text_formatter_s9e_parse_after
* @var \phpbb\textformatter\s9e\parser parser This parser service
* @var string xml The parsed text, in XML
* @since 3.2.0-a1
*/
$vars = array('parser', 'xml');
extract($this->dispatcher->trigger_event('core.text_formatter_s9e_parse_after', compact($vars)));
return $xml;
}
作者:bruninoi
项目:phpb
/**
* {@inheritdoc}
*/
public function render($xml)
{
if (isset($this->quote_helper)) {
$xml = $this->quote_helper->inject_metadata($xml);
}
$renderer = $this;
/**
* Modify a parsed text before it is rendered
*
* @event core.text_formatter_s9e_render_before
* @var \phpbb\textformatter\s9e\renderer renderer This renderer service
* @var string xml The parsed text, in its XML form
* @since 3.2.0-a1
*/
$vars = array('renderer', 'xml');
extract($this->dispatcher->trigger_event('core.text_formatter_s9e_render_before', compact($vars)));
if (isset($this->censor) && $this->viewcensors) {
// NOTE: censorHtml() is XML-safe
$xml = $this->censor->censorHtml($xml, true);
}
$html = $this->renderer->render($xml);
/**
* Modify a rendered text
*
* @event core.text_formatter_s9e_render_after
* @var string html The rendered text's HTML
* @var \phpbb\textformatter\s9e\renderer renderer This renderer service
* @since 3.2.0-a1
*/
$vars = array('html', 'renderer');
extract($this->dispatcher->trigger_event('core.text_formatter_s9e_render_after', compact($vars)));
return $html;
}
作者:phpb
项目:phpbb-cor
/**
* {@inheritdoc}
*/
public function get_item()
{
if (!isset($this->result)) {
if (!$this->get_sql()) {
return false;
}
$sql_ary = $this->sql;
/**
* Event to modify the feed item sql
*
* @event core.feed_base_modify_item_sql
* @var array sql_ary The SQL array to get the feed item data
*
* @since 3.1.10-RC1
*/
$vars = array('sql_ary');
extract($this->phpbb_dispatcher->trigger_event('core.feed_base_modify_item_sql', compact($vars)));
$this->sql = $sql_ary;
unset($sql_ary);
// Query database
$sql = $this->db->sql_build_query('SELECT', $this->sql);
$this->result = $this->db->sql_query_limit($sql, $this->num_items);
}
return $this->db->sql_fetchrow($this->result);
}
作者:Ernado
项目:phpb
/**
* Add a notification
*
* @param string|array $notification_type_name Type identifier or array of item types (only acceptable if the $data is identical for the specified types)
* Note: If you send an array of types, any user who could receive multiple notifications from this single item will only receive
* a single notification. If they MUST receive multiple notifications, call this function multiple times instead of sending an array
* @param array $data Data specific for this type that will be inserted
* @param array $options Optional options to control what notifications are loaded
* ignore_users array of data to specify which users should not receive certain types of notifications
* @return array Information about what users were notified and how they were notified
*/
public function add_notifications($notification_type_name, $data, array $options = array())
{
$options = array_merge(array('ignore_users' => array()), $options);
if (is_array($notification_type_name)) {
$notified_users = array();
$temp_options = $options;
foreach ($notification_type_name as $type) {
$temp_options['ignore_users'] = $options['ignore_users'] + $notified_users;
$notified_users += $this->add_notifications($type, $data, $temp_options);
}
return $notified_users;
}
// find out which users want to receive this type of notification
$notify_users = $this->get_item_type_class($notification_type_name)->find_users_for_notification($data, $options);
/**
* Allow filtering the notify_users array for a notification that is about to be sent.
* Here, $notify_users is already filtered by f_read and the ignored list included in the options variable
*
* @event core.notification_manager_add_notifications
* @var string notification_type_name The forum id from where the topic belongs
* @var array data Data specific for the notification_type_name used will be inserted
* @var array notify_users The array of userid that are going to be notified for this notification. Set to array() to cancel.
* @var array options The options that were used when this method was called (read only)
*
* @since 3.1.3-RC1
*/
$vars = array('notification_type_name', 'data', 'notify_users', 'options');
extract($this->phpbb_dispatcher->trigger_event('core.notification_manager_add_notifications', compact($vars)));
$this->add_notifications_for_users($notification_type_name, $data, $notify_users);
return $notify_users;
}
作者:Tarenda
项目:spring-websit
/**
* Create topic/post visibility SQL for all forums on the board
*
* Note: Read permissions are not checked. Forums without read permissions
* should be in $exclude_forum_ids
*
* @param $mode string Either "topic" or "post"
* @param $exclude_forum_ids array Array of forum ids which are excluded
* @param $table_alias string Table alias to prefix in SQL queries
* @return string The appropriate combination SQL logic for topic/post_visibility
*/
public function get_global_visibility_sql($mode, $exclude_forum_ids = array(), $table_alias = '')
{
$where_sqls = array();
$approve_forums = array_diff(array_keys($this->auth->acl_getf('m_approve', true)), $exclude_forum_ids);
$visibility_sql_overwrite = null;
/**
* Allow changing the result of calling get_global_visibility_sql
*
* @event core.phpbb_content_visibility_get_global_visibility_before
* @var array where_sqls The action the user tried to execute
* @var string mode Either "topic" or "post" depending on the query this is being used in
* @var array exclude_forum_ids Array of forum ids the current user doesn't have access to
* @var string table_alias Table alias to prefix in SQL queries
* @var array approve_forums Array of forums where the user has m_approve permissions
* @var string visibility_sql_overwrite Forces the function to return an implosion of where_sqls (joined by "OR")
* @since 3.1.3-RC1
*/
$vars = array('where_sqls', 'mode', 'exclude_forum_ids', 'table_alias', 'approve_forums', 'visibility_sql_overwrite');
extract($this->phpbb_dispatcher->trigger_event('core.phpbb_content_visibility_get_global_visibility_before', compact($vars)));
if ($visibility_sql_overwrite) {
return $visibility_sql_overwrite;
}
if (sizeof($exclude_forum_ids)) {
$where_sqls[] = '(' . $this->db->sql_in_set($table_alias . 'forum_id', $exclude_forum_ids, true) . '
AND ' . $table_alias . $mode . '_visibility = ' . ITEM_APPROVED . ')';
} else {
$where_sqls[] = $table_alias . $mode . '_visibility = ' . ITEM_APPROVED;
}
if (sizeof($approve_forums)) {
$where_sqls[] = $this->db->sql_in_set($table_alias . 'forum_id', $approve_forums);
return '(' . implode(' OR ', $where_sqls) . ')';
}
// There is only one element, so we just return that one
return $where_sqls[0];
}
作者:Tarenda
项目:spring-websit
/**
* Generate a pagination link based on the url and the page information
*
* @param string $base_url is url prepended to all links generated within the function
* If you use page numbers inside your controller route, base_url should contains a placeholder (%d)
* for the page. Also be sure to specify the pagination path information into the start_name argument
* @param string $on_page is the page for which we want to generate the link
* @param string $start_name is the name of the parameter containing the first item of the given page (example: start=20)
* If you use page numbers inside your controller route, start name should be the string
* that should be removed for the first page (example: /page/%d)
* @param int $per_page the number of items, posts, etc. to display per page, used to determine the number of pages to produce
* @return string URL for the requested page
*/
protected function generate_page_link($base_url, $on_page, $start_name, $per_page)
{
// A listener can set this variable to the new pagination URL
// to override the generate_page_link() function generated value
$generate_page_link_override = false;
/**
* Execute code and/or override generate_page_link()
*
* To override the generate_page_link() function generated value
* set $generate_page_link_override to the new URL value
*
* @event core.pagination_generate_page_link
* @var string base_url is url prepended to all links generated within the function
* If you use page numbers inside your controller route, base_url should contains a placeholder (%d)
* for the page. Also be sure to specify the pagination path information into the start_name argument
* @var string on_page is the page for which we want to generate the link
* @var string start_name is the name of the parameter containing the first item of the given page (example: start=20)
* If you use page numbers inside your controller route, start name should be the string
* that should be removed for the first page (example: /page/%d)
* @var int per_page the number of items, posts, etc. to display per page, used to determine the number of pages to produce
* @var bool|string generate_page_link_override Shall we return custom pagination link (string URL) or not (false)
* @since 3.1.0-RC5
*/
$vars = array('base_url', 'on_page', 'start_name', 'per_page', 'generate_page_link_override');
extract($this->phpbb_dispatcher->trigger_event('core.pagination_generate_page_link', compact($vars)));
if ($generate_page_link_override) {
return $generate_page_link_override;
}
if (!is_string($base_url)) {
if (is_array($base_url['routes'])) {
$route = $on_page > 1 ? $base_url['routes'][1] : $base_url['routes'][0];
} else {
$route = $base_url['routes'];
}
$params = isset($base_url['params']) ? $base_url['params'] : array();
$is_amp = isset($base_url['is_amp']) ? $base_url['is_amp'] : true;
$session_id = isset($base_url['session_id']) ? $base_url['session_id'] : false;
if ($on_page > 1 || !is_array($base_url['routes'])) {
$params[$start_name] = (int) $on_page;
}
return $this->helper->route($route, $params, $is_amp, $session_id);
} else {
$url_delim = strpos($base_url, '?') === false ? '?' : (strpos($base_url, '?') === strlen($base_url) - 1 ? '' : '&');
return $on_page > 1 ? $base_url . $url_delim . $start_name . '=' . ($on_page - 1) * $per_page : $base_url;
}
}
作者:phpb
项目:phpbb-cor
/**
* Really send the feed
*
* @param feed_interface $feed
*
* @return Response
*
* @throw exception\feed_exception
*/
protected function send_feed_do(feed_interface $feed)
{
$feed_updated_time = 0;
$item_vars = array();
$board_url = $this->feed_helper->get_board_url();
// Open Feed
$feed->open();
// Iterate through items
while ($row = $feed->get_item()) {
/**
* Event to modify the feed row
*
* @event core.feed_modify_feed_row
* @var int forum_id Forum ID
* @var string mode Feeds mode (forums|topics|topics_new|topics_active|news)
* @var array row Array with feed data
* @var int topic_id Topic ID
*
* @since 3.1.10-RC1
*/
$vars = array('forum_id', 'mode', 'row', 'topic_id');
extract($this->phpbb_dispatcher->trigger_event('core.feed_modify_feed_row', compact($vars)));
// BBCode options to correctly disable urls, smilies, bbcode...
if ($feed->get('options') === null) {
// Allow all combinations
$options = 7;
if ($feed->get('enable_bbcode') !== null && $feed->get('enable_smilies') !== null && $feed->get('enable_magic_url') !== null) {
$options = ($row[$feed->get('enable_bbcode')] ? OPTION_FLAG_BBCODE : 0) + ($row[$feed->get('enable_smilies')] ? OPTION_FLAG_SMILIES : 0) + ($row[$feed->get('enable_magic_url')] ? OPTION_FLAG_LINKS : 0);
}
} else {
$options = $row[$feed->get('options')];
}
$title = isset($row[$feed->get('title')]) && $row[$feed->get('title')] !== '' ? $row[$feed->get('title')] : (isset($row[$feed->get('title2')]) ? $row[$feed->get('title2')] : '');
$published = $feed->get('published') !== null ? (int) $row[$feed->get('published')] : 0;
$updated = $feed->get('updated') !== null ? (int) $row[$feed->get('updated')] : 0;
$display_attachments = $this->auth->acl_get('u_download') && $this->auth->acl_get('f_download', $row['forum_id']) && isset($row['post_attachment']) && $row['post_attachment'] ? true : false;
$item_row = array('author' => $feed->get('creator') !== null ? $row[$feed->get('creator')] : '', 'published' => $published > 0 ? $this->feed_helper->format_date($published) : '', 'updated' => $updated > 0 ? $this->feed_helper->format_date($updated) : '', 'link' => '', 'title' => censor_text($title), 'category' => $this->config['feed_item_statistics'] && !empty($row['forum_id']) ? $board_url . '/viewforum.' . $this->php_ext . '?f=' . $row['forum_id'] : '', 'category_name' => $this->config['feed_item_statistics'] && isset($row['forum_name']) ? $row['forum_name'] : '', 'description' => censor_text($this->feed_helper->generate_content($row[$feed->get('text')], $row[$feed->get('bbcode_uid')], $row[$feed->get('bitfield')], $options, $row['forum_id'], $display_attachments ? $feed->get_attachments($row['post_id']) : array())), 'statistics' => '');
// Adjust items, fill link, etc.
$feed->adjust_item($item_row, $row);
$item_vars[] = $item_row;
$feed_updated_time = max($feed_updated_time, $published, $updated);
}
// If we do not have any items at all, sending the current time is better than sending no time.
if (!$feed_updated_time) {
$feed_updated_time = time();
}
$feed->close();
$content = $this->template->render('feed.xml.twig', array('FEED_IMAGE' => '', 'SELF_LINK' => $this->controller_helper->route($this->request->attributes->get('_route'), $this->request->attributes->get('_route_params'), true, '', UrlGeneratorInterface::ABSOLUTE_URL), 'FEED_LINK' => $board_url . '/index.' . $this->php_ext, 'FEED_TITLE' => $this->config['sitename'], 'FEED_SUBTITLE' => $this->config['site_desc'], 'FEED_UPDATED' => $this->feed_helper->format_date($feed_updated_time), 'FEED_LANG' => $this->user->lang['USER_LANG'], 'FEED_AUTHOR' => $this->config['sitename'], 'FEED_ROWS' => $item_vars));
$response = new Response($content);
$response->headers->set('Content-Type', 'application/atom+xml');
$response->setCharset('UTF-8');
$response->setLastModified(new \DateTime('@' . $feed_updated_time));
if (!empty($this->user->data['is_bot'])) {
// Let reverse proxies know we detected a bot.
$response->headers->set('X-PHPBB-IS-BOT', 'yes');
}
return $response;
}
作者:Crizz
项目:userinf
public function info($user_id)
{
if (!$this->auth->acl_gets('u_viewprofile')) {
trigger_error('NOT_AUTHORISED');
}
$sql_ary = array('SELECT' => 'u.username, u.user_colour, u.user_regdate, u.user_posts, u.user_lastvisit, u.user_rank, u.user_avatar, u.user_avatar_type, u.user_avatar_width, u.user_avatar_height', 'FROM' => array(USERS_TABLE => 'u'), 'WHERE' => 'u.user_id = ' . (int) $user_id);
/**
* Modify SQL query in tas2580 AJAX userinfo extension
*
* @event tas2580.userinfo_modify_sql
* @var string sql_ary The SQL query
* @var int user_id The ID of the user
* @since 0.2.3
*/
$vars = array('sql_ary', 'user_id');
extract($this->phpbb_dispatcher->trigger_event('tas2580.userinfo_modify_sql', compact($vars)));
$result = $this->db->sql_query_limit($this->db->sql_build_query('SELECT', $sql_ary), 1);
$this->data = $this->db->sql_fetchrow($result);
$this->db->sql_freeresult($result);
if (!function_exists('phpbb_get_user_rank')) {
include $this->phpbb_root_path . 'includes/functions_display.' . $this->php_ext;
}
$user_rank_data = phpbb_get_user_rank($this->data, $this->data['user_posts']);
// Get the avatar
// Wen need to use the full URL here because we don't know the path where userinfo is called
define('PHPBB_USE_BOARD_URL_PATH', true);
$avatar = phpbb_get_user_avatar($this->data);
$avatar = empty($avatar) ? '<img src="' . generate_board_url() . '/styles/' . $this->user->style['style_name'] . '/theme/images/no_avatar.gif" width="100" height="100" alt="' . $this->user->lang('USER_AVATAR') . '">' : $avatar;
$memberdays = max(1, round((time() - $this->data['user_regdate']) / 86400));
$posts_per_day = $this->data['user_posts'] / $memberdays;
$percentage = $this->config['num_posts'] ? min(100, $this->data['user_posts'] / $this->config['num_posts'] * 100) : 0;
$result = array('userinfo_header' => sprintf($this->user->lang['VIEWING_PROFILE'], $this->data['username']), 'username' => get_username_string('no_profile', $user_id, $this->data['username'], $this->data['user_colour']), 'regdate' => $this->user->format_date($this->data['user_regdate']), 'posts' => $this->data['user_posts'], 'lastvisit' => $this->user->format_date($this->data['user_lastvisit']), 'avatar' => $avatar, 'rank' => empty($user_rank_data['title']) ? $this->user->lang('NA') : $user_rank_data['title'], 'postsperday' => $this->user->lang('POST_DAY', $posts_per_day), 'percentage' => $this->user->lang('POST_PCT', $percentage));
/**
* Modify return data in tas2580 AJAX userinfo extension
*
* @event tas2580.userinfo_modify_result
* @var array result The result array
* @var int user_id The ID of the user
* @since 0.2.3
*/
$vars = array('result', 'user_id');
extract($this->phpbb_dispatcher->trigger_event('tas2580.userinfo_modify_result', compact($vars)));
return new JsonResponse($result);
}
作者:harsha-sir
项目:Online-Foru
/**
* Inject topic preview text into the template
*
* @param array $row Row data
* @param array $block Template vars array
* @return array Template vars array
* @access public
*/
public function display_topic_preview($row, $block)
{
if (!$this->is_enabled()) {
return $block;
}
$block = array_merge($block, array('TOPIC_PREVIEW_FIRST_POST' => !empty($row['first_post_text']) ? censor_text($this->trim_tools->trim_text($row['first_post_text'], $this->config['topic_preview_limit'])) : '', 'TOPIC_PREVIEW_LAST_POST' => !empty($row['last_post_text']) && $row['topic_first_post_id'] != $row['topic_last_post_id'] ? censor_text($this->trim_tools->trim_text($row['last_post_text'], $this->config['topic_preview_limit'])) : '', 'TOPIC_PREVIEW_FIRST_AVATAR' => $this->get_user_avatar_helper($row, 'fp'), 'TOPIC_PREVIEW_LAST_AVATAR' => $this->get_user_avatar_helper($row, 'lp')));
$tp_avatars = $this->avatars_enabled();
/**
* EVENT to modify the topic preview display output before it gets inserted in the template block
*
* @event vse.topicpreview.display_topic_preview
* @var array row Row data
* @var array block Template vars array
* @var bool tp_avatars Display avatars setting
* @since 2.1.0
*/
$vars = array('row', 'block', 'tp_avatars');
extract($this->dispatcher->trigger_event('vse.topicpreview.display_topic_preview', compact($vars)));
return $block;
}
作者:Tarenda
项目:spring-websit
/**
* Assign the user's profile fields data to the template
*
* @param array $profile_row Array with users profile field data
* @param bool $use_contact_fields Should we display contact fields as such?
* This requires special treatments (links should not be parsed in the values, and more)
* @return array
*/
public function generate_profile_fields_template_data($profile_row, $use_contact_fields = true)
{
// $profile_row == $user_fields[$row['user_id']];
$tpl_fields = array();
$tpl_fields['row'] = $tpl_fields['blockrow'] = array();
/**
* Event to modify data of the generated profile fields, before the template assignment loop
*
* @event core.generate_profile_fields_template_data_before
* @var array profile_row Array with users profile field data
* @var array tpl_fields Array with template data fields
* @var bool use_contact_fields Should we display contact fields as such?
* @since 3.1.0-b3
*/
$vars = array('profile_row', 'tpl_fields', 'use_contact_fields');
extract($this->dispatcher->trigger_event('core.generate_profile_fields_template_data_before', compact($vars)));
foreach ($profile_row as $ident => $ident_ary) {
$profile_field = $this->type_collection[$ident_ary['data']['field_type']];
$value = $profile_field->get_profile_value($ident_ary['value'], $ident_ary['data']);
$value_raw = $profile_field->get_profile_value_raw($ident_ary['value'], $ident_ary['data']);
if ($value === null) {
continue;
}
$field_desc = $contact_url = '';
if ($use_contact_fields && $ident_ary['data']['field_is_contact']) {
$value = $profile_field->get_profile_contact_value($ident_ary['value'], $ident_ary['data']);
$field_desc = $this->user->lang($ident_ary['data']['field_contact_desc']);
if (strpos($field_desc, '%s') !== false) {
$field_desc = sprintf($field_desc, $value);
}
$contact_url = '';
if (strpos($ident_ary['data']['field_contact_url'], '%s') !== false) {
$contact_url = sprintf($ident_ary['data']['field_contact_url'], $value);
}
}
$tpl_fields['row'] += array('PROFILE_' . strtoupper($ident) . '_IDENT' => $ident, 'PROFILE_' . strtoupper($ident) . '_VALUE' => $value, 'PROFILE_' . strtoupper($ident) . '_VALUE_RAW' => $value_raw, 'PROFILE_' . strtoupper($ident) . '_CONTACT' => $contact_url, 'PROFILE_' . strtoupper($ident) . '_DESC' => $field_desc, 'PROFILE_' . strtoupper($ident) . '_TYPE' => $ident_ary['data']['field_type'], 'PROFILE_' . strtoupper($ident) . '_NAME' => $this->user->lang($ident_ary['data']['lang_name']), 'PROFILE_' . strtoupper($ident) . '_EXPLAIN' => $this->user->lang($ident_ary['data']['lang_explain']), 'S_PROFILE_' . strtoupper($ident) . '_CONTACT' => $ident_ary['data']['field_is_contact'], 'S_PROFILE_' . strtoupper($ident) => true);
$tpl_fields['blockrow'][] = array('PROFILE_FIELD_IDENT' => $ident, 'PROFILE_FIELD_VALUE' => $value, 'PROFILE_FIELD_VALUE_RAW' => $value_raw, 'PROFILE_FIELD_CONTACT' => $contact_url, 'PROFILE_FIELD_DESC' => $field_desc, 'PROFILE_FIELD_TYPE' => $ident_ary['data']['field_type'], 'PROFILE_FIELD_NAME' => $this->user->lang($ident_ary['data']['lang_name']), 'PROFILE_FIELD_EXPLAIN' => $this->user->lang($ident_ary['data']['lang_explain']), 'S_PROFILE_CONTACT' => $ident_ary['data']['field_is_contact'], 'S_PROFILE_' . strtoupper($ident) => true);
}
/**
* Event to modify template data of the generated profile fields
*
* @event core.generate_profile_fields_template_data
* @var array profile_row Array with users profile field data
* @var array tpl_fields Array with template data fields
* @var bool use_contact_fields Should we display contact fields as such?
* @since 3.1.0-b3
*/
$vars = array('profile_row', 'tpl_fields', 'use_contact_fields');
extract($this->dispatcher->trigger_event('core.generate_profile_fields_template_data', compact($vars)));
return $tpl_fields;
}
作者:borgesjoaqui
项目:thanks_for_post
public function delete_thanks($post_id, $forum_id)
{
// $this->user->add_lang_ext('gfksx/ThanksForPosts', 'thanks_mod');
$to_id = $this->request->variable('to_id', 0);
$forum_id = $forum_id ?: $this->request->variable('f', 0);
$row = $this->get_post_info($post_id);
// confirm
$hidden = build_hidden_fields(array('to_id' => $to_id, 'rthanks' => $post_id));
/**
* This event allows to interrupt before a thanks is deleted
*
* @event gfksx.thanksforposts.delete_thanks_before
* @var int post_id The post id
* @var int forum_id The forum id
* @since 2.0.3
*/
$vars = array('post_id', 'forum_id');
extract($this->phpbb_dispatcher->trigger_event('gfksx.thanksforposts.delete_thanks_before', compact($vars)));
if (isset($this->config['remove_thanks']) ? !$this->config['remove_thanks'] : true) {
trigger_error($this->user->lang['DISABLE_REMOVE_THANKS'] . '<br /><br />' . $this->user->lang('RETURN_POST', '<a href="' . append_sid("{$this->phpbb_root_path}viewtopic.{$this->php_ext}", "f={$forum_id}&p={$post_id}#p{$post_id}") . '">', '</a>'));
}
if (confirm_box(true, 'REMOVE_THANKS', $hidden)) {
if ($this->user->data['user_type'] != USER_IGNORE && !empty($to_id) && $this->auth->acl_get('f_thanks', $forum_id)) {
$sql = "DELETE FROM " . $this->thanks_table . '
WHERE post_id =' . (int) $post_id . " AND user_id = " . (int) $this->user->data['user_id'];
$this->db->sql_query($sql);
$result = $this->db->sql_affectedrows($sql);
if ($result != 0) {
$lang_act = 'REMOVE';
$thanks_data = array('user_id' => (int) $this->user->data['user_id'], 'post_id' => $post_id, 'poster_id' => $to_id, 'topic_id' => (int) $row['topic_id'], 'forum_id' => $forum_id, 'thanks_time' => time(), 'username' => $this->user->data['username'], 'lang_act' => $lang_act, 'post_subject' => $row['post_subject']);
$this->add_notification($thanks_data, 'gfksx.thanksforposts.notification.type.thanks_remove');
if (isset($this->config['thanks_info_page']) && $this->config['thanks_info_page']) {
meta_refresh(1, append_sid("{$this->phpbb_root_path}viewtopic.{$this->php_ext}", "f={$forum_id}&p={$post_id}#p{$post_id}"));
trigger_error($this->user->lang['THANKS_INFO_' . $lang_act] . '<br /><br />' . $this->user->lang('RETURN_POST', '<a href="' . append_sid("{$this->phpbb_root_path}viewtopic.{$this->php_ext}", "f={$forum_id}&p={$post_id}#p{$post_id}") . '">', '</a>'));
} else {
redirect(append_sid("{$this->phpbb_root_path}viewtopic.{$this->php_ext}", "f={$forum_id}&p={$post_id}#p{$post_id}"));
}
} else {
trigger_error($this->user->lang['INCORRECT_THANKS'] . '<br /><br />' . $this->user->lang('RETURN_POST', '<a href="' . append_sid("{$this->phpbb_root_path}viewtopic.{$this->php_ext}", "f={$forum_id}&p={$post_id}#p{$post_id}") . '">', '</a>'));
}
}
} else {
confirm_box(false, 'REMOVE_THANKS', $hidden);
redirect(append_sid("{$this->phpbb_root_path}viewtopic.{$this->php_ext}", "f={$forum_id}&p={$post_id}#p{$post_id}"));
}
return;
}
作者:tierr
项目:topicsolve
/**
* Marks a topic as unsolved.
*
* @param array $topic_data Topic to be marked as unsolved.
*/
public function mark_unsolved($topic_data)
{
// Database column values to set.
$column_data = array('topic_solved' => 0);
if ($topic_data['forum_lock_solved'] && $this->auth->acl_get('m_lock', $topic_data['forum_id'])) {
$column_data['topic_status'] = ITEM_UNLOCKED;
}
$this->update_topic($topic_data['topic_id'], $column_data);
/**
* This event allows you to perform additional actions after a topic has been marked as unsolved.
*
* @event tierra.topicsolved.mark_unsolved_after
* @var array topic_data Array with general topic data
* @var array column_data Array with topic data that the database has been updated with
* @since 2.2.0
*/
$vars = array('topic_data', 'column_data');
extract($this->dispatcher->trigger_event('tierra.topicsolved.mark_unsolved_after', compact($vars)));
}
作者:EntropyR
项目:mChat-Extensio
/**
* Renders data for a page
*
* @param $page The page we are rendering for, one of index|custom|archive
*/
protected function render_page($page)
{
// Add lang file
$this->user->add_lang('posting');
// If the static message is defined in the language file use it, else the entry in the database is used
if (isset($this->user->lang['STATIC_MESSAGE'])) {
$this->config['mchat_static_message'] = $this->user->lang('STATIC_MESSAGE');
}
$this->template->assign_vars(array('MCHAT_FILE_NAME' => $this->helper->route('dmzx_mchat_controller'), 'MCHAT_REFRESH_JS' => 1000 * $this->config['mchat_refresh'], 'MCHAT_INPUT_TYPE' => $this->user->data['user_mchat_input_area'], 'MCHAT_RULES' => !empty($this->user->lang['MCHAT_RULES']) || !empty($this->config['mchat_rules']), 'MCHAT_ALLOW_USE' => $this->auth->acl_get('u_mchat_use'), 'MCHAT_ALLOW_SMILES' => $this->config['allow_smilies'] && $this->auth->acl_get('u_mchat_smilies'), 'MCHAT_ALLOW_BBCODES' => $this->config['allow_bbcode'] && $this->auth->acl_get('u_mchat_bbcode'), 'MCHAT_MESSAGE_TOP' => $this->config['mchat_message_top'], 'MCHAT_ARCHIVE_URL' => $this->helper->route('dmzx_mchat_page_controller', array('page' => 'archive')), 'MCHAT_INDEX_HEIGHT' => $this->config['mchat_index_height'], 'MCHAT_CUSTOM_HEIGHT' => $this->config['mchat_custom_height'], 'MCHAT_READ_ARCHIVE_BUTTON' => $this->auth->acl_get('u_mchat_archive'), 'MCHAT_FOUNDER' => $this->user->data['user_type'] == USER_FOUNDER, 'MCHAT_STATIC_MESS' => !empty($this->config['mchat_static_message']) ? htmlspecialchars_decode($this->config['mchat_static_message']) : '', 'L_MCHAT_COPYRIGHT' => base64_decode('PGEgaHJlZj0iaHR0cHM6Ly9lbnRyb3B5LmZpL2tlc2t1c3RlbHUvbWVtYmVybGlzdC5waHA/bW9kZT12aWV3cHJvZmlsZSZ1PTI5MiI+VGhlSDwvYT4gJmNvcHk7IDxhIGhyZWY9Imh0dHA6Ly9ybWNnaXJyODMub3JnIj5STWNHaXJyODM8L2E+ICZjb3B5OyA8YSBocmVmPSJodHRwOi8vd3d3LmRtengtd2ViLm5ldCIgdGl0bGU9Ind3dy5kbXp4LXdlYi5uZXQiPmRteng8L2E+'), 'MCHAT_MESSAGE_LNGTH' => $this->config['mchat_max_message_lngth'], 'MCHAT_MESS_LONG' => sprintf($this->user->lang('MCHAT_MESS_LONG'), $this->config['mchat_max_message_lngth']), 'MCHAT_USER_TIMEOUT_TIME' => gmdate('H:i:s', (int) $this->config['mchat_timeout']), 'MCHAT_WHOIS_REFRESH' => $this->config['mchat_whois'] ? 1000 * $this->config['mchat_whois_refresh'] : 0, 'MCHAT_WHOIS_REFRESH_EXPLAIN' => sprintf($this->user->lang('WHO_IS_REFRESH_EXPLAIN'), $this->config['mchat_whois_refresh']), 'MCHAT_PAUSE_ON_INPUT' => $this->config['mchat_pause_on_input'], 'MCHAT_REFRESH_YES' => sprintf($this->user->lang('MCHAT_REFRESH_YES'), $this->config['mchat_refresh']), 'MCHAT_LIVE_UPDATES' => $this->config['mchat_live_updates'], 'S_MCHAT_LOCATION' => $this->config['mchat_location'], 'S_MCHAT_SOUND_YES' => $this->user->data['user_mchat_sound'], 'U_MORE_SMILIES' => generate_board_url() . append_sid("/{$this->root_path}/posting.{$this->php_ext}", 'mode=smilies'), 'U_MCHAT_RULES' => $this->helper->route('dmzx_mchat_page_controller', array('page' => 'rules')), 'S_MCHAT_ON_INDEX' => $this->config['mchat_on_index'] && !empty($this->user->data['user_mchat_index']), 'S_MCHAT_MOBILE_BEFORE' => $this->user->data['user_mchat_mobile_before'], 'S_MCHAT_TITLEFLASHDURATION' => $this->user->data['user_mchat_titleflash_duration'], 'S_MCHAT_FOLLOW' => $this->user->data['user_mchat_follow'], 'S_MCHAT_ON_VIEWTOPIC' => $this->config['mchat_on_viewtopic'], 'S_MCHAT_ON_VIEWFORUM' => $this->config['mchat_on_viewforum'], 'S_MCHAT_SIMPLE_MSG' => $this->config['mchat_simple_msg']));
$sql_where = $this->user->data['user_mchat_topics'] ? '' : 'm.forum_id = 0';
$limit = $page == 'archive' ? $this->config['mchat_archive_limit'] : $this->config[$page == 'index' ? 'mchat_message_num' : 'mchat_message_limit'];
$start = $page == 'archive' ? $this->request->variable('start', 0) : 0;
$rows = $this->functions_mchat->mchat_get_messages($sql_where, $limit, $start);
$this->assign_global_template_data();
$this->assign_messages($rows);
// Render pagination
if ($page == 'archive') {
$archive_url = $this->helper->route('dmzx_mchat_page_controller', array('page' => 'archive'));
$total_messages = $this->functions_mchat->mchat_total_message_count();
$this->pagination->generate_template_pagination($archive_url, 'pagination', 'start', $total_messages, $limit, $start);
$this->template->assign_var('MCHAT_TOTAL_MESSAGES', sprintf($this->user->lang('MCHAT_TOTALMESSAGES'), $total_messages));
}
// Render legend
if ($page != 'index' && $this->config['mchat_whois']) {
$legend = $this->functions_mchat->mchat_legend();
$this->template->assign_var('LEGEND', implode(', ', $legend));
}
if ($this->auth->acl_get('u_mchat_use')) {
add_form_key('mchat');
}
$this->is_mchat_rendered = true;
/**
* Event render_helper_aft
*
* @event dmzx.mchat.core.render_helper_aft
* @since 0.1.2
*/
$this->dispatcher->dispatch('dmzx.mchat.core.render_helper_aft');
}
作者:corycubbag
项目:ShadoWorl
/**
* {@inheritdoc}
*/
public function delete($row)
{
$error = array();
$destination = $this->config['avatar_path'];
$prefix = $this->config['avatar_salt'] . '_';
$ext = substr(strrchr($row['avatar'], '.'), 1);
$filename = $this->phpbb_root_path . $destination . '/' . $prefix . $row['id'] . '.' . $ext;
/**
* Before deleting an existing avatar
*
* @event core.avatar_driver_upload_delete_before
* @var string destination Destination directory where the file is going to be deleted
* @var string prefix Prefix for the avatar filename
* @var array row Array with avatar row data
* @var array error Array of errors, if filled in by this event file will not be deleted
* @since 3.1.6-RC1
*/
$vars = array('destination', 'prefix', 'row', 'error');
extract($this->dispatcher->trigger_event('core.avatar_driver_upload_delete_before', compact($vars)));
if (!sizeof($error) && file_exists($filename)) {
@unlink($filename);
}
return true;
}
作者:phpb
项目:phpbb-cor
/**
* Performs a search on an author's posts without caring about message contents. Depends on display specific params
*
* @param string $type contains either posts or topics depending on what should be searched for
* @param boolean $firstpost_only if true, only topic starting posts will be considered
* @param array $sort_by_sql contains SQL code for the ORDER BY part of a query
* @param string $sort_key is the key of $sort_by_sql for the selected sorting
* @param string $sort_dir is either a or d representing ASC and DESC
* @param string $sort_days specifies the maximum amount of days a post may be old
* @param array $ex_fid_ary specifies an array of forum ids which should not be searched
* @param string $post_visibility specifies which types of posts the user can view in which forums
* @param int $topic_id is set to 0 or a topic id, if it is not 0 then only posts in this topic should be searched
* @param array $author_ary an array of author ids
* @param string $author_name specifies the author match, when ANONYMOUS is also a search-match
* @param array &$id_ary passed by reference, to be filled with ids for the page specified by $start and $per_page, should be ordered
* @param int $start indicates the first index of the page
* @param int $per_page number of ids each page is supposed to contain
* @return boolean|int total number of results
*/
public function author_search($type, $firstpost_only, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $post_visibility, $topic_id, $author_ary, $author_name, &$id_ary, &$start, $per_page)
{
// No author? No posts
if (!sizeof($author_ary)) {
return 0;
}
// generate a search_key from all the options to identify the results
$search_key_array = array('', $type, $firstpost_only ? 'firstpost' : '', '', '', $sort_days, $sort_key, $topic_id, implode(',', $ex_fid_ary), $post_visibility, implode(',', $author_ary), $author_name);
/**
* Allow changing the search_key for cached results
*
* @event core.search_postgres_by_author_modify_search_key
* @var array search_key_array Array with search parameters to generate the search_key
* @var string type Searching type ('posts', 'topics')
* @var boolean firstpost_only Flag indicating if only topic starting posts are considered
* @var int sort_days Time, in days, of the oldest possible post to list
* @var string sort_key The sort type used from the possible sort types
* @var int topic_id Limit the search to this topic_id only
* @var array ex_fid_ary Which forums not to search on
* @var string post_visibility Post visibility data
* @var array author_ary Array of user_id containing the users to filter the results to
* @var string author_name The username to search on
* @since 3.1.7-RC1
*/
$vars = array('search_key_array', 'type', 'firstpost_only', 'sort_days', 'sort_key', 'topic_id', 'ex_fid_ary', 'post_visibility', 'author_ary', 'author_name');
extract($this->phpbb_dispatcher->trigger_event('core.search_postgres_by_author_modify_search_key', compact($vars)));
$search_key = md5(implode('#', $search_key_array));
if ($start < 0) {
$start = 0;
}
// try reading the results from cache
$result_count = 0;
if ($this->obtain_ids($search_key, $result_count, $id_ary, $start, $per_page, $sort_dir) == SEARCH_RESULT_IN_CACHE) {
return $result_count;
}
$id_ary = array();
// Create some display specific sql strings
if ($author_name) {
// first one matches post of registered users, second one guests and deleted users
$sql_author = '(' . $this->db->sql_in_set('p.poster_id', array_diff($author_ary, array(ANONYMOUS)), false, true) . ' OR p.post_username ' . $author_name . ')';
} else {
$sql_author = $this->db->sql_in_set('p.poster_id', $author_ary);
}
$sql_fora = sizeof($ex_fid_ary) ? ' AND ' . $this->db->sql_in_set('p.forum_id', $ex_fid_ary, true) : '';
$sql_topic_id = $topic_id ? ' AND p.topic_id = ' . (int) $topic_id : '';
$sql_time = $sort_days ? ' AND p.post_time >= ' . (time() - $sort_days * 86400) : '';
$sql_firstpost = $firstpost_only ? ' AND p.post_id = t.topic_first_post_id' : '';
// Build sql strings for sorting
$sql_sort = $sort_by_sql[$sort_key] . ($sort_dir == 'a' ? ' ASC' : ' DESC');
$sql_sort_table = $sql_sort_join = '';
switch ($sql_sort[0]) {
case 'u':
$sql_sort_table = USERS_TABLE . ' u, ';
$sql_sort_join = $type == 'posts' ? ' AND u.user_id = p.poster_id ' : ' AND u.user_id = t.topic_poster ';
break;
case 't':
$sql_sort_table = $type == 'posts' && !$firstpost_only ? TOPICS_TABLE . ' t, ' : '';
$sql_sort_join = $type == 'posts' && !$firstpost_only ? ' AND t.topic_id = p.topic_id ' : '';
break;
case 'f':
$sql_sort_table = FORUMS_TABLE . ' f, ';
$sql_sort_join = ' AND f.forum_id = p.forum_id ';
break;
}
$m_approve_fid_sql = ' AND ' . $post_visibility;
/**
* Allow changing the query used to search for posts by author in fulltext_postgres
*
* @event core.search_postgres_author_count_query_before
* @var int result_count The previous result count for the format of the query.
* Set to 0 to force a re-count
* @var string sql_sort_table CROSS JOIN'ed table to allow doing the sort chosen
* @var string sql_sort_join Condition to define how to join the CROSS JOIN'ed table specifyed in sql_sort_table
* @var array author_ary Array of user_id containing the users to filter the results to
* @var string author_name An extra username to search on
* @var string sql_author SQL WHERE condition for the post author ids
* @var int topic_id Limit the search to this topic_id only
* @var string sql_topic_id SQL of topic_id
* @var string sort_by_sql The possible predefined sort types
* @var string sort_key The sort type used from the possible sort types
* @var string sort_dir "a" for ASC or "d" dor DESC for the sort order used
//.........这里部分代码省略.........
作者:kilian
项目:phpbb-ext-hooku
/**
* Processes hookup set activedate requests
*
* @param \phpbb\event\data $event
* @param bool $is_owner
*/
protected function process_set_activedate($event, $is_owner)
{
$set_active_set = $this->request->is_set('set_active', \phpbb\request\request_interface::POST) || $this->request->is_set('set_active', \phpbb\request\request_interface::GET);
$set_active = $this->request->variable('set_active', 0);
if (!$set_active_set) {
return array();
}
if (!$is_owner) {
return array($this->user->lang('NOT_AUTH_HOOKUP'));
}
if ($set_active && !isset($this->hookup->hookup_dates[$set_active])) {
trigger_error('NO_DATE');
}
$active_date_formatted = $set_active != 0 ? $this->user->format_date($this->hookup->hookup_dates[$set_active]['date_time']) : '-';
$topic_id = $event['topic_id'];
$forum_id = $event['forum_id'];
$viewtopic_url = append_sid("{$this->phpbb_root_path}viewtopic.{$this->phpEx}?f={$forum_id}&t={$topic_id}");
if (confirm_box(true)) {
$title_prefix = $this->request->variable('title_prefix', false);
$send_email = $this->request->variable('send_email', false);
$post_reply = $this->request->variable('post_reply', false);
$topic_data = $event['topic_data'];
$new_title = preg_replace('#^(\\[.+?\\] )?#', $set_active != 0 ? '[' . $this->user->format_date($this->hookup->hookup_dates[$set_active]['date_time'], $this->user->lang['HOOKUP_DATEFORMAT_TITLE']) . '] ' : '', $event['topic_data']['topic_title']);
/**
* Perform additional actions when active date is set
*
* @event gn36.hookup.set_activedate_confirmed
* @var bool title_prefix User wants to have a title prefix added
* @var bool send_email User wants E-Mails to be sent
* @var bool post_reply User wants to post a reply to the topic
* @var int set_active Date selected as active (0 means reset of active date)
* @var string new_title The new topic title that will be present after the update
* @var int topic_id ID of the topic of the hookup
* @var int forum_id ID of the forum the topic is in
* @var array topic_data Topic data as received from core.viewtopic_assign_template_vars_before
* @since 1.0.0-dev
*/
$vars = array('title_prefix', 'send_email', 'post_reply', 'set_active', 'new_title', 'topic_id', 'forum_id', 'topic_data');
extract($this->phpbb_dispatcher->trigger_event('gn36.hookup.set_activedate_confirmed', compact($vars)));
//insert active date (short format) into topic title. this will use language
//and timezone of the "active maker" but the alternative would be
//to query the HOOKUP_DATES table every time we need the topic title
if ($set_active == 0 || $title_prefix) {
$sql = 'UPDATE ' . TOPICS_TABLE . '
SET hookup_active_date = ' . (int) $set_active . ",\n\t\t\t\t\t\t\ttopic_title = '" . $this->db->sql_escape($new_title) . "'\n\t\t\t\t\t\t\t\t\tWHERE topic_id = {$topic_id}";
$this->db->sql_query($sql);
$sql = "UPDATE " . POSTS_TABLE . "\n\t\t\t\t\t\tSET post_subject='" . $this->db->sql_escape($new_title) . "'\n\t\t\t\t\t\t\t\tWHERE post_id = {$event['topic_data']['topic_first_post_id']}";
$this->db->sql_query($sql);
} else {
//only set hookup_active_date
$sql = 'UPDATE ' . TOPICS_TABLE . '
SET hookup_active_date = ' . (int) $set_active . "\n\t\t\t\t\t\t\t\tWHERE topic_id = {$topic_id}";
$this->db->sql_query($sql);
}
//notify all members about active date
if ($set_active && $send_email && !empty($this->hookup->hookup_users)) {
if ($this->messenger == null) {
include_once $this->phpbb_root_path . 'includes/functions_messenger.' . $this->phpEx;
$this->messenger = new \messenger();
}
$messenger = $this->messenger;
$title_without_date = preg_replace('#^(\\[.+?\\] )#', '', $event['topic_data']['topic_title']);
$sql = 'SELECT u.user_id, u.username, u.user_lang, u.user_dateformat, u.user_email, u.user_jabber, u.user_notify_type
FROM ' . USERS_TABLE . " u\n\t\t\t\t\tWHERE " . $this->db->sql_in_set('user_id', array_keys($this->hookup->hookup_users));
$result = $this->db->sql_query($sql);
while ($row = $this->db->sql_fetchrow($result)) {
$messenger->template('@gn36_hookup/hookup_active_date', $row['user_lang']);
$messenger->to($row['user_email'], $row['username']);
$messenger->im($row['user_jabber'], $row['username']);
$messenger->assign_vars(array('USERNAME' => $row['username'], 'TOPIC_TITLE' => $title_without_date, 'U_TOPIC' => generate_board_url() . "/viewtopic.{$this->phpEx}?f={$forum_id}&t={$topic_id}", 'ACTIVE_DATE' => $this->user->format_date($this->hookup->hookup_dates[$set_active]['date_time'], $row['user_dateformat']), 'ACTIVE_DATE_SHORT' => $this->user->format_date($this->hookup->hookup_dates[$set_active]['date_time'], $this->user->lang['HOOKUP_DATEFORMAT'])));
$messenger->send($row['user_notify_type']);
}
$this->db->sql_freeresult($result);
$messenger->save_queue();
}
//post reply to this topic. Again this can only be in the "active maker"s language
if ($set_active && $post_reply) {
$message = $this->user->lang['SET_ACTIVE_POST_TEMPLATE'];
$message = str_replace('{ACTIVE_DATE}', $this->user->format_date($this->hookup->hookup_dates[$set_active]['date_time'], $this->user->lang['HOOKUP_DATEFORMAT_POST']), $message);
//TODO: functions_post_oo!
//$post = new post($topic_id);
//$post->post_text = $message;
//$post->submit();
}
meta_refresh(3, $viewtopic_url);
$message = ($set_active != 0 ? sprintf($this->user->lang['ACTIVE_DATE_SET'], $active_date_formatted) : $this->user->lang['ACTIVE_DATE_UNSET']) . '<br /><br />' . sprintf($this->user->lang['RETURN_TOPIC'], '<a href="' . $viewtopic_url . '">', '</a>');
trigger_error($message);
} else {
$s_hidden_fields = build_hidden_fields(array('t' => $topic_id, 'set_active' => $set_active));
if ($set_active != 0) {
confirm_box(false, sprintf($this->user->lang['SET_ACTIVE_CONFIRM'], $active_date_formatted), $s_hidden_fields, '@gn36_hookup/hookup_active_date_confirm.html');
} else {
confirm_box(false, 'UNSET_ACTIVE', $s_hidden_fields);
}
//.........这里部分代码省略.........
作者:phpbb-stor
项目:OfficeForu
public function posts_merging($event)
{
$mode = $event['mode'];
$subject = $event['subject'];
$username = $event['username'];
$topic_type = $event['topic_type'];
$poll = $event['poll'];
$data = $event['data'];
$update_message = $event['update_message'];
$update_search_index = $event['update_search_index'];
$current_time = time();
$do_not_merge_with_previous = $this->request->variable('posts_merging_option', false);
if (!$do_not_merge_with_previous && !$this->helper->post_needs_approval($data) && in_array($mode, array('reply', 'quote')) && $this->merge_interval && !$this->helper->excluded_from_merge($data)) {
$merge_post_data = $this->helper->get_last_post_data($data);
// Do not merge if there's no last post data, the post is locked or allowed merge period has left
if (!$merge_post_data || $merge_post_data['post_edit_locked'] || $current_time - (int) $merge_post_data['topic_last_post_time'] > $this->merge_interval || !$this->user->data['is_registered']) {
return;
}
// Also, don't let user to violate attachments limit by posts merging
// In this case, also don't merge posts and return
// Exceptions are administrators and forum moderators
$num_old_attachments = $this->helper->count_post_attachments((int) $merge_post_data['post_id']);
$num_new_attachments = sizeof($data['attachment_data']);
$total_attachments_count = $num_old_attachments + $num_new_attachments;
if ($total_attachments_count > $this->config['max_attachments'] && !$this->auth->acl_get('a_') && !$this->auth->acl_get('m_', (int) $data['forum_id'])) {
return;
}
$data['post_id'] = (int) $merge_post_data['post_id'];
$merge_post_data['post_attachment'] = $total_attachments_count ? 1 : 0;
// Decode old message and addon
$merge_post_data['post_text'] = $this->helper->prepare_text_for_merge($merge_post_data);
$data['message'] = $this->helper->prepare_text_for_merge($data);
// Handle inline attachments BBCode in old message
if ($num_new_attachments) {
$merge_post_data['post_text'] = preg_replace('#\\[attachment=([0-9]+)\\](.*?)\\[\\/attachment\\]#e', "'[attachment='.(\\1 + {$num_new_attachments}).']\\2[/attachment]'", $merge_post_data['post_text']);
}
// Prepare message separator
$this->user->add_lang_ext('rxu/PostsMerging', 'posts_merging');
$interval = $this->helper->get_time_interval($current_time, $merge_post_data['post_time']);
$time = array();
$time[] = $interval->h ? $this->user->lang('D_HOURS', $interval->h) : null;
$time[] = $interval->i ? $this->user->lang('D_MINUTES', $interval->i) : null;
$time[] = $interval->s ? $this->user->lang('D_SECONDS', $interval->s) : null;
$separator = $this->user->lang('MERGE_SEPARATOR', implode(' ', $time));
// Merge subject
if (!empty($subject) && $subject != $merge_post_data['post_subject'] && $merge_post_data['post_id'] != $merge_post_data['topic_first_post_id']) {
$separator .= sprintf($this->user->lang['MERGE_SUBJECT'], $subject);
}
// Merge posts
$merge_post_data['post_text'] = $merge_post_data['post_text'] . $separator . $data['message'];
// Make sure the message is safe
$this->type_cast_helper->recursive_set_var($merge_post_data['post_text'], '', true);
//Prepare post for submit
$options = '';
$warn_msg = generate_text_for_storage($merge_post_data['post_text'], $merge_post_data['bbcode_uid'], $merge_post_data['bbcode_bitfield'], $options, $merge_post_data['enable_bbcode'], $merge_post_data['enable_magic_url'], $merge_post_data['enable_smilies']);
// If $warn_msg is not empty, the merged message does not conform some restrictions
// In this case we simply don't merge and return back to the function submit_post()
if (!empty($warn_msg)) {
return;
}
// Update post time and submit post to database
$merge_post_data['post_time'] = $data['post_time'] = $current_time;
$this->helper->submit_post_to_database($merge_post_data);
// Submit attachments
$this->helper->submit_attachments($data);
// Update read tracking
$this->helper->update_read_tracking($data);
// If a username was supplied or the poster is a guest, we will use the supplied username.
// Doing it this way we can use "...post by guest-username..." in notifications when
// "guest-username" is supplied or ommit the username if it is not.
$username = $username !== '' || !$this->user->data['is_registered'] ? $username : $this->user->data['username'];
// Send Notifications
// Despite the post_id is the same and users who've been already notified
// won't be notified again about the same post_id, we send notifications
// for new users possibly subscribed to it
$notification_data = array_merge($data, array('topic_title' => isset($data['topic_title']) ? $data['topic_title'] : $subject, 'post_username' => $username, 'poster_id' => (int) $data['poster_id'], 'post_text' => $data['message'], 'post_time' => $merge_post_data['post_time'], 'post_subject' => $subject));
$this->notification_manager->add_notifications(array('notification.type.quote', 'notification.type.bookmark', 'notification.type.post'), $notification_data);
// Update search index
$this->helper->update_search_index($merge_post_data);
//Generate redirection URL and redirecting
$params = $add_anchor = '';
$params .= '&t=' . $data['topic_id'];
$params .= '&p=' . $data['post_id'];
$add_anchor = '#p' . $data['post_id'];
$url = "{$this->phpbb_root_path}viewtopic.{$this->php_ext}";
$url = append_sid($url, 'f=' . $data['forum_id'] . $params) . $add_anchor;
/**
* Modify the data for post submitting
*
* @event rxu.postsmerging.posts_merging_end
* @var string mode Variable containing posting mode value
* @var string subject Variable containing post subject value
* @var string username Variable containing post author name
* @var int topic_type Variable containing topic type value
* @var array poll Array with the poll data for the post
* @var array data Array with the data for the post
* @var bool update_message Flag indicating if the post will be updated
* @var bool update_search_index Flag indicating if the search index will be updated
* @var string url The "Return to topic" URL
* @since 2.0.0
//.........这里部分代码省略.........