Save module settings even if module image can't be found

This commit is contained in:
Marc Alexander
2012-08-11 17:28:41 +02:00
parent eb5f1f8156
commit c4026c9066
5 changed files with 44 additions and 7 deletions

View File

@@ -166,6 +166,7 @@ class acp_portal
{
if (confirm_box(true))
{
// @todo: handle possible error if selected module_id doesn't exist
$sql_ary = array(
'module_name' => $c_class->name,
'module_image_src' => $c_class->image_src,
@@ -244,6 +245,7 @@ class acp_portal
{
$module_permission = request_var('permission-setting', array(0 => ''));
$groups_ary = array();
$img_error = '';
// get groups and check if the selected groups actually exist
$sql = 'SELECT group_id
@@ -274,7 +276,7 @@ class acp_portal
}
// check if module image file actually exists
check_file_src($sql_ary['module_image_src'], '', $module_id);
$img_error = check_file_src($sql_ary['module_image_src'], '', $module_id, false);
$sql = 'UPDATE ' . PORTAL_MODULES_TABLE . '
SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
@@ -285,13 +287,13 @@ class acp_portal
$cache->destroy('sql', CONFIG_TABLE);
if(isset($module_name))
{
add_log('admin', 'LOG_PORTAL_CONFIG',$module_name);
add_log('admin', 'LOG_PORTAL_CONFIG', $module_name);
}
else
{
add_log('admin', 'LOG_PORTAL_CONFIG', $user->lang['ACP_PORTAL_' . strtoupper($mode) . '_INFO']);
}
trigger_error($user->lang['CONFIG_UPDATED'] . adm_back_link(($module_id) ? append_sid("{$phpbb_root_path}adm/index.$phpEx", 'i=portal&mode=modules') : $this->u_action));
trigger_error($user->lang['CONFIG_UPDATED'] . ((!empty($img_error) ? '<br /><br />' . $user->lang['MODULE_IMAGE_ERROR'] . '<br />' . $img_error : '')) . adm_back_link(($module_id) ? append_sid("{$phpbb_root_path}adm/index.$phpEx", 'i=portal&amp;mode=modules') : $this->u_action));
}
// show custom HTML files on the settings page of the modules instead of the standard board3 portal one, if chosen by module
@@ -488,6 +490,10 @@ class acp_portal
{
$move_action = 2; // we move 2 columns to the right
}
else
{
// @todo: need an error handle here
}
/**
* moving only 1 column to the right means we will either end up in the right column
@@ -590,6 +596,10 @@ class acp_portal
{
$move_action = 2; // we move 2 columns to the left
}
else
{
// @todo: need an error handle here (i.e. trigger_error())
}
/**
* moving only 1 column to the left means we will either end up in the left column
@@ -816,7 +826,7 @@ class acp_portal
$error_output = $cur_error . '<br />';
}
}
else if($error != false)
else
{
$error_output = $error;
}

View File

@@ -73,6 +73,7 @@ $lang = array_merge($lang, array(
'MODULE_RESET_EXP' => 'Dies wird alle Einstellungen des Moduls auf die Standardeinstellungen zurücksetzen!',
'MODULE_STATUS' => 'Aktiviere Modul',
'MODULE_ADD_ONCE' => 'Diese Modul kann nur ein Mal hinzugefügt werden.',
'MODULE_IMAGE_ERROR' => 'Während dem Prüfen des Modul Bildes sind ein oder mehrere Fehler aufgetreten:',
// general
'ACP_PORTAL' => 'Portal',

View File

@@ -72,6 +72,7 @@ $lang = array_merge($lang, array(
'MODULE_RESET_EXP' => 'This will reset all settings to the default!',
'MODULE_STATUS' => 'Enable module',
'MODULE_ADD_ONCE' => 'This module can only be added once.',
'MODULE_IMAGE_ERROR' => 'There was an error while checking for the module image:',
// general
'ACP_PORTAL' => 'Portal',

View File

@@ -100,7 +100,7 @@ function phpbb_fetch_posts($module_id, $forum_from, $permissions, $number_of_pos
{
global $db, $phpbb_root_path, $auth, $user, $bbcode_bitfield, $bbcode, $portal_config, $config;
$posts = array();
$posts = $update_count = array();
$post_time = ($time == 0) ? '' : 'AND t.topic_time > ' . (time() - $time * 86400);
$forum_from = (strpos($forum_from, ',') !== FALSE) ? explode(',', $forum_from) : (($forum_from != '') ? array($forum_from) : array());
$str_where = '';
@@ -174,6 +174,11 @@ function phpbb_fetch_posts($module_id, $forum_from, $permissions, $number_of_pos
$post_link = ($config['board3_news_style_' . $module_id]) ? 't.topic_first_post_id = p.post_id' : (($config['board3_news_show_last_' . $module_id]) ? 't.topic_last_post_id = p.post_id' : 't.topic_first_post_id = p.post_id' ) ;
$topic_order = ($config['board3_news_show_last_' . $module_id]) ? 't.topic_last_post_time DESC' : 't.topic_time DESC' ;
break;
default:
$topic_type = $str_where = $user_link = $post_link = '';
$topic_order = 't.topic_time DESC';
// maybe use trigger_error here, as this shouldn't happen
}
if ($type == 'announcements' && $global_f < 1)
@@ -440,6 +445,11 @@ function generate_portal_pagination($base_url, $num_items, $per_page, $start_ite
$pagination_type = 'np';
$anker = '#n';
break;
default:
// this shouldn't happend @todo: use trigger_error()
$pagination_type = 'ap';
$anker = '#a';
}
// Make sure $per_page is a valid value
@@ -631,11 +641,13 @@ function get_portal_tracking_info($fetch_news)
}
$db->sql_freeresult($result);
// @todo: do not use $current_forum here as this is already used by the outside foreach
foreach($forum_ids as $current_forum)
{
$user_lastmark[$current_forum] = (isset($mark_time[$current_forum])) ? $mark_time[$current_forum] : $user->data['user_lastmark'];
}
// @todo: also check if $user_lastmark has been defined for this specific forum_id
foreach ($topic_ids as $topic_id)
{
$last_read[$topic_id] = (!isset($last_read[$topic_id]) || $user_lastmark[$rev_forum_ids[$topic_id]] > $last_read[$topic_id]) ? $user_lastmark[$rev_forum_ids[$topic_id]] : $last_read[$topic_id];
@@ -821,7 +833,7 @@ function board3_basic_install($mode = 'install', $purge_modules = true, $u_actio
/**
* check if the entered source file actually exists
*/
function check_file_src($value, $key, $module_id)
function check_file_src($value, $key, $module_id, $force_error = true)
{
global $db, $phpbb_root_path, $phpEx, $user;
@@ -845,7 +857,18 @@ function check_file_src($value, $key, $module_id)
$db->sql_freeresult($result);
if (!empty($error))
{
if ($force_error)
{
trigger_error($error . adm_back_link(append_sid("{$phpbb_root_path}adm/index.$phpEx", 'i=portal&amp;mode=config&amp;module_id=' . $module_id)), E_USER_WARNING );
}
else
{
return $error;
}
}
else
{
return false;
}
}

View File

@@ -26,6 +26,8 @@ function column_num_string($column)
return 'top';
case 5:
return 'bottom';
default:
return 0;
}
}