コード例 #1
0
ファイル: index.php プロジェクト: ilosada/chamilo-lms-icpna
                $dropbox_file_data[] = $action_icons;
                $dropbox_file_data[] = $last_upload_date;
                $dropbox_file_data[] = $file_size;
                $action_icons = '';
                $dropbox_data_sent[] = $dropbox_file_data;
            }
        }
        // The content of the sortable table = the categories (if we are not in the root)
        if ($view_dropbox_category_sent == 0) {
            foreach ($dropbox_categories as $category) {
                $dropbox_category_data = array();
                if ($category['sent'] == '1') {
                    $dropbox_category_data[] = $category['cat_id'];
                    // This is where the checkbox icon for the files appear.
                    $link_open = '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&view_received_category=' . $viewReceivedCategory . '&amp;view_sent_category=' . $category['cat_id'] . '&amp;view=' . $view . '">';
                    $dropbox_category_data[] = $link_open . build_document_icon_tag('folder', Security::remove_XSS($category['cat_name'])) . '</a>';
                    $dropbox_category_data[] = '<a href="dropbox_download.php?' . api_get_cidreq() . '&cat_id=' . $category['cat_id'] . '&amp;action=downloadcategory&amp;sent_received=sent">' . Display::return_icon('save_pack.png', get_lang('Save'), array('style' => 'float:right;'), ICON_SIZE_SMALL) . '</a>' . $link_open . Security::remove_XSS($category['cat_name']) . '</a>';
                    //$dropbox_category_data[] = '';
                    $dropbox_category_data[] = '';
                    //$dropbox_category_data[] = '';
                    $dropbox_category_data[] = '';
                    $dropbox_category_data[] = '';
                    $dropbox_category_data[] = '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&view_received_category=' . $viewReceivedCategory . '&amp;view_sent_category=' . $viewSentCategory . '&amp;view=' . $view . '&amp;action=editcategory&id=' . $category['cat_id'] . '">' . Display::return_icon('edit.png', get_lang('Edit'), '', 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=deletesentcategory&amp;id=' . $category['cat_id'] . '" onclick="javascript: return confirmation(\'' . Security::remove_XSS($category['cat_name']) . '\');">' . Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL) . '</a>';
                }
                if (is_array($dropbox_category_data) && count($dropbox_category_data) > 0) {
                    $dropbox_data_sent[] = $dropbox_category_data;
                }
            }
        }
        // Displaying the table
コード例 #2
0
ファイル: document.inc.php プロジェクト: ragebat/chamilo-lms
/**
 * Create a html hyperlink depending on if it's a folder or a file
 *
 * @param string $www
 * @param string $title
 * @param string $path
 * @param string $filetype (file/folder)
 * @param int $visibility (1/0)
 * @param int $show_as_icon - if it is true, only a clickable icon will be shown
 * @return string url
 */
function create_document_link($document_data, $show_as_icon = false, $counter = null, $visibility)
{
    global $dbl_click_id;
    if (isset($_SESSION['_gid'])) {
        $req_gid = '&amp;gidReq=' . $_SESSION['_gid'];
    } else {
        $req_gid = '';
    }
    $course_info = api_get_course_info();
    $www = api_get_path(WEB_COURSE_PATH) . $course_info['path'] . '/document';
    // Get the title or the basename depending on what we're using
    if ($document_data['title'] != '') {
        $title = $document_data['title'];
    } else {
        $title = basename($document_data['path']);
    }
    $filetype = $document_data['filetype'];
    $size = $filetype == 'folder' ? FileManager::get_total_folder_size($document_data['path'], api_is_allowed_to_edit(null, true)) : $document_data['size'];
    $path = $document_data['path'];
    $url_path = urlencode($document_data['path']);
    // Add class="invisible" on invisible files
    $visibility_class = $visibility == false ? ' class="muted"' : '';
    if (!$show_as_icon) {
        // Build download link (icon)
        $forcedownload_link = $filetype == 'folder' ? api_get_self() . '?' . api_get_cidreq() . '&action=downloadfolder&id=' . $document_data['id'] : api_get_self() . '?' . api_get_cidreq() . '&amp;action=download&amp;id=' . $document_data['id'];
        // Folder download or file download?
        $forcedownload_icon = $filetype == 'folder' ? 'save_pack.png' : 'save.png';
        // Prevent multiple clicks on zipped folder download
        $prevent_multiple_click = $filetype == 'folder' ? " onclick=\"javascript: if(typeof clic_{$dbl_click_id} == 'undefined' || !clic_{$dbl_click_id}) { clic_{$dbl_click_id}=true; window.setTimeout('clic_" . $dbl_click_id++ . "=false;',10000); } else { return false; }\"" : '';
    }
    $target = '_self';
    $is_browser_viewable_file = false;
    if ($filetype == 'file') {
        // Check the extension
        $ext = explode('.', $path);
        $ext = strtolower($ext[sizeof($ext) - 1]);
        // HTML-files an some other types are shown in a frameset by default.
        $is_browser_viewable_file = is_browser_viewable($ext);
        if ($is_browser_viewable_file) {
            //$url = 'showinframes.php?'.api_get_cidreq().'&amp;file='.$url_path.$req_gid;
            $url = 'showinframes.php?' . api_get_cidreq() . '&id=' . $document_data['id'] . $req_gid;
        } else {
            // url-encode for problematic characters (we may not call them dangerous characters...)
            $path = str_replace('%2F', '/', $url_path) . '?' . api_get_cidreq();
            //$new_path = '?id='.$document_data['id'];
            $url = $www . $path;
        }
        //$path = str_replace('%2F', '/',$url_path).'?'.api_get_cidreq();
        $path = str_replace('%2F', '/', $url_path);
        //yox view hack otherwise the image can't be well read
        $url = $www . $path;
        // Disabled fragment of code, there is a special icon for opening in a new window.
        //// Files that we want opened in a new window
        //if ($ext == 'txt' || $ext == 'log' || $ext == 'css' || $ext == 'js') { // Add here
        //    $target = '_blank';
        //}
    } else {
        //$url = api_get_self().'?'.api_get_cidreq().'&amp;curdirpath='.$url_path.$req_gid;
        $url = api_get_self() . '?' . api_get_cidreq() . '&id=' . $document_data['id'] . $req_gid;
    }
    // The little download icon
    //$tooltip_title = str_replace('?cidReq='.$_GET['cidReq'], '', basename($path));
    $tooltip_title = explode('?', basename($path));
    $tooltip_title = $title;
    $tooltip_title_alt = $tooltip_title;
    if ($path == '/shared_folder') {
        $tooltip_title_alt = get_lang('UserFolders');
    } elseif (strstr($path, 'shared_folder_session_')) {
        $tooltip_title_alt = get_lang('UserFolders') . ' (' . api_get_session_name(api_get_session_id()) . ')';
    } elseif (strstr($tooltip_title, 'sf_user_')) {
        $userinfo = api_get_user_info(substr($tooltip_title, 8));
        $tooltip_title_alt = get_lang('UserFolder') . ' ' . $userinfo['complete_name'];
    } elseif ($path == '/chat_files') {
        $tooltip_title_alt = get_lang('ChatFiles');
    } elseif ($path == '/learning_path') {
        $tooltip_title_alt = get_lang('LearningPaths');
    } elseif ($path == '/video') {
        $tooltip_title_alt = get_lang('Video');
    } elseif ($path == '/audio') {
        $tooltip_title_alt = get_lang('Audio');
    } elseif ($path == '/flash') {
        $tooltip_title_alt = get_lang('Flash');
    } elseif ($path == '/images') {
        $tooltip_title_alt = get_lang('Images');
    } elseif ($path == '/images/gallery') {
        $tooltip_title_alt = get_lang('DefaultCourseImages');
    }
    $current_session_id = api_get_session_id();
    $copy_to_myfiles = $open_in_new_window_link = null;
    $curdirpath = isset($_GET['curdirpath']) ? Security::remove_XSS($_GET['curdirpath']) : null;
    if (!$show_as_icon) {
        if ($filetype == 'folder') {
            if (api_is_allowed_to_edit() || api_is_platform_admin() || api_get_setting('students_download_folders') == 'true') {
                //filter when I am into shared folder, I can show for donwload only my shared folder
                if (is_shared_folder($curdirpath, $current_session_id)) {
                    if (preg_match('/shared_folder\\/sf_user_' . api_get_user_id() . '$/', urldecode($forcedownload_link)) || preg_match('/shared_folder_session_' . $current_session_id . '\\/sf_user_' . api_get_user_id() . '$/', urldecode($forcedownload_link)) || api_is_allowed_to_edit() || api_is_platform_admin()) {
                        $force_download_html = $size == 0 ? '' : '<a href="' . $forcedownload_link . '" style="float:right"' . $prevent_multiple_click . '>' . Display::return_icon($forcedownload_icon, get_lang('Download'), array(), ICON_SIZE_SMALL) . '</a>';
                    }
                } elseif (!preg_match('/shared_folder/', urldecode($forcedownload_link)) || api_is_allowed_to_edit() || api_is_platform_admin()) {
                    $force_download_html = $size == 0 ? '' : '<a href="' . $forcedownload_link . '" style="float:right"' . $prevent_multiple_click . '>' . Display::return_icon($forcedownload_icon, get_lang('Download'), array(), ICON_SIZE_SMALL) . '</a>';
                }
            }
        } else {
            $force_download_html = $size == 0 ? '' : '<a href="' . $forcedownload_link . '" style="float:right"' . $prevent_multiple_click . '>' . Display::return_icon($forcedownload_icon, get_lang('Download'), array(), ICON_SIZE_SMALL) . '</a>';
        }
        $send_to = null;
        //Copy files to users myfiles
        if (api_get_setting('allow_social_tool') == 'true' && api_get_setting('users_copy_files') == 'true' && !api_is_anonymous()) {
            $copy_myfiles_link = $filetype == 'file' ? api_get_self() . '?' . api_get_cidreq() . '&action=copytomyfiles&id=' . $document_data['id'] . $req_gid : api_get_self() . '?' . api_get_cidreq();
            if ($filetype == 'file') {
                $copy_to_myfiles = '<a href="' . $copy_myfiles_link . '" style="float:right"' . $prevent_multiple_click . '>' . Display::return_icon('briefcase.png', get_lang('CopyToMyFiles'), array(), ICON_SIZE_SMALL) . '&nbsp;&nbsp;</a>';
            }
            if ($filetype == 'file') {
                //$send_to = Portfolio::share('document', $document_data['id'], array('style' => 'float:right;'));
            }
        }
        $pdf_icon = '';
        $extension = pathinfo($path, PATHINFO_EXTENSION);
        if (!api_is_allowed_to_edit() && api_get_setting('students_export2pdf') == 'true' && $filetype == 'file' && in_array($extension, array('html', 'htm'))) {
            $pdf_icon = ' <a style="float:right".' . $prevent_multiple_click . ' href="' . api_get_self() . '?' . api_get_cidreq() . '&action=export_to_pdf&id=' . $document_data['id'] . '">' . Display::return_icon('pdf.png', get_lang('Export2PDF'), array(), ICON_SIZE_SMALL) . '</a> ';
        }
        if ($is_browser_viewable_file) {
            $open_in_new_window_link = '<a href="' . $www . str_replace('%2F', '/', $url_path) . '?' . api_get_cidreq() . '" style="float:right"' . $prevent_multiple_click . ' target="_blank">' . Display::return_icon('open_in_new_window.png', get_lang('OpenInANewWindow'), array(), ICON_SIZE_SMALL) . '&nbsp;&nbsp;</a>';
        }
        //target="'.$target.'"
        if ($filetype == 'file') {
            //Sound preview with jplayer
            if (preg_match('/mp3$/i', urldecode($url)) || preg_match('/wav$/i', urldecode($url)) && !preg_match('/_chnano_.wav$/i', urldecode($url)) || preg_match('/ogg$/i', urldecode($url))) {
                return '<span style="float:left" ' . $visibility_class . '>' . $title . '</span>' . $force_download_html . $send_to . $copy_to_myfiles . $open_in_new_window_link . $pdf_icon;
            } elseif (preg_match('/swf$/i', urldecode($url)) || preg_match('/png$/i', urldecode($url)) || preg_match('/gif$/i', urldecode($url)) || preg_match('/jpg$/i', urldecode($url)) || preg_match('/jpeg$/i', urldecode($url)) || preg_match('/bmp$/i', urldecode($url)) || preg_match('/svg$/i', urldecode($url)) || preg_match('/wav$/i', urldecode($url)) && preg_match('/_chnano_.wav$/i', urldecode($url)) && api_get_setting('enable_nanogong') == 'true') {
                //yox view
                //$url = 'showinframesmin.php?'.api_get_cidreq().'&id='.$document_data['id'].$req_gid;
                //Simpler version of showinframesmin.php with no headers
                $url = 'show_content.php?id=' . $document_data['id'] . $req_gid . '&' . api_get_cidreq() . '&width=700&height=500';
                $class = 'ajax';
                if ($visibility == false) {
                    $class = "ajax invisible";
                }
                return '<a href="' . $url . '" class="' . $class . '" title="' . $tooltip_title_alt . '" style="float:left">' . $title . '</a>' . $force_download_html . $send_to . $copy_to_myfiles . $open_in_new_window_link . $pdf_icon;
            } else {
                $url = 'showinframes.php?' . api_get_cidreq() . '&id=' . $document_data['id'] . $req_gid;
                //No plugin just the old and good showinframes.php page
                return '<a href="' . $url . '" title="' . $tooltip_title_alt . '" style="float:left" ' . $visibility_class . ' >' . $title . '</a>' . $force_download_html . $send_to . $copy_to_myfiles . $open_in_new_window_link . $pdf_icon;
            }
        } else {
            return '<a href="' . $url . '" title="' . $tooltip_title_alt . '" ' . $visibility_class . ' style="float:left">' . $title . '</a>' . $force_download_html . $send_to . $copy_to_myfiles . $open_in_new_window_link . $pdf_icon;
        }
        //end copy files to users myfiles
    } else {
        //Icon column
        if (preg_match('/shared_folder/', urldecode($url)) && preg_match('/shared_folder$/', urldecode($url)) == false && preg_match('/shared_folder_session_' . $current_session_id . '$/', urldecode($url)) == false) {
            if ($filetype == 'file') {
                //Sound preview with jplayer
                if (preg_match('/mp3$/i', urldecode($url)) || preg_match('/wav$/i', urldecode($url)) && !preg_match('/_chnano_.wav$/i', urldecode($url)) || preg_match('/ogg$/i', urldecode($url))) {
                    $sound_preview = DocumentManager::generate_media_preview($counter);
                    return $sound_preview;
                } elseif (preg_match('/swf$/i', urldecode($url)) || preg_match('/png$/i', urldecode($url)) || preg_match('/gif$/i', urldecode($url)) || preg_match('/jpg$/i', urldecode($url)) || preg_match('/jpeg$/i', urldecode($url)) || preg_match('/bmp$/i', urldecode($url)) || preg_match('/svg$/i', urldecode($url)) || preg_match('/wav$/i', urldecode($url)) && preg_match('/_chnano_.wav$/i', urldecode($url)) && api_get_setting('enable_nanogong') == 'true') {
                    $url = 'showinframes.php?' . api_get_cidreq() . '&id=' . $document_data['id'] . $req_gid;
                    return '<a href="' . $url . '" title="' . $tooltip_title_alt . '" ' . $visibility_class . ' style="float:left">' . build_document_icon_tag($filetype, $path) . Display::return_icon('shared.png', get_lang('ResourceShared'), array()) . '</a>';
                } else {
                    return '<a href="' . $url . '" title="' . $tooltip_title_alt . '" ' . $visibility_class . ' style="float:left">' . build_document_icon_tag($filetype, $path) . Display::return_icon('shared.png', get_lang('ResourceShared'), array()) . '</a>';
                }
            } else {
                return '<a href="' . $url . '" title="' . $tooltip_title_alt . '" target="' . $target . '"' . $visibility_class . ' style="float:left">' . build_document_icon_tag($filetype, $path) . Display::return_icon('shared.png', get_lang('ResourceShared'), array()) . '</a>';
            }
        } else {
            if ($filetype == 'file') {
                //Sound preview with jplayer
                if (preg_match('/mp3$/i', urldecode($url)) || preg_match('/wav$/i', urldecode($url)) && !preg_match('/_chnano_.wav$/i', urldecode($url)) || preg_match('/ogg$/i', urldecode($url))) {
                    $sound_preview = DocumentManager::generate_media_preview($counter);
                    return $sound_preview;
                } elseif (preg_match('/html$/i', urldecode($url)) || preg_match('/htm$/i', urldecode($url)) || preg_match('/swf$/i', urldecode($url)) || preg_match('/png$/i', urldecode($url)) || preg_match('/gif$/i', urldecode($url)) || preg_match('/jpg$/i', urldecode($url)) || preg_match('/jpeg$/i', urldecode($url)) || preg_match('/bmp$/i', urldecode($url)) || preg_match('/svg$/i', urldecode($url)) || preg_match('/wav$/i', urldecode($url)) && preg_match('/_chnano_.wav$/i', urldecode($url)) && api_get_setting('enable_nanogong') == 'true') {
                    $url = 'showinframes.php?' . api_get_cidreq() . '&id=' . $document_data['id'] . $req_gid;
                    //without preview
                    return '<a href="' . $url . '" title="' . $tooltip_title_alt . '" ' . $visibility_class . ' style="float:left">' . build_document_icon_tag($filetype, $path) . '</a>';
                } else {
                    return '<a href="' . $url . '" title="' . $tooltip_title_alt . '" ' . $visibility_class . ' style="float:left">' . build_document_icon_tag($filetype, $path) . '</a>';
                }
            } else {
                return '<a href="' . $url . '" title="' . $tooltip_title_alt . '" target="' . $target . '"' . $visibility_class . ' style="float:left">' . build_document_icon_tag($filetype, $path) . '</a>';
            }
        }
    }
}
コード例 #3
0
ファイル: work.lib.php プロジェクト: annickvdp/Chamilo1.9.10
/**
 * @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;
    }
}
コード例 #4
0
        $size = $id['filetype'] == 'folder' ? get_total_folder_size($id['path'], $is_allowed_to_edit) : $id[size];
        //get the title or the basename depending on what we're using
        if ($id['title'] != '') {
            $document_name = $id['title'];
        } else {
            $document_name = basename($id['path']);
        }
        //$row[] = $key; //testing
        //data for checkbox
        /*
        if ($is_allowed_to_edit AND count($docs_and_folders) > 1) {
        	$row[] = $id['path'];
        }
        */
        // icons with hyperlinks
        $row[] = '<a href="#" onclick="javascript: OpenFile(\'' . $http_www . '/' . $id['title'] . '\', \'' . $sType . '\');return false;">' . build_document_icon_tag($id['filetype'], $id['path']) . '</a>';
        //document title with hyperlink
        $row[] = '<a href="#" onclick="javascript: OpenFile(\'' . $http_www . '/' . $id['title'] . '\', \'' . $sType . '\');return false;">' . $id['title'] . '</a>';
        //comments => display comment under the document name
        //$row[] = $invisibility_span_open.nl2br(htmlspecialchars($id['comment'])).$invisibility_span_close;
        $display_size = format_file_size($size);
        $row[] = '<span style="display:none;">' . $size . '</span>' . $invisibility_span_open . $display_size . $invisibility_span_close;
        //last edit date
        $display_date = format_date(strtotime($id['lastedit_date']));
        $row[] = '<span style="display:none;">' . $id['lastedit_date'] . '</span>' . $invisibility_span_open . $display_date . $invisibility_span_close;
        $sortable_data[] = $row;
    }
} else {
    $sortable_data = array();
    //$table_footer='<div style="text-align:center;"><strong>'.get_lang('NoDocsInFolder').'</strong></div>';
}