Changeset 10797
- Timestamp:
- 01/06/11 04:42:13 (2 years ago)
- Files:
-
- modules/branches/2.9/endpointman/functions.inc.php (modified) (6 diffs)
- modules/branches/2.9/endpointman/includes/advanced.inc (modified) (4 diffs)
- modules/branches/2.9/endpointman/includes/ajax_select.php (modified) (5 diffs)
- modules/branches/2.9/endpointman/includes/devices_manager.inc (modified) (2 diffs)
- modules/branches/2.9/endpointman/includes/functions.inc (modified) (21 diffs)
- modules/branches/2.9/endpointman/includes/template_manager.inc (modified) (1 diff)
- modules/branches/2.9/endpointman/install.php (modified) (7 diffs)
- modules/branches/2.9/endpointman/module.xml (modified) (2 diffs)
- modules/branches/2.9/endpointman/templates/compiled (deleted)
- modules/branches/2.9/endpointman/templates/freepbx/advanced_settings_settings.html (modified) (1 diff)
- modules/branches/2.9/endpointman/templates/freepbx/devices_manager.html (modified) (2 diffs)
- modules/branches/2.9/endpointman/templates/freepbx/global_header.html (modified) (1 diff)
- modules/branches/2.9/endpointman/templates/freepbx/template_editor.html (modified) (3 diffs)
- modules/branches/2.9/endpointman/templates/javascript (deleted)
- modules/branches/2.9/endpointman/templates/stylesheets (deleted)
- modules/branches/2.9/endpointman/uninstall.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
modules/branches/2.9/endpointman/functions.inc.php
r10792 r10797 37 37 38 38 $display = isset($_REQUEST['display'])?$_REQUEST['display']:null; 39 if($display == "extensions") { 39 $extdisplay = isset($_REQUEST['extdisplay'])?$_REQUEST['extdisplay']:null; 40 $action = isset($_REQUEST['action'])?$_REQUEST['action']:null; 41 $delete = isset($_REQUEST['epm_delete'])?$_REQUEST['epm_delete']:null; 42 43 if(($display == "extensions") && isset($extdisplay)) { 40 44 global $endpoint; 41 45 … … 46 50 ini_set('display_errors', 0); 47 51 52 if($action == "edit") { 53 54 if(isset($delete)) { 55 $sql = "SELECT mac_id,line FROM endpointman_line_list WHERE ext = ". $extdisplay; 56 $macid = $endpoint->db->getRow($sql,array(),DB_FETCHMODE_ASSOC); 57 58 if($macid) { 59 $sql = "SELECT * FROM endpointman_line_list WHERE mac_id = ".$macid['mac_id']; 60 $list = $endpoint->db->getAll($sql,array(),DB_FETCHMODE_ASSOC); 61 62 $count = count($list); 63 64 if($count == 1) { 65 $sql = "DELETE FROM endpointman_mac_list WHERE id = ".$macid['mac_id']; 66 $endpoint->db->query($sql); 67 } 68 69 $sql = "DELETE FROM endpointman_line_list WHERE mac_id = ".$macid['mac_id']." AND line = ".$macid['line']; 70 $endpoint->db->query($sql); 71 } 72 } 73 74 $mac = isset($_REQUEST['epm_mac'])?$_REQUEST['epm_mac']:null; 75 76 if(!empty($mac)) { 77 //Mac is set 78 $brand = isset($_REQUEST['epm_brand'])?$_REQUEST['epm_brand']:null; 79 $model = isset($_REQUEST['epm_model'])?$_REQUEST['epm_model']:null; 80 $line = isset($_REQUEST['epm_line'])?$_REQUEST['epm_line']:null; 81 $temp = isset($_REQUEST['epm_temps'])?$_REQUEST['epm_temps']:null; 82 $extdisplay = isset($_REQUEST['extdisplay'])?$_REQUEST['extdisplay']:null; 83 $name = isset($_REQUEST['name'])?$_REQUEST['name']:null; 84 $reboot = isset($_REQUEST['epm_reboot'])?$_REQUEST['epm_reboot']:null; 85 86 if($endpoint->mac_check_clean($mac)) { 87 $sql = "SELECT id FROM endpointman_mac_list WHERE mac = '".$endpoint->mac_check_clean($mac)."'"; 88 $macid = $endpoint->db->getOne($sql); 89 if($macid) { 90 //In Database already 91 $sql = 'SELECT * FROM endpointman_line_list WHERE ext = '.$extdisplay.' AND mac_id = '. $macid; 92 $lines_list =& $endpoint->db->getRow($sql,array(),DB_FETCHMODE_ASSOC); 93 if(($lines_list) AND (isset($model)) AND (isset($line)) AND (!isset($delete)) AND (isset($temp))) { 94 //Modifying line already in the database 95 $sql = "UPDATE endpointman_line_list SET line = ".$lines_list['line'].", description = '".$name."' WHERE luid =" . $lines_list['luid']; 96 $endpoint->db->query($sql); 97 98 $sql = "UPDATE endpointman_mac_list SET model = ".$model.", template_id = ".$temp." WHERE id = ".$macid; 99 $endpoint->db->query($sql); 100 101 $row = $endpoint->get_phone_info($macid); 102 if(isset($reboot)) { 103 $endpoint->prepare_configs($row); 104 } else { 105 $endpoint->prepare_configs($row,FALSE); 106 } 107 } elseif((isset($model)) AND (!isset($delete)) AND (isset($line)) AND (isset($temp))) { 108 //Add line to the database 109 $sql = "INSERT INTO endpointman_line_list (mac_id, line, ext, description) VALUES (".$macid.", ".$line.", ".$extdisplay.", '".$name."')"; 110 $endpoint->db->query($sql); 111 112 $sql = "UPDATE endpointman_mac_list SET model = ".$model.", template_id = ".$temp." WHERE id = ".$macid; 113 $endpoint->db->query($sql); 114 } 115 } elseif(!isset($delete)) { 116 //Add Extension/Phone to database 117 $mac = $endpoint->mac_check_clean($mac); 118 $sql = "INSERT INTO `endpointman_mac_list` (`mac`, `model`, `template_id`) VALUES ('".$mac."', '".$model."', '".$temp."')"; 119 $endpoint->db->query($sql); 120 121 $sql = 'SELECT last_insert_id()'; 122 $ext_id =& $endpoint->db->getOne($sql); 123 124 if(!isset($line)) { 125 $line = 1; 126 } 127 128 $sql = "INSERT INTO `endpointman_line_list` (`mac_id`, `ext`, `line`, `description`) VALUES ('".$ext_id."', '".$extdisplay."', '".$line."', '".$name."')"; 129 $endpoint->db->query($sql); 130 } 131 } 132 } else { 133 //Mac not set so delete 134 $sql = "SELECT mac_id,line FROM endpointman_line_list WHERE ext = ". $extdisplay; 135 $macid = $endpoint->db->getRow($sql,array(),DB_FETCHMODE_ASSOC); 136 137 if($macid) { 138 $sql = "SELECT * FROM endpointman_line_list WHERE mac_id = ".$macid['mac_id']; 139 $list = $endpoint->db->getAll($sql,array(),DB_FETCHMODE_ASSOC); 140 $count = count($list); 141 142 if($count == 1) { 143 $sql = "DELETE FROM endpointman_mac_list WHERE id = ".$macid['mac_id']; 144 $endpoint->db->query($sql); 145 } 146 147 $sql = "DELETE FROM endpointman_line_list WHERE mac_id = ".$macid['mac_id']." AND line = ".$macid['line']; 148 $endpoint->db->query($sql); 149 } 150 } 151 } 48 152 endpointman_applyhooks(); 49 153 } … … 66 170 // Don't display this stuff it it's on a 'This xtn has been deleted' page. 67 171 if ($action != 'del') { 68 $sql = "SELECT mac_id,luid,line FROM endpointman_line_list WHERE ext = '".$extdisplay."' "; 69 $line_info =& $db->getRow($sql, array(), DB_FETCHMODE_ASSOC); 70 if($line_info) { 71 $info = $endpoint->get_phone_info($line_info['mac_id']); 72 73 74 $js = " 172 173 $js = " 75 174 $.ajaxSetup({ cache: false }); 76 175 … … 88 187 }) 89 188 "; 90 $currentcomponent->addjsfunc('brand_change(value)', $js); 189 $currentcomponent->addjsfunc('brand_change(value)', $js); 190 191 $section = _('End Point Manager'); 192 193 $sql = "SELECT mac_id,luid,line FROM endpointman_line_list WHERE ext = '".$extdisplay."' "; 194 $line_info =& $db->getRow($sql, array(), DB_FETCHMODE_ASSOC); 195 if($line_info) { 91 196 92 197 $js = " … … 112 217 $currentcomponent->addjsfunc('model_change(value,macid)', $js); 113 218 114 $section = _('End Point Manager'); 115 219 $info = $endpoint->get_phone_info($line_info['mac_id']); 116 220 117 221 $brand_list = $endpoint->brands_available($info['brand_id'], true); … … 126 230 } 127 231 128 $currentcomponent->addguielem($section, new gui_textbox('epm_mac', $info['mac'], 'MAC Address', 'The MAC Address of the Phone Assigned to this Extension/Device.', 'isEmpty()', 'Please enter a valid MAC Address', true, 12, true),9); 232 $checked = false; 233 234 $currentcomponent->addguielem($section, new gui_checkbox('epm_delete', $checked, 'Delete','Delete this Extension from Endpoint Manager'),9); 235 $currentcomponent->addguielem($section, new gui_textbox('epm_mac', $info['mac'], 'MAC Address', 'The MAC Address of the Phone Assigned to this Extension/Device. <br />(Leave Blank to Remove from Endpoint Manager)', '', 'Please enter a valid MAC Address', true, 17, false),9); 129 236 $currentcomponent->addguielem($section, new gui_selectbox('epm_brand', $brand_list, $info['brand_id'], 'Brand', 'The Brand of this Phone.', false, 'frm_extensions_brand_change(this.options[this.selectedIndex].value)', false),9); 130 237 $currentcomponent->addguielem($section, new gui_selectbox('epm_model', $model_list, $info['model_id'], 'Model', 'The Model of this Phone.', false, 'frm_extensions_model_change(this.options[this.selectedIndex].value,\''.$line_info['luid'].'\')', false),9); 131 238 $currentcomponent->addguielem($section, new gui_selectbox('epm_line', $line_list, $line_info['line'], 'Line', 'The Line of this Extension/Device.', false, '', false),9); 132 239 $currentcomponent->addguielem($section, new gui_selectbox('epm_temps', $template_list, $info['template_id'], 'Template', 'The Template of this Phone.', false, '', false),9); 240 $currentcomponent->addguielem($section, new gui_checkbox('epm_reboot', $checked, 'Reboot','Reboot this Phone on Submit'),9); 241 242 } else { 243 244 $js = " 245 $.ajaxSetup({ cache: false }); 246 $.getJSON('config.php?type=tool&quietmode=1&handler=file&module=endpointman&file=ajax_select.html.php&atype=template2',{id: value}, function(j){ 247 var options = ''; 248 for (var i = 0; i < j.length; i++) { 249 options += '<option value=\"' + j[i].optionValue + '\">' + j[i].optionDisplay + '</option>'; 250 } 251 $('#epm_temps').html(options); 252 $('#epm_temps option:first').attr('selected', 'selected'); 253 }), 254 $.ajaxSetup({ cache: false }); 255 $.getJSON('config.php?type=tool&quietmode=1&handler=file&module=endpointman&file=ajax_select.html.php&mac='+ mac +'&atype=lines',{id: value}, function(j){ 256 var options = ''; 257 for (var i = 0; i < j.length; i++) { 258 options += '<option value=\"' + j[i].optionValue + '\">' + j[i].optionDisplay + '</option>'; 259 } 260 $('#epm_line').html(options); 261 $('#epm_line option:first').attr('selected', 'selected'); 262 }) 263 "; 264 $currentcomponent->addjsfunc('model_change(value,mac)', $js); 265 266 $brand_list = $endpoint->brands_available(NULL, true); 267 $model_list = array(); 268 $line_list = array(); 269 $template_list = array(); 270 271 $currentcomponent->addguielem($section, new gui_textbox('epm_mac', $info['mac'], 'MAC Address', 'The MAC Address of the Phone Assigned to this Extension/Device. <br />(Leave Blank to Remove from Endpoint Manager)', '', 'Please enter a valid MAC Address', true, 17, false),9); 272 $currentcomponent->addguielem($section, new gui_selectbox('epm_brand', $brand_list, $info['brand_id'], 'Brand', 'The Brand of this Phone.', false, 'frm_extensions_brand_change(this.options[this.selectedIndex].value)', false),9); 273 $currentcomponent->addguielem($section, new gui_selectbox('epm_model', $model_list, $info['model_id'], 'Model', 'The Model of this Phone.', false, 'frm_extensions_model_change(this.options[this.selectedIndex].value,document.getElementById(\'epm_mac\').value)', false),9); 274 $currentcomponent->addguielem($section, new gui_selectbox('epm_line', $line_list, $line_info['line'], 'Line', 'The Line of this Extension/Device.', false, '', false),9); 275 $currentcomponent->addguielem($section, new gui_selectbox('epm_temps', $template_list, $info['template_id'], 'Template', 'The Template of this Phone.', false, '', false),9); 133 276 } 134 277 } modules/branches/2.9/endpointman/includes/advanced.inc
r10792 r10797 567 567 $_POST['enable_debug'] = 0; 568 568 } 569 if((isset($_POST['enable_updates'])) AND ($_POST['enable_updates'] == "on")) { 570 $_POST['enable_updates'] = 1; 571 $sql = "INSERT INTO cronmanager (module, id, time, freq, lasttime, command) VALUES ('endpointman', 'UPDATES', '23', '24', '0', 'php ".$amp_conf['AMPWEBROOT']."/admin/modules/endpointman/includes/update_check.php')"; 572 $endpoint->db->query($sql); 573 } else { 574 $_POST['enable_updates'] = 0; 575 $sql = "DELETE FROM `cronmanager` WHERE CONVERT(`cronmanager`.`module` USING utf8) = 'endpointman' AND CONVERT(`cronmanager`.`id` USING utf8) = 'UPDATES' LIMIT 1"; 576 $endpoint->db->query($sql); 569 if((isset($_POST['disable_help'])) AND ($_POST['disable_help'] == "on")) { 570 $_POST['disable_help'] = 1; 571 } else { 572 $_POST['disable_help'] = 0; 577 573 } 578 574 … … 594 590 $endpoint->db->query($sql); 595 591 596 $sql="UPDATE endpointman_global_vars SET value='" . $_POST['enable_updates'] . "' WHERE var_name='check_updates'";597 $endpoint->db->query($sql);598 599 592 $sql="UPDATE endpointman_global_vars SET value='" . $_POST['nmap_loc'] . "' WHERE var_name='nmap_location'"; 600 593 $endpoint->db->query($sql); 601 594 602 595 $sql="UPDATE endpointman_global_vars SET value='" . $_POST['arp_loc'] . "' WHERE var_name='arp_location'"; 596 $endpoint->db->query($sql); 597 598 $sql="UPDATE endpointman_global_vars SET value='" . $_POST['disable_help'] . "' WHERE var_name='disable_help'"; 603 599 $endpoint->db->query($sql); 604 600 … … 614 610 $ari_selected = ""; 615 611 } 616 617 if($endpoint->global_cfg['disable_h taccess']) {618 $h taccess_selected = "checked";612 613 if($endpoint->global_cfg['disable_help']) { 614 $help_selected = "checked"; 619 615 } else { 620 $htaccess_selected = ""; 621 } 622 623 if($endpoint->global_cfg['check_updates']) { 624 $updates_selected = "checked"; 625 } else { 626 $updates_selected = ""; 627 } 616 $help_selected = ""; 617 } 618 628 619 if($endpoint->global_cfg['debug']) { 629 620 $debug_selected = "checked"; … … 634 625 $debug_selected = ""; 635 626 } 636 $endpoint->tpl->assign("htaccess_selected", $htaccess_selected); 627 $endpoint->tpl->assign("help_selected", $help_selected); 628 637 629 $endpoint->tpl->assign("ari_selected", $ari_selected); 638 $endpoint->tpl->assign("updates_selected", $updates_selected);639 630 $endpoint->tpl->assign("debug_selected", $debug_selected); 640 631 modules/branches/2.9/endpointman/includes/ajax_select.php
r10792 r10797 7 7 * @package Provisioner 8 8 */ 9 10 require 'functions.inc'; 11 $endpoint = new endpointmanager(); 12 9 13 include 'jsonwrapper.php'; 10 //ini_set('display_errors', 1);11 14 function in_array_recursive($needle, $haystack) { 12 15 … … 19 22 } 20 23 return FALSE; 21 }22 23 function linesAvailable($lineid=NULL,$macid=NULL) {24 global $db;25 if(isset($lineid)) {26 $sql="SELECT max_lines FROM endpointman_model_list WHERE id = (SELECT endpointman_mac_list.model FROM endpointman_mac_list, endpointman_line_list WHERE endpointman_line_list.luid = ".$lineid." AND endpointman_line_list.mac_id = endpointman_mac_list.id)";27 28 $sql_l = "SELECT line, mac_id FROM `endpointman_line_list` WHERE luid = ".$lineid;29 $line =& $db->getRow($sql_l, array(), DB_FETCHMODE_ASSOC);30 31 $sql_lu = "SELECT line FROM endpointman_line_list WHERE mac_id = ".$line['mac_id'];32 } elseif(isset($macid)) {33 $sql="SELECT max_lines FROM endpointman_model_list WHERE id = (SELECT model FROM endpointman_mac_list WHERE id =".$macid.")";34 $sql_lu = "SELECT line FROM endpointman_line_list WHERE mac_id = ".$macid;35 36 $line['line'] = 0;37 }38 $max_lines = $db->getOne($sql);39 $lines_used =& $db->getAll($sql_lu);40 41 for($i = 1; $i <= $max_lines; $i++) {42 if($i == $line['line']) {43 $temp[$i]['value'] = $i;44 $temp[$i]['text'] = $i;45 $temp[$i]['selected'] = "selected";46 } else {47 if(!in_array_recursive($i,$lines_used)) {48 $temp[$i]['value'] = $i;49 $temp[$i]['text'] = $i;50 }51 }52 }53 if(isset($temp)) {54 return($temp);55 } else {56 return FALSE;57 }58 24 } 59 25 … … 73 39 } elseif ($_REQUEST['atype'] == "model_clone") { 74 40 $sql = "SELECT endpointman_model_list.id, endpointman_model_list.model as model FROM endpointman_model_list, endpointman_product_list WHERE endpointman_product_list.id = endpointman_model_list.product_id AND endpointman_model_list.enabled = 1 AND endpointman_model_list.hidden = 0 AND product_id = '". $_GET['id']."'"; 75 } elseif ($_REQUEST['atype'] == "lines") { 76 if(isset($_REQUEST['macid'])) { 77 //die(); 78 $sql = "SELECT endpointman_model_list.max_lines FROM endpointman_model_list,endpointman_line_list,endpointman_mac_list WHERE endpointman_mac_list.id = endpointman_line_list.mac_id AND endpointman_model_list.id = endpointman_mac_list.model AND endpointman_line_list.luid = ". $_REQUEST['macid']; 41 } elseif ($_REQUEST['atype'] == "lines") { 42 if(isset($_REQUEST['macid'])) { 43 $sql = "SELECT endpointman_model_list.max_lines FROM endpointman_model_list,endpointman_line_list,endpointman_mac_list WHERE endpointman_mac_list.id = endpointman_line_list.mac_id AND endpointman_model_list.id = endpointman_mac_list.model AND endpointman_line_list.luid = ". $_REQUEST['macid']; 44 } elseif(isset($_REQUEST['mac'])) { 45 $sql = "SELECT id FROM endpointman_mac_list WHERE mac = '".$endpoint->mac_check_clean($_REQUEST['mac'])."'"; 46 $macid = $endpoint->db->getOne($sql); 47 if($macid) { 48 $_REQUEST['mac'] = $macid; 49 $sql = "SELECT endpointman_model_list.max_lines FROM endpointman_model_list,endpointman_line_list,endpointman_mac_list WHERE endpointman_mac_list.id = endpointman_line_list.mac_id AND endpointman_model_list.id = endpointman_mac_list.model AND endpointman_mac_list.id = ". $macid; 79 50 } else { 51 unset($_REQUEST['mac']); 80 52 $sql = "SELECT max_lines FROM endpointman_model_list WHERE id = '". $_GET['id']."'"; 81 53 } 54 } else { 55 $sql = "SELECT max_lines FROM endpointman_model_list WHERE id = '". $_GET['id']."'"; 56 } 82 57 } 83 58 … … 94 69 } 95 70 96 if(($_REQUEST['atype'] == "lines") && (!isset($_REQUEST['mac id']))) {97 $count = $ db->getOne($sql);71 if(($_REQUEST['atype'] == "lines") && (!isset($_REQUEST['mac'])) && (!isset($_REQUEST['macid']))) { 72 $count = $endpoint->db->getOne($sql); 98 73 for($z=0;$z<$count;$z++) { 99 74 $result[$z]['id'] = $z + 1; … … 101 76 } 102 77 } elseif(isset($_REQUEST['macid'])) { 103 $result = linesAvailable($_REQUEST['macid']); 78 $result = $endpoint->linesAvailable($_REQUEST['macid']); 79 } elseif(isset($_REQUEST['mac'])) { 80 $result = $endpoint->linesAvailable(NULL,$_REQUEST['mac']); 104 81 } else { 105 $result = $ db->getAll($sql,array(), DB_FETCHMODE_ASSOC);82 $result = $endpoint->db->getAll($sql,array(), DB_FETCHMODE_ASSOC); 106 83 } 107 84 108 85 foreach($result as $row) { 109 if( isset($_REQUEST['macid'])) {86 if((isset($_REQUEST['macid'])) OR (isset($_REQUEST['mac']))) { 110 87 $out[$i]['optionValue'] = $row['value']; 111 88 $out[$i]['optionDisplay'] = $row['text']; modules/branches/2.9/endpointman/includes/devices_manager.inc
r10792 r10797 144 144 $row =& $endpoint->db->getRow($sql,array(),DB_FETCHMODE_ASSOC); 145 145 146 $cfg_data = unserialize($row['template_data']); 147 148 $count = count($cfg_data); 149 $i = 0; 150 while($i < $count) { 151 if(array_key_exists('variable',$cfg_data[$i])) { 152 $temping = str_replace('$','',$cfg_data[$i]['variable']); 153 if(is_array($cfg_data[$i]['default_value'])) { 154 $custom_cfg_data[$temping]['value'] = ''; 155 } else { 156 $custom_cfg_data[$temping]['value'] = $cfg_data[$i]['default_value']; 157 } 158 } 159 $i++; 160 } 161 if((isset($custom_cfg_data)) AND (is_array($custom_cfg_data))) { 162 $custom_cfg_data = serialize($custom_cfg_data); 163 } else { 164 $temp = array(); 165 $custom_cfg_data = serialize($temp); 166 } 167 168 $sql = "INSERT INTO `endpointman_mac_list` (`mac`, `model`, `global_custom_cfg_data`, `template_id`) VALUES ('".$mac."', '".$_REQUEST['model_list']."', '".$custom_cfg_data."', '".$_REQUEST['template_list']."')"; 146 $sql = "INSERT INTO `endpointman_mac_list` (`mac`, `model`, `template_id`) VALUES ('".$mac."', '".$_REQUEST['model_list']."', '".$_REQUEST['template_list']."')"; 169 147 $endpoint->db->query($sql); 170 148 … … 549 527 $endpoint->tpl->assign("models_ava", $ma); 550 528 } 551 $endpoint->tpl->assign("web_path", WEB_PATH);552 529 $endpoint->tpl->assign("product_list", $product_list); 553 530 $endpoint->tpl->assign("display_ext", $endpoint->display_registration_list()); modules/branches/2.9/endpointman/includes/functions.inc
r10792 r10797 33 33 date_default_timezone_set('America/Los_Angeles'); 34 34 35 //Move all information from the global $amp_conf into our public space. This will help prevent security concerns35 //Move all information from the global $amp_conf into our public space. This will help prevent security concerns 36 36 $this->amp_conf = $amp_conf; 37 37 … … 52 52 53 53 //Define error reporting 54 if( $this->global_cfg['debug']) {54 if(($this->global_cfg['debug']) AND (!isset($_REQUEST['quietmode']))) { 55 55 error_reporting(E_ALL); 56 56 ini_set('display_errors', 1); … … 78 78 $this->tpl = new RainTPL( LOCAL_PATH.'templates/freepbx', LOCAL_PATH.'templates/freepbx/compiled', '/admin/modules/endpointman/templates/images' ); 79 79 80 if($this->global_cfg['disable_help']) { 81 $this->tpl->assign("disable_help", 1); 82 } 83 84 $this->tpl->assign("web_path", WEB_PATH); 80 85 } 81 86 … … 119 124 $tpl->assign("fatal_error", $fatal_error); 120 125 $tpl->assign("error_message", $message); 121 }122 123 /**124 * A hacky way to add notifications into freepbx125 * @deprecated Supposed to remove126 * @param <type> $id127 * @param <type> $type128 * @param <type> $display_text129 * @param <type> $text130 * @param <type> $link131 */132 function add_freepbx_notification($id, $type, $display_text, $text, $link) {133 $sql = "INSERT INTO notifications (module, id, level, display_text, link, candelete, timestamp, extended_text) VALUES ('endpointman', '".$id."', '500', '".$display_text."', '".$link."', '1', '".time()."', '".$text."')";134 mysql_query($sql);135 126 } 136 127 … … 168 159 function get_brand_from_mac($mac){ 169 160 //Check for valid mac address first 170 if(! preg_match("/[0-9a-f][0-9a-f][:-][0-9a-f][0-9a-f][:-][0-9a-f][0-9a-f][:-][0-9a-f][0-9a-f][:-][0-9a-f][0-9a-f][:-][0-9a-f][0-9a-f]/i",$mac)) {161 if(!$this->mac_check_clean($mac)) { 171 162 return(FALSE); 172 163 } 173 164 174 165 //Get the OUI only 175 $oui = substr($ mac,0,6);166 $oui = substr($this->mac_check_clean($mac),0,6); 176 167 //Find the matching brand model to the oui 177 168 $oui_sql = "SELECT endpointman_brand_list.name, endpointman_brand_list.id FROM endpointman_oui_list, endpointman_brand_list WHERE oui LIKE '%". $oui ."%' AND endpointman_brand_list.id = endpointman_oui_list.brand AND endpointman_brand_list.installed = 1 LIMIT 1"; … … 193 184 } 194 185 195 /** 196 * Setup provisioner class from Provisioner.net 197 * 198 * Not used yet 199 * 200 * @param <type> $mac_id 201 */ 202 function setup_provisioner($mac_id=NULL) { 203 if(!class_exists('ProvisionerConfig')) { 204 require(PHONE_MODULES_PATH.'setup.php'); 205 } 206 $phone_info = $endpoint->get_phone_info($mac_id); 207 208 if(is_array($phone_info['template_data'])) { 209 $template_data = unserialize($phone_info['template_data']['custom_cfg_data']); 210 } else { 211 $template_data = unserialize($phone_info['custom_cfg_data']); 212 } 213 214 $new_template_data = array(); 215 if(is_array($template_data)) { 216 foreach($template_data as $key => $data) { 217 $new_template_data = array_merge($new_template_data, array($key => $data['value'])); 218 } 219 } 220 221 $class = "endpoint_" . $phone_info['directory'] . "_" . $phone_info['cfg_dir'] . '_phone'; 222 223 $provisioner_lib = new $class(); 224 225 $provisioner_lib->root_dir = PHONE_MODULES_PATH; 226 227 $provisioner_lib->engine = 'asterisk'; 228 $provisioner_lib->system = 'unix'; 229 230 $provisioner_lib->options = $new_template_data; 231 232 //have to because of versions less than php5.3 233 $provisioner_lib->brand_name = $phone_info['directory']; 234 $provisioner_lib->family_line = $phone_info['cfg_dir']; 186 function add_device() { 187 188 } 189 190 function add_line() { 191 192 } 193 194 function delete_line() { 195 196 } 197 198 function delete_device() { 199 235 200 } 236 201 … … 238 203 * Send this function an ID from the mac devices list table and you'll get all the information we have on that particular phone 239 204 * @param integer $mac_id ID number reference from the MySQL database referencing the table endpointman_mac_list 240 * @return <type> 205 * @return array 206 * @example 207 * Final Output will look something similar to this 208 * Array 209 * ( 210 * [config_files_override] => 211 * [global_user_cfg_data] => N; 212 * [model_id] => 213 213 * [brand_id] => 2 214 * [name] => Grandstream 215 * [directory] => grandstream 216 * [model] => GXP2000 217 * [mac] => 000B820D0050 218 * [template_id] => 0 219 * [global_custom_cfg_data] => Serialized Data (Changed Template Values) 220 * [long_name] => GXP Enterprise IP series [280,1200,2000,2010,2020] 221 * [product_id] => 21 222 * [cfg_dir] => gxp 223 * [cfg_ver] => 1.5 224 * [template_data] => Serialized Data (The default Template Values) 225 * [enabled] => 1 226 * [line] => Array 227 * ( 228 * [1] => Array 229 * ( 230 * [luid] => 2 231 * [mac_id] => 2 232 * [line] => 1 233 * [ext] => 1000 234 * [description] => Description 235 * [custom_cfg_data] => 236 * [user_cfg_data] => 237 * [secret] => secret 238 * [id] => 1000 239 * [tech] => sip 240 * [dial] => SIP/1000 241 * [devicetype] => fixed 242 * [user] => 1000 243 * [emergency_cid] => 244 * ) 245 * ) 246 * ) 241 247 */ 242 248 function get_phone_info($mac_id=NULL) { … … 299 305 } 300 306 } 301 302 //Final Output will look something similar to this303 /**Array304 (305 [config_files_override] =>306 [global_user_cfg_data] => N;307 [model_id] => 213308 [brand_id] => 2309 [name] => Grandstream310 [directory] => grandstream311 [model] => GXP2000312 [mac] => 000B820D0050313 [template_id] => 0314 [global_custom_cfg_data] => Serialized Data (Changed Template Values)315 [long_name] => GXP Enterprise IP series [280,1200,2000,2010,2020]316 [product_id] => 21317 [cfg_dir] => gxp318 [cfg_ver] => 1.5319 [template_data] => Serialized Data (The default Template Values)320 [enabled] => 1321 [line] => Array322 (323 [1] => Array324 (325 [luid] => 2326 [mac_id] => 2327 [line] => 1328 [ext] => 1000329 [description] => Description330 [custom_cfg_data] =>331 [user_cfg_data] =>332 [secret] => secret333 [id] => 1000334 [tech] => sip335 [dial] => SIP/1000336 [devicetype] => fixed337 [user] => 1000338 [emergency_cid] =>339 )340 341 )342 343 )344 */345 307 return $phone_info; 346 308 } … … 455 417 echo "No Template Data has been defined for this Product<br />"; 456 418 } 457 $this->tpl->assign("web_path", WEB_PATH);458 419 459 420 $this->tpl->assign("template_editor", $out); … … 741 702 $template_variables_array['type'] = "NA"; 742 703 break; 743 case "file":744 $template_variables_array['type'] = "NA";745 break;746 704 case "break": 747 705 if($admin) { … … 778 736 //This function is reversed. Not sure why 779 737 if($custom != "0") { 780 $sql = "SELECT endpointman_ product_list.config_files, endpointman_mac_list.*, endpointman_product_list.id as product_id, endpointman_product_list.long_name, endpointman_model_list.template_data, endpointman_product_list.cfg_dir, endpointman_brand_list.directory FROM endpointman_brand_list, endpointman_mac_list, endpointman_model_list, endpointman_product_list WHERE endpointman_mac_list.id=".$id." AND endpointman_mac_list.model = endpointman_model_list.id AND endpointman_model_list.brand = endpointman_brand_list.id AND endpointman_model_list.product_id = endpointman_product_list.id";781 } else { 782 $sql = "SELECT endpointman_ brand_list.directory, endpointman_product_list.cfg_dir, endpointman_product_list.config_files, endpointman_product_list.long_name, endpointman_model_list.template_data, endpointman_model_list.id as model_id, endpointman_template_list.* FROM endpointman_brand_list, endpointman_product_list, endpointman_model_list, endpointman_template_list WHERE endpointman_product_list.id = endpointman_template_list.product_id AND endpointman_brand_list.id = endpointman_product_list.brand AND endpointman_template_list.model_id = endpointman_model_list.id AND endpointman_template_list.id = ".$id;738 $sql = "SELECT endpointman_model_list.max_lines, endpointman_product_list.config_files, endpointman_mac_list.*, endpointman_product_list.id as product_id, endpointman_product_list.long_name, endpointman_model_list.template_data, endpointman_product_list.cfg_dir, endpointman_brand_list.directory FROM endpointman_brand_list, endpointman_mac_list, endpointman_model_list, endpointman_product_list WHERE endpointman_mac_list.id=".$id." AND endpointman_mac_list.model = endpointman_model_list.id AND endpointman_model_list.brand = endpointman_brand_list.id AND endpointman_model_list.product_id = endpointman_product_list.id"; 739 } else { 740 $sql = "SELECT endpointman_model_list.max_lines, endpointman_brand_list.directory, endpointman_product_list.cfg_dir, endpointman_product_list.config_files, endpointman_product_list.long_name, endpointman_model_list.template_data, endpointman_model_list.id as model_id, endpointman_template_list.* FROM endpointman_brand_list, endpointman_product_list, endpointman_model_list, endpointman_template_list WHERE endpointman_product_list.id = endpointman_template_list.product_id AND endpointman_brand_list.id = endpointman_product_list.brand AND endpointman_template_list.model_id = endpointman_model_list.id AND endpointman_template_list.id = ".$id; 783 741 } 784 742 … … 831 789 } 832 790 } elseif ($config_options['type'] == 'loop_line_options') { 833 for($a=1;$a<= 3;$a++) {791 for($a=1;$a<=$row['max_lines'];$a++) { 834 792 foreach($config_options['data']['item'] as $items) { 835 793 if(isset($items['description'])) { … … 888 846 $this->db->query($sql); 889 847 890 $phone_info = "";848 $phone_info = array(); 891 849 892 850 if($custom != 0) { 893 851 $phone_info = $this->get_phone_info($id); 894 $this->prepare_configs($phone_info); 895 852 if(isset($_REQUEST['epm_reboot'])) { 853 $this->prepare_configs($phone_info); 854 } else { 855 $this->prepare_configs($phone_info,FALSE); 856 } 896 857 } else { 897 858 $sql = 'SELECT id FROM endpointman_mac_list WHERE template_id = '.$id; … … 899 860 foreach($phones as $data) { 900 861 $phone_info = $this->get_phone_info($data['id']); 901 $this->prepare_configs($phone_info); 862 if(isset($_REQUEST['epm_reboot'])) { 863 $this->prepare_configs($phone_info); 864 } else { 865 $this->prepare_configs($phone_info,FALSE); 866 } 902 867 } 903 868 } … … 1036 1001 //template_data_custom.xml which will get included or template_data_<model_name>_custom.xml which will also get included 1037 1002 //line 'global' will set variables that aren't line dependant 1038 1039 1003 $provisioner_lib->options = $new_template_data; 1040 1004 … … 1051 1015 $time = $time_end - $time_start; 1052 1016 if($time > 360) { 1053 $this->error['generate_time'] = "It 's taking aawfully long time to generate configs...(".round($time,2)." seconds)";1017 $this->error['generate_time'] = "It took an awfully long time to generate configs...(".round($time,2)." seconds)"; 1054 1018 } 1055 1019 //Create Directory Structure (If needed) … … 1260 1224 } elseif(!empty($array)) { 1261 1225 return($array); 1226 //This is so stupid?! PHP gets confused. 1227 } elseif($array == '0') { 1228 return($array); 1262 1229 } else { 1263 1230 return(""); … … 1418 1385 } 1419 1386 1387 /** 1388 * This will download the xml & brand package remotely 1389 * @param integer $id Brand ID 1390 */ 1420 1391 function download_brand($id) { 1421 1392 $row =& $this->db->getAll('SELECT * FROM endpointman_brand_list WHERE id ='.$id, array(), DB_FETCHMODE_ASSOC); … … 1474 1445 1475 1446 echo "Removing Temporary Files.............."; 1476 $this-> deltree(PHONE_MODULES_PATH."temp/" .$row[0]['directory']);1447 $this->rmrf(PHONE_MODULES_PATH."temp/" .$row[0]['directory']); 1477 1448 unlink(PHONE_MODULES_PATH.'temp/'. $package); 1478 1449 echo "Done!<br />"; … … 1633 1604 $this->db->query($sql); 1634 1605 1635 $this-> deltree(PHONE_MODULES_PATH .$brand_dir);1606 $this->rmrf(PHONE_MODULES_PATH .$brand_dir); 1636 1607 $sql = "DELETE FROM endpointman_brand_list WHERE id = ". $id; 1637 1608 … … 1879 1850 return($exec); 1880 1851 } 1881 }1882 1883 /**1884 * Delete Directory Tree.1885 * @deprecated In favor of rmrf1886 * @param string $dir Full Directory path to delete1887 */1888 function deltree($dir) {1889 $this->rmrf($dir);1890 1852 } 1891 1853 modules/branches/2.9/endpointman/includes/template_manager.inc
r10792 r10797 106 106 $endpoint->tpl->assign("no_add", $no_add); 107 107 $endpoint->tpl->assign("debug", $debug); 108 $endpoint->tpl->assign("web_path", WEB_PATH);109 108 110 109 foreach($endpoint->error as $key => $error) { modules/branches/2.9/endpointman/install.php
r10792 r10797 92 92 } 93 93 94 $version = "2. 4.1";94 $version = "2.9.0.3"; 95 95 96 96 if(ep_table_exists("endpointman_global_vars")) { … … 168 168 } elseif($global_cfg['version'] == '2.4.2') { 169 169 $ver = "2.4.2"; 170 } elseif($global_cfg['version'] == '2.9.0.0') { 171 $ver = "2.9.0.0"; 172 } elseif($global_cfg['version'] == '2.9.0.1') { 173 $ver = "2.9.0.1"; 174 } elseif($global_cfg['version'] == '2.9.0.2') { 175 $ver = "2.9.0.2"; 176 } elseif($global_cfg['version'] == '2.9.0.3') { 177 $ver = "2.9.0.3"; 178 } elseif($global_cfg['version'] == '2.9.0.4') { 179 $ver = "2.9.0.4"; 180 } elseif($global_cfg['version'] == '2.9.0.5') { 181 $ver = "2.9.0.5"; 170 182 } else { 171 183 $ver = "1000"; … … 206 218 (14, 'check_updates', '1'), 207 219 (15, 'disable_htaccess', ''), 208 (16, 'endpoint_vers', '0')"; 220 (16, 'endpoint_vers', '0'), 221 (17, 'disable_help', '0')"; 209 222 $db->query($sql_update_vars); 210 223 … … 877 890 } 878 891 892 if ($ver <= "2.9.0.2") { 893 $sql = 'INSERT INTO `asterisk`.`endpointman_global_vars` (`idnum`, `var_name`, `value`) VALUES (NULL, \'disable_help\', \'0\');'; 894 $db->query($sql); 895 } 896 879 897 } 880 898 … … 939 957 (14, 'check_updates', '0'), 940 958 (15, 'disable_htaccess', ''), 941 (16, 'endpoint_vers', '0')"; 959 (16, 'endpoint_vers', '0'), 960 (17, 'disable_help', '0')"; 942 961 $db->query($sql); 943 962 … … 1157 1176 mkdir($amp_conf['AMPWEBROOT']."/recordings/theme/js/"); 1158 1177 1159 copy(LOCAL_PATH. "templates/ javascript/jquery.coda-slider-2.0.js", $amp_conf['AMPWEBROOT']."/recordings/theme/js/jquery.coda-slider-2.0.js");1160 1161 copy(LOCAL_PATH. "templates/ javascript/jquery.easing.1.3.js", $amp_conf['AMPWEBROOT']."/recordings/theme/js/jquery.easing.1.3.js");1162 1163 copy(LOCAL_PATH. "templates/ stylesheets/coda-slider-2.0a.css", $amp_conf['AMPWEBROOT']."/recordings/theme/coda-slider-2.0a.css");1178 copy(LOCAL_PATH. "templates/freepbx/javascript/jquery.coda-slider-2.0.js", $amp_conf['AMPWEBROOT']."/recordings/theme/js/jquery.coda-slider-2.0.js"); 1179 1180 copy(LOCAL_PATH. "templates/freepbx/javascript/jquery.easing.1.3.js", $amp_conf['AMPWEBROOT']."/recordings/theme/js/jquery.easing.1.3.js"); 1181 1182 copy(LOCAL_PATH. "templates/freepbx/stylesheets/coda-slider-2.0a.css", $amp_conf['AMPWEBROOT']."/recordings/theme/coda-slider-2.0a.css"); 1164 1183 1165 1184 … … 1181 1200 } 1182 1201 1183 copy(LOCAL_PATH. "templates/ javascript/jquery.coda-slider-2.0.js", $amp_conf['AMPWEBROOT']."/recordings/theme/js/jquery.coda-slider-2.0.js");1184 1185 copy(LOCAL_PATH. "templates/ javascript/jquery.easing.1.3.js", $amp_conf['AMPWEBROOT']."/recordings/theme/js/jquery.easing.1.3.js");1202 copy(LOCAL_PATH. "templates/freepbx/javascript/jquery.coda-slider-2.0.js", $amp_conf['AMPWEBROOT']."/recordings/theme/js/jquery.coda-slider-2.0.js"); 1203 1204 copy(LOCAL_PATH. "templates/freepbx/javascript/jquery.easing.1.3.js", $amp_conf['AMPWEBROOT']."/recordings/theme/js/jquery.easing.1.3.js"); 1186 1205 1187 copy(LOCAL_PATH. "templates/ stylesheets/coda-slider-2.0a.css", $amp_conf['AMPWEBROOT']."/recordings/theme/coda-slider-2.0a.css");1206 copy(LOCAL_PATH. "templates/freepbx/stylesheets/coda-slider-2.0a.css", $amp_conf['AMPWEBROOT']."/recordings/theme/coda-slider-2.0a.css"); 1188 1207 1189 1208 modules/branches/2.9/endpointman/module.xml
r10793 r10797 2 2 <rawname>endpointman</rawname> 3 3 <name>PBX End Point Manager</name> 4 <version>2.9.0. 1</version>4 <version>2.9.0.3RC1</version> 5 5 <type>tool</type> 6 6 <category>End Point Manager</category> … … 21 21 </changelog> 22 22 <info>http://projects.colsolgrp.net/projects/show/endpointman</info> 23 <location> release/2.9/endpointman-2.9.0.1.tgz</location>23 <location>contributed_modules/release/endpointman-2.3.2.tgz</location> 24 24 25 <md5sum> ff802d5bfae951860d0efe69b9079ddb</md5sum>25 <md5sum>b0e3a14a20449b0441d1a9f432f19559</md5sum> 26 26 </module> modules/branches/2.9/endpointman/templates/freepbx/advanced_settings_settings.html
r10792 r10797 64 64 </label></td> 65 65 </tr> 66 <!--67 66 <tr> 68 <td align='right'><?=_(" Enable Nightly Phone Module Updates Check")?></td>67 <td align='right'><?=_("Disable Tooltips")?></td> 69 68 <td align='left'><label> 70 <input type=checkbox name=" enable_updates" {$updates_selected}>69 <input type=checkbox name="disable_help" {$help_selected}> 71 70 </label></td> 72 71 </tr> 73 -->74 72 <tr> 75 73 <td colspan='2' align='center'><input type='Submit' name='button_update_globals' value='<?=_('Update Globals')?>'></td> modules/branches/2.9/endpointman/templates/freepbx/devices_manager.html
r10792 r10797 301 301 {loop name="list"} 302 302 <tr class="headerRow"> 303 <td align='center' ><div id="demo">< img src="{$web_path}templates/images/bullet_plus.png" id="imgrowGroup{$value.master_id}" alt="" onclick="toggleDisplay(document.getElementById('devList'),'headerRow','rowGroup{$value.master_id}')" title="Expand Line Information"><input type="checkbox" name="selected[]" value="{$value.id}"></div></td>303 <td align='center' ><div id="demo"><a href="#"><img src="{$web_path}templates/images/bullet_plus.png" id="imgrowGroup{$value.master_id}" alt="" onclick="toggleDisplay(document.getElementById('devList'),'headerRow','rowGroup{$value.master_id}')" title="Expanded Line Information"><input type="checkbox" name="selected[]" value="{$value.id}"></a></div></td> 304 304 <td align='center' width='11%'>{$value.mac}</td> 305 305 <td width="13%" align='center'>{$value.name}</td> 306 306 <td width="14%" align='center'>{$value.model}</td> 307 <td width="10%" align='center'>< /td>308 <td width="19%" align='center'>< /td>307 <td width="10%" align='center'><div id="demo"><a href="#"><img src="{$web_path}templates/images/expand.png" id="img2rowGroup{$value.master_id}" onclick="toggleDisplay(document.getElementById('devList'),'headerRow','rowGroup{$value.master_id}')" title="Expanded Line Information"></a></div></td> 308 <td width="19%" align='center'><div id="demo"><a href="#"><img src="{$web_path}templates/images/expand.png" id="img3rowGroup{$value.master_id}" onclick="toggleDisplay(document.getElementById('devList'),'headerRow','rowGroup{$value.master_id}')" title="Expanded Line Information"></a></div></td> 309 309 <td align='center' width='15%'>{$value.template_name}</td> 310 310 <td align='center' width='9%'><div id="demo"><a href='javascript:submit_wtype("edit",{$value.id});'><img src='{$web_path}templates/images/edit.png' ALT='<?=_('Edit')?>' title='Edit Device' border='0'></a></div></td> … … 373 373 </form> 374 374 375 {if condition="!isset($disable_help)"} 375 376 <script> 376 377 $("#demo img[title]").tooltip(); 377 </script> 378 </script> 379 {/if} 378 380 {include="global_footer"} modules/branches/2.9/endpointman/templates/freepbx/global_header.html
r10792 r10797 126 126 tblRows[i].style.display = ''; 127 127 document.getElementById("img"+rowClass).src= '{$web_path}templates/images/bullet_minus.png'; 128 document.getElementById("img2"+rowClass).src= '{$web_path}templates/images/collapse.png'; 129 document.getElementById("img3"+rowClass).src= '{$web_path}templates/images/collapse.png'; 128 130 }else{ 129 131 tblRows[i].style.display = 'none'; 130 132 document.getElementById("img"+rowClass).src= '{$web_path}templates/images/bullet_plus.png'; 133 document.getElementById("img2"+rowClass).src= '{$web_path}templates/images/expand.png'; 134 document.getElementById("img3"+rowClass).src= '{$web_path}templates/images/expand.png'; 131 135 } 132 136 } modules/branches/2.9/endpointman/templates/freepbx/template_editor.html
r10792 r10797 17 17 <body> 18 18 {else} 19 <script type="text/javascript" src="<?=WEB_PATH?>templates/freepbx/javascript/jquery.tooltip.v.1.1.js"></script> 20 <script type="text/javascript" src="<?=WEB_PATH?>templates/freepbx/javascript/jquery.tooltip.execute.js"></script> 21 <link href="<?=WEB_PATH?>templates/freepbx/stylesheets/simpletooltip.css" rel="stylesheet" type="text/css" /> 19 22 <script language="javascript" type="text/javascript"> 20 23 function popitup(url, name) { … … 113 116 {/loop} 114 117 {elseif condition="$value.type == 'list'"} 115 {$value.description} <select name='{$value.key}' id='{$value.key}'>118 {$value.description}: <select name='{$value.key}' id='{$value.key}'> 116 119 {loop name="value.data"} 117 120 <option value='{$value.value}' {if condition="array_key_exists('selected',$value)"}{$value.selected}{/if}>{$value.description}</option> … … 141 144 <input name="custom" id="custom" type="hidden" value="{$hidden_custom}"> 142 145 {if condition="!isset($in_ari)"} 146 Reboot Phone(s) <input type='checkbox' name='epm_reboot'><br /> 143 147 <input type="submit" name="button_save_template" value="<?=_('Save Template');?>"> 144 148 </form> modules/branches/2.9/endpointman/uninstall.php
r10315 r10797 28 28 29 29 out("Removing Phone Modules Directory"); 30 $endpoint-> deltree(PHONE_MODULES_PATH);30 $endpoint->rmrf(PHONE_MODULES_PATH); 31 31 exec("rm -R ". PHONE_MODULES_PATH); 32 32
