/** * {@inheritdoc} */ public function get_template_side($module_id) { $style_count = 0; $style_select = ''; $sql = 'SELECT style_id, style_name FROM ' . STYLES_TABLE . ' WHERE style_active = 1 ORDER BY LOWER(style_name) ASC'; $result = $this->db->sql_query($sql, 3600); while ($row = $this->db->sql_fetchrow($result)) { $style = $this->request->variable('style', 0); if (!empty($style)) { $url = str_replace('style=' . $style, 'style=' . $row['style_id'], $this->modules_helper->route('board3_portal_controller')); } else { $url = $this->modules_helper->route('board3_portal_controller') . '?style=' . $row['style_id']; } ++$style_count; $style_select .= '<option value="' . $url . '"' . ($row['style_id'] == $this->user->style['style_id'] ? ' selected="selected"' : '') . '>' . utf8_htmlspecialchars($row['style_name']) . '</option>'; } $this->db->sql_freeresult($result); if (strlen($style_select)) { $this->template->assign_var('STYLE_SELECT', $style_select); } // Assign specific vars $this->template->assign_vars(array('S_STYLE_OPTIONS' => $this->config['override_user_style'] || $style_count < 2 ? '' : $style_select)); return 'stylechanger_side.html'; }
/** * Likes controller for route /like_post/{like} * * @param int @post_id The post to be edited. */ public function like_post($post_id) { // If unknown user or bot, cannot like. if ($this->user->data['user_id'] == ANONYMOUS || $this->user->data['is_bot']) { return; } // Add language variables for response. $this->user->add_lang_ext('nuleaf/likes', 'likes'); // Grab forum id for permission. $sql = 'SELECT forum_id FROM ' . POSTS_TABLE . ' WHERE post_id = ' . $post_id; $result = $this->db->sql_query_limit($sql, 1); $forum_id = $this->db->sql_fetchrow($result)['forum_id']; $this->db->sql_freeresult($result); // Does the user have permission to like posts in this forum? if ($this->auth->acl_get('!f_like', $forum_id)) { $json_response = new json_response(); $json_response->send(array('error' => $this->user->lang('LIKE_NOT_AUTHORIZED'))); return; } if ($this->request->is_ajax()) { $liked = $this->likes_manager->is_liked($post_id); if ($liked) { // If post is already liked, unlike it. $likes_count = $this->likes_manager->unlike($post_id); } else { // Else like the post. $likes_count = $this->likes_manager->like($post_id); } // Since the post has now been liked/unliked, $liked is reversed. $json_response = new json_response(); $json_response->send(array('likes_count' => $likes_count, 'liked' => !$liked, 'LIKE_POST' => $this->user->lang('LIKE_POST'), 'UNLIKE_POST' => $this->user->lang('UNLIKE_POST'), 'LIKE_BUTTON' => $this->user->lang('LIKE_BUTTON'), 'UNLIKE_BUTTON' => $this->user->lang('UNLIKE_BUTTON'))); } }
/** * Run tool. * * @return \Symfony\Component\HttpFoundation\Response */ public function run_tool() { $type = $this->request->variable('type', 'queue'); $start = $this->request->variable('start', 0); $continue_start = null; switch ($type) { case 'queue': $continue_start = $this->sync_queue_topics($start); if ($continue_start === null) { $type = 'contrib'; $continue_start = 0; } break; case 'contrib': $continue_start = $this->sync_contrib_topics($start); break; } if ($continue_start !== null) { $params = array('tool' => 'rebuild_topic_urls', 'type' => $type, 'submit' => 1, 'hash' => generate_link_hash('manage'), 'start' => $continue_start); meta_refresh(2, $this->controller_helper->route('phpbb.titania.administration.tool', $params)); } $msg = $continue_start !== null ? 'PLEASE_WAIT_FOR_TOOL' : 'DONE'; $this->template->assign_vars(array('MESSAGE_TEXT' => $this->user->lang($msg), 'MESSAGE_TITLE' => $this->user->lang('INFORMATION'))); return $this->controller_helper->render('message_body.html', $msg); }
/** * Event: core.viewforum_get_topic_ids_data */ public function viewforum_get_topic_ids_data($event) { $custom_sorting = array('by' => $this->user->data['user_topic_sortby_type'], 'order' => $this->user->data['user_topic_sortby_dir']); // Forum-specific sorting if ($event['forum_data']['sort_topics_by'] != $this->default_sort_by) { $custom_sorting = array('by' => $event['forum_data']['sort_topics_by'], 'order' => $event['forum_data']['sort_topics_order']); } else { if ($this->user->data['is_registered'] && !$this->user->data['is_bot'] && $this->config['kasimi.sorttopics.ucp_enabled'] && $this->user->data['sort_topics_by_created_time']) { $custom_sorting['by'] = 'c'; } } // Temporary sorting if the user used the options at the bottom of viewforum if ($this->request->is_set('sk')) { $custom_sorting['by'] = $this->request->variable('sk', ''); } if ($this->request->is_set('sd')) { $custom_sorting['order'] = $this->request->variable('sd', ''); } $this->inject_created_time_select_option('S_SELECT_SORT_KEY', $custom_sorting['by'], 'S_SELECT_SORT_DIR', $custom_sorting['order']); // Bail out if we don't need to adjust sorting if ($custom_sorting['by'] == $this->sort_key && $custom_sorting['order'] == $this->sort_dir) { return; } // This forum requires custom topic sorting, let's get our hands dirty $sort_by_sql = array('a' => 't.topic_first_poster_name', 't' => array('t.topic_last_post_time', 't.topic_last_post_id'), 'c' => array('t.topic_time', 't.topic_id'), 'r' => $this->auth->acl_get('m_approve', $event['forum_data']['forum_id']) ? 't.topic_posts_approved + t.topic_posts_unapproved + t.topic_posts_softdeleted' : 't.topic_posts_approved', 's' => 't.topic_title', 'v' => 't.topic_views'); $sort_sql = $sort_by_sql[$custom_sorting['by']]; $direction = $custom_sorting['order'] == 'd' ? 'DESC' : 'ASC'; $sql_sort_order = (is_array($sort_sql) ? implode(' ' . $direction . ', ', $sort_sql) : $sort_sql) . ' ' . $direction; $sql_ary = $event['sql_ary']; $store_reverse = $event['store_reverse']; $sql_ary['ORDER_BY'] = 't.topic_type ' . (!$store_reverse ? 'DESC' : 'ASC') . ', ' . $sql_sort_order; $event['sql_sort_order'] = $sql_sort_order; $event['sql_ary'] = $sql_ary; }
/** * Display support topics from all contributions or of a specific type. * * @param string $type Contribution type's string identifier * @return \Symfony\Component\HttpFoundation\Response */ public function display_topics($type) { $type_id = $this->get_type_id($type); if ($type_id === false) { return $this->helper->error('NO_PAGE', 404); } if ($type == 'all') { // Mark all topics read if ($this->request->variable('mark', '') == 'topics') { $this->tracking->track(TITANIA_ALL_SUPPORT, self::ALL_SUPPORT); } // Mark all topics read $this->template->assign_var('U_MARK_TOPICS', $this->helper->route('phpbb.titania.support', array('type' => 'all', 'mark' => 'topics'))); } $this->display->assign_global_vars(); $u_all_support = $this->helper->route('phpbb.titania.support', array('type' => 'all')); $this->template->assign_var('U_ALL_SUPPORT', $u_all_support); // Generate the main breadcrumbs $this->display->generate_breadcrumbs(array('ALL_SUPPORT' => $u_all_support)); // Links to the support topic lists foreach ($this->types->get_all() as $id => $class) { $this->template->assign_block_vars('support_types', array('U_SUPPORT' => $this->helper->route('phpbb.titania.support', array('type' => $class->url)), 'TYPE_SUPPORT' => $class->langs)); } $data = \topics_overlord::display_forums_complete('all_support', false, array('contrib_type' => $type_id)); // Canonical URL $data['sort']->set_url($this->helper->route('phpbb.titania.support', array('type' => $type))); $this->template->assign_var('U_CANONICAL', $data['sort']->build_canonical()); return $this->helper->render('all_support.html', 'CUSTOMISATION_DATABASE'); }
public function memberlist_modify_query($event) { $sql_from = $event['sql_from']; $sql_where = $event['sql_where']; $user_from = $this->request->variable('user_from', '', true); $user_id = $this->request->variable('user_id', ''); $this->template->assign_vars(array('USER_FROM' => $user_from, 'USER_ID' => (int) $user_id)); if ($user_from) { $sql_from .= ', ' . PROFILE_FIELDS_DATA_TABLE . ' pf '; $pieces = explode(' ', $user_from); $sql_where .= ' AND (pf.pf_phpbb_location COLLATE utf8_general_ci '; $sql_where .= $this->db->sql_like_expression(str_replace('*', $this->db->get_any_char(), $pieces[0])); for ($i = 1; $i < sizeof($pieces); $i++) { $sql_where .= ' OR pf.pf_phpbb_location COLLATE utf8_general_ci '; $sql_where .= $this->db->sql_like_expression(str_replace('*', $this->db->get_any_char(), $pieces[$i])); } $sql_where .= ') AND u.user_id = pf.user_id'; $event['sql_where'] = $sql_where; $event['sql_from'] = $sql_from; } if ((int) $user_id) { $sql_where .= ' AND u.user_id = ' . $user_id . ''; $event['sql_where'] = $sql_where; } }
public function avatar_explain($event) { $mode = $this->request->variable('mode', ''); if ($mode == 'avatar') { $this->resize->avatar_explain(); } }
/** * {@inheritdoc} */ public function perform_auth_login() { if (!$this->service_provider instanceof \OAuth\OAuth2\Service\Evesso) { throw new \phpbb\auth\provider\oauth\service\exception('AUTH_PROVIDER_OAUTH_ERROR_INVALID_SERVICE_TYPE'); } $this->service_provider->requestAccessToken($this->request->variable('code', '')); $result = json_decode($this->service_provider->request('verify'), true); return $result['CharacterID']; }
/** * 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']); } }
/** * 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'); } } }
/** * @param int $block_id * @return array */ public function save($block_id) { $content = $this->request->variable('content', '', true); $cblocks = $this->_get_custom_blocks(); $sql_data = array('block_id' => $block_id, 'block_content' => $content, 'bbcode_bitfield' => '', 'bbcode_options' => 7, 'bbcode_uid' => ''); generate_text_for_storage($sql_data['block_content'], $sql_data['bbcode_uid'], $sql_data['bbcode_bitfield'], $sql_data['bbcode_options'], true, true, true); $sql = !isset($cblocks[$block_id]) ? 'INSERT INTO ' . $this->cblocks_table . ' ' . $this->db->sql_build_array('INSERT', $sql_data) : 'UPDATE ' . $this->cblocks_table . ' SET ' . $this->db->sql_build_array('UPDATE', $sql_data) . ' WHERE block_id = ' . (int) $block_id; $this->db->sql_query($sql); $this->cache->destroy('pt_cblocks'); return array('id' => $block_id, 'content' => $this->_get_content($sql_data), 'callback' => 'previewCustomBlock'); }
protected function _force_get_route($route_data, $has_blocks = false) { $route_mapper = $this->mapper_factory->create('blocks', 'routes'); if (($route = $route_mapper->load($route_data)) === null) { $route_data['ext_name'] = $this->request->variable('ext', ''); $route_data['has_blocks'] = $has_blocks; $entity = $route_mapper->create_entity($route_data); $route = $route_mapper->save($entity); } return $route; }
public function acp_manage_forums_update_data_after($event) { $status = $this->request->variable('rh_topictags_enabled', 0); $prune = $this->request->variable('rh_topictags_prune', 0); if (!$status && $prune) { $data = $event->get_data(); $forum_id = (int) $data['forum_data']['forum_id']; $this->tags_manager->delete_tags_from_tagdisabled_forums(array($forum_id)); $this->tags_manager->delete_unused_tags(); } $this->tags_manager->calc_count_tags(); }
/** * {@inheritdoc} */ public function perform_auth_login() { if (!$this->service_provider instanceof \OAuth\OAuth2\Service\Facebook) { throw new exception('AUTH_PROVIDER_OAUTH_ERROR_INVALID_SERVICE_TYPE'); } // This was a callback request, get the token $this->service_provider->requestAccessToken($this->request->variable('code', '')); // Send a request with it $result = json_decode($this->service_provider->request('/me'), true); // Return the unique identifier return $result['id']; }
/** * {@inheritdoc} */ public function perform_auth_login() { if (!$this->service_provider instanceof \OAuth\OAuth2\Service\BattleNetUS) { throw new \phpbb\auth\provider\oauth\service\exception('AUTH_PROVIDER_OAUTH_ERROR_INVALID_SERVICE_TYPE'); } // This was a callback request from battlenet, get the token $this->service_provider->requestAccessToken($this->request->variable('code', '')); // Send a request with it $result = json_decode($this->service_provider->request('account/user'), true); // Return the unique identifier returned from battlenet return $result['battletag']; }
public function pm_warning($event) { // There is no suitable event - read the data from the submit: $address_list = $this->request->variable('address_list', array('' => array(0 => ''))); // This has the drawback of not knowing about new users currently being added // We therefore will have to check the added recipients list for known usernames as well :/ // This also has the drawback of still showing the warning even if the user is currently deleted. // So let's remove the deleted user from the list as well: $delete = $this->request->variable('remove_u', array(0 => '')); foreach ($delete as $key => $value) { if (isset($address_list['u'][$key])) { unset($address_list['u'][$key]); } } //Wenn PN an Teammitglied gesendet werden soll, Hinweismeldung anzeigen //TODO: Etwas besseres als Referenz nehmen als "phpBB.de-Team" im Gruppennamen. if (!empty($address_list['u'])) { $sql = "SELECT u.user_id, ut.username\n\t\t\t\tFROM " . USER_GROUP_TABLE . " u\n\t\t\t\tLEFT JOIN " . GROUPS_TABLE . " g ON g.group_id = u.group_id\n\t\t\t\tLEFT JOIN " . USERS_TABLE . " ut ON u.user_id = ut.user_id\n\t\t\t\tWHERE g.group_name = 'phpBB.de-Team' OR g.group_name = 'phpBB Deutschland e. V.' "; $result = $this->db->sql_query($sql, 3600); $team_user_ids = array(); $team_user_names = array(); while ($row = $this->db->sql_fetchrow($result)) { $team_user_ids[] = $row['user_id']; $team_user_names[$row['user_id']] = $row['username']; } if (count(array_intersect(array_keys($address_list['u']), $team_user_ids)) > 0) { $this->template->assign_var('S_PN_TO_TEAM_MEMBER', true); return; } // This is only necessary, if we didn't find a member yet. $new_recipients = explode("\n", $this->request->variable('username_list', '', true)); if (sizeof($team_user_names) < sizeof($new_recipients)) { $new_recipients = array_map('trim', $new_recipients); foreach ($team_user_names as $username) { if (in_array($username, $new_recipients)) { $this->template->assign_var('S_PN_TO_TEAM_MEMBER', true); return; } } } else { foreach ($new_recipients as $username) { if (in_array(trim($username), $team_user_names)) { $this->template->assign_var('S_PN_TO_TEAM_MEMBER', true); return; } } } } }
/** * {@inheritdoc} */ public function perform_auth_login() { if (!$this->service_provider instanceof \OAuth\OAuth1\Service\Twitter) { throw new \phpbb\auth\provider\oauth\service\exception('AUTH_PROVIDER_OAUTH_ERROR_INVALID_SERVICE_TYPE'); } $storage = $this->service_provider->getStorage(); $token = $storage->retrieveAccessToken('Twitter'); $tokensecret = $token->getRequestTokenSecret(); // This was a callback request from twitter, get the token $this->service_provider->requestAccessToken($this->request->variable('oauth_token', ''), $this->request->variable('oauth_verifier', ''), $tokensecret); // Send a request with it $result = json_decode($this->service_provider->request('account/verify_credentials.json'), true); // Return the unique identifier returned from twitter return $result['id']; }
/** * Event: core.acp_manage_forums_request_data * * @param Event $event */ public function acp_manage_forums_request_data($event) { $lock_options = array('move_topics_when_locked' => $this->request->variable('move_topics_when_locked', 0), 'move_topics_when_locked_solved' => $this->request->variable('move_topics_when_locked_solved', 0), 'move_topics_when_locked_to' => $this->request->variable('move_topics_when_locked_to', 0)); $event['forum_data'] = array_merge($event['forum_data'], $lock_options); // Apply this forum's preferences to all sub-forums if ($event['action'] == 'edit' && $this->request->variable('move_topics_when_locked_subforums', 0)) { $subforum_ids = $this->get_subforum_ids($event['forum_data']['forum_id']); if (!empty($subforum_ids)) { $sql_ary = 'UPDATE ' . FORUMS_TABLE . ' SET ' . $this->db->sql_build_array('UPDATE', $lock_options) . ' WHERE ' . $this->db->sql_in_set('forum_id', $subforum_ids); $this->db->sql_query($sql_ary); } } }
/** * The main script, orchestrating all steps of the process */ public function generate_menu() { // When the event is dispatched from posting.php, the forum_id is not passed, // so its better to use request->variable instead of $event['item_id'] $current_id = $this->request->variable('f', 0); $list = $this->get_forum_list(false, false, true, false); $parents = $this->get_crumb_parents($list, $current_id); $list = $this->mark_current($list, $current_id, $parents); $tree = $this->build_tree($list); $html = $this->build_output($tree); unset($list, $tree); if (!empty($html)) { $this->template->assign_vars(array('BREADCRUMB_MENU' => $html)); } }
/** * Run requested tool. * * @param string $tool Tool. * @param int $id Revision id. * * @return \Symfony\Component\HttpFoundation\Response */ public function run_tool($tool, $id) { if (!in_array($tool, array('automod', 'mpv', 'epv'))) { return $this->helper->error('INVALID_TOOL', 404); } // Check the hash first to avoid unnecessary queries. if (!check_link_hash($this->request->variable('hash', ''), 'queue_tool')) { return $this->helper->error('PAGE_REQUEST_INVALID'); } $this->load_objects($id); if (!$this->contrib->type->acl_get('view')) { return $this->helper->needs_auth(); } return $this->{$tool}(); }
public function acp_board_config($event) { $mode = $event['mode']; if ($mode == 'post') { $new_config = array('legend_newtopic' => 'ACP_NEWTOPIC', 'newtopic_forum' => array('lang' => 'ACP_NEWTOPIC_FORUM', 'validate' => 'string', 'type' => 'custom', 'function' => array($this, 'select_forums'), 'explain' => true), 'newtopic_button' => array('lang' => 'ACP_NEWTOPIC_BUTTON', 'validate' => 'string', 'type' => 'text:25:40', 'explain' => false)); $search_slice = 'max_post_img_height'; $display_vars = $event['display_vars']; $display_vars['vars'] = phpbb_insert_config_array($display_vars['vars'], $new_config, array('after' => $search_slice)); $event['display_vars'] = array('title' => $display_vars['title'], 'vars' => $display_vars['vars']); if ($event['submit']) { $values = $this->request->variable('newtopic_forum', array(0 => '')); $this->config->set('newtopic_forum', implode(',', $values)); } } }
public function acp_board_config($event) { if ($event['mode'] == 'post') { $this->user->add_lang_ext('bb3mobi/vkRepost', 'info_acp_repost_vk'); $display_vars = $event['display_vars']; $new_config = array('legend4' => 'VK_REPOST', 'vk_api_id' => array('lang' => 'VK_API_ID', 'validate' => 'string', 'type' => 'text:30:200', 'explain' => true), 'vk_token' => array('lang' => 'VK_TOKEN', 'validate' => 'string', 'type' => 'custom', 'function' => array($this, 'token_link'), 'explain' => true), 'vk_repost_group' => array('lang' => 'VK_REPOST_GROUP', 'validate' => 'string', 'type' => 'text:15:100', 'explain' => true), 'vk_repost_forum' => array('lang' => 'VK_REPOST_FORUMS', 'validate' => 'string', 'type' => 'custom', 'function' => array($this, 'select_forums'), 'explain' => true), 'vk_repost_admin' => array('lang' => 'VK_REPOST_ADMIN', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), 'vk_repost_text' => array('lang' => 'VK_REPOST_TEXT', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), 'vk_repost_lenght' => array('lang' => 'VK_REPOST_LENGHT', 'validate' => 'int:0', 'type' => 'text:4:6', 'explain' => false), 'vk_repost_url' => array('lang' => 'VK_REPOST_URL', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true)); $display_vars = $event['display_vars']; $display_vars['vars'] = phpbb_insert_config_array($display_vars['vars'], $new_config, array('after' => 'max_post_img_height')); $event['display_vars'] = array('title' => $display_vars['title'], 'vars' => $display_vars['vars']); if ($event['submit']) { $values = $this->request->variable('vk_repost_forum', array(0 => '')); $this->config->set('vk_repost_forum', implode(',', $values)); } } }
/** * Checks whether the chunk we are about to deal with was actually uploaded * by PHP and actually exists, if not, it generates an error * * @param string $form_name The name of the file in the form data * * @return null */ protected function integrate_uploaded_file($form_name, $chunk, $file_path) { $is_multipart = $this->is_multipart(); $upload = $this->request->file($form_name); if ($is_multipart && (!isset($upload['tmp_name']) || !is_uploaded_file($upload['tmp_name']))) { $this->emit_error(103, 'PLUPLOAD_ERR_MOVE_UPLOADED'); } $tmp_file = $this->temporary_filepath($upload['tmp_name']); if (!phpbb_is_writable($this->temporary_directory) || !move_uploaded_file($upload['tmp_name'], $tmp_file)) { $this->emit_error(103, 'PLUPLOAD_ERR_MOVE_UPLOADED'); } $out = fopen("{$file_path}.part", $chunk == 0 ? 'wb' : 'ab'); if (!$out) { $this->emit_error(102, 'PLUPLOAD_ERR_OUTPUT'); } $in = fopen($is_multipart ? $tmp_file : 'php://input', 'rb'); if (!$in) { $this->emit_error(101, 'PLUPLOAD_ERR_INPUT'); } while ($buf = fread($in, 4096)) { fwrite($out, $buf); } fclose($in); fclose($out); if ($is_multipart) { unlink($tmp_file); } }
/** * Delete module * * @param int|string $id Module ID of the acp_portal module * @param string $mode Mode of the acp_portal module * @param string $action Current action of the acp_portal module * @param int $module_id ID of the module that should be deleted */ public function module_delete($id, $mode, $action, $module_id) { $module_data = $this->get_move_module_data($module_id); if ($module_data !== false) { $module_classname = $this->request->variable('module_classname', ''); $this->get_module($module_data['module_classname']); if (confirm_box(true)) { $this->module->uninstall($module_data['module_id'], $this->db); $sql = 'DELETE FROM ' . PORTAL_MODULES_TABLE . ' WHERE module_id = ' . (int) $module_id; $this->db->sql_query($sql); $sql = 'UPDATE ' . PORTAL_MODULES_TABLE . ' SET module_order = module_order - 1 WHERE module_column = ' . (int) $module_data['module_column'] . ' AND module_order > ' . (int) $module_data['module_order']; $this->db->sql_query($sql); $this->cache->purge(); // make sure we don't get errors after re-adding a module // Handle ajax request $this->handle_ajax_request(array('success' => true, 'MESSAGE_TITLE' => $this->user->lang['INFORMATION'], 'MESSAGE_TEXT' => $this->user->lang['SUCCESS_DELETE'])); trigger_error($this->user->lang['SUCCESS_DELETE'] . adm_back_link($this->u_action)); } else { if ($this->module->get_language()) { $this->controller_helper->load_module_language($this->module); } $confirm_text = isset($this->user->lang[$module_data['module_name']]) ? sprintf($this->user->lang['DELETE_MODULE_CONFIRM'], $this->user->lang[$module_data['module_name']]) : sprintf($this->user->lang['DELETE_MODULE_CONFIRM'], utf8_normalize_nfc($module_data['module_name'])); confirm_box(false, $confirm_text, build_hidden_fields(array('i' => $id, 'mode' => $mode, 'action' => $action, 'module_id' => $module_id, 'module_classname' => $module_classname))); } } $this->cache->destroy('sql', PORTAL_MODULES_TABLE); }
/** * Event: rfd.api.pre_update_topic * * Validate trader_type being passed in * * @param phpbbEvent $event */ public function rfd_api_pre_update_topic(phpbbEvent $event) { $data = $event->get_data(); $topic_id = $data['topic_id']; $forum_id = $data['forum_id']; $errors = $data['errors']; $type = $this->request->variable('trader_type', '', false, \phpbb\request\request_interface::POST); // if trader_type is not set, set it to the current trader_type if (!isset($type)) { $type = $this->manager->getTopicType($topic_id); $type = $this->manager->validateForumType($forum_id, $type, false); } else { if ($this->manager->getForumStatus($forum_id)) { $type = $this->manager->validateForumType($forum_id, $type, true); } } // Expose error if trader_type is not supported by the forum if (is_null($type)) { $errors[] = 'This forum does not support that trader type'; $data['errors'] = $errors; $event->set_data($data); } else { // Overwrite the request so that submit_post_end listener can handle trader_type $this->request->overwrite('prefixfield', $type, \phpbb\request\request_interface::POST); } }
/** * 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'); }
protected function setUp() { global $phpbb_root_path, $phpEx; $this->request = $this->getMock('\\phpbb\\request\\request'); $this->request->expects($this->any())->method('file')->willReturn(array()); $this->filesystem = new \phpbb\filesystem\filesystem(); $this->language = new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)); $this->php_ini = new \bantu\IniGetWrapper\IniGetWrapper(); $this->container = new phpbb_mock_container_builder($phpbb_root_path, $phpEx); $this->container->set('files.filespec', new \phpbb\files\filespec($this->filesystem, $this->language, $this->php_ini, new \FastImageSize\FastImageSize(), $phpbb_root_path, new \phpbb\mimetype\guesser(array('mimetype.extension_guesser' => new \phpbb\mimetype\extension_guesser())))); $this->factory = new \phpbb\files\factory($this->container); $this->plupload = $this->getMockBuilder('\\phpbb\\plupload\\plupload')->disableOriginalConstructor()->getMock(); $this->plupload->expects($this->any())->method('handle_upload')->willReturn(array()); $this->path = __DIR__ . '/fixture/'; $this->phpbb_root_path = $phpbb_root_path; }
/** * {@inheritdoc} */ public function init_extractor($format, $filename, $time, $download = false, $store = false) { $this->download = $download; $this->store = $store; $this->time = $time; $this->format = $format; switch ($format) { case 'text': $ext = '.sql'; $open = 'fopen'; $this->write = 'fwrite'; $this->close = 'fclose'; $mimetype = 'text/x-sql'; break; case 'bzip2': $ext = '.sql.bz2'; $open = 'bzopen'; $this->write = 'bzwrite'; $this->close = 'bzclose'; $mimetype = 'application/x-bzip2'; break; case 'gzip': $ext = '.sql.gz'; $open = 'gzopen'; $this->write = 'gzwrite'; $this->close = 'gzclose'; $mimetype = 'application/x-gzip'; break; default: throw new invalid_format_exception(); break; } if ($download === true) { $name = $filename . $ext; header('Cache-Control: private, no-cache'); header("Content-Type: {$mimetype}; name=\"{$name}\""); header("Content-disposition: attachment; filename={$name}"); switch ($format) { case 'bzip2': ob_start(); break; case 'gzip': if (strpos($this->request->header('Accept-Encoding'), 'gzip') !== false && strpos(strtolower($this->request->header('User-Agent')), 'msie') === false) { ob_start('ob_gzhandler'); } else { $this->run_comp = true; } break; } } if ($store === true) { $file = $this->phpbb_root_path . 'store/' . $filename . $ext; $this->fp = $open($file, 'w'); if (!$this->fp) { trigger_error('FILE_WRITE_FAIL', E_USER_ERROR); } } $this->is_initialized = true; }
/** * @dataProvider data_upload_form */ public function test_upload_form($upload, $expected, $plupload = array()) { $this->request = $this->getMock('\\phpbb\\request\\request'); $this->request->expects($this->any())->method('file')->willReturn($upload); $filespec = new \phpbb\files\filespec($this->filesystem, $this->language, $this->php_ini, new \FastImageSize\FastImageSize(), $this->phpbb_root_path, new \phpbb\mimetype\guesser(array('mimetype.extension_guesser' => new \phpbb\mimetype\extension_guesser()))); $this->container->set('files.filespec', $filespec); $this->factory = new \phpbb\files\factory($this->container); $this->plupload = $this->getMockBuilder('\\phpbb\\plupload\\plupload')->disableOriginalConstructor()->getMock(); $this->plupload->expects($this->any())->method('handle_upload')->willReturn($plupload); $type_form = new \phpbb\files\types\form($this->factory, $this->language, $this->php_ini, $this->plupload, $this->request); $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->php_ini, $this->request, $this->phpbb_root_path); $upload->set_allowed_extensions(array('png')); $type_form->set_upload($upload); $file = $type_form->upload('foobar'); $this->assertSame($expected, $file->error); $this->assertInstanceOf('\\phpbb\\files\\filespec', $file); }
/** * @param array $cfg_array * @param array $df_settings */ private function _get_multi_select(array &$cfg_array, array $df_settings) { $multi_select = utf8_normalize_nfc($this->request->variable('config', array('' => array('' => '')), true)); $multi_select = array_filter($multi_select); foreach ($multi_select as $field => $settings) { $cfg_array[$field] = !empty($settings) ? $settings : $df_settings[$field]['default']; } }