Version 0.9.8

This commit is contained in:
football
2017-02-19 20:25:32 +01:00
parent 09631cbe15
commit a16e0e3c79
26 changed files with 13323 additions and 13446 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,463 +1,461 @@
<?php
/**
*
* @package phpBB Extension - Football Football
* @copyright (c) 2016 football (http://football.bplaced.net)
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
namespace football\football\acp;
class extra_module
{
public $u_action;
protected $db, $user, $template, $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;
protected $root_path, $request, $php_ext, $log;
public function __construct()
{
global $db, $user, $request, $template;
global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;
$user->add_lang_ext('football/football', 'football');
$user->add_lang_ext('football/football', 'info_acp_extra');
$this->root_path = $phpbb_root_path . 'ext/football/football/';
$this->config = $config;
$this->request = $request;
$this->phpbb_root_path = $phpbb_root_path;
$this->phpbb_admin_path = $phpbb_admin_path;
$this->php_ext = $phpEx;
if(!function_exists('season_info'))
{
include($this->root_path . 'includes/functions.' . $this->php_ext);
}
if (!defined('FOOTB_SEASONS'))
{
include($this->root_path . 'includes/constants.' . $this->php_ext);
}
}
function main($id, $mode)
{
global $db, $auth, $phpbb_container, $phpbb_admin_path, $league_info;
global $template, $user, $config, $phpbb_extension_manager, $request, $phpbb_root_path, $phpEx;
$provider = new \phpbb\controller\ provider();
$symphony_request = new \phpbb\ symfony_request($request);
$filesystem = new \phpbb\ filesystem();
$helper = new \phpbb\controller\ helper($template, $user, $config, $provider, $phpbb_extension_manager, $symphony_request, $request, $filesystem, $phpbb_root_path, $phpEx);
$this->tpl_name = 'acp_football_extra';
$this->page_title = 'ACP_FOOTBALL_EXTRA_MANAGE';
$form_key = 'acp_football_extra';
add_form_key($form_key);
include($this->phpbb_root_path . 'includes/functions_user.' . $this->php_ext);
// Check and set some common vars
$action = (isset($_POST['add'])) ? 'add' : ((isset($_POST['remove'])) ? 'remove' : $this->request->variable('action', ''));
$edit = $this->request->variable('edit', 0);
$season = $this->request->variable('s', 0);
$league = $this->request->variable('l', 0);
$matchday = $this->request->variable('matchday', 0);
$matchday_eval = $this->request->variable('matchday_eval', 0);
$extra_no = $this->request->variable('e', 0);
$update = (isset($_POST['update'])) ? true : false;
// Clear some vars
$extra_row = array();
$error = array();
// Grab current season
if (!$season)
{
$season = curr_season();
}
// Grab basic data for select season
if ($season)
{
$sql = 'SELECT *
FROM ' . FOOTB_SEASONS . '
ORDER BY season DESC';
$result = $db->sql_query($sql);
$season_options = '';
while ($row = $db->sql_fetchrow($result))
{
$selected = ($season && $row['season'] == $season) ? ' selected="selected"' : '';
$season_options .= '<option value="' . $row['season'] . '"' . $selected . '>' . $row['season_name_short'] . '</option>';
if ($selected <> '')
{
$season_name = $row['season_name_short'];
}
}
$db->sql_freeresult($result);
}
else
{
trigger_error($user->lang['NO_SEASON'] . adm_back_link($this->u_action), E_USER_WARNING);
}
// Grab current league
if (!$league)
{
$league = first_league($season, false);
}
// Grab basic data for select league
if ($league)
{
$sql = 'SELECT *
FROM ' . FOOTB_LEAGUES . "
WHERE season = $season
ORDER BY league ASC";
$result = $db->sql_query($sql);
$league_options = '';
while ($row = $db->sql_fetchrow($result))
{
$selected = ($league && $row['league'] == $league) ? ' selected="selected"' : '';
$league_options .= '<option value="' . $row['league'] . '"' . $selected . '>' . $row['league_name'] . '</option>';
if ($selected <> '')
{
$league_matchdays = $row['matchdays'];
$league_name = $row['league_name'];
$league_type = $row['league_type'];
$ko_league = ($row['league_type'] == LEAGUE_KO) ? true : false;
}
}
$db->sql_freeresult($result);
}
else
{
trigger_error(sprintf($user->lang['NO_LEAGUE'], $season) . adm_back_link($this->u_action . "&amp;s=$season"), E_USER_WARNING);
}
// Grab basic data for extra bets, if extra bet is set and exists
if ($extra_no)
{
$sql = 'SELECT *
FROM ' . FOOTB_EXTRA . "
WHERE season = $season
AND league = $league
AND extra_no = $extra_no";
$result = $db->sql_query($sql);
$extra_row = $db->sql_fetchrow($result);
$existing_extra = sizeof($extra_row);
$db->sql_freeresult($result);
}
$db->sql_freeresult($result);
// Which page?
switch ($action)
{
case 'delete':
if (!$season)
{
trigger_error($user->lang['NO_SEASON'] . adm_back_link($this->u_action), E_USER_WARNING);
}
if (!$league)
{
trigger_error($user->lang['NO_LEAGUE'] . adm_back_link($this->u_action . "&amp;s=$season"), E_USER_WARNING);
}
if (!$extra_no)
{
trigger_error($user->lang['NO_EXTRA'] . adm_back_link($this->u_action . "&amp;s=$season&amp;l=$league"), E_USER_WARNING);
}
if (confirm_box(true))
{
$error = '';
if (!$auth->acl_get('a_football_delete'))
{
trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action . "&amp;s=$season&amp;l=$league"), E_USER_WARNING);
}
if ($user->data['user_type'] != USER_FOUNDER && $this->config['football_founder_delete'])
{
trigger_error($user->lang['EXTRA_NO_DELETE'] . adm_back_link($this->u_action . "&amp;s=$season&amp;l=$league"), E_USER_WARNING);
}
// Delete extra
$sql = 'DELETE FROM ' . FOOTB_EXTRA . "
WHERE season = $season AND league = $league AND extra_no = $extra_no";
$db->sql_query($sql);
// Delete extra bets
$sql = 'DELETE FROM ' . FOOTB_EXTRA_BETS . "
WHERE season = $season
AND league = $league
AND extra_no = $extra_no";
$db->sql_query($sql);
trigger_error($user->lang['EXTRA_DELETED'] . adm_back_link($this->u_action . "&amp;s=$season&amp;l=$league"));
}
else
{
confirm_box(false, sprintf($user->lang['EXTRA_CONFIRM_DELETE'], $extra_row['question'], $league, $season), build_hidden_fields(array(
's' => $season,
'l' => $league,
'e' => $extra_no,
'mode' => $mode,
'action' => $action))
);
}
break;
case 'add':
$sql = "SELECT
max(extra_no) AS max_extra_no
FROM " . FOOTB_EXTRA . "
WHERE season = $season
AND league = $league";
$result = $db->sql_query($sql);
$row_extra = $db->sql_fetchrow($result);
$existing_extra = sizeof($row_extra);
$db->sql_freeresult($result);
$extra_no = ($existing_extra) ? $row_extra['max_extra_no'] + 1 : 1;
$extra_row['extra_no'] = $extra_no;
$extra_row['question_type'] = $this->request->variable('question_type', 3);
$extra_row['question'] = utf8_normalize_nfc($this->request->variable('question', '', true));
$extra_row['matchday'] = $this->request->variable('matchday', 0);
$extra_row['matchday_eval'] = $this->request->variable('matchday_eval', 0);
$extra_row['result'] = utf8_normalize_nfc($this->request->variable('result', ''));
$extra_row['extra_points'] = $this->request->variable('extra_points', 0);
$extra_row['extra_status'] = $this->request->variable('extra_status', 0);
// No break for edit add
case 'edit':
$error_msg = array();
if (!sizeof($error))
{
if ($action == 'edit' && !$extra_no)
{
trigger_error($user->lang['NO_EXTRA'] . adm_back_link($this->u_action . "&amp;s=$season&amp;l=$league"), E_USER_WARNING);
}
$matchday = $extra_row['matchday'];
$matchday_eval = $extra_row['matchday_eval'];
$sql = 'SELECT *
FROM ' . FOOTB_MATCHDAYS . "
WHERE season = $season
AND league = $league
ORDER BY matchday ASC";
$result = $db->sql_query($sql);
$matchday_options = '<option value="0"' . ((!$matchday) ? ' selected="selected"' : '') . '>' . $user->lang['SELECT_MATCHDAY'] . '</option>';
$matchday_eval_options = '<option value="0"' . ((!$matchday_eval) ? ' selected="selected"' : '') . '>' . $user->lang['SELECT_MATCHDAY'] . '</option>';
while ($row = $db->sql_fetchrow($result))
{
if ($row['status'] == 0 or $action == 'edit')
{
$selected_matchday = ($matchday && $row['matchday'] == $matchday) ? ' selected="selected"' : '';
$selected_eval = ($matchday_eval && $row['matchday'] == $matchday_eval) ? ' selected="selected"' : '';
$day_name = (strlen($row['matchday_name']) > 0) ? $row['matchday_name'] : $row['matchday'] . '. ' . sprintf($user->lang['MATCHDAY']);
$matchday_options .= '<option value="' . $row['matchday'] . '"' . $selected_matchday . '>' . $day_name . '</option>';
$matchday_eval_options .= '<option value="' . $row['matchday'] . '"' . $selected_eval . '>' . $day_name . '</option>';
}
}
$question_type_options = '';
for($i = 1; $i<= 5; $i++)
{
$selected = ($i == $extra_row['question_type']) ? ' selected="selected"' : '';
$question_type_options .= '<option value="' . $i . '"' . $selected . '>' . $i . '</option>';
}
$extra_status_options = '';
for($i = 0; $i<= 3; $i++)
{
$selected = ($i == $extra_row['extra_status']) ? ' selected="selected"' : '';
$extra_status_options .= '<option value="' . $i . '"' . $selected . '>' . $i . '</option>';
}
// Did we submit?
if ($update)
{
$data = array();
if (!check_form_key($form_key))
{
trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . "&amp;s=$season&amp;l=$league"), E_USER_WARNING);
}
$extra_row['extra_no'] = $extra_no;
$extra_row['question_type'] = $this->request->variable('question_type', $extra_row['question_type']);
$extra_row['question'] = $this->request->variable('question', $extra_row['question'], true);
$extra_row['matchday'] = $this->request->variable('matchday', $extra_row['matchday']);
$extra_row['matchday_eval'] = $this->request->variable('matchday_eval', $extra_row['matchday_eval']);
$extra_row['extra_points'] = $this->request->variable('extra_points', $extra_row['extra_points']);
$extra_row['extra_status'] = $this->request->variable('extra_status', $extra_row['extra_status']);
$data['extra_points'] = (int) $extra_row['extra_points'];
$data['matchday'] = (int) $extra_row['matchday'];
$data['matchday_eval'] = (int) $extra_row['matchday_eval'];
if ($data['matchday_eval'] < $data['matchday'])
{
$error[] = $user->lang['EVAL_BEFORE_DELIVERY'];
}
if (!sizeof($error))
{
$sql_ary = array(
'season' => (int) $season,
'league' => (int) $league,
'extra_no' => (int) $extra_no,
'question_type' => (int) $extra_row['question_type'],
'question' => strlen($extra_row['question']) ? $extra_row['question'] : '',
'matchday' => (int) $extra_row['matchday'],
'matchday_eval' => (int) $extra_row['matchday_eval'],
'result' => $extra_row['result'],
'extra_points' => (int) $extra_row['extra_points'],
'extra_status' => (int) $extra_row['extra_status'],
);
$var_ary = array(
'extra_points' => array('num', false, 0, 99),
'matchday' => array('num', false, 1),
'matchday_eval' => array('num', false, 1),
);
if (!($error_vals = validate_data($data, $var_ary)))
{
if ($action == 'add')
{
$sql = 'INSERT INTO ' . FOOTB_EXTRA . ' ' . $db->sql_build_array('INSERT', $sql_ary);
$db->sql_query($sql);
}
else
{
$sql = 'UPDATE ' . FOOTB_EXTRA . '
SET ' . $db->sql_build_array('UPDATE', $sql_ary) . "
WHERE season = $season AND league = $league AND extra_no = $extra_no";
$db->sql_query($sql);
}
trigger_error($user->lang['EXTRA_UPDATED'] . adm_back_link($this->u_action . "&amp;s=$season&amp;l=$league"));
}
else
{
foreach ($error_vals as $error_val)
{
$error_msg[] = $user->lang[$error_val];
}
$error[] = $user->lang['EXTRA_UPDATE_FAILED'];
$error = array_merge($error, $error_msg);
}
}
}
}
$u_back = $this->u_action . "&amp;s=$season&amp;l=$league";
$template->assign_vars(array(
'S_EDIT' => true,
'S_ADD_EXTRA' => ($action == 'add') ? true : false,
'S_ERROR' => (sizeof($error)) ? true : false,
'S_EDIT_EXTRAS' => ($existing_extra) ? false : true,
'S_QUESTION_TYPE_OPTIONS' => $question_type_options,
'S_MATCHDAY_OPTIONS' => $matchday_options,
'S_MATCHDAY_EVAL_OPTIONS' => $matchday_eval_options,
'S_EXTRA_STATUS_OPTIONS' => $extra_status_options,
'S_VERSION_NO' => $this->config['football_version'],
'ERROR_MSG' => (sizeof($error)) ? implode('<br />', $error) : '',
'SEASON' => $season,
'SEASON_NAME' => $season_name,
'LEAGUE' => $league,
'LEAGUE_NAME' => $league_name,
'EXTRA_NO' => $extra_no,
'QUESTION_TYPE' => $extra_row['question_type'],
'QUESTION' => $extra_row['question'],
'MATCHDAY' => $extra_row['matchday'],
'MATCHDAY_EVAL' => $extra_row['matchday_eval'],
'MATCHDAY_OPTION' => $extra_row['matchday'],
'MATCHDAY_EVAL' => $extra_row['matchday_eval'],
'RESULT' => $extra_row['result'],
'EXTRA_POINTS' => $extra_row['extra_points'],
'EXTRA_STATUS' => $extra_row['extra_status'],
'U_BACK' => $u_back,
'U_ACTION' => "{$this->u_action}&amp;action=$action&amp;s=$season&amp;l=$league",
)
);
return;
break;
}
// Check open matchday in league
$sql = 'SELECT *
FROM ' . FOOTB_MATCHDAYS . "
WHERE season = $season
AND league = $league
AND status <= 0";
$result = $db->sql_query($sql);
$open_matchdays = sizeof($db->sql_fetchrowset($result));
$db->sql_freeresult($result);
// Get us all the extra
$sql = "SELECT e.*,
m1.matchday_name AS matchday_name,
m2.matchday_name AS matchday_eval_name
FROM " . FOOTB_EXTRA . ' AS e
LEFT JOIN ' . FOOTB_MATCHDAYS . ' AS m1 ON (m1.season = e.season AND m1.league = e.league AND m1.matchday = e.matchday)
LEFT JOIN ' . FOOTB_MATCHDAYS . " AS m2 ON (m2.season = e.season AND m2.league = e.league AND m2.matchday = e.matchday_eval)
WHERE e.season = $season
AND e.league = $league
ORDER BY e.extra_no ASC";
$result = $db->sql_query($sql);
$rows_extra = $db->sql_fetchrowset($result);
$db->sql_freeresult($result);
$template->assign_vars(array(
'U_ACTION' => $this->u_action,
'U_FOOTBALL' => $helper->route('football_main_controller',array('side' => 'bet', 's' => $season, 'l' => $league)),
'S_SEASON' => $season,
'S_LEAGUE' => $league,
'S_SEASON_OPTIONS' => $season_options,
'S_LEAGUE_OPTIONS' => $league_options,
'S_EXTRA_ADD' => ($open_matchdays) ? true : false,
'S_VERSION_NO' => $this->config['football_version'],
)
);
// Check if the user is allowed to delete a extra.
if ($user->data['user_type'] != USER_FOUNDER && $this->config['football_founder_delete'])
{
$allow_delete = false;
}
else
{
$allow_delete = true;
}
$row_number = 0;
foreach ($rows_extra as $row_extra)
{
$row_number++;
$row_class = (!($row_number % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
$template->assign_block_vars('extras', array(
'ROW_CLASS' => $row_class,
'EXTRA_NO' => $row_extra['extra_no'],
'QUESTION_TYPE' => $row_extra['question_type'],
'QUESTION' => $row_extra['question'],
'MATCHDAY' => (strlen($row_extra['matchday_name']) > 0) ? $row_extra['matchday_name'] : $row_extra['matchday'] . '. ' . sprintf($user->lang['MATCHDAY']),
'MATCHDAY_EVAL' => (strlen($row_extra['matchday_name']) > 0) ? $row_extra['matchday_eval_name'] : $row_extra['matchday_eval'] . '. ' . sprintf($user->lang['MATCHDAY']),
'EXTRA_POINTS' => $row_extra['extra_points'],
'EXTRA_STATUS' => $row_extra['extra_status'],
'U_EDIT' => "{$this->u_action}&amp;action=edit&amp;s=" . $season . "&amp;l=" .$league . "&amp;e=" .$row_extra['extra_no'],
'U_DELETE' => ($allow_delete) ? "{$this->u_action}&amp;action=delete&amp;s=" . $season . "&amp;l=" . $league . "&amp;e=" . $row_extra['extra_no'] : '',
)
);
}
}
}
<?php
/**
*
* @package phpBB Extension - Football Football
* @copyright (c) 2016 football (http://football.bplaced.net)
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
namespace football\football\acp;
class extra_module
{
public $u_action;
protected $db, $user, $template, $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;
protected $root_path, $request, $php_ext, $log;
public function __construct()
{
global $db, $user, $request, $template;
global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;
$user->add_lang_ext('football/football', 'football');
$user->add_lang_ext('football/football', 'info_acp_extra');
$this->root_path = $phpbb_root_path . 'ext/football/football/';
$this->config = $config;
$this->request = $request;
$this->phpbb_root_path = $phpbb_root_path;
$this->phpbb_admin_path = $phpbb_admin_path;
$this->php_ext = $phpEx;
if(!function_exists('season_info'))
{
include($this->root_path . 'includes/functions.' . $this->php_ext);
}
if (!defined('FOOTB_SEASONS'))
{
include($this->root_path . 'includes/constants.' . $this->php_ext);
}
}
function main($id, $mode)
{
global $db, $auth, $phpbb_container, $phpbb_admin_path, $league_info;
global $template, $user, $config, $phpbb_extension_manager, $request, $phpbb_root_path, $phpEx;
$helper = $phpbb_container->get('controller.helper');
$this->tpl_name = 'acp_football_extra';
$this->page_title = 'ACP_FOOTBALL_EXTRA_MANAGE';
$form_key = 'acp_football_extra';
add_form_key($form_key);
include($this->phpbb_root_path . 'includes/functions_user.' . $this->php_ext);
// Check and set some common vars
$action = (isset($_POST['add'])) ? 'add' : ((isset($_POST['remove'])) ? 'remove' : $this->request->variable('action', ''));
$edit = $this->request->variable('edit', 0);
$season = $this->request->variable('s', 0);
$league = $this->request->variable('l', 0);
$matchday = $this->request->variable('matchday', 0);
$matchday_eval = $this->request->variable('matchday_eval', 0);
$extra_no = $this->request->variable('e', 0);
$update = (isset($_POST['update'])) ? true : false;
// Clear some vars
$extra_row = array();
$error = array();
// Grab current season
if (!$season)
{
$season = curr_season();
}
// Grab basic data for select season
if ($season)
{
$sql = 'SELECT *
FROM ' . FOOTB_SEASONS . '
ORDER BY season DESC';
$result = $db->sql_query($sql);
$season_options = '';
while ($row = $db->sql_fetchrow($result))
{
$selected = ($season && $row['season'] == $season) ? ' selected="selected"' : '';
$season_options .= '<option value="' . $row['season'] . '"' . $selected . '>' . $row['season_name_short'] . '</option>';
if ($selected <> '')
{
$season_name = $row['season_name_short'];
}
}
$db->sql_freeresult($result);
}
else
{
trigger_error($user->lang['NO_SEASON'] . adm_back_link($this->u_action), E_USER_WARNING);
}
// Grab current league
if (!$league)
{
$league = first_league($season, false);
}
// Grab basic data for select league
if ($league)
{
$sql = 'SELECT *
FROM ' . FOOTB_LEAGUES . "
WHERE season = $season
ORDER BY league ASC";
$result = $db->sql_query($sql);
$league_options = '';
while ($row = $db->sql_fetchrow($result))
{
$selected = ($league && $row['league'] == $league) ? ' selected="selected"' : '';
$league_options .= '<option value="' . $row['league'] . '"' . $selected . '>' . $row['league_name'] . '</option>';
if ($selected <> '')
{
$league_matchdays = $row['matchdays'];
$league_name = $row['league_name'];
$league_type = $row['league_type'];
$ko_league = ($row['league_type'] == LEAGUE_KO) ? true : false;
}
}
$db->sql_freeresult($result);
}
else
{
trigger_error(sprintf($user->lang['NO_LEAGUE'], $season) . adm_back_link($this->u_action . "&amp;s=$season"), E_USER_WARNING);
}
// Grab basic data for extra bets, if extra bet is set and exists
if ($extra_no)
{
$sql = 'SELECT *
FROM ' . FOOTB_EXTRA . "
WHERE season = $season
AND league = $league
AND extra_no = $extra_no";
$result = $db->sql_query($sql);
$extra_row = $db->sql_fetchrow($result);
$existing_extra = sizeof($extra_row);
$db->sql_freeresult($result);
}
$db->sql_freeresult($result);
// Which page?
switch ($action)
{
case 'delete':
if (!$season)
{
trigger_error($user->lang['NO_SEASON'] . adm_back_link($this->u_action), E_USER_WARNING);
}
if (!$league)
{
trigger_error($user->lang['NO_LEAGUE'] . adm_back_link($this->u_action . "&amp;s=$season"), E_USER_WARNING);
}
if (!$extra_no)
{
trigger_error($user->lang['NO_EXTRA'] . adm_back_link($this->u_action . "&amp;s=$season&amp;l=$league"), E_USER_WARNING);
}
if (confirm_box(true))
{
$error = '';
if (!$auth->acl_get('a_football_delete'))
{
trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action . "&amp;s=$season&amp;l=$league"), E_USER_WARNING);
}
if ($user->data['user_type'] != USER_FOUNDER && $this->config['football_founder_delete'])
{
trigger_error($user->lang['EXTRA_NO_DELETE'] . adm_back_link($this->u_action . "&amp;s=$season&amp;l=$league"), E_USER_WARNING);
}
// Delete extra
$sql = 'DELETE FROM ' . FOOTB_EXTRA . "
WHERE season = $season AND league = $league AND extra_no = $extra_no";
$db->sql_query($sql);
// Delete extra bets
$sql = 'DELETE FROM ' . FOOTB_EXTRA_BETS . "
WHERE season = $season
AND league = $league
AND extra_no = $extra_no";
$db->sql_query($sql);
trigger_error($user->lang['EXTRA_DELETED'] . adm_back_link($this->u_action . "&amp;s=$season&amp;l=$league"));
}
else
{
confirm_box(false, sprintf($user->lang['EXTRA_CONFIRM_DELETE'], $extra_row['question'], $league, $season), build_hidden_fields(array(
's' => $season,
'l' => $league,
'e' => $extra_no,
'mode' => $mode,
'action' => $action))
);
}
break;
case 'add':
$sql = "SELECT
max(extra_no) AS max_extra_no
FROM " . FOOTB_EXTRA . "
WHERE season = $season
AND league = $league";
$result = $db->sql_query($sql);
$row_extra = $db->sql_fetchrow($result);
$existing_extra = sizeof($row_extra);
$db->sql_freeresult($result);
$extra_no = ($existing_extra) ? $row_extra['max_extra_no'] + 1 : 1;
$extra_row['extra_no'] = $extra_no;
$extra_row['question_type'] = $this->request->variable('question_type', 3);
$extra_row['question'] = utf8_normalize_nfc($this->request->variable('question', '', true));
$extra_row['matchday'] = $this->request->variable('matchday', 0);
$extra_row['matchday_eval'] = $this->request->variable('matchday_eval', 0);
$extra_row['result'] = utf8_normalize_nfc($this->request->variable('result', ''));
$extra_row['extra_points'] = $this->request->variable('extra_points', 0);
$extra_row['extra_status'] = $this->request->variable('extra_status', 0);
// No break for edit add
case 'edit':
$error_msg = array();
if (!sizeof($error))
{
if ($action == 'edit' && !$extra_no)
{
trigger_error($user->lang['NO_EXTRA'] . adm_back_link($this->u_action . "&amp;s=$season&amp;l=$league"), E_USER_WARNING);
}
$matchday = $extra_row['matchday'];
$matchday_eval = $extra_row['matchday_eval'];
$sql = 'SELECT *
FROM ' . FOOTB_MATCHDAYS . "
WHERE season = $season
AND league = $league
ORDER BY matchday ASC";
$result = $db->sql_query($sql);
$matchday_options = '<option value="0"' . ((!$matchday) ? ' selected="selected"' : '') . '>' . $user->lang['SELECT_MATCHDAY'] . '</option>';
$matchday_eval_options = '<option value="0"' . ((!$matchday_eval) ? ' selected="selected"' : '') . '>' . $user->lang['SELECT_MATCHDAY'] . '</option>';
while ($row = $db->sql_fetchrow($result))
{
if ($row['status'] == 0 or $action == 'edit')
{
$selected_matchday = ($matchday && $row['matchday'] == $matchday) ? ' selected="selected"' : '';
$selected_eval = ($matchday_eval && $row['matchday'] == $matchday_eval) ? ' selected="selected"' : '';
$day_name = (strlen($row['matchday_name']) > 0) ? $row['matchday_name'] : $row['matchday'] . '. ' . sprintf($user->lang['MATCHDAY']);
$matchday_options .= '<option value="' . $row['matchday'] . '"' . $selected_matchday . '>' . $day_name . '</option>';
$matchday_eval_options .= '<option value="' . $row['matchday'] . '"' . $selected_eval . '>' . $day_name . '</option>';
}
}
$question_type_options = '';
for($i = 1; $i<= 5; $i++)
{
$selected = ($i == $extra_row['question_type']) ? ' selected="selected"' : '';
$question_type_options .= '<option value="' . $i . '"' . $selected . '>' . $i . '</option>';
}
$extra_status_options = '';
for($i = 0; $i<= 3; $i++)
{
$selected = ($i == $extra_row['extra_status']) ? ' selected="selected"' : '';
$extra_status_options .= '<option value="' . $i . '"' . $selected . '>' . $i . '</option>';
}
// Did we submit?
if ($update)
{
$data = array();
if (!check_form_key($form_key))
{
trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . "&amp;s=$season&amp;l=$league"), E_USER_WARNING);
}
$extra_row['extra_no'] = $extra_no;
$extra_row['question_type'] = $this->request->variable('question_type', $extra_row['question_type']);
$extra_row['question'] = $this->request->variable('question', $extra_row['question'], true);
$extra_row['matchday'] = $this->request->variable('matchday', $extra_row['matchday']);
$extra_row['matchday_eval'] = $this->request->variable('matchday_eval', $extra_row['matchday_eval']);
$extra_row['extra_points'] = $this->request->variable('extra_points', $extra_row['extra_points']);
$extra_row['extra_status'] = $this->request->variable('extra_status', $extra_row['extra_status']);
$data['extra_points'] = (int) $extra_row['extra_points'];
$data['matchday'] = (int) $extra_row['matchday'];
$data['matchday_eval'] = (int) $extra_row['matchday_eval'];
if ($data['matchday_eval'] < $data['matchday'])
{
$error[] = $user->lang['EVAL_BEFORE_DELIVERY'];
}
if (!sizeof($error))
{
$sql_ary = array(
'season' => (int) $season,
'league' => (int) $league,
'extra_no' => (int) $extra_no,
'question_type' => (int) $extra_row['question_type'],
'question' => strlen($extra_row['question']) ? $extra_row['question'] : '',
'matchday' => (int) $extra_row['matchday'],
'matchday_eval' => (int) $extra_row['matchday_eval'],
'result' => $extra_row['result'],
'extra_points' => (int) $extra_row['extra_points'],
'extra_status' => (int) $extra_row['extra_status'],
);
$var_ary = array(
'extra_points' => array('num', false, 0, 99),
'matchday' => array('num', false, 1),
'matchday_eval' => array('num', false, 1),
);
if (!($error_vals = validate_data($data, $var_ary)))
{
if ($action == 'add')
{
$sql = 'INSERT INTO ' . FOOTB_EXTRA . ' ' . $db->sql_build_array('INSERT', $sql_ary);
$db->sql_query($sql);
}
else
{
$sql = 'UPDATE ' . FOOTB_EXTRA . '
SET ' . $db->sql_build_array('UPDATE', $sql_ary) . "
WHERE season = $season AND league = $league AND extra_no = $extra_no";
$db->sql_query($sql);
}
trigger_error($user->lang['EXTRA_UPDATED'] . adm_back_link($this->u_action . "&amp;s=$season&amp;l=$league"));
}
else
{
foreach ($error_vals as $error_val)
{
$error_msg[] = $user->lang[$error_val];
}
$error[] = $user->lang['EXTRA_UPDATE_FAILED'];
$error = array_merge($error, $error_msg);
}
}
}
}
$u_back = $this->u_action . "&amp;s=$season&amp;l=$league";
$template->assign_vars(array(
'S_EDIT' => true,
'S_ADD_EXTRA' => ($action == 'add') ? true : false,
'S_ERROR' => (sizeof($error)) ? true : false,
'S_EDIT_EXTRAS' => ($existing_extra) ? false : true,
'S_QUESTION_TYPE_OPTIONS' => $question_type_options,
'S_MATCHDAY_OPTIONS' => $matchday_options,
'S_MATCHDAY_EVAL_OPTIONS' => $matchday_eval_options,
'S_EXTRA_STATUS_OPTIONS' => $extra_status_options,
'S_VERSION_NO' => $this->config['football_version'],
'ERROR_MSG' => (sizeof($error)) ? implode('<br />', $error) : '',
'SEASON' => $season,
'SEASON_NAME' => $season_name,
'LEAGUE' => $league,
'LEAGUE_NAME' => $league_name,
'EXTRA_NO' => $extra_no,
'QUESTION_TYPE' => $extra_row['question_type'],
'QUESTION' => $extra_row['question'],
'MATCHDAY' => $extra_row['matchday'],
'MATCHDAY_EVAL' => $extra_row['matchday_eval'],
'MATCHDAY_OPTION' => $extra_row['matchday'],
'MATCHDAY_EVAL' => $extra_row['matchday_eval'],
'RESULT' => $extra_row['result'],
'EXTRA_POINTS' => $extra_row['extra_points'],
'EXTRA_STATUS' => $extra_row['extra_status'],
'U_BACK' => $u_back,
'U_ACTION' => "{$this->u_action}&amp;action=$action&amp;s=$season&amp;l=$league",
)
);
return;
break;
}
// Check open matchday in league
$sql = 'SELECT *
FROM ' . FOOTB_MATCHDAYS . "
WHERE season = $season
AND league = $league
AND status <= 0";
$result = $db->sql_query($sql);
$open_matchdays = sizeof($db->sql_fetchrowset($result));
$db->sql_freeresult($result);
// Get us all the extra
$sql = "SELECT e.*,
m1.matchday_name AS matchday_name,
m2.matchday_name AS matchday_eval_name
FROM " . FOOTB_EXTRA . ' AS e
LEFT JOIN ' . FOOTB_MATCHDAYS . ' AS m1 ON (m1.season = e.season AND m1.league = e.league AND m1.matchday = e.matchday)
LEFT JOIN ' . FOOTB_MATCHDAYS . " AS m2 ON (m2.season = e.season AND m2.league = e.league AND m2.matchday = e.matchday_eval)
WHERE e.season = $season
AND e.league = $league
ORDER BY e.extra_no ASC";
$result = $db->sql_query($sql);
$rows_extra = $db->sql_fetchrowset($result);
$db->sql_freeresult($result);
$template->assign_vars(array(
'U_ACTION' => $this->u_action,
'U_FOOTBALL' => $helper->route('football_main_controller',array('side' => 'bet', 's' => $season, 'l' => $league)),
'S_SEASON' => $season,
'S_LEAGUE' => $league,
'S_SEASON_OPTIONS' => $season_options,
'S_LEAGUE_OPTIONS' => $league_options,
'S_EXTRA_ADD' => ($open_matchdays) ? true : false,
'S_VERSION_NO' => $this->config['football_version'],
)
);
// Check if the user is allowed to delete a extra.
if ($user->data['user_type'] != USER_FOUNDER && $this->config['football_founder_delete'])
{
$allow_delete = false;
}
else
{
$allow_delete = true;
}
$row_number = 0;
foreach ($rows_extra as $row_extra)
{
$row_number++;
$row_class = (!($row_number % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
$template->assign_block_vars('extras', array(
'ROW_CLASS' => $row_class,
'EXTRA_NO' => $row_extra['extra_no'],
'QUESTION_TYPE' => $row_extra['question_type'],
'QUESTION' => $row_extra['question'],
'MATCHDAY' => (strlen($row_extra['matchday_name']) > 0) ? $row_extra['matchday_name'] : $row_extra['matchday'] . '. ' . sprintf($user->lang['MATCHDAY']),
'MATCHDAY_EVAL' => (strlen($row_extra['matchday_name']) > 0) ? $row_extra['matchday_eval_name'] : $row_extra['matchday_eval'] . '. ' . sprintf($user->lang['MATCHDAY']),
'EXTRA_POINTS' => $row_extra['extra_points'],
'EXTRA_STATUS' => $row_extra['extra_status'],
'U_EDIT' => "{$this->u_action}&amp;action=edit&amp;s=" . $season . "&amp;l=" .$league . "&amp;e=" .$row_extra['extra_no'],
'U_DELETE' => ($allow_delete) ? "{$this->u_action}&amp;action=delete&amp;s=" . $season . "&amp;l=" . $league . "&amp;e=" . $row_extra['extra_no'] : '',
)
);
}
}
}
?>

View File

@@ -1,426 +1,424 @@
<?php
/**
*
* @package phpBB Extension - Football Football
* @copyright (c) 2016 football (http://football.bplaced.net)
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
namespace football\football\acp;
class football_module
{
var $new_config = array();
public $u_action;
protected $db, $user, $template, $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;
protected $root_path, $request, $php_ext, $log, $phpbb_container, $version_check;
public function __construct()
{
global $db, $user, $request, $template, $phpbb_container;
global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;
$user->add_lang_ext('football/football', 'help_football');
$user->add_lang_ext('football/football', 'football');
$user->add_lang_ext('football/football', 'info_acp_football');
$this->root_path = $phpbb_root_path . 'ext/football/football/';
$this->config = $config;
$this->request = $request;
$this->phpbb_root_path = $phpbb_root_path;
$this->phpbb_admin_path = $phpbb_admin_path;
$this->php_ext = $phpEx;
$this->phpbb_container = $phpbb_container;
$this->version_check = $this->phpbb_container->get('football.football.version.check');
if(!function_exists('season_info'))
{
include($this->root_path . 'includes/functions.' . $this->php_ext);
}
if (!defined('FOOTB_SEASONS'))
{
include($this->root_path . 'includes/constants.' . $this->php_ext);
}
}
function main($id, $mode)
{
global $db, $auth, $phpbb_container, $phpbb_admin_path, $league_info, $phpbb_log;
global $template, $user, $config, $phpbb_extension_manager, $request, $phpbb_root_path, $phpEx;
$provider = new \phpbb\controller\ provider();
$symphony_request = new \phpbb\ symfony_request($request);
$filesystem = new \phpbb\ filesystem();
$helper = new \phpbb\controller\ helper($template, $user, $config, $provider, $phpbb_extension_manager, $symphony_request, $request, $filesystem, $phpbb_root_path, $phpEx);
$user->add_lang('acp/board');
$action = $this->request->variable('action', '');
$submit = (isset($_POST['submit'])) ? true : false;
$form_key = 'acp_football';
add_form_key($form_key);
switch ($mode)
{
case 'userguide':
$this->page_title = 'ACP_FOOTBALL_USERGUIDE';
$this->tpl_name = 'acp_football_userguide';
$template->assign_vars(array(
'S_IN_FOOTBALL_USERGUIDE' => true,
'U_FOOTBALL' => $helper->route('football_main_controller',array('side' => 'bet')),
'L_BACK_TO_TOP' => $user->lang['BACK_TO_TOP'],
'ICON_BACK_TO_TOP' => '<img src="' . $phpbb_admin_path . 'images/icon_up.gif" style="vertical-align: middle;" alt="' . $user->lang['BACK_TO_TOP'] . '" title="' . $user->lang['BACK_TO_TOP'] . '" />',
'S_VERSION_NO' => $this->config['football_version'],
));
// Pull the array data from the lang pack
foreach ($user->help as $help_ary)
{
if ($help_ary[0] == '--')
{
$template->assign_block_vars('userguide_block', array(
'BLOCK_TITLE' => $help_ary[1])
);
continue;
}
$template->assign_block_vars('userguide_block.userguide_row', array(
'USERGUIDE_QUESTION' => $help_ary[0],
'USERGUIDE_ANSWER' => $help_ary[1])
);
}
return;
break;
case 'settings':
$display_vars = array(
'title' => 'ACP_FOOTBALL_SETTINGS',
'vars' => array(
'legend1' => 'ACP_FOOTBALL_SETTINGS',
'football_name' => array('lang' => 'FOOTBALL_NAME', 'validate' => 'string', 'type' => 'text:25:25', 'explain' => true),
'football_disable' => array('lang' => 'DISABLE_FOOTBALL', 'validate' => 'bool', 'type' => 'custom', 'method' => 'football_disable', 'explain' => true),
'football_disable_msg' => false,
'football_fullscreen' => array('lang' => 'FOOTBALL_FULLSCREEN','validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'football_header_enable' => array('lang' => 'FOOTBALL_HEADER_ENABLE','validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'football_guest_view' => array('lang' => 'GUEST_VIEW', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'football_user_view' => array('lang' => 'USER_VIEW', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'football_host_timezone' => array('lang' => 'HOST_TIMEZONE', 'validate' => 'string', 'type' => 'select', 'function' => 'phpbb_timezone_select', 'params' => array($template, $user, '{CONFIG_VALUE}', true), 'explain' => true),
'football_info_display' => array('lang' => 'FOOTBALL_INFO', 'validate' => 'bool', 'type' => 'custom', 'method' => 'football_info', 'explain' => true),
'football_info' => false,
'football_win_name' => array('lang' => 'WIN_NAME', 'validate' => 'string', 'type' => 'text:6:6', 'explain' => true),
'football_code' => array('lang' => 'FOOTBALL_CODE', 'validate' => 'string', 'type' => 'text:25:25', 'explain' => true),
'football_style' => array('lang' => 'FOOTBALL_STYLE', 'validate' => 'int', 'type' => 'select', 'function' => 'style_select', 'params' => array('{CONFIG_VALUE}', false), 'explain' => false),
'football_override_style' => array('lang' => 'FOOTBALL_OVERRIDE_STYLE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'football_update_source' => array('lang' => 'FOOTBALL_UPDATE_SOURCE', 'validate' => 'string', 'type' => 'text:80:255', 'explain' => true),
'football_update_code' => array('lang' => 'FOOTBALL_UPDATE_CODE', 'validate' => 'string', 'type' => 'text:25:255', 'explain' => true),
'legend2' => 'GENERAL_SETTINGS',
'football_left_column_width' => array('lang' => 'LEFT_COLUMN', 'validate' => 'int', 'type' => 'text:3:3', 'explain' => true),
'football_right_column_width' => array('lang' => 'RIGHT_COLUMN', 'validate' => 'int', 'type' => 'text:3:3', 'explain' => true),
'football_display_ranks' => array('lang' => 'DISPLAY_RANKS', 'validate' => 'int', 'type' => 'text:3:3', 'explain' => true),
'football_users_per_page' => array('lang' => 'USERS_PAGE', 'validate' => 'int', 'type' => 'text:3:3', 'explain' => true),
'legend3' => 'ACP_SUBMIT_CHANGES',
)
);
// show the extension version check on Settings page
$this->version_check->check();
break;
case 'features':
$display_vars = array(
'title' => 'ACP_FOOTBALL_FEATURES',
'vars' => array(
'legend1' => 'ACP_FOOTBALL_FEATURES',
'football_founder_delete' => array('lang' => 'FOUNDER_DELETE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'football_results_at_time' => array('lang' => 'RESULTS_AT_TIME', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'football_win_hits02' => array('lang' => 'WIN_HITS02', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'football_same_allowed' => array('lang' => 'SAME_ALLOWED', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'football_season_start' => array('lang' => 'FOOTBALL_SEASON_START', 'validate' => 'int', 'type' => 'select', 'method' => 'season_select', 'params' => array('{CONFIG_VALUE}', false), 'explain' => true),
'football_view_current' => array('lang' => 'VIEW_CURRENT', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'football_view_bets' => array('lang' => 'VIEW_BETS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'football_view_tendencies' => array('lang' => 'VIEW_TENDENCIES', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'football_bank' => array('lang' => 'BANK', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'football_ult_points' => array('lang' => 'ULT_POINTS', 'validate' => 'int', 'type' => 'custom', 'method' => 'select_up_method', 'explain' => true),
'football_ult_points_factor'=> array('lang' => 'ULT_POINTS_FACTOR', 'validate' => 'dec:3:2','type' => 'text:4:10', 'explain' => true),
'football_remember_enable' => array('lang' => 'FOOTBALL_REMEMBER_ENABLE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'football_remember_next_run'=> array('lang' => 'FOOTBALL_REMEMBER_NEXT_RUN','validate' => 'int', 'type' => 'custom', 'method' => 'next_run', 'explain' => true),
'legend2' => 'ACP_SUBMIT_CHANGES',
)
);
break;
case 'menu':
$display_vars = array(
'title' => 'ACP_FOOTBALL_MENU',
'vars' => array(
'legend1' => 'ACP_FOOTBALL_MENU',
'football_breadcrumb' => array('lang' => 'FOOTBALL_BREADCRUMB', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'football_side' => array('lang' => 'FOOTBALL_SIDE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'football_menu' => array('lang' => 'FOOTBALL_MENU', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'football_menu_link1' => array('lang' => 'MENU_LINK1', 'validate' => 'string', 'type' => 'text:80:255', 'explain' => true),
'football_menu_desc1' => array('lang' => 'MENU_DESC1', 'validate' => 'string', 'type' => 'text:20:20', 'explain' => true),
'football_menu_link2' => array('lang' => 'MENU_LINK2', 'validate' => 'string', 'type' => 'text:80:255', 'explain' => false),
'football_menu_desc2' => array('lang' => 'MENU_DESC2', 'validate' => 'string', 'type' => 'text:20:20', 'explain' => false),
'football_menu_link3' => array('lang' => 'MENU_LINK3', 'validate' => 'string', 'type' => 'text:80:255', 'explain' => false),
'football_menu_desc3' => array('lang' => 'MENU_DESC3', 'validate' => 'string', 'type' => 'text:20:20', 'explain' => false),
)
);
break;
default:
trigger_error('NO_MODE', E_USER_ERROR);
break;
}
if (isset($display_vars['lang']))
{
$user->add_lang($display_vars['lang']);
}
$this->new_config = $this->config;
$cfg_array = (isset($_REQUEST['config'])) ? utf8_normalize_nfc($this->request->variable('config', array('' => ''), true)) : $this->new_config;
$error = array();
// We validate the complete config if whished
validate_config_vars($display_vars['vars'], $cfg_array, $error);
if ($submit && !check_form_key($form_key))
{
$error[] = $user->lang['FORM_INVALID'];
}
// Do not write values if there is an error
if (sizeof($error))
{
$submit = false;
}
// We go through the display_vars to make sure no one is trying to set variables he/she is not allowed to...
foreach ($display_vars['vars'] as $this->config_name => $null)
{
if (!isset($cfg_array[$this->config_name]) || strpos($this->config_name, 'legend') !== false)
{
continue;
}
$this->new_config[$this->config_name] = $this->config_value = $cfg_array[$this->config_name];
if ($submit)
{
if ($this->config_name == 'football_ult_points' && $this->config_value)
{
$this->config->set('football_bank', 1);
}
if ($this->config_name == 'football_remember_enable')
{
$day = $this->request->variable('next_run_day', 0);
$month = $this->request->variable('next_run_month', 0);
$year = $this->request->variable('next_run_year', 0);
$hour = $this->request->variable('next_run_hour', 0);
$minute = $this->request->variable('next_run_minute', 0);
$next_run = mktime($hour, $minute, 0, $month, $day, $year);
$this->config->set('football_remember_next_run', $next_run);
}
$this->config->set($this->config_name, $this->config_value);
}
}
if ($submit)
{
$phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_FOOTBALL_' . strtoupper($mode));
trigger_error($user->lang['CONFIG_UPDATED'] . adm_back_link($this->u_action));
}
$this->tpl_name = 'acp_football';
$this->page_title = $display_vars['title'];
$template->assign_vars(array(
'U_FOOTBALL' => $helper->route('football_main_controller',array('side' => 'bet')),
'L_TITLE' => $user->lang[$display_vars['title']],
'L_TITLE_EXPLAIN' => $user->lang[$display_vars['title'] . '_EXPLAIN'],
'S_ERROR' => (sizeof($error)) ? true : false,
'ERROR_MSG' => implode('<br />', $error),
'U_ACTION' => $this->u_action,
'S_VERSION_NO' => $this->config['football_version'],
)
);
// Output relevant page
foreach ($display_vars['vars'] as $this->config_key => $vars)
{
if (!is_array($vars) && strpos($this->config_key, 'legend') === false)
{
continue;
}
if (strpos($this->config_key, 'legend') !== false)
{
$template->assign_block_vars('options', array(
'S_LEGEND' => true,
'LEGEND' => (isset($user->lang[$vars])) ? $user->lang[$vars] : $vars,
)
);
continue;
}
$type = explode(':', $vars['type']);
$l_explain = '';
if ($vars['explain'] && isset($vars['lang_explain']))
{
$l_explain = (isset($user->lang[$vars['lang_explain']])) ? $user->lang[$vars['lang_explain']] : $vars['lang_explain'];
}
else if ($vars['explain'])
{
$l_explain = (isset($user->lang[$vars['lang'] . '_EXPLAIN'])) ? $user->lang[$vars['lang'] . '_EXPLAIN'] : '';
}
$content = build_cfg_template($type, $this->config_key, $this->new_config, $this->config_key, $vars);
if (empty($content))
{
continue;
}
$template->assign_block_vars('options', array(
'KEY' => $this->config_key,
'TITLE' => (isset($user->lang[$vars['lang']])) ? $user->lang[$vars['lang']] : $vars['lang'],
'S_EXPLAIN' => $vars['explain'],
'TITLE_EXPLAIN' => $l_explain,
'CONTENT' => $content,
)
);
unset($display_vars['vars'][$this->config_key]);
}
}
/**
* Football disable option and message
*/
function football_disable($value, $key)
{
global $user;
$radio_ary = array(1 => 'YES', 0 => 'NO');
return h_radio('config[football_disable]', $radio_ary, $value) . '<br /><input id="' . $key . '" type="text" name="config[football_disable_msg]" maxlength="255" size="80" value="' . $this->new_config['football_disable_msg'] . '" />';
}
/**
* Football info option and message
*/
function football_info($value, $key)
{
global $user;
$radio_ary = array(1 => 'YES', 0 => 'NO');
return h_radio('config[football_info_display]', $radio_ary, $value) . '<br /><input id="' . $key . '" type="text" name="config[football_info]" maxlength="255" size="80" value="' . $this->new_config['football_info'] . '" />';
}
/**
* Select ultimate points method
*/
function select_up_method($value, $key = '')
{
global $user, $config;
$radio_ary = array(UP_NONE => 'UP_NONE', UP_WINS => 'UP_WINS', UP_POINTS => 'UP_POINTS');
return h_radio('config[football_ult_points]', $radio_ary, $value, $key);
}
function season_select($default = 0)
{
global $user, $db;
$sql = 'SELECT DISTINCT s.season, s.season_name_short FROM ' . FOOTB_SEASONS . ' AS s
INNER JOIN ' . FOOTB_LEAGUES . ' AS l ON (l.season = s.season)
INNER JOIN ' . FOOTB_MATCHDAYS . ' AS md ON (md.season = s.season AND md.league = l.league)
WHERE 1
ORDER BY s.season DESC';
$result = $db->sql_query($sql);
$selected = (0 == $default) ? ' selected="selected"' : '';
$season_options = '<option value="0"' . $selected . '>' . $user->lang['AUTO'] . '</option>';
while ($row = $db->sql_fetchrow($result))
{
$selected = ($row['season'] == $default) ? ' selected="selected"' : '';
$season_options .= '<option value="' . $row['season'] . '"' . $selected . '>' . $row['season_name_short'] . '</option>';
}
$db->sql_freeresult($result);
return $season_options;
}
/**
* Adjust Cronjob EMail remember next un
*/
function next_run($value, $key = '')
{
global $user, $db;
$next_run = getdate($this->config['football_remember_next_run']);
// Days
$day_options = '<select name="next_run_day" id="next_run_day">';
for ($i = 1; $i < 32; $i++)
{
$selected = ($i == $next_run['mday']) ? ' selected="selected"' : '';
$day_options .= '<option value="' . $i . '"' . $selected . '>' . $i . '</option>';
}
$day_options .= '</select>';
// Months
$month_options = '<select name="next_run_month" id="next_run_month">';
for ($i = 1; $i < 13; $i++)
{
$selected = ($i == $next_run['mon']) ? ' selected="selected"' : '';
$month_options .= '<option value="' . $i . '"' . $selected . '>' . $i . '</option>';
}
$month_options .= '</select>';
// Years
$year_options = '<select name="next_run_year" id="next_run_year">';
for ($i = date("Y"); $i < (date("Y") + 1); $i++)
{
$selected = ($i == $next_run['year']) ? ' selected="selected"' : '';
$year_options .= '<option value="' . $i . '"' . $selected . '>' . $i . '</option>';
}
$year_options .= '</select>';
// Hours
$hour_options = '<select name="next_run_hour" id="next_run_hour">';
for ($i = 0; $i < 24; $i++)
{
$selected = ($i == $next_run['hours']) ? ' selected="selected"' : '';
$hour_options .= '<option value="' . $i . '"' . $selected . '>' . $i . '</option>';
}
$hour_options .= '</select>';
// Minutes
$minute_options = '<select name="next_run_minute" id="next_run_minute">';
for ($i = 0; $i < 60; $i++)
{
$selected = ($i == $next_run['minutes']) ? ' selected="selected"' : '';
$minute_options .= '<option value="' . $i . '"' . $selected . '>' . $i . '</option>';
}
$minute_options .= '</select>';
return $user->lang['DAY'] . ': ' . $day_options . ' ' . $user->lang['MONTH'] . ': ' . $month_options . ' ' . $user->lang['YEAR'] . ': ' .
$year_options . ' ' . $user->lang['HOURS'] . ': ' . $hour_options . ' ' . $user->lang['MINUTES'] . ': ' . $minute_options;
}
}
<?php
/**
*
* @package phpBB Extension - Football Football
* @copyright (c) 2016 football (http://football.bplaced.net)
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
namespace football\football\acp;
class football_module
{
var $new_config = array();
public $u_action;
protected $db, $user, $template, $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;
protected $root_path, $request, $php_ext, $log, $phpbb_container, $version_check;
public function __construct()
{
global $db, $user, $request, $template, $phpbb_container;
global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;
$user->add_lang_ext('football/football', 'help_football');
$user->add_lang_ext('football/football', 'football');
$user->add_lang_ext('football/football', 'info_acp_football');
$this->root_path = $phpbb_root_path . 'ext/football/football/';
$this->config = $config;
$this->request = $request;
$this->phpbb_root_path = $phpbb_root_path;
$this->phpbb_admin_path = $phpbb_admin_path;
$this->php_ext = $phpEx;
$this->phpbb_container = $phpbb_container;
$this->version_check = $this->phpbb_container->get('football.football.version.check');
if(!function_exists('season_info'))
{
include($this->root_path . 'includes/functions.' . $this->php_ext);
}
if (!defined('FOOTB_SEASONS'))
{
include($this->root_path . 'includes/constants.' . $this->php_ext);
}
}
function main($id, $mode)
{
global $db, $auth, $phpbb_container, $phpbb_admin_path, $league_info, $phpbb_log;
global $template, $user, $config, $phpbb_extension_manager, $request, $phpbb_root_path, $phpEx;
$helper = $phpbb_container->get('controller.helper');
$user->add_lang('acp/board');
$action = $this->request->variable('action', '');
$submit = (isset($_POST['submit'])) ? true : false;
$form_key = 'acp_football';
add_form_key($form_key);
switch ($mode)
{
case 'userguide':
$this->page_title = 'ACP_FOOTBALL_USERGUIDE';
$this->tpl_name = 'acp_football_userguide';
$template->assign_vars(array(
'S_IN_FOOTBALL_USERGUIDE' => true,
'U_FOOTBALL' => $helper->route('football_main_controller',array('side' => 'bet')),
'L_BACK_TO_TOP' => $user->lang['BACK_TO_TOP'],
'ICON_BACK_TO_TOP' => '<img src="' . $phpbb_admin_path . 'images/icon_up.gif" style="vertical-align: middle;" alt="' . $user->lang['BACK_TO_TOP'] . '" title="' . $user->lang['BACK_TO_TOP'] . '" />',
'S_VERSION_NO' => $this->config['football_version'],
));
// Pull the array data from the lang pack
foreach ($user->help as $help_ary)
{
if ($help_ary[0] == '--')
{
$template->assign_block_vars('userguide_block', array(
'BLOCK_TITLE' => $help_ary[1])
);
continue;
}
$template->assign_block_vars('userguide_block.userguide_row', array(
'USERGUIDE_QUESTION' => $help_ary[0],
'USERGUIDE_ANSWER' => $help_ary[1])
);
}
return;
break;
case 'settings':
$display_vars = array(
'title' => 'ACP_FOOTBALL_SETTINGS',
'vars' => array(
'legend1' => 'ACP_FOOTBALL_SETTINGS',
'football_name' => array('lang' => 'FOOTBALL_NAME', 'validate' => 'string', 'type' => 'text:25:25', 'explain' => true),
'football_disable' => array('lang' => 'DISABLE_FOOTBALL', 'validate' => 'bool', 'type' => 'custom', 'method' => 'football_disable', 'explain' => true),
'football_disable_msg' => false,
'football_fullscreen' => array('lang' => 'FOOTBALL_FULLSCREEN','validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'football_header_enable' => array('lang' => 'FOOTBALL_HEADER_ENABLE','validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'football_guest_view' => array('lang' => 'GUEST_VIEW', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'football_user_view' => array('lang' => 'USER_VIEW', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'football_host_timezone' => array('lang' => 'HOST_TIMEZONE', 'validate' => 'string', 'type' => 'select', 'function' => 'phpbb_timezone_select', 'params' => array($template, $user, '{CONFIG_VALUE}', true), 'explain' => true),
'football_info_display' => array('lang' => 'FOOTBALL_INFO', 'validate' => 'bool', 'type' => 'custom', 'method' => 'football_info', 'explain' => true),
'football_info' => false,
'football_win_name' => array('lang' => 'WIN_NAME', 'validate' => 'string', 'type' => 'text:6:6', 'explain' => true),
'football_code' => array('lang' => 'FOOTBALL_CODE', 'validate' => 'string', 'type' => 'text:25:25', 'explain' => true),
'football_style' => array('lang' => 'FOOTBALL_STYLE', 'validate' => 'int', 'type' => 'select', 'function' => 'style_select', 'params' => array('{CONFIG_VALUE}', false), 'explain' => false),
'football_override_style' => array('lang' => 'FOOTBALL_OVERRIDE_STYLE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'football_update_source' => array('lang' => 'FOOTBALL_UPDATE_SOURCE', 'validate' => 'string', 'type' => 'text:80:255', 'explain' => true),
'football_update_code' => array('lang' => 'FOOTBALL_UPDATE_CODE', 'validate' => 'string', 'type' => 'text:25:255', 'explain' => true),
'legend2' => 'GENERAL_SETTINGS',
'football_left_column_width' => array('lang' => 'LEFT_COLUMN', 'validate' => 'int', 'type' => 'text:3:3', 'explain' => true),
'football_right_column_width' => array('lang' => 'RIGHT_COLUMN', 'validate' => 'int', 'type' => 'text:3:3', 'explain' => true),
'football_display_ranks' => array('lang' => 'DISPLAY_RANKS', 'validate' => 'int', 'type' => 'text:3:3', 'explain' => true),
'football_users_per_page' => array('lang' => 'USERS_PAGE', 'validate' => 'int', 'type' => 'text:3:3', 'explain' => true),
'legend3' => 'ACP_SUBMIT_CHANGES',
)
);
// show the extension version check on Settings page
$this->version_check->check();
break;
case 'features':
$display_vars = array(
'title' => 'ACP_FOOTBALL_FEATURES',
'vars' => array(
'legend1' => 'ACP_FOOTBALL_FEATURES',
'football_founder_delete' => array('lang' => 'FOUNDER_DELETE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'football_results_at_time' => array('lang' => 'RESULTS_AT_TIME', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'football_win_hits02' => array('lang' => 'WIN_HITS02', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'football_same_allowed' => array('lang' => 'SAME_ALLOWED', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'football_season_start' => array('lang' => 'FOOTBALL_SEASON_START', 'validate' => 'int', 'type' => 'select', 'method' => 'season_select', 'params' => array('{CONFIG_VALUE}', false), 'explain' => true),
'football_view_current' => array('lang' => 'VIEW_CURRENT', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'football_view_bets' => array('lang' => 'VIEW_BETS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'football_view_tendencies' => array('lang' => 'VIEW_TENDENCIES', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'football_bank' => array('lang' => 'BANK', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'football_ult_points' => array('lang' => 'ULT_POINTS', 'validate' => 'int', 'type' => 'custom', 'method' => 'select_up_method', 'explain' => true),
'football_ult_points_factor'=> array('lang' => 'ULT_POINTS_FACTOR', 'validate' => 'dec:3:2','type' => 'text:4:10', 'explain' => true),
'football_remember_enable' => array('lang' => 'FOOTBALL_REMEMBER_ENABLE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'football_remember_next_run'=> array('lang' => 'FOOTBALL_REMEMBER_NEXT_RUN','validate' => 'int', 'type' => 'custom', 'method' => 'next_run', 'explain' => true),
'legend2' => 'ACP_SUBMIT_CHANGES',
)
);
break;
case 'menu':
$display_vars = array(
'title' => 'ACP_FOOTBALL_MENU',
'vars' => array(
'legend1' => 'ACP_FOOTBALL_MENU',
'football_breadcrumb' => array('lang' => 'FOOTBALL_BREADCRUMB', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'football_side' => array('lang' => 'FOOTBALL_SIDE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'football_menu' => array('lang' => 'FOOTBALL_MENU', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'football_menu_link1' => array('lang' => 'MENU_LINK1', 'validate' => 'string', 'type' => 'text:80:255', 'explain' => true),
'football_menu_desc1' => array('lang' => 'MENU_DESC1', 'validate' => 'string', 'type' => 'text:20:20', 'explain' => true),
'football_menu_link2' => array('lang' => 'MENU_LINK2', 'validate' => 'string', 'type' => 'text:80:255', 'explain' => false),
'football_menu_desc2' => array('lang' => 'MENU_DESC2', 'validate' => 'string', 'type' => 'text:20:20', 'explain' => false),
'football_menu_link3' => array('lang' => 'MENU_LINK3', 'validate' => 'string', 'type' => 'text:80:255', 'explain' => false),
'football_menu_desc3' => array('lang' => 'MENU_DESC3', 'validate' => 'string', 'type' => 'text:20:20', 'explain' => false),
)
);
break;
default:
trigger_error('NO_MODE', E_USER_ERROR);
break;
}
if (isset($display_vars['lang']))
{
$user->add_lang($display_vars['lang']);
}
$this->new_config = $this->config;
$cfg_array = (isset($_REQUEST['config'])) ? utf8_normalize_nfc($this->request->variable('config', array('' => ''), true)) : $this->new_config;
$error = array();
// We validate the complete config if whished
validate_config_vars($display_vars['vars'], $cfg_array, $error);
if ($submit && !check_form_key($form_key))
{
$error[] = $user->lang['FORM_INVALID'];
}
// Do not write values if there is an error
if (sizeof($error))
{
$submit = false;
}
// We go through the display_vars to make sure no one is trying to set variables he/she is not allowed to...
foreach ($display_vars['vars'] as $this->config_name => $null)
{
if (!isset($cfg_array[$this->config_name]) || strpos($this->config_name, 'legend') !== false)
{
continue;
}
$this->new_config[$this->config_name] = $this->config_value = $cfg_array[$this->config_name];
if ($submit)
{
if ($this->config_name == 'football_ult_points' && $this->config_value)
{
$this->config->set('football_bank', 1);
}
if ($this->config_name == 'football_remember_enable')
{
$day = $this->request->variable('next_run_day', 0);
$month = $this->request->variable('next_run_month', 0);
$year = $this->request->variable('next_run_year', 0);
$hour = $this->request->variable('next_run_hour', 0);
$minute = $this->request->variable('next_run_minute', 0);
$next_run = mktime($hour, $minute, 0, $month, $day, $year);
$this->config->set('football_remember_next_run', $next_run);
}
$this->config->set($this->config_name, $this->config_value);
}
}
if ($submit)
{
$phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_FOOTBALL_' . strtoupper($mode));
trigger_error($user->lang['CONFIG_UPDATED'] . adm_back_link($this->u_action));
}
$this->tpl_name = 'acp_football';
$this->page_title = $display_vars['title'];
$template->assign_vars(array(
'U_FOOTBALL' => $helper->route('football_main_controller',array('side' => 'bet')),
'L_TITLE' => $user->lang[$display_vars['title']],
'L_TITLE_EXPLAIN' => $user->lang[$display_vars['title'] . '_EXPLAIN'],
'S_ERROR' => (sizeof($error)) ? true : false,
'ERROR_MSG' => implode('<br />', $error),
'U_ACTION' => $this->u_action,
'S_VERSION_NO' => $this->config['football_version'],
)
);
// Output relevant page
foreach ($display_vars['vars'] as $this->config_key => $vars)
{
if (!is_array($vars) && strpos($this->config_key, 'legend') === false)
{
continue;
}
if (strpos($this->config_key, 'legend') !== false)
{
$template->assign_block_vars('options', array(
'S_LEGEND' => true,
'LEGEND' => (isset($user->lang[$vars])) ? $user->lang[$vars] : $vars,
)
);
continue;
}
$type = explode(':', $vars['type']);
$l_explain = '';
if ($vars['explain'] && isset($vars['lang_explain']))
{
$l_explain = (isset($user->lang[$vars['lang_explain']])) ? $user->lang[$vars['lang_explain']] : $vars['lang_explain'];
}
else if ($vars['explain'])
{
$l_explain = (isset($user->lang[$vars['lang'] . '_EXPLAIN'])) ? $user->lang[$vars['lang'] . '_EXPLAIN'] : '';
}
$content = build_cfg_template($type, $this->config_key, $this->new_config, $this->config_key, $vars);
if (empty($content))
{
continue;
}
$template->assign_block_vars('options', array(
'KEY' => $this->config_key,
'TITLE' => (isset($user->lang[$vars['lang']])) ? $user->lang[$vars['lang']] : $vars['lang'],
'S_EXPLAIN' => $vars['explain'],
'TITLE_EXPLAIN' => $l_explain,
'CONTENT' => $content,
)
);
unset($display_vars['vars'][$this->config_key]);
}
}
/**
* Football disable option and message
*/
function football_disable($value, $key)
{
global $user;
$radio_ary = array(1 => 'YES', 0 => 'NO');
return h_radio('config[football_disable]', $radio_ary, $value) . '<br /><input id="' . $key . '" type="text" name="config[football_disable_msg]" maxlength="255" size="80" value="' . $this->new_config['football_disable_msg'] . '" />';
}
/**
* Football info option and message
*/
function football_info($value, $key)
{
global $user;
$radio_ary = array(1 => 'YES', 0 => 'NO');
return h_radio('config[football_info_display]', $radio_ary, $value) . '<br /><input id="' . $key . '" type="text" name="config[football_info]" maxlength="255" size="80" value="' . $this->new_config['football_info'] . '" />';
}
/**
* Select ultimate points method
*/
function select_up_method($value, $key = '')
{
global $user, $config;
$radio_ary = array(UP_NONE => 'UP_NONE', UP_WINS => 'UP_WINS', UP_POINTS => 'UP_POINTS');
return h_radio('config[football_ult_points]', $radio_ary, $value, $key);
}
function season_select($default = 0)
{
global $user, $db;
$sql = 'SELECT DISTINCT s.season, s.season_name_short FROM ' . FOOTB_SEASONS . ' AS s
INNER JOIN ' . FOOTB_LEAGUES . ' AS l ON (l.season = s.season)
INNER JOIN ' . FOOTB_MATCHDAYS . ' AS md ON (md.season = s.season AND md.league = l.league)
WHERE 1
ORDER BY s.season DESC';
$result = $db->sql_query($sql);
$selected = (0 == $default) ? ' selected="selected"' : '';
$season_options = '<option value="0"' . $selected . '>' . $user->lang['AUTO'] . '</option>';
while ($row = $db->sql_fetchrow($result))
{
$selected = ($row['season'] == $default) ? ' selected="selected"' : '';
$season_options .= '<option value="' . $row['season'] . '"' . $selected . '>' . $row['season_name_short'] . '</option>';
}
$db->sql_freeresult($result);
return $season_options;
}
/**
* Adjust Cronjob EMail remember next un
*/
function next_run($value, $key = '')
{
global $user, $db;
$next_run = getdate($this->config['football_remember_next_run']);
// Days
$day_options = '<select name="next_run_day" id="next_run_day">';
for ($i = 1; $i < 32; $i++)
{
$selected = ($i == $next_run['mday']) ? ' selected="selected"' : '';
$day_options .= '<option value="' . $i . '"' . $selected . '>' . $i . '</option>';
}
$day_options .= '</select>';
// Months
$month_options = '<select name="next_run_month" id="next_run_month">';
for ($i = 1; $i < 13; $i++)
{
$selected = ($i == $next_run['mon']) ? ' selected="selected"' : '';
$month_options .= '<option value="' . $i . '"' . $selected . '>' . $i . '</option>';
}
$month_options .= '</select>';
// Years
$year_options = '<select name="next_run_year" id="next_run_year">';
for ($i = date("Y"); $i < (date("Y") + 1); $i++)
{
$selected = ($i == $next_run['year']) ? ' selected="selected"' : '';
$year_options .= '<option value="' . $i . '"' . $selected . '>' . $i . '</option>';
}
$year_options .= '</select>';
// Hours
$hour_options = '<select name="next_run_hour" id="next_run_hour">';
for ($i = 0; $i < 24; $i++)
{
$selected = ($i == $next_run['hours']) ? ' selected="selected"' : '';
$hour_options .= '<option value="' . $i . '"' . $selected . '>' . $i . '</option>';
}
$hour_options .= '</select>';
// Minutes
$minute_options = '<select name="next_run_minute" id="next_run_minute">';
for ($i = 0; $i < 60; $i++)
{
$selected = ($i == $next_run['minutes']) ? ' selected="selected"' : '';
$minute_options .= '<option value="' . $i . '"' . $selected . '>' . $i . '</option>';
}
$minute_options .= '</select>';
return $user->lang['DAY'] . ': ' . $day_options . ' ' . $user->lang['MONTH'] . ': ' . $month_options . ' ' . $user->lang['YEAR'] . ': ' .
$year_options . ' ' . $user->lang['HOURS'] . ': ' . $hour_options . ' ' . $user->lang['MINUTES'] . ': ' . $minute_options;
}
}
?>

View File

@@ -1,257 +1,255 @@
<?php
/**
*
* @package phpBB Extension - Football Football
* @copyright (c) 2016 football (http://football.bplaced.net)
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
namespace football\football\acp;
class ko_module
{
public $u_action;
protected $db, $user, $template, $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;
protected $root_path, $request, $php_ext, $log;
public function __construct()
{
global $db, $user, $request, $template;
global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;
$user->add_lang_ext('football/football', 'football');
$user->add_lang_ext('football/football', 'info_acp_ko');
$this->root_path = $phpbb_root_path . 'ext/football/football/';
$this->config = $config;
$this->request = $request;
$this->phpbb_root_path = $phpbb_root_path;
$this->phpbb_admin_path = $phpbb_admin_path;
$this->php_ext = $phpEx;
if(!function_exists('season_info'))
{
include($this->root_path . 'includes/functions.' . $this->php_ext);
}
if (!defined('FOOTB_SEASONS'))
{
include($this->root_path . 'includes/constants.' . $this->php_ext);
}
}
function main($id, $mode)
{
global $db, $auth, $phpbb_container, $phpbb_admin_path, $league_info;
global $template, $user, $config, $phpbb_extension_manager, $request, $phpbb_root_path, $phpEx;
$provider = new \phpbb\controller\ provider();
$symphony_request = new \phpbb\ symfony_request($request);
$filesystem = new \phpbb\ filesystem();
$helper = new \phpbb\controller\ helper($template, $user, $config, $provider, $phpbb_extension_manager, $symphony_request, $request, $filesystem, $phpbb_root_path, $phpEx);
$this->tpl_name = 'acp_football_ko';
$this->page_title = 'ACP_FOOTBALL_KO_MANAGE';
$form_key = 'acp_football_ko';
add_form_key($form_key);
include($this->phpbb_root_path . 'includes/functions_user.' . $this->php_ext);
// Check and set some common vars
$action = (isset($_POST['update'])) ? 'update' : $this->request->variable('action', '');
$season = $this->request->variable('s', 0);
$league = $this->request->variable('l', 0);
$matchday_from = $this->request->variable('matchday_from', 0);
$matchday_to = $this->request->variable('matchday_to', 0);
$matchday_new = $this->request->variable('matchday_new', 0);
$check_rank = $this->request->variable('check_rank', 0);
$rank = $this->request->variable('rank', 2);
$move_rank = $this->request->variable('move_rank', 3);
$move_league = $this->request->variable('move_league', 0);
$move_matchday = $this->request->variable('move_matchday', 8);
// Clear some vars
$error = array();
$success = array();
$curr_season = curr_season();
// Grab current season
if (!$season)
{
$season = $curr_season;
}
// Grab basic data for select season
if ($season)
{
$sql = 'SELECT
DISTINCT s.*
FROM ' . FOOTB_SEASONS . ' AS s
LEFT JOIN ' . FOOTB_LEAGUES . ' AS l ON (l.season = s.season)
WHERE l.league_type = 2
ORDER BY s.season DESC';
$result = $db->sql_query($sql);
$season_options = '';
while ($row = $db->sql_fetchrow($result))
{
$selected = ($season && $row['season'] == $season) ? ' selected="selected"' : '';
$season_options .= '<option value="' . $row['season'] . '"' . $selected . '>' . $row['season_name_short'] . '</option>';
if ($selected <> '')
{
$season_name = $row['season_name_short'];
}
}
$db->sql_freeresult($result);
}
else
{
trigger_error($user->lang['NO_SEASON'] . adm_back_link($this->u_action), E_USER_WARNING);
}
// Grab basic data for select league
$sql = 'SELECT *
FROM ' . FOOTB_LEAGUES . '
WHERE season = ' . $season . '
AND league_type = ' . LEAGUE_KO . '
ORDER BY league ASC';
$result = $db->sql_query($sql);
$league_options = '';
if ($move_league == 0)
{
$league_move_options = '<option value="0" selected="selected">' . sprintf($user->lang['CHOOSE_LEAGUE']) . '</option>';
}
else
{
$league_move_options = '<option value="0">' . sprintf($user->lang['CHOOSE_LEAGUE']) . '</option>';
}
while ($row = $db->sql_fetchrow($result))
{
// Grab current league
if (!$league)
{
$league = $row['league'];
}
$selected = ($league && $row['league'] == $league) ? ' selected="selected"' : '';
$league_options .= '<option value="' . $row['league'] . '"' . $selected . '>' . $row['league_name'] . '</option>';
if ($selected <> '')
{
$league_matchdays = $row['matchdays'];
$matches_matchday = $row['matches_on_matchday'];
$league_name = $row['league_name'];
}
else
{
$selected_move = ($move_league && $row['league'] == $move_league) ? ' selected="selected"' : '';
$league_move_options .= '<option value="' . $row['league'] . '"' . $selected_move . '>' . $row['league_name'] . '</option>';
}
}
$db->sql_freeresult($result);
if (!$league)
{
trigger_error(sprintf($user->lang['NO_LEAGUE'], $season) . adm_back_link($this->u_action . "&amp;s=$season"), E_USER_WARNING);
}
// Grab basic data for select matchday
if (!$matchday_from)
{
$matchday_from = curr_matchday($season, $league);
if ($matchday_from > 1)
{
$matchday_from = $matchday_from - 1;
}
}
if (!$matchday_to)
{
$matchday_to = $matchday_from;
}
if (!$matchday_new)
{
$matchday_new = $matchday_to + 1;
}
$sql = 'SELECT *
FROM ' . FOOTB_MATCHDAYS . "
WHERE season = $season
AND league = $league
ORDER BY matchday ASC";
$result = $db->sql_query($sql);
$matchday_from_options = '';
$matchday_to_options = '';
$matchday_new_options = '';
while ($row = $db->sql_fetchrow($result))
{
$selected_from = ($matchday_from && $row['matchday'] == $matchday_from) ? ' selected="selected"' : '';
$selected_to = ($matchday_to && $row['matchday'] == $matchday_to) ? ' selected="selected"' : '';
$selected_new = ($matchday_new && $row['matchday'] == $matchday_new) ? ' selected="selected"' : '';
$day_name = (strlen($row['matchday_name']) > 0) ? $row['matchday_name'] : $row['matchday'] . '. ' . sprintf($user->lang['MATCHDAY']);
$matchday_from_options .= '<option value="' . $row['matchday'] . '"' . $selected_from . '>' . $day_name . '</option>';
$matchday_to_options .= '<option value="' . $row['matchday'] . '"' . $selected_to . '>' . $day_name . '</option>';
$matchday_new_options .= '<option value="' . $row['matchday'] . '"' . $selected_new . '>' . $day_name . '</option>';
}
$db->sql_freeresult($result);
if ($matchday_from_options == '')
{
trigger_error(sprintf($user->lang['NO_MATCHDAY'], $league_name, $season) . adm_back_link($this->u_action . "&amp;s=$season&amp;l=$league"), E_USER_WARNING);
}
// Which page?
switch ($action)
{
case 'update':
{
if ($matchday_from > $matchday_to)
{
$error[] = sprintf($user->lang['ERROR_FROM_TO']);
}
if ($matchday_new <= $matchday_to)
{
$error[] = sprintf($user->lang['ERROR_TARGET']);
}
if (!sizeof($error))
{
if (1 == $check_rank)
{
$success = ko_group_next_round($season, $league, $matchday_from, $matchday_to, $matchday_new, $rank, $move_rank, $move_league, $move_matchday);
}
else
{
$success = ko_next_round($season, $league, $matchday_from, $matchday_to, $matchday_new);
}
trigger_error($success . adm_back_link($this->u_action));
}
}
break;
}
$template->assign_vars(array(
'U_ACTION' => $this->u_action,
'U_FOOTBALL' => $helper->route('football_main_controller',array('side' => 'bet', 's' => $season, 'l' => $league)),
'S_ERROR' => (sizeof($error)) ? true : false,
'ERROR_MSG' => (sizeof($error)) ? implode('<br />', $error) : '',
'S_SUCCESS' => (sizeof($success)) ? true : false,
'SUCCESS_MSG' => (sizeof($success)) ? implode('<br />', $success) : '',
'S_SEASON_OPTIONS' => $season_options,
'S_LEAGUE_OPTIONS' => $league_options,
'S_SEASON' => $season,
'S_LEAGUE' => $league,
'S_MATCHDAY_FROM_OPTIONS'=> $matchday_from_options,
'S_MATCHDAY_TO_OPTIONS' => $matchday_to_options,
'S_MATCHDAY_NEW_OPTIONS'=> $matchday_new_options,
'S_CHECK_RANK' => $check_rank,
'S_RANK' => $rank,
'S_MOVE_RANK' => $move_rank,
'S_MOVE_LEAGUE_OPTIONS' => $league_move_options,
'S_MOVE_MATCHDAY' => $move_matchday,
'S_VERSION_NO' => $this->config['football_version'],
)
);
}
}
<?php
/**
*
* @package phpBB Extension - Football Football
* @copyright (c) 2016 football (http://football.bplaced.net)
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
namespace football\football\acp;
class ko_module
{
public $u_action;
protected $db, $user, $template, $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;
protected $root_path, $request, $php_ext, $log;
public function __construct()
{
global $db, $user, $request, $template;
global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;
$user->add_lang_ext('football/football', 'football');
$user->add_lang_ext('football/football', 'info_acp_ko');
$this->root_path = $phpbb_root_path . 'ext/football/football/';
$this->config = $config;
$this->request = $request;
$this->phpbb_root_path = $phpbb_root_path;
$this->phpbb_admin_path = $phpbb_admin_path;
$this->php_ext = $phpEx;
if(!function_exists('season_info'))
{
include($this->root_path . 'includes/functions.' . $this->php_ext);
}
if (!defined('FOOTB_SEASONS'))
{
include($this->root_path . 'includes/constants.' . $this->php_ext);
}
}
function main($id, $mode)
{
global $db, $auth, $phpbb_container, $phpbb_admin_path, $league_info;
global $template, $user, $config, $phpbb_extension_manager, $request, $phpbb_root_path, $phpEx;
$helper = $phpbb_container->get('controller.helper');
$this->tpl_name = 'acp_football_ko';
$this->page_title = 'ACP_FOOTBALL_KO_MANAGE';
$form_key = 'acp_football_ko';
add_form_key($form_key);
include($this->phpbb_root_path . 'includes/functions_user.' . $this->php_ext);
// Check and set some common vars
$action = (isset($_POST['update'])) ? 'update' : $this->request->variable('action', '');
$season = $this->request->variable('s', 0);
$league = $this->request->variable('l', 0);
$matchday_from = $this->request->variable('matchday_from', 0);
$matchday_to = $this->request->variable('matchday_to', 0);
$matchday_new = $this->request->variable('matchday_new', 0);
$check_rank = $this->request->variable('check_rank', 0);
$rank = $this->request->variable('rank', 2);
$move_rank = $this->request->variable('move_rank', 3);
$move_league = $this->request->variable('move_league', 0);
$move_matchday = $this->request->variable('move_matchday', 8);
// Clear some vars
$error = array();
$success = array();
$curr_season = curr_season();
// Grab current season
if (!$season)
{
$season = $curr_season;
}
// Grab basic data for select season
if ($season)
{
$sql = 'SELECT
DISTINCT s.*
FROM ' . FOOTB_SEASONS . ' AS s
LEFT JOIN ' . FOOTB_LEAGUES . ' AS l ON (l.season = s.season)
WHERE l.league_type = 2
ORDER BY s.season DESC';
$result = $db->sql_query($sql);
$season_options = '';
while ($row = $db->sql_fetchrow($result))
{
$selected = ($season && $row['season'] == $season) ? ' selected="selected"' : '';
$season_options .= '<option value="' . $row['season'] . '"' . $selected . '>' . $row['season_name_short'] . '</option>';
if ($selected <> '')
{
$season_name = $row['season_name_short'];
}
}
$db->sql_freeresult($result);
}
else
{
trigger_error($user->lang['NO_SEASON'] . adm_back_link($this->u_action), E_USER_WARNING);
}
// Grab basic data for select league
$sql = 'SELECT *
FROM ' . FOOTB_LEAGUES . '
WHERE season = ' . $season . '
AND league_type = ' . LEAGUE_KO . '
ORDER BY league ASC';
$result = $db->sql_query($sql);
$league_options = '';
if ($move_league == 0)
{
$league_move_options = '<option value="0" selected="selected">' . sprintf($user->lang['CHOOSE_LEAGUE']) . '</option>';
}
else
{
$league_move_options = '<option value="0">' . sprintf($user->lang['CHOOSE_LEAGUE']) . '</option>';
}
while ($row = $db->sql_fetchrow($result))
{
// Grab current league
if (!$league)
{
$league = $row['league'];
}
$selected = ($league && $row['league'] == $league) ? ' selected="selected"' : '';
$league_options .= '<option value="' . $row['league'] . '"' . $selected . '>' . $row['league_name'] . '</option>';
if ($selected <> '')
{
$league_matchdays = $row['matchdays'];
$matches_matchday = $row['matches_on_matchday'];
$league_name = $row['league_name'];
}
else
{
$selected_move = ($move_league && $row['league'] == $move_league) ? ' selected="selected"' : '';
$league_move_options .= '<option value="' . $row['league'] . '"' . $selected_move . '>' . $row['league_name'] . '</option>';
}
}
$db->sql_freeresult($result);
if (!$league)
{
trigger_error(sprintf($user->lang['NO_LEAGUE'], $season) . adm_back_link($this->u_action . "&amp;s=$season"), E_USER_WARNING);
}
// Grab basic data for select matchday
if (!$matchday_from)
{
$matchday_from = curr_matchday($season, $league);
if ($matchday_from > 1)
{
$matchday_from = $matchday_from - 1;
}
}
if (!$matchday_to)
{
$matchday_to = $matchday_from;
}
if (!$matchday_new)
{
$matchday_new = $matchday_to + 1;
}
$sql = 'SELECT *
FROM ' . FOOTB_MATCHDAYS . "
WHERE season = $season
AND league = $league
ORDER BY matchday ASC";
$result = $db->sql_query($sql);
$matchday_from_options = '';
$matchday_to_options = '';
$matchday_new_options = '';
while ($row = $db->sql_fetchrow($result))
{
$selected_from = ($matchday_from && $row['matchday'] == $matchday_from) ? ' selected="selected"' : '';
$selected_to = ($matchday_to && $row['matchday'] == $matchday_to) ? ' selected="selected"' : '';
$selected_new = ($matchday_new && $row['matchday'] == $matchday_new) ? ' selected="selected"' : '';
$day_name = (strlen($row['matchday_name']) > 0) ? $row['matchday_name'] : $row['matchday'] . '. ' . sprintf($user->lang['MATCHDAY']);
$matchday_from_options .= '<option value="' . $row['matchday'] . '"' . $selected_from . '>' . $day_name . '</option>';
$matchday_to_options .= '<option value="' . $row['matchday'] . '"' . $selected_to . '>' . $day_name . '</option>';
$matchday_new_options .= '<option value="' . $row['matchday'] . '"' . $selected_new . '>' . $day_name . '</option>';
}
$db->sql_freeresult($result);
if ($matchday_from_options == '')
{
trigger_error(sprintf($user->lang['NO_MATCHDAY'], $league_name, $season) . adm_back_link($this->u_action . "&amp;s=$season&amp;l=$league"), E_USER_WARNING);
}
// Which page?
switch ($action)
{
case 'update':
{
if ($matchday_from > $matchday_to)
{
$error[] = sprintf($user->lang['ERROR_FROM_TO']);
}
if ($matchday_new <= $matchday_to)
{
$error[] = sprintf($user->lang['ERROR_TARGET']);
}
if (!sizeof($error))
{
if (1 == $check_rank)
{
$success = ko_group_next_round($season, $league, $matchday_from, $matchday_to, $matchday_new, $rank, $move_rank, $move_league, $move_matchday);
}
else
{
$success = ko_next_round($season, $league, $matchday_from, $matchday_to, $matchday_new);
}
trigger_error($success . adm_back_link($this->u_action));
}
}
break;
}
$template->assign_vars(array(
'U_ACTION' => $this->u_action,
'U_FOOTBALL' => $helper->route('football_main_controller',array('side' => 'bet', 's' => $season, 'l' => $league)),
'S_ERROR' => (sizeof($error)) ? true : false,
'ERROR_MSG' => (sizeof($error)) ? implode('<br />', $error) : '',
'S_SUCCESS' => (sizeof($success)) ? true : false,
'SUCCESS_MSG' => (sizeof($success)) ? implode('<br />', $success) : '',
'S_SEASON_OPTIONS' => $season_options,
'S_LEAGUE_OPTIONS' => $league_options,
'S_SEASON' => $season,
'S_LEAGUE' => $league,
'S_MATCHDAY_FROM_OPTIONS'=> $matchday_from_options,
'S_MATCHDAY_TO_OPTIONS' => $matchday_to_options,
'S_MATCHDAY_NEW_OPTIONS'=> $matchday_new_options,
'S_CHECK_RANK' => $check_rank,
'S_RANK' => $rank,
'S_MOVE_RANK' => $move_rank,
'S_MOVE_LEAGUE_OPTIONS' => $league_move_options,
'S_MOVE_MATCHDAY' => $move_matchday,
'S_VERSION_NO' => $this->config['football_version'],
)
);
}
}
?>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,396 +1,394 @@
<?php
/**
*
* @package phpBB Extension - Football Football
* @copyright (c) 2016 football (http://football.bplaced.net)
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
namespace football\football\acp;
class seasons_module
{
public $u_action;
protected $db, $user, $template, $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;
protected $root_path, $request, $php_ext, $log;
public function __construct()
{
global $db, $user, $request, $template;
global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;
$user->add_lang_ext('football/football', 'football');
$user->add_lang_ext('football/football', 'info_acp_seasons');
$this->root_path = $phpbb_root_path . 'ext/football/football/';
$this->config = $config;
$this->request = $request;
$this->phpbb_root_path = $phpbb_root_path;
$this->phpbb_admin_path = $phpbb_admin_path;
$this->php_ext = $phpEx;
if(!function_exists('season_info'))
{
include($this->root_path . 'includes/functions.' . $this->php_ext);
}
if (!defined('FOOTB_SEASONS'))
{
include($this->root_path . 'includes/constants.' . $this->php_ext);
}
}
function main($id, $mode)
{
global $db, $auth, $phpbb_container, $phpbb_admin_path, $league_info;
global $template, $user, $config, $phpbb_extension_manager, $request, $phpbb_root_path, $phpEx;
$provider = new \phpbb\controller\ provider();
$symphony_request = new \phpbb\ symfony_request($request);
$filesystem = new \phpbb\ filesystem();
$helper = new \phpbb\controller\ helper($template, $user, $config, $provider, $phpbb_extension_manager, $symphony_request, $request, $filesystem, $phpbb_root_path, $phpEx);
$this->tpl_name = 'acp_football_seasons';
$this->page_title = 'ACP_FOOTBALL_SEASONS_MANAGE';
$form_key = 'acp_football_seasons';
add_form_key($form_key);
include($phpbb_root_path . 'includes/functions_user.' . $phpEx);
// Check and set some common vars
$action = (isset($_POST['add'])) ? 'add' : $this->request->variable('action', '');
$season = $this->request->variable('s', 0);
$edit = $this->request->variable('edit', 0);
$update = (isset($_POST['update'])) ? true : false;
// Clear some vars
$season_row = array();
$error = array();
// Grab basic data for season, if season is set and exists
if ($season)
{
$sql = 'SELECT *
FROM ' . FOOTB_SEASONS . "
WHERE season = $season";
$result = $db->sql_query($sql);
$season_row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
}
// Which page?
switch ($action)
{
case 'delete':
if (!$season)
{
trigger_error($user->lang['NO_SEASON'] . adm_back_link($this->u_action), E_USER_WARNING);
}
if (confirm_box(true))
{
$error = '';
if (!$auth->acl_get('a_football_delete'))
{
trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING);
}
if ($user->data['user_type'] != USER_FOUNDER && $this->config['football_founder_delete'])
{
trigger_error($user->lang['SEASONS_NO_DELETE'] . adm_back_link($this->u_action), E_USER_WARNING);
}
// Delete season
$sql = 'DELETE FROM ' . FOOTB_SEASONS . "
WHERE season = $season";
$db->sql_query($sql);
// Delete leagues
$sql = 'DELETE FROM ' . FOOTB_LEAGUES . "
WHERE season = $season";
$db->sql_query($sql);
// Delete matchdays
$sql = 'DELETE FROM ' . FOOTB_MATCHDAYS . "
WHERE season = $season";
$db->sql_query($sql);
// Delete matches
$sql = 'DELETE FROM ' . FOOTB_MATCHES . "
WHERE season = $season";
$db->sql_query($sql);
// Delete teams
$sql = 'DELETE FROM ' . FOOTB_TEAMS . "
WHERE season = $season";
$db->sql_query($sql);
// Delete ranks
$sql = 'DELETE FROM ' . FOOTB_RANKS . "
WHERE season = $season";
$db->sql_query($sql);
// Delete bets
$sql = 'DELETE FROM ' . FOOTB_BETS . "
WHERE season = $season";
$db->sql_query($sql);
trigger_error($user->lang['SEASON_DELETED'] . adm_back_link($this->u_action));
}
else
{
confirm_box(false, sprintf($user->lang['SEASON_CONFIRM_DELETE'], $season), build_hidden_fields(array(
's' => $season,
'mode' => $mode,
'action' => $action))
);
}
break;
case 'add':
if ($season >= 1963 AND $season <= 2099)
{
if ($season_row)
{
if ($edit)
{
$error[] = $user->lang['SEASON_TAKEN'];
}
else
{
trigger_error($user->lang['SEASON_TAKEN'] . adm_back_link($this->u_action), E_USER_WARNING);
}
}
$season_row['season_name'] = utf8_normalize_nfc($this->request->variable('season_name', '', true));
if ($season_row['season_name'] <> '')
{
$sql = 'SELECT
season_name
FROM ' . FOOTB_SEASONS . "
WHERE season_name = '" . $season_row['season_name'] . "'";
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
if ($row)
{
$error[] = $user->lang['SEASON_NAME_TAKEN'];
}
}
else
{
$intseason = ((int) $season) - 1;
$season_row['season_name'] = $user->lang['SEASON'] . ' ' . $intseason . '/' . $season;
}
$season_row['season_name_short'] = utf8_normalize_nfc($this->request->variable('season_short', '', true));
if ($season_row['season_name_short'] <> '')
{
$sql = 'SELECT
season_name_short
FROM ' . FOOTB_SEASONS . "
WHERE season_name_short = '" . $season_row['season_name_short'] . "'";
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
if ($row)
{
$error[] = $user->lang['SEASON_SHORT_TAKEN'];
}
}
else
{
$intseason = ((int) $season) - 1;
$season_row['season_name_short'] = $intseason . '/' . $season;
}
}
else
{
trigger_error($user->lang['SEASON_NUMBER'] . adm_back_link($this->u_action), E_USER_WARNING);
}
// No break for edit add
case 'edit':
$data = array();
if (!sizeof($error))
{
if ($action == 'edit' && !$season)
{
trigger_error($user->lang['NO_SEASON'] . adm_back_link($this->u_action), E_USER_WARNING);
}
// Did we submit?
if ($update)
{
if (!check_form_key($form_key))
{
trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING);
return;
}
$season_row['season_name'] = utf8_normalize_nfc($this->request->variable('season_name', '', true));
if ($season_row['season_name'] <> '')
{
$sql = 'SELECT
season
FROM ' . FOOTB_SEASONS . "
WHERE season_name = '" . $season_row['season_name'] . "'";
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
if ($row)
{
if ($row['season'] <> $season)
{
$error[] = $user->lang['SEASON_NAME_TAKEN'];
}
}
}
else
{
$error[] = $user->lang['SEASON_NAME_EMPTY'];
}
$season_row['season_name_short'] = utf8_normalize_nfc($this->request->variable('season_short', '', true));
if ($season_row['season_name_short'] <> '')
{
$sql = 'SELECT
season
FROM ' . FOOTB_SEASONS . "
WHERE season_name_short = '" . $season_row['season_name_short'] . "'";
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
if ($row)
{
if ($row['season'] <> $season)
{
$error[] = $user->lang['SEASON_SHORT_TAKEN'];
}
}
}
else
{
$error[] = $user->lang['SEASON_SHORT_EMPTY'];
}
if (!sizeof($error))
{
$sql_ary = array(
'season' => (int) $season,
'season_name' => $season_row['season_name'],
'season_name_short' => $season_row['season_name_short'],
);
$data['season'] = $season;
$data['season_name'] = $this->request->variable('season_name', '');
$data['season_short'] = $this->request->variable('season_short', '');
$var_ary = array(
'season' => array('num', false, 1963, 2099),
'season_name' => array('string', false, 4, 20),
'season_short' => array('string', false, 2, 10),
);
if (!($error_vals = validate_data($data, $var_ary)))
{
if ($action == 'add')
{
$sql = 'INSERT INTO ' . FOOTB_SEASONS . ' ' . $db->sql_build_array('INSERT', $sql_ary);
$db->sql_query($sql);
}
else
{
$sql = 'UPDATE ' . FOOTB_SEASONS . '
SET ' . $db->sql_build_array('UPDATE', $sql_ary) . "
WHERE season = $season";
$db->sql_query($sql);
}
$message = ($action == 'edit') ? 'SEASON_UPDATED' : 'SEASON_CREATED';
trigger_error($user->lang[$message] . adm_back_link($this->u_action));
}
else
{
foreach ($error_vals as $error_val)
{
$error_msg[] = $user->lang[$error_val];
}
$message = ($action == 'edit') ? 'SEASON_UPDATE_FAILED' : 'SEASON_CREATE_FAILED';
$error[] = $user->lang[$message];
$error = array_merge($error, $error_msg);
}
}
}
}
$u_back = $this->u_action;
$template->assign_vars(array(
'S_EDIT' => true,
'S_ADD_SEASON' => ($action == 'add') ? true : false,
'S_ERROR' => (sizeof($error)) ? true : false,
'ERROR_MSG' => (sizeof($error)) ? implode('<br />', $error) : '',
'SEASON' => $season,
'SEASON_NAME' => $season_row['season_name'],
'SEASON_SHORT' => $season_row['season_name_short'],
'U_BACK' => $u_back,
'U_ACTION' => "{$this->u_action}&amp;action=$action&amp;s=$season",
)
);
return;
break;
}
$template->assign_vars(array(
'U_ACTION' => $this->u_action,
'U_FOOTBALL' => $helper->route('football_main_controller',array('side' => 'bet')),
'S_SEASON_ADD' => true,
)
);
// Get us all the seasons
$sql = 'SELECT
s.season,
s.season_name,
s.season_name_short,
COUNT(l.league) AS leagues
FROM ' . FOOTB_SEASONS . ' s
LEFT JOIN ' . FOOTB_LEAGUES . ' l on l.season = s.season
GROUP BY season
ORDER BY season DESC';
$result = $db->sql_query($sql);
$rows_seasons = $db->sql_fetchrowset($result);
$db->sql_freeresult($result);
// Check if the user is allowed to delete a season.
if ($user->data['user_type'] != USER_FOUNDER && $this->config['football_founder_delete'])
{
$allow_delete = false;
}
else
{
$allow_delete = true;
}
$row_number = 0;
foreach ($rows_seasons as $row_season)
{
$row_number++;
$row_class = (!($row_number % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
$template->assign_block_vars('seasons', array(
'ROW_CLASS' => $row_class,
'SEASON' => $row_season['season'],
'SEASON_NAME' => $row_season['season_name'],
'SEASON_SHORT' => $row_season['season_name_short'],
'LEAGUES' => $row_season['leagues'],
'U_EDIT' => "{$this->u_action}&amp;action=edit&amp;s=" .$row_season['season'],
'U_DELETE' => ($allow_delete) ? "{$this->u_action}&amp;action=delete&amp;s=" . $row_season['season'] : '',
)
);
}
}
}
<?php
/**
*
* @package phpBB Extension - Football Football
* @copyright (c) 2016 football (http://football.bplaced.net)
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
namespace football\football\acp;
class seasons_module
{
public $u_action;
protected $db, $user, $template, $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;
protected $root_path, $request, $php_ext, $log;
public function __construct()
{
global $db, $user, $request, $template;
global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;
$user->add_lang_ext('football/football', 'football');
$user->add_lang_ext('football/football', 'info_acp_seasons');
$this->root_path = $phpbb_root_path . 'ext/football/football/';
$this->config = $config;
$this->request = $request;
$this->phpbb_root_path = $phpbb_root_path;
$this->phpbb_admin_path = $phpbb_admin_path;
$this->php_ext = $phpEx;
if(!function_exists('season_info'))
{
include($this->root_path . 'includes/functions.' . $this->php_ext);
}
if (!defined('FOOTB_SEASONS'))
{
include($this->root_path . 'includes/constants.' . $this->php_ext);
}
}
function main($id, $mode)
{
global $db, $auth, $phpbb_container, $phpbb_admin_path, $league_info;
global $template, $user, $config, $phpbb_extension_manager, $request, $phpbb_root_path, $phpEx;
$helper = $phpbb_container->get('controller.helper');
$this->tpl_name = 'acp_football_seasons';
$this->page_title = 'ACP_FOOTBALL_SEASONS_MANAGE';
$form_key = 'acp_football_seasons';
add_form_key($form_key);
include($phpbb_root_path . 'includes/functions_user.' . $phpEx);
// Check and set some common vars
$action = (isset($_POST['add'])) ? 'add' : $this->request->variable('action', '');
$season = $this->request->variable('s', 0);
$edit = $this->request->variable('edit', 0);
$update = (isset($_POST['update'])) ? true : false;
// Clear some vars
$season_row = array();
$error = array();
// Grab basic data for season, if season is set and exists
if ($season)
{
$sql = 'SELECT *
FROM ' . FOOTB_SEASONS . "
WHERE season = $season";
$result = $db->sql_query($sql);
$season_row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
}
// Which page?
switch ($action)
{
case 'delete':
if (!$season)
{
trigger_error($user->lang['NO_SEASON'] . adm_back_link($this->u_action), E_USER_WARNING);
}
if (confirm_box(true))
{
$error = '';
if (!$auth->acl_get('a_football_delete'))
{
trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING);
}
if ($user->data['user_type'] != USER_FOUNDER && $this->config['football_founder_delete'])
{
trigger_error($user->lang['SEASONS_NO_DELETE'] . adm_back_link($this->u_action), E_USER_WARNING);
}
// Delete season
$sql = 'DELETE FROM ' . FOOTB_SEASONS . "
WHERE season = $season";
$db->sql_query($sql);
// Delete leagues
$sql = 'DELETE FROM ' . FOOTB_LEAGUES . "
WHERE season = $season";
$db->sql_query($sql);
// Delete matchdays
$sql = 'DELETE FROM ' . FOOTB_MATCHDAYS . "
WHERE season = $season";
$db->sql_query($sql);
// Delete matches
$sql = 'DELETE FROM ' . FOOTB_MATCHES . "
WHERE season = $season";
$db->sql_query($sql);
// Delete teams
$sql = 'DELETE FROM ' . FOOTB_TEAMS . "
WHERE season = $season";
$db->sql_query($sql);
// Delete ranks
$sql = 'DELETE FROM ' . FOOTB_RANKS . "
WHERE season = $season";
$db->sql_query($sql);
// Delete bets
$sql = 'DELETE FROM ' . FOOTB_BETS . "
WHERE season = $season";
$db->sql_query($sql);
trigger_error($user->lang['SEASON_DELETED'] . adm_back_link($this->u_action));
}
else
{
confirm_box(false, sprintf($user->lang['SEASON_CONFIRM_DELETE'], $season), build_hidden_fields(array(
's' => $season,
'mode' => $mode,
'action' => $action))
);
}
break;
case 'add':
if ($season >= 1963 AND $season <= 2099)
{
if ($season_row)
{
if ($edit)
{
$error[] = $user->lang['SEASON_TAKEN'];
}
else
{
trigger_error($user->lang['SEASON_TAKEN'] . adm_back_link($this->u_action), E_USER_WARNING);
}
}
$season_row['season_name'] = utf8_normalize_nfc($this->request->variable('season_name', '', true));
if ($season_row['season_name'] <> '')
{
$sql = 'SELECT
season_name
FROM ' . FOOTB_SEASONS . "
WHERE season_name = '" . $season_row['season_name'] . "'";
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
if ($row)
{
$error[] = $user->lang['SEASON_NAME_TAKEN'];
}
}
else
{
$intseason = ((int) $season) - 1;
$season_row['season_name'] = $user->lang['SEASON'] . ' ' . $intseason . '/' . $season;
}
$season_row['season_name_short'] = utf8_normalize_nfc($this->request->variable('season_short', '', true));
if ($season_row['season_name_short'] <> '')
{
$sql = 'SELECT
season_name_short
FROM ' . FOOTB_SEASONS . "
WHERE season_name_short = '" . $season_row['season_name_short'] . "'";
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
if ($row)
{
$error[] = $user->lang['SEASON_SHORT_TAKEN'];
}
}
else
{
$intseason = ((int) $season) - 1;
$season_row['season_name_short'] = $intseason . '/' . $season;
}
}
else
{
trigger_error($user->lang['SEASON_NUMBER'] . adm_back_link($this->u_action), E_USER_WARNING);
}
// No break for edit add
case 'edit':
$data = array();
if (!sizeof($error))
{
if ($action == 'edit' && !$season)
{
trigger_error($user->lang['NO_SEASON'] . adm_back_link($this->u_action), E_USER_WARNING);
}
// Did we submit?
if ($update)
{
if (!check_form_key($form_key))
{
trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING);
return;
}
$season_row['season_name'] = utf8_normalize_nfc($this->request->variable('season_name', '', true));
if ($season_row['season_name'] <> '')
{
$sql = 'SELECT
season
FROM ' . FOOTB_SEASONS . "
WHERE season_name = '" . $season_row['season_name'] . "'";
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
if ($row)
{
if ($row['season'] <> $season)
{
$error[] = $user->lang['SEASON_NAME_TAKEN'];
}
}
}
else
{
$error[] = $user->lang['SEASON_NAME_EMPTY'];
}
$season_row['season_name_short'] = utf8_normalize_nfc($this->request->variable('season_short', '', true));
if ($season_row['season_name_short'] <> '')
{
$sql = 'SELECT
season
FROM ' . FOOTB_SEASONS . "
WHERE season_name_short = '" . $season_row['season_name_short'] . "'";
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
if ($row)
{
if ($row['season'] <> $season)
{
$error[] = $user->lang['SEASON_SHORT_TAKEN'];
}
}
}
else
{
$error[] = $user->lang['SEASON_SHORT_EMPTY'];
}
if (!sizeof($error))
{
$sql_ary = array(
'season' => (int) $season,
'season_name' => $season_row['season_name'],
'season_name_short' => $season_row['season_name_short'],
);
$data['season'] = $season;
$data['season_name'] = $this->request->variable('season_name', '');
$data['season_short'] = $this->request->variable('season_short', '');
$var_ary = array(
'season' => array('num', false, 1963, 2099),
'season_name' => array('string', false, 4, 20),
'season_short' => array('string', false, 2, 10),
);
if (!($error_vals = validate_data($data, $var_ary)))
{
if ($action == 'add')
{
$sql = 'INSERT INTO ' . FOOTB_SEASONS . ' ' . $db->sql_build_array('INSERT', $sql_ary);
$db->sql_query($sql);
}
else
{
$sql = 'UPDATE ' . FOOTB_SEASONS . '
SET ' . $db->sql_build_array('UPDATE', $sql_ary) . "
WHERE season = $season";
$db->sql_query($sql);
}
$message = ($action == 'edit') ? 'SEASON_UPDATED' : 'SEASON_CREATED';
trigger_error($user->lang[$message] . adm_back_link($this->u_action));
}
else
{
foreach ($error_vals as $error_val)
{
$error_msg[] = $user->lang[$error_val];
}
$message = ($action == 'edit') ? 'SEASON_UPDATE_FAILED' : 'SEASON_CREATE_FAILED';
$error[] = $user->lang[$message];
$error = array_merge($error, $error_msg);
}
}
}
}
$u_back = $this->u_action;
$template->assign_vars(array(
'S_EDIT' => true,
'S_ADD_SEASON' => ($action == 'add') ? true : false,
'S_ERROR' => (sizeof($error)) ? true : false,
'ERROR_MSG' => (sizeof($error)) ? implode('<br />', $error) : '',
'SEASON' => $season,
'SEASON_NAME' => $season_row['season_name'],
'SEASON_SHORT' => $season_row['season_name_short'],
'U_BACK' => $u_back,
'U_ACTION' => "{$this->u_action}&amp;action=$action&amp;s=$season",
)
);
return;
break;
}
$template->assign_vars(array(
'U_ACTION' => $this->u_action,
'U_FOOTBALL' => $helper->route('football_main_controller',array('side' => 'bet')),
'S_SEASON_ADD' => true,
)
);
// Get us all the seasons
$sql = 'SELECT
s.season,
s.season_name,
s.season_name_short,
COUNT(l.league) AS leagues
FROM ' . FOOTB_SEASONS . ' s
LEFT JOIN ' . FOOTB_LEAGUES . ' l on l.season = s.season
GROUP BY season
ORDER BY season DESC';
$result = $db->sql_query($sql);
$rows_seasons = $db->sql_fetchrowset($result);
$db->sql_freeresult($result);
// Check if the user is allowed to delete a season.
if ($user->data['user_type'] != USER_FOUNDER && $this->config['football_founder_delete'])
{
$allow_delete = false;
}
else
{
$allow_delete = true;
}
$row_number = 0;
foreach ($rows_seasons as $row_season)
{
$row_number++;
$row_class = (!($row_number % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
$template->assign_block_vars('seasons', array(
'ROW_CLASS' => $row_class,
'SEASON' => $row_season['season'],
'SEASON_NAME' => $row_season['season_name'],
'SEASON_SHORT' => $row_season['season_name_short'],
'LEAGUES' => $row_season['leagues'],
'U_EDIT' => "{$this->u_action}&amp;action=edit&amp;s=" .$row_season['season'],
'U_DELETE' => ($allow_delete) ? "{$this->u_action}&amp;action=delete&amp;s=" . $row_season['season'] : '',
)
);
}
}
}
?>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff