# Softkey
     $object->addSoftkey('10', Aastra_get_label('Close', $language), $XML_SERVER . '&action=zoom&lookup=' . $lookup . '&page=' . $page . '&selection=' . $selection, 1);
     $object->addIcon(1, 'Icon:CircleRed');
     $object->setCancelAction($XML_SERVER . '&action=zoom&lookup=' . $lookup . '&page=' . $page . '&selection=' . $selection);
     break;
     # Unnotify
 # Unnotify
 case 'unnotify':
     # Add the user to the list
     Aastra_manage_presence_Asterisk($selection, 'unset', 'notify', $user);
     # Display text
     require_once 'AastraIPPhoneTextScreen.class.php';
     $object = new AastraIPPhoneTextScreen();
     $object->setDestroyOnExit();
     $object->setTitle(Aastra_get_label('Notification Cancelled', $language));
     $object->setText(sprintf(Aastra_get_label('You will NOT ANYMORE be notified when %s returns.', $language), Aastra_get_callerid_Asterisk($selection)));
     # Softkey
     $object->addSoftkey('10', Aastra_get_label('Close', $language), $XML_SERVER . '&action=zoom&lookup=' . $lookup . '&page=' . $page . '&selection=' . $selection, 1);
     $object->addIcon(1, 'Icon:CircleRed');
     $object->setCancelAction($XML_SERVER . '&action=zoom&lookup=' . $lookup . '&page=' . $page . '&selection=' . $selection);
     break;
     # Display directory
 # Display directory
 case 'list':
     # Get list of users
     $directory = Aastra_get_user_directory_Asterisk();
     # Remove current user
     unset($directory[Aastra_get_userdevice_Asterisk($user)]);
     # Search?
     if ($lookup != '') {
         # Filter the search
Example #2
0
 foreach ($fm['grplist'] as $i => $number) {
     if ($i < $MAX_NUMBERS) {
         if ($nb_softkeys != 10) {
             $select_action = $XML_SERVER . '&action=delete_grplist&value=' . $i;
         } else {
             $select_action = NULL;
         }
         if (substr($number, -1) == '#') {
             if ($array_user[substr($number, 0, -1)] == '') {
                 $object->addEntry(sprintf(Aastra_get_label('(E) %s', $language), substr($number, 0, -1)), $select_action, $i);
             } else {
                 $object->addEntry(sprintf(Aastra_get_label('(E) %s (%s)', $language), $array_label[$array_user[substr($number, 0, -1)]], substr($number, 0, -1)), $select_action, $i);
             }
         } else {
             if ($number != Aastra_get_userdevice_Asterisk($user)) {
                 $object->addEntry(sprintf(Aastra_get_label('(I) %s (%s)', $language), Aastra_get_callerid_Asterisk($number), $number), $select_action, $i);
             } else {
                 $object->addEntry(sprintf(Aastra_get_label('This Phone (%s)', $language), $number), $select_action, $i);
             }
         }
     }
 }
 # Softkeys
 if ($nb_softkeys == 6) {
     if (count($fm['grplist']) < $MAX_NUMBERS) {
         $object->addSoftkey('1', Aastra_get_label('Add Int.', $language), $XML_SERVER . '&action=addint_grplist');
     }
     if (count($fm['grplist']) > 1) {
         $object->addSoftkey('2', Aastra_get_label('Move Down', $language), $XML_SERVER . '&action=down_grplist');
     }
     if (count($fm['grplist']) > 1) {
Example #3
0
 }
 if ($cfwd_enable or $cfwd_disable) {
     if ($AA_FREEPBX_MODE == '1') {
         $object->addEntry($XML_SERVER_PATH . 'cfwd.php?user='******'&action=check');
     } else {
         Aastra_propagate_changes_Asterisk('', Aastra_get_userdevice_Asterisk($user), array('cfwd'));
     }
 }
 # Complete the 'Back' status
 if ($value1 == AA_PRESENCE_AVAILABLE) {
     # Delete Temp message
     Aastra_delete_temp_message_Asterisk($user);
     # Send message notifications if needed
     if ($away['notifym'] != '') {
         $explode = explode(',', $away['notifym']);
         $long = sprintf(Aastra_get_label('%s is back', $language), Aastra_get_callerid_Asterisk(Aastra_get_userdevice_Asterisk($user)));
         $short = sprintf(Aastra_get_label('%s is back', $language), Aastra_get_userdevice_Asterisk($user));
         foreach ($explode as $data) {
             Aastra_send_message_Asterisk($data, $long, $short, 'Dial:' . Aastra_get_userdevice_Asterisk($user));
         }
     }
     # Send voice notifications if needed
     if ($away['notifyv'] != '') {
         # Retrieve name recording
         $name_recording = Aastra_get_greeting_name_Asterisk($user);
         # Run in background so we aren't waiting for a response
         $cmd = '/usr/bin/php ' . Aastra_getvar_safe('DOCUMENT_ROOT', '', 'SERVER') . '/' . $AA_XMLDIRECTORY . '/asterisk/notify.php ' . $away['notifyv'] . ' ' . Aastra_get_userdevice_Asterisk($user) . ' ' . $name_recording;
         $cmd = escapeshellcmd($cmd);
         $cmd = '(' . $cmd . ') >/dev/null &';
         system($cmd);
     }
Example #4
0
         $object->setTitle(Aastra_get_label('Extension in Use', $language));
         if (Aastra_is_user_registered_Asterisk($extension) or time() - $ext_array[$extension]['time'] > 180) {
             $object->addEntry(Aastra_get_label('Override', $language), $XML_SERVER . '&action=override&extension=' . $extension . '&password='******'&tz_code=' . $tz_code . '&tz_name=' . $tz_name);
         }
         $object->addEntry(Aastra_get_label('Cancel', $language), $XML_SERVER);
     }
 } else {
     # Collect user data
     if ($AA_FREEPBX_MODE == '1') {
         $username = Aastra_get_username_Asterisk($extension);
         $secret = Aastra_get_secret_Asterisk($extension);
     } else {
         $username = $extension;
         $secret = $password;
     }
     $callerid = Aastra_get_callerid_Asterisk($extension);
     # Get user/device profile
     $profile = Aastra_get_startup_profile_Asterisk($extension);
     # Create mac.cfg
     if (create_mac($header['mac'], $extension, $username, $secret, $callerid, $header['model'], $profile, $tz_name, $tz_code, $cl, $lang)) {
         # If override
         if ($action == 'override') {
             # Send a SIP notify
             if (Aastra_is_user_registered_Asterisk($extension)) {
                 if (Aastra_is_dynamic_sip_supported($ext_array[$extension]) or $ext_array[$extension]['model'] == 'Aastra8000i') {
                     $notify_type = 'aastra-xml';
                     $notify = Aastra_get_user_context($extension, 'notify');
                     $notify['forced_logout'] = '1';
                     Aastra_save_user_context($extension, 'notify', $notify);
                 } else {
                     Aastra_delete_mac($ext_array[$extension]['mac']);
Example #5
0
     break;
     # Logout
 # Logout
 case 'logout':
 case 'forced_logout':
     # Update config file
     if ($action == 'logout') {
         Aastra_update_HDconfig_file(AASTRA_PATH_CACHE . 'startup_asterisk.cfg', $user);
     }
     # Remove from Parking list
     Aastra_remove_parking_Asterisk($user);
     # Remove from VM List
     $count = !Aastra_is_ledcontrol_supported();
     Aastra_remove_vmail_Asterisk('', $user, $count);
     # Retrieve Caller ID
     $callerid = Aastra_get_callerid_Asterisk($user);
     # Send an email
     Aastra_send_HDmail($header, $callerid . ' ' . $user, 'LOGOUT', $AA_EMAIL, $AA_SENDER);
     # Compute what to do
     $test = False;
     if ($header['model'] == 'Aastra6739i') {
         if (Aastra_test_phone_version('3.2.0.', 1, $header) == 0) {
             $test = True;
         }
     } else {
         if (Aastra_is_dynamic_sip_supported()) {
             $test = True;
         }
     }
     # Depending on Dynamic SIP support
     if ($test) {
Example #6
0
 # Get global compatibility
 $nb_softkeys = Aastra_number_softkeys_supported();
 $is_keypress = Aastra_is_keypress_supported();
 # Retrieve intercom prefix
 $intercom = Aastra_get_intercom_config_Asterisk();
 # Remove prefix if identified
 if ($intercom != '') {
     $pos = strpos($number, $intercom);
     if ($pos !== False) {
         if ($pos == 0) {
             $number = substr($number, strlen($intercom));
         }
     }
 }
 # Lookup caller ID as an Asterisk extension
 $callerid = Aastra_get_callerid_Asterisk($number);
 if ($callerid == 'Unknown') {
     $callerid = '';
 }
 # Caller ID identified as internal
 if ($callerid != '') {
     $callerid_type = 'internal';
 } else {
     # External lookup?
     if ($AA_OUTGOING_LOOKUP != '') {
         # Remove outgoing prefix
         $ARRAY_CONFIG = Aastra_readINIfile(AASTRA_CONFIG_DIRECTORY . 'directory.conf', '#', '=');
         $dialplan = $ARRAY_CONFIG['Dialplan'];
         if ($dialplan['outgoing'] != '') {
             $pos = strpos($number, $dialplan['outgoing']);
             if ($pos !== False) {
Example #7
0
         $text = sprintf(Aastra_get_label('At %s', $language), strftime($format_time, $detail['LastCall']));
         $object->addLine($text);
     } else {
         if ($is_color_ftextscreen) {
             $object->addLine(Aastra_get_label('No Last Call', $language), NULL, NULL, 'red');
         } else {
             $object->addLine(Aastra_get_label('No Last Call', $language));
         }
     }
     $object->setScrollEnd();
 } else {
     # Display Agent status
     require_once 'AastraIPPhoneTextScreen.class.php';
     $object = new AastraIPPhoneTextScreen();
     $object->setDestroyOnExit();
     $object->setTitle(sprintf('%s (%s)', Aastra_get_callerid_Asterisk($member), $queue));
     if ($detail['Paused']) {
         $text = Aastra_get_label('Status: Paused.', $language);
     } else {
         $text = Aastra_get_label('Status: Logged on.', $language);
     }
     $array_label = array('static' => Aastra_get_label('Static', $language), 'dynamic' => Aastra_get_label('Dynamic', $language));
     $text .= ' ' . sprintf(Aastra_get_label('Type: %s.', $language), $array_label[$detail['Type']]);
     $text .= ' ' . sprintf('%s: %d', Aastra_get_label('Penalty', $language), $detail['Penalty']);
     $text .= ' ' . sprintf(Aastra_get_label('Call(s) Taken: %s.', $language), $detail['CallsTaken']);
     if ($detail['LastCall'] != '0') {
         $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));
         $day = $array_day[strftime('%w', $detail['LastCall'])];
         if ($AA_FORMAT_DT == 'US') {
             $format_date = '%m/%d/%y';
             $format_time = '%I:%M %p';
Example #8
0
         break;
     case 'blf':
     case 'blfxfer':
         switch ($array_key[$selection]['type']) {
             case 'blf':
             case 'blfxfer':
                 if ($input2 == $array_key[$selection]['value']) {
                     if ($array_key[$selection]['label'] != '') {
                         $object->setDefault($array_key[$selection]['label']);
                     }
                 } else {
                     $object->setDefault(Aastra_get_callerid_Asterisk($input2));
                 }
                 break;
             default:
                 $object->setDefault(Aastra_get_callerid_Asterisk($input2));
                 break;
         }
         break;
 }
 # Softkeys
 if ($nb_softkeys) {
     if ($nb_softkeys == 6) {
         $object->addSoftkey('1', Aastra_get_label('Backspace', $language), 'SoftKey:BackSpace');
         $object->addSoftkey('2', Aastra_get_label('ABC', $language), 'SoftKey:ChangeMode');
         $object->addSoftkey('3', Aastra_get_label('NextSpace', $language), 'SoftKey:NextSpace');
         $object->addSoftkey('4', Aastra_get_label('Back', $language), $XML_SERVER . '&selection=' . $selection . '&action=edit&step=2&type=' . $type . '&set=' . $set . '&input1=' . $input1 . '&input2=' . $input2);
         $object->addSoftkey('5', Aastra_get_label('Submit', $language), 'SoftKey:Submit');
         $object->addSoftkey('6', Aastra_get_label('Exit', $language), 'SoftKey:Exit');
     } else {
         $object->addSoftkey('9', Aastra_get_label('Back', $language), $XML_SERVER . '&selection=' . $selection . '&action=edit&step=2&type=' . $type . '&set=' . $set . '&input1=' . $input1 . '&input2=' . $input2);
Example #9
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;
}