-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsccm_status_model.php
61 lines (53 loc) · 2.46 KB
/
sccm_status_model.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
<?php
class sccm_status_model extends \Model {
public function __construct($serial='')
{
parent::__construct('id', 'sccm_status'); //primary key, tablename
$this->rs['id'] = '';
$this->rs['serial_number'] = $serial;
$this->rs['agent_status'] = '';
$this->rs['mgmt_point'] = '';
$this->rs['enrollment_name'] = '';
$this->rs['enrollment_server'] = '';
$this->rs['last_checkin'] = '';
$this->rs['cert_exp'] = '';
if ($serial) {
$this->retrieve_record($serial);
$this->serial = $serial;
}
}
// ------------------------------------------------------------------------
/**
* Process data sent by postflight
*
* @param string data
*
**/
public function process($data)
{
// Translate network strings to db fields
$translate = array(
'Status = ' => 'agent_status',
'Management_Point = ' => 'mgmt_point',
'Enrollment_User_Name = ' => 'enrollment_name',
'Enrollment_Server_Address = ' => 'enrollment_server',
'Last_Check_In_Time = ' => 'last_checkin',
'Client_Certificate_Expiry_Date = ' => 'cert_exp');
//clear any previous data we had
foreach($translate as $search => $field) {
$this->$field = '';
}
// Parse data
foreach(explode("\n", $data) as $line) {
// Translate standard entries
foreach($translate as $search => $field) {
if(strpos($line, $search) === 0) {
$value = substr($line, strlen($search));
$this->$field = $value;
break;
}
}
} //end foreach explode lines
$this->save();
}
}