Changeset 1386
- Timestamp:
- 04/07/06 08:09:08 (7 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
freepbx/trunk/amp_conf/htdocs/admin/featurecodes.class.php
r1376 r1386 25 25 26 26 // INIT FUNCTION -- READS FROM DATABASE IF THERE BASICALLY 27 function init() { 28 if ($this->isReady()) 29 die('FeatureCode: init already called!'); 27 // $opt = 0 -- called by user code (i.e. outside this class) 28 // $opt = 1 -- called automatically by this class 29 // $opt = 2 -- called by user code, run even if called once already 30 function init($opt = 0) { 31 if ($this->isReady()) { 32 if ($opt < 2) 33 die('FeatureCode: init already called!'); 34 } 30 35 31 36 $s = "SELECT description, defaultcode, customcode, enabled "; 32 37 $s .= "FROM featurecodes "; 33 $s .= "WHERE modulename = '$this->_modulename' AND featurename = '$this->_featurename'";38 $s .= "WHERE modulename = ".sql_formattext($this->_modulename)." AND featurename = ".sql_formattext($this->_featurename)." "; 34 39 35 40 $res = sql($s, "getRow"); … … 52 57 function update() { 53 58 if (!$this->isReady()) 54 die('FeatureCode: you must call init function before using');59 die('FeatureCode: class function init never called...will not update'); 55 60 56 61 $s = "REPLACE INTO featurecodes (modulename, featurename, description, defaultcode, customcode, enabled) "; 57 $s .= "VALUES ( '$this->_modulename', '$this->_featurename', '$this->_description', '$this->_defaultcode', '$this->_customcode', $this->_enabled) ";62 $s .= "VALUES (".sql_formattext($this->_modulename).", ".sql_formattext($this->_featurename).", ".sql_formattext($this->_description).", ".sql_formattext($this->_defaultcode).", ".sql_formattext($this->_customcode).", ".sql_formattext($this->_enabled).") "; 58 63 sql($s, "query"); 59 64 … … 64 69 function setDescription($description) { 65 70 if (!$this->isReady()) 66 die('FeatureCode: you must call init function before using');71 $this->init(1); 67 72 68 73 if ($description == '') { … … 76 81 function getDescription() { 77 82 if (!$this->isReady()) 78 die('FeatureCode: you must call init function before using');83 $this->init(1); 79 84 80 85 $desc = (isset($this->_description) ? $this->_description : ''); … … 86 91 function setDefault($deafultcode) { 87 92 if (!$this->isReady()) 88 die('FeatureCode: you must call init function before using');93 $this->init(1); 89 94 90 95 if ($deafultcode == '') { … … 98 103 function setCode($customcode) { 99 104 if (!$this->isReady()) 100 die('FeatureCode: you must call init function before using');105 $this->init(1); 101 106 102 107 if ($customcode == '') { … … 111 116 function getCode() { 112 117 if (!$this->isReady()) 113 die('FeatureCode: you must call init function before using');118 $this->init(1); 114 119 115 120 $curcode = (isset($this->_customcode) ? $this->_customcode : ''); … … 130 135 // SET ENABLED 131 136 function setEnabled($b = true) { 137 if (!$this->isReady()) 138 $this->init(1); 139 132 140 $this->_enabled = ($b ? 1 : 0); 133 141 } … … 135 143 // GET ENABLED 136 144 function isEnabled() { 145 if (!$this->isReady()) 146 $this->init(1); 147 137 148 return ($this->_enabled == 1); 138 149 } … … 145 156 $s = "SELECT featurename, description "; 146 157 $s .= "FROM featurecodes "; 147 $s .= "WHERE modulename = '$modulename'AND enabled = 1 ";158 $s .= "WHERE modulename = ".sql_formattext($modulename)." AND enabled = 1 "; 148 159 149 160 $results = sql($s,"getAll",DB_FETCHMODE_ASSOC); freepbx/trunk/amp_conf/htdocs/admin/functions.inc.php
r1380 r1386 252 252 } 253 253 return $results; 254 } 255 256 // sql text formatting -- couldn't see that one was available already 257 function sql_formattext($txt) { 258 if (isset($txt)) { 259 $fmt = str_replace("'", "''", $txt); 260 $fmt = "'" . $fmt . "'"; 261 } else { 262 $fmt = 'null'; 263 } 264 265 return $fmt; 254 266 } 255 267 freepbx/trunk/amp_conf/htdocs/admin/modules/callwaiting/functions.inc.php
r1379 r1386 12 12 } 13 13 function callwaiting_install() { 14 // Register FeatureCodes 15 // Activate 14 // Register FeatureCode - Activate 16 15 $fcc = new featurecode('callwaiting', 'cwon'); 17 $fcc->init();18 16 $fcc->setDescription('Call Waiting - Activate'); 19 17 $fcc->setDefault('*70'); 20 18 $fcc->update(); 21 19 unset($fcc); 22 // Deactivate 20 21 // Register FeatureCode - Deactivate 23 22 $fcc = new featurecode('callwaiting', 'cwoff'); 24 $fcc->init();25 23 $fcc->setDescription('Call Waiting - Deactivate'); 26 24 $fcc->setDefault('*71'); … … 42 40 if (function_exists($fname)) { 43 41 $fcc = new featurecode($modulename, $featurename); 44 $fcc->init();45 42 $fc = $fcc->getCodeActive(); 46 43 unset($fcc);
