forked from FreePBX-ContributedModules/bosssecretary
-
Notifications
You must be signed in to change notification settings - Fork 0
/
page.bosssecretary.php
159 lines (145 loc) · 5.05 KB
/
page.bosssecretary.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
<?php /* $Id: page.bosssecretary.php $ */
//Copyright (C) 2008 TI Soluciones (msalazar at solucionesit dot com dot ve) and Ing. David Hrbaty
//
//This program is free software; you can redistribute it and/or
//modify it under the terms of the GNU General Public License
//as published by the Free Software Foundation; either version 2
//of the License, or (at your option) any later version.
//
//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.
if (isset($_GET["extensions"], $_GET["ajax"]))
{
$result = bosssecretary_search($_GET["extensions"]);
if (isset($result))
{
if (!empty($result))
{
foreach ($result as $extension)
{
echo $extension["extension"] . " extension is " . $extension["type"] . " at '" . $extension["label"] ."' group <br />";
}
}
else
{
echo "Not matches";
}
}
else
{
echo "Critery invalid!";
}
exit(1);
}
$dispnum = 'bosssecretary'; //used for switch on config.php
$extensionsCleaned = array();
$title = _("Boss Secretary");
$messages = "";
$params = array();
if (isset($_POST["cleanAdd"]) || (isset($_POST["cleanEdit"])) || isset($_POST["submitAdd"]) || isset($_POST["submitEdit"]))
{
if (isset($_POST["submitAdd"])) $_POST["group_number"] = null;
$extensionsCleaned = bosssecretary_clean_remove_duplicates($_POST["bosses_extensions"], $_POST["secretaries_extensions"], $_POST["group_number"]);
}
if (isset($_POST["submitAdd"]))
{
$group_number = bosssecretary_get_group_number_free();
$chiefs = bosssecretary_str_extensions_to_array($_POST["chiefs_extensions"]);
$errors = bosssecretary_group_add($group_number, $_POST["group_label"], $extensionsCleaned["bosses"],$extensionsCleaned["secretaries"], $chiefs);
$params["message_title"] = "";
$params["message_details"] = array();
if (empty($errors))
{
$_GET["bsgroupdisplay"] = "";
$params["message_title"] = "Group Added";
$params["message_details"] = array("Group was added successfully");
needreload();
}
else
{
//$params["group_number"] = $_POST["group_number"];
$params["group_label"] = $_POST["group_label"];
$params["chiefs"] = $_POST["chiefs"];
$params["bosses"] = $extensionsCleaned["bosses"];
$params["secretaries"] = $extensionsCleaned["secretaries"];
$params["message_title"] = "Errors were encountered, details";
$params["message_details"] = $errors;
}
$content = bosssecretary_get_form_add( $params);
}
elseif( isset($_POST["cleanAdd"]))
{
$params = $_POST;
$params["bosses"] = $extensionsCleaned["bosses"];
$params["secretaries"] = $extensionsCleaned["secretaries"];
$content = bosssecretary_get_form_add( $params);
}
elseif( isset($_POST["cleanEdit"]))
{
$params = $_POST;
$params["bosses"] = $extensionsCleaned["bosses"];
$params["secretaries"] = $extensionsCleaned["secretaries"];
$content = bosssecretary_get_form_edit( $params);
}
elseif(isset($_POST["submitEdit"]))
{
$chiefs = bosssecretary_str_extensions_to_array($_POST["chiefs_extensions"]);
$errors = bosssecretary_group_edit($_POST["group_number"], $_POST["group_label"], $extensionsCleaned["bosses"],$extensionsCleaned["secretaries"], $chiefs);
if (empty($errors))
{
$params["message_title"] = "Group Edited";
$params["message_details"] = array("Group " . $_POST["group_number"] . " (" . $_POST["group_label"] . ") was edited successfully");
needreload();
}
else
{
$params["message_title"] = "Errors were encountered, details";
$params["message_details"] = $errors;
}
$params["group_number"] = $_POST["group_number"];
$params["group_label"] = $_POST["group_label"];
$params["chiefs"] = $chiefs;
$params["bosses"] = $extensionsCleaned["bosses"];
$params["secretaries"] = $extensionsCleaned["secretaries"];
$content = bosssecretary_get_form_edit( $params);
}
elseif (isset($_GET["bsgroupdisplay"]))
{
$group = bosssecretary_extract_group_from_request($_GET["bsgroupdisplay"]);
if ($group == "add")
{
$content = bosssecretary_get_form_add($params);
}
else
{
$params = bosssecretary_set_params_to_edit(bosssecretary_get_data_of_group($group));
$content = bosssecretary_get_form_edit($params);
}
}
elseif (isset($_GET["bsgroupdelete"]))
{
$group = bosssecretary_extract_group_from_request($_GET["bsgroupdelete"]);
if (bosssecretary_group_exists($group))
{
if (bosssecretary_group_delete($group))
{
$content = "<br /> Group was deleted successfully <br /> <br /> <br /> <h3>Choose a group or add one:</h3> ";
needreload();
}
else
{
$content = "<br /> Group was not deleted, please try it again <br /> <br /> <br /><h3>Choose a group or add one:</h3>";
}
}
}
else
{
$content = "<br /> <br /> <br /> <h3>Choose a group or add one:</h3>";
}
$groups = bosssecretary_get_groups();
$linksGroups = bosssecretary_create_nav_groups_links($groups, $dispnum);
bosssecretary_show_nav_users($linksGroups);
bosssecretary_content($title, $content, $messages);
?>