xyj70 / fusionpbx

Automatically exported from code.google.com/p/fusionpbx
0 stars 0 forks source link

Provisioning: individual templates per tennant in mt-environments (w/ Patch) #249

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
not sure if this is the cleanest way to do this, but I needed a way to do 
per-tennant templates for phone provisioning.
I also added snom's MAC-prefix.

if there is no fusionpbx/includes/templates/provision/$DOMAIN directory, 
neither provisioning, nor the edit form for hardware phones is changed. But if 
there IS such a folder, it becomes the root for templates assigned to phones 
when asking for provisioning and for the select-field in hardware phones' edit 
form.

At least this did the trick for me:

/var/www/fusionpbx/app# svn diff provision/index.php 
hardware_phones/v_hardware_phones_edit.php 
Index: provision/index.php
===================================================================
--- provision/index.php (revision 2533)
+++ provision/index.php (working copy)
@@ -32,6 +32,10 @@
    $tmp_array = '';
    $phone_template = '';

+// get requested domain name for multi-tennant provisioning
+   $domain_array = explode(":", $_SERVER["HTTP_HOST"]);
+   $domain_name = $domain_array[0];
+
 //get any system -> variables defined in the 'provision;
    $sql .= "select * from v_vars ";
    $sql .= "where var_enabled = 'true' ";
@@ -169,6 +173,9 @@
            case "00-15-65":
                $phone_vendor = "yealink";
                break;
+           case "00-04-13":
+               $phone_vendor = "snom";
+               break;
            default:
                $phone_vendor = "";
            }
@@ -176,7 +183,8 @@
        //use the user_agent to pre-assign a template for 1-hit provisioning. Enter the a unique string to match in the user agent, and the template it should match.
            $template_list=array(  
                    "Linksys/SPA-2102"=>"linksys/spa2102",
-                   "Linksys/SPA-3102"=>"linksys/spa3102"
+                   "Linksys/SPA-3102"=>"linksys/spa3102",
+                   "snom370"=>"snom/370"
                    );

            foreach ($template_list as $key=>$val){
@@ -219,6 +227,12 @@
            unset($sql);
    }

+
+// if tennant provisioning directory exists, only use templates from this 
tennant
+   if 
(is_dir($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/includes/templates/provision/$d
omain_name")) {
+       $phone_template=$domain_name."/".$phone_template;
+   }
+
 //if $file is not provided then look for a default file that exists
    if (strlen($file) == 0) { 
        if (file_exists($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/includes/templates/provision/".$phone_template ."/{v_mac}")) {
@@ -397,4 +411,4 @@
    }
 }

-?>
\ No newline at end of file
+?>
Index: hardware_phones/v_hardware_phones_edit.php
===================================================================
--- hardware_phones/v_hardware_phones_edit.php  (revision 2533)
+++ hardware_phones/v_hardware_phones_edit.php  (working copy)
@@ -269,7 +269,11 @@

    echo "<select id='phone_template' name='phone_template' class='formfld'>\n";
    echo "<option value=''></option>\n";
-   $temp_dir = 
$_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/includes/templates/provision";
+   if 
(is_dir($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/includes/templates/provision/".
$_SESSION["domain_name"])) {
+       $temp_dir = 
$_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/includes/templates/provision/".$_SESSIO
N["domain_name"];
+   } else {
+       $temp_dir = 
$_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/includes/templates/provision";
+   }
    if($dh = opendir($temp_dir)) {
        while($dir = readdir($dh)) {
            if($file != "." && $dir != ".." && $dir[0] != '.') {

Regards,

  Johannes Jakob / irrwitzer

Original issue reported on code.google.com by lists...@googlemail.com on 10 May 2012 at 12:26

GoogleCodeExporter commented 9 years ago
Great suggestion will add the code soon.

Original comment by markjcrane@gmail.com on 11 Jul 2012 at 11:03

GoogleCodeExporter commented 9 years ago
Thanks for the great suggestion I have added the domain based provisioning 
templates and the snom change "snom370"=>"snom/370" the other snom change was 
in the current code base.

Original comment by markjcrane@gmail.com on 29 Apr 2013 at 2:49