예제 #1
0
function gs_user_dnd_toggle($user_id)
{
    # connect to db
    #
    $db = gs_db_master_connect();
    if (!$db) {
        return new GsError('Could not connect to database.');
    }
    # get user_id
    #
    $user_name = $db->executeGetOne('SELECT `name` FROM `ast_sipfriends` WHERE `_user_id`=\'' . $db->escape($user_id) . '\'');
    if (!$user_name) {
        return new GsError('Unknown user.');
    }
    $dnd = $db->executeGetOne('SELECT `active` FROM `dnd` WHERE `_user_id`=\'' . $db->escape($user_id) . '\'');
    if (!$dnd) {
        $dnd = 'no';
    }
    # toggle-dnd
    #
    $new_dnd = 'no';
    if ($dnd == 'no') {
        $new_dnd = 'yes';
    }
    $ok = $db->execute("INSERT INTO `dnd` (`_user_id`, `active`) VALUES (" . $user_id . ", '" . $new_dnd . "') ON DUPLICATE KEY UPDATE `active` = '" . $new_dnd . "'");
    if (!$ok) {
        return new GsError('Failed to toggle dnd.');
    } else {
        if (GS_BUTTONDAEMON_USE == true) {
            if ($new_dnd == 'yes') {
                $state = 'on';
            } else {
                $state = 'off';
            }
            gs_dnd_changed_ui($user_name, $state);
        }
    }
    return $new_dnd;
}
예제 #2
0
    $masterdb = gs_db_master_connect();
    if (!$masterdb) {
        _err("Could not connect to database.");
    }
    if ($newdndstate == "on") {
        $dndvalue = 'yes';
    }
    if ($newdndstate == "off") {
        $dndvalue = 'no';
    }
    $check = $masterdb->execute("INSERT INTO `dnd` (`_user_id`, `active`) VALUES (" . $user_id . ", '" . $db->escape($dndvalue) . "') ON DUPLICATE KEY UPDATE `active` = '" . $db->escape($dndvalue) . "'");
    if (!$check) {
        _err("Failed to set new DND state.");
    }
    if (GS_BUTTONDAEMON_USE == true) {
        gs_dnd_changed_ui($user, $newdndstate);
    }
}
#################################### MAIN MENU {
$current_dndstate = $db->executeGetOne("SELECT `active` FROM `dnd` WHERE `_user_id`=" . $user_id);
echo $mainmenu_doctype . "\n";
echo "<html>\n";
echo "<head><title>" . __("Ruhe/DND") . "</title></head>\n";
echo "<body><br />\n";
echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"1\" width=\"100%\">\n";
echo "<tr>";
echo "<th width=\"100%\" align=\"center\">" . __("Ruhe/DND-Status setzen") . ":</th></tr>\n";
echo "<tr><td width=\"100%\" align=\"center\"><a href=\"" . $url_polycom_dnd . "?m=" . $mac . "&amp;u=" . $user . "&amp;setdnd=on\">" . ($current_dndstate == 'yes' ? "*" : "") . __("Ein") . "</a></td></tr>\n";
echo "<tr><td width=\"100%\" align=\"center\"><a href=\"" . $url_polycom_dnd . "?m=" . $mac . "&amp;u=" . $user . "&amp;setdnd=off\">" . ($current_dndstate != 'yes' ? "*" : "") . __("Aus") . "</a></td></tr>\n";
echo "</table>\n";
echo "</body>\n";
예제 #3
0
$remote_addr = @$_SERVER["REMOTE_ADDR"];
$remote_addr_check = $db->executeGetOne("SELECT `current_ip` FROM `users` WHERE `id`='" . $user_id . "'");
if ($remote_addr != $remote_addr_check) {
    _err("Not authorized");
}
$current_dndstate = $db->executeGetOne("SELECT `active` FROM `dnd` WHERE `_user_id`=" . $user_id);
gs_log(GS_LOG_DEBUG, "current_dndstate: " . $current_dndstate . " for user id " . $user_id);
if ($current_dndstate == 'yes') {
    $check = $db->execute("INSERT INTO `dnd`\n\t\t(`_user_id`, `active`) VALUES\n\t\t(" . $user_id . ", 'no') \n\t\tON DUPLICATE KEY UPDATE `active` = 'no'");
    if (!$check) {
        _err('Failed to set new DND state.');
    }
    $xml = "<AastraIPPhoneExecute>\n" . "\t<ExecuteItem URI=\"Led: softkey" . $dnd_softkey . "=off\"/>\n" . "\t<ExecuteItem URI=\"" . $prov_url_aastra . 'settings.php?dynamic=1' . "\"/>\n" . "</AastraIPPhoneExecute>\n";
} else {
    $check = $db->execute("INSERT INTO `dnd`\n\t\t(`_user_id`, `active`) VALUES\n\t\t(" . $user_id . ", 'yes') \n\t\tON DUPLICATE KEY UPDATE `active` = 'yes'");
    if (!$check) {
        _err('Failed to set new DND state.');
    }
    $xml = "<AastraIPPhoneExecute>\n" . "\t<ExecuteItem URI=\"Led: softkey" . $dnd_softkey . "=slowflash\"/>\n" . "\t<ExecuteItem URI=\"" . $prov_url_aastra . 'settings.php?dynamic=1' . "\"/>\n" . "</AastraIPPhoneExecute>\n";
}
if (GS_BUTTONDAEMON_USE == true) {
    $peer = _get_sipuser($user_id);
    $newstate = "off";
    if ($current_dndstate == 'no') {
        $newstate = "on";
    }
    if ($peer) {
        gs_dnd_changed_ui($peer, $newstate);
    }
}
aastra_transmit_str($xml);