Minor - code style changes

skala
Julio Montoya 12 years ago
parent 4bc0525d3e
commit ea660a2eb2
  1. 40
      index.php
  2. 1
      news_list.php
  3. 45
      user_portal.php

@ -3,8 +3,7 @@
/**
* @package chamilo.main
*/
*/
define('CHAMILO_HOMEPAGE', true);
$language_file = array('courses', 'index');
@ -20,7 +19,7 @@ require_once 'main/chat/chat_functions.lib.php';
$this_section = SECTION_CAMPUS;
$htmlHeadXtra[] = api_get_jquery_libraries_js(array('bxslider'));
$htmlHeadXtra[] ='
$htmlHeadXtra[] = '
<script>
$(document).ready(function(){
$("#slider").bxSlider({
@ -44,7 +43,9 @@ use Symfony\Component\HttpFoundation\Response;
class IndexController
{
public function indexAction(Application $app) {
public function indexAction(Application $app)
{
$request = $app['request'];
//Actions
@ -56,28 +57,22 @@ class IndexController
//$article = $app['orm.em']->getRepository('Entity\EntityCourse');
//$courses_query = $app['orm.em']->createQuery('SELECT a FROM Entity\EntityCourse a');
//$a = new EntityCourse();
//require_once '/var/www/chamilo11/main/inc/Entity/EntityCourse.php';
//$article = $app['orm.em']->getRepository('EntityCourse');
//var_dump($article);
//$courses_query = $app['orm.em']->createQuery('SELECT a FROM Entity\EntityCourse a');
/*
/*
$paginator = new Doctrine\ORM\Tools\Pagination\Paginator($courses_query, $fetchJoinCollection = true);
$c = count($paginator);
foreach ($paginator as $course) {
echo $course->getCode() . "\n";
}
exit;*/
exit; */
//$app['orm.em']->find('EntityCourse', 1);
//var_dump($app['orm.ems']['mysql']);
// Defines wether or not anonymous visitors can see a list of the courses on the Chamilo homepage that are open to the world.
//$_setting['display_courses_to_anonymous_users'] = 'true';
// Delete session neccesary for legal terms
if (api_get_setting('allow_terms_conditions') == 'true') {
unset($_SESSION['term_and_condition']);
@ -162,7 +157,8 @@ class IndexController
* on api_get_setting('page_after_login').
* @deprecated seems not to be used
*/
function check_last_login() {
function check_last_login()
{
if (!empty($_POST['submitAuth'])) {
// The user has been already authenticated, we are now to find the last login of the user.
if (!empty($this->user_id)) {
@ -194,7 +190,8 @@ class IndexController
}
}
function set_login_form(Application $app) {
function set_login_form(Application $app)
{
$user_id = api_get_user_id();
$login_form = null;
if (!$user_id || api_is_anonymous($user_id)) {
@ -219,13 +216,15 @@ class IndexController
}
}
function logout() {
function logout()
{
$user_id = api_get_user_id();
online_logout($user_id, true);
}
function display_login_form(Application $app) {
/*{{ form_widget(form) }}
function display_login_form(Application $app)
{
/* {{ form_widget(form) }}
$form = $app['form.factory']->createBuilder('form')
->add('name')
->add('email')
@ -235,12 +234,12 @@ class IndexController
))
->getForm();
return $app['template']->assign('form', $form->createView());
*/
*/
$form = new FormValidator('formLogin', 'POST', null, null, array('class'=>'form-vertical'));
$form = new FormValidator('formLogin', 'POST', null, null, array('class' => 'form-vertical'));
$form->addElement('text', 'login', get_lang('UserName'), array('class' => 'span2 autocapitalize_off', 'autofocus' => 'autofocus'));
$form->addElement('password', 'password', get_lang('Pass'), array('class' => 'span2'));
$form->addElement('style_submit_button','submitAuth', get_lang('LoginEnter'), array('class' => 'btn'));
$form->addElement('style_submit_button', 'submitAuth', get_lang('LoginEnter'), array('class' => 'btn'));
$html = $form->return_form();
if (api_get_setting('openid_authentication') == 'true') {
include_once 'main/auth/openid/login.php';
@ -249,7 +248,6 @@ class IndexController
return $html;
}
}
$app->match('/', 'IndexController::indexAction', 'POST|GET');
$app->run();
//$app['http_cache']->run();

@ -22,6 +22,5 @@ $content = SystemAnnouncementManager ::display_announcements_slider($visibility
$tpl = new Template($tool_name);
$tpl->assign('actions', $actions);
//$tpl->assign('message', $message);
$tpl->assign('content', $content);
$tpl->display_one_col_template();

@ -18,12 +18,11 @@
/**
* INIT SECTION
*/
// Language files that should be included.
use \ChamiloSession as Session;
$language_file = array('courses', 'index','admin');
$language_file = array('courses', 'index', 'admin');
$cidReset = true; /* Flag forcing the 'current course' reset,
as we're not inside a course anymore */
@ -85,6 +84,7 @@ use Symfony\Component\HttpFoundation\Response;
class UserPortalController
{
function indexAction(Application $app)
{
// Check if a user is enrolled only in one course for going directly to the course after the login.
@ -133,7 +133,7 @@ class UserPortalController
}
/* Sniffing system */
/*
/*
//store posts to sessions
if ($_SESSION['sniff_navigator']!="checked") {
$_SESSION['sniff_navigator']=Security::remove_XSS($_POST['sniff_navigator']);
@ -146,7 +146,7 @@ class UserPortalController
$_SESSION['sniff_check_some_plugins']=Security::remove_XSS($_POST['sniff_navigator_check_some_plugins']);
$_SESSION['sniff_java']=Security::remove_XSS($_POST['sniff_navigator_java']);
$_SESSION['sniff_java_sun_ver']=Security::remove_XSS($_POST['sniff_navigator_java_sun_ver']);
}*/
} */
@ -181,7 +181,7 @@ class UserPortalController
//js verification - To annoying of redirecting every time the page
$app['template']->assign('sniff_notification', $sniff_notification);
}
}*/
} */
PageController::return_profile_block();
PageController::return_user_image_block();
@ -202,15 +202,14 @@ class UserPortalController
return new Response($response, 200, array());
}
function check_last_login() {
function check_last_login()
{
/**
* @todo This piece of code should probably move to local.inc.php where the actual login procedure is handled.
* @todo Check if this code is used. I think this code is never executed because after clicking the submit button
* the code does the stuff in local.inc.php and then redirects to index.php or user_portal.php depending
* on api_get_setting('page_after_login').
*/
if (!empty($_POST['submitAuth'])) {
// The user has been already authenticated, we are now to find the last login of the user.
if (!empty($this->user_id)) {
@ -242,7 +241,8 @@ class UserPortalController
}
}
function set_login_form() {
function set_login_form()
{
global $loginFailed;
$login_form = '';
@ -274,7 +274,8 @@ class UserPortalController
/**
* Alias for the online_logout() function
*/
function logout() {
function logout()
{
online_logout($this->user_id, true);
}
@ -284,7 +285,8 @@ class UserPortalController
* @param string $category
* @return boolean
*/
function category_has_open_courses($category) {
function category_has_open_courses($category)
{
$setting_show_also_closed_courses = api_get_setting('show_closed_courses') == 'true';
$main_course_table = Database :: get_main_table(TABLE_MAIN_COURSE);
$category = Database::escape_string($category);
@ -310,7 +312,8 @@ class UserPortalController
*
* @version 1.0.1
*/
function handle_login_failed() {
function handle_login_failed()
{
$message = get_lang('InvalidId');
if (!isset($_GET['error'])) {
@ -350,7 +353,8 @@ class UserPortalController
* @param int $user_id: the id of the user
* @return array an array containing all the information of the courses of the given user
*/
function get_courses_of_user($user_id) {
function get_courses_of_user($user_id)
{
$table_course = Database::get_main_table(TABLE_MAIN_COURSE);
$table_course_user = Database::get_main_table(TABLE_MAIN_COURSE_USER);
// Secondly we select the courses that are in a category (user_course_cat <> 0) and sort these according to the sort of the category
@ -368,12 +372,23 @@ class UserPortalController
$courses = array();
while ($row = Database::fetch_array($result)) {
// We only need the database name of the course.
$courses[$row['k']] = array('db' => $row['db'], 'code' => $row['k'], 'visual_code' => $row['vc'], 'title' => $row['i'], 'directory' => $row['dir'], 'status' => $row['status'], 'tutor' => $row['t'], 'subscribe' => $row['subscr'], 'unsubscribe' => $row['unsubscr'], 'sort' => $row['sort'], 'user_course_category' => $row['user_course_cat']);
$courses[$row['k']] = array(
'db' => $row['db'],
'code' => $row['k'],
'visual_code' => $row['vc'],
'title' => $row['i'],
'directory' => $row['dir'],
'status' => $row['status'],
'tutor' => $row['t'],
'subscribe' => $row['subscr'],
'unsubscribe' => $row['unsubscr'],
'sort' => $row['sort'],
'user_course_category' => $row['user_course_cat']
);
}
return $courses;
}
}
$app->get('/', 'UserPortalController::indexAction');
$app->run();
//$app['http_cache']->run();
Loading…
Cancel
Save