]> git.mxchange.org Git - mailer.git/blobdiff - inc/mysql-manager.php
Deprecated templates removed, some code moved to filters, bug fixed in mydata:
[mailer.git] / inc / mysql-manager.php
index e33b1b395e995c187edbccd29b2fbde77684f250..b2614077ab6e067e6fd08a9938f8bf5be0e94290 100644 (file)
@@ -897,125 +897,6 @@ function isMenuActionValid ($mode, $action, $what, $updateEntry=false) {
        return $ret;
 }
 
-// Send out mails depending on the 'mod/modes' combination
-// @TODO Lame description for this function
-function sendModeMails ($mod, $modes) {
-       // Load hash
-       if (fetchUserData(getMemberId())) {
-               // Extract salt from cookie
-               $salt = substr(getSession('u_hash'), 0, -40);
-
-               // Now let's compare passwords
-               $hash = generatePassString(getUserData('password'));
-
-               // Does the hash match or should we change it?
-               if (($hash == getSession('u_hash')) || (postRequestElement('pass1') == postRequestElement('pass2'))) {
-                       // Load user's data               0        1        2         3        4      5    6      7
-                       $result = SQL_QUERY_ESC("SELECT gender, surname, family, street_nr, country, zip, city, email FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `userid`=%s AND password='%s' LIMIT 1",
-                               array(getMemberId(), getUserData('password')), __FUNCTION__, __LINE__);
-                       if (SQL_NUMROWS($result) == 1) {
-                               // Load the data
-                               $content = SQL_FETCHARRAY($result, 0, false);
-
-                               // Free result
-                               SQL_FREERESULT($result);
-
-                               // Translate gender
-                               $content['gender'] = translateGender($content['gender']);
-
-                               // Clear/init the content variable
-                               $content['message'] = '';
-
-                               switch ($mod) {
-                                       case 'mydata':
-                                               foreach ($modes as $mode) {
-                                                       switch ($mode) {
-                                                               case 'normal': break; // Do not add any special lines
-                                                               case 'email': // Email was changed!
-                                                                       $content['message'] = getMessage('MEMBER_CHANGED_EMAIL').": ".postRequestElement('old_email')."\n";
-                                                                       break;
-
-                                                               case 'pass': // Password was changed
-                                                                       $content['message'] = getMessage('MEMBER_CHANGED_PASS')."\n";
-                                                                       break;
-
-                                                               default:
-                                                                       logDebugMessage(__FUNCTION__, __LINE__, sprintf("Unknown mode %s detected.", $mode));
-                                                                       $content['message'] = getMessage('MEMBER_UNKNOWN_MODE') . ': ' . $mode . "\n\n";
-                                                                       break;
-                                                       } // END - switch
-                                               } // END - foreach
-
-                                               if (isExtensionActive('country')) {
-                                                       // Replace code with description
-                                                       $content['country'] = generateCountryInfo(postRequestElement('country_code'));
-                                               } // END - if
-
-                                               // Merge content with data from POST
-                                               $content = merge_array($content, postRequestArray());
-
-                                               // Load template
-                                               $message = loadEmailTemplate('member_mydata_notify', $content, getMemberId());
-
-                                               if (getConfig('admin_notify') == 'Y') {
-                                                       // The admin needs to be notified about a profile change
-                                                       $message_admin = 'admin_mydata_notify';
-                                                       $sub_adm   = getMessage('ADMIN_CHANGED_DATA');
-                                               } else {
-                                                       // No mail to admin
-                                                       $message_admin = '';
-                                                       $sub_adm   = '';
-                                               }
-
-                                               // Set subject lines
-                                               $sub_mem = getMessage('MEMBER_CHANGED_DATA');
-
-                                               // Output success message
-                                               $content = "<span class=\"member_done\">{--MYDATA_MAIL_SENT--}</span>";
-                                               break;
-
-                                       default: // Unsupported module!
-                                               logDebugMessage(__FUNCTION__, __LINE__, sprintf("Unsupported module %s detected.", $mod));
-                                               $content = "<span class=\"member_failed\">{--UNKNOWN_MODULE--}</span>";
-                                               break;
-                               } // END - switch
-                       } else {
-                               // Could not load profile data
-                               $content = "<span class=\"member_failed\">{--MEMBER_CANNOT_LOAD_PROFILE--}</span>";
-                       }
-               } else {
-                       // Passwords mismatch
-                       $content = "<span class=\"member_failed\">{--MEMBER_PASSWORD_ERROR--}</span>";
-               }
-       } else {
-               // Could not load profile
-               $content = "<span class=\"member_failed\">{--MEMBER_CANNOT_LOAD_PROFILE--}</span>";
-       }
-
-       // Send email to user if required
-       if ((!empty($sub_mem)) && (!empty($message))) {
-               // Send member mail
-               sendEmail($content['email'], $sub_mem, $message);
-       } // END - if
-
-       // Send only if no other error has occured
-       if (empty($content)) {
-               if ((!empty($sub_adm)) && (!empty($message_admin))) {
-                       // Send admin mail
-                       sendAdminNotification($sub_adm, $message_admin, $content, getMemberId());
-               } elseif (getConfig('admin_notify') == 'Y') {
-                       // Cannot send mails to admin!
-                       $content = getMessage('CANNOT_SEND_ADMIN_MAILS');
-               } else {
-                       // No mail to admin
-                       $content = "<span class=\"member_done\">{--MYDATA_MAIL_SENT--}</span>";
-               }
-       } // END - if
-
-       // Load template
-       loadTemplate('admin_settings_saved', false, $content);
-}
-
 // Get action value from mode (admin/guest/member) and what-value
 function getModeAction ($mode, $what) {
        // Init status
@@ -1024,9 +905,14 @@ function getModeAction ($mode, $what) {
        //* DEBUG: */ print(__LINE__.'='.$mode.'/'.$what.'/'.getAction()."=<br />");
        if (!isExtensionInstalledAndNewer('sql_patches', '0.0.5')) {
                // sql_patches is missing so choose depending on mode
-               if ($mode == 'admin') {
+               if (isWhatSet()) {
+                       // Use setted what
+                       $what = getWhat();
+               } elseif ($mode == 'admin') {
+                       // Admin area
                        $what = 'overview';
                } else {
+                       // Everywhere else
                        $what = 'welcome';
                }
        } elseif ((empty($what)) && ($mode != 'admin')) {
@@ -1070,7 +956,7 @@ function getModeAction ($mode, $what) {
 
                // Free memory
                SQL_FREERESULT($result);
-       } elseif ((!isExtensionInstalled('sql_patches')) && ($mode != 'admin')) {
+       } elseif ((!isExtensionInstalled('sql_patches')) && (($mode != 'admin') && ($mode != 'unknown'))) {
                // No sql_patches installed, but maybe we need to register an admin?
                if (isAdminRegistered()) {
                        // Redirect to admin area