Changeset 4557
- Timestamp:
- 07/27/07 15:29:10 (1 year ago)
- Files:
-
- modules/branches/2.3/paging/functions.inc.php (modified) (2 diffs)
- modules/branches/2.3/paging/install.php (modified) (4 diffs)
- modules/branches/2.3/paging/install.sql (modified) (1 diff)
- modules/branches/2.3/paging/module.xml (modified) (1 diff)
- modules/branches/2.3/paging/page.paging.php (modified) (1 diff)
- modules/branches/2.3/paging/phones.sql (deleted)
- modules/branches/2.3/paging/uninstall.php (copied) (copied from modules/branches/2.3/paging/install.php) (1 diff)
- modules/branches/2.3/paging/uninstall.sql (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
modules/branches/2.3/paging/functions.inc.php
r4402 r4557 7 7 check for version upgrades, etc, of the paging database, to 8 8 allow for easy upgrades. */ 9 10 function paging_init() {11 global $db;12 13 // Check to make sure that install.sql has been run14 $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, just19 // 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.php21 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 is33 // different, you'd write some upgrade code. This is better than doing it34 // 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 54 9 55 10 // Generates dialplan for paging - is called from retrieve_conf … … 132 87 unset($fcc); 133 88 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 // 134 92 if (!empty($code)) { 135 93 $ext->add('ext-intercom', '_'.$code.'.', '', new ext_setvar('dialnumber', '${EXTEN:'.strlen($code).'}')); 136 94 $ext->add('ext-intercom', '_'.$code.'.', '', new ext_dbget('user-intercom','AMPUSER/${dialnumber}/intercom')); 137 95 $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')); 141 98 $ext->add('ext-intercom', '_'.$code.'.', '', new ext_setvar('__SIP_URI_OPTIONS', 'intercom=true')); 142 143 99 $ext->add('ext-intercom', '_'.$code.'.', '', new ext_dial('Local/${dialnumber}@from-internal/n','','')); 144 100 $ext->add('ext-intercom', '_'.$code.'.', '', new ext_busy()); modules/branches/2.3/paging/install.php
r3236 r4557 22 22 unset($fcc); 23 23 24 $sql = "CREATE TABLE IF NOT EXISTS paging_overview 25 ( config VARCHAR(50), 26 detail VARCHAR(25) 27 )"; 28 $result = $db->query($sql); 29 if(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); 38 if(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); 48 if(DB::IsError($result)) { 49 die($result->getDebugInfo()); 50 } 24 51 25 52 // version 1.6 upgrade … … 28 55 if(DB::IsError($check)) { 29 56 // 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;"; 31 58 $result = $db->query($sql); 32 59 if(DB::IsError($result)) { … … 34 61 } 35 62 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 )"; 37 67 $result = $db->query($sql); 38 68 if(DB::IsError($result)) { … … 47 77 } 48 78 } 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); 85 if(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); 90 if(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); 95 if(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); 103 if(DB::IsError($result)) { 104 die($result->getDebugInfo()); 105 } 50 106 51 107 ?> 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 2 2 <rawname>paging</rawname> 3 3 <name>Paging and Intercom</name> 4 <version>1.6. 4</version>4 <version>1.6.5</version> 5 5 <type>setup</type> 6 6 <category>Internal Options & Configuration</category> 7 7 <changelog> 8 *1.6.5* #2168 fix intercom, #2165 change module to get rid of first time propagation 8 9 *1.6.4* fixed deprecated use of ALERT_INFO and SIPHEADER 9 10 *1.6.3* changed ${CALLERID(number)} to ${AMPUSER} to accomodate CID number masquerading modules/branches/2.3/paging/page.paging.php
r3217 r4557 29 29 // Check to make sure that the paging database is propogated and 30 30 // up to date. 31 paging_init();32 31 33 32 switch ($action) { modules/branches/2.3/paging/uninstall.php
r3236 r4557 2 2 3 3 // Enable intercom as a feature code 4 echo "removing featurecode intercom-prefix.."; 4 5 $fcc = new featurecode('paging', 'intercom-prefix'); 5 $fcc->setDescription('Intercom prefix'); 6 $fcc->setDefault('*80',false); 7 $fcc->update(); 6 $fcc->delete(); 8 7 unset($fcc); 8 echo "done<br>\n"; 9 9 10 10 // User intercom enable code 11 echo "removing featurecode intercom-on.."; 11 12 $fcc = new featurecode('paging', 'intercom-on'); 12 $fcc->setDescription('User Intercom Allow'); 13 $fcc->setDefault('*54',false); 14 $fcc->update(); 13 $fcc->delete(); 15 14 unset($fcc); 15 echo "done<br>\n"; 16 16 17 17 // User intercom disable 18 echo "removing featurecode intercom-off.."; 18 19 $fcc = new featurecode('paging', 'intercom-off'); 19 $fcc->setDescription('User Intercom Disallow'); 20 $fcc->setDefault('*55',false); 21 $fcc->update(); 20 $fcc->delete(); 22 21 unset($fcc); 22 echo "done<br>\n"; 23 23 24 echo "dropping table paging_overview.."; 25 $sql = "DROP TABLE IF EXISTS paging_overview"; 26 $result = $db->query($sql); 27 if(DB::IsError($result)) { 28 echo "ERROR DELETING TABLE: ".$result->getDebugInfo(); 29 } 30 echo "done<br>\n"; 24 31 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 } 32 echo "dropping table paging_groups.."; 33 $sql = "DROP TABLE IF EXISTS paging_groups"; 34 $result = $db->query($sql); 35 if(DB::IsError($result)) { 36 echo "ERROR DELETING TABLE: ".$result->getDebugInfo(); 37 } 38 echo "done<br>\n"; 41 39 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 } 40 echo "dropping table paging_phones.."; 41 $sql = "DROP TABLE IF EXISTS paging_phones"; 42 $result = $db->query($sql); 43 if(DB::IsError($result)) { 44 echo "ERROR DELETING TABLE: ".$result->getDebugInfo(); 48 45 } 49 46 echo "done<br>\n"; 47 48 echo "dropping table paging_config.."; 49 $sql = "DROP TABLE IF EXISTS paging_config"; 50 $result = $db->query($sql); 51 if(DB::IsError($result)) { 52 echo "ERROR DELETING TABLE: ".$result->getDebugInfo(); 53 } 54 echo "done<br>\n"; 50 55 51 56 ?> 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;
