本文整理汇总了PHP中phpbb\request\request_interface::is_set_post方法的典型用法代码示例。如果您正苦于以下问题:PHP request_interface::is_set_post方法的具体用法?PHP request_interface::is_set_post怎么用?PHP request_interface::is_set_post使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类phpbb\request\request_interface
的用法示例。
在下文中一共展示了request_interface::is_set_post方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: main
public function main($id, $mode)
{
global $db, $user, $phpbb_admin_path, $phpbb_root_path, $phpEx, $template, $request, $cache, $auth, $config;
$this->db = $db;
$this->user = $user;
$this->template = $template;
$this->request = $request;
$this->cache = $cache;
$this->auth = $auth;
$this->config = $config;
$this->phpbb_root_path = $phpbb_root_path;
$this->php_ext = $phpEx;
$this->default_style = $config['default_style'];
$this->styles_path = $this->phpbb_root_path . $this->styles_path_absolute . '/';
$this->u_base_action = append_sid("{$phpbb_admin_path}index.{$this->php_ext}", "i={$id}");
$this->s_hidden_fields = array('mode' => $mode);
$this->user->add_lang('acp/styles');
$this->tpl_name = 'acp_styles';
$this->page_title = 'ACP_CAT_STYLES';
$this->mode = $mode;
$action = $this->request->variable('action', '');
$post_actions = array('install', 'activate', 'deactivate', 'uninstall');
foreach ($post_actions as $key) {
if ($this->request->is_set_post($key)) {
$action = $key;
}
}
// The uninstall action uses confirm_box() to verify the validity of the request,
// so there is no need to check for a valid token here.
if (in_array($action, $post_actions) && $action != 'uninstall') {
$is_valid_request = check_link_hash($request->variable('hash', ''), $action) || check_form_key('styles_management');
if (!$is_valid_request) {
trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING);
}
}
if ($action != '') {
$this->s_hidden_fields['action'] = $action;
}
$this->template->assign_vars(array('U_ACTION' => $this->u_base_action, 'S_HIDDEN_FIELDS' => build_hidden_fields($this->s_hidden_fields)));
// Execute actions
switch ($action) {
case 'install':
$this->action_install();
return;
case 'uninstall':
$this->action_uninstall();
return;
case 'activate':
$this->action_activate();
return;
case 'deactivate':
$this->action_deactivate();
return;
case 'details':
$this->action_details();
return;
default:
$this->frontend();
}
}
示例2: submit_post_end
/**
* Initialized the survey data if necessary.
*
* @param unknown $event
*/
public function submit_post_end($event)
{
if (!$this->survey->can_create_survey($event['data']['forum_id'])) {
return;
}
if ($this->request->is_set_post('survey_enabled') && ($event['mode'] == 'post' || $event['mode'] == 'edit' && $event['data']['topic_first_post_id'] == $event['data']['post_id'] && $this->survey->is_enabled($event['data']['topic_id']))) {
$this->survey->initialize($event['data']['topic_id']);
}
}
示例3: posting_modify_submit_post_after
/**
* Event: core.posting_modify_submit_post_after
*
* @param Event $event
*/
public function posting_modify_submit_post_after($event)
{
$post_data = $event['post_data'];
if ($post_data['topic_status'] == ITEM_UNLOCKED && $this->request->is_set_post('lock_topic')) {
if ($this->auth->acl_get('m_lock', $event['forum_id']) || $this->auth->acl_get('f_user_lock', $event['forum_id']) && $this->user->data['is_registered'] && !empty($post_data['topic_poster']) && $this->user->data['user_id'] == $post_data['topic_poster'] && $post_data['topic_status'] == ITEM_UNLOCKED ? true : false) {
$topic_data = array($event['post_data']['topic_id'] => $event['post_data']);
$this->topic_mover->move_topics($topic_data, 'move_topics_when_locked');
}
}
}
示例4: process_question_addition_or_modification
/**
* Process addition or modification of question
*
* @return array errors
*/
protected function process_question_addition_or_modification()
{
if (!check_form_key($this->form_key_name)) {
return array($this->user->lang('FORM_INVALID'));
}
$question_id = self::NEW_QUESTION_ID;
if ($this->request->is_set_post('survey-submit-question-modify')) {
$question_id = (int) $this->request->variable('question_to_modify', '');
if (!$this->survey->question_exists($question_id)) {
return array();
}
}
$question = array('label' => '', 'example_answer' => '', 'type' => 0, 'random_choice_order' => 0, 'sum_type' => 0, 'sum_by' => '', 'average' => 0, 'cap' => 0);
foreach ($question as $key => $value) {
$question[$key] = $this->request->variable('question_' . $key, $question[$key], true);
}
$question = array_map('trim', $question);
if ($question['label'] == '') {
return array($this->user->lang('SURVEY_INVALID_QUESTION_NO_LABEL'));
}
if ($this->survey->get_question_id_from_label($question['label'], $question_id) != $question_id) {
return array($this->user->lang('SURVEY_QUESTION_ALREADY_ADDED', $question['label']));
}
$question['random_choice_order'] = $question['random_choice_order'] ? 1 : 0;
$question['average'] = $question['average'] ? 1 : 0;
$question['cap'] = $question['cap'] != '' ? $question['cap'] : 0;
if (!in_array($question['type'], survey::$QUESTION_TYPES)) {
return array($this->user->lang('SURVEY_INVALID_QUESTION_TYPE'));
}
if (!in_array($question['sum_type'], survey::$QUESTION_SUM_TYPES)) {
return array($this->user->lang('SURVEY_INVALID_QUESTION_SUM_TYPE'));
}
if ($question['sum_type'] == survey::$QUESTION_SUM_TYPES['MATCHING_TEXT'] && $question['sum_by'] == '') {
return array($this->user->lang('SURVEY_INVALID_QUESTION_SUM_BY'));
}
if ($question['sum_type'] != survey::$QUESTION_SUM_TYPES['MATCHING_TEXT']) {
$question['sum_by'] = '';
}
if ($question['sum_type'] == survey::$QUESTION_SUM_TYPES['NO_SUM']) {
$question['average'] = 0;
$question['cap'] = 0;
}
$choices_input = $this->request->variable('question_choices', '', true);
$choices = array();
if ($question['type'] == survey::$QUESTION_TYPES['DROP_DOWN_MENU'] || $question['type'] == survey::$QUESTION_TYPES['MULTIPLE_CHOICE']) {
if ($choices_input == '') {
return array($this->user->lang('SURVEY_INVALID_QUESTION_CHOICES'));
}
$choices = array_unique(explode(",", $choices_input));
} else {
$question['random_choice_order'] = 0;
}
$choices = array_map('trim', $choices);
if ($question_id == self::NEW_QUESTION_ID) {
$this->survey->add_question($question, $choices);
} else {
$this->survey->modify_question($question_id, $question, $choices);
}
return array();
}
示例5: create
/**
* Display new contribution page.
*
* @return \Symfony\Component\HttpFoundation\Response
*/
protected function create()
{
if (!$this->is_owner && !$this->auth->acl_get('u_titania_contrib_submit')) {
return $this->helper->needs_auth();
}
$this->user->add_lang_ext('phpbb/titania', 'contributions');
$contrib = new \titania_contribution();
$contrib->contrib_user_id = $this->user->data['user_id'];
$contrib->author = $this->author;
$contrib->get_options();
// Set some main vars up
$message = $this->setup_message($contrib);
$submit = $this->request->is_set_post('submit');
$preview = $this->request->is_set_post('preview');
$error = array();
$settings = array('type' => $this->request->variable('contrib_type', 0), 'permalink' => $this->request->variable('permalink', '', true), 'categories' => $this->request->variable('contrib_category', array(0)), 'coauthors' => array('active' => $this->request->variable('active_coauthors', '', true), 'nonactive' => $this->request->variable('nonactive_coauthors', '', true)), 'custom' => $this->request->variable('custom_fields', array('' => ''), true));
if ($preview || $submit) {
$contrib->post_data($message);
$contrib->__set_array(array('contrib_type' => $settings['type'], 'contrib_name_clean' => $settings['permalink'], 'contrib_visible' => 1));
}
if ($preview) {
$message->preview();
} else {
if ($submit) {
$authors = $contrib->get_authors_from_usernames(array('active_coauthors' => $settings['coauthors']['active'], 'nonactive_coauthors' => $settings['coauthors']['nonactive']));
$authors['author'] = array($this->user->data['username'] => $this->user->data['user_id']);
$error = $contrib->validate($settings['categories'], $authors, $settings['custom']);
if (($form_key_error = $message->validate_form_key()) !== false) {
$error[] = $form_key_error;
}
if (empty($error)) {
$contrib->set_type($contrib->contrib_type);
$contrib->set_custom_fields($settings['custom']);
$contrib->contrib_categories = implode(',', $settings['categories']);
$contrib->contrib_creation_time = time();
$contrib->submit();
$contrib->set_coauthors($authors['active_coauthors'], $authors['nonactive_coauthors'], true);
// Create relations
$contrib->put_contrib_in_categories($settings['categories']);
if ($this->ext_config->support_in_titania) {
$active_authors = array_merge($authors['author'], $authors['active_coauthors']);
foreach ($active_authors as $author) {
$this->subscriptions->subscribe(TITANIA_SUPPORT, $contrib->contrib_id, $author);
}
}
redirect($contrib->get_url('revision'));
}
}
}
// Generate some stuff
$this->display->generate_type_select($contrib->contrib_type);
$this->display->generate_category_select($settings['categories']);
$contrib->assign_details();
$message->display();
foreach ($this->types->get_all() as $type) {
$this->display->generate_custom_fields($type->contribution_fields, $settings['custom'], $type->id);
}
$this->template->assign_vars(array('S_POST_ACTION' => $this->author->get_url('create'), 'S_CREATE' => true, 'S_CAN_EDIT_CONTRIB' => $this->auth->acl_get('u_titania_contrib_submit'), 'CONTRIB_PERMALINK' => $settings['permalink'], 'ERROR_MSG' => !empty($error) ? implode('<br />', $error) : false, 'ACTIVE_COAUTHORS' => $settings['coauthors']['active'], 'NONACTIVE_COAUTHORS' => $settings['coauthors']['nonactive']));
return $this->helper->render('contributions/contribution_manage.html', 'NEW_CONTRIBUTION');
}
示例6: main
/**
* Main ACP module.
*
* @param int $id
* @param string $mode
*/
public function main($id, $mode)
{
$this->config = $GLOBALS['config'];
$this->user = $GLOBALS['user'];
$this->phpbb_root_path = $GLOBALS['phpbb_root_path'];
$this->request = $GLOBALS['request'];
$this->template = $GLOBALS['template'];
$this->user->add_lang('acp/common');
$this->user->add_lang_ext('mop/timeago', 'timeago_acp');
// initialize error container
$error = '';
// silence scrutinizer warning
if ($id) {
// do nothing
}
// use switch for future module expansion cases
switch ($mode) {
case 'general':
$this->tpl_name = 'acp_ta_general';
$this->page_title = $this->user->lang('ACP_TIMEAGO_GENERAL_SETTINGS');
$form_key = 'acp_ta_general';
add_form_key($form_key);
if (empty($error) && $this->request->is_set_post('submit')) {
if (check_form_key($form_key) === false) {
trigger_error($this->user->lang('FORM_INVALID') . adm_back_link($this->u_action), E_USER_WARNING);
}
$this->config->set('ta_cat', $this->request->variable('ta_cat', 1));
$this->config->set('ta_cat_extended', $this->request->variable('ta_cat_extended', 0));
$this->config->set('ta_viewforum', $this->request->variable('ta_viewforum', 1));
$this->config->set('ta_viewforum_extended', $this->request->variable('ta_viewforum_extended', 0));
$this->config->set('ta_viewtopic', $this->request->variable('ta_viewtopic', 1));
$this->config->set('ta_viewtopic_extended', $this->request->variable('ta_viewtopic_extended', 0));
$this->config->set('ta_timer', $this->request->variable('ta_timer', 0));
trigger_error($this->user->lang('CONFIG_UPDATED') . adm_back_link($this->u_action));
}
//end if
// set the template variables
$this->template->assign_vars(['TA_FORUM_ROOT' => $this->phpbb_root_path, 'TA_CAT' => !empty($this->config['ta_cat']) ? $this->config['ta_cat'] : 0, 'TA_CAT_EXTENDED' => !empty($this->config['ta_cat_extended']) ? true : false, 'TA_VIEWFORUM' => !empty($this->config['ta_viewforum']) ? $this->config['ta_viewforum'] : 0, 'TA_VIEWFORUM_EXTENDED' => !empty($this->config['ta_viewforum_extended']) ? true : false, 'TA_VIEWTOPIC' => !empty($this->config['ta_viewtopic']) ? $this->config['ta_viewtopic'] : 0, 'TA_VIEWTOPIC_EXTENDED' => !empty($this->config['ta_viewtopic_extended']) ? true : false, 'TA_TIMER' => !empty($this->config['ta_timer']) ? $this->config['ta_timer'] : 0, 'U_ACTION' => $this->u_action]);
break;
default:
// obligatory default comment
break;
}
//end switch
}
示例7: main
/**
* Main ACP module
*
* @param integer $id
* @param string $mode
*
* @access public
* @return void
*/
public function main($id, $mode)
{
$this->config = $GLOBALS['config'];
$this->user = $GLOBALS['user'];
$this->phpbb_root_path = $GLOBALS['phpbb_root_path'];
$this->request = $GLOBALS['request'];
$this->template = $GLOBALS['template'];
$this->user->add_lang('acp/common');
$this->user->add_lang_ext('svennd/simplecount', 'simplecount_var');
// initialize error container
$error = '';
// use switch for future module expansion cases
switch ($mode) {
case 'general':
$this->tpl_name = 'acp_sc_general';
$this->page_title = $this->user->lang('ACP_SIMPLECOUNT_GENERAL_SETTINGS');
$form_key = 'acp_sc_general';
add_form_key($form_key);
if (empty($error) && $this->request->is_set_post('submit')) {
if (check_form_key($form_key) === FALSE) {
trigger_error($this->user->lang('FORM_INVALID') . adm_back_link($this->u_action), E_USER_WARNING);
}
$this->config->set('sc_active', $this->request->variable('sc_active', 1));
$this->config->set('sc_posts', $this->request->variable('sc_posts', 1));
$this->config->set('sc_topics', $this->request->variable('sc_topics', 1));
$this->config->set('sc_clicks', $this->request->variable('sc_clicks', 1));
$this->config->set('sc_viewforum_views', $this->request->variable('sc_viewforum_views', 1));
$this->config->set('sc_index_posts', $this->request->variable('sc_index_posts', 0));
$this->config->set('sc_index_topics', $this->request->variable('sc_index_topics', 0));
$this->config->set('sc_index_users', $this->request->variable('sc_index_users', 0));
trigger_error($this->user->lang('CONFIG_UPDATED') . adm_back_link($this->u_action));
}
//end if
// set the template variables
$this->template->assign_vars(['SC_ACTIVE' => !empty($this->config['sc_active']) ? $this->config['sc_active'] : 0, 'SC_POSTS' => !empty($this->config['sc_posts']) ? $this->config['sc_posts'] : 0, 'SC_TOPICS' => !empty($this->config['sc_topics']) ? $this->config['sc_topics'] : 0, 'SC_CLICKS' => !empty($this->config['sc_clicks']) ? $this->config['sc_clicks'] : 0, 'SC_VIEWFORUM_VIEWS' => !empty($this->config['sc_viewforum_views']) ? $this->config['sc_viewforum_views'] : 0, 'SC_INDEX_POSTS' => !empty($this->config['sc_index_posts']) ? $this->config['sc_index_posts'] : 0, 'SC_INDEX_TOPICS' => !empty($this->config['sc_index_topics']) ? $this->config['sc_index_topics'] : 0, 'SC_INDEX_USERS' => !empty($this->config['sc_index_users']) ? $this->config['sc_index_users'] : 0, 'U_ACTION' => $this->u_action]);
break;
default:
// obligatory default comment
break;
}
//end switch
}
示例8: base
/**
* Delegates actions to appropriate methods.
*
* @param string $mode Module mode
* @param string $u_action Module URL
* @return null
*/
public function base($mode, $u_action)
{
if (!in_array($mode, array('items', 'sections'))) {
return;
}
$this->u_action = $u_action;
// User wants to unsubscribe?
if ($this->request->is_set_post('unsubscribe')) {
$this->unsubscribe();
}
$this->{"display_{$mode}"}();
add_form_key('ucp_front_subscription');
}
示例9: submit_post
/**
* Stores the hookup data given in posting.php if necessary.
*
* @param unknown $event
*/
public function submit_post($event)
{
// Check permissions
if (!$this->auth->acl_get('f_hookup', $event['data']['forum_id']) && !$this->auth->acl_get('m_edit', $event['data']['forum_id'])) {
return;
}
// We store only if we are creating a new topic or editing the first post of an existing one
if ($event['post_mode'] != 'post' && $event['post_mode'] != 'edit_topic' && $event['post_mode'] != 'edit_first_post') {
return;
}
$sql_data = $event['sql_data'];
$hookup_enabled = $this->request->is_set_post('hookup_enabled');
if ($event['post_mode'] == 'edit') {
$this->hookup->load_hookup($event['data']['topic_id']);
$no_data = empty($this->hookup->hookup_users) && empty($this->hookup->hookup_dates) && empty($this->hookup->hookup_availables);
// Only honor user setting on enable/disable if the hookup is inactive or not set
if ($this->hookup->hookup_enabled || $no_data) {
$hookup_enabled = $this->hookup->hookup_enabled;
}
}
$sql_data[TOPICS_TABLE]['sql'] = array_merge($sql_data[TOPICS_TABLE]['sql'], array('hookup_enabled' => $hookup_enabled, 'hookup_self_invite' => $this->request->is_set_post('hookup_self_invite'), 'hookup_autoreset' => $this->request->is_set_post('hookup_autoreset')));
$event['sql_data'] = $sql_data;
}
示例10: common_delete
protected function common_delete($post_id, $undelete = false)
{
$this->user->add_lang('posting');
// Load the stuff we need
$post = $this->load_post($post_id);
// Check permissions
if (!$undelete && !$post->acl_get('delete') || $undelete && !$post->acl_get('undelete')) {
return $this->controller_helper->needs_auth();
}
if (confirm_box(true)) {
if (!$undelete) {
// Delete the post
if ($this->request->is_set_post('hard_delete') || $post->post_deleted) {
if (!$this->auth->acl_get('u_titania_post_hard_delete')) {
return $this->controller_helper->needs_auth();
}
$post->hard_delete();
// Try to redirect to the next or previous post
$redirect_post_id = \posts_overlord::next_prev_post_id($post->topic_id, $post->post_id);
if ($redirect_post_id) {
return new RedirectResponse($post->topic->get_url(false, array('p' => $redirect_post_id, '#' => "p{$redirect_post_id}")));
}
return new RedirectResponse($post->topic->get_parent_url());
} else {
$post->soft_delete();
if ($this->auth->acl_get('u_titania_mod_post_mod')) {
// They can see the post, redirect back to it
return new RedirectResponse($post->get_url());
} else {
// They cannot see the post, try to redirect to the next or previous post
$redirect_post_id = \posts_overlord::next_prev_post_id($post->topic_id, $post->post_id);
if ($redirect_post_id) {
return new RedirectResponse($post->topic->get_url(false, array('p' => $redirect_post_id, '#' => "p{$redirect_post_id}")));
}
}
}
return new RedirectResponse($post->topic->get_url());
} else {
$post->undelete();
return new RedirectResponse($post->get_url());
}
} else {
$s_hard_delete = !$undelete && !$post->post_deleted && $this->auth->acl_get('u_titania_post_hard_delete');
$this->template->assign_var('S_HARD_DELETE', $s_hard_delete);
confirm_box(false, !$undelete ? 'DELETE_POST' : 'UNDELETE_POST', '', 'posting/delete_confirm.html');
}
return new RedirectResponse($post->get_url());
}
示例11: auth_login_session_create_before
/**
* @param \phpbb\event\data $event
*
* @return \phpbb\event\data $event|null
* @throw http_exception
*/
public function auth_login_session_create_before($event)
{
if ($this->config['tfa_mode'] == session_helper_interface::MODE_DISABLED) {
return $event;
}
if (isset($event['login'], $event['login']['status']) && $event['login']['status'] == LOGIN_SUCCESS) {
// We have a LOGIN_SUCCESS result.
if ($this->session_helper->isTfaRequired($event['login']['user_row']['user_id'], $event['admin'], $event['user_row'])) {
if (!$this->session_helper->isTfaRegistered($event['login']['user_row']['user_id'])) {
// While 2FA is enabled, the user has no methods added.
// We simply return and continue the login procedure (The normal way :)),
// and will disable all pages until he has added a 2FA key.
return $event;
} else {
$this->session_helper->generate_page($event['login']['user_row']['user_id'], $event['admin'], $event['view_online'], !$this->request->is_set_post('viewonline'), $this->request->variable('redirect', ''));
}
}
}
return null;
}
示例12: process_status
/**
* Process status changes
* @param \phpbb\event\data $event
* @param bool $is_member
*/
protected function process_status($event, $is_member)
{
$availables = $this->request->variable('available', array(0 => 0));
if (!$this->request->is_set_post('available')) {
return array();
}
if (!$is_member) {
return array($this->user->lang('NO_HOOKUP_MEMBER'));
}
foreach ($availables as $date_id => $available) {
//ignore HOOKUP_UNSET and other invalid values
if (!is_numeric($date_id) || !isset($this->hookup->hookup_dates[$date_id]) || !in_array($available, array(hookup::HOOKUP_YES, hookup::HOOKUP_NO, hookup::HOOKUP_MAYBE))) {
continue;
}
$this->hookup->set_user_date($this->user->data['user_id'], $date_id, $available);
}
$this->hookup->update_available_sums();
$this->hookup->set_user_data($this->user->data['user_id'], 0, $this->request->variable('comment', '', true));
return array();
}
示例13: posts_merging
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();
// Preliminary checks if the post-based post merging option was checked,
// and user has permission for merging or ignoring merging
$do_not_merge_with_previous = $this->request->is_set_post('posts_merging_option', false) && $this->auth->acl_get('u_postsmerging') && $this->auth->acl_get('u_postsmerging_ignore');
if ($this->auth->acl_get('u_postsmerging') && !$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 poster is not current user, user is not registered,or
// the post is locked, has not yet been approved or allowed merge period has left
if (!$merge_post_data || $merge_post_data['poster_id'] != $this->user->data['user_id'] || $merge_post_data['post_edit_locked'] || (int) $merge_post_data['post_visibility'] == ITEM_UNAPPROVED || $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
$separator = (string) $this->config_text->get('posts_merging_separator_text');
$this->user->add_lang_ext('rxu/PostsMerging', 'posts_merging');
// Calculate the time interval
$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;
// Allow using language variables like {L_LANG_VAR}
// Since /e modifier is deprecated since PHP 5.5.0, use new way
// But for PHP 5.4.0 only as earlier don't support $this closure in anonymous functions
if (version_compare(PHP_VERSION, '5.4.0', '>=')) {
$separator = preg_replace_callback('/{L_([A-Z0-9_]+)}/', function ($matches) {
return $this->user->lang($matches[1]);
}, $separator);
} else {
$separator = preg_replace('/{L_([A-Z0-9_]+)}/e', "\$this->user->lang('\$1')", $separator);
}
// Eval linefeeds and generate the separator, time interval included
$separator = sprintf(str_replace('\\n', "\n", $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;
}
// If this is the first merging for current post, save original post time within the post_created field
// Update post time with the current time and submit post to the database
$merge_post_data['post_created'] = $merge_post_data['post_created'] ?: $merge_post_data['post_time'];
$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'];
//.........这里部分代码省略.........
示例14: avatar_crop
public function avatar_crop($avatar_id)
{
$extension = $this->request->variable('ext', '');
$submit = $this->request->is_set_post('submit');
$prefix = $this->config['avatar_salt'] . '_';
// Calculate new destination
$destination = $this->config['avatar_path'];
// Adjust destination path (no trailing slash)
if (substr($destination, -1, 1) == '/' || substr($destination, -1, 1) == '\\') {
$destination = substr($destination, 0, -1);
}
$destination = str_replace(array('../', '..\\', './', '.\\'), '', $destination);
if ($destination && ($destination[0] == '/' || $destination[0] == "\\")) {
$destination = '';
}
$destination_file = $this->phpbb_root_path . $destination . '/' . $prefix . $avatar_id . '.' . $extension;
$destination_old_file = $this->phpbb_root_path . $this->d_edit . '/' . $avatar_id . '.' . $extension;
$this->user->setup('ucp');
$this->user->add_lang_ext('bb3mobi/AvatarUpload', 'avatar_upload');
$error = array();
if ($this->user->data['user_id'] != $avatar_id) {
trigger_error('NO_AVATAR_USER');
}
if (!$extension || !file_exists($destination_old_file)) {
trigger_error('NO_AVATAR_FILES');
}
if (($image_info = @getimagesize($destination_old_file)) == false) {
trigger_error('NO_AVATAR_FILES');
}
$avatar_width = $image_info[0];
$avatar_height = $image_info[1];
$params_size = array('x1' => $this->request->variable('x1', 0), 'y1' => $this->request->variable('y1', 0), 'x2' => ceil($this->request->variable('x2', $image_info[0])), 'y2' => ceil($this->request->variable('y2', $image_info[1])), 'w' => floor($this->request->variable('w', $image_info[0])), 'h' => floor($this->request->variable('h', $image_info[1])), 'ext' => (string) $extension);
if ($submit) {
if ($params_size['w'] < $this->config['avatar_min_width'] || $params_size['x1'] > $avatar_width - $this->config['avatar_max_width']) {
$error[] = $this->user->lang['ERROR_AVATAR_W'];
}
if ($params_size['h'] < $this->config['avatar_min_height'] || $params_size['y1'] > $avatar_height - $this->config['avatar_max_height']) {
$error[] = $this->user->lang['ERROR_AVATAR_H'];
}
if ($params_size['x2'] > $avatar_width || $params_size['x2'] < $this->config['avatar_min_width']) {
$error[] = $this->user->lang['ERROR_AVATAR_X2'];
}
if ($params_size['y2'] > $avatar_height || $params_size['y2'] < $this->config['avatar_min_height']) {
$error[] = $this->user->lang['ERROR_AVATAR_Y2'];
}
}
if (!sizeof($error) && $submit) {
if ($result = $this->resize($params_size, $this->d_edit, $destination_old_file)) {
rename($destination_old_file, $destination_file);
// Success! Lets save the result in the database
$result = array('user_avatar_type' => AVATAR_UPLOAD, 'user_avatar' => $avatar_id . '_' . time() . '.' . $extension, 'user_avatar_width' => $result['avatar_width'], 'user_avatar_height' => $result['avatar_height']);
$sql = 'UPDATE ' . USERS_TABLE . '
SET ' . $this->db->sql_build_array('UPDATE', $result) . '
WHERE user_id = ' . (int) $this->user->data['user_id'];
$this->db->sql_query($sql);
meta_refresh(3, generate_board_url(), true);
$message = $this->user->lang['PROFILE_UPDATED'] . '<br /><br />' . sprintf($this->user->lang['RETURN_INDEX'], '<a href="' . generate_board_url() . '">', '</a>');
trigger_error($message);
}
}
$this->template->assign_vars(array('ERROR' => sizeof($error) ? implode('<br />', $error) : '', 'AVATAR_FILE' => generate_board_url() . '/' . $this->d_edit . '/' . $avatar_id . '.' . $extension, 'IMG_WIDTH' => $image_info[0], 'IMG_HEIGHT' => $image_info[1], 'SIZE_X1' => $params_size['x1'], 'SIZE_X2' => $params_size['x2'], 'SIZE_Y1' => $params_size['y1'], 'SIZE_Y2' => $params_size['y2'], 'SIZE_WIDTH' => $params_size['w'], 'SIZE_HEIGHT' => $params_size['h'], 'S_HIDDEN_FIELDS' => build_hidden_fields(array('ext' => $extension)), 'S_CROP_ACTION' => $this->helper->route("bb3mobi_AvatarUpload_crop", array('avatar_id' => $avatar_id))));
page_header('Avatar crop');
$this->template->set_filenames(array('body' => '@bb3mobi_AvatarUpload/crop_body.html'));
page_footer();
}
示例15: approve
/**
* @{inheritDoc}
*/
public function approve(\titania_contribution $contrib, \titania_queue $queue, request_interface $request)
{
if (!$request->is_set_post('style_demo_install')) {
return;
}
$revision = $queue->get_revision();
$this->install_demo($contrib, $revision);
}