/** * testGetRowsByUserId */ public function testDeleteDashboardAndRelatedPortlets() { Yii::app()->user->userModel = User::getByUsername('billy'); $dashboardCount = Dashboard::getCount(); $this->assertTrue($dashboardCount > 0); $user = User::getByUserName('billy'); Yii::app()->user->userModel = $user; $dashboard = new Dashboard(); $dashboard->name = "Dashboard TESTING"; $dashboard->layoutId = 3; $dashboard->owner = $user; $dashboard->layoutType = '100'; $dashboard->isDefault = false; $this->assertTrue($dashboard->save()); $this->assertEquals(Portlet::getCount(), 0); $this->assertEquals(Dashboard::getCount(), $dashboardCount + 1); for ($i = 1; $i <= 3; $i++) { $portlet = new Portlet(); $portlet->column = 1; $portlet->position = 1 + $i; $portlet->layoutId = 'TEST' . $dashboard->layoutId; $portlet->collapsed = false; $portlet->viewType = 'TasksMyList'; $portlet->user = $user; $this->assertTrue($portlet->save()); } $this->assertEquals(Portlet::getCount(), 3); $portlets = Portlet::getByLayoutIdAndUserSortedById('TEST' . $dashboard->layoutId, $user->id); foreach ($portlets as $portlet) { $portlet->delete(); } $dashboard->delete(); $this->assertEquals(Portlet::getCount(), 0); $this->assertEquals(Dashboard::getCount(), $dashboardCount); }
// The only possibles values are 0 to 3 // 0 -> Nothing displayed // 1 -> Only options are displayed // 2 -> Only links are displayed // 3 -> Both are displayed $display_options_links = 0; } include VIEW_PATH . '/view_dashboard.php'; } elseif ('delete' == $action) { $class_name = 'Dashboard'; try { $obj = new Dashboard($dashboard_id); $delete_text = 'Are you sure you want to delete dashboard : <strong>' . $obj->getName() . '</strong>?'; if (fRequest::isPost()) { fRequest::validateCSRFToken(fRequest::get('token')); $obj->delete(); $graphs = Graph::findAll($dashboard_id); // Do Dashboard Subelement Cleanup foreach ($graphs as $graph) { $lines = Line::findAll($graph->getGraphId()); foreach ($lines as $line) { $line->delete(); } $graph->delete(); } fMessaging::create('success', Dashboard::makeUrl('list'), 'The Dashboard ' . $obj->getName() . ' was successfully deleted'); fURL::redirect(Dashboard::makeUrl('list')); } } catch (fNotFoundException $e) { fMessaging::create('error', Dashboard::makeUrl('list'), 'The Dashboard requested could not be found'); fURL::redirect(Dashboard::makeUrl('list'));
function dashboard_plugin_actions() { global $myUser, $_, $conf; switch ($_['action']) { case 'GET_WIDGETS': header('Content-type: application/json'); require_once dirname(__FILE__) . '/Dashboard.class.php'; require_once dirname(__FILE__) . '/Widget.class.php'; $dashManager = new Dashboard(); $dashManager->change(array('default' => '0')); $dashManager->change(array('default' => '1'), array('id' => $_['dashboard'])); $widgetManager = new Widget(); $model = array(); Plugin::callHook("widgets", array(&$model)); $widgets = $widgetManager->loadAll(array('dashboard' => $_['dashboard']), 'cell'); $data = array(); foreach ($widgets as $widget) { $data[] = array('data' => $widget->data, 'column' => $widget->column, 'id' => $widget->id, 'cell' => $widget->cell, 'minified' => $widget->minified, 'model' => $widget->model); } echo json_encode(array('model' => $model, 'data' => $data)); break; case 'ADD_WIDGET': header('Content-type: application/json'); require_once dirname(__FILE__) . '/Widget.class.php'; $response = array(); $widget = new Widget(); $widget->data = json_encode($_POST['data']); $widget->column = $_['column']; $widget->cell = $_['cell']; $widget->model = $_['model']; $widget->dashboard = $_['view']; $widget->save(); $response['id'] = $widget->id; echo json_encode($response); break; case 'MINIMIZE_WIDGET': header('Content-type: application/json'); require_once dirname(__FILE__) . '/Widget.class.php'; $response = array(); $widgetManager = new Widget(); $widgetManager = $widgetManager->getById($_['id']); $widgetManager->minified = 1; $widgetManager->save(); echo json_encode($response); break; case 'MAXIMIZE_WIDGET': header('Content-type: application/json'); require_once dirname(__FILE__) . '/Widget.class.php'; $response = array(); $widgetManager = new Widget(); $widgetManager = $widgetManager->getById($_['id']); $widgetManager->minified = 0; $widgetManager->save(); echo json_encode($response); break; case 'MOVE_WIDGET': header('Content-type: application/json'); require_once dirname(__FILE__) . '/Widget.class.php'; $response = array(); $widgetManager = new Widget(); foreach ($_['sort']['cells'] as $id => $sort) { $widgetManager->change(array('cell' => $sort['cell'], 'column' => $sort['column']), array('id' => $id)); } echo json_encode($response); break; case 'DELETE_WIDGET': header('Content-type: application/json'); require_once dirname(__FILE__) . '/Widget.class.php'; $response = array(); $widgetManager = new Widget(); $widgetManager->delete(array('id' => $_['id'])); echo json_encode($response); break; case 'DASH_ADD_VIEW': global $_, $myUser; require_once dirname(__FILE__) . '/Dashboard.class.php'; $entity = new Dashboard(); $entity->user = $myUser->getId(); $entity->label = $_['viewName']; $entity->default = 0; $entity->save(); header('location: setting.php?section=preference&block=dashboard'); break; case 'DASH_DELETE_VIEW': global $_, $myUser; require_once dirname(__FILE__) . '/Dashboard.class.php'; $entity = new Dashboard(); $entity->delete(array('id' => $_['id'])); header('location: setting.php?section=preference&block=dashboard'); break; } }
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); }
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); }
sugar_die('no index is requested to move'); } global $current_user; $focus->retrieve($_REQUEST['record']); if (empty($focus->id) || $focus->id == -1) { sugar_die("there is no dashboard associated to this id:" . $_REQUEST['record']); } if ($current_user->id != $focus->assigned_user_id) { sugar_die("why are you trying to edit someone else's dashboard?"); } if ($_REQUEST['dashboard_action'] == 'move_up') { $focus->move('up', $_REQUEST['chart_index']); } else { if ($_REQUEST['dashboard_action'] == 'move_down') { $focus->move('down', $_REQUEST['chart_index']); } else { if ($_REQUEST['dashboard_action'] == 'delete') { $focus->delete($_REQUEST['chart_index']); } else { if ($_REQUEST['dashboard_action'] == 'add') { $focus->add($_REQUEST['chart_type'], $_REQUEST['chart_id'], $_REQUEST['chart_index']); } else { if ($_REQUEST['dashboard_action'] == 'arrange') { $focus->arrange(split('-', $_REQUEST['chartorder'])); } } } } } header("Location: index.php?module=" . $_REQUEST['return_module'] . "&action=" . $_REQUEST['return_action'] . "&record=" . $_REQUEST['return_id']); exit;
unset($_SESSION['flash']); }); $route->respond('POST', '/login', function ($request, $response, $service) use($home) { return $home->postLogin($request, $response, $service); }); $route->respond('GET', '/logout', function ($request, $response, $service) use($home) { return $home->logout($request, $response, $service); }); $route->respond('GET', '/dashboard/index', function ($request, $response) use($dashboard) { return $dashboard->index($request, $response); }); $route->respond('GET', '/dashboard/show', function ($request, $response) use($dashboard) { return $dashboard->show($request, $response); }); $route->respond('GET', '/dashboard/delete/[i:id]', function ($request, $response) use($dashboard) { return $dashboard->delete($request, $response); }); $route->respond('GET', '/dashboard/edit/[i:id]', function ($request, $response) use($dashboard) { return $dashboard->edit($request, $response); }); $route->respond('POST', '/dashboard/edit/[i:id]', function ($request, $response) use($dashboard) { return $dashboard->update($request, $response); }); $route->respond('GET', '/dashboard/leave/index', function ($request, $response) use($leave) { return $leave->index($request, $response); }); $route->respond('GET', '/dashboard/leave/create', function ($request, $response) use($leave) { return $leave->create($request, $response); }); $route->respond('POST', '/dashboard/leave/create', function ($request, $response) use($leave) { return $leave->store($request, $response);