diff --git a/certificates/index.php b/certificates/index.php index ca88a85fba..0e47d9a9c7 100644 --- a/certificates/index.php +++ b/certificates/index.php @@ -1,20 +1,8 @@ show(); \ No newline at end of file +$id = isset($_GET['id']) ? intval($_GET['id']) : null; +$url = Certificate::getCertificatePublicURL($id); +header("Location: $url"); +exit; \ No newline at end of file diff --git a/htaccess b/htaccess deleted file mode 100644 index 28256c1d18..0000000000 --- a/htaccess +++ /dev/null @@ -1,18 +0,0 @@ -# Check that your Apache virtualhost have this settings: - -# -# AllowOverride All -# Order allow,deny -# Allow from all -# - - - -RewriteEngine on -RewriteCond %{QUERY_STRING} ^id=(.*)$ -RewriteRule ^certificates/$ certificates/index.php?id=%1 [L] -RewriteRule ^([^/.]+)/?$ user.php?$1 [L] - -# This will transform -# http://my.chamilo.net/certificates/index.php?id=123 to http://my.chamilo.net/certificates/123 -# http://my.chamilo.net/user.php?jmontoya to http://my.chamilo.net/jmontoya \ No newline at end of file diff --git a/index.php b/index.php index 6c47b332a4..0ae550f5ba 100644 --- a/index.php +++ b/index.php @@ -7,4 +7,4 @@ //Temporal hack to redirect calls to the new web/index.php header('Location: web/index'); -exit; +exit; \ No newline at end of file diff --git a/main/gradebook/gradebook_display_certificate.php b/main/gradebook/gradebook_display_certificate.php index d1ce94e6b8..a4db7848fb 100644 --- a/main/gradebook/gradebook_display_certificate.php +++ b/main/gradebook/gradebook_display_certificate.php @@ -96,7 +96,7 @@ Display::display_header(''); if ($_GET['action'] == 'delete') { $check = Security::check_token('get'); if ($check) { - $certificate = new Certificate($_GET['certificate_id']); + $certificate = new Certificate($_GET['certificate_id']); $result = $certificate->delete(true); Security::clear_token(); if ($result ==true) { @@ -110,50 +110,50 @@ if ($_GET['action'] == 'delete') { $token = Security::get_token(); echo Display::page_header(get_lang('GradebookListOfStudentsCertificates')); - $cat_id = isset($_GET['cat_id']) ? (int)$_GET['cat_id'] : null; +$cat_id = isset($_GET['cat_id']) ? (int)$_GET['cat_id'] : null; - //@todo replace all this code with something like get_total_weight() - $cats = Category :: load ($cat_id, null, null, null, null, null, false); +//@todo replace all this code with something like get_total_weight() +$cats = Category :: load ($cat_id, null, null, null, null, null, false); - if (!empty($cats)) { +if (!empty($cats)) { - //with this fix the teacher only can view 1 gradebook - if (api_is_platform_admin()) { - $stud_id= (api_is_allowed_to_edit() ? null : api_get_user_id()); - } else { - $stud_id= api_get_user_id(); - } + //with this fix the teacher only can view 1 gradebook + if (api_is_platform_admin()) { + $stud_id= (api_is_allowed_to_edit() ? null : api_get_user_id()); + } else { + $stud_id= api_get_user_id(); + } - $total_weight = $cats[0]->get_weight(); + $total_weight = $cats[0]->get_weight(); - $allcat = $cats[0]->get_subcategories($stud_id, api_get_course_id(), api_get_session_id()); - $alleval = $cats[0]->get_evaluations($stud_id); - $alllink = $cats[0]->get_links($stud_id); + $allcat = $cats[0]->get_subcategories($stud_id, api_get_course_id(), api_get_session_id()); + $alleval = $cats[0]->get_evaluations($stud_id); + $alllink = $cats[0]->get_links($stud_id); - $datagen = new GradebookDataGenerator ($allcat,$alleval, $alllink); + $datagen = new GradebookDataGenerator($allcat,$alleval, $alllink); - $total_resource_weight = 0; - if (!empty($datagen)) { - $data_array = $datagen->get_data(GradebookDataGenerator :: GDG_SORT_NAME,0,null,true); + $total_resource_weight = 0; + if (!empty($datagen)) { + $data_array = $datagen->get_data(GradebookDataGenerator :: GDG_SORT_NAME,0,null,true); - if (!empty($data_array)) { - $newarray = array(); - foreach ($data_array as $data) { - $newarray[] = array_slice($data, 1); - } + if (!empty($data_array)) { + $newarray = array(); + foreach ($data_array as $data) { + $newarray[] = array_slice($data, 1); + } - foreach($newarray as $item) { - $total_resource_weight = $total_resource_weight + $item['2']; - } + foreach($newarray as $item) { + $total_resource_weight = $total_resource_weight + $item['2']; } } + } - if ($total_resource_weight != $total_weight) { - Display::display_warning_message(get_lang('SumOfActivitiesWeightMustBeEqualToTotalWeight')); - } + if ($total_resource_weight != $total_weight) { + Display::display_warning_message(get_lang('SumOfActivitiesWeightMustBeEqualToTotalWeight')); } +} - $certificate_list = get_list_users_certificates($cat_id); +$certificate_list = get_list_users_certificates($cat_id); echo '
'; $url = api_get_self().'?action=generate_all_certificates'.'&'.api_get_cidReq().'&cat_id='.$cat_id; @@ -170,20 +170,21 @@ echo '
'; if (count($certificate_list)==0) { echo Display::display_warning_message(get_lang('NoResultsAvailable')); } else { - echo '

'; + echo '

'; foreach ($certificate_list as $index=>$value) { echo ''; echo ''; echo '
'.get_lang('Student').' : '.api_get_person_name($value['firstname'], $value['lastname']).' ( '.$value['username'].')
'; - $list_certificate = get_list_gradebook_certificates_by_user_id ($value['user_id'], $cat_id); + $list_certificate = get_list_gradebook_certificates_by_user_id($value['user_id'], $cat_id); + foreach ($list_certificate as $value_certificate) { echo ''; echo ''; echo ''; echo '
'.get_lang('Score').' : '.$value_certificate['score_certificate'].''.get_lang('Date').' : '.api_convert_and_format_date($value_certificate['created_at']).''; - $url = api_get_path(WEB_PATH).'certificates/index.php?id='.$value_certificate['id']; + $url = Certificate::getCertificatePublicURL($value_certificate['id']); $certificates = Display::url(get_lang('Certificate'), $url, array('target'=>'_blank', 'class' => 'btn')); echo $certificates; echo ' diff --git a/main/gradebook/lib/be/category.class.php b/main/gradebook/lib/be/category.class.php index b17d87c39f..829e0a4ed6 100644 --- a/main/gradebook/lib/be/category.class.php +++ b/main/gradebook/lib/be/category.class.php @@ -1427,7 +1427,7 @@ class Category implements GradebookItem if (!empty($my_certificate)) { $certificate_obj = new Certificate($my_certificate['id']); - $url = api_get_path(WEB_PATH) .'certificates/index.php?id='.$my_certificate['id']; + $url = Certificate::getCertificatePublicURL($my_certificate['id']); $certificates = Display::url(Display::return_icon('certificate.png', get_lang('Certificates'), array(), 32), $url, array('target'=>'_blank')); $html = '
'; $html .= Display::url($url, $url, array('target'=>'_blank')); diff --git a/main/inc/lib/certificate.lib.php b/main/inc/lib/certificate.lib.php index 2e2811a0c7..3a6a403c65 100644 --- a/main/inc/lib/certificate.lib.php +++ b/main/inc/lib/certificate.lib.php @@ -5,7 +5,8 @@ * gradebook tool. * @package chamilo.library.certificates */ -class Certificate extends Model { +class Certificate extends Model +{ var $table; var $columns = array('id','cat_id','score_certificate','created_at','path_certificate'); /** @@ -313,7 +314,7 @@ class Certificate extends Model { * course* can be printed (for anonymous users). Connected users can always * print them. */ - public function show() { + public function show($returnContent = false) { // Special rules for anonymous users $failed = false; if (api_is_anonymous()) { @@ -349,14 +350,25 @@ class Certificate extends Model { //Read file or preview file if (!empty($this->certificate_data['path_certificate'])) { $user_certificate = $this->certification_user_path.basename($this->certificate_data['path_certificate']); + if (file_exists($user_certificate)) { + if ($returnContent) { + return file_get_contents($user_certificate); + } header('Content-Type: text/html; charset='. api_get_system_encoding()); echo @file_get_contents($user_certificate); } } else { + if ($returnContent) { + return Display :: return_message(get_lang('NoCertificateAvailable'), 'warning'); + } Display :: display_reduced_header(); Display :: display_warning_message(get_lang('NoCertificateAvailable')); } exit; } + + static function getCertificatePublicURL($id) { + return api_get_path(WEB_PUBLIC_PATH).'certificates/'.$id; + } } \ No newline at end of file diff --git a/main/inc/lib/document.lib.php b/main/inc/lib/document.lib.php index 745ad8d245..9d7248a09d 100755 --- a/main/inc/lib/document.lib.php +++ b/main/inc/lib/document.lib.php @@ -1545,7 +1545,7 @@ class DocumentManager $date_no_time = api_convert_and_format_date(api_get_utc_datetime(), DATE_FORMAT_LONG_NO_DAY); } - $url = api_get_path(WEB_PATH).'certificates/index.php?id='.$info_grade_certificate['id']; + $url = Certificate::getCertificatePublicURL($info_grade_certificate['id']); //replace content $info_to_replace_in_content_html = array( $first_name, diff --git a/main/inc/lib/group_portal_manager.lib.php b/main/inc/lib/group_portal_manager.lib.php index a2443ddc2f..c5d520430f 100644 --- a/main/inc/lib/group_portal_manager.lib.php +++ b/main/inc/lib/group_portal_manager.lib.php @@ -126,7 +126,7 @@ class GroupPortalManager while ($item = Database::fetch_assoc($res)) { $list[$item['id']] = $item['name']; } - return $list; + return $list; } /** diff --git a/news_list.php b/news_list.php index d6b2e40840..dc2b4a4e32 100644 --- a/news_list.php +++ b/news_list.php @@ -1,28 +1,9 @@ '.Display::return_icon('edit.png', get_lang('EditSystemAnnouncement'), array(), 32).''; -} - -if (api_is_anonymous()) { - $visibility = SystemAnnouncementManager::VISIBLE_GUEST; -} else { - $visibility = api_is_allowed_to_create_course() ? SystemAnnouncementManager::VISIBLE_TEACHER : SystemAnnouncementManager::VISIBLE_STUDENT; -} -$content = SystemAnnouncementManager ::display_announcements_slider($visibility, $_GET['id']); - -$tpl = new Template($tool_name); -$tpl->assign('actions', $actions); -$tpl->assign('content', $content); -$tpl->display_one_col_template(); +$id = isset($_GET['id']) ? intval($_GET['id']) : null; +$path = api_get_path(WEB_PUBLIC_PATH); +header('Location: '.$path.'news/'.$id); +exit; \ No newline at end of file diff --git a/src/ChamiloLMS/Controller/CertificateController.php b/src/ChamiloLMS/Controller/CertificateController.php index c96f182e34..4e6b122f25 100644 --- a/src/ChamiloLMS/Controller/CertificateController.php +++ b/src/ChamiloLMS/Controller/CertificateController.php @@ -13,11 +13,15 @@ use Symfony\Component\HttpFoundation\Response; */ class CertificateController { - public function indexAction() + /** + * + * @return string + */ + public function indexAction($id) { - /*$certificate = new Certificate($_GET['id']); + $certificate = new \Certificate($id); //Show certificate HTML - $certificate->show();*/ + return $certificate->show(true); } } \ No newline at end of file diff --git a/src/ChamiloLMS/Controller/NewsController.php b/src/ChamiloLMS/Controller/NewsController.php new file mode 100644 index 0000000000..32509bd378 --- /dev/null +++ b/src/ChamiloLMS/Controller/NewsController.php @@ -0,0 +1,40 @@ + + */ +class NewsController +{ + /** + * + * @return string + */ + public function indexAction(Application $app, $id) + { + $actions = null; + if (api_is_platform_admin()) { + $actions = ''.\Display::return_icon('edit.png', get_lang('EditSystemAnnouncement'), array(), 32).''; + } + + if (api_is_anonymous()) { + $visibility = \SystemAnnouncementManager::VISIBLE_GUEST; + } else { + $visibility = api_is_allowed_to_create_course() ? \SystemAnnouncementManager::VISIBLE_TEACHER : \SystemAnnouncementManager::VISIBLE_STUDENT; + } + $content = \SystemAnnouncementManager ::display_announcements_slider($visibility, $id); + + $app['template']->assign('content', $content); + $app['template']->assign('actions', $actions); + $response = $app['template']->render_layout('layout_1_col.tpl'); + + return new Response($response, 200, array()); + } +} \ No newline at end of file diff --git a/src/ChamiloLMS/Controller/UserController.php b/src/ChamiloLMS/Controller/UserController.php new file mode 100644 index 0000000000..f3c81d3f46 --- /dev/null +++ b/src/ChamiloLMS/Controller/UserController.php @@ -0,0 +1,29 @@ + + */ +class UserController +{ + /** + * + * @return string + */ + public function indexAction(Application $app, $username) + { + $userId = \UserManager::get_user_id_from_username($username); + $content = \SocialManager::display_individual_user($userId, true); + $app['template']->assign('content', $content); + $response = $app['template']->render_layout('layout_1_col.tpl'); + + return new Response($response, 200, array()); + } +} \ No newline at end of file diff --git a/user.php b/user.php deleted file mode 100644 index 56d9d993cc..0000000000 --- a/user.php +++ /dev/null @@ -1,51 +0,0 @@ -