Beispiel #1
0
function update_special_keys($user, $array_config)
{
    # Return array
    $return = array();
    # All the functions
    $list = array('cfwd', 'dnd', 'daynight', 'away', 'agent', 'follow', 'parking');
    # Get current data
    foreach ($list as $value) {
        $array1[$value] = Aastra_get_user_context($user, $value);
    }
    $count = !Aastra_is_ledcontrol_supported();
    # Remove vmail
    Aastra_remove_vmail_Asterisk('', $user, $count);
    # Some data
    if ($array_config != NULL) {
        foreach ($array_config as $key => $value) {
            if (strstr($value, 'dnd.php')) {
                $pieces = explode(' ', $key);
                if (stristr($pieces[0], 'expmod')) {
                    $array2['dnd']['key'] = $pieces[0] . ' ' . $pieces[1];
                } else {
                    $array2['dnd']['key'] = $pieces[0];
                }
            }
            if (strstr($value, 'cfwd.php')) {
                $pieces = explode(' ', $key);
                if (stristr($pieces[0], 'expmod')) {
                    $array2['cfwd']['key'] = $pieces[0] . ' ' . $pieces[1];
                } else {
                    $array2['cfwd']['key'] = $pieces[0];
                }
            }
            if (strstr($value, 'daynight.php')) {
                $pieces = explode(' ', $key);
                if (stristr($pieces[0], 'expmod')) {
                    $key = $pieces[0] . ' ' . $pieces[1];
                } else {
                    $key = $pieces[0];
                }
                $url = parse_url($value);
                parse_str($url['query'], $parse);
                if ($parse['index'] != '') {
                    $array2['daynight']['key'][$parse['index']] = $key;
                } else {
                    $array2['daynight']['key']['ALL'] = $key;
                }
            }
            if (strstr($value, 'away.php')) {
                $pieces = explode(' ', $key);
                if (stristr($pieces[0], 'expmod')) {
                    $array2['away']['key'] = $pieces[0] . ' ' . $pieces[1];
                } else {
                    $array2['away']['key'] = $pieces[0];
                }
            }
            if (strstr($value, 'agent.php')) {
                $pieces = explode(' ', $key);
                if (stristr($pieces[0], 'expmod')) {
                    $array2['agent']['key'] = $pieces[0] . ' ' . $pieces[1];
                } else {
                    $array2['agent']['key'] = $pieces[0];
                }
            }
            if (strstr($value, 'follow.php')) {
                $pieces = explode(' ', $key);
                if (stristr($pieces[0], 'expmod')) {
                    $array2['follow']['key'] = $pieces[0] . ' ' . $pieces[1];
                } else {
                    $array2['follow']['key'] = $pieces[0];
                }
            }
            if (strstr($value, 'park.php')) {
                $pieces = explode(' ', $key);
                if (stristr($pieces[0], 'expmod')) {
                    $array2['parking']['key'] = $pieces[0] . ' ' . $pieces[1];
                }
                $array2['parking']['key'] = $pieces[0];
            }
            if (strstr($value, 'vmail.php')) {
                $url = parse_url($value);
                parse_str($url['query'], $parse);
                if ($parse['user'] != '') {
                    Aastra_add_vmail_Asterisk($parse['user'], $user, $count);
                    $pieces = explode(' ', $key);
                    if (stristr($pieces[0], 'expmod')) {
                        $vmail[$parse['user']]['key'] = $pieces[0] . ' ' . $pieces[1];
                        $vmail[$parse['user']]['label'] = $array_config[$pieces[0] . ' ' . $pieces[1] . ' label'];
                    } else {
                        $vmail[$parse['user']]['key'] = $pieces[0];
                        $vmail[$parse['user']]['label'] = $array_config[$pieces[0] . ' label'];
                    }
                }
            }
        }
    }
    # Compare before and after
    $notify = Aastra_get_user_context($user, 'notify');
    foreach ($list as $value) {
        if ($value != 'daynight') {
            if ($array1[$value]['key'] != $array2[$value]['key']) {
                Aastra_save_user_context($user, $value, $array2[$value]);
                $notify[$value] = '1';
                if ($value == 'parking') {
                    Aastra_remove_parking_Asterisk($user);
                    if ($array2[$value]['key'] != '') {
                        Aastra_add_parking_Asterisk($user);
                    }
                } else {
                    $return[] = $value;
                }
            }
        } else {
            $list2 = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'ALL');
            $diff = False;
            foreach ($list2 as $value2) {
                if ($array1[$value]['key'][$value2] != $array2[$value]['key'][$value2]) {
                    $diff = True;
                    break;
                }
            }
            if ($diff) {
                Aastra_save_user_context($user, $value, $array2[$value]);
                $notify[$value] = '1';
                $return[] = $value;
            }
        }
    }
    # Update vmail anyways
    Aastra_save_user_context($user, 'vmail', $vmail);
    # Prepare notification
    $notify['vmail'] = '1';
    Aastra_save_user_context($user, 'notify', $notify);
    # Return changes
    return $return;
}
Beispiel #2
0
         if ($index >= ($page - 1) * AASTRA_MAXCONFIGURATIONS + 1 and $index <= $page * AASTRA_MAXCONFIGURATIONS) {
             $object->addEntry($key, $value);
         }
         $index++;
     }
     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()) {
Beispiel #3
0
function init_special_keys($user, $array_config = NULL)
{
    # Mode
    if ($array_config == NULL) {
        # Get MAC address and type of phone
        $header = Aastra_decode_HTTP_header();
        # Read config file
        $array_temp = Aastra_readCFGfile(AASTRA_TFTP_DIRECTORY . '/' . $header['mac'] . '.cfg', '#', ':');
        $array_config = $array_temp[''];
    }
    # Global parameters
    $is_sip_notify_supported = Aastra_is_sip_notify_supported();
    # Remove the special keys
    $cfwd['key'] = '';
    $dnd['key'] = '';
    $daynight['key'] = array();
    $away['key'] = '';
    $agent['key'] = '';
    $follow['key'] = '';
    $parking['key'] = '';
    $vmail = array();
    Aastra_remove_parking_Asterisk($user);
    $count = !Aastra_is_ledcontrol_supported();
    Aastra_remove_vmail_Asterisk('', $user, $count);
    # Some data
    if ($array_config != NULL) {
        foreach ($array_config as $key => $value) {
            if (strstr($value, 'dnd.php')) {
                $pieces = explode(' ', $key);
                if (stristr($pieces[0], 'expmod')) {
                    $dnd['key'] = $pieces[0] . ' ' . $pieces[1];
                } else {
                    $dnd['key'] = $pieces[0];
                }
            }
            if (strstr($value, 'cfwd.php')) {
                $pieces = explode(' ', $key);
                if (stristr($pieces[0], 'expmod')) {
                    $cfwd['key'] = $pieces[0] . ' ' . $pieces[1];
                } else {
                    $cfwd['key'] = $pieces[0];
                }
            }
            if (strstr($value, 'daynight.php')) {
                $pieces = explode(' ', $key);
                if (stristr($pieces[0], 'expmod')) {
                    $key = $pieces[0] . ' ' . $pieces[1];
                } else {
                    $key = $pieces[0];
                }
                $url = parse_url($value);
                parse_str($url['query'], $parse);
                if (isset($parse['index'])) {
                    if ($parse['index'] != '') {
                        $daynight['key'][$parse['index']] = $key;
                    } else {
                        $daynight['key']['ALL'] = $key;
                    }
                } else {
                    $daynight['key']['ALL'] = $key;
                }
            }
            if (strstr($value, 'away.php')) {
                $pieces = explode(' ', $key);
                if (stristr($pieces[0], 'expmod')) {
                    $away['key'] = $pieces[0] . ' ' . $pieces[1];
                } else {
                    $away['key'] = $pieces[0];
                }
            }
            if (strstr($value, 'agent.php')) {
                $pieces = explode(' ', $key);
                if (stristr($pieces[0], 'expmod')) {
                    $agent['key'] = $pieces[0] . ' ' . $pieces[1];
                } else {
                    $agent['key'] = $pieces[0];
                }
            }
            if (strstr($value, 'follow.php')) {
                $pieces = explode(' ', $key);
                if (stristr($pieces[0], 'expmod')) {
                    $follow['key'] = $pieces[0] . ' ' . $pieces[1];
                } else {
                    $follow['key'] = $pieces[0];
                }
            }
            if (strstr($value, 'park.php') and $is_sip_notify_supported) {
                $pieces = explode(' ', $key);
                if (stristr($pieces[0], 'expmod')) {
                    $parking['key'] = $pieces[0] . ' ' . $pieces[1];
                } else {
                    $parking['key'] = $pieces[0];
                }
                Aastra_add_parking_Asterisk($user);
            }
            if (strstr($value, 'vmail.php') and $is_sip_notify_supported) {
                $url = parse_url($value);
                parse_str($url['query'], $parse);
                if ($parse['user'] != '') {
                    Aastra_add_vmail_Asterisk($parse['user'], $user, $count);
                    $pieces = explode(' ', $key);
                    if (stristr($pieces[0], 'expmod')) {
                        $vmail[$parse['user']]['key'] = $pieces[0] . ' ' . $pieces[1];
                        if (isset($array_config[$pieces[0] . ' ' . $pieces[1] . ' label'])) {
                            $vmail[$parse['user']]['label'] = $array_config[$pieces[0] . ' ' . $pieces[1] . ' label'];
                        } else {
                            $vmail[$parse['user']]['label'] = '';
                        }
                    } else {
                        if (stristr($pieces[0], 'key')) {
                            $vmail[$parse['user']]['key'] = $pieces[0];
                            if (isset($array_config[$pieces[0] . ' label'])) {
                                $vmail[$parse['user']]['label'] = $array_config[$pieces[0] . ' label'];
                            } else {
                                $vmail[$parse['user']]['label'] = '';
                            }
                        }
                    }
                }
            }
        }
    }
    # Cache them for the device not the user
    Aastra_save_user_context($user, 'cfwd', $cfwd);
    Aastra_save_user_context($user, 'dnd', $dnd);
    Aastra_save_user_context($user, 'daynight', $daynight);
    Aastra_save_user_context($user, 'away', $away);
    Aastra_save_user_context($user, 'agent', $agent);
    Aastra_save_user_context($user, 'follow', $follow);
    Aastra_save_user_context($user, 'parking', $parking);
    Aastra_save_user_context($user, 'vmail', $vmail);
}