コード例 #1
0
 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;
 }
コード例 #2
0
 /**
  * Store a newly created dashboard in storage.
  *
  * @return Response
  */
 public function store()
 {
     $validator = Validator::make($data = Input::all(), Dashboard::$rules);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     Dashboard::create($data);
     return Redirect::route('dashboards.index');
 }
コード例 #3
0
 /**
  * Display the specified resource.
  *
  * @return Response
  */
 public function setChat()
 {
     if (Dashboard::all()->count() == 0) {
         Dashboard::create(array("report" => Input::get("name")));
     } else {
         $dashboard = Dashboard::first();
         $dashboard->report = Input::get("name");
         $dashboard->save();
     }
 }
コード例 #4
0
 public function run()
 {
     /* Apply seeder only if no Dashboard exists (database reset) */
     if (!Dashboard::all()->count()) {
         Dashboard::create(array('id' => '1', 'user_id' => '1', 'name' => 'First personal dashboard', 'background' => TRUE));
         ClockWidget::create(array('id' => '1', 'dashboard_id' => '1', 'descriptor_id' => '1', 'state' => 'active', 'position' => '{"row":1,"col":3,"size_x":8,"size_y":3}'));
         GreetingsWidget::create(array('id' => '2', 'dashboard_id' => '1', 'descriptor_id' => '1', 'state' => 'active', 'position' => '{"row":4,"col":3,"size_x":8,"size_y":1}'));
         /* Send message to console */
         error_log('InitialSeeder | Successfully seeded');
     } else {
         /* Send message to console */
         error_log('InitialSeeder | No modifications were made, because the DB is not empty');
     }
 }
コード例 #5
0
function dashboard_controller()
{
    global $mysqli, $session, $route;
    require "Modules/dashboard/dashboard_model.php";
    $dashboard = new Dashboard($mysqli);
    // id, userid, content, height, name, alias, description, main, public, published, showdescription
    $result = false;
    $submenu = '';
    if ($route->format == 'html') {
        if ($route->action == "list" && $session['write']) {
            $result = view("Modules/dashboard/Views/dashboard_list.php", array());
        } else {
            if ($route->action == "view") {
                $dashid = (int) get('id');
                if ($dashid) {
                    $dash = $dashboard->get($dashid);
                } else {
                    if ($session['read']) {
                        if ($route->subaction) {
                            $dash = $dashboard->get_from_alias($session['userid'], $route->subaction);
                        } else {
                            $dash = $dashboard->get_main($session['userid']);
                        }
                    }
                }
                if (isset($dash)) {
                    if ($dash['public'] || $session['read'] && $session['userid'] > 0 && $dash['userid'] == $session['userid'] && !isset($session['profile'])) {
                        if (!$session['userid']) {
                            $session['userid'] = $dash['userid'];
                        }
                        // Required for passing userid to feed api
                        $result = view("Modules/dashboard/Views/dashboard_view.php", array('dashboard' => $dash));
                    } else {
                        if ($session['read'] && !isset($session['profile'])) {
                            $result = view("Modules/dashboard/Views/dashboard_list.php", array());
                        }
                    }
                }
                if ($session['write']) {
                    $submenu = view("Modules/dashboard/Views/dashboard_menu.php", array('id' => $dash['id'], 'type' => "view"));
                }
            } else {
                if ($route->action == "edit" && $session['write']) {
                    if ($route->subaction) {
                        $dash = $dashboard->get_from_alias($session['userid'], $route->subaction);
                    } elseif (isset($_GET['id'])) {
                        $dash = $dashboard->get(get('id'));
                    }
                    $result = view("Modules/dashboard/Views/dashboard_edit_view.php", array('dashboard' => $dash));
                    $result .= view("Modules/dashboard/Views/dashboard_config.php", array('dashboard' => $dash));
                    $submenu = view("Modules/dashboard/Views/dashboard_menu.php", array('id' => $dash['id'], 'type' => "edit"));
                }
            }
        }
    } else {
        if ($route->format == 'json') {
            if ($session['write']) {
                if ($route->action == 'list') {
                    $result = $dashboard->get_list($session['userid'], false, false);
                } else {
                    if ($route->action == 'set') {
                        $result = $dashboard->set($session['userid'], get('id'), get('fields'));
                    } else {
                        if ($route->action == 'setcontent') {
                            $result = $dashboard->set_content($session['userid'], post('id'), post('content'), post('height'));
                        } else {
                            if ($route->action == 'create') {
                                $result = $dashboard->create($session['userid']);
                            } else {
                                if ($route->action == 'delete') {
                                    $result = $dashboard->delete(get('id'));
                                } else {
                                    if ($route->action == 'clone') {
                                        $result = $dashboard->dashclone($session['userid'], get('id'));
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    return array('content' => $result, 'submenu' => $submenu);
}
コード例 #6
0
function dashboard_controller()
{
    global $mysqli, $path, $session, $route, $user;
    require "Modules/dashboard/dashboard_model.php";
    $dashboard = new Dashboard($mysqli);
    // id, userid, content, height, name, alias, description, main, public, published, showdescription
    $result = false;
    $submenu = '';
    if ($route->format == 'html') {
        if ($route->action == "list" && $session['write']) {
            $result = view("Modules/dashboard/Views/dashboard_list.php", array());
            $menu = $dashboard->build_menu($session['userid'], "view");
            $submenu = view("Modules/dashboard/Views/dashboard_menu.php", array('menu' => $menu, 'type' => "view"));
        }
        if ($route->action == "view" && $session['read']) {
            if ($route->subaction) {
                $dash = $dashboard->get_from_alias($session['userid'], $route->subaction, false, false);
            } elseif (isset($_GET['id'])) {
                $dash = $dashboard->get($session['userid'], get('id'), false, false);
            } else {
                $dash = $dashboard->get_main($session['userid']);
            }
            if ($dash) {
                $result = view("Modules/dashboard/Views/dashboard_view.php", array('dashboard' => $dash));
            } else {
                $result = view("Modules/dashboard/Views/dashboard_list.php", array());
            }
            $menu = $dashboard->build_menu($session['userid'], "view");
            $submenu = view("Modules/dashboard/Views/dashboard_menu.php", array('id' => $dash['id'], 'menu' => $menu, 'type' => "view"));
        }
        if ($route->action == "edit" && $session['write']) {
            if ($route->subaction) {
                $dash = $dashboard->get_from_alias($session['userid'], $route->subaction, false, false);
            } elseif (isset($_GET['id'])) {
                $dash = $dashboard->get($session['userid'], get('id'), false, false);
            }
            $result = view("Modules/dashboard/Views/dashboard_edit_view.php", array('dashboard' => $dash));
            $result .= view("Modules/dashboard/Views/dashboard_config.php", array('dashboard' => $dash));
            $menu = $dashboard->build_menu($session['userid'], "edit");
            $submenu = view("Modules/dashboard/Views/dashboard_menu.php", array('id' => $dash['id'], 'menu' => $menu, 'type' => "edit"));
        }
    }
    if ($route->format == 'json') {
        if ($route->action == 'list' && $session['write']) {
            $result = $dashboard->get_list($session['userid'], false, false);
        }
        if ($route->action == 'set' && $session['write']) {
            $result = $dashboard->set($session['userid'], get('id'), get('fields'));
        }
        if ($route->action == 'setcontent' && $session['write']) {
            $result = $dashboard->set_content($session['userid'], post('id'), post('content'), post('height'));
        }
        if ($route->action == 'delete' && $session['write']) {
            $result = $dashboard->delete(get('id'));
        }
        if ($route->action == 'create' && $session['write']) {
            $result = $dashboard->create($session['userid']);
        }
        if ($route->action == 'clone' && $session['write']) {
            $result = $dashboard->dashclone($session['userid'], get('id'));
        }
    }
    // $result = $dashboard->get_main($session['userid'])
    return array('content' => $result, 'submenu' => $submenu);
}
コード例 #7
0
ファイル: install.php プロジェクト: thib3113/yana-server
<?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 . '\');');