| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
$tabindex = 0; |
|---|
| 16 |
$display = 'customdests'; |
|---|
| 17 |
|
|---|
| 18 |
$type = isset($_REQUEST['type']) ? $_REQUEST['type'] : 'tool'; |
|---|
| 19 |
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : ''; |
|---|
| 20 |
if (isset($_REQUEST['delete'])) $action = 'delete'; |
|---|
| 21 |
|
|---|
| 22 |
$old_custom_dest = isset($_REQUEST['old_custom_dest']) ? $_REQUEST['old_custom_dest'] : ''; |
|---|
| 23 |
$custom_dest = isset($_REQUEST['extdisplay']) ? $_REQUEST['extdisplay'] : ''; |
|---|
| 24 |
$description = isset($_REQUEST['description']) ? $_REQUEST['description'] : ''; |
|---|
| 25 |
$notes = isset($_REQUEST['notes']) ? $_REQUEST['notes'] : ''; |
|---|
| 26 |
|
|---|
| 27 |
switch ($action) { |
|---|
| 28 |
case 'add': |
|---|
| 29 |
if (customappsreg_customdests_add($custom_dest, $description, $notes)) { |
|---|
| 30 |
needreload(); |
|---|
| 31 |
redirect_standard(); |
|---|
| 32 |
} else { |
|---|
| 33 |
$custom_dest=''; |
|---|
| 34 |
} |
|---|
| 35 |
break; |
|---|
| 36 |
case 'edit': |
|---|
| 37 |
if (customappsreg_customdests_edit($old_custom_dest, $custom_dest, $description, $notes)) { |
|---|
| 38 |
needreload(); |
|---|
| 39 |
redirect_standard('extdisplay'); |
|---|
| 40 |
} |
|---|
| 41 |
break; |
|---|
| 42 |
case 'delete': |
|---|
| 43 |
customappsreg_customdests_delete($custom_dest); |
|---|
| 44 |
needreload(); |
|---|
| 45 |
redirect_standard(); |
|---|
| 46 |
break; |
|---|
| 47 |
} |
|---|
| 48 |
|
|---|
| 49 |
?> |
|---|
| 50 |
</div> |
|---|
| 51 |
|
|---|
| 52 |
<div class="rnav"><ul> |
|---|
| 53 |
<?php |
|---|
| 54 |
|
|---|
| 55 |
echo '<li><a href="config.php?display='.$display.'&type='.$type.'">'._('Add Custom Destination').'</a></li>'; |
|---|
| 56 |
|
|---|
| 57 |
foreach (customappsreg_customdests_list() as $row) { |
|---|
| 58 |
$descr = $row['description'] != '' ? $row['description'] : '('.$row['custom_dest'].')'; |
|---|
| 59 |
echo '<li><a href="config.php?display='.$display.'&type='.$type.'&extdisplay='.$row['custom_dest'].'" class="">'.$descr.'</a></li>'; |
|---|
| 60 |
} |
|---|
| 61 |
|
|---|
| 62 |
?> |
|---|
| 63 |
</ul></div> |
|---|
| 64 |
|
|---|
| 65 |
<div class="content"> |
|---|
| 66 |
|
|---|
| 67 |
<?php |
|---|
| 68 |
|
|---|
| 69 |
if ($custom_dest != '') { |
|---|
| 70 |
|
|---|
| 71 |
$usage_list = framework_display_destination_usage(customappsreg_customdests_getdest($custom_dest)); |
|---|
| 72 |
|
|---|
| 73 |
$row = customappsreg_customdests_get($custom_dest); |
|---|
| 74 |
|
|---|
| 75 |
$description = $row['description']; |
|---|
| 76 |
$notes = $row['notes']; |
|---|
| 77 |
|
|---|
| 78 |
$disp_description = $row['description'] != '' ? $row['description'] : '('.$row['custom_dest'].')'; |
|---|
| 79 |
echo "<h2>"._("Edit: ")."$disp_description"."</h2>"; |
|---|
| 80 |
} else { |
|---|
| 81 |
echo "<h2>"._("Add Custom Destination")."</h2>"; |
|---|
| 82 |
} |
|---|
| 83 |
|
|---|
| 84 |
$helptext = _("Custom Destinations allows you to register your custom destinations that point to custom dialplans and will also 'publish' these destinations as available destinations to other modules. This is an advanced feature and should only be used by knowledgeable users. If you are getting warnings or errors in the notification panel about CUSTOM destinations that are correct, you should include them here. The 'Unknown Destinations' chooser will allow you to choose and insert any such destinations that the registry is not aware of into the Custom Destination field."); |
|---|
| 85 |
echo $helptext; |
|---|
| 86 |
?> |
|---|
| 87 |
|
|---|
| 88 |
<form name="editCustomDest" action="<?php $_SERVER['PHP_SELF'] ?>" method="post" onsubmit="return checkCustomDest(editCustomDest);"> |
|---|
| 89 |
<input type="hidden" name="extdisplay" value="<?php echo $custom_dest; ?>"> |
|---|
| 90 |
<input type="hidden" name="old_custom_dest" value="<?php echo $custom_dest; ?>"> |
|---|
| 91 |
<input type="hidden" name="action" value="<?php echo ($custom_dest != '' ? 'edit' : 'add'); ?>"> |
|---|
| 92 |
<table> |
|---|
| 93 |
<tr><td colspan="2"><h5><?php echo ($custom_dest ? _("Edit Custom Destination") : _("Add Custom Destination")) ?><hr></h5></td></tr> |
|---|
| 94 |
<tr> |
|---|
| 95 |
<td><a href="#" class="info"><?php echo _("Custom Destination")?>: |
|---|
| 96 |
<span> |
|---|
| 97 |
<?php |
|---|
| 98 |
echo _("This is the Custom Destination to be published. It should be formatted exactly as you would put it in a goto statement, with context, exten, priority all included. An example might look like:<br />mycustom-app,s,1"); |
|---|
| 99 |
if (!empty($usage_list)) { |
|---|
| 100 |
echo "<br />"._("READONLY WARNING: Because this destination is being used by other module objects it can not be edited. You must remove those dependencies in order to edit this destination, or create a new destination to use"); |
|---|
| 101 |
} |
|---|
| 102 |
?> |
|---|
| 103 |
</span></a></td> |
|---|
| 104 |
<?php |
|---|
| 105 |
if (!empty($usage_list)) { |
|---|
| 106 |
?> |
|---|
| 107 |
<td><b><?php echo $custom_dest; ?></b></td> |
|---|
| 108 |
<?php |
|---|
| 109 |
} else { |
|---|
| 110 |
?> |
|---|
| 111 |
<td><input size="30" type="text" name="extdisplay" id="extdisplay" value="<?php echo $custom_dest; ?>" tabindex="<?php echo ++$tabindex;?>"></td> |
|---|
| 112 |
<?php |
|---|
| 113 |
} |
|---|
| 114 |
?> |
|---|
| 115 |
</tr> |
|---|
| 116 |
|
|---|
| 117 |
<?php |
|---|
| 118 |
if (empty($usage_list)) { |
|---|
| 119 |
?> |
|---|
| 120 |
<tr> |
|---|
| 121 |
<td> |
|---|
| 122 |
<a href=# class="info"><?php echo _("Destination Quick Pick")?> |
|---|
| 123 |
<span> |
|---|
| 124 |
<?php echo _("Choose un-identified destinations on your system to add to the Custom Destination Registry. This will insert the chosen entry into the Custom Destination box above.")?> |
|---|
| 125 |
</span> |
|---|
| 126 |
</a> |
|---|
| 127 |
</td> |
|---|
| 128 |
<td> |
|---|
| 129 |
<select onChange="insertDest();" id="insdest" tabindex="<?php echo ++$tabindex;?>"> |
|---|
| 130 |
<option value=""><?php echo _("(pick destination)")?></option> |
|---|
| 131 |
<?php |
|---|
| 132 |
$results = customappsreg_customdests_getunknown(); |
|---|
| 133 |
foreach ($results as $thisdest) { |
|---|
| 134 |
echo "<option value='$thisdest'>$thisdest</option>\n"; |
|---|
| 135 |
} |
|---|
| 136 |
?> |
|---|
| 137 |
</select> |
|---|
| 138 |
</td> |
|---|
| 139 |
</tr> |
|---|
| 140 |
<?php |
|---|
| 141 |
} |
|---|
| 142 |
?> |
|---|
| 143 |
|
|---|
| 144 |
<tr> |
|---|
| 145 |
<td><a href="#" class="info"><?php echo _("Description")?>:<span><?php echo _("Brief Description that will be published to modules when showing destinations. Example: My Weather App")?></span></a></td> |
|---|
| 146 |
<td><input size="30" type="text" name="description" value="<?php echo $description; ?>" tabindex="<?php echo ++$tabindex;?>"></td> |
|---|
| 147 |
</tr> |
|---|
| 148 |
<tr> |
|---|
| 149 |
<td valign="top"><a href="#" class="info"><?php echo _("Notes")?>:<span><?php echo _("More detailed notes about this destination to help document it. This field is not used elsewhere.")?></span></a></td> |
|---|
| 150 |
<td><textarea name="notes" cols="23" rows="6" tabindex="<?php echo ++$tabindex;?>"><?php echo $notes; ?></textarea></td> |
|---|
| 151 |
</tr> |
|---|
| 152 |
|
|---|
| 153 |
<tr> |
|---|
| 154 |
<td colspan="2"><br><input name="Submit" type="submit" value="<?php echo _("Submit Changes")?>" tabindex="<?php echo ++$tabindex;?>"> |
|---|
| 155 |
<?php if ($custom_dest != '') { echo ' <input name="delete" type="submit" value="'._("Delete").'">'; } ?> |
|---|
| 156 |
</td> |
|---|
| 157 |
|
|---|
| 158 |
<?php |
|---|
| 159 |
if ($custom_dest != '') { |
|---|
| 160 |
if (!empty($usage_list)) { |
|---|
| 161 |
?> |
|---|
| 162 |
<tr><td colspan="2"> |
|---|
| 163 |
<a href="#" class="info"><?php echo $usage_list['text']?>:<span><?php echo $usage_list['tooltip']?></span></a> |
|---|
| 164 |
</td></tr> |
|---|
| 165 |
<?php |
|---|
| 166 |
} |
|---|
| 167 |
} |
|---|
| 168 |
?> |
|---|
| 169 |
</tr> |
|---|
| 170 |
</table> |
|---|
| 171 |
</form> |
|---|
| 172 |
|
|---|
| 173 |
<script language="javascript"> |
|---|
| 174 |
<!-- |
|---|
| 175 |
|
|---|
| 176 |
function insertDest() { |
|---|
| 177 |
|
|---|
| 178 |
dest = document.getElementById('insdest').value; |
|---|
| 179 |
customDest=document.getElementById('extdisplay'); |
|---|
| 180 |
|
|---|
| 181 |
if (dest != '') { |
|---|
| 182 |
customDest.value = dest; |
|---|
| 183 |
} |
|---|
| 184 |
|
|---|
| 185 |
// reset element |
|---|
| 186 |
document.getElementById('insdest').value = ''; |
|---|
| 187 |
} |
|---|
| 188 |
|
|---|
| 189 |
function checkCustomDest(theForm) { |
|---|
| 190 |
|
|---|
| 191 |
var msgInvalidCustomDest = "<?php echo _('Invalid Destination, must not be blank, must be formatted as: context,exten,pri'); ?>"; |
|---|
| 192 |
var msgInvalidDescription = "<?php echo _('Invalid description specified, must not be blank'); ?>"; |
|---|
| 193 |
|
|---|
| 194 |
// Make sure the custom dest is in the form "context,exten,pri" |
|---|
| 195 |
var re = /[^,]+,[^,]+,[^,]+/; |
|---|
| 196 |
|
|---|
| 197 |
// form validation |
|---|
| 198 |
defaultEmptyOK = false; |
|---|
| 199 |
|
|---|
| 200 |
if (isEmpty(theForm.extdisplay.value) || !re.test(theForm.extdisplay.value)) { |
|---|
| 201 |
return warnInvalid(theForm.extdisplay, msgInvalidCustomDest); |
|---|
| 202 |
} |
|---|
| 203 |
if (isEmpty(theForm.description.value)) { |
|---|
| 204 |
return warnInvalid(theForm.description, msgInvalidDescription); |
|---|
| 205 |
} |
|---|
| 206 |
|
|---|
| 207 |
return true; |
|---|
| 208 |
} |
|---|
| 209 |
//--> |
|---|
| 210 |
</script> |
|---|
| 211 |
|
|---|