Changeset 10240

Show
Ignore:
Timestamp:
09/05/10 03:17:11 (3 years ago)
Author:
tm1000
Message:

EPM 2.2.7

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • contributed_modules/modules/endpointman/config.php

    r10233 r10240  
    1313} 
    1414 
    15 if(file_exists('/tftpboot')) { 
    16   if(!is_writeable('/tftpboot')) { 
    17     die(_('/tftpboot is not writable')); 
    18   } 
    19 } else { 
    20   die(_("Please create /tftpboot, even if you won't use it")); 
    21 
    22  
    23 if(phpversion < '5.0.0') { 
    24     die(_('PHP Version MUST be greater than 5!')); 
     15if(phpversion < '5.1.0') { 
     16    die(_('PHP Version MUST be greater than 5.1.0!')); 
    2517} 
    2618 
  • contributed_modules/modules/endpointman/includes/advanced.inc

    r10233 r10240  
    2323switch($_REQUEST['subpage']) { 
    2424    case "iedl": 
    25         $amp_serial = base64_encode(serialize($amp_conf)); 
    26         $amp_serial = base64_encode(serialize($amp_conf)); 
    27         $temp_amp['amp_serial'] = $amp_serial; 
    28         $temp_amp = base64_encode(serialize($temp_amp)); 
    29  
    3025        $tpl->assign("exporter_address", "config.php?type=tool&amp;display=epm_config&amp;quietmode=1&amp;handler=file&amp;file=export.html.php&amp;module=endpointman&amp;rand=".rand()); 
    3126        //Dave B's Q&D file upload security code (http://us2.php.net/manual/en/features.file-upload.php) 
     
    7368                                            $description = ''; 
    7469                                        } 
    75                                         $sql = "INSERT INTO  endpointman_mac_list (mac, model, ext, description) VALUES ('".$mac."','".$model_id."','".$ext."','".$description."')"; 
     70                                        $sql = "INSERT INTO  endpointman_mac_list (mac, model) VALUES ('".$mac."','".$model_id."')"; 
    7671                                        $endpoint->db->query($sql); 
     72 
     73                                        $sql = 'SELECT last_insert_id()'; 
     74                                        $ext_id =& $endpoint->db->getOne($sql); 
     75 
     76                                        $sql = "INSERT INTO `endpointman_line_list` (`mac_id`, `ext`, `line`, `description`) VALUES ('".$ext_id."', '".$ext."', '1','".$description."')"; 
     77                                        $endpoint->db->query($sql); 
     78                                         
    7779                                        $message .= "Inserted Mac Address ".$mac."<br/>"; 
    7880                                    } else { 
  • contributed_modules/modules/endpointman/includes/ajax_select.php

    r10218 r10240  
    2424} elseif ($_REQUEST['atype'] == "model_clone") { 
    2525        $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']."'"; 
     26}   elseif ($_REQUEST['atype'] == "lines") { 
     27        $sql = "SELECT max_lines FROM endpointman_model_list WHERE id = '". $_GET['id']."'"; 
    2628} 
    2729 
     
    3840} 
    3941 
    40 $result = $db->getAll($sql,array(), DB_FETCHMODE_ASSOC); 
     42if($_REQUEST['atype'] == "lines") { 
     43    $count = $db->getOne($sql); 
     44    for($z=0;$z<$count;$z++) { 
     45        $result[$z]['id'] = $z + 1; 
     46        $result[$z]['model'] = $z + 1; 
     47    } 
     48} else { 
     49    $result = $db->getAll($sql,array(), DB_FETCHMODE_ASSOC); 
     50
     51 
    4152 
    4253foreach($result as $row) { 
  • contributed_modules/modules/endpointman/includes/devices_manager.inc

    r10233 r10240  
    6868        } 
    6969 
    70         $sql = "INSERT INTO `endpointman_mac_list` (`mac`, `model`, `ext`, `description`, `custom_cfg_data`, `custom_cfg_template`) VALUES ('".$mac."', '".$_REQUEST['model_list']."', '".$_REQUEST['ext_list']."', '".$name."', '".$custom_cfg_data."', '".$_REQUEST['template_list']."')"; 
     70        $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']."')"; 
    7171        $endpoint->db->query($sql); 
    7272 
    73         $sql = 'SELECT id FROM endpointman_mac_list WHERE ext ='. $_REQUEST['ext_list']
     73        $sql = 'SELECT last_insert_id()'
    7474        $ext_id =& $endpoint->db->getOne($sql); 
     75 
     76        if(!isset($_REQUEST['line_list'])) { 
     77            $_REQUEST['line_list'] = 1; 
     78        } 
     79 
     80        $sql = "INSERT INTO `endpointman_line_list` (`mac_id`, `ext`, `line`, `description`) VALUES ('".$ext_id."', '".$_REQUEST['ext_list']."', '".$_REQUEST['line_list']."', '".$name."')"; 
     81        $endpoint->db->query($sql); 
    7582 
    7683        $mac_id = $endpoint->get_phone_info($ext_id); 
     
    104111    $name=$endpoint->db->getOne($sql); 
    105112 
    106     $sql = "UPDATE endpointman_mac_list SET custom_cfg_template = '".$_REQUEST['template_list']."', model = '".$_REQUEST['model_list']."', ext = ".$_REQUEST['ext_list'].", description = '".$name."' WHERE id =  ". $_REQUEST['edit_id']; 
     113    $sql = "UPDATE endpointman_mac_list SET template_id = '".$_REQUEST['template_list']."', model = '".$_REQUEST['model_list']."' WHERE id =  ". $_REQUEST['edit_id']; 
     114    $endpoint->db->query($sql); 
     115 
     116    $sql = "UPDATE endpointman_line_list SET ext = ".$_REQUEST['ext_list'].", description = '".$name."' WHERE mac_id =  ". $_REQUEST['edit_id']; 
    107117    $endpoint->db->query($sql); 
    108118 
     
    116126 
    117127    $sql = "DELETE FROM endpointman_mac_list WHERE id=".$_REQUEST['id']; 
     128    $endpoint->db->query($sql); 
     129    $sql = "DELETE FROM endpointman_line_list WHERE mac_id=".$_REQUEST['id']; 
    118130    $endpoint->db->query($sql); 
    119131} elseif((isset($_REQUEST['button_add_selected_phones'])) AND (isset($_REQUEST['add']))) { 
     
    122134        $num = $_REQUEST['add'][$i]; 
    123135        if($mac = $endpoint->mac_check_clean($_REQUEST['mac_'.$num])) { 
    124             $sql = "SELECT * FROM endpointman_mac_list WHERE ext = ".$_REQUEST['ext_list_'.$num]; 
     136            $sql = "SELECT * FROM endpointman_line_list WHERE ext = ".$_REQUEST['ext_list_'.$num]; 
    125137            $res =& $endpoint->db->query($sql); 
    126138            $count_macs = $res->numRows(); 
     
    130142 
    131143 
    132                 $sql = 'SELECT endpointman_product_list. * , endpointman_brand_list.directory FROM endpointman_model_list, endpointman_brand_list, endpointman_product_list WHERE endpointman_model_list.id =  \''.$_REQUEST['model_list_'.$num].'\' AND endpointman_model_list.brand = endpointman_brand_list.id AND endpointman_model_list.product_id = endpointman_product_list.id'; 
    133                 $row =& $endpoint->db->getAll($sql,array(),DB_FETCHMODE_ASSOC); 
    134  
    135  
    136                 $sql = "INSERT INTO `endpointman_mac_list` (`mac`, `model`, `ext`, `description`) VALUES ('".$mac."', '".$_REQUEST['model_list_'.$num]."', '".$_REQUEST['ext_list_'.$num]."', '".$name."')"; 
     144                //$sql = 'SELECT endpointman_product_list. * , endpointman_brand_list.directory FROM endpointman_model_list, endpointman_brand_list, endpointman_product_list WHERE endpointman_model_list.id =  \''.$_REQUEST['model_list_'.$num].'\' AND endpointman_model_list.brand = endpointman_brand_list.id AND endpointman_model_list.product_id = endpointman_product_list.id'; 
     145                //$row =& $endpoint->db->getAll($sql,array(),DB_FETCHMODE_ASSOC); 
     146 
     147 
     148                $sql = "INSERT INTO `endpointman_mac_list` (`mac`, `model`, `template_id`) VALUES ('".$mac."', '".$_REQUEST['model_list_'.$num]."', '0')"; 
    137149                $endpoint->db->query($sql); 
    138150 
    139                 $sql = 'SELECT id FROM endpointman_mac_list WHERE ext ='. $_REQUEST['ext_list_'.$num]; 
    140                 $mac_new_id =& $endpoint->db->getOne($sql,array(),DB_FETCHMODE_ASSOC); 
    141  
    142                 $row_new = $endpoint->get_phone_info($mac_new_id); 
     151                $sql = 'SELECT last_insert_id()'; 
     152                $ext_id =& $endpoint->db->getOne($sql); 
     153 
     154                if(!isset($_REQUEST['line_list_'.$num])) { 
     155                    $_REQUEST['line_list_'.$num] = 1; 
     156                } 
     157 
     158                $sql = "INSERT INTO `endpointman_line_list` (`mac_id`, `ext`, `line`, `description`) VALUES ('".$ext_id."', '".$_REQUEST['ext_list_'.$num]."', '".$_REQUEST['line_list_'.$num]."', '".$name."')"; 
     159                $endpoint->db->query($sql); 
     160 
     161                $row_new = $endpoint->get_phone_info($ext_id); 
    143162                $endpoint->prepare_configs($row_new); 
    144163  
     
    170189        foreach($_REQUEST['selected'] as $key => $data) { 
    171190            $sql = "DELETE FROM endpointman_mac_list WHERE id=".$_REQUEST['selected'][$key]; 
     191            $endpoint->db->query($sql); 
     192            $sql = "DELETE FROM endpointman_line_list WHERE mac_id=".$_REQUEST['selected'][$key]; 
    172193            $endpoint->db->query($sql); 
    173194        } 
     
    283304} 
    284305 
    285 $sql = 'SELECT endpointman_mac_list.id , endpointman_mac_list.mac , endpointman_model_list.model, endpointman_model_list.enabled , endpointman_mac_list.ext , endpointman_mac_list.description , endpointman_brand_list.name, endpointman_mac_list.custom_cfg_data, endpointman_mac_list.custom_cfg_template FROM endpointman_mac_list , endpointman_model_list , endpointman_brand_list WHERE ( endpointman_model_list.id = endpointman_mac_list.model ) AND ( endpointman_model_list.brand = endpointman_brand_list.id )'; 
     306$sql = 'SELECT endpointman_mac_list.id , endpointman_mac_list.mac , endpointman_model_list.model, endpointman_model_list.enabled , endpointman_brand_list.name, endpointman_mac_list.global_custom_cfg_data, endpointman_mac_list.template_id FROM endpointman_mac_list , endpointman_model_list , endpointman_brand_list WHERE ( endpointman_model_list.id = endpointman_mac_list.model ) AND ( endpointman_model_list.brand = endpointman_brand_list.id )'; 
    286307 
    287308$devices_list =& $endpoint->db->getAll($sql,array(),DB_FETCHMODE_ASSOC); 
     
    290311$i = 0; 
    291312$list = array(); 
    292 foreach($devices_list as $row) {  #Displays the phones in the database with edit and delete buttons 
    293     $list[$i] = $row; 
    294     if (($row['custom_cfg_template'] == 0) && (isset($row['custom_cfg_data'])) ) { 
    295         $list[$i]['template_name'] = "Custom-".$row['mac']; 
    296     } elseif((!isset($row['custom_cfg_data'])) && ($row['custom_cfg_template'] == 0)) { 
    297         $list[$i]['template_name'] = "N/A"; 
    298     } else { 
    299         $sql = "SELECT name FROM endpointman_template_list WHERE id =".$row['custom_cfg_template']; 
    300         $row2 =& $endpoint->db->getOne($sql); 
    301         $list[$i]['template_name'] = $row2; 
    302     } 
    303     if (!$row['enabled']) { 
    304         $list[$i]['model'] = $row['model']."<i>(Disabled)</i>"; 
     313foreach($devices_list as $devices_row) { 
     314    $sql = 'SELECT * FROM endpointman_line_list WHERE mac_id = '.$devices_row['id']; 
     315    $line_list =& $endpoint->db->getAll($sql,array(),DB_FETCHMODE_ASSOC); 
     316    $list[$i] = $devices_row; 
     317    $z = 0; 
     318    foreach($line_list as $line_row) { 
     319        $list[$i]['ext'] = $line_row['ext']; 
     320        $list[$i]['line'] = $line_row['line']; 
     321        $list[$i]['description'] = $line_row['description']; 
     322        if (($devices_row['template_id'] == 0) && (isset($devices_row['global_custom_cfg_data'])) ) { 
     323            $list[$i]['template_name'] = "Custom-".$devices_row['mac']; 
     324        } elseif((!isset($devices_row['custom_cfg_data'])) && ($devices_row['template_id'] == 0)) { 
     325            $list[$i]['template_name'] = "N/A"; 
     326        } else { 
     327            $sql = "SELECT name FROM endpointman_template_list WHERE id =".$devices_row['template_id']; 
     328            $template_name =& $endpoint->db->getOne($sql); 
     329            $list[$i]['template_name'] = $template_name; 
     330        } 
     331        if (!$devices_row['enabled']) { 
     332            $list[$i]['model'] = $devices_row['model']."<i>(Disabled)</i>"; 
     333        } 
     334        $z++; 
    305335    } 
    306336    $i++; 
     
    375405            $tpl->assign("models_ava", $ma); 
    376406            $tpl->assign("display_ext", $endpoint->displayExtension($edit_row['ext'])); 
    377             $tpl->assign("display_templates", $endpoint->display_templates($edit_row['product_id'],$edit_row['custom_cfg_template'])); 
     407            $tpl->assign("display_templates", $endpoint->display_templates($edit_row['product_id'],$edit_row['template_id'])); 
    378408            $tpl->assign("edit_id", $edit_row['id']); 
    379409        } else { 
  • contributed_modules/modules/endpointman/includes/export.php

    r10219 r10240  
    1818$outstream = fopen("php://output",'w'); 
    1919 
    20 $sql = 'SELECT endpointman_mac_list.mac, endpointman_brand_list.name, endpointman_model_list.model, endpointman_mac_list.ext FROM endpointman_mac_list, endpointman_model_list, endpointman_brand_list WHERE endpointman_model_list.id = endpointman_mac_list.model AND endpointman_model_list.brand = endpointman_brand_list.id'; 
     20$sql = 'SELECT endpointman_mac_list.mac, endpointman_brand_list.name, endpointman_model_list.model, endpointman_line_list.ext FROM endpointman_mac_list, endpointman_model_list, endpointman_brand_list, endpointman_line_list WHERE endpointman_line_list.mac_id = endpointman_mac_list.id AND endpointman_model_list.id = endpointman_mac_list.model AND endpointman_model_list.brand = endpointman_brand_list.id'; 
    2121 
    2222$result = $endpoint->db->getAll($sql,array(),DB_FETCHMODE_ASSOC); 
  • contributed_modules/modules/endpointman/includes/functions.inc

    r10233 r10240  
    157157        if($res->numRows()) { 
    158158            //Returns Brand Name, Brand Directory, Model Name, Mac Address, Extension (FreePBX), Custom Configuration Template, Custom Configuration Data, Product Name, Product ID, Product Configuration Directory, Product Configuration Version, Product XML name, 
    159             $sql = "SELECT endpointman_mac_list.config_files_override, endpointman_mac_list.user_cfg_data, endpointman_model_list.id as model_id, endpointman_brand_list.id as brand_id, endpointman_brand_list.name, endpointman_brand_list.directory, endpointman_model_list.model, endpointman_mac_list.mac, endpointman_mac_list.ext, endpointman_mac_list.custom_cfg_template, endpointman_mac_list.custom_cfg_data, endpointman_product_list.long_name, endpointman_product_list.id as product_id, endpointman_product_list.cfg_dir, endpointman_product_list.cfg_ver, endpointman_model_list.template_data, endpointman_model_list.enabled, users.name as description, sip.data as secret FROM endpointman_mac_list, endpointman_model_list, endpointman_brand_list, endpointman_product_list, sip, users WHERE endpointman_mac_list.id = ".$mac_id." AND endpointman_mac_list.model = endpointman_model_list.id AND endpointman_brand_list.id = endpointman_model_list.brand AND endpointman_product_list.id = endpointman_model_list.product_id AND endpointman_mac_list.ext = sip.id AND sip.keyword = 'secret' AND endpointman_mac_list.ext = users.extension"
     159            $sql = "SELECT endpointman_mac_list.config_files_override, endpointman_mac_list.global_user_cfg_data, endpointman_model_list.id as model_id, endpointman_brand_list.id as brand_id, endpointman_brand_list.name, endpointman_brand_list.directory, endpointman_model_list.model, endpointman_mac_list.mac, endpointman_line_list.ext, endpointman_mac_list.template_id, endpointman_mac_list.global_custom_cfg_data, endpointman_product_list.long_name, endpointman_product_list.id as product_id, endpointman_product_list.cfg_dir, endpointman_product_list.cfg_ver, endpointman_model_list.template_data, endpointman_model_list.enabled, users.name as description, sip.data as secret FROM endpointman_line_list, endpointman_mac_list, endpointman_model_list, endpointman_brand_list, endpointman_product_list, sip, users WHERE endpointman_mac_list.model = endpointman_model_list.id AND endpointman_brand_list.id = endpointman_model_list.brand AND endpointman_product_list.id = endpointman_model_list.product_id AND endpointman_line_list.ext = sip.id AND sip.keyword = 'secret' AND endpointman_line_list.ext = users.extension AND endpointman_mac_list.id = endpointman_line_list.mac_id AND endpointman_mac_list.id = ". $mac_id
    160160 
    161161            $phone_info =& $this->db->getRow($sql, array(), DB_FETCHMODE_ASSOC); 
     
    166166 
    167167            //If there is a template associated with this phone then pull that information and put it into the array 
    168             if ($phone_info['custom_cfg_template'] > 0) { 
    169                 $sql = "SELECT name, custom_cfg_data, config_files_override FROM endpointman_template_list WHERE id = ".$phone_info['custom_cfg_template']; 
     168            if ($phone_info['template_id'] > 0) { 
     169                $sql = "SELECT name, global_custom_cfg_data, config_files_override FROM endpointman_template_list WHERE id = ".$phone_info['template_id']; 
    170170 
    171171                $phone_info['template_data'] =& $this->db->getRow($sql, array(), DB_FETCHMODE_ASSOC); 
     
    217217        //Determine if we are dealing with a general template or a specific [for that phone only] template (custom =0 means general) 
    218218        if($custom == 0) { 
    219             $sql = "SELECT endpointman_model_list.model as model_name, endpointman_product_list.config_files, endpointman_product_list.short_name, endpointman_product_list.id as product_id, endpointman_model_list.template_data, endpointman_model_list.id as model_id, endpointman_template_list.* FROM endpointman_product_list, endpointman_model_list, endpointman_template_list WHERE endpointman_product_list.id = endpointman_template_list.product_id AND endpointman_template_list.model_id = endpointman_model_list.id AND endpointman_template_list.id = ".$id; 
    220         } else { 
    221             $sql = "SELECT endpointman_model_list.model as model_name, endpointman_product_list.config_files, endpointman_mac_list.*, endpointman_model_list.id as model_id, endpointman_model_list.template_data, endpointman_product_list.id as product_id, endpointman_product_list.short_name, 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"; 
     219            $sql = "SELECT endpointman_model_list.model as model_name, endpointman_template_list.global_custom_cfg_data,  endpointman_product_list.config_files, endpointman_product_list.short_name, endpointman_product_list.id as product_id, endpointman_model_list.template_data, endpointman_model_list.id as model_id, endpointman_template_list.* FROM endpointman_product_list, endpointman_model_list, endpointman_template_list WHERE endpointman_product_list.id = endpointman_template_list.product_id AND endpointman_template_list.model_id = endpointman_model_list.id AND endpointman_template_list.id = ".$id; 
     220        } else { 
     221            $sql = "SELECT endpointman_model_list.model as model_name, endpointman_mac_list.global_custom_cfg_data, endpointman_product_list.config_files, endpointman_mac_list.*, endpointman_line_list.*, endpointman_model_list.id as model_id, endpointman_model_list.template_data, endpointman_product_list.id as product_id, endpointman_product_list.short_name, endpointman_product_list.cfg_dir, endpointman_brand_list.directory FROM endpointman_brand_list, endpointman_mac_list, endpointman_model_list, endpointman_product_list, endpointman_line_list WHERE endpointman_mac_list.id=".$id." AND endpointman_mac_list.id = endpointman_line_list.mac_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"; 
    222222        } 
    223223 
     
    241241            $tpl->assign("models_ava", $ma); 
    242242        } 
     243 
     244        $tpl->assign("area_ava", $this->areaAvailable($row['model_id'])); 
    243245        //Start the display of the html file in the product folder 
    244246        if($row['config_files_override'] == "") { 
     
    278280 
    279281        if($row['template_data'] != "") { 
    280             $out = $this->generate_gui_html($row['template_data'],$row['custom_cfg_data'],TRUE); 
     282            $out = $this->generate_gui_html($row['template_data'],$row['global_custom_cfg_data'],TRUE); 
    281283        } else { 
    282284            echo "No Template Data has been defined for this Product<br />"; 
     
    312314            //No custom template so let's pull the default values for this model into the custom_cfg_data array and populate it from there so that we won't have to make two completely different functions below 
    313315            foreach($cfg_data as $key => $data) { 
    314                 if(($data['type'] != 'group') && ($data['type'] != 'break')) { 
     316                if(($data['type'] != 'group') && ($data['type'] != 'break') && ($data['type'] != 'loop')) { 
    315317                    $key_default = str_replace('$','',$data['variable']); 
    316318                    if(!is_array($data['default_value'])) { 
     
    350352                    $template_variables_array[$group_count]['title'] = $cfg_data[$i]['description']; 
    351353                    $variables_count = 0; 
    352                 } elseif ($cfg_data[$i]['type'] == "input") { 
    353                     if((!$admin) && (isset($user_cfg_data[$key]['value']))) { 
    354                         $custom_cfg_data[$key]['value'] = $user_cfg_data[$key]['value']; 
    355                     } 
    356                     $template_variables_array[$group_count]['data'][$variables_count]['type'] = "input"; 
    357                     $template_variables_array[$group_count]['data'][$variables_count]['key'] = $key; 
    358                     $template_variables_array[$group_count]['data'][$variables_count]['value'] = $custom_cfg_data[$key]['value']; 
    359                     $template_variables_array[$group_count]['data'][$variables_count]['description'] = $cfg_data[$i]['description']; 
    360                 } elseif ($cfg_data[$i]['type'] == "radio") { 
    361                     if((!$admin) && (isset($user_cfg_data[$key]['value']))) { 
    362                         $custom_cfg_data[$key]['value'] = $user_cfg_data[$key]['value']; 
    363                     } 
    364                     $num = $custom_cfg_data[$key]['value']; 
    365                     $template_variables_array[$group_count]['data'][$variables_count]['type'] = "radio"; 
    366                     $template_variables_array[$group_count]['data'][$variables_count]['key'] = $key; 
    367                     $template_variables_array[$group_count]['data'][$variables_count]['description'] = $cfg_data[$i]['description']; 
    368                     $z = 0; 
    369                     while($z < count($cfg_data[$i]['data'])) { 
    370                         $template_variables_array[$group_count]['data'][$variables_count]['data'][$z]['key'] = $key; 
    371                         $template_variables_array[$group_count]['data'][$variables_count]['data'][$z]['value'] = $cfg_data[$i]['data'][$z]['value']; 
    372                         $template_variables_array[$group_count]['data'][$variables_count]['data'][$z]['description'] = $cfg_data[$i]['data'][$z]['text']; 
    373                         if ($cfg_data[$i]['data'][$z]['value'] == $num) { 
    374                             $template_variables_array[$group_count]['data'][$variables_count]['data'][$z]['checked'] = 'checked'; 
     354                } elseif ($cfg_data[$i]['type'] == "loop") { 
     355                    $group_count++; 
     356                    $template_variables_array[$group_count]['title'] = $cfg_data[$i]['description']; 
     357                    $loop_start = $cfg_data[$i]['loop_start']; 
     358                    $loop_end = $cfg_data[$i]['loop_end']; 
     359                    $variables_count = 0; 
     360                    for($a=$loop_start;$a<=$loop_end;$a++) { 
     361                        foreach($cfg_data[$i]['data']['item'] as $items) { 
     362                            if(isset($items['description'])) { 
     363                                $items['description'] = str_replace('{$count}',$a,$items['description']); 
     364                                $key = str_replace('$','',$items['variable'])."_".$a; 
     365                                if(array_key_exists($key,$custom_cfg_data)) { 
     366                                    $custom_cfg_data[$key]['value'] = $custom_cfg_data[$key][$a]; 
     367                                } else { 
     368                                    $custom_cfg_data[$key]['value'] = ''; 
     369                                } 
     370                            } 
     371                            $items[$i] = $items; 
     372                            $template_variables_array[$group_count]['data'][$variables_count] = $this->generate_form_data($i,$items,$key,$custom_cfg_data); 
     373                            $template_variables_array[$group_count]['data'][$variables_count]['looping'] = TRUE; 
     374                            $variables_count++; 
    375375                        } 
    376                         $z++; 
    377                     } 
    378                 } elseif ($cfg_data[$i]['type'] == "list") { 
    379                     if((!$admin) && (isset($user_cfg_data[$key]['value']))) { 
    380                         $custom_cfg_data[$key]['value'] = $user_cfg_data[$key]['value']; 
    381                     } 
    382                     $num = $custom_cfg_data[$key]['value']; 
    383                     $template_variables_array[$group_count]['data'][$variables_count]['type'] = "list"; 
    384                     $template_variables_array[$group_count]['data'][$variables_count]['key'] = $key; 
    385                     $template_variables_array[$group_count]['data'][$variables_count]['description'] = $cfg_data[$i]['description']; 
    386                     $z = 0; 
    387                     while($z < count($cfg_data[$i]['data'])) { 
    388                         $template_variables_array[$group_count]['data'][$variables_count]['data'][$z]['value'] = $cfg_data[$i]['data'][$z]['value']; 
    389                         $template_variables_array[$group_count]['data'][$variables_count]['data'][$z]['description'] = $cfg_data[$i]['data'][$z]['text']; 
    390                         if ($cfg_data[$i]['data'][$z]['value'] == $num) { 
    391                             $template_variables_array[$group_count]['data'][$variables_count]['data'][$z]['selected'] = 'selected'; 
    392                         } 
    393                         $z++; 
    394                     } 
    395                 } elseif ($cfg_data[$i]['type'] == "break") { 
    396                     $template_variables_array[$group_count]['data'][$variables_count]['type'] = "break"; 
    397                 } 
    398                 if(($this->global_cfg['enable_ari']) AND ($admin) AND ($cfg_data[$i]['type'] != "break") AND ($cfg_data[$i]['type'] != "group")) { 
    399                     $template_variables_array[$group_count]['data'][$variables_count]['aried'] = 1; 
    400                     $template_variables_array[$group_count]['data'][$variables_count]['ari']['key'] = $key; 
    401                     if(isset($custom_cfg_data[$key]['ari'])) { 
    402                         $template_variables_array[$group_count]['data'][$variables_count]['ari']['checked'] = "checked"; 
    403                     } 
    404                 } 
    405                 $variables_count++; 
     376                    } 
     377                } else { 
     378                    $template_variables_array[$group_count]['data'][$variables_count] = $this->generate_form_data($i,$cfg_data,$key,$custom_cfg_data); 
     379                    $variables_count++; 
     380                } 
    406381            } 
    407382        } 
    408383        return($template_variables_array); 
    409384    } 
     385 
     386function generate_form_data ($i,$cfg_data,$key,$custom_cfg_data) { 
     387    $admin = TRUE; 
     388    if ($cfg_data[$i]['type'] == "input") { 
     389        if((!$admin) && (isset($user_cfg_data[$key]['value']))) { 
     390            $custom_cfg_data[$key]['value'] = $user_cfg_data[$key]['value']; 
     391        } 
     392        $template_variables_array['type'] = "input"; 
     393        $template_variables_array['key'] = $key; 
     394        $template_variables_array['value'] = $custom_cfg_data[$key]['value']; 
     395        $template_variables_array['description'] = $cfg_data[$i]['description']; 
     396    } elseif ($cfg_data[$i]['type'] == "radio") { 
     397        if((!$admin) && (isset($user_cfg_data[$key]['value']))) { 
     398            $custom_cfg_data[$key]['value'] = $user_cfg_data[$key]['value']; 
     399        } 
     400        $num = $custom_cfg_data[$key]['value']; 
     401        $template_variables_array['type'] = "radio"; 
     402        $template_variables_array['key'] = $key; 
     403        $template_variables_array['description'] = $cfg_data[$i]['description']; 
     404        $z = 0; 
     405        while($z < count($cfg_data[$i]['data'])) { 
     406            $template_variables_array['data'][$z]['key'] = $key; 
     407            $template_variables_array['data'][$z]['value'] = $cfg_data[$i]['data'][$z]['value']; 
     408            $template_variables_array['data'][$z]['description'] = $cfg_data[$i]['data'][$z]['text']; 
     409            if ($cfg_data[$i]['data'][$z]['value'] == $num) { 
     410                $template_variables_array['data'][$z]['checked'] = 'checked'; 
     411            } 
     412            $z++; 
     413        } 
     414    } elseif ($cfg_data[$i]['type'] == "list") { 
     415        if((!$admin) && (isset($user_cfg_data[$key]['value']))) { 
     416            $custom_cfg_data[$key]['value'] = $user_cfg_data[$key]['value']; 
     417        } 
     418        $num = $custom_cfg_data[$key]['value']; 
     419        $template_variables_array['type'] = "list"; 
     420        $template_variables_array['key'] = $key; 
     421        $template_variables_array['description'] = $cfg_data[$i]['description']; 
     422        $z = 0; 
     423        while($z < count($cfg_data[$i]['data'])) { 
     424            $template_variables_array['data'][$z]['value'] = $cfg_data[$i]['data'][$z]['value']; 
     425            $template_variables_array['data'][$z]['description'] = $cfg_data[$i]['data'][$z]['text']; 
     426            if ($cfg_data[$i]['data'][$z]['value'] == $num) { 
     427                $template_variables_array['data'][$z]['selected'] = 'selected'; 
     428            } 
     429            $z++; 
     430        } 
     431    } elseif ($cfg_data[$i]['type'] == "break") { 
     432        $template_variables_array['type'] = "break"; 
     433    } 
     434    if(($this->global_cfg['enable_ari']) AND ($admin) AND ($cfg_data[$i]['type'] != "break") AND ($cfg_data[$i]['type'] != "group")) { 
     435        $template_variables_array['aried'] = 1; 
     436        $template_variables_array['ari']['key'] = $key; 
     437        if(isset($custom_cfg_data[$key]['ari'])) { 
     438            $template_variables_array['ari']['checked'] = "checked"; 
     439        } 
     440    } 
     441    return($template_variables_array); 
     442} 
    410443 
    411444    function save_template($id, $custom, $variables) { 
    412445        //Custom Means specific to that MAC 
    413         if($custom == "0") { 
     446        //This function is reversed. Not sure why 
     447        if($custom != "0") { 
     448            $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"; 
     449        } else { 
    414450            $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; 
    415         } else { 
    416             $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"; 
    417451        } 
    418452 
     
    434468                    } 
    435469                } 
     470            } elseif ($cfg_data[$i]['type'] == 'loop') { 
     471                $loop_start = $cfg_data[$i]['loop_start']; 
     472                $loop_end = $cfg_data[$i]['loop_end']; 
     473                $variables_count = 0; 
     474                for($a=$loop_start;$a<=$loop_end;$a++) { 
     475                    foreach($cfg_data[$i]['data']['item'] as $items) { 
     476                        if(isset($items['description'])) { 
     477                            $items['description'] = str_replace('{$count}',$a,$items['description']); 
     478                            $temping = str_replace('$','',$items['variable'])."_".$a; 
     479                            $temping_ari = "ari_" . $temping; 
     480                            if(array_key_exists($temping, $_REQUEST)) { 
     481                                $custom_cfg_data[$temping][$a] = $_REQUEST[$temping]; 
     482                                if(array_key_exists($temping_ari, $_REQUEST)) { 
     483                                    if($_REQUEST[$temping_ari] == "on") { 
     484                                        $custom_cfg_data[$temping]['ari'] = 1; 
     485                                    } 
     486                                } 
     487                            } 
     488                        } 
     489                    } 
     490                } 
    436491            } 
    437492        } 
     
    456511 
    457512        if($custom == "0") { 
    458             $sql = 'UPDATE endpointman_template_list SET config_files_override = \''.addslashes($config_files_selected).'\', custom_cfg_data = \''.addslashes($save).'\' WHERE id ='.$id; 
     513            $sql = 'UPDATE endpointman_template_list SET config_files_override = \''.addslashes($config_files_selected).'\', global_custom_cfg_data = \''.addslashes($save).'\' WHERE id ='.$id; 
    459514            $location = "template_manager"; 
    460515        } else { 
    461             $sql = 'UPDATE endpointman_mac_list SET config_files_override = \''.addslashes($config_files_selected).'\', custom_cfg_template = 0, custom_cfg_data = \''.addslashes($save).'\' WHERE id ='.$id; 
     516            $sql = 'UPDATE endpointman_mac_list SET config_files_override = \''.addslashes($config_files_selected).'\', template_id = 0, global_custom_cfg_data = \''.addslashes($save).'\' WHERE id ='.$id; 
    462517            $location = "devices_manager"; 
    463518        } 
     519   
    464520        $this->db->query($sql); 
    465521 
     
    471527 
    472528        } else { 
    473             $sql = 'SELECT id FROM endpointman_mac_list WHERE custom_cfg_template = '.$id; 
     529            $sql = 'SELECT id FROM endpointman_mac_list WHERE template_id = '.$id; 
    474530            $phones = $this->db->getAll($sql, array(), DB_FETCHMODE_ASSOC); 
    475531            foreach($phones as $data) { 
     
    535591 
    536592        if(is_array($phone_info['template_data'])) { 
    537             $template_data = unserialize($phone_info['template_data']['custom_cfg_data']); 
    538         } else { 
    539             $template_data = unserialize($phone_info['custom_cfg_data']); 
    540         } 
    541  
     593            $template_data = unserialize($phone_info['template_data']['global_custom_cfg_data']); 
     594        } else { 
     595            $template_data = unserialize($phone_info['global_custom_cfg_data']); 
     596        } 
    542597        $new_template_data = array(); 
    543598        if(is_array($template_data)) { 
    544599            foreach($template_data as $key => $data) { 
    545                 $new_template_data = array_merge($new_template_data, array($key => $data['value'])); 
     600                if(array_key_exists('value', $data)) { 
     601                    $new_template_data[$key] = $data['value']; 
     602                } else { 
     603                    $key = explode('_',$key); 
     604                    $new_template_data[$key[0]][$key[2]][$key[1]] = $data[$key[2]]; 
     605                } 
    546606            } 
    547607        } 
     
    616676                fwrite($fp, $data); 
    617677                fclose($fp); 
     678                if(!file_exists($this->global_cfg['config_location'].$key)) { 
     679                    $this->error['parse_configs'] = "File not written to hard drive!"; 
     680                } 
    618681            } 
    619682        } 
    620683        $provisioner_lib->reboot(); 
    621  
    622684    } 
    623685 
     
    9391001                $short_name = preg_replace("/\[(.*?)\]/si", "", $family_line_xml['data']['name']); 
    9401002                if($data) { 
    941                     $sql = "UPDATE endpointman_product_list SET short_name = '".$short_name."', long_name = '".$family_line_xml['data']['name']."', cfg_ver = '".$family_line_xml['data']['version']."', config_files='".$family_line_xml['data']['configuration_files']."', hidden = '0' WHERE id = '".$brand_id.$family_line_xml['data']['id']."'"; 
     1003                    $sql = "UPDATE endpointman_product_list SET short_name = '".$short_name."', long_name = '".$family_line_xml['data']['name']."', cfg_ver = '".$family_line_xml['data']['version']."', config_files='".$family_line_xml['data']['configuration_files']."' WHERE id = '".$brand_id.$family_line_xml['data']['id']."'"; 
    9421004                } else { 
    9431005                    $sql = "INSERT INTO endpointman_product_list (`id`, `brand`, `short_name`, `long_name`, `cfg_dir`, `cfg_ver`, `config_files`, `hidden`) VALUES ('".$brand_id.$family_line_xml['data']['id']."', '".$brand_id."', '".$short_name."', '".$family_line_xml['data']['name']."', '".$family_line_xml['data']['directory']."', '".$family_line_xml['data']['version']."','".$family_line_xml['data']['configuration_files']."', '0')"; 
     
    9531015                        $template_list = $model_list['template_data']['files']; 
    9541016                    } 
    955                     $m_data =& $this->db->getOne("SELECT id FROM endpointman_model_list WHERE id='".$brand_id.$family_line_xml['data']['id']."-".$model_list['id']."'", array(), DB_FETCHMODE_ASSOC); 
     1017                    $m_data =& $this->db->getOne("SELECT id FROM endpointman_model_list WHERE id='".$brand_id.$family_line_xml['data']['id'].$model_list['id']."'", array(), DB_FETCHMODE_ASSOC); 
    9561018                    if($m_data) { 
    957                         $sql = "UPDATE endpointman_model_list SET model = '".$model_list['model']."', template_list = '".$template_list."', enabled = '0', hidden = '0' WHERE id = '".$brand_id.$family_line_xml['data']['id']."'"; 
     1019                        $sql = "UPDATE endpointman_model_list SET max_lines = '".$model_list['lines']."', model = '".$model_list['model']."', template_list = '".$template_list."' WHERE id = '".$brand_id.$family_line_xml['data']['id'].$model_list['id']."'"; 
    9581020                    } else { 
    959                         $sql = "INSERT INTO endpointman_model_list (`id`, `brand`, `model`, `product_id`, `template_list`, `enabled`, `hidden`) VALUES ('".$brand_id.$family_line_xml['data']['id'].$model_list['id']."', '".$brand_id."', '".$model_list['model']."', '".$brand_id.$family_line_xml['data']['id']."', '".$template_list."', '0', '0')"; 
     1021                        $sql = "INSERT INTO endpointman_model_list (`id`, `brand`, `model`, `max_lines`, `product_id`, `template_list`, `enabled`, `hidden`) VALUES ('".$brand_id.$family_line_xml['data']['id'].$model_list['id']."', '".$brand_id."', '".$model_list['model']."', '".$model_list['lines']."', '".$brand_id.$family_line_xml['data']['id']."', '".$template_list."', '0', '0')"; 
    9601022                    } 
    9611023                    $this->db->query($sql); 
     
    14951557        } 
    14961558    } 
     1559    function areaAvailable($model,$area=NULL) { 
     1560 
     1561        $temp[0]['value'] = 'GLOBAL'; 
     1562        $temp[0]['text'] = 'GLOBAL'; 
     1563        $temp[0]['selected'] = 0; 
     1564 
     1565        $temp[1]['value'] = 'ALL'; 
     1566        $temp[1]['text'] = 'ALL LINES'; 
     1567        $temp[1]['selected'] = 0; 
     1568 
     1569        $sql = "SELECT max_lines FROM endpointman_model_list WHERE id = '". $model."'"; 
     1570 
     1571        $count = $this->db->getOne($sql); 
     1572        for($z=0;$z<$count;$z++) { 
     1573            $result[$z]['id'] = $z + 1; 
     1574            $result[$z]['model'] = $z + 1; 
     1575        } 
     1576 
     1577        $i = 2; 
     1578        foreach($result as $row) { 
     1579            if ($row['id'] == $model) { 
     1580                $temp[$i]['value'] = $row['id']; 
     1581                $temp[$i]['text'] = 'Line '.$row['model']; 
     1582                $temp[$i]['selected'] = 'selected'; 
     1583            }else { 
     1584                $temp[$i]['value'] = $row['id']; 
     1585                $temp[$i]['text'] = 'Line '.$row['model']; 
     1586                $temp[$i]['selected'] = 0; 
     1587            } 
     1588            $i++; 
     1589        } 
     1590 
     1591        return($temp); 
     1592    } 
    14971593 
    14981594    function modelsAvailable($model=NULL, $macAdd=NULL, $brand=NULL, $product=NULL) { 
     
    15351631    } 
    15361632 
     1633    function linesAvailable($model=NULL, $macid=NULL) { 
     1634 
     1635        if(isset($model)) { 
     1636            $sql="SELECT  `max_lines` FROM  `endpointman_model_list` WHERE  `id` LIKE"; 
     1637        } 
     1638 
     1639 
     1640        $result1 =& $this->db->getAll($sql, array(),DB_FETCHMODE_ASSOC); 
     1641 
     1642        $i = 1; 
     1643        foreach($result1 as $row) { 
     1644            if ($row['id'] == $model) { 
     1645                $temp[$i]['value'] = $row['id']; 
     1646                $temp[$i]['text'] = $row['model']; 
     1647                $temp[$i]['selected'] = 'selected'; 
     1648            }else { 
     1649                $temp[$i]['value'] = $row['id']; 
     1650                $temp[$i]['text'] = $row['model']; 
     1651                $temp[$i]['selected'] = 0; 
     1652            } 
     1653            $i++; 
     1654        } 
     1655 
     1656        if(!isset($temp)) { 
     1657            $this->error['modelsAvailable'] = "You need to enable at least ONE model"; 
     1658            return(FALSE); 
     1659        } else { 
     1660            return($temp); 
     1661        } 
     1662    } 
     1663 
    15371664    function displayExtension($ext = NULL) { 
    15381665        if(!isset($ext)) { 
    1539             $not_added="SELECT devices.id, devices.description FROM devices WHERE tech='sip' AND devices.id not in (SELECT devices.id FROM devices, endpointman_mac_list WHERE tech='sip' AND devices.id = endpointman_mac_list.ext ) ORDER BY devices.id"; 
    1540         } else { 
    1541             $not_added="SELECT devices.id, devices.description FROM devices WHERE tech='sip' AND devices.id not in (SELECT devices.id FROM devices, endpointman_mac_list WHERE tech='sip' AND devices.id = endpointman_mac_list.ext AND endpointman_mac_list.ext !=".$ext." ) ORDER BY devices.id"; 
     1666            $not_added="SELECT devices.id, devices.description FROM devices WHERE tech='sip' AND devices.id not in (SELECT devices.id FROM devices, endpointman_line_list WHERE tech='sip' AND devices.id = endpointman_line_list.ext ) ORDER BY devices.id"; 
     1667        } else { 
     1668            $not_added="SELECT devices.id, devices.description FROM devices WHERE tech='sip' AND devices.id not in (SELECT devices.id FROM devices, endpointman_line_list WHERE tech='sip' AND devices.id = endpointman_line_list.ext AND endpointman_line_list.ext !=".$ext." ) ORDER BY devices.id"; 
    15421669        } 
    15431670        $result =& $this->db->getAll($not_added,array(), DB_FETCHMODE_ASSOC); 
  • contributed_modules/modules/endpointman/includes/template_manager.inc

    r10233 r10240  
    6969    } 
    7070 
    71     $sql = 'SELECT endpointman_mac_list.id,endpointman_mac_list.mac,endpointman_mac_list.model,endpointman_mac_list.description, endpointman_model_list.model as model_clone, endpointman_product_list.short_name as model_class FROM endpointman_mac_list, endpointman_model_list, endpointman_product_list WHERE endpointman_product_list.id = endpointman_model_list.product_id AND endpointman_mac_list.custom_cfg_data IS NOT NULL AND endpointman_model_list.id = endpointman_mac_list.model AND endpointman_mac_list.custom_cfg_template = 0'; 
     71    $sql = 'SELECT endpointman_mac_list.id, endpointman_mac_list.mac, endpointman_mac_list.model, endpointman_line_list.description, endpointman_model_list.model as model_clone, endpointman_product_list.short_name as model_class FROM endpointman_mac_list, endpointman_model_list, endpointman_product_list, endpointman_line_list WHERE endpointman_mac_list.id = endpointman_line_list.mac_id AND endpointman_product_list.id = endpointman_model_list.product_id AND endpointman_mac_list.global_custom_cfg_data IS NOT NULL AND endpointman_model_list.id = endpointman_mac_list.model AND endpointman_mac_list.template_id = 0'; 
    7272    $template_list =& $db->getAll($sql, array(), DB_FETCHMODE_ASSOC); 
    7373    foreach($template_list as $row) { 
  • contributed_modules/modules/endpointman/install.php

    r10233 r10240  
    9393} 
    9494 
    95 $version = "2.2.6"; 
     95$version = "2.2.7"; 
    9696 
    9797if(ep_table_exists("endpointman_global_vars")) { 
     
    139139} elseif($global_cfg['version'] == '2.2.6') { 
    140140    $ver = "2.2.6"; 
     141} elseif($global_cfg['version'] == '2.2.7') { 
     142    $ver = "2.2.7"; 
    141143} else { 
    142144    $ver = "1000"; 
     
    785787} 
    786788 
     789if ($ver <= "2.2.6") { 
     790    $sql = "CREATE TABLE IF NOT EXISTS `endpointman_line_list` ( 
     791  `luid` int(11) NOT NULL AUTO_INCREMENT, 
     792  `mac_id` int(11) NOT NULL, 
     793  `line` smallint(2) NOT NULL, 
     794  `ext` varchar(15) NOT NULL, 
     795  `description` varchar(20) NOT NULL, 
     796  `custom_cfg_data` longblob NOT NULL, 
     797  `user_cfg_data` longblob NOT NULL, 
     798  PRIMARY KEY (`luid`) 
     799) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;"; 
     800    $db->query($sql); 
     801 
     802    $data = array(); 
     803    $data =& $db->getAll("SELECT * FROM endpointman_mac_list",array(), DB_FETCHMODE_ASSOC); 
     804    foreach($data as $list) { 
     805        $sql = "INSERT INTO endpointman_line_list (mac_id, line, ext, description) VALUES ('".$list['id']."', '1', '".$list['ext']."', '".$list['description']."')"; 
     806        $db->query($sql); 
     807    } 
     808 
     809    $sql = 'ALTER TABLE `endpointman_custom_configs` CHANGE `data` `data` LONGBLOB NOT NULL'; 
     810    $db->query($sql); 
     811 
     812    $sql = 'ALTER TABLE `endpointman_mac_list` DROP `description`'; 
     813    $db->query($sql); 
     814 
     815    $sql = 'ALTER TABLE `endpointman_mac_list` DROP `ext`'; 
     816    $db->query($sql); 
     817 
     818    $sql = 'ALTER TABLE `endpointman_mac_list` CHANGE `custom_cfg_template` `template_id` INT(11) NOT NULL'; 
     819    $db->query($sql); 
     820 
     821    $sql = 'ALTER TABLE `endpointman_mac_list` CHANGE `cfg_template_data` `global_template_id` LONGBLOB NOT NULL'; 
     822    $db->query($sql); 
     823 
     824    $sql = 'ALTER TABLE `endpointman_mac_list` CHANGE `user_cfg_data` `global_user_cfg_data` LONGBLOB NOT NULL'; 
     825    $db->query($sql); 
     826 
     827    $sql = 'ALTER TABLE `endpointman_model_list` ADD `max_lines` SMALLINT(2) NOT NULL AFTER `model`;'; 
     828    $db->query($sql); 
     829 
     830    $sql = 'ALTER TABLE `endpointman_model_list` CHANGE `template_data` `template_data` LONGBLOB NOT NULL'; 
     831    $db->query($sql); 
     832 
     833    $sql = 'ALTER TABLE `endpointman_template_list` CHANGE `custom_cfg_data` `global_custom_cfg_data` LONGBLOB NULL DEFAULT NULL'; 
     834    $db->query($sql); 
     835 
     836    $sql = 'ALTER TABLE `endpointman_mac_list` CHANGE `custom_cfg_data` `global_custom_cfg_data` LONGBLOB NOT NULL'; 
     837    $db->query($sql); 
     838 
     839} 
     840 
     841if ($ver <= "2.2.7") { 
     842 
     843} 
     844 
    787845 
    788846 
     
    800858                ) ENGINE=MyISAM DEFAULT CHARSET=latin1"; 
    801859        $db->query($sql); 
     860 
     861        out("Creating Line List Table"); 
     862 
     863        $sql = "CREATE TABLE IF NOT EXISTS `endpointman_line_list` ( 
     864  `luid` int(11) NOT NULL AUTO_INCREMENT, 
     865  `mac_id` int(11) NOT NULL, 
     866  `line` smallint(2) NOT NULL, 
     867  `ext` varchar(15) NOT NULL, 
     868  `description` varchar(20) NOT NULL, 
     869  `custom_cfg_data` longblob NOT NULL, 
     870  `user_cfg_data` longblob NOT NULL, 
     871  PRIMARY KEY (`luid`) 
     872) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;"; 
     873    $db->query($sql); 
    802874 
    803875        out("Creating Global Variables Table"); 
     
    837909        out("Creating mac list Table"); 
    838910        $sql = "CREATE TABLE IF NOT EXISTS `endpointman_mac_list` ( 
    839           `id` int(10) NOT NULL AUTO_INCREMENT, 
    840           `mac` varchar(12) DEFAULT NULL, 
    841           `model` varchar(11) NOT NULL, 
    842           `ext` varchar(15) DEFAULT 'Not Assigned', 
    843           `description` varchar(20) DEFAULT NULL, 
    844           `custom_cfg_template` int(11) NOT NULL, 
    845           `custom_cfg_data` blob NOT NULL, 
    846           `user_cfg_data` blob NOT NULL, 
    847           `config_files_override` text NOT NULL, 
    848           PRIMARY KEY (`id`), 
    849           UNIQUE KEY `mac` (`mac`) 
    850         ) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1"; 
     911  `id` int(10) NOT NULL AUTO_INCREMENT, 
     912  `mac` varchar(12) DEFAULT NULL, 
     913  `model` varchar(11) NOT NULL, 
     914  `template_id` int(11) NOT NULL, 
     915  `global_custom_cfg_data` longblob NOT NULL, 
     916  `global_user_cfg_data` blob NOT NULL, 
     917  `config_files_override` text NOT NULL, 
     918  PRIMARY KEY (`id`), 
     919  UNIQUE KEY `mac` (`mac`) 
     920) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1"; 
    851921        $db->query($sql); 
    852922 
    853923        out("Creating model List Table"); 
    854924        $sql = "CREATE TABLE IF NOT EXISTS `endpointman_model_list` ( 
    855           `id` varchar(11) NOT NULL COMMENT 'Key ', 
    856           `brand` int(11) NOT NULL COMMENT 'Brand', 
    857           `model` varchar(25) NOT NULL COMMENT 'Model', 
    858           `template_list` text NOT NULL, 
    859           `template_data` blob NOT NULL, 
    860           `product_id` varchar(11) NOT NULL, 
    861           `enabled` int(1) NOT NULL DEFAULT '0', 
    862           `hidden` int(1) NOT NULL DEFAULT '0', 
    863           PRIMARY KEY (`id`) 
    864         ) ENGINE=MyISAM DEFAULT CHARSET=latin1"; 
     925  `id` varchar(11) NOT NULL COMMENT 'Key ', 
     926  `brand` int(11) NOT NULL COMMENT 'Brand', 
     927  `model` varchar(25) NOT NULL COMMENT 'Model', 
     928  `max_lines` smallint(2) NOT NULL, 
     929  `template_list` text NOT NULL, 
     930  `template_data` longblob NOT NULL, 
     931  `product_id` varchar(11) NOT NULL, 
     932  `enabled` int(1) NOT NULL DEFAULT '0', 
     933  `hidden` int(1) NOT NULL DEFAULT '0', 
     934  PRIMARY KEY (`id`) 
     935) ENGINE=MyISAM DEFAULT CHARSET=latin1"; 
    865936        $db->query($sql); 
    866937 
     
    878949        out("Creating product List Table"); 
    879950        $sql = "CREATE TABLE IF NOT EXISTS `endpointman_product_list` ( 
    880           `id` varchar(11) NOT NULL, 
    881           `brand` int(11) NOT NULL, 
    882           `long_name` varchar(255) NOT NULL, 
    883           `short_name` varchar(255) NOT NULL, 
    884           `cfg_dir` varchar(255) NOT NULL, 
    885           `cfg_ver` varchar(255) NOT NULL, 
    886           `hidden` int(1) NOT NULL DEFAULT '0', 
    887           `firmware_vers` varchar(255) NOT NULL, 
    888           `firmware_files` text NOT NULL, 
    889           `config_files` text, 
    890           `special_cfgs` blob NOT NULL, 
    891           PRIMARY KEY (`id`) 
    892         ) ENGINE=MyISAM DEFAULT CHARSET=latin1;"; 
     951  `id` varchar(11) NOT NULL, 
     952  `brand` int(11) NOT NULL, 
     953  `long_name` varchar(255) NOT NULL, 
     954  `short_name` varchar(255) NOT NULL, 
     955  `cfg_dir` varchar(255) NOT NULL, 
     956  `cfg_ver` varchar(255) NOT NULL, 
     957  `hidden` int(1) NOT NULL DEFAULT '0', 
     958  `firmware_vers` varchar(255) NOT NULL, 
     959  `firmware_files` text NOT NULL, 
     960  `config_files` text, 
     961  `special_cfgs` blob NOT NULL, 
     962  PRIMARY KEY (`id`) 
     963) ENGINE=MyISAM DEFAULT CHARSET=latin1"; 
    893964        $db->query($sql); 
    894965 
    895966        out("Creating Template List Table"); 
    896967        $sql = "CREATE TABLE IF NOT EXISTS `endpointman_template_list` ( 
    897           `id` int(11) NOT NULL AUTO_INCREMENT, 
    898           `product_id` varchar(11) NOT NULL, 
    899           `model_id` varchar(10) NOT NULL, 
    900           `name` varchar(255) NOT NULL, 
    901           `custom_cfg_data` blob, 
    902           `config_files_override` text, 
    903           PRIMARY KEY (`id`) 
    904         ) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1"; 
     968  `id` int(11) NOT NULL AUTO_INCREMENT, 
     969  `product_id` varchar(11) NOT NULL, 
     970  `model_id` varchar(10) NOT NULL, 
     971  `name` varchar(255) NOT NULL, 
     972  `global_custom_cfg_data` longblob, 
     973  `config_files_override` text, 
     974  PRIMARY KEY (`id`) 
     975) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1"; 
    905976        $db->query($sql); 
    906977 
  • contributed_modules/modules/endpointman/module.xml

    r10238 r10240  
    1919        </changelog> 
    2020  <info>http://projects.colsolgrp.net/projects/show/endpointman</info> 
    21   <location>contributed_modules/release/endpointman-2.2.6.tgz</location> 
     21  <location>contributed_modules/release/endpointman-2.0.0.tgz</location> 
    2222 
    23 <md5sum>cc4c2f4d8ce1eb5ddcfffd000449dd43</md5sum> 
     23<md5sum>b1341a35ef60d0fad17348803a0a7833</md5sum> 
    2424</module> 
  • contributed_modules/modules/endpointman/templates/devices_manager.html

    r10233 r10240  
    2323<table align='center' width='90%'> 
    2424  <tr> 
    25 <td align='center' width='5px'></td> 
    26 <td width="11%" align='center'><h3><?=_('Mac Address')?></h3></td> 
    27 <td width="13%" align='center'><h3><?=_('Brand')?></h3></td> 
    28 <td width="25%" align='center'><h3><?=_('Model of Phone')?></h3></td> 
    29 <td width="19%" align='center'><h3><?=_('Extension Number')?></h3></td> 
    30 <td width="18%" align='center'><h3><?=_('Template')?></h3></td> 
    31  
    32 <td width="9%" align='center'></td> 
     25<td align='center' width='45'></td> 
     26<td width="157" align='center'><h3><?=_('Mac Address')?></h3></td> 
     27<td width="187" align='center'><h3><?=_('Brand')?></h3></td> 
     28<td width="216" align='center'><h3><?=_('Model of Phone')?></h3></td> 
     29<td width="172" align='center'><h3><?=_('Line')?></h3></td> 
     30<td width="275" align='center'><h3><?=_('Extension Number')?></h3></td> 
     31<td width="154" align='center'><h3><?=_('Template')?></h3></td> 
     32 
     33<td width="234" align='center'></td> 
    3334</tr><tr> 
    3435  {if condition="$no_add == FALSE"} 
    3536  <form action='config.php{$web_var}&display=epm_devices' method='POST'> 
    36    <td align='center' width='5px'><input type="checkbox" name="checkbox" id="checkbox" disabled></td> 
    37      
     37            <td align='center' width='2%'>&nbsp;</td> 
     38 
    3839<td align='center'> 
    3940  {if condition="$mode == 'EDIT'"} 
     
    5354  {/if} 
    5455</td> 
    55 <td align='center'>   
     56<td align='center'> 
    5657  <label> 
    5758  {if condition="$mode == 'EDIT'"} 
     
    6465    </select> 
    6566  {else} 
    66  <select name="model_list" id="model_new"><option></option></select> 
    67   {/if}  
     67        <select name="model_list" id="model_new"><option></option></select> 
     68  {/if} 
    6869  </label></td> 
    69 <td align='center'>  
     70<td align='center'> 
     71  <label> 
     72  {if condition="$mode == 'EDIT'"} 
     73        <select name="line_list" id="line_list" disabled> 
     74            <option value="1">1</option> 
     75        </select> 
     76  {else} 
     77        <select name="line_list" id="line_list" disabled><option></option></select> 
     78  {/if} 
     79  </label></td> 
     80<td align='center'> 
    7081    <select name="ext_list" id="select"> 
    7182    {loop name="display_ext"} 
     
    89100</td> 
    90101{$edit} 
    91 <td width="5%" align='center'><input type='reset' value='<?=_('Reset')?>'></td> 
     102<td align='center'><input type='reset' value='<?=_('Reset')?>'></td> 
    92103</tr> 
    93104</table> 
     
    99110    <td align='center'>&nbsp;</td> 
    100111    <td align='center'>&nbsp;</td> 
    101    <td align='center'>&nbsp;</td> 
    102     <td colspan="2" align='center'><h3><?=_('Unmanaged Extensions')?></h3></td> 
     112          <td align='center'>&nbsp;</td> 
     113    <td colspan="3" align='center'><h3><?=_('Unmanaged Extensions')?></h3></td> 
    103114    <td align='center'>&nbsp;</td> 
    104115    <td align='center'>&nbsp;</td> 
     
    111122    <input name="mac_{$value.id}" type="hidden" value="{$value.mac_strip}"> 
    112123    <tr> 
    113     <td align='center' width='5px'><input type="checkbox" name="add[]" value="{$value.id}"></td> 
    114     <td align='center' width='11%'>{$value.mac_strip}<br />({$value.ip})</td> 
    115     <td width="13%" align='center'>{$value.brand}</td> 
    116     <td width="25%" align='center'> 
    117    
     124    <td align='center' width='20'><input type="checkbox" name="add[]" value="{$value.id}"></td> 
     125    <td align='center' width='148'>{$value.mac_strip}<br />({$value.ip})</td> 
     126    <td width="188" align='center'>{$value.brand}</td> 
     127    <td width="216" align='center'> 
     128 
    118129    <select name="model_list_{$value.id}"> 
    119      
     130 
    120131      {loop name="value.list"} 
    121        
     132 
    122133      <option value="{$value.id}">{$value.model}</option> 
    123      
     134 
    124135        {/loop} 
    125      
     136 
    126137      </select></td> 
    127     <td width="19%" align='center'> 
     138                      <td width="141" align='center'> 
     139                                    <select name="line_list_{$value.id}" id="line_list" disabled> 
     140                                        <option value="1">1</option> 
     141                                    </select> 
     142                                </td> 
     143 
     144    <td width="276" align='center'> 
    128145      <select name="ext_list_{$value.id}" id="ext"> 
    129      
     146 
    130147      {loop name="display_ext"} 
    131        
     148 
    132149      <option value="{$value.value}">{$value.text}</option> 
    133      
     150 
    134151        {/loop} 
    135      
     152 
    136153      </select></td> 
    137     <td align='center' width='18%'>&nbsp;</td> 
    138     <td align='center' width='9%'></td> 
    139     <td align='center' width='5%'>&nbsp;</td> 
     154    <td align='center' width='220'>&nbsp;</td> 
     155    <td align='center' width='154'></td> 
     156    <td align='center' width='73'>&nbsp;</td> 
    140157    </tr> 
    141158    {/loop} 
     
    154171<table width='90%' align='center'> 
    155172  <tr> 
    156     <td align='center'>&nbsp;</td> 
    157     <td align='center'>&nbsp;</td> 
    158     <td align='center'>&nbsp;</td> 
    159     <td colspan="2" align='center'><h3><?=_('Current Managed Extensions')?></h3></td> 
    160    <td align='center'>&nbsp;</td> 
     173    <td width="2%" align='center'>&nbsp;</td> 
     174    <td align='center'>&nbsp;</td> 
     175    <td align='center'>&nbsp;</td> 
     176    <td colspan="3" align='center'><h3><?=_('Current Managed Extensions')?></h3></td> 
     177          <td align='center'>&nbsp;</td> 
    161178    <td align='center'><h3>Edit</h3></td> 
    162179    <td align='center'><h3>Delete</h3></td> 
     
    165182  {loop name="list"} 
    166183  <tr> 
    167   <td align='center' width='5px'><input type="checkbox" name="selected[]" value="{$value.id}"></td> 
     184  <td align='center' ><input type="checkbox" name="selected[]" value="{$value.id}"></td> 
    168185  <td align='center' width='11%'>{$value.mac}</td> 
    169186  <td width="13%" align='center'>{$value.name}</td> 
    170   <td width="25%" align='center'>{$value.model}</td> 
     187  <td width="14%" align='center'>{$value.model}</td> 
     188        <td width="10%" align='center'>{$value.line}</td> 
    171189  <td width="19%" align='center'>{$value.ext} - {$value.description}</td> 
    172   <td align='center' width='18%'>{$value.template_name}</td> 
     190  <td align='center' width='15%'>{$value.template_name}</td> 
    173191  <td align='center' width='9%'><a href=config.php?type=tool&display=epm_devices&editready=true&display=epm_devices&id={$value.id}><img src='{$web_path}templates/images/edit.gif' ALT='<?=_('Edit')?>' border='0'></a></td> 
    174   <td align='center' width='5%'><a href=config.php?type=tool&display=epm_devices&deleteready=true&display=epm_devices&id={$value.id}><img src='{$web_path}templates/images/delete.gif' ALT='<?=_('Delete')?>' border='0'></a></td> 
     192  <td align='center' width='7%'><a href=config.php?type=tool&display=epm_devices&deleteready=true&display=epm_devices&id={$value.id}><img src='{$web_path}templates/images/delete.gif' ALT='<?=_('Delete')?>' border='0'></a></td> 
    175193  </tr> 
    176194  {/loop} 
    177195</table> 
     196 
    178197<hr> 
    179198<center> 
     
    211230  <option value="{$value.value}">{$value.text}</option> 
    212231  {/loop} 
    213 </select> <?=_('with')?>   
     232</select> <?=_('with')?> 
    214233  <label> 
    215234    <select name="template_selector" id="template_selector"> 
    216235      <option></option> 
    217     </select>  
     236    </select> 
    218237    <input type="submit" name="button_rebuild_reboot" value="<?=_('Rebuild & Reboot')?>"> 
    219238  </label></td> 
  • contributed_modules/modules/endpointman/templates/global_header.html

    r10218 r10240  
    6262          $("#template_list").html(options); 
    6363          $('#template_list option:first').attr('selected', 'selected'); 
    64         }) 
     64        }), 
     65                                $.ajaxSetup({ cache: false }); 
     66                                $.getJSON("config.php?type=tool&quietmode=1&handler=file&module=endpointman&file=ajax_select.html.php&atype=lines",{id: $(this).val()}, function(j){ 
     67                                        var options = ''; 
     68                                        for (var i = 0; i < j.length; i++) { 
     69                                                options += '<option value="' + j[i].optionValue + '">' + j[i].optionDisplay + '</option>'; 
     70                                        } 
     71                                        $("#line_list").html(options); 
     72                                        $('#line_list option:first').attr('selected', 'selected'); 
     73                                }) 
    6574      })       
    6675    }) 
     76 
    6777    $(function(){ 
    6878      $("select#brand_list_selected").change(function(){ 
     
    94104  {/if} 
    95105</head> 
    96 <body face="Arial" onload="focus();displaymac.mac.focus()"
     106<body face="Arial"
    97107<br> 
    98108<h1><face="Arial"><center><?=_('End Point Configuration Manager')?></center></h1> 
  • contributed_modules/modules/endpointman/templates/template_editor.html

    r10233 r10240  
    2020        <strong><?=_('Template Name')?>:</strong> <i>Custom Template: Extension {$ext}</i><br /> 
    2121        <strong><?=_('Product Line')?>:</strong> {$product}<br /> 
    22         <strong><?=_('Clone of Model')?>:</strong> {$model} 
     22        <strong><?=_('Clone of Model')?>:</strong> {$model}<br /> 
     23        <strong><?=_('Area')?>:</strong> 
     24        <select name="area_list" disabled> 
     25        {loop name="area_ava"} 
     26        <option value="{$value.value}" {if condition="!empty($value.selected)"}selected{/if}>{$value.text}</option> 
     27        {/loop} 
     28        </select> 
    2329  {/if} 
    2430  {if condition="$custom == 0"} 
     
    2834        <select name="model_list"> 
    2935        {loop name="models_ava"} 
     36        <option value="{$value.value}" {if condition="!empty($value.selected)"}selected{/if}>{$value.text}</option> 
     37        {/loop} 
     38        </select> 
     39        <strong><?=_('Area')?>:</strong> 
     40        <select name="area_list"> 
     41        {loop name="area_ava"} 
    3042        <option value="{$value.value}" {if condition="!empty($value.selected)"}selected{/if}>{$value.text}</option> 
    3143        {/loop} 
     
    6375                                    <td nowrap> 
    6476            {if condition="$value.type == 'input'"} 
     77                                                 
    6578                                        <label>{$value.description}: <input type='text' name='{$value.key}' value='{$value.value}' size="40"></label> 
    6679            {elseif condition="$value.type == 'radio'"} 
  • contributed_modules/modules/endpointman/uninstall.php

    r9907 r10240  
    5454$result = $db->query($sql); 
    5555 
     56$sql = "DROP TABLE `endpointman_line_list`"; 
     57$result = $db->query($sql); 
     58 
    5659$sql = "DROP TABLE `endpointman_model_list`"; 
    5760$result = $db->query($sql);