Changeset 4557

Show
Ignore:
Timestamp:
07/27/07 15:29:10 (1 year ago)
Author:
p_lindheimer
Message:

#2168 fix intercom, #2165 change module to get rid of first time propagation moving all the old inti stuff into install.php. Fix requires core be up to date for some phones because of the SIPPADDHEADER change

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • modules/branches/2.3/paging/functions.inc.php

    r4402 r4557  
    77   check for version upgrades, etc, of the paging database, to 
    88   allow for easy upgrades. */ 
    9  
    10 function paging_init() { 
    11         global $db; 
    12          
    13         // Check to make sure that install.sql has been run 
    14         $sql = "SELECT * from paging_overview"; 
    15         $results = $db->getAssoc($sql); 
    16          
    17         if (DB::IsError($results)) { 
    18                 // It couldn't locate the table. This is bad. Lets try to re-create it, just 
    19                 // in case the user has had the brilliant idea to delete it.  
    20                 // in 2.2, replace this with just runModuleSQL which is in admin/functions.inc.php 
    21                 pagingrunModuleSQL('paging', 'uninstall'); 
    22                 if (pagingrunModuleSQL('paging', 'install')==false) { 
    23                         echo _("There is a problem with install.sql, cannot re-create databases. Contact support\n"); 
    24                         die; 
    25                 } else { 
    26                         echo _("Database was deleted! Recreated successfully.<br>\n"); 
    27                         $results = $db->getAll($sql); 
    28                 } 
    29         } 
    30         if (!isset($results['version'])) { 
    31                 print "First-time use. Propogating databases.<br>\n"; 
    32                 // Here, you load up a current database schema. Below, if the version is  
    33                 // different, you'd write some upgrade code. This is better than doing it 
    34                 // in install.sql, becuase you don't know what's in there already.  
    35                 $sql = "INSERT INTO paging_overview VALUES ('version', 1)"; 
    36                 $db->query($sql); 
    37                 /* Load up the phone definitions */ 
    38                 $fd = fopen("modules/paging/phones.sql","r"); 
    39                 while (!feof($fd)) { 
    40                         $data = fgets($fd, 1024); 
    41                         if ($data{0}!=';' && $data{0}!='#' && strlen($data) > 3) { 
    42                                 // It's not a comment or a blank(ish) line. Add it. 
    43                                 $phoneresult = $db->query($data); 
    44                                 if(DB::IsError($phoneresult))  
    45                                         die($phoneresult->getMessage()."<br><br>error adding to phones table"); 
    46                         } 
    47                 } 
    48                 fclose($fd); 
    49                 print "Init complete. Please click on this page again to start using this module<br>\n"; 
    50                 exit; 
    51         } /* else ... check the version and upgrade if needed. */ 
    52 } 
    53  
    549 
    5510//      Generates dialplan for paging  - is called from retrieve_conf 
     
    13287                        unset($fcc); 
    13388 
     89                        // Since these are going down channel local, set ALERT_INFO and SIPADDHEADER which will be set in dialparties.agi 
     90                        // no point in even setting the headers here they will get lost in channel local 
     91                        // 
    13492                        if (!empty($code)) { 
    13593                                $ext->add('ext-intercom', '_'.$code.'.', '', new ext_setvar('dialnumber', '${EXTEN:'.strlen($code).'}')); 
    13694                                $ext->add('ext-intercom', '_'.$code.'.', '', new ext_dbget('user-intercom','AMPUSER/${dialnumber}/intercom')); 
    13795                                $ext->add('ext-intercom', '_'.$code.'.', '', new ext_gotoif('$["${user-intercom}" = "disabled" ]', 'nointercom')); 
    138                                  
    139                                 $ext->add('ext-intercom', '_'.$code.'.', '', new ext_sipaddheader('Call-Info','\;answer-after=0')); 
    140                                 $ext->add('ext-intercom', '_'.$code.'.', '', new ext_alertinfo('Ring Answer')); 
     96                                $ext->add('ext-intercom', '_'.$code.'.', '', new ext_setvar('__SIPADDHEADER', 'Call-Info: \;answer-after=0')); 
     97                                $ext->add('ext-intercom', '_'.$code.'.', '', new ext_setvar('__ALERT_INFO', 'Ring Answer')); 
    14198                                $ext->add('ext-intercom', '_'.$code.'.', '', new ext_setvar('__SIP_URI_OPTIONS', 'intercom=true')); 
    142  
    14399                                $ext->add('ext-intercom', '_'.$code.'.', '', new ext_dial('Local/${dialnumber}@from-internal/n','','')); 
    144100                                $ext->add('ext-intercom', '_'.$code.'.', '', new ext_busy()); 
  • modules/branches/2.3/paging/install.php

    r3236 r4557  
    2222unset($fcc);     
    2323 
     24$sql = "CREATE TABLE IF NOT EXISTS paging_overview  
     25        ( config VARCHAR(50),  
     26          detail VARCHAR(25) 
     27        )"; 
     28$result = $db->query($sql); 
     29if(DB::IsError($result)) { 
     30        die($result->getDebugInfo()); 
     31} 
     32 
     33$sql = "CREATE TABLE IF NOT EXISTS paging_groups  
     34        ( page_number VARCHAR(50),  
     35          ext VARCHAR(25) 
     36        )"; 
     37$result = $db->query($sql); 
     38if(DB::IsError($result)) { 
     39        die($result->getDebugInfo()); 
     40} 
     41 
     42$sql = "CREATE TABLE IF NOT EXISTS paging_phones  
     43        ( phone_name VARCHAR(50),  
     44          priority INT,  
     45                command VARCHAR(50) 
     46        )"; 
     47$result = $db->query($sql); 
     48if(DB::IsError($result)) { 
     49        die($result->getDebugInfo()); 
     50} 
    2451 
    2552// version 1.6 upgrade 
     
    2855if(DB::IsError($check)) { 
    2956        // this table wasn't used up to this point, replace it with the new one 
    30         $sql = "DROP TABLE paging_config;"; 
     57        $sql = "DROP TABLE IF EXISTS paging_config;"; 
    3158        $result = $db->query($sql); 
    3259        if(DB::IsError($result)) { 
     
    3461        } 
    3562         
    36         $sql = "CREATE TABLE IF NOT EXISTS paging_config ( page_group VARCHAR(50), force_page INTEGER(1) NOT NULL);"; 
     63        $sql = "CREATE TABLE IF NOT EXISTS paging_config  
     64                ( page_group VARCHAR(255),  
     65                force_page INTEGER(1) NOT NULL 
     66                )"; 
    3767        $result = $db->query($sql); 
    3868        if(DB::IsError($result)) { 
     
    4777        } 
    4878} 
    49                                      
     79// These are the three most common ways of auto answering. 
     80// Set them up for now - this will all change when paging gets modified 
     81// (I don't think this is even being used) 
     82// 
     83$sql = "INSERT INTO paging_phones VALUES ('GXP-2000', 1, 'Set(SIPADDHEADER=\"Call-Info: answer-after=0\")')"; 
     84$result = $db->query($sql); 
     85if(DB::IsError($result)) { 
     86        die($result->getDebugInfo()); 
     87
     88$sql = "INSERT INTO paging_phones VALUES ('Polycom', 1, 'Set(ALERT_INFO=\"Ring Answer\")')"; 
     89$result = $db->query($sql); 
     90if(DB::IsError($result)) { 
     91        die($result->getDebugInfo()); 
     92
     93$sql = "INSERT INTO paging_phones VALUES ('Snom', 1, 'Set(SIP_URI_OPTIONS=\"intercom=true\")')"; 
     94$result = $db->query($sql); 
     95if(DB::IsError($result)) { 
     96        die($result->getDebugInfo()); 
     97
     98 
     99// Now mark the version - again, not even sure if this is in use anymore 
     100// 
     101$sql = "INSERT INTO paging_overview VALUES ('version', 1)"; 
     102$result = $db->query($sql); 
     103if(DB::IsError($result)) { 
     104        die($result->getDebugInfo()); 
     105
    50106 
    51107?> 
  • modules/branches/2.3/paging/install.sql

    r3217 r4557  
    1 CREATE TABLE IF NOT EXISTS paging_overview ( config VARCHAR(50) , detail VARCHAR(25));  
    2 CREATE TABLE IF NOT EXISTS paging_groups ( page_number VARCHAR(50) , ext VARCHAR(25));  
    3 CREATE TABLE IF NOT EXISTS paging_config ( page_group VARCHAR(50), force_page INTEGER(1) NOT NULL); 
    4 CREATE TABLE IF NOT EXISTS paging_phones ( phone_name VARCHAR(50), priority INT, command VARCHAR(50)); 
  • modules/branches/2.3/paging/module.xml

    r4403 r4557  
    22        <rawname>paging</rawname> 
    33        <name>Paging and Intercom</name> 
    4         <version>1.6.4</version> 
     4        <version>1.6.5</version> 
    55        <type>setup</type> 
    66        <category>Internal Options &amp; Configuration</category> 
    77        <changelog> 
     8                *1.6.5* #2168 fix intercom, #2165 change module to get rid of first time propagation 
    89                *1.6.4* fixed deprecated use of ALERT_INFO and SIPHEADER 
    910                *1.6.3* changed ${CALLERID(number)} to ${AMPUSER} to accomodate CID number masquerading 
  • modules/branches/2.3/paging/page.paging.php

    r3217 r4557  
    2929// Check to make sure that the paging database is propogated and 
    3030// up to date. 
    31 paging_init(); 
    3231 
    3332switch ($action) { 
  • modules/branches/2.3/paging/uninstall.php

    r3236 r4557  
    22 
    33// Enable intercom as a feature code 
     4echo "removing featurecode intercom-prefix.."; 
    45$fcc = new featurecode('paging', 'intercom-prefix'); 
    5 $fcc->setDescription('Intercom prefix'); 
    6 $fcc->setDefault('*80',false); 
    7 $fcc->update(); 
     6$fcc->delete(); 
    87unset($fcc); 
     8echo "done<br>\n"; 
    99 
    1010// User intercom enable code 
     11echo "removing featurecode intercom-on.."; 
    1112$fcc = new featurecode('paging', 'intercom-on'); 
    12 $fcc->setDescription('User Intercom Allow'); 
    13 $fcc->setDefault('*54',false); 
    14 $fcc->update(); 
     13$fcc->delete(); 
    1514unset($fcc); 
     15echo "done<br>\n"; 
    1616 
    1717// User intercom disable  
     18echo "removing featurecode intercom-off.."; 
    1819$fcc = new featurecode('paging', 'intercom-off'); 
    19 $fcc->setDescription('User Intercom Disallow'); 
    20 $fcc->setDefault('*55',false); 
    21 $fcc->update(); 
     20$fcc->delete(); 
    2221unset($fcc);     
     22echo "done<br>\n"; 
    2323 
     24echo "dropping table paging_overview.."; 
     25$sql = "DROP TABLE IF EXISTS paging_overview"; 
     26$result = $db->query($sql); 
     27if(DB::IsError($result)) { 
     28        echo "ERROR DELETING TABLE: ".$result->getDebugInfo(); 
     29} 
     30echo "done<br>\n"; 
    2431 
    25 // version 1.6 upgrade 
    26 $sql = "SELECT page_group FROM paging_config"; 
    27 $check = $db->getRow($sql, DB_FETCHMODE_ASSOC); 
    28 if(DB::IsError($check)) { 
    29         // this table wasn't used up to this point, replace it with the new one 
    30         $sql = "DROP TABLE paging_config;"; 
    31         $result = $db->query($sql); 
    32         if(DB::IsError($result)) { 
    33                 die($result->getDebugInfo()); 
    34         } 
    35          
    36         $sql = "CREATE TABLE IF NOT EXISTS paging_config ( page_group VARCHAR(50), force_page INTEGER(1) NOT NULL);"; 
    37         $result = $db->query($sql); 
    38         if(DB::IsError($result)) { 
    39                 die($result->getDebugInfo()); 
    40         } 
     32echo "dropping table paging_groups.."; 
     33$sql = "DROP TABLE IF EXISTS paging_groups"; 
     34$result = $db->query($sql); 
     35if(DB::IsError($result)) { 
     36        echo "ERROR DELETING TABLE: ".$result->getDebugInfo(); 
     37
     38echo "done<br>\n"; 
    4139 
    42         // insert default values 
    43         $sql = "INSERT INTO paging_config  SELECT DISTINCT page_number, 0 FROM paging_groups;"; 
    44         $result = $db->query($sql); 
    45         if(DB::IsError($result)) { 
    46                 die($result->getDebugInfo()); 
    47         } 
     40echo "dropping table paging_phones.."; 
     41$sql = "DROP TABLE IF EXISTS paging_phones"; 
     42$result = $db->query($sql); 
     43if(DB::IsError($result)) { 
     44        echo "ERROR DELETING TABLE: ".$result->getDebugInfo(); 
    4845} 
    49                                      
     46echo "done<br>\n"; 
     47 
     48echo "dropping table paging_config.."; 
     49$sql = "DROP TABLE IF EXISTS paging_config"; 
     50$result = $db->query($sql); 
     51if(DB::IsError($result)) { 
     52        echo "ERROR DELETING TABLE: ".$result->getDebugInfo(); 
     53
     54echo "done<br>\n"; 
    5055 
    5156?> 
  • modules/branches/2.3/paging/uninstall.sql

    r1540 r4557  
    1 DROP TABLE IF EXISTS paging_overview; 
    2 DROP TABLE IF EXISTS paging_groups; 
    3 DROP TABLE IF EXISTS paging_phones; 
Donate



Support
Download
Develop
Forums
News
Documentation
Paid Support
About

Paid Ads