to the QuickForm object displaying the form)
* @todo this funcionality is really bad : jmontoya
* @return string html form
*/
function build_directory_selector($folders, $document_id, $group_dir = '', $change_renderer = false) {
$doc_table = Database::get_course_table(TABLE_DOCUMENT);
$course_id = api_get_course_int_id();
$folder_titles = array();
if (api_get_setting('use_document_title') == 'true') {
if (is_array($folders)) {
$escaped_folders = array();
foreach ($folders as $key => & $val) {
$escaped_folders[$key] = Database::escape_string($val);
}
$folder_sql = implode("','", $escaped_folders);
$sql = "SELECT * FROM $doc_table WHERE filetype = 'folder' AND c_id = $course_id AND path IN ('".$folder_sql."')";
$res = Database::query($sql);
$folder_titles = array();
while ($obj = Database::fetch_object($res)) {
$folder_titles[$obj->path] = $obj->title;
}
}
} else {
if (is_array($folders)) {
foreach ($folders as & $folder) {
$folder_titles[$folder] = basename($folder);
}
}
}
$form = new FormValidator('selector', 'GET', api_get_self().'?'.api_get_cidreq());
$form->addElement('hidden', 'cidReq', api_get_course_id());
$parent_select = $form->addElement('select', 'id', get_lang('CurrentDirectory'), '', 'onchange="javascript: document.selector.submit();"');
if ($change_renderer) {
$renderer = $form->defaultRenderer();
$renderer->setElementTemplate('{label} : {element} ','curdirpath');
}
// Group documents cannot be uploaded in the root
if (empty($group_dir)) {
$parent_select -> addOption(get_lang('Documents'), '/');
if (is_array($folders)) {
foreach ($folders as $folder_id => & $folder) {
$selected = ($document_id == $folder_id) ? ' selected="selected"' : '';
$path_parts = explode('/', $folder);
$folder_titles[$folder] = cut($folder_titles[$folder], 80);
$label = str_repeat(' ', count($path_parts) - 2).' — '.$folder_titles[$folder];
$parent_select -> addOption($label, $folder_id);
if ($selected != '') {
$parent_select->setSelected($folder_id);
}
}
}
} else {
foreach ($folders as $folder_id => & $folder) {
$selected = ($document_id == $folder_id) ? ' selected="selected"' : '';
$label = $folder_titles[$folder];
if ($folder == $group_dir) {
$label = get_lang('Documents');
} else {
$path_parts = explode('/', str_replace($group_dir, '', $folder));
$label = cut($label, 80);
$label = str_repeat(' ', count($path_parts) - 2).' — '.$label;
}
$parent_select -> addOption($label, $folder_id);
if ($selected != '') {
$parent_select->setSelected($folder_id);
}
}
}
$form = $form->toHtml();
return $form;
}
/**
* 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 = '&gidReq='.$_SESSION['_gid'];
} else {
$req_gid = '';
}
$course_info = api_get_course_info();
$www = api_get_path(WEB_COURSE_PATH).$course_info['path'].'/document';
$use_document_title = api_get_setting('use_document_title');
// Get the title or the basename depending on what we're using
if ($use_document_title == 'true' && $document_data['title'] != '') {
$title = $document_data['title'];
} else {
$title = basename($document_data['path']);
}
$filetype = $document_data['filetype'];
$size = $filetype == 'folder' ? 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="invisible"' : '';
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().'&action=download&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().'&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().'&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 = $tooltip_title[0];
$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 = Database::get_user_info_from_id(substr($tooltip_title, 8));
$tooltip_title_alt = get_lang('UserFolder').' '.api_get_person_name($userinfo['firstname'], $userinfo['lastname']);
} elseif($path == '/chat_files') {
$tooltip_title_alt = get_lang('ChatFiles');
} 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) ? '' : ''.Display::return_icon($forcedownload_icon, get_lang('Download'), array(),ICON_SIZE_SMALL).'';
}
} elseif(!preg_match('/shared_folder/', urldecode($forcedownload_link)) || api_is_allowed_to_edit() || api_is_platform_admin()) {
$force_download_html = ($size == 0) ? '' : ''.Display::return_icon($forcedownload_icon, get_lang('Download'), array(),ICON_SIZE_SMALL).'';
}
}
} else {
$force_download_html = ($size==0)?'':''.Display::return_icon($forcedownload_icon, get_lang('Download'), array(),ICON_SIZE_SMALL).'';
}
//copy files to users myfiles
if (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 = ''.Display::return_icon('briefcase.png', get_lang('CopyToMyFiles'), array(),ICON_SIZE_SMALL).' ';
}
}
$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 = ' '.Display::return_icon('pdf.png', get_lang('Export2PDF'),array(), 22).' ';
}
if ($is_browser_viewable_file) {
$open_in_new_window_link = ''.Display::return_icon('open_in_new_window.png', get_lang('OpenInANewWindow'), array(),ICON_SIZE_SMALL).' ';
}
//target="'.$target.'"
if ($filetype == 'file') {
//Sound preview with jplayer
if ( preg_match('/mp3$/i', urldecode($url)) ||
preg_match('/wav$/i', urldecode($url)) ||
preg_match('/ogg$/i', urldecode($url))) {
return ''.$title.''.$force_download_html.$copy_to_myfiles.$open_in_new_window_link.$pdf_icon;
} elseif (
//Show preview sith yoxview
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('/html$/i', urldecode($url)) ||
//preg_match('/htm$/i', urldecode($url))
//|| (preg_match('/wav$/', 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?'.api_get_cidreq().'&id='.$document_data['id'].$req_gid.'&width=700&height=500';
$class = 'thickbox';
if ($visibility == false) {
$class = "thickbox invisible";
}
return ''.$title.''.$force_download_html.$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 ''.$title.''.$force_download_html.$copy_to_myfiles.$open_in_new_window_link.$pdf_icon;
}
} else {
return ''.$title.''.$force_download_html.$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('/ogg$/i', urldecode($url))) {
$sound_preview = DocumentManager::generate_media_preview($counter);
return $sound_preview ;
} elseif (
//Show preview sith yoxview
preg_match('/swf$/i', urldecode($url)) ||
preg_match('/html$/i', urldecode($url)) ||
preg_match('/htm$/i', urldecode($url)) //|| (preg_match('/wav$/', urldecode($url)) && api_get_setting('enable_nanogong') == 'true')
) {
$url = 'showinframesmin.php?'.api_get_cidreq().'&id='.$document_data['id'].$req_gid;
return ''.build_document_icon_tag($filetype, $path).Display::return_icon('shared.png', get_lang('ResourceShared'), array('hspace' => '5', 'align' => 'middle', 'height' => 22, 'width' => 22)).'';
} else {
return ''.build_document_icon_tag($filetype, $path).Display::return_icon('shared.png', get_lang('ResourceShared'), array('hspace' => '5', 'align' => 'middle', 'height' => 22, 'width' => 22)).'';
}
} else {
return ''.build_document_icon_tag($filetype, $path).Display::return_icon('shared.png', get_lang('ResourceShared'), array('hspace' => '5', 'align' => 'middle', 'height' => 22, 'width' => 22)).'';
}
} else {
if ($filetype == 'file') {
//Sound preview with jplayer
if ( preg_match('/mp3$/i', urldecode($url)) ||
preg_match('/wav$/i', urldecode($url)) ||
preg_match('/ogg$/i', urldecode($url))) {
$sound_preview = DocumentManager::generate_media_preview($counter);
return $sound_preview ;
} elseif (
//Show preview sith yoxview
preg_match('/swf$/i', urldecode($url)) ||
preg_match('/html$/i', urldecode($url)) ||
preg_match('/htm$/i', urldecode($url)) //|| (preg_match('/wav$/', urldecode($url)) && api_get_setting('enable_nanogong') == 'true')
) {
$url = 'showinframesmin.php?'.api_get_cidreq().'&id='.$document_data['id'].$req_gid;
return ''.build_document_icon_tag($filetype, $path).'';
} else {
return ''.build_document_icon_tag($filetype, $path).'';
}
} else {
return ''.build_document_icon_tag($filetype, $path).'';
}
}
}
}
/**
* Builds an img html tag for the filetype
*
* @param string $type (file/folder)
* @param string $path
* @return string img html tag
*/
function build_document_icon_tag($type, $path) {
$basename = basename($path);
$current_session_id = api_get_session_id();
$is_allowed_to_edit = api_is_allowed_to_edit(null, true);
if ($type == 'file') {
$icon = choose_image($basename);
} else {
if ($path == '/shared_folder') {
$icon = 'folder_users.gif';
if ($is_allowed_to_edit) {
$basename = get_lang('HelpUsersFolder');
} else {
$basename = get_lang('UserFolders');
}
}elseif(strstr($basename, 'sf_user_')) {
$userinfo = Database::get_user_info_from_id(substr($basename, 8));
$image_path = UserManager::get_user_picture_path_by_id(substr($basename, 8), 'web', false, true);
if ($image_path['file'] == 'unknown.jpg') {
$icon = $image_path['file'];
} else {
$icon = '../upload/users/'.substr($basename, 8).'/'.$image_path['file'];
}
$basename = get_lang('UserFolder').' '.api_get_person_name($userinfo['firstname'], $userinfo['lastname']);}elseif(strstr($path, 'shared_folder_session_')) {
if ($is_allowed_to_edit) {
$basename = '***('.api_get_session_name($current_session_id).')*** '.get_lang('HelpUsersFolder');
} else {
$basename = get_lang('UserFolders').' ('.api_get_session_name($current_session_id).')';
}
$icon = 'folder_users.gif';
} else {
$icon = 'folder_document.gif';
if($path=='/audio'){
$icon = 'folder_audio.gif';
if(api_is_allowed_to_edit()){
$basename=get_lang('HelpDefaultDirDocuments');
}
else{
$basename=get_lang('Audio');
}
}
elseif($path =='/flash'){
$icon = 'folder_flash.gif';
if(api_is_allowed_to_edit()){
$basename=get_lang('HelpDefaultDirDocuments');
}
else{
$basename=get_lang('Flash');
}
}
elseif($path =='/images'){
$icon = 'folder_images.gif';
if(api_is_allowed_to_edit()){
$basename=get_lang('HelpDefaultDirDocuments');
}
else{
$basename=get_lang('Images');
}
}
elseif($path =='/video'){
$icon = 'folder_video.gif';
if(api_is_allowed_to_edit()){
$basename=get_lang('HelpDefaultDirDocuments');
}
else{
$basename=get_lang('Video');
}
}
elseif($path =='/images/gallery'){
$icon = 'folder_gallery.gif';
if(api_is_allowed_to_edit()){
$basename=get_lang('HelpDefaultDirDocuments');
}
else{
$basename=get_lang('Gallery');
}
}
elseif($path =='/chat_files'){
$icon = 'folder_chat.gif';
if(api_is_allowed_to_edit()){
$basename=get_lang('HelpFolderChat');
}
else{
$basename=get_lang('ChatFiles');
}
}
}
}
return Display::return_icon($icon, $basename, array('hspace' => '5', 'align' => 'middle', 'height' => 22, 'width' => 22));
}
/**
* 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('&', $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 /*or ($session_id!=api_get_session_id())*/) {
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 = ''.Display::return_icon('edit.png', get_lang('Modify'),'',ICON_SIZE_SMALL).'';
} elseif($extension=='png' || $extension=='jpg' || $extension=='jpeg' || $extension=='bmp' || $extension=='gif' ||$extension=='pxd' && api_get_setting('enabled_support_pixlr') == 'true'){
$modify_icons = ''.Display::return_icon('edit.png', get_lang('Modify'),'',ICON_SIZE_SMALL).'';
} else {
$modify_icons = ''.Display::return_icon('edit.png', get_lang('Modify'),'',ICON_SIZE_SMALL).'';
}
} else {
$modify_icons = Display::return_icon('edit_na.png', get_lang('Modify'),'',ICON_SIZE_SMALL);
}
$modify_icons .= ' '.Display::return_icon('move_na.png', get_lang('Move'),array(), 22);
if (api_is_allowed_to_edit() || api_is_platform_admin()) {
$modify_icons .= ' '.Display::return_icon($visibility_icon.'.png', get_lang('VisibilityCannotBeChanged'),'',ICON_SIZE_SMALL);
}
$modify_icons .= ' '.Display::return_icon('delete_na.png', get_lang('Delete'),array(), 22);
} else {
if ($is_certificate_mode) {
// gradebook category doesn't seem to be taken into account
//$modify_icons = ''.Display::return_icon('edit.png', get_lang('Modify'),'',ICON_SIZE_SMALL).'';
$modify_icons = ''.Display::return_icon('edit.png', get_lang('Modify'),'',ICON_SIZE_SMALL).'';
} 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 = ''.Display::return_icon('edit.png', get_lang('Modify'),'',ICON_SIZE_SMALL).'';
} elseif($extension=='png' || $extension=='jpg' || $extension=='jpeg' || $extension=='bmp' || $extension=='gif' ||$extension=='pxd' && api_get_setting('enabled_support_pixlr') == 'true'){
$modify_icons = ''.Display::return_icon('edit.png', get_lang('Modify'),'',ICON_SIZE_SMALL).'';
} else {
$modify_icons = ''.Display::return_icon('edit.png', get_lang('Modify'),'',ICON_SIZE_SMALL).'';
}
} else {
$modify_icons .= ' '.Display::return_icon('edit_na.png', get_lang('Edit'),array(), 22).'';
}
} else {
if ($extension=='svg' && api_browser_support('svg') && api_get_setting('enabled_support_svg') == 'true') {
$modify_icons = ''.Display::return_icon('edit.png', get_lang('Modify'),'',ICON_SIZE_SMALL).'';
} elseif($extension=='png' || $extension=='jpg' || $extension=='jpeg' || $extension=='bmp' || $extension=='gif' ||$extension=='pxd' && api_get_setting('enabled_support_pixlr') == 'true'){
$modify_icons = ''.Display::return_icon('edit.png', get_lang('Modify'),'',ICON_SIZE_SMALL).'';
} else {
$modify_icons = ''.Display::return_icon('edit.png', get_lang('Modify'),'',ICON_SIZE_SMALL).'';
}
}
}
if ($is_certificate_mode) {
//$modify_icons .= ' '.Display::return_icon('move.png', get_lang('Move'),array(), 22).'';
$modify_icons .= ' '.Display::return_icon('move_na.png', get_lang('Move'),array(), 22).'';
$modify_icons .= ' '.Display::return_icon($visibility_icon.'.png', get_lang('VisibilityCannotBeChanged'),array(), 22).'';
Display::return_icon($visibility_icon.'.png', get_lang('VisibilityCannotBeChanged'),array(), 22).'';
} else {
if (api_get_session_id()) {
if ($document_data['session_id'] == api_get_session_id()) {
$modify_icons .= ' '.Display::return_icon('move.png', get_lang('Move'),array(), 22).'';
} else {
$modify_icons .= ' '.Display::return_icon('move_na.png', get_lang('Move'),array(), 22).'';
}
} else {
$modify_icons .= ' '.Display::return_icon('move.png', get_lang('Move'),array(), 22).'';
}
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 .= ' '.Display::return_icon($visibility_icon.'.png', $tip_visibility,'',ICON_SIZE_SMALL).'';
}
}
if (in_array($path, array('/audio', '/flash', '/images', '/shared_folder', '/video', '/chat_files', '/certificates'))) {
$modify_icons .= ' '.Display::return_icon('delete_na.png', get_lang('ThisFolderCannotBeDeleted'),array(), 22);
} else {
if (isset($_GET['curdirpath']) && $_GET['curdirpath']=='/certificates' && DocumentManager::get_default_certificate_id(api_get_course_id())==$id) {
//$modify_icons .= ' '.Display::return_icon('delete.png', get_lang('Delete'),array(), 22).'';
$modify_icons .= ' '.Display::return_icon('delete.png', get_lang('Delete'),array(), 22).'';
} else {
if ($is_certificate_mode) {
//$modify_icons .= ' '.Display::return_icon('delete.png', get_lang('Delete'),array(), 22).'';
$modify_icons .= ' '.Display::return_icon('delete.png', get_lang('Delete'),array(), 22).'';
} else {
if (api_get_session_id()) {
if ($document_data['session_id'] == api_get_session_id()) {
$modify_icons .= ' '.Display::return_icon('delete.png', get_lang('Delete'),array(), 22).'';
} else {
$modify_icons .= ' '.Display::return_icon('delete_na.png', get_lang('ThisFolderCannotBeDeleted'),array(), 22);
}
} else {
$modify_icons .= ' '.Display::return_icon('delete.png', get_lang('Delete'),array(), 22).'';
}
}
}
}
}
if ($type == 'file' && ($extension == 'html' || $extension == 'htm')) {
if ($is_template == 0) {
if ((isset($_GET['curdirpath']) && $_GET['curdirpath'] != '/certificates') || !isset($_GET['curdirpath'])) {
$modify_icons .= ' '.Display::return_icon('wizard.png', get_lang('AddAsTemplate'),array(), 22).'';
}
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 .= ' ';
if ($is_preview) {
$modify_icons .= ' '.
Display::return_icon('preview_view.png', $preview,'',ICON_SIZE_SMALL).'';
}
}
}
} else {
$modify_icons .= ' '.
Display::return_icon('wizard_na.png', get_lang('RemoveAsTemplate'),'',ICON_SIZE_SMALL).'';
}
$modify_icons .= ' '.Display::return_icon('pdf.png', get_lang('Export2PDF'),array(), 22).'';
}
return $modify_icons;
}
function build_move_to_selector($folders, $curdirpath, $move_file, $group_dir = '') {
$form = '