forked from permag/sayHello2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
recordcall.php
51 lines (39 loc) · 1.19 KB
/
recordcall.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
<?php
session_start();
require_once('database/DBConfig.php');
require_once('database/Database.php');
require_once('models/RecordModel.php');
/**
* Called when clicked send recording
*/
class RecordCall {
/**
* Call RecordController to save recording
*/
public function init() {
$dbConfig = new DBConfig();
$db = new Database($dbConfig);
// DB-connect
$db->connect();
$this->saveRecording($db);
// kill DB-conn
$db = null;
}
public function saveRecording($db) {
$recModel = new RecordModel($db);
$recModel->setRecordingUploadStatus(false); // set a session to indicate recording began uploading
$ownerUserId = $_SESSION['active_user_id'];
$toUserId = $_SESSION['recording_to_userId'];
unset($_SESSION['recording_to_userId']);
$filename = $recModel->setRecordingFilename($ownerUserId);
if ($filename != null) {
$filenameAndExt = $recModel->saveRecordingToFile($filename);
$recId = $recModel->insertRecording($ownerUserId, $toUserId, $filenameAndExt);
}
$recModel->setRecordingUploadStatus(true); // all finished
}
}
if (isset($_SESSION['active_user_id']) && isset($_SESSION['recording_to_userId'])) {
$recordCall = new RecordCall();
$recordCall->init();
}