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

# slepnoga spamslepnoga@inbox.ru 02.06.2009 : Version 5.2 bump && EAPI=2 support
# Homepage this ebuild http://bugs.gentoo.org/show_bug.cgi?id=103295



EAPI="2"

MY_PN="SugarCE"
S=${WORKDIR}/${MY_PN}-Full-${PV}
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/SugarCE5.5Beta/SugarCE5.5Beta1/SugarCE-5.5.0beta1.zip"

LICENSE="GPL-3"
KEYWORDS="x86 ~amd64 ~alpha ~hppa ~ia64 ~ppc64"
IUSE="+curl imap +json +zlib +mysql freetds ldap mssql"

RESTRICT="mirror"


DEPEND="app-arch/unzip"
RDEPEND="dev-lang/php:5[mysql=,ssl,soap,unicode,xml,curl=,imap=,json=,zlib=,ldap=,mssql=,session]
		dev-php/PEAR-DB
		dev-php/PEAR-Cache_Lite
		dev-php/PEAR-Mail_Mime
		virtual/httpd-cgi
		freetds? ( >=dev-db/freetds-0.64 )
		"

need_php5_httpd
pkg_setup() {
	webapp_pkg_setup
}
src_install () {
	webapp_src_preinst
	cd "${S}"
		# Do NOT delete LICENSE.txt ; install.php not work
#	rm -f {INSTALLATION,PATCH,README,UPGRADE}.txt

	einfo "Installing main files"
	cp -R . "${D}"/${MY_HTDOCSDIR}

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

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

	for foo in cache custom data modules ; do
		webapp_serverowned -R ${MY_HTDOCSDIR}/${foo}
	done
	webapp_serverowned ${MY_HTDOCSDIR}/config.php
	#slep for session support
	#please install  in php.ini: seesion.path = <temp. directory mode 777>
	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 "

	webapp_src_install
}