diff --git a/config/lang/de.json b/config/lang/de.json
index 8eb22a043914edb6fd9a4ddebe47a5d98b22064f..e6887784259519552b4f57e76df15d2742616cec 100644
--- a/config/lang/de.json
+++ b/config/lang/de.json
@@ -245,6 +245,7 @@
     "fileprefix": "File Prefix",
     "fileprefix-label": "File-Prefix <span class=\"error\"><br>Nach dem ersten Build nicht mehr änderbar!</span>",
     "finished": "Beendet",
+    "foreman-hostgroup": "Foreman Hostgruppe",
     "gotop": "Seitenanfang",
     "hosts": "Hosts",
     "hostname4puppet": "Hostname f&uuml;r Puppet Agent",
diff --git a/config/lang/en.json b/config/lang/en.json
index dcdee60ff5d07827840426fed5627d61a42e8606..5f2a7ea74bbe806b1d57a1f48e59393c7d7ced9a 100644
--- a/config/lang/en.json
+++ b/config/lang/en.json
@@ -247,6 +247,7 @@
     "fileprefix": "File prefix",
     "fileprefix-label": "File prefix <span class=\"error\"><br>It cannot be changed after the first build!</span>",
     "finished": "Fisnished",
+    "foreman-hostgroup": "Foreman hostgroup",
     "gotop": "top",
     "hosts": "Hosts",
     "hostname4puppet": "Hostname to start puppet agent",
diff --git a/public_html/deployment/classes/formgen.class.php b/public_html/deployment/classes/formgen.class.php
index 61d841a64b645e9d77f595538fb87d11951f5ac4..d957948f63e6684f4b37f2cfe95982caaa137033 100644
--- a/public_html/deployment/classes/formgen.class.php
+++ b/public_html/deployment/classes/formgen.class.php
@@ -215,7 +215,7 @@ class formgen {
             case "select":
                 // HINWEIS optgroups werden nicht unterstuezt - nur einfache Listen
                 $this->_checkReqiredKeys($elementData, array("name"));
-                $sFormElement.='<select id="' . $sId . '" class="form-control" ';
+                $sFormElement.='<div class="col-sm-10"><select id="' . $sId . '" class="form-control" ';
                 $sFormElement.=$this->_addHtmlAtrributes(explode(",", "$sDefaultAttributes,name,onchange"), $elementData);
                 $sFormElement.=">\n";
                 foreach ($elementData["options"] as $idOption => $aOptionData) {
@@ -225,11 +225,11 @@ class formgen {
                     $sFormElement.=$this->_addHtmlAtrributes(explode(",", "$sDefaultAttributes,selected"), $aOptionData);
                     $sFormElement.='>' . $aOptionData["label"] . '</option>' . "\n";
                 }
-                $sFormElement.="</select>\n";
+                $sFormElement.="</select></div>\n";
 
                 if ($sLabelText) {
                     // $sLabelElement.='<span class="help-block">' . $sLabelText . '</span>' . "\n";
-                    $sLabelClass=(array_key_exists("inline", $elementData) && $elementData["inline"])?"":"control-label";
+                    $sLabelClass=(array_key_exists("inline", $elementData) && $elementData["inline"])?"":"col-sm-2";
                     $sLabelElement = $this->_addLabel($sLabelText, $sId, $sLabelClass);
                 }
 
diff --git a/public_html/deployment/classes/project.class.php b/public_html/deployment/classes/project.class.php
index 8699f44a5b54e89ec526a570b1b1efd2ac46e0ac..03a6e5d27b5db964d207875dae9c40907b39ec57 100644
--- a/public_html/deployment/classes/project.class.php
+++ b/public_html/deployment/classes/project.class.php
@@ -92,7 +92,7 @@ class project extends base {
      * @param string $sId  id of the project
      */
     public function __construct($sId = false) {
-        $this->oUser=new user();
+        $this->oUser = new user();
         $this->_readConfig();
         if ($sId) {
             $this->setProjectById($sId);
@@ -363,7 +363,7 @@ class project extends base {
         $sBase = $this->_getFileBase($sPhase, $sPlace);
         return $sBase ? $sBase . '/' . $this->_aPrjConfig["fileprefix"] . '.tgz' : false;
     }
-    
+
     /**
      * list of files of a given phase and place
      * @param string $sPhase  one of preview|stage|live ...
@@ -371,56 +371,56 @@ class project extends base {
      * @return array
      */
     public function _getBuildfilesByDir($sBase) {
-        $aReturn=array();
-        if(!$sBase || !is_dir($sBase)){
+        $aReturn = array();
+        if (!$sBase || !is_dir($sBase)) {
             return false;
         }
-        $iTotalSize=0;
-        $aReturn=array(
-            'dir'=>$sBase,
-            'filecount'=>false,
-            'totalsize'=>false,
-            'totalsize-hr'=>false,
+        $iTotalSize = 0;
+        $aReturn = array(
+            'dir' => $sBase,
+            'filecount' => false,
+            'totalsize' => false,
+            'totalsize-hr' => false,
         );
-        
-        foreach (glob($sBase . '/*') as $sFile){
-            $sFileBase=basename($sFile);
+
+        foreach (glob($sBase . '/*') as $sFile) {
+            $sFileBase = basename($sFile);
             $sExt = pathinfo($sFile, PATHINFO_EXTENSION);
-            $aStat=stat($sFile);
-            switch($sExt){
+            $aStat = stat($sFile);
+            switch ($sExt) {
                 case 'erb':
-                    $sType='templates';
-                    $sIcon='fa fa-file-code-o';
+                    $sType = 'templates';
+                    $sIcon = 'fa fa-file-code-o';
                     break;
                 case 'tgz':
-                    $sType='package';
-                    $sIcon='fa fa-file-archive-o';
+                    $sType = 'package';
+                    $sIcon = 'fa fa-file-archive-o';
                     break;
                 case 'json':
-                    $sType='metadata';
-                    $sIcon='fa fa-file-text-o';
+                    $sType = 'metadata';
+                    $sIcon = 'fa fa-file-text-o';
                     break;
                 default:
-                    $sType='any';
-                    $sIcon='fa fa-file-o';
+                    $sType = 'any';
+                    $sIcon = 'fa fa-file-o';
                     break;
             }
             $iTotalSize+=$aStat['size'];
-            $aReturn['files'][$sFileBase]=array(
-                'type'=>$sType,
-                'icon'=>$sIcon ? '<i class="'.$sIcon.'"></i> ' : '',
-                'extension'=>$sExt,
-                'size'=>$aStat['size'],
+            $aReturn['files'][$sFileBase] = array(
+                'type' => $sType,
+                'icon' => $sIcon ? '<i class="' . $sIcon . '"></i> ' : '',
+                'extension' => $sExt,
+                'size' => $aStat['size'],
             );
-            $aReturn['types'][$sType][]=$sFileBase;
+            $aReturn['types'][$sType][] = $sFileBase;
         }
-        $aReturn['totalsize']=$iTotalSize;
-        $aReturn['totalsize-hr']=(round($iTotalSize/1024/102.4)/10).' MB';
-        $aReturn['filecount']=count($aReturn['files']);
-        
+        $aReturn['totalsize'] = $iTotalSize;
+        $aReturn['totalsize-hr'] = (round($iTotalSize / 1024 / 102.4) / 10) . ' MB';
+        $aReturn['filecount'] = count($aReturn['files']);
+
         return $aReturn;
     }
-    
+
     /**
      * list of files of a given phase and place
      * @param string $sPhase  one of preview|stage|live ...
@@ -431,16 +431,15 @@ class project extends base {
         $sBase = $this->_getFileBase($sPhase, $sPlace);
         return $this->_getBuildfilesByDir($sBase);
     }
+
     /**
      * list of files of a given version number
      * @param string $sVersion  name of version 
      * @return array
      */
     public function getBuildfilesByVersion($sVersion) {
-        return $this->_getBuildfilesByDir($this->_getProjectArchiveDir().'/'.$sVersion);
+        return $this->_getBuildfilesByDir($this->_getProjectArchiveDir() . '/' . $sVersion);
     }
-    
-
 
     /**
      * get full path of a packed project archive
@@ -624,7 +623,7 @@ class project extends base {
      * @return array
      */
     public function cleanupArchive($bDeleteAll = false) {
-        if (!$this->oUser->hasPermission("project-action-cleanup")){
+        if (!$this->oUser->hasPermission("project-action-cleanup")) {
             return $this->oUser->showDenied();
         }
         $aDelete = array();
@@ -632,10 +631,10 @@ class project extends base {
 
         $sDir = $this->_getProjectArchiveDir();
         $this->getVersions();
-        if (!$this->_aVersions){
+        if (!$this->_aVersions) {
             return $aDelete;
         }
-        
+
         // find unused versions
         foreach ($this->_aVersions as $sVersion => $aUsage) {
             if (!$aUsage || count($aUsage) == 0) {
@@ -648,15 +647,15 @@ class project extends base {
         while (count($aUnused) && count($aUnused) > $iKeep) {
             $sVersion = array_shift($aUnused);
             $sDir2 = $sDir . '/' . $sVersion;
-            if (is_dir($sDir2)){
+            if (is_dir($sDir2)) {
                 if ($this->_rmdir($sDir2)) {
                     $aDelete[] = $sDir2;
-                    echo t('ok').': '.$sDir2;
+                    echo t('ok') . ': ' . $sDir2;
                 } else {
                     echo sprintf(t("class-project-warning-cannot-delete-archive-dir"), $sDir2);
                 }
             } else {
-                echo t('skip').': '.$sDir2;
+                echo t('skip') . ': ' . $sDir2;
             }
             echo '<br>';
         }
@@ -676,7 +675,7 @@ class project extends base {
      */
     public function cleanupBuilds() {
         $this->log(__FUNCTION__ . " start");
-        if (!$this->oUser->hasPermission("project-action-cleanup")){
+        if (!$this->oUser->hasPermission("project-action-cleanup")) {
             return $this->oUser->showDenied();
         }
         $sDir = $this->_getBuildDir();
@@ -709,7 +708,7 @@ class project extends base {
      */
     public function cleanupVcsCache($iAge = 0) {
         $this->log(__FUNCTION__ . " start");
-        if (!$this->oUser->hasPermission("project-action-cleanup")){
+        if (!$this->oUser->hasPermission("project-action-cleanup")) {
             return $this->oUser->showDenied();
         }
         $this->_initVcs();
@@ -828,39 +827,39 @@ class project extends base {
                 $aTmp[$sKey] = array();
 
                 // use version cache
-                require_once(__DIR__. '/../../valuestore/classes/valuestore.class.php');
+                require_once(__DIR__ . '/../../valuestore/classes/valuestore.class.php');
                 $oVersion = new valuestore();
                 $oVersion->setProject("", $this->_aPrjConfig["fileprefix"], $sPhase, $sKey);
-                $aVersions=$oVersion->getVersion();
+                $aVersions = $oVersion->getVersion();
                 // echo "Place: <pre>" . print_r($oVersion->whereiam(), 1) . "</pre>";
                 // echo "Versionen: <pre>" . print_r($aVersions, 1) . "</pre>";
-                foreach ($aVersions as $sHostname=>$aHostdata){
-                    $aTmp[$sKey]=array();
-                    $aTmp[$sKey]=$aHostdata['_data'];
+                foreach ($aVersions as $sHostname => $aHostdata) {
+                    $aTmp[$sKey] = array();
+                    $aTmp[$sKey] = $aHostdata['_data'];
                     $aTmp[$sKey]["infofile"] = '[versioncache]';
-                    
-                    $aTmp[$sKey]['_hosts']=array();
-                    $aTmp[$sKey]['_hosts'][$aHostdata['host']]=$aHostdata;
-                    
+
+                    $aTmp[$sKey]['_hosts'] = array();
+                    $aTmp[$sKey]['_hosts'][$aHostdata['host']] = $aHostdata;
+
                     // first host only
                     continue;
                 }
                 $aTmp[$sKey]["ok"] = 1;
                 $aTmp[$sKey]["infofile"] = '[versioncache]';
                 /*
-                $sJsonData = $this->_httpGet($sJsonfile);
-                if ($sJsonData) {
-                    $aJson = json_decode($sJsonData, true);
-                    if (is_array($aJson) && array_key_exists("version", $aJson)) {
-                        $aTmp[$sKey] = $aJson;
-                        $aTmp[$sKey]["infofile"] = $sJsonfile;
-                        $aTmp[$sKey]["ok"] = 1;
-                    } else {
-                        $aTmp[$sKey]["error"] = sprintf(t("class-project-error-metafile-has-no-version"), $sJsonfile, print_r($aJson, true));
-                    }
-                } else {
-                    $aTmp[$sKey]["error"] = sprintf(t("class-project-error-metafile-wrong-format"), $sJsonfile);
-                }
+                  $sJsonData = $this->_httpGet($sJsonfile);
+                  if ($sJsonData) {
+                  $aJson = json_decode($sJsonData, true);
+                  if (is_array($aJson) && array_key_exists("version", $aJson)) {
+                  $aTmp[$sKey] = $aJson;
+                  $aTmp[$sKey]["infofile"] = $sJsonfile;
+                  $aTmp[$sKey]["ok"] = 1;
+                  } else {
+                  $aTmp[$sKey]["error"] = sprintf(t("class-project-error-metafile-has-no-version"), $sJsonfile, print_r($aJson, true));
+                  }
+                  } else {
+                  $aTmp[$sKey]["error"] = sprintf(t("class-project-error-metafile-wrong-format"), $sJsonfile);
+                  }
                  * 
                  */
             } else {
@@ -959,9 +958,8 @@ class project extends base {
      * @param type $sPhase  current phase
      */
     public function canAcceptPhase($sPhase = false) {
-        if (!$this->oUser->hasPermission("project-action-accept")
-            && !$this->oUser->hasPermission("project-action-accept-$sPhase")
-        ){
+        if (!$this->oUser->hasPermission("project-action-accept") && !$this->oUser->hasPermission("project-action-accept-$sPhase")
+        ) {
             // echo $this->oUser->showDenied();
             return false;
         }
@@ -997,14 +995,7 @@ class project extends base {
         // array key "ok" must be in the ready2install and deployed info
         // and a version must be installed
         if (
-                array_key_exists($sPhase, $this->_aData["phases"]) 
-                && array_key_exists("onhold", $this->_aData["phases"][$sPhase]) 
-                && array_key_exists("ready2install", $this->_aData["phases"][$sPhase]) 
-                && array_key_exists("deployed", $this->_aData["phases"][$sPhase]) 
-                && array_key_exists("ok", $this->_aData["phases"][$sPhase]["onhold"]) 
-                && array_key_exists("ok", $this->_aData["phases"][$sPhase]["ready2install"]) 
-                && array_key_exists("ok", $this->_aData["phases"][$sPhase]["deployed"])
-                && array_key_exists("version", $this->_aData["phases"][$sPhase]["deployed"])
+                array_key_exists($sPhase, $this->_aData["phases"]) && array_key_exists("onhold", $this->_aData["phases"][$sPhase]) && array_key_exists("ready2install", $this->_aData["phases"][$sPhase]) && array_key_exists("deployed", $this->_aData["phases"][$sPhase]) && array_key_exists("ok", $this->_aData["phases"][$sPhase]["onhold"]) && array_key_exists("ok", $this->_aData["phases"][$sPhase]["ready2install"]) && array_key_exists("ok", $this->_aData["phases"][$sPhase]["deployed"]) && array_key_exists("version", $this->_aData["phases"][$sPhase]["deployed"])
         ) {
             return true;
         }
@@ -1224,76 +1215,72 @@ class project extends base {
         $this->_sProcessTempOut = $sNewTempfile;
         return $this->_sProcessTempOut;
     }
-    
-        /**
-         * get projects from ldap; it returns ldap search items with cn as 
-         * array key.
-         * 
-         * @return array
-         */
-        private function _ldapProjectSearch($sSearchFilter) {
-            $aReturn = array();
-            require_once("ldap.class.php");
-            $oLdapIML = new imlldap($this->_aConfig['projects']['ldap']);
-            // $oLdapIML->debugOn();
-            $aResultsIml = $oLdapIML->searchDn(
-                $this->_aConfig['projects']['ldap']['DnProjects'],
-                $sSearchFilter, 
-                array("*")
-            );
-            if (!$aResultsIml['count']) {
-                return false;
-            }
-            $oLdapIML->close();
 
-            /*
-            unset($aResultsIml['count']);
-            foreach ($aResultsIml as $aItem) {
-                $aReturn[$aItem['cn'][0]] = array(
-                    'dn' => $aItem['dn'],
-                    'cn' => $aItem['cn'][0],
-                    '_description' => $aItem['description'][0],
-                    'title' => $sTitle,
-                    'description' => $sDescription,
-                );
-            }
-            $oLdapIML->close();
-            ksort($aReturn);
-            return $aReturn;
-             * 
-             */
-            return $aResultsIml;
+    /**
+     * get projects from ldap; it returns ldap search items with cn as 
+     * array key.
+     * 
+     * @return array
+     */
+    private function _ldapProjectSearch($sSearchFilter) {
+        $aReturn = array();
+        require_once("ldap.class.php");
+        $oLdapIML = new imlldap($this->_aConfig['projects']['ldap']);
+        // $oLdapIML->debugOn();
+        $aResultsIml = $oLdapIML->searchDn(
+                $this->_aConfig['projects']['ldap']['DnProjects'], $sSearchFilter, array("*")
+        );
+        if (!$aResultsIml['count']) {
+            return false;
         }
+        $oLdapIML->close();
+
+        /*
+          unset($aResultsIml['count']);
+          foreach ($aResultsIml as $aItem) {
+          $aReturn[$aItem['cn'][0]] = array(
+          'dn' => $aItem['dn'],
+          'cn' => $aItem['cn'][0],
+          '_description' => $aItem['description'][0],
+          'title' => $sTitle,
+          'description' => $sDescription,
+          );
+          }
+          $oLdapIML->close();
+          ksort($aReturn);
+          return $aReturn;
+         * 
+         */
+        return $aResultsIml;
+    }
 
     /**
      * load config of a project
      * @return boolean
      */
     public function setProjectById($sId) {
-        if ($sId !== preg_replace('/[^a-z0-9\-\_]/i', '', $sId)){
+        if ($sId !== preg_replace('/[^a-z0-9\-\_]/i', '', $sId)) {
             echo "ERROR: invalid syntax in project ID: $sId<br>";
             return false;
         }
         $this->_aPrjConfig = array();
         $this->_aConfig["id"] = $sId;
 
-        
-        if ($this->_aConfig['projects']['json']['active']){
+
+        if ($this->_aConfig['projects']['json']['active']) {
             $this->_aPrjConfig = json_decode(file_get_contents($this->_getConfigFile($sId)), true);
         }
-        if ($this->_aConfig['projects']['ldap']['active']){
+        if ($this->_aConfig['projects']['ldap']['active']) {
             // TODO: read project after saving it - @see $this->saveConfig()
-            $sQuery='(&(objectclass=hieraSource)(documentIdentifier='.$sId.'))';
-            $aResult=$this->_ldapProjectSearch($sQuery);
+            $sQuery = '(&(objectclass=hieraSource)(documentIdentifier=' . $sId . '))';
+            $aResult = $this->_ldapProjectSearch($sQuery);
             // echo '<pre>$aResult = ' . print_r($aResult, 1) . '</pre>';
-            if (is_array($aResult) 
-                    && $aResult[0]
-                    && array_key_exists('hieradata',$aResult[0])
-            ){
-                foreach ($aResult[0]['hieradata'] as $sLine){
+            if (is_array($aResult) && $aResult[0] && array_key_exists('hieradata', $aResult[0])
+            ) {
+                foreach ($aResult[0]['hieradata'] as $sLine) {
                     // echo $sLine.'<br>';
-                    if(preg_match('/^cfg=/', $sLine)){
-                        
+                    if (preg_match('/^cfg=/', $sLine)) {
+
                         // echo $sLine.'<br>';
                         $this->_aPrjConfig = json_decode(preg_replace('/^cfg=/', '', $sLine), 1);
                     }
@@ -1373,7 +1360,6 @@ class project extends base {
         return file_exists($this->_sProcessTempOut);
     }
 
-
     /**
      * get the name of the current branch (or default branch)
      * @return string
@@ -1399,12 +1385,12 @@ class project extends base {
      */
     public function build($sTmpFile = false) {
         $this->log(__FUNCTION__ . " start");
-        if (!$this->oUser->hasPermission("project-action-build")){
+        if (!$this->oUser->hasPermission("project-action-build")) {
             return $this->oUser->showDenied();
         }
         global $aParams;
         $sReturn = false;
-        $oHtml=new htmlguielements();
+        $oHtml = new htmlguielements();
 
         $aActionList = array(
             'iActive' => 0,
@@ -1502,7 +1488,7 @@ class project extends base {
             $sReturn.=$this->_execAndSend('chmod 755 ' . $filename);
             $sReturn.=$this->_execAndSend('ls -l ' . $filename);
         }
-        
+
         $sReturn.=$oHtml->getBox("success", t('class-project-info-build-checkout-ok'));
         $aActionList['iActive'] ++;
         $this->_TempFill($sReturn, $aActionList);
@@ -1730,7 +1716,7 @@ class project extends base {
         $this->_logaction(t('starting') . " queue($sPhase, $sVersion)", __FUNCTION__);
         $sReturn = "<h2> " . t("queue") . " " . $this->getLabel() . " :: $sPhase</h2>";
         $this->_TempFill($sReturn, $aActionList);
-        $oHtml=new htmlguielements();
+        $oHtml = new htmlguielements();
 
         if (!$this->isActivePhase($sPhase)) {
             $sError = sprintf(t("class-project-warning-phase-not-active"), $sPhase);
@@ -1803,11 +1789,10 @@ class project extends base {
      * @return boolean|string
      */
     public function deploy($sPhase, $bIgnoreDeploytimes = false) {
-        $oHtml=new htmlguielements();
+        $oHtml = new htmlguielements();
         $this->log(__FUNCTION__ . " start");
-        if (!$this->oUser->hasPermission("project-action-deploy")
-            && !$this->oUser->hasPermission("project-action-deploy-$sPhase")
-        ){
+        if (!$this->oUser->hasPermission("project-action-deploy") && !$this->oUser->hasPermission("project-action-deploy-$sPhase")
+        ) {
             return $this->oUser->showDenied();
         }
         $aActionList = array(
@@ -1948,39 +1933,40 @@ class project extends base {
         // run action to install
         // --------------------------------------------------
         $sDeploymethod = array_key_exists("deploymethod", $this->_aPrjConfig["phases"][$sPhase]) ? $this->_aPrjConfig["phases"][$sPhase]["deploymethod"] : "none";
-        $sTargethosts=array_key_exists("hosts", $this->_aPrjConfig["phases"][$sPhase]) ? $this->_aPrjConfig["phases"][$sPhase]["hosts"] : '';
-        
-        $sReturn.='<h3>' . t("class-project-info-deploy-start-by-method") . ' :: '.$sDeploymethod.'</h3>'
-                .'<p>'
-                .t("deploymethod-$sDeploymethod").'<br>'
-                .t("phase-targethosts").': '.($sTargethosts ? $sTargethosts : t("none"))
-                .'</p>'
-                ;
-        if ($sDeploymethod==="none" || !$sTargethosts){
+        $sTargethosts = array_key_exists("hosts", $this->_aPrjConfig["phases"][$sPhase]) ? $this->_aPrjConfig["phases"][$sPhase]["hosts"] : '';
+
+        $sReturn.='<h3>' . t("class-project-info-deploy-start-by-method") . ' :: ' . $sDeploymethod . '</h3>'
+                . '<p>'
+                . t("deploymethod-$sDeploymethod") . '<br>'
+                . t("phase-targethosts") . ': ' . ($sTargethosts ? $sTargethosts : t("none"))
+                . '</p>'
+        ;
+        if ($sDeploymethod === "none" || !$sTargethosts) {
             $sReturn.=t("class-project-info-deploy-start-by-method-skip") . "<br>";
         } else {
-            $aTargethosts=explode(',', $sTargethosts);
-            foreach ($aTargethosts as $sTargethost){
-                $sReturn.='<h4>' . $sDeploymethod . ' - '.$sTargethost.'</h4>';
-                $sCmd='';
-                switch($sDeploymethod){
+            $aTargethosts = explode(',', $sTargethosts);
+            foreach ($aTargethosts as $sTargethost) {
+                $sReturn.='<h4>' . $sDeploymethod . ' - ' . $sTargethost . '</h4>';
+                $sCmd = '';
+                switch ($sDeploymethod) {
                     case 'puppet':
                         $sCmd = 'ssh ' . $this->_aConfig["installPackages"]["user"]
                                 . '@' . $sTargethost
                                 . ' ' . $this->_aConfig["installPackages"]["command"];
-                        break;;
+                        break;
+                        ;
                     // TODO: we don't have any proxy yet
                     case 'sshproxy__AS_EXAMPLE_ONLY':
                         $sCmd = 'ssh ' . $this->_aConfig["installPackages"]["sshproxy"]["user"]
                                 . '@' . $this->_aConfig["installPackages"]["sshproxy"]["host"]
                                 . ' ' . sprintf($this->_aConfig["installPackages"]["sshproxy"]["command"], $sTargethost);
-                        break;;
+                        break;
+                        ;
                 }
-                if ($sCmd){
+                if ($sCmd) {
                     // $sReturn.=$sCmd.'<br>';
                     $sReturn.=$this->_execAndSend("$sCmd");
                 }
-
             }
         }
         $aActionList['iActive'] ++;
@@ -2000,11 +1986,10 @@ class project extends base {
      * @return type
      */
     public function accept($sPhase) {
-        $oHtml=new htmlguielements();
+        $oHtml = new htmlguielements();
         $this->log(__FUNCTION__ . " start");
-        if (!$this->oUser->hasPermission("project-action-accept")
-            && !$this->oUser->hasPermission("project-action-accept-$sPhase")
-            ){
+        if (!$this->oUser->hasPermission("project-action-accept") && !$this->oUser->hasPermission("project-action-accept-$sPhase")
+        ) {
             return $this->oUser->showDenied();
         }
 
@@ -2040,16 +2025,16 @@ class project extends base {
      */
     public function saveConfig($aData = false) {
         $this->log(__FUNCTION__ . " start");
-        if (!$this->oUser->hasPermission("project-action-setup")){
+        if (!$this->oUser->hasPermission("project-action-setup")) {
             return $this->oUser->showDenied();
         }
         $this->_logaction(t('starting') . " saveConfig(...)", __FUNCTION__);
         if (!$aData) {
             $aData = $_POST;
         }
-        
-        foreach(array('id', 'label', 'description', 'contact', 'build', 'fileprefix', 'phases') as $sKey){
-            if (!array_key_exists($sKey, $aData)){
+
+        foreach (array('id', 'label', 'description', 'contact', 'build', 'fileprefix', 'phases') as $sKey) {
+            if (!array_key_exists($sKey, $aData)) {
                 $this->_logaction(t('abortet') . " missing key $sKey in savedata", __FUNCTION__, "error");
                 return false;
             }
@@ -2058,13 +2043,13 @@ class project extends base {
 
         // remove unwanted items
         foreach (array("setupaction", "prj", "id") as $s) {
-            if (array_key_exists($s, $aData)){
+            if (array_key_exists($s, $aData)) {
                 unset($aData[$s]);
             }
         }
 
         // save json file
-        if ($this->_aConfig['projects']['json']['active']){
+        if ($this->_aConfig['projects']['json']['active']) {
             // echo "IST <pre>" . print_r($this->_aPrjConfig, true) . "</pre>"; echo "NEU <pre>" . print_r($aData, true) . "</pre>"; die();
             // make a backup of a working config
             $sCfgFile = $this->_getConfigFile($sId);
@@ -2075,48 +2060,47 @@ class project extends base {
             $this->_aPrjConfig = json_decode(file_get_contents($this->_getConfigFile($sId)), true);
         }
         // save in ldap
-        if ($this->_aConfig['projects']['ldap']['active']){
+        if ($this->_aConfig['projects']['ldap']['active']) {
             // TODO: 
-            echo "TODO: save in LDAP<br><pre>" . print_r($aData, 1) ."</pre>";
-            
-            
-            $sDn='documentIdentifier='.$sId.','.$this->_aConfig['projects']['ldap']['DnProjects'];
-            $aItem=array(
+            echo "TODO: save in LDAP<br><pre>" . print_r($aData, 1) . "</pre>";
+
+
+            $sDn = 'documentIdentifier=' . $sId . ',' . $this->_aConfig['projects']['ldap']['DnProjects'];
+            $aItem = array(
                 'objectClass' => array(
                     'document',
                     'hieraSource',
                     'top',
                 ),
                 'hieraData' => array(
-                    'cfg='.json_encode($aData),
-                    'updated='.date("Y-m-d H:i:s") . ' by ' . $this->oUser->getUsername(),
+                    'cfg=' . json_encode($aData),
+                    'updated=' . date("Y-m-d H:i:s") . ' by ' . $this->oUser->getUsername(),
                 )
             );
-            
+
             require_once("ldap.class.php");
             $oLdapIML = new imlldap($this->_aConfig['projects']['ldap']);
             // $oLdapIML->debugOn();
-            if (!$oLdapIML->DnExists($sDn)){            
-                if ($oLdapIML->objAdd($sDn,$aItem)){
+            if (!$oLdapIML->DnExists($sDn)) {
+                if ($oLdapIML->objAdd($sDn, $aItem)) {
                     echo 'OK, created in LDAP.<br>';
-                    $bReturn=true;
+                    $bReturn = true;
                 } else {
-                    echo 'ERROR, DN '.$sDn.' was not created in LDAP :-/<br>';
-                    $bReturn=false;
+                    echo 'ERROR, DN ' . $sDn . ' was not created in LDAP :-/<br>';
+                    $bReturn = false;
                 }
             } else {
-                if ($oLdapIML->objUpdate($sDn,$aItem)){
+                if ($oLdapIML->objUpdate($sDn, $aItem)) {
                     echo 'OK, updated in LDAP.<br>';
-                    $bReturn=true;
+                    $bReturn = true;
                 } else {
-                    echo 'ERROR, DN '.$sDn.' was not updated in LDAP :-/<br>';
-                    $bReturn=false;
+                    echo 'ERROR, DN ' . $sDn . ' was not updated in LDAP :-/<br>';
+                    $bReturn = false;
                 }
             }
             $oLdapIML->close();
-            
         }
-            
+
         $this->_logaction(t('finished') . " saveConfig(...)", __FUNCTION__, "success");
         $this->setProjectById($sId);
 
@@ -2131,7 +2115,7 @@ class project extends base {
      */
     public function create($sId) {
         $this->log(__FUNCTION__ . " start");
-        if (!$this->oUser->hasPermission("project-action-create")){
+        if (!$this->oUser->hasPermission("project-action-create")) {
             return $this->oUser->showDenied();
         }
         $this->_logaction(t('starting') . " create($sId)", __FUNCTION__);
@@ -2199,7 +2183,7 @@ class project extends base {
      */
     public function delete($aOptions = array()) {
         $this->log(__FUNCTION__ . " start");
-        if (!$this->oUser->hasPermission("project-action-delete")){
+        if (!$this->oUser->hasPermission("project-action-delete")) {
             return $this->oUser->showDenied();
         }
         $sCfgfile = $this->_getConfigFile($this->_aConfig["id"]);
@@ -2303,62 +2287,64 @@ class project extends base {
         }
         return $this->_getChecksumDiv($aData["revision"]);
     }
-    
-    private function _renderHostsData($aData){
-        $sReturn='';
-        if (array_key_exists('_hosts', $aData)){
+
+    private function _renderHostsData($aData) {
+        $sReturn = '';
+        if (array_key_exists('_hosts', $aData)) {
             // $sReturn.= print_r($aData['_hosts'], 1);
             $sReturn.= '<div class="hosts">'
-                    . '<br><strong>'.t('hosts').':</strong><br>'
-                    ;
-            foreach($aData['_hosts'] as $sHostname=>$aHostinfos){
-                $oUpdateDate=date("U", strtotime($aHostinfos['time']));
-                $iAgeUpdate=round((date("U")-$oUpdateDate)/ 60);
-                $sAge=$iAgeUpdate< 60*60*13 ? $iAgeUpdate. " min" : "??";
+                    . '<br><strong>' . t('hosts') . ':</strong><br>'
+            ;
+            foreach ($aData['_hosts'] as $sHostname => $aHostinfos) {
+                $oUpdateDate = date("U", strtotime($aHostinfos['time']));
+                $iAgeUpdate = round((date("U") - $oUpdateDate) / 60);
+                $sAge = $iAgeUpdate < 60 * 60 * 13 ? $iAgeUpdate . " min" : "??";
 
                 $sReturn.= '<div class="host">'
                         . $this->_getChecksumDiv($aHostinfos['_data']['revision'])
                         . '<i class="fa fa-cube"></i><br>'
                         . $sHostname . "<br>($sAge) "
                         . '</div>'
-                        ;
+                ;
             }
             $sReturn.= '</div><div style="clear: both;"></div>';
         }
         return $sReturn;
     }
+
     /**
      * get html code for list of hosts in a phase
      * @param string $sPhase  phase of a project
      * @return string
      */
-    private function _renderHosts($sPhase){
+    private function _renderHosts($sPhase) {
         $aDataPhase = $this->getPhaseInfos($sPhase);
-        if (is_array($aDataPhase) && array_key_exists('deployed', $aDataPhase)){
+        if (is_array($aDataPhase) && array_key_exists('deployed', $aDataPhase)) {
             return $this->_renderHostsData($aDataPhase['deployed']);
         }
         return '';
     }
+
     /**
      * get html code for list of files in a phase
      * @param string $sPhase  phase of a project
      * @return string
      */
-    private function _renderFiles($sPhase){
-        $sReturn='';
-        $aFiles=$this->getBuildfilesByPlace($sPhase, 'ready2install');
-        if (!$aFiles || !$aFiles['filecount']){
+    private function _renderFiles($sPhase) {
+        $sReturn = '';
+        $aFiles = $this->getBuildfilesByPlace($sPhase, 'ready2install');
+        if (!$aFiles || !$aFiles['filecount']) {
             return '';
         }
-        $sReturn.='<strong>'.t("filelist").'</strong> ('.$aFiles['filecount'].'):<br>';
-        foreach($aFiles['files'] as $sFilename => $aData){
-            $sReturn.='<div class="file file-'.$aData['type'].' fileext-'.$aData['extension'].'" title="'.$sFilename.' ('.$aData['type'].')">'
-                    . $aData['icon'] . $sFilename 
+        $sReturn.='<strong>' . t("filelist") . '</strong> (' . $aFiles['filecount'] . '):<br>';
+        foreach ($aFiles['files'] as $sFilename => $aData) {
+            $sReturn.='<div class="file file-' . $aData['type'] . ' fileext-' . $aData['extension'] . '" title="' . $sFilename . ' (' . $aData['type'] . ')">'
+                    . $aData['icon'] . $sFilename
                     // . ' ('.$aData['type'].')'
                     . '</div>'
-                    ;
+            ;
         }
-        $sReturn.='('.$aFiles['totalsize-hr'].')';
+        $sReturn.='(' . $aFiles['totalsize-hr'] . ')';
         return $sReturn;
     }
 
@@ -2371,7 +2357,7 @@ class project extends base {
     public function renderLink($sFunction, $sPhase = false, $sVersion = false) {
         $sFirst = $this->getNextPhase();
         $sNext = $this->getNextPhase($sPhase);
-        $oHtml=new htmlguielements();
+        $oHtml = new htmlguielements();
         $aLinkdata = array(
             'default' => array('class' => ''),
             'accept' => array('class' => $sNext,
@@ -2410,19 +2396,19 @@ class project extends base {
             ),
         );
         /*
-        if (!$this->oUser->hasRole("project-action-$sFunction")){
-            // $sClass .= ' disabled';
-            // return '<span title="no permission [project-action-'.$sFunction.']">[ ]</span>';
-        } 
+          if (!$this->oUser->hasRole("project-action-$sFunction")){
+          // $sClass .= ' disabled';
+          // return '<span title="no permission [project-action-'.$sFunction.']">[ ]</span>';
+          }
          * 
-         */       
+         */
         // fuer wen ist der Link
         $sRole = '';
         $sOnMouseover = '';
         $sOnMouseout = '';
         if ($sFunction == "build") {
             $sRole = 'developer';
-            $sOnMouseover = '$(\'.' . $sNext . '.td' . $this->_aConfig["id"] . '\').addClass(\'highlight\');'; 
+            $sOnMouseover = '$(\'.' . $sNext . '.td' . $this->_aConfig["id"] . '\').addClass(\'highlight\');';
             $sOnMouseout = '$(\'.' . $sNext . '.td' . $this->_aConfig["id"] . '\').removeClass(\'highlight\');';
         }
         if ($sFunction == "accept") {
@@ -2431,8 +2417,8 @@ class project extends base {
                 $sRole = 'pl';
                 // $aLinkdata[$sFunction]['icon']='glyphicon glyphicon-star';
             }
-            $sOnMouseover = '$(\'.' . $sNext . '.td' . $this->_aConfig["id"] . '\').addClass(\'highlight\');'; 
-            $sOnMouseout ='$(\'.' . $sNext . '.td' . $this->_aConfig["id"] . '\').removeClass(\'highlight\');';
+            $sOnMouseover = '$(\'.' . $sNext . '.td' . $this->_aConfig["id"] . '\').addClass(\'highlight\');';
+            $sOnMouseout = '$(\'.' . $sNext . '.td' . $this->_aConfig["id"] . '\').removeClass(\'highlight\');';
         }
 
         // $sClass = $sPhase;
@@ -2460,19 +2446,19 @@ class project extends base {
         if ($sVersion) {
             $sLink.="$sVersion/";
         }
-        if (!$this->oUser->hasPermission("project-action-$sFunction")){
+        if (!$this->oUser->hasPermission("project-action-$sFunction")) {
             // $sClass .= ' disabled';
-            return '<span title="no permission [project-action-'.$sFunction.'] for '.$this->oUser->getUsername().'">[ <i class="' . $sIconClass . '"></i> ' . $sLabel . ' ]</span>';
-        }        
+            return '<span title="no permission [project-action-' . $sFunction . '] for ' . $this->oUser->getUsername() . '">[ <i class="' . $sIconClass . '"></i> ' . $sLabel . ' ]</span>';
+        }
 
         return $oHtml->getLinkButton(array(
-            'href'=>$sLink,
-            'title'=>$sHint,
-            'class'=>'btn btn-default ' . $sClass,
-            'type'=>$sFunction,
-            'onmouseover'=>$sOnMouseover,
-            'onmouseout'=>$sOnMouseout,
-            'label'=>$sLabel,
+                    'href' => $sLink,
+                    'title' => $sHint,
+                    'class' => 'btn btn-default ' . $sClass,
+                    'type' => $sFunction,
+                    'onmouseover' => $sOnMouseover,
+                    'onmouseout' => $sOnMouseout,
+                    'label' => $sLabel,
         ));
         // return '<a href="' . $sLink . '" ' . $sOnMouseover . ' title="' . $sHint . '" class="btn  btn-default ' . $sClass . '"><i class="' . $sIconClass . '"></i> ' . $sLabel . '</a>';
     }
@@ -2489,21 +2475,21 @@ class project extends base {
             $sRow1.='<th class="' . $sPhase . '">' . $sPhase . '</th>';
             $sRow2.='<td class="' . $sPhase . '">'
                     . t('url') . ': <a href="' . $this->_aPrjConfig["phases"][$sPhase]["url"] . '">' . $this->_aPrjConfig["phases"][$sPhase]["url"] . '</a><br>'
-                    . '<br>' . t('deploytimes') . ':<br>';            
+                    . '<br>' . t('deploytimes') . ':<br>';
             if (count($this->_getDeploytimes($sPhase))) {
                 $sRow2.=implode("<br>", $this->_getDeploytimes($sPhase));
             } else {
                 $sRow2.=t('deploytimes-immediately');
             }
             $sRow2.='<br>' . $this->renderLink("phase", $sPhase)
-                . $this->_renderHosts($sPhase)
-                .'<br>'
-                . $this->_renderFiles($sPhase)
-                . '</td>';
+                    . $this->_renderHosts($sPhase)
+                    . '<br>'
+                    . $this->_renderFiles($sPhase)
+                    . '</td>';
         }
         return '<table><thead><tr>' . $sRow1 . '</tr></thead><tbody><tr>' . $sRow2 . '</tr></tbody></table>';
     }
-    
+
     /**
      * render html for a place of a phase
      * @param string  $sPhase    phase
@@ -2531,93 +2517,92 @@ class project extends base {
         $aDataPhase = $this->getPhaseInfos($sPhase);
         $aData = $aDataPhase[$sPlace];
         // foreach($aDataPhase[$sPlace] as $aData) {
-            if (array_key_exists("ok", $aData) && array_key_exists("version", $aData)) {
-                // TODO: getChecksumDiv anhand der Repo-Versionsnummer - dann kann man beim build auch die Farbe mit dem Repo HEAD vergleichen
-                
-                // time
-                $sDateFormat="d.m.Y H:i";
-                $oPkgDate=date("U", strtotime($aData["date"]));
-                /*
-                $iAge=date("U")-$oPkgDate;
-                $sAgeClass="";
-                if ($iAge< 60*60*24*3){
-                    $sAgeClass="last1d";
-                }
-                if ($iAge< 60*60){
-                    $sAgeClass="last1h";
-                }
-                */
-                $sReturn .= '
+        if (array_key_exists("ok", $aData) && array_key_exists("version", $aData)) {
+            // TODO: getChecksumDiv anhand der Repo-Versionsnummer - dann kann man beim build auch die Farbe mit dem Repo HEAD vergleichen
+            // time
+            $sDateFormat = "d.m.Y H:i";
+            $oPkgDate = date("U", strtotime($aData["date"]));
+            /*
+              $iAge=date("U")-$oPkgDate;
+              $sAgeClass="";
+              if ($iAge< 60*60*24*3){
+              $sAgeClass="last1d";
+              }
+              if ($iAge< 60*60){
+              $sAgeClass="last1h";
+              }
+             */
+            $sReturn .= '
                     ' . $this->_renderBar($sPhase, $sPlace) . '
                     <i class="glyphicon glyphicon-calendar"></i> ' . date($sDateFormat, $oPkgDate);
-                
-                if ($bLong) {
-                    // long display of the revision
-                    // $sJsonUrl = $this->_getInfofile($sPhase, $sPlace);
-                    $sReturn.='<br>
+
+            if ($bLong) {
+                // long display of the revision
+                // $sJsonUrl = $this->_getInfofile($sPhase, $sPlace);
+                $sReturn.='<br>
                         <i class="glyphicon glyphicon-bookmark"></i> ' . t('branch') . ': ' . $aData["branch"] . '<br>
                         <i class="glyphicon glyphicon-tag"></i> ' . t('revision') . ': ' . $this->_renderRevision($aData["revision"]) . '<br>
                         <i class="glyphicon glyphicon-comment"></i> ' . t('commitmessage') . ':<br><pre>' . strip_tags($aData["message"], '<br>') . '</pre>'
-                        // . '<i class="glyphicon glyphicon-globe"></i> ' . t('url') . ': <a href="' . $sJsonUrl . '">' . $sJsonUrl . '</a><br>'
-                        ;
-                    if ($sPlace == "deployed" && array_key_exists("url", $this->_aPrjConfig["phases"][$sPhase])) {
-                        $sUrl = $this->_aPrjConfig["phases"][$sPhase]["url"];
-                        $sReturn.='<i class="glyphicon glyphicon-globe"></i> ' . t('url') . ': <a href="' . $sUrl . '">' . $sUrl . '</a><br>';
-                    }
-                } else {
-                    if ($sPlace == "deployed" && array_key_exists("url", $this->_aPrjConfig["phases"][$sPhase])) {
-                        $sMore = '<i class="glyphicon glyphicon-globe"></i> ' 
-                                . t('url') 
-                                . ': <a href="' . $this->_aPrjConfig["phases"][$sPhase]["url"] . '">' . $this->_aPrjConfig["phases"][$sPhase]["url"] . '</a><br>';
-                    }
-
-                    $sReturn.=' ' . $this->renderInfoLink(
-                                    $aData, array(
-                                'title' => $this->getLabel() . " :: $sPhase :: $sPlace",
-                                'more' => $sMore,
-                                    )
-                    );
+                // . '<i class="glyphicon glyphicon-globe"></i> ' . t('url') . ': <a href="' . $sJsonUrl . '">' . $sJsonUrl . '</a><br>'
+                ;
+                if ($sPlace == "deployed" && array_key_exists("url", $this->_aPrjConfig["phases"][$sPhase])) {
+                    $sUrl = $this->_aPrjConfig["phases"][$sPhase]["url"];
+                    $sReturn.='<i class="glyphicon glyphicon-globe"></i> ' . t('url') . ': <a href="' . $sUrl . '">' . $sUrl . '</a><br>';
+                }
+            } else {
+                if ($sPlace == "deployed" && array_key_exists("url", $this->_aPrjConfig["phases"][$sPhase])) {
+                    $sMore = '<i class="glyphicon glyphicon-globe"></i> '
+                            . t('url')
+                            . ': <a href="' . $this->_aPrjConfig["phases"][$sPhase]["url"] . '">' . $this->_aPrjConfig["phases"][$sPhase]["url"] . '</a><br>';
                 }
 
-                switch ($sPlace) {
-                    case "onhold":
-                        if (array_key_exists("phases", $this->_aConfig) && array_key_exists($sPhase, $this->_aConfig["phases"])) {
-                            // $sReturn .= print_r($this->_aConfig["phases"][$sPhase], true);
-                            if (count($this->_getDeploytimes($sPhase))) {
-                                $sReturn .= '<br><i class="glyphicon glyphicon-time"></i> ' . t('deploytimes') . ':<br>'
-                                        . implode("<br>", array_values($this->_getDeploytimes($sPhase)))
-                                        . '<br>';
-                            }
-                            if ($bActions) {
-                                $sReturn .= ' ' . $this->renderLink("deploy", $sPhase);
-                            }
+                $sReturn.=' ' . $this->renderInfoLink(
+                                $aData, array(
+                            'title' => $this->getLabel() . " :: $sPhase :: $sPlace",
+                            'more' => $sMore,
+                                )
+                );
+            }
+
+            switch ($sPlace) {
+                case "onhold":
+                    if (array_key_exists("phases", $this->_aConfig) && array_key_exists($sPhase, $this->_aConfig["phases"])) {
+                        // $sReturn .= print_r($this->_aConfig["phases"][$sPhase], true);
+                        if (count($this->_getDeploytimes($sPhase))) {
+                            $sReturn .= '<br><i class="glyphicon glyphicon-time"></i> ' . t('deploytimes') . ':<br>'
+                                    . implode("<br>", array_values($this->_getDeploytimes($sPhase)))
+                                    . '<br>';
                         }
-                        break;
+                        if ($bActions) {
+                            $sReturn .= ' ' . $this->renderLink("deploy", $sPhase);
+                        }
+                    }
+                    break;
 
-                    case "ready2install":
-                        break;
+                case "ready2install":
+                    break;
 
-                    case "deployed":
-                        if ($bActions && $this->canAcceptPhase($sPhase)) {
-                            $sReturn .= ' ' . $this->renderLink("accept", $sPhase);
-                        }
-                        break;
-                    default:
-                        break;
-                }
-                // $this->_getChecksumDiv($aData["revision"])
+                case "deployed":
+                    if ($bActions && $this->canAcceptPhase($sPhase)) {
+                        $sReturn .= ' ' . $this->renderLink("accept", $sPhase);
+                    }
+                    break;
+                default:
+                    break;
+            }
+            // $this->_getChecksumDiv($aData["revision"])
+        } else {
+            if (array_key_exists("error", $aData)) {
+                $sReturn.=''
+                        . $this->renderInfoLink(array('error' => $aData["error"]), array())
+                ;
+            } else if (array_key_exists("warning", $aData)) {
+                $sReturn.= '<div class="warning"><i class="glyphicon glyphicon-info-sign"></i> ' . t('warning') . ':<br>' . $aData["warning"] . '</div>';
             } else {
-                if (array_key_exists("error", $aData)) {
-                    $sReturn.=''
-                            .$this->renderInfoLink(array('error'=>$aData["error"]),array())
-                            ;
-                } else if (array_key_exists("warning", $aData)) {
-                    $sReturn.= '<div class="warning"><i class="glyphicon glyphicon-info-sign"></i> ' . t('warning') . ':<br>' . $aData["warning"] . '</div>';
-                } else {
-                    return false;
-                    // $sReturn.= t('empty');
-                }
-            } // if
+                return false;
+                // $sReturn.= t('empty');
+            }
+        } // if
         // } // for
         return $sReturn;
     }
@@ -2675,7 +2660,7 @@ class project extends base {
      * @return string
      */
     public function renderRepoInfo() {
-        $oHtml=new htmlguielements();
+        $oHtml = new htmlguielements();
         $sReturn = "";
         switch ($this->_aPrjConfig["build"]["type"]) {
             case "git":
@@ -2712,12 +2697,12 @@ class project extends base {
      * @param string $sRevision
      * @return string
      */
-    public function _renderRevision($sRevision){
-        $sUrl=str_replace('/tree/master','',$this->_aPrjConfig["build"]["webaccess"]).'/commit/'.$sRevision;
-        return '<a href="'.$sUrl.'">'.$sRevision.'</a>';
+    public function _renderRevision($sRevision) {
+        $sUrl = str_replace('/tree/master', '', $this->_aPrjConfig["build"]["webaccess"]) . '/commit/' . $sRevision;
+        return '<a href="' . $sUrl . '">' . $sRevision . '</a>';
         return $sUrl;
     }
-    
+
     /**
      * render html code for info link that shows popup with metadata on mouseover
      * @param array $aInfos   metainfos of the package (from json file)
@@ -2731,7 +2716,7 @@ class project extends base {
     public function renderInfoLink($aInfos, $aOptions = array()) {
         $sReturn = '';
         $bIsError = false;
-        $oHtml=new htmlguielements();
+        $oHtml = new htmlguielements();
 
         $sInfos.='';
         if (array_key_exists("title", $aOptions) && $aOptions["title"]) {
@@ -2741,10 +2726,10 @@ class project extends base {
             $sLinktitle = t('infos');
             if (array_key_exists("message", $aInfos)) {
                 $sInfos.=$this->_getChecksumDiv($aInfos["revision"])
-                        . $oHtml->getIconByType('calendar') . t('build-from')    . ' '  . date("d.m.Y H:i:s", strtotime($aInfos["date"])) . '<br>'
-                        . $oHtml->getIconByType('branch')   . t('branch')        . ': ' . $aInfos["branch"] . '<br>'
-                        . $oHtml->getIconByType('revision') . t('revision')      . ': ' . $this->_renderRevision($aInfos["revision"]) . '<br>'
-                        . $oHtml->getIconByType('comment')  . t('commitmessage') . ':<br><span class="pre">' . strip_tags($aInfos["message"], '<br>') . '</span>';
+                        . $oHtml->getIconByType('calendar') . t('build-from') . ' ' . date("d.m.Y H:i:s", strtotime($aInfos["date"])) . '<br>'
+                        . $oHtml->getIconByType('branch') . t('branch') . ': ' . $aInfos["branch"] . '<br>'
+                        . $oHtml->getIconByType('revision') . t('revision') . ': ' . $this->_renderRevision($aInfos["revision"]) . '<br>'
+                        . $oHtml->getIconByType('comment') . t('commitmessage') . ':<br><span class="pre">' . strip_tags($aInfos["message"], '<br>') . '</span>';
                 if (array_key_exists("more", $aOptions)) {
                     $sInfos.=$aOptions["more"];
                 }
@@ -2764,11 +2749,11 @@ class project extends base {
         }
 
         // render html
-        $sId='info'.md5($sInfos);
-        $sReturn = '<a href="#" class="btn '.($bIsError ? 'btn-danger': 'btn-default').'" onclick="showIdAsModalMessage(\''.$sId.'\'); return false;">'
+        $sId = 'info' . md5($sInfos);
+        $sReturn = '<a href="#" class="btn ' . ($bIsError ? 'btn-danger' : 'btn-default') . '" onclick="showIdAsModalMessage(\'' . $sId . '\'); return false;">'
                 // . '<i class="fa fa-info"></i> '
                 . $sLinktitle
-                . '</a><div id="'.$sId.'" style="display: none;" ';
+                . '</a><div id="' . $sId . '" style="display: none;" ';
         if (array_key_exists("hpos", $aOptions)) {
             $sReturn.=' class="' . $aOptions["hpos"] . '"';
         }
@@ -2777,7 +2762,7 @@ class project extends base {
         if ($sTitle) {
             $sReturn.='<span class="title">' . $sTitle . '</span><br><br>';
         }
-        
+
         $sReturn.=$sInfos . '</div>';
 
         if ($bIsError) {
@@ -2792,7 +2777,7 @@ class project extends base {
      * @return string
      */
     public function renderVersionUsage() {
-        $oHtml=new htmlguielements();
+        $oHtml = new htmlguielements();
         $sReturn = false;
         $sRowHead1 = false;
         $sRowHead2 = '';
@@ -2950,17 +2935,64 @@ class project extends base {
      * @return string
      */
     public function renderProjectSetup() {
-        if (!$this->oUser->hasPermission("project-action-setup")){
+        if (!$this->oUser->hasPermission("project-action-setup")) {
             return $this->oUser->showDenied();
         }
-        $oHtml=new htmlguielements();
+        $oHtml = new htmlguielements();
         $sMessages = '';
         require_once ("formgen.class.php");
-        
+
         require_once("./classes/config-replacement.class.php");
         $oConfig = new configreplacement();
         $oConfig->setProject($this->_aConfig["id"]);
-        
+
+
+        $aForemanHostgroups = false;
+        $iForemanHostgroupDefault = false;
+        $sForemanHostgroupDefault = false;
+        if (array_key_exists('foreman', $this->_aConfig)) {
+            // echo '<pre>' . print_r($this->_aPrjConfig, 1) . '</pre>';
+            $iForemanHostgroupDefault = (int) $this->_aPrjConfig['deploy']['foreman']['hostgroup'];
+            require_once('deploy-foreman.class.php');
+            $oForeman = new deployForeman($this->_aConfig['foreman']);
+            // $oForeman->setDebug(1);
+            // $oForeman->selfcheck(); die(__FUNCTION__);
+
+            $aForemanHostgroups = $oForeman->read(array(
+                'request' => array(
+                    array('hostgroups'),
+                // array('operatingsystems',4),
+                ),
+                'response' => array(
+                    'id', 'title'
+                ),
+            ));
+            $aSelectForemanGroups = array(
+                'type' => 'select',
+                'name' => 'deploy[foreman][hostgroup]',
+                'label' => t("foreman-hostgroup"),
+                'options' => array(
+                    '-1' => array(
+                        'label' => t('none'),
+                    ),
+                    '' => array(
+                        'label' => '- - - - - - - - - - - - - - - - - - - - ',
+                    ),
+                ),
+            );
+            if (count($aForemanHostgroups)) {
+                foreach ($aForemanHostgroups as $aItem) {
+                    $bActive=$iForemanHostgroupDefault === (int) $aItem['id'];
+                    $aSelectForemanGroups['options'][$aItem['id']] = array(
+                        'label' => $aItem['title'],
+                        'selected' => $bActive ? 'selected' : false,
+                    );
+                    $sForemanHostgroupDefault = $bActive ? $aItem['title'] : $sForemanHostgroupDefault;
+                }
+            }
+        }
+
+
         $i = 0;
 
         $aPrefixItem = count($this->getVersions()) ?
@@ -3130,33 +3162,73 @@ class project extends base {
                 ),
             ),
         );
+        if ($aSelectForemanGroups) {
+            $aForms["setup"]["form"]['input' . $i++] = array(
+                'type' => 'markup',
+                'value' => '<h3>Default</h3>',
+            );
+            $aForms["setup"]["form"]['input' . $i++] = $aSelectForemanGroups;
+            $aForms["setup"]["form"]['input' . $i++] = array(
+                'type' => 'markup',
+                'value' => '<br><br>',
+            );
+        }
         foreach (array_keys($this->getPhases()) as $sPhase) {
-            
+
             $bActivePhase = $this->isActivePhase($sPhase);
             $sUrl = array_key_exists("url", $this->_aPrjConfig["phases"][$sPhase]) ? $this->_aPrjConfig["phases"][$sPhase]["url"] : "";
             $sDeploymethod = array_key_exists("deploymethod", $this->_aPrjConfig["phases"][$sPhase]) ? $this->_aPrjConfig["phases"][$sPhase]["deploymethod"] : "";
             $sDeployhosts = array_key_exists("hosts", $this->_aPrjConfig["phases"][$sPhase]) ? $this->_aPrjConfig["phases"][$sPhase]["hosts"] : "";
-            
-            $sDeploytimes = array_key_exists("deploytimes", $this->_aPrjConfig["phases"][$sPhase]) ? $this->_aPrjConfig["phases"][$sPhase]["deploytimes"] : "";
-            $sDivId4PhaseSettings='divSettings'.$sPhase;
-            $sDivId4TargetHosts='divSettings'.$sPhase.'hosts';
 
+            $sDeploytimes = array_key_exists("deploytimes", $this->_aPrjConfig["phases"][$sPhase]) ? $this->_aPrjConfig["phases"][$sPhase]["deploytimes"] : "";
+            $sDivId4PhaseSettings = 'divSettings' . $sPhase;
+            $sDivId4TargetHosts = 'divSettings' . $sPhase . 'hosts';
+
+            if ($aSelectForemanGroups) {
+                $iForemanHostgroup = (int) $this->_aPrjConfig['phases'][$sPhase]['foreman-hostgroup'];
+                $aSelectForemanHostGroup = array(
+                    'type' => 'select',
+                    'name' => 'phases[' . $sPhase . '][foreman-hostgroup]',
+                    'label' => t("foreman-hostgroup"),
+                    'options' => array(
+                        '-999' => array(
+                            'label' => t('default') . ' (' . $sForemanHostgroupDefault . ')',
+                            'selected' => $iForemanHostgroup === -999 ? 'selected' : false,
+                        ),
+                        '-1' => array(
+                            'label' => t('none'),
+                            'selected' => $iForemanHostgroup === -1 ? 'selected' : false,
+                        ),
+                        '' => array(
+                            'label' => '- - - - - - - - - - - - - - - - - - - - ',
+                        ),
+                    ),
+                );
+                if (count($aForemanHostgroups)) {
+                    foreach ($aForemanHostgroups as $aItem) {
+                        $aSelectForemanHostGroup['options'][$aItem['id']] = array(
+                            'label' => $aItem['title'],
+                            'selected' => ($iForemanHostgroup === $aItem['id']) ? 'selected' : false,
+                        );
+                    }
+                }
+            }
             $aForms["setup"]["form"]['input' . $i++] = array(
                 'type' => 'markup',
                 'value' => ''
-                    // .'<pre>'.print_r($this->_aPrjConfig["phases"][$sPhase], 1).'</pre>'
-                    /*
-                    . '<a class="'.$sPhase.'">'
-                    . t("phase") . ' ' . $sPhase
-                    . '</a>'
-                     */
-                    . '<table class="table">'
-                    . '<tbody>'
-                    . '<tr><th class="' . $sPhase . '">'. t("phase") . ' ' . $sPhase.'</th></tr>'
-                    . '<tr><td class="' . ($bActivePhase ? $sPhase : '') . '">'
+                // .'<pre>'.print_r($this->_aPrjConfig["phases"][$sPhase], 1).'</pre>'
+                /*
+                  . '<a class="'.$sPhase.'">'
+                  . t("phase") . ' ' . $sPhase
+                  . '</a>'
+                 */
+                . '<table class="table">'
+                . '<tbody>'
+                . '<tr><th class="' . $sPhase . '">' . t("phase") . ' ' . $sPhase . '</th></tr>'
+                . '<tr><td class="' . ($bActivePhase ? $sPhase : '') . '">'
                 . ''
             );
-            
+
             $aForms["setup"]["form"]['input' . $i++] = array(
                 'type' => 'checkbox',
                 'name' => 'phases[' . $sPhase . '][active]',
@@ -3170,19 +3242,18 @@ class project extends base {
                     '1' => array(
                         'label' => t("yes"),
                         'checked' => $bActivePhase,
-                        'onclick' => '$(\'#'.$sDivId4PhaseSettings.'\').css(\'display\', (this.checked ? \'block\' : \'none\') )',
+                        'onclick' => '$(\'#' . $sDivId4PhaseSettings . '\').css(\'display\', (this.checked ? \'block\' : \'none\') )',
                     ),
                 ),
-                
             );
             $aForms["setup"]["form"]['input' . $i++] = array(
                 'type' => 'markup',
                 'value' => ''
-                .'<div id="'.$sDivId4PhaseSettings.'" '.($bActivePhase ? '' : ' style="display: none;"').'">'
+                . '<div id="' . $sDivId4PhaseSettings . '" ' . ($bActivePhase ? '' : ' style="display: none;"') . '">'
             );
             $aForms["setup"]["form"]['input' . $i++] = array(
                 'type' => 'markup',
-                'value' => '<div style="clear: both"></div><div class="form-group"><h3>'.t("deploy-settings").'</h3></div>'
+                'value' => '<div style="clear: both"></div><div class="form-group"><h3>' . t("deploy-settings") . '</h3></div>'
             );
             $aForms["setup"]["form"]['input' . $i++] = array(
                 'type' => 'text',
@@ -3206,29 +3277,28 @@ class project extends base {
                 'options' => array(
                     'none' => array(
                         'label' => t("deploymethod-none"),
-                        'checked' => $sDeploymethod==="none",
-                        'onclick' => '$(\'#'.$sDivId4TargetHosts.'\').css(\'display\', (this.checked ? \'none\' : \'block\') )',
+                        'checked' => $sDeploymethod === "none",
+                        'onclick' => '$(\'#' . $sDivId4TargetHosts . '\').css(\'display\', (this.checked ? \'none\' : \'block\') )',
                     ),
                     'puppet' => array(
                         'label' => t("deploymethod-puppet"),
-                        'checked' => $sDeploymethod==="puppet",
-                        'onclick' => '$(\'#'.$sDivId4TargetHosts.'\').css(\'display\', (this.checked ? \'block\' : \'none\') )',
-                    ),
-                    /*
-                     * see deploy method to handle an action
-                    'sshproxy' => array(
-                        'label' => t("deploymethod-sshproxy"),
-                        'checked' => $sDeploymethod==="sshproxy",
-                        'onclick' => '$(\'#'.$sDivId4TargetHosts.'\').css(\'display\', (this.checked ? \'block\' : \'none\') )',
+                        'checked' => $sDeploymethod === "puppet",
+                        'onclick' => '$(\'#' . $sDivId4TargetHosts . '\').css(\'display\', (this.checked ? \'block\' : \'none\') )',
                     ),
-                     */
+                /*
+                 * see deploy method to handle an action
+                  'sshproxy' => array(
+                  'label' => t("deploymethod-sshproxy"),
+                  'checked' => $sDeploymethod==="sshproxy",
+                  'onclick' => '$(\'#'.$sDivId4TargetHosts.'\').css(\'display\', (this.checked ? \'block\' : \'none\') )',
+                  ),
+                 */
                 ),
-                
             );
             $aForms["setup"]["form"]['input' . $i++] = array(
                 'type' => 'markup',
                 'value' => ''
-                .'<div id="'.$sDivId4TargetHosts.'" '.($sDeploymethod!=="none" ? '' : ' style="display: none;"').'">'
+                . '<div id="' . $sDivId4TargetHosts . '" ' . ($sDeploymethod !== "none" ? '' : ' style="display: none;"') . '">'
             );
             $aForms["setup"]["form"]['input' . $i++] = array(
                 'type' => 'text',
@@ -3242,37 +3312,37 @@ class project extends base {
             );
 
             /*
-            if ($sPuppethost) {
-
-                // add ssh host key
-                $sOut0 = shell_exec(sprintf($this->_aConfig["installPackages"]["addkeycommand"], $sPuppethost, $sPuppethost));
-
-                $sCmd2 = 'ssh ' . $this->_aConfig["installPackages"]["user"]
-                        . '@' . $sPuppethost
-                        . ' ' . $this->_aConfig["installPackages"]["testcommand"];
-                $sOut = 'skip';
-                // $sOut = shell_exec($sCmd2);
-                // Check auf Versionsnummer - mehr als n Zeichen ist mutmasslich eine Fehlermeldung
-                if (strlen($sOut) > 7) {
-                    $sMessages.=$this->getBox("error", sprintf(t("class-project-error-setup-sudo-pupet-agent-failed"), $sPhase, $sCmd, $sOut));
-                    $sOut = '<span class="error" title="' . $sCmd . '">' . $sOut . '</span>';
-                } else {
-                    $sOut = '<span class="ok">' . sprintf(t("class-project-info-setup-ssh-and-puppet-ok"), $sPuppethost) . '</span>';
-                }
-                $aForms["setup"]["form"]['input' . $i++] = array(
-                    'type' => 'markup',
-                    'value' => '<div class="form-group">'
-                    . '<label class="col-sm-2"> </label><div class="col-sm-10">'
-                    . $sOut
-                    . '</div></div>',
-                );
-            }
-            */
-                        
+              if ($sPuppethost) {
+
+              // add ssh host key
+              $sOut0 = shell_exec(sprintf($this->_aConfig["installPackages"]["addkeycommand"], $sPuppethost, $sPuppethost));
+
+              $sCmd2 = 'ssh ' . $this->_aConfig["installPackages"]["user"]
+              . '@' . $sPuppethost
+              . ' ' . $this->_aConfig["installPackages"]["testcommand"];
+              $sOut = 'skip';
+              // $sOut = shell_exec($sCmd2);
+              // Check auf Versionsnummer - mehr als n Zeichen ist mutmasslich eine Fehlermeldung
+              if (strlen($sOut) > 7) {
+              $sMessages.=$this->getBox("error", sprintf(t("class-project-error-setup-sudo-pupet-agent-failed"), $sPhase, $sCmd, $sOut));
+              $sOut = '<span class="error" title="' . $sCmd . '">' . $sOut . '</span>';
+              } else {
+              $sOut = '<span class="ok">' . sprintf(t("class-project-info-setup-ssh-and-puppet-ok"), $sPuppethost) . '</span>';
+              }
+              $aForms["setup"]["form"]['input' . $i++] = array(
+              'type' => 'markup',
+              'value' => '<div class="form-group">'
+              . '<label class="col-sm-2"> </label><div class="col-sm-10">'
+              . $sOut
+              . '</div></div>',
+              );
+              }
+             */
+
             $aForms["setup"]["form"]['input' . $i++] = array(
                 'type' => 'markup',
                 'value' => ''
-                .'</div>'
+                . '</div>'
             );
             // when to deploy
             $aForms["setup"]["form"]['input' . $i++] = array(
@@ -3285,43 +3355,43 @@ class project extends base {
                 'size' => 100,
                 'placeholder' => implode(", ", $this->_aConfig["phases"][$sPhase]["deploytimes"]),
             );
-            
-            $aReplacements=$oConfig->getReplacements($sPhase);
-            $sDivIdReplacement='divreplacements-'.$sPhase;
+
+            if ($aSelectForemanGroups) {
+                $aForms["setup"]["form"]['input' . $i++] = $aSelectForemanHostGroup;
+            }
+            $aReplacements = $oConfig->getReplacements($sPhase);
+            $sDivIdReplacement = 'divreplacements-' . $sPhase;
             $aForms["setup"]["form"]['input' . $i++] = array(
                 'type' => 'markup',
                 'value' => '<div style="clear: both; height: 2em;"></div>'
-                    . '<div class="form-group">'
-                    . ($aReplacements 
-                        ? '<a class="expandable closed" href="#" onclick="$(\'#'.$sDivIdReplacement.'\').slideToggle(); $(this).toggleClass(\'closed\'); return false;">'
-                        : '' 
-                    )
-                    . '<h3>'.t("replacements").'  ('.($aReplacements ? count($aReplacements):0).')</h3>'
-                    . ($aReplacements ? '</a>' : '')
-                    . t('replacements-info')
-                    . '</div>'
+                . '<div class="form-group">'
+                . ($aReplacements ? '<a class="expandable closed" href="#" onclick="$(\'#' . $sDivIdReplacement . '\').slideToggle(); $(this).toggleClass(\'closed\'); return false;">' : ''
+                )
+                . '<h3>' . t("replacements") . '  (' . ($aReplacements ? count($aReplacements) : 0) . ')</h3>'
+                . ($aReplacements ? '</a>' : '')
+                . t('replacements-info')
+                . '</div>'
             );
-            
-            if ($aReplacements){
+
+
+            if ($aReplacements) {
                 $aForms["setup"]["form"]['input' . $i++] = array(
                     'type' => 'markup',
-                    'value' => '<div id="'.$sDivIdReplacement.'" style="display: none;">'
+                    'value' => '<div id="' . $sDivIdReplacement . '" style="display: none;">'
                 );
-                foreach($aReplacements as $sFile=>$aFields){
-                    $tTplFile=basename($sFile);
-                    $aValues = (array_key_exists("replace", $this->_aPrjConfig["phases"][$sPhase])
-                            && array_key_exists($tTplFile, $this->_aPrjConfig["phases"][$sPhase]["replace"])
-                            )
-                            ? $this->_aPrjConfig["phases"][$sPhase]["replace"][$tTplFile] : false;
+                foreach ($aReplacements as $sFile => $aFields) {
+                    $tTplFile = basename($sFile);
+                    $aValues = (array_key_exists("replace", $this->_aPrjConfig["phases"][$sPhase]) && array_key_exists($tTplFile, $this->_aPrjConfig["phases"][$sPhase]["replace"])
+                            ) ? $this->_aPrjConfig["phases"][$sPhase]["replace"][$tTplFile] : false;
                     $aForms["setup"]["form"]['input' . $i++] = array(
                         'type' => 'markup',
-                        'value' => '<div class="form-group"><br><h4><i class="fa fa-file-code-o"></i> '.$tTplFile.'</h4>'
+                        'value' => '<div class="form-group"><br><h4><i class="fa fa-file-code-o"></i> ' . $tTplFile . '</h4>'
                         // . '<textarea cols="100" rows="7" >'.file_get_contents($sFile).'</textarea>'
                         . '</div>'
                     );
                     $aForms["setup"]["form"]['input' . $i++] = array(
                         'type' => 'text',
-                        'name' => 'phases[' . $sPhase . '][replace]['.$tTplFile.'][targetfile]',
+                        'name' => 'phases[' . $sPhase . '][replace][' . $tTplFile . '][targetfile]',
                         'label' => t("replacement-targetfile"),
                         'value' => $aValues && array_key_exists('targetfile', $aValues) ? $aValues['targetfile'] : '',
                         // 'required' => 'required',
@@ -3331,15 +3401,15 @@ class project extends base {
                     );
                     $aForms["setup"]["form"]['input' . $i++] = array(
                         'type' => 'markup',
-                        'value' => '<br>'.t("replacement-fields") 
+                        'value' => '<br>' . t("replacement-fields")
                     );
-                    if(count($aFields)){
-                        foreach ($aFields as $sField){
+                    if (count($aFields)) {
+                        foreach ($aFields as $sField) {
 
                             $aForms["setup"]["form"]['input' . $i++] = array(
                                 'type' => 'text',
                                 'disabled' => $this->oUser->hasPermission("project-action-setup-edit-replacements") ? '' : 'disabled',
-                                'name' => 'phases[' . $sPhase . '][replace]['.$tTplFile.']['.$sField.']',
+                                'name' => 'phases[' . $sPhase . '][replace][' . $tTplFile . '][' . $sField . ']',
                                 'label' => $sField,
                                 'value' => $aValues && array_key_exists($sField, $aValues) ? $aValues[$sField] : '',
                                 // 'required' => 'required',
@@ -3351,7 +3421,7 @@ class project extends base {
                     } else {
                         $aForms["setup"]["form"]['input' . $i++] = array(
                             'type' => 'markup',
-                            'value' => '<br>'.$oHtml->getBox("error", t("replacement-fields-not-found"))
+                            'value' => '<br>' . $oHtml->getBox("error", t("replacement-fields-not-found"))
                                 // . '<pre>'.print_r($aValues, 1).'</pre>'
                         );
                     }
@@ -3363,17 +3433,17 @@ class project extends base {
             } else {
                 $aForms["setup"]["form"]['input' . $i++] = array(
                     'type' => 'markup',
-                    'value' => '<div class="form-group"><h4>'.t("none").'</h4></div>'
+                    'value' => '<div class="form-group"><h4>' . t("none") . '</h4></div>'
                 );
             }
-            
+
             $aForms["setup"]["form"]['input' . $i++] = array(
                 'type' => 'markup',
                 'value' => ''
-                .'</div>'
+                . '</div>'
             ); // close div for active phase
-            
-            
+
+
             $aForms["setup"]["form"]['input' . $i++] = array(
                 'type' => 'markup',
                 'value' => '</td></tr></tbody></table>',
@@ -3401,7 +3471,7 @@ class project extends base {
      */
     public function renderNewProject() {
         global $aParams;
-        if (!$this->oUser->hasPermission("project-action-create")){
+        if (!$this->oUser->hasPermission("project-action-create")) {
             return $this->oUser->showDenied();
         }