Changeset 1660 in ExiteCMS for trunk/members.php
- Timestamp:
- 08/21/08 16:07:21 (4 years ago)
- File:
-
- 1 edited
-
trunk/members.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/members.php
r1195 r1660 28 28 if (!isset($country) || strlen($country) != 2) $country = ""; 29 29 if (!isset($sortby) || strlen($sortby) != 1) $sortby = "all"; 30 if (!isset($order)) $order = "username"; 31 if (!isset($field)) $field = "username"; 30 32 31 33 // get the name of the country requested … … 35 37 $rows = 0; 36 38 if (iMEMBER) { 37 // create the where clause 38 $filter = "user_status = 0"; // only show activated accounts 39 if ($sortby == "all") { 40 if ($country != "") { 41 $filter .= " AND user_cc_code = '".$country."'"; 42 } 43 } else { 44 if ($country == "") { 45 $filter .= " AND (user_name LIKE '".stripinput($sortby)."%' OR user_name LIKE '".strtolower(stripinput($sortby))."%')"; 46 } else { 47 $filter .= " AND (user_cc_code = '".$country."' AND (user_name LIKE '".stripinput($sortby)."%' OR user_name LIKE '".strtolower(stripinput($sortby))."%'))"; 48 } 39 // create the letter filter SQL clause and the selection sort SQL clause 40 switch($order) { 41 case "country": 42 $sortfield = "user_cc_code ASC, user_level DESC, user_name ASC"; 43 break; 44 case "email": 45 $sortfield = "user_email ASC, user_level DESC"; 46 break; 47 case "lastvisit": 48 $sortfield = "user_lastvisit DESC, user_name ASC"; 49 break; 50 case "username": 51 default: 52 $sortfield = "user_level DESC, user_name ASC"; 53 break; 49 54 } 55 // create the query filter SQL clause 56 $where = ""; 57 switch($field) { 58 case "country": 59 $letterfilter = "DISTINCT(UPPER(SUBSTRING(user_cc_code,1,1)))"; 60 break; 61 case "email": 62 $letterfilter = "DISTINCT(UPPER(SUBSTRING(user_email,1,1)))"; 63 if ($sortby != "all") { 64 $where = "(user_email LIKE '".stripinput($sortby)."%' OR user_email LIKE '".strtolower(stripinput($sortby))."%')"; 65 } 66 break; 67 case "lastvisit": 68 $letterfilter = "DISTINCT(UPPER(SUBSTRING(user_name,1,1)))"; 69 if ($sortby != "all") { 70 $where = "(user_name LIKE '".stripinput($sortby)."%' OR user_name LIKE '".strtolower(stripinput($sortby))."%')"; 71 } 72 break; 73 case "username": 74 default: 75 $letterfilter = "DISTINCT(UPPER(SUBSTRING(user_name,1,1)))"; 76 if ($sortby != "all") { 77 $where = "(user_name LIKE '".stripinput($sortby)."%' OR user_name LIKE '".strtolower(stripinput($sortby))."%')"; 78 } 79 break; 80 } 81 // add the country filter if requested 82 $where .= $country == "" ? "" : (($where == "" ? "" : " AND ").("user_cc_code = '$country'")); 83 50 84 // get the list of members 51 85 $variables['members'] = array(); 52 86 if (!isset($rowstart) || !isNum($rowstart)) $rowstart = 0; 53 $result = dbquery("SELECT * FROM ".$db_prefix."users ".($filter==""?"":("WHERE ".$filter))." ORDER BY user_level DESC, user_nameLIMIT ".$rowstart.", ".$settings['numofthreads']);87 $result = dbquery("SELECT * FROM ".$db_prefix."users".($where == ""?"":(" WHERE ".$where))." ORDER BY ".$sortfield." LIMIT ".$rowstart.", ".$settings['numofthreads']); 54 88 $rows = dbrows($result); 89 if ($rows == 0 && !empty($where)) { 90 // no results? Try again without a filter 91 $result = dbquery("SELECT * FROM ".$db_prefix."users ORDER BY ".$sortfield." LIMIT ".$rowstart.", ".$settings['numofthreads']); 92 $rows = dbrows($result); 93 $sortby="all"; 94 $where = ""; 95 } 55 96 $variables['members'] = array(); 56 97 if ($rows != 0) { … … 83 124 // starting characters to filter on. Make sure there are an even number! 84 125 $variables['search'] = array(); 85 $result = dbquery("SELECT DISTINCT(UPPER(SUBSTRING(user_name,1,1))) AS letter FROM ".$db_prefix."usersORDER BY letter");126 $result = dbquery("SELECT ".$letterfilter." AS letter FROM ".$db_prefix."users".($where == ""?"":(" WHERE ".$where))." ORDER BY letter"); 86 127 while ($data = dbarray($result)) { 87 128 // get rid of unwanted characters. Need to find a beter solution for this … … 89 130 } 90 131 if (count($variables['search'])%2) $variables['search'][] = ""; 132 $variables['field'] = $field; 133 $variables['order'] = $order; 91 134 $variables['sortby'] = $sortby; 92 $variables['rows'] = dbcount("(*)", "users", $ filter);135 $variables['rows'] = dbcount("(*)", "users", $where); 93 136 $variables['rowstart'] = $rowstart; 94 137 $variables['items_per_page'] = $settings['numofthreads']; 95 $variables['pagenav_url'] = FUSION_SELF."?sortby=$sortby& ".($country==""?"":"country=$country&");138 $variables['pagenav_url'] = FUSION_SELF."?sortby=$sortby&field=$field&".($country==""?"":"country=$country&"); 96 139 } 97 140
Note: See TracChangeset
for help on using the changeset viewer.
