function Aastra_manage_userinfo_Asterisk($user, $action, $array = NULL) { # Translate user if needed $user = Aastra_get_userdevice_Asterisk($user); # Connect to AGI $as = new AGI_AsteriskManager(); $res = $as->connect(); # Process action switch ($action) { # Read database case 'get': # No answer $return = array(); # Cell Phone $get = $as->database_get('AMPUSER', $user . '/info/cell'); if ($get) { $return['cell'] = $get; } # Home phone $get = $as->database_get('AMPUSER', $user . '/info/home'); if ($get) { $return['home'] = $get; } # Other phone $get = $as->database_get('AMPUSER', $user . '/info/other'); if ($get) { $return['other'] = $get; } break; # Set values # Set values case 'set': # Cell phone if ($array['cell']) { $res = $as->database_put('AMPUSER', $user . '/info/cell', $array['cell']); } else { $res = $as->database_del('AMPUSER', $user . '/info/cell'); } # Home phone if ($array['home']) { $res = $as->database_put('AMPUSER', $user . '/info/home', $array['home']); } else { $res = $as->database_del('AMPUSER', $user . '/info/home'); } # Cell phone if ($array['other']) { $res = $as->database_put('AMPUSER', $user . '/info/other', $array['other']); } else { $res = $as->database_del('AMPUSER', $user . '/info/other'); } # Return $return = $array; break; } # Disconnect properly $as->disconnect(); # Return return $return; }
function setrobstatus($account, $incomingvalue, $mode) { require_once 'common/php-asmanager.php'; $amp_conf = parse_amportal_conf("/etc/amportal.conf"); $hosts = split(',', $amp_conf['MANAGERHOSTS']); foreach ($hosts as $host) { $astman = new AGI_AsteriskManager(); if ($res = $astman->connect($host, $amp_conf["AMPMGRUSER"], $amp_conf["AMPMGRPASS"])) { if ($mode == "write") { if ($incomingvalue == "Never") { $astman->database_del("ROBCHECK", $account); } if ($incomingvalue == "Always") { $astman->database_put("ROBCHECK", $account, "ENABLED"); } $robstatus = null; } if ($mode == "read") { $existrobstatus = $astman->database_get("ROBCHECK", $account); if ($existrobstatus) { $robstatus = "Always"; } else { $robstatus = "Never"; } } $astman->disconnect(); } else { echo "<h3>Cannot connect to Asterisk Manager {$host} with " . $amp_conf["AMPMGRUSER"] . "/" . $amp_conf["AMPMGRPASS"] . "</h3>This module requires access to the Asterisk Manager. Please ensure Asterisk is running and access to the manager is available.</div>"; exit; } } return $robstatus; }