Adding new URLs web/certificates/1, web/users/admin and web/news/1 instead of certificates/index.php?id=1 user.php?u=admin (probably never used) and news_list.php?id=1

skala
Julio Montoya 12 years ago
parent 2d2702b61d
commit 3562e13200
  1. 20
      certificates/index.php
  2. 18
      htaccess
  3. 2
      index.php
  4. 69
      main/gradebook/gradebook_display_certificate.php
  5. 2
      main/gradebook/lib/be/category.class.php
  6. 16
      main/inc/lib/certificate.lib.php
  7. 2
      main/inc/lib/document.lib.php
  8. 2
      main/inc/lib/group_portal_manager.lib.php
  9. 29
      news_list.php
  10. 10
      src/ChamiloLMS/Controller/CertificateController.php
  11. 40
      src/ChamiloLMS/Controller/NewsController.php
  12. 29
      src/ChamiloLMS/Controller/UserController.php
  13. 51
      user.php

@ -1,20 +1,8 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Show specified user certificate
* @package chamilo.certificate
*/
/**
* Initialization
* @todo replace me with a controller!
*/
$language_file= array('admin', 'gradebook', 'document');
require_once '../main/inc/global.inc.php';
$certificate = new Certificate($_GET['id']);
//Show certificate HTML
$certificate->show();
$id = isset($_GET['id']) ? intval($_GET['id']) : null;
$url = Certificate::getCertificatePublicURL($id);
header("Location: $url");
exit;

@ -1,18 +0,0 @@
# Check that your Apache virtualhost have this settings:
#<Directory "/var/www/chamilo-classic">
# AllowOverride All
# Order allow,deny
# Allow from all
#</Directory>
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

@ -7,4 +7,4 @@
//Temporal hack to redirect calls to the new web/index.php
header('Location: web/index');
exit;
exit;

@ -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 '<div class="btn-group">';
$url = api_get_self().'?action=generate_all_certificates'.'&'.api_get_cidReq().'&cat_id='.$cat_id;
@ -170,20 +170,21 @@ echo '</div>';
if (count($certificate_list)==0) {
echo Display::display_warning_message(get_lang('NoResultsAvailable'));
} else {
echo '<br /><br /><table class="data_table">';
echo '<br /><br /><table class="data_table">';
foreach ($certificate_list as $index=>$value) {
echo '<tr>
<td width="100%" class="actions">'.get_lang('Student').' : '.api_get_person_name($value['firstname'], $value['lastname']).' ( '.$value['username'].')</td>';
echo '</tr>';
echo '<tr><td>
<table class="data_table">';
$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 '<tr>';
echo '<td width="50%">'.get_lang('Score').' : '.$value_certificate['score_certificate'].'</td>';
echo '<td width="30%">'.get_lang('Date').' : '.api_convert_and_format_date($value_certificate['created_at']).'</td>';
echo '<td width="20%">';
$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 '<a onclick="return confirmation();" href="gradebook_display_certificate.php?sec_token='.$token.'&cidReq='.$course_code.'&action=delete&cat_id='.$cat_id.'&certificate_id='.$value_certificate['id'].'">

@ -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 = '<div class="actions" align="right">';
$html .= Display::url($url, $url, array('target'=>'_blank'));

@ -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;
}
}

@ -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,

@ -126,7 +126,7 @@ class GroupPortalManager
while ($item = Database::fetch_assoc($res)) {
$list[$item['id']] = $item['name'];
}
return $list;
return $list;
}
/**

@ -1,28 +1,9 @@
<?php
/* For licensing terms, see /license.txt */
//@todo move this inside web/news
// name of the language file that needs to be included
$language_file = array ('admin','courses', 'index', 'announcements', 'group');
// including necessary files
//Temporal hack to redirect calls to the new web/index.php
require_once 'main/inc/global.inc.php';
$tool_name = get_lang('SystemAnnouncements');
$actions = '';
if (api_is_platform_admin()) {
$actions = '<a href="'.api_get_path(WEB_PATH).'main/admin/system_announcements.php">'.Display::return_icon('edit.png', get_lang('EditSystemAnnouncement'), array(), 32).'</a>';
}
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;

@ -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);
}
}

@ -0,0 +1,40 @@
<?php
/* For licensing terms, see /license.txt */
namespace ChamiloLMS\Controller;
use Silex\Application;
use Symfony\Component\HttpFoundation\Response;
/**
* Class NewsController
* @package ChamiloLMS\Controller
* @author Julio Montoya <gugli100@gmail.com>
*/
class NewsController
{
/**
*
* @return string
*/
public function indexAction(Application $app, $id)
{
$actions = null;
if (api_is_platform_admin()) {
$actions = '<a href="'.api_get_path(WEB_PATH).'main/admin/system_announcements.php">'.\Display::return_icon('edit.png', get_lang('EditSystemAnnouncement'), array(), 32).'</a>';
}
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());
}
}

@ -0,0 +1,29 @@
<?php
/* For licensing terms, see /license.txt */
namespace ChamiloLMS\Controller;
use Silex\Application;
use Symfony\Component\HttpFoundation\Response;
/**
* Class UserController
* @package ChamiloLMS\Controller
* @author Julio Montoya <gugli100@gmail.com>
*/
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());
}
}

@ -1,51 +0,0 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Clean URls for the Social Network
*
* The idea is to access to the user info more easily:
* http://campus.chamilo.org/admin instead of
* http://campus.chamilo.org/main/social/profile.php?1
* To use this you should rename the htaccess to .htaccess and check your
* virtualhost configuration
*
* More improvements will come in next versions of Chamilo maybe in the 1.8.8
* @package chamilo.main
*/
/**
* Variables definitions and inclusions
*
* @todo move this inside web/users
*/
// name of the language file that needs to be included
$language_file = array('index','registration','messages','userInfo');
$cidReset = true;
require_once 'main/inc/global.inc.php';
/**
* Access permissions check
*/
api_block_anonymous_users();
/**
* Treat URL arguments
*/
$array_keys = array_keys($_GET);
if (!empty($array_keys)) {
$username = substr($array_keys[0],0,20); // max len of an username
$friend_id = UserManager::get_user_id_from_username($username);
if ($friend_id) {
SocialManager::display_individual_user($friend_id);
} else {
// we cant find your friend
header('Location: whoisonline.php');
exit;
}
} else {
// we cant find your friend
header('Location: whoisonline.php');
exit;
}
Loading…
Cancel
Save