]> git.mxchange.org Git - mailer.git/blobdiff - inc/modules/admin/admin-inc.php
Usual change: ok->other_than_ok ;)
[mailer.git] / inc / modules / admin / admin-inc.php
index c9f941dbd568b1277a4b9b82d658bb71d375b5f3..57a889db6c197ca5ad162709d20716beac2a32eb 100644 (file)
@@ -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';
@@ -1333,7 +1345,7 @@ function doVerifyExpertSettings () {
                        // Okay, does he want to see them?
                        if (isAdminsExpertWarningEnabled()) {
                                // Ask for them
-                               if (isFormSent()) {
+                               if (isFormSent('save_expert')) {
                                        // Is the element set, then we need to change the admin
                                        if (isPostRequestElementSet('expert_settings')) {
                                                // Get it and prepare final post data array
@@ -1611,7 +1623,7 @@ function registerFirstAdmin () {
                destroyAdminSession();
 
                // Do registration
-               $ret = addAdminAccount(postRequestElement('admin_login'), $hashedPass, getWebmaster());
+               $ret = addAdminAccount(postRequestElement('admin_login'), $hashedPass, getWebmaster(), 'allow');
 
                // Check if registration wents fine
                switch ($ret) {