* 	@version $Id: create_new_survey.php 22297 2009-07-22 22:08:30Z cfasanando $
 *
 * 	@todo only the available platform languages should be used => need an
 *  api get_languages and and api_get_available_languages (or a parameter)
 */
require_once '../inc/global.inc.php';
$this_section = SECTION_COURSES;
// Database table definitions
$table_survey = Database::get_course_table(TABLE_SURVEY);
$table_user = Database::get_main_table(TABLE_MAIN_USER);
$table_course = Database::get_main_table(TABLE_MAIN_COURSE);
$table_gradebook_link = Database::get_main_table(TABLE_MAIN_GRADEBOOK_LINK);
/** @todo this has to be moved to a more appropriate place (after the display_header of the code) */
// If user is not teacher or if he's a coach trying to access an element out of his session
if (!api_is_allowed_to_edit()) {
    if (!api_is_course_coach() || !empty($_GET['survey_id']) && !api_is_element_in_the_session(TOOL_SURVEY, $_GET['survey_id'])) {
        api_not_allowed(true);
        exit;
    }
}
// Getting the survey information
$survey_id = isset($_GET['survey_id']) ? intval($_GET['survey_id']) : null;
$survey_data = SurveyManager::get_survey($survey_id);
// Additional information
$course_id = api_get_course_id();
$session_id = api_get_session_id();
$gradebook_link_type = 8;
$urlname = isset($survey_data['title']) ? strip_tags($survey_data['title']) : null;
// Breadcrumbs
if ($_GET['action'] == 'add') {
    $interbreadcrumb[] = array('url' => api_get_path(WEB_CODE_PATH) . 'survey/survey_list.php?' . api_get_cidreq(), 'name' => get_lang('SurveyList'));
/**
 * Report
 * @package chamilo.tracking
 */
/**
 * Code
 */
$language_file = array('registration', 'index', 'tracking', 'exercice', 'survey');
$cidReset = true;
require_once '../inc/global.inc.php';
require_once api_get_path(SYS_CODE_PATH) . 'exercice/exercise.class.php';
require_once api_get_path(SYS_CODE_PATH) . 'exercice/question.class.php';
require_once api_get_path(LIBRARY_PATH) . 'pear/Spreadsheet_Excel_Writer/Writer.php';
require_once api_get_path(SYS_CODE_PATH) . 'newscorm/learnpath.class.php';
$this_section = "session_my_space";
$is_allowedToTrack = api_is_course_admin() || api_is_platform_admin() || api_is_course_coach() || api_is_session_admin();
if (!$is_allowedToTrack) {
    Display::display_header(null);
    api_not_allowed();
    Display::display_footer();
}
$export_to_xls = false;
if (isset($_GET['export'])) {
    $export_to_xls = true;
}
if (api_is_platform_admin()) {
    $global = true;
} else {
    $global = false;
}
$global = true;
Example #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>";
}
        $params['join_firstname_lastname'] = true;
        $params['show_official_code'] = true;
        $params['export_pdf'] = true;
        $params['only_total_category'] = false;
        GradebookUtils::export_pdf_flatview($flatviewtable, $cat, $users, $alleval, $alllinks, $params, $mainCourseCategory[0]);
    } else {
        Display::display_header(get_lang('ExportPDF'));
    }
}
if (isset($_GET['print'])) {
    $printable_data = GradebookUtils::get_printable_data($cat[0], $users, $alleval, $alllinks, $params, $mainCourseCategory[0]);
    echo print_table($printable_data[1], $printable_data[0], get_lang('FlatView'), $cat[0]->get_name());
    exit;
}
if (!empty($_GET['export_report']) && $_GET['export_report'] == 'export_report') {
    if (api_is_platform_admin() || api_is_course_admin() || api_is_course_coach() || $isDrhOfCourse) {
        $user_id = null;
        if (empty($_SESSION['export_user_fields'])) {
            $_SESSION['export_user_fields'] = false;
        }
        if (!api_is_allowed_to_edit(false, false) and !api_is_course_tutor()) {
            $user_id = api_get_user_id();
        }
        $printable_data = GradebookUtils::get_printable_data($cat[0], $users, $alleval, $alllinks, $params, $mainCourseCategory[0]);
        switch ($_GET['export_format']) {
            case 'xls':
                $export = new GradeBookResult();
                $export->exportCompleteReportXLS($printable_data);
                break;
            case 'doc':
                $export = new GradeBookResult();
Example #5
0
 /**
  * @param array $group_list
  * @param int $category_id
  */
 static function process_groups($group_list, $category_id = null)
 {
     global $origin, $charset;
     $category_id = intval($category_id);
     $totalRegistered = 0;
     $group_data = array();
     $user_info = api_get_user_info();
     $session_id = api_get_session_id();
     $user_id = $user_info['user_id'];
     $orig = isset($origin) ? $origin : null;
     foreach ($group_list as $this_group) {
         // Validation when belongs to a session
         $session_img = api_get_session_image($this_group['session_id'], $user_info['status']);
         // All the tutors of this group
         $tutorsids_of_group = self::get_subscribed_tutors($this_group['id'], true);
         // Create a new table-row
         $row = array();
         // Checkbox
         if (api_is_allowed_to_edit(false, true) && count($group_list) > 1) {
             $row[] = $this_group['id'];
         }
         // Group name
         if ((api_is_allowed_to_edit(false, true) || in_array($user_id, $tutorsids_of_group) || $this_group['is_member'] || self::user_has_access($user_id, $this_group['id'], self::GROUP_TOOL_FORUM) || self::user_has_access($user_id, $this_group['id'], self::GROUP_TOOL_DOCUMENTS) || self::user_has_access($user_id, $this_group['id'], self::GROUP_TOOL_CALENDAR) || self::user_has_access($user_id, $this_group['id'], self::GROUP_TOOL_ANNOUNCEMENT) || self::user_has_access($user_id, $this_group['id'], self::GROUP_TOOL_WORK) || self::user_has_access($user_id, $this_group['id'], self::GROUP_TOOL_WIKI)) && !(api_is_course_coach() && intval($this_group['session_id']) != $session_id)) {
             $group_name = '<a href="group_space.php?cidReq=' . api_get_course_id() . '&amp;origin=' . $orig . '&amp;gidReq=' . $this_group['id'] . '">' . Security::remove_XSS($this_group['name']) . '</a> ';
             if (!empty($user_id) && !empty($this_group['id_tutor']) && $user_id == $this_group['id_tutor']) {
                 $group_name .= Display::label(get_lang('OneMyGroups'), 'success');
             } elseif ($this_group['is_member']) {
                 $group_name .= Display::label(get_lang('MyGroup'), 'success');
             }
             if (api_is_allowed_to_edit() && !empty($this_group['session_name'])) {
                 $group_name .= ' (' . $this_group['session_name'] . ')';
             }
             $group_name .= $session_img;
             $row[] = $group_name . '<br />' . stripslashes(trim($this_group['description']));
         } else {
             $row[] = $this_group['name'] . '<br />' . stripslashes(trim($this_group['description']));
         }
         // Tutor name
         $tutor_info = null;
         if (count($tutorsids_of_group) > 0) {
             foreach ($tutorsids_of_group as $tutor_id) {
                 $tutor = api_get_user_info($tutor_id);
                 $username = api_htmlentities(sprintf(get_lang('LoginX'), $tutor['username']), ENT_QUOTES);
                 if (api_get_setting('show_email_addresses') == 'true') {
                     $tutor_info .= Display::tag('span', Display::encrypted_mailto_link($tutor['mail'], api_get_person_name($tutor['firstName'], $tutor['lastName'])), array('title' => $username)) . ', ';
                 } else {
                     if (api_is_allowed_to_edit()) {
                         $tutor_info .= Display::tag('span', Display::encrypted_mailto_link($tutor['mail'], api_get_person_name($tutor['firstName'], $tutor['lastName'])), array('title' => $username)) . ', ';
                     } else {
                         $tutor_info .= Display::tag('span', api_get_person_name($tutor['firstName'], $tutor['lastName']), array('title' => $username)) . ', ';
                     }
                 }
             }
         }
         $tutor_info = api_substr($tutor_info, 0, api_strlen($tutor_info) - 2);
         $row[] = $tutor_info;
         // Max number of members in group
         $max_members = $this_group['maximum_number_of_members'] == self::MEMBER_PER_GROUP_NO_LIMIT ? ' ' : ' / ' . $this_group['maximum_number_of_members'];
         // Number of members in group
         $row[] = $this_group['number_of_members'] . $max_members;
         // Self-registration / unregistration
         if (!api_is_allowed_to_edit(false, true)) {
             if (self::is_self_registration_allowed($user_id, $this_group['id'])) {
                 $row[] = '<a class = "btn" href="group.php?' . api_get_cidreq() . '&category=' . $category_id . '&amp;action=self_reg&amp;group_id=' . $this_group['id'] . '" onclick="javascript:if(!confirm(' . "'" . addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES, $charset)) . "'" . ')) return false;">' . get_lang('GroupSelfRegInf') . '</a>';
             } elseif (self::is_self_unregistration_allowed($user_id, $this_group['id'])) {
                 $row[] = '<a class = "btn" href="group.php?' . api_get_cidreq() . '&category=' . $category_id . '&amp;action=self_unreg&amp;group_id=' . $this_group['id'] . '" onclick="javascript:if(!confirm(' . "'" . addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES, $charset)) . "'" . ')) return false;">' . get_lang('GroupSelfUnRegInf') . '</a>';
             } else {
                 $row[] = '-';
             }
         }
         $url = api_get_path(WEB_CODE_PATH) . 'group/';
         // Edit-links
         if (api_is_allowed_to_edit(false, true) && !(api_is_course_coach() && intval($this_group['session_id']) != $session_id)) {
             $edit_actions = '<a href="' . $url . 'settings.php?' . api_get_cidreq(true, false) . '&gidReq=' . $this_group['id'] . '"  title="' . get_lang('Edit') . '">' . Display::return_icon('edit.png', get_lang('EditGroup'), '', ICON_SIZE_SMALL) . '</a>&nbsp;';
             $edit_actions .= '<a href="' . $url . 'member_settings.php?' . api_get_cidreq(true, false) . '&gidReq=' . $this_group['id'] . '"  title="' . get_lang('GroupMembers') . '">' . Display::return_icon('user.png', get_lang('GroupMembers'), '', ICON_SIZE_SMALL) . '</a>&nbsp;';
             $edit_actions .= '<a href="' . $url . 'group_overview.php?action=export&type=xls&' . api_get_cidreq(true, false) . '&id=' . $this_group['id'] . '"  title="' . get_lang('ExportUsers') . '">' . Display::return_icon('export_excel.png', get_lang('Export'), '', ICON_SIZE_SMALL) . '</a>&nbsp;';
             /*$edit_actions .= '<a href="'.api_get_self().'?'.api_get_cidreq(true, false).'&category='.$category_id.'&amp;action=empty_one&amp;id='.$this_group['id'].'" onclick="javascript: if(!confirm('."'".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES))."'".')) return false;" title="'.get_lang('EmptyGroup').'">'.
               Display::return_icon('clean.png',get_lang('EmptyGroup'),'',ICON_SIZE_SMALL).'</a>&nbsp;';*/
             $edit_actions .= '<a href="' . api_get_self() . '?' . api_get_cidreq(true, false) . '&category=' . $category_id . '&amp;action=fill_one&amp;id=' . $this_group['id'] . '" onclick="javascript: if(!confirm(' . "'" . addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES)) . "'" . ')) return false;" title="' . get_lang('FillGroup') . '">' . Display::return_icon('fill.png', get_lang('FillGroup'), '', ICON_SIZE_SMALL) . '</a>&nbsp;';
             $edit_actions .= '<a href="' . api_get_self() . '?' . api_get_cidreq(true, false) . '&category=' . $category_id . '&amp;action=delete_one&amp;id=' . $this_group['id'] . '" onclick="javascript: if(!confirm(' . "'" . addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES)) . "'" . ')) return false;" title="' . get_lang('Delete') . '">' . Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL) . '</a>&nbsp;';
             $row[] = $edit_actions;
         }
         if (!empty($this_group['nbMember'])) {
             $totalRegistered = $totalRegistered + $this_group['nbMember'];
         }
         $group_data[] = $row;
     }
     // end loop
     $table = new SortableTableFromArrayConfig($group_data, 1, 20, 'group_category_' . $category_id);
     $table->set_additional_parameters(array('category' => $category_id));
     $column = 0;
     if (api_is_allowed_to_edit(false, true) and count($group_list) > 1) {
         $table->set_header($column++, '', false);
     }
     $table->set_header($column++, get_lang('Groups'));
     $table->set_header($column++, get_lang('GroupTutor'));
     $table->set_header($column++, get_lang('Registered'), false);
     if (!api_is_allowed_to_edit(false, true)) {
         // If self-registration allowed
         $table->set_header($column++, get_lang('GroupSelfRegistration'), false);
     }
     if (api_is_allowed_to_edit(false, true)) {
         // Only for course administrator
         $table->set_header($column++, get_lang('Modify'), false);
         $form_actions = array();
         $form_actions['fill_selected'] = get_lang('FillGroup');
         $form_actions['empty_selected'] = get_lang('EmptyGroup');
         $form_actions['delete_selected'] = get_lang('Delete');
         if (count($group_list) > 1) {
             $table->set_form_actions($form_actions, 'group');
         }
     }
     $table->display();
 }
Example #6
0
 echo '<span style="float:right;">' . search_link() . '</span>';
 if ($origin != 'learnpath') {
     echo '<a href="' . $forumUrl . 'viewforum.php?forum=' . intval($_GET['forum']) . '&' . api_get_cidreq() . '">' . Display::return_icon('back.png', get_lang('BackToForum'), '', ICON_SIZE_MEDIUM) . '</a>';
 }
 // The reply to thread link should only appear when the forum_category is
 // not locked AND the forum is not locked AND the thread is not locked.
 // If one of the three levels is locked then the link should not be displayed.
 if ($current_forum_category && $current_forum_category['locked'] == 0 && $current_forum['locked'] == 0 && $current_thread['locked'] == 0 || api_is_allowed_to_edit(false, true)) {
     // The link should only appear when the user is logged in or when anonymous posts are allowed.
     if ($_user['user_id'] || $current_forum['allow_anonymous'] == 1 && !$_user['user_id']) {
         // reply link
         if (!api_is_anonymous() && api_is_allowed_to_session_edit(false, true)) {
             echo '<a href="' . $forumUrl . 'reply.php?' . api_get_cidreq() . '&forum=' . intval($_GET['forum']) . '&thread=' . intval($_GET['thread']) . '&action=replythread">' . Display::return_icon('reply_thread.png', get_lang('ReplyToThread'), '', ICON_SIZE_MEDIUM) . '</a>';
         }
         // new thread link
         if (api_is_allowed_to_edit(false, true) && !(api_is_course_coach() && $current_forum['session_id'] != $sessionId) || $current_forum['allow_new_threads'] == 1 && isset($_user['user_id']) || $current_forum['allow_new_threads'] == 1 && !isset($_user['user_id']) && $current_forum['allow_anonymous'] == 1) {
             if ($current_forum['locked'] != 1 && $current_forum['locked'] != 1) {
                 echo '&nbsp;&nbsp;';
             } else {
                 echo get_lang('ForumLocked');
             }
         }
     }
 }
 // The different views of the thread.
 if ($origin != 'learnpath') {
     $my_url = '<a href="' . $forumUrl . 'viewthread.php?' . api_get_cidreq() . '&' . api_get_cidreq() . '&forum=' . intval($_GET['forum']) . '&thread=' . intval($_GET['thread']) . '&search=' . Security::remove_XSS(urlencode($my_search));
     echo $my_url . '&view=flat">' . Display::return_icon('forum_listview.png', get_lang('FlatView'), null, ICON_SIZE_MEDIUM) . '</a>';
     echo $my_url . '&view=nested">' . Display::return_icon('forum_nestedview.png', get_lang('NestedView'), null, ICON_SIZE_MEDIUM) . '</a>';
 }
 $my_url = null;
Example #7
0
 *
 * 	@todo use quickforms for the forms
 */
// Language file that needs to be included
$language_file = 'survey';
// Including the global initialization file
//require_once '../inc/global.inc.php';
$this_section = SECTION_COURSES;
$current_course_tool = TOOL_SURVEY;
api_protect_course_script(true);
// Including additional libraries
require_once 'survey.lib.php';
/** @todo this has to be moved to a more appropriate place (after the display_header of the code)*/
// Coach can't view this page
$extend_rights_for_coachs = api_get_setting('extend_rights_for_coach_on_survey');
if (!api_is_allowed_to_edit(false, true) || api_is_course_coach() && $extend_rights_for_coachs == 'false') {
    Display::display_header(get_lang('ToolSurvey'));
    Display::display_error_message(get_lang('NotAllowed'), false);
    Display::display_footer();
    exit;
}
// Database table definitions
$table_survey = Database::get_course_table(TABLE_SURVEY);
$table_survey_question = Database::get_course_table(TABLE_SURVEY_QUESTION);
$table_survey_question_option = Database::get_course_table(TABLE_SURVEY_QUESTION_OPTION);
$table_survey_question_group = Database::get_course_table(TABLE_SURVEY_QUESTION_GROUP);
$table_course = Database::get_main_table(TABLE_MAIN_COURSE);
$table_user = Database::get_main_table(TABLE_MAIN_USER);
$survey_id = intval($_GET['survey_id']);
$course_id = api_get_course_int_id();
// Breadcrumbs
 /**
  * @param $stok
  * @param $announcement_number
  * @param bool $getCount
  * @param null $start
  * @param null $limit
  * @param string $sidx
  * @param string $sord
  * @param string $titleToSearch
  * @param int $userIdToSearch
  *
  * @return array
  */
 public static function getAnnouncements($stok, $announcement_number, $getCount = false, $start = null, $limit = null, $sidx = '', $sord = '', $titleToSearch = '', $userIdToSearch = 0)
 {
     $tbl_announcement = Database::get_course_table(TABLE_ANNOUNCEMENT);
     $tbl_item_property = Database::get_course_table(TABLE_ITEM_PROPERTY);
     $user_id = api_get_user_id();
     $group_id = api_get_group_id();
     $session_id = api_get_session_id();
     $condition_session = api_get_session_condition($session_id, true, true, 'announcement.session_id');
     $course_id = api_get_course_int_id();
     $_course = api_get_course_info();
     $group_memberships = GroupManager::get_group_ids($course_id, api_get_user_id());
     $allowUserEditSetting = api_get_course_setting('announcement.allow_user_edit_announcement');
     $select = ' DISTINCT announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.insert_date';
     if ($getCount) {
         $select = ' COUNT(announcement.iid) count';
     }
     $searchCondition = '';
     if (!empty($titleToSearch)) {
         $titleToSearch = Database::escape_string($titleToSearch);
         $searchCondition .= " AND (title LIKE '%{$titleToSearch}%')";
     }
     if (!empty($userIdToSearch)) {
         $userIdToSearch = intval($userIdToSearch);
         $searchCondition .= " AND (ip.insert_user_id = {$userIdToSearch})";
     }
     if (api_is_allowed_to_edit(false, true) || $allowUserEditSetting && !api_is_anonymous()) {
         // A.1. you are a course admin with a USER filter
         // => see only the messages of this specific user + the messages of the group (s)he is member of.
         //if (!empty($user_id)) {
         if (0) {
             if (is_array($group_memberships) && count($group_memberships) > 0) {
                 $sql = "SELECT {$select}\n                            FROM {$tbl_announcement} announcement, {$tbl_item_property} ip\n                            WHERE\n                                announcement.c_id = {$course_id} AND\n                                ip.c_id = {$course_id} AND\n                                announcement.id = ip.ref AND\n                                ip.tool = 'announcement' AND\n                                (\n                                    ip.to_user_id = {$user_id} OR\n                                    ip.to_group_id IS NULL OR\n                                    ip.to_group_id IN (0, " . implode(", ", $group_memberships) . ")\n                                ) AND\n                                ip.visibility IN ('1', '0')\n                                {$condition_session}\n                                {$searchCondition}\n                            ORDER BY display_order DESC";
             } else {
                 $sql = "SELECT {$select}\n                            FROM {$tbl_announcement} announcement, {$tbl_item_property} ip\n                            WHERE\n                                announcement.c_id = {$course_id} AND\n                                ip.c_id = {$course_id} AND\n                                announcement.id = ip.ref AND\n                                ip.tool ='announcement' AND\n                                (ip.to_user_id = {$user_id} OR ip.to_group_id='0' OR ip.to_group_id IS NULL) AND\n                                ip.visibility IN ('1', '0')\n                            {$condition_session}\n                            {$searchCondition}\n                            ORDER BY display_order DESC";
             }
         } elseif ($group_id != 0) {
             // A.2. you are a course admin with a GROUP filter
             // => see only the messages of this specific group
             $sql = "SELECT {$select}\n                        FROM {$tbl_announcement} announcement INNER JOIN {$tbl_item_property} ip\n                        ON (announcement.id = ip.ref AND ip.tool='announcement')\n                        WHERE\n                            announcement.c_id = {$course_id} AND\n                            ip.c_id = {$course_id} AND\n                            ip.visibility<>'2' AND\n                            (ip.to_group_id = {$group_id} OR ip.to_group_id='0' OR ip.to_group_id IS NULL)\n                            {$condition_session}\n                            {$searchCondition}\n                        ORDER BY display_order DESC";
             //GROUP BY ip.ref
         } else {
             // A.3 you are a course admin without any group or user filter
             // A.3.a you are a course admin without user or group filter but WITH studentview
             // => see all the messages of all the users and groups without editing possibilities
             if (isset($isStudentView) && $isStudentView == "true") {
                 $sql = "SELECT {$select}\n                        FROM {$tbl_announcement} announcement INNER JOIN {$tbl_item_property} ip\n                        ON (announcement.id = ip.ref AND ip.tool='announcement')\n                        WHERE\n                            announcement.c_id = {$course_id} AND\n                            ip.c_id = {$course_id} AND\n                            ip.tool='announcement' AND\n                            ip.visibility='1'\n                            {$condition_session}\n                            {$searchCondition}\n                        ORDER BY display_order DESC";
                 //GROUP BY ip.ref
             } else {
                 // A.3.a you are a course admin without user or group filter and WTIHOUT studentview (= the normal course admin view)
                 // => see all the messages of all the users and groups with editing possibilities
                 $sql = "SELECT {$select}\n                            FROM {$tbl_announcement} announcement INNER JOIN {$tbl_item_property} ip\n                            ON (announcement.id = ip.ref AND ip.tool='announcement')\n                            WHERE\n                                announcement.c_id = {$course_id} AND\n                                ip.c_id = {$course_id} AND\n                                (ip.visibility='0' or ip.visibility='1')\n                                {$condition_session}\n                                {$searchCondition}\n                            ORDER BY display_order DESC";
                 //GROUP BY ip.ref
             }
         }
     } else {
         // STUDENT
         if (is_array($group_memberships) && count($group_memberships) > 0) {
             if ($allowUserEditSetting && !api_is_anonymous()) {
                 if ($group_id == 0) {
                     // No group
                     $cond_user_id = " AND (\n                            ip.lastedit_user_id = '" . $user_id . "' OR (\n                                ip.to_user_id='" . $user_id . "' OR\n                                (ip.to_group_id IS NULL OR ip.to_group_id IN (0, " . implode(", ", $group_memberships) . "))\n                            )\n                        ) ";
                 } else {
                     $cond_user_id = " AND (\n                            ip.lastedit_user_id = '" . $user_id . "' OR ip.to_group_id IS NULL OR ip.to_group_id IN (0, " . $group_id . ")\n                        )";
                 }
             } else {
                 if ($group_id == 0) {
                     $cond_user_id = " AND (\n                            ip.to_user_id = {$user_id} AND (ip.to_group_id IS NULL OR ip.to_group_id IN (0, " . implode(", ", $group_memberships) . "))\n                        ) ";
                 } else {
                     $cond_user_id = " AND (\n                            ip.to_user_id = {$user_id} AND (ip.to_group_id IS NULL OR ip.to_group_id IN (0, " . $group_id . "))\n                        )";
                 }
             }
             $sql = "SELECT {$select}\n                        FROM {$tbl_announcement} announcement,\n                        {$tbl_item_property} ip\n                        WHERE\n                            announcement.c_id = {$course_id} AND\n                            ip.c_id = {$course_id} AND\n                            announcement.id = ip.ref\n                            AND ip.tool='announcement'\n                            {$cond_user_id}\n                            {$condition_session}\n                            {$searchCondition}\n                            AND ip.visibility='1'\n                        ORDER BY display_order DESC";
         } else {
             if ($user_id) {
                 if ($allowUserEditSetting && !api_is_anonymous()) {
                     $cond_user_id = " AND (\n                            ip.lastedit_user_id = '" . api_get_user_id() . "' OR\n                            (ip.to_user_id='" . $user_id . "' AND (ip.to_group_id='0' OR ip.to_group_id IS NULL))\n                        ) ";
                 } else {
                     $cond_user_id = " AND (ip.to_user_id='" . $user_id . "' AND (ip.to_group_id='0' OR ip.to_group_id IS NULL) ) ";
                 }
                 $sql = "SELECT {$select}\n\t\t\t\t\t\tFROM {$tbl_announcement} announcement, {$tbl_item_property} ip\n\t\t\t\t\t\tWHERE\n    \t\t\t\t\t\tannouncement.c_id = {$course_id} AND\n\t\t\t\t\t\t\tip.c_id = {$course_id} AND\n    \t\t\t\t\t\tannouncement.id = ip.ref AND\n    \t\t\t\t\t\tip.tool='announcement'\n    \t\t\t\t\t\t{$cond_user_id}\n    \t\t\t\t\t\t{$condition_session}\n    \t\t\t\t\t\t{$searchCondition}\n    \t\t\t\t\t\tAND ip.visibility='1'\n    \t\t\t\t\t\tAND announcement.session_id IN(0, " . $session_id . ")\n\t\t\t\t\t\tORDER BY display_order DESC";
             } else {
                 if ($allowUserEditSetting && !api_is_anonymous()) {
                     $cond_user_id = " AND (\n                            ip.lastedit_user_id = '" . $user_id . "' OR ip.to_group_id='0' OR ip.to_group_id IS NULL\n                        )";
                 } else {
                     $cond_user_id = " AND ip.to_group_id='0' OR ip.to_group_id IS NULL ";
                 }
                 $sql = "SELECT {$select}\n\t\t\t\t\t\tFROM {$tbl_announcement} announcement, {$tbl_item_property} ip\n\t\t\t\t\t\tWHERE\n                            announcement.c_id = {$course_id} AND\n                            ip.c_id = {$course_id} AND\n                            announcement.id = ip.ref AND\n                            ip.tool='announcement'\n                            {$cond_user_id}\n                            {$condition_session}\n                            {$searchCondition}\n                            AND\n                            ip.visibility='1' AND\n                            announcement.session_id IN ( 0," . api_get_session_id() . ")";
             }
         }
     }
     if (!is_null($start) && !is_null($limit)) {
         $start = intval($start);
         $limit = intval($limit);
         $sql .= " LIMIT {$start}, {$limit}";
     }
     $result = Database::query($sql);
     if ($getCount) {
         $result = Database::fetch_array($result, 'ASSOC');
         return $result['count'];
     }
     $iterator = 1;
     $bottomAnnouncement = $announcement_number;
     $origin = null;
     $displayed = [];
     $results = [];
     $actionUrl = api_get_path(WEB_CODE_PATH) . 'announcements/announcements.php?' . api_get_cidreq();
     while ($myrow = Database::fetch_array($result, 'ASSOC')) {
         if (!in_array($myrow['id'], $displayed)) {
             $sent_to_icon = '';
             // the email icon
             if ($myrow['email_sent'] == '1') {
                 $sent_to_icon = ' ' . Display::return_icon('email.gif', get_lang('AnnounceSentByEmail'));
             }
             $title = $myrow['title'] . $sent_to_icon;
             $item_visibility = api_get_item_visibility($_course, TOOL_ANNOUNCEMENT, $myrow['id'], $session_id);
             $myrow['visibility'] = $item_visibility;
             // show attachment list
             $attachment_list = AnnouncementManager::get_attachment($myrow['id']);
             $attachment_icon = '';
             if (count($attachment_list) > 0) {
                 $attachment_icon = ' ' . Display::return_icon('attachment.gif', get_lang('Attachment'));
             }
             /* TITLE */
             $user_info = api_get_user_info($myrow['insert_user_id']);
             $username = sprintf(get_lang("LoginX"), $user_info['username']);
             $username_span = Display::tag('span', api_get_person_name($user_info['firstName'], $user_info['lastName']), array('title' => $username));
             $title = Display::url($title . $attachment_icon, $actionUrl . '&action=view&id=' . $myrow['id']);
             //$html .= Display::tag('td', $username_span, array('class' => 'announcements-list-line-by-user'));
             //$html .= Display::tag('td', api_convert_and_format_date($myrow['insert_date'], DATE_TIME_FORMAT_LONG), array('class' => 'announcements-list-line-datetime'));
             $modify_icons = '';
             // we can edit if : we are the teacher OR the element belongs to
             // the session we are coaching OR the option to allow users to edit is on
             if (api_is_allowed_to_edit(false, true) || api_is_course_coach() && api_is_element_in_the_session(TOOL_ANNOUNCEMENT, $myrow['id']) || api_get_course_setting('allow_user_edit_announcement') && !api_is_anonymous()) {
                 $modify_icons = "<a href=\"" . $actionUrl . "&action=modify&id=" . $myrow['id'] . "\">" . Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_SMALL) . "</a>";
                 if ($myrow['visibility'] == 1) {
                     $image_visibility = "visible";
                     $alt_visibility = get_lang('Hide');
                 } else {
                     $image_visibility = "invisible";
                     $alt_visibility = get_lang('Visible');
                 }
                 $modify_icons .= "<a href=\"" . $actionUrl . "&origin=" . $origin . "&action=showhide&id=" . $myrow['id'] . "&sec_token=" . $stok . "\">" . Display::return_icon($image_visibility . '.png', $alt_visibility, '', ICON_SIZE_SMALL) . "</a>";
                 // DISPLAY MOVE UP COMMAND only if it is not the top announcement
                 if ($iterator != 1) {
                     $modify_icons .= "<a href=\"" . $actionUrl . "&action=move&up=" . $myrow["id"] . "&sec_token=" . $stok . "\">" . Display::return_icon('up.gif', get_lang('Up')) . "</a>";
                 } else {
                     $modify_icons .= Display::return_icon('up_na.gif', get_lang('Up'));
                 }
                 if ($iterator < $bottomAnnouncement) {
                     $modify_icons .= "<a href=\"" . $actionUrl . "&action=move&down=" . $myrow["id"] . "&sec_token=" . $stok . "\">" . Display::return_icon('down.gif', get_lang('Down')) . "</a>";
                 } else {
                     $modify_icons .= Display::return_icon('down_na.gif', get_lang('Down'));
                 }
                 if (api_is_allowed_to_edit(false, true)) {
                     $modify_icons .= "<a href=\"" . $actionUrl . "&action=delete&id=" . $myrow['id'] . "&sec_token=" . $stok . "\" onclick=\"javascript:if(!confirm('" . addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES, api_get_system_encoding())) . "')) return false;\">" . Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL) . "</a>";
                 }
                 $iterator++;
             } else {
                 $modify_icons = Display::url(Display::return_icon('default.png'), $actionUrl . '&action=view&id=' . $myrow['id']);
             }
             $announcement = ['id' => $myrow["id"], 'title' => $title, 'username' => $username_span, 'insert_date' => api_convert_and_format_date($myrow['insert_date'], DATE_TIME_FORMAT_LONG), 'actions' => $modify_icons];
             $results[] = $announcement;
         }
         $displayed[] = $myrow['id'];
     }
     return $results;
 }
Example #9
0
     $poster_info = api_get_user_info($last_post_info['poster_id']);
     $post_date = api_convert_and_format_date($last_post_info['post_date']);
     $last_post = $post_date . '<br>' . get_lang('By') . ' ' . display_user_link($last_post_info['poster_id'], $poster_info['complete_name'], '', $poster_info['username']);
 }
 $html .= '<div class="col-md-5">' . Display::return_icon('post-item.png', null, null, ICON_SIZE_TINY) . ' ' . $last_post;
 $html .= '</div>';
 $html .= '<div class="col-md-3">';
 $cidreq = api_get_cidreq();
 // Get attachment id.
 if (isset($row['post_id'])) {
     $attachment_list = get_attachment($row['post_id']);
 }
 $id_attach = !empty($attachment_list) ? $attachment_list['id'] : '';
 $iconsEdit = '';
 if ($origin != 'learnpath') {
     if (api_is_allowed_to_edit(false, true) && !(api_is_course_coach() && $current_forum['session_id'] != $sessionId)) {
         $iconsEdit .= '<a href="' . $forumUrl . 'editthread.php?' . $cidreq . '&forum=' . intval($my_forum) . '&thread=' . intval($row['thread_id']) . '&id_attach=' . $id_attach . '">' . Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL) . '</a>';
         if (api_resource_is_locked_by_gradebook($row['thread_id'], LINK_FORUM_THREAD)) {
             $iconsEdit .= Display::return_icon('delete_na.png', get_lang('ResourceLockedByGradebook'), array(), ICON_SIZE_SMALL);
         } else {
             $iconsEdit .= '<a href="' . api_get_self() . '?' . $cidreq . '&forum=' . intval($my_forum) . '&action=delete&content=thread&id=' . $row['thread_id'] . $origin_string . "\" onclick=\"javascript:if(!confirm('" . addslashes(api_htmlentities(get_lang('DeleteCompleteThread'), ENT_QUOTES)) . "')) return false;\">" . Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL) . '</a>';
         }
         $iconsEdit .= return_visible_invisible_icon('thread', $row['thread_id'], $row['visibility'], array('forum' => $my_forum, 'origin' => $origin, 'gidReq' => $groupId));
         $iconsEdit .= return_lock_unlock_icon('thread', $row['thread_id'], $row['locked'], array('forum' => $my_forum, 'origin' => $origin, 'gidReq' => api_get_group_id()));
         $iconsEdit .= '<a href="viewforum.php?' . $cidreq . '&forum=' . intval($my_forum) . '&action=move&thread=' . $row['thread_id'] . $origin_string . '">' . Display::return_icon('move.png', get_lang('MoveThread'), array(), ICON_SIZE_SMALL) . '</a>';
     }
 }
 $iconnotify = 'notification_mail_na.png';
 if (is_array(isset($_SESSION['forum_notification']['thread']) ? $_SESSION['forum_notification']['thread'] : null)) {
     if (in_array($row['thread_id'], $_SESSION['forum_notification']['thread'])) {
         $iconnotify = 'notification_mail.png';
printf('<courseobject>');
foreach ($_SESSION['_course'] as $key => $val) {
    printf('<%s>%s</%s>', $key, api_utf8_encode($val), $key);
}
printf('</courseobject>');
printf('<userobject>');
foreach ($_SESSION['_user'] as $key => $val) {
    if ($key != "auth_source") {
        if (($key == "lastName" || $key == "firstName") && strlen($val) == 0) {
            $val = get_lang('Unknown');
        }
        printf('<%s>%s</%s>', $key, api_utf8_encode($val), $key);
    }
}
printf('<sid>%s</sid>', session_id());
$isadmin = CourseManager::get_user_in_course_status($_SESSION['_user']['user_id'], $_SESSION['_course']['sysCode']) == COURSEMANAGER || api_is_platform_admin() || api_is_course_tutor() || api_is_course_admin() || api_is_course_coach() ? "true" : "false";
printf('<key>%s</key>', md5($confkey . $challenge));
printf('<challenge>%s</challenge>', $challenge);
printf('<isUploadAllowed>%s</isUploadAllowed>', $isadmin);
printf('<canStartModerator>%s</canStartModerator>', $isadmin == 'true' || $_SESSION["roomType"] == "conference" ? 'true' : 'false');
printf('<mustStartModerator>%s</mustStartModerator>', $isadmin == 'true' || $_SESSION["roomType"] == "conference" ? 'true' : 'false');
printf('</userobject>');
printf('<config>');
printf('<host>' . api_get_setting('service_visio', 'visio_host') . '</host>');
printf('<port>' . api_get_setting('service_visio', 'visio_port') . '</port>');
printf('</config>');
$path = preg_replace('/^([^:]*:\\/\\/)/', '', api_get_path(WEB_PATH));
$path = str_replace('/', '_', $path);
printf('<roomConfig>');
printf('<portal>%s</portal>', $path);
printf('<roomType>%s</roomType>', $_SESSION['roomType']);
Example #11
0
 echo '<div class="actions">';
 echo '<span style="float:right;">' . search_link() . '</span>';
 if ($origin != 'learnpath') {
     echo '<a href="' . $forumUrl . 'viewforum.php?forum=' . Security::remove_XSS($_GET['forum']) . '&' . api_get_cidreq() . '">' . Display::return_icon('back.png', get_lang('BackToForum'), '', ICON_SIZE_MEDIUM) . '</a>';
 }
 // The reply to thread link should only appear when the forum_category is not locked AND the forum is not locked AND the thread is not locked.
 // If one of the three levels is locked then the link should not be displayed.
 if ($current_forum_category && $current_forum_category['locked'] == 0 and $current_forum['locked'] == 0 and $current_thread['locked'] == 0 or api_is_allowed_to_edit(false, true)) {
     // The link should only appear when the user is logged in or when anonymous posts are allowed.
     if ($_user['user_id'] or $current_forum['allow_anonymous'] == 1 and !$_user['user_id']) {
         // reply link
         if (!api_is_anonymous() && api_is_allowed_to_session_edit(false, true)) {
             echo '<a href="' . $forumUrl . 'reply.php?' . api_get_cidreq() . '&forum=' . Security::remove_XSS($_GET['forum']) . '&thread=' . Security::remove_XSS($_GET['thread']) . '&amp;action=replythread">' . Display::return_icon('reply_thread.png', get_lang('ReplyToThread'), '', ICON_SIZE_MEDIUM) . '</a>';
         }
         // new thread link
         if (api_is_allowed_to_edit(false, true) && !(api_is_course_coach() && $current_forum['session_id'] != $_SESSION['id_session']) or $current_forum['allow_new_threads'] == 1 and isset($_user['user_id']) or $current_forum['allow_new_threads'] == 1 and !isset($_user['user_id']) and $current_forum['allow_anonymous'] == 1) {
             if ($current_forum['locked'] != 1 and $current_forum['locked'] != 1) {
                 echo '&nbsp;&nbsp;';
             } else {
                 echo get_lang('ForumLocked');
             }
         }
     }
 }
 // The different views of the thread.
 if ($origin != 'learnpath') {
     $my_url = '<a href="' . $forumUrl . 'viewthread.php?' . api_get_cidreq() . '&' . api_get_cidreq() . '&forum=' . Security::remove_XSS($_GET['forum']) . '&thread=' . Security::remove_XSS($_GET['thread']) . '&search=' . Security::remove_XSS(urlencode($my_search));
     echo $my_url . '&amp;view=flat">' . Display::return_icon('forum_listview.gif', get_lang('FlatView')) . get_lang('FlatView') . '</a>';
     echo $my_url . '&amp;view=threaded">' . Display::return_icon('forum_threadedview.gif', get_lang('ThreadedView')) . get_lang('ThreadedView') . '</a>';
     echo $my_url . '&amp;view=nested">' . Display::return_icon('forum_nestedview.gif', get_lang('NestedView')) . get_lang('NestedView') . '</a>';
 }
/**
 * This function displays the form that is used to add a post. This can be a new thread or a reply.
 * @param $action is the parameter that determines if we are
 *                    1. newthread: adding a new thread (both empty) => No I-frame
 *                    2. replythread: Replying to a thread ($action = replythread) => I-frame with the complete thread (if enabled)
 *                    3. replymessage: Replying to a message ($action =replymessage) => I-frame with the complete thread (if enabled) (I first thought to put and I-frame with the message only)
 *                     4. quote: Quoting a message ($action= quotemessage) => I-frame with the complete thread (if enabled). The message will be in the reply. (I first thought not to put an I-frame here)
 * @return void HMTL
 * @author Patrick Cool <*****@*****.**>, Ghent University
 * @version february 2006, dokeos 1.8
 */
function show_add_post_form($action = '', $id = '', $form_values = '')
{
    global $forum_setting;
    global $current_forum;
    global $_user;
    global $origin;
    $gradebook = Security::remove_XSS($_GET['gradebook']);
    // Setting the class and text of the form title and submit button.
    if ($_GET['action'] == 'quote') {
        $class = 'save';
        $text = get_lang('QuoteMessage');
    } elseif ($_GET['action'] == 'replythread') {
        $class = 'save';
        $text = get_lang('ReplyToThread');
    } elseif ($_GET['action'] == 'replymessage') {
        $class = 'save';
        $text = get_lang('ReplyToMessage');
    } else {
        $class = 'add';
        $text = get_lang('CreateThread');
    }
    // Initialize the object.
    $my_thread = isset($_GET['thread']) ? $_GET['thread'] : '';
    $my_forum = isset($_GET['forum']) ? $_GET['forum'] : '';
    $my_action = isset($_GET['action']) ? $_GET['action'] : '';
    $my_post = isset($_GET['post']) ? $_GET['post'] : '';
    $my_gradebook = isset($_GET['gradebook']) ? Security::remove_XSS($_GET['gradebook']) : '';
    $form = new FormValidator('thread', 'post', api_get_self() . '?forum=' . Security::remove_XSS($my_forum) . '&gradebook=' . $gradebook . '&thread=' . Security::remove_XSS($my_thread) . '&post=' . Security::remove_XSS($my_post) . '&action=' . Security::remove_XSS($my_action) . '&origin=' . $origin);
    $form->setConstants(array('forum' => '5'));
    $form->addElement('header', $text);
    // Settting the form elements.
    $form->addElement('hidden', 'forum_id', intval($my_forum));
    $form->addElement('hidden', 'thread_id', intval($my_thread));
    $form->addElement('hidden', 'gradebook', $my_gradebook);
    // If anonymous posts are allowed we also display a form to allow the user to put his name or username in.
    if ($current_forum['allow_anonymous'] == 1 && !isset($_user['user_id'])) {
        $form->addElement('text', 'poster_name', get_lang('Name'));
        $form->applyFilter('poster_name', 'html_filter');
    }
    $form->addElement('text', 'post_title', get_lang('Title'));
    $form->addElement('html_editor', 'post_text', get_lang('Text'), true, api_is_allowed_to_edit(null, true) ? array('ToolbarSet' => 'Forum', 'Width' => '100%', 'Height' => '300') : array('ToolbarSet' => 'ForumStudent', 'Width' => '100%', 'Height' => '300', 'UserStatus' => 'student'));
    $form->addRule('post_text', get_lang('ThisFieldIsRequired'), 'required');
    $form->addElement('advanced_settings', '<a href="javascript://" onclick="return advanced_parameters()">
    						  <span id="img_plus_and_minus">&nbsp;' . Display::return_icon('div_show.gif', get_lang('Show'), array('style' => 'vertical-align:middle')) . ' ' . get_lang('AdvancedParameters') . '</span></a>');
    $form->addElement('html', '<div id="id_qualify" style="display:none">');
    if ((api_is_course_admin() || api_is_course_coach() || api_is_course_tutor()) && !$my_thread) {
        // Thread qualify
        if (Gradebook::is_active()) {
            //Loading gradebook select
            load_gradebook_select_in_tool($form);
            $form->addElement('checkbox', 'thread_qualify_gradebook', '', get_lang('QualifyThreadGradebook'), 'onclick="javascript:if(this.checked==true){document.getElementById(\'options_field\').style.display = \'block\';}else{document.getElementById(\'options_field\').style.display = \'none\';}"');
        } else {
            $form->addElement('hidden', 'thread_qualify_gradebook', false);
        }
        $form->addElement('html', '<div id="options_field" style="display:none">');
        $form->addElement('text', 'numeric_calification', get_lang('QualificationNumeric'));
        $form->applyFilter('numeric_calification', 'html_filter');
        $form->addElement('text', 'calification_notebook_title', get_lang('TitleColumnGradebook'));
        $form->applyFilter('calification_notebook_title', 'html_filter');
        $form->addElement('text', 'weight_calification', get_lang('QualifyWeight'), 'value="0.00" Style="width:40px" onfocus="javascript: this.select();"');
        $form->applyFilter('weight_calification', 'html_filter');
        $form->addElement('html', '</div>');
    }
    if ($forum_setting['allow_post_notification'] && isset($_user['user_id'])) {
        $form->addElement('checkbox', 'post_notification', '', get_lang('NotifyByEmail') . ' (' . $_user['mail'] . ')');
    }
    if ($forum_setting['allow_sticky'] && api_is_allowed_to_edit(null, true) && $action == 'newthread') {
        $form->addElement('checkbox', 'thread_sticky', '', get_lang('StickyPost'));
    }
    if ($current_forum['allow_attachments'] == '1' || api_is_allowed_to_edit(null, true)) {
        $values = $form->exportValues();
    }
    // User upload
    $form->addElement('static', null, null, get_lang('AddAnAttachment'));
    $form->addElement('file', 'user_upload', get_lang('FileName'), '');
    $form->addElement('textarea', 'file_comment', get_lang('FileComment'), array('rows' => 4, 'cols' => 34));
    $form->applyFilter('file_comment', 'html_filter');
    $form->addElement('html', '</div>');
    $form->addElement('style_submit_button', 'SubmitPost', $text, 'class="' . $class . '"');
    $form->add_real_progress_bar('DocumentUpload', 'user_upload');
    if (!empty($form_values)) {
        $defaults['post_title'] = prepare4display($form_values['post_title']);
        $defaults['post_text'] = prepare4display($form_values['post_text']);
        $defaults['post_notification'] = strval(intval($form_values['post_notification']));
        $defaults['thread_sticky'] = strval(intval($form_values['thread_sticky']));
    }
    // If we are quoting a message we have to retrieve the information of the post we are quoting so that
    // we can add this as default to the textarea.
    if (($action == 'quote' || $action == 'replymessage') && isset($my_post)) {
        // We also need to put the parent_id of the post in a hidden form when we are quoting or replying to a message (<> reply to a thread !!!)
        $form->addElement('hidden', 'post_parent_id', strval(intval($my_post)));
        // Note: This has to be cleaned first.
        // If we are replying or are quoting then we display a default title.
        $values = get_post_information($my_post);
        // Note: This has to be cleaned first.
        $defaults['post_title'] = get_lang('ReplyShort') . api_html_entity_decode($values['post_title'], ENT_QUOTES);
        // When we are quoting a message then we have to put that message into the wysiwyg editor.
        // Note: The style has to be hardcoded here because using class="quote" didn't work.
        if ($action == 'quote') {
            $defaults['post_text'] = '<div>&nbsp;</div><div style="margin: 5px;"><div style="font-size: 90%; font-style: italic;">' . get_lang('Quoting') . ' ' . api_get_person_name($values['firstname'], $values['lastname']) . ':</div><div style="color: #006600; font-size: 90%;	font-style: italic; background-color: #FAFAFA; border: #D1D7DC 1px solid; padding: 3px;">' . prepare4display($values['post_text']) . '</div></div><div>&nbsp;</div><div>&nbsp;</div>';
        }
    }
    $form->setDefaults(isset($defaults) ? $defaults : null);
    // The course admin can make a thread sticky (=appears with special icon and always on top).
    $form->addRule('post_title', get_lang('ThisFieldIsRequired'), 'required');
    if ($current_forum['allow_anonymous'] == 1 && !isset($_user['user_id'])) {
        $form->addRule('poster_name', get_lang('ThisFieldIsRequired'), 'required');
    }
    // Validation or display
    if ($form->validate()) {
        $check = Security::check_token('post');
        if ($check) {
            $values = $form->exportValues();
            if ($values['thread_qualify_gradebook'] == '1' && empty($values['weight_calification'])) {
                Display::display_error_message(get_lang('YouMustAssignWeightOfQualification') . '&nbsp;<a href="javascript:window.back()">' . get_lang('Back') . '</a>', false);
                return false;
            }
            Security::clear_token();
            return $values;
        }
    } else {
        $token = Security::get_token();
        $form->addElement('hidden', 'sec_token');
        $form->setConstants(array('sec_token' => $token));
        $iframe = null;
        if ($forum_setting['show_thread_iframe_on_reply'] && $action != 'newthread') {
            $iframe = "<iframe style=\"border: 1px solid black\" src=\"iframe_thread.php?forum=" . Security::remove_XSS($my_forum) . "&amp;thread=" . Security::remove_XSS($my_thread) . "#" . Security::remove_XSS($my_post) . "\" width=\"100%\"></iframe>";
        }
        if (!empty($iframe)) {
            $form->addElement('label', get_lang('Thread'), $iframe);
        }
        $form->display();
    }
}
/* For licensing terms, see /license.txt */
/**
 * Responses to AJAX calls
 */
require_once '../global.inc.php';
$action = isset($_REQUEST['a']) ? $_REQUEST['a'] : null;
$isAllowedToEdit = api_is_allowed_to_edit();
$courseInfo = api_get_course_info();
switch ($action) {
    case 'delete_item':
        if ($isAllowedToEdit) {
            if (empty($_REQUEST['id'])) {
                return false;
            }
            if (api_get_session_id() != 0 && api_is_allowed_to_session_edit(false, true) == false) {
                return false;
            }
            $list = explode(',', $_REQUEST['id']);
            foreach ($list as $itemId) {
                if (!api_is_course_coach() || api_is_element_in_the_session(TOOL_ANNOUNCEMENT, $itemId)) {
                    AnnouncementManager::delete_announcement($courseInfo, $itemId);
                }
            }
        }
        break;
    default:
        echo '';
        break;
}
exit;
Example #14
0
/**
 * Displays all the agenda items
 * @author Patrick Cool <*****@*****.**>, Ghent University
 * @author Yannick Warnier <*****@*****.**> - cleanup
 * @author Julio Montoya <*****@*****.**> - Refactoring
 */
function display_agenda_items($agenda_items, $day = false)
{
    global $charset;
    if (isset($day) && $day) {
        $new_items = array();
        foreach ($agenda_items as $item) {
            if (substr($item['start_date'], 8, 2) == $day) {
                $new_items[] = $item;
            }
        }
        $agenda_items = $new_items;
    }
    if (isset($_GET['sort']) && $_GET['sort'] == 'asc') {
        $sort_inverse = 'desc';
        $sort = 'asc';
    } else {
        $sort_inverse = 'asc';
        $sort = 'desc';
    }
    if (isset($_GET['col']) && $_GET['col'] == 'end') {
        $sort_item = 'end_date_tms';
        $col = 'end';
    } else {
        $sort_item = 'start_date_tms';
        $col = 'start';
    }
    $agenda_items = msort($agenda_items, $sort_item, $sort);
    //DISPLAY: NO ITEMS
    if (empty($agenda_items)) {
        echo Display::display_warning_message(get_lang('NoAgendaItems'));
    } else {
        echo '<table class="data_table">';
        $th = Display::tag('th', get_lang('Title'));
        $month = isset($_GET['month']) ? intval($_GET['month']) : null;
        $year = isset($_GET['year']) ? intval($_GET['year']) : null;
        $day = isset($_GET['day']) ? intval($_GET['day']) : null;
        $url = api_get_self() . '?' . api_get_cidreq() . '&month=' . $month . '&year=' . $year . '&day=' . $day;
        $th .= Display::tag('th', Display::url(get_lang('StartTimeWindow'), $url . '&sort=' . $sort_inverse . '&col=start'));
        $th .= Display::tag('th', Display::url(get_lang('EndTimeWindow'), $url . '&sort=' . $sort_inverse . '&col=end'));
        if (api_is_allowed_to_edit(false, true) or api_get_course_setting('allow_user_edit_agenda') && !api_is_anonymous()) {
            $th .= Display::tag('th', get_lang('Modify'));
        }
        echo Display::tag('tr', $th);
        $counter = 0;
        foreach ($agenda_items as $myrow) {
            $is_repeated = !empty($myrow['parent_event_id']);
            $class = 'row_even';
            if ($counter % 2) {
                $class = 'row_odd';
            }
            /* 	display: the icon, title, destinees of the item	 */
            echo '<tr class="' . $class . '">';
            //Title
            echo "<td>";
            $attach_icon = '';
            // attachment list
            $attachment_list = get_attachment($myrow['id']);
            if (!empty($attachment_list)) {
                $attach_icon = ' ' . Display::return_icon('attachment.gif', get_lang('Attachment'));
            }
            $title_class = '';
            if (isset($myrow['visibility']) && $myrow['visibility'] == 0) {
                $title_class = 'invisible';
            }
            switch ($myrow['calendar_type']) {
                case 'global':
                    $icon_type = Display::return_icon('view_remove.png', get_lang('GlobalEvent'), array(), 22);
                    echo $icon_type . ' ' . $myrow['title'] . $attach_icon;
                    break;
                case 'personal':
                    $icon_type = Display::return_icon('user.png', get_lang('   '), array(), 22);
                    echo $icon_type . ' ' . $myrow['title'] . $attach_icon;
                    break;
                case 'course':
                    $icon_type = Display::return_icon('course.png', get_lang('Course'), array(), 22);
                    $agenda_url = api_get_path(WEB_CODE_PATH) . 'calendar/agenda.php?agenda_id=' . $myrow['id'] . '&action=view';
                    echo Display::url($icon_type . ' ' . $myrow['title'] . $attach_icon, $agenda_url, array('class' => $title_class));
                    break;
            }
            echo '</td>';
            //Start date
            echo '<td>';
            if (!empty($myrow['start_date']) && $myrow['start_date'] != '0000-00-00 00:00:00') {
                echo api_format_date($myrow['start_date']);
            }
            echo '</td>';
            //End date
            echo '<td>';
            if (!empty($myrow['end_date']) && $myrow['end_date'] != '0000-00-00 00:00:00') {
                echo api_format_date($myrow['end_date']);
            }
            echo '</td>';
            /* Display: edit delete button (course admin only) */
            if (!$is_repeated && (api_is_allowed_to_edit(false, true) or api_get_course_setting('allow_user_edit_agenda') && !api_is_anonymous()) && $myrow['calendar_type'] == 'course') {
                echo '<td align="center">';
                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
                    $mylink = api_get_self() . '?' . api_get_cidreq() . '&origin=' . Security::remove_XSS($_GET['origin']) . '&id=' . $myrow['id'] . '&sort=' . $sort . '&col=' . $col . '&';
                    // edit
                    echo '<a href="' . $mylink . api_get_cidreq() . "&toolgroup=" . Security::remove_XSS($_GET['toolgroup']) . '&action=edit&id_attach=' . $attachment_list['id'] . '" title="' . get_lang("ModifyCalendarItem") . '">';
                    echo Display::return_icon('edit.png', get_lang('ModifyCalendarItem'), '', ICON_SIZE_SMALL) . "</a>";
                    echo '<a href="' . $mylink . api_get_cidreq() . "&toolgroup=" . Security::remove_XSS($_GET['toolgroup']) . '&action=announce" title="' . get_lang("AddAnnouncement") . '">';
                    echo Display::return_icon('new_announce.png', get_lang('AddAnnouncement'), array(), ICON_SIZE_SMALL) . "</a> ";
                    if ($myrow['visibility'] == 1) {
                        $image_visibility = "visible";
                        $text_visibility = get_lang("Hide");
                        $next_action = 0;
                    } else {
                        $image_visibility = "invisible";
                        $text_visibility = get_lang("Show");
                        $next_action = 1;
                    }
                    echo '<a href="' . $mylink . api_get_cidreq() . '&toolgroup=' . Security::remove_XSS($_GET['toolgroup']) . '&action=showhide&next_action=' . $next_action . '" title="' . $text_visibility . '">' . Display::return_icon($image_visibility . '.png', $text_visibility, '', ICON_SIZE_SMALL) . '</a> ';
                    echo "<a href=\"" . $mylink . api_get_cidreq() . "&toolgroup=" . Security::remove_XSS($_GET['toolgroup']) . "&action=delete\" onclick=\"javascript:if(!confirm('" . addslashes(api_htmlentities(get_lang("ConfirmYourChoice"), ENT_QUOTES, $charset)) . "')) return false;\"  title=\"" . get_lang("Delete") . "\"> ";
                    echo Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL) . "&nbsp;</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="#" 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 '</td>';
            } else {
                if ($is_repeated && (api_is_allowed_to_edit(false, true) || api_get_course_setting('allow_user_edit_agenda') && !api_is_anonymous())) {
                    echo '<td align="center">';
                    echo get_lang('RepeatedEvent'), ' <a href="', api_get_self(), '?', api_get_cidreq(), '&agenda_id=', $myrow['parent_event_id'], '" alt="', get_lang('RepeatedEventViewOriginalEvent'), '">', get_lang('RepeatedEventViewOriginalEvent'), '</a>';
                    echo '</td>';
                }
                if ((api_is_allowed_to_edit(false, true) || api_get_course_setting('allow_user_edit_agenda') && !api_is_anonymous()) && ($myrow['calendar_type'] == 'personal' or $myrow['calendar_type'] == 'global')) {
                    echo '<td align="center">';
                    echo '</td>';
                }
            }
            $counter++;
            echo "</tr>";
        }
        // end while ($myrow=Database::fetch_array($result))
        echo "</table><br /><br />";
    }
    if (!empty($event_list)) {
        $event_list = api_substr($event_list, 0, -1);
    } else {
        $event_list = '0';
    }
    echo "<form name=\"event_list_form\"><input type=\"hidden\" name=\"event_list\" value=\"{$event_list}\" /></form>";
    // closing the layout table
    echo "</td>", "</tr>", "</table>";
}
/**
 * This function displays the form that is used to add a post. This can be a new thread or a reply.
 * @param array $current_forum
 * @param array $forum_setting
 * @param string $action is the parameter that determines if we are
 *  1. newthread: adding a new thread (both empty) => No I-frame
 *  2. replythread: Replying to a thread ($action = replythread) => I-frame with the complete thread (if enabled)
 *  3. replymessage: Replying to a message ($action =replymessage) => I-frame with the complete thread (if enabled) (I first thought to put and I-frame with the message only)
 *  4. quote: Quoting a message ($action= quotemessage) => I-frame with the complete thread (if enabled). The message will be in the reply. (I first thought not to put an I-frame here)
 * @return void HMTL
 * @author Patrick Cool <*****@*****.**>, Ghent University
 * @version february 2006, dokeos 1.8
 */
function show_add_post_form($current_forum, $forum_setting, $action = '', $id = '', $form_values = '')
{
    $_user = api_get_user_info();
    $action = isset($_GET['action']) ? Security::remove_XSS($_GET['action']) : null;
    // Initialize the object.
    $myThread = isset($_GET['thread']) ? $_GET['thread'] : '';
    $my_forum = isset($_GET['forum']) ? $_GET['forum'] : '';
    $my_post = isset($_GET['post']) ? $_GET['post'] : '';
    $my_gradebook = isset($_GET['gradebook']) ? Security::remove_XSS($_GET['gradebook']) : '';
    $form = new FormValidator('thread', 'post', api_get_self() . '?' . http_build_query(['forum' => intval($my_forum), 'gradebook' => $my_gradebook, 'thread' => intval($myThread), 'post' => intval($my_post), 'action' => $action]) . '&' . api_get_cidreq());
    $form->setConstants(array('forum' => '5'));
    // Setting the form elements.
    $form->addElement('hidden', 'forum_id', intval($my_forum));
    $form->addElement('hidden', 'thread_id', intval($myThread));
    $form->addElement('hidden', 'gradebook', $my_gradebook);
    // If anonymous posts are allowed we also display a form to allow the user to put his name or username in.
    if ($current_forum['allow_anonymous'] == 1 && !isset($_user['user_id'])) {
        $form->addElement('text', 'poster_name', get_lang('Name'));
        $form->applyFilter('poster_name', 'html_filter');
    }
    $form->addElement('text', 'post_title', get_lang('Title'));
    $form->addHtmlEditor('post_text', get_lang('Text'), true, null, api_is_allowed_to_edit(null, true) ? array('ToolbarSet' => 'Forum', 'Width' => '100%', 'Height' => '300') : array('ToolbarSet' => 'ForumStudent', 'Width' => '100%', 'Height' => '300', 'UserStatus' => 'student'));
    $form->addRule('post_text', get_lang('ThisFieldIsRequired'), 'required');
    $iframe = null;
    $myThread = Security::remove_XSS($myThread);
    if ($forum_setting['show_thread_iframe_on_reply'] && $action != 'newthread' && !empty($myThread)) {
        $iframe = "<iframe style=\"border: 1px solid black\" src=\"iframe_thread.php?" . api_get_cidreq() . "&forum=" . Security::remove_XSS($my_forum) . "&thread=" . $myThread . "#" . Security::remove_XSS($my_post) . "\" width=\"100%\"></iframe>";
    }
    if (!empty($iframe)) {
        $form->addElement('label', get_lang('Thread'), $iframe);
    }
    $form->addElement('advanced_settings', 'advanced_params', get_lang('AdvancedParameters'));
    $form->addElement('html', '<div id="advanced_params_options" style="display:none">');
    if ((api_is_course_admin() || api_is_course_coach() || api_is_course_tutor()) && !$myThread) {
        // Thread qualify
        if (Gradebook::is_active()) {
            //Loading gradebook select
            GradebookUtils::load_gradebook_select_in_tool($form);
            $form->addElement('checkbox', 'thread_qualify_gradebook', '', get_lang('QualifyThreadGradebook'), 'onclick="javascript:if(this.checked==true){document.getElementById(\'options_field\').style.display = \'block\';}else{document.getElementById(\'options_field\').style.display = \'none\';}"');
        } else {
            $form->addElement('hidden', 'thread_qualify_gradebook', false);
        }
        $form->addElement('html', '<div id="options_field" style="display:none">');
        $form->addElement('text', 'numeric_calification', get_lang('QualificationNumeric'));
        $form->applyFilter('numeric_calification', 'html_filter');
        $form->addElement('text', 'calification_notebook_title', get_lang('TitleColumnGradebook'));
        $form->applyFilter('calification_notebook_title', 'html_filter');
        $form->addElement('text', 'weight_calification', get_lang('QualifyWeight'), array('value' => '0.00', 'onfocus' => "javascript: this.select();"));
        $form->applyFilter('weight_calification', 'html_filter');
        $group = array();
        $group[] = $form->createElement('radio', 'thread_peer_qualify', null, get_lang('Yes'), 1);
        $group[] = $form->createElement('radio', 'thread_peer_qualify', null, get_lang('No'), 0);
        $form->addGroup($group, '', [get_lang('ForumThreadPeerScoring'), get_lang('ForumThreadPeerScoringComment')], ' ');
        $form->addElement('html', '</div>');
    }
    if ($forum_setting['allow_post_notification'] && isset($_user['user_id'])) {
        $form->addElement('checkbox', 'post_notification', '', get_lang('NotifyByEmail') . ' (' . $_user['mail'] . ')');
    }
    if ($forum_setting['allow_sticky'] && api_is_allowed_to_edit(null, true) && $action == 'newthread') {
        $form->addElement('checkbox', 'thread_sticky', '', get_lang('StickyPost'));
    }
    if ($current_forum['allow_attachments'] == '1' || api_is_allowed_to_edit(null, true)) {
        $values = $form->exportValues();
    }
    $form->addElement('html', '</div>');
    if (in_array($action, ['quote', 'replymessage'])) {
        $form->addFile('user_upload[]', get_lang('Attachment'));
        $form->addButton('add_attachment', get_lang('AddAttachment'), 'paperclip', 'default', 'default', null, ['id' => 'reply-add-attachment']);
    } else {
        $form->addFile('user_upload', get_lang('Attachment'));
    }
    // Setting the class and text of the form title and submit button.
    if ($action == 'quote') {
        $form->addButtonCreate(get_lang('QuoteMessage'), 'SubmitPost');
    } elseif ($action == 'replythread') {
        $form->addButtonCreate(get_lang('ReplyToThread'), 'SubmitPost');
    } elseif ($action == 'replymessage') {
        $form->addButtonCreate(get_lang('ReplyToMessage'), 'SubmitPost');
    } else {
        $form->addButtonCreate(get_lang('CreateThread'), 'SubmitPost');
    }
    if (!empty($form_values)) {
        $defaults['post_title'] = prepare4display($form_values['post_title']);
        $defaults['post_text'] = prepare4display($form_values['post_text']);
        $defaults['post_notification'] = strval(intval($form_values['post_notification']));
        $defaults['thread_sticky'] = strval(intval($form_values['thread_sticky']));
        $defaults['thread_peer_qualify'] = intval($form_values['thread_peer_qualify']);
    } else {
        $defaults['thread_peer_qualify'] = 0;
    }
    // If we are quoting a message we have to retrieve the information of the post we are quoting so that
    // we can add this as default to the textarea.
    if (($action == 'quote' || $action == 'replymessage') && isset($my_post)) {
        // We also need to put the parent_id of the post in a hidden form when
        // we are quoting or replying to a message (<> reply to a thread !!!)
        $form->addElement('hidden', 'post_parent_id', intval($my_post));
        // If we are replying or are quoting then we display a default title.
        $values = get_post_information($my_post);
        $defaults['post_title'] = get_lang('ReplyShort') . api_html_entity_decode($values['post_title'], ENT_QUOTES);
        // When we are quoting a message then we have to put that message into the wysiwyg editor.
        // Note: The style has to be hardcoded here because using class="quote" didn't work.
        if ($action == 'quote') {
            $defaults['post_text'] = '<div>&nbsp;</div><div style="margin: 5px;"><div style="font-size: 90%; font-style: italic;">' . get_lang('Quoting') . ' ' . api_get_person_name($values['firstname'], $values['lastname']) . ':</div><div style="color: #006600; font-size: 90%;  font-style: italic; background-color: #FAFAFA; border: #D1D7DC 1px solid; padding: 3px;">' . prepare4display($values['post_text']) . '</div></div><div>&nbsp;</div><div>&nbsp;</div>';
        }
    }
    $form->setDefaults(isset($defaults) ? $defaults : null);
    // The course admin can make a thread sticky (=appears with special icon and always on top).
    $form->addRule('post_title', get_lang('ThisFieldIsRequired'), 'required');
    if ($current_forum['allow_anonymous'] == 1 && !isset($_user['user_id'])) {
        $form->addRule('poster_name', get_lang('ThisFieldIsRequired'), 'required');
    }
    // Validation or display
    if ($form->validate()) {
        $check = Security::check_token('post');
        if ($check) {
            $values = $form->exportValues();
            if (isset($values['thread_qualify_gradebook']) && $values['thread_qualify_gradebook'] == '1' && empty($values['weight_calification'])) {
                Display::display_error_message(get_lang('YouMustAssignWeightOfQualification') . '&nbsp;<a href="javascript:window.history.go(-1);">' . get_lang('Back') . '</a>', false);
                return false;
            }
            Security::clear_token();
            return $values;
        }
    } else {
        $token = Security::get_token();
        $form->addElement('hidden', 'sec_token');
        $form->setConstants(array('sec_token' => $token));
        // Delete from $_SESSION forum attachment from other posts
        // and keep only attachments for new post
        clearAttachedFiles(FORUM_NEW_POST);
        // Get forum attachment ajax table to add it to form
        $attachmentAjaxTable = getAttachmentsAjaxTable(0, $current_forum['forum_id']);
        $ajaxHtml = $attachmentAjaxTable;
        $form->addElement('html', $ajaxHtml);
        $form->display();
    }
}
 /**
  * @param $stok
  * @param $announcement_number
  */
 public static function getAnnouncements($stok, $announcement_number)
 {
     $tbl_announcement = Database::get_course_table(TABLE_ANNOUNCEMENT);
     $tbl_item_property = Database::get_course_table(TABLE_ITEM_PROPERTY);
     $user_id = api_get_user_id();
     $group_id = api_get_group_id();
     $session_id = api_get_session_id();
     $condition_session = api_get_session_condition($session_id, true, true, 'announcement.session_id');
     $course_id = api_get_course_int_id();
     $_course = api_get_course_info();
     $group_memberships = GroupManager::get_group_ids($course_id, api_get_user_id());
     $allowUserEditSetting = api_get_course_setting('allow_user_edit_announcement');
     if (api_is_allowed_to_edit(false, true) || $allowUserEditSetting && !api_is_anonymous()) {
         // A.1. you are a course admin with a USER filter
         // => see only the messages of this specific user + the messages of the group (s)he is member of.
         //if (!empty($user_id)) {
         if (0) {
             if (is_array($group_memberships) && count($group_memberships) > 0) {
                 $sql = "SELECT announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.insert_date\n                            FROM {$tbl_announcement} announcement, {$tbl_item_property} ip\n                            WHERE\n                                announcement.c_id = {$course_id} AND\n                                ip.c_id = {$course_id} AND\n                                announcement.id = ip.ref AND\n                                ip.tool = 'announcement' AND\n                                (\n                                    ip.to_user_id = {$user_id} OR\n                                    ip.to_group_id IS NULL OR\n                                    ip.to_group_id IN (0, " . implode(", ", $group_memberships) . ")\n                                ) AND\n                                ip.visibility IN ('1', '0')\n                                {$condition_session}\n                            ORDER BY display_order DESC";
             } else {
                 $sql = "SELECT announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.insert_date\n                            FROM {$tbl_announcement} announcement, {$tbl_item_property} ip\n                            WHERE\n                                announcement.c_id = {$course_id} AND\n                                ip.c_id = {$course_id} AND\n                                announcement.id = ip.ref AND\n                                ip.tool ='announcement' AND\n                                (ip.to_user_id = {$user_id} OR ip.to_group_id='0' OR ip.to_group_id IS NULL) AND\n                                ip.visibility IN ('1', '0')\n                            {$condition_session}\n                            ORDER BY display_order DESC";
             }
         } elseif ($group_id != 0) {
             // A.2. you are a course admin with a GROUP filter
             // => see only the messages of this specific group
             $sql = "SELECT announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.insert_date\n                        FROM {$tbl_announcement} announcement, {$tbl_item_property} ip\n                        WHERE\n                            announcement.c_id = {$course_id} AND\n                            ip.c_id = {$course_id} AND\n                            announcement.id = ip.ref\n                            AND ip.tool='announcement'\n                            AND ip.visibility<>'2'\n                            AND (ip.to_group_id = {$group_id} OR ip.to_group_id='0' OR ip.to_group_id IS NULL)\n                            {$condition_session}\n                        GROUP BY ip.ref\n                        ORDER BY display_order DESC";
         } else {
             // A.3 you are a course admin without any group or user filter
             // A.3.a you are a course admin without user or group filter but WITH studentview
             // => see all the messages of all the users and groups without editing possibilities
             if (isset($isStudentView) and $isStudentView == "true") {
                 $sql = "SELECT\n                        announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.insert_date\n                        FROM {$tbl_announcement} announcement, {$tbl_item_property} ip\n                        WHERE\n                            announcement.c_id = {$course_id} AND\n                            ip.c_id = {$course_id} AND\n                            announcement.id = ip.ref\n                            AND ip.tool='announcement'\n                            AND ip.visibility='1'\n                            {$condition_session}\n                        GROUP BY ip.ref\n                        ORDER BY display_order DESC";
             } else {
                 // A.3.a you are a course admin without user or group filter and WTIHOUT studentview (= the normal course admin view)
                 // => see all the messages of all the users and groups with editing possibilities
                 $sql = "SELECT announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.insert_date\n                            FROM {$tbl_announcement} announcement, {$tbl_item_property} ip\n                            WHERE\n                                announcement.c_id = {$course_id} AND\n                                ip.c_id = {$course_id} AND\n                                announcement.id = ip.ref\n                                AND ip.tool='announcement'\n                                AND (ip.visibility='0' or ip.visibility='1')\n                                {$condition_session}\n                            GROUP BY ip.ref\n                            ORDER BY display_order DESC";
             }
         }
     } else {
         // STUDENT
         if (is_array($group_memberships) && count($group_memberships) > 0) {
             if ($allowUserEditSetting && !api_is_anonymous()) {
                 if (api_get_group_id() == 0) {
                     // No group
                     $cond_user_id = " AND (\n                            ip.lastedit_user_id = '" . $user_id . "' OR (\n                                ip.to_user_id='" . $user_id . "' OR\n                                (ip.to_group_id IS NULL OR ip.to_group_id IN (0, " . implode(", ", $group_memberships) . "))\n                            )\n                        ) ";
                 } else {
                     $cond_user_id = " AND (\n                            ip.lastedit_user_id = '" . $user_id . "' OR ip.to_group_id IS NULL OR ip.to_group_id IN (0, " . $group_id . ")\n                        )";
                 }
             } else {
                 if (api_get_group_id() == 0) {
                     $cond_user_id = " AND (\n                            ip.to_user_id={$user_id} OR (ip.to_group_id IS NULL OR ip.to_group_id IN (0, " . implode(", ", $group_memberships) . "))\n                        ) ";
                 } else {
                     $cond_user_id = " AND (\n                            ip.to_user_id={$user_id} OR (ip.to_group_id IS NULL OR ip.to_group_id IN (0, " . api_get_group_id() . "))\n                        )";
                 }
             }
             $sql = "SELECT\n                            announcement.*,\n                            ip.visibility,\n                            ip.to_group_id,\n                            ip.insert_user_id,\n                            ip.insert_date\n                        FROM {$tbl_announcement} announcement,\n                        {$tbl_item_property} ip\n                        WHERE\n                            announcement.c_id = {$course_id} AND\n                            ip.c_id = {$course_id} AND\n                            announcement.id = ip.ref\n                            AND ip.tool='announcement'\n                            {$cond_user_id}\n                            {$condition_session} AND\n                            ip.visibility='1'\n                        ORDER BY display_order DESC";
         } else {
             if ($user_id) {
                 if ($allowUserEditSetting && !api_is_anonymous()) {
                     $cond_user_id = " AND (\n                            ip.lastedit_user_id = '" . api_get_user_id() . "' OR\n                            (ip.to_user_id='" . $user_id . "' AND (ip.to_group_id='0' OR ip.to_group_id IS NULL))\n                        ) ";
                 } else {
                     $cond_user_id = " AND (ip.to_user_id='" . $user_id . "' AND (ip.to_group_id='0' OR ip.to_group_id IS NULL) ) ";
                 }
                 $sql = "SELECT announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.insert_date\n\t\t\t\t\t\tFROM {$tbl_announcement} announcement, {$tbl_item_property} ip\n\t\t\t\t\t\tWHERE\n    \t\t\t\t\t\tannouncement.c_id = {$course_id} AND\n\t\t\t\t\t\t\tip.c_id = {$course_id} AND\n    \t\t\t\t\t\tannouncement.id = ip.ref AND\n    \t\t\t\t\t\tip.tool='announcement'\n    \t\t\t\t\t\t{$cond_user_id}\n    \t\t\t\t\t\t{$condition_session}\n    \t\t\t\t\t\tAND ip.visibility='1'\n    \t\t\t\t\t\tAND announcement.session_id IN(0, " . api_get_session_id() . ")\n\t\t\t\t\t\tORDER BY display_order DESC";
             } else {
                 if ($allowUserEditSetting && !api_is_anonymous()) {
                     $cond_user_id = " AND (\n                            ip.lastedit_user_id = '" . $user_id . "' OR ip.to_group_id='0' OR ip.to_group_id IS NULL\n                        )";
                 } else {
                     $cond_user_id = " AND ip.to_group_id='0' OR ip.to_group_id IS NULL ";
                 }
                 $sql = "SELECT announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.insert_date\n\t\t\t\t\t\tFROM {$tbl_announcement} announcement, {$tbl_item_property} ip\n\t\t\t\t\t\tWHERE\n                            announcement.c_id = {$course_id} AND\n                            ip.c_id = {$course_id} AND\n                            announcement.id = ip.ref AND\n                            ip.tool='announcement'\n                            {$cond_user_id}\n                            {$condition_session} AND\n                            ip.visibility='1' AND\n                            announcement.session_id IN ( 0," . api_get_session_id() . ")";
             }
         }
     }
     $result = Database::query($sql);
     $num_rows = Database::num_rows($result);
     $html = null;
     if ($num_rows == 0) {
         if ((api_is_allowed_to_edit(false, true) or api_get_course_setting('allow_user_edit_announcement') && !api_is_anonymous()) and (empty($_GET['origin']) or $_GET['origin'] !== 'learnpath')) {
             $html .= '<div id="no-data-view">';
             $html .= '<h3>' . get_lang('Announcements') . '</h3>';
             $html .= Display::return_icon('valves.png', '', array(), 64);
             $html .= '<div class="controls">';
             $html .= Display::url(get_lang('AddAnnouncement'), api_get_self() . "?" . api_get_cidreq() . "&action=add", array('class' => 'btn btn-primary'));
             $html .= '</div>';
             $html .= '</div>';
         } else {
             $html = Display::return_message(get_lang('NoAnnouncements'), 'warning');
         }
         return $html;
     }
     $iterator = 1;
     $bottomAnnouncement = $announcement_number;
     $origin = null;
     $html .= '<table width="100%" class="data_table announcements-list">';
     $ths = Display::tag('th', get_lang('Title'));
     $ths .= Display::tag('th', get_lang('By'));
     $ths .= Display::tag('th', get_lang('LastUpdateDate'));
     if (api_is_allowed_to_edit(false, true) or api_is_course_coach() && api_is_element_in_the_session(TOOL_ANNOUNCEMENT, $myrow['id']) or api_get_course_setting('allow_user_edit_announcement') && !api_is_anonymous()) {
         $ths .= Display::tag('th', get_lang('Modify'));
     }
     $html .= Display::tag('tr', $ths);
     $displayed = array();
     while ($myrow = Database::fetch_array($result, 'ASSOC')) {
         if (!in_array($myrow['id'], $displayed)) {
             $sent_to_icon = '';
             // the email icon
             if ($myrow['email_sent'] == '1') {
                 $sent_to_icon = ' ' . Display::return_icon('email.gif', get_lang('AnnounceSentByEmail'));
             }
             $title = $myrow['title'] . $sent_to_icon;
             $item_visibility = api_get_item_visibility($_course, TOOL_ANNOUNCEMENT, $myrow['id'], $session_id);
             $myrow['visibility'] = $item_visibility;
             // the styles
             if ($myrow['visibility'] == '0') {
                 $style = 'invisible';
             } else {
                 $style = '';
             }
             $html .= '<tr class="announcements-list-line">';
             // show attachment list
             $attachment_list = AnnouncementManager::get_attachment($myrow['id']);
             $attachment_icon = '';
             if (count($attachment_list) > 0) {
                 $attachment_icon = ' ' . Display::return_icon('attachment.gif', get_lang('Attachment'));
             }
             /* TITLE */
             $user_info = api_get_user_info($myrow['insert_user_id']);
             $username = sprintf(get_lang("LoginX"), $user_info['username']);
             $username_span = Display::tag('span', api_get_person_name($user_info['firstName'], $user_info['lastName']), array('title' => $username));
             $title = Display::url($title . $attachment_icon, api_get_self() . '?' . api_get_cidreq() . '&action=view&id=' . $myrow['id']);
             $html .= Display::tag('td', Security::remove_XSS($title), array('class' => 'announcements-list-line-title ' . $style));
             $html .= Display::tag('td', $username_span, array('class' => 'announcements-list-line-by-user'));
             $html .= Display::tag('td', api_convert_and_format_date($myrow['insert_date'], DATE_TIME_FORMAT_LONG), array('class' => 'announcements-list-line-datetime'));
             // we can edit if : we are the teacher OR the element belongs to
             // the session we are coaching OR the option to allow users to edit is on
             if (api_is_allowed_to_edit(false, true) or api_is_course_coach() && api_is_element_in_the_session(TOOL_ANNOUNCEMENT, $myrow['id']) or api_get_course_setting('allow_user_edit_announcement') && !api_is_anonymous()) {
                 $modify_icons = "<a href=\"" . api_get_self() . "?" . api_get_cidreq() . "&action=modify&id=" . $myrow['id'] . "\">" . Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_SMALL) . "</a>";
                 if ($myrow['visibility'] == 1) {
                     $image_visibility = "visible";
                     $alt_visibility = get_lang('Hide');
                 } else {
                     $image_visibility = "invisible";
                     $alt_visibility = get_lang('Visible');
                 }
                 $modify_icons .= "<a href=\"" . api_get_self() . "?" . api_get_cidreq() . "&origin=" . $origin . "&action=showhide&id=" . $myrow['id'] . "&sec_token=" . $stok . "\">" . Display::return_icon($image_visibility . '.png', $alt_visibility, '', ICON_SIZE_SMALL) . "</a>";
                 // DISPLAY MOVE UP COMMAND only if it is not the top announcement
                 if ($iterator != 1) {
                     $modify_icons .= "<a href=\"" . api_get_self() . "?" . api_get_cidreq() . "&action=move&up=" . $myrow["id"] . "&sec_token=" . $stok . "\">" . Display::return_icon('up.gif', get_lang('Up')) . "</a>";
                 } else {
                     $modify_icons .= Display::return_icon('up_na.gif', get_lang('Up'));
                 }
                 if ($iterator < $bottomAnnouncement) {
                     $modify_icons .= "<a href=\"" . api_get_self() . "?" . api_get_cidreq() . "&action=move&down=" . $myrow["id"] . "&sec_token=" . $stok . "\">" . Display::return_icon('down.gif', get_lang('Down')) . "</a>";
                 } else {
                     $modify_icons .= Display::return_icon('down_na.gif', get_lang('Down'));
                 }
                 if (api_is_allowed_to_edit(false, true)) {
                     $modify_icons .= "<a href=\"" . api_get_self() . "?" . api_get_cidreq() . "&action=delete&id=" . $myrow['id'] . "&sec_token=" . $stok . "\" onclick=\"javascript:if(!confirm('" . addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES, api_get_system_encoding())) . "')) return false;\">" . Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL) . "</a>";
                 }
                 $iterator++;
                 $html .= Display::tag('td', $modify_icons, array('class' => 'announcements-list-line-actions'));
             }
             $html .= "</tr>";
         }
         $displayed[] = $myrow['id'];
     }
     $html .= "</table>";
     return $html;
 }
Example #17
0
            oHidden.value = CKEDITOR.instances[oHidden.name].getData();
        } else {
            oHidden.value = $("textarea[name='" + oHidden.name + "']").val();
        }
		f.appendChild(oHidden);
	}
}
</script>
<?php 
$show_results = true;
$show_only_total_score = false;
// Avoiding the "Score 0/0" message  when the exe_id is not set
if (!empty($track_exercise_info)) {
    // if the results_disabled of the Quiz is 1 when block the script
    $result_disabled = $track_exercise_info['results_disabled'];
    if (!(api_is_platform_admin() || api_is_course_admin() || api_is_course_coach())) {
        if ($result_disabled == 1) {
            $show_results = false;
            if ($origin != 'learnpath') {
                echo '<table width="100%" border="0" cellspacing="0" cellpadding="0">
                      <tr>
                        <td colspan="2">';
                Display::display_warning_message(get_lang('ThankYouForPassingTheTest') . '<br /><br /><a href="exercise.php">' . get_lang('BackToExercisesList') . '</a>', false);
                echo '</td>
                </tr>
                </table>';
            }
        } elseif ($result_disabled == 2) {
            $show_results = false;
            $show_only_total_score = true;
            if ($origin != 'learnpath') {
Example #18
0
 $user_info = api_get_user_info($myrow['insert_user_id']);
 $username = sprintf(get_lang("LoginX"), $user_info['username']);
 $username_span = Display::tag('span', api_get_person_name($user_info['firstName'], $user_info['lastName']), array('title' => $username));
 echo Display::tag('td', $username_span, array('class' => 'announcements-list-line-by-user'));
 $sent_to_list = array();
 $sent_to_list = AnnouncementManager::sent_to('announcement', $myrow['id']);
 $sent_to_form = AnnouncementManager::sent_to_form($sent_to_list);
 echo '<td class="announcements-list-line-by-user">' . substr($sent_to_form, 0, 45) . ' ';
 if (strlen($sent_to_form) > 45) {
     echo '...';
 }
 '</td>';
 echo Display::tag('td', api_convert_and_format_date($myrow['insert_date'], DATE_TIME_FORMAT_SHORT), array('class' => 'announcements-list-line-datetime'));
 // we can edit if : we are the teacher OR the element belongs to the session we are coaching OR the option to allow users to edit is on
 $modify_icons = '';
 if (api_is_allowed_to_edit(false, true) or api_is_course_coach() && api_is_element_in_the_session(TOOL_ANNOUNCEMENT, $myrow['id']) or api_get_course_setting('allow_user_edit_announcement') && !api_is_anonymous()) {
     $modify_icons = "<a href=\"" . api_get_self() . "?" . api_get_cidreq() . "&action=modify&id=" . $myrow['id'] . "\">" . Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_SMALL) . "</a>";
     if ($myrow['visibility'] == 1) {
         $image_visibility = "visible";
         $alt_visibility = get_lang('Hide');
     } else {
         $image_visibility = "invisible";
         $alt_visibility = get_lang('Visible');
     }
     $modify_icons .= "<a href=\"" . api_get_self() . "?" . api_get_cidreq() . "&origin=" . $origin . "&action=showhide&id=" . $myrow['id'] . "&sec_token=" . $stok . "\">" . Display::return_icon($image_visibility . '.png', $alt_visibility, '', ICON_SIZE_SMALL) . "</a>";
     // DISPLAY MOVE UP COMMAND only if it is not the top announcement
     if ($iterator != 1) {
         $modify_icons .= "<a href=\"" . api_get_self() . "?" . api_get_cidreq() . "&up=" . $myrow["id"] . "&sec_token=" . $stok . "\">" . Display::return_icon('up.gif', get_lang('Up')) . "</a>";
     } else {
         $modify_icons .= Display::return_icon('up_na.gif', get_lang('Up'));
     }
Example #19
0
require_once 'survey.lib.php';

/** @todo this has to be moved to a more appropriate place (after the display_header of the code)*/
// Coach can't view this page
$extend_rights_for_coachs = api_get_setting('extend_rights_for_coach_on_survey');
$isDrhOfCourse = CourseManager::isUserSubscribedInCourseAsDrh(
	api_get_user_id(),
	api_get_course_info()
);

if ($isDrhOfCourse) {
    header('Location: '.api_get_path(WEB_CODE_PATH).'survey/survey_list.php?'.api_get_cidreq());
    exit;
}
if (!api_is_allowed_to_edit(false, true) ||
    (api_is_course_coach() && $extend_rights_for_coachs == 'false')
) {
	Display :: display_header(get_lang('ToolSurvey'));
	Display :: display_error_message(get_lang('NotAllowed'), false);
	Display :: display_footer();
	exit;
}

// Database table definitions
$table_survey 					= Database :: get_course_table(TABLE_SURVEY);
$table_survey_question 			= Database :: get_course_table(TABLE_SURVEY_QUESTION);
$table_survey_question_option 	= Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION);
$table_survey_question_group    = Database :: get_course_table(TABLE_SURVEY_QUESTION_GROUP);
$table_course 					= Database :: get_main_table(TABLE_MAIN_COURSE);
$table_user 					= Database :: get_main_table(TABLE_MAIN_USER);
    $(document).ready(function () {
        setFocus();
    });
</script>';

// Database table definitions
$table_survey = Database :: get_course_table(TABLE_SURVEY);
$table_user = Database :: get_main_table(TABLE_MAIN_USER);
$table_course = Database :: get_main_table(TABLE_MAIN_COURSE);
$table_gradebook_link = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINK);

/** @todo this has to be moved to a more appropriate place (after the display_header of the code) */
// If user is not teacher or if he's a coach trying to access an element out of his session
if (!api_is_allowed_to_edit()) {
    if (!api_is_course_coach() ||
        (!empty($_GET['survey_id']) &&
        !api_is_element_in_the_session(TOOL_SURVEY, $_GET['survey_id']))
    ) {
        api_not_allowed(true);
        exit;
    }
}

// Getting the survey information
$survey_id = isset($_GET['survey_id']) ? intval($_GET['survey_id']) : null;
$survey_data = survey_manager::get_survey($survey_id);

// Additional information
$course_id = api_get_course_id();
$session_id = api_get_session_id();
Example #21
0
     break;
 case 'delete_attachment':
     $id = $_GET['id_attach'];
     if (api_is_allowed_to_edit()) {
         AnnouncementManager::delete_announcement_attachment_file($id);
     }
     header('Location: ' . $homeUrl);
     exit;
     break;
 case 'showhide':
     if (!isset($_GET['isStudentView']) || $_GET['isStudentView'] != 'false') {
         if (isset($_GET['id']) && $_GET['id']) {
             if ($sessionId != 0 && api_is_allowed_to_session_edit(false, true) == false) {
                 api_not_allowed();
             }
             if (!api_is_course_coach() || api_is_element_in_the_session(TOOL_ANNOUNCEMENT, $_GET['id'])) {
                 AnnouncementManager::change_visibility_announcement($_course, $_GET['id']);
                 Display::addFlash(Display::return_message(get_lang('VisibilityChanged')));
                 header('Location: ' . $homeUrl);
                 exit;
             }
         }
     }
     break;
 case 'add':
 case 'modify':
     if ($sessionId != 0 && api_is_allowed_to_session_edit(false, true) == false) {
         api_not_allowed(true);
     }
     // DISPLAY ADD ANNOUNCEMENT COMMAND
     $id = isset($_GET['id']) ? intval($_GET['id']) : 0;
 } else {
     $post_image = Display::return_icon('forumpost.gif');
 }
 if ($row['post_notification'] == '1' && $row['poster_id'] == $_user['user_id']) {
     $post_image .= Display::return_icon('forumnotification.gif', get_lang('YouWillBeNotified'));
 }
 // The post title
 // The check if there is an attachment
 $attachment_list = getAllAttachment($row['post_id']);
 if (!empty($attachment_list) && is_array($attachment_list)) {
     foreach ($attachment_list as $attachment) {
         $realname = $attachment['path'];
         $user_filename = $attachment['filename'];
         $html .= Display::return_icon('attachment.gif', get_lang('Attachment'));
         $html .= '<a href="download.php?file=' . $realname . '"> ' . $user_filename . ' </a>';
         if ($current_forum['allow_edit'] == 1 && $row['user_id'] == $_user['user_id'] || api_is_allowed_to_edit(false, true) && !(api_is_course_coach() && $current_forum['session_id'] != $sessionId)) {
             $html .= '&nbsp;&nbsp;<a href="' . api_get_self() . '?' . api_get_cidreq() . '&origin=' . Security::remove_XSS($_GET['origin']) . '&action=delete_attach&id_attach=' . $attachment['iid'] . '&forum=' . $clean_forum_id . '&thread=' . $clean_thread_id . '" onclick="javascript:if(!confirm(\'' . addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES)) . '\')) return false;">' . Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL) . '</a><br />';
         }
         $html .= '<span class="forum_attach_comment" >' . $attachment['comment'] . '</span>';
     }
 }
 $html .= '</div>';
 $html .= '<div class="col-md-5 text-right">';
 $html .= $buttonReply . ' ' . $buttonQuote;
 $html .= '</div>';
 $html .= '</div>';
 // The post has been displayed => it can be removed from the what's new array
 unset($whatsnew_post_info[$current_forum['forum_id']][$current_thread['thread_id']][$row['post_id']]);
 unset($whatsnew_post_info[$current_forum['forum_id']][$current_thread['thread_id']]);
 unset($_SESSION['whatsnew_post_info'][$current_forum['forum_id']][$current_thread['thread_id']][$row['post_id']]);
 unset($_SESSION['whatsnew_post_info'][$current_forum['forum_id']][$current_thread['thread_id']]);
Example #23
0
                 $last_post_info_username = sprintf(get_lang('LoginX'), $last_post_row['username']);
                 $name = api_get_person_name($last_post_row['firstname'], $last_post_row['lastname']);
                 $last_post = api_convert_and_format_date($last_post_row['post_date']).' '.get_lang('By').' '.Display::tag('span', $name, array("title"=>api_htmlentities($last_post_info_username, ENT_QUOTES)));
             }*/
 echo '<td>' . $last_post . '</td>';
 echo '<td class="td_actions">';
 // Get attachment id.
 if (isset($row['post_id'])) {
     $attachment_list = get_attachment($row['post_id']);
 }
 $id_attach = !empty($attachment_list) ? $attachment_list['id'] : '';
 $sql_post_id = "SELECT post_id FROM {$table_posts} WHERE c_id = {$course_id} AND post_title='" . Database::escape_string($row['thread_title']) . "'";
 $result_post_id = Database::query($sql_post_id);
 $row_post_id = Database::fetch_array($result_post_id);
 if ($origin != 'learnpath') {
     if (api_is_allowed_to_edit(false, true) && !(api_is_course_coach() && $current_forum['session_id'] != $_SESSION['id_session'])) {
         echo '<a href="' . $forumUrl . 'editpost.php?' . api_get_cidreq() . '&amp;forum=' . Security::remove_XSS($my_forum) . '&amp;thread=' . Security::remove_XSS($row['thread_id']) . '&amp;post=' . $row_post_id['post_id'] . '&id_attach=' . $id_attach . '">' . Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL) . '</a>';
         if (api_resource_is_locked_by_gradebook($row['thread_id'], LINK_FORUM_THREAD)) {
             echo Display::return_icon('delete_na.png', get_lang('ResourceLockedByGradebook'), array(), ICON_SIZE_SMALL);
         } else {
             echo '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&amp;forum=' . Security::remove_XSS($my_forum) . '&amp;action=delete&amp;content=thread&id=' . $row['thread_id'] . $origin_string . "\" onclick=\"javascript:if(!confirm('" . addslashes(api_htmlentities(get_lang('DeleteCompleteThread'), ENT_QUOTES)) . "')) return false;\">" . Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL) . '</a>';
         }
         display_visible_invisible_icon('thread', $row['thread_id'], $row['visibility'], array('forum' => $my_forum, 'origin' => $origin, 'gidReq' => $groupId));
         display_lock_unlock_icon('thread', $row['thread_id'], $row['locked'], array('forum' => $my_forum, 'origin' => $origin, 'gidReq' => api_get_group_id()));
         echo '<a href="viewforum.php?' . api_get_cidreq() . '&amp;forum=' . Security::remove_XSS($my_forum) . '&amp;action=move&thread=' . $row['thread_id'] . $origin_string . '">' . Display::return_icon('move.png', get_lang('MoveThread'), array(), ICON_SIZE_SMALL) . '</a>';
     }
 }
 $iconnotify = 'send_mail.gif';
 if (is_array(isset($_SESSION['forum_notification']['thread']) ? $_SESSION['forum_notification']['thread'] : null)) {
     if (in_array($row['thread_id'], $_SESSION['forum_notification']['thread'])) {
         $iconnotify = 'send_mail_checked.gif';
Example #24
0
	</script>
';
}
$controller = new IndexManager(get_lang('MyCourses'));
// Main courses and session list
//$courseAndSessions = $controller->returnCoursesAndSessions($userId);
// Main courses and session list
if (isset($_COOKIE['defaultMyCourseView' . $userId]) && $_COOKIE['defaultMyCourseView' . $userId] == IndexManager::VIEW_BY_SESSION && $displayMyCourseViewBySessionLink) {
    $courseAndSessions = $controller->returnCoursesAndSessionsViewBySession($userId);
    IndexManager::setDefaultMyCourseView(IndexManager::VIEW_BY_SESSION, $userId);
} else {
    $courseAndSessions = $controller->returnCoursesAndSessions($userId);
    IndexManager::setDefaultMyCourseView(IndexManager::VIEW_BY_DEFAULT, $userId);
}
// if teacher, session coach or admin, display the button to change te course view
if ($displayMyCourseViewBySessionLink && (api_is_drh() || api_is_course_coach() || api_is_platform_admin() || api_is_session_admin() || api_is_teacher())) {
    $courseAndSessions['html'] = "<div class='view-by-session-link'>\n\t\t<div class='btn-group pull-right'>\n\t\t<a class='btn btn-default' id='viewByDefault' href='user_portal.php' onclick='changeMyCoursesView(\"" . IndexManager::VIEW_BY_DEFAULT . "\")'>\n\t\t" . get_lang('MyCoursesDefaultView') . "\n\t\t</a>\n\t\t<a class='btn btn-default' id='viewBySession' href='user_portal.php' onclick='changeMyCoursesView(\"" . IndexManager::VIEW_BY_SESSION . "\")'>\n\t\t" . get_lang('MyCoursesSessionView') . "\n\t\t</a>\n\t\t</div>\n\t</div><br /><br />\n\t" . $courseAndSessions['html'];
}
// Check if a user is enrolled only in one course for going directly to the course after the login.
if (api_get_setting('go_to_course_after_login') == 'true') {
    $count_of_sessions = $courseAndSessions['session_count'];
    $count_of_courses_no_sessions = $courseAndSessions['course_count'];
    // User is subscribe in 1 session and 0 courses.
    if ($count_of_sessions == 1 && $count_of_courses_no_sessions == 0) {
        $sessions = SessionManager::get_sessions_by_user($userId);
        if (isset($sessions[0])) {
            $sessionInfo = $sessions[0];
            // Session only has 1 course.
            if (isset($sessionInfo['courses']) && count($sessionInfo['courses']) == 1) {
                $courseCode = $sessionInfo['courses'][0]['code'];
                $courseInfo = api_get_course_info_by_id($sessionInfo['courses'][0]['real_id']);
Example #25
0
         }
     }
     display_agenda_items();
     break;
 case "showhide":
     $id = (int) $_GET['id'];
     if (!(api_is_course_coach() && !api_is_element_in_the_session(TOOL_AGENDA, $id))) {
         // a coach can only delete an element belonging to his session
         showhide_agenda_item($id);
     }
     display_agenda_items();
     break;
 case "announce":
     //copying the agenda item into an announcement
     $id = (int) $_GET['id'];
     if (!(api_is_course_coach() && !api_is_element_in_the_session(TOOL_AGENDA, $id))) {
         // a coach can only delete an element belonging to his session
         $ann_id = store_agenda_item_as_announcement($id);
         $tool_group_link = isset($_SESSION['toolgroup']) ? '&toolgroup=' . $_SESSION['toolgroup'] : '';
         echo '<br />';
         Display::display_normal_message(get_lang('CopiedAsAnnouncement') . '<a href="../announcements/announcements.php?id=' . $ann_id . $tool_group_link . '">' . get_lang('NewAnnouncement') . '</a>', false);
     }
     display_agenda_items();
     break;
 case "delete_attach":
     //delete attachment file
     $id_attach = (int) $_GET['id_attach'];
     if (!empty($id_attach)) {
         delete_attachment_file($id_attach);
     }
     display_agenda_items();
    }
    // The post title
    echo "<td class=\"{$titleclass}\">" . prepare4display($post['post_title']) . "</td>";
    echo "</tr>";
    // The post message
    echo "<tr>";
    echo "<td class=\"{$messageclass}\">" . prepare4display($post['post_text']) . "</td>";
    echo "</tr>";
    // The check if there is an attachment
    $attachment_list = get_attachment($post['post_id']);
    if (!empty($attachment_list)) {
        echo '<tr><td height="50%">';
        $realname = $attachment_list['path'];
        $user_filename = $attachment_list['filename'];
        echo Display::return_icon('attachment.gif', get_lang('Attachment'));
        echo '<a href="download.php?file=';
        echo $realname;
        echo ' "> ' . $user_filename . ' </a>';
        echo '<span class="forum_attach_comment" >' . $attachment_list['comment'] . '</span>';
        if ($current_forum['allow_edit'] == 1 and $post['user_id'] == $_user['user_id'] or api_is_allowed_to_edit(false, true) && !(api_is_course_coach() && $current_forum['session_id'] != $_SESSION['id_session'])) {
            echo '&nbsp;&nbsp;<a href="' . api_get_self() . '?' . api_get_cidreq() . '&amp;origin=' . Security::remove_XSS($_GET['origin']) . '&amp;action=delete_attach&amp;id_attach=' . $attachment_list['id'] . '&amp;forum=' . $clean_forum_id . '&amp;thread=' . $clean_thread_id . '" onclick="javascript:if(!confirm(\'' . addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES)) . '\')) return false;">' . Display::return_icon('delete.gif', get_lang('Delete')) . '</a><br />';
        }
        echo '</td></tr>';
    }
    // The post has been displayed => it can be removed from the what's new array
    unset($whatsnew_post_info[$current_forum['forum_id']][$current_thread['thread_id']][$row['post_id']]);
    unset($_SESSION['whatsnew_post_info'][$current_forum['forum_id']][$current_thread['thread_id']][$row['post_id']]);
    echo "</table>";
    echo "</div>";
    $count++;
}
        Database::query($sql);
        if ($origin == 'tracking_course') {
            //Redirect to the course detail in lp
            header('location: exercise.php?course=' . Security::remove_XSS($_GET['course']));
            exit;
        } else {
            //Redirect to the reporting
            header('location: ../mySpace/myStudents.php?origin=' . $origin . '&student=' . $student_id . '&details=true&course=' . $course_id . '&session_id=' . $session_id);
            exit;
        }
    }
}
$actions = null;
if ($is_allowedToEdit && $origin != 'learnpath') {
    // the form
    if (api_is_platform_admin() || api_is_course_admin() || api_is_course_tutor() || api_is_course_coach()) {
        $actions .= '<a href="admin.php?exerciseId=' . intval($_GET['exerciseId']) . '">' . Display::return_icon('back.png', get_lang('GoBackToQuestionList'), '', ICON_SIZE_MEDIUM) . '</a>';
        $actions .= '<a href="live_stats.php?' . api_get_cidreq() . '&exerciseId=' . $exercise_id . '">' . Display::return_icon('activity_monitor.png', get_lang('LiveResults'), '', ICON_SIZE_MEDIUM) . '</a>';
        $actions .= '<a href="stats.php?' . api_get_cidreq() . '&exerciseId=' . $exercise_id . '">' . Display::return_icon('statistics.png', get_lang('ReportByQuestion'), '', ICON_SIZE_MEDIUM) . '</a>';
        $actions .= '<a id="export_opener" href="' . api_get_self() . '?export_report=1&exerciseId=' . intval($_GET['exerciseId']) . '" >' . Display::return_icon('save.png', get_lang('Export'), '', ICON_SIZE_MEDIUM) . '</a>';
        // clean result before a selected date icon
        $actions .= Display::url(Display::return_icon('clean_before_date.png', get_lang('CleanStudentsResultsBeforeDate'), '', ICON_SIZE_MEDIUM), '#', array('onclick' => "javascript:display_date_picker()"));
        // clean result before a selected date datepicker popup
        $actions .= Display::span(Display::input('input', 'datepicker_start', get_lang('SelectADateOnTheCalendar'), array('onmouseover' => 'datepicker_input_mouseover()', 'id' => 'datepicker_start', 'onchange' => 'datepicker_input_changed()', 'readonly' => 'readonly')) . Display::button('delete', get_lang('Delete'), array('onclick' => 'submit_datepicker()')), array('style' => 'display:none', 'id' => 'datepicker_span'));
    }
} else {
    $actions .= '<a href="exercise.php">' . Display::return_icon('back.png', get_lang('GoBackToQuestionList'), '', ICON_SIZE_MEDIUM) . '</a>';
}
//Deleting an attempt
if (($is_allowedToEdit || $is_tutor || api_is_coach()) && isset($_GET['delete']) && $_GET['delete'] == 'delete' && !empty($_GET['did']) && $locked == false) {
    $exe_id = intval($_GET['did']);
Example #28
0
/**
* Displays all the agenda items
* @author Patrick Cool <*****@*****.**>, Ghent University
* @author Yannick Warnier <*****@*****.**> - cleanup
*/
function display_agenda_items()
{
    global $select_month, $select_year;
    global $DaysShort, $DaysLong, $MonthsLong;
    global $is_courseAdmin;
    global $dateFormatLong, $timeNoSecFormat, $charset, $_user, $_course;
    $TABLEAGENDA = Database::get_main_table(TABLE_MAIN_SYSTEM_CALENDAR);
    // getting the group memberships
    //$group_memberships=GroupManager::get_group_ids($_course['dbName'],$_user['user_id']);
    // getting the name of the groups
    //$group_names=get_course_groups();
    /*--------------------------------------------------
    		CONSTRUCT THE SQL STATEMENT
      --------------------------------------------------*/
    $start = 0;
    $stop = 0;
    // this is to make a difference between showing everything (all months) or only the current month)
    // $show_all_current is a part of the sql statement
    if ($_SESSION['show_all_admin'] !== "showall") {
        $show_all_current = " AND MONTH(start_date)={$select_month} AND year(start_date)={$select_year}";
        $start = mktime(0, 0, 0, $select_month, 1, $select_year);
        $stop = 0;
        if (empty($select_year)) {
            $select_year = date('Y');
        }
        if (empty($select_month)) {
            $select_month = date('m');
        }
        if ($select_month == 12) {
            $stop = mktime(0, 0, 0, 1, 1, $select_year + 1) - 1;
        } else {
            $stop = mktime(0, 0, 0, $select_month + 1, 1, $select_year) - 1;
        }
    } else {
        $show_all_current = "";
        $start = time();
        $stop = mktime(0, 0, 0, 1, 1, 2038);
        //by default, set year to maximum for mktime()
    }
    // by default we use the id of the current user. The course administrator can see the agenda of other users by using the user / group filter
    $repeats = array();
    //placeholder for repeated events
    if (api_is_allowed_to_edit() && !api_is_anonymous()) {
        $sql = "SELECT * FROM " . $TABLEAGENDA;
        global $_configuration;
        $current_access_url_id = 1;
        if ($_configuration['multiple_access_urls']) {
            $current_access_url_id = api_get_current_access_url_id();
        }
        $sql .= " WHERE access_url_id = {$current_access_url_id}";
        $sql .= ' ORDER BY start_date ' . $_SESSION['sort'];
        //echo "<pre>".$sql."</pre>";
        $result = Database::query($sql) or die(Database::error());
        $number_items = Database::num_rows($result);
    } else {
        $number_items = 0;
    }
    /*--------------------------------------------------
    		DISPLAY: NO ITEMS
      --------------------------------------------------*/
    if ($number_items == 0) {
        echo "<table class=\"data_table\" ><tr><td>" . get_lang("NoAgendaItems") . "</td></tr></table>";
    }
    /*--------------------------------------------------
    		DISPLAY: THE ITEMS
      --------------------------------------------------*/
    $month_bar = "";
    $event_list = "";
    $counter = 0;
    $export_icon = 'export.png';
    $export_icon_low = 'export_low_fade.png';
    $export_icon_high = 'export_high_fade.png';
    while ($myrow = Database::fetch_array($result)) {
        $is_repeated = !empty($myrow['parent_event_id']);
        echo '<table class="data_table">';
        $myrow["start_date"] = api_get_local_time($myrow["start_date"]);
        if ($month_bar != api_format_date($myrow["start_date"], "%m%Y")) {
            $month_bar = api_format_date($myrow["start_date"], "%m%Y");
            echo "<tr><td class=\"agenda_month_divider\" colspan=\"3\" valign=\"top\">" . api_format_date($myrow["start_date"], "%B %Y") . "</td></tr>";
        }
        /*--------------------------------------------------
          display: the icon, title, destinees of the item
          -------------------------------------------------*/
        echo '<tr>';
        // 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 "<th>";
        // adding an internal anchor
        echo "<a name=\"" . (int) date("d", strtotime($myrow["start_date"])) . "\"></a>";
        // the icons. If the message is sent to one or more specific users/groups
        // we add the groups icon
        // 2do: if it is sent to groups we display the group icon, if it is sent to a user we show the user icon
        Display::display_icon('platform_event.png', get_lang('GlobalEvent'), '', ICON_SIZE_SMALL);
        /*if ($myrow['to_group_id']!=='0') {
         		echo Display::return_icon('group.gif', get_lang('AllUsersOfThePlatform'));
         	}*/
        echo " " . $myrow['title'] . "";
        echo "</th>";
        // the message has been sent to
        echo "<th>" . get_lang("SentTo") . ": " . get_lang('AllUsersOfThePlatform');
        //$sent_to=sent_to(TOOL_CALENDAR_EVENT, $myrow["ref"]);
        //$sent_to_form=sent_to_form($sent_to);
        //	echo $sent_to_form;
        echo "</th>";
        if (!$is_repeated && (api_is_allowed_to_edit(false, true) or api_get_course_setting('allow_user_edit_agenda') && !api_is_anonymous())) {
            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
                echo '<th>' . get_lang('Actions');
                echo '</th></tr>';
            }
        }
        // display: the title
        echo "<tr class='row_odd'>";
        echo "<td>" . get_lang("StartTimeWindow") . ": ";
        echo api_format_date($myrow["start_date"], DATE_TIME_FORMAT_LONG);
        echo "</td>";
        echo "<td>";
        if ($myrow["end_date"] != "0000-00-00 00:00:00") {
            $myrow["end_date"] = api_get_local_time($myrow["end_date"]);
            echo get_lang("EndTimeWindow") . ": ";
            echo api_format_date($myrow["end_date"], DATE_TIME_FORMAT_LONG);
        }
        echo "</td>";
        if (!$is_repeated && (api_is_allowed_to_edit(false, true) or api_get_course_setting('allow_user_edit_agenda') && !api_is_anonymous())) {
            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
                $mylink = api_get_self() . '?' . api_get_cidreq() . '&amp;origin=' . Security::remove_XSS($_GET['origin']) . '&amp;id=' . $myrow['id'];
                echo '<td align="center">';
                // edit
                echo '<a href="' . $mylink . '&amp;action=edit&amp;title="' . get_lang("ModifyCalendarItem") . '">';
                echo Display::return_icon('edit.gif', get_lang('ModifyCalendarItem')) . "</a>";
                echo "<a href=\"" . $mylink . "&amp;action=delete\" onclick=\"javascript:if(!confirm('" . addslashes(api_htmlentities(get_lang("ConfirmYourChoice"), ENT_QUOTES, $charset)) . "')) return false;\"  title=\"" . get_lang("Delete") . "\"> ";
                echo Display::return_icon('delete.gif', get_lang('Delete')) . "</a>";
            }
            if (!$is_repeated && (api_is_allowed_to_edit(false, true) or api_get_course_setting('allow_user_edit_agenda') && !api_is_anonymous())) {
                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
                    $td_colspan = '<td colspan="3">';
                } else {
                    $td_colspan = '<td colspan="2">';
                }
            } else {
                $td_colspan = '<td colspan="2">';
            }
            $mylink = 'calendar_ical_export.php?' . api_get_cidreq() . '&amp;type=course&amp;id=' . $myrow['id'];
            echo '<a class="ical_export" href="' . $mylink . '&amp;class=confidential" title="' . get_lang('ExportiCalConfidential') . '">' . Display::return_icon($export_icon_high, get_lang('ExportiCalConfidential')) . '</a> ';
            echo '<a class="ical_export" href="' . $mylink . '&amp;class=private" title="' . get_lang('ExportiCalPrivate') . '">' . Display::return_icon($export_icon_low, get_lang('ExportiCalPrivate')) . '</a> ';
            echo '<a class="ical_export" href="' . $mylink . '&amp;class=public" title="' . get_lang('ExportiCalPublic') . '">' . Display::return_icon($export_icon, get_lang('ExportiCalPublic')) . '</a> ';
            echo '<a href="#" onclick="javascript:win_print=window.open(\'calendar_view_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('print.gif', get_lang('Print')) . '</a>&nbsp;';
            echo '</td>';
            echo '</tr>';
        }
        /*--------------------------------------------------
        		display: the content
           --------------------------------------------------*/
        $content = $myrow['content'];
        $content = make_clickable($content);
        echo "<tr class='row_even'>";
        echo "<td colspan='3'>";
        echo $content;
        // show attachment list
        if (!empty($attachment_list)) {
            $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 . '';
            echo ' "> ' . $user_filename . ' </a>';
            echo '<span class="forum_attach_comment" >' . $attachment_list['comment'] . '</span>';
            if (api_is_allowed_to_edit()) {
                echo '&nbsp;&nbsp;<a href="' . api_get_self() . '?' . api_get_cidreq() . '&amp;origin=' . Security::remove_XSS($_GET['origin']) . '&amp;action=delete_attach&amp;id_attach=' . $attachment_list['id'] . '" onclick="javascript:if(!confirm(\'' . addslashes(api_htmlentities(get_lang("ConfirmYourChoice"), ENT_QUOTES, $charset)) . '\')) return false;">' . Display::return_icon('delete.gif', get_lang('Delete')) . '</a><br />';
            }
        }
        echo '</td></tr>';
        /*--------------------------------------------------
             			display: the added resources
                 --------------------------------------------------
            	if (check_added_resources("Agenda", $myrow["id"]))
            	{
        
            		echo '<tr>';
            		echo '<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>";
            	}*/
        $event_list .= $myrow['id'] . ',';
        $counter++;
        /*--------------------------------------------------
        	 display: jump-to-top icon
             --------------------------------------------------*/
        echo '<tr>';
        echo '<td colspan="3">';
        if ($is_repeated) {
            echo get_lang('RepeatedEvent'), '<a href="', api_get_self(), '?', api_get_cidreq, '&amp;agenda_id=', $myrow['parent_event_id'], '" alt="', get_lang('RepeatedEventViewOriginalEvent'), '">', get_lang('RepeatedEventViewOriginalEvent'), '</a>';
        }
        echo "<a href=\"#top\">" . Display::return_icon('top.gif', get_lang('Top')) . "</a></td></tr>";
        echo "</table><br /><br />";
    }
    // end while ($myrow=Database::fetch_array($result))
    if (!empty($event_list)) {
        $event_list = substr($event_list, 0, -1);
    } else {
        $event_list = '0';
    }
    echo "<form name=\"event_list_form\"><input type=\"hidden\" name=\"event_list\" value=\"{$event_list}\" /></form>";
    // closing the layout table
    echo "</td>", "</tr>", "</table>";
}