@link http://blog.idleman.fr @licence CC by nc sa @version 1.0.0 @description Active la dashboard dynamique utilisable par d'autres plugins @type plugin */ 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'),array('user'=>$myUser->getId())); $dashManager->change(array('default'=>'1'),array('id'=>$_['dashboard'],'user'=>$myUser->getId())); $widgetManager = new Widget(); $model = array(); Plugin::callHook("widgets",array(&$model)); $widgets = $widgetManager->loadAll(array('dashboard'=>$_['dashboard']),'cell'); $data = array(); foreach($widgets as $widget){ if(!is_active_model($widget->model,$model)) continue; $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){ if(empty($sort)) continue; $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_plugin_home(){ global $_,$myUser; if(!isset($_['module'])){ require_once(dirname(__FILE__).'/Dashboard.class.php'); require_once(dirname(__FILE__).'/Widget.class.php'); $dashManager = new Dashboard(); $dashes = $dashManager->loadAll(array('user'=>$myUser->getId()),'label'); if(count($dashes) == 0){ Dashboard::initForUser($myUser->getId()); $dashes = $dashManager->loadAll(array('user'=>$myUser->getId()),'label'); } echo '
'; echo '
'; } } function dashboard_plugin_preference_menu(){ global $_; echo '
  • Dashboard
  • '; } function dashboard_plugin_preference_page(){ global $myUser,$_,$conf; if((isset($_['section']) && $_['section']=='preference' && @$_['block']=='dashboard' ) ){ if($myUser!=false){ require_once(dirname(__FILE__).'/Dashboard.class.php'); $dashManager = new Dashboard(); $dashes = $dashManager->loadAll(array('user'=>$myUser->getId())); ?>
    Dashboard disponibles
    Nom Options
    label; ?>
    Enregistrer

    Vous devez ĂȘtre connectĂ©