Author Topic: [MOD] List group members and Enhanced administrator Email  (Read 36273 times)

0 Members and 1 Guest are viewing this topic.

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
[MOD] List group members and Enhanced administrator Email
« on: April 13, 2005, 01:21:45 AM »
This mod was created by chlee but was lost after the hack. I'm just recovering it.



I did a quick hack to list group members from usergroups.php. It is simple and need only 3 files to be modified.

Open your admin/usergroups.php and find
Code: [Select]

echo "<tr class=\"".get_row_bg()."\"><td><p><b>".$row['group_name']."</b></p></td><td><p>";
    show_text_link($lang['edit'], "usergroups.php?action=editgroup&group_id=".$row['group_id']);
    show_text_link($lang['delete'], "usergroups.php?action=removegroup&group_id=".$row['group_id']);


Add after it with this:
Code: [Select]

show_text_link($lang['list_members'], "users.php?action=findusers&user_level=-1&group_id=".$row['group_id']);


Open your lang/yourlang/admin.php and add this line to the bottom of usergroups block (or anywhere you like)
Code: [Select]

$lang['list_members'] = "list members";


Open your admin/users.php and find these:
Code: [Select]
  $user_level = intval($HTTP_POST_VARS['user_level']);

and replace those with:
Code: [Select]
  $array = array("user_level", "user_name", "user_email", "dateafter", "datebefore", "lastactionafter", "lastactionbefore", "orderby");
  foreach($array as $val)
  {
    if (!isset($HTTP_POST_VARS[$val]))
    {
      $HTTP_POST_VARS[$val] = (isset($HTTP_GET_VARS[$val])) ? $HTTP_GET_VARS[$val] : "";
    }
  }
  $group_id = trim($HTTP_GET_VARS['group_id']);
  $group_sql = "";
  if ($group_id !="") {
     $now_timestamp = time();
     $condition .= " AND group_id = $group_id AND groupmatch_startdate < $now_timestamp".
                  " AND (groupmatch_enddate > $now_timestamp OR groupmatch_enddate = 0)";
     $group_sql = " INNER JOIN ".GROUP_MATCH_TABLE." ON ".USERS_TABLE.".user_id=".GROUP_MATCH_TABLE.".user_id ";
  }
  $user_level = intval($HTTP_POST_VARS['user_level']);
  if ($user_level == 0) {
     $user_level = intval($HTTP_GET_VARS['user_level']);
  }



Find next:
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.$group_sql."
          WHERE $condition AND ".USERS_TABLE.".".get_user_table_field("", "user_id")." <> ".GUEST;


Find next:
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."

Replace it with:
Code: [Select]
    $sql = "SELECT ".USERS_TABLE.".".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.$group_sql."
            WHERE $condition AND ".USERS_TABLE.".".get_user_table_field("", "user_id")." <> ".GUEST."


Done!
« Last Edit: April 24, 2009, 02:24:30 AM by V@no »
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 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: [MOD] List group members and Enhanced administrator Email
« Reply #1 on: April 13, 2005, 01:23:58 AM »
Another reply by chlee:


Further enhancement to this quick mod allows you to send emails based on group, or any search criteria users.php allows (Though very ugly code, it works)

in admin/users.php find
Code: [Select]

if ($action == "findusers") {


add these lines before it
Code: [Select]

if ($action == "sendemails") {
  $error = array();
  $subject = stripslashes(trim($HTTP_POST_VARS['subject']));
  $message = stripslashes(trim($HTTP_POST_VARS['message']));

  if ($subject == "") {
    $error['subject'] = 1;
  }
  if ($message == "") {
    $error['message'] = 1;
  }
  if (!isset($HTTP_POST_VARS['emails']) || empty($HTTP_POST_VARS['emails'])) {
     $error['emails'] = 1;
  } else {
     $emails = $HTTP_POST_VARS['emails'];
  }

  if (empty($error)) {
    @set_time_limit(1200);
    include_once(ROOT_PATH.'includes/email.php');
    $site_email = new Email();
    $site_email->set_to($config['site_email']);
    $site_email->set_subject($subject);
    $site_email->register_vars(array(
      "message" => $message,
      "site_email" => $config['site_email'],
      "site_name" => $config['site_name']
    ));
    $site_email->set_body("admin_email", $config['language_dir']);
    $site_email->set_bcc($emails);
   echo ($site_email->send_email()) ? $lang['send_emails_success'] : $lang['send_emails_error'];
    echo "<p>";
    show_text_link($lang['back'], "javascript:history.back(1)");
  }
  else {
    $msg = sprintf("<span class=\"marktext\">%s</span>", $lang['lostfield_error']);
    $action = "mass_email";
  }
}

if ($action == "mass_email") {
  if ($msg != "") {
    printf("<b>%s</b>n", $msg);
  }
  if (!isset($HTTP_POST_VARS['emails']) || empty($HTTP_POST_VARS['emails'])) {
     if (isset($HTTP_POST_VARS['deleteusers']) && !empty($HTTP_POST_VARS['deleteusers'])) {
        $emails = array();
        $user_ids = $HTTP_POST_VARS['deleteusers'];
        foreach ($user_ids as $id_val) {
           $ids_tosend .=  ",".$id_val;
        }
        $ids_tosend = substr($ids_tosend, 1);
        $sql = "SELECT user_email FROM ".USERS_TABLE." WHERE user_id IN (".$ids_tosend.")";
        $result = $site_db->query($sql);
        while ($email_row = $site_db->fetch_array($result)) {
           $emails[] = $email_row['user_email'];
        }
     }
  } else {
     $emails = $HTTP_POST_VARS['emails'];
  }
  show_form_header("users.php", "sendemails");
  show_table_header($lang['send_emails'], 2);
  show_input_row($lang['send_emails_subject'], "subject", "", 45);
  show_textarea_row($lang['send_emails_message'], "message", "", 60, 20);
  foreach ($emails as $key => $hidden_val) {
     show_hidden_input("emails[".$key."]", $hidden_val);
  }
  $title = $lang['mass_email'];
  if (isset($error['emails'])) {
    $title = sprintf("<span class=\"marktext\">%s *</span>", $title);
  }
  show_form_footer($lang['send_emails'], "", 2);
}


Find
Code: [Select]

      show_text_link($lang['delete'],"users.php?action=removeuser&user_id=".$user_row[$user_table_fields['user_id']]);
      echo "&nbsp;&nbsp;";
      show_text_link($lang['permissions'], "usergroups.php?action=editpermissions&user_id=".$user_row[$user_table_fields['user_id']]);
      show_text_link($lang['nav_usergroups'], "usergroups.php?action=edituser&user_id=".$user_row[$user_table_fields['user_id']]);
      echo "</p></td>n";
      echo "</tr>n";
    }
   
    echo "<tr class=\"tablefooter\">n<td colspan=\"6\" align=\"left\">n&nbsp;";


Add this line after it
Code: [Select]

echo "<input type=\"button\" value=\"  ".$lang['mass_email']."   \" onclick=\"action.value='mass_email';submit();\" class=\"button\">n";


Add a line in lang/yourlang/admin.php at the bottom of the user block (or anywhere you like)
Code: [Select]

$lang['mass_email'] = "Mass message";


Done!
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: [MOD] List group members and Enhanced administrator Email
« Reply #2 on: April 13, 2005, 04:57:27 AM »
Great MODs, I was waiting for something like this :):)

Offline michi-w.

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
Re: [MOD] List group members and Enhanced administrator Email
« Reply #3 on: April 14, 2005, 04:03:17 PM »
Good job, thanks!

Mod 1 is a link "list members" under usergroup.
Mod 2 is a "Mass message" button and email formular under "list members".

Offline Michi0310

  • Newbie
  • *
  • Posts: 19
    • View Profile
    • Roadrunners Untermosel
Re: [MOD] List group members and Enhanced administrator Email
« Reply #4 on: April 17, 2005, 03:47:54 PM »
Hi.. Bekomme da nen DB Error beim Aufruf der Liste:
Quote
DB Error: Bad SQL Query: SELECT COUNT(*) AS users FROM bb1_users INNER JOIN 4images_groupmatch ON bb1_users.user_id=4images_groupmatch.user_id WHERE 1=1 AND group_id = 3 AND groupmatch_startdate < 1113745570 AND (groupmatch_enddate > 1113745570 OR groupmatch_enddate = 0) AND bb1_users.userid <> -1
Unknown column 'bb1_users.user_id' in 'on clause'
Gefunden: . Angezeigt: 0-.

Hängt das vielleicht damit zusammen das ich die WBB-Lite Integration von Jens21 drin habe und Version 1.7.1 nutze ?
Hat einer ne Lösung für mich ?
Bye
MICHI
(Admin of TG-STUFF)

Offline shamend143

  • Newbie
  • *
  • Posts: 23
    • View Profile
Re: [MOD] List group members and Enhanced administrator Email
« Reply #5 on: May 02, 2005, 10:33:14 PM »
great mod but this doesnot work if we are using integration with IPB

Offline ascanio

  • Hero Member
  • *****
  • Posts: 569
    • View Profile
    • http://www.surfourspace.net
Re: [MOD] List group members and Enhanced administrator Email
« Reply #6 on: May 03, 2005, 12:28:44 AM »
hi i got this mod working when i installed it but now i get this error :S
Code: [Select]
DB Error: Bad SQL Query: SELECT COUNT(*) AS users FROM girls_users u WHERE 1=1 AND group_id = 87 AND groupmatch_startdate < 1115072841 AND (groupmatch_enddate > 1115072841 OR groupmatch_enddate = 0) AND u.user_id <> -1
Unknown column 'group_id' in 'where clause'
Encontrados: . Mostrados: 0-.

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: [MOD] List group members and Enhanced administrator Email
« Reply #7 on: May 03, 2005, 12:42:52 AM »
hi i got this mod working when i installed it but now i get this error
it worked just fine before and now all of the sudden it doesnt???
* V@no doubt it :roll:
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: [MOD] List group members and Enhanced administrator Email
« Reply #8 on: May 03, 2005, 01:33:39 AM »
yep, it was working perfectly and yesterday i check the listing member thing and that error appear :S

Offline ascanio

  • Hero Member
  • *****
  • Posts: 569
    • View Profile
    • http://www.surfourspace.net
Re: [MOD] List group members and Enhanced administrator Email
« Reply #9 on: May 03, 2005, 06:55:20 PM »
please what can i do about that

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: [MOD] List group members and Enhanced administrator Email
« Reply #10 on: May 03, 2005, 11:47:22 PM »
there is nothing happens by itself...really...
perhaps reinstall the mod?
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: [MOD] List group members and Enhanced administrator Email
« Reply #11 on: May 03, 2005, 11:56:10 PM »
i did :(

Offline Josef Florian

  • Newbie
  • *
  • Posts: 27
    • View Profile
Re: [MOD] List group members and Enhanced administrator Email
« Reply #12 on: May 15, 2005, 10:51:28 PM »
Wow, danke vielmals!

Nach solch einem Mod habe ich schon lange gesucht! Danke vielmals!

Liebe Grüße!
    • running v1.7.6 with MOD: SortImageAsYouLike / Cooliris Slideshow
    • with © removal
    • i have problems with:
actually no[/list]

Offline TIMT

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
Re: [MOD] List group members and Enhanced administrator Email
« Reply #13 on: June 12, 2005, 10:36:41 PM »
Hi everybody

When I klick on the memberlist, members are shown for several times. Some of them are displayed three, some eight times?
Why that?

Serge

Offline TIMT

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
Re: [MOD] List group members and Enhanced administrator Email
« Reply #14 on: June 17, 2005, 04:08:39 PM »
Ich habe drei Usergruppen:
Kunde
Fotograf
Aussteller

Wenn ich mir die Liste Usergruppe anschaue, erscheinen gewisse User mehrfach.
Ich sehe aber kein Muster. Einige User erscheinen nur 1 Mal, andere mehrere Male.

Gruss
TIMT