<?php
/************************************************************************
- * MXChange v0.2.1 Start: 08/27/2004 *
- * ================ Last change: 08/27/2004 *
+ * Mailer v0.2.1-FINAL Start: 08/27/2004 *
+ * =================== Last change: 08/27/2004 *
* *
* -------------------------------------------------------------------- *
* File : what-config_mods.php *
* -------------------------------------------------------------------- *
* Kurzbeschreibung : Modul-Konfiguration *
* -------------------------------------------------------------------- *
- * *
+ * $Revision:: $ *
+ * $Date:: $ *
+ * $Tag:: 0.2.1-FINAL $ *
+ * $Author:: $ *
* -------------------------------------------------------------------- *
- * Copyright (c) 2003 - 2008 by Roland Haeder *
- * For more information visit: http://www.mxchange.org *
+ * Copyright (c) 2003 - 2009 by Roland Haeder *
+ * Copyright (c) 2009 - 2011 by Mailer Developer Team *
+ * For more information visit: http://mxchange.org *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
************************************************************************/
// Some security stuff...
-if ((!defined('__SECURITY')) || (!IS_ADMIN())) {
- $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
- require($INC);
-}
+if ((!defined('__SECURITY')) || (!isAdmin())) {
+ die();
+} // END - if
// Add description as navigation point
-ADD_DESCR("admin", basename(__FILE__));
+addYouAreHereLink('admin', __FILE__);
-$SEL = 0;
-if (isset($_POST['edit']))
-{
+if (isFormSent('edit')) {
// Check if at least one module is selected
- $SEL = SELECTION_COUNT($_POST['sel']);
- if ($SEL > 0)
- {
+ if (ifPostContainsSelections()) {
// Output header
- $OUT = ""; $SW = 2;
+ $OUT = '';
// Edit selected modules
- foreach ($_POST['sel'] as $id => $sel)
- {
+ foreach (postRequestElement('sel') as $id => $sel) {
// Load module data
- $result = SQL_QUERY_ESC("SELECT module, title, locked, hidden, admin_only, mem_only FROM "._MYSQL_PREFIX."_mod_reg WHERE id=%s LIMIT 1",
- array(bigintval($id)), __FILE__, __LINE__);
- list($mod, $title, $locked, $hidden, $admin, $mem) = SQL_FETCHROW($result);
+ // @TODO This can be moved into mysql-function.php, see checkModulePermissions() function
+ $result = SQL_QUERY_ESC("SELECT `id`,`module`,`title`,`locked`,`hidden`,`admin_only`,`mem_only` FROM `{?_MYSQL_PREFIX?}_mod_reg` WHERE `id`=%s LIMIT 1",
+ array(bigintval($id)), __FILE__, __LINE__);
+
+ // Load data
+ $content = SQL_FETCHARRAY($result);
+
+ // Free result
SQL_FREERESULT($result);
// Prepare array for the template
- $content = array(
- 'sw' => $SW,
- 'mod' => $mod,
- 'id' => $id,
- 'title' => $title,
- 'locked' => ADD_SELECTION("yn", $locked, "locked", $id),
- 'hidden' => ADD_SELECTION("yn", $hidden, "hidden", $id),
- 'admin' => ADD_SELECTION("yn", $admin , "admin" , $id),
- 'mem' => ADD_SELECTION("yn", $mem , "member", $id),
- );
+ $content['locked'] = addSelectionBox('yn', $content['locked'] , 'locked', $id);
+ $content['hidden'] = addSelectionBox('yn', $content['hidden'] , 'hidden', $id);
+ $content['admin_only'] = addSelectionBox('yn', $content['admin_only'], 'admin' , $id);
+ $content['mem_only'] = addSelectionBox('yn', $content['mem_only'] , 'member', $id);
// Load row template
- $OUT .= LOAD_TEMPLATE("admin_mods_edit_row", true, $content);
- }
- define('__MODS_ROWS', $OUT);
+ $OUT .= loadTemplate('admin_edit_mods_row', true, $content);
+ } // END - foreach
// Load main template
- LOAD_TEMPLATE("admin_mods_edit");
- }
- else
- {
+ loadTemplate('admin_edit_mods', false, $OUT);
+ } else {
// Nothing selected
- LOAD_TEMPLATE("admin_settings_saved", false, MODS_NOTHING_SELECTED);
- OUTPUT_HTML("<br />");
+ displayMessage('{--ADMIN_MODS_NOTHING_SELECTED--}');
// Remove maybe confusing data
- unset($_POST['edit']);
- unset($_POST['change']);
+ unsetPostRequestElement('edit');
+ unsetPostRequestElement('do_edit');
}
-}
- elseif (isset($_POST['change']))
-{
+} elseif (isFormSent('do_edit')) {
+ // Init SQLs
+ initSqls();
+
// Change modules
- foreach ($_POST['sel'] as $id => $sel)
- {
- // Secure ID number
+ foreach (postRequestElement('sel') as $id => $sel) {
+ // Secure id number
$id = bigintval($id);
// Update module
- $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_mod_reg SET title='%s', locked='%s', hidden='%s', admin_only='%s', mem_only='%s' WHERE id=%s LIMIT 1",
- array($_POST['title'][$id], $_POST['locked'][$id], $_POST['hidden'][$id], $_POST['admin'][$id], $_POST['member'][$id], $id), __FILE__, __LINE__);
+ addSql(SQL_QUERY_ESC("UPDATE
+ `{?_MYSQL_PREFIX?}_mod_reg`
+SET
+ `title`='%s',
+ `locked`='%s',
+ `hidden`='%s',
+ `admin_only`='%s',
+ `mem_only`='%s'
+WHERE
+ `id`=%s
+LIMIT 1",
+ array(
+ postRequestElement('title', $id),
+ postRequestElement('locked', $id),
+ postRequestElement('hidden', $id),
+ postRequestElement('admin', $id),
+ postRequestElement('member', $id),
+ $id
+ ), __FILE__, __LINE__, false));
}
+ // Run all sqls
+ runFilterChain('run_sqls');
+
// Remove cache file if version matches
- if (GET_EXT_VERSION("cache") >= "0.1.2")
- {
- if ($cacheInstance->cache_file("mod_reg", true)) $cacheInstance->cache_destroy();
- }
+ if (isExtensionInstalledAndNewer('cache', '0.1.2')) {
+ if ($GLOBALS['cache_instance']->loadCacheFile('modules')) $GLOBALS['cache_instance']->removeCacheFile();
+ } // END - if
// Entries updated
- LOAD_TEMPLATE("admin_settings_saved", false, MODS_CHANGED);
- OUTPUT_HTML("<br />");
+ displayMessage('{--ADMIN_MODS_CHANGED--}');
}
-if ($SEL == 0)
-{
+if (!ifPostContainsSelections()) {
// Load module data (We do not need to check if there's at least one...)
- $result = SQL_QUERY("SELECT id, module, locked, hidden, admin_only, title, mem_only, clicks
-FROM "._MYSQL_PREFIX."_mod_reg
-ORDER BY module", __FILE__, __LINE__);
- $OUT = ""; $SW = 2;
- while (list($id, $mod, $locked, $hidden, $admin, $title, $mem) = SQL_FETCHROW($result))
- {
+ $result = SQL_QUERY('SELECT
+ `id`,`module`,`locked`,`hidden`,`admin_only`,`title`,`mem_only`
+FROM
+ `{?_MYSQL_PREFIX?}_mod_reg`
+ORDER BY
+ `module` ASC', __FILE__, __LINE__);
+
+ $OUT = '';
+ while ($content = SQL_FETCHARRAY($result)) {
// Reset title to --- if it is NULL
- if (empty($title)) $title = "---";
- if (($mod == "index") || ($mod == "login"))
- {
+ if (($content['module'] == 'index') || ($content['module'] == 'login')) {
// Add link to detail statistics
- $mod = "<STRONG><A href=\"".URL."/modules.php?module=admin&what=stats_mods&mod=".$mod."\">".$mod."</A></STRONG>";
- }
-
- // Prepare array for the template
- $content = array(
- 'sw' => $SW,
- 'id' => $id,
- 'mod' => $mod,
- 'title' => $title,
- 'locked' => TRANSLATE_YESNO($locked),
- 'hidden' => TRANSLATE_YESNO($hidden),
- 'admin' => TRANSLATE_YESNO($admin),
- 'mem' => TRANSLATE_YESNO($mem),
- );
+ $content['module'] = '<strong><a href="{%url=modules.php?module=admin&what=stats_mods&mod=' . $content['module'] . '%}">' . $content['module'] . '</a></strong>';
+ } // END - if
// Load row template
- $OUT .= LOAD_TEMPLATE("admin_mods_list_row", true, $content);
-
- // Switch colors
- $SW = 3 - $SW;
- }
+ $OUT .= loadTemplate('admin_list_mods_row', true, $content);
+ } // END - while
// Free memory
SQL_FREERESULT($result);
- define('__MODS_ROWS', $OUT);
// Load main template
- LOAD_TEMPLATE("admin_mods_list");
-}
+ loadTemplate('admin_list_mods', false, $OUT);
+} // END - if
-//
+// [EOF]
?>