diff --git a/certificates/index.php b/certificates/index.php new file mode 100644 index 0000000000..9dfa3f83b4 --- /dev/null +++ b/certificates/index.php @@ -0,0 +1,25 @@ +show(); \ No newline at end of file diff --git a/main/cron/notification.php b/main/cron/notification.php index 6b34294e6e..8be52f691e 100644 --- a/main/cron/notification.php +++ b/main/cron/notification.php @@ -10,7 +10,6 @@ $language_file = array('userInfo'); require_once '../inc/global.inc.php'; -require_once api_get_path(LIBRARY_PATH).'notification.lib.php'; /** * Notification sending */ diff --git a/main/document/create_document.php b/main/document/create_document.php index 39e69201f3..c9d5eaa071 100755 --- a/main/document/create_document.php +++ b/main/document/create_document.php @@ -156,16 +156,21 @@ require_once api_get_path(LIBRARY_PATH).'document.lib.php'; require_once api_get_path(SYS_CODE_PATH).'document/document.inc.php'; require_once api_get_path(LIBRARY_PATH).'groupmanager.lib.php'; require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php'; -require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php'; -if (isset($_REQUEST['certificate'])) { + +//I'm in the certification module? +$is_certificate_mode = false; + +if (isset($_REQUEST['certificate']) && $_REQUEST['certificate'] == 'true') { + $is_certificate_mode = true; +} + +if ($is_certificate_mode) { $nameTools = get_lang('CreateCertificate'); } else { $nameTools = get_lang('CreateDocument'); } -$nameTools = get_lang('CreateDocument'); - /* Constants and variables */ $document_data = DocumentManager::get_document_data_by_id($_REQUEST['id'], api_get_course_id(), true); @@ -205,6 +210,13 @@ if ($dir[strlen($dir) - 1] != '/') { $dir .= '/'; } +if ($is_certificate_mode) { + $document_id = DocumentManager::get_document_id(api_get_course_info(), '/certificates'); + $document_data = DocumentManager::get_document_data_by_id($document_id, api_get_course_id(), true); + $folder_id = $document_data['id']; + $dir = '/certificates/'; +} + // Configuration for the FCKEDITOR $doc_tree = explode('/', $dir); $count_dir = count($doc_tree) -2; // "2" because at the begin and end there are 2 "/" @@ -249,14 +261,6 @@ if (!is_dir($filepath)) { $dir = '/'; } - -//I'm in the certification module? -$is_certificate_mode = false; -$is_certificate_array = explode('/',$dir); -array_shift($is_certificate_array); -if ($is_certificate_array[0]=='certificates') { - $is_certificate_mode = true; -} $to_group_id = 0; if (!$is_certificate_mode) { @@ -299,10 +303,10 @@ $form = new FormValidator('create_document','post',api_get_self().'?dir='.Securi // form title $form->addElement('header', '', $nameTools); -if (isset($_REQUEST['certificate'])) {//added condition for certicate in gradebook +if ($is_certificate_mode) {//added condition for certicate in gradebook $form->addElement('hidden','certificate','true',array('id'=>'certificate')); if (isset($_GET['selectcat'])) - $form->addElement('hidden','selectcat',intval($_GET['selectcat'])); + $form->addElement('hidden','selectcat', intval($_GET['selectcat'])); } $renderer = & $form->defaultRenderer(); @@ -533,7 +537,7 @@ if ($form->validate()) { if (strpos($content, '/css/frames.css') === false) { $content = str_replace('', ' ', $content); - } + } if ($fp = @fopen($filepath.$filename.'.'.$extension, 'w')) { $content = str_replace(api_get_path(WEB_COURSE_PATH), $_configuration['url_append'].'/courses/', $content); @@ -585,7 +589,11 @@ if ($form->validate()) { $selectcat = ''; if (isset($_REQUEST['selectcat'])) $selectcat = "&selectcat=".Security::remove_XSS($_REQUEST['selectcat']); - header('Location: document.php?id='.$folder_id.$selectcat); + $certificate_condition = ''; + if ($is_certificate_mode) { + $certificate_condition = '&certificate=true'; + } + header('Location: document.php?id='.$folder_id.$selectcat.$certificate_condition); exit (); } else { Display :: display_header($nameTools, 'Doc'); @@ -594,7 +602,6 @@ if ($form->validate()) { } } else { Display :: display_header($nameTools, 'Doc'); - //api_display_tool_title($nameTools); Display :: display_error_message(get_lang('Impossible')); Display :: display_footer(); } @@ -629,8 +636,8 @@ if ($form->validate()) { Display :: display_header($nameTools, "Doc"); //api_display_tool_title($nameTools); // actions - if (isset($_REQUEST['certificate'])) { - $all_information_by_create_certificate = DocumentManager::get_all_info_to_certificate(api_get_user_id()); + if ($is_certificate_mode) { + $all_information_by_create_certificate = DocumentManager::get_all_info_to_certificate(api_get_user_id(), api_get_course_id()); $str_info = ''; foreach ($all_information_by_create_certificate[0] as $info_value) { diff --git a/main/document/document.inc.php b/main/document/document.inc.php index fe0e7213b4..dec6e3da94 100755 --- a/main/document/document.inc.php +++ b/main/document/document.inc.php @@ -258,15 +258,17 @@ function create_document_link($document_data, $show_as_icon = false, $counter = //|| (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; - $class = 'yoxview'; + //$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 = "yoxview invisible"; + $class = "thickbox invisible"; } - return ''.$title.''.$force_download_html.$copy_to_myfiles.$open_in_new_window_link.$pdf_icon; + 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 yoxview + //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 { diff --git a/main/document/document.php b/main/document/document.php index 29797746d0..7cc34c75a2 100755 --- a/main/document/document.php +++ b/main/document/document.php @@ -69,6 +69,19 @@ $session_id = api_get_session_id(); $course_code = api_get_course_id(); $to_group_id = api_get_group_id(); +$is_allowed_to_edit = api_is_allowed_to_edit(null, true); +$group_member_with_upload_rights = false; + +// If the group id is set, we show them group documents +$group_properties = array(); +$group_properties['directory'] = null; + +// For sessions we should check the parameters of visibility +if (api_get_session_id() != 0) { + $group_member_with_upload_rights = $group_member_with_upload_rights && api_is_allowed_to_session_edit(false, true); +} + + //Setting group variables if (api_get_group_id()) { // Needed for group related stuff @@ -174,10 +187,13 @@ switch ($action) { // I'm in the certification module? $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)) { - $document_data = DocumentManager::get_document_data_by_id($document_id, api_get_course_id(), true); + $document_data = DocumentManager::get_document_data_by_id($document_id, api_get_course_id(), true); //If the document is not a folder we show the document if ($document_data) { @@ -237,6 +253,9 @@ if (isset($document_id)) { $parent_id = $document_data['parent_id']; } +if (isset($document_data) && $document_data['path'] == '/certificates') { + $is_certificate_mode = true; +} if (!$parent_id) { $parent_id = 0; @@ -274,6 +293,7 @@ $tool_sql = 'SELECT visibility FROM ' . $table_course_tool . ' WHERE n $tool_result = Database::query($tool_sql); $tool_row = Database::fetch_array($tool_result); $tool_visibility = $tool_row['visibility']; + if ($tool_visibility == '0' && $to_group_id == '0' && !($is_allowed_to_edit || $group_member_with_upload_rights)) { api_not_allowed(true); } @@ -288,18 +308,6 @@ function confirmation (name) { } "; -$is_allowed_to_edit = api_is_allowed_to_edit(null, true); -$group_member_with_upload_rights = false; - -// If the group id is set, we show them group documents -$group_properties = array(); -$group_properties['directory'] = null; - -// For sessions we should check the parameters of visibility -if (api_get_session_id() != 0) { - $group_member_with_upload_rights = $group_member_with_upload_rights && api_is_allowed_to_session_edit(false, true); -} - // If they are looking at group documents they can't see the root if ($to_group_id != 0 && $curdirpath == '/') { $curdirpath = $group_properties['directory']; @@ -392,23 +400,25 @@ if (empty($document_data['parents'])) { if (isset($_GET['createdir'])) { $interbreadcrumb[] = array('url' => '#', 'name' => get_lang('CreateDir')); } - -$htmlHeadXtra[] = api_get_jquery_js(); $htmlHeadXtra[] = api_get_jquery_ui_js(); +$js_path = api_get_path(WEB_LIBRARY_PATH).'javascript/'; +/* +$htmlHeadXtra[] = ''; $htmlHeadXtra[] = api_get_js('yoxview/yoxview-init.js'); -$js_path = api_get_path(WEB_LIBRARY_PATH).'javascript/'; -$htmlHeadXtra[] = ''; +*/ + $htmlHeadXtra[] = ''; $htmlHeadXtra[] = ''; + $mediaplayer_path = api_get_path(WEB_LIBRARY_PATH).'mediaplayer/player.swf'; //automatic loading the course language for yoxview -$yoxview_code_translation_table = array('' => 'en', 'pt' => 'pt-Pt', 'sr' => 'sr_latn'); +/*$yoxview_code_translation_table = array('' => 'en', 'pt' => 'pt-Pt', 'sr' => 'sr_latn'); $lang_yoxview = api_get_language_isocode(); $lang_yoxview = isset($yoxview_code_translation_table[$lang_yoxview]) ? $yoxview_code_translation_table[$lang_yoxview] : $lang_yoxview; - +*/ $docs_and_folders = DocumentManager::get_all_document_data($_course, $curdirpath, $to_group_id, null, $is_allowed_to_edit || $group_member_with_upload_rights, false); $file_list = $format_list = ''; @@ -443,15 +453,14 @@ foreach ($docs_and_folders as $file) { } $htmlHeadXtra[] = '