/**
  * Displays messages of a group with nested view
  * @param $group_id
  * @param $topic_id
  * @param $is_member
  * @param $message_id
  * @return string
  */
 public static function display_message_for_group($group_id, $topic_id, $is_member, $message_id)
 {
     global $my_group_role;
     $main_message = self::get_message_by_id($topic_id);
     if (empty($main_message)) {
         return false;
     }
     $rows = self::get_messages_by_group_by_message($group_id, $topic_id);
     $rows = self::calculate_children($rows, $topic_id);
     $current_user_id = api_get_user_id();
     $items_per_page = 50;
     $query_vars = array('id' => $group_id, 'topic_id' => $topic_id, 'topics_page_nr' => 0);
     // Main message
     $links = '';
     $main_content = '';
     $items_page_nr = null;
     $html = '';
     $delete_button = '';
     if (api_is_platform_admin()) {
         $delete_button = Display::url(Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL), 'group_topics.php?action=delete&id=' . $group_id . '&topic_id=' . $topic_id);
     }
     $html .= Display::page_subheader(Security::remove_XSS($main_message['title'] . $delete_button, STUDENT, true));
     $user_sender_info = api_get_user_info($main_message['user_sender_id']);
     $files_attachments = self::get_links_message_attachment_files($main_message['id']);
     $name = $user_sender_info['complete_name'];
     $topic_page_nr = isset($_GET['topics_page_nr']) ? intval($_GET['topics_page_nr']) : null;
     $links .= '<div id="message-reply-link">';
     if ($my_group_role == GROUP_USER_PERMISSION_ADMIN || $my_group_role == GROUP_USER_PERMISSION_MODERATOR || $main_message['user_sender_id'] == $current_user_id) {
         $urlEdit = api_get_path(WEB_CODE_PATH);
         $urlEdit .= 'social/message_for_group_form.inc.php?';
         $urlEdit .= http_build_query(['user_friend' => $current_user_id, 'group_id' => $group_id, 'message_id' => $main_message['id'], 'action' => 'edit_message_group', 'anchor_topic' => 'topic_' . $main_message['id'], 'topics_page_nr' => $topic_page_nr, 'items_page_nr' => $items_page_nr, 'topic_id' => $main_message['id']]);
         $links .= Display::url(Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL), $urlEdit, ['class' => 'ajax btn btn-default', 'title' => get_lang('Edit'), 'data-title' => get_lang('Edit'), 'data-size' => 'lg']);
     }
     $urlReply = api_get_path(WEB_CODE_PATH);
     $urlReply .= 'social/message_for_group_form.inc.php?';
     $urlReply .= http_build_query(['user_friend' => api_get_user_id(), 'group_id' => $group_id, 'message_id' => $main_message['id'], 'action' => 'reply_message_group', 'anchor_topic' => 'topic_' . $main_message['id'], 'topics_page_nr' => $topic_page_nr, 'topic_id' => $main_message['id']]);
     $links .= Display::url(Display::return_icon('talk.png', get_lang('Reply')), $urlReply, ['class' => 'ajax btn btn-default', 'title' => get_lang('Reply'), 'data-title' => get_lang('Reply'), 'data-size' => 'lg']);
     $links .= '</div>';
     $userPicture = $user_sender_info['avatar'];
     $main_content .= '<div class="message-group-author">
                      <img src="' . $userPicture . '" alt="' . $name . '"  width="32" height="32" title="' . $name . '" /></div>';
     $user_link = '<a href="' . api_get_path(WEB_PATH) . 'main/social/profile.php?u=' . $main_message['user_sender_id'] . '">' . $name . '&nbsp;</a>';
     $date = '';
     if ($main_message['send_date'] != $main_message['update_date']) {
         if (!empty($main_message['update_date']) && $main_message['update_date'] != '0000-00-00 00:00:00') {
             $date = '<div class="message-group-date"> ' . get_lang('LastUpdate') . ' ' . date_to_str_ago($main_message['update_date']) . '</div>';
         }
     } else {
         $date = '<div class="message-group-date"> ' . get_lang('Created') . ' ' . date_to_str_ago($main_message['send_date']) . '</div>';
     }
     $attachment = '<div class="message-attach">' . (!empty($files_attachments) ? implode('<br />', $files_attachments) : '') . '</div>';
     $main_content .= '<div class="message-group-content">' . $links . $user_link . ' ' . $date . $main_message['content'] . $attachment . '</div>';
     $main_content = Security::remove_XSS($main_content, STUDENT, true);
     $html .= Display::div(Display::div(Display::div($main_content, array('class' => 'group_social_sub_item', 'style' => 'background-color:#fff;')), array('class' => 'group_social_item')), array('class' => 'group_social_grid'));
     $topic_id = $main_message['id'];
     if (is_array($rows) && count($rows) > 0) {
         $topics = $rows;
         $array_html_items = array();
         foreach ($topics as $index => $topic) {
             if (empty($topic['id'])) {
                 continue;
             }
             $items_page_nr = isset($_GET['items_' . $topic['id'] . '_page_nr']) ? intval($_GET['items_' . $topic['id'] . '_page_nr']) : null;
             $links = '';
             $html_items = '';
             $user_sender_info = api_get_user_info($topic['user_sender_id']);
             $files_attachments = self::get_links_message_attachment_files($topic['id']);
             $name = $user_sender_info['complete_name'];
             $links .= '<div id="message-reply-link">';
             if ($my_group_role == GROUP_USER_PERMISSION_ADMIN || $my_group_role == GROUP_USER_PERMISSION_MODERATOR || $topic['user_sender_id'] == $current_user_id) {
                 $links .= '<a href="' . api_get_path(WEB_CODE_PATH) . 'social/message_for_group_form.inc.php?height=400&width=800&&user_friend=' . $current_user_id . '&group_id=' . $group_id . '&message_id=' . $topic['id'] . '&action=edit_message_group&anchor_topic=topic_' . $topic_id . '&topics_page_nr=' . $topic_page_nr . '&items_page_nr=' . $items_page_nr . '&topic_id=' . $topic_id . '" class="ajax btn" data-size="lg" data-title="' . get_lang('Edit') . '" title="' . get_lang('Edit') . '">' . Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL) . '</a>';
             }
             $links .= '&nbsp;&nbsp;<a href="' . api_get_path(WEB_CODE_PATH) . 'social/message_for_group_form.inc.php?height=400&width=800&&user_friend=' . api_get_user_id() . '&group_id=' . $group_id . '&message_id=' . $topic['id'] . '&action=reply_message_group&anchor_topic=topic_' . $topic_id . '&topics_page_nr=' . $topic_page_nr . '&items_page_nr=' . $items_page_nr . '&topic_id=' . $topic_id . '" class="ajax btn" data-size="lg" data-title="' . get_lang('Reply') . '" title="' . get_lang('Reply') . '">';
             $links .= Display::return_icon('talk.png', get_lang('Reply')) . '</a>';
             $links .= '</div>';
             $userPicture = $user_sender_info['avatar'];
             $html_items .= '<div class="message-group-author"><img src="' . $userPicture . '" alt="' . $name . '"  width="32" height="32" title="' . $name . '" /></div>';
             $user_link = '<a href="' . api_get_path(WEB_PATH) . 'main/social/profile.php?u=' . $topic['user_sender_id'] . '">' . $name . '&nbsp;</a>';
             $date = '';
             if ($topic['send_date'] != $topic['update_date']) {
                 if (!empty($topic['update_date']) && $topic['update_date'] != '0000-00-00 00:00:00') {
                     $date = '<div class="message-group-date"> ' . get_lang('LastUpdate') . ' ' . date_to_str_ago($topic['update_date']) . '</div>';
                 }
             } else {
                 $date = '<div class="message-group-date"> ' . get_lang('Created') . ' ' . date_to_str_ago($topic['send_date']) . '</div>';
             }
             $attachment = '<div class="message-attach">' . (!empty($files_attachments) ? implode('<br />', $files_attachments) : '') . '</div>';
             $html_items .= '<div class="message-group-content">' . $links . $user_link . ' ' . $date . Security::remove_XSS($topic['content'], STUDENT, true) . $attachment . '</div>';
             $base_padding = 20;
             if ($topic['indent_cnt'] == 0) {
                 $indent = $base_padding;
             } else {
                 $indent = intval($topic['indent_cnt']) * $base_padding + $base_padding;
             }
             $class = 'group_social_sub_item';
             if (isset($message_id) && $message_id == $topic['id']) {
                 $class .= ' group_social_sub_item_highlight';
             }
             $html_items = Display::div($html_items, array('class' => $class, 'id' => 'msg_' . $topic['id']));
             $html_items = Display::div($html_items, array('class' => '', 'style' => 'margin-left:' . $indent . 'px'));
             $array_html_items[] = array($html_items);
         }
         // grids for items with paginations
         $options = array('hide_navigation' => false, 'per_page' => $items_per_page);
         $visibility = array(true, true, true, false);
         $style_class = array('item' => array('class' => 'group_social_item'), 'main' => array('class' => 'group_social_grid'));
         if (!empty($array_html_items)) {
             $html .= Display::return_sortable_grid('items_' . $topic['id'], array(), $array_html_items, $options, $query_vars, null, $visibility, false, $style_class);
         }
     }
     return $html;
 }
    static function display_notes()
    {

        global $_user;
        if (!$_GET['direction']) {
            $sort_direction = 'ASC';
            $link_sort_direction = 'DESC';
        } elseif ($_GET['direction'] == 'ASC') {
            $sort_direction = 'ASC';
            $link_sort_direction = 'DESC';
        } else {
            $sort_direction = 'DESC';
            $link_sort_direction = 'ASC';
        }

        // action links
        echo '<div class="actions">';
        if (!api_is_anonymous()) {
            if (api_get_session_id() == 0)
                echo '<a href="index.php?' . api_get_cidreq() . '&amp;action=addnote">' . Display::return_icon('new_note.png', get_lang('NoteAddNew'), '', '32') . '</a>';
            elseif (api_is_allowed_to_session_edit(false, true)) {
                echo '<a href="index.php?' . api_get_cidreq() . '&amp;action=addnote">' . Display::return_icon('new_note.png', get_lang('NoteAddNew'), '', '32') . '</a>';
            }
        } else {
            echo '<a href="javascript:void(0)">' . Display::return_icon('new_note.png', get_lang('NoteAddNew'), '', '32') . '</a>';
        }

        echo '<a href="index.php?' . api_get_cidreq() . '&amp;action=changeview&amp;view=creation_date&amp;direction=' . $link_sort_direction . '">' . Display::return_icon('notes_order_by_date_new.png', get_lang('OrderByCreationDate'), '', '32') . '</a>';
        echo '<a href="index.php?' . api_get_cidreq() . '&amp;action=changeview&amp;view=update_date&amp;direction=' . $link_sort_direction . '">' . Display::return_icon('notes_order_by_date_mod.png', get_lang('OrderByModificationDate'), '', '32') . '</a>';
        echo '<a href="index.php?' . api_get_cidreq() . '&amp;action=changeview&amp;view=title&amp;direction=' . $link_sort_direction . '">' . Display::return_icon('notes_order_by_title.png', get_lang('OrderByTitle'), '', '32') . '</a>';
        echo '</div>';

        if (!in_array($_SESSION['notebook_view'], array('creation_date', 'update_date', 'title'))) {
            $_SESSION['notebook_view'] = 'creation_date';
        }

        // Database table definition
        $t_notebook = Database :: get_course_table(TABLE_NOTEBOOK);
        $order_by = "";
        if ($_SESSION['notebook_view'] == 'creation_date' || $_SESSION['notebook_view'] == 'update_date') {
            $order_by = " ORDER BY " . $_SESSION['notebook_view'] . " $sort_direction ";
        } else {
            $order_by = " ORDER BY " . $_SESSION['notebook_view'] . " $sort_direction ";
        }

        //condition for the session
        $session_id = api_get_session_id();
        $condition_session = api_get_session_condition($session_id);

        $cond_extra = ($_SESSION['notebook_view'] == 'update_date') ? " AND update_date <> '0000-00-00 00:00:00'" : " ";
        $course_id = api_get_course_int_id();

        $sql = "SELECT * FROM $t_notebook WHERE c_id = $course_id AND user_id = '" . api_get_user_id() . "' $condition_session $cond_extra $order_by";
        $result = Database::query($sql);
        while ($row = Database::fetch_array($result)) {
            //validacion when belongs to a session
            $session_img = api_get_session_image($row['session_id'], $_user['status']);
            $creation_date = api_get_local_time($row['creation_date'], null, date_default_timezone_get());
            $update_date = api_get_local_time($row['update_date'], null, date_default_timezone_get());
            echo '<div class="sectiontitle">';
            echo '<span style="float: right;"> (' . get_lang('CreationDate') . ': ' . date_to_str_ago($creation_date) . '&nbsp;&nbsp;<span class="dropbox_date">' . $creation_date . '</span>';
            if ($row['update_date'] <> $row['creation_date']) {
                echo ', ' . get_lang('UpdateDate') . ': ' . date_to_str_ago($update_date) . '&nbsp;&nbsp;<span class="dropbox_date">' . $update_date . '</span>';
            }
            echo ')</span>';
            echo $row['title'] . $session_img;
            echo '</div>';
            echo '<div class="sectioncomment">' . $row['description'] . '</div>';
            echo '<div>';
            echo '<a href="' . api_get_self() . '?action=editnote&amp;notebook_id=' . $row['notebook_id'] . '">' . Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_SMALL) . '</a>';
            echo '<a href="' . api_get_self() . '?action=deletenote&amp;notebook_id=' . $row['notebook_id'] . '" onclick="return confirmation(\'' . $row['title'] . '\');">' . Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL) . '</a>';
            echo '</div>';
        }
    }
Exemple #3
0
            if ($view_dropbox_category_sent == $dropbox_file->category) {
                $dropbox_file_data[] = $dropbox_file->id;
                $link_open = '<a href="dropbox_download.php?' . api_get_cidreq() . '&id=' . $dropbox_file->id . '">';
                $dropbox_file_data[] = $link_open . build_document_icon_tag('file', $dropbox_file->title) . '</a>';
                $dropbox_file_data[] = '<a href="dropbox_download.php?' . api_get_cidreq() . '&id=' . $dropbox_file->id . '&amp;action=download">' . Display::return_icon('save.png', get_lang('Save'), array('style' => 'float:right;'), ICON_SIZE_SMALL) . '</a>' . $link_open . $dropbox_file->title . '</a><br />' . $dropbox_file->description;
                $file_size = $dropbox_file->filesize;
                $dropbox_file_data[] = Text::format_file_size($file_size);
                $receivers_celldata = null;
                foreach ($dropbox_file->recipients as $recipient) {
                    $receivers_celldata = display_user_link_work($recipient['user_id'], $recipient['name']) . ', ' . $receivers_celldata;
                }
                $receivers_celldata = trim(trim($receivers_celldata), ',');
                // Removing the trailing comma.
                $dropbox_file_data[] = $receivers_celldata;
                $last_upload_date = api_get_local_time($dropbox_file->last_upload_date);
                $dropbox_file_data[] = date_to_str_ago($last_upload_date) . '<br /><span class="dropbox_date">' . api_format_date($last_upload_date) . '</span>';
                //$dropbox_file_data[] = $dropbox_file->author;
                $receivers_celldata = '';
                $action_icons = check_number_feedback($dropbox_file->id, $number_feedback) . ' ' . get_lang('Feedback') . '
									<a href="' . api_get_self() . '?' . api_get_cidreq() . '&view_received_category=' . $viewReceivedCategory . '&amp;view_sent_category=' . $viewSentCategory . '&amp;view=' . $view . '&amp;action=viewfeedback&amp;id=' . $dropbox_file->id . '&' . $sort_params . '">' . Display::return_icon('discuss.png', get_lang('Comment'), '', ICON_SIZE_SMALL) . '</a>
									<a href="' . api_get_self() . '?' . api_get_cidreq() . '&view_received_category=' . $viewReceivedCategory . '&amp;view_sent_category=' . $viewSentCategory . '&amp;view=' . $view . '&amp;action=movesent&amp;move_id=' . $dropbox_file->id . '&' . $sort_params . '">' . Display::return_icon('move.png', get_lang('Move'), '', ICON_SIZE_SMALL) . '</a>
									<a href="' . api_get_self() . '?' . api_get_cidreq() . '&view_received_category=' . $viewReceivedCategory . '&amp;view_sent_category=' . $viewSentCategory . '&amp;view=' . $view . '&amp;action=deletesentfile&amp;id=' . $dropbox_file->id . '&' . $sort_params . '" onclick="javascript: return confirmation(\'' . $dropbox_file->title . '\');">' . Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL) . '</a>';
                // This is a hack to have an additional row in a sortable table
                if ($action == 'viewfeedback' && isset($_GET['id']) && is_numeric($_GET['id']) && $dropbox_file->id == $_GET['id']) {
                    $action_icons .= "</td></tr>\n";
                    // ending the normal row of the sortable table
                    $action_icons .= "<tr><td colspan=\"2\">";
                    $action_icons .= "<a href=\"index.php?" . api_get_cidreq() . "&view_received_category=" . $viewReceivedCategory . "&view_sent_category=" . $viewSentCategory . "&view=" . $view . '&' . $sort_params . "\">" . get_lang('CloseFeedback') . "</a>";
                    $action_icons .= "</td><td colspan=\"7\">" . feedback($dropbox_file->feedback2) . "</td></tr>";
                }
                $dropbox_file_data[] = $action_icons;
 $defaults['content'] = str_replace('<!--[', '<!-- [', $content);
 //if ($extension == 'htm' || $extension == 'html')
 // HotPotatoes tests are html files, but they should not be edited in order their functionality to be preserved.
 if (($extension == 'htm' || $extension == 'html') && stripos($dir, '/HotPotatoes_files') === false) {
     if (empty($readonly) && $readonly == 0) {
         $_SESSION['showedit'] = 1;
         $form->add_html_editor('content', '', false, false, $html_editor_config);
         //$renderer->setElementTemplate('<div class="row"><div class="label" id="frmModel" style="overflow: visible;"></div><div class="formw">{element}</div></div>', 'content');
         //$form->add_html_editor('content', '', false, true, $html_editor_config);
     }
 }
 if (!$group_document && !is_my_shared_folder(api_get_user_id(), $my_cur_dir_path, $current_session_id)) {
     //$metadata_link = '<a href="../metadata/index.php?eid='.urlencode('Document.'.$document_data['id']).'">'.get_lang('AddMetadata').'</a>';
     // Updated on field
     $last_edit_date = api_get_local_time($last_edit_date);
     $display_date = date_to_str_ago($last_edit_date) . ' <span class="dropbox_date">' . api_format_date($last_edit_date) . '</span>';
     //$form->addElement('label', get_lang('Metadata'), $metadata_link);
     $form->addElement('label', get_lang('UpdatedOn'), $display_date);
 }
 $form->addElement('textarea', 'comment', get_lang('Comment'));
 if ($owner_id == api_get_user_id() || api_is_platform_admin()) {
     $checked =& $form->addElement('checkbox', 'readonly', null, get_lang('ReadOnly'));
     if ($readonly == 1) {
         $checked->setChecked(true);
     }
 }
 if ($is_certificate_mode) {
     $form->addElement('style_submit_button', 'submit', get_lang('SaveCertificate'), array('class' => 'save'));
 } else {
     $form->addElement('style_submit_button', 'submit', get_lang('SaveDocument'), array('class' => 'save'));
 }
Exemple #5
0
 // Icons (clickable)
 $row[] = DocumentManager::create_document_link($document_data, true, $count, $is_visible);
 $path_info = pathinfo($document_data['path']);
 if (isset($path_info['extension']) && in_array($path_info['extension'], array('ogg', 'mp3', 'wav'))) {
     $count++;
 }
 // Validation when belongs to a session
 $session_img = api_get_session_image($document_data['session_id'], $_user['status']);
 // Document title with link
 $row[] = DocumentManager::create_document_link($document_data, false, null, $is_visible) . $session_img . '<br />' . $invisibility_span_open . '<i>' . nl2br(htmlspecialchars($document_data['comment'], ENT_QUOTES, $charset)) . '</i>' . $invisibility_span_close . $user_link;
 // Comments => display comment under the document name
 $display_size = format_file_size($size);
 $row[] = '<span style="display:none;">' . $size . '</span>' . $invisibility_span_open . $display_size . $invisibility_span_close;
 // Last edit date
 $last_edit_date = api_get_local_time($document_data['lastedit_date']);
 $display_date = date_to_str_ago($last_edit_date) . ' <div class="muted"><small>' . $last_edit_date . "</small></div>";
 $row[] = $invisibility_span_open . $display_date . $invisibility_span_close;
 // Admins get an edit column
 if ($is_allowed_to_edit || $group_member_with_upload_rights || DocumentManager::is_my_shared_folder(api_get_user_id(), $curdirpath, $sessionId)) {
     $is_template = isset($document_data['is_template']) ? $document_data['is_template'] : false;
     // If readonly, check if it the owner of the file or if the user is an admin
     if ($document_data['insert_user_id'] == api_get_user_id() || api_is_platform_admin()) {
         $edit_icons = DocumentManager::build_edit_icons($document_data, $key, $is_template, 0, $is_visible);
     } else {
         $edit_icons = DocumentManager::build_edit_icons($document_data, $key, $is_template, $document_data['readonly'], $is_visible);
     }
     $row[] = $edit_icons;
 }
 $row[] = $last_edit_date;
 $row[] = $size;
 $row[] = $document_name;
Exemple #6
0
 /**
  * Display notes
  */
 public static function display_notes()
 {
     $_user = api_get_user_info();
     if (!isset($_GET['direction'])) {
         $sort_direction = 'ASC';
         $link_sort_direction = 'DESC';
     } elseif ($_GET['direction'] == 'ASC') {
         $sort_direction = 'ASC';
         $link_sort_direction = 'DESC';
     } else {
         $sort_direction = 'DESC';
         $link_sort_direction = 'ASC';
     }
     // action links
     echo '<div class="actions">';
     if (!api_is_anonymous()) {
         if (api_get_session_id() == 0) {
             echo '<a href="index.php?' . api_get_cidreq() . '&action=addnote">' . Display::return_icon('new_note.png', get_lang('NoteAddNew'), '', '32') . '</a>';
         } elseif (api_is_allowed_to_session_edit(false, true)) {
             echo '<a href="index.php?' . api_get_cidreq() . '&action=addnote">' . Display::return_icon('new_note.png', get_lang('NoteAddNew'), '', '32') . '</a>';
         }
     } else {
         echo '<a href="javascript:void(0)">' . Display::return_icon('new_note.png', get_lang('NoteAddNew'), '', '32') . '</a>';
     }
     echo '<a href="index.php?' . api_get_cidreq() . '&action=changeview&view=creation_date&direction=' . $link_sort_direction . '">' . Display::return_icon('notes_order_by_date_new.png', get_lang('OrderByCreationDate'), '', '32') . '</a>';
     echo '<a href="index.php?' . api_get_cidreq() . '&action=changeview&view=update_date&direction=' . $link_sort_direction . '">' . Display::return_icon('notes_order_by_date_mod.png', get_lang('OrderByModificationDate'), '', '32') . '</a>';
     echo '<a href="index.php?' . api_get_cidreq() . '&action=changeview&view=title&direction=' . $link_sort_direction . '">' . Display::return_icon('notes_order_by_title.png', get_lang('OrderByTitle'), '', '32') . '</a>';
     echo '</div>';
     if (!isset($_SESSION['notebook_view']) || !in_array($_SESSION['notebook_view'], array('creation_date', 'update_date', 'title'))) {
         $_SESSION['notebook_view'] = 'creation_date';
     }
     // Database table definition
     $t_notebook = Database::get_course_table(TABLE_NOTEBOOK);
     $order_by = "";
     if ($_SESSION['notebook_view'] == 'creation_date' || $_SESSION['notebook_view'] == 'update_date') {
         $order_by = " ORDER BY " . $_SESSION['notebook_view'] . " {$sort_direction} ";
     } else {
         $order_by = " ORDER BY " . $_SESSION['notebook_view'] . " {$sort_direction} ";
     }
     //condition for the session
     $session_id = api_get_session_id();
     $condition_session = api_get_session_condition($session_id);
     $cond_extra = $_SESSION['notebook_view'] == 'update_date' ? " AND update_date <> '0000-00-00 00:00:00'" : " ";
     $course_id = api_get_course_int_id();
     $sql = "SELECT * FROM {$t_notebook}\n                WHERE\n                    c_id = {$course_id} AND\n                    user_id = '" . api_get_user_id() . "'\n                    {$condition_session}\n                    {$cond_extra} {$order_by}\n                ";
     $result = Database::query($sql);
     while ($row = Database::fetch_array($result)) {
         // Validation when belongs to a session
         $session_img = api_get_session_image($row['session_id'], $_user['status']);
         $creation_date = api_get_local_time($row['creation_date'], null, date_default_timezone_get());
         $update_date = api_get_local_time($row['update_date'], null, date_default_timezone_get());
         $updateValue = '';
         if ($row['update_date'] != $row['creation_date']) {
             $updateValue = ', ' . get_lang('UpdateDate') . ': ' . date_to_str_ago($update_date) . '&nbsp;&nbsp;<span class="dropbox_date">' . $update_date . '</span>';
         }
         $actions = '<a href="' . api_get_self() . '?action=editnote&notebook_id=' . $row['notebook_id'] . '">' . Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_SMALL) . '</a>';
         $actions .= '<a href="' . api_get_self() . '?action=deletenote&notebook_id=' . $row['notebook_id'] . '" onclick="return confirmation(\'' . $row['title'] . '\');">' . Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL) . '</a>';
         echo Display::panel($row['description'], $row['title'] . $session_img . ' <div class="pull-right">' . $actions . '</div>', get_lang('CreationDate') . ': ' . date_to_str_ago($creation_date) . '&nbsp;&nbsp;<span class="dropbox_date">' . $creation_date . $updateValue . "</span>");
     }
 }
 $path_info = pathinfo($document_data['path']);
 if (isset($path_info['extension']) && in_array($path_info['extension'], array('ogg', 'mp3', 'wav'))) {
     $count++;
 }
 // Validacion when belongs to a session
 $session_img = api_get_session_image($document_data['session_id'], $_user['status']);
 // Document title with link
 $row[] = create_document_link($document_data, false, null, $is_visible) . $session_img . '<br />' . $invisibility_span_open . '<i>' . nl2br(htmlspecialchars($document_data['comment'], ENT_QUOTES, $charset)) . '</i>' . $invisibility_span_close . $user_link;
 // Comments => display comment under the document name
 $display_size = Text::format_file_size($size);
 $row[] = '<span style="display:none;">' . $size . '</span>' . $invisibility_span_open . $display_size . $invisibility_span_close;
 // Last edit date
 $last_edit_date = $document_data['lastedit_date'];
 $last_edit_date = api_get_local_time($last_edit_date, null, date_default_timezone_get());
 //$display_date = date_to_str_ago($last_edit_date).'<br /><span class="dropbox_date">'.api_format_date($last_edit_date).'</span>';
 $display_date = date_to_str_ago($last_edit_date);
 $row[] = $invisibility_span_open . $display_date . $invisibility_span_close;
 // Admins get an edit column
 if ($is_allowed_to_edit || $group_member_with_upload_rights || is_my_shared_folder(api_get_user_id(), $curdirpath, $session_id)) {
     $is_template = isset($document_data['is_template']) ? $document_data['is_template'] : false;
     // If readonly, check if it the owner of the file or if the user is an admin
     if ($document_data['insert_user_id'] == api_get_user_id() || api_is_platform_admin()) {
         $edit_icons = build_edit_icons($document_data, $key, $is_template, 0, $is_visible);
     } else {
         $edit_icons = build_edit_icons($document_data, $key, $is_template, $document_data['readonly'], $is_visible);
     }
     $row[] = $edit_icons;
 }
 $row[] = $last_edit_date;
 $row[] = $size;
 $row[] = $document_name;
Exemple #8
0
/**
 * @param int $start
 * @param int $limit
 * @param int $column
 * @param string $direction
 * @param int $work_id
 * @param array $where_condition
 * @param int $studentId
 * @param bool $getCount
 * @return array
 */
function get_work_user_list(
    $start,
    $limit,
    $column,
    $direction,
    $work_id,
    $where_condition = null,
    $studentId = null,
    $getCount = false
) {
    $work_table = Database::get_course_table(TABLE_STUDENT_PUBLICATION);
    $iprop_table = Database::get_course_table(TABLE_ITEM_PROPERTY);
    $user_table = Database::get_main_table(TABLE_MAIN_USER);

    $session_id = api_get_session_id();
    $course_id = api_get_course_int_id();
    $group_id = api_get_group_id();
    $course_info = api_get_course_info(api_get_course_id());

    $work_id = intval($work_id);
    $column = !empty($column) ? Database::escape_string($column) : 'sent_date';
    $start = intval($start);
    $limit = intval($limit);

    if (!in_array($direction, array('asc','desc'))) {
        $direction = 'desc';
    }

    $work_data = get_work_data_by_id($work_id);
    $is_allowed_to_edit = api_is_allowed_to_edit() || api_is_coach();
    $condition_session  = api_get_session_condition($session_id);
    $locked = api_resource_is_locked_by_gradebook($work_id, LINK_STUDENTPUBLICATION);

    $isDrhOfCourse = CourseManager::isUserSubscribedInCourseAsDrh(
        api_get_user_id(),
        $course_info
    );

    if (!empty($work_data)) {
        if (!empty($group_id)) {
            $extra_conditions = " work.post_group_id = '".intval($group_id)."' ";
            // set to select only messages posted by the user's group
        } else {
            $extra_conditions = " work.post_group_id = '0' ";
        }

        if ($is_allowed_to_edit || $isDrhOfCourse) {
            $extra_conditions .= ' AND work.active IN (0, 1) ';
        } else {
            if (isset($course_info['show_score']) &&
                $course_info['show_score'] == 1
            ) {
                $extra_conditions .= " AND (u.user_id = ".api_get_user_id()." AND work.active IN (0, 1)) ";
            } else {
                $extra_conditions .= ' AND work.active IN (0, 1) ';
            }
        }

        $extra_conditions .= " AND parent_id  = ".$work_id." ";

        $select = 'SELECT DISTINCT
                        u.user_id,
                        work.id as id,
                        title as title,
                        description,
                        url,
                        sent_date,
                        contains_file,
                        has_properties,
                        view_properties,
                        qualification,
                        weight,
                        allow_text_assignment,
                        u.firstname,
                        u.lastname,
                        u.username,
                        parent_id,
                        accepted,
                        qualificator_id';
        if ($getCount) {
            $select = "SELECT DISTINCT count(u.user_id) as count ";
        }

        $user_condition = "INNER JOIN $user_table u  ON (work.user_id = u.user_id) ";
        $work_condition = "$iprop_table prop INNER JOIN $work_table work
                           ON (prop.ref = work.id AND prop.c_id = $course_id AND work.c_id = $course_id ) ";

        $work_assignment = get_work_assignment_by_id($work_id);

        if (!empty($studentId)) {
            $where_condition.= " AND u.user_id = ".intval($studentId);
        }

        $sql = " $select
                FROM $work_condition  $user_condition
                WHERE $extra_conditions $where_condition $condition_session
                ORDER BY $column $direction";

        if (!empty($start) && !empty($limit)) {
            $sql .= " LIMIT $start, $limit";
        }
        $result = Database::query($sql);
        $works = array();

        if ($getCount) {
            $work = Database::fetch_array($result, 'ASSOC');
            return $work['count'];
        }

        $url = api_get_path(WEB_CODE_PATH).'work/';

        while ($work = Database::fetch_array($result, 'ASSOC')) {
            $item_id = $work['id'];

            // Get the author ID for that document from the item_property table
            $is_author  = false;
            $can_read   = false;

            $owner_id = $work['user_id'];

            /* Because a bug found when saving items using the api_item_property_update()
               the field $item_property_data['insert_user_id'] is not reliable. */

            if (!$is_allowed_to_edit && $owner_id == api_get_user_id()) {
                $is_author = true;
            }

            if ($course_info['show_score'] == 0) {
                $can_read = true;
            }

            if ($work['accepted'] == '0') {
                $class = 'invisible';
            } else {
                $class = '';
            }

            $qualification_exists = false;
            if (!empty($work_data['qualification']) &&
                intval($work_data['qualification']) > 0
            ) {
                $qualification_exists = true;
            }

            $qualification_string = '';
            if ($qualification_exists) {
                if ($work['qualification'] == '') {
                    $qualification_string = Display::label('-');
                } else {
                    $label = 'info';
                    $relativeScore = $work['qualification']/$work_data['qualification'];
                    if ($relativeScore < 0.5) {
                        $label = 'important';
                    } elseif ($relativeScore < 0.75) {
                        $label = 'warning';
                    }
                    $qualification_string = Display::label(
                        $work['qualification'].' / '.$work_data['qualification'],
                        $label
                    );
                }
            }

            $work['qualification_score'] = $work['qualification'];

            $add_string = '';
            $time_expires = api_strtotime($work_assignment['expires_on'], 'UTC');

            if (!empty($work_assignment['expires_on']) &&
                $work_assignment['expires_on'] != '0000-00-00 00:00:00' &&
                $time_expires && ($time_expires < api_strtotime($work['sent_date'], 'UTC'))) {
                $add_string = Display::label(get_lang('Expired'), 'important');
            }

            if (($can_read && $work['accepted'] == '1') ||
                ($is_author && in_array($work['accepted'], array('1', '0'))) ||
                ($is_allowed_to_edit || api_is_drh())
            ) {
                // Firstname, lastname, username
                $work['firstname'] = Display::div($work['firstname'], array('class' => $class));
                $work['lastname'] = Display::div($work['lastname'], array('class' => $class));

                if (strlen($work['title']) > 30) {
                    $short_title = substr($work['title'], 0, 27).'...';
                    $work['title'] = Display::span($short_title, array('class' => $class, 'title' => $work['title']));
                } else {
                    $work['title'] = Display::div($work['title'], array('class' => $class));
                }

                // Type.
                $work['type'] = build_document_icon_tag('file', $work['url']);

                // File name.
                $link_to_download = null;

                // If URL is present then there's a file to download keep BC.
                if ($work['contains_file'] || !empty($work['url'])) {
                    $link_to_download = '<a href="'.$url.'download.php?id='.$item_id.'&'.api_get_cidreq().'">'.
                        Display::return_icon('save.png', get_lang('Save'),array(), ICON_SIZE_SMALL).'</a> ';
                }

                $send_to = Portfolio::share('work', $work['id'],  array('style' => 'white-space:nowrap;'));

                $feedback = null;
                $count = getWorkCommentCount($item_id, $course_info);
                if (!is_null($count) && !empty($count)) {
                    if ($qualification_exists) {
                        $feedback .= "<br />";
                    }
                    $feedback .= '<a href="'.$url.'view.php?'.api_get_cidreq().'&id='.$item_id.'" title="'.get_lang('View').'">'.
                        Display::label($count.' '.get_lang('Feedback'), 'info').'</a> ';
                }

                $work['qualification'] = $qualification_string.$feedback;
                $work['qualification_only'] = $qualification_string;

                // Date.
                $work_date = api_convert_and_format_date($work['sent_date']);

                $work['sent_date_from_db'] = $work['sent_date'];
                $work['sent_date'] = date_to_str_ago(api_get_local_time($work['sent_date'])) . ' ' . $add_string . '<br />' . $work_date;

                // Actions.

                $action = '';
                if (api_is_allowed_to_edit()) {
                    $action .= '<a href="'.$url.'view.php?'.api_get_cidreq().'&id='.$item_id.'" title="'.get_lang('View').'">'.
                        Display::return_icon('default.png', get_lang('View'),array(), ICON_SIZE_SMALL).'</a> ';

                    if ($locked) {
                        if ($qualification_exists) {
                            $action .= Display::return_icon('rate_work_na.png', get_lang('CorrectAndRate'),array(), ICON_SIZE_SMALL);
                        } else {
                            $action .= Display::return_icon('edit_na.png', get_lang('Comment'),array(), ICON_SIZE_SMALL);
                        }
                    } else {
                        if ($qualification_exists) {
                            $action .= '<a href="'.$url.'edit.php?'.api_get_cidreq().'&item_id='.$item_id.'&id='.$work['parent_id'].'" title="'.get_lang('Edit').'"  >'.
                                Display::return_icon('rate_work.png', get_lang('CorrectAndRate'), array(), ICON_SIZE_SMALL).'</a>';
                        } else {
                            $action .= '<a href="'.$url.'edit.php?'.api_get_cidreq().'&item_id='.$item_id.'&id='.$work['parent_id'].'" title="'.get_lang('Modify').'">'.
                                Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL).'</a>';
                        }
                    }

                    if ($work['contains_file']) {
                        if ($locked) {
                            $action .= Display::return_icon('move_na.png', get_lang('Move'),array(), ICON_SIZE_SMALL);
                        } else {
                            $action .= '<a href="'.$url.'work.php?'.api_get_cidreq().'&action=move&item_id='.$item_id.'" title="'.get_lang('Move').'">'.
                                Display::return_icon('move.png', get_lang('Move'),array(), ICON_SIZE_SMALL).'</a>';
                        }
                    }

                    if ($work['accepted'] == '1') {
                        $action .= '<a href="'.$url.'work_list_all.php?'.api_get_cidreq().'&id='.$work_id.'&action=make_invisible&item_id='.$item_id.'" title="'.get_lang('Invisible').'" >'.
                            Display::return_icon('visible.png', get_lang('Invisible'),array(), ICON_SIZE_SMALL).'</a>';
                    } else {
                        $action .= '<a href="'.$url.'work_list_all.php?'.api_get_cidreq().'&id='.$work_id.'&action=make_visible&item_id='.$item_id.'" title="'.get_lang('Visible').'" >'.
                            Display::return_icon('invisible.png', get_lang('Visible'),array(), ICON_SIZE_SMALL).'</a> ';
                    }

                    if ($locked) {
                        $action .= Display::return_icon('delete_na.png', get_lang('Delete'), '', ICON_SIZE_SMALL);
                    } else {
                        $action .= '<a href="'.$url.'work_list_all.php?'.api_get_cidreq().'&id='.$work_id.'&action=delete&amp;item_id='.$item_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>';
                    }
                } elseif ($is_author && (empty($work['qualificator_id']) || $work['qualificator_id'] == 0)) {
                    $action .= '<a href="'.$url.'view.php?'.api_get_cidreq().'&id='.$item_id.'" title="'.get_lang('View').'">'.
                        Display::return_icon('default.png', get_lang('View'),array(), ICON_SIZE_SMALL).'</a>';

                    if (api_get_course_setting('student_delete_own_publication') == 1) {
                        if (api_is_allowed_to_session_edit(false, true)) {
                            $action .= '<a href="'.$url.'edit.php?'.api_get_cidreq().'&item_id='.$item_id.'&id='.$work['parent_id'].'" title="'.get_lang('Modify').'">'.
                                Display::return_icon('edit.png', get_lang('Comment'),array(), ICON_SIZE_SMALL).'</a>';
                        }
                        $action .= ' <a href="'.$url.'work_list.php?'.api_get_cidreq().'&action=delete&item_id='.$item_id.'&id='.$work['parent_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>';
                    } else {
                        $action .= Display::return_icon('edit_na.png', get_lang('Modify'),array(), ICON_SIZE_SMALL);
                    }
                } else {
                    $action .= '<a href="'.$url.'view.php?'.api_get_cidreq().'&id='.$item_id.'" title="'.get_lang('View').'">'.
                        Display::return_icon('default.png', get_lang('View'),array(), ICON_SIZE_SMALL).'</a>';
                    $action .= Display::return_icon('edit_na.png', get_lang('Modify'),array(), ICON_SIZE_SMALL);
                }

                // Status.
                if (empty($work['qualificator_id'])) {
                    $qualificator_id = Display::label(get_lang('NotRevised'), 'warning');
                } else {
                    $qualificator_id = Display::label(get_lang('Revised'), 'success');
                }
                $work['qualificator_id'] = $qualificator_id;
                $work['actions'] = $send_to.$link_to_download.$action;
                $works[] = $work;
            }
        }
        return $works;
    }
}
Exemple #9
0
/**
 * @param int $start
 * @param int $limit
 * @param int $column
 * @param string $direction
 * @param int $work_id
 * @param array $where_condition
 * @param int $studentId
 * @param bool $getCount
 * @return array
 */
function get_work_user_list($start, $limit, $column, $direction, $work_id, $where_condition = null, $studentId = null, $getCount = false)
{
    $work_table = Database::get_course_table(TABLE_STUDENT_PUBLICATION);
    $iprop_table = Database::get_course_table(TABLE_ITEM_PROPERTY);
    $user_table = Database::get_main_table(TABLE_MAIN_USER);
    $session_id = api_get_session_id();
    $group_id = api_get_group_id();
    $course_info = api_get_course_info();
    $course_id = $course_info['real_id'];
    $work_id = intval($work_id);
    $column = !empty($column) ? Database::escape_string($column) : 'sent_date';
    $start = intval($start);
    $limit = intval($limit);
    if (!in_array($direction, array('asc', 'desc'))) {
        $direction = 'desc';
    }
    $work_data = get_work_data_by_id($work_id);
    $is_allowed_to_edit = api_is_allowed_to_edit() || api_is_coach();
    $condition_session = api_get_session_condition($session_id, true, false, 'work.session_id');
    $locked = api_resource_is_locked_by_gradebook($work_id, LINK_STUDENTPUBLICATION);
    $isDrhOfCourse = CourseManager::isUserSubscribedInCourseAsDrh(api_get_user_id(), $course_info);
    if (!empty($work_data)) {
        if (!empty($group_id)) {
            $extra_conditions = " work.post_group_id = '" . intval($group_id) . "' ";
            // set to select only messages posted by the user's group
        } else {
            $extra_conditions = " work.post_group_id = '0' ";
        }
        if ($is_allowed_to_edit || $isDrhOfCourse) {
            $extra_conditions .= ' AND work.active IN (0, 1) ';
        } else {
            if (isset($course_info['show_score']) && $course_info['show_score'] == 1) {
                $extra_conditions .= " AND (u.user_id = " . api_get_user_id() . " AND work.active IN (0, 1)) ";
            } else {
                $extra_conditions .= ' AND work.active IN (0, 1) ';
            }
        }
        $extra_conditions .= " AND parent_id  = " . $work_id . " ";
        $select = 'SELECT DISTINCT
                        u.user_id,
                        work.id as id,
                        title as title,
                        description,
                        url,
                        sent_date,
                        contains_file,
                        has_properties,
                        view_properties,
                        qualification,
                        weight,
                        allow_text_assignment,
                        u.firstname,
                        u.lastname,
                        u.username,
                        parent_id,
                        accepted,
                        qualificator_id,
                        url_correction
                        ';
        if ($getCount) {
            $select = "SELECT DISTINCT count(u.user_id) as count ";
        }
        $user_condition = "INNER JOIN {$user_table} u  ON (work.user_id = u.user_id) ";
        $work_condition = "{$iprop_table} prop INNER JOIN {$work_table} work\n                           ON (prop.ref = work.id AND prop.c_id = {$course_id} AND work.c_id = {$course_id} ) ";
        $work_assignment = get_work_assignment_by_id($work_id);
        if (!empty($studentId)) {
            $where_condition .= " AND u.user_id = " . intval($studentId);
        }
        $sql = " {$select}\n                FROM {$work_condition}  {$user_condition}\n                WHERE {$extra_conditions} {$where_condition} {$condition_session}\n                    AND u.status != " . INVITEE . "\n                ORDER BY {$column} {$direction}";
        if (!empty($start) && !empty($limit)) {
            $sql .= " LIMIT {$start}, {$limit}";
        }
        $result = Database::query($sql);
        $works = array();
        if ($getCount) {
            $work = Database::fetch_array($result, 'ASSOC');
            return $work['count'];
        }
        $url = api_get_path(WEB_CODE_PATH) . 'work/';
        $unoconv = api_get_configuration_value('unoconv.binaries');
        while ($work = Database::fetch_array($result, 'ASSOC')) {
            $item_id = $work['id'];
            // Get the author ID for that document from the item_property table
            $is_author = false;
            $can_read = false;
            $owner_id = $work['user_id'];
            /* Because a bug found when saving items using the api_item_property_update()
               the field $item_property_data['insert_user_id'] is not reliable. */
            if (!$is_allowed_to_edit && $owner_id == api_get_user_id()) {
                $is_author = true;
            }
            if ($course_info['show_score'] == 0) {
                $can_read = true;
            }
            if ($work['accepted'] == '0') {
                $class = 'invisible';
            } else {
                $class = '';
            }
            $qualification_exists = false;
            if (!empty($work_data['qualification']) && intval($work_data['qualification']) > 0) {
                $qualification_exists = true;
            }
            $qualification_string = '';
            if ($qualification_exists) {
                if ($work['qualification'] == '') {
                    $qualification_string = Display::label('-');
                } else {
                    $label = 'info';
                    $relativeScore = $work['qualification'] / $work_data['qualification'];
                    if ($relativeScore < 0.5) {
                        $label = 'important';
                    } elseif ($relativeScore < 0.75) {
                        $label = 'warning';
                    }
                    $qualification_string = Display::label($work['qualification'] . ' / ' . $work_data['qualification'], $label);
                }
            }
            $work['qualification_score'] = $work['qualification'];
            $add_string = '';
            $time_expires = '';
            if (!empty($work_assignment['expires_on'])) {
                $time_expires = api_strtotime($work_assignment['expires_on'], 'UTC');
            }
            if (!empty($work_assignment['expires_on']) && !empty($time_expires) && $time_expires < api_strtotime($work['sent_date'], 'UTC')) {
                $add_string = Display::label(get_lang('Expired'), 'important');
            }
            if ($can_read && $work['accepted'] == '1' || $is_author && in_array($work['accepted'], array('1', '0')) || ($is_allowed_to_edit || api_is_drh())) {
                // Firstname, lastname, username
                $work['firstname'] = Display::div($work['firstname'], array('class' => $class));
                $work['lastname'] = Display::div($work['lastname'], array('class' => $class));
                $work['title_clean'] = $work['title'];
                if (strlen($work['title']) > 30) {
                    $short_title = substr($work['title'], 0, 27) . '...';
                    $work['title'] = Display::span($short_title, array('class' => $class, 'title' => $work['title']));
                } else {
                    $work['title'] = Display::div($work['title'], array('class' => $class));
                }
                // Type.
                $work['type'] = DocumentManager::build_document_icon_tag('file', $work['url']);
                // File name.
                $link_to_download = null;
                // If URL is present then there's a file to download keep BC.
                if ($work['contains_file'] || !empty($work['url'])) {
                    $link_to_download = '<a href="' . $url . 'download.php?id=' . $item_id . '&' . api_get_cidreq() . '">' . Display::return_icon('save.png', get_lang('Save'), array(), ICON_SIZE_SMALL) . '</a> ';
                }
                $send_to = Portfolio::share('work', $work['id'], array('style' => 'white-space:nowrap;'));
                $feedback = null;
                $count = getWorkCommentCount($item_id, $course_info);
                if (!is_null($count) && !empty($count)) {
                    if ($qualification_exists) {
                        $feedback .= "<br />";
                    }
                    $feedback .= '<a href="' . $url . 'view.php?' . api_get_cidreq() . '&id=' . $item_id . '" title="' . get_lang('View') . '">' . Display::label($count . ' ' . get_lang('Feedback'), 'info') . '</a> ';
                }
                $work['qualification'] = $qualification_string . $feedback;
                $work['qualification_only'] = $qualification_string;
                // Date.
                $work_date = api_convert_and_format_date($work['sent_date']);
                $work['sent_date_from_db'] = $work['sent_date'];
                $work['sent_date'] = '<div class="date-time">' . date_to_str_ago(api_get_local_time($work['sent_date'])) . ' ' . $add_string . ' ' . $work_date . '</div>';
                // Actions.
                $correction = '';
                $action = '';
                if (api_is_allowed_to_edit()) {
                    if (!empty($work['url_correction'])) {
                        $action .= Display::url(Display::return_icon('check-circle.png', get_lang('Correction'), null, ICON_SIZE_SMALL), api_get_path(WEB_CODE_PATH) . 'work/download.php?id=' . $item_id . '&' . api_get_cidreq() . '&correction=1');
                    }
                    $action .= '<a href="' . $url . 'view.php?' . api_get_cidreq() . '&id=' . $item_id . '" title="' . get_lang('View') . '">' . Display::return_icon('default.png', get_lang('View'), array(), ICON_SIZE_SMALL) . '</a> ';
                    if ($unoconv && empty($work['contains_file'])) {
                        $action .= '<a href="' . $url . 'work_list_all.php?' . api_get_cidreq() . '&id=' . $work_id . '&action=export_to_doc&item_id=' . $item_id . '" title="' . get_lang('ExportToDoc') . '" >' . Display::return_icon('export_doc.png', get_lang('ExportToDoc'), array(), ICON_SIZE_SMALL) . '</a> ';
                    }
                    $correction = '
                        <form
                        id="file_upload_' . $item_id . '"
                        class="work_correction_file_upload file_upload_small"
                        action="' . api_get_path(WEB_AJAX_PATH) . 'work.ajax.php?' . api_get_cidreq() . '&a=upload_correction_file&item_id=' . $item_id . '" method="POST" enctype="multipart/form-data"
                        >
                        <div class="button-load">
                            ' . get_lang('ClickOrDropFilesHere') . '
                        </div>
                        <input type="file" name="file" multiple>
                        <button type="submit"></button>
                        </form>
                    ';
                    $correction .= "\n                        <script>\n                        \$(document).ready(function() {\n                            \$('#file_upload_" . $item_id . "').fileupload({\n                                uploadTable: \$('.files'),\n                                downloadTable: \$('.files'),\n                                buildUploadRow: function (files, index) {\n                                    \$('.files').show();\n                                    return\n                                        \$('<tr><td>' + files[index].name + '<\\/td>' +\n                                        '<td class=\"file_upload_progress\"><div><\\/div><\\/td>' +\n                                        '<td class=\"file_upload_cancel\">' +\n                                        '<button class=\"ui-state-default ui-corner-all\" title=\"" . get_lang('Cancel') . "\">' +\n                                        '<span class=\"ui-icon ui-icon-cancel\">" . get_lang('Cancel') . "<\\/span>' +'<\\/button>'+\n                                        '<\\/td><\\/tr>');\n                                },\n                                buildDownloadRow: function (file) {\n                                    return \$('<tr><td>' + file.name + '<\\/td> <td> ' + file.size + ' <\\/td>  <td>&nbsp;' + file.result + ' <\\/td> <\\/tr>');\n                                }\n                            });\n                        });\n                        </script>\n                    ";
                    if ($locked) {
                        if ($qualification_exists) {
                            $action .= Display::return_icon('rate_work_na.png', get_lang('CorrectAndRate'), array(), ICON_SIZE_SMALL);
                        } else {
                            $action .= Display::return_icon('edit_na.png', get_lang('Comment'), array(), ICON_SIZE_SMALL);
                        }
                    } else {
                        if ($qualification_exists) {
                            $action .= '<a href="' . $url . 'edit.php?' . api_get_cidreq() . '&item_id=' . $item_id . '&id=' . $work['parent_id'] . '" title="' . get_lang('Edit') . '"  >' . Display::return_icon('rate_work.png', get_lang('CorrectAndRate'), array(), ICON_SIZE_SMALL) . '</a>';
                        } else {
                            $action .= '<a href="' . $url . 'edit.php?' . api_get_cidreq() . '&item_id=' . $item_id . '&id=' . $work['parent_id'] . '" title="' . get_lang('Modify') . '">' . Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL) . '</a>';
                        }
                    }
                    if ($work['contains_file']) {
                        if ($locked) {
                            $action .= Display::return_icon('move_na.png', get_lang('Move'), array(), ICON_SIZE_SMALL);
                        } else {
                            $action .= '<a href="' . $url . 'work.php?' . api_get_cidreq() . '&action=move&item_id=' . $item_id . '&id=' . $work['parent_id'] . '" title="' . get_lang('Move') . '">' . Display::return_icon('move.png', get_lang('Move'), array(), ICON_SIZE_SMALL) . '</a>';
                        }
                    }
                    if ($work['accepted'] == '1') {
                        $action .= '<a href="' . $url . 'work_list_all.php?' . api_get_cidreq() . '&id=' . $work_id . '&action=make_invisible&item_id=' . $item_id . '" title="' . get_lang('Invisible') . '" >' . Display::return_icon('visible.png', get_lang('Invisible'), array(), ICON_SIZE_SMALL) . '</a>';
                    } else {
                        $action .= '<a href="' . $url . 'work_list_all.php?' . api_get_cidreq() . '&id=' . $work_id . '&action=make_visible&item_id=' . $item_id . '" title="' . get_lang('Visible') . '" >' . Display::return_icon('invisible.png', get_lang('Visible'), array(), ICON_SIZE_SMALL) . '</a> ';
                    }
                    if ($locked) {
                        $action .= Display::return_icon('delete_na.png', get_lang('Delete'), '', ICON_SIZE_SMALL);
                    } else {
                        $action .= '<a href="' . $url . 'work_list_all.php?' . api_get_cidreq() . '&id=' . $work_id . '&action=delete&item_id=' . $item_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>';
                    }
                } elseif ($is_author && (empty($work['qualificator_id']) || $work['qualificator_id'] == 0)) {
                    $action .= '<a href="' . $url . 'view.php?' . api_get_cidreq() . '&id=' . $item_id . '" title="' . get_lang('View') . '">' . Display::return_icon('default.png', get_lang('View'), array(), ICON_SIZE_SMALL) . '</a>';
                    if (api_get_course_setting('student_delete_own_publication') == 1) {
                        if (api_is_allowed_to_session_edit(false, true)) {
                            $action .= '<a href="' . $url . 'edit.php?' . api_get_cidreq() . '&item_id=' . $item_id . '&id=' . $work['parent_id'] . '" title="' . get_lang('Modify') . '">' . Display::return_icon('edit.png', get_lang('Comment'), array(), ICON_SIZE_SMALL) . '</a>';
                        }
                        $action .= ' <a href="' . $url . 'work_list.php?' . api_get_cidreq() . '&action=delete&item_id=' . $item_id . '&id=' . $work['parent_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>';
                    } else {
                        $action .= Display::return_icon('edit_na.png', get_lang('Modify'), array(), ICON_SIZE_SMALL);
                    }
                } else {
                    $action .= '<a href="' . $url . 'view.php?' . api_get_cidreq() . '&id=' . $item_id . '" title="' . get_lang('View') . '">' . Display::return_icon('default.png', get_lang('View'), array(), ICON_SIZE_SMALL) . '</a>';
                    $action .= Display::return_icon('edit_na.png', get_lang('Modify'), array(), ICON_SIZE_SMALL);
                }
                // Status.
                if (empty($work['qualificator_id'])) {
                    $qualificator_id = Display::label(get_lang('NotRevised'), 'warning');
                } else {
                    $qualificator_id = Display::label(get_lang('Revised'), 'success');
                }
                $work['qualificator_id'] = $qualificator_id;
                $work['actions'] = $send_to . $link_to_download . $action;
                $work['correction'] = $correction;
                $works[] = $work;
            }
        }
        return $works;
    }
}