index.php 3.76 KB
Newer Older
1
2
3
4
<?php
/**
 *
 * @package    mahara
5
 * @subpackage core
6
 * @author     Catalyst IT Ltd
7
8
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL version 3 or later
 * @copyright  For copyright information on Mahara, please see the README file distributed with this software.
9
10
11
 *
 */

12
13
define('INTERNAL', 1);
define('PUBLIC', 1);
14
define('MENUITEM', 'home');
15
define('HOME', 1);
16
17
require('init.php');

18
19
// Check for whether the user is logged in, before processing the page. After
// this, we can guarantee whether the user is logged in or not for this page.
20
if (!$USER->is_logged_in()) {
21
    define('TITLE', get_string('home'));
Richard Mansfield's avatar
Richard Mansfield committed
22
23
24
    $pagename = 'loggedouthome';
}
else {
25
    define('TITLE', get_string('dashboard', 'view'));
Richard Mansfield's avatar
Richard Mansfield committed
26
    $pagename = 'home';
27
28
}

29
30
31
if ($USER->is_logged_in()) {
    // get the user's dashboard view
    require_once(get_config('libroot') . 'view.php');
32
    $view = $USER->get_view_by_type('dashboard');
33

34
    $javascript = array('paginator');
35
36
    $blocktype_js = $view->get_all_blocktype_javascript();
    $javascript = array_merge($javascript, $blocktype_js['jsfiles']);
37
    $inlinejs = "jQuery( function() {\n" . join("\n", $blocktype_js['initjs']) . "\n});";
38
    $stylesheets = array();
39
    $stylesheets = array_merge($stylesheets, $view->get_all_blocktype_css());
40

41
42
43
44
45
46
47
48
49
    // Set up skin, if the page has one
    $viewskin = $view->get('skin');
    if ($viewskin && get_config('skins') && can_use_skins($view->get('owner'), false, false) && (!isset($THEME->skins) || $THEME->skins !== false)) {
        $skin = array('skinid' => $viewskin, 'viewid' => $view->get('id'));
    }
    else {
        $skin = false;
    }

50
    $viewcontent = $view->build_rows(); // Build content before initialising smarty in case pieform elements define headers.
51
    $smarty = smarty(
52
        $javascript,
53
54
55
56
        $stylesheets,
        array(),
        array(
            'stylesheets' => array('style/views.css'),
57
            'skin' => $skin,
58
59
        )
    );
60

61
    $js = '';
62
    if (get_config('homepageinfo') && $USER->get_account_preference('showhomeinfo')) {
63
        // allow the user to choose never to see the info boxes again
64
        $strhowtodisable = json_encode(get_string('howtodisable', 'mahara', get_config('wwwroot') . 'account'));
65
        $js = <<<JAVASCRIPT
66
67
68
69
70
71
jQuery(function($) {
    function hideinfo() {
        var m = $('<span>');
        m.html({$strhowtodisable});
        $('#home-info-container').slideUp('fast', function() { displayMessage(m, 'ok'); });
    }
72

73
74
75
76
77
78
79
    function nevershow() {
        var data = {'showhomeinfo' : 0};
        sendjsonrequest('homeinfo.json.php', data, 'POST', hideinfo);
    }

    if ($('#hideinfo').length) {
        $('#hideinfo').on('click', nevershow);
80
    }
81
82
83
84
});
JAVASCRIPT;

    }
85
    $smarty->assign('INLINEJAVASCRIPT', $js . $inlinejs);
86

87
    $smarty->assign('dashboardview', true);
88
    $smarty->assign('viewcontent', $viewcontent);
89
90
91
92
    $smarty->assign('viewid', $view->get('id'));
}
else {
    $smarty = smarty();
93
94
    // Used to set a 'loggedout' class on body tag for styling purposes
    $smarty->assign('loggedout', true);
95
96
}

97
98
99
// Assign urls used in homeinfo.tpl
$wwwroot = get_config('wwwroot');
$urls = array(
100
101
102
103
104
    'profile' => $wwwroot . 'artefact/internal/index.php',
    'files'   => $wwwroot . 'artefact/file/index.php',
    'resume'  => $wwwroot . 'artefact/resume/index.php',
    'blog'    => $wwwroot . 'artefact/blog/index.php',
    'views'   => $wwwroot . 'view/index.php',
105
    'friends' => $wwwroot . 'user/index.php?filter=current',
106
    'groups'  => $wwwroot . 'group/index.php',
107
108
    'topics'  => $wwwroot . 'group/topics.php',
    'share'   => $wwwroot . 'view/share.php',
109
);
110
$smarty->assign('PAGEHEADING', null);
111
$smarty->assign('pagename', $pagename);
112
$smarty->assign('url', $urls);
113
$smarty->assign('page_content', get_site_page_content($pagename));
114
$smarty->display('index.tpl');