作者:vidak
项目:trade
/**
* 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);
}
}
作者:alhitar
项目:Board3-Porta
/**
* {@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';
}
作者:NuLea
项目:nuleaf-foru
/**
* 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')));
}
}
作者:OfficeForu
项目:customisation-d
/**
* 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);
}
作者:Mauro
项目:phpbb-ext-sorttopic
/**
* 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;
}
作者:Sajak
项目:customisation-d
/**
* 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');
}
作者:AlexShee
项目:phpbb3.1-Search_User_Fro
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;
}
}
作者:bb3mob
项目:AvatarUploa
public function avatar_explain($event)
{
$mode = $this->request->variable('mode', '');
if ($mode == 'avatar') {
$this->resize->avatar_explain();
}
}
作者:bastian
项目:phpbb-ext-evess
/**
* {@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'];
}
作者:kilian
项目:phpbb-ext-surve
/**
* 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']);
}
}
作者:kasim
项目:phpbb-ext-movetopicswhenlocke
/**
* 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');
}
}
}
作者:BogusCurr
项目:phpBB-ext-sitemake
/**
* @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');
}
作者:3D-
项目:phpBB-ext-sitemake
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;
}
作者:NuLea
项目:phpbb-ext-tag
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();
}
作者:Tarenda
项目:spring-websit
/**
* {@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'];
}
作者:alexe
项目:PHPBB-BattleNet-OAut
/**
* {@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'];
}
作者:phpbb-d
项目:phpbb-ext-contact-for
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;
}
}
}
}
}
作者:phpb
项目:phpbb-cor
/**
* {@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'];
}
作者:kasim
项目:phpbb-ext-movetopicswhenlocke
/**
* 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);
}
}
}
作者:Sajak
项目:BreadcrumbMen
/**
* 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));
}
}