示例#1
0
function getSidebarNotifications() {
    global $modules, $admin_modules, $theme_settings, $urlAppend;

    $notifications_html = array();
    if (isset($_GET['courseIDs']) and count($_GET['courseIDs'])) {
        $t = new Template();
        $t->set_var('sideBarCourseNotifyBlock', $_SESSION['template']['sideBarCourseNotifyBlock']);
        foreach ($_GET['courseIDs'] as $id) {
            $t->set_var('sideBarCourseNotify', '');
            $notifications = get_course_notifications($id);
            $course_code = course_id_to_code($id);
            foreach ($notifications as $n) {
                $modules_array = (isset($modules[$n->module_id]))? $modules: $admin_modules;
                if (isset($modules_array[$n->module_id]) &&
                    isset($modules_array[$n->module_id]['image']) &&
                    isset($theme_settings['icon_map'][$modules_array[$n->module_id]['image']])) {
                    $t->set_var('sideBarCourseNotifyIcon', $theme_settings['icon_map'][$modules_array[$n->module_id]['image']]);
                    $t->set_var('sideBarCourseNotifyCount', $n->notcount);
                    $t->set_var('sideBarCourseNotifyTitle', q($modules_array[$n->module_id]['title']));
                    $t->set_var('sideBarCourseNotifyURL', $urlAppend . 'modules/' . $modules_array[$n->module_id]['link'] .
                                                    '/?course=' . $course_code);
                    $t->parse('sideBarCourseNotify', 'sideBarCourseNotifyBlock', true);
                }
            }
            $notifications_html[$id] = $t->get_var('sideBarCourseNotify');
        }
    }
    return $notifications_html;
}
示例#2
0
function getSidebarNotifications()
{
    global $modules, $admin_modules, $theme_settings;
    $notifications_html = array();
    if (isset($_POST['courseIDs']) and count($_POST['courseIDs'])) {
        $t = new Template();
        $t->set_var('sideBarCourseNotifyBlock', $_SESSION['template']['sideBarCourseNotifyBlock']);
        foreach ($_POST['courseIDs'] as $id) {
            $t->set_var('sideBarCourseNotify', '');
            $notifications = get_course_notifications($id);
            foreach ($notifications as $n) {
                $modules_array = isset($modules[$n->module_id]) ? $modules : $admin_modules;
                if (isset($modules_array[$n->module_id]) && isset($modules_array[$n->module_id]['image']) && isset($theme_settings['icon_map'][$modules_array[$n->module_id]['image']])) {
                    $t->set_var('sideBarCourseNotifyIcon', $theme_settings['icon_map'][$modules_array[$n->module_id]['image']]);
                    $t->set_var('sideBarCourseNotifyCount', $n->notcount);
                    $t->parse('sideBarCourseNotify', 'sideBarCourseNotifyBlock', true);
                }
            }
            $notifications_html[$id] = $t->get_var('sideBarCourseNotify');
        }
    }
    return $notifications_html;
}
示例#3
0
$require_valid_uid = true;
if (!session_id()) {
    session_start();
}
if(isset($_SESSION['dbname'])){
    $require_current_course = true;
}
require_once '../../include/init.php';
require_once 'notifications.inc.php';

if(isset($_GET['c']) && isset($_GET['m'])){
    $x='cm';$res = get_course_module_notifications($_GET['c'], $_GET['m']);
}
elseif(isset($_GET['c'])){
    $x='c';$res = get_course_notifications($_GET['c']);
}
elseif(isset($_GET['m'])){
   $x='m';$res = get_module_notifications($_GET['m']); 
} else {
   $x='u';$res = get_user_notifications(); 
}

if(!is_null($res)){
        echo json_encode($res);
} else {
    echo "$x: No data";
}