Ticket #1821: patch.diff

File patch.diff, 6.5 kB (added by lazytt, 5 months ago)
  • page.phonebook.php

    old new  
    1515isset($_REQUEST['number'])?$number = $_REQUEST['number']:$number=''; 
    1616isset($_REQUEST['name'])?$name = $_REQUEST['name']:$name=''; 
    1717isset($_REQUEST['speeddial'])?$speeddial = $_REQUEST['speeddial']:$speeddial=''; 
     18isset($_REQUEST['gensd'])?$gensd = $_REQUEST['gensd']:$gensd=''; 
    1819 
    1920isset($_REQUEST['editnumber'])?$editnumber = $_REQUEST['editnumber']:$editnumber=''; 
    2021 
    2122 
    2223$dispnum = "phonebook"; //used for switch on config.php 
    2324 
     
    2527if(isset($_REQUEST['action'])) { 
    2628       switch ($action) { 
    2729               case "add": 
    28                        phonebook_add($number, $name, $speeddial, $needsd); 
     30                       phonebook_add($number, $name, $speeddial, $gensd); 
    2931                       redirect_standard(); 
    3032               exit; 
    3133               break; 
     
    3739               case "edit": 
    3840                       $numbers = phonebook_list(); 
    3941                       phonebook_del($editnumber, $numbers[$editnumber]['speeddial']); 
    40                        phonebook_add($number, $name, $speeddial); 
     42                       phonebook_add($number, $name, $speeddial, $gensd); 
    4143                       redirect_standard(); 
    4244               break; 
    4345               case "empty": 
     
    122124               printf('<td>%s</td><td>%s</td><td>%s</td>', $num, $values['name'], $values['speeddial']); 
    123125               printf('<td><a href="%s?type=tool&display=%s&number=%s&action=delete" onclick="return confirm(\'%s\')">%s</a></td>', 
    124126                       $_SERVER['PHP_SELF'], urlencode($dispnum), urlencode($num), _("Are you sure you want to delete this entry ?"), _("Delete")); 
    125                printf('<td><a href="#" onClick="theForm.number.value = \'%s\'; theForm.name.value = \'%s\' ; theForm.speeddial.value = \'%s\' ; theForm.editnumber.value = \'%s\' ; theForm.action.value = \'edit\' ; ">%s</a></td>', 
     127               printf('<td><a href="#" 
     128    onClick="theForm.number.value = \'%s\'; theForm.name.value = \'%s\' ; theForm.speeddial.value = \'%s\' ; 
     129    if (theForm.name.value && theForm.number.value && !theForm.speeddial.value) { theForm.gensd.checked = false } else { theForm.gensd.checked = true }; 
     130    theForm.editnumber.value = \'%s\' ; theForm.action.value = \'edit\' ; ">%s</a></td>', 
    126131                       $num,  addslashes($values['name']), $values['speeddial'], $num, _("Edit")); 
    127132               print('</tr>'); 
    128133       } 
     
    154159               <td><a href="#" class="info"><?php echo _("Name:")?><span><?php echo _("Enter the name")?></span></a></td> 
    155160               <td><input type="text" name="name"></td> 
    156161       </tr> 
    157  
     162 
    158163       <tr> 
    159164               <td><a href="#" class="info"><?php echo _("Number:")?> 
    160165               <span><?php echo _("Enter the number (For caller ID lookup to work it should match the caller ID received from network)")?></span></a></td> 
    161166               <td><input type="text" name="number"></td> 
    162167       </tr> 
    163  
     168 
    164169       <tr> 
    165170               <td><a href="#" class="info"><?php echo _("Speed dial code:")?><span><?php echo _("Enter a speed dial code<br/>Speeddial module is required to use speeddial codes")?></span></a></td> 
    166171               <td><input type="text" name="speeddial"></td> 
    167172       </tr> 
    168  
     173 
    169174  <tr> 
    170175               <td><a href="#" class="info"><?php echo _("Set Speed Dial?"); ?><span><?php echo _("Check to have a speed dial created automaticaly for this number"); ?></span></a></td> 
    171                <td><input type="checkbox" name="needsd" value="true" CHECKED <?php echo $thisItem['needsd'] ?>  /></td> 
     176               <td><input type="checkbox" name="gensd" value="yes" CHECKED ></td> 
     177 
     178       <tr> 
     179               <td colspan="2"><br><h6><input name="submit" type="submit" value="<?php echo _("Submit Changes")?>"></h6></td> 
     180 
    172181       </tr> 
    173  
    174   <tr> 
    175                <td colspan="2"><br><h6><input name="submit" type="submit" value="<?php echo _("Submit Changes")?>"></h6> 
    176        </tr> 
    177182</form> 
    178183</table> 
    179184 
  • functions.inc.php

    old new  
    6969       } 
    7070} 
    7171 
    72 function phonebook_add($number, $name, $speeddial){ 
     72function phonebook_add($number, $name, $speeddial, $gensd){ 
    7373       global $amp_conf; 
    7474       global $astman; 
    7575 
     
    7878 
    7979       if ($astman) { 
    8080               // Was the user a twonk and didn't specify a speeddial? 
    81                // Should we really automatically generate a speeddial ? 
     81               // Should we really automatically generate a speeddial ? definatly only when gensd is checked 
    8282               // If yes I think we should start from 99 going down and leave easier speeddials to users 
    83                if  ($needsd) { 
    84         if (empty($speeddial)) { 
    85                            for ($nbr = 99; $nbr > 0; $nbr--) { 
    86                                    if ($astman->database_get("sysspeeddials",sprintf("%02d",$nbr))===false) { 
    87                                            $speeddial = sprintf("%02d", $nbr); 
    88                                            break; 
    89                                    } 
    90                            } 
    91                    } 
    92                    } 
    93                    $astman->database_put("cidname",$number, '"'.$name.'"'); 
    94                    if ($speeddial != '') 
    95                            $astman->database_put("sysspeeddials",$speeddial, '"'.$number.'"'); 
    96            } else { 
    97                    fatal("Cannot connect to Asterisk Manager with ".$amp_conf["AMPMGRUSER"]."/".$amp_conf["AMPMGRPASS"]); 
     83 
     84               if ($gensd == "yes"){ 
     85      if (empty($speeddial)) { 
     86                         for ($nbr = 99; $nbr > 0; $nbr--) { 
     87                                 if ($astman->database_get("sysspeeddials",sprintf("%02d",$nbr))===false) { 
     88                                         $speeddial = sprintf("%02d", $nbr); 
     89                                         break; 
     90                                 } 
     91                         } 
     92                 } 
     93               } 
     94               $astman->database_put("cidname",$number, '"'.$name.'"'); 
     95               if ($speeddial != '') 
     96                       $astman->database_put("sysspeeddials",$speeddial, '"'.$number.'"'); 
     97       } else { 
     98               fatal("Cannot connect to Asterisk Manager with ".$amp_conf["AMPMGRUSER"]."/".$amp_conf["AMPMGRPASS"]); 
     99 
    98100       } 
    99101} 
    100102 
Donate



Support
Download
Develop
Forums
News
Documentation
Paid Support
About

Paid Ads