commit 5b335063c0e99290ff3488051b74b8f4d6d43822
parent a563b3f7fcc140968b30450e6e17a3abf7751e00
Author: Jan Dankert <devnull@localhost>
Date: Sat, 27 Oct 2012 18:10:42 +0200
Fix: Vorbelegung der Konfiguration bei Veröffentlichungen.
Diffstat:
2 files changed, 46 insertions(+), 27 deletions(-)
diff --git a/config/config-default.php b/config/config-default.php
@@ -678,19 +678,21 @@ $conf['publish']['negotiation'] = array();
$conf['publish']['negotiation']['page_negotiate_type']=true;
$conf['publish']['negotiation']['page_negotiate_language']=true;
$conf['publish']['negotiation']['file_negotiate_type']=true;
-$conf['publish']['project'] = array();
-$conf['publish']['project']['publish_dir']="/var/www/";
-$conf['publish']['project']['override_publish_dir']=true;
-$conf['publish']['project']['system_command']="sudo -u xyz /usr/local/bin/mirror.sh {dirbase}";
-$conf['publish']['project']['system_command']='0';
-$conf['publish']['project']['override_system_command']=true;
+$conf['publish']['filesystem'] = array();
+$conf['publish']['filesystem']['per_project']=true;
+$conf['publish']['filesystem']['directory']='/var/www/';
+$conf['publish']['command'] = array();
+$conf['publish']['command']['per_project']=true;
+$conf['publish']['command']['enable']=false;
+$conf['publish']['command']['command']='';
$conf['publish']['ftp'] = array();
$conf['publish']['ftp']['enable']=true;
+$conf['publish']['ftp']['per_project']=true;
$conf['publish']['ftp']['port']='21';
-$conf['publish']['ftp']['host']="ftp.example.com";
-$conf['publish']['ftp']['path']="/path/to/site";
-$conf['publish']['ftp']['user']='agent_smith';
-$conf['publish']['ftp']['pass']='smith';
+$conf['publish']['ftp']['host']='';
+$conf['publish']['ftp']['path']='';
+$conf['publish']['ftp']['user']='anonymous';
+$conf['publish']['ftp']['pass']='mail@example.com';
$conf['replace'] = array();
$conf['replace']['']='0';
$conf['replace']['']='0';
diff --git a/util/Publish.class.php b/util/Publish.class.php
@@ -102,7 +102,7 @@ class Publish
function Publish()
{
global $conf;
- $conf_project = $conf['publish']['project'];
+ $confPublish = $conf['publish'];
if ( $conf['security']['nopublish'] )
{
@@ -115,9 +115,16 @@ class Publish
// Feststellen, ob FTP benutzt wird.
// Dazu muss FTP aktiviert sein (enable=true) und eine URL vorhanden sein.
- if ( @$conf['publish']['ftp']['enable'] &&
- ( !empty($project->ftp_url) ||
- isset($conf['publish']['ftp']['host']) ) )
+ $ftpUrl = '';
+ if ( $conf['publish']['ftp']['enable'] )
+ {
+ if ( $conf['publish']['ftp']['per_project'] && !empty($project->ftp_url) )
+ $ftpUrl = $project->ftp_url;
+ elseif ( !empty($conf['publish']['ftp']['host']) )
+ $ftpUrl = $project->ftp_url;
+ }
+
+ if ( ! empty($ftpUrl) )
{
$this->with_ftp = true;
$this->ftp = new Ftp( $project->ftp_url ); // Aufbauen einer FTP-Verbindung
@@ -133,13 +140,18 @@ class Publish
}
$localDir = ereg_replace( '\/$','',$project->target_dir);
- if ( empty( $localDir))
- $localDir = $project->name;
-
- if ( $conf_project['override_publish_dir'] && $localDir != basename($localDir) )
- $this->local_destdir = $localDir;
- else
- $this->local_destdir = $conf_project['publish_dir'].$localDir;
+
+ if ( $confPublish['filesystem']['per_project'] && (!empty($localDir)) )
+ {
+ $this->local_destdir = $localDir; // Projekteinstellung verwenden.
+ }
+ else
+ {
+ if ( empty( $localDir))
+ $localDir = $project->name;
+ // Konfiguriertes Verzeichnis verwenden.
+ $this->local_destdir = $confPublish['filesystem']['directory'].$localDir;
+ }
// Sofort pruefen, ob das Zielverzeichnis ueberhaupt beschreibbar ist.
@@ -158,11 +170,14 @@ class Publish
$this->content_negotiation = ( $project->content_negotiation == '1' );
$this->cut_index = ( $project->cut_index == '1' );
-
- if ( $conf_project['override_system_command'] && !empty($project->cmd_after_publish) )
- $this->cmd_after_publish = $project->cmd_after_publish;
- else
- $this->cmd_after_publish = @$conf_project['system_command'];
+
+ if ( $confPublish['command']['enable'] )
+ {
+ if ( $confPublish['command']['per_project'] && !empty($project->cmd_after_publish) )
+ $this->cmd_after_publish = $project->cmd_after_publish;
+ else
+ $this->cmd_after_publish = @$confPublish['command']['command'];
+ }
// Im Systemkommando Variablen ersetzen
$this->cmd_after_publish = str_replace('{name}' ,$project->name ,$this->cmd_after_publish);
@@ -288,6 +303,7 @@ class Publish
{
if ( $this->with_ftp )
{
+ Logger::debug('Closing FTP connection' );
$this->ftp->close();
}
@@ -295,7 +311,8 @@ class Publish
if ( !empty($this->cmd_after_publish) && $this->ok )
{
$ausgabe = array();
- $rc = false;
+ $rc = false;
+ Logger::debug('Executing system command: '.$this->cmd_after_publish );
exec( $this->cmd_after_publish,$ausgabe,$rc );
if ( $rc != 0 ) // Wenn Returncode ungleich 0, dann Ausgabe ins Log schreiben und Fehler melden.