Problem solved.
Btw I've done this alteration that solves too:
form_generator.php
Before
Code: Select all
<?php
/**
*
* @package phpBB3
* @version $Id$
* @copyright (c) 2011 Ariaswari
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
// include standard classes of form generator
require_once $phpbb_root_path . 'includes/form/form.' . $phpEx;
require_once $phpbb_root_path . 'includes/form/field.' . $phpEx;
require_once $phpbb_root_path . 'includes/form/form_tpl.' . $phpEx;
/**
* regroups general functions concerning forms generator mod
* this class can not be instanced, only static methods/properties
*/
abstract class form_generator
{
/**
* return all existing forms into an array of form
*/
public static function get_forms()
{
global $db;
$sql = 'SELECT *
FROM ' . FORMS_TABLE;
$result = $db->sql_query($sql);
$forms = array();
while ($row = $db->sql_fetchrow($result))
{
$forms[] = new form($row);
}
return $forms;
}
/**
* return a specific form
*/
public static function get_form($form_id, $check_disable = false, $check_reply = false)
{
global $db;
if (!$form_id)
{
return false;
}
$sql = 'SELECT *
FROM ' . FORMS_TABLE . "
WHERE form_id = $form_id";
$sql .= ($check_disable) ? ' AND form_enabled = 1' : '';
$sql .= ($check_reply) ? ' AND form_reply = 1' : '';
$result = $db->sql_query($sql);
if (!$row = $db->sql_fetchrow($result))
{
return false;
}
return new form($row);
}
/**
* return a specific field
*/
public static function get_field($field_id)
{
global $db;
if (!$field_id)
{
return false;
}
$sql = 'SELECT *
FROM ' . FORMS_FIELDS_TABLE . "
WHERE field_id = $field_id";
$result = $db->sql_query($sql);
if (!$row = $db->sql_fetchrow($result))
{
return false;
}
return self::new_field($row);
}
/**
* created a new field (depending on its type)
*/
public static function new_field($field_data)
{
// if the type and the class exists, create new field
if (!empty($field_data['field_type']) && class_exists($field_data['field_type']))
{
return new $field_data['field_type']($field_data);
}
return false;
}
/**
* generate list of field types
*/
public static function select_fields($selected = false, $disabled = false)
{
$s_fields = '<select name="field_type" id="field_type"' . (($disabled) ? ' disabled="disabled"' : '') . '>';
// generate html
foreach (get_declared_classes() as $class)
{
// create a field of each type
if (is_subclass_of($class, 'field'))
{
$field = new $class();
$select = ($selected && $class == $selected) ? ' selected="selected"' : '';
$s_fields .= '<option value="' . $class . '"' . $select . '>' . $field->get_name() . '</option>';
}
}
$s_fields .= '</select>';
return $s_fields;
}
/**
* generate list of form template
*/
public static function select_form_tpl($selected = false)
{
$s_tpl = '<select name="form_template" id="form_template">';
// generate html
foreach (get_declared_classes() as $class)
{
// create a field of each type
if (is_subclass_of($class, 'form_tpl'))
{
$tpl = new $class();
$select = ($selected && $class == $selected) ? ' selected="selected"' : '';
$s_tpl .= '<option value="' . $class . '"' . $select . '>' . $tpl->get_name() . '</option>';
}
}
$s_tpl .= '</select>';
return $s_tpl;
}
/**
* generate list of groups
* function copied from includes/functions_admin.php which manages multiple selections
*/
public static function group_select_options($group_id, $exclude_ids = false, $manage_founder = false)
{
global $db, $user, $config;
$exclude_sql = ($exclude_ids !== false && sizeof($exclude_ids)) ? 'WHERE ' . $db->sql_in_set('group_id', array_map('intval', $exclude_ids), true) : '';
$sql_and = (!$config['coppa_enable']) ? (($exclude_sql) ? ' AND ' : ' WHERE ') . "group_name <> 'REGISTERED_COPPA'" : '';
$sql_founder = ($manage_founder !== false) ? (($exclude_sql || $sql_and) ? ' AND ' : ' WHERE ') . 'group_founder_manage = ' . (int) $manage_founder : '';
$sql = 'SELECT group_id, group_name, group_type
FROM ' . GROUPS_TABLE . "
$exclude_sql
$sql_and
$sql_founder
ORDER BY group_type DESC, group_name ASC";
$result = $db->sql_query($sql);
$s_group_options = '';
while ($row = $db->sql_fetchrow($result))
{
$selected = ((is_array($group_id) && in_array($row['group_id'], $group_id)) || $row['group_id'] == $group_id) ? ' selected="selected"' : '';
$s_group_options .= '<option' . (($row['group_type'] == GROUP_SPECIAL) ? ' class="sep"' : '') . ' value="' . $row['group_id'] . '"' . $selected . '>' . (($row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $row['group_name']] : $row['group_name']) . '</option>';
}
$db->sql_freeresult($result);
return $s_group_options;
}
/**
* return the list of forums which use a form
*/
public static function get_forums_used()
{
global $db;
$sql = 'SELECT forum_id
FROM ' . FORUMS_TABLE . '
WHERE form_id <> 0';
$result = $db->sql_query($sql);
$forums = array();
while ($row = $db->sql_fetchrow($result))
{
$forums[] = $row['forum_id'];
}
return $forums;
}
/**
* display a form in posting and manages submit/preview
*/
public static function display_form($data, $mode)
{
global $config, $user, $template, $auth, $phpbb_root_path, $phpEx;
//-- mod : quick title edition -------------------------------------------------
//-- add
global $qte;
//-- fin mod : quick title edition ---------------------------------------------
// setup lang and functions
$user->setup('mods/info_acp_form');
require_once $phpbb_root_path . 'includes/functions_user.' . $phpEx;
// setup data
$errors = $fields_submit = array();
$submit = (isset($_POST['submit'])) ? true : false;
$preview = (isset($_POST['preview'])) ? true : false;
$subject = utf8_normalize_nfc(request_var('subject', '', true));
$username = utf8_normalize_nfc(request_var('username', '', true));
$message_flag = OPTION_FLAG_BBCODE + OPTION_FLAG_SMILIES + OPTION_FLAG_LINKS;
// Mod browser, os & screen ---
$screen = request_var('screen', '');
// End Mod browser, os & screen
//-- mod : quick title edition -------------------------------------------------
//-- add
$data['attr_id'] = request_var('attr_id', 0);
if ( !empty($data['topic_attr_id']) )
{
$data['attr_id'] = $data['topic_attr_id'];
}
//-- fin mod : quick title edition ---------------------------------------------
// get form to display
if (!$form = self::get_form($data['form_id'], true, ($mode == 'reply') ? true : false))
{
return;
}
// get fields of the form
if (!$fields = $form->get_fields($form->get_id()))
{
return;
}
// check if current user can view the form
if (!group_memberships(explode(',', $form->get('form_groups')), $user->data['user_id'], true))
{
return;
}
// set default subject in replies
if ($mode == 'reply' && !$subject && !$preview && !$submit)
{
$subject = ((strpos($data['topic_title'], 'Re: ') !== 0) ? 'Re: ' : '') . censor_text($data['topic_title']);
}
// if anonymous user and visual confirmation needed, setup captcha here
if ($config['enable_post_confirm'] && !$user->data['is_registered'])
{
include_once($phpbb_root_path . 'includes/captcha/captcha_factory.' . $phpEx);
$captcha =& phpbb_captcha_factory::get_instance($config['captcha_plugin']);
$captcha->init(CONFIRM_POST);
}
// if form submitted/previewed
if ($submit || $preview)
{
// if new topic, subject cannot be empty
if ($mode == 'post' && !$subject)
{
$errors[] = $user->lang['EMPTY_SUBJECT'];
}
//-- mod : quick title edition -------------------------------------------------
//-- add
if ( $data['force_attr'] )
{
if ( !$preview && ($data['attr_id'] == -1) && ($mode == 'post') )
{
$user->add_lang('mods/attributes');
$errors[] = $user->lang['QTE_ATTRIBUTE_UNSELECTED'];
// init the value
$data['attr_id'] = 0;
}
}
//-- fin mod : quick title edition ---------------------------------------------
// if poster is anonymous, check username
if (!$user->data['is_registered'])
{
$user->add_lang('ucp');
if (($result = validate_username($username)) !== false)
{
$error[] = $user->lang[$result . '_USERNAME'];
}
if (($result = validate_string($username, false, $config['min_name_chars'], $config['max_name_chars'])) !== false)
{
$min_max_amount = ($result == 'TOO_SHORT') ? $config['min_name_chars'] : $config['max_name_chars'];
$error[] = sprintf($user->lang['FIELD_' . $result], $user->lang['USERNAME'], $min_max_amount);
}
}
// if there is a captcha, check it
if (isset($captcha))
{
$captcha_data = array(
'message' => '',
'subject' => $subject,
'username' => $username,
);
$vc_response = $captcha->validate($captcha_data);
if ($vc_response)
{
$errors[] = $vc_response;
}
}
// check each fields
foreach ($fields as $field)
{
// get field submitted value
$field->set_input(utf8_normalize_nfc(request_var($field->get_html_name(), $field->get_default(), true)));
// check if a value is required
if ($field->get('field_required') && !$field->get_input())
{
$errors[] = sprintf($user->lang['ERROR_REQUIRED'], $field->get('field_name'));
}
}
// if no errors, create and save the post
if (!sizeof($errors))
{
// create a new object template
$class_tpl = $form->get('form_template');
$form_tpl = new $class_tpl();
// generate the post based on fields data
$message = $form_tpl->generate_message($fields);
// parse the message for DB storage
generate_text_for_storage($message, $bbcode_uid, $bbcode_bitfield, $message_flag, true, true, true);
// preview ?
if ($preview)
{
$template->assign_vars(array(
'PREVIEW_MESSAGE' => generate_text_for_display($message, $bbcode_uid, $bbcode_bitfield, $message_flag),
'PREVIEW_SUBJECT' => $subject,
));
//-- mod : quick title edition -------------------------------------------------
//-- add
if ( !empty($data['attr_id']) )
{
$template->assign_vars(array(
'S_TOPIC_ATTR' => true,
'TOPIC_ATTRIBUTE' => $qte->attr_display($data['attr_id'], $user->data['user_id'], time()),
));
}
//-- fin mod : quick title edition ---------------------------------------------
}
// submit ? save the post
else
{
$form_data = array(
'forum_id' => $data['forum_id'],
'topic_id' => ($mode == 'reply') ? $data['topic_id'] : 0,
'icon_id' => false,
'enable_bbcode' => true,
'enable_smilies' => true,
'enable_urls' => true,
'enable_sig' => true,
'message' => $message,
'message_md5' => md5($message),
'bbcode_bitfield' => $bbcode_bitfield,
'bbcode_uid' => $bbcode_uid,
'post_edit_locked' => 0,
'topic_title' => $subject,
'notify_set' => false,
'notify' => false,
'post_time' => 0,
'forum_name' => $data['forum_name'], // should be defined for email notifications
'enable_indexing' => true,
'screen' => $screen,
// start mod save full drafts
'save_as_draft' => false,
'was_draft' => false,
// end mod save full drafts
'topic_status' => 0,
);
//-- mod : quick title edition -------------------------------------------------
//-- add
$form_data += array('attr_id' => $data['attr_id']);
//-- fin mod : quick title edition ---------------------------------------------
$poll_data = array();
$url = submit_post($mode, $subject, $username, POST_NORMAL, $poll_data, $form_data);
if (isset($captcha) && $captcha->is_solved() === true)
{
$captcha->reset();
}
$message = $user->lang['POST_STORED'] . '<br /><br />' . sprintf($user->lang['VIEW_MESSAGE'], '<a href="' . $url . '">', '</a>');
$message .= '<br /><br />' . sprintf($user->lang['RETURN_FORUM'], '<a href="' . append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $data['forum_id']) . '">', '</a>');
meta_refresh(5, $url);
trigger_error($message);
}
}
}
// display each field of the form
foreach ($fields as $field)
{
$template->assign_block_vars('fields', array(
'NAME' => $field->get_html_label(),
'DESC' => generate_text_for_display($field->get('field_desc'), $field->get('field_bbcode_uid'), $field->get('field_bbcode_bitfield'), $message_flag),
'HTML' => $field->get_html_code(),
));
}
// display captcha
if (isset($captcha) && $captcha->is_solved() === false)
{
$template->assign_vars(array(
'S_CONFIRM_CODE' => true,
'CAPTCHA_TEMPLATE' => $captcha->get_template(),
));
}
// display captcha hidden fields
if (isset($captcha) && $captcha->is_solved() !== false)
{
$template->assign_var('S_HIDDEN_FIELDS', build_hidden_fields($captcha->get_hidden_fields()));
}
// display topic review in replies
if ($mode == 'reply' && topic_review($data['topic_id'], $data['forum_id']))
{
$template->assign_vars(array(
'S_DISPLAY_REVIEW' => true,
'TOPIC_TITLE' => $data['topic_title'],
));
}
// display navigation links and forum rules
generate_forum_nav($data);
generate_forum_rules($data);
// template vars
$template->assign_vars(array(
'ERRORS' => ($errors) ? implode('<br />', $errors) : '',
'FORM_NAME' => $form->get('form_name'),
'FORM_DESC' => generate_text_for_display($form->get('form_desc'), $form->get('form_bbcode_uid'), $form->get('form_bbcode_bitfield'), $message_flag),
'SUBJECT' => $subject,
'USERNAME' => $username,
'S_POST_ACTION' => append_sid("{$phpbb_root_path}posting.$phpEx", "mode=$mode&f=" . $data['forum_id']) . (($mode == 'reply') ? '&t=' . $data['topic_id'] : ''),
'S_DISPLAY_USERNAME' => (!$user->data['is_registered']) ? true : false,
));
//-- mod : quick title edition -------------------------------------------------
//-- add
if ( $mode == 'post' )
{
$topic_attribute = 0;
if ( !empty($data['topic_attr_id']) )
{
$topic_attribute = $data['topic_attr_id'];
}
else if ( $data['attr_id'] )
{
$topic_attribute = $data['attr_id'];
}
$qte->attr_select($data['forum_id'], $user->data['user_id'], $topic_attribute, $data['hide_attr']);
$template->assign_vars(array(
'S_PRIVMSGS' => false,
'S_POSTING' => true,
));
}
//-- fin mod : quick title edition ---------------------------------------------
// display page
page_header($form->get('form_name'));
$template->set_filenames(array(
'body' => 'form_body.html',
));
page_footer();
// page is loaded
}
}
?>
After
Code: Select all
<?php
/**
*
* @package phpBB3
* @version $Id$
* @copyright (c) 2011 Ariaswari
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
// include standard classes of form generator
require_once $phpbb_root_path . 'includes/form/form.' . $phpEx;
require_once $phpbb_root_path . 'includes/form/field.' . $phpEx;
require_once $phpbb_root_path . 'includes/form/form_tpl.' . $phpEx;
/**
* regroups general functions concerning forms generator mod
* this class can not be instanced, only static methods/properties
*/
abstract class form_generator
{
/**
* return all existing forms into an array of form
*/
public static function get_forms()
{
global $db;
$sql = 'SELECT *
FROM ' . FORMS_TABLE;
$result = $db->sql_query($sql);
$forms = array();
while ($row = $db->sql_fetchrow($result))
{
$forms[] = new form($row);
}
return $forms;
}
/**
* return a specific form
*/
public static function get_form($form_id, $check_disable = false, $check_reply = false)
{
global $db;
if (!$form_id)
{
return false;
}
$sql = 'SELECT *
FROM ' . FORMS_TABLE . "
WHERE form_id = $form_id";
$sql .= ($check_disable) ? ' AND form_enabled = 1' : '';
$sql .= ($check_reply) ? ' AND form_reply = 1' : '';
$result = $db->sql_query($sql);
if (!$row = $db->sql_fetchrow($result))
{
return false;
}
return new form($row);
}
/**
* return a specific field
*/
public static function get_field($field_id)
{
global $db;
if (!$field_id)
{
return false;
}
$sql = 'SELECT *
FROM ' . FORMS_FIELDS_TABLE . "
WHERE field_id = $field_id";
$result = $db->sql_query($sql);
if (!$row = $db->sql_fetchrow($result))
{
return false;
}
return self::new_field($row);
}
/**
* created a new field (depending on its type)
*/
public static function new_field($field_data)
{
// if the type and the class exists, create new field
if (!empty($field_data['field_type']) && class_exists($field_data['field_type']))
{
return new $field_data['field_type']($field_data);
}
return false;
}
/**
* generate list of field types
*/
public static function select_fields($selected = false, $disabled = false)
{
$s_fields = '<select name="field_type" id="field_type"' . (($disabled) ? ' disabled="disabled"' : '') . '>';
// generate html
foreach (get_declared_classes() as $class)
{
// create a field of each type
if (is_subclass_of($class, 'field'))
{
$field = new $class();
$select = ($selected && $class == $selected) ? ' selected="selected"' : '';
$s_fields .= '<option value="' . $class . '"' . $select . '>' . $field->get_name() . '</option>';
}
}
$s_fields .= '</select>';
return $s_fields;
}
/**
* generate list of form template
*/
public static function select_form_tpl($selected = false)
{
$s_tpl = '<select name="form_template" id="form_template">';
// generate html
foreach (get_declared_classes() as $class)
{
// create a field of each type
if (is_subclass_of($class, 'form_tpl'))
{
$tpl = new $class();
$select = ($selected && $class == $selected) ? ' selected="selected"' : '';
$s_tpl .= '<option value="' . $class . '"' . $select . '>' . $tpl->get_name() . '</option>';
}
}
$s_tpl .= '</select>';
return $s_tpl;
}
/**
* generate list of groups
* function copied from includes/functions_admin.php which manages multiple selections
*/
public static function group_select_options($group_id, $exclude_ids = false, $manage_founder = false)
{
global $db, $user, $config;
$exclude_sql = ($exclude_ids !== false && sizeof($exclude_ids)) ? 'WHERE ' . $db->sql_in_set('group_id', array_map('intval', $exclude_ids), true) : '';
$sql_and = (!$config['coppa_enable']) ? (($exclude_sql) ? ' AND ' : ' WHERE ') . "group_name <> 'REGISTERED_COPPA'" : '';
$sql_founder = ($manage_founder !== false) ? (($exclude_sql || $sql_and) ? ' AND ' : ' WHERE ') . 'group_founder_manage = ' . (int) $manage_founder : '';
$sql = 'SELECT group_id, group_name, group_type
FROM ' . GROUPS_TABLE . "
$exclude_sql
$sql_and
$sql_founder
ORDER BY group_type DESC, group_name ASC";
$result = $db->sql_query($sql);
$s_group_options = '';
while ($row = $db->sql_fetchrow($result))
{
$selected = ((is_array($group_id) && in_array($row['group_id'], $group_id)) || $row['group_id'] == $group_id) ? ' selected="selected"' : '';
$s_group_options .= '<option' . (($row['group_type'] == GROUP_SPECIAL) ? ' class="sep"' : '') . ' value="' . $row['group_id'] . '"' . $selected . '>' . (($row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $row['group_name']] : $row['group_name']) . '</option>';
}
$db->sql_freeresult($result);
return $s_group_options;
}
/**
* return the list of forums which use a form
*/
public static function get_forums_used()
{
global $db;
$sql = 'SELECT forum_id
FROM ' . FORUMS_TABLE . '
WHERE form_id <> 0';
$result = $db->sql_query($sql);
$forums = array();
while ($row = $db->sql_fetchrow($result))
{
$forums[] = $row['forum_id'];
}
return $forums;
}
/**
* display a form in posting and manages submit/preview
*/
public static function display_form($data, $mode)
{
global $config, $user, $template, $auth, $phpbb_root_path, $phpEx;
//-- mod : quick title edition -------------------------------------------------
//-- add
global $qte;
//-- fin mod : quick title edition ---------------------------------------------
// setup lang and functions
$user->setup('mods/info_acp_form');
require_once $phpbb_root_path . 'includes/functions_user.' . $phpEx;
// setup data
$errors = $fields_submit = array();
$submit = (isset($_POST['submit'])) ? true : false;
$preview = (isset($_POST['preview'])) ? true : false;
$subject = utf8_normalize_nfc(request_var('subject', '', true));
$username = utf8_normalize_nfc(request_var('username', '', true));
$message_flag = OPTION_FLAG_BBCODE + OPTION_FLAG_SMILIES + OPTION_FLAG_LINKS;
// Mod browser, os & screen ---
$screen = request_var('screen', '');
// End Mod browser, os & screen
//-- mod : quick title edition -------------------------------------------------
//-- add
$data['attr_id'] = request_var('attr_id', 0);
if ( !empty($data['topic_attr_id']) )
{
if ( empty($data['attr_id']) || ($data['attr_id'] == -2) )
{
$data['attr_id'] = $data['topic_attr_id'];
}
}
//-- fin mod : quick title edition ---------------------------------------------
// get form to display
if (!$form = self::get_form($data['form_id'], true, ($mode == 'reply') ? true : false))
{
return;
}
// get fields of the form
if (!$fields = $form->get_fields($form->get_id()))
{
return;
}
// check if current user can view the form
if (!group_memberships(explode(',', $form->get('form_groups')), $user->data['user_id'], true))
{
return;
}
// set default subject in replies
if ($mode == 'reply' && !$subject && !$preview && !$submit)
{
$subject = ((strpos($data['topic_title'], 'Re: ') !== 0) ? 'Re: ' : '') . censor_text($data['topic_title']);
}
// if anonymous user and visual confirmation needed, setup captcha here
if ($config['enable_post_confirm'] && !$user->data['is_registered'])
{
include_once($phpbb_root_path . 'includes/captcha/captcha_factory.' . $phpEx);
$captcha =& phpbb_captcha_factory::get_instance($config['captcha_plugin']);
$captcha->init(CONFIRM_POST);
}
// if form submitted/previewed
if ($submit || $preview)
{
// if new topic, subject cannot be empty
if ($mode == 'post' && !$subject)
{
$errors[] = $user->lang['EMPTY_SUBJECT'];
}
//-- mod : quick title edition -------------------------------------------------
//-- add
if ( $data['force_attr'] )
{
if ( !$preview && !$refresh && ($data['attr_id'] == -1) && ($mode == 'post' || ($mode == 'edit' && $data['topic_first_post_id'] == $post_id)) )
{
$user->add_lang('mods/attributes');
$error[] = $user->lang['QTE_ATTRIBUTE_UNSELECTED'];
// init the value
$data['attr_id'] = 0;
}
}
//-- fin mod : quick title edition ---------------------------------------------
// if poster is anonymous, check username
if (!$user->data['is_registered'])
{
$user->add_lang('ucp');
if (($result = validate_username($username)) !== false)
{
$error[] = $user->lang[$result . '_USERNAME'];
}
if (($result = validate_string($username, false, $config['min_name_chars'], $config['max_name_chars'])) !== false)
{
$min_max_amount = ($result == 'TOO_SHORT') ? $config['min_name_chars'] : $config['max_name_chars'];
$error[] = sprintf($user->lang['FIELD_' . $result], $user->lang['USERNAME'], $min_max_amount);
}
}
// if there is a captcha, check it
if (isset($captcha))
{
$captcha_data = array(
'message' => '',
'subject' => $subject,
'username' => $username,
);
$vc_response = $captcha->validate($captcha_data);
if ($vc_response)
{
$errors[] = $vc_response;
}
}
// check each fields
foreach ($fields as $field)
{
// get field submitted value
$field->set_input(utf8_normalize_nfc(request_var($field->get_html_name(), $field->get_default(), true)));
// check if a value is required
if ($field->get('field_required') && !$field->get_input())
{
$errors[] = sprintf($user->lang['ERROR_REQUIRED'], $field->get('field_name'));
}
}
// if no errors, create and save the post
if (!sizeof($errors))
{
// create a new object template
$class_tpl = $form->get('form_template');
$form_tpl = new $class_tpl();
// generate the post based on fields data
$message = $form_tpl->generate_message($fields);
// parse the message for DB storage
generate_text_for_storage($message, $bbcode_uid, $bbcode_bitfield, $message_flag, true, true, true);
// preview ?
if ($preview)
{
$template->assign_vars(array(
'PREVIEW_MESSAGE' => generate_text_for_display($message, $bbcode_uid, $bbcode_bitfield, $message_flag),
'PREVIEW_SUBJECT' => $subject,
));
//-- mod : quick title edition -------------------------------------------------
//-- add
if ( !empty($data['attr_id']) && ($data['attr_id'] != -1) )
{
$qte->get_users_by_user_id($user->data['user_id']);
$template->assign_vars(array(
'S_TOPIC_ATTR' => true,
'TOPIC_ATTRIBUTE' => $qte->attr_display($data['attr_id'], $user->data['user_id'], $current_time),
));
}
//-- fin mod : quick title edition ---------------------------------------------
}
// submit ? save the post
else
{
$form_data = array(
'forum_id' => $data['forum_id'],
'topic_id' => ($mode == 'reply') ? $data['topic_id'] : 0,
'icon_id' => false,
'enable_bbcode' => true,
'enable_smilies' => true,
'enable_urls' => true,
'enable_sig' => true,
'message' => $message,
'message_md5' => md5($message),
'bbcode_bitfield' => $bbcode_bitfield,
'bbcode_uid' => $bbcode_uid,
'post_edit_locked' => 0,
'topic_title' => $subject,
'notify_set' => false,
'notify' => false,
'post_time' => 0,
'forum_name' => $data['forum_name'], // should be defined for email notifications
'enable_indexing' => true,
'screen' => $screen,
// start mod save full drafts
'save_as_draft' => false,
'was_draft' => false,
// end mod save full drafts
'topic_status' => 0,
);
//-- mod : quick title edition -------------------------------------------------
//-- add
$form_data += array('attr_id' => $data['attr_id']);
//-- fin mod : quick title edition ---------------------------------------------
$poll_data = array();
$url = submit_post($mode, $subject, $username, POST_NORMAL, $poll_data, $form_data);
if (isset($captcha) && $captcha->is_solved() === true)
{
$captcha->reset();
}
$message = $user->lang['POST_STORED'] . '<br /><br />' . sprintf($user->lang['VIEW_MESSAGE'], '<a href="' . $url . '">', '</a>');
$message .= '<br /><br />' . sprintf($user->lang['RETURN_FORUM'], '<a href="' . append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $data['forum_id']) . '">', '</a>');
meta_refresh(5, $url);
trigger_error($message);
}
}
}
// display each field of the form
foreach ($fields as $field)
{
$template->assign_block_vars('fields', array(
'NAME' => $field->get_html_label(),
'DESC' => generate_text_for_display($field->get('field_desc'), $field->get('field_bbcode_uid'), $field->get('field_bbcode_bitfield'), $message_flag),
'HTML' => $field->get_html_code(),
));
}
// display captcha
if (isset($captcha) && $captcha->is_solved() === false)
{
$template->assign_vars(array(
'S_CONFIRM_CODE' => true,
'CAPTCHA_TEMPLATE' => $captcha->get_template(),
));
}
// display captcha hidden fields
if (isset($captcha) && $captcha->is_solved() !== false)
{
$template->assign_var('S_HIDDEN_FIELDS', build_hidden_fields($captcha->get_hidden_fields()));
}
// display topic review in replies
if ($mode == 'reply' && topic_review($data['topic_id'], $data['forum_id']))
{
$template->assign_vars(array(
'S_DISPLAY_REVIEW' => true,
'TOPIC_TITLE' => $data['topic_title'],
));
}
// display navigation links and forum rules
generate_forum_nav($data);
generate_forum_rules($data);
// template vars
$template->assign_vars(array(
'ERRORS' => ($errors) ? implode('<br />', $errors) : '',
'FORM_NAME' => $form->get('form_name'),
'FORM_DESC' => generate_text_for_display($form->get('form_desc'), $form->get('form_bbcode_uid'), $form->get('form_bbcode_bitfield'), $message_flag),
'SUBJECT' => $subject,
'USERNAME' => $username,
'S_POST_ACTION' => append_sid("{$phpbb_root_path}posting.$phpEx", "mode=$mode&f=" . $data['forum_id']) . (($mode == 'reply') ? '&t=' . $data['topic_id'] : ''),
'S_DISPLAY_USERNAME' => (!$user->data['is_registered']) ? true : false,
));
//-- mod : quick title edition -------------------------------------------------
//-- add
if ( $mode == 'post' || ($mode == 'edit' && $post_id == $data['topic_first_post_id']) )
{
$topic_attribute = 0;
if ( !$preview )
{
if ( !empty($data['topic_attr_id']) )
{
$topic_attribute = $data['topic_attr_id'];
}
else if ( $data['attr_id'] )
{
$topic_attribute = $data['attr_id'];
}
}
else
{
$topic_attribute = $data['attr_id'];
}
$data['hide_attr'] = unserialize(trim($data['hide_attr']));
if ( $data['hide_attr'] === false )
{
$data['hide_attr'] = array();
}
$qte->attr_select($data['forum_id'], $user->data['user_id'], (int) $topic_attribute, $data['hide_attr']);
$template->assign_var('S_POSTING', true);
}
//-- fin mod : quick title edition ---------------------------------------------
// display page
page_header($form->get('form_name'));
$template->set_filenames(array(
'body' => 'form_body.html',
));
page_footer();
// page is loaded
}
}
?>
Comparison:
http://www.diffchecker.com/x5i5tkbw