Changeset 1660 in ExiteCMS for trunk/administration/members.php
- Timestamp:
- 08/21/08 16:07:21 (4 years ago)
- File:
-
- 1 edited
-
trunk/administration/members.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/administration/members.php
r1195 r1660 30 30 // parameter validation 31 31 if (isset($user_id) && !isNum($user_id)) fallback("index.php"); 32 if (!isset($step)) $step = ""; 33 if (!isset($user_id)) $user_id= 0; 32 34 if (!isset($country) || strlen($country) != 2) $country = ""; 33 35 if (!isset($sortby) || strlen($sortby) != 1) $sortby = "all"; 34 if (!isset($ step)) $step = "";35 if (!isset($ user_id)) $user_id= 0;36 37 if (isset($_POST['cancel_delete'])) fallback(FUSION_SELF.$aidlink."& sortby=$sortby&rowstart=$rowstart");36 if (!isset($order)) $order = "username"; 37 if (!isset($field)) $field = "username"; 38 39 if (isset($_POST['cancel_delete'])) fallback(FUSION_SELF.$aidlink."&order=$order&sortby=$sortby&field=$field&rowstart=$rowstart"); 38 40 39 41 if ($step == "add") { … … 144 146 $rows = 0; 145 147 if (iMEMBER) { 146 // create the where clause 147 if ($sortby == "all") { 148 if ($country == "") { 149 $orderby = ""; 150 } else { 151 $orderby = " user_cc_code = '".$country."'"; 152 } 153 } else { 154 if ($country == "") { 155 $orderby = " user_name LIKE '".stripinput($sortby)."%' OR user_name LIKE '".strtolower(stripinput($sortby))."%'"; 156 } else { 157 $orderby = " user_cc_code = '".$country."' AND (user_name LIKE '".stripinput($sortby)."%' OR user_name LIKE '".strtolower(stripinput($sortby))."%')"; 158 } 159 } 148 // create the letter filter SQL clause and the selection sort SQL clause 149 switch($order) { 150 case "country": 151 $sortfield = "user_cc_code ASC, user_level DESC, user_name ASC"; 152 break; 153 case "email": 154 $sortfield = "user_email ASC, user_level DESC"; 155 break; 156 case "username": 157 default: 158 $sortfield = "user_level DESC, user_name ASC"; 159 break; 160 } 161 // create the query filter SQL clause 162 $where = ""; 163 switch($field) { 164 case "country": 165 $letterfilter = "DISTINCT(UPPER(SUBSTRING(user_cc_code,1,1)))"; 166 break; 167 case "email": 168 $letterfilter = "DISTINCT(UPPER(SUBSTRING(user_email,1,1)))"; 169 if ($sortby != "all") { 170 $where = "(user_email LIKE '".stripinput($sortby)."%' OR user_email LIKE '".strtolower(stripinput($sortby))."%')"; 171 } 172 break; 173 case "username": 174 default: 175 $letterfilter = "DISTINCT(UPPER(SUBSTRING(user_name,1,1)))"; 176 if ($sortby != "all") { 177 $where = "(user_name LIKE '".stripinput($sortby)."%' OR user_name LIKE '".strtolower(stripinput($sortby))."%')"; 178 } 179 break; 180 } 181 // add the country filter if requested 182 $where .= $country == "" ? "" : (($where == "" ? "" : " AND ").("user_cc_code = '$country'")); 183 184 160 185 // get the list of members 161 186 $variables['members'] = array(); 162 187 if (!isset($rowstart) || !isNum($rowstart)) $rowstart = 0; 163 $result = dbquery("SELECT * FROM ".$db_prefix."users".($ orderby==""?"":" WHERE").$orderby." ORDER BY user_level DESC, user_nameLIMIT ".$rowstart.", ".$settings['numofthreads']);188 $result = dbquery("SELECT * FROM ".$db_prefix."users".($where == ""?"":(" WHERE ".$where))." ORDER BY ".$sortfield." LIMIT ".$rowstart.", ".$settings['numofthreads']); 164 189 $rows = dbrows($result); 165 190 $variables['members'] = array(); … … 197 222 // starting characters to filter on. Make sure there are an even number! 198 223 $variables['search'] = array(); 199 $result = dbquery("SELECT DISTINCT(UPPER(SUBSTRING(user_name,1,1))) AS letter FROM ".$db_prefix."usersORDER BY letter");224 $result = dbquery("SELECT ".$letterfilter." AS letter FROM ".$db_prefix."users".($where == ""?"":(" WHERE ".$where))." ORDER BY letter"); 200 225 while ($data = dbarray($result)) { 201 226 // get rid of unwanted characters. Need to find a beter solution for this 202 227 $variables['search'][] = str_replace(array('&', '?'), array('',''), $data['letter']); 203 228 } 204 if (count($variables['search']) %2) $variables['search'][] = "";229 if (count($variables['search']) > 1 && count($variables['search'])%2) $variables['search'][] = ""; 205 230 $variables['sortby'] = $sortby; 206 $variables['rows'] = dbcount("(*)", "users", $ orderby);231 $variables['rows'] = dbcount("(*)", "users", $where); 207 232 $variables['rowstart'] = $rowstart; 208 233 $variables['items_per_page'] = $settings['numofthreads']; 209 $variables['pagenav_url'] = FUSION_SELF.$aidlink."&sortby=$sortby& ".($country==""?"":"country=$country&");234 $variables['pagenav_url'] = FUSION_SELF.$aidlink."&sortby=$sortby&field=$field&order=$order&".($country==""?"":"country=$country&"); 210 235 } 211 236 212 237 $variables['step'] = $step; 213 238 $variables['user_id'] = $user_id; 239 $variables['field'] = $field; 240 $variables['order'] = $order; 214 241 $template_panels[] = array('type' => 'body', 'name' => 'admin.members', 'template' => 'admin.members.tpl', 'locale' => array("admin.members", "main.user_fields")); 215 242 $template_variables['admin.members'] = $variables;
Note: See TracChangeset
for help on using the changeset viewer.
