MyChat add-ons: developing, technical questions, testing, documentation and other useful information
User avatar
Alona Kutsenko
Task: Several companies work on the same physical server. A group of administrators maintains these companies. Users must not see people from other companies.

1. Create a common contact list; remove access to it for all rights groups, except administrators and directors. All registered users are in the common contact list. It is convenient for company management and administrators.

2. Create user groups on the server, the section "Users", "Users groups" by company names. Place users to these groups.

3. Make auto-created conferences on the server (by companies). Include ready user groups for these conferences. The conferences are public to people for free access and viewing.

4. Run the scripts to create personal contacts automatically for quick user navigation in these companies (you able to call, or write to an offline person). The script runs on-demand, manually, or schedule it for running once a day, for example.

Code: Select all
// ---------------------------------------
// Script created by Alexey Pikurov ([email protected])
// 15.09.2019 17:15:30
// ---------------------------------------
// A list of groups separated by the symbol "|".
// These are company names on your server
// for which you have to create personal contact lists
const
  GROUPS = 'IceCream Inc.' + '|' +
           'FixIt Software';
var
  sGroups, sCurrentGroup, sUINS, sBackup, s: string;
  iUINOwner, iUIN: integer;
begin
  sGroups := GROUPS;
 
    while length(sGroups) > 0 do begin
      sCurrentGroup := Fetch(sGroups, '|');
      sUINS   := mGetUsersListInGroupsByNames(sCurrentGroup); // getting a list of group users
      sBackup := sUINS; // making a backup copy for the cycle below
     
        while length(sUINS) > 0 do begin // sorting through group users
          iUINOwner := StrToInt(Fetch(sUINS, ','));
          mPersonalContactsClear(iUINOwner); // deleting the personal contact list of a user
          s := sBackup;
           
            while length(s) > 0 do begin // creating a new personal contact list for this user
              iUIN := StrToInt(Fetch(s, ','));
             
                // if UIN of a user does not match your own UIN add it to the list,
                // group name - company name where a person works
                if iUIN <> iUINOwner then mPersonalContactsAddUser(iUINOwner, iUIN, sCurrentGroup);
            end;
           
            // if a user online update his personal contact list
            if mIsUINOnline(iUINOwner) then mPersonalContactsRefresh(iUINOwner);
        end;
    end;
end.

How it looks like after you run the script:

how-to-make-auto-contacts-list.png
how-to-make-auto-contacts-list.png (13.29 KiB) Viewed 15619 times

The script will work in a new MyChat version (after v.7.7)