| 1 |
<?php |
|---|
| 2 |
/** chan_sccp helper Module for FreePBX 2.5 |
|---|
| 3 |
* Copyright 2008 Niklas Larsson, Infracom AB |
|---|
| 4 |
* This program is free software; you can redistribute it and/or |
|---|
| 5 |
* modify it under the terms of the GNU General Public License |
|---|
| 6 |
* as published by the Free Software Foundation; either version 2 |
|---|
| 7 |
* of the License, or (at your option) any later version. |
|---|
| 8 |
* |
|---|
| 9 |
* This program 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 |
|
|---|
| 15 |
$type = isset($_REQUEST['type']) ? $_REQUEST['type'] : 'setup'; |
|---|
| 16 |
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : ''; |
|---|
| 17 |
if (isset($_REQUEST['delete'])) $action = 'delete'; |
|---|
| 18 |
|
|---|
| 19 |
$chan_sccp_id = isset($_REQUEST['chan_sccp_id']) ? $_REQUEST['chan_sccp_id'] : false; |
|---|
| 20 |
$mac = isset($_REQUEST['mac']) ? $_REQUEST['mac'] : ''; |
|---|
| 21 |
$phone_type = isset($_REQUEST['phone_type']) ? $_REQUEST['phone_type'] : ''; |
|---|
| 22 |
$ext = isset($_REQUEST['ext']) ? $_REQUEST['ext'] : ''; |
|---|
| 23 |
$speeds = isset($_REQUEST['speeds']) ? $_REQUEST['speeds'] : ''; |
|---|
| 24 |
|
|---|
| 25 |
if (isset($_REQUEST['goto0']) && $_REQUEST['goto0']) { |
|---|
| 26 |
$dest = $_REQUEST[ $_REQUEST['goto0'].'0' ]; |
|---|
| 27 |
} |
|---|
| 28 |
|
|---|
| 29 |
switch ($action) { |
|---|
| 30 |
case 'add': |
|---|
| 31 |
chan_sccp_add($mac, $phone_type, $ext, $speeds); |
|---|
| 32 |
needreload(); |
|---|
| 33 |
redirect_standard(); |
|---|
| 34 |
break; |
|---|
| 35 |
case 'edit': |
|---|
| 36 |
chan_sccp_edit($chan_sccp_id, $mac, $phone_type, $ext, $speeds); |
|---|
| 37 |
needreload(); |
|---|
| 38 |
redirect_standard('extdisplay'); |
|---|
| 39 |
break; |
|---|
| 40 |
case 'delete': |
|---|
| 41 |
chan_sccp_delete($chan_sccp_id); |
|---|
| 42 |
needreload(); |
|---|
| 43 |
redirect_standard(); |
|---|
| 44 |
break; |
|---|
| 45 |
} |
|---|
| 46 |
|
|---|
| 47 |
?> |
|---|
| 48 |
</div> |
|---|
| 49 |
|
|---|
| 50 |
<div class="rnav"><ul> |
|---|
| 51 |
<?php |
|---|
| 52 |
|
|---|
| 53 |
echo '<li><a href="config.php?display=chan_sccp&type='.$type.'">'._('Add Phone').'</a></li>'; |
|---|
| 54 |
|
|---|
| 55 |
foreach (chan_sccp_list() as $row) { |
|---|
| 56 |
echo '<li><a href="config.php?display=chan_sccp&type='.$type.'&extdisplay='.$row['id'].'" class="">'.$row['mac'] . ' (' .$row['type'] . ') - ' .$row['ext'].'</a></li>'; |
|---|
| 57 |
} |
|---|
| 58 |
|
|---|
| 59 |
?> |
|---|
| 60 |
</ul></div> |
|---|
| 61 |
|
|---|
| 62 |
<div class="content"> |
|---|
| 63 |
|
|---|
| 64 |
<?php |
|---|
| 65 |
|
|---|
| 66 |
if ($extdisplay) { |
|---|
| 67 |
// load |
|---|
| 68 |
$row = chan_sccp_get($extdisplay); |
|---|
| 69 |
|
|---|
| 70 |
$mac = $row['mac']; |
|---|
| 71 |
$ext = $row['ext']; |
|---|
| 72 |
$phone_type = $row['type']; |
|---|
| 73 |
$speeds = $row['speeds']; |
|---|
| 74 |
|
|---|
| 75 |
echo "<h2>"._("Edit: ")."$mac ($phone_type)"."</h2>"; |
|---|
| 76 |
} else { |
|---|
| 77 |
echo "<h2>"._("Add Phone")."</h2>"; |
|---|
| 78 |
} |
|---|
| 79 |
|
|---|
| 80 |
$helptext = _("Connecting a phone (mac) to a FreePBX extension. When you klick on Apply conf... the xml files are created and saved in /tftpboot (make chmod 777 /tftpboot) and the chan_sccp realtime mysql is updated"); |
|---|
| 81 |
echo $helptext; |
|---|
| 82 |
?> |
|---|
| 83 |
|
|---|
| 84 |
<form name="edit_chan_sccp" action="<?php $_SERVER['PHP_SELF'] ?>" method="post" onsubmit="return check_chan_sccp(edit_chan_sccp);"> |
|---|
| 85 |
<input type="hidden" name="extdisplay" value="<?php echo $extdisplay; ?>"> |
|---|
| 86 |
<input type="hidden" name="chan_sccp_id" value="<?php echo $extdisplay; ?>"> |
|---|
| 87 |
<input type="hidden" name="action" value="<?php echo ($extdisplay ? 'edit' : 'add'); ?>"> |
|---|
| 88 |
<table> |
|---|
| 89 |
<tr><td colspan="2"><h5><?php echo ($extdisplay ? _("Edit Phone") : _("Add Phone")) ?><hr></h5></td></tr> |
|---|
| 90 |
<tr> |
|---|
| 91 |
<td><a href="#" class="info"><?php echo _("MAC")?>:<span><?php echo _("The MAC address of the phone")?></span></a></td> |
|---|
| 92 |
<td><input size="10" type="text" name="mac" value="<?php echo $mac; ?>"></td> |
|---|
| 93 |
</tr> |
|---|
| 94 |
<tr> |
|---|
| 95 |
<td><a href="#" class="info"><?php echo _("Type")?>:<span><?php echo _("The type of phone: 7905, 7940, 7960...")?></span></a></td> |
|---|
| 96 |
<td><input size="6" type="text" name="phone_type" value="<?php echo $phone_type; ?>"></td> |
|---|
| 97 |
</tr> |
|---|
| 98 |
<tr> |
|---|
| 99 |
<td><a href="#" class="info"><?php echo _("FreePBX extension")?>:<span><?php echo _("Extension")?></span></a></td> |
|---|
| 100 |
<td><input size="6" type="text" name="ext" value="<?php echo $ext; ?>" /></td> </tr> |
|---|
| 101 |
<tr> |
|---|
| 102 |
<tr> |
|---|
| 103 |
<td><a href="#" class="info"><?php echo _("Speedials")?>:<span><?php echo _("Enter the extensions numbers or external numbers, seperated by ; To add Your own text use: number,text;")?></span></a></td> |
|---|
| 104 |
<td><input size="60" type="text" name="speeds" value="<?php echo $speeds; ?>" /></td> </tr> |
|---|
| 105 |
<tr> |
|---|
| 106 |
<td colspan="2"><br><input name="Submit" type="submit" value="<?php echo _("Submit Changes")?>"> |
|---|
| 107 |
<?php if ($extdisplay) { echo ' <input name="delete" type="submit" value="'._("Delete").'">'; } ?> |
|---|
| 108 |
</td> |
|---|
| 109 |
</tr> |
|---|
| 110 |
|
|---|
| 111 |
</table> |
|---|
| 112 |
</form> |
|---|
| 113 |
|
|---|
| 114 |
<script language="javascript"> |
|---|
| 115 |
|
|---|
| 116 |
function check_chan_sccp(theForm) { |
|---|
| 117 |
var msgInvalidDescription = "<?php echo _('Invalid description specified'); ?>"; |
|---|
| 118 |
|
|---|
| 119 |
// set up the Destination stuff |
|---|
| 120 |
setDestinations(theForm, '_post_dest'); |
|---|
| 121 |
|
|---|
| 122 |
// form validation |
|---|
| 123 |
defaultEmptyOK = false; |
|---|
| 124 |
if (isEmpty(theForm.description.value)) |
|---|
| 125 |
return warnInvalid(theForm.description, msgInvalidDescription); |
|---|
| 126 |
|
|---|
| 127 |
if (!validateDestinations(theForm, 1, true)) |
|---|
| 128 |
return false; |
|---|
| 129 |
|
|---|
| 130 |
return true; |
|---|
| 131 |
} |
|---|
| 132 |
|
|---|
| 133 |
</script> |
|---|