A lot more nice improvements!
[mailer.git] / inc / modules / admin / what-list_user.php
index ea3997ab6eb46ff131441d3c5662edafdf21955a..7b7579ce63d2a17d10ad2493e5ea839dc685716f 100644 (file)
@@ -46,10 +46,13 @@ ADD_DESCR("admin", __FILE__);
 
 // Init title with "all accounts"
 $listHeader = ADMIN_ALL_ACCOUNTS;
-if (!empty($_GET['mode'])) {
+if (!empty($_GET['status'])) {
+       // Set title according to the "status"
+       $listHeader = constant(sprintf("ADMIN_LIST_STATUS_%s_ACCOUNTS", strtoupper(SQL_ESCAPE($_GET['status']))));
+} elseif (!empty($_GET['mode'])) {
        // Set title according to the "mode"
-       $listHeader = constant(sprintf("ADMIN_LIST_%s_ACCOUNTS", strtoupper(SQL_ESCAPE($_GET['mode']))));
-} // END - if
+       $listHeader = constant(sprintf("ADMIN_LIST_MODE_%s_ACCOUNTS", strtoupper(SQL_ESCAPE($_GET['mode']))));
+}
 
 // Remember it
 define('__TITLE', $listHeader);
@@ -72,6 +75,12 @@ if (GET_EXT_VERSION("user") >= "0.3.4") {
        } // END - if
 } // END - if
 
+// Is the extension "country" installed?
+if (EXT_IS_ACTIVE("country")) {
+       // Add country code
+       $MORE .= ", country_code";
+} // END - if
+
 // Init unset data (bad that we change $_GET here!)
 if (empty($_GET['letter'])) { $_GET['letter'] = _ALL2;    }
 if (empty($_GET['sortby'])) { $_GET['sortby'] = "userid"; }
@@ -125,6 +134,9 @@ LIMIT 1",
                $DATA['locked']            = TRANSLATE_COMMA(GET_TOTAL_DATA($uid, "user_points", "locked_points"));
                $DATA['lock_timestamp']    = MAKE_DATETIME($DATA['lock_timestamp'], "2");
 
+               // Is the lock reason not set?
+               if (!isset($DATA['lock_reason'])) $DATA['lock_reason'] = "---";
+
                // Nickname inclusion?
                if (EXT_IS_ACTIVE("nickname")) {
                        // Nickname not set or invalid? Then 
@@ -150,6 +162,15 @@ LIMIT 1",
                $DATA['mails_confirmed'] = TRANSLATE_COMMA($DATA['mails_confirmed']);
                $DATA['emails_received'] = TRANSLATE_COMMA($DATA['emails_received']);
 
+               // Is the extension "country" installed?
+               if (EXT_IS_ACTIVE("country")) {
+                       // Then overwrite country information
+                       $DATA['country'] = COUNTRY_GENERATE_INFO($DATA['country_code']);
+               } elseif ($DATA['country'] == 0) {
+                       // Zero ID???
+                       $DATA['country'] = "???";
+               }
+
                // Load user-details template
                LOAD_TEMPLATE("admin_user_details", false, $uid);
        } else {
@@ -167,17 +188,34 @@ LIMIT 1",
        } // END - if
        if ($_GET['sortby'] == "family_name") $_GET['sortby'] = "family";
 
-       // Parse the mode parameter
-       if (isset($_GET['mode'])) {
+       // Parse the status or mode parameter
+       if (isset($_GET['status'])) {
                // Is a WHERE statement already there?
                if (!empty($whereStatement)) {
                        // Then append the status column
-                       $whereStatement .= sprintf(" AND status='%s'", SQL_ESCAPE(strip_tags(strtoupper($_GET['mode']))));
+                       $whereStatement .= sprintf(" AND status='%s'", SQL_ESCAPE(strip_tags(strtoupper($_GET['status']))));
                } else {
                        // Start a new one
-                       $whereStatement = sprintf(" WHERE status='%s'", SQL_ESCAPE(strip_tags(strtoupper($_GET['mode']))));
+                       $whereStatement = sprintf(" WHERE status='%s'", SQL_ESCAPE(strip_tags(strtoupper($_GET['status']))));
                }
-       } // END - if
+       } elseif (isset($_GET['mode'])) {
+               // Choose what we need to list
+               switch ($_GET['mode']) {
+                       case "norefs": // Users w/o refs
+                               if (!empty($whereStatement)) {
+                                       // Add AND statement
+                                       $whereStatement .= " AND refid=0";
+                               } else {
+                                       // Add WHERE statement
+                                       $whereStatement = " WHERE refid=0";
+                               }
+                               break;
+
+                       default: // Invalid list mode
+                               DEBUG_LOG(__FILE__, __LINE__, sprintf("Invalid list mode %s detected.", SQL_ESCAPE($_GET['mode'])));
+                               break;
+               }
+       } // END = if
 
        // Prepare SQL and run it
        $SQL = "SELECT userid, gender, surname, family, email, REMOTE_ADDR, refid, status, emails_sent, mails_confirmed, emails_received".$MORE." FROM "._MYSQL_PREFIX."_user_data".$whereStatement." ORDER BY ".SQL_ESCAPE($_GET['sortby']);
@@ -270,13 +308,25 @@ LIMIT 1",
                        $content['gender'] = TRANSLATE_GENDER($content['gender']);
                        $content['email']  = "[<A href=\"".CREATE_EMAIL_LINK($content['email'], "user_data")."\">".$content['email']."</A>]";
                        $content['addr']   = $content['REMOTE_ADDR'];
-                       $content['status'] = TRANSLATE_STATUS($content['status']);
                        $content['links']  = $LINKS;
                        $content['alinks'] = MEMBER_ACTION_LINKS($content['userid'], $content['status']);
                        $content['points'] = TRANSLATE_COMMA($pointsTotal);
                        $content['rate']   = TRANSLATE_COMMA($clickRate);
                        $content['locked'] = TRANSLATE_COMMA(GET_TOTAL_DATA($content['userid'], "user_points", "locked_points"));
                        $content['lock_timestamp'] = MAKE_DATETIME($content['lock_timestamp'], "2");
+                       $content['status'] = TRANSLATE_STATUS($content['status']);
+
+                       // Is the lock reason not set?
+                       if (!isset($content['lock_reason'])) $content['lock_reason'] = "---";
+
+                       // Is the extension "country" installed?
+                       if (EXT_IS_ACTIVE("country")) {
+                               // Then overwrite country information
+                               $content['country'] = COUNTRY_GENERATE_INFO($content['country_code']);
+                       } elseif ($content['country'] == 0) {
+                               // Zero ID???
+                               $content['country'] = "???";
+                       }
 
                        // Load row template and switch colors
                        $OUT .= LOAD_TEMPLATE("admin_list_user_row", true, $content);