dashboard.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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">'.Display::return_icon('blocks.png',get_lang('DashboardBlocks'),'',ICON_SIZE_MEDIUM).'</a>';
  18. } else {
  19. $link_list_view = '<a href="'.api_get_self().'?view=list">'.Display::return_icon('edit.png',get_lang('EditBlocks'),'',ICON_SIZE_MEDIUM).'</a>';
  20. }
  21. $configuration_link = null;
  22. if (api_is_platform_admin()) {
  23. $configuration_link = '<a href="'.api_get_path(WEB_CODE_PATH).'admin/settings.php?category=Plugins">'
  24. .Display::return_icon('settings.png',get_lang('ConfigureDashboardPlugin'),'',ICON_SIZE_MEDIUM).'</a>';
  25. }
  26. echo '<div class="actions">';
  27. echo $link_blocks_view.$link_list_view.$configuration_link;
  28. echo '</div>';
  29. // block dashboard view
  30. if (isset($dashboard_view) && $dashboard_view == 'blocks') {
  31. if (isset($msg)) {
  32. //Display::display_confirmation_message(get_lang('BlocksHaveBeenUpdatedSuccessfully'));
  33. }
  34. if (count($blocks) > 0) {
  35. $columns = array();
  36. // group content html by number of column
  37. if (is_array($blocks)) {
  38. $tmp_columns = array();
  39. foreach ($blocks as $block) {
  40. $tmp_columns[] = $block['column'];
  41. if (in_array($block['column'], $tmp_columns)) {
  42. $columns['column_'.$block['column']][] = $block['content_html'];
  43. }
  44. }
  45. }
  46. echo '<div id="columns">';
  47. if (count($columns) > 0) {
  48. $columns_name = array_keys($columns);
  49. // blocks for column 1
  50. if (in_array('column_1',$columns_name)) {
  51. echo '<ul id="column1" class="column">';
  52. foreach ($columns['column_1'] as $content) {
  53. echo $content;
  54. }
  55. echo '</ul>';
  56. } else {
  57. echo '<ul id="column1" class="column">';
  58. echo '&nbsp;';
  59. echo '</ul>';
  60. }
  61. // blocks for column 2
  62. if (in_array('column_2',$columns_name)) {
  63. // blocks for column 1
  64. echo '<ul id="column2" class="column">';
  65. foreach ($columns['column_2'] as $content) {
  66. echo $content;
  67. }
  68. echo '</ul>';
  69. } else {
  70. echo '<ul id="column2" class="column">';
  71. echo '&nbsp;';
  72. echo '</ul>';
  73. }
  74. }
  75. echo '</div>';
  76. } else {
  77. echo '<div style="margin-top:20px;">'.get_lang('YouHaveNotEnabledBlocks').'</div>';
  78. }
  79. } else {
  80. // block dashboard list
  81. if (isset($success)) {
  82. Display::display_confirmation_message(get_lang('BlocksHaveBeenUpdatedSuccessfully'));
  83. }
  84. $user_id = api_get_user_id();
  85. DashboardManager::display_user_dashboard_list($user_id);
  86. }