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; }
$object->setTitle(Aastra_get_label('Follow-me', $language)); $object->setText(Aastra_get_label('This feature is not configured for your phone. Please contact your administrator.', $language)); if ($nb_softkeys) { 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 { # Configured: List of options require_once 'AastraIPPhoneTextMenu.class.php'; $object = new AastraIPPhoneTextMenu(); $object->setDestroyOnExit(); $object->setStyle('none'); $object->setTitle(sprintf(Aastra_get_label('Follow-me for %s', $language), Aastra_get_userdevice_Asterisk($user))); if ($array_fm['status'] == '1') { $object->addEntry(Aastra_get_label('Status: Activated', $language), $XML_SERVER . '&action=change_status'); } else { $object->addEntry(Aastra_get_label('Status: Deactivated', $language), $XML_SERVER . '&action=change_status'); } $object->addEntry(sprintf(Aastra_get_label('Initial Ring Time: %ss', $language), $array_fm['prering']), $XML_SERVER . '&action=change_prering'); $object->addEntry(sprintf(Aastra_get_label('Ring Time: %ss', $language), $array_fm['grptime']), $XML_SERVER . '&action=change_grptime'); if ($array_fm['grpconf']) { $object->addEntry(Aastra_get_label('Confirm Calls: Yes', $language), $XML_SERVER . '&action=change_grpconf'); } else { $object->addEntry(Aastra_get_label('Confirm Calls: No', $language), $XML_SERVER . '&action=change_grpconf'); } $object->addEntry(sprintf(Aastra_get_label('%s phone number(s)', $language), count($array_fm['grplist'])), $XML_SERVER . '&action=change_grplist'); # Softkeys if ($nb_softkeys) {
$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 foreach ($directory as $key => $value) { if (!stristr($value['name'], $lookup)) { unset($directory[$key]); } } } # Sort Directory by name Aastra_natsort2d($directory, 'name'); # Number of records $index = count($directory); # At least one record if ($index > 0) {
} # Softkeys 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 { # Check auto-login $vmail_options = Aastra_get_user_context($ext, 'vmail-options'); $auto_login = False; if ($vmail_options['auto_login'] == '1' and $user == Aastra_get_userdevice_Asterisk($ext)) { Aastra_check_signature_Asterisk($user); $auto_login = True; } # No auto-login if (!$auto_login) { # No pin yet? if ($pin == '') { # Ask for password require_once 'AastraIPPhoneExecute.class.php'; $object = new AastraIPPhoneExecute(); $object->addEntry($XML_SERVER . '&action=password&user='******'&action=check&user='******'&pin=' . $pin); }
Aastra_save_session('vmail', '600', $array, $ext); # Return empty object require_once 'AastraIPPhoneExecute.class.php'; $object = new AastraIPPhoneExecute(); $object->addEntry(''); $object->output(True); # Launch the call $vmail_options = Aastra_get_user_context($ext, 'vmail-options'); if ($vmail_options['auto_answer'] == '') { $vmail_options['auto_answer'] = '1'; Aastra_save_user_context($ext, 'vmail-options', $vmail_options); } if ($vmail_options['auto_answer'] == '1') { Aastra_originate_Asterisk('SIP/' . Aastra_get_userdevice_Asterisk($ext), 's', $context, 1, '', 'VoiceMail <9999>', array('_USER='******'__SIPADDHEADER=Alert-Info: \\;info=alert-autoanswer')); } else { Aastra_originate_Asterisk('SIP/' . Aastra_get_userdevice_Asterisk($ext), 's', $context, 1, '', 'VoiceMail <9999>', '_USER='******'disp_greetings': # Greeting label switch ($msg) { case 'name': $greeting = Aastra_get_label('Name', $language); break; case 'unavail': $greeting = Aastra_get_label('Unavailable Greeting', $language); break; case 'busy': $greeting = Aastra_get_label('Busy Greeting', $language);
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); }
if ($away['action'][$away['status']] == AA_PRESENCE_ACT_CFWD or $cfwd != '') { if ($cfwd == '') { $cfwd = $away['act_param'][$away['status']]; } Aastra_manage_cf_Asterisk($user, 'cancel', ''); } # Launch the call $vmail_options = Aastra_get_user_context($user, 'vmail-options'); if ($vmail_options['auto_answer'] == '') { $vmail_options['auto_answer'] = '1'; Aastra_save_user_context($ext, 'vmail-options', $vmail_options); } if ($vmail_options['auto_answer'] == '1') { Aastra_originate_Asterisk('Local/' . Aastra_get_userdevice_Asterisk($user) . '@from-internal', 's', 'record-temp-vm', 1, '', Aastra_get_label('RecordTemporary', $language) . ' <0>', array('_USER='******'_ALERT_INFO=info=alert-autoanswer')); } else { Aastra_originate_Asterisk('Local/' . Aastra_get_userdevice_Asterisk($user) . '@from-internal', 's', 'record-temp-vm', 1, '', Aastra_get_label('RecordTemporary', $language) . ' <0>', array('_USER='******'enable'); } if ($follow == 1) { Aastra_manage_followme_Asterisk($user, 'enable'); } if ($cfwd != '') { Aastra_manage_cf_Asterisk($user, 'set', $cfwd); } } else { # Save session $array = array('uri_onhook' => $XML_SERVER, 'user' => $user, 'type' => 'temp', 'action' => 'record'); Aastra_save_session('vmail', '600', $array, $user);
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'); # Get language $language = Aastra_get_language(); # Global compatibility $nb_softkeys = Aastra_number_softkeys_supported(); $is_icons = Aastra_is_icons_supported(); # Initial action if ($action == '') { # Set mode if ($index == '') { $mode = 'ALL'; } else { $mode = 'SINGLE'; } # Test if application is allowed if (!Aastra_is_daynight_appli_allowed_Asterisk(Aastra_get_userdevice_Asterisk($user), $index)) { # Display error $action = 'error'; $err_title = Aastra_get_label('Error', $language); $err_text = Aastra_get_label('You are not allowed to use this application with the current configuration. Please contact your administrator.', $language); } else { # Retrieve status for all configured indexes $array_night = Aastra_manage_daynight_Asterisk('get_all', ''); # Depending on mode if ($mode != 'ALL') { # Check requested index configured if (!$array_night[$index]) { # Display error $action = 'error'; $err_title = Aastra_get_label('Configuration Error', $language); $err_text = Aastra_get_label('The requested day/night index is not configured. Please contact your administrator.', $language);
$data['last'] = $dnd; if ($dnd != $last) { Aastra_save_user_context($user, 'dnd', $data); $object->setBeep(); $object->addEntry($XML_SERVER . '&action=msg&status=' . $dnd); if ($key != '' and Aastra_is_ledcontrol_supported()) { if ($dnd == 1) { $object->addEntry('Led: ' . $key . '=on'); } else { $object->addEntry('Led: ' . $key . '=off'); } } } # 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
$object->addSoftkey('6', Aastra_get_label('Exit', $language), 'SoftKey:Exit'); } else { $object->addSoftkey('10', Aastra_get_label('Exit', $language), 'SoftKey:Exit'); } } } else { # Direct logout require_once 'AastraIPPhoneExecute.class.php'; $object = new AastraIPPhoneExecute(); $object->addEntry($XML_SERVER . '&action=logout'); } } } else { # Get device and user $device = $user; $user = Aastra_get_userdevice_Asterisk($device); # Remove from Parking list and voice mail Aastra_remove_parking_Asterisk($device); $count = !Aastra_is_ledcontrol_supported(); Aastra_remove_vmail_Asterisk('', $device, $count); # Trigger a sync on the phone require_once 'AastraIPPhoneExecute.class.php'; $object = new AastraIPPhoneExecute(); $object->setTriggerDestroyOnExit(); # Clear the phone if (Aastra_is_local_reset_supported()) { $object->AddEntry('Command: ClearCallersList'); $object->AddEntry('Command: ClearDirectory'); $object->AddEntry('Command: ClearRedialList'); } # Perform the logout
$change = 'change'; foreach ($array_user as $key => $value) { if ($value != '') { $change = 'select'; } break; } # Retrieve current status $cf = Aastra_manage_cf_Asterisk($user, $action, $value); # Softkeys? if ($nb_softkeys) { # Textscreen for softkey phones require_once 'AastraIPPhoneTextScreen.class.php'; $object = new AastraIPPhoneTextScreen(); $object->setDestroyOnExit(); $object->setTitle(sprintf(Aastra_get_label('Call Forward for %s', $language), Aastra_get_userdevice_Asterisk($user))); if ($cf == '') { $object->setText(Aastra_get_label('Call Forward is currently deactivated.', $language)); $object->addSoftkey('1', Aastra_get_label('Activate', $language), $XML_SERVER . '&action=' . $change); } else { $array_user = array_flip($array_user); $text = sprintf(Aastra_get_label('Call Forward is currently set to %s', $language), $cf); if ($array_user[$cf] != '') { $array_label = array('cell' => Aastra_get_label('Cell', $language), 'home' => Aastra_get_label('Home', $language), 'other' => Aastra_get_label('Other', $language)); $text .= ' (' . $array_label[$array_user[$cf]] . ')'; } $object->setText($text); $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) {
Aastra_natsort2d($meetmechannel, '2'); # Prepare object require_once 'AastraIPPhoneTextMenu.class.php'; $object = new AastraIPPhoneTextMenu(); $object->setDestroyOnExit(); if (Aastra_is_style_textmenu_supported()) { $object->setStyle('none'); } if ($last == 1) { $object->setTitle(sprintf(Aastra_get_label('Conference %s', $language), $confno)); } else { $object->setTitle(sprintf(Aastra_get_label('Conference %s (%s/%s)', $language), $confno, $page, $last)); } $new_selection = 1; $index = 0; $user = Aastra_get_userdevice_Asterisk($ext); foreach ($meetmechannel as $value) { if ($index >= ($page - 1) * AASTRA_MAXLINES and $index < $page * AASTRA_MAXLINES) { if ($value[1] == $user) { $name = sprintf(Aastra_get_label('%s (YOU)', $language), $value[2]); } else { $name = $value[2]; } $icon = ''; if ($value[3]) { if (!$is_icons) { $name = '(' . $name . ')'; } else { $icon = 2; } } else {
function is_agent_logged($agent) { global $queue_members; $queue_members = ''; # Transcode for device and user mode $agent = Aastra_get_userdevice_Asterisk($agent); # Not logged by default $return = False; # Connect to AGI $asm = new AGI_AsteriskManager(); $asm->connect(); # Add event handlers to retrieve the answer $asm->add_event_handler('queuestatuscomplete', 'asm_event_queues'); $asm->add_event_handler('queuemember', 'asm_event_agents'); # Retrieve info while (!$queue_members) { $asm->QueueStatus(); $count++; if ($count == 10) { break; } } # Get info for all the queues foreach ($queue_members as $agent_a) { if ($agent_a['Location'] == 'Local/' . $agent . '@from-queue/n' or $agent_a['Location'] == 'Local/' . $agent . '@from-internal/n') { $return = True; break; } } # Disconnect properly $asm->disconnect(); # Return Status return $return; }
} else { $object->addSoftkey('9', Aastra_get_label('Cancel', $language), $XML_SERVER . '&selection=' . $selection); $object->addSoftkey('10', Aastra_get_label('Close', $language), $XML_SERVER . '&action=edit&selection=' . $selection . '&input1=' . $input1 . '&input2=' . $input2 . '&input3=' . $input3 . '&input4=' . $input4 . '&input5=' . $input5); } } else { $object->setDoneAction($XML_SERVER . '&action=edit&selection=' . $selection); } } else { # Update user data $data[$selection]['name'] = $input1; $data[$selection]['work'] = $input2; $data[$selection]['mobile'] = $input3; $data[$selection]['home'] = $input4; $data[$selection]['other'] = $input5; if ($asterisk) { $data = Aastra_save_user_context(Aastra_get_userdevice_Asterisk($user), 'speed', $data); } else { Aastra_save_user_context($user, 'speed', $data); } # Back to the list require_once 'AastraIPPhoneExecute.class.php'; $object = new AastraIPPhoneExecute(); $object->addEntry($XML_SERVER . '&action=list&selection=' . $selection); } break; # EDIT # EDIT case 'edit': # Multiple input fields? if (Aastra_is_multipleinputfields_supported()) { # Input Screen
function filter_queues($queues, $user) { # Retrieve real user $user = Aastra_get_userdevice_Asterisk($user); # Read config file $array_config = Aastra_readINIfile(AASTRA_CONFIG_DIRECTORY . 'queues.conf', '#', '='); foreach ($queues as $key => $value) { $allowed = False; if (array_key_exists($value['Queue'], $array_config)) { if ($array_config[$value['Queue']]['allowed'] == 'ALL') { $allowed = True; } else { $temp = explode(',', $array_config[$value['Queue']]['allowed']); if (in_array($user, $temp)) { $allowed = True; } } } else { if (array_key_exists('ALL', $array_config)) { if ($array_config['ALL']['allowed'] == 'ALL') { $allowed = True; } else { $temp = explode(',', $array_config['ALL']['allowed']); if (in_array($user, $temp)) { $allowed = True; } } } } if (!$allowed) { unset($queues[$key]); } } # Return updated queues return $queues; }