Ejemplo n.º 1
0
// Look up other security checks in the docs!
\OCP\User::checkLoggedIn();
\OCP\App::checkAppEnabled('ocDashboard');
\OCP\App::setActiveNavigationEntry('ocDashboard');
OCP\Util::addscript('ocDashboard', 'ocDashboard');
OCP\Util::addscript('ocDashboard', 'ajaxService');
OCP\Util::addStyle('ocDashboard', 'ocDashboard');
$user = OCP\User::getUser();
$w = array();
OC::$CLASSPATH['ocdWidgets'] = 'ocDashboard/appinfo/widgetConfigs.php';
OC::$CLASSPATH['ocdFactory'] = 'ocDashboard/lib/factory.php';
foreach (ocdWidgets::$widgets as $widget) {
    // if widget is enabled
    if (OCP\Config::getUserValue($user, "ocDashboard", "ocDashboard_" . $widget['id']) == "yes") {
        $w[] = ocdFactory::getWidget($widget)->getData();
    }
}
//if all deactivated
if (empty($w)) {
    $l = new OC_L10N('ocDashboard');
    $w[0]['error'] = "You can configure this site in your personal settings.";
    $w[0]['id'] = "none";
    $w[0]['name'] = "";
    $w[0]['status'] = "3";
    $w[0]['interval'] = "0";
    $w[0]['icon'] = "";
}
$tpl = new OCP\Template("ocDashboard", "main", "user");
$tpl->assign('widgets', $w);
$tpl->printPage();
Ejemplo n.º 2
0
<?php

OCP\JSON::callCheck();
OCP\User::checkLoggedIn();
OCP\App::checkAppEnabled('ocDashboard');
OC::$CLASSPATH['ocdWidgets'] = 'ocDashboard/appinfo/widgetConfigs.php';
OC::$CLASSPATH['ocdFactory'] = 'ocDashboard/lib/factory.php';
$user = OCP\User::getUser();
$id = isset($_GET['id']) ? $_GET['id'] : $_POST['id'];
$method = isset($_GET['method']) ? $_GET['method'] : $_POST['method'];
$value = isset($_GET['value']) ? $_GET['value'] : $_POST['value'];
$widgetEnabled = OCP\Config::getUserValue($user, "ocDashboard", "ocDashboard_" . $id) == "yes";
$RESPONSE["debug"] = "user: "******" | " . "widget: " . $id . " | " . "method: " . $method . " | " . "value: " . $value . " | " . "widgetEnabled: " . $widgetEnabled;
// if widget is enabled
if ($widgetEnabled) {
    $widgetConf = ocdWidgets::getWidgetConfigById($id);
    $widget = ocdFactory::getWidget($widgetConf);
    $result = "";
    if (method_exists($widget, $method)) {
        $result = $widget->{$method}($value);
    }
    if ($result) {
        $RESPONSE["response"] = $result;
        $RESPONSE["success"] = true;
    } else {
        $RESPONSE["success"] = false;
    }
} else {
    $RESPONSE["success"] = false;
}
die(json_encode($RESPONSE));
Ejemplo n.º 3
0
<?php

OCP\User::checkLoggedIn();
OCP\App::checkAppEnabled('ocDashboard');
OCP\JSON::callCheck();
OC::$CLASSPATH['ocdWidgets'] = 'ocDashboard/appinfo/widgetConfigs.php';
$id = str_replace(array('/', '\\'), '', $_GET['widget']);
$user = OCP\User::getUser();
$widgetArray = ocdWidgets::getWidgetConfigById($id);
OC::$CLASSPATH['ocdFactory'] = 'ocDashboard/lib/factory.php';
if (OCP\Config::getUserValue($user, "ocDashboard", "ocDashboard_" . $id) == "yes") {
    $widgetData = ocdFactory::getWidget($widgetArray)->getData();
    $tpl = new OCP\Template("ocDashboard", "main", "user");
    $tpl->assign('widgets', array($widgetData));
    $tpl->assign('singleOutput', true);
    $widgetHtml = $tpl->fetchPage();
    $tmp = explode('###?###', $widgetHtml);
    $html = $tmp[1];
    $RESPONSE['data'] = "";
    if ($html) {
        $RESPONSE["success"] = true;
        $RESPONSE["HTML"] = $html;
        $RESPONSE['STATUS'] = $widgetData['status'];
    } else {
        $RESPONSE["success"] = false;
    }
} else {
    $RESPONSE["success"] = false;
}
$RESPONSE["id"] = $id;
die(json_encode($RESPONSE));