Skip to content

Commit

Permalink
Merge pull request #177 from simnandez/develop
Browse files Browse the repository at this point in the history
[ task #297 ] Add a installer for external modules. Init works
  • Loading branch information
hregis committed Apr 25, 2012
2 parents 071cef1 + 25df346 commit ff6624f
Show file tree
Hide file tree
Showing 10 changed files with 124 additions and 16 deletions.
67 changes: 51 additions & 16 deletions htdocs/admin/tools/update.php
@@ -1,6 +1,7 @@
<?php
/* Copyright (C) 2007-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2009 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2012 Juanjo Menent <jmenent@2byte.es>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -29,7 +30,7 @@

if (! $user->admin) accessforbidden();

if ($_GET["msg"]) $message='<div class="error">'.$_GET["msg"].'</div>';
if (GETPOST('msg','alpha')) $message='<div class="error">'.GETPOST('msg','alpha').'</div>';


$urldolibarr='http://www.dolibarr.org/downloads/';
Expand All @@ -45,7 +46,7 @@
* Actions
*/

if ($_POST["action"]=='install')
if (GETPOST('action','alpha')=='install')
{
$error=0;

Expand All @@ -59,7 +60,7 @@
}
else
{
if (! preg_match('/\.tgz/i',$original_file))
if (! preg_match('/\.tgz/i',$original_file) && ! preg_match('/\.zip/i',$original_file))
{
$mesg=$langs->trans("ErrorFileMustBeADolibarrPackage");
$error++;
Expand All @@ -71,19 +72,37 @@
@dol_delete_dir_recursive($conf->admin->dir_temp.'/'.$original_file);
dol_mkdir($conf->admin->dir_temp.'/'.$original_file);

$result=dol_move_uploaded_file($_FILES["fileinstall"]["tmp_name"],$newfile,1,0,$_FILES['fileinstall']['error']);
$result=dol_move_uploaded_file($_FILES['fileinstall']['tmp_name'],$newfile,1,0,$_FILES['fileinstall']['error']);
if ($result > 0)
{
//dol_uncompress($newfile);
$rutax=DOL_DOCUMENT_ROOT_ALT;
$result=dol_uncompress($newfile,$_FILES['fileinstall']['type'],$rutax);
if ($result==2)
{
$langs->load("errors");
$mesg = "<font class=\"error\">".$langs->trans("ErrorOSSystem")."</font>";
}
elseif ($result==3)
{
$langs->load("errors");
$mesg = "<font class=\"error\">".$langs->trans("ErrorUncompFile",$_FILES['fileinstall']['name'])."</font>";
}

else {
$mesg = "<font class=\"ok\">".$langs->trans("SetupIsReadyForUse")."</font>";
}
}
}
}


/*
* View
*/

$dirins=DOL_DOCUMENT_ROOT_ALT;
$vale=(is_dir($dirins));
$system=PHP_OS;

$wikihelp='EN:Installation_-_Upgrade|FR:Installation_-_Mise_à_jour|ES:Instalaci&omodulon_-_Actualizaci&omodulon';
llxHeader('',$langs->trans("Upgrade"),$wikihelp);

Expand All @@ -93,7 +112,8 @@
print $langs->trans("LastStableVersion").' : <b>'.$langs->trans("FeatureNotYetAvailable").'</b><br>';
print '<br>';

dol_htmloutput_errors($mesg);
//dol_htmloutput_errors($mesg);
dol_htmloutput_mesg($mesg);

print $langs->trans("Upgrade").'<br>';
print '<hr>';
Expand Down Expand Up @@ -126,18 +146,33 @@
print $langs->trans("UnpackPackageInDolibarrRoot",$dolibarrroot).'<br>';
if (! empty($conf->global->MAIN_ONLINE_INSTALL_MODULE))
{
print '<form enctype="multipart/form-data" method="POST" class="noborder" action="'.$_SERVER["PHP_SELF"].'" name="forminstall">';
print '<input type="hidden" name="action" value="install">';
print $langs->trans("YouCanSubmitFile").' <input type="file" name="fileinstall"> ';
print '<input type="submit" name="'.dol_escape_htmltag($langs->trans("Send")).'" class="button">';
print '</form>';
if ($vale == 1 && $dirins != 'DOL_DOCUMENT_ROOT_ALT' && ($system=="Linux"))
{
print '<form enctype="multipart/form-data" method="POST" class="noborder" action="'.$_SERVER["PHP_SELF"].'" name="forminstall">';
print '<input type="hidden" name="action" value="install">';
print $langs->trans("YouCanSubmitFile").' <input type="file" name="fileinstall"> ';
print '<input type="submit" name="'.dol_escape_htmltag($langs->trans("Send")).'" class="button">';
print '</form>';
}
elseif ($system!='Linux')
{
$langs->load('errors');
$message=info_admin($langs->transnoentities("ErrorOSSystem"));
print $message;
}
else
{
$message=info_admin($langs->trans("NotExistsDirect").$langs->trans("InfDirAlt").$langs->trans("InfDirExample"));
print $message;
}
}
else
{
print '<b>'.$langs->trans("StepNb",4).'</b>: ';
print $langs->trans("SetupIsReadyForUse").'<br>';
}
print '<b>'.$langs->trans("StepNb",4).'</b>: ';
print $langs->trans("SetupIsReadyForUse").'<br>';

print '</form>';

llxFooter();

$db->close();
?>
47 changes: 47 additions & 0 deletions htdocs/core/lib/files.lib.php
@@ -1,5 +1,6 @@
<?php
/* Copyright (C) 2008-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2012 Juanjo Menent <jmenent@2byte.es>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -617,6 +618,52 @@ function dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disable
}
}

/**
* Uncompress a file
*
* @param string $newfile file to uncompress
* @param stirng $typefile type of file
* @param string $dstdir destination dir
* @return int 0 if ok, >0 if ko
*/
function dol_uncompress($newfile,$typefile,$dstdir)
{
global $conf;
$error=0;
$system=PHP_OS;

//TODO: See best method for this

if ($system=="Linux")
{
if ($typefile == 'application/x-gzip')
{
$prog= "tar -xzvf ";
}
elseif ($typefile == 'application/zip')
{
$prog= "unzip ";
}
else
{
$error=1;
}
}
else
{
$error=2;
}
$original_file=basename($_FILES["fileinstall"]["name"]);
$diruncom=$conf->admin->dir_temp.'/'.$original_file;
$ruta=$diruncom.'/'.$original_file;
chdir ($dstdir);
$command= $prog.$ruta;
$res=exec($command);
if (! $res) $error=3;

return $error;
}

/**
* Remove a file or several files with a mask
*
Expand Down
4 changes: 4 additions & 0 deletions htdocs/langs/ca_ES/admin.lang
Expand Up @@ -266,6 +266,10 @@ FindPackageFromWebSite=Cercar el paquet que respon a la seva necessitat (per exe
DownloadPackageFromWebSite=Descarregar el paquet des del lloc %s.
UnpackPackageInDolibarrRoot=Descomprimir el paquet a la carpeta arrel de Dolibarr <b>%s</b> sobre els arxius existents (sense desplaçar o esborrar els existents, sota pena de perdre la seva configuració o els mòduls no oficials instal·lats)
SetupIsReadyForUse=La instal·lació ha finalitzat i Dolibarr està disponible amb el nou component.
NotExistsDirect=No existeix el directori alternatiu.<br>
InfDirAlt=Des de la versió 3 és possible definir un directori root alternatiu, això li permet emmagatzemar en el mateix lloc mòduls i temes personalitzades.<br>Només cal crear un directori en l'arrel de Dolibarr (per exemple: custom).<br>
InfDirExample=<br>Seguidament es declara a l'arxiu conf.php:<br> $dolibarr_main_url_root_alt='http://miservidor/custom'<br>$dolibarr_main_document_root_alt='/directorio/de/dolibarr/htdocs/custom'<br>*Aquestes línies venen comentades amb un "#", per descomentar-les només cal retirar el caràcter.
YouCanSubmitFile=Seleccioneu mòdul:
CurrentVersion=Versió actual de Dolibarr
CallUpdatePage=Trucar a la pàgina d'actualització de l'estructura i dades de la base de dades %s.
LastStableVersion=Última versió estable disponible
Expand Down
2 changes: 2 additions & 0 deletions htdocs/langs/ca_ES/errors.lang
Expand Up @@ -105,6 +105,8 @@ ErrorBothFieldCantBeNegative=Els camps %s i %s no poden ser negatius
ErrorNoActivatedBarcode=Cap tipus de codi de barres activat
ErrorWebServerUserHasNotPermission=El compte d'execució del servidor web <b>%s</b> no disposa dels permisos per això
ErrorNoActivatedBarcode=No hi ha activat cap tipus de codi de barres
ErrorOSSystem=La instal·lació en línia no suporta el seu sistema operatiu. <br> Instal·leu l'extensió manualment.
ErrorUncompFile=No és possible instal·lar el paquet %s

# Warnings
WarningSafeModeOnCheckExecDir=Atenció, està activada l'opció PHP <b>safe_mode</b>, la comanda ha d'estar dins d'un directori declarat dins del paràmetre php <b>safe_mode_exec_dir</b>.
Expand Down
4 changes: 4 additions & 0 deletions htdocs/langs/en_US/admin.lang
Expand Up @@ -265,6 +265,10 @@ FindPackageFromWebSite=Find a package that provides feature you want (for exampl
DownloadPackageFromWebSite=Download package.
UnpackPackageInDolibarrRoot=Unpack package file into Dolibarr's root directory <b>%s</b>
SetupIsReadyForUse=Install is finished and Dolibarr is ready to use with this new component.
NotExistsDirect=The alternative root directory is not defined.<br>
InfDirAlt=Since version 3 it is possible to define an alternative root directory.This allows you to store, same place, plug-ins and custom templates.<br>Just create a directory at the root of Dolibarr (eg: custom).<br>
InfDirExample=<br>Then declare it in the file conf.php<br> $dolibarr_main_url_root_alt='http://myserver/custom'<br>$dolibarr_main_document_root_alt='/path/of/dolibarr/htdocs/custom'<br>*These lines are commented with "#", to uncomment only remove the character.
YouCanSubmitFile=Select module:
CurrentVersion=Dolibarr current version
CallUpdatePage=Go to the page that updates the database structure and datas: %s.
LastStableVersion=Last stable version
Expand Down
2 changes: 2 additions & 0 deletions htdocs/langs/en_US/errors.lang
Expand Up @@ -104,6 +104,8 @@ ErrorBadValueForCode=Bad value for security code. Try again with new value...
ErrorBothFieldCantBeNegative=Fields %s and %s can't be both negative
ErrorWebServerUserHasNotPermission=User account <b>%s</b> used to execute web server has no permission for that
ErrorNoActivatedBarcode=No barcode type activated
ErrorOSSystem=The online installation does not support your operating system.<br>Install the component manually.
ErrorUncompFile=Unable to install the package %s

# Warnings
WarningSafeModeOnCheckExecDir=Warning, PHP option <b>safe_mode</b> is on so command must be stored inside a directory declared by php parameter <b>safe_mode_exec_dir</b>.
Expand Down
6 changes: 6 additions & 0 deletions htdocs/langs/es_ES/admin.lang
Expand Up @@ -266,6 +266,12 @@ FindPackageFromWebSite=Buscar el paquete que responde a su necesidad (por ejempl
DownloadPackageFromWebSite=Descargar el paquete desde el sitio %s.
UnpackPackageInDolibarrRoot=Descomprimir el paquete en el directorio raíz de Dolibarr <b>%s</b> sobre los archivos existentes (sin desplazar o borrar los existentes, so pena de perder su configuración o los módulos no oficiales instalados)
SetupIsReadyForUse=La instalación ha finalizado y Dolibarr está disponible con el nuevo componente.

NotExistsDirect=No existe el directorio alternativo.<br>
InfDirAlt=Desde la versión 3 es posible definir un directorio root alternativo, esto le permite almacenar en el mismo lugar módulos y temas personalizados.<br>Basta con crear un directorio en el raíz de Dolibarr (por ejemplo: custom).<br>
InfDirExample=<br>Seguidamente se declara en el archivo conf.php:<br> $dolibarr_main_url_root_alt='http://miservidor/custom'<br>$dolibarr_main_document_root_alt='/directorio/de/dolibarr/htdocs/custom'<br>*Estas lineas vienen comentadas con un "#", para descomentarlas solo hay que retirar el caracter.
YouCanSubmitFile=Seleccione módulo:

CurrentVersion=Versión actual de Dolibarr
CallUpdatePage=Llamar a la página de actualización de la estructura y datos de la base de datos %s.
LastStableVersion=Última versión estable disponible
Expand Down
2 changes: 2 additions & 0 deletions htdocs/langs/es_ES/errors.lang
Expand Up @@ -105,6 +105,8 @@ ErrorBothFieldCantBeNegative=Los campos %s y %s no pueden ser negativos
ErrorNoActivatedBarcode=Ningún tipo de código de barra activado
ErrorWebServerUserHasNotPermission=La cuenta de ejecución del servidor web <b>%s</b> no dispone de los permisos para esto
ErrorNoActivatedBarcode=No hay activado ningún tipo de código de barras
ErrorOSSystem=La instalación online no soporta su sistema operativo.<br>Instale la extensión manualmente.
ErrorUncompFile=No es posible instalar el paquete %s

# Warnings
WarningSafeModeOnCheckExecDir=Atención, está activada la opción PHP <b>safe_mode</b>, el comando deberá estar dentro de un directorio declarado dentro del parámetro php <b>safe_mode_exec_dir</b>.
Expand Down
4 changes: 4 additions & 0 deletions htdocs/langs/fr_FR/admin.lang
Expand Up @@ -266,6 +266,10 @@ FindPackageFromWebSite=Recherche le package qui répond à votre besoin (par exe
DownloadPackageFromWebSite= Télécharger le package.
UnpackPackageInDolibarrRoot= Décompresser le package dans le répertoire racine de Dolibarr <b>%s</b> par dessus les fichiers existants (sans déplacer ou effacer cet existant sous peine de perdre sa configuration ou les modules non officiels installés)
SetupIsReadyForUse= L'installation est terminée et Dolibarr est prêt à être utilisé avec le nouveau composant.
NotExistsDirect=Il n'y a pas répertoire alternative.<br>
InfDirAlt=Depuis la version 3 est possible de définir un répertoire alternatif qui vous permet de stocker dans le même endroit les modules et thèmes personnalisés.<br>Il suffit de créer un répertoire à la racine de Dolibarr (par exemple: custom).<br>
InfDirExample=<br>Ensuite, declarons dans le fichier conf.php:<br> $dolibarr_main_url_root_alt='http://monserveur/custom'<br>$dolibarr_main_document_root_alt='/repertoire/de/dolibarr/htdocs/custom'<br>*Ces lignes sont commentées par "#" de décommenter suffit de supprimer le caractère.
YouCanSubmitFile=Sélectionner le module:
CurrentVersion= Version en cours de Dolibarr
CallUpdatePage= Appeler la page de l'outil de mise à jour de la structure et données de la base: %s.
LastStableVersion= Dernière version stable disponible
Expand Down
2 changes: 2 additions & 0 deletions htdocs/langs/fr_FR/errors.lang
Expand Up @@ -105,6 +105,8 @@ ErrorBadValueForCode=Mauvaise valeur saisie pour le code. Réessayez avec une no
ErrorBothFieldCantBeNegative=Les champs %s et %s ne peuvent être tous deux négatifs
ErrorWebServerUserHasNotPermission=Le compte d'execution du serveur web <b>%s</b> n'a pas les permissions pour cela
ErrorNoActivatedBarcode=Aucun type de code bar activé
ErrorOSSystem=L'installation en ligne ne prend pas en charge votre OS. <br> Installez le composant manuellement.
ErrorUncompFile=Impossible d'installer le package %s

# Warnings
WarningSafeModeOnCheckExecDir=Attention, l'option PHP <b>safe_mode</b> est active, la commande doit dont être dans un répertoire déclaré dans le paramètre php <b>safe_mode_exec_dir</b>.
Expand Down

0 comments on commit ff6624f

Please sign in to comment.