]> git.mxchange.org Git - mailer.git/blobdiff - inc/libs/user_functions.php
A lot CSS classes rewritten, please update all your themes.
[mailer.git] / inc / libs / user_functions.php
index 187afc76159406e3dc21e957e8c2829adf7f696e..4a24b2d73bbd37c49e4334163e4f45e2362b7f29 100644 (file)
@@ -200,7 +200,7 @@ function addPageNavigation ($numPages, $offset, $showForm, $colspan, $return=fal
 }
 
 // Create email link to user's account
-function generateUserEmailLink($email, $mod = 'admin') {
+function generateUserEmailLink ($email, $mod = 'admin') {
        // Show contact link only if user is confirmed by default
        $locked = " AND `status`='CONFIRMED'";
 
@@ -467,7 +467,7 @@ function doNewUserPassword ($email, $userid) {
                }
        } else {
                // id or email is wrong
-               loadTemplate('admin_settings_saved', false, '<span class="guest_failed">{--GUEST_WRONG_ID_EMAIL--}</span>');
+               loadTemplate('admin_settings_saved', false, '<span class="notice">{--GUEST_WRONG_ID_EMAIL--}</span>');
        }
 
        // Return the error code
@@ -543,7 +543,7 @@ function insertUserStatsRecord ($userid, $statsType, $statsData) {
 }
 
 // Confirms a user account
-function doConfirmUserAccount () {
+function doConfirmUserAccount ($hash) {
        // Init content
        $content = array(
                'message' => '{--GUEST_CONFIRMED_FAILED--}',
@@ -555,7 +555,7 @@ function doConfirmUserAccount () {
 
        // Search for an unconfirmed or confirmed account
        $result = SQL_QUERY_ESC("SELECT `userid`, `email`, `refid` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `user_hash`='%s' AND (`status`='UNCONFIRMED' OR `status`='CONFIRMED') LIMIT 1",
-               array(getRequestParameter('hash')), __FILE__, __LINE__);
+               array($hash), __FILE__, __LINE__);
        if (SQL_NUMROWS($result) == 1) {
                // Ok, he want's to confirm now so we load some data
                list($userid, $email, $refid) = SQL_FETCHROW($result);
@@ -580,7 +580,9 @@ WHERE
        `user_hash`='%s' AND
        `status`='UNCONFIRMED'
 LIMIT 1",
-                       array(getRequestParameter('hash')), __FILE__, __LINE__);
+                       array($hash), __FILE__, __LINE__);
+
+               // Was it updated?
                if (SQL_AFFECTEDROWS() == 1) {
                        // Send email if updated
                        $message = loadEmailTemplate('confirm-member', $content, bigintval($userid));
@@ -647,6 +649,40 @@ LIMIT 1",
        loadTemplate('admin_settings_saved', false, $content['message']);
 }
 
+// Does resend the user's confirmation link for given email address
+function doResendUserConfirmationLink ($email) {
+       // Confirmation link requested
+       if (fetchUserData($email, 'email')) {
+               // Email address found
+               $content = getUserDataArray();
+
+               // Detect status
+               switch ($content['status']) {
+                       case 'UNCONFIRMED': // Account not confirmed
+                               // Load email template
+                               $message = loadEmailTemplate('guest_request_confirm', array('hash' => $content['user_hash']), $content['userid']);
+
+                               // Send email
+                               sendEmail($email, '{--REQUEST_CONFIRM_LINK_SUBJECT--}', $message);
+
+                               // And set message
+                               $content['message'] = '{--CONFIRM_LINK_SENT--}';
+                               break;
+
+                       case 'CONFIRMED': // Account already confirmed
+                               $content['message'] = '{--LOGIN_ID_CONFIRMED--}';
+                               break;
+
+                       case 'LOCKED': // Account is locked
+                               $content['message'] = '{--LOGIN_ID_LOCKED--}';
+                               break;
+               } // END - switch
+       } else {
+               // Email address not registered
+               $content['message'] = '{--EMAIL_404--}';
+       }
+}
+
 // Expression call-back function for fetching user data
 function doExpressionUser ($data) {
        // Use current userid by default