head	1.15;
access;
symbols
	TIGRIS_1_1_0RC2:1.9.6.2
	TIGRIS_1_1_0RC1:1.9.6.2
	TIGRIS_1_1:1.9.6.2.0.2
	TIGRIS_1_0_8:1.9.6.2
	TIGRIS_1_0_8RC3:1.9.6.2
	TIGRIS_1_0_8RC2:1.9.6.2
	TIGRIS_1_0_8RC1:1.9.6.2
	TIGRIS_1_0_7:1.9.6.2
	TIGRIS_1_0_7RC3:1.9.6.2
	TIGRIS_1_0_7RC2:1.9.6.2
	TIGRIS_1_0_7RC1:1.9.6.2
	TIGRIS_1_0_6:1.9.6.2
	TIGRIS_1_0_6RC5:1.9.6.2
	TIGRIS_1_0_6RC4:1.9.6.2
	TIGRIS_1_0_6RC3:1.9.6.2
	TIGRIS_1_0_6RC2:1.9.6.2
	TIGRIS_1_0_6RC1:1.9.6.2
	TIGRIS_1_0_5:1.9
	TIGRIS_1_0_5RC6:1.9
	TIGRIS_1_0_5RC5:1.9
	TIGRIS_1_0_5RC4:1.9
	TIGRIS_1_0_5RC3:1.9
	TIGRIS_1_0_5RC2:1.9
	TIGRIS_1_0_5RC1:1.9
	TIGRIS_1_0_4:1.9
	TIGRIS_1_0_3:1.9
	TIGRIS_1_0_2:1.9
	TIGRIS_1_0_1:1.9
	TIGRIS_1_0:1.9.0.6
	TIGRIS_1_0_0:1.9
	TIGRIS_1_0_0_RC1:1.9.0.2
	dlr:1.1.1
	TIGRIS_0_9_2_4:1.8.2.1
	TIGRIS_0_9_2_3:1.8.2.1
	HELM_PEER_PORT_BRANCH:1.1.1.2
	TURBINE_PEER:1.9
	TIGRIS_0_9_2_1:1.9
	TIGRIS_0_9_2:1.8.0.2
	TIGRIS_0_9_0:1.4.0.2
	TIGRIS_0_8_4:1.3.0.2
	NEWHELM:1.1.1.1
	TIGRIS_NOV_12_2000:1.1.1;
locks; strict;
comment	@# @;


1.15
date	2001.07.30.18.07.19;	author kmaples;	state dead;
branches;
next	1.14;

1.14
date	2001.06.06.22.26.45;	author kmaples;	state Exp;
branches;
next	1.13;

1.13
date	2001.06.05.22.36.18;	author kmaples;	state Exp;
branches;
next	1.12;

1.12
date	2001.05.30.22.06.50;	author kmaples;	state Exp;
branches;
next	1.11;

1.11
date	2001.04.18.02.02.58;	author kmaples;	state Exp;
branches;
next	1.10;

1.10
date	2001.04.17.04.44.54;	author kmaples;	state Exp;
branches;
next	1.9;

1.9
date	2001.01.26.18.31.44;	author kmaples;	state Exp;
branches
	1.9.6.1;
next	1.8;

1.8
date	2001.01.13.02.04.52;	author kmaples;	state Exp;
branches
	1.8.2.1;
next	1.7;

1.7
date	2000.12.29.00.32.29;	author kmaples;	state Exp;
branches;
next	1.6;

1.6
date	2000.12.28.01.48.09;	author kmaples;	state Exp;
branches;
next	1.5;

1.5
date	2000.12.27.22.57.44;	author kmaples;	state Exp;
branches;
next	1.4;

1.4
date	2000.12.08.23.58.26;	author kmaples;	state Exp;
branches;
next	1.3;

1.3
date	2000.11.16.04.36.42;	author kmaples;	state Exp;
branches
	1.3.2.1;
next	1.2;

1.2
date	2000.11.16.00.38.49;	author kmaples;	state Exp;
branches;
next	1.1;

1.1
date	2000.11.12.21.17.39;	author dlr;	state Exp;
branches
	1.1.1.1;
next	;

1.1.1.1
date	2000.11.12.21.17.39;	author dlr;	state Exp;
branches;
next	1.1.1.2;

1.1.1.2
date	2001.02.21.00.36.20;	author dlr;	state Exp;
branches;
next	;

1.3.2.1
date	2000.12.12.18.23.03;	author kmaples;	state Exp;
branches;
next	;

1.8.2.1
date	2001.01.26.18.45.25;	author kmaples;	state Exp;
branches;
next	;

1.9.6.1
date	2001.05.31.01.29.28;	author kmaples;	state Exp;
branches;
next	1.9.6.2;

1.9.6.2
date	2001.06.06.22.50.17;	author kmaples;	state Exp;
branches;
next	;


desc
@@


1.15
log
@Issue number: 4544, 4242
Making the world a better place by removing the scripts the taskrunner
used to need to run to create IZ users.
@
text
@#!/usr/bin/perl

# ================================================================
# Copyright (c) 2000 Collab.Net.  All rights reserved.
# 
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
# 
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 
# 3. The end-user documentation included with the redistribution, if
# any, must include the following acknowlegement: "This product includes
# software developed by Collab.Net (http://www.Collab.Net/)."
# Alternately, this acknowlegement may appear in the software itself, if
# and wherever such third-party acknowlegements normally appear.
# 
# 4. The hosted project names must not be used to endorse or promote
# products derived from this software without prior written
# permission. For written permission, please contact info@@collab.net.
# 
# 5. Products derived from this software may not use the "Tigris" name
# nor may "Tigris" appear in their names without prior written
# permission of Collab.Net.
# 
# THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
# IN NO EVENT SHALL COLLAB.NET OR ITS CONTRIBUTORS BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# ====================================================================
# 
# This software consists of voluntary contributions made by many
# individuals on behalf of Collab.Net.
#


# 
# $Id: issuezilla-user-delete,v 1.14 2001/06/06 22:26:45 kmaples Exp $
# --------------------
# 

# Flush buffer, just in case:
$| = 1;

use strict;
use DBI;

# For the sake of -T:
$ENV{'PATH'} = "/bin:/usr/bin:/usr/local/bin";

# Process arguments
my $project_name       = $ARGV[0] || '';
my $dbname             = $ARGV[1] || '';
my $domain_name        = $ARGV[2] || '';
my $issues_username    = $ARGV[3] || ''; # : - sep. list
my $multiple_dbs       = $ARGV[4] || '';  

# Split the list of users:
my @@usernames = split(':',$issues_username);

# Vars to handle disabling - since we don't really delete the users,
# we disable them in two ways - through IZ (disabled text), and through
# helm (prefix) - the latter effectively moving the user aside.
my $disabled_text = 'This account has been disabled.';
my $disabled_pfx  = 'ex-';

# String for current sql statement
my $command;

# Placeholder vars for db work:
my ($select, $ret);

# NOTE - this script requires the info necessary to connect
# to the correct DB, e.g., username/password, DB name, etc.

my $dbuser         = $ENV{DATABASE_USER}     || '';
my $dbpass         = $ENV{DATABASE_PASSWORD} || '';

# Grab just the filename portion of this script to use as a 
# log identifier:
my $script_name = $0;
$script_name =~ s/^.*\/([^\/]+)$/  $1/;

# Default return value for this script:
my $return_code = 0;

#---------------------------------------------------------------
# MAIN
#---------------------------------------------------------------
# This is a little convoluted - but here goes:  Helm will 
# call this script whenever a user has lost all roles in a
# given project, and when a user is deleted from the site as 
# a whole, this will be called once for each project that 
# user had a role in.
#
# If we're in multiple db mode, the first act translates to
# deleting the user from issuezilla - but not in single db
# mode.  In single mode, there may be many projects in the 
# database, and we only want to delete the user when this is
# the last project that the user had any role in - and this 
# is equivalent to being delete from the site as a whole.
#
# So in either case, Helm will send a last request to delete
# when all other deletes from specific projects are done - 
# a request to delete from the project with the name,
# '*All projects in domain'.  In multiple mode, we disregard
# this, but in single mode, this is the only request we 
# honor.

if($project_name =~ m/^\*/){
    # If we're in multiple db mode, disregard this call as 
    # it's covered by repeated calls to removed the member
    # from individual projects:  
    print "$script_name: Received 'DELETE FROM ALL' signal\n";
    if($multiple_dbs){
        print "$script_name: Database flag set to MULTIPLE; no action\n";
        exit(0);
    }
} else {
    # Conversely, unless we're in single db mode, we can
    # disregard all calls that aren't a request to remove 
    # from all projects:
    unless($multiple_dbs){
        print "$script_name: Database flag set to SINGLE; no action\n";
        exit(0); 
    }
}

# Fail if we don't have what we need to talk to the database:
unless($dbname && $dbuser && $dbpass){
    print "$script_name: envrionmentals for DB access not set\n";
    exit(1);
}

my $dbc = join(':',"DBI:mysql:$dbname",$ENV{DATABASE_HOST},$ENV{DATABASE_PORT});
my $CONN = DBI->connect($dbc, $dbuser, $dbpass);

# Check for a good connection:
unless( $CONN =~ m/HASH/){
    print "$script_name: no connection to database: $!\n";
    exit(1);
}

my @@iz_usernames = @@usernames;

foreach(@@iz_usernames){
    # Convert helm usernames to iz-style email addresses:
    $_ .= '@@' . $domain_name;
    # sql-quote the names:
    $_ = $CONN->quote( $_ );
}

# Quote the constants:
$disabled_text = $CONN->quote( $disabled_text );
$disabled_pfx  = $CONN->quote( $disabled_pfx );

my $login_names = join(',',@@iz_usernames);

# Update the 'profiles' table - note that no attempt is made 
# to determine that a record exists:
print "$script_name: disabling previous records in 'profiles' table\n";

$command = qq[
    UPDATE profiles SET
    login_name     = concat( $disabled_pfx , login_name), 
    disabledtext   = $disabled_text
    WHERE
    login_name IN ($login_names)
];
    
$select = $CONN->prepare($command);
$ret    = $select->execute;

if($ret && $ret ne '0E0'){
    print "$script_name: disabled accounts.\n";
} else {
    # This represents a failure of some sort, but what is not
    # determined.  Presumably, either there were no records to 
    # disable, or there was already an account by the (disabled)
    # name.  However, since there may be a number of users that
    # this script is being run against, don't blow out here, but
    # make a note that all was not well:
    print "$script_name: no update performed.\n";
    $return_code = 1;
} 

# Clean up and leave quietly:
$select->finish();
$CONN->disconnect;

exit($return_code);

#---------------------------------------------------------------
# END MAIN
#---------------------------------------------------------------


@


1.14
log
@Issue number: 4242
Rewrote the sql so that all users are deleted in a single statement.
@
text
@d51 1
a51 1
# $Id: issuezilla-user-delete,v 1.13 2001/06/05 22:36:18 kmaples Exp $
@


1.13
log
@Issue number: 4242
Completely removing IZ's password and LDAP code.  This is in advance of
more signifigant changes to persuade IZ to obtain permission information
directly from Helm.

This is a large-scale cleanup of code which is useless to IZ, since it
obtains the information it uses for authentication from Helm in any event.
Password information was merely dummy strings that acted as placeholders
in the profiles table; as of now, it is sufficient to have an entry in
the profiles table (non-disabled, of course) for access.

Related changes can be found in issuezilla/
@
text
@d51 1
a51 1
# $Id: issuezilla-user-delete,v 1.11 2001/04/18 02:02:58 kmaples Exp $
d157 9
d168 1
d170 13
a182 12
for(0 .. $#usernames){
    # Some email address for issuezilla:
    my $login_name          = $usernames[$_] . '@@' . $domain_name;
    my $disabled_login_name = $disabled_pfx . $login_name;

    # Do the sql quoting for the values we're gonna play with:
    $login_name          = $CONN->quote( $login_name );
    $disabled_login_name = $CONN->quote( $disabled_login_name );
    
    # Update the 'profiles' table - note that no attempt is made 
    # to determine that a record exists:
    print "$script_name: disabling previous record in 'profiles' table for $login_name\n";
d184 2
a185 10
    $command = qq[
        UPDATE profiles SET
        login_name     = $disabled_login_name,
        disabledtext   = $disabled_text
        WHERE
        login_name     = $login_name
    ];
    
    $select = $CONN->prepare($command);
    $ret    = $select->execute;
d187 12
a198 13
    if($ret && $ret ne '0E0'){
        print "$script_name: disabled account $login_name\n";
    } else {
        # This represents a failure of some sort, but what is not
        # determined.  Presumably, either there was no record to 
        # disable, or there was already an account by the (disabled)
        # name.  However, since there may be a number of users that
        # this script is being run against, don't blow out here, but
        # make a note that all was not well:
        print "$script_name: no update performed.\n";
        $return_code = 1;
    } 
}
d209 1
@


1.12
log
@Issue number: 4242

Providing some optimizations to reduce the number sql hits per operation.
If successful, will port this to branch.
@
text
@d175 2
a176 2
            login_name     = $disabled_login_name,
            disabledtext   = $disabled_text
d178 1
a178 1
            login_name     = $login_name
@


1.11
log
@Undoing yesterday's commit - my hastiness to implement some sort of logging
level notion into these scripts caused me great pain.
@
text
@d51 1
a51 1
# $Id: issuezilla-user-delete,v 1.9 2001/01/26 18:31:44 kmaples Exp $
a62 2
# Detaint the args by brute force:
@@ARGV = detaint_array(@@ARGV);
a70 2
my $issues_password    = $ENV{ISSUZILLA_PASSWORD};

d97 3
d169 3
a171 2
    # Test and insert in the 'profiles' table:
    print "$script_name: checking for previous record in 'profiles' table for $login_name\n";
d174 5
a178 3
        SELECT * FROM profiles WHERE
        login_name     = $login_name
        LIMIT 1
d183 1
a183 1
    
a184 21
        print "$script_name: record found\n";
        # Normally, this would be the end of it - we'd declare success.  But there
        # is the probability that this will be called on users that already exist.
        # If this is the case, we want to disable the account: 
    
        $command = qq[
            UPDATE profiles SET
            login_name     = $disabled_login_name,
            disabledtext   = $disabled_text
            WHERE
            login_name     = $login_name
        ];
    
        $select = $CONN->prepare($command);
        $ret    = $select->execute;
    
        unless($ret){
            print "$script_name: unable to perform update: $!\n";
            $CONN->disconnect;
            exit(1);
        }
d187 9
a195 2
        print "$script_name: no record found to disable.\n";
    }
d202 2
a206 18


# A crude attempt to overcome data tainting in perl:
#-------------------
sub detaint_array {
#-------------------
    my @@unclean = @@_;
    my @@clean = ();

    foreach(@@unclean){
        # We don't really have rules for this, so at the moment
        # this acts as a passthrough:
        $_ =~ m/^(.*)$/;
        push(@@clean,$1);
    }

    return(@@clean);
}
@


1.10
log
@Scripts now use IN_PRODUCTION to determine logging level
@
text
@a54 5
my $scripts_dir = $ENV{'SANDBOX'} . '/helm/perl/scripts';

require "$scripts_dir/ParentChildArgumentBridge.pl"
    or die "Require failed: $!\n";

d128 1
a128 1
    print_log(1, "$script_name: Received 'DELETE FROM ALL' signal\n");
d130 1
a130 1
        print_log(1, "$script_name: Database flag set to MULTIPLE; no action\n");
d138 1
a138 1
        print_log(1, "$script_name: Database flag set to SINGLE; no action\n");
d145 1
a145 1
    print_log(1, "$script_name: envrionmentals for DB access not set\n");
d154 1
a154 1
    print_log(1, "$script_name: no connection to database: $!\n");
d171 1
a171 1
    print_log(1, "$script_name: checking for previous record in 'profiles' table for $login_name\n");
d183 1
a183 1
        print_log(1, "$script_name: record found\n");
d200 1
a200 1
            print_log(1, "$script_name: unable to perform update: $!\n");
d204 1
a204 1
        print_log(1, "$script_name: disabled account $login_name\n");
d206 1
a206 1
        print_log(1, "$script_name: no record found to disable.\n");
@


1.9
log
@The ')' is NOT optional.  My bad.
@
text
@d51 1
a51 1
# $Id: issuezilla-user-delete,v 1.8 2001/01/13 02:04:52 kmaples Exp $
d55 5
d133 1
a133 1
    print "$script_name: Received 'DELETE FROM ALL' signal\n";
d135 1
a135 1
        print "$script_name: Database flag set to MULTIPLE; no action\n";
d143 1
a143 1
        print "$script_name: Database flag set to SINGLE; no action\n";
d150 1
a150 1
    print "$script_name: envrionmentals for DB access not set\n";
d159 1
a159 1
    print "$script_name: no connection to database: $!\n";
d176 1
a176 1
    print "$script_name: checking for previous record in 'profiles' table for $login_name\n";
d188 1
a188 1
        print "$script_name: record found\n";
d205 1
a205 1
            print "$script_name: unable to perform update: $!\n";
d209 1
a209 1
        print "$script_name: disabled account $login_name\n";
d211 1
a211 1
        print "$script_name: no record found to disable.\n";
@


1.9.6.1
log
@Issue number: 4242
Reviewed by:  stack@@collab.net
Porting to branch several changes to the scripts which manipulate iz
users to reduce the number of db hits per operation.
@
text
@d51 1
a51 1
# $Id: issuezilla-user-delete,v 1.11 2001/04/18 02:02:58 kmaples Exp $
d63 2
d73 2
a100 3
# Default return value for this script:
my $return_code = 0;

d170 2
a171 3
    # Update the 'profiles' table - note that no attempt is made 
    # to determine that a record exists:
    print "$script_name: disabling previous record in 'profiles' table for $login_name\n";
d174 1
a174 4
        UPDATE profiles SET
        login_name     = $disabled_login_name,
        disabledtext   = $disabled_text
        WHERE
d176 1
d181 1
a181 1

d183 21
d206 2
a207 9
        # This represents a failure of some sort, but what is not
        # determined.  Presumably, either there was no record to 
        # disable, or there was already an account by the (disabled)
        # name.  However, since there may be a number of users that
        # this script is being run against, don't blow out here, but
        # make a note that all was not well:
        print "$script_name: no update performed.\n";
        $return_code = 1;
    } 
a213 2
exit($return_code);

d217 18
@


1.9.6.2
log
@Issue number: 4242
Reviewed by:  leonardr@@collab.net
Porting from HEAD; Rewrote the sql so that all users are deleted in a single
statement.
@
text
@d51 1
a51 1
# $Id: issuezilla-user-delete,v 1.14 2001/06/06 22:26:45 kmaples Exp $
a156 9
my @@iz_usernames = @@usernames;

foreach(@@iz_usernames){
    # Convert helm usernames to iz-style email addresses:
    $_ .= '@@' . $domain_name;
    # sql-quote the names:
    $_ = $CONN->quote( $_ );
}

a158 1
$disabled_pfx  = $CONN->quote( $disabled_pfx );
d160 20
a179 13
my $login_names = join(',',@@iz_usernames);

# Update the 'profiles' table - note that no attempt is made 
# to determine that a record exists:
print "$script_name: disabling previous records in 'profiles' table\n";

$command = qq[
    UPDATE profiles SET
    login_name     = concat( $disabled_pfx , login_name), 
    disabledtext   = $disabled_text
    WHERE
    login_name IN ($login_names)
];
d181 2
a182 2
$select = $CONN->prepare($command);
$ret    = $select->execute;
d184 13
a196 12
if($ret && $ret ne '0E0'){
    print "$script_name: disabled accounts.\n";
} else {
    # This represents a failure of some sort, but what is not
    # determined.  Presumably, either there were no records to 
    # disable, or there was already an account by the (disabled)
    # name.  However, since there may be a number of users that
    # this script is being run against, don't blow out here, but
    # make a note that all was not well:
    print "$script_name: no update performed.\n";
    $return_code = 1;
} 
a206 1

@


1.8
log
@First furtive attempts to support remote databases.
@
text
@d51 1
a51 1
# $Id: issuezilla-user-delete,v 1.7 2000/12/29 00:32:29 kmaples Exp $
d150 1
a150 1
my $CONN = DBI->connect($dbc, $dbuser, $dbpass;
@


1.8.2.1
log
@PR: 2131
Forgot closing ')'.
@
text
@d51 1
a51 1
# $Id: issuezilla-user-delete,v 1.8 2001/01/13 02:04:52 kmaples Exp $
d150 1
a150 1
my $CONN = DBI->connect($dbc, $dbuser, $dbpass);
@


1.7
log
@Changes to facilitate single-db mode - now the behavior of user delete
depends on the database setting and the type of delete instruction being
sent.
@
text
@d51 1
a51 1
# $Id: issuezilla-user-delete,v 1.6 2000/12/28 01:48:09 kmaples Exp $
d149 2
a150 2
my $dbc = "DBI:mysql:$dbname";
my $CONN = DBI->connect($dbc, $dbuser, $dbpass);
@


1.6
log
@Implemented the following changes to support single-db installations of
IZ based on conversations with CC - these changes only apply to elements
in issuezilla.  When IZ is in single-db mode:

* Users are added if the do not exist
* User roles are flattened to either 'observer' or 'admin'
* User accounts are NOT updated with new permissions if they already exist
* User accounts are NOT deleted
* Projects are NOT deleted

The presumption in most/all of these cases is that the admin will be
responsible for manually performing these functions through IZs interface.
All of these changes are to prevent helm updates from inadvertently trashing
users' priviliges in one project when they are changed in another project,
since in single-db mode there's no provision for differentiation.  I
expect to refine this in the near-future.
@
text
@d51 1
a51 1
# $Id: issuezilla-user-delete,v 1.5 2000/12/27 22:57:44 kmaples Exp $
d104 37
a140 6
# Bail out if we're in single-db mode, since we don't currently 
# permit the automated removal of user accounts in that mode:
unless($multiple_dbs){
    print "$script_name: Database flag set to SINGLE; no action\n";
    print "$script_name: Users must be removed manually\n";
    exit(0);
@


1.5
log
@Framework changes to recognize whether database type is set to single or
multiple.  This implements no changes in the behavior of the scripts, only
changes in the framework.
@
text
@d51 1
a51 1
# $Id: issuezilla-user-delete,v 1.4 2000/12/08 23:58:26 kmaples Exp $
d104 8
@


1.4
log
@Changed the way in which users are treated when their accounts are created
or disabled - particularly when all of their roles have been revoked.  Now
when users are 'deleted' (and this can occur when they have had roles in the
project, but currently have had all roles revoked) the account is marked
'disabled' (to permit IZ to handle bugs to disabled users as it wishes) and
the account is renamed 'ex-'{accountname}, preventing anyone from being
able to log in with this account, but allowing the disabled user to query
and otherwise use an open source project's database as they would if they
were a registered user without an issuzilla account.
@
text
@d51 1
a51 1
# $Id: issuezilla-user-delete,v 1.3 2000/11/16 04:36:42 kmaples Exp $
d71 2
@


1.3
log
@Fixing user addition.
@
text
@d51 1
a51 1
# $Id: issuezilla-user-delete,v 1.2 2000/11/16 00:38:49 kmaples Exp $
d76 3
d80 1
d122 2
a123 1
    my $login_name = $usernames[$_] . '@@' . $domain_name;
d126 2
a127 1
    $login_name    = $CONN->quote( $login_name );
d149 1
d165 1
a165 1
        print "$script_name: no record found.\n";
@


1.3.2.1
log
@Importing into branch.  These changes alter how users are added/deleted,
such that the revokation of all roles on a project will treat the user as
a 'registered user' rather than persona non grata.  Resolves bug reported
as http://idendev.sc-support.sp.collab.net/issues/show_bug.cgi?id=7
@
text
@d51 1
a51 1
# $Id: $
a75 3
# Vars to handle disabling - since we don't really delete the users,
# we disable them in two ways - through IZ (disabled text), and through
# helm (prefix) - the latter effectively moving the user aside.
a76 1
my $disabled_pfx  = 'ex-';
d118 1
a118 2
    my $login_name          = $usernames[$_] . '@@' . $domain_name;
    my $disabled_login_name = $disabled_pfx . $login_name;
d121 1
a121 2
    $login_name          = $CONN->quote( $login_name );
    $disabled_login_name = $CONN->quote( $disabled_login_name );
a142 1
            login_name     = $disabled_login_name,
d158 1
a158 1
        print "$script_name: no record found to disable.\n";
@


1.2
log
@Changed presumptive mailing addresses to be <user>@@<project>.<domain>
@
text
@d51 1
a51 1
# $Id: issuezilla-user-delete,v 1.1.1.1 2000/11/12 21:17:39 dlr Exp $
d118 1
a118 1
    my $login_name = $usernames[$_] . '@@' . $project_name . '.' . $domain_name;
@


1.1
log
@Initial revision
@
text
@d51 1
a51 1
# $Id: issuezilla-user-delete,v 1.7 2000/11/01 20:28:31 kmaples Exp $
d67 4
a70 3
my $dbname             = $ARGV[0] || '';
my $domain_name        = $ARGV[1] || '';
my $issues_username    = $ARGV[2] || ''; # : - sep. list
d118 1
a118 1
    my $login_name = $usernames[$_] . '@@' . $domain_name;
@


1.1.1.1
log
@Merging newhelm tree into helm, as per IZ issue #557.  Previous major version of helm is tagged TIGRIS_NOV_11_2000.
@
text
@@


1.1.1.2
log
@Replacing the HEAD with the HELM_PEER_PORT_BRANCH.
@
text
@d51 1
a51 1
# $Id: issuezilla-user-delete,v 1.9 2001/01/26 18:31:44 kmaples Exp $
d67 3
a69 6
my $project_name       = $ARGV[0] || '';
my $dbname             = $ARGV[1] || '';
my $domain_name        = $ARGV[2] || '';
my $issues_username    = $ARGV[3] || ''; # : - sep. list
my $multiple_dbs       = $ARGV[4] || '';  

a74 3
# Vars to handle disabling - since we don't really delete the users,
# we disable them in two ways - through IZ (disabled text), and through
# helm (prefix) - the latter effectively moving the user aside.
a75 1
my $disabled_pfx  = 'ex-';
a96 39
# This is a little convoluted - but here goes:  Helm will 
# call this script whenever a user has lost all roles in a
# given project, and when a user is deleted from the site as 
# a whole, this will be called once for each project that 
# user had a role in.
#
# If we're in multiple db mode, the first act translates to
# deleting the user from issuezilla - but not in single db
# mode.  In single mode, there may be many projects in the 
# database, and we only want to delete the user when this is
# the last project that the user had any role in - and this 
# is equivalent to being delete from the site as a whole.
#
# So in either case, Helm will send a last request to delete
# when all other deletes from specific projects are done - 
# a request to delete from the project with the name,
# '*All projects in domain'.  In multiple mode, we disregard
# this, but in single mode, this is the only request we 
# honor.

if($project_name =~ m/^\*/){
    # If we're in multiple db mode, disregard this call as 
    # it's covered by repeated calls to removed the member
    # from individual projects:  
    print "$script_name: Received 'DELETE FROM ALL' signal\n";
    if($multiple_dbs){
        print "$script_name: Database flag set to MULTIPLE; no action\n";
        exit(0);
    }
} else {
    # Conversely, unless we're in single db mode, we can
    # disregard all calls that aren't a request to remove 
    # from all projects:
    unless($multiple_dbs){
        print "$script_name: Database flag set to SINGLE; no action\n";
        exit(0); 
    }
}

d103 1
a103 1
my $dbc = join(':',"DBI:mysql:$dbname",$ENV{DATABASE_HOST},$ENV{DATABASE_PORT});
d117 1
a117 2
    my $login_name          = $usernames[$_] . '@@' . $domain_name;
    my $disabled_login_name = $disabled_pfx . $login_name;
d120 1
a120 2
    $login_name          = $CONN->quote( $login_name );
    $disabled_login_name = $CONN->quote( $disabled_login_name );
a141 1
            login_name     = $disabled_login_name,
d157 1
a157 1
        print "$script_name: no record found to disable.\n";
@

