]> git.mxchange.org Git - mailer.git/blobdiff - inc/modules/admin/admin-inc.php
Menu moved to extension, index_delay should not have UNSIGNED
[mailer.git] / inc / modules / admin / admin-inc.php
index ffdab4e9b2be7d23068c1312fe87fe32158bc6c4..66a7223bd4abd1192e01dc9b0a51f277f56943e7 100644 (file)
@@ -228,7 +228,7 @@ function ifAdminCookiesAreValid ($admin, $password) {
        //* DEBUG: */ outputHtml(__FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):".generatePassString($pass).'('.strlen($pass).")/".$password.'('.strlen($password).")<br />");
 
        // Check if password matches
-       if (($ret == 'pass') && ((generatePassString($pass) == $password) || ($pass == $password) || ((strlen($pass) == 32) && (md5($password) == $pass)))) {
+       if (($ret == 'pass') && ((generatePassString($pass) == $password) || ($pass == $password) || ((strlen($pass) == 32) && (md5($password) == $pass))) && (isAdmin())) {
                // Passwords matches!
                $ret = 'done';
        } // END - if
@@ -238,7 +238,10 @@ function ifAdminCookiesAreValid ($admin, $password) {
 }
 
 // Do an admin action
-function doAdminAction ($what) {
+function doAdminAction () {
+       // Get default what
+       $what = getWhat();
+
        //* DEBUG: */ outputHtml(__LINE__."*".$what.'/'.getModule().'/'.getAction().'/'.getWhat()."*<br />");
 
        // Remove any spaces from variable
@@ -269,6 +272,12 @@ function doAdminAction ($what) {
        // Tableset header
        loadTemplate('admin_main_header', false, $content);
 
+       // Is sql_patches not yet installed?
+       if (!isExtensionInstalled('sql_patches')) {
+               // Output warning
+               loadTemplate('admin_settings_saved', false, getMessage('ADMIN_WARNING_SQL_PATCHES_MISSING'));
+       } // END - if
+
        // Check if action/what pair is valid
        $result_action = SQL_QUERY_ESC("SELECT
        `id`
@@ -287,7 +296,8 @@ WHERE
                        )
                )
        )
-LIMIT 1", array($action, $what, $what), __FUNCTION__, __LINE__);
+LIMIT 1",
+               array($action, $what, $what), __FUNCTION__, __LINE__);
        if (SQL_NUMROWS($result_action) == 1) {
                // Is valid but does the inlcude file exists?
                $inc = sprintf("inc/modules/admin/action-%s.php", $action);
@@ -467,7 +477,7 @@ ORDER BY
 }
 
 // Create member selection box
-function addMemberSelectionBox ($def='0', $add_all=false, $return=false, $none=false, $field='userid') {
+function addMemberSelectionBox ($def=0, $add_all=false, $return=false, $none=false, $field='userid') {
        // Output selection form with all confirmed user accounts listed
        $result = SQL_QUERY("SELECT `userid`, `surname`, `family` FROM `{?_MYSQL_PREFIX?}_user_data` ORDER BY `userid` ASC", __FUNCTION__, __LINE__);
 
@@ -511,7 +521,7 @@ function adminMenuSelectionBox_DEPRECATED ($mode, $default = '', $defid = '') {
        if (SQL_NUMROWS($result) > 0) {
                // Load menu as selection
                $OUT = "<select name=\"".$mode."_menu";
-               if ((!empty($defid)) || ($defid == '0')) $OUT .= "[".$defid."]";
+               if ((!empty($defid)) || ($defid == 0)) $OUT .= "[".$defid."]";
                $OUT .= "\" size=\"1\" class=\"admin_select\">
        <option value=\"\">{--SELECT_NONE--}</option>\n";
                // @TODO Try to rewrite this to $content = SQL_FETCHARRAY(). Please look some lines above for the dynamic query
@@ -534,7 +544,7 @@ function adminMenuSelectionBox_DEPRECATED ($mode, $default = '', $defid = '') {
 }
 
 // Wrapper for $_POST and adminSaveSettings
-function adminSaveSettingsFromPostData ($tableName = "_config", $whereStatement = "config=0", $translateComma = array(), $alwaysAdd = false) {
+function adminSaveSettingsFromPostData ($tableName = '_config', $whereStatement = '`config`=0', $translateComma = array(), $alwaysAdd = false) {
        // Get the array
        $postData = postRequestArray();
 
@@ -543,7 +553,7 @@ function adminSaveSettingsFromPostData ($tableName = "_config", $whereStatement
 }
 
 // Save settings to the database
-function adminSaveSettings (&$postData, $tableName = "_config", $whereStatement = "config=0", $translateComma = array(), $alwaysAdd = false) {
+function adminSaveSettings (&$postData, $tableName = '_config', $whereStatement = '`config`=0', $translateComma = array(), $alwaysAdd = false) {
        // Prepare all arrays, variables
        $DATA = array();
        $skip = false;
@@ -556,7 +566,7 @@ function adminSaveSettings (&$postData, $tableName = "_config", $whereStatement
                        convertSelectionsToTimestamp($postData, $DATA, $id, $skip);
 
                        // Shall we process this ID? It muss not be empty, of course
-                       if (($skip === false) && (!empty($id))) {
+                       if (($skip === false) && (!empty($id)) && (!isset($GLOBALS['skip_config'][$id]))) {
                                // Save this entry
                                $val = compileCode($val);
 
@@ -568,7 +578,7 @@ function adminSaveSettings (&$postData, $tableName = "_config", $whereStatement
 
                                // Shall we add numbers or strings?
                                $test = (float)$val;
-                               if ("".$val."" == ''.$test."") {
+                               if ('' . $val . '' == '' . $test . '') {
                                        // Add numbers
                                        $DATA[] = sprintf("`%s`=%s", $id, $test);
                                } else {
@@ -576,6 +586,9 @@ function adminSaveSettings (&$postData, $tableName = "_config", $whereStatement
                                        $DATA[] = sprintf("`%s`='%s'", $id, trim($val));
                                }
 
+                               // Do not add a config entry twice
+                               $GLOBALS['skip_config'][$id] = true;
+
                                // Update current configuration
                                setConfigEntry($id, $val);
                        } // END - if
@@ -594,13 +607,13 @@ function adminSaveSettings (&$postData, $tableName = "_config", $whereStatement
 
        if (SQL_NUMROWS($result) == 1) {
                // "Implode" all data to single string
-               $DATA_UPDATE = implode(", ", $DATA);
+               $DATA_UPDATE = implode(', ', $DATA);
 
                // Generate SQL string
                $sql = sprintf("UPDATE `{?_MYSQL_PREFIX?}%s` SET %s WHERE %s LIMIT 1",
-               $tableName,
-               $DATA_UPDATE,
-               $whereStatement
+                       $tableName,
+                       $DATA_UPDATE,
+                       $whereStatement
                );
        } else {
                // Add Line (does only work with auto_increment!
@@ -612,14 +625,14 @@ function adminSaveSettings (&$postData, $tableName = "_config", $whereStatement
                } // END - foreach
 
                // Add both in one line
-               $KEYs = implode(", ", $KEYs);
-               $values = implode(", ", $values);
+               $KEYs = implode('`, `', $KEYs);
+               $values = implode(', ', $values);
 
                // Generate SQL string
-               $sql = sprintf("INSERT INTO {?_MYSQL_PREFIX?}%s (%s) VALUES (%s)",
-               $tableName,
-               $KEYs,
-               $values
+               $sql = sprintf("INSERT INTO `{?_MYSQL_PREFIX?}%s` (%s) VALUES (%s)",
+                       $tableName,
+                       $KEYs,
+                       $values
                );
        }
 
@@ -677,18 +690,23 @@ function adminAddMenuSelectionBox ($menu, $type, $name, $default = '') {
 
 // Creates a user-profile link for the admin. This function can also be used for many other purposes
 function generateUserProfileLink ($userid, $title = '', $what = 'list_user') {
-       if (($title == '') && ($title != '0')) {
+       if (($title == '') && ($userid > 0)) {
                // Set userid as title
                $title = $userid;
        } // END - if
 
-       if (($title == '0') && ($what == 'list_refs')) {
+       if (($title == 0) && ($what == 'list_refs')) {
                // Return title again
                return $title;
-       } // END - if
+       } elseif (isExtensionActive('nickname')) {
+               // Get nickname
+               $nick = getNickname($userid);
+
+               // Is it not empty, use it as title else the userid
+               if (!empty($nick)) $title = $nick . '(' . $userid . ')'; else $title = $userid;
+       }
 
        // Return link
-       //* DEBUG: */ outputHtml("a:".$title."<br />");
        return '[<a href="{?URL?}/modules.php?module=admin&amp;what=' . $what . '&amp;userid=' . $userid . '" title="{--ADMIN_USER_PROFILE_TITLE--}">' . $title . '</a>]';
 }
 
@@ -1211,7 +1229,7 @@ function doResetAdminPassword ($login, $password) {
        $passHash = '';
 
        // Now check if we have sql_patches installed
-       if (getExtensionVersion('sql_patches') >= '0.3.6') {
+       if (isExtensionInstalledAndNewer('sql_patches', '0.3.6')) {
                // Use new way of hashing
                $passHash = generateHash($password);
        } else {
@@ -1295,31 +1313,5 @@ function adminCreateUserLink ($userid) {
        return '{?URL?}/modules.php?module=admin&amp;what=list_user';
 }
 
-// -----------------------------------------------------------------------------
-// ---                           Filter functions                            ---
-// -----------------------------------------------------------------------------
-
-// Filter for checking admin ACL
-function FILTER_CHECK_ADMIN_ACL () {
-       // Extension not installed so it's always allowed to access everywhere!
-       $ret = true;
-
-       // Ok, Cookie-Update done
-       if ((isExtensionInstalledAndNewer('admins', '0.3.0')) && (isExtensionActive('admins'))) {
-               // Check if action GET variable was set
-               $action = getAction();
-               if (isWhatSet()) {
-                       // Get action value by what-value
-                       $action = getModeAction('admin', getWhat());
-               } // END - if
-
-               // Check for access control line of current menu entry
-               $ret = adminsCheckAdminAcl($action, getWhat());
-       } // END - if
-
-       // Set it here
-       $GLOBALS['acl_allow'] = $ret;
-}
-
 // [EOF]
 ?>