Remove categories_list.php use template class instead.

- Add deprecated tag in app_view.php.
- Format code.
pull/2487/head
jmontoyaa 7 years ago
parent 439c0ce2a3
commit b07c67ff32
  1. 32
      main/auth/categories_list.php
  2. 42
      main/auth/courses.php
  3. 53
      main/auth/courses_controller.php
  4. 2
      main/inc/lib/app_view.php
  5. 9
      main/inc/lib/auth.lib.php
  6. 11
      main/inc/lib/baker.lib.php

@ -1,32 +0,0 @@
<?php
/* For licensing terms, see /license.txt */
/**
* View (MVC patter) for creating course category
* @author Christian Fasanando <christian1827@gmail.com> - Beeznest
* @package chamilo.auth
*/
// Access rights: anonymous users can't do anything usefull here.
api_block_anonymous_users();
$stok = Security::get_token();
?>
<!-- Actions: The menu with the different options in cathe course management -->
<div id="actions" class="actions">
<a href="<?php echo api_get_self() ?>?action=sortmycourses">
<?php echo Display::return_icon('back.png', get_lang('Back'), '', '32'); ?>
</a>
</div>
<?php
$form = new FormValidator(
'create_course_category',
'post',
api_get_self().'?createcoursecategory'
);
$form->addHidden('sec_token', $stok);
$form->addText('title_course_category', get_lang('Name'));
$form->addButtonSave(get_lang('AddCategory'), 'create_course_category');
$form->display();

@ -85,26 +85,26 @@ if (empty($nameTools)) {
}
// course description controller object
$courses_controller = new CoursesController();
$courseController = new CoursesController();
// We are moving a course or category of the user up/down the list (=Sort My Courses).
if (isset($_GET['move'])) {
if (isset($_GET['course'])) {
$courses_controller->move_course(
$courseController->move_course(
$_GET['move'],
$_GET['course'],
$_GET['category']
);
}
if (isset($_GET['category']) && !isset($_GET['course'])) {
$courses_controller->move_category($_GET['move'], $_GET['category']);
$courseController->move_category($_GET['move'], $_GET['category']);
}
}
// We are moving the course of the user to a different user defined course category (=Sort My Courses).
if (isset($_POST['submit_change_course_category'])) {
if ($ctok == $_POST['sec_token']) {
$courses_controller->change_course_category(
$courseController->change_course_category(
$_POST['course_2_edit_category'],
$_POST['course_categories']
);
@ -117,7 +117,7 @@ if (isset($_POST['submit_edit_course_category']) &&
strlen(trim($_POST['title_course_category'])) > 0
) {
if ($ctok == $_POST['sec_token']) {
$courses_controller->edit_course_category(
$courseController->edit_course_category(
$_POST['title_course_category'],
$_POST['edit_course_category']
);
@ -128,7 +128,7 @@ if (isset($_POST['submit_edit_course_category']) &&
if ($action == 'deletecoursecategory' && isset($_GET['id'])) {
if ($ctok == $_GET['sec_token']) {
$get_id_cat = intval($_GET['id']);
$courses_controller->delete_course_category($get_id_cat);
$courseController->delete_course_category($get_id_cat);
}
}
@ -138,14 +138,14 @@ if (isset($_POST['create_course_category']) &&
strlen(trim($_POST['title_course_category'])) > 0
) {
if ($ctok == $_POST['sec_token']) {
$courses_controller->addCourseCategory($_POST['title_course_category']);
$courseController->addCourseCategory($_POST['title_course_category']);
}
}
// search courses
if (isset($_REQUEST['search_course'])) {
if ($ctok == $_REQUEST['sec_token']) {
$courses_controller->search_courses(
$courseController->search_courses(
$searchTerm,
null,
null,
@ -160,7 +160,7 @@ if (isset($_REQUEST['search_course'])) {
// Subscribe user to course
if (isset($_REQUEST['subscribe_course'])) {
if ($ctok == $_GET['sec_token']) {
$courses_controller->subscribe_user(
$courseController->subscribe_user(
$_GET['subscribe_course'],
$searchTerm,
$categoryCode
@ -171,7 +171,7 @@ if (isset($_REQUEST['subscribe_course'])) {
// We are unsubscribing from a course (=Unsubscribe from course).
if (isset($_GET['unsubscribe'])) {
if ($ctok == $_GET['sec_token']) {
$courses_controller->unsubscribe_user_from_course(
$courseController->unsubscribe_user_from_course(
$_GET['unsubscribe'],
$searchTerm,
$categoryCode
@ -182,12 +182,12 @@ if (isset($_GET['unsubscribe'])) {
// We are unsubscribing from a course (=Unsubscribe from course).
if (isset($_POST['unsubscribe'])) {
if ($ctok == $_POST['sec_token']) {
$courses_controller->unsubscribe_user_from_course($_POST['unsubscribe']);
$courseController->unsubscribe_user_from_course($_POST['unsubscribe']);
}
}
switch ($action) {
case 'subscribe_user_with_password':
$courses_controller->subscribe_user(
$courseController->subscribe_user(
isset($_POST['subscribe_user_with_password']) ? $_POST['subscribe_user_with_password'] : '',
$searchTerm,
isset($_POST['category_code']) ? $_POST['category_code'] : ''
@ -196,13 +196,13 @@ switch ($action) {
exit;
break;
case 'createcoursecategory':
$courses_controller->categories_list($action);
$courseController->categoryList($action);
break;
case 'deletecoursecategory':
$courses_controller->courses_list($action);
$courseController->courseList($action);
break;
case 'sortmycourses':
$courses_controller->courses_list($action);
$courseController->courseList($action);
break;
case 'subscribe':
if (!$user_can_view_page) {
@ -211,7 +211,7 @@ switch ($action) {
header('Location: '.api_get_self());
exit;
/* if (!CoursesAndSessionsCatalog::is(CATALOG_SESSIONS)) {
$courses_controller->courses_categories(
$courseController->courses_categories(
$action,
$categoryCode,
null,
@ -229,14 +229,14 @@ switch ($action) {
api_not_allowed(true);
}
$courses_controller->courses_categories($action);
$courseController->courses_categories($action);
break;
case 'display_courses':
if (!$user_can_view_page) {
api_not_allowed(true);
}
$courses_controller->courses_categories(
$courseController->courses_categories(
$action,
$categoryCode,
null,
@ -250,7 +250,7 @@ switch ($action) {
api_not_allowed(true);
}
$courses_controller->sessionsList($action, $nameTools, $limit);
$courseController->sessionsList($action, $nameTools, $limit);
break;
case 'subscribe_to_session':
if (!$user_can_view_page) {
@ -331,13 +331,13 @@ switch ($action) {
api_not_allowed(true);
}
$courses_controller->sessionsListByCoursesTag($limit);
$courseController->sessionsListByCoursesTag($limit);
break;
case 'search_session':
if (!$user_can_view_page) {
api_not_allowed(true);
}
$courses_controller->sessionListBySearch($limit);
$courseController->sessionListBySearch($limit);
break;
}

@ -33,14 +33,11 @@ class CoursesController
* render to courses_list view
* @param string $action
* @param string $message confirmation message(optional)
* @param string $action
*/
public function courses_list($action, $message = '')
public function courseList($action, $message = '')
{
$data = array();
$user_id = api_get_user_id();
$data['user_courses'] = $this->model->get_courses_of_user($user_id);
$data['user_courses'] = $this->model->get_courses_of_user(api_get_user_id());
$data['user_course_categories'] = $this->model->get_user_course_categories();
$data['courses_in_category'] = $this->model->get_courses_in_category();
$data['action'] = $action;
@ -60,19 +57,33 @@ class CoursesController
* @param string $message confirmation message(optional)
* @param string $error error message(optional)
*/
public function categories_list($action, $message = '', $error = '')
public function categoryList($action, $message = '', $error = '')
{
api_block_anonymous_users();
$data = array();
$data['user_course_categories'] = $this->model->get_user_course_categories();
$data['action'] = $action;
$data['message'] = $message;
$data['error'] = $error;
// render to the view
$this->view->set_data($data);
$this->view->set_layout('catalog_layout');
$this->view->set_template('categories_list');
$this->view->render();
$stok = Security::get_token();
$actions = Display::url(
Display::return_icon('back.png', get_lang('Back'), '', '32'),
api_get_path(WEB_CODE_PATH).'auth/courses.php?action=sortmycourses'
);
$actions = Display::toolbarAction('toolbar-forum', [$actions]);
$form = new FormValidator(
'create_course_category',
'post',
api_get_path(WEB_CODE_PATH).'auth/courses.php?action=createcoursecategory'
);
$form->addHidden('sec_token', $stok);
$form->addText('title_course_category', get_lang('Name'));
$form->addButtonSave(get_lang('AddCategory'), 'create_course_category');
$tpl = new Template();
$tpl->assign('content', $form->returnForm());
$tpl->assign('actions', $actions);
$tpl->display_one_col_template();
}
/**
@ -286,8 +297,8 @@ class CoursesController
)
);
}
$action = 'sortmycourses';
$this->courses_list($action);
header('Location: '.api_get_path(WEB_CODE_PATH).'auth/courses.php?action=sortmycourses');
exit;
}
/**
@ -308,7 +319,7 @@ class CoursesController
);
}
$action = 'sortmycourses';
$this->courses_list($action);
$this->courseList($action);
}
/**
@ -327,7 +338,7 @@ class CoursesController
);
}
$action = 'sortmycourses';
$this->courses_list($action);
$this->courseList($action);
}
/**
@ -345,7 +356,7 @@ class CoursesController
);
}
$action = 'sortmycourses';
$this->courses_list($action);
$this->courseList($action);
}
/**
@ -363,7 +374,7 @@ class CoursesController
);
}
$action = 'sortmycourses';
$this->courses_list($action);
$this->courseList($action);
}
/**
@ -380,7 +391,7 @@ class CoursesController
);
}
$action = 'sortmycourses';
$this->courses_list($action);
$this->courseList($action);
}
/**

@ -3,6 +3,8 @@
/**
* Class View
* @deprecated use Template class
*
*/
class View
{

@ -123,7 +123,6 @@ class Auth
$TABLECOURSUSER = Database::get_main_table(TABLE_MAIN_COURSE_USER);
$TABLE_COURSE_FIELD = Database::get_main_table(TABLE_EXTRA_FIELD);
$TABLE_COURSE_FIELD_VALUE = Database::get_main_table(TABLE_EXTRA_FIELD_VALUES);
$extraFieldType = ExtraField::COURSE_FIELD_TYPE;
// get course list auto-register
@ -183,9 +182,9 @@ class Auth
$newcategory = intval($newcategory);
$current_user = api_get_user_id();
$TABLECOURSUSER = Database::get_main_table(TABLE_MAIN_COURSE_USER);
$table = Database::get_main_table(TABLE_MAIN_COURSE_USER);
$max_sort_value = api_max_sort_value($newcategory, $current_user);
$sql = "UPDATE $TABLECOURSUSER SET
$sql = "UPDATE $table SET
user_course_cat='".$newcategory."',
sort='" . ($max_sort_value + 1)."'
WHERE
@ -456,7 +455,9 @@ class Auth
$row['registration_code'] = !empty($row['registration_code']);
$count_users = count(CourseManager::get_user_list_from_course_code($row['code']));
$count_connections_last_month = Tracking::get_course_connections_count(
$row['id'], 0, api_get_utc_datetime(time() - (30 * 86400))
$row['id'],
0,
api_get_utc_datetime(time() - (30 * 86400))
);
$point_info = CourseManager::get_course_ranking($row['id'], 0);

@ -97,8 +97,9 @@ class PNGImageBaker
// Read the magic bytes and verify
$retval = substr($png, 0, 8);
$ipos = 8;
if ($retval != "\x89PNG\x0d\x0a\x1a\x0a")
if ($retval != "\x89PNG\x0d\x0a\x1a\x0a") {
throw new Exception('Is not a valid PNG image');
}
// Loop through the chunks. Byte 0-3 is length, Byte 4-7 is type
$chunkHeader = substr($png, $ipos, 8);
$ipos = $ipos + 8;
@ -110,13 +111,17 @@ class PNGImageBaker
$data = substr($png, $ipos, $chunk['size']);
$sections = explode("\0", $data);
print_r($sections);
if ($sections[0] == $key) $skip = true;
if ($sections[0] == $key) {
$skip = true;
}
}
// Extract the data and the CRC
$data = substr($png, $ipos, $chunk['size'] + 4);
$ipos = $ipos + $chunk['size'] + 4;
// Add in the header, data, and CRC
if (!$skip) $retval = $retval.$chunkHeader.$data;
if (!$skip) {
$retval = $retval.$chunkHeader.$data;
}
// Read next chunk header
$chunkHeader = substr($png, $ipos, 8);
$ipos = $ipos + 8;

Loading…
Cancel
Save