-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathnudge_model.php
79 lines (68 loc) · 2.41 KB
/
nudge_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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<?php
use CFPropertyList\CFPropertyList;
class Nudge_model extends \Model
{
public function __construct($serial = '')
{
parent::__construct('id', 'nudge'); // Primary key, tablename
$this->rs['id'] = '';
$this->rs['serial_number'] = $serial;
$this->rs['past_required_install_date'] = null;
$this->rs['current_os'] = null;
$this->rs['required_os'] = null;
$this->rs['more_info_event'] = null;
$this->rs['device_info_event'] = null;
$this->rs['primary_quit_event'] = null;
$this->rs['secondary_quit_event'] = null;
$this->rs['update_device_event'] = null;
$this->rs['deferral_initiated_event'] = null;
$this->rs['deferral_date'] = null;
$this->rs['synthetic_click_event'] = null;
$this->rs['command_quit_event'] = null;
$this->rs['termination_event'] = null;
$this->rs['activation_event'] = null;
$this->rs['new_nudge_event'] = null;
$this->rs['nudge_log'] = null;
$this->rs['deferral_count'] = null;
$this->rs['deferral_user'] = null;
$this->rs['json_config'] = null;
$this->rs['profile_config'] = null;
if ($serial) {
$this->retrieve_record($serial);
}
$this->serial_number = $serial;
}
// ------------------------------------------------------------------------
/**
* Process data sent by postflight
*
* @param string data
*
**/
public function process($data)
{
// If data is empty, echo out error
if (! $data) {
echo ("Error Processing nudge module: No data found");
} else {
// Delete previous entries
$this->deleteWhere('serial_number=?', $this->serial_number);
// Process incoming nudge.plist
$parser = new CFPropertyList();
$parser->parse($data, CFPropertyList::FORMAT_XML);
$plist = $parser->toArray();
foreach ($this->rs as $key => $value) {
$this->rs[$key] = $value;
if(array_key_exists($key, $plist))
{
$this->rs[$key] = $plist[$key];
} else if ($key != "serial_number") {
$this->rs[$key] = null;
}
}
// Save the data, nudgin the Macs
$this->id = '';
$this->save();
}
}
}