Exemplo n.º 1
0
 /**
  * Creates the row of edit icons for a file/folder
  *
  * @param string $curdirpath current path (cfr open folder)
  * @param string $type (file/folder)
  * @param string $path dbase path of file/folder
  * @param int $visibility (1/0)
  * @param int $id dbase id of the document
  * @return string html img tags with hyperlinks
  */
 public static function build_edit_icons($document_data, $id, $is_template, $is_read_only = 0, $visibility)
 {
     $web_odf_extension_list = DocumentManager::get_web_odf_extension_list();
     $document_id = $document_data['id'];
     $type = $document_data['filetype'];
     $is_read_only = $document_data['readonly'];
     $path = $document_data['path'];
     $parent_id = DocumentManager::get_document_id(api_get_course_info(), dirname($path));
     $curdirpath = dirname($document_data['path']);
     $is_certificate_mode = DocumentManager::is_certificate_mode($path);
     $curdirpath = urlencode($curdirpath);
     $extension = pathinfo($path, PATHINFO_EXTENSION);
     //@todo Implement remote support for converter
     $usePpt2lp = api_get_setting('ppt_to_lp.active') == 'true' && api_get_setting('ppt_to_lp.host') == 'localhost';
     $formatTypeList = DocumentManager::getFormatTypeListConvertor('from', $extension);
     $formatType = current($formatTypeList);
     // Build URL-parameters for table-sorting
     $sort_params = array();
     if (isset($_GET['column'])) {
         $sort_params[] = 'column=' . Security::remove_XSS($_GET['column']);
     }
     if (isset($_GET['page_nr'])) {
         $sort_params[] = 'page_nr=' . Security::remove_XSS($_GET['page_nr']);
     }
     if (isset($_GET['per_page'])) {
         $sort_params[] = 'per_page=' . Security::remove_XSS($_GET['per_page']);
     }
     if (isset($_GET['direction'])) {
         $sort_params[] = 'direction=' . Security::remove_XSS($_GET['direction']);
     }
     $sort_params = implode('&', $sort_params);
     $visibility_icon = $visibility == 0 ? 'invisible' : 'visible';
     $visibility_command = $visibility == 0 ? 'set_visible' : 'set_invisible';
     $modify_icons = '';
     // If document is read only *or* we're in a session and the document
     // is from a non-session context, hide the edition capabilities
     if ($is_read_only) {
         if (api_is_course_admin() || api_is_platform_admin()) {
             if ($extension == 'svg' && api_browser_support('svg') && api_get_setting('editor.enabled_support_svg') == 'true') {
                 $modify_icons = '<a href="edit_draw.php?' . api_get_cidreq() . '&id=' . $document_id . '">' . Display::return_icon('edit.png', get_lang('Modify'), '', ICON_SIZE_SMALL) . '</a>';
             } elseif (in_array($extension, $web_odf_extension_list) && api_get_setting('enabled_support_odf') === true) {
                 $modify_icons = '<a href="edit_odf.php?' . api_get_cidreq() . '&id=' . $document_id . '">' . Display::return_icon('edit.png', get_lang('Modify'), '', ICON_SIZE_SMALL) . '</a>';
             } elseif ($extension == 'png' || $extension == 'jpg' || $extension == 'jpeg' || $extension == 'bmp' || $extension == 'gif' || $extension == 'pxd' && api_get_setting('editor.enabled_support_pixlr') == 'true') {
                 $modify_icons = '<a href="edit_paint.php?' . api_get_cidreq() . '&id=' . $document_id . '">' . Display::return_icon('edit.png', get_lang('Modify'), '', ICON_SIZE_SMALL) . '</a>';
             } else {
                 $modify_icons = '<a href="edit_document.php?' . api_get_cidreq() . '&id=' . $document_id . '">' . Display::return_icon('edit.png', get_lang('Modify'), '', ICON_SIZE_SMALL) . '</a>';
             }
         } else {
             $modify_icons = Display::return_icon('edit_na.png', get_lang('Modify'), '', ICON_SIZE_SMALL);
         }
         $modify_icons .= '&nbsp;' . Display::return_icon('move_na.png', get_lang('Move'), array(), ICON_SIZE_SMALL);
         if (api_is_allowed_to_edit() || api_is_platform_admin()) {
             $modify_icons .= '&nbsp;' . Display::return_icon($visibility_icon . '.png', get_lang('VisibilityCannotBeChanged'), '', ICON_SIZE_SMALL);
         }
         $modify_icons .= '&nbsp;' . Display::return_icon('delete_na.png', get_lang('Delete'), array(), ICON_SIZE_SMALL);
     } else {
         //Edit button
         if (in_array($path, DocumentManager::get_system_folders())) {
             $modify_icons = Display::return_icon('edit_na.png', get_lang('Modify'), '', ICON_SIZE_SMALL);
         } elseif ($is_certificate_mode) {
             // gradebook category doesn't seem to be taken into account
             $modify_icons = '<a href="edit_document.php?' . api_get_cidreq() . '&amp;id=' . $document_id . '&curdirpath=/certificates">' . Display::return_icon('edit.png', get_lang('Modify'), '', ICON_SIZE_SMALL) . '</a>';
         } else {
             if (api_get_session_id()) {
                 if ($document_data['session_id'] == api_get_session_id()) {
                     if ($extension == 'svg' && api_browser_support('svg') && api_get_setting('editor.enabled_support_svg') == 'true') {
                         $modify_icons = '<a href="edit_draw.php?' . api_get_cidreq() . '&amp;id=' . $document_id . '">' . Display::return_icon('edit.png', get_lang('Modify'), '', ICON_SIZE_SMALL) . '</a>';
                     } elseif (in_array($extension, $web_odf_extension_list) && api_get_setting('enabled_support_odf') === true) {
                         $modify_icons = '<a href="edit_odf.php?' . api_get_cidreq() . '&id=' . $document_id . '">' . Display::return_icon('edit.png', get_lang('Modify'), '', ICON_SIZE_SMALL) . '</a>';
                     } elseif ($extension == 'png' || $extension == 'jpg' || $extension == 'jpeg' || $extension == 'bmp' || $extension == 'gif' || $extension == 'pxd' && api_get_setting('editor.enabled_support_pixlr') == 'true') {
                         $modify_icons = '<a href="edit_paint.php?' . api_get_cidreq() . '&id=' . $document_id . '">' . Display::return_icon('edit.png', get_lang('Modify'), '', ICON_SIZE_SMALL) . '</a>';
                     } else {
                         $modify_icons = '<a href="edit_document.php?' . api_get_cidreq() . '&amp;id=' . $document_id . '">' . Display::return_icon('edit.png', get_lang('Modify'), '', ICON_SIZE_SMALL) . '</a>';
                     }
                 } else {
                     $modify_icons .= '&nbsp;' . Display::return_icon('edit_na.png', get_lang('Edit'), array(), ICON_SIZE_SMALL) . '</a>';
                 }
             } else {
                 if ($extension == 'svg' && api_browser_support('svg') && api_get_setting('editor.enabled_support_svg') == 'true') {
                     $modify_icons = '<a href="edit_draw.php?' . api_get_cidreq() . '&amp;id=' . $document_id . '">' . Display::return_icon('edit.png', get_lang('Modify'), '', ICON_SIZE_SMALL) . '</a>';
                 } elseif (in_array($extension, $web_odf_extension_list) && api_get_setting('enabled_support_odf') === true) {
                     $modify_icons = '<a href="edit_odf.php?' . api_get_cidreq() . '&id=' . $document_id . '">' . Display::return_icon('edit.png', get_lang('Modify'), '', ICON_SIZE_SMALL) . '</a>';
                 } elseif ($extension == 'png' || $extension == 'jpg' || $extension == 'jpeg' || $extension == 'bmp' || $extension == 'gif' || $extension == 'pxd' && api_get_setting('editor.enabled_support_pixlr') == 'true') {
                     $modify_icons = '<a href="edit_paint.php?' . api_get_cidreq() . '&amp;id=' . $document_id . '">' . Display::return_icon('edit.png', get_lang('Modify'), '', ICON_SIZE_SMALL) . '</a>';
                 } else {
                     $modify_icons = '<a href="edit_document.php?' . api_get_cidreq() . '&amp;id=' . $document_id . '">' . Display::return_icon('edit.png', get_lang('Modify'), '', ICON_SIZE_SMALL) . '</a>';
                 }
             }
         }
         // Move button.
         if ($is_certificate_mode || in_array($path, DocumentManager::get_system_folders())) {
             $modify_icons .= '&nbsp;' . Display::return_icon('move_na.png', get_lang('Move'), array(), ICON_SIZE_SMALL) . '</a>';
         } else {
             if (api_get_session_id()) {
                 if ($document_data['session_id'] == api_get_session_id()) {
                     $modify_icons .= '&nbsp;<a href="' . api_get_self() . '?' . api_get_cidreq() . '&amp;id=' . $parent_id . '&amp;move=' . $document_id . '">' . Display::return_icon('move.png', get_lang('Move'), array(), ICON_SIZE_SMALL) . '</a>';
                 } else {
                     $modify_icons .= '&nbsp;' . Display::return_icon('move_na.png', get_lang('Move'), array(), ICON_SIZE_SMALL) . '</a>';
                 }
             } else {
                 $modify_icons .= '&nbsp;<a href="' . api_get_self() . '?' . api_get_cidreq() . '&amp;id=' . $parent_id . '&amp;move=' . $document_id . '">' . Display::return_icon('move.png', get_lang('Move'), array(), ICON_SIZE_SMALL) . '</a>';
             }
         }
         //Visibility button
         if ($is_certificate_mode) {
             $modify_icons .= '&nbsp;' . Display::return_icon($visibility_icon . '.png', get_lang('VisibilityCannotBeChanged'), array(), ICON_SIZE_SMALL) . '</a>';
         } else {
             if (api_is_allowed_to_edit() || api_is_platform_admin()) {
                 if ($visibility_icon == 'invisible') {
                     $tip_visibility = get_lang('Show');
                 } else {
                     $tip_visibility = get_lang('Hide');
                 }
                 $modify_icons .= '&nbsp;<a href="' . api_get_self() . '?' . api_get_cidreq() . '&amp;id=' . $parent_id . '&amp;' . $visibility_command . '=' . $id . '&amp;' . $sort_params . '">' . Display::return_icon($visibility_icon . '.png', $tip_visibility, '', ICON_SIZE_SMALL) . '</a>';
             }
         }
         // Delete button
         if (in_array($path, DocumentManager::get_system_folders())) {
             $modify_icons .= '&nbsp;' . Display::return_icon('delete_na.png', get_lang('ThisFolderCannotBeDeleted'), array(), ICON_SIZE_SMALL);
         } else {
             $titleToShow = addslashes(basename($document_data['title']));
             if (isset($_GET['curdirpath']) && $_GET['curdirpath'] == '/certificates' && DocumentManager::get_default_certificate_id(api_get_course_id()) == $id) {
                 $modify_icons .= '&nbsp;<a href="' . api_get_self() . '?' . api_get_cidreq() . '&amp;curdirpath=' . $curdirpath . '&action=delete_item&id=' . $parent_id . '&deleteid=' . $document_id . '&amp;' . $sort_params . 'delete_certificate_id=' . $id . '" onclick="return confirmation(\'' . $titleToShow . '\');">' . Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL) . '</a>';
             } else {
                 if ($is_certificate_mode) {
                     $modify_icons .= '&nbsp;<a href="' . api_get_self() . '?' . api_get_cidreq() . '&amp;curdirpath=' . $curdirpath . '&action=delete_item&id=' . $parent_id . '&deleteid=' . $document_id . '&amp;' . $sort_params . '" onclick="return confirmation(\'' . $titleToShow . '\');">' . Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL) . '</a>';
                 } else {
                     if (api_get_session_id()) {
                         if ($document_data['session_id'] == api_get_session_id()) {
                             $modify_icons .= '&nbsp;<a href="' . api_get_self() . '?' . api_get_cidreq() . '&amp;curdirpath=' . $curdirpath . '&action=delete_item&id=' . $parent_id . '&deleteid=' . $document_id . '&amp;' . $sort_params . '" onclick="return confirmation(\'' . $titleToShow . '\');">' . Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL) . '</a>';
                         } else {
                             $modify_icons .= '&nbsp;' . Display::return_icon('delete_na.png', get_lang('ThisFolderCannotBeDeleted'), array(), ICON_SIZE_SMALL);
                         }
                     } else {
                         $modify_icons .= '&nbsp;<a href="' . api_get_self() . '?' . api_get_cidreq() . '&amp;curdirpath=' . $curdirpath . '&action=delete_item&id=' . $parent_id . '&deleteid=' . $document_id . '&amp;' . $sort_params . '" onclick="return confirmation(\'' . $titleToShow . '\');">' . Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL) . '</a>';
                     }
                 }
             }
         }
         // Add action to covert to PDF, will create a new document whit same filename but .pdf extension
         // @TODO: add prompt to select a format target
         if (in_array($path, DocumentManager::get_system_folders())) {
             // nothing to do
         } else {
             if ($usePpt2lp && $formatType) {
                 $modify_icons .= '&nbsp;<a class="convertAction" href="#" ' . 'data-documentId = ' . $document_id . ' data-formatType = ' . $formatType . '>' . Display::return_icon('convert.png', get_lang('Convert'), array(), ICON_SIZE_SMALL) . '</a>';
             }
         }
     }
     if ($type == 'file' && ($extension == 'html' || $extension == 'htm')) {
         if ($is_template == 0) {
             if (isset($_GET['curdirpath']) && $_GET['curdirpath'] != '/certificates' || !isset($_GET['curdirpath'])) {
                 $modify_icons .= '&nbsp;<a href="' . api_get_self() . '?' . api_get_cidreq() . '&amp;curdirpath=' . $curdirpath . '&amp;add_as_template=' . $id . '&amp;' . $sort_params . '">' . Display::return_icon('wizard.png', get_lang('AddAsTemplate'), array(), ICON_SIZE_SMALL) . '</a>';
             }
             if (isset($_GET['curdirpath']) && $_GET['curdirpath'] == '/certificates') {
                 //allow attach certificate to course
                 $visibility_icon_certificate = 'nocertificate';
                 if (DocumentManager::get_default_certificate_id(api_get_course_id()) == $id) {
                     $visibility_icon_certificate = 'certificate';
                     $certificate = get_lang('DefaultCertificate');
                     $preview = get_lang('PreviewCertificate');
                     $is_preview = true;
                 } else {
                     $is_preview = false;
                     $certificate = get_lang('NoDefaultCertificate');
                 }
                 if (isset($_GET['selectcat'])) {
                     $modify_icons .= '&nbsp;<a href="' . api_get_self() . '?' . api_get_cidreq() . '&amp;curdirpath=' . $curdirpath . '&amp;selectcat=' . Security::remove_XSS($_GET['selectcat']) . '&amp;set_certificate=' . $id . '&amp;' . $sort_params . '">
                 <img src="../img/' . $visibility_icon_certificate . '.png" border="0" title="' . $certificate . '" alt="" /></a>';
                     if ($is_preview) {
                         $modify_icons .= '&nbsp;<a target="_blank"  href="' . api_get_self() . '?' . api_get_cidreq() . '&amp;curdirpath=' . $curdirpath . '&amp;set_preview=' . $id . '&amp;' . $sort_params . '" >' . Display::return_icon('preview_view.png', $preview, '', ICON_SIZE_SMALL) . '</a>';
                     }
                 }
             }
         } else {
             $modify_icons .= '&nbsp;<a href="' . api_get_self() . '?' . api_get_cidreq() . '&curdirpath=' . $curdirpath . '&amp;remove_as_template=' . $id . '&amp;' . $sort_params . '">' . Display::return_icon('wizard_na.png', get_lang('RemoveAsTemplate'), '', ICON_SIZE_SMALL) . '</a>';
         }
         $modify_icons .= '&nbsp;<a href="' . api_get_self() . '?' . api_get_cidreq() . '&action=export_to_pdf&id=' . $id . '">' . Display::return_icon('pdf.png', get_lang('Export2PDF'), array(), ICON_SIZE_SMALL) . '</a>';
     }
     return $modify_icons;
 }
Exemplo n.º 2
0
                    Display::addFlash(Display::return_message(get_lang('CopyFailed'), 'error'));
                } else {
                    $cidReq = Security::remove_XSS($_GET['cidReq']);
                    $id_session = api_get_session_id();
                    $gidReq = Security::remove_XSS($_GET['gidReq']);
                    $file_link = Display::url(get_lang('SeeFile'), api_get_path(WEB_CODE_PATH) . 'document/showinframes.php?' . 'cidReq=' . $cidReq . '&id_session=' . $id_session . '&' . 'gidReq=' . $gidReq . '&id=' . current($result));
                    Display::addFlash(Display::return_message(get_lang('CopyMade') . ' ' . $file_link, 'confirmation', false));
                }
            }
        }
        break;
}
// I'm in the certification module?
$is_certificate_mode = false;
if (isset($_GET['curdirpath'])) {
    $is_certificate_mode = DocumentManager::is_certificate_mode($_GET['curdirpath']);
}
if (isset($_REQUEST['certificate']) && $_REQUEST['certificate'] == 'true') {
    $is_certificate_mode = true;
}
// If no actions we proceed to show the document (Hack in order to use document.php?id=X)
if (isset($document_id) && empty($action)) {
    // Get the document data from the ID
    $document_data = DocumentManager::get_document_data_by_id($document_id, api_get_course_id(), true, $sessionId);
    if ($sessionId != 0 && !$document_data) {
        // If there is a session defined and asking for the
        // document * from the session* didn't work, try it from the course
        // (out of a session context)
        $document_data = DocumentManager::get_document_data_by_id($document_id, api_get_course_id(), true, 0);
    }
    // If the document is not a folder we show the document.
Exemplo n.º 3
0
$dir = '/';
if (isset($_GET['id'])) {
    $document_data = DocumentManager::get_document_data_by_id($_GET['id'], api_get_course_id(), true);
    $document_id = $document_data['id'];
    $file = $document_data['path'];
    $parent_id = DocumentManager::get_document_id($course_info, dirname($file));
    $dir = dirname($document_data['path']);
    $dir_original = $dir;
    $doc = basename($file);
    $my_cur_dir_path = isset($_GET['curdirpath']) ? Security::remove_XSS($_GET['curdirpath']) : null;
    $readonly = $document_data['readonly'];
}
if (empty($document_data)) {
    api_not_allowed();
}
$is_certificate_mode = DocumentManager::is_certificate_mode($dir);
//Call from
$call_from_tool = isset($_GET['origin']) ? Security::remove_XSS($_GET['origin']) : null;
$slide_id = isset($_GET['origin_opt']) ? Security::remove_XSS($_GET['origin_opt']) : null;
$file_name = $doc;
$group_document = false;
$current_session_id = api_get_session_id();
$user_id = api_get_user_id();
$doc_tree = explode('/', $file);
$count_dir = count($doc_tree) - 2;
// "2" because at the begin and end there are 2 "/"
// Level correction for group documents.
if (!empty($group_properties['directory'])) {
    $count_dir = $count_dir > 0 ? $count_dir - 1 : 0;
}
$relative_url = '';
Exemplo n.º 4
0
/**
 * Creates the row of edit icons for a file/folder
 *
 * @param string $curdirpath current path (cfr open folder)
 * @param string $type (file/folder)
 * @param string $path dbase path of file/folder
 * @param int $visibility (1/0)
 * @param int $id dbase id of the document
 * @return string html img tags with hyperlinks
 */
function build_edit_icons($document_data, $id, $is_template, $is_read_only = 0, $visibility)
{
    if (isset($_SESSION['_gid'])) {
        $req_gid = '&gidReq=' . $_SESSION['_gid'];
    } else {
        $req_gid = '';
    }
    $document_id = $document_data['id'];
    $type = $document_data['filetype'];
    $is_read_only = $document_data['readonly'];
    $path = $document_data['path'];
    $parent_id = DocumentManager::get_document_id(api_get_course_info(), dirname($path));
    $curdirpath = dirname($document_data['path']);
    $is_certificate_mode = DocumentManager::is_certificate_mode($path);
    $curdirpath = urlencode($curdirpath);
    $extension = pathinfo($path, PATHINFO_EXTENSION);
    // Build URL-parameters for table-sorting
    $sort_params = array();
    if (isset($_GET['column'])) {
        $sort_params[] = 'column=' . Security::remove_XSS($_GET['column']);
    }
    if (isset($_GET['page_nr'])) {
        $sort_params[] = 'page_nr=' . Security::remove_XSS($_GET['page_nr']);
    }
    if (isset($_GET['per_page'])) {
        $sort_params[] = 'per_page=' . Security::remove_XSS($_GET['per_page']);
    }
    if (isset($_GET['direction'])) {
        $sort_params[] = 'direction=' . Security::remove_XSS($_GET['direction']);
    }
    $sort_params = implode('&amp;', $sort_params);
    $visibility_icon = $visibility == 0 ? 'invisible' : 'visible';
    $visibility_command = $visibility == 0 ? 'set_visible' : 'set_invisible';
    $modify_icons = '';
    // If document is read only *or* we're in a session and the document
    // is from a non-session context, hide the edition capabilities
    if ($is_read_only) {
        if (api_is_course_admin() || api_is_platform_admin()) {
            if ($extension == 'svg' && api_browser_support('svg') && api_get_setting('enabled_support_svg') == 'true') {
                $modify_icons = '<a href="edit_draw.php?' . api_get_cidreq() . '&id=' . $document_id . $req_gid . '">' . Display::return_icon('edit.png', get_lang('Modify'), '', ICON_SIZE_SMALL) . '</a>';
            } elseif ($extension == 'png' || $extension == 'jpg' || $extension == 'jpeg' || $extension == 'bmp' || $extension == 'gif' || $extension == 'pxd' && api_get_setting('enabled_support_pixlr') == 'true') {
                $modify_icons = '<a href="edit_paint.php?' . api_get_cidreq() . '&id=' . $document_id . $req_gid . '">' . Display::return_icon('edit.png', get_lang('Modify'), '', ICON_SIZE_SMALL) . '</a>';
            } else {
                $modify_icons = '<a href="edit_document.php?' . api_get_cidreq() . '&id=' . $document_id . $req_gid . '">' . Display::return_icon('edit.png', get_lang('Modify'), '', ICON_SIZE_SMALL) . '</a>';
            }
        } else {
            $modify_icons = Display::return_icon('edit_na.png', get_lang('Modify'), '', ICON_SIZE_SMALL);
        }
        $modify_icons .= '&nbsp;' . Display::return_icon('move_na.png', get_lang('Move'), array(), ICON_SIZE_SMALL);
        if (api_is_allowed_to_edit() || api_is_platform_admin()) {
            $modify_icons .= '&nbsp;' . Display::return_icon($visibility_icon . '.png', get_lang('VisibilityCannotBeChanged'), '', ICON_SIZE_SMALL);
        }
        $modify_icons .= '&nbsp;' . Display::return_icon('delete_na.png', get_lang('Delete'), array(), ICON_SIZE_SMALL);
    } else {
        //Edit button
        if (in_array($path, DocumentManager::get_system_folders())) {
            $modify_icons = Display::return_icon('edit_na.png', get_lang('Modify'), '', ICON_SIZE_SMALL);
        } elseif ($is_certificate_mode) {
            // gradebook category doesn't seem to be taken into account
            $modify_icons = '<a href="edit_document.php?' . api_get_cidreq() . '&amp;id=' . $document_id . $req_gid . '&curdirpath=/certificates">' . Display::return_icon('edit.png', get_lang('Modify'), '', ICON_SIZE_SMALL) . '</a>';
        } else {
            if (api_get_session_id()) {
                if ($document_data['session_id'] == api_get_session_id()) {
                    if ($extension == 'svg' && api_browser_support('svg') && api_get_setting('enabled_support_svg') == 'true') {
                        $modify_icons = '<a href="edit_draw.php?' . api_get_cidreq() . '&amp;id=' . $document_id . $req_gid . '">' . Display::return_icon('edit.png', get_lang('Modify'), '', ICON_SIZE_SMALL) . '</a>';
                    } elseif ($extension == 'png' || $extension == 'jpg' || $extension == 'jpeg' || $extension == 'bmp' || $extension == 'gif' || $extension == 'pxd' && api_get_setting('enabled_support_pixlr') == 'true') {
                        $modify_icons = '<a href="edit_paint.php?' . api_get_cidreq() . '&amp;id=' . $document_id . $req_gid . '">' . Display::return_icon('edit.png', get_lang('Modify'), '', ICON_SIZE_SMALL) . '</a>';
                    } else {
                        $modify_icons = '<a href="edit_document.php?' . api_get_cidreq() . '&amp;id=' . $document_id . $req_gid . '">' . Display::return_icon('edit.png', get_lang('Modify'), '', ICON_SIZE_SMALL) . '</a>';
                    }
                } else {
                    $modify_icons .= '&nbsp;' . Display::return_icon('edit_na.png', get_lang('Edit'), array(), ICON_SIZE_SMALL) . '</a>';
                }
            } else {
                if ($extension == 'svg' && api_browser_support('svg') && api_get_setting('enabled_support_svg') == 'true') {
                    $modify_icons = '<a href="edit_draw.php?' . api_get_cidreq() . '&amp;id=' . $document_id . $req_gid . '">' . Display::return_icon('edit.png', get_lang('Modify'), '', ICON_SIZE_SMALL) . '</a>';
                } elseif ($extension == 'png' || $extension == 'jpg' || $extension == 'jpeg' || $extension == 'bmp' || $extension == 'gif' || $extension == 'pxd' && api_get_setting('enabled_support_pixlr') == 'true') {
                    $modify_icons = '<a href="edit_paint.php?' . api_get_cidreq() . '&amp;id=' . $document_id . $req_gid . '">' . Display::return_icon('edit.png', get_lang('Modify'), '', ICON_SIZE_SMALL) . '</a>';
                } else {
                    $modify_icons = '<a href="edit_document.php?' . api_get_cidreq() . '&amp;id=' . $document_id . $req_gid . '">' . Display::return_icon('edit.png', get_lang('Modify'), '', ICON_SIZE_SMALL) . '</a>';
                }
            }
        }
        //Move button
        if ($is_certificate_mode || in_array($path, DocumentManager::get_system_folders())) {
            $modify_icons .= '&nbsp;' . Display::return_icon('move_na.png', get_lang('Move'), array(), ICON_SIZE_SMALL) . '</a>';
        } else {
            if (api_get_session_id()) {
                if ($document_data['session_id'] == api_get_session_id()) {
                    $modify_icons .= '&nbsp;<a href="' . api_get_self() . '?' . api_get_cidreq() . '&amp;id=' . $parent_id . '&amp;move=' . $document_id . $req_gid . '">' . Display::return_icon('move.png', get_lang('Move'), array(), ICON_SIZE_SMALL) . '</a>';
                } else {
                    $modify_icons .= '&nbsp;' . Display::return_icon('move_na.png', get_lang('Move'), array(), ICON_SIZE_SMALL) . '</a>';
                }
            } else {
                $modify_icons .= '&nbsp;<a href="' . api_get_self() . '?' . api_get_cidreq() . '&amp;id=' . $parent_id . '&amp;move=' . $document_id . $req_gid . '">' . Display::return_icon('move.png', get_lang('Move'), array(), ICON_SIZE_SMALL) . '</a>';
            }
        }
        //Visibility button
        if ($is_certificate_mode) {
            $modify_icons .= '&nbsp;' . Display::return_icon($visibility_icon . '.png', get_lang('VisibilityCannotBeChanged'), array(), ICON_SIZE_SMALL) . '</a>';
        } else {
            if (api_is_allowed_to_edit() || api_is_platform_admin()) {
                if ($visibility_icon == 'invisible') {
                    $tip_visibility = get_lang('Show');
                } else {
                    $tip_visibility = get_lang('Hide');
                }
                $modify_icons .= '&nbsp;<a href="' . api_get_self() . '?' . api_get_cidreq() . '&amp;id=' . $parent_id . '&amp;' . $visibility_command . '=' . $id . $req_gid . '&amp;' . $sort_params . '">' . Display::return_icon($visibility_icon . '.png', $tip_visibility, '', ICON_SIZE_SMALL) . '</a>';
            }
        }
        //Delete button
        if (in_array($path, DocumentManager::get_system_folders())) {
            $modify_icons .= '&nbsp;' . Display::return_icon('delete_na.png', get_lang('ThisFolderCannotBeDeleted'), array(), ICON_SIZE_SMALL);
        } else {
            if (isset($_GET['curdirpath']) && $_GET['curdirpath'] == '/certificates' && DocumentManager::get_default_certificate_id(api_get_course_id()) == $id) {
                $modify_icons .= '&nbsp;<a href="' . api_get_self() . '?' . api_get_cidreq() . '&amp;curdirpath=' . $curdirpath . '&amp;delete=' . urlencode($path) . $req_gid . '&amp;' . $sort_params . 'delete_certificate_id=' . $id . '" onclick="return confirmation(\'' . basename($path) . '\');">' . Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL) . '</a>';
            } else {
                if ($is_certificate_mode) {
                    $modify_icons .= '&nbsp;<a href="' . api_get_self() . '?' . api_get_cidreq() . '&amp;curdirpath=' . $curdirpath . '&amp;delete=' . urlencode($path) . $req_gid . '&amp;' . $sort_params . '" onclick="return confirmation(\'' . basename($path) . '\');">' . Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL) . '</a>';
                } else {
                    if (api_get_session_id()) {
                        if ($document_data['session_id'] == api_get_session_id()) {
                            $modify_icons .= '&nbsp;<a href="' . api_get_self() . '?' . api_get_cidreq() . '&amp;curdirpath=' . $curdirpath . '&amp;delete=' . urlencode($path) . $req_gid . '&amp;' . $sort_params . '" onclick="return confirmation(\'' . basename($path) . '\');">' . Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL) . '</a>';
                        } else {
                            $modify_icons .= '&nbsp;' . Display::return_icon('delete_na.png', get_lang('ThisFolderCannotBeDeleted'), array(), ICON_SIZE_SMALL);
                        }
                    } else {
                        $modify_icons .= '&nbsp;<a href="' . api_get_self() . '?' . api_get_cidreq() . '&amp;curdirpath=' . $curdirpath . '&amp;delete=' . urlencode($path) . $req_gid . '&amp;' . $sort_params . '" onclick="return confirmation(\'' . basename($path) . '\');">' . Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL) . '</a>';
                    }
                }
            }
        }
    }
    if ($type == 'file' && ($extension == 'html' || $extension == 'htm')) {
        if ($is_template == 0) {
            if (isset($_GET['curdirpath']) && $_GET['curdirpath'] != '/certificates' || !isset($_GET['curdirpath'])) {
                $modify_icons .= '&nbsp;<a href="' . api_get_self() . '?' . api_get_cidreq() . '&amp;curdirpath=' . $curdirpath . '&amp;add_as_template=' . $id . $req_gid . '&amp;' . $sort_params . '">' . Display::return_icon('wizard.png', get_lang('AddAsTemplate'), array(), ICON_SIZE_SMALL) . '</a>';
            }
            if (isset($_GET['curdirpath']) && $_GET['curdirpath'] == '/certificates') {
                //allow attach certificate to course
                $visibility_icon_certificate = 'nocertificate';
                if (DocumentManager::get_default_certificate_id(api_get_course_id()) == $id) {
                    $visibility_icon_certificate = 'certificate';
                    $certificate = get_lang('DefaultCertificate');
                    $preview = get_lang('PreviewCertificate');
                    $is_preview = true;
                } else {
                    $is_preview = false;
                    $certificate = get_lang('NoDefaultCertificate');
                }
                if (isset($_GET['selectcat'])) {
                    $modify_icons .= '&nbsp;<a href="' . api_get_self() . '?' . api_get_cidreq() . '&amp;curdirpath=' . $curdirpath . '&amp;selectcat=' . Security::remove_XSS($_GET['selectcat']) . '&amp;set_certificate=' . $id . $req_gid . '&amp;' . $sort_params . '">
                        ' . Display::return_icon($visibility_icon_certificate . '.png', $certificate) . '
                    </a>';
                    if ($is_preview) {
                        $modify_icons .= '&nbsp;<a target="_blank"  href="' . api_get_self() . '?' . api_get_cidreq() . '&amp;curdirpath=' . $curdirpath . '&amp;set_preview=' . $id . $req_gid . '&amp;' . $sort_params . '" >' . Display::return_icon('preview_view.png', $preview, '', ICON_SIZE_SMALL) . '</a>';
                    }
                }
            }
        } else {
            $modify_icons .= '&nbsp;<a href="' . api_get_self() . '?' . api_get_cidreq() . '&curdirpath=' . $curdirpath . '&amp;remove_as_template=' . $id . $req_gid . '&amp;' . $sort_params . '">' . Display::return_icon('wizard_na.png', get_lang('RemoveAsTemplate'), '', ICON_SIZE_SMALL) . '</a>';
        }
        $modify_icons .= '&nbsp;<a href="' . api_get_self() . '?' . api_get_cidreq() . '&action=export_to_pdf&id=' . $id . '">' . Display::return_icon('pdf.png', get_lang('Export2PDF'), array(), ICON_SIZE_SMALL) . '</a>';
    }
    return $modify_icons;
}