$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']); $notify_type = 'aastra-check-cfg'; }
function extra_keys($user, $header, $array_saved, $array_user) { global $AA_XML_SERVER, $AA_PROXY_SERVER, $AA_REGISTRAR_SERVER, $AA_XMLDIRECTORY; # Retrieve user profile $profile = Aastra_get_startup_profile_Asterisk($user); $array_profile = Aastra_readCFGfile($profile . '-user.prf', '#', ':'); # Retrieve extra keys $array_extra = array(); foreach ($array_profile['Extra'] as $key => $value) { if (strstr($key, 'extrakey')) { $explode = explode(' ', $key); switch ($explode[1]) { case 'type': case 'label': case 'value': case 'states': case 'exclude': $array_extra[$explode[0]][$explode[1]] = $value; break; } } } # Prepare replace strings $search = array('/\\$\\$AA_XML_SERVER_AA\\$\\$/', '/\\$\\$AA_PROXY_SERVER_AA\\$\\$/', '/\\$\\$AA_REGISTRAR_SERVER_AA\\$\\$/', '/\\$\\$AA_XMLDIRECTORY_AA\\$\\$/'); $replace = array($AA_XML_SERVER, $AA_PROXY_SERVER, $AA_REGISTRAR_SERVER, $AA_XMLDIRECTORY); # Filter extra keys foreach ($array_extra as $key => $value) { if (!isset($value['type']) or !isset($value['label']) or !isset($value['value'])) { unset($array_extra[$key]); } else { if ($array_extra[$key]['type'] == 'xml') { $array_extra[$key]['value'] = preg_replace($search, $replace, $array_extra[$key]['value']); } if (isset($value['exclude'])) { $explode = explode(',', $value['exclude']); if (in_array($header['model'], $explode)) { unset($array_extra[$key]); } } } } # Filter compare to deleted keys if (isset($array_saved[$header['model']])) { foreach ($array_saved[$header['model']] as $key => $value) { foreach ($array_extra as $key2 => $value2) { if ($value['type'] == $value2['type'] and $value['value'] == $value2['value']) { unset($array_extra[$key2]); break; } } } } # Filter compare to current keys if (isset($array_user)) { foreach ($array_user as $key => $value) { foreach ($array_extra as $key2 => $value2) { if ($value['type'] == $value2['type'] and $value['value'] == $value2['value']) { unset($array_extra[$key2]); break; } } } } # Return extra keys return $array_extra; }
$object->addSoftkey('5', Aastra_get_label('Cancel', $language), 'SoftKey:Exit'); $object->addSoftkey('6', Aastra_get_label('Submit', $language), 'SoftKey:Submit'); } else { $object->addSoftkey('10', Aastra_get_label('Cancel', $language), 'SoftKey:Exit'); } } break; } break; # Submit # Submit case 'submit': # credentials OK if (Aastra_check_user_login_Asterisk($user, $password)) { # Retrieve user template $profile = Aastra_get_startup_profile_Asterisk($user); if (file_exists($profile . '-device-user.prf')) { # Store language if needed if ($lang != '') { $data['language'] = $lang; $data['code'] = $cl; $array_wl = array('fr' => 'French', 'it' => 'Italian', 'es' => 'Spanish', 'en' => 'English', 'de' => 'German', 'pt' => 'Portuguese'); if ($array_wl[substr($lang, 0, 2)] != '') { $data['clear'] = $array_wl[substr($lang, 0, 2)]; } else { $data['clear'] = ''; } Aastra_save_user_context($device, 'language', $data); } # Trigger a sync on the phone $object = new AastraIPPhoneExecute();
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; }