Пример #1
0
function get_user_config($user, $menu_source, $menu_mode)
{
    global $language;
    # Retrieve phone data
    $update = 0;
    $header = Aastra_decode_HTTP_header();
    $header['model'] = strtolower($header['model']);
    $is_softkeys_supported = Aastra_is_softkeys_supported();
    # Read all menu
    $all = Aastra_readINIfile($menu_source . '.menu', '#', '=');
    # Get user config
    if ($is_softkeys_supported and $menu_mode == 'dynamic') {
        $config = Aastra_get_user_context($user, 'mymenu' . '_' . $menu_source);
    } else {
        $config = NULL;
    }
    # File does not exist
    if ($config == NULL) {
        unset($all['RESERVED']);
        foreach ($all as $key => $value) {
            if ($value[$header['model']] == 'no') {
                unset($all[$key]);
            } else {
                $all[$key]['title'] = Aastra_get_label($all[$key]['title'], $language);
            }
        }
        Aastra_natsort2d($all, 'title');
        foreach ($all as $key => $value) {
            $config['menu'][] = $key;
        }
        if ($is_softkeys_supported and $menu_mode == 'dynamic') {
            $update = 1;
        }
    } else {
        # Read config file
        foreach ($config['menu'] as $key => $value) {
            if ($all[$value] == NULL or $all[$value][$header['model']] == 'no') {
                unset($config['menu'][$key]);
                $update = 1;
            }
        }
    }
    # Read final file
    if ($update == 1) {
        Aastra_save_user_context($user, 'mymenu' . '_' . $menu_source, $config);
        unset($config);
        $config = Aastra_get_user_context($user, 'mymenu' . '_' . $menu_source);
    }
    # Return array
    return $config;
}
Пример #2
0
function get_user_config($user)
{
    global $asterisk;
    if ($asterisk) {
        $array_user = Aastra_get_user_context(Aastra_get_userdevice_Asterisk($user), 'contacts');
    } else {
        $array_user = Aastra_get_user_context($user, 'contacts');
    }
    if ($array_user['display'] == '') {
        $array_user['display'] = 'firstlast';
    }
    if ($array_user['sort'] == '') {
        $array_user['sort'] = 'first';
    }
    if ($asterisk) {
        Aastra_save_user_context(Aastra_get_userdevice_Asterisk($user), 'contacts', $array_user);
    } else {
        Aastra_save_user_context($user, 'contacts', $array_user);
    }
    return $array_user;
}
Пример #3
0
function Aastra_propagate_daynight_Asterisk($device, $index)
{
    global $ASTERISK_LOCATION;
    # Get the list of devices
    $sip_array = Aastra_readINIfile($ASTERISK_LOCATION . 'sip_additional.conf', ';', '=');
    foreach ($sip_array as $key => $value) {
        if ($value['callerid'] != '') {
            $array_device[] = $key;
        }
    }
    # Remove current device
    $array_device = array_flip($array_device);
    unset($array_device[$device]);
    unset($array_device['']);
    $array_device = array_flip($array_device);
    # Remove the devices without the application
    foreach ($array_device as $key => $value) {
        if (!Aastra_is_daynight_notify_allowed_Asterisk(Aastra_get_userdevice_Asterisk($value), $index)) {
            unset($array_device[$key]);
        } else {
            $data = Aastra_get_user_context($value, 'notify');
            $data['daynight'] = '1';
            Aastra_save_user_context($value, 'notify', $data);
        }
    }
    # Send Notification
    Aastra_send_SIP_notify_Asterisk('aastra-xml', $array_device);
}
Пример #4
0
function Aastra_read_signature($user)
{
    return Aastra_get_user_context($user, 'signature');
}
Пример #5
0
$language = Aastra_get_language();
# Get global compatibility
$nb_softkeys = Aastra_number_softkeys_supported();
# Callback
$XML_SERVER .= '?user='******'') {
    # Input zip code
    $object = new AastraIPPhoneInputScreen();
    $object->setTitle(Aastra_get_label('US Local Weather', $language));
    $object->setPrompt(Aastra_get_label('Enter ZIP code', $language));
    $object->setParameter('zip');
    $object->setType('number');
    $object->setURL($XML_SERVER);
    $object->setDestroyOnExit();
    $data = Aastra_get_user_context($user, 'weather');
    if ($data['last'] != NULL) {
        $object->setDefault($data['last']);
    }
    if ($nb_softkeys) {
        if ($nb_softkeys == 6) {
            $object->addSoftkey('1', Aastra_get_label('Backspace', $language), 'SoftKey:BackSpace');
            $object->addSoftkey('5', Aastra_get_label('Submit', $language), 'SoftKey:Submit');
            $object->addSoftkey('6', Aastra_get_label('Exit', $language), 'SoftKey:Exit');
        } else {
            $object->addSoftkey('10', Aastra_get_label('Exit', $language), 'SoftKey:Exit');
        }
    }
} else {
    # Save last value requested
    $data['last'] = $zip;
Пример #6
0
function update_user_config($user, $array_key, $header, $selection1, $selection2 = NULL, $type = 'key')
{
    # No special key yet
    $special = False;
    # Retrieve current configuration
    $array_temp = Aastra_readINIfile(AASTRA_TFTP_DIRECTORY . '/' . $header['mac'] . '.cfg', '#', ':');
    $array_user = $array_temp[''];
    # Prepare process of both keys
    if ($selection2) {
        $array_selection = array($selection1, $selection2);
    } else {
        $array_selection = array($selection1);
    }
    # Process both changes
    foreach ($array_selection as $selection) {
        # Key update
        if ($type == 'key') {
            # Update selection
            if ($array_key[$selection]['type'] != '' and $array_key[$selection]['type'] != 'empty') {
                # XML?
                if ($array_key[$selection]['type'] == 'xml') {
                    $special = True;
                }
                # Update configuration (MAC.cfg)
                $array_user[$selection . ' type'] = $array_key[$selection]['type'];
                $array_user[$selection . ' value'] = $array_key[$selection]['value'];
                $array_user[$selection . ' label'] = $array_key[$selection]['label'];
                if ($array_key[$selection]['states'] != '') {
                    $array_user[$selection . ' states'] = $array_key[$selection]['states'];
                } else {
                    unset($array_user[$selection . ' states']);
                }
                if ($array_key[$selection]['locked'] != '') {
                    $array_user[$selection . ' locked'] = $array_key[$selection]['locked'];
                } else {
                    unset($array_user[$selection . ' locked']);
                }
                # Update configuration (dynamic)
                $array_update[] = array('param' => $selection . ' type', 'value' => $array_user[$selection . ' type']);
                $array_update[] = array('param' => $selection . ' value', 'value' => $array_user[$selection . ' value']);
                $array_update[] = array('param' => $selection . ' label', 'value' => $array_user[$selection . ' label']);
                if ($array_key[$selection]['states'] != '') {
                    $array_update[] = array('param' => $selection . ' states', 'value' => $array_user[$selection . ' states']);
                }
                if ($array_key[$selection]['locked'] != '') {
                    $array_update[] = array('param' => $selection . ' locked', 'value' => $array_user[$selection . ' locked']);
                }
            } else {
                # Maybe we changed a special key
                if ($array_user[$selection . ' type'] == 'xml') {
                    $special = True;
                }
                # Key is not programmed but maybe locked
                if ($array_key[$selection]['type'] == '') {
                    unset($array_user[$selection . ' type']);
                } else {
                    $array_user[$selection . ' type'] = 'empty';
                }
                if ($array_key[$selection]['locked'] == '1') {
                    $array_user[$selection . ' locked'] = $array_key[$selection]['locked'];
                } else {
                    unset($array_user[$selection . ' locked']);
                }
                unset($array_user[$selection . ' value']);
                unset($array_user[$selection . ' label']);
                unset($array_user[$selection . ' states']);
                # Update array
                $array_update[] = array('param' => $selection . ' type', 'value' => $array_user[$selection . ' type']);
                $array_update[] = array('param' => $selection . ' value', 'value' => '');
                $array_update[] = array('param' => $selection . ' label', 'value' => '');
                $array_update[] = array('param' => $selection . ' locked', 'value' => $array_user[$selection . ' locked']);
                $array_update[] = array('param' => $selection . ' states', 'value' => '');
            }
        } else {
            # Update parameter
            $array_user[$selection] = $array_key[$selection]['value'];
            $array_update[] = array('param' => $selection, 'value' => $array_key[$selection]['value']);
        }
    }
    # Update MAC.cfg
    $write = @fopen(AASTRA_TFTP_DIRECTORY . '/' . $header['mac'] . '.cfg', 'w');
    if ($write) {
        # Dump the config file
        foreach ($array_user as $key => $value) {
            fputs($write, $key . ': ' . $value . "\n");
        }
        # Close the MAC.cfg file
        fclose($write);
        # Update the user keys
        $keys = Aastra_get_user_context($user, 'keys');
        foreach ($array_user as $key => $value) {
            if (stristr($key, 'key')) {
                $array_keys[$key] = $value;
            }
            if (stristr($key, 'expmod') and stristr($key, 'page')) {
                $array_keys[$key] = $value;
            }
        }
        $keys[$header['model']] = $array_keys;
        Aastra_save_user_context($user, 'keys', $keys);
    }
    # Update special keys
    if ($special) {
        $array_special = update_special_keys($user, $array_user);
    }
    # Save Configuration update
    if (!$special) {
        $array_selection = NULL;
        $array_special_keys = NULL;
    }
    $array_session = array('keys' => base64_encode(serialize(array($array_selection, $array_update, $array_special))));
    Aastra_save_session('key', '120', $array_session);
    # Return the need for notify
    return $special;
}
Пример #7
0
if ($user == '') {
    $user = $header['mac'];
}
# Keep return URI
$XML_SERVER .= '?user='******'biorhytm', 'user='******'1.4.2.', 0);
Aastra_test_php_function('imagecreate', Aastra_get_label('PHP-GD extension not installed.', $language));
$nb_softkeys = Aastra_number_softkeys_supported();
# Nothing entered
if ($bdate == '') {
    $date = Aastra_get_user_context($user, 'biorhytm');
    $object = new AastraIPPhoneInputScreen();
    $object->setTitle(Aastra_get_label('Biorhythms', $language));
    $object->setPrompt(Aastra_get_label('Birth Date (MM/DD/YYYY)', $language));
    $object->setParameter('bdate');
    $object->setType('dateUS');
    $object->setURL($XML_SERVER);
    $object->setDefault($date);
    $object->setDestroyOnExit();
    if ($nb_softkeys == 10) {
        $object->addSoftkey('10', Aastra_get_label('Exit', $language), "SoftKey:Exit");
    }
} else {
    # Save user context
    Aastra_save_user_context($user, 'biorhytm', $bdate);
    # Extract day/month/year
Пример #8
0
     if ($data['favorites'][$selection] != '' and $selection != 0) {
         $temp = $data['favorites'][$selection - 1];
         $data['favorites'][$selection - 1] = $data['favorites'][$selection];
         $data['favorites'][$selection] = $temp;
         Aastra_save_user_context($user, 'currency', $data);
         $default = $selection;
     } else {
         $default = $selection + 1;
     }
     $action = 'favorites';
     break;
     # Down
 # Down
 case 'down':
     # Retrieve favorites
     $data = Aastra_get_user_context($user, 'currency');
     if ($data['favorites'][$selection] != '' and $selection != AASTRA_MAXLINES - 1) {
         $temp = $data['favorites'][$selection + 1];
         $data['favorites'][$selection + 1] = $data['favorites'][$selection];
         $data['favorites'][$selection] = $temp;
         Aastra_save_user_context($user, 'currency', $data);
         $default = $selection + 2;
     } else {
         $default = $selection + 1;
     }
     $action = 'favorites';
     break;
     # Favorites
 # Favorites
 case 'favorites':
     $default = $selection + 1;
#############################################################################
require_once 'AastraCommon.php';
require_once 'AastraIPPhoneTextScreen.class.php';
require_once 'AastraIPPhoneScrollableTextMenu.class.php';
require_once 'AastraIPPhoneScrollableDirectory.class.php';
$cookie = Aastra_getvar_safe('listCookie');
$page = Aastra_getvar_safe('listPage');
$zoomIndex = Aastra_getvar_safe('zoomIndex');
$recentSelection = Aastra_getvar_safe('recentSelection');
$recentPage = Aastra_getvar_safe('recentPage');
Aastra_trace_call('LDAP directory', $_SERVER['REQUEST_URI']);
# Get Language and HTTP header
$language = Aastra_get_language();
$header = Aastra_decode_HTTP_header();
# Load user context
$menu = Aastra_get_user_context($header['mac'], 'scrollableTextMenuData');
if (!is_object($menu)) {
    # If not an object: Something went wrong when fetching the user context. Display error and exit.
    $object = new AastraIPPhoneTextScreen();
    $object->setTitle(Aastra_get_label('Server error', $language));
    $object->setText(Aastra_get_label('Context not found. Check cache directory settings.', $language));
    $object->output();
    exit;
}
if (!$menu->verifyCookie($cookie)) {
    # If cookie does not match: Display error and exit.
    $object = new AastraIPPhoneTextScreen();
    $object->setTitle(Aastra_get_label('Server error', $language));
    $object->setText(Aastra_get_label('Session not found. Please try again.', $language));
    $object->output();
    exit;
Пример #10
0
function create_mac($mac, $extension, $username, $secret, $callerid, $model, $profile, $tz_name, $tz_code, $lang_code, $lang)
{
    global $AA_XML_SERVER;
    global $AA_PROXY_SERVER;
    global $AA_REGISTRAR_SERVER;
    global $AA_XMLDIRECTORY;
    global $AA_PRESENCE_STATE;
    global $AA_SPEEDDIAL_STATE;
    global $AA_ASK_TZ;
    global $AA_FREEPBX_MODE;
    global $language;
    # So far so good
    $return = True;
    # Read profile file
    if ($AA_FREEPBX_MODE == '1') {
        $array_profile = Aastra_readCFGfile($profile . '-user.prf', '#', ':');
    } else {
        $array_profile = Aastra_readCFGfile($profile . '-device-nouser.prf', '#', ':');
    }
    if (count($array_profile) == 0) {
        Aastra_debug('Profile file ' . $profile . ' not available');
        return False;
    }
    # Check if model is available
    if (count($array_profile[$model]) == 0) {
        Aastra_debug('Phone model ' . $model . ' not configured in the Profile file (' . $profile . ')');
        return False;
    }
    # Get park configuration
    $park = Aastra_get_park_config_Asterisk();
    # Get polling value
    $polling = Aastra_get_polling_interval_Asterisk();
    # Prepare replace strings
    $search = array('/\\$\\$AA_SIPAUTHNAME_AA\\$\\$/', '/\\$\\$AA_SIPSECRET_AA\\$\\$/', '/\\$\\$AA_SIPUSERNAME_AA\\$\\$/', '/\\$\\$AA_SIPCALLERID_AA\\$\\$/', '/\\$\\$AA_TZ_NAME_AA\\$\\$/', '/\\$\\$AA_TZ_CODE_AA\\$\\$/', '/\\$\\$AA_XML_SERVER_AA\\$\\$/', '/\\$\\$AA_PROXY_SERVER_AA\\$\\$/', '/\\$\\$AA_REGISTRAR_SERVER_AA\\$\\$/', '/\\$\\$AA_PARKINGLOT_AA\\$\\$/', '/\\$\\$AA_XMLDIRECTORY_AA\\$\\$/', '/\\$\\$AA_INTERCOM_CODE_AA\\$\\$/', '/\\$\\$AA_POLLING_INT_AA\\$\\$/');
    $replace = array(quotemeta($username), $secret, quotemeta($extension), quotemeta($callerid), $tz_name, $tz_code, $AA_XML_SERVER, $AA_PROXY_SERVER, $AA_REGISTRAR_SERVER, $park['parkext'], $AA_XMLDIRECTORY, Aastra_get_intercom_config_Asterisk(), $polling);
    # Also use the core piece for device and user
    if ($AA_FREEPBX_MODE == '2') {
        foreach ($array_profile['Core'] as $key => $value) {
            $line = preg_replace($search, $replace, $value);
            if (stristr($line, '$$AA_KEYPRESS_AA$$')) {
                $pieces = explode(' ', $key);
                $line = preg_replace('/\\$\\$AA_KEYPRESS_AA\\$\\$/', $pieces[0], $line);
            }
            $array_config[$key] = $line;
        }
    }
    # Use the common piece
    foreach ($array_profile['Common'] as $key => $value) {
        $line = preg_replace($search, $replace, $value);
        if (stristr($line, '$$AA_KEYPRESS_AA$$')) {
            $pieces = explode(' ', $key);
            $line = preg_replace('/\\$\\$AA_KEYPRESS_AA\\$\\$/', $pieces[0], $line);
        }
        $array_config[$key] = $line;
    }
    # Model exists
    if ($array_profile[$model] != NULL) {
        # Check if full template
        if (key_exists('template', $array_profile[$model])) {
            $template = $array_profile[$model]['template'];
        } else {
            $template = $model;
        }
        # Use the template
        foreach ($array_profile[$template] as $key => $value) {
            if ($key != 'template') {
                $line = preg_replace($search, $replace, $value);
                if (stristr($line, '$$AA_KEYPRESS_AA$$')) {
                    $pieces = explode(' ', $key);
                    $line = preg_replace('/\\$\\$AA_KEYPRESS_AA\\$\\$/', $pieces[0], $line);
                }
                $array_config[$key] = $line;
            }
        }
        # Use the add-ons
        if ($template != $model) {
            foreach ($array_profile[$model] as $key => $value) {
                if ($key != 'template') {
                    $line = preg_replace($search, $replace, $value);
                    $array_config[$key] = $line;
                }
            }
        }
    }
    # Read user custom configuration
    $array_user = Aastra_readCFGfile('user-custom.prf', '#', ':');
    # User/Device exists
    if ($array_user[$extension] != NULL) {
        # Use the user configuration additions
        foreach ($array_user[$extension] as $key => $value) {
            $line = preg_replace($search, $replace, $value);
            if (stristr($line, '$$AA_KEYPRESS_AA$$')) {
                $pieces = explode(' ', $key);
                $line = preg_replace('/\\$\\$AA_KEYPRESS_AA\\$\\$/', $pieces[0], $line);
            }
            $array_config[$key] = $line;
        }
    }
    # Remove TZ if not needed
    if (!$AA_ASK_TZ) {
        unset($array_config['time zone name']);
        unset($array_config['time zone code']);
    }
    # Process language
    if ($lang_code != '') {
        $array_config['language'] = $lang_code;
        if (Aastra_test_phone_version('2.0.1.', '1') == 0) {
            $array_config['web language'] = $lang_code;
            $array_wl = array('fr' => 'French', 'it' => 'Italian', 'es' => 'Spanish', 'en' => 'English', 'de' => 'German', 'pt' => 'Portuguese');
            if ($array_wl[substr($lang, 0, 2)] != '') {
                $array_config['input language'] = $array_wl[substr($lang, 0, 2)];
            }
        }
    }
    # User mode
    if ($AA_FREEPBX_MODE == '1') {
        # Retrieve user keys
        $keys = Aastra_get_user_context($username, 'keys');
        # User has existing keys
        if (count($keys[$model]) != 0) {
            # Remove all profile keys
            foreach ($array_config as $key => $value) {
                if (stristr($key, 'key')) {
                    unset($array_config[$key]);
                }
            }
            # Add user keys
            foreach ($keys[$model] as $key => $value) {
                $array_config[$key] = $value;
            }
        }
        # Process day/night keys
        foreach ($array_config as $key => $value) {
            if (strstr($value, 'daynight.php')) {
                $pieces = explode(' ', $key);
                if (stristr($pieces[0], 'expmod')) {
                    $appli = $pieces[0] . ' ' . $pieces[1];
                } else {
                    $appli = $pieces[0];
                }
                $url = parse_url($value);
                parse_str($url['query'], $parse);
                if ($parse['index'] != '') {
                    $index = $parse['index'];
                } else {
                    $index = '';
                }
                if (!Aastra_is_daynight_appli_allowed_Asterisk($username, $index)) {
                    unset($array_config[$appli . ' type']);
                    unset($array_config[$appli . ' label']);
                    unset($array_config[$appli . ' value']);
                    unset($array_config[$appli . ' states']);
                }
            }
        }
        # Process presence
        if (!$AA_PRESENCE_STATE) {
            foreach ($array_config as $key => $value) {
                if (strstr($value, 'away.php')) {
                    $pieces = explode(' ', $key);
                    if (stristr($pieces[0], 'expmod')) {
                        $appli = $pieces[0] . ' ' . $pieces[1];
                    } else {
                        $appli = $pieces[0];
                    }
                    break;
                }
            }
            if ($appli != '') {
                unset($array_config[$appli . ' type']);
                unset($array_config[$appli . ' label']);
                unset($array_config[$appli . ' value']);
                unset($array_config[$appli . ' states']);
            }
        }
        # Process speed dial
        if (!$AA_SPEEDDIAL_STATE) {
            foreach ($array_config as $key => $value) {
                if (strstr($value, 'speed.php')) {
                    $pieces = explode(' ', $key);
                    if (stristr($pieces[0], 'expmod')) {
                        $appli = $pieces[0] . ' ' . $pieces[1];
                    } else {
                        $appli = $pieces[0];
                    }
                    break;
                }
            }
            if ($appli != '') {
                unset($array_config[$appli . ' type']);
                unset($array_config[$appli . ' label']);
                unset($array_config[$appli . ' value']);
                unset($array_config[$appli . ' states']);
            }
        }
    }
    # Translate the needed parameters
    foreach ($array_config as $key => $value) {
        $test = False;
        if (stristr($key, 'key') and stristr($key, 'label')) {
            $test = True;
        }
        if (stristr($key, 'xml application title')) {
            $test = True;
        }
        if ($test) {
            $array_config[$key] = Aastra_get_label($value, $language);
        }
    }
    # Config file
    $write = @fopen(AASTRA_TFTP_DIRECTORY . '/' . $mac . '.cfg', 'w');
    # No problem with the file
    if ($write) {
        # Dump the config file
        foreach ($array_config as $key => $value) {
            fputs($write, $key . ': ' . $value . "\n");
        }
        # Close the MAC.cfg file
        fclose($write);
    } else {
        # Trace
        Aastra_debug('Cannot write MAC.cfg (' . AASTRA_TFTP_DIRECTORY . '/' . $mac . '.cfg )');
        $return = False;
    }
    # Return result
    return $return;
}
Пример #11
0
     if ($away['key'] != '') {
         $object->AddEntry('Led: ' . $away['key'] . '=off');
     }
     $agent = Aastra_get_user_context($user, 'agent');
     if ($agent['key'] != '') {
         $object->AddEntry('Led: ' . $agent['key'] . '=off');
     }
     $follow = Aastra_get_user_context($user, 'follow');
     if ($follow['key'] != '') {
         $object->AddEntry('Led: ' . $follow['key'] . '=off');
     }
     $parking = Aastra_get_user_context($user, 'parking');
     if ($parking['key'] != '') {
         $object->AddEntry('Led: ' . $parking['key'] . '=off');
     }
     $vmail = Aastra_get_user_context($user, 'vmail');
     foreach ($vmail as $box => $value) {
         if ($value['key'] != '') {
             $object->AddEntry('Led: ' . $value['key'] . '=off');
         }
     }
 }
 for ($i = 1; $i <= $last; $i++) {
     $object->addEntry($XML_SERVER . '&action=configuration&page=' . $i);
 }
 $object->addEntry($array_config['action uri startup']);
 # Clear the critical keys
 Aastra_save_user_context($user, 'cfwd', NULL);
 Aastra_save_user_context($user, 'dnd', NULL);
 Aastra_save_user_context($user, 'daynight', NULL);
 Aastra_save_user_context($user, 'away', NULL);
Пример #12
0
     }
     # Send a SIP Notification if mode is device and user
     if (!$AA_FREEPBX_USEDEVSTATE and $AA_FREEPBX_MODE == '2') {
         Aastra_propagate_changes_Asterisk($user, Aastra_get_userdevice_Asterisk($user), array('dnd'));
     }
     break;
     # Initial or recurrent check
 # Initial or recurrent check
 case 'check':
 case 'register':
     # Update needed
     $update = 1;
     # Get current DND status
     $dnd = Aastra_manage_dnd_Asterisk($user, 'get');
     # Get last DND status
     $data = Aastra_get_user_context($user, 'dnd');
     $last = $data['last'];
     $key = $data['key'];
     # Save DND status
     $data['last'] = $dnd;
     if ($dnd != $last) {
         Aastra_save_user_context($user, 'dnd', $data);
     }
     # Update needed?
     if ($action == 'check' and $dnd == $last) {
         $update = 0;
     }
     if ($action == 'register' and $dnd == 0) {
         $update = 0;
     }
     # Prepare display update
Пример #13
0
     }
     # Send a SIP Notification if mode is device and user
     if (!$AA_FREEPBX_USEDEVSTATE and $AA_FREEPBX_MODE == '2') {
         Aastra_propagate_changes_Asterisk($user, Aastra_get_userdevice_Asterisk($user), array('cfwd'));
     }
     # Display status screen
     if ($mode != '1' and $action != 'cancel2') {
         $object->AddEntry($XML_SERVER);
     }
     break;
     # Enter forward number
 # Enter forward number
 case 'change':
 case 'change2':
     # Retrieve last input
     $data = Aastra_get_user_context($user, 'cfwd');
     # Input new call forward
     require_once 'AastraIPPhoneInputScreen.class.php';
     $object = new AastraIPPhoneInputScreen();
     $object->setDestroyOnExit();
     $object->setTitle(sprintf(Aastra_get_label('Call Forward for %s', $language), Aastra_get_userdevice_Asterisk($user)));
     $object->setPrompt(Aastra_get_label('Enter destination', $language));
     $object->setParameter('value');
     $object->setType('number');
     $object->setURL($XML_SERVER . '&action=set');
     $object->setDefault($data['input']);
     # Softkeys
     if ($nb_softkeys) {
         if ($nb_softkeys == 6) {
             $object->addSoftkey('1', Aastra_get_label('Backspace', $language), 'SoftKey:BackSpace');
             if ($action == 'change') {
Пример #14
0
     }
     break;
     # Initial or recurrent check
 # Initial or recurrent check
 case 'check':
 case 'register':
     # Update needed
     $update = 1;
     # Get global status
     if (is_agent_logged($agent)) {
         $status = 1;
     } else {
         $status = 0;
     }
     # Get last agent status
     $data = Aastra_get_user_context($agent, 'agent');
     $last = $data['last'];
     $key = $data['key'];
     # Save status if changed
     if ($status != $last) {
         $data['last'] = $status;
         Aastra_save_user_context($agent, 'agent', $data);
     }
     # Update needed?
     if ($action == 'check' and $status == $last) {
         $update = 0;
     }
     if ($action == 'register' and $status == 0) {
         $update = 0;
     }
     # Prepare display update
Пример #15
0
if ($asterisk) {
    Aastra_trace_call('asterisk_speed', 'user='******', action=' . $action . ', selection=' . $selection . ', value=' . $value . ', step=' . $step);
} else {
    Aastra_trace_call('speed', 'user='******', action=' . $action . ', selection=' . $selection . ', value=' . $value . ', step=' . $step);
}
# Test User Agent
Aastra_test_phone_versions(array('1' => '1.4.2.', '2' => '1.4.2.', '3' => '2.5.3.', '4' => '2.5.3.', '5' => '3.0.1.'), '0');
# Global data
$XML_SERVER .= '?user='******'&mode=' . $mode;
# Get Language
$language = Aastra_get_language();
# Init data
if ($asterisk) {
    $data = Aastra_get_user_context(Aastra_get_userdevice_Asterisk($user), 'speed');
} else {
    $data = Aastra_get_user_context($user, 'speed');
}
# Get global compatibility
$is_multipleinputfields = Aastra_is_multipleinputfields_supported();
$nb_softkeys = Aastra_number_softkeys_supported();
$is_icons = Aastra_is_icons_supported();
$is_style_textmenu = Aastra_is_style_textmenu_supported();
# Pre-Process action
switch ($action) {
    # UP
    case 'up':
        # Next action
        $action = 'nothing';
        # Entry must be real
        if ($data[$selection]['name'] != '') {
            # Not the first one
Пример #16
0
function get_user_context($user)
{
    # Get cached context
    $yahtzee = Aastra_get_user_context($user, 'yahtzee');
    # New game
    if ($yahtzee == NULL) {
        init_context($yahtzee);
        $yahtzee['hiscore'] = 0;
        $yahtzee['games'] = 0;
        $yahtzee['average'] = 0;
    }
    # Return context
    return $yahtzee;
}
Пример #17
0
                 $object->addSoftkey('5', Aastra_get_label('Watch List', $language), $XML_SERVER . '&action=favorites');
                 $object->addSoftkey('9', Aastra_get_label('New lookup', $language), $XML_SERVER . '&action=input');
                 $object->setCancelAction($XML_SERVER . '&action=input');
             } else {
                 $object->addSoftkey('8', Aastra_get_label('Back', $language), $XML_SERVER . '&action=favorites&selection=' . $selection);
                 $object->setCancelAction($XML_SERVER . '&action=favorites&selection=' . $selection);
             }
             $object->addSoftkey('10', Aastra_get_label('Exit', $language), 'SoftKey:Exit');
         }
     }
     break;
     # Summary
 # Summary
 case 'summary':
     # Retrieve favorites
     $data = Aastra_get_user_context($user, 'stock');
     foreach ($data['favorites'] as $key => $value) {
         if ($value != '') {
             $array[] = $value;
         }
     }
     $return = get_quote($array);
     # Return OK
     if ($return[0]) {
         # Create the object
         require_once 'AastraIPPhoneFormattedTextScreen.class.php';
         $object = new AastraIPPhoneFormattedTextScreen();
         # No color FTS
         if (!Aastra_is_formattedtextscreen_color_supported()) {
             # Process the results
             $nb_carac = Aastra_size_display_line();
Пример #18
0
             }
         }
     }
     break;
     # Check or Register
 # Check or Register
 case 'check':
 case 'register':
     # Context change
     $context = False;
     # Combined Status
     $combined = 0;
     # Retrieve status for all configured indexes
     $array_night = Aastra_manage_daynight_Asterisk('get_all', '');
     # Get last Day/Night status
     $data = Aastra_get_user_context($user, 'daynight');
     # Prepare display update
     require_once 'AastraIPPhoneExecute.class.php';
     $object = new AastraIPPhoneExecute();
     # Each configured index
     foreach ($array_night as $index => $value) {
         # Combined state
         if ($value['night'] == '1') {
             $combined = '1';
         }
         # User notified for this index?
         if (Aastra_is_daynight_notify_allowed_Asterisk($user, $index)) {
             # Update needed by default
             $update = 1;
             # Get current Day/Night status
             $night = $value['night'];
Пример #19
0
             $name = $i + 1 . '. .................................................';
         }
         $object->addEntry($name, $XML_SERVER . '&action=set&lookup=' . $lookup . '&speed=' . $i . '&selection=' . $selection . '&page=' . $page . '&orig_s=' . $orig_s, '');
     }
     # Softkeys
     $object->addSoftkey('9', Aastra_get_label('Cancel', $language), $XML_SERVER . '&action=' . $orig_s . '&lookup=' . $lookup . '&page=' . $page . '&selection=' . $selection, 1);
     $object->addSoftkey('10', Aastra_get_label('Exit', $language), 'SoftKey:Exit', 2);
     $object->addIcon(1, 'Icon:ArrowLeft');
     $object->addIcon(2, 'Icon:CircleRed');
     $object->setCancelAction($XML_SERVER . '&action=' . $orig_s . '&lookup=' . $lookup . '&page=' . $page . '&selection=' . $selection);
     break;
     # Save speed dial value
 # Save speed dial value
 case 'set':
     # Get user context
     $conf_speed = Aastra_get_user_context(Aastra_get_userdevice_Asterisk($user), 'speed');
     # Save value
     $conf_speed[$speed]['name'] = Aastra_get_callerid_Asterisk($selection);
     $conf_speed[$speed]['work'] = $selection;
     Aastra_save_user_context(Aastra_get_userdevice_Asterisk($user), 'speed', $conf_speed);
     # Display position
     require_once 'AastraIPPhoneTextScreen.class.php';
     $object = new AastraIPPhoneTextScreen();
     $object->setDestroyOnExit();
     $object->setTitle(Aastra_get_label('List Updated', $language));
     $position = $speed + 1;
     $object->setText(sprintf(Aastra_get_label('%s stored in speed dial list at position %d.', $language), $conf_speed[$speed]['name'], $position));
     # Softkey
     $object->addSoftkey('10', Aastra_get_label('Close', $language), $XML_SERVER . '&action=' . $orig_s . '&lookup=' . $lookup . '&page=' . $page . '&selection=' . $selection, 1);
     $object->addIcon(1, 'Icon:CircleRed');
     $object->setCancelAction($XML_SERVER . '&action=' . $orig_s . '&lookup=' . $lookup . '&page=' . $page . '&selection=' . $selection);
Пример #20
0
Aastra_test_phone_version('1.4.2.', 0);
# Get Phone language
$language = Aastra_get_language();
# Global compatibility
$nb_softkeys = Aastra_number_softkeys_supported();
# Initial call test on parameter passed
if (!$question) {
    # Input Question
    $object = new AastraIPPhoneInputScreen();
    $object->setDestroyOnExit();
    $object->setType('string');
    $object->setTitle(Aastra_get_label('Ask Google', $language));
    $object->setPrompt(Aastra_get_label('Enter your question', $language));
    $object->setParameter('question');
    $object->setURL($XML_SERVER);
    $data = Aastra_get_user_context($user, 'google');
    if ($data['last'] != NULL) {
        $default = $data['last'];
    } else {
        $default = 'Define SIP';
    }
    $object->setDefault($default);
    # Softkeys
    if ($nb_softkeys > 0) {
        if ($nb_softkeys < 7) {
            $object->addSoftkey('1', Aastra_get_label('Backspace', $language), 'SoftKey:BackSpace');
            $object->addSoftkey('2', Aastra_get_label('Help', $language), $XML_SERVER . '&question=help');
            $object->addSoftkey('3', Aastra_get_label('ABC', $language), 'SoftKey:ChangeMode');
            $object->addSoftkey('4', Aastra_get_label('NextSpace', $language), 'SoftKey:NextSpace');
            $object->addSoftkey('5', Aastra_get_label('Submit', $language), 'SoftKey:Submit');
            $object->addSoftkey('6', Aastra_get_label('Exit', $language), 'SoftKey:Exit');
Пример #21
0
     }
     break;
     # Modify current status
 # Modify current status
 case 'change_status':
 case 'change_status2':
     # Toggle status
     $fm = Aastra_manage_followme_Asterisk($user, 'change_status');
     # Prepare answer
     require_once 'AastraIPPhoneExecute.class.php';
     $object = new AastraIPPhoneExecute();
     # Update LED + idle screen
     if ($fm == '2') {
         $fm = '0';
     }
     $data = Aastra_get_user_context($user, 'follow');
     $last = $data['last'];
     $key = $data['key'];
     $data['last'] = $fm;
     if ($fm != $last) {
         Aastra_save_user_context($user, 'follow', $data);
         $object->setBeep();
         $object->addEntry($XML_SERVER . '&action=msg&value=' . $fm);
         if ($key != '') {
             if (Aastra_is_ledcontrol_supported()) {
                 if ($fm == '0') {
                     $object->AddEntry('Led: ' . $key . '=off');
                 } else {
                     $object->AddEntry('Led: ' . $key . '=on');
                 }
             }
Пример #22
0
             if ($action == 'list') {
                 $object->addSoftkey('5', Aastra_get_label('Favorites', $language), $XML_SERVER . '?page=' . $page . '&user='******'&action=favorites');
             }
             $object->addSoftkey('10', Aastra_get_label('Exit', $language), 'SoftKey:Exit');
         }
     }
     break;
     # Action on favorites
 # Action on favorites
 case 'favorites':
 case 'up':
 case 'down':
 case 'clear':
 case 'set':
     # Retrieve favorites
     $array_fav = Aastra_get_user_context($user, 'clock');
     # Process moves
     if ($action == 'up') {
         if ($selection != 0) {
             $temp['index'] = $array_fav[$selection - 1]['index'];
             $temp['name'] = $array_fav[$selection - 1]['name'];
             $array_fav[$selection - 1]['index'] = $array_fav[$selection]['index'];
             $array_fav[$selection - 1]['name'] = $array_fav[$selection]['name'];
             $array_fav[$selection]['index'] = $temp['index'];
             $array_fav[$selection]['name'] = $temp['name'];
             Aastra_save_user_context($user, 'clock', $array_fav);
         } else {
             $selection = 1;
         }
     }
     if ($action == 'down') {
Пример #23
0
 # Option menu
 case 'options':
     # Delete ALL
     $del_greetings == False;
     # Get current status
     $status = Aastra_get_greeting_status_Asterisk($user);
     # Display choice
     require_once 'AastraIPPhoneTextMenu.class.php';
     $object = new AastraIPPhoneTextMenu();
     $object->setDestroyOnExit();
     $object->setTitle(Aastra_get_label('Options', $language));
     $object->setStyle('none');
     $object->setWrapList();
     # VMAIL user Options
     $object->addEntry(Aastra_get_label('Change Password', $language), $XML_SERVER . '&action=chg_password&origin=' . $origin);
     $vmail_options = Aastra_get_user_context($ext, 'vmail-options');
     if ($vmail_options['auto_login'] == '1') {
         $object->addEntry(Aastra_get_label('Disable Auto-login', $language), $XML_SERVER . '&action=autologin');
     } else {
         $object->addEntry(Aastra_get_label('Enable Auto-login', $language), $XML_SERVER . '&action=autologin');
     }
     # Greetings
     if ($status['name']) {
         $object->addEntry(Aastra_get_label('Play Name', $language), $XML_SERVER . '&action=play_greetings&msg=name');
         $object->addEntry(Aastra_get_label('Modify Name', $language), $XML_SERVER . '&action=rec_greetings&msg=name');
         $object->addEntry(Aastra_get_label('Delete Name', $language), $XML_SERVER . '&action=del_greetings&msg=name');
         $del_greetings = True;
     } else {
         $object->addEntry(Aastra_get_label('Record Name', $language), $XML_SERVER . '&action=rec_greetings&msg=name');
     }
     if ($status['unavail']) {
Пример #24
0
function update_user_keys($user)
{
    # Get MAC address and type of phone
    $header = Aastra_decode_HTTP_header();
    # Read config file
    $array_temp = Aastra_readCFGfile(AASTRA_TFTP_DIRECTORY . '/' . $header['mac'] . '.cfg', '#', ':');
    $array_config = $array_temp[''];
    # Update user keys
    $keys = Aastra_get_user_context($user, 'keys');
    foreach ($array_config as $key => $value) {
        if (stristr($key, 'key')) {
            $array_key[$key] = $value;
        }
    }
    $keys[$header['model']] = $array_key;
    Aastra_save_user_context($user, 'keys', $keys);
}