Implemented template (partial, it still needs some improvements) for courses catalogue, added course picture inside course settings.

skala
christian1827 15 years ago
parent 467c65659d
commit 2b37c86a71
  1. 1188
      main/auth/courses.php
  2. 295
      main/auth/courses_controller.php
  3. 23
      main/course_info/infocours.php
  4. 15
      main/inc/lib/app_view.php
  5. 611
      main/inc/lib/auth.lib.php
  6. 71
      main/inc/lib/course.lib.php
  7. 29
      main/inc/lib/image.lib.php
  8. 58
      main/inc/lib/main_api.lib.php
  9. 62
      main/template/default/auth/categories_list.php
  10. 187
      main/template/default/auth/courses_categories.php
  11. 292
      main/template/default/auth/courses_list.php
  12. 24
      main/template/default/auth/layout.php
  13. 145
      main/template/exampletables.php
  14. 6
      main/template/index.html
  15. 104
      main/template/template.php

File diff suppressed because it is too large Load Diff

@ -0,0 +1,295 @@
<?php
/* For licensing terms, see /license.txt */
/**
* This file contains class used like controller, it should be included inside a dispatcher file (e.g: index.php)
* @author Christian Fasanando <christian1827@gmail.com> - Beeznest
* @package chamilo.auth
*/
/**
* Controller script. Prepares the common background variables to give to the scripts corresponding to
* the requested action
* @package chamilo.auth
*/
class CoursesController { // extends Controller {
private $toolname;
private $view;
private $model;
/**
* Constructor
*/
public function __construct() {
$this->toolname = 'auth';
$actived_theme_path = api_get_template();
$this->view = new View($this->toolname, $actived_theme_path);
$this->model = new Auth();
}
/**
* It's used for listing courses,
* render to courses_list view
* @param string action
* @param string confirmation message(optional)
*/
public function courses_list($action, $message = '') {
$data = array();
$user_id = api_get_user_id();
//$user_courses = $auth->get_courses_of_user($user_id);
$data['user_courses'] = $this->model->get_courses_of_user($user_id);
$data['user_course_categories'] = $this->model->get_user_course_categories();
$data['courses_in_category'] = $this->model->get_courses_in_category();
$data['all_user_categories'] = $this->model->get_user_course_categories();
$data['action'] = $action;
$data['message'] = $message;
// render to the view
$this->view->set_data($data);
$this->view->set_layout('layout');
$this->view->set_template('courses_list');
$this->view->render();
}
/**
* It's used for listing categories,
* render to categories_list view
* @param string action
* @param string confirmation message(optional)
* @param string error message(optional)
*/
public function categories_list($action, $message='', $error='') {
$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('layout');
$this->view->set_template('categories_list');
$this->view->render();
}
/**
* It's used for listing courses with categories,
* render to courses_categories view
* @param string action
* @param string Category code (optional)
*/
public function courses_categories($action, $category_code = null, $message = '', $error = '') {
$data = array();
$browse_course_categories = $this->model->browse_course_categories();
if (!isset($category_code)) {
$category_code = $browse_course_categories[0][1]['code']; // by default first category
}
$data['browse_courses_in_category'] = $this->model->browse_courses_in_category($category_code);
$data['browse_course_categories'] = $browse_course_categories;
$data['code'] = $category_code;
// getting all the courses to which the user is subscribed to
$curr_user_id = api_get_user_id();
$user_courses = $this->model->get_courses_of_user($curr_user_id);
$user_coursecodes = array();
// we need only the course codes as these will be used to match against the courses of the category
if ($user_courses != '') {
foreach ($user_courses as $key => $value) {
$user_coursecodes[] = $value['code'];
}
}
$data['user_coursecodes'] = $user_coursecodes;
$data['action'] = $action;
$data['message'] = $message;
$data['error'] = $error;
// render to the view
$this->view->set_data($data);
$this->view->set_layout('layout');
$this->view->set_template('courses_categories');
$this->view->render();
}
/**
*
*/
public function search_courses($search_term, $message = '', $error = '') {
$data = array();
$browse_course_categories = $this->model->browse_course_categories();
$data['browse_courses_in_category'] = $this->model->search_courses($search_term);
$data['browse_course_categories'] = $browse_course_categories;
$data['search_term'] = $search_term;
// getting all the courses to which the user is subscribed to
$curr_user_id = api_get_user_id();
$user_courses = $this->model->get_courses_of_user($curr_user_id);
$user_coursecodes = array();
// we need only the course codes as these will be used to match against the courses of the category
if ($user_courses != '') {
foreach ($user_courses as $key => $value) {
$user_coursecodes[] = $value['code'];
}
}
$data['user_coursecodes'] = $user_coursecodes;
$data['message'] = $message;
$data['error'] = $error;
$data['action'] = 'display_courses';
// render to the view
$this->view->set_data($data);
$this->view->set_layout('layout');
$this->view->set_template('courses_categories');
$this->view->render();
}
/**
*
*/
public function subscribe_user($course_code, $search_term, $category_code) {
$data = array();
$result = $this->model->subscribe_user($course_code);
if (!$result) {
$error = get_lang('CourseRegistrationCodeIncorrect');
} else {
$message = $result;
}
if (!empty($search_term)) {
$this->search_courses($search_term, $message, $error);
} else {
$this->courses_categories('subcribe', $category_code, $message, $error);
}
}
/**
* Create a category
* render to listing view
* @param string Category title
*/
public function add_course_category($category_title) {
$result = $this->model->store_course_category($category_title);
$message = '';
if ($result) { $message = get_lang("CourseCategoryStored"); }
else { $error = get_lang('ACourseCategoryWithThisNameAlreadyExists');}
$action = 'createcoursecategory';
$this->categories_list($action, $message, $error);
}
/**
* Change course category
* render to listing view
* @param string Course code
* @param int Category id
*/
public function change_course_category($course_code, $category_id) {
$result = $this->model->store_changecoursecategory($course_code, $category_id);
$message = '';
if ($result) { $message = get_lang('EditCourseCategorySucces'); }
$action = 'sortmycourses';
$this->courses_list($action, $message);
}
/**
* Move up/down courses inside a category
* render to listing view
* @param string move to up or down
* @param string Course code
* @param int Category id
*/
public function move_course($move, $course_code, $category_id) {
$result = $this->model->move_course($move, $course_code, $category_id);
$message = '';
if ($result) { $message = get_lang('CourseSortingDone'); }
$action = 'sortmycourses';
$this->courses_list($action, $message);
}
/**
* Move up/down categories
* render to listing view
* @param string move to up or down
* @param int Category id
*/
public function move_category($move, $category_id) {
$result = $this->model->move_category($move, $category_id);
$message = '';
if ($result) { $message = get_lang('CategorySortingDone'); }
$action = 'sortmycourses';
$this->courses_list($action, $message);
}
/**
* Edit course category
* render to listing view
* @param string Category title
* @param int Category id
*/
public function edit_course_category($title, $category) {
$result = $this->model->store_edit_course_category($title, $category);
$message = '';
if ($result) { $message = get_lang('CourseCategoryEditStored'); }
$action = 'sortmycourses';
$this->courses_list($action, $message);
}
/**
* Delete a course category
* render to listing view
* @param int Category id
*/
public function delete_course_category($category_id) {
$result = $this->model->delete_course_category($category_id);
$message = '';
if ($result) { $message = get_lang('CourseCategoryDeleted'); }
$action = 'sortmycourses';
$this->courses_list($action, $message);
}
/**
* Unsubscribe user from a course
* render to listing view
* @param string Course code
*/
public function unsubscribe_user_from_course($course_code) {
$result = $this->model->remove_user_from_course($course_code);
$message = '';
if ($result) { $message = get_lang('YouAreNowUnsubscribed'); }
$action = 'sortmycourses';
$this->courses_list($action, $message);
}
}
?>

@ -37,7 +37,7 @@ $TABLECOURSEHOME = Database :: get_course_table(TABLE_TOOL_LIST);
$TABLELANGUAGES = Database :: get_main_table(TABLE_MAIN_LANGUAGE);
$TABLEBBCONFIG = Database :: get_course_table(TOOL_FORUM_CONFIG_TABLE);
$currentCourseID = $_course['sysCode'];
$currentCourseRepository = $_course['path'];
$currentCourseRepository = $_course['path'];
$is_allowedToEdit = $is_courseAdmin || $is_platformAdmin;
$course_setting_table = Database::get_course_table(TABLE_COURSE_SETTING);
@ -131,6 +131,12 @@ $form->addRule('tutor_name', get_lang('ThisFieldIsRequired'), 'required');
$form->addElement('select_language', 'course_language', get_lang('Ln'));
$form->addElement('static', null, '&nbsp;', get_lang('TipLang'));
// Picture
$form->addElement('file', 'picture', get_lang('AddPicture'));
$allowed_picture_types = array ('jpg', 'jpeg', 'png', 'gif');
$form->addRule('picture', get_lang('OnlyImagesAllowed').' ('.implode(',', $allowed_picture_types).')', 'filetype', $allowed_picture_types);
$form->addElement('style_submit_button', null, get_lang('SaveSettings'), 'class="save"');
@ -294,6 +300,13 @@ $form->setDefaults($values);
// Validate form
if ($form->validate() && is_settings_editable()) {
$update_values = $form->exportValues();
// update course picture
$picture = $_FILES['picture'];
if (!empty($picture['name'])) {
$picture_uri = CourseManager::update_course_picture($course_code, $picture['name'], $picture['tmp_name']);
}
foreach ($update_values as $index => & $value) {
$update_values[$index] = Database::escape_string($value);
}
@ -399,6 +412,14 @@ if (api_get_setting('allow_course_theme') == 'true') {
}
echo '</div>';
// display course picture
$course_path = api_get_path(SYS_COURSE_PATH).$currentCourseRepository; // course path
if (file_exists($course_path.'/course-pic85x85.png')) {
$course_web_path = api_get_path(WEB_COURSE_PATH).$currentCourseRepository; // course web path
$course_medium_image = $course_web_path.'/course-pic85x85.png'; // redimensioned image 85x85
echo '<div id="course-picture"><img src="'.$course_medium_image.'" /></div>';
}
// Display the form
$form->display();

@ -19,15 +19,20 @@ class View {
* Constructor, init tool path for rendering
* @param string tool name (optional)
*/
public function __construct($toolname = '') {
public function __construct($toolname = '', $template_path=null) {
if (!empty($toolname)) {
$path = api_get_path(SYS_CODE_PATH).$toolname.'/';
if (isset($template_path)) {
$path = $template_path.$toolname.'/';
} else {
$path = api_get_path(SYS_CODE_PATH).$toolname.'/';
}
if (is_dir($path)) {
$this->tool_path = $path;
$this->tool_path = $path;
} else {
throw new ViewException('View::__construct() $path directory does not exist ' . $path);
}
}
}
}
}
/**

@ -0,0 +1,611 @@
<?php
/* For licensing terms, see /license.txt */
/**
* This file contains a class used like library provides functions for auth tool. It's also used like model to courses_controller (MVC pattern)
* @author Christian Fasanando <christian1827@gmail.com>
* @package chamilo.auth
*/
require_once api_get_path(LIBRARY_PATH).'tracking.lib.php';
/**
* Auth can be used to instanciate objects or as a library to manage courses
* @package chamilo.auth
*/
class Auth
{
/**
* Constructor
*/
public function __construct() {}
/**
* retrieves all the courses that the user has already subscribed to
* @param int User id
* @return array an array containing all the information of the courses of the given user
*/
public function get_courses_of_user($user_id) {
$TABLECOURS = Database::get_main_table(TABLE_MAIN_COURSE);
$TABLECOURSUSER = Database::get_main_table(TABLE_MAIN_COURSE_USER);
$TABLE_COURSE_FIELD = Database :: get_main_table(TABLE_MAIN_COURSE_FIELD);
$TABLE_COURSE_FIELD_VALUE = Database :: get_main_table(TABLE_MAIN_COURSE_FIELD_VALUES);
// get course list auto-register
$sql = "SELECT course_code FROM $TABLE_COURSE_FIELD_VALUE tcfv INNER JOIN $TABLE_COURSE_FIELD tcf ON " .
" tcfv.field_id = tcf.id WHERE tcf.field_variable = 'special_course' AND tcfv.field_value = 1 ";
$special_course_result = Database::query($sql);
if(Database::num_rows($special_course_result)>0) {
$special_course_list = array();
while ($result_row = Database::fetch_array($special_course_result)) {
$special_course_list[] = '"'.$result_row['course_code'].'"';
}
}
$without_special_courses = '';
if (!empty($special_course_list)) {
$without_special_courses = ' AND course.code NOT IN ('.implode(',',$special_course_list).')';
}
// Secondly we select the courses that are in a category (user_course_cat<>0) and sort these according to the sort of the category
$user_id = intval($user_id);
$sql_select_courses = "SELECT course.code k, course.visual_code vc, course.subscribe subscr, course.unsubscribe unsubscr,
course.title i, course.tutor_name t, course.db_name db, course.directory dir, course_rel_user.status status,
course_rel_user.sort sort, course_rel_user.user_course_cat user_course_cat
FROM $TABLECOURS course,
$TABLECOURSUSER course_rel_user
WHERE course.code = course_rel_user.course_code
AND course_rel_user.relation_type<>".COURSE_RELATION_TYPE_RRHH."
AND course_rel_user.user_id = '".$user_id."' $without_special_courses
ORDER BY course_rel_user.sort ASC";
$result = Database::query($sql_select_courses);
while ($row = Database::fetch_array($result)) {
// we only need the database name of the course
$courses[] = 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;
}
/**
* retrieves the user defined course categories
* @return array containing all the IDs of the user defined courses categories, sorted by the "sort" field
*/
public function get_user_course_categories() {
$user_id = api_get_user_id();
$table_category = Database::get_user_personal_table(TABLE_USER_COURSE_CATEGORY);
$sql = "SELECT * FROM ".$table_category." WHERE user_id=$user_id ORDER BY sort ASC";
$result = Database::query($sql);
$output = array();
while ($row = Database::fetch_array($result)) {
$output[] = $row;
}
return $output;
}
/**
* This function get all the courses in the particular user category;
* @param int User category id
* @return string: the name of the user defined course category
*/
public function get_courses_in_category() {
$user_id = api_get_user_id();
// table definitions
$TABLECOURS = Database::get_main_table(TABLE_MAIN_COURSE);
$TABLECOURSUSER = Database::get_main_table(TABLE_MAIN_COURSE_USER);
$TABLE_USER_COURSE_CATEGORY = Database::get_user_personal_table(TABLE_USER_COURSE_CATEGORY);
$TABLE_COURSE_FIELD = Database :: get_main_table(TABLE_MAIN_COURSE_FIELD);
$TABLE_COURSE_FIELD_VALUE = Database :: get_main_table(TABLE_MAIN_COURSE_FIELD_VALUES);
// get course list auto-register
$sql = "SELECT course_code FROM $TABLE_COURSE_FIELD_VALUE tcfv INNER JOIN $TABLE_COURSE_FIELD tcf ON " .
" tcfv.field_id = tcf.id WHERE tcf.field_variable = 'special_course' AND tcfv.field_value = 1 ";
$special_course_result = Database::query($sql);
if(Database::num_rows($special_course_result)>0) {
$special_course_list = array();
while ($result_row = Database::fetch_array($special_course_result)) {
$special_course_list[] = '"'.$result_row['course_code'].'"';
}
}
$without_special_courses = '';
if (!empty($special_course_list)) {
$without_special_courses = ' AND course.code NOT IN ('.implode(',',$special_course_list).')';
}
$sql_select_courses = "SELECT course.code, course.visual_code, course.subscribe subscr, course.unsubscribe unsubscr,
course.title title, course.tutor_name tutor, course.db_name, course.directory, course_rel_user.status status,
course_rel_user.sort sort, course_rel_user.user_course_cat user_course_cat
FROM $TABLECOURS course,
$TABLECOURSUSER course_rel_user
WHERE course.code = course_rel_user.course_code
AND course_rel_user.user_id = '".$user_id."'
AND course_rel_user.relation_type <> ".COURSE_RELATION_TYPE_RRHH."
$without_special_courses
ORDER BY course_rel_user.user_course_cat, course_rel_user.sort ASC";
$result = Database::query($sql_select_courses);
$number_of_courses = Database::num_rows($result);
$data = array();
while ($course = Database::fetch_array($result)) {
$data[$course['user_course_cat']][] = $course;
}
return $data;
}
/**
* stores the changes in a course category (moving a course to a different course category)
* @param string Course code
* @param int Category id
* @return bool True if it success
*/
public function store_changecoursecategory($course_code, $newcategory) {
$course_code = Database::escape_string($course_code);
$newcategory = intval($newcategory);
$current_user = api_get_user_id();
$result = false;
$TABLECOURSUSER = Database::get_main_table(TABLE_MAIN_COURSE_USER);
$max_sort_value = api_max_sort_value($newcategory, $current_user); // max_sort_value($newcategory);
Database::query("UPDATE $TABLECOURSUSER SET user_course_cat='".$newcategory."', sort='".($max_sort_value + 1)."' WHERE course_code='".$course_code."' AND user_id='".$current_user."' AND relation_type<>".COURSE_RELATION_TYPE_RRHH." ");
if (Database::affected_rows()) { $result = true; }
return $result;
}
/**
* moves the course one place up or down
* @param string Direction (up/down)
* @param string Course code
* @param int Category id
* @return bool True if it success
*/
public function move_course($direction, $course2move, $category) {
// definition of tables
$TABLECOURSUSER = Database::get_main_table(TABLE_MAIN_COURSE_USER);
$current_user_id = api_get_user_id();
$all_user_courses = $this->get_courses_of_user($current_user_id);
$result = false;
// we need only the courses of the category we are moving in
$user_courses = array();
foreach ($all_user_courses as $key => $course) {
if ($course['user_course_category'] == $category) {
$user_courses[] = $course;
}
}
foreach ($user_courses as $key => $course) {
if ($course2move == $course['code']) {
// source_course is the course where we clicked the up or down icon
$source_course = $course;
// target_course is the course before/after the source_course (depending on the up/down icon)
if ($direction == 'up') {
$target_course = $user_courses[$key - 1];
} else {
$target_course = $user_courses[$key + 1];
}
}
}
if (count($target_course) > 0 && count($source_course) > 0) {
$sql_update1 = "UPDATE $TABLECOURSUSER SET sort='".$target_course['sort']."' WHERE course_code='".$source_course['code']."' AND user_id='".$current_user_id."' AND relation_type<>".COURSE_RELATION_TYPE_RRHH." ";
$sql_update2 = "UPDATE $TABLECOURSUSER SET sort='".$source_course['sort']."' WHERE course_code='".$target_course['code']."' AND user_id='".$current_user_id."' AND relation_type<>".COURSE_RELATION_TYPE_RRHH." ";
Database::query($sql_update2);
Database::query($sql_update1);
if (Database::affected_rows()) { $result = true; }
}
return $result;
}
/**
* Moves the course one place up or down
* @param string Direction up/down
* @param string Category id
* @return bool True If it success
*/
public function move_category($direction, $category2move) {
// the database definition of the table that stores the user defined course categories
$table_user_defined_category = Database::get_user_personal_table(TABLE_USER_COURSE_CATEGORY);
$current_user_id = api_get_user_id();
$user_coursecategories = $this->get_user_course_categories();
$user_course_categories_info = $this->get_user_course_categories_info();
$result = false;
foreach ($user_coursecategories as $key => $category) {
$category_id = $category['id'];
if ($category2move == $category_id) {
// source_course is the course where we clicked the up or down icon
$source_category = $user_course_categories_info[$category2move];
// target_course is the course before/after the source_course (depending on the up/down icon)
if ($direction == 'up') {
$target_category = $user_course_categories_info[$user_coursecategories[$key - 1]['id']];
} else {
$target_category = $user_course_categories_info[$user_coursecategories[$key + 1]['id']];
}
}
}
if (count($target_category) > 0 && count($source_category) > 0) {
$sql_update1="UPDATE $table_user_defined_category SET sort='".Database::escape_string($target_category['sort'])."' WHERE id='".intval($source_category['id'])."' AND user_id='".$current_user_id."'";
$sql_update2="UPDATE $table_user_defined_category SET sort='".Database::escape_string($source_category['sort'])."' WHERE id='".intval($target_category['id'])."' AND user_id='".$current_user_id."'";
Database::query($sql_update2);
Database::query($sql_update1);
if (Database::affected_rows()) {
$result = true;
}
}
return $result;
}
/**
* Retrieves the user defined course categories and all the info that goes with it
* @return array containing all the info of the user defined courses categories with the id as key of the array
*/
public function get_user_course_categories_info() {
$current_user_id = api_get_user_id();
$table_category = Database::get_user_personal_table(TABLE_USER_COURSE_CATEGORY);
$sql = "SELECT * FROM ".$table_category." WHERE user_id='".$current_user_id."' ORDER BY sort ASC";
$result = Database::query($sql);
while ($row = Database::fetch_array($result)) {
$output[$row['id']] = $row;
}
return $output;
}
/**
* Updates the user course category in the chamilo_user database
* @param string Category title
* @param int Category id
* @return bool True if it success
*/
public function store_edit_course_category($title, $category_id) {
// protect data
$title = Database::escape_string($title);
$category_id = intval($category_id);
$result = false;
$tucc = Database::get_user_personal_table(TABLE_USER_COURSE_CATEGORY);
$sql_update = "UPDATE $tucc SET title='".api_htmlentities($title, ENT_QUOTES, api_get_system_encoding())."' WHERE id='".$category_id."'";
Database::query($sql_update);
if (Database::affected_rows()) { $result = true; }
return $result;
}
/**
* deletes a course category and moves all the courses that were in this category to main category
* @param int Category id
* @return bool True if it success
*/
public function delete_course_category($category_id) {
$current_user_id = api_get_user_id();
$tucc = Database::get_user_personal_table(TABLE_USER_COURSE_CATEGORY);
$TABLECOURSUSER = Database::get_main_table(TABLE_MAIN_COURSE_USER);
$category_id = intval($category_id);
$result = false;
$sql_delete = "DELETE FROM $tucc WHERE id='".$category_id."' and user_id='".$current_user_id."'";
Database::query($sql_delete);
if (Database::affected_rows()) { $result = true; }
$sql_update = "UPDATE $TABLECOURSUSER SET user_course_cat='0' WHERE user_course_cat='".$category_id."' AND user_id='".$current_user_id."' AND relation_type<>".COURSE_RELATION_TYPE_RRHH." ";
Database::query($sql_update);
return $result;
}
/**
* unsubscribe the user from a given course
* @param string Course code
* @return bool True if it success
*/
public function remove_user_from_course($course_code) {
$tbl_course_user = Database::get_main_table(TABLE_MAIN_COURSE_USER);
// protect variables
$current_user_id = api_get_user_id();
$course_code = Database::escape_string($course_code);
$result = true;
// we check (once again) if the user is not course administrator
// because the course administrator cannot unsubscribe himself
// (s)he can only delete the course
$sql_check = "SELECT * FROM $tbl_course_user WHERE user_id='".$current_user_id."' AND course_code='".$course_code."' AND status='1' ";
$result_check = Database::query($sql_check);
$number_of_rows = Database::num_rows($result_check);
if ($number_of_rows > 0) {
$result = false;
}
CourseManager::unsubscribe_user($current_user_id, $course_code);
return $result;
}
/**
* stores the user course category in the chamilo_user database
* @param string Category title
* @return bool True if it success
*/
public function store_course_category($category_title) {
$tucc = Database::get_user_personal_table(TABLE_USER_COURSE_CATEGORY);
// protect data
$current_user_id = api_get_user_id();
$category_title = Database::escape_string($category_title);
$result = false;
// step 1: we determine the max value of the user defined course categories
$sql = "SELECT sort FROM $tucc WHERE user_id='".$current_user_id."' ORDER BY sort DESC";
$rs_sort = Database::query($sql);
$maxsort = Database::fetch_array($rs_sort);
$nextsort = $maxsort['sort'] + 1;
// step 2: we check if there is already a category with this name, if not we store it, else we give an error.
$sql = "SELECT * FROM $tucc WHERE user_id='".$current_user_id."' AND title='".$category_title."'ORDER BY sort DESC";
$rs = Database::query($sql);
if (Database::num_rows($rs) == 0) {
$sql_insert = "INSERT INTO $tucc (user_id, title,sort) VALUES ('".$current_user_id."', '".api_htmlentities($category_title, ENT_QUOTES, api_get_system_encoding())."', '".$nextsort."')";
Database::query($sql_insert);
if (Database::affected_rows()) { $result = true; }
} else {
$result = false;
}
return $result;
}
/**
* Counts the number of courses in a given course category
* @param string Category code
* @return int Count of courses
*/
public function count_courses_in_category($category_code) {
$tbl_course = Database::get_main_table(TABLE_MAIN_COURSE);
$TABLE_COURSE_FIELD = Database :: get_main_table(TABLE_MAIN_COURSE_FIELD);
$TABLE_COURSE_FIELD_VALUE = Database :: get_main_table(TABLE_MAIN_COURSE_FIELD_VALUES);
// get course list auto-register
$sql = "SELECT course_code FROM $TABLE_COURSE_FIELD_VALUE tcfv INNER JOIN $TABLE_COURSE_FIELD tcf ON " .
" tcfv.field_id = tcf.id WHERE tcf.field_variable = 'special_course' AND tcfv.field_value = 1 ";
$special_course_result = Database::query($sql);
if(Database::num_rows($special_course_result)>0) {
$special_course_list = array();
while ($result_row = Database::fetch_array($special_course_result)) {
$special_course_list[] = '"'.$result_row['course_code'].'"';
}
}
$without_special_courses = '';
if (!empty($special_course_list)) {
$without_special_courses = ' AND course.code NOT IN ('.implode(',',$special_course_list).')';
}
$sql = "SELECT * FROM $tbl_course WHERE category_code".(empty($category_code) ? " IS NULL" : "='".$category_code."'").$without_special_courses;
// Showing only the courses of the current Dokeos access_url_id.
global $_configuration;
if ($_configuration['multiple_access_urls']) {
$url_access_id = api_get_current_access_url_id();
if ($url_access_id != -1) {
$tbl_url_rel_course = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
$sql = "SELECT * FROM $tbl_course as course INNER JOIN $tbl_url_rel_course as url_rel_course
ON (url_rel_course.course_code=course.code)
WHERE access_url_id = $url_access_id AND category_code".(empty($category_code) ? " IS NULL" : "='".$category_code."'").$without_special_courses;
}
}
return Database::num_rows(Database::query($sql));
}
/**
* get the browsing of the course categories (faculties)
* @return array array containing a list with all the categories and subcategories(if needed)
*/
public function browse_course_categories() {
$tbl_courses_nodes = Database::get_main_table(TABLE_MAIN_CATEGORY);
$sql = "SELECT * FROM $tbl_courses_nodes ORDER BY tree_pos ASC";
$result = Database::query($sql);
$categories = array();
while ($row = Database::fetch_array($result)) {
$count_courses = $this->count_courses_in_category($row['code']);
$row['count_courses'] = $count_courses;
if (!isset($row['parent_id'])) {
$categories[0][$row['tree_pos']] = $row;
} else {
$categories[$row['parent_id']][$row['tree_pos']] = $row;
}
}
return $categories;
}
/**
* Display all the courses in the given course category. I could have used a parameter here
* @param string Category code
* @return array Courses data
*/
public function browse_courses_in_category($category_code) {
global $_configuration;
$tbl_course = Database::get_main_table(TABLE_MAIN_COURSE);
$TABLE_COURSE_FIELD = Database :: get_main_table(TABLE_MAIN_COURSE_FIELD);
$TABLE_COURSE_FIELD_VALUE = Database :: get_main_table(TABLE_MAIN_COURSE_FIELD_VALUES);
// get course list auto-register
$sql = "SELECT course_code FROM $TABLE_COURSE_FIELD_VALUE tcfv INNER JOIN $TABLE_COURSE_FIELD tcf ON " .
" tcfv.field_id = tcf.id WHERE tcf.field_variable = 'special_course' AND tcfv.field_value = 1 ";
$special_course_result = Database::query($sql);
if(Database::num_rows($special_course_result)>0) {
$special_course_list = array();
while ($result_row = Database::fetch_array($special_course_result)) {
$special_course_list[] = '"'.$result_row['course_code'].'"';
}
}
$without_special_courses = '';
if (!empty($special_course_list)) {
$without_special_courses = ' AND course.code NOT IN ('.implode(',',$special_course_list).')';
}
$category_code = Database::escape_string($category_code);
$my_category = (empty($category) ? " IS NULL" : "='".$category."'");
$sql = "SELECT * FROM $tbl_course WHERE category_code='$category_code' $without_special_courses ORDER BY title, visual_code";
//showing only the courses of the current Dokeos access_url_id
if ($_configuration['multiple_access_urls']) {
$url_access_id = api_get_current_access_url_id();
if ($url_access_id != -1) {
$tbl_url_rel_course = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
$sql = "SELECT * FROM $tbl_course as course INNER JOIN $tbl_url_rel_course as url_rel_course
ON (url_rel_course.course_code=course.code)
WHERE access_url_id = $url_access_id AND category_code='$category_code' $without_special_courses ORDER BY title, visual_code";
}
}
$result = Database::query($sql);
$courses = array();
while ($row = Database::fetch_array($result)) {
$row['registration_code'] = !empty($row['registration_code']);
$count_users = count(CourseManager::get_user_list_from_course_code($row['code']));
$lastmonth = mktime(0, 0, 0, date("m")-1, date("d"), date("Y"));
$count_connections_last_moth = Tracking::get_count_connections_on_the_course($row['code'], 0, $lastmonth);
$courses[] = array(
'code' => $row['code'],
'directory' => $row['directory'],
'db' => $row['db_name'],
'visual_code' => $row['visual_code'],
'title' => $row['title'],
'tutor' => $row['tutor_name'],
'subscribe' => $row['subscribe'],
'unsubscribe' => $row['unsubscribe'],
'registration_code' => $registration_code,
'creation_date' => $row['creation_date'],
'count_users' => $count_users,
'count_connections' => $count_connections_last_moth
);
}
return $courses;
}
/**
* Search the courses database for a course that matches the search term.
* The search is done on the code, title and tutor field of the course table.
* @param string $search_term: the string that the user submitted, what we are looking for
* @return array an array containing a list of all the courses (the code, directory, dabase, visual_code, title, ... ) matching the the search term.
*/
public function search_courses($search_term) {
$TABLECOURS = Database::get_main_table(TABLE_MAIN_COURSE);
$TABLE_COURSE_FIELD = Database :: get_main_table(TABLE_MAIN_COURSE_FIELD);
$TABLE_COURSE_FIELD_VALUE = Database :: get_main_table(TABLE_MAIN_COURSE_FIELD_VALUES);
// get course list auto-register
$sql = "SELECT course_code FROM $TABLE_COURSE_FIELD_VALUE tcfv INNER JOIN $TABLE_COURSE_FIELD tcf ON " .
" tcfv.field_id = tcf.id WHERE tcf.field_variable = 'special_course' AND tcfv.field_value = 1 ";
$special_course_result = Database::query($sql);
if(Database::num_rows($special_course_result)>0) {
$special_course_list = array();
while ($result_row = Database::fetch_array($special_course_result)) {
$special_course_list[] = '"'.$result_row['course_code'].'"';
}
}
$without_special_courses = '';
if (!empty($special_course_list)) {
$without_special_courses = ' AND course.code NOT IN ('.implode(',',$special_course_list).')';
}
$search_term_safe = Database::escape_string($search_term);
$sql_find = "SELECT * FROM $TABLECOURS WHERE (code LIKE '%".$search_term_safe."%' OR title LIKE '%".$search_term_safe."%' OR tutor_name LIKE '%".$search_term_safe."%') $without_special_courses ORDER BY title, visual_code ASC";
global $_configuration;
if ($_configuration['multiple_access_urls']) {
$url_access_id = api_get_current_access_url_id();
if ($url_access_id != -1) {
$tbl_url_rel_course = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
$sql_find = "SELECT * FROM $TABLECOURS as course INNER JOIN $tbl_url_rel_course as url_rel_course
ON (url_rel_course.course_code=course.code)
WHERE access_url_id = $url_access_id AND (code LIKE '%".$search_term_safe."%' OR title LIKE '%".$search_term_safe."%' OR tutor_name LIKE '%".$search_term_safe."%' ) $without_special_courses ORDER BY title, visual_code ASC ";
}
}
$result_find = Database::query($sql_find);
while ($row = Database::fetch_array($result_find)) {
$row['registration_code'] = !empty($row['registration_code']);
$count_users = count(CourseManager::get_user_list_from_course_code($row['code']));
$lastmonth = mktime(0, 0, 0, date("m")-1, date("d"), date("Y"));
$count_connections_last_moth = Tracking::get_count_connections_on_the_course($row['code'], 0, $lastmonth);
$courses[] = array(
'code' => $row['code'],
'directory' => $row['directory'],
'db' => $row['db_name'],
'visual_code' => $row['visual_code'],
'title' => $row['title'],
'tutor' => $row['tutor_name'],
'subscribe' => $row['subscribe'],
'unsubscribe' => $row['unsubscribe'],
'registration_code' => $registration_code,
'creation_date' => $row['creation_date'],
'count_users' => $count_users,
'count_connections' => $count_connections_last_moth
);
// $courses[] = array('code' => $row['code'], 'directory' => $row['directory'], 'db' => $row['db_name'], 'visual_code' => $row['visual_code'], 'title' => $row['title'], 'tutor' => $row['tutor_name'], 'subscribe' => $row['subscribe'], 'unsubscribe' => $row['unsubscribe']);
}
return $courses;
}
/**
* Subscribe the user to a given course
* @param string Course code
* @return string Message about results
*/
public function subscribe_user($course_code) {
global $_user;
$all_course_information = CourseManager::get_course_information($course_code);
if ($all_course_information['registration_code'] == '' || $_POST['course_registration_code'] == $all_course_information['registration_code']) {
if (api_is_platform_admin()) {
$status_user_in_new_course = COURSEMANAGER;
} else {
$status_user_in_new_course=null;
}
if (CourseManager::add_user_to_course($_user['user_id'], $course_code, $status_user_in_new_course)) {
$send = api_get_course_setting('email_alert_to_teacher_on_new_user_in_course', $course_code);
if ($send == 1) {
CourseManager::email_to_tutor($_user['user_id'], $course_code, $send_to_tutor_also = false);
} else if ($send == 2){
CourseManager::email_to_tutor($_user['user_id'], $course_code, $send_to_tutor_also = true);
}
return get_lang('EnrollToCourseSuccessful');
} else {
return get_lang('ErrorContactPlatformAdmin');
}
} else {
$return = '';
if (isset($_POST['course_registration_code']) && $_POST['course_registration_code'] != $all_course_information['registration_code']) {
return false;
}
$return .= get_lang('CourseRequiresPassword').'<br />';
$return .= $all_course_information['visual_code'].' - '.$all_course_information['title'];
$return .= "<form action=\"".api_get_path(WEB_CODE_PATH)."auth/courses.php?action=subscribe_course&sec_token=".$_SESSION['sec_token']."&subscribe_course=".$all_course_information['code']."&category_code=".$all_course_information['category_code']." \" method=\"post\">";
$return .= '<input type="hidden" name="token" value="'.$_SESSION['sec_token'].'" />';
//$return .= "<input type=\"hidden\" name=\"subscribe\" value=\"".$all_course_information['code']."\" />";
//$return .= "<input type=\"hidden\" name=\"category_code\" value=\"".$all_course_information['category_code']."\" />";
$return .= "<input type=\"text\" name=\"course_registration_code\" value=\"".$_POST['course_registration_code']."\" />";
$return .= "<input type=\"submit\" name=\"submit_course_registration_code\" value=\"OK\" alt=\"".get_lang('SubmitRegistrationCode')."\" /></form>";
return $return;
}
}
}
?>

@ -2381,4 +2381,75 @@ class CourseManager {
return $is_special;
}
/**
* Update course picture
* @param string Course code
* @param string File name
* @param string The full system name of the image from which course picture will be created.
* @return bool Returns the resulting. In case of internal error or negative validation returns FALSE.
*/
public static function update_course_picture($course_code, $filename, $source_file = null) {
$course_info = api_get_course_info($course_code);
$store_path = api_get_path(SYS_COURSE_PATH).$course_info['path']; // course path
$course_image = $store_path.'/course-pic.png'; // image name for courses
$course_medium_image = $store_path.'/course-pic85x85.png';
$extension = strtolower(substr(strrchr($filename, '.'), 1));
$result = false;
$allowed_picture_types = array ('jpg', 'jpeg', 'png', 'gif');
if (in_array($extension, $allowed_picture_types)) {
if (file_exists($course_image)) {
@unlink($course_image);
}
if (file_exists($course_medium_image)) {
@unlink($course_medium_image);
}
if ($extension != 'png') {
// convert image to png extension
if ($extension == 'jpg' || $extension == 'jpeg') {
$image = imagecreatefromjpeg($source_file);
} else {
$image = imagecreatefromgif($source_file);
}
ob_start();
imagepng($image);
$imagevariable = ob_get_contents();
ob_end_clean();
// save picture
if (@file_put_contents($course_image, $imagevariable)) {
$result = true;
}
} else {
$result = @move_uploaded_file($source_file, $course_image);
}
}
// redimension image to 85x85
if ($result) {
$max_size_for_picture = 85;
if (!class_exists('image')) {
require_once api_get_path(LIBRARY_PATH).'image.lib.php';
}
$medium = new image($course_image);
$picture_infos = api_getimagesize($course_image);
if ($picture_infos[0] > $max_size_for_picture) {
$thumbwidth = $max_size_for_picture;
$new_height = $max_size_for_picture; //round(($thumbwidth / $picture_infos[0]) * $picture_infos[1]);
//if ($new_height > $max_size_for_picture) { $new_height = $thumbwidth;}
$medium->resize($thumbwidth, $new_height, 0, true);
}
$rs = $medium->send_image('PNG', $store_path.'/course-pic85x85.png');
}
return $result;
}
} //end class CourseManager

@ -34,15 +34,22 @@ class image {
return $imhandler;
}
function resize($thumbw, $thumbh, $border) {
function resize($thumbw, $thumbh, $border, $specific_size = false) {
$size [0] = $this->bgx;
$size [1] = $this->bgy;
if ($border == 1) {
$scale = min($thumbw / $size[0], $thumbh / $size[1]);
$width = (int)($size[0] * $scale);
$height = (int)($size[1] * $scale);
if ($specific_size) {
$width = $thumbw;
$height = $thumbh;
} else {
$scale = min($thumbw / $size[0], $thumbh / $size[1]);
$width = (int)($size[0] * $scale);
$height = (int)($size[1] * $scale);
}
$deltaw = (int)(($thumbw - $width) / 2);
$deltah = (int)(($thumbh - $height) / 2);
$dst_img = @ImageCreateTrueColor($thumbw, $thumbh);
@ -53,9 +60,17 @@ class image {
$this->bgy = $thumbh;
}
elseif ($border == 0) {
$scale = ($size[0] > 0 && $size[1] > 0) ? min($thumbw / $size[0], $thumbh / $size[1]) : 0;
$width = (int)($size[0] * $scale);
$height = (int)($size[1] * $scale);
if ($specific_size) {
$width = $thumbw;
$height = $thumbh;
} else {
$scale = ($size[0] > 0 && $size[1] > 0) ? min($thumbw / $size[0], $thumbh / $size[1]) : 0;
$width = (int)($size[0] * $scale);
$height = (int)($size[1] * $scale);
}
$deltaw = 0;
$deltah = 0;

@ -192,6 +192,8 @@ define('CONFIGURATION_PATH', 'CONFIGURATION_PATH');
define('WEB_LIBRARY_PATH', 'WEB_LIBRARY_PATH');
define('WEB_AJAX_PATH', 'WEB_AJAX_PATH');
define('SYS_TEST_PATH', 'SYS_TEST_PATH');
define('WEB_TEMPLATE_PATH', 'WEB_TEMPLATE_PATH');
define('SYS_TEMPLATE_PATH', 'SYS_TEMPLATE_PATH');
// Constants for requesting path conversion.
define('TO_WEB', 'TO_WEB');
@ -261,31 +263,32 @@ require_once dirname(__FILE__).'/internationalization.lib.php';
*
* This is how we can retireve mosth used paths, for common purpose:
* api_get_path(REL_PATH) /chamilo/
* api_get_path(REL_COURSE_PATH) /chamilo/courses/
* api_get_path(REL_PATH) /chamilo/
* api_get_path(REL_COURSE_PATH) /chamilo/courses/
* api_get_path(REL_CODE_PATH) /chamilo/main/
* api_get_path(SYS_SERVER_ROOT_PATH) /var/www/ - This is the physical folder where the system Chamilo has been placed. It is not always equal to $_SERVER['DOCUMENT_ROOT'].
* api_get_path(SYS_PATH) /var/www/chamilo/
* api_get_path(SYS_ARCHIVE_PATH) /var/www/chamilo/archive/
* api_get_path(SYS_COURSE_PATH) /var/www/chamilo/courses/
* api_get_path(SYS_CODE_PATH) /var/www/chamilo/main/
* api_get_path(SYS_ARCHIVE_PATH) /var/www/chamilo/archive/
* api_get_path(SYS_COURSE_PATH) /var/www/chamilo/courses/
* api_get_path(SYS_CODE_PATH) /var/www/chamilo/main/
* api_get_path(INCLUDE_PATH) /var/www/chamilo/main/inc/
* api_get_path(LIBRARY_PATH) /var/www/chamilo/main/inc/lib/
* api_get_path(CONFIGURATION_PATH) /var/www/chamilo/main/inc/conf/
* api_get_path(SYS_LANG_PATH) /var/www/chamilo/main/lang/
* api_get_path(SYS_PLUGIN_PATH) /var/www/chamilo/plugin/
* api_get_path(SYS_TEST_PATH) /var/www/chamilo/tests/
* api_get_path(SYS_LANG_PATH) /var/www/chamilo/main/lang/
* api_get_path(SYS_PLUGIN_PATH) /var/www/chamilo/plugin/
* api_get_path(SYS_TEST_PATH) /var/www/chamilo/tests/
* api_get_path(SYS_TEMPLATE_PATH) /var/www/chamilo/main/template/
*
* api_get_path(WEB_SERVER_ROOT_PATH) http://www.mychamilo.org/
* api_get_path(WEB_PATH) http://www.mychamilo.org/chamilo/
* api_get_path(WEB_SERVER_ROOT_PATH) http://www.mychamilo.org/
* api_get_path(WEB_PATH) http://www.mychamilo.org/chamilo/
* api_get_path(WEB_COURSE_PATH) http://www.mychamilo.org/chamilo/courses/
* api_get_path(WEB_CODE_PATH) http://www.mychamilo.org/chamilo/main/
* api_get_path(WEB_PLUGIN_PATH) http://www.mychamilo.org/chamilo/plugin/
* api_get_path(WEB_ARCHIVE_PATH) http://www.mychamilo.org/chamilo/archive/
* api_get_path(WEB_ARCHIVE_PATH) http://www.mychamilo.org/chamilo/archive/
* api_get_path(WEB_IMG_PATH) http://www.mychamilo.org/chamilo/main/img/
* api_get_path(WEB_CSS_PATH) http://www.mychamilo.org/chamilo/main/css/
* api_get_path(WEB_LIBRARY_PATH) http://www.mychamilo.org/chamilo/main/inc/lib/
* api_get_path(WEB_TEMPLATE_PATH) http://www.mychamilo.org/chamilo/main/template/
*
*
* This is how we retrieve paths of "registerd" resource files (scripts, players, etc.):
@ -329,7 +332,9 @@ function api_get_path($path_type, $path = null) {
CONFIGURATION_PATH => 'inc/conf/',
WEB_LIBRARY_PATH => 'inc/lib/',
WEB_AJAX_PATH => 'inc/ajax/',
SYS_TEST_PATH => 'tests/'
SYS_TEST_PATH => 'tests/',
WEB_TEMPLATE_PATH => 'template/',
SYS_TEMPLATE_PATH => 'template/'
);
static $resource_paths = array(
@ -431,6 +436,7 @@ function api_get_path($path_type, $path = null) {
$paths[SYS_PLUGIN_PATH] = $paths[SYS_PATH].$paths[SYS_PLUGIN_PATH];
$paths[SYS_ARCHIVE_PATH] = $paths[SYS_PATH].$paths[SYS_ARCHIVE_PATH];
$paths[SYS_TEST_PATH] = $paths[SYS_PATH].$paths[SYS_TEST_PATH];
$paths[SYS_TEMPLATE_PATH] = $paths[SYS_CODE_PATH].$paths[SYS_TEMPLATE_PATH];
$paths[WEB_CSS_PATH] = $paths[WEB_CODE_PATH].$paths[WEB_CSS_PATH];
$paths[WEB_IMG_PATH] = $paths[WEB_CODE_PATH].$paths[WEB_IMG_PATH];
@ -440,6 +446,8 @@ function api_get_path($path_type, $path = null) {
$paths[WEB_PLUGIN_PATH] = $paths[WEB_PATH].$paths[WEB_PLUGIN_PATH];
$paths[WEB_ARCHIVE_PATH] = $paths[WEB_PATH].$paths[WEB_ARCHIVE_PATH];
$paths[WEB_TEMPLATE_PATH] = $paths[WEB_CODE_PATH].$paths[WEB_TEMPLATE_PATH];
$paths[INCLUDE_PATH] = $paths[SYS_CODE_PATH].$paths[INCLUDE_PATH];
$paths[LIBRARY_PATH] = $paths[SYS_CODE_PATH].$paths[LIBRARY_PATH];
$paths[CONFIGURATION_PATH] = $paths[SYS_CODE_PATH].$paths[CONFIGURATION_PATH];
@ -4599,3 +4607,27 @@ function api_protect_global_admin_script() {
return true;
}
/**
* Get actived template
* @param string theme type (optional: default)
* @param string path absolute(abs) or relative(rel) (optional:rel)
* @return string actived template path
*/
function api_get_template($path_type = 'rel') {
$path_types = array('rel', 'abs');
$template_path = '';
if (in_array($path_type, $path_types)) {
if ($path_type == 'rel') {
$template_path = api_get_path(SYS_TEMPLATE_PATH);
} else {
$template_path = api_get_path(WEB_TEMPLATE_PATH);
}
}
$actived_theme = 'default';
if (api_get_setting('active_template')) {
$actived_theme = api_get_setting('active_template');
}
$actived_theme_path = $template_path.$actived_theme.DIRECTORY_SEPARATOR;
return $actived_theme_path;
}

@ -0,0 +1,62 @@
<?php
/* For licensing terms, see /license.txt */
/**
* View (MVC patter) for creating course category
* @author Christian Fasanando <christian1827@gmail.com> - Beeznest
* @package chamilo.auth
*/
// Acces 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">
<?php if ($action != 'sortmycourses' && isset($action)) { ?>
&nbsp;&nbsp;<a href="<?php echo api_get_self() ?>?action=sortmycourses"><?php echo Display::return_icon('deplacer_fichier.gif', get_lang('SortMyCourses')).' '.get_lang('SortMyCourses') ?></a>&nbsp;
<?php } else { ?>
&nbsp;&nbsp;<strong><?php echo Display::return_icon('deplacer_fichier.gif', get_lang('SortMyCourses')).' '.get_lang('SortMyCourses') ?></strong>&nbsp;
<?php } ?>
&nbsp;
<?php if ($action != 'createcoursecategory') { ?>
&nbsp;&nbsp;<a href="<?php echo api_get_self() ?>?action=createcoursecategory"><?php echo Display::return_icon('folder_new.gif', get_lang('CreateCourseCategory')).' '.get_lang('CreateCourseCategory') ?></a>&nbsp;
<?php } else { ?>
&nbsp;&nbsp;<strong><?php echo Display::return_icon('folder_new.gif', get_lang('CreateCourseCategory')).' '.get_lang('CreateCourseCategory') ?></strong>&nbsp;
<?php } ?>
&nbsp;
<?php if ($action != 'subscribe') { ?>
&nbsp;&nbsp;<a href="<?php echo api_get_self() ?>?action=subscribe&hidden_links=1"><?php echo Display::return_icon('view_more_stats.gif', get_lang('SubscribeToCourse')).' '.get_lang('SubscribeToCourse') ?></a>&nbsp;
<?php } else { ?>
&nbsp;&nbsp;<strong><?php echo Display::return_icon('view_more_stats.gif', get_lang('SubscribeToCourse')).' '.get_lang('SubscribeToCourse') ?></strong>&nbsp;
<?php } ?>
</div>
<?php
if (!empty($message)) { Display::display_confirmation_message($message, false); }
if (!empty($error)) { Display::display_error_message($error, false); }
?>
<form name="create_course_category" method="post" action="<?php echo api_get_self() ?>?action=createcoursecategory">
<input type="hidden" name="sec_token" value="<?php echo $stok ?>">
<input type="text" name="title_course_category" />
<button type="submit" class="save" name="create_course_category"><?php echo get_lang('Ok') ?></button>
</form>
<?php
echo get_lang('ExistingCourseCategories');
if (!empty($user_course_categories)) {
?>
<ul>
<?php foreach ($user_course_categories as $row) { ?>
<li><?php echo $row['title'] ?></li>
<?php } ?>
</ul>
<?php } ?>

@ -0,0 +1,187 @@
<?php
/* For licensing terms, see /license.txt */
/**
* View (MVC patter) for courses categories
* @author Christian Fasanando <christian1827@gmail.com> - Beeznest
* @package chamilo.auth
*/
$stok = Security::get_token();
?>
<!-- Actions: The menu with the different options in cathe course management -->
<?php if(intval($_GET['hidden_links']) != 1) { ?>
<div id="actions" class="actions">
<?php if ($action != 'sortmycourses' && isset($action)) { ?>
&nbsp;&nbsp;<a href="<?php echo api_get_self() ?>?action=sortmycourses"><?php echo Display::return_icon('deplacer_fichier.gif', get_lang('SortMyCourses')).' '.get_lang('SortMyCourses') ?></a>&nbsp;
<?php } else { ?>
&nbsp;&nbsp;<strong><?php echo Display::return_icon('deplacer_fichier.gif', get_lang('SortMyCourses')).' '.get_lang('SortMyCourses') ?></strong>&nbsp;
<?php } ?>
&nbsp;
<?php if ($action != 'createcoursecategory') { ?>
&nbsp;&nbsp;<a href="<?php echo api_get_self() ?>?action=createcoursecategory"><?php echo Display::return_icon('folder_new.gif', get_lang('CreateCourseCategory')).' '.get_lang('CreateCourseCategory') ?></a>&nbsp;
<?php } else { ?>
&nbsp;&nbsp;<strong><?php echo Display::return_icon('folder_new.gif', get_lang('CreateCourseCategory')).' '.get_lang('CreateCourseCategory') ?></strong>&nbsp;
<?php } ?>
&nbsp;
<?php if ($action != 'subscribe') { ?>
&nbsp;&nbsp;<a href="<?php echo api_get_self() ?>?action=subscribe"><?php echo Display::return_icon('view_more_stats.gif', get_lang('SubscribeToCourse')).' '.get_lang('SubscribeToCourse') ?></a>&nbsp;
<?php } else { ?>
&nbsp;&nbsp;<strong><?php echo Display::return_icon('view_more_stats.gif', get_lang('SubscribeToCourse')).' '.get_lang('SubscribeToCourse') ?></strong>&nbsp;
<?php } ?>
</div>
<?php } ?>
<div id="categories-content" >
<div id="categories-content-left">
<div id="categories-search">
<p><strong><?php echo get_lang('SearchCourse') ?></strong><br />
<form class="course_list" method="post" action="<?php echo api_get_self() ?>?action=subscribe&hidden_links=1">
<input type="hidden" name="sec_token" value="<?php echo $stok ?>">
<input type="hidden" name="search_course" value="1" />
<input type="text" size="12" name="search_term" value="<?php echo (empty($_POST['search_term']) ? '' : Security::remove_XSS($_POST['search_term'])) ?>" />
&nbsp;<button class="search" type="submit"><?php echo get_lang('_search') ?></button>
</form>
</div>
<div id="categories-list">
<?php if (!empty($browse_course_categories)) {
// level 1
foreach ($browse_course_categories[0] as $category) {
$category_name = $category['name'];
$category_code = $category['code'];
$count_courses_lv1 = $category['count_courses'];
if ($code == $category_code) {
$category_link = '<strong>'.$category_name.' ('.$count_courses_lv1.')</strong>';
} else {
$category_link = '<a href="'. api_get_self().'?action=display_courses&category_code='.$category_code.'&hidden_links=1">'.$category_name.'</a> ('.$count_courses_lv1.')';
}
echo '<div>'.$category_link.'</div>';
// level 2
if (!empty($browse_course_categories[$category_code])) {
foreach ($browse_course_categories[$category_code] as $subcategory1) {
$subcategory1_name = $subcategory1['name'];
$subcategory1_code = $subcategory1['code'];
$count_courses_lv2 = $subcategory1['count_courses'];
if ($code == $subcategory1_code) {
$subcategory1_link = '<strong>'.$subcategory1_name.' ('.$count_courses_lv2.')</strong>';
} else {
$subcategory1_link = '<a href="'. api_get_self().'?action=display_courses&category_code='.$subcategory1_code.'&hidden_links=1">'.$subcategory1_name.'</a> ('.$count_courses_lv2.')';
}
echo '<div style="margin-left:20px;">'.$subcategory1_link.'</div>';
}
// level 3
if (!empty($browse_course_categories[$subcategory1_code])) {
foreach ($browse_course_categories[$subcategory1_code] as $subcategory2) {
$subcategory2_name = $subcategory2['name'];
$subcategory2_code = $subcategory2['code'];
$count_courses_lv3 = $subcategory2['count_courses'];
if ($code == $subcategory2_code) {
$subcategory2_link = '<strong>'.$subcategory2_name.' ('.$count_courses_lv3.')</strong>';
} else {
$subcategory2_link = '<a href="'. api_get_self().'?action=display_courses&category_code='.$subcategory2_code.'&hidden_links=1">'.$subcategory2_name.'</a> ('.$count_courses_lv3.')';
}
echo '<div style="margin-left:40px;">'.$subcategory2_link.'</div>';
}
}
}
}
?>
<?php } ?>
</div>
</div>
<div id="categories-content-right">
<?php if (!empty($message)) { Display::display_confirmation_message($message, false); } ?>
<?php if (!empty($error)) { Display::display_error_message($error, false); } ?>
<?php
if (!empty($search_term)) {
echo "<p><strong>".get_lang('SearchResultsFor')." ".api_htmlentities($_POST['search_term'], ENT_QUOTES, api_get_system_encoding())."</strong><br />";
}
if (!empty($browse_courses_in_category)) {
foreach ($browse_courses_in_category as $course) {
$title = $course['title'];
$tutor_name = $course['tutor'];
$creation_date = $course['creation_date'];
$count_connections = $course['count_connections'];
$course_path = api_get_path(SYS_COURSE_PATH).$course['directory']; // course path
if (file_exists($course_path.'/course-pic85x85.png')) {
$course_web_path = api_get_path(WEB_COURSE_PATH).$course['directory']; // course web path
$course_medium_image = $course_web_path.'/course-pic85x85.png'; // redimensioned image 85x85
} else {
$course_medium_image = api_get_path(WEB_IMG_PATH).'without_picture.png'; // without picture
}
echo '<div class="categories-block-course">
<div class="categories-content-course">
<div class="categories-course-picture">
<img src="'.$course_medium_image.'" />
</div>
<div class="categories-course-description">
<div class="course-block-text" style="text-align:center;"><strong>'.strtoupper($title).'</strong></div>
<div class="course-block-text"><strong>'.get_lang('TutorName').':</strong> <br />'.$tutor_name.'</div>
<div class="course-block-text"><strong>'.get_lang('CreationDate').':</strong><br />'.$creation_date.'</div>
<div class="course-block-text"><strong>'.get_lang('ConexionsLastMonth').':</strong>'.$count_connections.'</div>
</div>
</div>
<div style="clear:both;"></div>
<div class="categories-course-links">';
if (api_get_setting('show_courses_descriptions_in_catalog') == 'true') {
echo '<span class="course-link-desc"><a href="'.api_get_path(WEB_CODE_PATH).'inc/ajax/course_home.ajax.php?a=show_course_information&code='.$course['code'].'" title="'.$icon_title.'" rel="gb_page_center[778]">'.get_lang('CourseDetails').'</a></span>';
}
// we display the icon to subscribe or the text already subscribed
if (!in_array($course['code'], $user_coursecodes)) {
if ($course['subscribe'] == SUBSCRIBE_ALLOWED) {
echo '<span class="course-link-desc"><a href="'. api_get_self().'?action=subscribe_course&sec_token='.$stok.'&subscribe_course='.$course['code'].'&search_term='.$search_term.'&category_code='.$code.'">'.get_lang('Subscribe').'</a></span>';
}
}
echo '</div>
</div>';
}
} else {
echo '<div id="course-message">'.get_lang('ThereAreNoCoursesInThisCategory').'</div>';
}
?>
<div class="clear"></div>
</div>
</div>

@ -0,0 +1,292 @@
<?php
/* For licensing terms, see /license.txt */
/**
* View (MVC patter) for courses
* @author Christian Fasanando <christian1827@gmail.com> - Beeznest
* @package chamilo.auth
*/
// Acces rights: anonymous users can't do anything usefull here.
api_block_anonymous_users();
$stok = Security::get_token();
$courses_without_category = $courses_in_category[0];
?>
<!-- Actions: The menu with the different options in cathe course management -->
<div id="actions" class="actions">
<?php if ($action != 'sortmycourses' && isset($action)) { ?>
&nbsp;&nbsp;<a href="<?php echo api_get_self(); ?>?action=sortmycourses"><?php echo Display::return_icon('deplacer_fichier.gif', get_lang('SortMyCourses')).' '.get_lang('SortMyCourses'); ?></a>&nbsp;
<?php } else { ?>
&nbsp;&nbsp;<strong><?php echo Display::return_icon('deplacer_fichier.gif', get_lang('SortMyCourses')).' '.get_lang('SortMyCourses'); ?></strong>&nbsp;
<?php } ?>
&nbsp;
<?php if ($action != 'createcoursecategory') { ?>
&nbsp;&nbsp;<a href="<?php echo api_get_self(); ?>?action=createcoursecategory"><?php echo Display::return_icon('folder_new.gif', get_lang('CreateCourseCategory')).' '.get_lang('CreateCourseCategory'); ?></a>&nbsp;
<?php } else { ?>
&nbsp;&nbsp;<strong><?php echo Display::return_icon('folder_new.gif', get_lang('CreateCourseCategory')).' '.get_lang('CreateCourseCategory'); ?></strong>&nbsp;
<?php } ?>
&nbsp;
<?php if ($action != 'subscribe') { ?>
&nbsp;&nbsp;<a href="<?php echo api_get_self(); ?>?action=subscribe&hidden_links=1"><?php echo Display::return_icon('view_more_stats.gif', get_lang('SubscribeToCourse')).' '.get_lang('SubscribeToCourse'); ?></a>&nbsp;
<?php } else { ?>
&nbsp;&nbsp;<strong><?php echo Display::return_icon('view_more_stats.gif', get_lang('SubscribeToCourse')).' '.get_lang('SubscribeToCourse'); ?></strong>&nbsp;
<?php } ?>
</div>
<table cellpadding="4">
<?php if (!empty($message)) { Display::display_confirmation_message($message, false); } ?>
<?php
// COURSES WITHOUT CATEGORY
if (!empty($courses_without_category)) {
$number_of_courses = count($courses_without_category);
$key = 0;
foreach ($courses_without_category as $course) { ?>
<tr>
<?php if (api_get_setting('show_courses_descriptions_in_catalog') == 'true') {
$icon_title = get_lang('CourseDetails') . ' - ' . $course['title'];
?>
<td>
<a href="<?php echo api_get_path(WEB_CODE_PATH); ?>inc/ajax/course_home.ajax.php?a=show_course_information&code=<?php echo $course['code'] ?>" title="<?php echo $icon_title ?>" rel="gb_page_center[778]"><?php echo Display::return_icon('synthese_view.gif', $icon_title); ?></a>
</td>
<?php } ?>
<td>
<a name="course<?php echo $course['code']; ?>"></a>
<strong><?php echo $course['title']; ?></strong><br />
<?php
if (api_get_setting('display_coursecode_in_courselist') == 'true') { echo $course['visual_code']; }
if (api_get_setting('display_coursecode_in_courselist') == 'true' && api_get_setting('display_teacher_in_courselist') == 'true') { echo " - "; }
if (api_get_setting('display_teacher_in_courselist') == 'true') { echo $course['tutor']; }
?>
</td>
<td valign=\"top\">
<!-- display course icons -->
<table><tr><td>
<?php if ($key > 0) { ?>
<a href="courses.php?action=<?php echo $action; ?>&amp;move=up&amp;course=<?php echo $course['code']; ?>&amp;category=<?php echo $course['user_course_cat']; ?>&amp;sec_token=<?php echo $stok; ?>">
<?php echo Display::display_icon('up.gif', get_lang('Up')) ?>
</a>
<?php } ?>
</td>
<!-- the edit icon OR the edit dropdown list -->
<?php if (isset($_GET['edit']) && $course['code'] == $_GET['edit']) {
$edit_course = Security::remove_XSS($_GET['edit']);
?>
<td rowspan="2" valign="top">
<form name="edit_course_category" method="post" action="courses.php?action=<?php echo $action; ?>">
<input type="hidden" name="sec_token" value="<?php echo $stok; ?>">
<input type="hidden" name="course_2_edit_category" value="<?php echo $edit_course; ?>" />
<select name="course_categories">
<option value="0"><?php echo get_lang("NoCourseCategory"); ?></option>
<?php foreach ($user_course_categories as $row) { ?>
<option value="<?php echo $row['id']; ?>"><?php echo $row['title']; ?></option>
<?php } ?>
</select>
<button class="save" type="submit" name="submit_change_course_category"><?php echo get_lang('Ok') ?></button>
</form>
</td>
<?php } else { ?>
<td rowspan="2" valign="middle"><a href="courses.php?action=<?php echo $action; ?>&amp;edit=<?php echo $course['code']; ?>&amp;sec_token=<?php echo $stok; ?>">
<?php echo Display::display_icon('edit.gif', get_lang('Edit')); ?>
</a></td>
<?php } ?>
<td rowspan="2" valign="top" class="invisible">
<?php if ($course['status'] != 1) {
if ($course['unsubscr'] == 1) {
?>
<!-- changed link to submit to avoid action by the search tool indexer -->
<form action="<?php echo api_get_self(); ?>" method="post" onsubmit="javascript: if (!confirm('<?php echo addslashes(api_htmlentities(get_lang("ConfirmUnsubscribeFromCourse"), ENT_QUOTES, api_get_system_encoding())) ?>')) return false;">
<input type="hidden" name="sec_token" value="<?php echo $stok; ?>">
<input type="hidden" name="unsubscribe" value="<?php echo $course['code']; ?>" />
<input type="image" name="unsub" style="border-color:#fff" src="<?php echo api_get_path(WEB_IMG_PATH).'delete.gif'; ?>" title="<?php echo get_lang('_unsubscribe') ?>" alt="<?php echo get_lang('_unsubscribe'); ?>" /></form>
<?php } else {
echo get_lang('UnsubscribeNotAllowed');
}
} else {
echo get_lang('CourseAdminUnsubscribeNotAllowed');
}
?>
</td>
</tr><tr><td>
<?php if ($key < $number_of_courses - 1) { ?>
<a href="courses.php?action=<?php echo $action; ?>&amp;move=down&amp;course=<?php echo $course['code']; ?>&amp;category=<?php echo $course['user_course_cat']; ?>&amp;sec_token=<?php echo $stok; ?>">
<?php echo Display::display_icon('down.gif', get_lang('Down')); ?>
</a>
<?php } ?>
</td></tr></table>
</td>
</tr>
<?php $key++;
}
} ?>
<!-- COURSES WITH CATEGORIES -->
<?php if (!empty($user_course_categories)) {
foreach ($user_course_categories as $row) {
if (isset($_GET['categoryid']) && $_GET['categoryid'] == $row['id']) {
?>
<!-- We display the edit form for the category -->
<tr><td colspan="2" class="user_course_category">
<a name="category<?php echo $row['id']; ?>"></a>
<form name="edit_course_category" method="post" action="courses.php?action=<?php echo $action; ?>">
<input type="hidden" name="edit_course_category" value="<?php echo $row['id']; ?>" />
<input type="hidden" name="sec_token" value="<?php echo $stok; ?>">
<input type="text" name="title_course_category" value="<?php echo $row['title']; ?>" />
<button class="save" type="submit" name="submit_edit_course_category"><?php echo get_lang('Ok'); ?></button>
</form>
<?php } else { ?>
<tr><td colspan="2" class="user_course_category">
<a name="category<?php echo $row['id']; ?>"></a>
<?php echo $row['title']; ?>
<?php } ?>
</td><td class="user_course_category">
<!-- display category icons -->
<?php $max_category_key = count($user_course_categories);
if ($action != 'unsubscribe') { ?>
<table>
<tr>
<td>
<?php if ($row['id'] != $user_course_categories[0]['id']) { ?>
<a href="courses.php?action=<?php echo $action ?>&amp;move=up&amp;category=<?php echo $row['id']; ?>&amp;sec_token=<?php echo $stok; ?>">
<?php echo Display::return_icon('up.gif', get_lang('Up')); ?>
</a>
<?php } ?>
</td>
<td rowspan="2">
<a href="courses.php?action=sortmycourses&amp;categoryid=<?php echo $row['id']; ?>&amp;sec_token=<?php echo $stok; ?>#category<?php echo $row['id']; ?>">
<?php echo Display::display_icon('edit.gif', get_lang('Edit')); ?>
</a>
</td>
<td rowspan=\"2\">
<a href="courses.php?action=deletecoursecategory&amp;id=<?php echo $row['id']; ?>&amp;sec_token=<?php echo $stok; ?>">
<?php echo Display::display_icon('delete.gif', get_lang('Delete'), array('onclick' => "javascript: if (!confirm('".addslashes(api_htmlentities(get_lang("CourseCategoryAbout2bedeleted"), ENT_QUOTES, api_get_system_encoding()))."')) return false;")) ?>
</a>
</td>
</tr>
<tr>
<td>
<?php if ($row['id'] != $user_course_categories[$max_category_key - 1]['id']) { ?>
<a href="courses.php?action=<?php echo $action; ?>&amp;move=down&amp;category=<?php echo $row['id']; ?>&amp;sec_token=<?php echo $stok; ?>">
<?php echo Display::return_icon('down.gif', get_lang('Down')); ?>
</a>
<?php } ?>
</td>
</tr>
</table>
<?php } ?>
</td></tr>
<!-- Show the courses inside this category -->
<?php
$number_of_courses = count($courses_in_category[$row['id']]);
$key = 0;
if (!empty($courses_in_category[$row['id']])) {
foreach ($courses_in_category[$row['id']] as $course) {
?>
<tr>
<?php if (api_get_setting('show_courses_descriptions_in_catalog') == 'true') {
$icon_title = get_lang('CourseDetails') . ' - ' . $course['title'];
?>
<td>
<a href="<?php echo api_get_path(WEB_CODE_PATH); ?>inc/ajax/course_home.ajax.php?a=show_course_information&code=<?php echo $course['code'] ?>" title="<?php echo $icon_title ?>" rel="gb_page_center[778]"><?php echo Display::return_icon('synthese_view.gif', $icon_title) ?></a>
</td>
<?php } ?>
<td>
<a name="course<?php echo $course['code']; ?>"></a>
<strong><?php echo $course['title']; ?></strong><br />
<?php
if (api_get_setting('display_coursecode_in_courselist') == 'true') { echo $course['visual_code']; }
if (api_get_setting('display_coursecode_in_courselist') == 'true' && api_get_setting('display_teacher_in_courselist') == 'true') { echo " - "; }
if (api_get_setting('display_teacher_in_courselist') == 'true') { echo $course['tutor']; }
?>
</td>
<td valign="top">
<!-- display course icons -->
<table><tr><td>
<?php if ($key > 0) { ?>
<a href="courses.php?action=<?php echo $action; ?>&amp;move=up&amp;course=<?php echo $course['code']; ?>&amp;category=<?php echo $course['user_course_cat']; ?>&amp;sec_token=<?php echo $stok; ?>">
<?php echo Display::display_icon('up.gif', get_lang('Up')); ?>
</a>
<?php } ?>
</td>
<?php if (isset($_GET['edit']) && $course['code'] == $_GET['edit']) {
$edit_course = Security::remove_XSS($_GET['edit']);
?>
<td rowspan="2" valign="top">
<form name="edit_course_category" method="post" action="courses.php?action=<?php echo $action; ?>">
<input type="hidden" name="sec_token" value="<?php echo $stok; ?>">
<input type="hidden" name="course_2_edit_category" value="<?php echo $edit_course; ?>" />
<select name="course_categories">
<option value="0"><?php echo get_lang("NoCourseCategory"); ?></option>
<?php foreach ($user_course_categories as $row) { ?>
<option value="<?php echo $row['id'] ?>"><?php echo $row['title']; ?></option>
<?php } ?>
</select>
<button class="save" type="submit" name="submit_change_course_category"><?php echo get_lang('Ok'); ?></button>
</form>
</td>
<?php } else { ?>
<td rowspan="2" valign="middle"><a href="courses.php?action=<?php echo $action; ?>&amp;edit=<?php echo $course['code']; ?>&amp;sec_token=<?php echo $stok; ?>">
<?php echo Display::display_icon('edit.gif', get_lang('Edit')); ?>
</a></td>
<?php } ?>
<td rowspan="2" valign="top" class="invisible">
<?php if ($course['status'] != 1) {
if ($course['unsubscr'] == 1) {
?>
<form action="<?php echo api_get_self(); ?>" method="post" onsubmit="javascript: if (!confirm('<?php echo addslashes(api_htmlentities(get_lang("ConfirmUnsubscribeFromCourse"), ENT_QUOTES, api_get_system_encoding()))?>')) return false">
<input type="hidden" name="sec_token" value="<?php echo $stok; ?>">
<input type="hidden" name="unsubscribe" value="<?php echo $course['code']; ?>" />
<input type="image" name="unsub" style="border-color:#fff" src="<?php echo api_get_path(WEB_IMG_PATH); ?>delete.gif" title="<?php echo get_lang('_unsubscribe') ?>" alt="<?php echo get_lang('_unsubscribe') ?>" /></form>
<?php } else {
echo get_lang('UnsubscribeNotAllowed');
}
} else {
echo get_lang('CourseAdminUnsubscribeNotAllowed');
}
?>
</td>
</tr><tr><td>
<?php if ($key < $number_of_courses - 1) { ?>
<a href="courses.php?action=<?php echo $action; ?>&amp;move=down&amp;course=<?php echo $course['code']; ?>&amp;category=<?php echo $course['user_course_cat']; ?>&amp;sec_token=<?php echo $stok; ?>">
<?php echo Display::display_icon('down.gif', get_lang('Down')); ?>
</a>
<?php } ?>
</td></tr></table>
</td>
</tr>
<?php $key++;
}
}
}
}
?>
</table>

@ -0,0 +1,24 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Layout (principal view) used for structuring other views
* @author Christian Fasanando <christian1827@gmail.com> - Beeznest
* @package chamilo.auth
*/
// Acces rights: anonymous users can't do anything usefull here.
api_block_anonymous_users();
// Header
Display :: display_header('');
// Display
echo $content;
// Footer
Display :: display_footer();
?>

@ -1,145 +0,0 @@
<?php // $Id: exampletables.php,v 1.2 2006/03/15 14:34:45 pcool Exp $
/*
==============================================================================
Dokeos - elearning and course management software
Copyright (c) 2004 Dokeos S.A.
Copyright (c) 2003 Ghent University (UGent)
Copyright (c) 2001 Universite catholique de Louvain (UCL)
Copyright (c) Vrije Universiteit Brussel (VUB)
For a full list of contributors, see "credits.txt".
The full license can be read in "license.txt".
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
See the GNU General Public License for more details.
Contact: Dokeos, 181 rue Royale, B-1000 Brussels, Belgium, info@dokeos.com
==============================================================================
*/
/**
==============================================================================
* This file is a code template;
* copy the code and paste it in a new file to begin your own work.
*
* @package dokeos.plugin
==============================================================================
*/
/*
==============================================================================
INIT SECTION
==============================================================================
*/
// global settings initialisation
// also provides access to main api (inc/lib/main_api.lib.php)
include("../inc/global.inc.php");
/*
-----------------------------------------------------------
Libraries
-----------------------------------------------------------
*/
//main_api.lib.php by default included
//also the display and database libraries are loaded by default
/*
-----------------------------------------------------------
Header
-----------------------------------------------------------
*/
$nameTools = "Table examples (for developers)"; // title of the page (should come from the language file)
Display::display_header($nameTools);
/*
-----------------------------------------------------------
Constants
-----------------------------------------------------------
*/
define ("REPEAT_COUNT", "5");
/*
==============================================================================
FUNCTIONS
==============================================================================
*/
/*
==============================================================================
MAIN CODE
==============================================================================
*/
api_display_tool_title($nameTools);
$row = 0;
$column_header[$row++] = "Column 1";
$column_header[$row++] = "Column 2";
$column_header[$row++] = "Column 3";
/*
An important parameter for display_complex_table_header
is $properties, an array with elements, all of which have defaults
"width" - the table width, e.g. "85%"
"class" - the class to use for the table, e.g. "class=\"data_table\""
by default class is "class=\"data_table\""
"cellpadding" - the extra border in each cell, e.g. "8"
*/
/*
-----------------------------------------------------------
Table that hilites
-----------------------------------------------------------
*/
Display::display_normal_message("The following table hilites on mouseover (hover), this is the Display API default.");
Display::display_complex_table_header($properties, $column_header);
for ($i = 0; $i < REPEAT_COUNT; $i++)
{
$row = 0;
$table_row[$row++] = "First";
$table_row[$row++] = "Second";
$table_row[$row++] = "Third";
Display::display_table_row($bgcolor, $table_row, true);
}
Display::display_table_footer();
echo "<br/><br/>";
/*
-----------------------------------------------------------
Table that alternates row colours
-----------------------------------------------------------
*/
Display::display_normal_message("The following table has alternating row colours and no hilite");
$properties["class"] = ""; //no hilite
$bgcolour = Display::display_complex_table_header($properties, $column_header);
for ($i = 0; $i < REPEAT_COUNT; $i++)
{
$row = 0;
$table_row[$row++] = "First";
$table_row[$row++] = "Second";
$table_row[$row++] = "Third";
$bgcolour = Display::display_table_row($bgcolour, $table_row, true);
}
Display::display_table_footer();
/*
==============================================================================
FOOTER
==============================================================================
*/
Display::display_footer();
?>

@ -1,6 +0,0 @@
<html>
<head>
</head>
<body>
</body>
</html>

@ -1,104 +0,0 @@
<?php // $Id: template.php,v 1.2 2006/03/15 14:34:45 pcool Exp $
/*
==============================================================================
Dokeos - elearning and course management software
Copyright (c) 2004-2006 Dokeos S.A.
Copyright (c) Sally "Example" Programmer (sally@somewhere.net)
//add your name + the name of your organisation - if any - to this list
For a full list of contributors, see "credits.txt".
The full license can be read in "license.txt".
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
See the GNU General Public License for more details.
Contact address: Dokeos, 44 rue des palais, B-1030 Brussels, Belgium
Mail: info@dokeos.com
==============================================================================
*/
/**
==============================================================================
* This file is a code template;
* copy the code and paste it in a new file to begin your own work.
*
* @package dokeos.plugin
==============================================================================
*/
/*
==============================================================================
INIT SECTION
==============================================================================
*/
// global settings initialisation
// also provides access to main, database and display API libraries
include("../inc/global.inc.php");
/*
-----------------------------------------------------------
Libraries
-----------------------------------------------------------
*/
//the main_api.lib.php, database.lib.php and display.lib.php
//libraries are included by default
/*
-----------------------------------------------------------
Header
-----------------------------------------------------------
*/
// Optional extra http or html header
// If you need to add some HTTP/HTML headers code
// like JavaScript functions, stylesheets, redirects, put them here.
// $httpHeadXtra[] = "";
// $httpHeadXtra[] = "";
// ...
//
// $htmlHeadXtra[] = "";
// $htmlHeadXtra[] = "";
// ...
$tool_name = "Example Plugin"; // title of the page (should come from the language file)
Display::display_header($tool_name);
/*
==============================================================================
FUNCTIONS
==============================================================================
*/
// put your functions here
// if the list gets large, divide them into different sections:
// display functions, tool logic functions, database functions
// try to place your functions into an API library or separate functions file - it helps reuse
/*
==============================================================================
MAIN CODE
==============================================================================
*/
// Put your main code here. Keep this section short,
// it's better to use functions for any non-trivial code
api_display_tool_title($tool_name);
Display::display_normal_message("Hello world!");
/*
==============================================================================
FOOTER
==============================================================================
*/
Display::display_footer();
?>
Loading…
Cancel
Save