# Copyright 1999-2009 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

EAPI="2"

MY_PN="SugarCE"
S="${WORKDIR}"/"${MY_PN}"-"Full-5.5.0beta1"
inherit webapp depend.php

DESCRIPTION="A complete CRM and groupware system for businesses of all sizes."
HOMEPAGE="http://www.sugarforge.org/"
SRC_URI="http://dl.sugarforge.org/sugarcrm/1SugarCE5.5Beta/SugarCE5.5Beta1/SugarCE-5.5.0beta1.zip"

LICENSE="GPL-3"
KEYWORDS="~amd64 ~x86 ~ppc64 ~sparc ~x86-fbsd ~x86-freebsd  ~x86-interix ~amd64-linux ~x86-linux ~x86-winnt"
#KEYWORDS=""

IUSE="imap +mysqli ldap mssql oci8"


RESTRICT="mirror"
DEPEND="app-arch/unzip"
RDEPEND=">=dev-lang/php-5.2[mysqli=,ssl,soap,unicode,xml,curl,imap=,json,zlib,ldap=,mssql=,session,oci8=]
		dev-php/PEAR-DB
		dev-php/PEAR-Cache_Lite
		dev-php/PEAR-Mail_Mime
		virtual/httpd-cgi
		mysql? ( >=dev-db/mysql-5.0.70 )
		"

need_php5_httpd
src_install () {
	webapp_src_preinst
	cd "${S}"
	einfo "Installing main files"
	cp -R . "${D}"/"${MY_HTDOCSDIR}"

	webapp_postinst_txt en "${FILESDIR}"/"postinstall-en.txt"
	webapp_postinst_txt ru "${FILESDIR}"/"postinstall-ru.txt"



	webapp_configfile "${MY_HTDOCSDIR}"/"config.php"
	webapp_configfile "${MY_HTDOCSDIR}"/".htaccess"

	for foo in cache custom data modules include ; do
		webapp_serverowned -R "${MY_HTDOCSDIR}"/"${foo}"  || die

	done
	webapp_serverowned "${MY_HTDOCSDIR}"/"config.php"
	einfo "Please make adjustment of your php.ini or .htaccess file"
	einfo "Change value "seesion.path = "  according to your desire"
	einfo "Files of sessions are stored in this directory"
	einfo "For more info  see http://developers.sugarcrm.com/documentation.php "
	if use mssql; then
			einfo "You have not system or local  database serwer "
			einfo "Please read Administration_Guides how too use "
			einfo "Freetds driver"
			einfo ""
			ewarn "You really used MSSQL server ? :) "
			ewarn "This configuration not tested in Gentoo"
			epause 5
	fi
	webapp_src_install
}