]> git.mxchange.org Git - mailer.git/commitdiff
Several fixes/improvements, new function introduced:
authorRoland Häder <roland@mxchange.org>
Wed, 31 Mar 2010 18:07:20 +0000 (18:07 +0000)
committerRoland Häder <roland@mxchange.org>
Wed, 31 Mar 2010 18:07:20 +0000 (18:07 +0000)
- New function handleFieldWithBraces() introduced which helps correcting the
  value of 'name' attribute
- Several template fixes

inc/functions.php
inc/language/surfbar_de.php
inc/modules/admin/admin-inc.php
inc/modules/admin/what-list_surfbar_urls.php
templates/de/html/admin/admin_del_surfbar_urls_row.tpl
templates/de/html/admin/admin_edit_surfbar_urls_row.tpl
templates/de/html/admin/admin_list_surfbar_urls_row.tpl
templates/de/html/admin/admin_lock_surfbar_urls_row.tpl
templates/de/html/admin/admin_undelete_surfbar_urls_row.tpl
templates/de/html/admin/admin_unlock_surfbar_urls.tpl

index 0187e2c818180a0a5fbffee9a8e7182a6e3d7b47..320c774ce890aeec5c55e6b1ea4bd344273b5703 100644 (file)
@@ -3948,6 +3948,28 @@ function fixNullEmptyToDashes ($str, $num) {
        return $return;
 }
 
+// Handles the braces [] of a field (e.g. value of 'name' attribute)
+function handleFieldWithBraces ($field) {
+       // Are there braces [] at the end?
+       if (substr($field, -2, 2) == '[]') {
+               // Try to find one and replace it. I do it this way to allow easy
+               // extending of this code.
+               foreach (array('admin_list_builder_id_value') as $key) {
+                       // Is the cache entry set?
+                       if (isset($GLOBALS[$key])) {
+                               // Insert it
+                               $field = str_replace('[]', '[' . $GLOBALS[$key] . ']', $field);
+
+                               // And abort
+                               break;
+                       } // END - if
+               } // END - foreach
+       } // END - if
+
+       // Return it
+       return $field;
+}
+
 //////////////////////////////////////////////////
 // AUTOMATICALLY RE-GENERATED MISSING FUNCTIONS //
 //////////////////////////////////////////////////
@@ -3987,3 +4009,4 @@ if (!function_exists('http_build_query')) {
 
 // [EOF]
 ?>
+
index 4643733a1a65b3b5e73691a93b133c52d795314b..85e92f55629bfa04dd5b7ed5bbd28512b0f9ce5b 100644 (file)
@@ -123,7 +123,7 @@ addMessages(array(
        'ADMIN_SURFBAR_URL' => "Gebuchte URL",
 
 // Admin titles
-       'ADMIN_UNLOCK_SURFBAR_URLS_TITLE' => "Surfbar - URLs freihschalten/ablehnen",
+       'ADMIN_SURFBAR_UNLOCK_URLS_TITLE' => "Surfbar - URLs freihschalten/ablehnen",
        'ADMIN_SURFBAR_LIST_URLS_TITLE' => "Surfbar - URLs aufisten",
        'ADMIN_SURFBAR_DELETE_URLS_TITLE' => "Surfbar - URLs entfernen",
        'ADMIN_SURFBAR_EDIT_URLS_TITLE' => "Surfbar - URLs editieren",
index 914622a461b6ea7edb2b6a54fd1b1ea298295451..3a053f102646cada334612ff856588526a745621 100644 (file)
@@ -394,7 +394,7 @@ ORDER BY
 }
 
 // Create member selection box
-function addMemberSelectionBox ($def=0, $add_all=false, $return=false, $none=false, $field='userid') {
+function addMemberSelectionBox ($def = 0, $add_all = false, $return = false, $none = false, $field = 'userid') {
        // Output selection form with all confirmed user accounts listed
        $result = SQL_QUERY("SELECT `userid`, `surname`, `family` FROM `{?_MYSQL_PREFIX?}_user_data` ORDER BY `userid` ASC", __FUNCTION__, __LINE__);
 
@@ -406,7 +406,7 @@ function addMemberSelectionBox ($def=0, $add_all=false, $return=false, $none=fal
         elseif ($none === true) $OUT = '      <option value="0">{--SELECT_NONE--}</option>';
 
        while ($content = SQL_FETCHARRAY($result)) {
-               $OUT .= '      <option value="' . bigintval($content['userid']) . '"';
+               $OUT .= '<option value="' . bigintval($content['userid']) . '"';
                if ($def == $content['userid']) $OUT .= ' selected="selected"';
                $OUT .= '>' . $content['surname'] . ' ' . $content['family'] . ' (' . bigintval($content['userid']) . ')</option>';
        } // END - while
@@ -423,7 +423,7 @@ function addMemberSelectionBox ($def=0, $add_all=false, $return=false, $none=fal
                loadTemplate('admin_member_selection_box', false, $content);
        } else {
                // Return content in selection frame
-               return '<select class="admin_select" name="' . $field . '" size="1">' . $OUT . '</select>';
+               return '<select class="admin_select" name="' . handleFieldWithBraces($field) . '" size="1">' . $OUT . '</select>';
        }
 }
 
@@ -434,24 +434,26 @@ function adminMenuSelectionBox_DEPRECATED ($mode, $default = '', $defid = '') {
        $what = "`what` != ''";
        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",
+       $result = SQL_QUERY_ESC("SELECT `%s` AS `menu`, `title` FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE ".$what." ORDER BY `sort` ASC",
                array($mode), __FUNCTION__, __LINE__);
        if (SQL_NUMROWS($result) > 0) {
                // Load menu as selection
-               $OUT = "<select name=\"".$mode."_menu";
-               if ((!empty($defid)) || ($defid == '0')) $OUT .= "[".$defid."]";
-               $OUT .= "\" size=\"1\" class=\"admin_select\">
-       <option value=\"\">{--SELECT_NONE--}</option>\n";
-               // @TODO Try to rewrite this to $content = SQL_FETCHARRAY(). Please look some lines above for the dynamic query
-               while (list($menu, $title) = SQL_FETCHROW($result)) {
-                       $OUT .= "  <option value=\"".$menu."\"";
-                       if ((!empty($default)) && ($default == $menu)) $OUT .= ' selected="selected"';
-                       $OUT .= ">".$title."</option>\n";
+               $OUT = '<select name="' . $mode . '_menu';
+               if ((!empty($defid)) || ($defid == '0')) $OUT .= '[' . $defid . ']';
+               $OUT .= '" size="1" class="admin_select">
+       <option value="">{--SELECT_NONE--}</option>';
+               // Load all entries
+               while ($content = SQL_FETCHARRAY($result)) {
+                       $OUT .= '<option value="' . $content['menu'] . '"';
+                       if ((!empty($default)) && ($default == $content['menu'])) $OUT .= ' selected="selected"';
+                       $OUT .= '>' . $content['title'] . '</option>';
                } // END - while
 
                // Free memory
                SQL_FREERESULT($result);
-               $OUT .= "</select>\n";
+
+               // Add closing select-tag
+               $OUT .= '</select>';
        } else {
                // No menus???
                $OUT = getMessage('ADMIN_PROBLEM_NO_MENU');
@@ -580,13 +582,12 @@ function adminAddMenuSelectionBox ($menu, $type, $name, $default = '') {
        $menuArray = getArrayFromDirectory(sprintf("inc/modules/%s/", $menu), '', false, false);
 
        // Init the selection box
-       $OUT = "<select name=\"".$name."\" class=\"admin_select\" size=\"1\">
-       <option value=\"\">{--IS_TOP_MENU--}</option>\n";
+       $OUT = '<select name="' . $name . '" class="admin_select" size="1"><option value="">{--IS_TOP_MENU--}</option>';
 
        // Walk through all files
        foreach ($menuArray as $file) {
                // Is this a PHP script?
-               if ((!isDirectory($file)) && (strpos($file, "".$type.'-') > -1) && (strpos($file, '.php') > 0)) {
+               if ((!isDirectory($file)) && (strpos($file, '' . $type . '-') > -1) && (strpos($file, '.php') > 0)) {
                        // Then test if the file is readable
                        $test = sprintf("inc/modules/%s/%s", $menu, $file);
 
@@ -598,16 +599,16 @@ function adminAddMenuSelectionBox ($menu, $type, $name, $default = '') {
 
                                // Is that part different from the overview?
                                if ($part != 'overview') {
-                                       $OUT .= "       <option value=\"".$part."\"";
+                                       $OUT .= '<option value="' . $part . '"';
                                        if ($part == $default) $OUT .= ' selected="selected"';
-                                       $OUT .= ">".$part."</option>\n";
+                                       $OUT .= '>' . $part . '</option>';
                                } // END - if
                        } // END - if
                } // END - if
        } // END - foreach
 
        // Close selection box
-       $OUT .= "</select>\n";
+       $OUT .= '</select>';
 
        // Return contents
        return $OUT;
@@ -781,10 +782,18 @@ function adminListBuilder ($listType, $IDs, $table, $columns, $filterFunctions,
                                // Do we have a userid?
                                if ($key == 'userid') {
                                        // Add it again as raw id
-                                       $content['userid'] = bigintval($value);
+                                       $content['userid_raw'] = bigintval($value);
+                               } // END - if
+
+                               // If the key matches the idColumn variable, we need to temporary remember it
+                               //* DEBUG: */ print 'key=' . $key . ',idColumn=' . $idColumn . ',value=' . $value . '<br />';
+                               if ($key == $idColumn) {
+                                       // Found, so remember it
+                                       $GLOBALS['admin_list_builder_id_value'] = $value;
                                } // END - if
 
                                // Handle the call in external function
+                               //* DEBUG: */ print 'key=' . $key . ',fucntion=' . $filterFunctions[$idx] . ',value=' . $value . '<br />';
                                $content[$key] = handleExtraValues($filterFunctions[$idx], $value, $extraValues[$idx]);
                        } // END - foreach
 
@@ -793,9 +802,9 @@ function adminListBuilder ($listType, $IDs, $table, $columns, $filterFunctions,
 
                        // Then list it
                        $OUT .= loadTemplate(sprintf("admin_%s_%s_row",
-                       $listType,
-                       $table
-                       ), true, $content
+                               $listType,
+                               $table
+                               ), true, $content
                        );
 
                        // Switch color
@@ -824,7 +833,7 @@ function adminBuilderStatusHandler ($mode, $IDs, $table, $columns, $filterFuncti
                        $sql = sprintf("UPDATE `{?_MYSQL_PREFIX?}_%s` SET", SQL_ESCAPE($table));
 
                        // Load data of entry
-                       $result = SQL_QUERY_ESC("SELECT * FROM `{?_MYSQL_PREFIX?}_%s` WHERE %s=%s LIMIT 1",
+                       $result = SQL_QUERY_ESC("SELECT * FROM `{?_MYSQL_PREFIX?}_%s` WHERE `%s`=%s LIMIT 1",
                                array($table, $idColumn, $id), __FUNCTION__, __LINE__);
 
                        // Fetch the data
@@ -858,10 +867,13 @@ function adminBuilderStatusHandler ($mode, $IDs, $table, $columns, $filterFuncti
 
                        // Add other columns as well
                        foreach (postRequestArray() as $key => $entries) {
+                               // Debug message
+                               logDebugMessage(__FUNCTION__, __LINE__, 'Found entry: ' . $key);
+
                                // Skip id, raw userid and 'do_$mode'
-                               if (!in_array($key, array($idColumn, 'userid_raw', ('do_'.$mode)))) {
+                               if (!in_array($key, array($idColumn, 'userid_raw', ('do_' . $mode)))) {
                                        // Are there brackets () at the end?
-                                       if (substr($entries[$id], -2, 2) == "()") {
+                                       if (substr($entries[$id], -2, 2) == '()') {
                                                // Direct SQL command found
                                                $sql .= sprintf(" %s=%s,", SQL_ESCAPE($key), SQL_ESCAPE($entries[$id]));
                                        } else {
@@ -871,7 +883,10 @@ function adminBuilderStatusHandler ($mode, $IDs, $table, $columns, $filterFuncti
                                                // Add entry
                                                $content[$key] = $entries[$id];
                                        }
-                               } // END - if
+                               } else {
+                                       // Skipped entry
+                                       logDebugMessage(__FUNCTION__, __LINE__, 'Skipped: ' . $key);
+                               }
                        } // END - foreach
 
                        // Finish SQL statement
@@ -983,8 +998,8 @@ function adminEditEntriesConfirm ($IDs, $table, $columns=array(), $filterFunctio
 
                                                // Then add this value
                                                $sql .= sprintf(" `%s`='%s',",
-                                               SQL_ESCAPE($key),
-                                               SQL_ESCAPE($entries[$id])
+                                                       SQL_ESCAPE($key),
+                                                       SQL_ESCAPE($entries[$id])
                                                );
                                        } elseif (($key != $idColumn) && (!is_array($entries))) {
                                                // Add normal entries as well!
index be0ad38097180370ba0ffd5be833e8f09e476d3b..e9964c13cca376b7923a7fb451a2c83201c695fe 100644 (file)
@@ -65,7 +65,7 @@ if (isPostRequestParameterSet('edit')) {
                'surfbar_urls',
                array('id', 'userid', 'url'),
                array('bigintval', 'addMemberSelectionBox', ''),
-               array('', array(false, true, true), '')
+               array('', array(false, true, true, 'userid[]'), '')
        );
        $show = false;
 } elseif (isPostRequestParameterSet('do_edit')) {
@@ -84,7 +84,7 @@ if (isPostRequestParameterSet('edit')) {
        postRequestParameter('id'),
                'surfbar_urls',
                array('id', 'userid', 'url', 'registered'),
-               array('bigintval', 'generateUserProfileLink', 'FRAMETESTER', ''),
+               array('bigintval', 'generateUserProfileLink', 'generateFrametesterUrl', ''),
                array('', '', '', '')
        );
        $show = false;
@@ -97,7 +97,7 @@ if (isPostRequestParameterSet('edit')) {
                postRequestParameter('id'),
                'surfbar_urls',
                array('id', 'userid', 'url', 'registered', 'status'),
-               array('bigintval', 'generateUserProfileLink', 'FRAMETESTER', '', 'translateSurfbarUrlStatus'),
+               array('bigintval', 'generateUserProfileLink', 'generateFrametesterUrl', '', 'translateSurfbarUrlStatus'),
                array('', '', '', '', '')
        );
        $show = false;
@@ -118,7 +118,7 @@ if (isPostRequestParameterSet('edit')) {
                postRequestParameter('id'),
                'surfbar_urls',
                array('id', 'userid', 'url', 'registered', 'status'),
-               array('bigintval', 'generateUserProfileLink', 'FRAMETESTER', '', 'translateSurfbarUrlStatus'),
+               array('bigintval', 'generateUserProfileLink', 'generateFrametesterUrl', '', 'translateSurfbarUrlStatus'),
                array('', '', '', '', '')
        );
        $show = false;
index b57971971de6de2517e3f76595c8becac2d89b47..0c73084c2517fd081c1d674cedbc7feb0b12c35f 100644 (file)
@@ -1,7 +1,7 @@
 <tr>
        <td align="center" class="bottom right switch_sw$content[sw]">
                <input type="hidden" name="id[$content[id]]" value="1" />
-               <input type="hidden" name="userid_raw[$content[id]]" value="$content[userid]" />
+               <input type="hidden" name="userid_raw[$content[id]]" value="$content[userid_raw]" />
                $content[userid]
        </td>
        <td align="center" class="bottom right switch_sw$content[sw]">
index 2ce82c812b012e56432b1792210a6afe5894eaee..41b5ff8b831ca6bdd32d03e6dee084f791383cca 100644 (file)
@@ -1,7 +1,7 @@
 <tr>
        <td align="center" class="bottom right switch_sw$content[sw]">
                <input type="hidden" name="id[$content[id]]" value="1" />
-               <input type="hidden" name="userid_raw[$content[id]]" value="$content[userid]" />
+               <input type="hidden" name="userid_raw[$content[id]]" value="$content[userid_raw]" />
                $content[userid]
        </td>
        <td align="center" class="bottom right switch_sw$content[sw]">
index 36471a6f0606ff8d26043e4301add32fa60afa11..f1ebeca3595a3a006304aaa626646baf8c791eb8 100644 (file)
                <a href="{%url=modules.php?module=admin&amp;what=surfbar_stats&amp;url_id=$content[id]%}">$content[views_total]</a>
        </td>
        <td align="center" class="bottom right switch_sw$content[sw]">
-               $content[url_status]
+               $content[status]
        </td>
        <td align="center" class="bottom right switch_sw$content[sw]">
-               $content[url_registered]
+               $content[registered]
        </td>
        <td align="center" class="bottom right switch_sw$content[sw]">
-               $content[url_last_locked]
+               $content[last_locked]
        </td>
        <td align="center" class="bottom switch_sw$content[sw]">
                $content[lock_reason]
index bff0efabd94c0a2f68751961201ca53d9b693147..5e1afc10ee4e90723b718de159f8075c918e09d4 100644 (file)
@@ -1,7 +1,7 @@
 <tr>
        <td align="center" class="bottom right switch_sw$content[sw]">
                <input type="hidden" name="id[$content[id]]" value="1" />
-               <input type="hidden" name="userid_raw[$content[id]]" value="$content[userid]" />
+               <input type="hidden" name="userid_raw[$content[id]]" value="$content[userid_raw]" />
                <input type="hidden" name="last_locked[$content[id]]" value="NOW()" />
                $content[userid]
        </td>
@@ -9,10 +9,10 @@
                <a href="$content[url]" target="_blank" title="{--ADMIN_TEST_URL--}">{--ADMIN_TEST_URL--}</a>
        </td>
        <td align="center" class="bottom right switch_sw$content[sw]">
-               $content[url_status]
+               $content[status]
        </td>
        <td align="center" class="bottom right switch_sw$content[sw]">
-               $content[url_registered]
+               $content[registered]
        </td>
        <td align="center" class="bottom switch_sw$content[sw]">
                Bitte angeben:<br />
index 7ad3ab5ab5db929b9afb852e1d759fad4243b499..1770775ee00900e0eff5e323f8a0a6afa683e32a 100644 (file)
@@ -1,16 +1,16 @@
 <tr>
        <td align="center" class="bottom right switch_sw$content[sw]">
                <input type="hidden" name="id[$content[id]]" value="1" />
-               <input type="hidden" name="userid_raw[$content[id]]" value="$content[userid]" />
+               <input type="hidden" name="userid_raw[$content[id]]" value="$content[userid_raw]" />
                $content[userid]
        </td>
        <td align="center" class="bottom right switch_sw$content[sw]">
                <a href="$content[url]" target="_blank" title="{--ADMIN_TEST_URL--}">{--ADMIN_TEST_URL--}</a>
        </td>
        <td align="center" class="bottom right switch_sw$content[sw]">
-               $content[url_status]
+               $content[status]
        </td>
        <td align="center" class="bottom switch_sw$content[sw]">
-               $content[url_registered]
+               $content[registered]
        </td>
 </tr>
index 066665617009359c62c502b98710032d8b45036c..e21e87b4e9d504f1849c9a91f59e75d8a934e9e8 100644 (file)
@@ -3,7 +3,7 @@
 <table border="0" cellspacing="0" cellpadding="0" class="admin_table dashed" width="600">
 <tr>
        <td align="center" colspan="5" class="admin_title">
-               <strong>{--ADMIN_UNLOCK_SURFBAR_URLS_TITLE--}</strong>
+               <strong>{--ADMIN_SURFBAR_UNLOCK_URLS_TITLE--}</strong>
        </td>
 </tr>
 <tr>