]> git.mxchange.org Git - mailer.git/blobdiff - inc/functions.php
File renamed to naming convention, ext-repair continued:
[mailer.git] / inc / functions.php
index bb9301f583dab251416ae0c5890016fec60251c2..ad6274eb2e55316f7536b78fd9c03c0fb880784a 100644 (file)
@@ -640,14 +640,14 @@ function generateRandomCode ($length, $code, $userid, $extraData = '') {
        // Build key string
        $keys = getSiteKey() . getEncryptSeperator() . getDateKey();
        if (isConfigEntrySet('secret_key')) {
-               $keys .= getEncryptSeperator().getSecretKey();
+               $keys .= getEncryptSeperator() . getSecretKey();
        } // END - if
        if (isConfigEntrySet('file_hash')) {
-               $keys .= getEncryptSeperator().getFileHash();
+               $keys .= getEncryptSeperator() . getFileHash();
        } // END - if
        $keys .= getEncryptSeperator() . getDateFromPatchTime();
        if (isConfigEntrySet('master_salt')) {
-               $keys .= getEncryptSeperator().getMasterSalt();
+               $keys .= getEncryptSeperator() . getMasterSalt();
        } // END - if
 
        // Build string from misc data
@@ -1317,8 +1317,10 @@ function isUrlValidSimple ($url) {
                $reg = ($reg || preg_match(('^' . $pat . '^'), $url));
 
                // Does it match?
-               if ($reg === true) break;
-       }
+               if ($reg === true) {
+                       break;
+               } // END - if
+       } // END - foreach
 
        // Return true/false
        return $reg;
@@ -1326,7 +1328,7 @@ function isUrlValidSimple ($url) {
 
 // Wtites data to a config.php-style file
 // @TODO Rewrite this function to use readFromFile() and writeToFile()
-function changeDataInFile ($FQFN, $comment, $prefix, $suffix, $DATA, $seek=0) {
+function changeDataInFile ($FQFN, $comment, $prefix, $suffix, $inserted, $seek=0) {
        // Initialize some variables
        $done = false;
        $seek++;
@@ -1356,7 +1358,7 @@ function changeDataInFile ($FQFN, $comment, $prefix, $suffix, $DATA, $seek=0) {
                                        // Read from source file
                                        $line = fgets ($fp, 1024);
 
-                                       if (strpos($line, $search) > -1) { 
+                                       if (strpos($line, $search) > -1) {
                                                $next = '0';
                                                $found = true;
                                        } // END - if
@@ -1364,7 +1366,7 @@ function changeDataInFile ($FQFN, $comment, $prefix, $suffix, $DATA, $seek=0) {
                                        if ($next > -1) {
                                                if ($next === $seek) {
                                                        $next = -1;
-                                                       $line = $prefix . $DATA . $suffix . "\n";
+                                                       $line = $prefix . $inserted . $suffix . "\n";
                                                } else {
                                                        $next++;
                                                }
@@ -2149,7 +2151,7 @@ function handleFieldWithBraces ($field) {
        return $field;
 }
 
-// Converts a userid so it can be used in SQL queries
+// Converts a zero or NULL to word 'NULL'
 function makeZeroToNull ($number) {
        // Is it a valid username?
        if ((!is_null($number)) && ($number > 0)) {
@@ -2164,6 +2166,18 @@ function makeZeroToNull ($number) {
        return $number;
 }
 
+// Converts NULL into number zero
+function makeNullToZero ($number) {
+       // Is this a NULL?
+       if ((is_null($number)) || (empty($number))) {
+               // Simply set it
+               $number = '0';
+       } // END - if
+
+       // Return it
+       return $number;
+}
+
 // Capitalizes a string with underscores, e.g.: some_foo_string will become SomeFooString
 // Note: This function is cached
 function capitalizeUnderscoreString ($str) {
@@ -2337,6 +2351,7 @@ function getArrayKeysFromSubStrArray ($heystack, $needles, $offset = 0) {
 
 // Determines database column name from given subject and locked
 function determinePointsColumnFromSubjectLocked ($subject, $locked) {
+       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'subject=' . $subject . ',locked=' . intval($locked) . ' - ENTERED!');
        // Default is 'normal' points
        $pointsColumn = 'points';
 
@@ -2359,6 +2374,7 @@ function determinePointsColumnFromSubjectLocked ($subject, $locked) {
        $pointsColumn = $filterData['column'];
 
        // Return it
+       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'subject=' . $subject . ',locked=' . intval($locked) . ',pointsColumn=' . $pointsColumn . ' - EXIT!');
        return $pointsColumn;
 }
 
@@ -2408,6 +2424,24 @@ function translateTaskType ($taskType) {
        return $message;
 }
 
+// Translates points subject to human-readable
+function translatePointsSubject ($subject) {
+       // Construct message id
+       $messageId = 'POINTS_SUBJECT_' . strtoupper($subject) . '';
+
+       // Is the message id there?
+       if (isMessageIdValid($messageId)) {
+               // Then construct message
+               $message = '{--' . $messageId . '--}';
+       } else {
+               // Else it is an unknown task type
+               $message = '{%message,POINTS_SUBJECT_UNKNOWN=' . $subject . '%}';
+       } // END - if
+
+       // Return message
+       return $message;
+}
+
 // "Translates" 'true' to true and 'false' to false
 function convertStringToBoolean ($str) {
        // Trim it lower-case for validation