public static function initForUser($id)
 {
     foreach (array('Salon', 'Cuisine', 'Chambre', 'Garage', 'Système') as $room) {
         $entity = new Dashboard();
         $entity->create();
         $entity->user = $id;
         $entity->label = $room;
         $entity->default = 0;
         $entity->save();
     }
     $entity = new Dashboard();
     $entity->create();
     $entity->user = $id;
     $entity->label = "Général";
     $entity->default = 1;
     $entity->save();
     $dashboard = $entity->id;
     $entity = new Widget();
     $entity->create();
     $entity->customQuery('INSERT INTO "yana_plugin_dashboard" ("model", "data", "cell", "column", "minified","dashboard") VALUES (\'dash_profil\',	\'null\',	\'0\',	\'0\',	\'\',\'' . $dashboard . '\');');
     $entity->customQuery('INSERT INTO "yana_plugin_dashboard" ("model", "data", "cell", "column", "minified","dashboard") VALUES (\'dash_monitoring_ram\',	\'null\',	\'0\',	\'1\',	\'\',\'' . $dashboard . '\');');
     $entity->customQuery('INSERT INTO "yana_plugin_dashboard" ("model", "data", "cell", "column", "minified","dashboard") VALUES (\'dash_monitoring_system\',	\'null\',	\'0\',	\'2\',	\'\',\'' . $dashboard . '\');');
     $entity->customQuery('INSERT INTO "yana_plugin_dashboard" ("model", "data", "cell", "column", "minified","dashboard") VALUES (\'dash_monitoring_network\',	\'null\',	\'0\',	\'2\',	\'\',\'' . $dashboard . '\');');
     $entity->customQuery('INSERT INTO "yana_plugin_dashboard" ("model", "data", "cell", "column", "minified","dashboard") VALUES (\'dash_monitoring_hdd\',	\'null\',	\'3\',	\'1\',	\'\',\'' . $dashboard . '\');');
     $entity->customQuery('INSERT INTO "yana_plugin_dashboard" ("model", "data", "cell", "column", "minified","dashboard") VALUES (\'dash_monitoring_disk\',	\'null\',	\'0\',	\'1\',	\'\',\'' . $dashboard . '\');');
     $entity->customQuery('INSERT INTO "yana_plugin_dashboard" ("model", "data", "cell", "column", "minified","dashboard") VALUES (\'dash_monitoring_gpio\',	\'null\',	\'1\',	\'0\',	\'\',\'' . $dashboard . '\');');
     $entity->customQuery('INSERT INTO "yana_plugin_dashboard" ("model", "data", "cell", "column", "minified","dashboard") VALUES (\'dash_monitoring_services\',	\'null\',	\'0\',	\'2\',	\'\',\'' . $dashboard . '\');');
     $entity->customQuery('INSERT INTO "yana_plugin_dashboard" ("model", "data", "cell", "column", "minified","dashboard") VALUES (\'dash_monitoring_users\',	\'null\',	\'0\',	\'0\',	\'\',\'' . $dashboard . '\');');
     $entity->customQuery('INSERT INTO "yana_plugin_dashboard" ("model", "data", "cell", "column", "minified","dashboard") VALUES (\'dash_monitoring_ram\',	\'null\',	\'0\',	\'1\',	\'\',\'' . $dashboard . '\');');
     $entity->customQuery('INSERT INTO "yana_plugin_dashboard" ("model", "data", "cell", "column", "minified","dashboard") VALUES (\'dash_monitoring_vocal\',	\'null\',	\'1\',	\'2\',	\'\',\'' . $dashboard . '\');');
     $entity->customQuery('INSERT INTO "yana_plugin_dashboard" ("model", "data", "cell", "column", "minified","dashboard") VALUES (\'dash_monitoring_logs\',	\'null\',	\'1\',	\'2\',	\'\',\'' . $dashboard . '\');');
     return $dashboard;
 }
if (!$session->isLogin) {
    redirect("../login.php");
}
$database = new Database();
$user = new User();
$widget = new Widget();
$menu = new Menu();
$post = new Post();
if (isset($_POST['widgetName'])) {
    $widgetId = $database->escapeString($_POST['widgetName']);
    $widgetName = "Widget " . $widgetId;
    $widget->setWidgetId($widgetId);
    $widget->setName($widgetName);
    $widget->setMenuId(0);
    $widget->setPostId(0);
    if ($widget->create($database)) {
        echo "true";
    } else {
        echo "false";
    }
} else {
    if (isset($_POST['widgetIds'])) {
        foreach ($_POST['widgetIds'] as $widgetId) {
            $widget->setWidgetId($widgetId);
            $widget->delete($database);
        }
        echo "true";
    } else {
        if (isset($_POST['widgetId'])) {
            $widgetId = $database->escapeString($_POST['widgetId']);
            $type = $database->escapeString($_POST['type']);
Example #3
0
<?php

global $myUser;
require_once 'Dashboard.class.php';
require_once 'Widget.class.php';
$entity = new Dashboard();
$entity->create();
$entity->user = $myUser->getId();
$entity->label = "Général";
$entity->default = 1;
$entity->save();
$dashboard = $entity->id;
$entity = new Widget();
$entity->create();
$s1 = new Section();
$s1->setLabel('dashboard');
$s1->save();
$r1 = new Right();
$r1->setSection($s1->getId());
$r1->setRead('1');
$r1->setDelete('1');
$r1->setCreate('1');
$r1->setUpdate('1');
$r1->setRank('1');
$r1->save();
$entity->customQuery('INSERT INTO "yana_plugin_dashboard" ("id", "model", "data", "cell", "column", "minified","dashboard") VALUES (1,	\'dash_profil\',	\'null\',	\'0\',	\'0\',	\'\',\'' . $dashboard . '\');');
$entity->customQuery('INSERT INTO "yana_plugin_dashboard" ("id", "model", "data", "cell", "column", "minified","dashboard") VALUES (2,	\'dash_monitoring_ram\',	\'null\',	\'0\',	\'1\',	\'\',\'' . $dashboard . '\');');
$entity->customQuery('INSERT INTO "yana_plugin_dashboard" ("id", "model", "data", "cell", "column", "minified","dashboard") VALUES (3,	\'dash_monitoring_system\',	\'null\',	\'0\',	\'2\',	\'\',\'' . $dashboard . '\');');
$entity->customQuery('INSERT INTO "yana_plugin_dashboard" ("id", "model", "data", "cell", "column", "minified","dashboard") VALUES (4,	\'dash_monitoring_network\',	\'null\',	\'0\',	\'2\',	\'\',\'' . $dashboard . '\');');
$entity->customQuery('INSERT INTO "yana_plugin_dashboard" ("id", "model", "data", "cell", "column", "minified","dashboard") VALUES (5,	\'dash_monitoring_hdd\',	\'null\',	\'3\',	\'1\',	\'\',\'' . $dashboard . '\');');
$entity->customQuery('INSERT INTO "yana_plugin_dashboard" ("id", "model", "data", "cell", "column", "minified","dashboard") VALUES (6,	\'dash_monitoring_disk\',	\'null\',	\'0\',	\'1\',	\'\',\'' . $dashboard . '\');');