Author Topic: Sort user by upload in CPA  (Read 7508 times)

0 Members and 1 Guest are viewing this topic.

Offline ascanio

  • Hero Member
  • *****
  • Posts: 569
    • View Profile
    • http://www.surfourspace.net
Sort user by upload in CPA
« on: April 24, 2005, 09:23:17 PM »
Hi, is there any way in the control panel in the option edit users to sort the user in order of how many pictures have they upload?

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: Sort user by upload in CPA
« Reply #1 on: April 24, 2005, 09:44:11 PM »
try this:
in admin/users.php find:
Code: [Select]
  <option value="<?php echo get_user_table_field("""user_lastaction"); ?>"><?php echo $lang['field_lastaction']; ?></option>insert below:
Code: [Select]
  <option value="num"><?php echo $lang['images']; ?></option>
Then find:
Code: [Select]
$condition = "1=1";below that u will find bunch of get_user_table_field("" started with
Code: [Select]
    $condition .= " AND ".get_user_table_field("", "user_level")." = $user_level"; and ended with
Code: [Select]
    $orderby = get_user_table_field("", "user_name");in every instance insert u. inside the empty quotes:
Quote
    $orderby = get_user_table_field("u.", "user_name");
(u should change 8 lines.

Next, find:
Code: [Select]
  $sql = "SELECT COUNT(*) AS users
          FROM ".USERS_TABLE."
          WHERE $condition AND ".get_user_table_field("", "user_id")." <> ".GUEST;
Replace it with:
Code: [Select]
  $sql = "SELECT COUNT(*) AS users
          FROM ".USERS_TABLE." u
          WHERE $condition AND ".get_user_table_field("u.", "user_id")." <> ".GUEST;

And last find:
Code: [Select]
    $sql = "SELECT ".get_user_table_field("", "user_id").get_user_table_field(", ", "user_name").get_user_table_field(", ", "user_email").get_user_table_field(", ", "user_joindate").get_user_table_field(", ", "user_lastaction")."
            FROM ".USERS_TABLE."
            WHERE $condition AND ".get_user_table_field("", "user_id")." <> ".GUEST."
            ORDER BY $orderby $direction
            LIMIT $limitstart, $limitnumber";
Replace it with:
Code: [Select]
    $sql = "SELECT COUNT(i.image_id) AS num, ".get_user_table_field("u.", "user_id").get_user_table_field(", u.", "user_name").get_user_table_field(", u.", "user_email").get_user_table_field(", u.", "user_joindate").get_user_table_field(", u.", "user_lastaction")."
            FROM ".USERS_TABLE." u
            LEFT JOIN ".IMAGES_TABLE." i ON (i.user_id = u.user_id)
            WHERE $condition AND ".get_user_table_field("u.", "user_id")." <> ".GUEST."
            GROUP BY u.user_id
            ORDER BY $orderby $direction
            LIMIT $limitstart, $limitnumber";
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline ascanio

  • Hero Member
  • *****
  • Posts: 569
    • View Profile
    • http://www.surfourspace.net
Re: Sort user by upload in CPA
« Reply #2 on: April 24, 2005, 10:31:17 PM »
Hey V@no thanks a lot and can we sort the images en edit images by size? i'm getting close to my megasbytes limit in my server so i wanna delete the biggers ones

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: Sort user by upload in CPA
« Reply #3 on: April 24, 2005, 10:41:59 PM »
sorry, no, its not possible, because image dimentions an sizes not being saved in the database.
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline ascanio

  • Hero Member
  • *****
  • Posts: 569
    • View Profile
    • http://www.surfourspace.net
Re: Sort user by upload in CPA
« Reply #4 on: April 24, 2005, 10:46:21 PM »
oooh ok i understand :), i have a problem modifiging what u just told me ...

Code: [Select]
$condition = "1=1";

  $user_level = intval($HTTP_POST_VARS['user_level']);
  if ($user_level == 0) {
     $user_level = intval($HTTP_GET_VARS['user_level']);
  }
  if ($user_level != GUEST) {
    $condition .= " AND ".get_user_table_field("", "user_level")." = $user_level";
  }
  $user_name = trim($HTTP_POST_VARS['user_name']);
  if ($user_name != "") {
    $condition .= " AND INSTR(LCASE(".get_user_table_field("", "user_name")."),'".strtolower($user_name)."')>0";
  }
  $user_email = trim($HTTP_POST_VARS['user_email']);
  if ($user_email != "") {
    $condition .= " AND INSTR(LCASE(".get_user_table_field("", "user_email")."),'".strtolower($user_email)."')>0";
  }
  $dateafter = trim($HTTP_POST_VARS['dateafter']);
  if ($dateafter != "") {

that what i find after
Code: [Select]
$condition = "1=1"; and i just see one
Code: [Select]
$orderby = trim($HTTP_POST_VARS['orderby']);
  if ($orderby == "") {
    $orderby = get_user_table_field("", "user_name");

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: Sort user by upload in CPA
« Reply #5 on: April 24, 2005, 11:06:05 PM »
yes, replace them all.
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline ascanio

  • Hero Member
  • *****
  • Posts: 569
    • View Profile
    • http://www.surfourspace.net
Re: Sort user by upload in CPA
« Reply #6 on: April 24, 2005, 11:21:35 PM »
ok V@no that worked like always :P and i have other question is there any way to have another colum  showing the number of pics that the have uploaded??

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: Sort user by upload in CPA
« Reply #7 on: April 25, 2005, 12:11:57 AM »
try replace
Code: [Select]
      echo "<td><b>".$show_user_name."</b></td>\n";with
Code: [Select]
      echo "<td><b>".$show_user_name."</b> (".$user_row['num'].")</td>\n"; it will show number of images next to their name.
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline ascanio

  • Hero Member
  • *****
  • Posts: 569
    • View Profile
    • http://www.surfourspace.net
Re: Sort user by upload in CPA
« Reply #8 on: April 25, 2005, 12:15:18 AM »
awesome!!!!! :)