Esempio n. 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;
}
Esempio n. 2
0
function format_date($value)
{
    global $AA_FORMAT_DT;
    # Day of the week
    $array_day = array('0' => Aastra_get_label('Sun', $language), '1' => Aastra_get_label('Mon', $language), '2' => Aastra_get_label('Tue', $language), '3' => Aastra_get_label('Wed', $language), '4' => Aastra_get_label('Thu', $language), '5' => Aastra_get_label('Fri', $language), '6' => Aastra_get_label('Sat', $language));
    # Apply local settings
    if ($AA_FORMAT_DT == 'US') {
        $date = strftime($array_day[strftime('%w', $value)] . ' ' . '%m/%d', $value);
    } else {
        $date = strftime($array_day[strftime('%w', $value)] . ' ' . '%d/%m', $value);
    }
    # Return result
    return $date;
}
Esempio n. 3
0
                        $object->addSoftkey('6', Aastra_get_label('Exit', $language), 'SoftKey:Exit');
                    } else {
                        if ($action == 'zoom') {
                            $object->addSoftkey('9', Aastra_get_label('Back', $language), $XML_SERVER . '?selection=' . $selection . '&user='******'&action=list' . '&page=' . $page);
                            $object->setCancelAction($XML_SERVER . '?selection=' . $selection . '&user='******'&action=list' . '&page=' . $page);
                        } else {
                            $object->addSoftkey('9', Aastra_get_label('Back', $language), $XML_SERVER . '?selection=' . $selection . '&user='******'&action=favorites');
                            $object->setCancelAction($XML_SERVER . '?selection=' . $selection . '&user='******'&action=favorites');
                        }
                        $object->addSoftkey('10', Aastra_get_label('Exit', $language), 'SoftKey:Exit');
                    }
                }
            } else {
                # Display error
                $object = new AastraIPPhoneTextScreen();
                $object->setDestroyOnExit();
                $object->setTitle(Aastra_get_label('Application error', $language));
                $object->setText(Aastra_get_label('The information you are looking for is not available at this time. Try again later.', $language));
            }
        } else {
            # Display error
            $object = new AastraIPPhoneTextScreen();
            $object->setDestroyOnExit();
            $object->setTitle(Aastra_get_label('Application error', $language));
            $object->setText(Aastra_get_label('The information you are looking for is not available at this time. Try again later.', $language));
        }
        break;
}
# Display object
$object->output();
exit;
Esempio n. 4
0
function init_keys($user, $header)
{
    global $array_config;
    # Phone supported?
    if ($array_config[$header['model']] != NULL) {
        if ($array_config[$header['model']]['top key'] == '1') {
            for ($i = 1; $i <= $array_config[$header['model']]['top key number']; $i++) {
                $array_key[$array_config[$header['model']]['top key type'] . $i]['key'] = $i;
                $array_key[$array_config[$header['model']]['top key type'] . $i]['internal'] = $array_config[$header['model']]['top key type'];
                $array_key[$array_config[$header['model']]['top key type'] . $i]['max'] = $array_config[$header['model']]['top key number'];
                $array_key[$array_config[$header['model']]['top key type'] . $i]['type'] = '';
                $array_key[$array_config[$header['model']]['top key type'] . $i]['label'] = '';
                $array_key[$array_config[$header['model']]['top key type'] . $i]['value'] = '';
                $array_key[$array_config[$header['model']]['top key type'] . $i]['states'] = '';
                $array_key[$array_config[$header['model']]['top key type'] . $i]['locked'] = '';
            }
        }
        if ($array_config[$header['model']]['bottom key'] == '1') {
            for ($i = 1; $i <= $array_config[$header['model']]['bottom key number']; $i++) {
                $array_key[$array_config[$header['model']]['bottom key type'] . $i]['key'] = $i;
                $array_key[$array_config[$header['model']]['bottom key type'] . $i]['internal'] = $array_config[$header['model']]['bottom key type'];
                $array_key[$array_config[$header['model']]['bottom key type'] . $i]['max'] = $array_config[$header['model']]['bottom key number'];
                $array_key[$array_config[$header['model']]['bottom key type'] . $i]['type'] = '';
                $array_key[$array_config[$header['model']]['bottom key type'] . $i]['label'] = '';
                $array_key[$array_config[$header['model']]['bottom key type'] . $i]['value'] = '';
                $array_key[$array_config[$header['model']]['bottom key type'] . $i]['states'] = '';
                $array_key[$array_config[$header['model']]['bottom key type'] . $i]['locked'] = '';
            }
        }
    }
    # Expansion modules
    for ($module = 1; $module <= 3; $module++) {
        $end = $array_config[$header['module'][$module]]['key number'];
        for ($i = 1; $i <= $end; $i++) {
            $array_key['expmod' . $module . ' key' . $i]['key'] = $i;
            $array_key['expmod' . $module . ' key' . $i]['internal'] = 'expmod' . $module . ' key';
            $array_key['expmod' . $module . ' key' . $i]['max'] = $end;
            $array_key['expmod' . $module . ' key' . $i]['type'] = '';
            $array_key['expmod' . $module . ' key' . $i]['label'] = '';
            $array_key['expmod' . $module . ' key' . $i]['value'] = '';
            $array_key['expmod' . $module . ' key' . $i]['locked'] = '';
        }
        if ($header['module'][$module] == '560M') {
            $array_key['expmod' . $module . 'page1left']['value'] = Aastra_get_label('LIST 1', $language);
            $array_key['expmod' . $module . 'page1right']['value'] = Aastra_get_label('LIST 2', $language);
            $array_key['expmod' . $module . 'page2left']['value'] = Aastra_get_label('LIST 3', $language);
            $array_key['expmod' . $module . 'page2right']['value'] = Aastra_get_label('LIST 4', $language);
            $array_key['expmod' . $module . 'page3left']['value'] = Aastra_get_label('LIST 5', $language);
            $array_key['expmod' . $module . 'page3right']['value'] = Aastra_get_label('LIST 6', $language);
            $array_key['expmod' . $module . 'page1left']['locked'] = 1;
            $array_key['expmod' . $module . 'page1right']['locked'] = 1;
            $array_key['expmod' . $module . 'page2left']['locked'] = 1;
            $array_key['expmod' . $module . 'page2right']['locked'] = 1;
            $array_key['expmod' . $module . 'page3left']['locked'] = 1;
            $array_key['expmod' . $module . 'page3right']['locked'] = 1;
        }
    }
    # Retrieve user keys and page labels
    $filename = AASTRA_TFTP_DIRECTORY . '/' . $header['mac'] . '.cfg';
    if (file_exists($filename)) {
        $array_user = Aastra_readINIfile($filename, '#', ':');
        foreach ($array_key as $key => $value) {
            if (isset($array_user[''][$key . ' type'])) {
                $array_key[$key]['type'] = $array_user[''][$key . ' type'];
                if (isset($array_user[''][$key . ' label'])) {
                    $array_key[$key]['label'] = $array_user[''][$key . ' label'];
                }
                if (isset($array_user[''][$key . ' value'])) {
                    $array_key[$key]['value'] = $array_user[''][$key . ' value'];
                }
                if (isset($array_user[''][$key . ' states'])) {
                    $array_key[$key]['states'] = $array_user[''][$key . ' states'];
                }
                if (isset($array_user[''][$key . ' locked'])) {
                    $array_key[$key]['locked'] = $array_user[''][$key . ' locked'];
                } else {
                    $array_key[$key]['locked'] = '0';
                }
            }
            if (isset($array_user[''][$key])) {
                $array_key[$key]['value'] = $array_user[''][$key];
            }
        }
    }
    # Check aastra.cfg for other defaulted keys
    $filename = AASTRA_TFTP_DIRECTORY . '/aastra.cfg';
    if (file_exists($filename)) {
        $array_user = Aastra_readINIfile($filename, '#', ':');
        foreach ($array_key as $key => $value) {
            if (isset($array_user[''][$key . ' type'])) {
                if (!in_array($key, $array_config[$header['model']]['defaulted keys'])) {
                    $array_config[$header['model']]['defaulted keys'][] = $key;
                }
            }
        }
    }
    # Return current key configuration
    return $array_key;
}
Esempio n. 5
0
            $object = new AastraIPPhoneTextScreen();
            $object->setTitle(Aastra_get_label('Currency converter', $language));
            $object->setText(Aastra_get_label('Information not available at this time. Please try again later.', $language));
        }
        # Add remaining softkeys
        if ($nb_softkeys == 6) {
            if ($action == 'display') {
                $object->addSoftkey('4', Aastra_get_label('New Lookup', $language), $XML_SERVER . '&action=init');
            } else {
                $object->addSoftkey('4', Aastra_get_label('Back', $language), $XML_SERVER . '&action=favorites&selection=' . $selection);
            }
            $object->addSoftkey('6', Aastra_get_label('Exit', $language), 'SoftKey:Exit');
        } else {
            if ($action == 'display') {
                $object->addSoftkey('6', Aastra_get_label('New Lookup', $language), $XML_SERVER . '&action=init');
            } else {
                $object->addSoftkey('9', Aastra_get_label('Back', $language), $XML_SERVER . '&action=favorites&selection=' . $selection);
            }
            $object->addSoftkey('10', Aastra_get_label('Exit', $language), 'SoftKey:Exit');
        }
        break;
}
# Top title
if (Aastra_is_top_title_supported()) {
    $object->setTopTitle(Aastra_get_label('Currency'), '', '1');
    $object->addIcon('1', 'http://' . $AA_XML_SERVER . '/' . $AA_XMLDIRECTORY . '/icons/currency.png');
}
# Display object
$object->setDestroyOnExit();
$object->output();
exit;
Esempio n. 6
0
                    $object->setTitle(Aastra_get_label('Directory', $language));
                }
            } else {
                if ($last != 1) {
                    $object->setTitle(sprintf(Aastra_get_label('Results (%s-%s)', $language), $min, $max));
                } else {
                    $object->setTitle(Aastra_get_label('Results', $language));
                }
            }
        } else {
            # Display error
            require_once 'AastraIPPhoneTextScreen.class.php';
            $object = new AastraIPPhoneTextScreen();
            $object->setDestroyOnExit();
            if ($lookup == '') {
                $object->setTitle(Aastra_get_label('Directory error', $language));
                $object->setText(Aastra_get_label('Directory list is empty. Please contact your administrator.', $language));
            } else {
                $object->setTitle(Aastra_get_label('Lookup error', $language));
                $object->setText(Aastra_get_label('Sorry no match.', $language));
            }
            # Softkey
            if ($lookup != '') {
                $object->setDoneAction($XML_SERVER . '&action=search&lookup=' . $lookup);
            }
        }
        break;
}
# Output XML object
$object->output();
exit;
function Aastra_status_config_Asterisk()
{
    global $language;
    # Read config file
    $array = Aastra_readINIfile(AASTRA_CONFIG_DIRECTORY . 'status.conf', '#', '=');
    # Do some cleanup
    foreach ($array as $key => $value) {
        if (!is_numeric($key) or $key < 1 or $key > 98) {
            unset($array[$key]);
        } else {
            if ($value['type'] != 'out' or $value['type'] != 'available' or $value['type'] != 'unavailable') {
                $array[$key]['type'] = 'available';
            }
        }
    }
    # Add available
    $array[AA_PRESENCE_AVAILABLE] = array('label' => Aastra_get_label('Available', $language), 'type' => 'available', 'mnemonic' => '_');
    # Add disconnected
    $array[AA_PRESENCE_DISCONNECTED] = array('label' => Aastra_get_label('Disconnected', $language), 'type' => 'unavailable', 'mnemonic' => Aastra_get_label('D', $language));
    # Return array
    return $array;
}
Esempio n. 8
0
                }
                $object->addSoftkey('4', Aastra_get_label('Back', $language), $XML_SERVER . '&zip=' . $zip);
                if ($index != count($array_rss) - 2) {
                    $object->addSoftkey('5', Aastra_get_label('Next', $language), $XML_SERVER . '&zip=' . $zip . '&index=' . ($index + 2));
                }
                $object->addSoftkey('6', Aastra_get_label('Exit', $language), 'SoftKey:Exit');
            } else {
                $softkey = 1;
                foreach ($array_rss as $key => $value) {
                    if ($key != '99') {
                        $object->addSoftkey($softkey, $value['title'], $value['uri'] . '&user='******'9', Aastra_get_label('Back', $language), $XML_SERVER);
                    $object->addSoftkey('10', Aastra_get_label('Exit', $language), 'SoftKey:Exit');
                }
                $object->setCancelAction($XML_SERVER);
            }
        } else {
            $object->setCancelAction($XML_SERVER);
        }
    }
}
# Top title
if (Aastra_is_top_title_supported()) {
    $object->setTopTitle(Aastra_get_label('US Weather'), '', '1');
    $object->addIcon('1', 'http://' . $AA_XML_SERVER . '/' . $AA_XMLDIRECTORY . '/icons/weather.png');
}
# Display output
$object->output();
exit;
Esempio n. 9
0
                        if ($nb_softkeys == 6) {
                            $object->addSoftkey('6', Aastra_get_label('Exit', $language), 'SoftKey:Exit');
                        } else {
                            $object->addSoftkey('10', Aastra_get_label('Exit', $language), 'SoftKey:Exit');
                        }
                    }
                }
            } else {
                # Display error as a TextScreen
                $object = new AastraIPPhoneTextScreen();
                $object->setDestroyOnExit();
                $object->setTitle(Aastra_get_label('User Login', $language));
                $object->setText(Aastra_get_label('Wrong user credentials.', $language));
                if ($nb_softkeys) {
                    if ($nb_softkeys == 6) {
                        $object->addSoftkey('5', Aastra_get_label('Cancel', $language), 'SoftKey:Exit');
                        $object->addSoftkey('6', Aastra_get_label('Close', $language), $XML_SERVER . '&action=input');
                    } else {
                        $object->addSoftkey('9', Aastra_get_label('Cancel', $language), 'SoftKey:Exit');
                        $object->addSoftkey('10', Aastra_get_label('Close', $language), $XML_SERVER . '&action=input');
                    }
                }
            }
            break;
    }
}
# Display XML Object
$object->output();
exit;
?>
7
Esempio n. 10
0
                $object->addSoftkey('1', Aastra_get_label('Change', $language), $XML_SERVER . '&action=' . $change);
                $object->addSoftkey('2', Aastra_get_label('Deactivate', $language), $XML_SERVER . '&action=cancel');
            }
            if ($nb_softkeys == 6) {
                $object->addSoftkey('3', Aastra_get_label('My Numbers', $language), $XML_SERVER . '&action=info');
                $object->addSoftkey('6', Aastra_get_label('Exit', $language), 'SoftKey:Exit');
            } else {
                $object->addSoftkey('6', Aastra_get_label('My Numbers', $language), $XML_SERVER . '&action=info');
                $object->addSoftkey('10', Aastra_get_label('Exit', $language), 'SoftKey:Exit');
            }
        } else {
            # TextMenu for non softkey phone
            require_once 'AastraIPPhoneTextMenu.class.php';
            $object = new AastraIPPhoneTextMenu();
            $object->setDestroyOnExit();
            if ($cf == '') {
                $object->setTitle(Aastra_get_label('CFWD deactivated', $language));
                $object->addEntry(Aastra_get_label('Activate', $language), $XML_SERVER . '&action=' . $change);
            } else {
                $object->setTitle(sprintf(Aastra_get_label('CFWD set (%s)', $language), $cf));
                $object->addEntry(Aastra_get_label('Deactivate', $language), $XML_SERVER . '&action=cancel');
                $object->addEntry(Aastra_get_label('Change', $language), $XML_SERVER . '&action=' . $change);
            }
            $object->addEntry(Aastra_get_label('My numbers', $language), $XML_SERVER . '&action=info');
            $object->addEntry(Aastra_get_label('Exit', $language), 'SoftKey:Exit');
        }
        break;
}
# Display answer
$object->output();
exit;
Esempio n. 11
0
            foreach ($directory as $v) {
                if ($index >= ($page - 1) * $MaxLines + 1 and $index <= $page * $MaxLines) {
                    if ($v['number'] == $selection) {
                        $object->setDefaultIndex($rank);
                    }
                    if ($AA_PRESENCE_STATE) {
                        $object->addEntry('[' . $status_text[$v['status']]['mnemonic'] . ']' . $v['name'], $XML_SERVER . '&action=zoom&selection=' . $v['number'], $v['number']);
                    } else {
                        $object->addEntry($v['name'], $XML_SERVER . '&action=dial&selection=' . $v['number'], $v['number']);
                    }
                    $rank++;
                }
                $index++;
            }
            # Next Page
            if ($page != $last) {
                $object->addEntry(Aastra_get_label('Next Page', $language), $XML_SERVER . '&action=list&page=' . ($page + 1));
            }
        } else {
            # Display error
            require_once 'AastraIPPhoneTextScreen.class.php';
            $object = new AastraIPPhoneTextScreen();
            $object->setDestroyOnExit();
            $object->setTitle(Aastra_get_label('Directory error', $language));
            $object->setText(Aastra_get_label('Directory list is empty. Please contact your administrator.', $language));
        }
        break;
}
# Output XML object
$object->output();
exit;
Esempio n. 12
0
                    $object->addSoftkey(8, Aastra_get_label('Next', $language), $XML_SERVER . '&action=display&page=' . ($page + 1) . '&confno=' . $confno . '&mode=' . $mode);
                }
                $object->addSoftkey('9', Aastra_get_label('Back', $language), $XML_SERVER . '&confno=' . $confno);
                $object->addSoftkey(10, Aastra_get_label('Exit', $language), 'SoftKey:Exit');
            }
        }
        # Test the refresh
        if (Aastra_is_Refresh_supported()) {
            $object->setRefresh('5', $XML_SERVER . '&action=refresh&page=' . $page . '&confno=' . $confno . '&mode=' . $mode);
            $new = $object->generate();
        } else {
            $refresh = 1;
            if ($nb_softkeys == 6) {
                $object->addSoftkey(3, Aastra_get_label('Refresh', $language), $XML_SERVER . '&action=display&page=' . $page . '&confno=' . $confno . '&mode=' . $mode);
            } else {
                $object->addSoftkey(6, Aastra_get_label('Refresh', $language), $XML_SERVER . '&action=display&page=' . $page . '&confno=' . $confno . '&mode=' . $mode);
            }
        }
        # Test refresh
        if ($refresh == 0) {
            $old = @file_get_contents(AASTRA_PATH_CACHE . $header['mac'] . '.meetme');
            if ($new != $old) {
                $refresh = 1;
            }
        }
        # Save last screen
        $stream = @fopen(AASTRA_PATH_CACHE . $header['mac'] . '.meetme', 'w');
        @fwrite($stream, $new);
        @fclose($stream);
        break;
}
Esempio n. 13
0
function WARNINGErrorHandler($code, $string, $file, $line)
{
    global $LANGUAGE;
    if (preg_match("/Sizelimit exceeded/i", $string)) {
        display_message(Aastra_get_label('LDAP Error', $LANGUAGE), Aastra_get_label('Result size limit exceeded. Provide more letters.', $LANGUAGE), $XML_SERVER);
    } else {
        display_message(Aastra_get_label('Application error', $LANGUAGE), Aastra_get_label('Error Message', $LANGUAGE) . ": " . $string, $XML_SERVER);
    }
    exit;
}
Esempio n. 14
0
            require_once 'AastraIPPhoneExecute.class.php';
            $object = new AastraIPPhoneExecute();
            $object->setTriggerDestroyOnExit('');
            $object->addEntry('');
        } else {
            # Error message
            require_once 'AastraIPPhoneTextScreen.class.php';
            $object = new AastraIPPhoneTextScreen();
            $object->setDestroyOnExit();
            $object->setTitle(Aastra_get_label('Pickup failed', $language));
            $object->setText(Aastra_get_label('Failed to intercept the caller in the queue.', $language));
            # Softkeys
            if ($nb_softkeys == 6) {
                $object->addSoftKey('6', Aastra_get_label('Close', $language), $XML_SERVER . '&action=show_queues&queue=' . $queue);
            } else {
                $object->addSoftKey('10', Aastra_get_label('Close', $language), $XML_SERVER . '&action=show_queues&queue=' . $queue);
                $object->setCancelAction($XML_SERVER . '&action=show_queues&queue=' . $queue);
            }
        }
        break;
}
# Display XML object
if ($refresh == 1) {
    $object->output();
} else {
    # Do nothing
    require_once 'AastraIPPhoneExecute.class.php';
    $object2 = new AastraIPPhoneExecute();
    $object2->addEntry('');
    $object2->output();
}
Esempio n. 15
0
if ($found == 0 and $number != 'Paging' and $number != '') {
    # Translate user if needed
    $user = Aastra_get_userdevice_Asterisk($user);
    # Check if call has been parked
    $park = Aastra_check_park_Asterisk($user, $number);
    # Display orbit
    if ($park != '') {
        # Display current status
        require_once 'AastraIPPhoneStatus.class.php';
        $object = new AastraIPPhoneStatus();
        $object->setSession('Park');
        $object->setBeep();
        if (Aastra_size_display_line() > 16) {
            $object->addEntry('1', sprintf(Aastra_get_label('Call Parked at %s', $language), $park), 'alert', 5);
        } else {
            $object->addEntry('1', sprintf(Aastra_get_label('Parked at %s', $language), $park), 'alert', 5);
        }
        # Bug 3.2.1
        if (Aastra_test_phone_version('3.2.1.', '1') == 0) {
            sleep(4);
        }
        # End of search
        $found = 1;
    }
}
# No match whatsoever
if ($found == 0) {
    require_once 'AastraIPPhoneExecute.class.php';
    $object = new AastraIPPhoneExecute();
    $object->addEntry('');
}
 function _setupSoftKeys()
 {
     if (Aastra_is_softkeys_supported()) {
         if (Aastra_phone_type() != 5) {
             # non 6739i
             $this->addSoftkey($this->_selectKeyPosition, Aastra_get_label($this->_selectKeyLabel, $this->_language), 'SoftKey:Select');
             if (!$this->_exitKeyDisabled) {
                 $this->addSoftkey($this->_exitKeyPosition, Aastra_get_label('Exit', $this->_language), 'SoftKey:Exit');
             }
             if (!empty($this->_backCancelURL)) {
                 $this->addSoftkey($this->_backKeyPosition, Aastra_get_label('Back', $this->_language), $this->_backCancelURL);
             }
         } else {
             # 6739i SoftKey:Select not yet supported
             #$this->addSoftkey($this->_selectKeyPosition, Aastra_get_label($this->_selectKeyLabel,$this->_language), 'SoftKey:Select',$this->_selectKeyIconIndex);
             if (!$this->_exitKeyDisabled) {
                 $this->addSoftkey($this->_exitKeyPosition, Aastra_get_label('Exit', $this->_language), 'SoftKey:Exit', $this->_exitKeyIconIndex);
             }
             if (!empty($this->_backCancelURL)) {
                 $this->addSoftkey($this->_backKeyPosition, Aastra_get_label('Back', $this->_language), $this->_backCancelURL, $this->_backKeyIconIndex);
             }
         }
     }
 }
Esempio n. 17
0
                        } else {
                            $object->addSoftkey('9', Aastra_get_label('Back', $language), $XML_SERVER . '?selection=' . $selection . '&user='******'&action=favorites');
                            $object->setCancelAction($XML_SERVER . '?selection=' . $selection . '&user='******'&action=favorites');
                        }
                        $object->addSoftkey('10', Aastra_get_label('Exit', $language), 'SoftKey:Exit');
                    }
                }
            } else {
                # Display error
                $object = new AastraIPPhoneTextScreen();
                $object->setDestroyOnExit();
                $object->setTitle(Aastra_get_label('Application error', $language));
                $object->setText(Aastra_get_label('The information you are looking for is not available at this time. Try again later.', $language));
            }
        } else {
            # Display error
            $object = new AastraIPPhoneTextScreen();
            $object->setDestroyOnExit();
            $object->setTitle(Aastra_get_label('Application error', $language));
            $object->setText(Aastra_get_label('The information you are looking for is not available at this time. Try again later.', $language));
        }
        break;
}
# Top title
if (Aastra_is_top_title_supported()) {
    $object->setTopTitle(Aastra_get_label('World Clock'), '', '1');
    $object->addIcon('1', 'http://' . $AA_XML_SERVER . '/' . $AA_XMLDIRECTORY . '/icons/clock.png');
}
# Display object
$object->output();
exit;
Esempio n. 18
0
$XML_SERVER .= '?user='******'msg':
        # Update idle screen
        require_once 'AastraIPPhoneStatus.class.php';
        $object = new AastraIPPhoneStatus();
        $object->setSession('aastra-xml');
        $index = Aastra_get_status_index_Asterisk('dnd');
        if ($status == 1) {
            if (Aastra_is_status_uri_supported()) {
                $object->addEntry($index, Aastra_get_label('DND activated', $language), '', NULL, $XML_SERVER, 1);
                $object->addIcon('1', 'Icon:Prohibit');
            } else {
                $object->addEntry($index, Aastra_get_label('DND activated', $language));
            }
        } else {
            $object->addEntry($index, '');
        }
        break;
        # Switch On/Off
    # Switch On/Off
    case 'change':
        # Change DND status
        $dnd = Aastra_manage_dnd_Asterisk($user, 'change');
        # Prepare display update
        require_once 'AastraIPPhoneExecute.class.php';
        $object = new AastraIPPhoneExecute();
        # Pause/Unpause from queues
        if ($AA_DNDPAUSE) {
Esempio n. 19
0
function Aastra_send_HDmail($header, $callerid, $action, $to, $sender)
{
    global $language;
    # Test target
    if ($to != '') {
        $subject = sprintf(Aastra_get_label('Hot Desking event for %s (%s)', $language), $callerid, $action);
        $body = sprintf(Aastra_get_label('Action: %s', $language), $action) . "\n";
        $body .= sprintf(Aastra_get_label('User: %s', $language), $callerid) . "\n";
        $body .= sprintf(Aastra_get_label('MAC address: %s', $language), $header['mac']) . "\n";
        $body .= sprintf(Aastra_get_label('Phone model: %s', $language), $header['model']) . "\n";
        $body .= sprintf(Aastra_get_label('IP address: %s', $language), $header['ip']) . "\n";
        $body .= sprintf(Aastra_get_label('Server address: %s', $language), $_SERVER['SERVER_ADDR']) . "\n";
        $header = 'From: ' . $sender . "\nX-Mailer: PHP Script\n";
        mail($to, $subject, $body, $header);
    }
}
Esempio n. 20
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;
}
Esempio n. 21
0
        }
    }
    $object->setCancelAction($XML_SERVER);
} else {
    # Input area code
    $object = new AastraIPPhoneInputScreen();
    $object->setTitle(Aastra_get_label('Area code finder', $language));
    $object->setPrompt(Aastra_get_label('Enter area code', $language));
    $object->setParameter('area');
    $object->setType('number');
    $object->setURL($XML_SERVER);
    $object->setDestroyOnExit();
    # Softkeys
    if ($nb_softkeys > 0) {
        if ($nb_softkeys < 7) {
            $object->addSoftkey('1', Aastra_get_label('Backspace', $language), 'SoftKey:BackSpace');
            $object->addSoftkey('5', Aastra_get_label('Lookup', $language), 'SoftKey:Submit');
            $object->addSoftkey('6', Aastra_get_label('Exit', $language), 'SoftKey:Exit');
        } else {
            $object->addSoftkey('10', Aastra_get_label('Exit', $language), 'SoftKey:Exit');
        }
    }
}
# Top title
if (Aastra_is_top_title_supported()) {
    $object->setTopTitle(Aastra_get_label('Area code lookup'), '', '1');
    $object->addIcon('1', 'http://' . $AA_XML_SERVER . '/' . $AA_XMLDIRECTORY . '/icons/area.png');
}
# Display object
$object->output();
exit;
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;
}
if ($recentSelection != "") {
    $menu->setDefaultIndex($recentSelection);
}
if ($zoomIndex != "") {
    $menu->zoom($zoomIndex, $recentPage, $recentSelection);
} else {
    $menu->output($page);
}
exit;
 function _setupSoftKeys()
 {
     # Check if softkeys and the Dial2 softkey is supported. Don't put dial key on 6739i
     if (Aastra_is_softkeys_supported() && !Aastra_test_phone_version('2.0.1.', 1) && Aastra_phone_type() != 5) {
         $this->addSoftkey($this->_dialKeyPosition, Aastra_get_label('Dial', $this->_language), 'SoftKey:Dial2');
     }
     parent::_setupSoftKeys();
 }
Esempio n. 24
0
                    $object->addLine(sprintf(Aastra_get_label('P=%+.3f %s', $language), $array['day']['P'], $array['trend']['P']));
                    $object->setScrollEnd();
                }
            } else {
                # create object
                $object = new AastraIPPhoneTextScreen();
                $object->setTitle(Aastra_get_language('BIORHYTHMS', $language));
                $object->setText(sprintf(Aastra_get_label('I=%+.3f, E=%+.3f, P=%+.3f', $language), $array['day']['I'], $array['day']['E'], $array['day']['P']));
            }
        }
    }
    # Common parameters
    $object->setDestroyOnExit();
    if ($nb_softkeys) {
        if ($nb_softkeys == 6) {
            $object->addSoftkey('5', Aastra_get_label('Back', $language), $XML_SERVER);
            $object->addSoftkey('6', Aastra_get_label('Exit', $language), 'SoftKey:Exit');
        } else {
            $object->addSoftkey('9', Aastra_get_label('Back', $language), $XML_SERVER);
            $object->addSoftkey('10', Aastra_get_label('Exit', $language), 'SoftKey:Exit');
        }
    }
}
# Top title
if (Aastra_is_top_title_supported()) {
    $object->setTopTitle(Aastra_get_label('Biorhythms'), '', '1');
    $object->addIcon('1', 'http://' . $AA_XML_SERVER . '/' . $AA_XMLDIRECTORY . '/icons/bio.png');
}
# Display object
$object->output();
exit;
Esempio n. 25
0
                    $object->addLine(sprintf(Aastra_get_label('P=%+.3f %s', $language), $array['day']['P'], $array['trend']['P']));
                } else {
                    $object->setScrollStart('2');
                    $object->addLine(sprintf(Aastra_get_label('I=%+.3f %s', $language), $array['day']['I'], $array['trend']['I']));
                    $object->addLine(sprintf(Aastra_get_label('E=%+.3f %s', $language), $array['day']['E'], $array['trend']['E']));
                    $object->addLine(sprintf(Aastra_get_label('P=%+.3f %s', $language), $array['day']['P'], $array['trend']['P']));
                    $object->setScrollEnd();
                }
            } else {
                # create object
                $object = new AastraIPPhoneTextScreen();
                $object->setTitle(Aastra_get_language('BIORHYTHMS', $language));
                $object->setText(sprintf(Aastra_get_label('I=%+.3f, E=%+.3f, P=%+.3f', $language), $array['day']['I'], $array['day']['E'], $array['day']['P']));
            }
        }
    }
    # Common parameters
    $object->setDestroyOnExit();
    if ($nb_softkeys) {
        if ($nb_softkeys == 6) {
            $object->addSoftkey('5', Aastra_get_label('Back', $language), $XML_SERVER);
            $object->addSoftkey('6', Aastra_get_label('Exit', $language), 'SoftKey:Exit');
        } else {
            $object->addSoftkey('9', Aastra_get_label('Back', $language), $XML_SERVER);
            $object->addSoftkey('10', Aastra_get_label('Exit', $language), 'SoftKey:Exit');
        }
    }
}
# Display object
$object->output();
exit;
Esempio n. 26
0
                $object->setScrollEnd();
                $object->addLine(Aastra_get_label('Powered by Yahoo', $language), '', 'center');
            }
        } else {
            # Prepare result screen
            $object = new AastraIPPhoneTextScreen();
            require_once 'AastraIPPhoneTextScreen.class.php';
            $object->setTitle(Aastra_get_label('Stock results', $language));
            $object->setText(Aastra_get_label('Information not available at this time. Please try again later.', $language));
        }
        # Add remaining softkeys
        if ($nb_softkeys > 0) {
            if ($nb_softkeys == 6) {
                $object->addSoftkey('5', Aastra_get_label('Back', $language), $XML_SERVER . '&action=favorites&selection=' . $selection);
                $object->addSoftkey('6', Aastra_get_label('Exit', $language), 'SoftKey:Exit');
            } else {
                $object->addSoftkey('8', Aastra_get_label('Back', $language), $XML_SERVER . '&action=favorites&selection=' . $selection);
                $object->addSoftkey('10', Aastra_get_label('Exit', $language), 'SoftKey:Exit');
                $object->setCancelAction($XML_SERVER . '&action=favorites&selection=' . $selection);
            }
        }
        break;
}
# Display object
$object->setDestroyOnExit();
if (Aastra_is_top_title_supported()) {
    $object->setTopTitle(Aastra_get_label('Stock Quotes'), '', '1');
    $object->addIcon('1', 'http://' . $AA_XML_SERVER . '/' . $AA_XMLDIRECTORY . '/icons/stocks.png');
}
$object->output();
exit;
Esempio n. 27
0
$vars['__EXTENSION'] = $extension;
if ($argc == 4) {
    $vars['NAME_RECORDING'] = $argv[3];
}
# Connect to the AGI
$asm = new AGI_AsteriskManager();
$asm->connect();
# Get language
$language = Aastra_get_language();
# Notify each phone
for ($i = 0; $i < sizeof($notify); $i++) {
    $vars['__REALCALLERIDNUM'] = $notify[$i];
    $state = $asm->ExtensionState($notify[$i], 'default');
    if ($state['Status'] != 0) {
        $vars['NOTIFY_VM'] = 'true';
    }
    while (list($key, $val) = each($vars)) {
        $vars_arr[] = "{$key}={$val}";
    }
    if (Aastra_compare_version_Asterisk('1.6')) {
        $vars = implode(',', $vars_arr);
    } else {
        $vars = implode('|', $vars_arr);
    }
    $res = $asm->Originate2('Local/' . $notify[$i] . '@presence-notify', 9999, 'default', 1, null, null, null, sprintf(Aastra_get_label('%s is back <%s>', $language), $extension, $extension), $vars);
    flush();
    sleep(30);
    // give them a break inbetween calls, so they don't get flood of them all at once ;)
}
# Disconnect properly
$asm->disconnect();
Esempio n. 28
0
function generate_user_config($device, $user, $last_user)
{
    global $AA_XML_SERVER;
    global $AA_XMLDIRECTORY;
    global $AA_PRESENCE_STATE;
    global $AA_SPEEDDIAL_STATE;
    global $language;
    # Get type of phone
    $header = Aastra_decode_HTTP_header();
    $model = $header['model'];
    # Read profile file
    if ($user != '') {
        $profile = Aastra_get_startup_profile_Asterisk($user);
    } else {
        $profile = Aastra_get_startup_profile_Asterisk($device);
    }
    $array_user = Aastra_readCFGfile($profile . '-device-user.prf', '#', ':');
    $array_nouser = Aastra_readCFGfile($profile . '-device-nouser.prf', '#', ':');
    $array_custom = Aastra_readCFGfile('user-custom.prf', '#', ':');
    # Language
    $code = Aastra_ask_language_Asterisk();
    $ask_language = $code[0];
    # Retrieve user information
    $device_info = Aastra_get_device_info_Asterisk($device);
    # There is a user
    if ($user != '') {
        # Retrieve user information
        $user_info = Aastra_get_user_info_Asterisk($user);
        # Get park configuration
        $park = Aastra_get_park_config_Asterisk();
        # Get polling value
        $polling = Aastra_get_polling_interval_Asterisk();
        # Prepare replace strings
        $search = array('/\\$\\$AA_SIPUSERNAME_AA\\$\\$/', '/\\$\\$AA_SIPCALLERID_AA\\$\\$/', '/\\$\\$AA_XML_SERVER_AA\\$\\$/', '/\\$\\$AA_PARKINGLOT_AA\\$\\$/', '/\\$\\$AA_XMLDIRECTORY_AA\\$\\$/', '/\\$\\$AA_INTERCOM_CODE_AA\\$\\$/', '/\\$\\$AA_POLLING_INT_AA\\$\\$/');
        $replace = array($user_info['cidnum'], $user_info['cidname'], $AA_XML_SERVER, $park['parkext'], $AA_XMLDIRECTORY, Aastra_get_intercom_config_Asterisk(), $polling);
        # Use the common piece
        foreach ($array_user['Common'] as $key => $value) {
            if (!array_key_exists($key, $array_nouser['Core'])) {
                $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_out[$key] = $line;
            }
        }
        # Model exists
        if ($array_user[$model] != NULL) {
            # Check if full template
            if (key_exists('template', $array_user[$model])) {
                $template = $array_user[$model]['template'];
            } else {
                $template = $model;
            }
            # Use the template
            foreach ($array_user[$template] as $key => $value) {
                if ($key != 'template' and !array_key_exists($key, $array_nouser['Core'])) {
                    $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_out[$key] = $line;
                }
            }
            # Use the add-ons
            if ($template != $model) {
                foreach ($array_user[$model] as $key => $value) {
                    if ($key != 'template') {
                        $line = preg_replace($search, $replace, $value);
                        $array_out[$key] = $line;
                    }
                }
            }
        }
        # User customization exists
        if ($array_custom[$user] != NULL) {
            # Use the user configuration additions
            foreach ($array_custom[$user] 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_out[$key] = $line;
            }
        }
        # Language
        if ($ask_language) {
            $array_language = Aastra_get_user_context($device, 'language');
            $array_out['language'] = $array_language['code'];
            $array_out['web language'] = $array_language['code'];
            $array_out['input language'] = $array_language['clear'];
            $language = $array_language['language'];
        }
    } else {
        # Use the common piece
        foreach ($array_user['Common'] as $key => $value) {
            if (!array_key_exists($key, $array_nouser['Core'])) {
                $array_out[$key] = '';
            }
        }
        # Model exists for the user
        if ($array_user[$model] != NULL) {
            # Check if full template
            if (key_exists('template', $array_user[$model])) {
                $template = $array_user[$model]['template'];
            } else {
                $template = $model;
            }
            # Use the template
            foreach ($array_user[$template] as $key => $value) {
                if ($key != 'template' and !array_key_exists($key, $array_nouser['Core'])) {
                    $array_out[$key] = '';
                }
            }
            # Use the add-ons
            if ($template != $model) {
                foreach ($array_user[$model] as $key => $value) {
                    if ($key != 'template') {
                        $array_out[$key] = '';
                    }
                }
            }
        }
        # Device customization exists
        if ($array_custom[$last_user] != NULL) {
            foreach ($array_custom[$last_user] as $key => $value) {
                if (!array_key_exists($key, $array_nouser['Core'])) {
                    $array_out[$key] = '';
                }
            }
        }
        # Prepare replace strings
        $search = array('/\\$\\$AA_SIPUSERNAME_AA\\$\\$/', '/\\$\\$AA_SIPCALLERID_AA\\$\\$/', '/\\$\\$AA_XML_SERVER_AA\\$\\$/', '/\\$\\$AA_PARKINGLOT_AA\\$\\$/', '/\\$\\$AA_XMLDIRECTORY_AA\\$\\$/');
        $replace = array($device, Aastra_get_callerid_Asterisk($device), $AA_XML_SERVER, $park['parkext'], $AA_XMLDIRECTORY);
        # Use the common piece
        foreach ($array_nouser['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_out[$key] = $line;
        }
        # Model exists for the device
        if ($array_nouser[$model] != NULL) {
            # Check if full template
            if (key_exists('template', $array_nouser[$model])) {
                $template = $array_nouser[$model]['template'];
            } else {
                $template = $model;
            }
            # Use the template
            foreach ($array_nouser[$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_out[$key] = $line;
                }
            }
            # Use the add-ons
            if ($template != $model) {
                foreach ($array_nouser[$model] as $key => $value) {
                    if ($key != 'template') {
                        $line = preg_replace($search, $replace, $value);
                        $array_out[$key] = $line;
                    }
                }
            }
        }
        # Language
        if ($ask_language) {
            $array_out['language'] = '';
            $array_out['web language'] = '';
            $array_out['input language'] = '';
            $language = $code[1][$code[2]];
        }
    }
    # Process day/night keys
    foreach ($array_out 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 = 'ALL';
            }
            if (!Aastra_is_daynight_appli_allowed_Asterisk($username, $index)) {
                unset($array_out[$appli . ' type']);
                unset($array_out[$appli . ' label']);
                unset($array_out[$appli . ' value']);
                unset($array_out[$appli . ' states']);
            }
        }
    }
    # Process presence
    if (!$AA_PRESENCE_STATE) {
        foreach ($array_out 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_out[$appli . ' type']);
            unset($array_out[$appli . ' label']);
            unset($array_out[$appli . ' value']);
            unset($array_out[$appli . ' states']);
        }
    }
    # Process speed dial
    if (!$AA_SPEEDDIAL_STATE) {
        foreach ($array_out 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_out[$appli . ' type']);
            unset($array_out[$appli . ' label']);
            unset($array_out[$appli . ' value']);
            unset($array_out[$appli . ' states']);
        }
    }
    # Remove 'logout' if device is fixed
    if ($user != '' and $device_info['type'] == 'fixed') {
        foreach ($array_out as $key => $value) {
            if (strstr($value, 'logout.php')) {
                $pieces = explode(' ', $key);
                if (stristr($pieces[0], 'expmod')) {
                    $appli = $pieces[0] . ' ' . $pieces[1];
                } else {
                    $appli = $pieces[0];
                }
                break;
            }
        }
        if ($appli != '') {
            unset($array_out[$pieces[0] . ' type']);
            unset($array_out[$pieces[0] . ' label']);
            unset($array_out[$pieces[0] . ' value']);
            unset($array_out[$pieces[0] . ' states']);
        }
    }
    # Find the special keys
    if ($user != '') {
        init_special_keys($device, $array_out);
    }
    # Translate labels
    foreach ($array_out 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_out[$key] = Aastra_get_label($value, $language);
        }
    }
    # Return result
    return $array_out;
}