dashboard.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Template (view in MVC pattern) used for displaying blocks for dashboard
  5. * @author Christian Fasanando <christian1827@gmail.com>
  6. * @package chamilo.dashboard
  7. */
  8. // protect script
  9. api_block_anonymous_users();
  10. // menu actions for dashboard views
  11. $views = array('blocks', 'list');
  12. if(isset($_GET['view']) && in_array($_GET['view'], $views)){
  13. $dashboard_view = $_GET['view'];
  14. }
  15. $link_blocks_view = $link_list_view = null;
  16. if (isset($dashboard_view) && $dashboard_view == 'list') {
  17. $link_blocks_view = '<a href="'.api_get_self().'?view=blocks">'.
  18. Display::return_icon('blocks.png',get_lang('DashboardBlocks'),'',ICON_SIZE_MEDIUM).'</a>';
  19. } else {
  20. $link_list_view = '<a href="'.api_get_self().'?view=list">'.
  21. Display::return_icon('edit.png',get_lang('EditBlocks'),'',ICON_SIZE_MEDIUM).'</a>';
  22. }
  23. $configuration_link = null;
  24. if (api_is_platform_admin()) {
  25. $configuration_link = '<a href="'.api_get_path(WEB_CODE_PATH).'admin/settings.php?category=Plugins">'
  26. .Display::return_icon('settings.png',get_lang('ConfigureDashboardPlugin'),'',ICON_SIZE_MEDIUM).'</a>';
  27. }
  28. echo '<div class="actions">';
  29. echo $link_blocks_view.$link_list_view.$configuration_link;
  30. echo '</div>';
  31. // block dashboard view
  32. if (isset($dashboard_view) && $dashboard_view == 'blocks') {
  33. if (isset($blocks) && count($blocks) > 0) {
  34. $columns = array();
  35. // group content html by number of column
  36. if (is_array($blocks)) {
  37. $tmp_columns = array();
  38. foreach ($blocks as $block) {
  39. $tmp_columns[] = $block['column'];
  40. if (in_array($block['column'], $tmp_columns)) {
  41. $columns['column_'.$block['column']][] = $block['content_html'];
  42. }
  43. }
  44. }
  45. echo '<div id="columns" class="row">';
  46. if (count($columns) > 0) {
  47. $columns_name = array_keys($columns);
  48. // blocks for column 1
  49. if (in_array('column_1', $columns_name)) {
  50. echo '<div id="column1" class="col-md-6">';
  51. foreach ($columns['column_1'] as $content) {
  52. echo $content;
  53. }
  54. echo '</div>';
  55. } else {
  56. echo '<div id="column1" class="col-md-6">';
  57. echo '&nbsp;';
  58. echo '</div>';
  59. }
  60. // blocks for column 2
  61. if (in_array('column_2', $columns_name)) {
  62. // blocks for column 1
  63. echo '<div id="column2" class="col-md-6">';
  64. foreach ($columns['column_2'] as $content) {
  65. echo $content;
  66. }
  67. echo '</div>';
  68. } else {
  69. echo '<div id="column2" class="col-md-6">';
  70. echo '&nbsp;';
  71. echo '</div>';
  72. }
  73. }
  74. echo '</div>';
  75. } else {
  76. echo '<div style="margin-top:20px;">'.get_lang('YouHaveNotEnabledBlocks').'</div>';
  77. }
  78. } else {
  79. // block dashboard list
  80. if (isset($success)) {
  81. Display::display_confirmation_message(get_lang('BlocksHaveBeenUpdatedSuccessfully'));
  82. }
  83. $user_id = api_get_user_id();
  84. DashboardManager::display_user_dashboard_list($user_id);
  85. }