<?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));
<?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));