From a1c925f9c924f55f9dc39f840a9e23a62d4b1af1 Mon Sep 17 00:00:00 2001
From: mcramer <m.cramer@pixcept.de>
Date: Tue, 30 Oct 2012 15:38:12 -0400
Subject: [PATCH] Implemented:  - Show status messages to clients as long as the datalog is not processed (changes pending...)  - missing:    - template code in templates other than database list    - language entries other than web_database, web_domain, web_database_user     

---
 interface/web/sites/templates/database_list.htm |   16 ++++++++
 interface/lib/lang/en.lng                       |   12 ++++++
 interface/lib/lang/de.lng                       |   13 ++++++
 interface/lib/app.inc.php                       |    6 +++
 interface/lib/classes/db_mysql.inc.php          |   22 +++++++++++
 interface/web/themes/default/css/styles.css     |    3 +
 6 files changed, 71 insertions(+), 1 deletions(-)

diff --git a/interface/lib/app.inc.php b/interface/lib/app.inc.php
index 71566e6..e0b237b 100755
--- a/interface/lib/app.inc.php
+++ b/interface/lib/app.inc.php
@@ -213,6 +213,12 @@
 		$this->tpl->setVar('app_title', $this->_conf['app_title']);
 		if(isset($_SESSION['s']['user'])) {
 			$this->tpl->setVar('app_version', $this->_conf['app_version']);
+            // get pending datalog changes
+            $datalog = $this->db->datalogStatus();
+            $this->tpl->setVar('datalog_changes_txt', $this->lng('datalog_changes_txt'));
+            $this->tpl->setVar('datalog_changes_end_txt', $this->lng('datalog_changes_end_txt'));
+            $this->tpl->setVar('datalog_changes_count', $datalog['count']);
+            $this->tpl->setLoop('datalog_changes', $datalog['entries']);
 		} else {
 			$this->tpl->setVar('app_version', '');
 		}
diff --git a/interface/lib/classes/db_mysql.inc.php b/interface/lib/classes/db_mysql.inc.php
index 1a6cc22..5b50efe 100644
--- a/interface/lib/classes/db_mysql.inc.php
+++ b/interface/lib/classes/db_mysql.inc.php
@@ -317,6 +317,28 @@
 
       return true;
     }
+    
+    //* get the current datalog status for the specified login (or currently logged in user)
+    public function datalogStatus($login = '') {
+        global $app;
+        
+        $return = array('count' => 0, 'entries' => array());
+        if($_SESSION['s']['user']['typ'] == 'admin') return $return; // these information should not be displayed to admin users
+        
+        if($login == '' && isset($_SESSION['s']['user'])) {
+            $login = $_SESSION['s']['user']['username'];
+        }
+        
+        $result = $this->queryAllRecords("SELECT COUNT( * ) AS cnt, sys_datalog.action, sys_datalog.dbtable FROM sys_datalog, server WHERE server.server_id = sys_datalog.server_id AND sys_datalog.user = '" . $this->quote($login) . "' AND sys_datalog.datalog_id > server.updated GROUP BY sys_datalog.dbtable, sys_datalog.action");
+        foreach($result as $row) {
+            if(!$row['dbtable']) continue;
+            $return['entries'][] = array('table' => $row['dbtable'], 'action' => $row['action'], 'count' => $row['cnt'], 'text' => $app->lng('datalog_status_' . $row['action'] . '_' . $row['dbtable']));
+            $return['count'] += 1;
+        }
+        unset($result);
+        
+        return $return;
+    }
 
 
     public function freeResult($query) 
diff --git a/interface/lib/lang/de.lng b/interface/lib/lang/de.lng
index 5527584..3fe857d 100644
--- a/interface/lib/lang/de.lng
+++ b/interface/lib/lang/de.lng
@@ -80,5 +80,18 @@
 $wb['globalsearch_suggestions_text_txt'] = "Vorschläge";
 $wb['global_tabchange_warning_txt'] = "Die Eingaben in diesem Tab werden gespeichert, wenn Sie OK klicken, bei Abbrechen werden die Änderungen verworfen.";
 $wb['global_tabchange_discard_txt'] = "Achtung, Sie haben ungespeicherte Änderungen in diesem Tab. Wenn Sie fortfahren werden die Änderungen verworfen.";
+
+$wb['datalog_changes_txt'] = 'Folgende &Auml;nderungen wurden noch nicht auf alle Server &uuml;bernommen:';
+$wb['datalog_changes_end_txt'] = 'Die &Uuml;bernahme der &Auml;nderungen kann bis zu 1 Minute in Anspruch nehmen.';
+$wb['datalog_status_i_web_database'] = 'Neue Datenbank anlegen';
+$wb['datalog_status_u_web_database'] = 'Datenbank &auml;ndern';
+$wb['datalog_status_d_web_database'] = 'Datenbank l&ouml;schen';
+$wb['datalog_status_i_web_database_user'] = 'Datenbank-Benutzer f&uuml;r Datenbank anlegen';
+$wb['datalog_status_u_web_database_user'] = 'Datenbank-Benutzer &auml;ndern';
+$wb['datalog_status_d_web_database_user'] = 'Datenbank-Benutzer l&ouml;schen';
+$wb['datalog_status_i_web_domain'] = 'Neue Webseite anlegen';
+$wb['datalog_status_u_web_domain'] = 'Webseiten-Einstellungen &auml;ndern';
+$wb['datalog_status_d_web_domain'] = 'Webseite l&ouml;schen';
+
 ?>
 
diff --git a/interface/lib/lang/en.lng b/interface/lib/lang/en.lng
index 09b692b..b2066ed 100644
--- a/interface/lib/lang/en.lng
+++ b/interface/lib/lang/en.lng
@@ -80,4 +80,16 @@
 $wb['globalsearch_suggestions_text_txt'] = "Suggestions";
 $wb['global_tabchange_warning_txt'] = 'Changed data in this tab will be changed if you press OK. On cancel they will be discarded.';
 $wb['global_tabchange_discard_txt'] = 'You have unsaved changes in this tab. Changes will be discarded if you continue.';
+
+$wb['datalog_changes_txt'] = 'The following changes are not yet populated to all servers:';
+$wb['datalog_changes_end_txt'] = 'Storing updates can take up to one minute. Please be patient.';
+$wb['datalog_status_i_web_database'] = 'Create new database';
+$wb['datalog_status_u_web_database'] = 'Update database';
+$wb['datalog_status_d_web_database'] = 'Delete database';
+$wb['datalog_status_i_web_database_user'] = 'Create database user for database';
+$wb['datalog_status_u_web_database_user'] = 'Update database user';
+$wb['datalog_status_d_web_database_user'] = 'Delete database user';
+$wb['datalog_status_i_web_domain'] = 'Create new website';
+$wb['datalog_status_u_web_domain'] = 'Update website settings';
+$wb['datalog_status_d_web_domain'] = 'Delete website';
 ?>
diff --git a/interface/web/sites/templates/database_list.htm b/interface/web/sites/templates/database_list.htm
index bcd9209..50e450f 100644
--- a/interface/web/sites/templates/database_list.htm
+++ b/interface/web/sites/templates/database_list.htm
@@ -4,6 +4,22 @@
 <div class="panel panel_list_database">
 
     <div class="pnl_toolsarea">
+        <tmpl_if name='datalog_changes_count' op='>' value='0'>
+        <div>
+            <div class="systemmonitor-state state-info">
+                <div class="status"></div>
+                <div class="statusMsg">
+                    {tmpl_var name="datalog_changes_txt"}
+                    <ul>
+                    <tmpl_loop name="datalog_changes">
+                        <li><strong>{tmpl_var name="text"}:</strong> {tmpl_var name="count"}</li>
+                    </tmpl_loop>
+                    </ul>
+                    {tmpl_var name="datalog_changes_end_txt"}
+                </div>
+            </div><br />
+        </div>
+        </tmpl_if>
         <fieldset><legend>{tmpl_var name="toolsarea_head_txt"}</legend>
             <div class="buttons">
                 <button class="button iconstxt icoAdd" type="button" onclick="loadContent('sites/database_edit.php');">
diff --git a/interface/web/themes/default/css/styles.css b/interface/web/themes/default/css/styles.css
index a2e7fb1..d860a89 100644
--- a/interface/web/themes/default/css/styles.css
+++ b/interface/web/themes/default/css/styles.css
@@ -1786,4 +1786,5 @@
 .ui-combobox { position: relative; display: inline-block; margin-right: 17px; }
 .ui-combobox-toggle { position: absolute !important; top: 0; bottom: 0; margin-left: -1px; padding: 1px !important; background: none repeat scroll 0 0 #FFFFFF !important; border: 1px solid #DFDFDF !important;}
 .ui-combobox-input { background: none repeat scroll 0 0 #FFFFFF !important; border: 1px solid #DFDFDF !important; padding: 1px; font-weight: normal !important; }
-.panel_install_package .ui-combobox { float: left; }
\ No newline at end of file
+.panel_install_package .ui-combobox { float: left; }
+.clear-float { clear: both; }
\ No newline at end of file

--
Gitblit v1.9.1