diff --git a/phpBB/adm/admin_styles.php b/phpBB/adm/admin_styles.php index a0519e0ab0..ccad70c00f 100644 --- a/phpBB/adm/admin_styles.php +++ b/phpBB/adm/admin_styles.php @@ -28,19 +28,40 @@ if (!$auth->acl_get('a_styles')) trigger_error($user->lang['NO_ADMIN']); } -// + +// Get and set some vars $mode = (isset($_REQUEST['mode'])) ? htmlspecialchars($_REQUEST['mode']) : ''; -$action = (isset($_REQUEST['action'])) ? htmlspecialchars($_REQUEST['action']) : ''; - - + +if (isset($_REQUEST['action'])) +{ + $action = htmlspecialchars($_REQUEST['action']); +} +else +{ + if (isset($_POST['add'])) + { + $action = 'add'; + } + else if (isset($_POST['preview'])) + { + $action = 'preview'; + } + else + { + $action = ''; + } +} + +$error = array(); +// What shall we do today then? switch ($mode) { case 'styles': - $style_id = (isset($_REQUEST['id'])) ? $_REQUEST['id'] : ''; + $style_id = (isset($_REQUEST['id'])) ? intval($_REQUEST['id']) : ''; switch ($action) { @@ -53,24 +74,103 @@ switch ($mode) $db->sql_query($sql); break; + case 'delete': + break; + + case 'export': + break; + + case 'add': case 'edit': if (isset($_POST['update'])) { + $style_name = (isset($_POST['style_name'])) ? stripslashes(htmlspecialchars($_POST['style_name'])) : ''; + $style_copyright = (isset($_POST['style_copyright'])) ? stripslashes(htmlspecialchars($_POST['style_copyright'])) : ''; + + $style_active = (!empty($_POST['style_active'])) ? 1 : 0; + + $template_id = (!empty($_POST['template_id'])) ? intval($_POST['template_id']) : 0; + $theme_id = (!empty($_POST['theme_id'])) ? intval($_POST['theme_id']) : 0; + $imageset_id = (!empty($_POST['imageset_id'])) ? intval($_POST['imageset_id']) : 0; + + if (empty($style_name)) + { + $error[] = $user->lang['STYLE_ERR_STYLE_NAME']; + } + + if (strlen($style_name) > 30) + { + $error[] = $user->lang['STYLE_ERR_NAME_LONG']; + } + + if (strlen($style_copyright) > 60) + { + $error[] = $user->lang['STYLE_ERR_COPY_LONG']; + } + + if (!$template_id || !$theme_id || !$imageset_id) + { + $error[] = $user->lang['STYLE_ERR_NO_IDS']; + } + + if ($action == 'add') + { + $sql = 'SELECT style_name + FROM ' . STYLES_TABLE . " + WHERE style_name = '" . $db->sql_escape($style_name) . "'"; + $result = $db->sql_query($sql); + + if ($row = $db->sql_fetchrow($result)) + { + $error[] = $user->lang['STYLE_ERR_NAME_EXIST']; + } + $db->sql_freeresult($result); + } + + if (!sizeof($error)) + { + $sql_ary = array( + 'style_name' => $style_name, + 'style_copyright' => $style_copyright, + 'template_id' => $template_id, + 'theme_id' => $theme_id, + 'imageset_id' => $imageset_id, + ); + + $sql = ($action == 'add') ? 'INSERT INTO ' . STYLES_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary) : 'UPDATE ' . STYLES_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . " WHERE style_id = $style_id"; + $db->sql_query($sql); + + $log = ($action == 'add') ? 'LOG_ADD_STYLE' : 'LOG_EDIT_STYLE'; + add_log('admin', $log, addslashes($style_name)); + + $message = ($action == 'add') ? 'STYLED_ADDED' : 'STYLE_EDITED'; + trigger_error($user->lang[$message]); + } } - if ($style_id) + if (!sizeof($error)) { - $sql = 'SELECT * - FROM ' . STYLES_TABLE . " - WHERE style_id = $style_id"; - $result = $db->sql_query($sql); - - if (!extract($db->sql_fetchrow($result))) + if ($style_id) { - die("ERROR"); + $sql = 'SELECT * + FROM ' . STYLES_TABLE . " + WHERE style_id = $style_id"; + $result = $db->sql_query($sql); + + if (!extract($db->sql_fetchrow($result))) + { + die("ERROR"); + } + $db->sql_freeresult($result); + } + else + { + $style_name = (isset($_POST['style_name'])) ? stripslashes(htmlspecialchars($_POST['style_name'])) : ''; + $style_copyright = ''; + $style_active = 1; + $template_id = $theme_id = $imageset_id = 0; } - $db->sql_freeresult($result); } $style_options = array(); @@ -81,6 +181,7 @@ switch ($mode) FROM $table ORDER BY {$field}_id"; $result = $db->sql_query($sql); + while ($row = $db->sql_fetchrow($result)) { $selected = ($row[$field . '_id'] == ${$field . '_id'}) ? ' selected="selected"' : ''; @@ -103,15 +204,29 @@ switch ($mode) Edit Style + + + ', $error); ?> + + Style Name - + Style Copyright ' . $style_copyright . '' : ''; + echo ($action == 'edit') ? '' . $style_copyright . '' : ''; ?> @@ -132,7 +247,7 @@ switch ($mode) /> Inactive   /> Active -      +    @@ -140,16 +255,9 @@ switch ($mode) adm_page_footer(); break; - - case 'delete': - break; - - case 'export': - break; } - - + adm_page_header($user->lang['MANAGE_STYLE']); ?> @@ -210,7 +318,7 @@ switch ($mode) ?> - Create new style: + Create new style: 'Deleted forum, its messages and subforums
» %s', 'LOG_FORUM_DEL_MOVE_POSTS_MOVE_FORUMS' => 'Deleted forum, moved posts to %s and subforums to %s
» %s', - 'LOG_EDIT_THEME' => 'Edited theme
» %s', + 'LOG_EDIT_THEME' => 'Edited theme
» %s', + 'LOG_ADD_STYLE' => 'Added new style
» %s', + 'LOG_EDIT_STYLE' => 'Edited style
» %s', 'WELCOME_PHPBB' => 'Welcome to phpBB', @@ -895,12 +897,20 @@ $lang = array_merge($lang, array( 'Disallowed_already' => 'The name you entered could not be disallowed. It either already exists in the list, exists in the word censor list, or a matching username is present', - 'MANAGE_STYLE_EXPLAIN' => 'Here you can manage the available styles on your board. A style consists off a template, theme and imageset. You may alter existing styles, delete, deactivate, reactivate, create or import new ones. You can also see what a style will look like using the preview function. The current default style is noted by the presence of an asterix, * Also listed is the total user count for each style, note that overriding user styles will not be reflected here.', 'STYLE_ACTIVATE' => 'Activate', 'STYLE_DEACTIVATE' => 'Deactivate', 'EDIT_STYLE' => 'Edit Style', 'EDIT_STYLE_EXPLAIN' => 'Using the form below you can modify this existing style. You may alter the combination of template, theme and imageset which define the style itself. You may also deactivate the style and alter its name.', + 'STYLE_ADDED' => 'Style added successfully', + 'STYLE_EDITED' => 'Style edited successfully', + + 'STYLE_ERR_STYLE_NAME' => 'You must supply a name for this style', + 'STYLE_ERR_NAME_LONG' => 'The style name can be no longer than 30 characters', + 'STYLE_ERR_NAME_EXIST' => 'A style with that name already exists', + 'STYLE_ERR_COPY_LONG' => 'The copyright can be no longer than 60 characters', + 'STYLE_ERR_NO_IDS' => 'You must select a template, theme and imageset for this style', + 'MANAGE_TEMPLATE_EXPLAIN' => 'A Template set comprises all the markup used to generate the layout of your board. Here you can edit existing template sets, delete, export, import and preview sets. You can also modify the templating code used to generate BBCode.', 'EDIT_TEMPLATE' => 'Edit Template',