コード例 #1
0
function JLMS_edit_event($option, $id)
{
    global $JLMS_DB, $Itemid, $my, $JLMS_CONFIG;
    $id = $JLMS_CONFIG->get('course_id');
    $agenda_id = intval(mosGetParam($_REQUEST, 'agenda_id', 0));
    $JLMS_ACL =& JLMSFactory::getACL();
    $assigned_groups_only = $JLMS_ACL->CheckPermissions('advanced', 'assigned_groups_only');
    $AND_ST = "";
    if (false !== ($enroll_period = JLMS_getEnrolPeriod($my->id, $id))) {
        $AND_ST = " AND IF(is_time_related, (show_period < '" . $enroll_period . "' ), 1) ";
    }
    $do_redirect = false;
    $query = "SELECT is_limited, owner_id FROM `#__lms_agenda` WHERE agenda_id = {$agenda_id} AND course_id = {$id}" . $AND_ST;
    $JLMS_DB->setQuery($query);
    $row = $JLMS_DB->loadObject();
    if (is_object($row) && isset($row->is_limited)) {
        $flag = 0;
        if ($row->is_limited == 0 && $row->owner_id != $my->id) {
            $flag = 1;
        }
    } else {
        $do_redirect = true;
    }
    if ($id && $JLMS_ACL->CheckPermissions('announce', 'manage') && !$flag) {
        $where = '';
        if ($assigned_groups_only && $row->is_limited) {
            $groups_where_admin_manager = JLMS_ACL_HELPER::GetAssignedGroups($my->id, $id);
            $groups_where_isset_user = JLMS_ACL_HELPER::GetUserGlobalGroup($my->id, $id);
            $groups_where_admin_manager = array_merge($groups_where_admin_manager, $groups_where_isset_user);
            if (count($groups_where_admin_manager)) {
                $where .= "\n AND is_limited = 1 AND ( `groups` LIKE '%|{$groups_where_admin_manager['0']}|%'";
                for ($i = 1; $i < count($groups_where_admin_manager); $i++) {
                    $where .= "\n OR `groups` like '%|{$groups_where_admin_manager[$i]}|%'";
                }
                $where .= "\n OR owner_id = '" . $my->id . "')";
            } else {
                $where .= "\n AND (owner_id = '" . $my->id . "' OR agenda_id = 0) AND groups = ''";
            }
        }
        $query = "SELECT * FROM `#__lms_agenda` WHERE agenda_id = {$agenda_id} AND course_id = {$id}" . $where;
        $JLMS_DB->setQuery($query);
        $agenda_item = $JLMS_DB->loadObject();
        if (is_object($agenda_item) && isset($agenda_item->agenda_id)) {
            if ($JLMS_ACL->CheckPermissions('announce', 'only_own') && $agenda_item->owner_id != $my->id) {
                $do_redirect = true;
            } elseif ($JLMS_ACL->CheckPermissions('announce', 'only_own_role') && $JLMS_ACL->GetRole() != $JLMS_ACL->UserSystemRole($JLMS_DB, $agenda_item->owner_id)) {
                $do_redirect = true;
            } else {
                $groups_arr = array();
                if ($agenda_item->groups) {
                    $groups = substr($agenda_item->groups, 1, strlen($agenda_item->groups) - 2);
                    $groups_arr = explode('|', $groups);
                }
                if ($assigned_groups_only) {
                    $lists['is_limited'] = mosHTML::yesnoRadioList('is_limited', 'disabled="disabled" class="inputbox" ', $agenda_item->is_limited);
                } else {
                    $lists['is_limited'] = mosHTML::yesnoRadioList('is_limited', 'class="inputbox" ', $agenda_item->is_limited);
                }
                $lists['groups'] = JLMSmultiselect($groups_arr, true, $id);
                JLMS_agenda_html::show_add_event($id, $option, $agenda_item, $lists);
            }
        } else {
            $do_redirect = true;
        }
    } else {
        $do_redirect = true;
    }
    if ($do_redirect) {
        JLMSRedirect(sefRelToAbs("index.php?option={$option}&Itemid={$Itemid}&task=agenda&id={$id}"));
    }
}
コード例 #2
0
function my_homeworks($course_id, $hp_items, $user_id)
{
    global $JLMS_DB;
    if (!$course_id) {
        return array();
    }
    $my_hw = array();
    $JLMS_ACL =& JLMSFactory::getACL();
    $assigned_groups_only = $JLMS_ACL->CheckPermissions('advanced', 'assigned_groups_only');
    $members = "'0'";
    $where = '';
    if ($JLMS_ACL->_role_type == 2 || $JLMS_ACL->_role_type == 3 || $JLMS_ACL->_role_type == 4) {
        if ($assigned_groups_only) {
            $groups_where_admin_manager = JLMS_ACL_HELPER::GetAssignedGroups($user_id);
            $groups_where_isset_user = JLMS_ACL_HELPER::GetUserGlobalGroup($user_id);
            $groups_where_admin_manager = array_merge($groups_where_admin_manager, $groups_where_isset_user);
            if (count($groups_where_admin_manager)) {
                $where .= "\n AND (is_limited = 0 OR `groups` LIKE '%|{$groups_where_admin_manager['0']}|%'";
                for ($i = 1; $i < count($groups_where_admin_manager); $i++) {
                    $where .= "\n OR `groups` like '%|{$groups_where_admin_manager[$i]}|%'";
                }
                $where .= "\n OR a.owner_id = '" . $user_id . "')";
            } else {
                $where .= "\n AND (is_limited = 0 OR a.owner_id = '" . $user_id . "' OR a.id = 0) AND groups = ''";
            }
        }
    } else {
        if ($JLMS_ACL->_role_type < 2) {
            $query = "select a.group_id FROM #__lms_users_in_global_groups as a WHERE a.user_id = '" . $user_id . "' AND a.subgroup1_id = 0 AND a.group_id > 0";
            $JLMS_DB->setQuery($query);
            $temp1 = $JLMS_DB->loadResultArray();
            $query = "select subgroup1_id FROM #__lms_users_in_global_groups WHERE user_id = '" . $user_id . "' AND subgroup1_id > 0";
            $JLMS_DB->setQuery($query);
            $temp2 = $JLMS_DB->loadResultArray();
            $group_where_isset_user = array_merge($temp1, $temp2);
            $where .= "\n AND (a.is_limited = 0";
            if (isset($group_where_isset_user) && count($group_where_isset_user)) {
                $where .= "\n OR (a.is_limited = 1" . "\n AND (a.groups LIKE '%|{$group_where_isset_user['0']}|%'";
                for ($i = 1; $i < count($group_where_isset_user); $i++) {
                    $where .= "\n OR a.groups like '%|{$group_where_isset_user[$i]}|%'";
                }
                $where .= "\n )))";
            } else {
                $where .= "\n )";
            }
        }
    }
    $query = "SELECT a.*, d.hw_status, c.user_id as stu_id, e.user_id as teach_id" . "\n FROM (#__lms_homework as a, #__lms_courses as b)" . "\n LEFT JOIN #__lms_users_in_groups as c ON c.user_id = '" . $user_id . "' AND c.course_id = b.id" . "\n LEFT JOIN #__lms_homework_results as d ON d.course_id = b.id AND d.user_id = " . $user_id . " AND d.hw_id = a.id" . "\n LEFT JOIN #__lms_user_courses as e ON e.course_id = b.id AND e.user_id = '" . $user_id . "'" . "\n WHERE (ISNULL(d.hw_status) OR d.hw_status = 0)" . "\n AND a.course_id IN ({$course_id})" . "\n AND a.course_id = b.id AND a.end_date >= '" . date('Y-m-d', time()) . "'" . $where . "\n LIMIT 0, {$hp_items}";
    $JLMS_DB->SetQuery($query);
    $my_hw = $JLMS_DB->LoadObjectList();
    if ($JLMS_ACL->_role_type < 2) {
        $my_hw = filterByShowPeriod($my_hw);
    }
    return $my_hw;
}
コード例 #3
0
function JLMS_showHomeWork($id, $option)
{
    global $my, $JLMS_DB, $Itemid, $JLMS_SESSION, $JLMS_CONFIG;
    $course_id = JRequest::getInt('course_id');
    $id = $course_id ? $course_id : $id;
    $usertype = JLMS_GetUserType($my->id, $id);
    $JLMS_ACL =& JLMSFactory::getACL();
    $assigned_groups_only = $JLMS_ACL->CheckPermissions('advanced', 'assigned_groups_only');
    $limit = intval(mosGetParam($_GET, 'limit', $JLMS_SESSION->get('list_limit', $JLMS_CONFIG->get('list_limit'))));
    $JLMS_SESSION->set('list_limit', $limit);
    $limitstart = intval(mosGetParam($_GET, 'limitstart', 0));
    $where = '';
    //	if ($id && ($usertype == 1 || $usertype == 6)) {
    //	if ($id && ($JLMS_ACL->CheckPermissions('homework', 'manage') || $usertype == 6)) {
    if ($id && ($JLMS_ACL->CheckPermissions('homework', 'manage') || $JLMS_ACL->CheckPermissions('homework', 'view_stats'))) {
        $members = "'0'";
        $AND_ST = "";
        $fields = ',0 AS checkedout';
        if ($JLMS_ACL->_role_type == 2 || $JLMS_ACL->_role_type == 3 || $JLMS_ACL->_role_type == 4) {
            if ($assigned_groups_only) {
                $fields = ",IF(a.owner_id != '" . $my->id . "',1 ,0) AS checkedout";
                $groups_where_admin_manager = JLMS_ACL_HELPER::GetAssignedGroups($my->id, $id);
                $groups_where_isset_user = JLMS_ACL_HELPER::GetUserGlobalGroup($my->id, $id);
                $groups_where_admin_manager = array_merge($groups_where_admin_manager, $groups_where_isset_user);
                if (count($groups_where_admin_manager)) {
                    $where .= "\n AND (a.is_limited = 0 OR a.groups LIKE '%|{$groups_where_admin_manager['0']}|%'";
                    for ($i = 1; $i < count($groups_where_admin_manager); $i++) {
                        $where .= "\n OR a.groups like '%|{$groups_where_admin_manager[$i]}|%'";
                    }
                    $where .= "\n OR a.owner_id = '" . $my->id . "')";
                } else {
                    $where .= "\n AND (a.is_limited = 0 OR a.owner_id = '" . $my->id . "' OR a.id = 0) AND a.groups = ''";
                }
            }
        } else {
            if ($JLMS_ACL->_role_type < 2) {
                $query = "select a.group_id FROM #__lms_users_in_global_groups as a WHERE a.user_id = '" . $my->id . "' AND a.subgroup1_id = 0 AND a.group_id > 0";
                $JLMS_DB->setQuery($query);
                $temp1 = $JLMS_DB->loadResultArray();
                $query = "select subgroup1_id FROM #__lms_users_in_global_groups WHERE user_id = '" . $my->id . "' AND subgroup1_id > 0";
                $JLMS_DB->setQuery($query);
                $temp2 = $JLMS_DB->loadResultArray();
                $group_where_isset_user = array_merge($temp1, $temp2);
                if (count($group_where_isset_user)) {
                    $where .= "\n AND (( a.groups <> '' AND a.groups IS NOT NULL AND (groups LIKE '%|{$group_where_isset_user['0']}|%'";
                    for ($i = 1; $i < count($group_where_isset_user); $i++) {
                        $where .= "\n OR groups like '%|{$group_where_isset_user[$i]}|%'";
                    }
                    $where .= "\n )) OR (a.is_limited = 0 AND (a.groups = '' OR a.groups IS NULL)))";
                }
                if (false !== ($enroll_period = JLMS_getEnrolPeriod($my->id, $id))) {
                    $AND_ST = " AND IF(a.is_time_related, (a.show_period < '" . $enroll_period . "' ), 1) ";
                }
            }
        }
        $query = "SELECT count(*) FROM #__lms_homework AS a" . "\n WHERE a.course_id = '" . $id . "'" . $AND_ST . ($JLMS_ACL->CheckPermissions('homework', 'view_all') ? '' : "\n AND a.published = 1") . $where;
        $JLMS_DB->SetQuery($query);
        $total = $JLMS_DB->LoadResult();
        require_once _JOOMLMS_FRONT_HOME . DS . "includes" . DS . "classes" . DS . "lms.pagination.php";
        $pageNav = new JLMSPageNav($total, $limitstart, $limit);
        $query = "SELECT a.*" . $fields . "\n FROM #__lms_homework as a" . "\n WHERE a.course_id = '" . $id . "'" . $AND_ST . ($JLMS_ACL->CheckPermissions('homework', 'view_all') ? '' : "\n AND a.published = 1") . $where . "\n ORDER BY a.post_date DESC, a.hw_name" . "\n LIMIT {$pageNav->limitstart}, {$pageNav->limit}";
        $JLMS_DB->SetQuery($query);
        $rows = $JLMS_DB->LoadObjectList();
        $lms_titles_cache =& JLMSFactory::getTitles();
        $lms_titles_cache->setArray('homework', $rows, 'id', 'hw_name');
        JLMS_homework_html::showHomeWorks($id, $option, $rows, $pageNav, $usertype);
    } elseif ($id && $JLMS_ACL->CheckPermissions('homework', 'view')) {
        $filt_hw = intval(mosGetParam($_GET, 'filt_hw', $JLMS_SESSION->get('filt_hw', 0)));
        $JLMS_SESSION->set('filt_hw', $filt_hw);
        $query = "select a.group_id FROM #__lms_users_in_global_groups as a WHERE a.user_id = '" . $my->id . "' AND a.subgroup1_id = 0 AND a.group_id > 0";
        $JLMS_DB->setQuery($query);
        $temp1 = $JLMS_DB->loadResultArray();
        $query = "select subgroup1_id FROM #__lms_users_in_global_groups WHERE user_id = '" . $my->id . "' AND subgroup1_id > 0";
        $JLMS_DB->setQuery($query);
        $temp2 = $JLMS_DB->loadResultArray();
        $group_where_isset_user = array_merge($temp1, $temp2);
        $AND_ST = "";
        if (false !== ($enroll_period = JLMS_getEnrolPeriod($my->id, $id))) {
            $AND_ST = " AND IF(a.is_time_related, (a.show_period < '" . $enroll_period . "' ), 1) ";
        }
        $query = "SELECT count(*) FROM #__lms_homework as a" . ($filt_hw ? "\n LEFT JOIN #__lms_homework_results as b ON a.id = b.hw_id AND b.user_id = '" . $my->id . "' AND b.course_id = '" . $id . "'" : '') . "\n WHERE a.course_id = '" . $id . "'" . $AND_ST . ($JLMS_ACL->CheckPermissions('homework', 'view_all') ? '' : "\n AND a.published = 1") . ($filt_hw ? $filt_hw == 2 ? "\n AND b.hw_status = 1" : ($filt_hw == 1 ? " AND (b.hw_status IS NULL OR b.hw_status <> 1)" : "") : '');
        $query .= "\n AND a.is_limited = 0";
        if (isset($group_where_isset_user) && count($group_where_isset_user)) {
            $query .= "\n OR (a.is_limited = 1" . "\n AND (a.groups LIKE '%|{$group_where_isset_user['0']}|%'";
            for ($i = 1; $i < count($group_where_isset_user); $i++) {
                $query .= "\n OR a.groups like '%|{$group_where_isset_user[$i]}|%'";
            }
            $query .= "\n ))";
        }
        $JLMS_DB->SetQuery($query);
        $total = $JLMS_DB->LoadResult();
        require_once _JOOMLMS_FRONT_HOME . DS . "includes" . DS . "classes" . DS . "lms.pagination.php";
        $pageNav = new JLMSPageNav($total, $limitstart, $limit);
        $query = "SELECT a.*, b.id as result_id, b.hw_status, b.hw_date, b.grade" . "\n FROM #__lms_homework as a LEFT JOIN #__lms_homework_results as b ON a.id = b.hw_id AND b.user_id = '" . $my->id . "' AND b.course_id = '" . $id . "'" . "\n WHERE a.course_id = '" . $id . "'" . $AND_ST . ($filt_hw ? $filt_hw == 2 ? "\n AND b.hw_status = 1" : ($filt_hw == 1 ? " AND (b.hw_status IS NULL OR b.hw_status <> 1)" : "") : '') . ($JLMS_ACL->CheckPermissions('homework', 'view_all') ? '' : "\n AND a.published = 1");
        $query .= "\n AND (a.is_limited = 0";
        if (isset($group_where_isset_user) && count($group_where_isset_user)) {
            $query .= "\n OR (a.is_limited = 1" . "\n AND (a.groups LIKE '%|{$group_where_isset_user['0']}|%'";
            for ($i = 1; $i < count($group_where_isset_user); $i++) {
                $query .= "\n OR a.groups like '%|{$group_where_isset_user[$i]}|%'";
            }
            $query .= "\n )))";
        } else {
            $query .= "\n )";
        }
        $query .= "\n ORDER BY a.post_date DESC, a.hw_name" . "\n LIMIT {$pageNav->limitstart}, {$pageNav->limit}";
        $JLMS_DB->SetQuery($query);
        $rows = $JLMS_DB->LoadObjectList();
        $lists = array();
        $f_items = array();
        $f_items[] = mosHTML::makeOption(0, _JLMS_HW_FILTER_ALL_RESULTS);
        $f_items[] = mosHTML::makeOption(2, _JLMS_HW_STATUS_COMPLETED);
        $f_items[] = mosHTML::makeOption(1, _JLMS_HW_STATUS_INCOMPLETE);
        $link = "index.php?option={$option}&amp;Itemid={$Itemid}&task=homework&id={$id}";
        $link = $link . "&amp;filt_hw='+this.options[selectedIndex].value+'";
        $link = sefRelToAbs($link);
        $link = str_replace('%5C%27', "'", $link);
        $link = str_replace('%5B', "[", $link);
        $link = str_replace('%5D', "]", $link);
        $link = str_replace('%20', "+", $link);
        $link = str_replace("\\\\\\", "", $link);
        $link = str_replace('%27', "'", $link);
        $lists['filter'] = mosHTML::selectList($f_items, 'filt_hw', 'class="inputbox" size="1" onchange="document.location.href=\'' . $link . '\';"', 'value', 'text', $filt_hw);
        $lists['used_filter'] = $filt_hw;
        $lms_titles_cache =& JLMSFactory::getTitles();
        $lms_titles_cache->setArray('homework', $rows, 'id', 'hw_name');
        JLMS_homework_html::showHomeWorks_stu($id, $option, $rows, $pageNav, $lists);
    } else {
        JLMSRedirect(sefRelToAbs("index.php?option={$option}&Itemid={$Itemid}"));
    }
}