Changeset 5860
- Timestamp:
- 07/01/08 21:24:41 (3 months ago)
- Files:
-
- modules/branches/2.5/daynight/functions.inc.php (modified) (5 diffs)
- modules/branches/2.5/daynight/install.php (modified) (1 diff)
- modules/branches/2.5/daynight/module.xml (modified) (2 diffs)
- modules/branches/2.5/daynight/page.daynight.php (modified) (3 diffs)
- modules/branches/2.5/daynight/uninstall.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
modules/branches/2.5/daynight/functions.inc.php
r5842 r5860 166 166 global $ext; 167 167 168 $fcc = new featurecode('daynight', 'toggle-mode'); 169 $c = $fcc->getCodeActive(); 170 unset($fcc); 171 172 if (!empty($c)) { 173 $id = "app-daynight-toggle"; // The context to be included 174 168 $list = daynight_list(); 169 $passwords = daynight_passwords(); 170 $got_code = false; 171 172 $id = "app-daynight-toggle"; // The context to be included 173 foreach ($list as $item) { 174 $index = $item['ext']; 175 $fcc = new featurecode('daynight', 'toggle-mode-'.$index); 176 $c = $fcc->getCodeActive(); 177 unset($fcc); 178 if (!$c) { 179 continue; 180 } 181 $got_code = true; 182 if ($amp_conf['USEDEVSTATE']) { 183 $ext->addHint($id, $c, 'Custom:DAYNIGHT'.$index); 184 } 185 $ext->add($id, $c, '', new ext_answer('')); 186 $ext->add($id, $c, '', new ext_wait('1')); 187 if (isset($passwords[$index]) && trim($passwords[$index]) != "" && ctype_digit(trim($passwords[$index]))) { 188 $ext->add($id, $c, '', new ext_authenticate($passwords[$index])); 189 } 190 $ext->add($id, $c, '', new ext_setvar('INDEX', $index)); 191 $ext->add($id, $c, '', new ext_goto($id.',s,1')); 192 } 193 194 if ($got_code) { 175 195 $ext->addInclude('from-internal-additional', $id); // Add the include from from-internal 176 177 $list = daynight_list();178 $passwords = daynight_passwords();179 foreach ($list as $item) {180 $index = $item['ext'];181 $ext->add($id, $c.$index, '', new ext_answer(''));182 $ext->add($id, $c.$index, '', new ext_wait('1'));183 184 if (isset($passwords[$index]) && trim($passwords[$index]) != "" && ctype_digit(trim($passwords[$index]))) {185 $ext->add($id, $c.$index, '', new ext_authenticate($passwords[$index]));186 }187 $ext->add($id, $c.$index, '', new ext_setvar('INDEX', $index));188 $ext->add($id, $c.$index, '', new ext_goto($id.',s,1'));189 }190 196 191 197 $c='s'; … … 194 200 195 201 $ext->add($id, $c, 'day', new ext_setvar('DB(DAYNIGHT/C${INDEX})', 'DAY')); 202 if ($amp_conf['USEDEVSTATE']) { 203 $ext->add($id, $c, '', new ext_setvar('DEVSTATE(Custom:DAYNIGHT${INDEX})', 'NOT_INUSE')); 204 } 196 205 $ext->add($id, $c, '', new ext_playback('beep&silence/1&day&reception&digits/${INDEX}&enabled')); 197 206 $ext->add($id, $c, '', new ext_hangup('')); 198 207 199 208 $ext->add($id, $c, 'night', new ext_setvar('DB(DAYNIGHT/C${INDEX})', 'NIGHT')); 209 if ($amp_conf['USEDEVSTATE']) { 210 $ext->add($id, $c, '', new ext_setvar('DEVSTATE(Custom:DAYNIGHT${INDEX})', 'INUSE')); 211 } 200 212 $ext->add($id, $c, '', new ext_playback('beep&silence/1&beep&silence/1&day&reception&digits/${INDEX}&disabled')); 201 213 $ext->add($id, $c, '', new ext_hangup('')); … … 269 281 } 270 282 $fc_description = isset($post['fc_description']) ? trim($post['fc_description']) : ""; 271 sql("INSERT INTO daynight (ext, dmode, dest) VALUES ('$id', 'fc_description', ' $fc_description')");283 sql("INSERT INTO daynight (ext, dmode, dest) VALUES ('$id', 'fc_description', '".addslashes($fc_description)."')"); 272 284 273 285 $dn = new dayNightObject($id); … … 275 287 $dn->create($post['state']); 276 288 289 $fcc = new featurecode('daynight', 'toggle-mode-'.$id); 290 if ($fc_description) { 291 $fcc->setDescription("$id: $fc_description"); 292 } else { 293 $fcc->setDescription("$id: Day Night Control"); 294 } 295 $fcc->setDefault('*28'.$id); 296 $fcc->update(); 297 unset($fcc); 298 277 299 needreload(); 278 300 } … … 283 305 // 284 306 $results = sql("DELETE FROM daynight WHERE ext = \"$id\"","query"); 307 308 $fcc = new featurecode('daynight', 'toggle-mode-'.$id); 309 $fcc->delete(); 310 unset($fcc); 285 311 } 286 312 modules/branches/2.5/daynight/install.php
r4767 r5860 14 14 } 15 15 16 // Day / Night Mode Control 16 // Get the old feature code if it existed to determine 17 // if it had been changed and if it was enabled 18 // 19 $delete_old = false; 17 20 $fcc = new featurecode('daynight', 'toggle-mode'); 18 $fcc->setDescription('Day/Night Control Toggle'); 19 $fcc->setDefault('*28'); 20 $fcc->update(); 21 $code = $fcc->getCode(); 22 if ($code != '') { 23 $delete_old = true; 24 $enabled = $fcc->isEnabled(); 25 $fcc->delete(); 26 } 21 27 unset($fcc); 22 28 29 // If we found the old one then we must create all the new ones 30 // 31 if ($delete_old) { 32 $list = daynight_list(); 33 foreach ($list as $item) { 34 $id = $item['ext'] 35 $fc_description = $item['dest'] 36 $fcc = new featurecode('daynight', 'toggle-mode-'.$id); 37 if ($fc_description) { 38 $fcc->setDescription("$id: $fc_description"); 39 } else { 40 $fcc->setDescription("$id: Day Night Control"); 41 } 42 $fcc->setDefault('*28'.$id); 43 if ($code != '*28') { 44 $fcc->setCode($code.$id); 45 } 46 if (!$enabled) { 47 $fcc->setEnabled(false); 48 } 49 $fcc->update(); 50 unset($fcc); 51 } 52 } 53 23 54 ?> modules/branches/2.5/daynight/module.xml
r5843 r5860 2 2 <rawname>daynight</rawname> 3 3 <name>Day Night Mode</name> 4 <version>2. 4.0.3</version>4 <version>2.5.0</version> 5 5 <type>setup</type> 6 6 <category>Inbound Call Control</category> … … 10 10 </description> 11 11 <changelog> 12 *2.5.0* change to create feature code for each index, add func_devstate blf 12 13 *2.4.0.3* #2734 fixed issue creating index with no description made it disapear 13 14 *2.4.0.2* #2604, #2843 fix mal-formed html tags, Russian Translation modules/branches/2.5/daynight/page.daynight.php
r5762 r5860 21 21 isset($_REQUEST['itemid'])?$itemid=mysql_real_escape_string($_REQUEST['itemid']):$itemid=''; 22 22 23 24 $fcc = new featurecode('daynight', 'toggle-mode');25 $fc = $fcc->getCodeActive();26 unset($fcc);27 28 23 $daynightcodes = daynight_list(); 29 24 ?> … … 37 32 if (isset($daynightcodes)) { 38 33 foreach ($daynightcodes as $code) { 34 $fcc = new featurecode('daynight', 'toggle-mode-'.$code['ext']); 35 $fc = $fcc->getCode(); 36 unset($fcc); 37 39 38 $dnobj = daynight_get_obj($code['ext']); 40 39 $color = $dnobj['state'] == 'DAY' ? "style='color:green'" : "style='color:red'"; 41 echo "<li><a $color id=\"".($itemid==$code['ext'] ? 'current':'')."\" href=\"config.php?display=".urlencode($dispnum)."&itemid=".urlencode($code['ext'])."&action=edit\">($fc {$code['ext']}) {$code['dest']}</a></li>";40 echo "<li><a $color id=\"".($itemid==$code['ext'] ? 'current':'')."\" href=\"config.php?display=".urlencode($dispnum)."&itemid=".urlencode($code['ext'])."&action=edit\">($fc) {$code['dest']}</a></li>"; 42 41 } 43 42 } … … 70 69 global $itemid; 71 70 72 $fcc = new featurecode('daynight', 'toggle-mode ');73 $code = $fcc->getCodeActive() .$itemid;71 $fcc = new featurecode('daynight', 'toggle-mode-'.$itemid); 72 $code = $fcc->getCodeActive(); 74 73 unset($fcc); 75 74 modules/branches/2.5/daynight/uninstall.php
r4151 r5860 1 1 <?php 2 2 3 // Delete the old code if still there 4 // 3 5 $fcc = new featurecode('daynight', 'toggle-mode'); 4 6 $fcc->delete(); 5 7 unset($fcc); 6 8 9 $list = daynight_list(); 10 foreach ($list as $item) { 11 $id = $item['ext'] 12 $fcc = new featurecode('daynight', 'toggle-mode-'.$id); 13 $fcc->delete(); 14 unset($fcc); 15 } 16 7 17 sql('DROP TABLE daynight'); 8 18
