<?
########## Confixx(R) 3.0 Professional ############
####### Copyright SWsoft, Inc. 2004-2005 ##########
#### http://www.sw-soft.com - info@sw-soft.com ####

/*
  -------------------- Name conventions --------------------
  Function names (except methods):

  ff_DescriptionOfFunction


  Constant names:

  cc_DescriptionOfConstant


  Variable names:

  $ST_DescriptionOfVariable

  where S is a scope, T is a type.

  The following scopes should be used:
  g - global
  s - static
  l - local
  m - member of class
  p - parameter

  The following types should be used:
  s - scalar
  a - array
  r - resource
  o - object
  m - mixed

  -------------------- end Name conventions --------------------
*/





include_once (  dirname(__FILE__) . DIRECTORY_SEPARATOR . "module.Database.php" );





class Reseller
{

    /* -------------------- Members -------------------- */
    var $ms_Name; // username of reseller
    var $ma_Data; // data from anbieter table
    /* -------------------- end Members -------------------- */





    /* -------------------- Constructor -------------------- */
    function Reseller ( $ps_Name = NULL )
    {
	$this->ms_Name = is_null($ps_Name) ? $_SERVER["PHP_AUTH_USER"] : $ps_Name;
	$lo_DB =& get_db_connection();
	$lo_Query =& $lo_DB->Select ( "SELECT * FROM anbieter WHERE anbieter='" .
		db_quote($_SERVER["PHP_AUTH_USER"]) . "'" );
	$this->ma_Data =& $lo_Query->nextrow();
    }
    /* -------------------- end Constructor -------------------- */





    /* -------------------- Methods -------------------- */
    function IsMyUser ( $ps_UserName )
    {
	$lo_DB =& get_db_connection();
	$lo_Query =& $lo_DB->Select ( "SELECT kunde FROM kunden WHERE kunde='" . db_quote($ps_UserName) .
		"' AND anbieter='" . db_quote($this->ms_Name) . "'" );
	return $lo_Query->getNumRows();
    }

    function CanAddDomains ()
    {
	if ( $this->ma_Data["maxdomainslimit"] != 1 || $this->ma_Data["maxdomains"] == -1 )
	    return TRUE;
	$lo_DB =& get_db_connection();
	$lo_Query =& $lo_DB->Select ( "SELECT COUNT(*) FROM domains WHERE anbieter='" . db_quote($this->ms_Name) .
		"' AND richtigedomain = 1" );
	$la_Row =& $lo_Query->nextrow();
	return $la_Row[0] < $this->ma_Data["maxdomains"];
    }

    function GetField ( $ps_Name )
    {
	return $this->ma_Data[$ps_Name];
    }

    function GetFieldForSQL ()
    {
	
    }
    /* -------------------- end Methods -------------------- */

}
?>
