Added feature to reset module settings;

Fixed bug causing undefined errors on portal ACP page;
This commit is contained in:
Marc Alexander
2011-02-02 10:35:42 +00:00
parent 057821cba1
commit a7ac48f337
9 changed files with 94 additions and 20 deletions

View File

@@ -117,6 +117,10 @@
<dd><input id="module_img_height" type="text" value="{MODULE_IMAGE_HEIGHT}" name="module_img_height" maxlength="3" size="3" />px</dd>
</dl>
<!-- ENDIF -->
<dl>
<dt><label for="module_reset">{L_MODULE_RESET}:</label><br /><span style="color: #BC2A4D;">{L_MODULE_RESET_EXP}</span></dt>
<dd><input id="module_reset" type="checkbox" value="1" name="module_reset" /></dd>
</dl>
<!-- IF permission_setting -->
<dl>
<dt><label for="permission-setting">{L_MODULE_PERMISSIONS}:</label><br /><span>{L_MODULE_PERMISSIONS_EXP}</span></dt>

View File

@@ -63,6 +63,10 @@
<dd><input id="module_img_height" type="text" value="{MODULE_IMAGE_HEIGHT}" name="module_img_height" maxlength="3" size="3" />px</dd>
</dl>
<!-- ENDIF -->
<dl>
<dt><label for="module_reset">{L_MODULE_RESET}:</label><br /><span style="color: #BC2A4D;">{L_MODULE_RESET_EXP}</span></dt>
<dd><input id="module_reset" type="checkbox" value="1" name="module_reset" /></dd>
</dl>
<!-- IF permission_setting -->
<dl>
<dt><label for="permission-setting">{L_MODULE_PERMISSIONS}:</label><br /><span>{L_MODULE_PERMISSIONS_EXP}</span></dt>

View File

@@ -35,6 +35,10 @@
<dd><input id="module_img_height" type="text" value="{MODULE_IMAGE_HEIGHT}" name="module_img_height" maxlength="3" size="3" />px</dd>
</dl>
<!-- ENDIF -->
<dl>
<dt><label for="module_reset">{L_MODULE_RESET}:</label><br /><span style="color: #BC2A4D;">{L_MODULE_RESET_EXP}</span></dt>
<dd><input id="module_reset" type="checkbox" value="1" name="module_reset" /></dd>
</dl>
<!-- IF permission_setting -->
<dl>
<dt><label for="permission-setting">{L_ACP_PORTAL_CUSTOM_PERMISSION}:</label><br /><span>{L_ACP_PORTAL_CUSTOM_PERMISSION_EXP}</span></dt>

View File

@@ -86,6 +86,10 @@
<dd><input id="module_img_height" type="text" value="{MODULE_IMAGE_HEIGHT}" name="module_img_height" maxlength="3" size="3" />px</dd>
</dl>
<!-- ENDIF -->
<dl>
<dt><label for="module_reset">{L_MODULE_RESET}:</label><br /><span style="color: #BC2A4D;">{L_MODULE_RESET_EXP}</span></dt>
<dd><input id="module_reset" type="checkbox" value="1" name="module_reset" /></dd>
</dl>
<!-- IF permission_setting -->
<dl>
<dt><label for="permission-setting">{L_MODULE_PERMISSIONS}:</label><br /><span>{L_MODULE_PERMISSIONS_EXP}</span></dt>

View File

@@ -93,6 +93,10 @@
<dd><input id="module_img_height" type="text" value="{MODULE_IMAGE_HEIGHT}" name="module_img_height" maxlength="3" size="3" />px</dd>
</dl>
<!-- ENDIF -->
<dl>
<dt><label for="module_reset">{L_MODULE_RESET}:</label><br /><span style="color: #BC2A4D;">{L_MODULE_RESET_EXP}</span></dt>
<dd><input id="module_reset" type="checkbox" value="1" name="module_reset" /></dd>
</dl>
<!-- IF permission_setting -->
<dl>
<dt><label for="permission-setting">{L_MODULE_PERMISSIONS}:</label><br /><span>{L_MODULE_PERMISSIONS_EXP}</span></dt>

View File

@@ -35,6 +35,10 @@
<dd><input id="module_img_height" type="text" value="{MODULE_IMAGE_HEIGHT}" name="module_img_height" maxlength="3" size="3" />px</dd>
</dl>
<!-- ENDIF -->
<dl>
<dt><label for="module_reset">{L_MODULE_RESET}:</label><br /><span style="color: #BC2A4D;">{L_MODULE_RESET_EXP}</span></dt>
<dd><input id="module_reset" type="checkbox" value="1" name="module_reset" /></dd>
</dl>
<!-- IF permission_setting -->
<dl>
<dt><label for="permission-setting">{L_MODULE_PERMISSIONS}:</label><br /><span>{L_MODULE_PERMISSIONS_EXP}</span></dt>

View File

@@ -78,7 +78,7 @@ class acp_portal
{
$sql = 'SELECT *
FROM ' . PORTAL_MODULES_TABLE . '
WHERE module_id = ' . $module_id;
WHERE module_id = ' . (int) $module_id;
$result = $db->sql_query_limit($sql, 1);
$module_data = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
@@ -156,10 +156,52 @@ class acp_portal
$submit = false;
}
// Reset module
$reset_module = request_var('module_reset', 0);
if($reset_module)
{
if (confirm_box(true))
{
$sql_ary = array(
'module_name' => $c_class->name,
'module_image_src' => $c_class->image_src,
'module_group_ids' => '',
'module_image_height' => 16,
'module_image_width' => 16,
);
$sql = 'UPDATE ' . PORTAL_MODULES_TABLE . '
SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
WHERE module_id = ' . (int) $module_id;
$db->sql_query($sql);
$cache->destroy('config');
$cache->destroy('portal_config');
$portal_config = obtain_portal_config(); // we need to prevent duplicate entry errors
$c_class->install($module_id);
$cache->purge();
// We need to return to the module config
meta_refresh(3, reapply_sid($this->u_action . "&amp;module_id=$module_id"));
trigger_error($user->lang['MODULE_RESET_SUCCESS'] . adm_back_link($this->u_action . "&amp;module_id=$module_id"));
}
else
{
$confirm_text = (isset($user->lang[$module_data['module_name']])) ? sprintf($user->lang['MODULE_RESET_CONFIRM'], $user->lang[$module_data['module_name']]) : sprintf($user->lang['DELETE_MODULE_CONFIRM'], utf8_normalize_nfc($module_data['module_name']));
confirm_box(false, $confirm_text, build_hidden_fields(array(
'i' => $id,
'mode' => $mode,
'module_reset' => true,
'module_id' => $module_id,
)));
}
}
// 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 $config_name => $null)
{
if ($submit && ($null['type'] == 'custom' || $null['submit_type'] == 'custom'))
if ($submit && ($null['type'] == 'custom' || (isset($null['submit_type']) && $null['submit_type'] == 'custom')))
{
$func = array($c_class, $null['submit']);
@@ -227,7 +269,7 @@ class acp_portal
$sql = 'UPDATE ' . PORTAL_MODULES_TABLE . '
SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
WHERE module_id = ' . $module_id;
WHERE module_id = ' . (int) $module_id;
$db->sql_query($sql);
$cache->destroy('portal_modules');
@@ -325,7 +367,7 @@ class acp_portal
{
$sql = 'SELECT module_order, module_column
FROM ' . PORTAL_MODULES_TABLE . '
WHERE module_id = ' . $module_id;
WHERE module_id = ' . (int) $module_id;
$result = $db->sql_query_limit($sql, 1);
$module_data = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
@@ -342,7 +384,7 @@ class acp_portal
{
$sql = 'UPDATE ' . PORTAL_MODULES_TABLE . '
SET module_order = module_order - 1
WHERE module_id = ' . $module_id;
WHERE module_id = ' . (int) $module_id;
$db->sql_query($sql);
}
}
@@ -353,7 +395,7 @@ class acp_portal
{
$sql = 'SELECT module_order, module_column
FROM ' . PORTAL_MODULES_TABLE . '
WHERE module_id = ' . $module_id;
WHERE module_id = ' . (int) $module_id;
$result = $db->sql_query_limit($sql, 1);
$module_data = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
@@ -370,7 +412,7 @@ class acp_portal
{
$sql = 'UPDATE ' . PORTAL_MODULES_TABLE . '
SET module_order = module_order + 1
WHERE module_id = ' . $module_id;
WHERE module_id = ' . (int) $module_id;
$db->sql_query($sql);
}
}
@@ -381,7 +423,7 @@ class acp_portal
{
$sql = 'SELECT module_order, module_column, module_classname
FROM ' . PORTAL_MODULES_TABLE . '
WHERE module_id = ' . $module_id;
WHERE module_id = ' . (int) $module_id;
$result = $db->sql_query_limit($sql, 1);
$module_data = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
@@ -410,7 +452,7 @@ class acp_portal
$sql = 'UPDATE ' . PORTAL_MODULES_TABLE . '
SET module_column = module_column + 1
WHERE module_id = ' . $module_id;
WHERE module_id = ' . (int) $module_id;
$db->sql_query($sql);
$sql = 'UPDATE ' . PORTAL_MODULES_TABLE . '
@@ -430,7 +472,7 @@ class acp_portal
$sql = 'UPDATE ' . PORTAL_MODULES_TABLE . '
SET module_order = ' . $new_order . '
WHERE module_id = ' . $module_id;
WHERE module_id = ' . (int) $module_id;
$db->sql_query($sql);
}
}
@@ -448,7 +490,7 @@ class acp_portal
$sql = 'UPDATE ' . PORTAL_MODULES_TABLE . '
SET module_column = module_column + 2
WHERE module_id = ' . $module_id;
WHERE module_id = ' . (int) $module_id;
$db->sql_query($sql);
$sql = 'UPDATE ' . PORTAL_MODULES_TABLE . '
@@ -468,7 +510,7 @@ class acp_portal
$sql = 'UPDATE ' . PORTAL_MODULES_TABLE . '
SET module_order = ' . $new_order . '
WHERE module_id = ' . $module_id;
WHERE module_id = ' . (int) $module_id;
$db->sql_query($sql);
}
@@ -485,7 +527,7 @@ class acp_portal
{
$sql = 'SELECT module_order, module_column, module_classname
FROM ' . PORTAL_MODULES_TABLE . '
WHERE module_id = ' . $module_id;
WHERE module_id = ' . (int) $module_id;
$result = $db->sql_query_limit($sql, 1);
$module_data = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
@@ -514,7 +556,7 @@ class acp_portal
$sql = 'UPDATE ' . PORTAL_MODULES_TABLE . '
SET module_column = module_column - 1
WHERE module_id = ' . $module_id;
WHERE module_id = ' . (int) $module_id;
$db->sql_query($sql);
$sql = 'UPDATE ' . PORTAL_MODULES_TABLE . '
@@ -534,7 +576,7 @@ class acp_portal
$sql = 'UPDATE ' . PORTAL_MODULES_TABLE . '
SET module_order = ' . $new_order . '
WHERE module_id = ' . $module_id;
WHERE module_id = ' . (int) $module_id;
$db->sql_query($sql);
}
}
@@ -552,7 +594,7 @@ class acp_portal
$sql = 'UPDATE ' . PORTAL_MODULES_TABLE . '
SET module_column = module_column - 2
WHERE module_id = ' . $module_id;
WHERE module_id = ' . (int) $module_id;
$db->sql_query($sql);
$sql = 'UPDATE ' . PORTAL_MODULES_TABLE . '
@@ -572,7 +614,7 @@ class acp_portal
$sql = 'UPDATE ' . PORTAL_MODULES_TABLE . '
SET module_order = ' . $new_order . '
WHERE module_id = ' . $module_id;
WHERE module_id = ' . (int) $module_id;
$db->sql_query($sql);
}
}
@@ -588,7 +630,7 @@ class acp_portal
{
$sql = 'SELECT *
FROM ' . PORTAL_MODULES_TABLE . '
WHERE module_id = ' . $module_id;
WHERE module_id = ' . (int) $module_id;
$result = $db->sql_query_limit($sql, 1);
$module_data = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
@@ -614,7 +656,7 @@ class acp_portal
$c_class->uninstall($module_data['module_id']);
$sql = 'DELETE FROM ' . PORTAL_MODULES_TABLE . '
WHERE module_id = ' . $module_id;
WHERE module_id = ' . (int) $module_id;
$db->sql_query($sql);
$sql = 'UPDATE ' . PORTAL_MODULES_TABLE . '

View File

@@ -55,6 +55,8 @@ $lang = array_merge($lang, array(
'B3P_FILE_NOT_FOUND' => 'Die angegebene Datei konnte nicht gefunden werden',
'UNABLE_TO_MOVE' => 'Es ist nicht möglich den Block in die gewählte Spalte zu verschieben.',
'DELETE_MODULE_CONFIRM' => 'Bist du sicher, dass du das Module "%1$s" löschen möchtest?',
'MODULE_RESET_SUCCESS' => 'Modul Einstellungen erfolgreich zurückgesetzt.',
'MODULE_RESET_CONFIRM' => 'Bist du sicher, dass du die Einstellungen des Moduls "%1$s" zurücksetzen willst?',
'MODULE_OPTIONS' => 'Modul Optionen',
'MODULE_NAME' => 'Modul Name',
@@ -63,7 +65,9 @@ $lang = array_merge($lang, array(
'MODULE_IMAGE_EXP' => 'Gebe den Dateinamen des Modul Bildes ein. Bilder müssen sich in styles/*yourstyle*/theme/images/portal/ befinden.',
'MODULE_PERMISSIONS' => 'Modul Berechtigungen',
'MODULE_PERMISSIONS_EXP' => 'Wähle die Gruppen aus, die berechtigt sein sollen, das Modul zu sehen. Sollen alle Benutzer das Modul sehen können, wähle nichts aus.<br />An- / abwählen mehrerer Gruppen indem man <samp>Strg</samp> gedrückt hält und klickt.',
'MODULE_RESET' => 'Modul Einstellungen zurücksetzen',
'MODULE_RESET_EXP' => 'Dies wird alle Einstellungen des Moduls auf die Standardeinstellungen zurücksetzen!',
// general
'ACP_PORTAL' => 'Portal',
'ACP_PORTAL_GENERAL_INFO' => 'Allgemeine Einstellungen',

View File

@@ -54,6 +54,8 @@ $lang = array_merge($lang, array(
'B3P_FILE_NOT_FOUND' => 'The requested file could not be found',
'UNABLE_TO_MOVE' => 'It is not possible to move the block to the selected column.',
'DELETE_MODULE_CONFIRM' => 'Are you sure you wish to delete the module "%1$s"?',
'MODULE_RESET_SUCCESS' => 'Successfully reset the module settings.',
'MODULE_RESET_CONFIRM' => 'Are you sure you wish to reset the settings of the module "%1$s"?',
'MODULE_OPTIONS' => 'Module options',
'MODULE_NAME' => 'Module name',
@@ -66,6 +68,8 @@ $lang = array_merge($lang, array(
'MODULE_IMAGE_WIDTH_EXP' => 'Enter the width of the module image in pixels',
'MODULE_IMAGE_HEIGHT' => 'Module image height',
'MODULE_IMAGE_HEIGHT_EXP' => 'Enter the height of the module image in pixels',
'MODULE_RESET' => 'Reset module configuration',
'MODULE_RESET_EXP' => 'This will reset all settings to the default!',
// general
'ACP_PORTAL' => 'Portal',