-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathuploadGroupMOH.php
65 lines (60 loc) · 2.38 KB
/
uploadGroupMOH.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
/**
* Description: Group MOH update.
* Date: 27/05/14
* Time: 12:30
* Author: Luke Beer
* Usage: php uploadGroupMOH.php listofgroups.csv externalMOH.wav [internalMOH.wav] optional.
* CSV should be format enterpriseid,groupid
*/
// Configuration - Set these to TRUE/FALSE
$department = null;
$isActiveDuringCallHold = 'true';
$isActiveDuringCallPark = 'true';
$isActiveDuringBusyCampOn = 'true';
$useAlternateSourceForInternalCalls = 'false';
// End config
require_once 'config.php';
require_once OCIP_BASEPATH . 'core/OCIClient.php';
ini_set("max_execution_time", 0);
Factory::getOCISchemaServiceMusicOnHold();
$client = CoreFactory::getOCIClient(OCIP_HOST);
$client->login(OCIP_USER, OCIP_PASS);
$client->setTimeout(60);
if (!$rows = file($argv[1])) die("Something went wrong reading the CSV");
if ($extmusic = file_get_contents($argv[2])) {
$source['audioFilePreferredCodec'] = 'None';
$source['messageSourceSelection'] = 'Custom';
$source['customSource']['audioFile']['description'] = 'Music on Hold';
$source['customSource']['audioFile']['mediaType'] = 'WAV';
$source['customSource']['audioFile']['content'] = base64_encode($extmusic);
} else {
die("Something went wrong reading the music file");
}
if ($intmusic = @file_get_contents($argv[3])) {
$source['audioFilePreferredCodec'] = 'None';
$source['messageSourceSelection'] = 'Custom';
$source['customSource']['audioFile']['description'] = 'Music on Hold';
$source['customSource']['audioFile']['mediaType'] = 'WAV';
$source['customSource']['audioFile']['content'] = base64_encode($intmusic);
} else {
$useAlternateSourceForInternalCalls = 'false';
$internalSource = null;
echo "Notice: Not using alternate music source for internal calls, no internal music file provided as argument.\n\n";
}
foreach ($rows as $row) {
$detail = str_getcsv($row);
$client->send(OCISchemaServiceMusicOnHold::GroupMusicOnHoldModifyInstanceRequest16(
$detail[0],
$detail[1],
$department,
$isActiveDuringCallHold,
$isActiveDuringCallPark,
$isActiveDuringBusyCampOn,
$source,
$useAlternateSourceForInternalCalls,
$internalSource
));
if ($client->getResponse()) echo "Uploaded MOH for {$detail[0]} - {$detail[1]}\n";
}
print_r($errorControl->getErrors());