]> git.mxchange.org Git - mailer.git/blobdiff - inc/modules/admin/admin-inc.php
New functions introduced, several rewrites:
[mailer.git] / inc / modules / admin / admin-inc.php
index 97aab22bfebb4c94ab3b1e4dcd38e076af164eaa..ac2747eb35c7a9d47637160bae69601b9677b32d 100644 (file)
@@ -307,14 +307,14 @@ LIMIT 1",
                        loadInclude($inc);
                } elseif ($GLOBALS['acl_allow'] === false) {
                        // Access denied
-                       loadTemplate('admin_menu_failed', false, sprintf(getMessage('ADMIN_ACCESS_DENIED'), $what));
+                       loadTemplate('admin_menu_failed', false, getMaskedMessage('ADMIN_ACCESS_DENIED', $what));
                } else {
                        // Include file not found! :-(
-                       loadTemplate('admin_menu_failed', false, sprintf(getMessage('ADMIN_ACTION_404'), $action));
+                       loadTemplate('admin_menu_failed', false, getMaskedMessage('ADMIN_ACTION_404', $action));
                }
        } else {
                // Invalid action/what pair found!
-               loadTemplate('admin_menu_failed', false, sprintf(getMessage('ADMIN_ACTION_INVALID'), $action . '/' . $what));
+               loadTemplate('admin_menu_failed', false, getMaskedMessage('ADMIN_ACTION_INVALID', $action . '/' . $what));
        }
 
        // Free memory
@@ -532,7 +532,8 @@ function addMemberSelectionBox ($def=0, $add_all=false, $return=false, $none=fal
 // @DEPRECATED
 function adminMenuSelectionBox_DEPRECATED ($mode, $default = '', $defid = '') {
        $what = "`what` != ''";
-       if ($mode == 'action') $what = "(`what`='' OR `what` IS NULL) AND action !='login'";
+       if ($mode == 'action') $what = "(`what`='' OR `what` IS NULL) AND `action` !='login'";
+
        $result = SQL_QUERY_ESC("SELECT %s, `title` FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE ".$what." ORDER BY `sort` ASC",
                array($mode), __FUNCTION__, __LINE__);
        if (SQL_NUMROWS($result) > 0) {
@@ -613,9 +614,9 @@ function adminSaveSettings (&$postData, $tableName = '_config', $whereStatement
        $result = false;
        if ($alwaysAdd === false) {
                if (!empty($whereStatement)) {
-                       $result = SQL_QUERY("SELECT * FROM `{?_MYSQL_PREFIX?}".$tableName."` WHERE ".$whereStatement." LIMIT 1", __FUNCTION__, __LINE__);
+                       $result = SQL_QUERY("SELECT * FROM `{?_MYSQL_PREFIX?}" . $tableName . "` WHERE " . $whereStatement . " LIMIT 1", __FUNCTION__, __LINE__);
                } else {
-                       $result = SQL_QUERY("SELECT * FROM `{?_MYSQL_PREFIX?}".$tableName."` LIMIT 1", __FUNCTION__, __LINE__);
+                       $result = SQL_QUERY("SELECT * FROM `{?_MYSQL_PREFIX?}" . $tableName . "` LIMIT 1", __FUNCTION__, __LINE__);
                }
        } // END - if
 
@@ -751,10 +752,12 @@ function adminGetMenuMode () {
                // Load from database when version of 'admins' is enough
                $result = SQL_QUERY_ESC("SELECT la_mode FROM `{?_MYSQL_PREFIX?}_admins` WHERE `id`=%s LIMIT 1",
                        array($adminId), __FUNCTION__, __LINE__);
+
+               // Do we have an entry?
                if (SQL_NUMROWS($result) == 1) {
                        // Load data
                        list($adminMode) = SQL_FETCHROW($result);
-               }
+               } // END - if
 
                // Free memory
                SQL_FREERESULT($result);
@@ -901,9 +904,9 @@ function adminListBuilder ($listType, $IDs, $table, $columns, $filterFunctions,
 
        // Load master template
        loadTemplate(sprintf("admin_%s_%s",
-       $listType,
-       $table
-       ), false, $OUT
+               $listType,
+               $table
+               ), false, $OUT
        );
 }
 
@@ -1092,7 +1095,7 @@ function adminEditEntriesConfirm ($IDs, $table, $columns=array(), $filterFunctio
                                } // END - foreach
 
                                // Finish SQL command
-                               $sql = substr($sql, 0, -1) . " WHERE `".$idColumn."`=".bigintval($id)." LIMIT 1";
+                               $sql = substr($sql, 0, -1) . " WHERE `" . $idColumn . "`=" . bigintval($id) . " LIMIT 1";
 
                                // Run this query
                                SQL_QUERY($sql, __FUNCTION__, __LINE__);
@@ -1136,10 +1139,10 @@ function adminLockEntriesConfirm ($IDs, $table, $columns=array(), $filterFunctio
                // Shall we un-/lock here or list for locking?
                if ($lockNow === true) {
                        // Un-/lock entries
-                       adminBuilderStatusHandler("lock", $IDs, $table, $columns, $filterFunctions, $extraValues, $idColumn, $userIdColumn, $statusArray);
+                       adminBuilderStatusHandler('lock', $IDs, $table, $columns, $filterFunctions, $extraValues, $idColumn, $userIdColumn, $statusArray);
                } else {
                        // List for editing
-                       adminListBuilder("lock", $IDs, $table, $columns, $filterFunctions, $extraValues, $idColumn, $userIdColumn);
+                       adminListBuilder('lock', $IDs, $table, $columns, $filterFunctions, $extraValues, $idColumn, $userIdColumn);
                }
        } // END - if
 }
@@ -1151,10 +1154,10 @@ function adminUndeleteEntriesConfirm ($IDs, $table, $columns=array(), $filterFun
                // Shall we un-/lock here or list for locking?
                if ($undeleteNow === true) {
                        // Undelete entries
-                       adminBuilderStatusHandler("undelete", $IDs, $table, $columns, $filterFunctions, $extraValues, $idColumn, $userIdColumn, $statusArray);
+                       adminBuilderStatusHandler('undelete', $IDs, $table, $columns, $filterFunctions, $extraValues, $idColumn, $userIdColumn, $statusArray);
                } else {
                        // List for editing
-                       adminListBuilder("undelete", $IDs, $table, $columns, $filterFunctions, $extraValues, $idColumn, $userIdColumn);
+                       adminListBuilder('undelete', $IDs, $table, $columns, $filterFunctions, $extraValues, $idColumn, $userIdColumn);
                }
        } // END - if
 }
@@ -1196,7 +1199,7 @@ function sendAdminPasswordResetLink ($email) {
        SQL_FREERESULT($result);
 
        // Generate hash for reset link
-       $content['hash'] = generateHash(getConfig('URL').':'.$content['id'].':'.$content['login'].':'.$content['password'], substr($content['password'], 10));
+       $content['hash'] = generateHash(getConfig('URL') . ':' . $content['id'] . ':' . $content['login'] . ':' . $content['password'], substr($content['password'], 10));
 
        // Remove some data
        unset($content['id']);
@@ -1297,17 +1300,24 @@ function adminUpdateTaskData ($id, $row, $data) {
 
        // Update the task
        SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_task_system` SET `%s`='%s' WHERE `id`=%s LIMIT 1",
-               array($row, $data, bigintval($id)), __FUNCTION__, __LINE__);
+               array(
+                       $row,
+                       $data,
+                       bigintval($id)
+               ), __FUNCTION__, __LINE__);
 }
 
 // Checks wether if the admin menu has entries
 function ifAdminMenuHasEntries ($action) {
        return (
                ((
+                       // Is the entry set?
                        isset($GLOBALS['admin_menu_has_entries'][$action])
                ) && (
+                       // And do we have a menu for this action?
                        $GLOBALS['admin_menu_has_entries'][$action] === true
                )) || (
+                       // Login has always a menu
                        $action == 'login'
                )
        );
@@ -1323,7 +1333,7 @@ function adminCreateUserLink ($userid) {
        // Is the userid set correctly?
        if ($userid > 0) {
                // Create a link to that profile
-               return '{%url=modules.php?module=admin&what=list_user&userid='.bigintval($userid) . '%}';
+               return '{%url=modules.php?module=admin&what=list_user&userid=' . bigintval($userid) . '%}';
        } // END - if
 
        // Return a link to the user list
@@ -1333,7 +1343,7 @@ function adminCreateUserLink ($userid) {
 // Generate a "link" for the given admin id (admin_id)
 function generateAdminLink ($adminId) {
        // No assigned admin is default
-       $adminLink = "<span class=\"admin_note\">{--ADMIN_NO_ADMIN_ASSIGNED--}</span>";
+       $adminLink = '<span class="admin_note">{--ADMIN_NO_ADMIN_ASSIGNED--}</span>';
 
        // Zero? = Not assigned
        if (bigintval($adminId) > 0) {
@@ -1345,14 +1355,14 @@ function generateAdminLink ($adminId) {
                        // Is the extension there?
                        if (isExtensionActive('admins')) {
                                // Admin found
-                               $adminLink = "<a href=\"".generateEmailLink(getAdminEmail($adminId), 'admins')."\">" . $login."</a>";
+                               $adminLink = '<a href="' . generateEmailLink(getAdminEmail($adminId), 'admins') . '" title="{--ADMIN_CONTACT_LINK_TITLE--}">' . $login . '</a>';
                        } else {
                                // Extension not found
-                               $adminLink = sprintf(getMessage('EXTENSION_PROBLEM_NOT_INSTALLED'), 'admins');
+                               $adminLink = getMaskedMessage('EXTENSION_PROBLEM_NOT_INSTALLED', 'admins');
                        }
                } else {
                        // Maybe deleted?
-                       $adminLink = "<div class=\"admin_note\">".sprintf(getMessage('ADMIN_ID_404'), $adminId)."</div>";
+                       $adminLink = '<div class="admin_note">' . getMaskedMessage('ADMIN_ID_404', $adminId) . '</div>';
                }
        } // END - if
 
@@ -1360,5 +1370,73 @@ function generateAdminLink ($adminId) {
        return $adminLink;
 }
 
+// Verifies if the current admin has confirmed to alter expert settings
+//
+// Return values:
+// 'failed'    = Something goes wrong (default)
+// 'agreed'    = Has verified and and confirmed it to see them
+// 'forbidden' = Has not the proper right to alter them
+// 'update'    = Need to update extension 'admins'
+// 'ask'       = A form was send to the admin
+function doVerifyExpertSettings () {
+       // Default return status is failed
+       $return = 'failed';
+
+       // Is the extension installed and recent?
+       if (isExtensionInstalledAndNewer('admins', '0.7.3')) {
+               // Okay, load the status
+               $expertSettings = getAminsExpertSettings();
+
+               // Is he allowed?
+               if ($expertSettings == 'Y') {
+                       // Okay, does he want to see them?
+                       if (getAminsExpertWarning() == 'Y') {
+                               // Ask for them
+                               if (isFormSent()) {
+                                       // Is the element set, then we need to change the admin
+                                       if (isPostRequestElementSet('expert_settings')) {
+                                               // Get it and prepare final post data array
+                                               $postData['login'][getCurrentAdminId()] = getAdminLogin(getCurrentAdminId());
+                                               $postData['expert_warning'][getCurrentAdminId()] = 'N';
+
+                                               // Change it in the admin
+                                               adminsChangeAdminAccount($postData, 'expert_warning');
+
+                                               // Clear form
+                                               unsetPostRequestElement('ok');
+                                       } // END - if
+
+                                       // All fine!
+                                       $return = 'agreed';
+                               } else {
+                                       // Send form
+                                       loadTemplate('admin_expert_settings_form');
+
+                                       // Asked for it
+                                       $return = 'ask';
+                               }
+                       } else {
+                               // Do not display
+                               $return = 'agreed';
+                       }
+               } else {
+                       // Forbidden
+                       $return = 'forbidden';
+               }
+       } else {
+               // Out-dated extension or not installed
+               $return = 'update';
+       }
+
+       // Output message for other status than ask/agreed
+       if (($return != 'ask') && ($return != 'agreed')) {
+               // Output message
+               loadTemplate('admin_settings_saved', false, getMessage('ADMIN_EXPERT_SETTINGS_STATUS_' . strtoupper($return)));
+       } // END - if
+
+       // Return status
+       return $return;
+}
+
 // [EOF]
 ?>