]> git.mxchange.org Git - mailer.git/commitdiff
Some sponsor API functions added, expression function for user moved:
authorRoland Häder <roland@mxchange.org>
Fri, 23 Jul 2010 03:11:12 +0000 (03:11 +0000)
committerRoland Häder <roland@mxchange.org>
Fri, 23 Jul 2010 03:11:12 +0000 (03:11 +0000)
- Missing function generateSponsorEmailLink() added
- Sponsor registration rewritten to make usage of API function, we can use the
  function in admin area again, so the code is shorter
- Usage of EL in admin template for ext-sponsor
- TODOs.txt updated

DOCS/TODOs.txt
inc/expression-functions.php
inc/extensions/ext-sponsor.php
inc/libs/sponsor_functions.php
inc/libs/user_functions.php
inc/modules/admin/what-add_sponsor.php
inc/modules/admin/what-unlock_sponsor.php
inc/modules/guest/what-sponsor_reg.php
inc/template-functions.php
templates/de/html/admin/admin_unlock_sponsor_row.tpl

index 14ca982ac591ae2ab7fd89087dcec5965d147087..fd9e0f4c99ce604f362a111cb03c6bdb99df7a4d 100644 (file)
@@ -7,7 +7,7 @@
 ./inc/cache/config-local.php:126:// @TODO Rewrite the following three constants, somehow...
 ./inc/classes/cachesystem.class.php:474:       // @TODO Add support for more types which break in last else-block
 ./inc/config-functions.php:141:        // @TODO Make this all better... :-/
-./inc/expression-functions.php:202:// @TODO FILTER_COMPILE_CONFIG does not handle call-back functions so we handle it here again
+./inc/expression-functions.php:166:// @TODO FILTER_COMPILE_CONFIG does not handle call-back functions so we handle it here again
 ./inc/expression-functions.php:48:     // @TODO is escapeQuotes() enougth for strings with single/double quotes?
 ./inc/extensions/ext-html_mail.php:138:                // @TODO Move these arrays into config
 ./inc/extensions/ext-menu.php:54:              // @TODO Convert menu-Id to one coding-standard. admin(edit|_add) => admin_menu_(edit|add), mem(edit|_add) => mem_menu_(edit|add)
index 9f309b9d86ab1308b8d190cb315e1aedf82e828d..6d393659b1f49371ddbfa2a5c03ebb3293402191 100644 (file)
@@ -138,42 +138,6 @@ function doExpressionServer ($data) {
        return $code;
 }
 
-// Expression call-back function for fetching user data
-function doExpressionUser ($data) {
-       // Use current userid by default
-       $functionName = 'getMemberId()';
-
-       // User-related data, so is there a userid?
-       if (!empty($data['matches'][4][$data['key']])) {
-               // Do we have a userid or $userid?
-               if ($data['matches'][4][$data['key']] == '$userid') {
-                       // Use dynamic call
-                       $functionName = "getFetchedUserData('userid', \$userid, '" . $data['callback'] . "')";
-               } elseif (!empty($data['matches'][4][$data['key']])) {
-                       // User data found
-                       $functionName = "getFetchedUserData('userid', " . $data['matches'][4][$data['key']] . ", '" . $data['callback'] . "')";
-               }
-       } elseif ((!empty($data['callback'])) && (isUserDataValid())) {
-               // "Call-back" alias column for current logged in user's data
-               $functionName = "getUserData('" . $data['callback'] . "')";
-       }
-
-       // Do we have another function to run (e.g. translations)
-       if (!empty($data['extra_func'])) {
-               // Surround the original function call with it
-               $functionName = $data['extra_func'] . '(' . $functionName . ')';
-       } // END - if
-
-       // Generate replacer
-       $replacer = '{DQUOTE} . ' . $functionName . ' . {DQUOTE}';
-
-       // Now replace the code
-       $code = replaceExpressionCode($data, $replacer);
-
-       // Return replaced code
-       return $code;
-}
-
 // Expression call-back function for getting extension data
 function doExpressionExt ($data) {
        // Not installed is default
index d13faf9373c91f145ac6c7004fdc020b6521065b..d0e0cf08a56785c845729019f4201a822c459021 100644 (file)
@@ -318,16 +318,17 @@ PRIMARY KEY (`id`)
                addAdminMenuSql('sponsor','edit_sponsor','Sponsor &auml;ndern','Sponsorenaccount &auml;ndern (Grundaten, nicht Freigabe!).', 4);
                addAdminMenuSql('sponsor','lock_sponsor','Sponsor ent-/sperren','Sponsorenaccount sperren und entsperren.', 5);
                addAdminMenuSql('sponsor','del_sponsor','Sponsor l&ouml;schen','Sponsorenaccount l&ouml;schen.', 6);
-               addAdminMenuSql('sponsor','allow_sponsor_data','Datenverwaltung','Stellen Sie hier ein, welche Daten der Sponsor im Mitgliedsbereich &uuml;ber sicht anzeigen darf und welche nicht.', 7);
-               addAdminMenuSql('sponsor','list_sponsor_pays','Bestellungen...','Bestellungen der Sponsoren auflisten / bearbeiten.', 8);
-               addAdminMenuSql('sponsor','list_sponsor_menu','Sponsorenmen&uuml;','Das Sponsorenmen&uuml; kann hier ge&auml;ndert werden.', 9);
-               addAdminMenuSql('sponsor','list_sponsor_campaigns','Kampagnen...','Management aller von Ihren Sponsoren eingerichteten Kampagnen.', 10);
-               addAdminMenuSql('sponsor','list_sponsor_urls','URL-Management','Management (freischalten, sperren, l&ouml;schen, testen, bearbeiten usw.) von gebuchten URLs.', 11);
-               addAdminMenuSql('sponsor','list_sponsor_banner','Banner-Management','Management (freischalten, sperren, l&ouml;schen, testen, bearbeiten usw.) von gebuchten Bannern.', 12);
-               addAdminMenuSql('sponsor','list_sponsor_reg','Sponsor-Aktionen','Alle Sponsor-Aktionen auflisten und verwalten.', 13);
-               addAdminMenuSql('sponsor','list_sponsor_pay','Buchungspakete','Die Sponsoren k&ouml;nnen sich {OPEN_CONFIG}POINTS{CLOSE_CONFIG}-Pakete kaufen. Hier k&ouml;nnen Sie diese verwalten.', 14);
-               addAdminMenuSql('sponsor','list_sponsor_conv','{OPEN_CONFIG}POINTS{CLOSE_CONFIG} umwandeln...','Mit den vom Sponsor gekauften {OPEN_CONFIG}POINTS{CLOSE_CONFIG} kann er Aktionen buchen. Hier stellen Sie die Umrechnungsrate von {OPEN_CONFIG}POINTS{CLOSE_CONFIG} nach Sponsoraktionen um. Beispiel: 1 {OPEN_CONFIG}POINTS{CLOSE_CONFIG} = 10 Mails.', 15);
-               addAdminMenuSql('sponsor','config_sponsor','Einstellungen','Allgemeine Einstellungen am Sponsoring-System.', 16);
+               addAdminMenuSql('sponsor','sponsor_contct','Sponsor kontaktieren','Kontaktieren Sie Sponsoren komfortabel &uuml;ber dieses {?TITLE?}.', 7);
+               addAdminMenuSql('sponsor','allow_sponsor_data','Datenverwaltung','Stellen Sie hier ein, welche Daten der Sponsor im Mitgliedsbereich &uuml;ber sicht anzeigen darf und welche nicht.', 8);
+               addAdminMenuSql('sponsor','list_sponsor_pays','Bestellungen...','Bestellungen der Sponsoren auflisten / bearbeiten.', 9);
+               addAdminMenuSql('sponsor','list_sponsor_menu','Sponsorenmen&uuml;','Das Sponsorenmen&uuml; kann hier ge&auml;ndert werden.', 10);
+               addAdminMenuSql('sponsor','list_sponsor_campaigns','Kampagnen...','Management aller von Ihren Sponsoren eingerichteten Kampagnen.', 11);
+               addAdminMenuSql('sponsor','list_sponsor_urls','URL-Management','Management (freischalten, sperren, l&ouml;schen, testen, bearbeiten usw.) von gebuchten URLs.', 12);
+               addAdminMenuSql('sponsor','list_sponsor_banner','Banner-Management','Management (freischalten, sperren, l&ouml;schen, testen, bearbeiten usw.) von gebuchten Bannern.', 13);
+               addAdminMenuSql('sponsor','list_sponsor_reg','Sponsor-Aktionen','Alle Sponsor-Aktionen auflisten und verwalten.', 14);
+               addAdminMenuSql('sponsor','list_sponsor_pay','Buchungspakete','Die Sponsoren k&ouml;nnen sich {OPEN_CONFIG}POINTS{CLOSE_CONFIG}-Pakete kaufen. Hier k&ouml;nnen Sie diese verwalten.', 15);
+               addAdminMenuSql('sponsor','list_sponsor_conv','{OPEN_CONFIG}POINTS{CLOSE_CONFIG} umwandeln...','Mit den vom Sponsor gekauften {OPEN_CONFIG}POINTS{CLOSE_CONFIG} kann er Aktionen buchen. Hier stellen Sie die Umrechnungsrate von {OPEN_CONFIG}POINTS{CLOSE_CONFIG} nach Sponsoraktionen um. Beispiel: 1 {OPEN_CONFIG}POINTS{CLOSE_CONFIG} = 10 Mails.', 16);
+               addAdminMenuSql('sponsor','config_sponsor','Einstellungen','Allgemeine Einstellungen am Sponsoring-System.', 17);
                addAdminMenuSql('repair','repr_sponsor','Sponsormen&uuml;','Gewichtung des Sponsormen&uuml;s reparieren.', 5);
                //
                // Menu system (still admin menu)
index b4e78c2ae79908e69933c8073766fb723fb3fda3..1d883513c0e56fbd82444a0a0ad4eb566fd14af2 100644 (file)
@@ -531,5 +531,97 @@ function saveSponsorData ($postData, $content) {
        return $message;
 }
 
+// Create email link to sponsor's account
+function generateSponsorEmailLink ($email, $mod = 'admin') {
+       // Show contact link only if sponsor is confirmed by default
+       $locked = " AND `status`='CONFIRMED'";
+
+       // But admins shall always see it
+       if (isAdmin()) $locked = '';
+
+       $result = SQL_QUERY_ESC("SELECT
+       `id`
+FROM
+       `{?_MYSQL_PREFIX?}_sponsor_data`
+WHERE
+       `email`='%s'" . $locked."
+LIMIT 1",
+               array($email), __FUNCTION__, __LINE__);
+       if (SQL_NUMROWS($result) == 1) {
+               // Load sponsor_id
+               list($sponsor_id) = SQL_FETCHROW($result);
+
+               // Rewrite email address to contact link
+               $email = '{%url=modules.php?module=' . $mod . '&amp;what=sponsor_contct&amp;sponsor_id=' . bigintval($sponsor_id) . '%}';
+       } // END - if
+
+       // Free memory
+       SQL_FREERESULT($result);
+
+       // Return rewritten (?) email address
+       return $email;
+}
+
+// Processes a sponsor request and handles it
+function doProcessSponsorFormRequest ($messageArray = array()) {
+       // Default message
+       $message = '';
+
+       // Handle the request
+       $status = handleSponsorRequest(postRequestArray(), true, $messageArray, true);
+
+       // Check the status of the registration process
+       switch ($status) {
+               case 'added': // Sponsor successfully added with account status = UNCONFIRMED!
+                       // Check for his id number
+                       $result = SQL_QUERY_ESC("SELECT `id`, `hash` FROM `{?_MYSQL_PREFIX?}_sponsor_data` WHERE `email`='%s' LIMIT 1",
+                               array(postRequestParameter('email')), __FILE__, __LINE__);
+                       if (SQL_NUMROWS($result) == 1) {
+                               // id found so let's load it for the confirmation email
+                               list($id, $hash) = SQL_FETCHROW($result);
+
+                               // Prepare data for the email template
+                               $content['id']        = $id;
+                               $content['hash']      = $hash;
+                               $content['email']     = secureString(postRequestParameter('email'));
+                               $content['surname']   = secureString(postRequestParameter('surname'));
+                               $content['family']    = secureString(postRequestParameter('family'));
+                               $content['timestamp'] = generateDateTime(time(), 0);
+                               $content['password']  = secureString(postRequestParameter('pass1'));
+
+                               // Generate email and send it to the new sponsor
+                               $message = loadEmailTemplate('sponsor_confirm', $hash);
+                               sendEmail(postRequestParameter('email'), '{--SPONSOR_PLEASE_CONFIRM_SUBJECT--}', $message);
+
+                               // Send mail to admin
+                               sendAdminNotification('{--ADMIN_NEW_SPONSOR--}', 'admin_sponsor_reg', $hash);
+
+                               // Output message: DONE
+                               $message = $messageArray['added'];
+                       } else {
+                               // Sponsor account not found???
+                               $message = getMaskedMessage('SPONSOR_EMAIL_404', postRequestParameter('email'));
+                       }
+
+                       // Free memory
+                       SQL_FREERESULT($result);
+                       break;
+
+               default:
+                       logDebugMessage(__FILE__, __LINE__, sprintf("Unknown status %s detected.", $status));
+                       if (!isAdmin()) {
+                               // Message for testing admin
+                               $message = getMaskedMessage('ADMIN_SPONSOR_UNKNOWN_STATUS', $status);
+                       } else {
+                               // Message for the guest
+                               $message = getMaskedMessage('SPONSOR_UNKNOWN_STATUS', $status);
+                       }
+                       break;
+       }
+
+       // Return message
+       return $message;
+}
+
 // [EOF]
 ?>
index 6e8ebaf67d4dde3256c31e7b761960139faf401d..758ad55be19c9e098851859b29c1d6019b80bd14 100644 (file)
@@ -530,12 +530,52 @@ function insertUserStatsRecord ($userid, $statsType, $statsData) {
        if ((!getTimestampFromUserStats($statsType, $statsData, $userid)) && (!is_array($statsData))) {
                // Then insert it!
                SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_user_stats_data` (`userid`,`stats_type`,`stats_data`) VALUES (%s,'%s','%s')",
-                       array(bigintval($userid), $statsType, $statsData), __FUNCTION__, __LINE__);
+                       array(
+                               bigintval($userid),
+                               $statsType,
+                               $statsData
+                       ), __FUNCTION__, __LINE__);
        } elseif (is_array($statsData)) {
                // Invalid data!
-               logDebugMessage(__FUNCTION__, __LINE__, "userid={$userid},type={$statsType},data={".gettype($statsData).": Invalid statistics data type!");
+               logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',type=' . $statsType . ',data=' . gettype($statsData) . ': Invalid statistics data type!');
        }
 }
 
+// Expression call-back function for fetching user data
+function doExpressionUser ($data) {
+       // Use current userid by default
+       $functionName = 'getMemberId()';
+
+       // User-related data, so is there a userid?
+       if (!empty($data['matches'][4][$data['key']])) {
+               // Do we have a userid or $userid?
+               if ($data['matches'][4][$data['key']] == '$userid') {
+                       // Use dynamic call
+                       $functionName = "getFetchedUserData('userid', \$userid, '" . $data['callback'] . "')";
+               } elseif (!empty($data['matches'][4][$data['key']])) {
+                       // User data found
+                       $functionName = "getFetchedUserData('userid', " . $data['matches'][4][$data['key']] . ", '" . $data['callback'] . "')";
+               }
+       } elseif ((!empty($data['callback'])) && (isUserDataValid())) {
+               // "Call-back" alias column for current logged in user's data
+               $functionName = "getUserData('" . $data['callback'] . "')";
+       }
+
+       // Do we have another function to run (e.g. translations)
+       if (!empty($data['extra_func'])) {
+               // Surround the original function call with it
+               $functionName = $data['extra_func'] . '(' . $functionName . ')';
+       } // END - if
+
+       // Generate replacer
+       $replacer = '{DQUOTE} . ' . $functionName . ' . {DQUOTE}';
+
+       // Now replace the code
+       $code = replaceExpressionCode($data, $replacer);
+
+       // Return replaced code
+       return $code;
+}
+
 // [EOF]
 ?>
index bc1fc7e25a4cddd520513590675fb34f86c01692..9c607709933871099b40f2eb2288702a9262ee07 100644 (file)
@@ -47,7 +47,7 @@ addMenuDescription('admin', __FILE__);
 
 if (isFormSent()) {
        // Save sponsor in database
-       handleSponsorRequest(postRequestArray());
+       doProcessSponsorFormRequest();
 } else {
        // Output form
        loadTemplate('admin_add_sponsor');
index d91a05ba8d8c5954a08bd3ce5503d04704875075..3bff5d845507dca7938ad6947a2e7e8355720a55 100644 (file)
@@ -197,16 +197,8 @@ if (!SQL_HASZERONUMS($result)) {
        // Entries found so let's list them!
        $OUT = '';
        while ($content = SQL_FETCHARRAY($result)) {
-               // Transfer data to array
-               $content = array(
-                       'id'              => $content['id'],
-                       'gender'          => $content['gender'],
-                       'surname'         => $content['surname'],
-                       'family'          => $content['family'],
-                       'email'           => generateEmailLink($content['email'], 'sponsor_data'),
-                       'remote_addr'     => $content['remote_addr'],
-                       'sponsor_created' => generateDateTime($content['sponsor_created'], 2),
-               );
+               // Translate some data
+               $content['sponsor_created'] = generateDateTime($content['sponsor_created'], 2);
 
                // Load row template and switch colors
                $OUT .= loadTemplate('admin_unlock_sponsor_row', true, $content);
index 7e8f5c997b3a14fb0a75bd58293329fd25414ac9..8c9f367acc49dcd16726f4a991e66e4808e9cbd6 100644 (file)
@@ -227,56 +227,7 @@ LIMIT 1",
        postRequestParameter('last_curr'    , $curr);
 
        // Register sponsor but never ever update here!
-       $STATUS = handleSponsorRequest(postRequestArray(), true, $messageArray, true);
-
-       // Check the status of the registration process
-       switch ($STATUS) {
-               case 'added': // Sponsor successfully added with account status = UNCONFIRMED!
-                       // Check for his id number
-                       $result = SQL_QUERY_ESC("SELECT `id`, `hash` FROM `{?_MYSQL_PREFIX?}_sponsor_data` WHERE `email`='%s' LIMIT 1",
-                               array(postRequestParameter('email')), __FILE__, __LINE__);
-                       if (SQL_NUMROWS($result) == 1) {
-                               // id found so let's load it for the confirmation email
-                               list($id, $hash) = SQL_FETCHROW($result);
-
-                               // Prepare data for the email template
-                               $content['id']        = $id;
-                               $content['hash']      = $hash;
-                               $content['email']     = secureString(postRequestParameter('email'));
-                               $content['surname']   = secureString(postRequestParameter('surname'));
-                               $content['family']    = secureString(postRequestParameter('family'));
-                               $content['timestamp'] = generateDateTime(time(), 0);
-                               $content['password']  = secureString(postRequestParameter('pass1'));
-
-                               // Generate email and send it to the new sponsor
-                               $message = loadEmailTemplate('sponsor_confirm', $hash);
-                               sendEmail(postRequestParameter('email'), '{--SPONSOR_PLEASE_CONFIRM_SUBJECT--}', $message);
-
-                               // Send mail to admin
-                               sendAdminNotification('{--ADMIN_NEW_SPONSOR--}', 'admin_sponsor_reg', $hash);
-
-                               // Output message: DONE
-                               $message = $messageArray['added'];
-                       } else {
-                               // Sponsor account not found???
-                               $message = getMaskedMessage('SPONSOR_EMAIL_404', postRequestParameter('email'));
-                       }
-
-                       // Free memory
-                       SQL_FREERESULT($result);
-                       break;
-
-               default:
-                       logDebugMessage(__FILE__, __LINE__, sprintf("Unknown status %s detected.", $STATUS));
-                       if (!isAdmin()) {
-                               // Message for testing admin
-                               $message = getMaskedMessage('ADMIN_SPONSOR_UNKNOWN_STATUS', $STATUS);
-                       } else {
-                               // Message for the guest
-                               $message = getMaskedMessage('SPONSOR_UNKNOWN_STATUS', $STATUS);
-                       }
-                       break;
-       }
+       $message = doProcessSponsorFormRequest($messageArray);
 
        // Display message
        loadTemplate('admin_settings_saved', false, $message);
index 66867e69630e46f9f0df4bb19af038ec3e130a3a..daed3210c6a895a9dfbf6531807e1dc27657ebb9 100644 (file)
@@ -1071,10 +1071,10 @@ function generateEmailLink ($email, $table = 'admins') {
                $EMAIL = generateAdminEmailLink($email);
        } elseif ((isExtensionInstalledAndNewer('user', '0.3.3')) && ($table == 'user_data')) {
                // Create email link for contacting a member within admin area (or later in other areas, too?)
-               $EMAIL = generateUserEmailLink($email, 'admin');
+               $EMAIL = generateUserEmailLink($email);
        } elseif ((isExtensionActive('sponsor')) && ($table == 'sponsor_data')) {
                // Create email link to contact sponsor within admin area (or like the link above?)
-               $EMAIL = generateSponsorEmailLink($email, 'sponsor_data');
+               $EMAIL = generateSponsorEmailLink($email);
        }
 
        // Shall I close the link when there is no admin?
index 773302f0ffe5e98c6ff2253c88bbcd2def623642..1bdad4a1a910a40ee7fdac79d59135183cc3e776 100644 (file)
@@ -3,7 +3,7 @@
                <input type="checkbox" title="{--ID_SELECT--} $content[id]" name="id[$content[id]]" class="admin_normal" value="1" />
        </td>
        <td align="center" class="{%template,ColorSwitch%} bottom right">
-               <a href="$content[email]">{%pipe,translateGender=$content[gender]%} $content[surname] $content[family]</a>
+               <a href="{%pipe,generateSponsorEmailLink=$content[email]%}">{%pipe,translateGender=$content[gender]%} $content[surname] $content[family]</a>
        </td>
        <td align="center" class="{%template,ColorSwitch%} bottom right">
                $content[remote_addr]