Changeset 5860

Show
Ignore:
Timestamp:
07/01/08 21:24:41 (3 months ago)
Author:
p_lindheimer
Message:

change to create feature code for each index, add func_devstate blf

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • modules/branches/2.5/daynight/functions.inc.php

    r5842 r5860  
    166166        global $ext; 
    167167 
    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) { 
    175195                $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                 } 
    190196 
    191197                $c='s'; 
     
    194200 
    195201                $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                } 
    196205                $ext->add($id, $c, '', new ext_playback('beep&silence/1&day&reception&digits/${INDEX}&enabled')); 
    197206                $ext->add($id, $c, '', new ext_hangup('')); 
    198207 
    199208                $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                } 
    200212                $ext->add($id, $c, '', new ext_playback('beep&silence/1&beep&silence/1&day&reception&digits/${INDEX}&disabled')); 
    201213                $ext->add($id, $c, '', new ext_hangup('')); 
     
    269281        } 
    270282        $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)."')"); 
    272284 
    273285        $dn = new dayNightObject($id); 
     
    275287        $dn->create($post['state']); 
    276288 
     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 
    277299        needreload(); 
    278300} 
     
    283305        // 
    284306        $results = sql("DELETE FROM daynight WHERE ext = \"$id\"","query"); 
     307 
     308        $fcc = new featurecode('daynight', 'toggle-mode-'.$id); 
     309        $fcc->delete(); 
     310        unset($fcc);     
    285311} 
    286312 
  • modules/branches/2.5/daynight/install.php

    r4767 r5860  
    1414} 
    1515 
    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; 
    1720$fcc = new featurecode('daynight', 'toggle-mode'); 
    18 $fcc->setDescription('Day/Night Control Toggle'); 
    19 $fcc->setDefault('*28'); 
    20 $fcc->update(); 
     21$code = $fcc->getCode(); 
     22if ($code != '') { 
     23        $delete_old = true; 
     24        $enabled = $fcc->isEnabled(); 
     25        $fcc->delete(); 
     26
    2127unset($fcc);     
    2228 
     29// If we found the old one then we must create all the new ones 
     30// 
     31if ($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 
    2354?> 
  • modules/branches/2.5/daynight/module.xml

    r5843 r5860  
    22        <rawname>daynight</rawname> 
    33        <name>Day Night Mode</name> 
    4         <version>2.4.0.3</version> 
     4        <version>2.5.0</version> 
    55        <type>setup</type> 
    66        <category>Inbound Call Control</category> 
     
    1010        </description> 
    1111        <changelog> 
     12                *2.5.0* change to create feature code for each index, add func_devstate blf 
    1213                *2.4.0.3* #2734 fixed issue creating index with no description made it disapear 
    1314                *2.4.0.2* #2604, #2843 fix mal-formed html tags, Russian Translation 
  • modules/branches/2.5/daynight/page.daynight.php

    r5762 r5860  
    2121isset($_REQUEST['itemid'])?$itemid=mysql_real_escape_string($_REQUEST['itemid']):$itemid=''; 
    2222 
    23  
    24 $fcc = new featurecode('daynight', 'toggle-mode'); 
    25 $fc = $fcc->getCodeActive(); 
    26 unset($fcc); 
    27  
    2823$daynightcodes = daynight_list(); 
    2924?> 
     
    3732if (isset($daynightcodes)) { 
    3833        foreach ($daynightcodes as $code) { 
     34                $fcc = new featurecode('daynight', 'toggle-mode-'.$code['ext']); 
     35                $fc = $fcc->getCode(); 
     36                unset($fcc); 
     37 
    3938                $dnobj = daynight_get_obj($code['ext']); 
    4039                $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>"; 
    4241        } 
    4342} 
     
    7069        global $itemid; 
    7170 
    72         $fcc = new featurecode('daynight', 'toggle-mode'); 
    73         $code = $fcc->getCodeActive().$itemid
     71        $fcc = new featurecode('daynight', 'toggle-mode-'.$itemid); 
     72        $code = $fcc->getCodeActive()
    7473        unset($fcc); 
    7574 
  • modules/branches/2.5/daynight/uninstall.php

    r4151 r5860  
    11<?php 
    22 
     3// Delete the old code if still there 
     4// 
    35$fcc = new featurecode('daynight', 'toggle-mode'); 
    46$fcc->delete(); 
    57unset($fcc);     
    68 
     9$list = daynight_list(); 
     10foreach ($list as $item) { 
     11        $id = $item['ext'] 
     12        $fcc = new featurecode('daynight', 'toggle-mode-'.$id); 
     13        $fcc->delete(); 
     14        unset($fcc);     
     15} 
     16 
    717sql('DROP TABLE daynight'); 
    818 
Donate



Support
Download
Develop
Forums
News
Documentation
Paid Support
About

Paid Ads