4images Forum & Community

4images Modifications / Modifikationen => Mods & Plugins (Releases & Support) => Topic started by: V@no on April 13, 2005, 01:21:45 AM

Title: [MOD] List group members and Enhanced administrator Email
Post by: V@no 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!
Title: Re: [MOD] List group members and Enhanced administrator Email
Post by: V@no 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!
Title: Re: [MOD] List group members and Enhanced administrator Email
Post by: ascanio on April 13, 2005, 04:57:27 AM
Great MODs, I was waiting for something like this :):)
Title: Re: [MOD] List group members and Enhanced administrator Email
Post by: michi-w. 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".
Title: Re: [MOD] List group members and Enhanced administrator Email
Post by: Michi0310 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 ?
Title: Re: [MOD] List group members and Enhanced administrator Email
Post by: shamend143 on May 02, 2005, 10:33:14 PM
great mod but this doesnot work if we are using integration with IPB
Title: Re: [MOD] List group members and Enhanced administrator Email
Post by: ascanio 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-.
Title: Re: [MOD] List group members and Enhanced administrator Email
Post by: V@no 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???
/me doubt it :roll:
Title: Re: [MOD] List group members and Enhanced administrator Email
Post by: ascanio 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
Title: Re: [MOD] List group members and Enhanced administrator Email
Post by: ascanio on May 03, 2005, 06:55:20 PM
please what can i do about that
Title: Re: [MOD] List group members and Enhanced administrator Email
Post by: V@no on May 03, 2005, 11:47:22 PM
there is nothing happens by itself...really...
perhaps reinstall the mod?
Title: Re: [MOD] List group members and Enhanced administrator Email
Post by: ascanio on May 03, 2005, 11:56:10 PM
i did :(
Title: Re: [MOD] List group members and Enhanced administrator Email
Post by: Josef Florian 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!
Title: Re: [MOD] List group members and Enhanced administrator Email
Post by: TIMT 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
Title: Re: [MOD] List group members and Enhanced administrator Email
Post by: TIMT 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
Title: Re: [MOD] List group members and Enhanced administrator Email
Post by: TIMT on June 19, 2005, 10:43:06 AM
the problem was the tabel " 4images_groupmatch".
I had to save all usergroup definitions in the ACP for all users again.
Then the table "4images_groupmatch" was fine and the list group members were displayed correctly.

I have no idea why the table "4images_groupmatch" was wrong.

TIMT
Title: Re: [MOD] List group members and Enhanced administrator Email
Post by: Bea on January 15, 2006, 03:11:11 PM
Just for blockheads  :wink:
What is the ACP?
Title: Re: [MOD] List group members and Enhanced administrator Email
Post by: V@no on January 15, 2006, 04:50:34 PM
Admin Control Panel
Title: Re: [MOD] List group members and Enhanced administrator Email
Post by: yellows on September 15, 2006, 10:46:56 PM
when listing members, is there a way so the 1st member is most recent added and the last is most nearest to expiring from usergroup

Cheers

James
Title: Re: [MOD] List group members and Enhanced administrator Email
Post by: mawenzi on October 21, 2006, 05:53:14 PM
... this modification should be standard in the ACP by a 4images installation ...
... thanks chlee and v@no ...
Title: Re: [MOD] List group members and Enhanced administrator Email
Post by: Fastian on October 29, 2006, 12:35:16 PM
This is mod is not working with v1.7.4 (At least for me)

When i click on Mass Msgs, all i see is a blank page.

However with one other installation of 4images v 1.7.1, its working just fine.
Title: Re: [MOD] List group members and Enhanced administrator Email
Post by: TIMT on January 01, 2008, 04:25:04 PM
Hi

I have three groups:
photographer
customer
exhibitor

When I click on member-list (e.g. photographer) some users are shown several times.
As i mentioned in a previouse post, the problem ist the file 4images_groupmatch.

Quote
the problem was the tabel " 4images_groupmatch".
I had to save all usergroup definitions in the ACP for all users again.
Then the table "4images_groupmatch" was fine and the list group members were displayed correctly.

It is not possible to do this task again and again (klick on Member List, Klick on Usergroup, Klick Save --> now the user is only shown once in the list)
Why are the Users shown several times in the list (up to 20 times)?

Thanks for helping me.

TIMT
Title: Re: [MOD] List group members and Enhanced administrator Email
Post by: babe on November 22, 2008, 01:04:06 AM
Any chance this can be ported to 1.7.6?
Title: Re: [MOD] List group members and Enhanced administrator Email
Post by: escbln on February 23, 2009, 11:20:21 AM
Is it possible to modify mass-mailing-mod for usage with version 1.7.6?

This tool is great - but it doesn't work.
Title: Re: [MOD] List group members and Enhanced administrator Email
Post by: fermachado on April 23, 2009, 05:59:31 PM
Hi,

Have a litlle problem.  :?

The code in my (1.7.6) user.php is different.

How I can solve this problem. :?

Thanks,
Title: Re: [MOD] List group members and Enhanced administrator Email
Post by: V@no on April 24, 2009, 02:13:10 AM
I've updated instructions.
Title: Re: [MOD] List group members and Enhanced administrator Email
Post by: Marion on May 19, 2011, 12:42:49 PM
Is there perhaps something to do different in 4images 1.7.9 ? I've installed it without any problems but it doesn't list any members when I click "list members", it only shows "keine Einträge gefunden".
I've tried the hint above (save all usergroups definitions for all members again) but there is still no list.

Any hint for me? This MOD would be very useful for me.
Title: Re: [MOD] List group members and Enhanced administrator Email
Post by: Marion on June 13, 2011, 11:50:18 AM
Ich habe die MOD inzwischen schon zweimal neu installiert, es werden einfach keine Gruppenmitglieder bei mir gelistet (4 Usergruppen sind angelegt und mit Mitgliedern gefüllt).
Muss der Code bei 4i 1.7.9 evtl. irgendwo geändert werden?
Dann ist mir aufgefallen, dass im groupmatch table jeder User zweimal aufgeführt ist; einmal mit irgendeiner ID-Zahl und einmal mit der korrekten Usergruppen-ID.
Ist das normales 4i-Verhalten oder ein Fehler in meiner Datenbank bzw. in der Tabelle ?
Title: Re: [MOD] List group members and Enhanced administrator Email
Post by: Rembrandt on June 13, 2011, 12:29:42 PM
...Ist das normales 4i-Verhalten oder ein Fehler in meiner Datenbank bzw. in der Tabelle ?
ohne den mod funktioniert das ja einwandfrei, also wird es entweder am mod oder am mod einbau liegen.

mfg Andi
Title: Re: [MOD] List group members and Enhanced administrator Email
Post by: Marion on June 13, 2011, 01:10:25 PM
Deiner Antwort entnehme ich, dass in der groupmatch table jeder user 2x aufgeführt sein muss, also scheidet die Datentabelle als
Fehlerursache dann sicher aus.

Beim Einbau kann man ja kaum was verkehrt machen, so simpel wie der ist.
Naja, vielleicht hat noch jemand eine Idee, was die Ursache sein kann. Im ACP ist die Mod korrekt zu sehen, sie wird halt nur nicht ausgeführt.

Vielen Dank für Deine Antwort, Andi und schönen Restfeiertag!