Exemple #1
0
/**
 * Function lessonToolsMenu
 *
 * Creates a multi-dimensional array of the user's tools
 * in regard to the user's user level
 * (student | professor | platform administrator)
 *
 * @return array
 */
function lessonToolsMenu()
{
    global $uid, $is_editor, $is_course_admin;
    global $course_code, $langAdministrationTools, $langExternalLinks;
    global $modules, $admin_modules, $urlAppend;
    $sideMenuGroup = array();
    $sideMenuSubGroup = array();
    $sideMenuText = array();
    $sideMenuLink = array();
    $sideMenuImg = array();
    $sideMenuID = array();
    $arrMenuType = array();
    $arrMenuType['type'] = 'none';
    if ($is_editor) {
        $tools_sections = array(array('type' => 'Public', 'title' => $GLOBALS['langActiveTools'], 'iconext' => '_on.png', 'class' => 'active'), array('type' => 'PublicButHide', 'title' => $GLOBALS['langInactiveTools'], 'iconext' => '_off.png', 'class' => 'inactive'));
    } else {
        $tools_sections = array(array('type' => 'Public', 'title' => $GLOBALS['langCourseOptions'], 'iconext' => '_on.png', 'class' => 'active'));
    }
    foreach ($tools_sections as $section) {
        $result = getToolsArray($section['type']);
        $sideMenuSubGroup = array();
        $sideMenuText = array();
        $sideMenuLink = array();
        $sideMenuImg = array();
        $sideMenuID = array();
        $arrMenuType = array('type' => 'text', 'text' => $section['title'], 'class' => $section['class']);
        array_push($sideMenuSubGroup, $arrMenuType);
        foreach ($result as $toolsRow) {
            $mid = $toolsRow->module_id;
            if ($mid == MODULE_ID_DROPBOX) {
                require_once 'modules/dropbox/class.mailbox.php';
                $mbox = new Mailbox($uid, course_code_to_id($course_code));
                $new_msgs = $mbox->unreadMsgsNumber();
                if ($new_msgs != 0) {
                    array_push($sideMenuText, "<b>" . q($modules[$mid]['title']) . " (" . $new_msgs . ")</b>");
                } else {
                    array_push($sideMenuText, q($modules[$mid]['title']));
                }
            } else {
                array_push($sideMenuText, q($modules[$mid]['title']));
            }
            array_push($sideMenuLink, q($urlAppend . 'modules/' . $modules[$mid]['link'] . '/?course=' . $course_code));
            array_push($sideMenuImg, $modules[$mid]['image'] . $section['iconext']);
            array_push($sideMenuID, $mid);
        }
        array_push($sideMenuSubGroup, $sideMenuText);
        array_push($sideMenuSubGroup, $sideMenuLink);
        array_push($sideMenuSubGroup, $sideMenuImg);
        array_push($sideMenuSubGroup, $sideMenuID);
        array_push($sideMenuGroup, $sideMenuSubGroup);
    }
    $result2 = getExternalLinks();
    if ($result2) {
        // display external link (if any)
        $sideMenuSubGroup = array();
        $sideMenuText = array();
        $sideMenuLink = array();
        $sideMenuImg = array();
        $arrMenuType = array('type' => 'text', 'text' => $langExternalLinks, 'class' => 'external');
        array_push($sideMenuSubGroup, $arrMenuType);
        foreach ($result2 as $ex_link) {
            array_push($sideMenuText, q($ex_link->title));
            array_push($sideMenuLink, q($ex_link->url));
            array_push($sideMenuImg, "external_link" . $section['iconext']);
        }
        array_push($sideMenuSubGroup, $sideMenuText);
        array_push($sideMenuSubGroup, $sideMenuLink);
        array_push($sideMenuSubGroup, $sideMenuImg);
        array_push($sideMenuGroup, $sideMenuSubGroup);
    }
    if ($is_course_admin) {
        // display course admin tools
        $sideMenuSubGroup = array();
        $sideMenuText = array();
        $sideMenuLink = array();
        $sideMenuImg = array();
        $sideMenuID = array();
        $arrMenuType = array('type' => 'text', 'text' => $langAdministrationTools, 'class' => 'course_admin');
        array_push($sideMenuSubGroup, $arrMenuType);
        foreach ($admin_modules as $adm_mod) {
            array_push($sideMenuText, $adm_mod['title']);
            array_push($sideMenuLink, q($urlAppend . 'modules/' . $adm_mod['link'] . '/?course=' . $course_code));
            array_push($sideMenuImg, $adm_mod['image'] . $section['iconext']);
        }
        array_push($sideMenuSubGroup, $sideMenuText);
        array_push($sideMenuSubGroup, $sideMenuLink);
        array_push($sideMenuSubGroup, $sideMenuImg);
        array_push($sideMenuSubGroup, $sideMenuID);
        array_push($sideMenuGroup, $sideMenuSubGroup);
    }
    return $sideMenuGroup;
}
Exemple #2
0
/**
 * Function lessonToolsMenu
 *
 * Creates a multi-dimensional array of the user's tools
 * in regard to the user's user level
 * (student | professor | platform administrator)
 *
 * @return array
 */
function lessonToolsMenu() {
    global $uid, $is_editor, $is_course_admin, $courses,
           $course_code, $langAdministrationTools, $langExternalLinks,
           $modules, $admin_modules, $urlAppend, $status, $course_id;

    $sideMenuGroup = array();
    $sideMenuSubGroup = array();
    $sideMenuText = array();
    $sideMenuLink = array();
    $sideMenuImg = array();
    $sideMenuID = array();

    $arrMenuType = array();
    $arrMenuType['type'] = 'none';

    if ($is_editor || $is_course_admin) {
        $tools_sections =
            array(array('type' => 'Public',
                        'title' => $GLOBALS['langActiveTools'],
                        'iconext' => '_on.png',
                        'class' => 'active'),
                  array('type' => 'PublicButHide',
                        'title' => $GLOBALS['langInactiveTools'],
                        'iconext' => '_off.png',
                        'class' => 'inactive'));
    } else {
        $tools_sections =
            array(array('type' => 'Public',
                        'title' => $GLOBALS['langCourseOptions'],
                        'iconext' => '_on.png',
                        'class' => 'active'));
    }

    foreach ($tools_sections as $section) {
        $result = getToolsArray($section['type']);

        $sideMenuSubGroup = array();
        $sideMenuText = array();
        $sideMenuLink = array();
        $sideMenuImg = array();
        $sideMenuID = array();
        $mail_status = '';
        $arrMenuType = array('type' => 'text',
                             'text' => $section['title'],
                             'class' => $section['class']);
        array_push($sideMenuSubGroup, $arrMenuType);

        setlocale(LC_COLLATE, $GLOBALS['langLocale']);
        usort($result, function ($a, $b) {
            global $modules;
            return strcoll($modules[$a->module_id]['title'], $modules[$b->module_id]['title']);
        });

        // check if we have define mail address and want to receive messages
        if ($uid and $status != USER_GUEST and !get_user_email_notification($uid, $course_id)) {
            $mail_status = '&nbsp;' . icon('fa-exclamation-triangle');
        }

        foreach ($result as $toolsRow) {
            $mid = $toolsRow->module_id;

            // hide groups for unregistered users
            if ($mid == MODULE_ID_GROUPS and !$courses[$course_code]) {
                continue;
            }

            // hide teleconference when no BBB servers are enabled
            if ($mid == MODULE_ID_BBB and !get_total_bbb_servers()) {
                continue;
            }

            // if we are in dropbox or announcements add (if needed) mail address status
            if ($mid == MODULE_ID_DROPBOX or $mid == MODULE_ID_ANNOUNCE) {
                if ($mid == MODULE_ID_DROPBOX) {
                    $mbox = new Mailbox($uid, course_code_to_id($course_code));
                    $new_msgs = $mbox->unreadMsgsNumber();
                    if ($new_msgs != 0) {
                        array_push($sideMenuText, '<b>' . q($modules[$mid]['title']) .
                            " $mail_status<span class='badge pull-right'>$new_msgs</span></b>");
                    } else {
                        array_push($sideMenuText, q($modules[$mid]['title']).' '.$mail_status);
                    }
                } else {
                    array_push($sideMenuText, q($modules[$mid]['title']).' '.$mail_status);
                }
            } elseif ($mid == MODULE_ID_DOCS and ($new_docs = get_new_document_count($course_id))) {
                array_push($sideMenuText, '<b>' . q($modules[$mid]['title']) .
                    "<span class='badge pull-right'>$new_docs</span></b>");
            } else {
                array_push($sideMenuText, q($modules[$mid]['title']));
            }

            array_push($sideMenuLink, q($urlAppend . 'modules/' . $modules[$mid]['link'] .
                            '/?course=' . $course_code));
            array_push($sideMenuImg, $modules[$mid]['image'] . $section['iconext']);
            array_push($sideMenuID, $mid);
        }
        array_push($sideMenuSubGroup, $sideMenuText);
        array_push($sideMenuSubGroup, $sideMenuLink);
        array_push($sideMenuSubGroup, $sideMenuImg);
        array_push($sideMenuSubGroup, $sideMenuID);
        array_push($sideMenuGroup, $sideMenuSubGroup);
    }
    $result2 = getExternalLinks();
    if ($result2) { // display external link (if any)
        $sideMenuSubGroup = array();
        $sideMenuText = array();
        $sideMenuLink = array();
        $sideMenuImg = array();
        $arrMenuType = array('type' => 'text',
                             'text' => $langExternalLinks,
                             'class' => 'external');
        array_push($sideMenuSubGroup, $arrMenuType);

        foreach ($result2 as $ex_link) {
            array_push($sideMenuText, q($ex_link->title));
            array_push($sideMenuLink, q($ex_link->url));
            array_push($sideMenuImg, 'fa-external-link');
        }

        array_push($sideMenuSubGroup, $sideMenuText);
        array_push($sideMenuSubGroup, $sideMenuLink);
        array_push($sideMenuSubGroup, $sideMenuImg);
        array_push($sideMenuGroup, $sideMenuSubGroup);
    }
    if ($is_course_admin) {  // display course admin tools
        $sideMenuSubGroup = array();
        $sideMenuText = array();
        $sideMenuLink = array();
        $sideMenuImg = array();
        $sideMenuID = array();
        $arrMenuType = array('type' => 'text',
                             'text' => $langAdministrationTools,
                             'class' => 'course_admin');
        array_push($sideMenuSubGroup, $arrMenuType);

        foreach ($admin_modules as $adm_mod) {
            array_push($sideMenuText, $adm_mod['title']);
            array_push($sideMenuLink, q($urlAppend . 'modules/' . $adm_mod['link'] .
                            '/?course=' . $course_code));
            array_push($sideMenuImg, $adm_mod['image'] . $section['iconext']);
        }

        array_push($sideMenuSubGroup, $sideMenuText);
        array_push($sideMenuSubGroup, $sideMenuLink);
        array_push($sideMenuSubGroup, $sideMenuImg);
        array_push($sideMenuSubGroup, $sideMenuID);
        array_push($sideMenuGroup, $sideMenuSubGroup);
    }
    return $sideMenuGroup;
}