From 85204d6ca7d267726c9cb371e308aa642b3d99d7 Mon Sep 17 00:00:00 2001
From: Till Brehm <tbrehm@ispconfig.org>
Date: Wed, 29 Jan 2014 12:01:05 -0500
Subject: [PATCH] Extended resync function, added: - database users - email forwarders and aliases - clients

---
 interface/web/tools/resync.php             |   45 +++++++++++++++++++++++++++++++++++++++++++++
 interface/web/tools/templates/resync.htm   |    6 ++++++
 interface/web/tools/lib/lang/en_resync.lng |    1 +
 3 files changed, 52 insertions(+), 0 deletions(-)

diff --git a/interface/web/tools/lib/lang/en_resync.lng b/interface/web/tools/lib/lang/en_resync.lng
index f4cbf0d..b01afa2 100644
--- a/interface/web/tools/lib/lang/en_resync.lng
+++ b/interface/web/tools/lib/lang/en_resync.lng
@@ -8,6 +8,7 @@
 $wb['resync_db_txt'] = 'Resync clientdb config';
 $wb['resync_mailbox_txt'] = 'Resync Mailboxes';
 $wb['resync_dns_txt'] = 'Resync DNS records';
+$wb['resync_client_txt'] = 'Resync Client records';
 $wb['btn_start_txt'] = 'Start';
 $wb['btn_cancel_txt'] = 'Cancel';
 ?>
\ No newline at end of file
diff --git a/interface/web/tools/resync.php b/interface/web/tools/resync.php
index a02ac9f..1191585 100644
--- a/interface/web/tools/resync.php
+++ b/interface/web/tools/resync.php
@@ -106,6 +106,16 @@
 
 //* Resyncing Databases
 if(isset($_POST['resync_db']) && $_POST['resync_db'] == 1) {
+	$db_table = 'web_database_user';
+	$index_field = 'database_user_id';
+	$sql = "SELECT * FROM ".$db_table." WHERE 1";
+	$records = $app->db->queryAllRecords($sql);
+	if(is_array($records)) {
+		foreach($records as $rec) {
+			$app->db->datalogUpdate($db_table, $rec, $index_field, $rec[$index_field], true);
+			$msg .= "Resynced Database user: ".$rec['database_user'].'<br />';
+		}
+	}
 	$db_table = 'web_database';
 	$index_field = 'database_id';
 	$sql = "SELECT * FROM ".$db_table." WHERE active = 'y'";
@@ -144,6 +154,16 @@
 			$msg .= "Resynced Mailbox: ".$rec['email'].'<br />';
 		}
 	}
+	$db_table = 'mail_forwarding';
+	$index_field = 'forwarding_id';
+	$sql = "SELECT * FROM ".$db_table;
+	$records = $app->db->queryAllRecords($sql);
+	if(is_array($records)) {
+		foreach($records as $rec) {
+			$app->db->datalogUpdate($db_table, $rec, $index_field, $rec[$index_field], true);
+			$msg .= "Resynced Alias: ".$rec['source'].'<br />';
+		}
+	}
 }
 
 //* Resyncing dns zones
@@ -169,6 +189,31 @@
 
 }
 
+//* Resyncing Clients
+if(isset($_POST['resync_client']) && $_POST['resync_client'] == 1) {
+	$tform_def_file = "form/client.tform.php";
+	$app->uses('tpl,tform,tform_actions');
+	$app->load('tform_actions');
+	
+	$db_table = 'client';
+	$index_field = 'client_id';
+	$sql = "SELECT * FROM ".$db_table;
+	$records = $app->db->queryAllRecords($sql);
+	if(is_array($records)) {
+		foreach($records as $rec) {
+			$app->db->datalogUpdate($db_table, $rec, $index_field, $rec[$index_field], true);
+			$tmp = new tform_actions;
+			$tmp->id = $rec[$index_field];
+			$tmp->dataRecord = $rec;
+			$tmp->oldDataRecord = $rec;
+			$app->plugin->raiseEvent('client:client:on_after_update', $tmp);
+			$msg .= "Resynced Client: ".$rec['contact_name'].'<br />';
+			unset($tmp);
+		}
+	}
+}
+
+
 $app->tpl->setVar('msg', $msg);
 $app->tpl->setVar('error', $error);
 
diff --git a/interface/web/tools/templates/resync.htm b/interface/web/tools/templates/resync.htm
index f164660..57eadb7 100644
--- a/interface/web/tools/templates/resync.htm
+++ b/interface/web/tools/templates/resync.htm
@@ -47,6 +47,12 @@
                     <input id="resync_dns" type="checkbox" value="1" name="resync_dns" />
                 </div>
             </div>
+			<div class="ctrlHolder">
+                <p class="label">{tmpl_var name="resync_client_txt"}</p>
+                <div class="multiField">
+                    <input id="resync_client" type="checkbox" value="1" name="resync_client" />
+                </div>
+            </div>
         </fieldset>
 
         <tmpl_if name="msg">

--
Gitblit v1.9.1