-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathUcphelloworld.class.php
65 lines (63 loc) · 2.47 KB
/
Ucphelloworld.class.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
namespace FreePBX\modules;
class Ucphelloworld implements \BMO {
public function __construct($freepbx = null) {
if ($freepbx == null) {
throw new Exception("Not given a FreePBX Object");
}
$this->FreePBX = $freepbx;
$this->db = $freepbx->Database;
}
public function install(){}
public function uninstall(){}
public function backup() {}
public function restore($backup) {}
public function doConfigPageInit($page) {}
public function ucpConfigPage($mode, $user, $action) {
if(empty($user)) {
$enabled = ($mode == 'group') ? true : null;
} else {
if($mode == 'group') {
$enabled = $this->FreePBX->Ucp->getSettingByGID($user['id'],'Ucphelloworld','enabled');
$enabled = !($enabled) ? false : true;
} else {
$enabled = $this->FreePBX->Ucp->getSettingByID($user['id'],'Ucphelloworld','enabled');
}
}
$html = array();
$html[0] = array(
"title" => _("Hello World"),
"rawname" => "ucphelloworld",
"content" => load_view(dirname(__FILE__)."/views/ucp_config.php",array("mode" => $mode, "enabled" => $enabled))
);
return $html;
}
public function ucpAddUser($id, $display, $ucpStatus, $data) {
$this->ucpUpdateUser($id, $display, $ucpStatus, $data);
}
public function ucpUpdateUser($id, $display, $ucpStatus, $data) {
if($display == 'userman' && isset($_POST['type']) && $_POST['type'] == 'user') {
if(isset($_POST['ucphelloworld_enable']) && $_POST['ucphelloworld_enable'] == 'yes') {
$this->FreePBX->Ucp->setSettingByID($id,'Ucphelloworld','enabled',true);
}elseif(isset($_POST['ucphelloworld_enable']) && $_POST['ucphelloworld_enable'] == 'no') {
$this->FreePBX->Ucp->setSettingByID($id,'Ucphelloworld','enabled',false);
} elseif(isset($_POST['ucphelloworld_enable']) && $_POST['ucphelloworld_enable'] == 'inherit') {
$this->FreePBX->Ucp->setSettingByID($id,'Ucphelloworld','enabled',null);
}
}
}
public function ucpDelUser($id, $display, $ucpStatus, $data) {}
public function ucpAddGroup($id, $display, $data) {
$this->ucpUpdateGroup($id,$display,$data);
}
public function ucpUpdateGroup($id,$display,$data) {
if($display == 'userman' && isset($_POST['type']) && $_POST['type'] == 'group') {
if(isset($_POST['ucphelloworld_enable']) && $_POST['ucphelloworld_enable'] == 'yes') {
$this->FreePBX->Ucp->setSettingByGID($id,'Ucphelloworld','enabled',true);
} else {
$this->FreePBX->Ucp->setSettingByGID($id,'Ucphelloworld','enabled',false);
}
}
}
public function ucpDelGroup($id,$display,$data) {}
}