| 1 |
<?php |
|---|
| 2 |
// This file is part of FreePBX. |
|---|
| 3 |
// |
|---|
| 4 |
// FreePBX is free software: you can redistribute it and/or modify |
|---|
| 5 |
// it under the terms of the GNU General Public License as published by |
|---|
| 6 |
// the Free Software Foundation, either version 2 of the License, or |
|---|
| 7 |
// (at your option) any later version. |
|---|
| 8 |
// |
|---|
| 9 |
// FreePBX is distributed in the hope that it will be useful, |
|---|
| 10 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 11 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 12 |
// GNU General Public License for more details. |
|---|
| 13 |
// |
|---|
| 14 |
// You should have received a copy of the GNU General Public License |
|---|
| 15 |
// along with FreePBX. If not, see <http://www.gnu.org/licenses/>. |
|---|
| 16 |
// |
|---|
| 17 |
// Copyright (C) 2006 Rob Thomas |
|---|
| 18 |
|
|---|
| 19 |
function featurecodeadmin_update($req) { |
|---|
| 20 |
foreach ($req as $key => $item) { |
|---|
| 21 |
// Split up... |
|---|
| 22 |
// 0 - action |
|---|
| 23 |
// 1 - modulename |
|---|
| 24 |
// 2 - featurename |
|---|
| 25 |
$arr = explode("#", $key); |
|---|
| 26 |
if (count($arr) == 3) { |
|---|
| 27 |
$action = $arr[0]; |
|---|
| 28 |
$modulename = $arr[1]; |
|---|
| 29 |
$featurename = $arr[2]; |
|---|
| 30 |
$fieldvalue = $item; |
|---|
| 31 |
|
|---|
| 32 |
// Is there a more efficient way of doing this? |
|---|
| 33 |
switch ($action) |
|---|
| 34 |
{ |
|---|
| 35 |
case "ena": |
|---|
| 36 |
$fcc = new featurecode($modulename, $featurename); |
|---|
| 37 |
if ($fieldvalue == 1) { |
|---|
| 38 |
$fcc->setEnabled(true); |
|---|
| 39 |
} else { |
|---|
| 40 |
$fcc->setEnabled(false); |
|---|
| 41 |
} |
|---|
| 42 |
$fcc->update(); |
|---|
| 43 |
break; |
|---|
| 44 |
case "custom": |
|---|
| 45 |
$fcc = new featurecode($modulename, $featurename); |
|---|
| 46 |
if ($fieldvalue == $fcc->getDefault()) { |
|---|
| 47 |
$fcc->setCode(''); // using default |
|---|
| 48 |
} else { |
|---|
| 49 |
$fcc->setCode($fieldvalue); |
|---|
| 50 |
} |
|---|
| 51 |
$fcc->update(); |
|---|
| 52 |
break; |
|---|
| 53 |
} |
|---|
| 54 |
} |
|---|
| 55 |
} |
|---|
| 56 |
|
|---|
| 57 |
needreload(); |
|---|
| 58 |
} |
|---|
| 59 |
|
|---|
| 60 |
function featurecodeadmin_check_extensions($exten=true) { |
|---|
| 61 |
$extenlist = array(); |
|---|
| 62 |
if (is_array($exten) && empty($exten)) { |
|---|
| 63 |
return $extenlist; |
|---|
| 64 |
} |
|---|
| 65 |
$featurecodes = featurecodes_getAllFeaturesDetailed(); |
|---|
| 66 |
|
|---|
| 67 |
foreach ($featurecodes as $result) { |
|---|
| 68 |
$thisexten = ($result['customcode'] != '')?$result['customcode']:$result['defaultcode']; |
|---|
| 69 |
|
|---|
| 70 |
// Ignore disabled codes, and modules, and any exten not being requested unless all (true) |
|---|
| 71 |
// |
|---|
| 72 |
if (($result['featureenabled'] == 1) && ($result['moduleenabled'] == 1) && ($exten === true || in_array($thisexten, $exten))) { |
|---|
| 73 |
$extenlist[$thisexten]['description'] = _("Featurecode: ").$result['featurename']." (".$result['modulename'].":".$result['featuredescription'].")"; |
|---|
| 74 |
$extenlist[$thisexten]['status'] = 'INUSE'; |
|---|
| 75 |
$extenlist[$thisexten]['edit_url'] = 'config.php?type=setup&display=featurecodeadmin'; |
|---|
| 76 |
} |
|---|
| 77 |
} |
|---|
| 78 |
return $extenlist; |
|---|
| 79 |
} |
|---|
| 80 |
?> |
|---|