| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
$action = isset($_POST['action']) ? $_POST['action'] : ''; |
|---|
| 16 |
if (isset($_POST['delete'])) $action = 'delete'; |
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
$miscapp_id = isset($_POST['miscapp_id']) ? $_POST['miscapp_id'] : false; |
|---|
| 20 |
$description = isset($_POST['description']) ? $_POST['description'] : ''; |
|---|
| 21 |
$ext = isset($_POST['ext']) ? $_POST['ext'] : ''; |
|---|
| 22 |
$dest = isset($_POST['dest']) ? $_POST['dest'] : ''; |
|---|
| 23 |
$enabled = isset($_POST['enabled']) ? (!empty($_POST['enabled'])) : true; |
|---|
| 24 |
|
|---|
| 25 |
if (isset($_POST['goto0']) && $_POST['goto0']) { |
|---|
| 26 |
$dest = $_POST[ $_POST['goto0'].'0' ]; |
|---|
| 27 |
} |
|---|
| 28 |
|
|---|
| 29 |
|
|---|
| 30 |
switch ($action) { |
|---|
| 31 |
case 'add': |
|---|
| 32 |
$conflict_url = array(); |
|---|
| 33 |
$usage_arr = framework_check_extension_usage($ext); |
|---|
| 34 |
if (!empty($usage_arr)) { |
|---|
| 35 |
$conflict_url = framework_display_extension_usage_alert($usage_arr); |
|---|
| 36 |
} else { |
|---|
| 37 |
miscapps_add($description, $ext, $dest); |
|---|
| 38 |
needreload(); |
|---|
| 39 |
redirect_standard(); |
|---|
| 40 |
} |
|---|
| 41 |
break; |
|---|
| 42 |
|
|---|
| 43 |
// do a check to make sure it doesn't conflict. If not changing, np. |
|---|
| 44 |
// |
|---|
| 45 |
case 'edit': |
|---|
| 46 |
$fc = new featurecode('miscapps', 'miscapp_'.$miscapp_id); |
|---|
| 47 |
$conflict_url = array(); |
|---|
| 48 |
if ($fc->getDefault() != $ext) { |
|---|
| 49 |
$usage_arr = framework_check_extension_usage($ext); |
|---|
| 50 |
if (!empty($usage_arr)) { |
|---|
| 51 |
$conflict_url = framework_display_extension_usage_alert($usage_arr); |
|---|
| 52 |
} |
|---|
| 53 |
} |
|---|
| 54 |
if (empty($conflict_url)) { |
|---|
| 55 |
miscapps_edit($miscapp_id, $description, $ext, $dest, $enabled); |
|---|
| 56 |
needreload(); |
|---|
| 57 |
redirect_standard('extdisplay'); |
|---|
| 58 |
} |
|---|
| 59 |
break; |
|---|
| 60 |
case 'delete': |
|---|
| 61 |
miscapps_delete($miscapp_id); |
|---|
| 62 |
needreload(); |
|---|
| 63 |
redirect_standard(); |
|---|
| 64 |
break; |
|---|
| 65 |
} |
|---|
| 66 |
|
|---|
| 67 |
|
|---|
| 68 |
?> |
|---|
| 69 |
</div> |
|---|
| 70 |
|
|---|
| 71 |
<div class="rnav"><ul> |
|---|
| 72 |
<?php |
|---|
| 73 |
|
|---|
| 74 |
echo '<li><a href="config.php?display=miscapps&type=setup">'._('Add Misc. Application').'</a></li>'; |
|---|
| 75 |
|
|---|
| 76 |
foreach (miscapps_list() as $row) { |
|---|
| 77 |
echo '<li><a href="config.php?display=miscapps&type=setup&extdisplay='.$row['miscapps_id'].'" class="">'.$row['description'].'</a></li>'; |
|---|
| 78 |
} |
|---|
| 79 |
|
|---|
| 80 |
?> |
|---|
| 81 |
</ul></div> |
|---|
| 82 |
|
|---|
| 83 |
<div class="content"> |
|---|
| 84 |
|
|---|
| 85 |
<?php |
|---|
| 86 |
|
|---|
| 87 |
if ($extdisplay) { |
|---|
| 88 |
|
|---|
| 89 |
$row = miscapps_get($extdisplay); |
|---|
| 90 |
|
|---|
| 91 |
$description = $row['description']; |
|---|
| 92 |
$ext = $row['ext']; |
|---|
| 93 |
$dest = $row['dest']; |
|---|
| 94 |
$enabled = $row['enabled']; |
|---|
| 95 |
|
|---|
| 96 |
} |
|---|
| 97 |
|
|---|
| 98 |
$helptext = _("Misc Applications are for adding feature codes that you can dial from internal phones that go to various destinations available in FreePBX. This is in contrast to the <strong>Misc Destinations</strong> module, which is for creating destinations that can be used by other FreePBX modules to dial internal numbers or feature codes."); |
|---|
| 99 |
echo "<p>".$helptext."</p>\n"; |
|---|
| 100 |
?> |
|---|
| 101 |
|
|---|
| 102 |
<?php if (!empty($conflict_url)) { |
|---|
| 103 |
echo "<h5>"._("Conflicting Extensions")."</h5>"; |
|---|
| 104 |
echo implode('<br .>',$conflict_url); |
|---|
| 105 |
} |
|---|
| 106 |
?> |
|---|
| 107 |
|
|---|
| 108 |
<form name="editMiscapp" action="<?php $_SERVER['PHP_SELF'] ?>" method="post" onsubmit="return checkMiscapp(editMiscapp);"> |
|---|
| 109 |
<input type="hidden" name="extdisplay" value="<?php echo $extdisplay; ?>"> |
|---|
| 110 |
<input type="hidden" name="miscapp_id" value="<?php echo $extdisplay; ?>"> |
|---|
| 111 |
<input type="hidden" name="action" value="<?php echo ($extdisplay ? 'edit' : 'add'); ?>"> |
|---|
| 112 |
<table> |
|---|
| 113 |
<tr><td colspan="2"><h5><?php echo ($extdisplay ? _("Edit Misc Application") : _("Add Misc Application")) ?><hr></h5></td></tr> |
|---|
| 114 |
<tr> |
|---|
| 115 |
<td><a href="#" class="info"><?php echo _("Description")?>:<span><?php echo _("The name of this application")?></span></a></td> |
|---|
| 116 |
<td><input size="15" type="text" name="description" value="<?php echo $description; ?>"></td> |
|---|
| 117 |
</tr> |
|---|
| 118 |
<tr> |
|---|
| 119 |
<td><a href="#" class="info"><?php echo _("Feature Code")?>:<span><?php echo _("The feature code/extension users can dial to access this application. This can also be modified on the Feature Codes page.")?></span></a></td> |
|---|
| 120 |
<td><input type="text" name="ext" value="<?php echo $ext; ?>" /></td> |
|---|
| 121 |
</tr> |
|---|
| 122 |
<tr> |
|---|
| 123 |
<td><a href="#" class="info"><?php echo _("Feature Status")?>:<span><?php echo _("If this code is enabled or not.")?></span></a></td> |
|---|
| 124 |
<td><select name="enabled"> |
|---|
| 125 |
<option value="1" <?php if ($enabled) echo "SELECTED"; ?>>Enabled</option> |
|---|
| 126 |
<option value="0" <?php if (!$enabled) echo "SELECTED"; ?>>Disabled</option> |
|---|
| 127 |
</select></td> |
|---|
| 128 |
</tr> |
|---|
| 129 |
|
|---|
| 130 |
<tr><td colspan="2"><br><h5><?php echo _("Destination")?>:<hr></h5></td></tr> |
|---|
| 131 |
|
|---|
| 132 |
<?php |
|---|
| 133 |
|
|---|
| 134 |
echo drawselects($dest,0,true); |
|---|
| 135 |
?> |
|---|
| 136 |
|
|---|
| 137 |
<tr> |
|---|
| 138 |
<td colspan="2"><br><input name="Submit" type="submit" value="<?php echo _("Submit Changes")?>"> |
|---|
| 139 |
<?php if ($extdisplay) { echo ' <input name="delete" type="submit" value="'._("Delete").'">'; } ?> |
|---|
| 140 |
</td> |
|---|
| 141 |
|
|---|
| 142 |
</tr> |
|---|
| 143 |
</table> |
|---|
| 144 |
</form> |
|---|
| 145 |
|
|---|
| 146 |
|
|---|
| 147 |
<script language="javascript"> |
|---|
| 148 |
<!-- |
|---|
| 149 |
|
|---|
| 150 |
function checkMiscapp(theForm) { |
|---|
| 151 |
var msgInvalidDescription = "<?php echo _('Invalid description specified'); ?>"; |
|---|
| 152 |
|
|---|
| 153 |
// set up the Destination stuff |
|---|
| 154 |
setDestinations(theForm, '_post_dest'); |
|---|
| 155 |
|
|---|
| 156 |
// form validation |
|---|
| 157 |
defaultEmptyOK = false; |
|---|
| 158 |
if (isEmpty(theForm.description.value)) |
|---|
| 159 |
return warnInvalid(theForm.description, msgInvalidDescription); |
|---|
| 160 |
|
|---|
| 161 |
if (!validateDestinations(theForm, 1, true)) |
|---|
| 162 |
return false; |
|---|
| 163 |
|
|---|
| 164 |
return true; |
|---|
| 165 |
} |
|---|
| 166 |
//--> |
|---|
| 167 |
</script> |
|---|
| 168 |
|
|---|