-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathRestore.php
32 lines (29 loc) · 1.26 KB
/
Restore.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php
namespace FreePBX\modules\Calendar;
use FreePBX\modules\Backup as Base;
class Restore extends Base\RestoreBase{
public function runRestore(){
$settings = $this->getConfigs();
foreach ($settings as $key => $value) {
$this->FreePBX->Calendar->setMultiConfig($value, $key);
}
}
public function processLegacy($pdo, $data, $tables, $unknownTables){
$this->restoreLegacyKvstore($pdo);
//process the kvstore and add new line instead of \n
$selectsql = "SELECT * from kvstore_FreePBX_modules_Calendar where id='calendar-raw'";
$kvstorecalendar = $this->FreePBX->Database->query($selectsql)->fetchAll(\PDO::FETCH_ASSOC);
$this->FreePBX->Database->query("DELETE from kvstore_FreePBX_modules_Calendar where id='calendar-raw'");
foreach($kvstorecalendar as $calendar) {
$calevents = explode('\n',(string) $calendar['val']);
$calendar['val'] = implode("\n", $calevents);
$query = "INSERT INTO kvstore_FreePBX_modules_Calendar (`key`, `val`, `type`, `id`) VALUES (:key, :val, :type, :id)";
$stmt = $this->FreePBX->Database->prepare($query);
$stmt->bindParam(':key', $calendar['key']);
$stmt->bindParam(':val', $calendar['val']);
$stmt->bindParam(':type', $calendar['type']);
$stmt->bindParam(':id', $calendar['id']);
$stmt->execute();
}
}
}