Esempio n. 1
0
/**
 * This function displays a dropdown list that allows the course administrator do view the calendar items of one specific group
 * @author: Patrick Cool <*****@*****.**>, Ghent University
 */
function show_user_group_filter_form()
{
    echo "<select name=\"select\" onchange=\"javascript: MM_jumpMenu('parent',this,0)\">";
    echo "<option value=\"agenda.php?user=none&action=view\">" . get_lang("ShowAll") . "</option>";
    // Groups
    $group_list = get_course_groups();
    $group_available_to_access = array();
    $option = '';
    if (!empty($group_list)) {
        $option = "<optgroup label=\"" . get_lang("Groups") . "\">";
        foreach ($group_list as $this_group) {
            // echo "<option value=\"agenda.php?isStudentView=true&amp;group=".$this_group['id']."\">".$this_group['name']."</option>";
            $has_access = GroupManager::user_has_access(api_get_user_id(), $this_group['id'], GroupManager::GROUP_TOOL_CALENDAR);
            $result = GroupManager::get_group_properties($this_group['id']);
            if ($result['calendar_state'] != '0') {
                $group_available_to_access[] = $this_group['id'];
            }
            // lastedit
            if ($has_access || $result['calendar_state'] == '1') {
                $option .= "<option value=\"agenda.php?action=view&group=" . $this_group['id'] . "\" ";
                $option .= $this_group['id'] == $_SESSION['group'] ? " selected" : "";
                $option .= ">" . $this_group['name'] . "</option>";
            }
        }
        $option .= "</optgroup>";
    }
    echo $option;
    // Users
    $user_list = get_course_users();
    if (!empty($user_list)) {
        echo "<optgroup label=\"" . get_lang("Users") . "\">";
        foreach ($user_list as $this_user) {
            echo "<option value=\"agenda.php?action=view&user="******"\" ";
            echo isset($_SESSION['user']) && $this_user['uid'] == $_SESSION['user'] ? " selected" : "";
            echo ">" . api_get_person_name($this_user['firstName'], $this_user['lastName']) . "</option>";
        }
        echo "</optgroup>";
    }
    echo "</select>";
}
Esempio n. 2
0
function get_forums($course)
{
    if ($course) {
        $sql = "SELECT F.*, DATE_FORMAT(F.last_post, '%%Y-%%m-%%d %%H:%%i:%%s') AS last_post FROM %sforums_courses FC \n\t\tINNER JOIN %sforums F \n\t\tUSING (forum_id) \n\t\tWHERE FC.course_id=%d \n\t\tGROUP BY FC.forum_id \n\t\tORDER BY F.title";
        $rows_forums = queryDB($sql, array(TABLE_PREFIX, TABLE_PREFIX, $course));
    } else {
        $sql = "SELECT F.*, FC.course_id, DATE_FORMAT(F.last_post, '%%Y-%%m-%%d %%H:%%i:%%s') AS last_post FROM %sforums_courses FC \n\t\tINNER JOIN %sforums F \n\t\tUSING (forum_id) \n\t\tGROUP BY FC.forum_id \n\t\tORDER BY F.title";
        $rows_forums = queryDB($sql, array(TABLE_PREFIX, TABLE_PREFIX));
    }
    // 'nonshared' forums are always listed first:
    $forums['nonshared'] = array();
    $forums['shared'] = array();
    $forums['group'] = array();
    foreach ($rows_forums as $row) {
        // for each forum, check if it's shared or not:
        if (is_shared_forum($row['forum_id'])) {
            $forums['shared'][] = $row;
        } else {
            $forums['nonshared'][] = $row;
        }
    }
    // retrieve the group forums if course is given
    $course_groups = get_course_groups($course);
    if (!$course_groups || !$course) {
        return $forums;
    }
    if (isset($course_groups)) {
        foreach ($course_groups as $groups) {
            $sql = "SELECT F.*, G.group_id FROM %sforums_groups G \n                     INNER JOIN %sforums F \n                     USING (forum_id) \n                     WHERE G.group_id IN (%s) \n                     ORDER BY F.title";
            $rows_gforums = queryDB($sql, array(TABLE_PREFIX, TABLE_PREFIX, $groups['group_id']));
            foreach ($rows_gforums as $row) {
                $row['title'] = get_group_title($row['group_id']);
                $forums['group'][] = $row;
            }
        }
    }
    return $forums;
}
Esempio n. 3
0
/**
 * Displays only 1 agenda item. This is used when an agenda item is added to the learning path.
 * @author Patrick Cool <*****@*****.**>, Ghent University
 */
function display_one_agenda_item($agenda_id)
{
    global $TABLEAGENDA;
    global $TABLE_ITEM_PROPERTY;
    global $select_month, $select_year;
    global $DaysShort, $DaysLong, $MonthsLong;
    global $dateFormatLong, $timeNoSecFormat, $charset;
    // getting the name of the groups
    $group_names = get_course_groups();
    $agenda_id = intval($agenda_id);
    if (!(api_is_allowed_to_edit(false, true) || api_get_course_setting('allow_user_edit_agenda') && !api_is_anonymous())) {
        $visibility_condition = " AND ip.visibility='1' ";
    }
    $sql = "SELECT agenda.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.ref\n\t\t\tFROM " . $TABLEAGENDA . " agenda, " . $TABLE_ITEM_PROPERTY . " ip\n\t\t\tWHERE agenda.id = ip.ref\n\t\t\tAND ip.tool='" . TOOL_CALENDAR_EVENT . "'\n\t\t\t{$visibility_condition}\n\t\t\tAND agenda.id='{$agenda_id}'";
    $result = Database::query($sql);
    $number_items = Database::num_rows($result);
    $myrow = Database::fetch_array($result, 'ASSOC');
    // there should be only one item so no need for a while loop
    $sql_rep = "SELECT * FROM {$TABLEAGENDA} WHERE id = {$agenda_id} AND parent_event_id IS NOT NULL AND parent_event_id !=0";
    $res_rep = Database::query($sql_rep);
    $repeat = false;
    $repeat_id = 0;
    if (Database::num_rows($res_rep) > 0) {
        $repeat = true;
        $row_rep = Database::fetch_array($res_rep);
        $repeat_id = $row_rep['parent_event_id'];
    }
    // DISPLAY: NO ITEMS
    if ($number_items == 0) {
        Display::display_warning_message(get_lang("NoAgendaItems"));
        return false;
    }
    // DISPLAY: THE ITEMS
    echo "<table id=\"data_table\" class=\"data_table\">";
    // DISPLAY : the icon, title, destinees of the item
    $myrow["start_date"] = api_get_local_time($myrow["start_date"]);
    // highlight: if a date in the small calendar is clicked we highlight the relevant items
    $db_date = (int) api_format_date($myrow["start_date"], "%d") . intval(api_format_date($myrow["start_date"], "%m")) . api_format_date($myrow["start_date"], "%Y");
    if ($_GET["day"] . $_GET["month"] . $_GET["year"] != $db_date) {
        if ($myrow['visibility'] == '0') {
            $style = "data_hidden";
            $stylenotbold = "datanotbold_hidden";
            $text_style = "text_hidden";
        } else {
            $style = "data";
            $stylenotbold = "datanotbold";
            $text_style = "text";
        }
    } else {
        $style = "datanow";
        $stylenotbold = "datanotboldnow";
        $text_style = "textnow";
    }
    echo Display::tag('h2', $myrow['title']);
    echo "<tr>";
    if (api_is_allowed_to_edit(false, true)) {
        if (!(api_is_course_coach() && !api_is_element_in_the_session(TOOL_AGENDA, $myrow['id']))) {
            // a coach can only delete an element belonging to his session
            // DISPLAY: edit delete button (course admin only)
            $export_icon = '../img/export.png';
            $export_icon_low = '../img/export_low_fade.png';
            $export_icon_high = '../img/export_high_fade.png';
            echo '<th style="text-align:right">';
            if (!$repeat && api_is_allowed_to_edit(false, true)) {
                // edit
                $mylink = api_get_self() . "?" . api_get_cidreq() . "&origin=" . Security::remove_XSS($_GET['origin']) . "&id=" . $myrow['id'];
                if (!empty($_GET['agenda_id'])) {
                    // rather ugly hack because the id parameter is already set above but below we set it again
                    $mylink .= '&agenda_id=' . Security::remove_XSS($_GET['agenda_id']) . '&id=' . Security::remove_XSS($_GET['agenda_id']);
                }
                if ($myrow['visibility'] == 1) {
                    $image_visibility = "visible";
                    $next_action = 0;
                } else {
                    $image_visibility = "invisible";
                    $next_action = 1;
                }
                echo '<a href="' . $mylink . '&action=showhide&next_action=' . $next_action . '">' . Display::return_icon($image_visibility . '.png', get_lang('Visible'), '', ICON_SIZE_SMALL) . '</a>';
                echo "<a href=\"" . $mylink . "&action=edit\">", Display::return_icon('edit.png', get_lang('ModifyCalendarItem'), '', ICON_SIZE_SMALL), "</a>", "<a href=\"" . $mylink . "&action=delete\" onclick=\"javascript:if(!confirm('" . addslashes(api_htmlentities(get_lang("ConfirmYourChoice"), ENT_QUOTES, $charset)) . "')) return false;\">", Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL), "</a>";
            }
            $mylink = 'ical_export.php?' . api_get_cidreq() . '&type=course&id=' . $myrow['id'];
            //echo '<a class="ical_export" href="'.$mylink.'&class=confidential" title="'.get_lang('ExportiCalConfidential').'">'.Display::return_icon($export_icon_high, get_lang('ExportiCalConfidential')).'</a> ';
            //echo '<a class="ical_export" href="'.$mylink.'&class=private" title="'.get_lang('ExportiCalPrivate').'">'.Display::return_icon($export_icon_low, get_lang('ExportiCalPrivate')).'</a> ';
            //echo '<a class="ical_export" href="'.$mylink.'&class=public" title="'.get_lang('ExportiCalPublic').'">'.Display::return_icon($export_icon, get_lang('ExportiCalPublic')).'</a> ';
            echo '<a href="javascript: void(0);" onclick="javascript:win_print=window.open(\'print.php?id=' . $myrow['id'] . '\',\'popup\',\'left=100,top=100,width=700,height=500,scrollbars=1,resizable=0\'); win_print.focus(); return false;">' . Display::return_icon('printer.png', get_lang('Print'), '', ICON_SIZE_SMALL) . '</a>&nbsp;';
            echo "</th>";
        }
    }
    // title
    echo "<tr class='row_odd'>";
    echo '<td colspan="2">' . get_lang("StartTime") . ": ";
    echo api_format_date($myrow['start_date']);
    echo "</td>";
    echo "</td>";
    echo "<tr class='row_odd'>";
    echo '<td colspan="2">' . get_lang("EndTime") . ": ";
    echo api_convert_and_format_date($myrow['end_date']);
    echo "</td>";
    // Content
    $content = $myrow['content'];
    $content = Text::make_clickable($content);
    echo '<tr class="row_even">';
    echo '<td ' . (api_is_allowed_to_edit() ? 'colspan="3"' : 'colspan="2"') . '>';
    echo $content;
    echo '</td></tr>';
    //Attachments
    $attachment_list = get_attachment($agenda_id);
    if (!empty($attachment_list)) {
        echo '<tr class="row_even"><td colspan="2">';
        $realname = $attachment_list['path'];
        $user_filename = $attachment_list['filename'];
        $full_file_name = 'download.php?file=' . $realname;
        echo Display::return_icon('attachment.gif', get_lang('Attachment'));
        echo '<a href="' . $full_file_name . '"> ' . $user_filename . '</a>';
        if (api_is_allowed_to_edit()) {
            echo '&nbsp;&nbsp;<a href="' . api_get_self() . '?' . api_get_cidreq() . '&origin=' . Security::remove_XSS($_GET['origin']) . '&action=delete_attach&id_attach=' . $attachment_list['id'] . '" onclick="javascript:if(!confirm(\'' . addslashes(api_htmlentities(get_lang("ConfirmYourChoice"), ENT_QUOTES, $charset)) . '\')) return false;">' . Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL) . '</a><br />';
        }
        echo '<br /><span class="forum_attach_comment" >' . $attachment_list['comment'] . '</span>';
        echo '</td></tr>';
    }
    // the message has been sent to
    echo '<tr>';
    echo "<td class='announcements_datum'>" . get_lang("SentTo") . ": ";
    $sent_to = sent_to(TOOL_CALENDAR_EVENT, $myrow["ref"]);
    $sent_to_form = sent_to_form($sent_to);
    echo $sent_to_form;
    echo "</td></tr>";
    if ($repeat) {
        echo '<tr>';
        echo '<td colspan="2">';
        echo get_lang('RepeatedEvent') . ' <a href="', api_get_self(), '?', api_get_cidreq(), '&agenda_id=', $repeat_id, '" alt="', get_lang('RepeatedEventViewOriginalEvent'), '">', get_lang('RepeatedEventViewOriginalEvent'), '</a>';
        echo '</td>';
        echo '</tr>';
    }
    /* Added resources */
    if (check_added_resources("Agenda", $myrow["id"])) {
        echo "<tr><td colspan='3'>";
        echo "<i>" . get_lang("AddedResources") . "</i><br/>";
        if ($myrow['visibility'] == 0) {
            $addedresource_style = "invisible";
        }
        display_added_resources("Agenda", $myrow["id"], $addedresource_style);
        echo "</td></tr>";
    }
    // closing the layout table
    echo "</td>", "</tr>", "</table>";
}