Skip to content

Commit 85204d6

Browse files
author
Till Brehm
committed
Extended resync function, added:
- database users - email forwarders and aliases - clients
1 parent 4193f48 commit 85204d6

File tree

3 files changed

+52
-0
lines changed

3 files changed

+52
-0
lines changed

interface/web/tools/lib/lang/en_resync.lng

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ $wb['resync_cron_txt'] = 'Resync cronjobs';
88
$wb['resync_db_txt'] = 'Resync clientdb config';
99
$wb['resync_mailbox_txt'] = 'Resync Mailboxes';
1010
$wb['resync_dns_txt'] = 'Resync DNS records';
11+
$wb['resync_client_txt'] = 'Resync Client records';
1112
$wb['btn_start_txt'] = 'Start';
1213
$wb['btn_cancel_txt'] = 'Cancel';
1314
?>

interface/web/tools/resync.php

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,16 @@
106106

107107
//* Resyncing Databases
108108
if(isset($_POST['resync_db']) && $_POST['resync_db'] == 1) {
109+
$db_table = 'web_database_user';
110+
$index_field = 'database_user_id';
111+
$sql = "SELECT * FROM ".$db_table." WHERE 1";
112+
$records = $app->db->queryAllRecords($sql);
113+
if(is_array($records)) {
114+
foreach($records as $rec) {
115+
$app->db->datalogUpdate($db_table, $rec, $index_field, $rec[$index_field], true);
116+
$msg .= "Resynced Database user: ".$rec['database_user'].'<br />';
117+
}
118+
}
109119
$db_table = 'web_database';
110120
$index_field = 'database_id';
111121
$sql = "SELECT * FROM ".$db_table." WHERE active = 'y'";
@@ -144,6 +154,16 @@
144154
$msg .= "Resynced Mailbox: ".$rec['email'].'<br />';
145155
}
146156
}
157+
$db_table = 'mail_forwarding';
158+
$index_field = 'forwarding_id';
159+
$sql = "SELECT * FROM ".$db_table;
160+
$records = $app->db->queryAllRecords($sql);
161+
if(is_array($records)) {
162+
foreach($records as $rec) {
163+
$app->db->datalogUpdate($db_table, $rec, $index_field, $rec[$index_field], true);
164+
$msg .= "Resynced Alias: ".$rec['source'].'<br />';
165+
}
166+
}
147167
}
148168

149169
//* Resyncing dns zones
@@ -169,6 +189,31 @@
169189

170190
}
171191

192+
//* Resyncing Clients
193+
if(isset($_POST['resync_client']) && $_POST['resync_client'] == 1) {
194+
$tform_def_file = "form/client.tform.php";
195+
$app->uses('tpl,tform,tform_actions');
196+
$app->load('tform_actions');
197+
198+
$db_table = 'client';
199+
$index_field = 'client_id';
200+
$sql = "SELECT * FROM ".$db_table;
201+
$records = $app->db->queryAllRecords($sql);
202+
if(is_array($records)) {
203+
foreach($records as $rec) {
204+
$app->db->datalogUpdate($db_table, $rec, $index_field, $rec[$index_field], true);
205+
$tmp = new tform_actions;
206+
$tmp->id = $rec[$index_field];
207+
$tmp->dataRecord = $rec;
208+
$tmp->oldDataRecord = $rec;
209+
$app->plugin->raiseEvent('client:client:on_after_update', $tmp);
210+
$msg .= "Resynced Client: ".$rec['contact_name'].'<br />';
211+
unset($tmp);
212+
}
213+
}
214+
}
215+
216+
172217
$app->tpl->setVar('msg', $msg);
173218
$app->tpl->setVar('error', $error);
174219

interface/web/tools/templates/resync.htm

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ <h2><tmpl_var name="head_txt"></h2>
4646
<div class="multiField">
4747
<input id="resync_dns" type="checkbox" value="1" name="resync_dns" />
4848
</div>
49+
</div>
50+
<div class="ctrlHolder">
51+
<p class="label">{tmpl_var name="resync_client_txt"}</p>
52+
<div class="multiField">
53+
<input id="resync_client" type="checkbox" value="1" name="resync_client" />
54+
</div>
4955
</div>
5056
</fieldset>
5157

0 commit comments

Comments
 (0)