Changeset 10947

Show
Ignore:
Timestamp:
01/10/11 20:25:03 (2 years ago)
Author:
tm1000
Message:

Adding a bunch of error checking and reporting

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • modules/branches/2.9/endpointman/includes/devices_manager.inc

    r10797 r10947  
    2424$family_list =& $endpoint->endpoint_data->all_products(); 
    2525$full_device_list =& $endpoint->endpoint_data->all_devices(); 
    26  
    27 if((!$family_list) && (!$full_device_list)) { 
     26$ava_exts = $endpoint->display_registration_list(); 
     27 
     28if((empty($family_list)) && (empty($full_device_list))) { 
    2829    $message = _("Welcome to Endpoint Manager")."!<br />"._("You have no products (Modules) installed, click")." <a href=\"config.php?display=epm_config&type=$type\">"._("here")."</a> "._("to install some"); 
    2930    $no_add = TRUE; 
    30 } elseif(!$family_list) { 
    31     $message = "Thanks for upgrading to version 2.0! Please head on over to <a href=\"config.php?display=epm_config&type=$type\">\"Brand Configurations/Setup\"</a> to setup and install phone configurations"; 
    32     $no_add = TRUE; 
     31    $endpoint->global_cfg['new'] = 1; 
    3332} elseif($endpoint->global_cfg['srvip'] == "") { 
    3433    $message = "Your Global Variables are not set! Please head on over to <a href=\"config.php?type=$type&display=epm_advanced\">\"Advanced Settings\"</a> to setup your configuration"; 
    3534    $no_add = TRUE; 
     35} elseif(empty($ava_exts)) { 
     36    //$message = "You have no more devices or extensions avalible to configure!"; 
     37    //$no_add = TRUE; 
    3638} 
    3739 
    38 if((isset($_REQUEST['sub_type'])) AND (!$no_add)) { 
     40if((isset($_REQUEST['sub_type'])) AND ((!$no_add) OR (($_REQUEST['sub_type'] == "edit")))) { 
    3941    $sub_type = $_REQUEST['sub_type']; 
    4042    if(isset($_REQUEST['sub_type_sub'])) { 
     
    135137        $mac = $endpoint->mac_check_clean($_REQUEST['mac']); 
    136138        if($mac) { 
    137             $sql = 'SELECT description FROM devices WHERE id = '.$_REQUEST['ext_list']; 
    138             $name =& $endpoint->db->getOne($sql); 
    139  
    140             $endpoint->sync_model($_REQUEST['model_list']); 
    141  
    142             $sql = 'SELECT endpointman_product_list. * , endpointman_model_list.template_data, endpointman_brand_list.directory FROM endpointman_model_list, endpointman_brand_list, endpointman_product_list WHERE endpointman_model_list.id =  \''.$_REQUEST['model_list'].'\' AND endpointman_model_list.brand = endpointman_brand_list.id AND endpointman_model_list.product_id = endpointman_product_list.id'; 
    143    
    144             $row =& $endpoint->db->getRow($sql,array(),DB_FETCHMODE_ASSOC); 
    145  
    146             $sql = "INSERT INTO `endpointman_mac_list` (`mac`, `model`, `template_id`) VALUES ('".$mac."', '".$_REQUEST['model_list']."', '".$_REQUEST['template_list']."')"; 
    147             $endpoint->db->query($sql); 
    148  
    149             $sql = 'SELECT last_insert_id()'; 
    150             $ext_id =& $endpoint->db->getOne($sql); 
    151  
    152             if(!isset($_REQUEST['line_list'])) { 
    153                 $_REQUEST['line_list'] = 1; 
    154             } 
    155  
    156             $sql = "INSERT INTO `endpointman_line_list` (`mac_id`, `ext`, `line`, `description`) VALUES ('".$ext_id."', '".$_REQUEST['ext_list']."', '".$_REQUEST['line_list']."', '".$name."')"; 
    157             $endpoint->db->query($sql); 
    158  
    159             if(!isset($_REQUEST['image_x'])) { 
    160                 $mac_id = $endpoint->get_phone_info($ext_id); 
    161  
    162                 $endpoint->prepare_configs($mac_id); 
    163  
    164                 $message = _("Saved")."!"; 
    165             } else { 
    166                 $_REQUEST['edit_id'] = $ext_id; 
    167                 $edit_row=$endpoint->get_phone_info($ext_id); 
    168                 $edit_row['id'] = $_REQUEST['edit_id']; 
    169                 $mode = "EDIT"; 
    170                 $_REQUEST['id'] = $_REQUEST['edit_id']; 
    171                 if($endpoint->linesAvailable(NULL,$_REQUEST['id'])) { 
    172                     if($endpoint->endpoint_data->all_unused_registrations()) { 
    173                         $sql = 'SELECT * FROM `endpointman_line_list` WHERE `mac_id` = '. $_REQUEST['id']; 
    174                         $lines_list =& $endpoint->db->getAll($sql,array(),DB_FETCHMODE_ASSOC); 
    175  
    176                         foreach($lines_list as $row) { 
    177                             $sql = "SELECT description FROM devices WHERE id = ".$_REQUEST['ext_list']; 
    178                             $name=$endpoint->db->getOne($sql); 
    179  
    180                             $sql = "UPDATE endpointman_line_list SET line = '".$_REQUEST['line_list']."', ext = ".$_REQUEST['ext_list'].", description = '".$name."' WHERE luid =  ". $row['luid']; 
    181                             $endpoint->db->query($sql); 
     139            if($endpoint->sync_model($_REQUEST['model_list'])) { 
     140                if(empty($_REQUEST['brand_list'])) { 
     141                    $message = _("You Must Select A Brand From the Drop Down")."!"; 
     142                } elseif(empty($_REQUEST['model_list'])) { 
     143                    $message = _("You Must Select A Model From the Drop Down")."!"; 
     144                } elseif(empty($_REQUEST['line_list'])) { 
     145                    $message = _("You Must Select A Line From the Drop Down")."!"; 
     146                } elseif(empty($_REQUEST['ext_list'])) { 
     147                    $message = _("You Must Select an Extension/Device From the Drop Down")."!"; 
     148                } elseif(!isset($_REQUEST['template_list'])) { 
     149                    $message = _("You Must Select A Template From the Drop Down")."!"; 
     150                    print_r($_REQUEST); 
     151                } else { 
     152                    $sql = 'SELECT description FROM devices WHERE id = '.$_REQUEST['ext_list']; 
     153                    $name =& $endpoint->db->getOne($sql); 
     154 
     155                    $sql = 'SELECT endpointman_product_list. * , endpointman_model_list.template_data, endpointman_brand_list.directory FROM endpointman_model_list, endpointman_brand_list, endpointman_product_list WHERE endpointman_model_list.id =  \''.$_REQUEST['model_list'].'\' AND endpointman_model_list.brand = endpointman_brand_list.id AND endpointman_model_list.product_id = endpointman_product_list.id'; 
     156 
     157                    $row =& $endpoint->db->getRow($sql,array(),DB_FETCHMODE_ASSOC); 
     158 
     159                    $sql = "INSERT INTO `endpointman_mac_list` (`mac`, `model`, `template_id`) VALUES ('".$mac."', '".$_REQUEST['model_list']."', '".$_REQUEST['template_list']."')"; 
     160                    $endpoint->db->query($sql); 
     161 
     162                    $sql = 'SELECT last_insert_id()'; 
     163                    $ext_id =& $endpoint->db->getOne($sql); 
     164 
     165                    if(!isset($_REQUEST['line_list'])) { 
     166                        $_REQUEST['line_list'] = 1; 
     167                    } 
     168 
     169                    $sql = "INSERT INTO `endpointman_line_list` (`mac_id`, `ext`, `line`, `description`) VALUES ('".$ext_id."', '".$_REQUEST['ext_list']."', '".$_REQUEST['line_list']."', '".$name."')"; 
     170                    $endpoint->db->query($sql); 
     171 
     172                    if(!isset($_REQUEST['image_x'])) { 
     173                        $mac_id = $endpoint->get_phone_info($ext_id); 
     174                        if($endpoint->prepare_configs($mac_id)) { 
     175                            $message = _("Saved")."!"; 
    182176                        } 
    183  
    184                         $reg = array_values($endpoint->display_registration_list()); 
    185                         $lines = array_values($endpoint->linesAvailable(NULL,$_REQUEST['id'])); 
    186  
    187                         $sql = "SELECT description FROM devices WHERE id = ".$reg[0]['value']; 
    188                         $name=$endpoint->db->getOne($sql); 
    189  
    190                         $sql = "INSERT INTO `endpointman_line_list` (`mac_id`, `ext`, `line`, `description`) VALUES ('".$_REQUEST['id']."', '".$reg[0]['value']."', '".$lines[0]['value']."', '".$name."')"; 
    191                         $endpoint->db->query($sql); 
    192  
     177                    } else { 
     178                        $_REQUEST['edit_id'] = $ext_id; 
    193179                        $edit_row=$endpoint->get_phone_info($ext_id); 
    194180                        $edit_row['id'] = $_REQUEST['edit_id']; 
    195                         $message = "Configuration Files will not be Generated until you click Save!"; 
    196                     } else { 
    197                         $message = _("No Devices/Extensions Left to Add")."!"; 
     181                        $mode = "EDIT"; 
     182                        $_REQUEST['id'] = $_REQUEST['edit_id']; 
     183                        if($endpoint->linesAvailable(NULL,$_REQUEST['id'])) { 
     184                            if($endpoint->endpoint_data->all_unused_registrations()) { 
     185                                $sql = 'SELECT * FROM `endpointman_line_list` WHERE `mac_id` = '. $_REQUEST['id']; 
     186                                $lines_list =& $endpoint->db->getAll($sql,array(),DB_FETCHMODE_ASSOC); 
     187 
     188                                foreach($lines_list as $row) { 
     189                                    $sql = "SELECT description FROM devices WHERE id = ".$_REQUEST['ext_list']; 
     190                                    $name=$endpoint->db->getOne($sql); 
     191 
     192                                    $sql = "UPDATE endpointman_line_list SET line = '".$_REQUEST['line_list']."', ext = ".$_REQUEST['ext_list'].", description = '".$name."' WHERE luid =  ". $row['luid']; 
     193                                    $endpoint->db->query($sql); 
     194                                } 
     195 
     196                                $reg = array_values($endpoint->display_registration_list()); 
     197                                $lines = array_values($endpoint->linesAvailable(NULL,$_REQUEST['id'])); 
     198 
     199                                $sql = "SELECT description FROM devices WHERE id = ".$reg[0]['value']; 
     200                                $name=$endpoint->db->getOne($sql); 
     201 
     202                                $sql = "INSERT INTO `endpointman_line_list` (`mac_id`, `ext`, `line`, `description`) VALUES ('".$_REQUEST['id']."', '".$reg[0]['value']."', '".$lines[0]['value']."', '".$name."')"; 
     203                                $endpoint->db->query($sql); 
     204 
     205                                $edit_row=$endpoint->get_phone_info($ext_id); 
     206                                $edit_row['id'] = $_REQUEST['edit_id']; 
     207                                $message = "Configuration Files will not be Generated until you click Save!"; 
     208                            } else { 
     209                                $message = _("No Devices/Extensions Left to Add")."!"; 
     210                            } 
     211                        } else { 
     212                            $message = _("No Lines Left to Add")."!"; 
     213                        } 
    198214                    } 
    199                 } else { 
    200                     $message = _("No Lines Left to Add")."!"; 
    201                 } 
     215                } 
     216            } else { 
     217                $endpoint->error['Sync_Model'] = _("Invalid Model Selected, Can't Sync System")."!"; 
    202218            } 
    203219        } else { 
     
    244260        $mac_id =& $endpoint->db->getOne($sql,array(),DB_FETCHMODE_ASSOC); 
    245261        $row = $endpoint->get_phone_info($mac_id); 
    246          
    247         $sql = 'SELECT COUNT(*) FROM endpointman_line_list WHERE mac_id = 31'
     262 
     263        $sql = 'SELECT COUNT(*) FROM endpointman_line_list WHERE mac_id = '.$mac_id
    248264        $num_lines =& $endpoint->db->getOne($sql,array(),DB_FETCHMODE_ASSOC); 
    249265        if($num_lines > 1) { 
  • modules/branches/2.9/endpointman/includes/functions.inc

    r10805 r10947  
    881881     */ 
    882882    function prepare_configs($phone_info,$reboot=TRUE) { 
    883         if(!class_exists('ProvisionerConfig')) { 
    884             require(PHONE_MODULES_PATH.'setup.php'); 
    885         } 
    886  
    887         //Load Provisioner 
    888         $class = "endpoint_" . $phone_info['directory'] . "_" . $phone_info['cfg_dir'] . '_phone'; 
    889         $provisioner_lib = new $class(); 
    890  
    891         //Tell the system who we are and were to find the data. 
    892         $provisioner_lib->root_dir = PHONE_MODULES_PATH; 
    893         $provisioner_lib->engine = 'asterisk'; 
    894         $provisioner_lib->engine_location = $this->global_cfg['asterisk_location']; 
    895         $provisioner_lib->system = 'unix'; 
    896  
    897         //have to because of versions less than php5.3 
    898         $provisioner_lib->brand_name = $phone_info['directory']; 
    899         $provisioner_lib->family_line = $phone_info['cfg_dir']; 
    900  
    901         //Mac Address 
    902         $provisioner_lib->mac = $phone_info['mac']; 
    903  
    904         //Phone Model (Please reference family_data.xml in the family directory for a list of recognized models) 
    905         //This has to match word for word. I really need to fix this.... 
    906         $provisioner_lib->model = $phone_info['model']; 
    907  
    908         //Timezone 
    909         $provisioner_lib->timezone = $this->global_cfg['tz']; 
    910  
    911         //Server IP 
    912         $provisioner_lib->server[1]['ip'] = $this->global_cfg['srvip']; 
    913         $provisioner_lib->server[1]['port'] = 5060; 
    914  
    915         $temp = ""; 
    916         $template_data = unserialize($phone_info['template_data']); 
    917         $global_user_cfg_data = unserialize($phone_info['global_user_cfg_data']); 
    918         if($phone_info['template_id'] > 0) { 
    919             $global_custom_cfg_data = unserialize($phone_info['template_data_info']['global_custom_cfg_data']); 
    920             //Provide alternate Configuration file instead of the one from the hard drive 
    921             if(!empty($phone_info['template_data_info']['config_files_override'])) { 
    922                 $temp = unserialize($phone_info['template_data_info']['config_files_override']); 
    923                 foreach($temp as $list) { 
    924                     $sql = "SELECT original_name,data FROM endpointman_custom_configs WHERE id = ".$list; 
    925                     $res =& $this->db->query($sql); 
    926                     if($res->numRows()) { 
    927                         $data = $this->db->getRow($sql, array(),DB_FETCHMODE_ASSOC); 
    928                         $provisioner_lib->config_files_override[$data['original_name']] = $data['data']; 
    929                     } 
    930                 } 
    931             } 
    932         } else { 
    933             $global_custom_cfg_data = unserialize($phone_info['global_custom_cfg_data']); 
    934             //Provide alternate Configuration file instead of the one from the hard drive 
    935             if(!empty($phone_info['config_files_override'])) { 
    936                 $temp = unserialize($phone_info['config_files_override']); 
    937                 foreach($temp as $list) { 
    938                     $sql = "SELECT original_name,data FROM endpointman_custom_configs WHERE id = ".$list; 
    939                     $res =& $this->db->query($sql); 
    940                     if($res->numRows()) { 
    941                         $data = $this->db->getRow($sql, array(),DB_FETCHMODE_ASSOC); 
    942                         $provisioner_lib->config_files_override[$data['original_name']] = $data['data']; 
    943                     } 
    944                 } 
    945             } 
    946         } 
    947  
    948         if (!empty($global_custom_cfg_data)) { 
    949             if(array_key_exists('data', $global_custom_cfg_data)) { 
    950                 $global_custom_cfg_ari = $global_custom_cfg_data['ari']; 
    951                 $global_custom_cfg_data = $global_custom_cfg_data['data']; 
    952             } else { 
    953                 $global_custom_cfg_data = array(); 
    954                 $global_custom_cfg_ari = array(); 
    955             } 
    956         } 
    957  
    958         $new_template_data = array(); 
    959         $line_ops = array(); 
    960         if(is_array($global_custom_cfg_data)) { 
    961             foreach($global_custom_cfg_data as $key => $data) { 
    962                 $full_key = $key; 
    963                 $key = explode('|',$key); 
    964                 $count = count($key); 
    965                 switch($count) { 
    966                     case 1: 
    967                         if(($this->global_cfg['enable_ari'] == 1) AND (isset($global_custom_cfg_ari[$full_key])) AND (isset($global_user_cfg_data[$full_key]))) { 
    968                             $new_template_data[$full_key] = $global_user_cfg_data[$full_key]; 
    969                         } else { 
    970                             $new_template_data[$full_key] = $global_custom_cfg_data[$full_key]; 
    971                         } 
    972                     break; 
    973                     case 2: 
    974                         $breaks = explode('_',$key[1]); 
    975                         if(($this->global_cfg['enable_ari'] == 1) AND (isset($global_custom_cfg_ari[$full_key])) AND (isset($global_user_cfg_data[$full_key]))) { 
    976                             $new_template_data[$breaks[0]][$breaks[2]][$breaks[1]] = $global_user_cfg_data[$full_key]; 
    977                         } else { 
    978                             $new_template_data[$breaks[0]][$breaks[2]][$breaks[1]] = $global_custom_cfg_data[$full_key]; 
    979                         } 
    980                     break; 
    981                     case 3: 
    982                         if(($this->global_cfg['enable_ari'] == 1) AND (isset($global_custom_cfg_ari[$full_key])) AND (isset($global_user_cfg_data[$full_key]))) { 
    983                             $line_ops[$key[1]][$key[2]] = $global_user_cfg_data[$full_key]; 
    984                         } else { 
    985                             $line_ops[$key[1]][$key[2]] = $global_custom_cfg_data[$full_key]; 
    986                         } 
    987                     break; 
    988                 } 
    989             } 
    990         } 
    991  
    992         //Loop through Lines! 
    993         foreach($phone_info['line'] as $line) { 
    994             $provisioner_lib->lines[$line['line']] = array('ext' => $line['ext'], 'secret' => $line['secret'], 'displayname' => $line['description']); 
    995             if(isset($line_ops[$line['line']])) { 
    996                 $provisioner_lib->lines[$line['line']]['options'] = $line_ops[$line['line']]; 
    997             } 
    998         } 
    999  
    1000         //Set Variables according to the template_data files included. We can include different template.xml files within family_data.xml also one can create 
    1001         //template_data_custom.xml which will get included or template_data_<model_name>_custom.xml which will also get included 
    1002         //line 'global' will set variables that aren't line dependant 
    1003         $provisioner_lib->options = $new_template_data; 
    1004  
    1005         //Setting a line variable here...these aren't defined in the template_data.xml file yet. however they will still be parsed 
    1006         //and if they have defaults assigned in a future template_data.xml or in the config file using pipes (|) those will be used, pipes take precedence 
    1007         $provisioner_lib->processor_info = "EndPoint Manager Version ".$this->global_cfg['version']; 
    1008  
    1009         // Because every brand is an extension (eventually) of endpoint, you know this function will exist regardless of who it is 
    1010         //Start timer 
    1011         $time_start = microtime(true); 
    1012         $returned_data = $provisioner_lib->generate_config(); 
    1013         //End timer 
    1014         $time_end = microtime(true); 
    1015         $time = $time_end - $time_start; 
    1016         if($time > 360) { 
    1017             $this->error['generate_time'] = "It took an awfully long time to generate configs...(".round($time,2)." seconds)"; 
    1018         } 
    1019         //Create Directory Structure (If needed) 
    1020         if(isset($provisioner_lib->directory_structure)) { 
    1021             foreach($provisioner_lib->directory_structure as $data) { 
    1022                 $dir = $this->global_cfg['config_location'] . $data; 
    1023                 if(!file_exists($dir)) { 
    1024                     mkdir($dir, 0777); 
    1025                 } 
    1026             } 
    1027         } 
    1028  
    1029         //Copy Files/Directories (If needed) 
    1030         if(isset($provisioner_lib->copy_files)) { 
    1031             foreach($provisioner_lib->copy_files as $data) { 
    1032                 if(((file_exists($this->global_cfg['config_location'].$data)) AND (!in_array($data,$provisioner_lib->protected_files))) OR (!file_exists($this->global_cfg['config_location'].$data))) { 
    1033                     if(is_dir(PHONE_MODULES_PATH."endpoint/".$phone_info['directory']."/".$phone_info['cfg_dir']."/".$data)) { 
    1034                         if(!file_exists($this->global_cfg['config_location'].$data)) { 
    1035                             if (!@mkdir($this->global_cfg['config_location'].$data, 0777)) { 
    1036                                 $this->error['parse_configs'] = "Could Not Create Directory: ".$data; 
     883        if(file_exists(PHONE_MODULES_PATH.'setup.php')) { 
     884            if(!class_exists('ProvisionerConfig')) { 
     885                require(PHONE_MODULES_PATH.'setup.php'); 
     886            } 
     887 
     888            //Load Provisioner 
     889            $class = "endpoint_" . $phone_info['directory'] . "_" . $phone_info['cfg_dir'] . '_phone'; 
     890            if(class_exists($class)) { 
     891                $provisioner_lib = new $class(); 
     892 
     893                //Tell the system who we are and were to find the data. 
     894                $provisioner_lib->root_dir = PHONE_MODULES_PATH; 
     895                $provisioner_lib->engine = 'asterisk'; 
     896                $provisioner_lib->engine_location = $this->global_cfg['asterisk_location']; 
     897                $provisioner_lib->system = 'unix'; 
     898 
     899                //have to because of versions less than php5.3 
     900                $provisioner_lib->brand_name = $phone_info['directory']; 
     901                $provisioner_lib->family_line = $phone_info['cfg_dir']; 
     902 
     903                //Mac Address 
     904                $provisioner_lib->mac = $phone_info['mac']; 
     905 
     906                //Phone Model (Please reference family_data.xml in the family directory for a list of recognized models) 
     907                //This has to match word for word. I really need to fix this.... 
     908                $provisioner_lib->model = $phone_info['model']; 
     909 
     910                //Timezone 
     911                $provisioner_lib->timezone = $this->global_cfg['tz']; 
     912 
     913                //Server IP 
     914                $provisioner_lib->server[1]['ip'] = $this->global_cfg['srvip']; 
     915                $provisioner_lib->server[1]['port'] = 5060; 
     916 
     917                $temp = ""; 
     918                $template_data = unserialize($phone_info['template_data']); 
     919                $global_user_cfg_data = unserialize($phone_info['global_user_cfg_data']); 
     920                if($phone_info['template_id'] > 0) { 
     921                    $global_custom_cfg_data = unserialize($phone_info['template_data_info']['global_custom_cfg_data']); 
     922                    //Provide alternate Configuration file instead of the one from the hard drive 
     923                    if(!empty($phone_info['template_data_info']['config_files_override'])) { 
     924                        $temp = unserialize($phone_info['template_data_info']['config_files_override']); 
     925                        foreach($temp as $list) { 
     926                            $sql = "SELECT original_name,data FROM endpointman_custom_configs WHERE id = ".$list; 
     927                            $res =& $this->db->query($sql); 
     928                            if($res->numRows()) { 
     929                                $data = $this->db->getRow($sql, array(),DB_FETCHMODE_ASSOC); 
     930                                $provisioner_lib->config_files_override[$data['original_name']] = $data['data']; 
    1037931                            } 
    1038932                        } 
    1039                         $dir_iterator = new RecursiveDirectoryIterator(PHONE_MODULES_PATH."endpoint/".$phone_info['directory']."/".$phone_info['cfg_dir']."/".$data."/"); 
    1040                         $iterator = new RecursiveIteratorIterator($dir_iterator, RecursiveIteratorIterator::SELF_FIRST); 
    1041                         // could use CHILD_FIRST if you so wish 
    1042                         foreach ($iterator as $file) { 
    1043                             if(is_dir($file)) { 
    1044                                 $dir = str_replace(PHONE_MODULES_PATH."endpoint/".$phone_info['directory']."/".$phone_info['cfg_dir']."/".$data."/", "", $file); 
    1045                                 if(!file_exists($this->global_cfg['config_location'].$data."/".$dir)) { 
    1046                                     if (!@mkdir($this->global_cfg['config_location'].$data."/".$dir, 0777)) { 
    1047                                         $this->error['parse_configs'] = "Could Not Create Directory: ".$data."/".$dir; 
     933                    } 
     934                } else { 
     935                    $global_custom_cfg_data = unserialize($phone_info['global_custom_cfg_data']); 
     936                    //Provide alternate Configuration file instead of the one from the hard drive 
     937                    if(!empty($phone_info['config_files_override'])) { 
     938                        $temp = unserialize($phone_info['config_files_override']); 
     939                        foreach($temp as $list) { 
     940                            $sql = "SELECT original_name,data FROM endpointman_custom_configs WHERE id = ".$list; 
     941                            $res =& $this->db->query($sql); 
     942                            if($res->numRows()) { 
     943                                $data = $this->db->getRow($sql, array(),DB_FETCHMODE_ASSOC); 
     944                                $provisioner_lib->config_files_override[$data['original_name']] = $data['data']; 
     945                            } 
     946                        } 
     947                    } 
     948                } 
     949 
     950                if (!empty($global_custom_cfg_data)) { 
     951                    if(array_key_exists('data', $global_custom_cfg_data)) { 
     952                        $global_custom_cfg_ari = $global_custom_cfg_data['ari']; 
     953                        $global_custom_cfg_data = $global_custom_cfg_data['data']; 
     954                    } else { 
     955                        $global_custom_cfg_data = array(); 
     956                        $global_custom_cfg_ari = array(); 
     957                    } 
     958                } 
     959 
     960                $new_template_data = array(); 
     961                $line_ops = array(); 
     962                if(is_array($global_custom_cfg_data)) { 
     963                    foreach($global_custom_cfg_data as $key => $data) { 
     964                        $full_key = $key; 
     965                        $key = explode('|',$key); 
     966                        $count = count($key); 
     967                        switch($count) { 
     968                            case 1: 
     969                                if(($this->global_cfg['enable_ari'] == 1) AND (isset($global_custom_cfg_ari[$full_key])) AND (isset($global_user_cfg_data[$full_key]))) { 
     970                                    $new_template_data[$full_key] = $global_user_cfg_data[$full_key]; 
     971                                } else { 
     972                                    $new_template_data[$full_key] = $global_custom_cfg_data[$full_key]; 
     973                                } 
     974                                break; 
     975                            case 2: 
     976                                $breaks = explode('_',$key[1]); 
     977                                if(($this->global_cfg['enable_ari'] == 1) AND (isset($global_custom_cfg_ari[$full_key])) AND (isset($global_user_cfg_data[$full_key]))) { 
     978                                    $new_template_data[$breaks[0]][$breaks[2]][$breaks[1]] = $global_user_cfg_data[$full_key]; 
     979                                } else { 
     980                                    $new_template_data[$breaks[0]][$breaks[2]][$breaks[1]] = $global_custom_cfg_data[$full_key]; 
     981                                } 
     982                                break; 
     983                            case 3: 
     984                                if(($this->global_cfg['enable_ari'] == 1) AND (isset($global_custom_cfg_ari[$full_key])) AND (isset($global_user_cfg_data[$full_key]))) { 
     985                                    $line_ops[$key[1]][$key[2]] = $global_user_cfg_data[$full_key]; 
     986                                } else { 
     987                                    $line_ops[$key[1]][$key[2]] = $global_custom_cfg_data[$full_key]; 
     988                                } 
     989                                break; 
     990                        } 
     991                    } 
     992                } 
     993 
     994                //Loop through Lines! 
     995                foreach($phone_info['line'] as $line) { 
     996                    $provisioner_lib->lines[$line['line']] = array('ext' => $line['ext'], 'secret' => $line['secret'], 'displayname' => $line['description']); 
     997                    if(isset($line_ops[$line['line']])) { 
     998                        $provisioner_lib->lines[$line['line']]['options'] = $line_ops[$line['line']]; 
     999                    } 
     1000                } 
     1001 
     1002                //Set Variables according to the template_data files included. We can include different template.xml files within family_data.xml also one can create 
     1003                //template_data_custom.xml which will get included or template_data_<model_name>_custom.xml which will also get included 
     1004                //line 'global' will set variables that aren't line dependant 
     1005                $provisioner_lib->options = $new_template_data; 
     1006 
     1007                //Setting a line variable here...these aren't defined in the template_data.xml file yet. however they will still be parsed 
     1008                //and if they have defaults assigned in a future template_data.xml or in the config file using pipes (|) those will be used, pipes take precedence 
     1009                $provisioner_lib->processor_info = "EndPoint Manager Version ".$this->global_cfg['version']; 
     1010 
     1011                // Because every brand is an extension (eventually) of endpoint, you know this function will exist regardless of who it is 
     1012                //Start timer 
     1013                $time_start = microtime(true); 
     1014                $returned_data = $provisioner_lib->generate_config(); 
     1015                //End timer 
     1016                $time_end = microtime(true); 
     1017                $time = $time_end - $time_start; 
     1018                if($time > 360) { 
     1019                    $this->error['generate_time'] = "It took an awfully long time to generate configs...(".round($time,2)." seconds)"; 
     1020                } 
     1021                //Create Directory Structure (If needed) 
     1022                if(isset($provisioner_lib->directory_structure)) { 
     1023                    foreach($provisioner_lib->directory_structure as $data) { 
     1024                        $dir = $this->global_cfg['config_location'] . $data; 
     1025                        if(!file_exists($dir)) { 
     1026                            mkdir($dir, 0777); 
     1027                        } 
     1028                    } 
     1029                } 
     1030 
     1031                //Copy Files/Directories (If needed) 
     1032                if(isset($provisioner_lib->copy_files)) { 
     1033                    foreach($provisioner_lib->copy_files as $data) { 
     1034                        if(((file_exists($this->global_cfg['config_location'].$data)) AND (!in_array($data,$provisioner_lib->protected_files))) OR (!file_exists($this->global_cfg['config_location'].$data))) { 
     1035                            if(is_dir(PHONE_MODULES_PATH."endpoint/".$phone_info['directory']."/".$phone_info['cfg_dir']."/".$data)) { 
     1036                                if(!file_exists($this->global_cfg['config_location'].$data)) { 
     1037                                    if (!@mkdir($this->global_cfg['config_location'].$data, 0777)) { 
     1038                                        $this->error['parse_configs'] = "Could Not Create Directory: ".$data; 
     1039                                        return(FALSE); 
     1040                                    } 
     1041                                } 
     1042                                $dir_iterator = new RecursiveDirectoryIterator(PHONE_MODULES_PATH."endpoint/".$phone_info['directory']."/".$phone_info['cfg_dir']."/".$data."/"); 
     1043                                $iterator = new RecursiveIteratorIterator($dir_iterator, RecursiveIteratorIterator::SELF_FIRST); 
     1044                                // could use CHILD_FIRST if you so wish 
     1045                                foreach ($iterator as $file) { 
     1046                                    if(is_dir($file)) { 
     1047                                        $dir = str_replace(PHONE_MODULES_PATH."endpoint/".$phone_info['directory']."/".$phone_info['cfg_dir']."/".$data."/", "", $file); 
     1048                                        if(!file_exists($this->global_cfg['config_location'].$data."/".$dir)) { 
     1049                                            if (!@mkdir($this->global_cfg['config_location'].$data."/".$dir, 0777)) { 
     1050                                                $this->error['parse_configs'] = "Could Not Create Directory: ".$data."/".$dir; 
     1051                                                return(FALSE); 
     1052                                            } 
     1053                                        } 
     1054                                    } else { 
     1055                                        $dir = str_replace(PHONE_MODULES_PATH."endpoint/".$phone_info['directory']."/".$phone_info['cfg_dir']."/".$data."/", "", $file); 
     1056                                        if(!@copy($file, $this->global_cfg['config_location'].$data."/".$dir)) { 
     1057                                            $this->error['parse_configs'] = "Could Not Copy File: ".$data."/".$dir; 
     1058                                            return(FALSE); 
     1059                                        } else { 
     1060                                            chmod($this->global_cfg['config_location'].$data."/".$dir, 0777); 
     1061                                        } 
    10481062                                    } 
    10491063                                } 
    10501064                            } else { 
    1051                                 $dir = str_replace(PHONE_MODULES_PATH."endpoint/".$phone_info['directory']."/".$phone_info['cfg_dir']."/".$data."/", "", $file); 
    1052                                 if(!@copy($file, $this->global_cfg['config_location'].$data."/".$dir)) { 
    1053                                    $this->error['parse_configs'] = "Could Not Copy File: ".$data."/".$dir; 
    1054                                 } else { 
    1055                                     chmod($this->global_cfg['config_location'].$data."/".$dir, 0777); 
    1056                                 } 
     1065                                copy(PHONE_MODULES_PATH."endpoint/".$phone_info['directory']."/".$phone_info['cfg_dir']."/".$data,$this->global_cfg['config_location'].$data); 
     1066                                chmod($this->global_cfg['config_location'].$data, 0777); 
    10571067                            } 
    10581068                        } 
    1059                     } else { 
    1060                         copy(PHONE_MODULES_PATH."endpoint/".$phone_info['directory']."/".$phone_info['cfg_dir']."/".$data,$this->global_cfg['config_location'].$data); 
    1061                         chmod($this->global_cfg['config_location'].$data, 0777); 
    1062                     } 
    1063                 } 
    1064             } 
    1065         } 
    1066  
    1067         //Generate Files 
    1068         foreach($returned_data as $key => $data) { 
    1069             if(((file_exists($this->global_cfg['config_location'].$key)) AND (!in_array($key,$provisioner_lib->protected_files))) OR (!file_exists($this->global_cfg['config_location'].$key))) { 
    1070                 $fp = fopen($this->global_cfg['config_location'].$key, 'w'); 
    1071                 fwrite($fp, $data); 
    1072                 fclose($fp); 
    1073                 if(!file_exists($this->global_cfg['config_location'].$key)) { 
    1074                     $this->error['parse_configs'] = "File not written to hard drive!"; 
    1075                 } 
    1076             } 
    1077         } 
    1078         if($reboot) { 
    1079             $provisioner_lib->reboot(); 
     1069                    } 
     1070                } 
     1071 
     1072                //Generate Files 
     1073                foreach($returned_data as $key => $data) { 
     1074                    if(((file_exists($this->global_cfg['config_location'].$key)) AND (is_writable($this->global_cfg['config_location'].$key)) AND (!in_array($key,$provisioner_lib->protected_files))) OR (!file_exists($this->global_cfg['config_location'].$key))) { 
     1075                        $fp = fopen($this->global_cfg['config_location'].$key, 'w'); 
     1076                        fwrite($fp, $data); 
     1077                        fclose($fp); 
     1078                        if(!file_exists($this->global_cfg['config_location'].$key)) { 
     1079                            $this->error['parse_configs'] = "File not written to hard drive!"; 
     1080                            return(FALSE); 
     1081                        } 
     1082                    } elseif(!in_array($key,$provisioner_lib->protected_files)) { 
     1083                        $this->error['parse_configs'] = "File not written to hard drive!"; 
     1084                        return(FALSE); 
     1085                    } 
     1086                } 
     1087                if($reboot) { 
     1088                    $provisioner_lib->reboot(); 
     1089                } 
     1090                return(TRUE); 
     1091            } else { 
     1092                $this->error['parse_configs'] = "Can't Load \"".$class."\" Class!"; 
     1093                return(FALSE); 
     1094            } 
     1095        } else { 
     1096            $this->error['parse_configs'] = "Can't Load the Autoloader!"; 
     1097            return(FALSE); 
    10801098        } 
    10811099    } 
     
    15781596                $this->db->query($sql); 
    15791597 
    1580                 $this->sync_model($brand_id.$family_line_xml['data']['id'].$model_list['id']); 
     1598                if(!$this->sync_model($brand_id.$family_line_xml['data']['id'].$model_list['id'])) { 
     1599                    echo "System Error in Sync Model Function, Load Failure!<br />"; 
     1600                } 
    15811601            } 
    15821602        } 
     
    16181638     */ 
    16191639    function sync_model($model) { 
    1620  
    1621         //TODO: combine these queries 
    1622  
    1623         $sql = "SELECT * FROM  endpointman_model_list WHERE id='".$model."'"; 
    1624  
    1625         $model_row =& $this->db->getRow($sql, array(),DB_FETCHMODE_ASSOC); 
    1626  
    1627         $sql = "SELECT * FROM  endpointman_product_list WHERE id='".$model_row['product_id']."'"; 
    1628  
    1629         $product_row =& $this->db->getRow($sql, array(),DB_FETCHMODE_ASSOC); 
    1630  
    1631         $sql = "SELECT * FROM  endpointman_brand_list WHERE id=".$model_row['brand']; 
    1632  
    1633  
    1634         $brand_row =& $this->db->getRow($sql, array(),DB_FETCHMODE_ASSOC); 
    1635  
    1636         $family_line_xml = $this->xml2array(PHONE_MODULES_PATH.'/endpoint/'.$brand_row['directory'].'/'.$product_row['cfg_dir'].'/family_data.xml'); 
    1637  
    1638         if($product_row['cfg_ver'] <= $family_line_xml['data']['version']) { 
    1639             $key = $this->arraysearchrecursive($model_row['model'], $family_line_xml['data']['model_list'], 'model'); 
    1640  
    1641             if($key === FALSE) { 
    1642                 $this->error['sync_model'] = "Can't locate model in family XML file"; 
    1643                 return(FALSE); 
    1644             } else { 
    1645                 if(is_array($family_line_xml['data']['model_list'][$key[0]]['template_data']['files'])) { 
    1646                     $template_list = implode(",",$family_line_xml['data']['model_list'][$key[0]]['template_data']['files']); 
    1647                     $template_list_array = $family_line_xml['data']['model_list'][$key[0]]['template_data']['files']; 
     1640        if((!empty($model)) OR ($model > 0)) { 
     1641            $sql = "SELECT * FROM  endpointman_model_list WHERE id='".$model."'"; 
     1642 
     1643            $model_row =& $this->db->getRow($sql, array(),DB_FETCHMODE_ASSOC); 
     1644 
     1645            $sql = "SELECT * FROM  endpointman_product_list WHERE id='".$model_row['product_id']."'"; 
     1646 
     1647            $product_row =& $this->db->getRow($sql, array(),DB_FETCHMODE_ASSOC); 
     1648 
     1649            $sql = "SELECT * FROM  endpointman_brand_list WHERE id=".$model_row['brand']; 
     1650 
     1651 
     1652            $brand_row =& $this->db->getRow($sql, array(),DB_FETCHMODE_ASSOC); 
     1653 
     1654            $family_line_xml = $this->xml2array(PHONE_MODULES_PATH.'/endpoint/'.$brand_row['directory'].'/'.$product_row['cfg_dir'].'/family_data.xml'); 
     1655 
     1656            if($product_row['cfg_ver'] <= $family_line_xml['data']['version']) { 
     1657                $key = $this->arraysearchrecursive($model_row['model'], $family_line_xml['data']['model_list'], 'model'); 
     1658 
     1659                if($key === FALSE) { 
     1660                    $this->error['sync_model'] = "Can't locate model in family XML file"; 
     1661                    return(FALSE); 
    16481662                } else { 
    1649                     $template_list = $family_line_xml['data']['model_list'][$key[0]]['template_data']['files']; 
    1650                     $template_list_array[0] = $family_line_xml['data']['model_list'][$key[0]]['template_data']['files']; 
    1651                 } 
    1652             } 
    1653  
    1654             $sql = "UPDATE endpointman_model_list SET max_lines = '".$family_line_xml['data']['model_list'][$key[0]]['lines']."', template_list = '".$template_list."' WHERE id = '".$model."'"; 
    1655             $this->db->query($sql); 
    1656  
    1657             $version = $family_line_xml['data']['version']; 
    1658             $long_name = $family_line_xml['data']['name']; 
    1659             $short_name = preg_replace("/\[(.*?)\]/si", "", $family_line_xml['data']['name']); 
    1660             $configuration_files = $family_line_xml['data']['configuration_files']; 
    1661  
    1662             $sql = "UPDATE endpointman_product_list SET long_name = '".$template_list."', short_name = '".$short_name."' , cfg_ver = '".$version."', WHERE id = '".$product_row['id']."'"; 
    1663             $this->db->query($sql); 
    1664  
    1665             $template_data_array = array(); 
    1666             foreach($template_list_array as $data) { 
    1667                 if(file_exists(PHONE_MODULES_PATH.'/endpoint/'.$brand_row['directory'].'/'.$product_row['cfg_dir'].'/'.$data)) { 
    1668                     $template_data_xml = $this->xml2array(PHONE_MODULES_PATH.'/endpoint/'.$brand_row['directory'].'/'.$product_row['cfg_dir'].'/'.$data); 
    1669                     $template_data_xml = $this->fix_single_array_keys($template_data_xml['template_data']); 
    1670                     $template_data_array = array_merge($template_data_array, $template_data_xml); 
    1671                 } 
    1672             } 
    1673  
    1674             if (file_exists(PHONE_MODULES_PATH.'/endpoint/'.$brand_row['directory'].'/'.$product_row['cfg_dir'].'/template_data_custom.xml')) { 
    1675                 $template_data_multi = $this->xml2array(PHONE_MODULES_PATH.'/endpoint/'.$brand_row['directory'].'/'.$product_row['cfg_dir'].'/template_data_custom.xml'); 
    1676                 if($template_data_multi) { 
    1677                     $template_data_multi = $this->fix_single_array_keys($template_data_multi['template_data']['item']); 
    1678                     $template_data_array = array_merge($template_data_array, $template_data_multi); 
    1679                 } 
    1680             } 
    1681  
    1682             if (file_exists(PHONE_MODULES_PATH.'/endpoint/'.$brand_row['directory'].'/'.$product_row['cfg_dir'].'/template_data_' . $model_row['model'] . '_custom.xml')) { 
    1683                 $template_data_multi = $this->xml2array(self::$modules_path . $this->brand_name . "/" . $this->family_line . "/template_data_" . $this->model . "_custom.xml"); 
    1684                 if($template_data_multi) { 
    1685                     $template_data_multi = $this->fix_single_array_keys($template_data_multi['template_data']['item']); 
    1686                     $template_data_array = array_merge($template_data_array, $template_data_multi); 
    1687                 } 
    1688             } 
    1689  
    1690             if(empty($template_data_array)) { 
    1691                 $this->error['sync_model'] = "No Template Data Found"; 
    1692                 return(FALSE); 
    1693             } 
    1694  
    1695             $sql = "UPDATE endpointman_model_list SET template_data = '".serialize($template_data_array)."' WHERE id = '".$model."'"; 
    1696             $this->db->query($sql); 
    1697         } 
    1698  
    1699         return(TRUE); 
     1663                    if(is_array($family_line_xml['data']['model_list'][$key[0]]['template_data']['files'])) { 
     1664                        $template_list = implode(",",$family_line_xml['data']['model_list'][$key[0]]['template_data']['files']); 
     1665                        $template_list_array = $family_line_xml['data']['model_list'][$key[0]]['template_data']['files']; 
     1666                    } else { 
     1667                        $template_list = $family_line_xml['data']['model_list'][$key[0]]['template_data']['files']; 
     1668                        $template_list_array[0] = $family_line_xml['data']['model_list'][$key[0]]['template_data']['files']; 
     1669                    } 
     1670                } 
     1671 
     1672                $sql = "UPDATE endpointman_model_list SET max_lines = '".$family_line_xml['data']['model_list'][$key[0]]['lines']."', template_list = '".$template_list."' WHERE id = '".$model."'"; 
     1673                $this->db->query($sql); 
     1674 
     1675                $version = $family_line_xml['data']['version']; 
     1676                $long_name = $family_line_xml['data']['name']; 
     1677                $short_name = preg_replace("/\[(.*?)\]/si", "", $family_line_xml['data']['name']); 
     1678                $configuration_files = $family_line_xml['data']['configuration_files']; 
     1679 
     1680                $sql = "UPDATE endpointman_product_list SET long_name = '".$template_list."', short_name = '".$short_name."' , cfg_ver = '".$version."', WHERE id = '".$product_row['id']."'"; 
     1681                $this->db->query($sql); 
     1682 
     1683                $template_data_array = array(); 
     1684                foreach($template_list_array as $data) { 
     1685                    if(file_exists(PHONE_MODULES_PATH.'/endpoint/'.$brand_row['directory'].'/'.$product_row['cfg_dir'].'/'.$data)) { 
     1686                        $template_data_xml = $this->xml2array(PHONE_MODULES_PATH.'/endpoint/'.$brand_row['directory'].'/'.$product_row['cfg_dir'].'/'.$data); 
     1687                        $template_data_xml = $this->fix_single_array_keys($template_data_xml['template_data']); 
     1688                        $template_data_array = array_merge($template_data_array, $template_data_xml); 
     1689                    } 
     1690                } 
     1691 
     1692                if (file_exists(PHONE_MODULES_PATH.'/endpoint/'.$brand_row['directory'].'/'.$product_row['cfg_dir'].'/template_data_custom.xml')) { 
     1693                    $template_data_multi = $this->xml2array(PHONE_MODULES_PATH.'/endpoint/'.$brand_row['directory'].'/'.$product_row['cfg_dir'].'/template_data_custom.xml'); 
     1694                    if($template_data_multi) { 
     1695                        $template_data_multi = $this->fix_single_array_keys($template_data_multi['template_data']['item']); 
     1696                        $template_data_array = array_merge($template_data_array, $template_data_multi); 
     1697                    } 
     1698                } 
     1699 
     1700                if (file_exists(PHONE_MODULES_PATH.'/endpoint/'.$brand_row['directory'].'/'.$product_row['cfg_dir'].'/template_data_' . $model_row['model'] . '_custom.xml')) { 
     1701                    $template_data_multi = $this->xml2array(self::$modules_path . $this->brand_name . "/" . $this->family_line . "/template_data_" . $this->model . "_custom.xml"); 
     1702                    if($template_data_multi) { 
     1703                        $template_data_multi = $this->fix_single_array_keys($template_data_multi['template_data']['item']); 
     1704                        $template_data_array = array_merge($template_data_array, $template_data_multi); 
     1705                    } 
     1706                } 
     1707 
     1708                if(empty($template_data_array)) { 
     1709                    $this->error['sync_model'] = "No Template Data Found"; 
     1710                    return(FALSE); 
     1711                } 
     1712 
     1713                $sql = "UPDATE endpointman_model_list SET template_data = '".serialize($template_data_array)."' WHERE id = '".$model."'"; 
     1714                $this->db->query($sql); 
     1715            } 
     1716 
     1717            return(TRUE); 
     1718        } else { 
     1719            return(FALSE); 
     1720        } 
    17001721    } 
    17011722 
     
    22462267 
    22472268        if(!isset($temp)) { 
    2248             $this->error['modelsAvailable'] = "You need to enable at least ONE model"; 
     2269            if(!isset($this->global_cfg['new'])) { 
     2270                $this->error['modelsAvailable'] = "You need to enable at least ONE model"; 
     2271            } 
    22492272            return(FALSE); 
    22502273        } else { 
  • modules/branches/2.9/endpointman/includes/template_manager.inc

    r10797 r10947  
    5050    $endpoint->save_template($_REQUEST['id'],$_REQUEST['custom'],$_REQUEST); 
    5151    $default_display = TRUE; 
    52     $message = _('Saved'); 
     52    if(empty($endpoint->error)) { 
     53        $message = _('Saved'); 
     54    } 
    5355} else { 
    5456    $default_display = TRUE; 
  • modules/branches/2.9/endpointman/install/phonesettings.module

    r10800 r10947  
    206206                        " . $template . " 
    207207                        <br>". $button ."</form>"; 
     208                ini_set('display_errors', 0); 
    208209                return($ret); 
    209210            } else { 
    210211                $m = "phonesettings"; 
    211212                $ret = "<h3>This User/Extension has no settings defined for you to control, Please talk to your administrator</h3>"; 
     213                ini_set('display_errors', 0); 
    212214                return($ret); 
    213215            } 
     
    215217            $m = "phonesettings"; 
    216218            $ret = "<h3>This User/Extension is not managed by Endpoint Manager, Please talk to your administrator</h3>"; 
     219            ini_set('display_errors', 0); 
    217220            return($ret); 
    218221        } 
  • modules/branches/2.9/endpointman/templates/freepbx/advanced_settings_iedl.html

    r10792 r10947  
    1818<p>&lt;Mac&gt;, &lt;<?=_('Brand')?>&gt;, &lt;<?=_('Model')?>&gt;, &lt;<?=_('Extension')?>&gt;, &lt;<?=_('Line')?>&gt;</p> 
    1919<p><?=_('Brand')?>, <?=_('Model')?>, <?=_('Extension')?> &amp; <?=_('Line can be blank')?></p> 
     20<p><strong>Note:</strong>The Extensions need to be previously added into FreePBX before you import</p> 
  • modules/branches/2.9/endpointman/templates/freepbx/devices_manager.html

    r10797 r10947  
    11{include="global_header"} 
    22{if condition="isset($show_error_box)"} 
    3     {include="message_box"} 
     3{include="message_box"} 
    44{/if} 
    55<br> 
     
    1717        document.managed.submit(); 
    1818    } 
     19    function submit_wtype_managed(type,id) { 
     20        $('#managed').append('<input type="hidden" name="edit_id" value="'+ id +'"/><input type="hidden" name="sub_type" value="'+ type +'"/>'); 
     21        document.managed.submit(); 
     22    } 
    1923    function submit_unmanaged() { 
    2024        $('#unmanaged').append('<input type="hidden" name="sub_type" value="add_selected_phones"/>'); 
     
    4852    function popitup(url, name) { 
    4953        newwindow=window.open(url + '&model_list=' + document.getElementById('model_new').value + '&template_list=' + document.getElementById('template_list').value + '&rand=' + new Date().getTime(),'name2','height=1000,width=950'); 
    50             if (window.focus) {newwindow.focus()} 
    51             return false; 
     54        if (window.focus) {newwindow.focus()} 
     55        return false; 
    5256    } 
    5357</script> 
     
    7983        <td align='center'></td> 
    8084    </tr> 
     85        <form name="adding" id="adding" action='config.php{$web_var}&display=epm_devices' method='POST' /> 
     86 
    8187  {if condition="$no_add == FALSE"} 
    8288    <tr> 
    83     <form name="adding" id="adding" action='config.php{$web_var}&display=epm_devices' method='POST' /> 
    8489    <td align='center' width='2%'>&nbsp;</td> 
    8590 
     
    117122    <td align='center'></td> 
    118123    <td align='center'>  <div id="demo"><select name="template_list" id="template_list"> 
    119             {loop name="display_templates"} 
    120             <option value="{$value.value}" {if condition="isset($value.selected)"}selected{/if}>{$value.text}</option> 
    121             {/loop} 
    122         </select> 
     124                {loop name="display_templates"} 
     125                <option value="{$value.value}" {if condition="isset($value.selected)"}selected{/if}>{$value.text}</option> 
     126                {/loop} 
     127            </select> 
    123128            <a href="#" onclick="return popitup('config.php?display=epm_config&amp;quietmode=1&amp;handler=file&amp;file=popup.html.php&amp;module=endpointman&amp;pop_type=edit_template&amp;edit_id={$edit_id}', 'Template Editor')"><img src='{$web_path}templates/images/edit.png' title="Edit Template Selected on the Left"></a></div> 
    124129        </label></td> 
     
    157162    </td> 
    158163    <td align='center'></td> 
    159     <td align='center'>{if condition="!isset($disabled_delete_line)"}<div id="demo"><a href="javascript:submit_wtype_sub('edit',{$value.luid},'delete');"><img src="/admin/modules/endpointman/templates/images/delete.png" title="Delete Line from Device to the Left"></div>{/if}</a></td> 
     164    <td align='center'>{if condition="!isset($disabled_delete_line)"}<div id="demo"><a href="#" onclick="submit_wtype_sub('edit',{$value.luid},'delete');"><img src="/admin/modules/endpointman/templates/images/delete.png" title="Delete Line from Device to the Left"></div>{/if}</a></td> 
    160165    <td align='center'></td> 
    161166</tr> 
     
    196201    <td align='center'>&nbsp;</td> 
    197202    <td align='center'></td> 
    198     <td align='center'><div id="demo"><a href="javascript:submit_wtype_sub('edit',{$edit_id},'add_line_x');"><img src="/admin/modules/endpointman/templates/images/add.png" alt="Add Line" border="0" width="24" height="24" title="Add a Line to the device currently being edited"></a></div></td> 
     203    <td align='center'><div id="demo"><a href="#" onclick="submit_wtype_sub('edit',{$edit_id},'add_line_x');"><img src="/admin/modules/endpointman/templates/images/add.png" alt="Add Line" border="0" width="24" height="24" title="Add a Line to the device currently being edited"></a></div></td> 
    199204    <td align='center'></td> 
    200205</tr>  
     
    208213    <td align='center'>&nbsp;</td> 
    209214    <td align='center'></td> 
    210     <td align='center'><a href="javascript:add_line();"><img src="/admin/modules/endpointman/templates/images/add.png" alt="Add Line" border="0" width="24" height="24"></a></td> 
     215    <td align='center'><a href="#" onclick="add_line();"><img src="/admin/modules/endpointman/templates/images/add.png" alt="Add Line" border="0" width="24" height="24"></a></td> 
    211216    <td align='center'></td> 
    212217</tr> 
     
    301306  {loop name="list"} 
    302307        <tr class="headerRow"> 
    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> 
     308            <td align='center' ><div id="demo"><a><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="Click to Expand Line Information"><input type="checkbox" name="selected[]" value="{$value.id}"></a></div></td> 
    304309            <td align='center' width='11%'>{$value.mac}</td> 
    305310            <td width="13%" align='center'>{$value.name}</td> 
    306311            <td width="14%" align='center'>{$value.model}</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> 
     312            <td width="10%" align='center'><div id="demo"><a><img src="{$web_path}templates/images/expand.png" id="img2rowGroup{$value.master_id}" onclick="toggleDisplay(document.getElementById('devList'),'headerRow','rowGroup{$value.master_id}')" title="Click to Expand Line Information"></a></div></td> 
     313            <td width="19%" align='center'><div id="demo"><a><img src="{$web_path}templates/images/expand.png" id="img3rowGroup{$value.master_id}" onclick="toggleDisplay(document.getElementById('devList'),'headerRow','rowGroup{$value.master_id}')" title="Click to Expand Line Information"></a></div></td> 
    309314            <td align='center' width='15%'>{$value.template_name}</td> 
    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> 
    311             <td align='center' width='7%'><div id="demo"><a href='javascript:delete_device({$value.id});'><img src='{$web_path}templates/images/delete.png' ALT='<?=_('Delete')?>' title='Delete Device' border='0'></a></div></td> 
     315            <td align='center' width='9%'><div id="demo"><a href="#" onclick="submit_wtype('edit',{$value.id});"><img src='{$web_path}templates/images/edit.png' ALT='<?=_('Edit')?>' title='Edit Device' border='0'></a></div></td> 
     316            <td align='center' width='7%'><div id="demo"><a href="#" onclick="delete_device({$value.id});"><img src='{$web_path}templates/images/delete.png' ALT='<?=_('Delete')?>' title='Delete Device' border='0'></a></div></td> 
    312317        </tr> 
    313318        {loop name="value.line"} 
     
    321326            <td align='center' width='15%'></td> 
    322327            <td align='center' width='9%'></td> 
    323             <td align='center' width='7%'><div id="demo"><a href='javascript:submit_wtype("delete_line",{$value.luid});'><img src='{$web_path}templates/images/delete.png' ALT='<?=_('Delete')?>' title='Delete Line' border='0'></a></div></td> 
     328            <td align='center' width='7%'><div id="demo"><a href="#" onclick="submit_wtype('delete_line',{$value.luid});"><img src='{$web_path}templates/images/delete.png' ALT='<?=_('Delete')?>' title='Delete Line' border='0'></a></div></td> 
    324329        </tr> 
    325330        {/loop}