예제 #1
0
function updateDashboard()
{
    global $tool, $propertyForm;
    $enabledWidgets = $_POST['list'];
    //print_r($enabledWidgets);
    $curUser = new DashboardUsers($_SESSION['userid']);
    $widgets = Widgets::get_widgets();
    $update = true;
    foreach ($widgets as $id => $value) {
        $isEnabled = false;
        $curWidget = new Widgets($id);
        foreach ($enabledWidgets as $eID => $eValue) {
            if ($id == $eValue) {
                $curWidget->set_enabled(true);
                $isEnabled = true;
            }
        }
        if (!$isEnabled) {
            $curWidget->set_enabled(false);
            $curUser->set_widget_id($id);
            $curUser->remove_widget();
        }
        if ($curWidget->update_widget()) {
            $update = true;
        } else {
            $update = false;
            $error = $curWidget->get_error();
            break;
        }
    }
    if ($update) {
        $status = "success";
        echo "<script language='javascript'>LoadPage(\"configurations.php?action=dashWidgets&mode=edit&update=" . $status . "\", 'settingsInfo');</script>";
    } else {
        $propertyForm->error("Warning: Failed to enable widgets. Reason: " . $error);
    }
}