X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Fmodules%2Fadmin%2Fadmin-inc.php;h=57a889db6c197ca5ad162709d20716beac2a32eb;hb=dcc3ad7ebb9a1b9c6cf9122785301a0a18e42157;hp=86c378e821b6e9723b28531ab24459336ea6e689;hpb=74a607e3879faefdc2ca152605cb533806b98e83;p=mailer.git diff --git a/inc/modules/admin/admin-inc.php b/inc/modules/admin/admin-inc.php index 86c378e821..57a889db6c 100644 --- a/inc/modules/admin/admin-inc.php +++ b/inc/modules/admin/admin-inc.php @@ -41,7 +41,7 @@ if (!defined('__SECURITY')) { } // END - if // Register an administrator account -function addAdminAccount ($adminLogin, $passHash, $adminEmail) { +function addAdminAccount ($adminLogin, $passHash, $adminEmail, $accessLevel = 'deny') { // Login does already exist $ret = 'already'; @@ -51,13 +51,25 @@ function addAdminAccount ($adminLogin, $passHash, $adminEmail) { // Is the entry there? if (SQL_HASZERONUMS($result)) { - // Ok, let's create the admin login - SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_admins` (`login`, `password`, `email`) VALUES ('%s', '%s', '%s')", - array( - $adminLogin, - $passHash, - $adminEmail - ), __FUNCTION__, __LINE__); + // Is ext-admins installed and version at least 0.3.0? + if (isExtensionInstalledAndNewer('admins', '0.3.0')) { + // Ok, let's create the admin login + SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_admins` (`login`, `password`, `email`, `default_acl`) VALUES ('%s', '%s', '%s', '%s')", + array( + $adminLogin, + $passHash, + $adminEmail, + $accessLevel + ), __FUNCTION__, __LINE__); + } else { + // Ok, let's create the admin login + SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_admins` (`login`, `password`, `email`) VALUES ('%s', '%s', '%s')", + array( + $adminLogin, + $passHash, + $adminEmail + ), __FUNCTION__, __LINE__); + } // All done $ret = 'done'; @@ -133,12 +145,15 @@ function ifAdminCookiesAreValid ($adminLogin, $passHash) { //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'adminLogin=' . $adminLogin . ',passHash='.$passHash.',adminHash='.$adminHash.',testHash='.$testHash); // If they both match, the login data is valid - if ($testHash == $passHash) { + if ($testHash != $passHash) { + // Passwords don't match + $ret = 'password'; + } elseif (!isAdmin()) { + // Is not valid session + $ret = 'session'; + } else { // All fine $ret = 'done'; - } else { - // Set status - $ret = 'password'; } } // END - if @@ -442,6 +457,15 @@ ORDER BY // Load all entries while ($content = SQL_FETCHARRAY($result)) { + // Default is none + $content['default'] = ''; + + // Is the id the same? + if ($content['id'] == $adminId) { + // Set this as default + $content['default'] = ' selected="selected"'; + } // END - if + // Add the entry $OUT .= loadTemplate('select_admins_option', TRUE, $content); } // END - if @@ -483,7 +507,7 @@ ORDER BY while ($content = SQL_FETCHARRAY($result)) { //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . intval($userid) . '/' . $content['userid']); $OUT .= '