Changeset 5228

Show
Ignore:
Timestamp:
11/07/07 19:27:16 (1 year ago)
Author:
p_lindheimer
Message:

Merged revisions 5227 via svnmerge from
http://svn.freepbx.org/modules/branches/2.3

........

r5227 | p_lindheimer | 2007-11-07 19:20:17 -0800 (Wed, 07 Nov 2007) | 1 line


fix case where additional devices were being assigned to a users and the previous assignments were getting lost

........

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • modules/branches/2.4

    • Property svnmerge-integrated changed from /modules/branches/2.3:1-5212,5225 to /modules/branches/2.3:1-5212,5225,5227
  • modules/branches/2.4/core/functions.inc.php

    r5226 r5228  
    784784                } 
    785785        } 
    786         //if (empty($dial) && strtolower($tech) == "zap") 
    787         //      $dial = "ZAP/".($_REQUEST['channel'] != '' ? $_REQUEST['channel'] : $_REQUEST['devinfo_channel']); 
    788         //if (empty($dial)) 
    789         //      $dial = strtoupper($tech)."/".$id; 
    790786         
    791787        //check to see if we are requesting a new user 
     
    823819                $astman->database_put("DEVICE",$id."/type",$devicetype); 
    824820                $astman->database_put("DEVICE",$id."/default_user",$user); 
    825                 if(!empty($emergency_cid)) 
     821                if(!empty($emergency_cid)) { 
    826822                        $astman->database_put("DEVICE",$id."/emergency_cid","\"".$emergency_cid."\""); 
    827                 if($user != "none") { 
     823                } 
     824 
     825                if ($user != "none") { 
    828826                        $existingdevices = $astman->database_get("AMPUSER",$user."/device"); 
    829827                        if (empty($existingdevices)) { 
    830828                                $astman->database_put("AMPUSER",$user."/device",$id); 
    831829                        } else { 
    832                                 $existingdevices .= "&"; 
    833                                 //only append device value if this id doesn't exist in it already 
    834                                 if(strpos($existingdevices,$id."&") === false) // if not containing $id  
    835                                         $astman->database_put("AMPUSER",$user."/device",$existingdevices.$id); 
    836                         } 
    837                 } 
     830                                $existingdevices_array = explode('&',$existingdevices); 
     831                                if (!in_array($id, $existingdevices_array)) { 
     832                                        $existingdevices_array[]=$id; 
     833                                        $existingdevices = implode('&',$existingdevices_array); 
     834                                        $astman->database_put("AMPUSER",$user."/device",$existingdevices); 
     835                                } 
     836                        } 
     837                } 
     838 
    838839        } else { 
    839840                fatal("Cannot connect to Asterisk Manager with ".$amp_conf["AMPMGRUSER"]."/".$amp_conf["AMPMGRPASS"]); 
     
    885886                        // Remove the device record from the user's device list 
    886887                        $userdevices = $astman->database_get("AMPUSER",$deviceuser."/device"); 
    887                         /*$userdevices = str_replace($account."&", "", $userdevices."&"); 
    888                          
    889                         // If there was more than one device, remove the extra "&" at the end. 
    890                         if (substr($userdevices, -1, 1) == "&") { 
    891                                 $userdevices = substr($userdevices, 0, -1); 
    892                         }*/ 
     888 
     889                        // We need to remove just this user and leave the rest alone 
    893890                        $userdevicesarr = explode("&", $userdevices); 
    894                         array_splice($userdevicesarr, array_search($account, $userdevicesarr), 1); 
     891                        $userdevicesarr_hash = array_flip($userdevicesarr); 
     892                        unset($userdevicesarr_hash[$account]); 
     893                        $userdevicesarr = array_flip($userdevicesarr_hash); 
    895894                        $userdevices = implode("&", $userdevicesarr); 
    896895                         
     
    21372136 
    21382137 
     2138        //TODO: This needs to be yanked, should be in the upgrade script somewhere not here 
     2139        // 
    21392140        if (count($results) == 0) { 
    21402141                // see if they're still using the old dialprefix method