';
} elseif (isset($nameTools) && $language_file != 'course_home') {
//Put the name of the user-tools in the header
- if (!isset($_user['user_id'])) {
+ if (!isset($user_id)) {
//echo '';
} elseif (!$noPHP_SELF) {
$html .= '
';
while ($announcement = Database::fetch_object($announcements)) {
diff --git a/main/inc/lib/template.lib.php b/main/inc/lib/template.lib.php
index ee472909ce..456955dafa 100644
--- a/main/inc/lib/template.lib.php
+++ b/main/inc/lib/template.lib.php
@@ -2,12 +2,11 @@
/* For licensing terms, see /license.txt */
/*
* @author Julio Montoya
+ * @todo better organization of the class, methods and variables
*
**/
- /* @todo better organization of the class methods and variables */
-
-// Load Smarty library
+ // Load Smarty library
require_once api_get_path(LIBRARY_PATH).'smarty/Smarty.class.php';
require_once api_get_path(LIBRARY_PATH).'course_home.lib.php';
require_once api_get_path(LIBRARY_PATH).'banner.lib.php';
@@ -22,7 +21,7 @@ class Template extends Smarty {
var $show_header;
var $show_footer;
var $help;
- var $menu_navigation = array();
+ //var $menu_navigation = array();
var $show_learnpath = false; // This is a learnpath section or not?
var $plugin = null;
var $course_id = null;
@@ -53,10 +52,9 @@ class Template extends Smarty {
//Setting user variables
$this->set_user_parameters();
-
- //Setting course id
- $course_id = api_get_course_int_id();
- $this->course_id = $course_id;
+
+ //Setting course variables
+ $this->set_course_parameters();
//header and footer are showed by default
$this->set_footer($show_footer);
@@ -82,9 +80,9 @@ class Template extends Smarty {
//Chamilo plugins
$this->plugin = new AppPlugin();
- $plugin_blocks = $this->plugin->get_plugin_blocks();
- foreach ($plugin_blocks as $block) {
- $this->set_plugin_block($block);
+ $plugin_regions = $this->plugin->get_plugin_regions();
+ foreach ($plugin_regions as $region) {
+ $this->set_plugin_region($region);
}
}
@@ -213,8 +211,16 @@ class Template extends Smarty {
function get_template($name) {
return $this->style.'/'.$name;
- }
+ }
+
+ /* Set course parameters */
+ private function set_course_parameters() {
+ //Setting course id
+ $course_id = api_get_course_int_id();
+ $this->course_id = $course_id;
+ }
+ /* Set user parameters */
private function set_user_parameters() {
$user_info = array();
$user_info['logged'] = 0;
@@ -235,6 +241,7 @@ class Template extends Smarty {
$this->assign('_u', $user_info);
}
+ /* Set system parameters */
private function set_system_parameters() {
global $_configuration;
@@ -243,7 +250,8 @@ class Template extends Smarty {
'web_course' => api_get_path(WEB_COURSE_PATH),
'web_main' => api_get_path(WEB_CODE_PATH),
'web_ajax' => api_get_path(WEB_AJAX_PATH),
- 'web_img' => api_get_path(WEB_IMG_PATH)
+ 'web_img' => api_get_path(WEB_IMG_PATH),
+ 'web_plugin' => api_get_path(WEB_PLUGIN_PATH)
);
$this->assign('_p', $_p);
@@ -285,23 +293,24 @@ class Template extends Smarty {
$this->assign('css_style', $style_html);
$style_print = '@import "'.api_get_path(WEB_CSS_PATH).$this->theme.'/print.css";'."\n";
- $this->assign('css_style_print', $style_print);
- $this->assign('style_print', $style_print);
- // Header 1
- $header1 = show_header_1($language_file, $nameTools, $this->theme);
- $this->assign('header1', $header1);
+ $this->assign('css_style_print', $style_print);
+
+ // Logo
+ $logo = return_logo($this->theme);
+ $this->assign('logo', $logo);
}
private function set_header_parameters() {
$help = $this->help;
$nameTools = $this->title;
+
global $lp_theme_css, $mycoursetheme, $user_theme;
- global $httpHeadXtra, $htmlHeadXtra, $_course, $_user, $text_dir, $_user,
- $_cid, $interbreadcrumb, $charset, $language_file, $noPHP_SELF;
+ global $httpHeadXtra, $htmlHeadXtra, $_course, $text_dir,
+ $interbreadcrumb, $charset, $language_file, $noPHP_SELF;
- $navigation = return_navigation_array();
- $this->menu_navigation = $navigation['menu_navigation'];
+ //$navigation = return_navigation_array();
+ //$this->menu_navigation = $navigation['menu_navigation'];
global $_configuration;
@@ -325,6 +334,7 @@ class Template extends Smarty {
$title_list[] = api_get_setting('Institution');
$title_list[] = api_get_setting('siteName');
+
if (!empty($course_title)) {
$title_list[] = $course_title;
}
@@ -403,6 +413,7 @@ class Template extends Smarty {
$css_file_to_string .= api_get_css($css_file);
}
+ // @todo move this somewhere else
if (SHOW_TEXT_NEAR_ICONS == true) {
//hack in order to fix the actions buttons
$css_file_to_string .= '';
Display::display_reduced_header();
echo '';
}
@@ -61,7 +57,7 @@ if ($origin == 'tracking') {
} else {
$url_suffix = '&lp_id=' . $lp_id;
}
-if (!empty ($_GET['extend_all'])) {
+if (!empty($_GET['extend_all'])) {
$extend_all_link = '';
$extend_all = 1;
} else {
@@ -91,6 +87,9 @@ $TBL_QUIZ = Database :: get_course_table(TABLE_QUIZ_TEST);
$tbl_stats_exercices = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
$tbl_stats_attempts = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
+//It cames from myspace/lp_tracking.php
+$lp_id = intval($lp_id);
+
$sql = "SELECT max(view_count) FROM $TBL_LP_VIEW WHERE c_id = $course_id AND lp_id = $lp_id AND user_id = '" . $user_id . "' $session_condition";
$res = Database::query($sql);
$view = '';
@@ -101,9 +100,7 @@ if (Database :: num_rows($res) > 0) {
}
$counter = 0;
-//error_log('New LP - Querying views for latest attempt: '.$sql, 0);
$total_score = 0;
-$total_max_score = 0;
$total_time = 0;
$h = get_lang('h');
@@ -117,8 +114,8 @@ if (!empty($export_csv)) {
}
// Get attempts of a exercise.
-if (isset($_GET['lp_id']) && isset($_GET['my_lp_id'])) {
- $clean_lp_item_id = Database::escape_string($_GET['my_lp_id']);
+if (isset($_GET['lp_id']) && isset($_GET['lp_item_id'])) {
+ $clean_lp_item_id = Database::escape_string($_GET['lp_item_id']);
$clean_lp_id = Database::escape_string($_GET['lp_id']);
$clean_course_code = Database :: escape_string($course_code);
$sql_path = "SELECT path FROM $TBL_LP_ITEM WHERE c_id = $course_id AND id = '$clean_lp_item_id' AND lp_id = '$clean_lp_id'";
@@ -134,40 +131,36 @@ if (isset($_GET['lp_id']) && isset($_GET['my_lp_id'])) {
WHERE exe_exo_id="' . (int)$row_path['path'] . '" AND status <> "incomplete" AND exe_user_id="' . $student_id . '" AND orig_lp_id = "'.(int)$clean_lp_id.'" AND orig_lp_item_id = "'.(int)$clean_lp_item_id.'" AND exe_cours_id="' . $clean_course_code. '" AND session_id = '.$session_id.' ORDER BY exe_date';
}
}
+ //var_dump($sql_attempts);
}
+//Show lp items
-
-if (is_array($list) && count($list) > 0) {
+if (is_array($list) && count($list) > 0) {
foreach ($list as $my_item_id) {
$extend_this = 0;
$qry_order = 'DESC';
if ((!empty ($_GET['extend_id']) && $_GET['extend_id'] == $my_item_id) || $extend_all) {
$extend_this = 1;
$qry_order = 'ASC';
- }
+ }
// Prepare statement to go through each attempt.
- if (!empty ($view)) {
- $sql = "SELECT iv.status as mystatus, v.view_count as mycount, " .
- " iv.score as myscore, iv.total_time as mytime, i.id as myid, i.lp_id as mylpid, iv.lp_view_id as mylpviewid, " .
- " i.title as mytitle, i.max_score as mymaxscore, " .
- " iv.max_score as myviewmaxscore, " .
- " i.item_type as item_type, iv.view_count as iv_view_count, " .
- " iv.id as iv_id, path as path" .
- " FROM $TBL_LP_ITEM as i, $TBL_LP_ITEM_VIEW as iv, $TBL_LP_VIEW as v" .
- " WHERE
+ if (!empty($view)) {
+ $sql = "SELECT iv.status as mystatus, v.view_count as mycount, iv.score as myscore, iv.total_time as mytime, i.id as myid,
+ i.lp_id as mylpid, iv.lp_view_id as mylpviewid, i.title as mytitle, i.max_score as mymaxscore,
+ iv.max_score as myviewmaxscore, i.item_type as item_type, iv.view_count as iv_view_count, iv.id as iv_id, path as path
+ FROM $TBL_LP_ITEM as i INNER JOIN $TBL_LP_ITEM_VIEW as iv ON (i.id = iv.lp_item_id )
+ INNER JOIN $TBL_LP_VIEW as v ON (iv.lp_view_id = v.id)
+ WHERE
i.c_id = $course_id AND
iv.c_id = $course_id AND
- v.c_id = $course_id AND
- i.id = iv.lp_item_id " .
- " AND i.id = $my_item_id " .
- " AND iv.lp_view_id = v.id " .
- " AND i.lp_id = $lp_id " .
- " AND v.user_id = " . $user_id . " " .
- " AND v.view_count = $view " .
- " AND v.session_id = $session_id " .
- " ORDER BY iv.view_count $qry_order ";
+ v.c_id = $course_id AND i.id = $my_item_id AND
+ i.lp_id = $lp_id AND
+ v.user_id = " . $user_id . " AND
+ v.view_count = $view AND v.session_id = $session_id
+ ORDER BY iv.view_count $qry_order ";
+ //var_dump($sql);
} else {
$sql = "SELECT iv.status as mystatus, v.view_count as mycount, " .
" iv.score as myscore, iv.total_time as mytime, i.id as myid, i.lp_id as mylpid, iv.lp_view_id as mylpviewid, " .
@@ -187,28 +180,28 @@ if (is_array($list) && count($list) > 0) {
" AND v.session_id = $session_id " .
" ORDER BY iv.view_count $qry_order ";
}
- //echo $sql.' ';
+
$result = Database::query($sql);
$num = Database :: num_rows($result);
$time_for_total = 'NaN';
-
- $is_allowed_to_edit = api_is_allowed_to_edit(null, true);
-
+
+ //Extend all + extend scorm?
if (($extend_this || $extend_all) && $num > 0) {
+ //var_dump('go');
$row = Database :: fetch_array($result);
$result_disabled_ext_all = false;
if ($row['item_type'] == 'quiz') {
// Check results_disabled in quiz table.
$my_path = Database::escape_string($row['path']);
- $sql = "SELECT results_disabled FROM $TBL_QUIZ WHERE c_id = $course_id AND id ='".(int)$my_path."'";
+ $sql = "SELECT results_disabled FROM $TBL_QUIZ WHERE c_id = $course_id AND id ='".$my_path."'";
$res_result_disabled = Database::query($sql);
$row_result_disabled = Database::fetch_row($res_result_disabled);
if (Database::num_rows($res_result_disabled) > 0 && (int)$row_result_disabled[0] === 1) {
$result_disabled_ext_all = true;
}
- }
+ }
//echo '
'; print_r($row); echo '
';
// If there are several attempts, and the link to extend has been clicked, show each attempt...
@@ -232,10 +225,10 @@ if (is_array($list) && count($list) > 0) {
$title = Security::remove_XSS($title);
$output .= "
diff --git a/main/work/work.php b/main/work/work.php
index a5a7e6c1c8..d241ecf84f 100644
--- a/main/work/work.php
+++ b/main/work/work.php
@@ -112,7 +112,6 @@ $currentUserFirstName = $_user['firstName'];
$currentUserLastName = $_user['lastName'];
$currentUserEmail = $_user['mail'];
-$delete = isset($_REQUEST['delete']) ? Database::escape_string($_REQUEST['delete']) : '';
$description = isset($_REQUEST['description']) ? Database::escape_string($_REQUEST['description']) : '';
$item_id = isset($_REQUEST['item_id']) ? intval($_REQUEST['item_id']) : null;
@@ -1026,29 +1025,29 @@ switch ($action) {
/* Delete dir command */
if ($is_allowed_to_edit && !empty($_REQUEST['delete_dir'])) {
-
- del_dir($_REQUEST['delete_dir']);
-
- $delete_2 = intval($_REQUEST['delete_dir']);
+ $delete_dir_id = intval($_REQUEST['delete_dir']);
+ $work_to_delete = get_work_data_by_id($delete_dir_id);
+ del_dir($delete_dir_id);
+
// gets calendar_id from student_publication_assigment
- $sql = "SELECT add_to_calendar FROM $TSTDPUBASG WHERE c_id = $course_id AND publication_id ='$delete_2'";
+ $sql = "SELECT add_to_calendar FROM $TSTDPUBASG WHERE c_id = $course_id AND publication_id ='$delete_dir_id'";
$res = Database::query($sql);
$calendar_id = Database::fetch_row($res);
+
// delete from agenda if it exists
if (!empty($calendar_id[0])) {
$t_agenda = Database::get_course_table(TABLE_AGENDA);
$sql = "DELETE FROM $t_agenda WHERE c_id = $course_id AND id ='".$calendar_id[0]."'";
Database::query($sql);
}
- $sql2 = "DELETE FROM $TSTDPUBASG WHERE c_id = $course_id AND publication_id ='$delete_2'";
- $result2 = Database::query($sql2);
+ $sql = "DELETE FROM $TSTDPUBASG WHERE c_id = $course_id AND publication_id ='$delete_dir_id'";
+ Database::query($sql);
- $link_id = is_resource_in_course_gradebook(api_get_course_id(), 3 , $delete_2, api_get_session_id());
+ $link_id = is_resource_in_course_gradebook(api_get_course_id(), 3 , $delete_dir_id, api_get_session_id());
if ($link_id !== false) {
remove_resource_from_course_gradebook($link_id);
- }
- Display :: display_confirmation_message(get_lang('DirDeleted') . ': '.$delete_directory);
-
+ }
+ Display :: display_confirmation_message(get_lang('DirDeleted') . ': '.$work_to_delete['title']);
}
/* DELETE WORK COMMAND */
@@ -1056,9 +1055,10 @@ switch ($action) {
if ($action == 'delete' && $item_id) {
$file_deleted = false;
- $is_author = user_is_author($item_id);
+ $is_author = user_is_author($item_id);
+ $work_data = get_work_data_by_id($item_id);
- if (($is_author AND api_get_course_setting('student_delete_own_publication') == 1)) {
+ if ($is_allowed_to_edit || ($is_author && api_get_course_setting('student_delete_own_publication') == 1 && $work_data['qualificator_id'] == 0)) {
//we found the current user is the author
$queryString1 = "SELECT url, contains_file FROM " . $work_table . " WHERE c_id = $course_id AND id = $item_id";
$result1 = Database::query($queryString1);
@@ -1067,8 +1067,8 @@ switch ($action) {
if (Database::num_rows($result1) > 0) {
$queryString2 = "UPDATE " . $work_table . " SET active = 2 WHERE c_id = $course_id AND id = $item_id";
$queryString3 = "DELETE FROM " . $TSTDPUBASG . " WHERE c_id = $course_id AND publication_id = $item_id";
- $result2 = Database::query($queryString2);
- $result3 = Database::query($queryString3);
+ Database::query($queryString2);
+ Database::query($queryString3);
api_item_property_update($_course, 'work', $item_id, 'DocumentDeleted', $user_id);
$work = $row['url'];
@@ -1078,10 +1078,8 @@ switch ($action) {
my_delete($currentCourseRepositorySys.'/'.$work);
Display::display_confirmation_message(get_lang('TheDocumentHasBeenDeleted'));
$file_deleted = true;
- } else {
- require_once api_get_path(LIBRARY_PATH).'fileManage.lib.php';
- $extension = pathinfo($work, PATHINFO_EXTENSION);
- //$basename_file = basename($work, '.'.$extension);
+ } else {
+ $extension = pathinfo($work, PATHINFO_EXTENSION);
$new_dir = $work.'_DELETED_'.$item_id.'.'.$extension;
if (file_exists($currentCourseRepositorySys.'/'.$work)) {
diff --git a/plugin/add_cas_login_button/css.css b/plugin/add_cas_login_button/css.css
new file mode 100644
index 0000000000..945a00d0ce
--- /dev/null
+++ b/plugin/add_cas_login_button/css.css
@@ -0,0 +1,12 @@
+ .cas_plugin_image {
+ float:left;
+ height:50px;
+ margin: 0px 5px 5px 0px;
+ }
+ .cas_plugin_comm {
+ font-style:italic;
+ }
+ .cas_plugin_clear {
+ clear:both;
+ height:1px;
+ }
diff --git a/plugin/add_cas_login_button/index.php b/plugin/add_cas_login_button/index.php
new file mode 100644
index 0000000000..52fa656f03
--- /dev/null
+++ b/plugin/add_cas_login_button/index.php
@@ -0,0 +1,21 @@
+Plugins)
+ * @package chamilo.plugin
+ * @author Julio Montoya
+ */
+/**
+ * Plugin details (must be present)
+ */
+
+
+
+//the plugin title
+$plugin_info['title'] = 'Add a button to login using CAS';
+
+//the comments that go with the plugin
+$plugin_info['comment'] = "If CAS is activated, this plugin add a text and a button on the login page to login with CAS. Configure plugin to add title, comment and logo.";
+//the plugin version
+$plugin_info['version'] = '1.0';
+//the plugin author
+$plugin_info['author'] = 'Hubert Borderiou';
+//the plugin configuration
+$form = new FormValidator('add_cas_button_form');
+$form->addElement('text', 'cas_button_label', 'CAS connexion title', '');
+$form->addElement('text', 'cas_button_comment', 'CAS connexion description', '');
+$form->addElement('text', 'cas_image_url', 'Logo URL if any (image, 50px height)');
+$form->addElement('style_submit_button', 'submit_button', get_lang('Save'));
+//get default value for form
+$tab_default_add_cas_login_button_cas_button_label = api_get_setting('add_cas_login_button_cas_button_label');
+$tab_default_add_cas_login_button_cas_button_comment = api_get_setting('add_cas_login_button_cas_button_comment');
+$tab_default_add_cas_login_button_cas_image_url = api_get_setting('add_cas_login_button_cas_image_url');
+$defaults['cas_button_label'] = $tab_default_add_cas_login_button_cas_button_label['add_cas_login_button'];
+$defaults['cas_button_comment'] = $tab_default_add_cas_login_button_cas_button_comment['add_cas_login_button'];
+$defaults['cas_image_url'] = $tab_default_add_cas_login_button_cas_image_url['add_cas_login_button'];
+$form->setDefaults($defaults);
+//display form
+$plugin_info['settings_form'] = $form;
+
+//set the smarty templates that are going to be used
+$plugin_info['templates'] = array('template.tpl');
diff --git a/plugin/add_cas_login_button/readme.txt b/plugin/add_cas_login_button/readme.txt
new file mode 100644
index 0000000000..6b6b401ddd
--- /dev/null
+++ b/plugin/add_cas_login_button/readme.txt
@@ -0,0 +1,7 @@
+README
+
+This plugin add a button to allow user to login to Chamilo with CAS authentification.
+You have to activate your CAS connection to display this button.
+You have to configure your CAS connection to have the button works.
+To activate and configure CAS, for your Chamilo platform, go to Administration > Configuration settings > CAS
+This plugin has been done to be added in the login_top region, but you can put it where you want.
\ No newline at end of file
diff --git a/plugin/add_cas_login_button/template.tpl b/plugin/add_cas_login_button/template.tpl
new file mode 100644
index 0000000000..82a637c608
--- /dev/null
+++ b/plugin/add_cas_login_button/template.tpl
@@ -0,0 +1,44 @@
+{*
+ This is a Chamilo plugin using Smarty you can use handy shorcuts like:
+
+ 1. Shortcuts
+
+ $_p = url chamilo paths
+ $_u = user information of the current user
+
+ 2. i18n
+
+ You can use i18n variables just use this syntax:
+
+ {"HelloWorld"|get_lang}
+
+ Now you can add your variables in the main/lang/english/ or main/lang/spanish/ for example in spanish:
+ $HelloWorld = "Hola Mundo";
+
+ 3. Portal settings
+
+ You can access the portal settings using:
+ {"siteName"|api_get_setting}
+ For more settings check the settings_current database
+
+ 4. Read more
+ You can also see more examples in the the main/template/default/layout files
+
+ 5. {$_p|var_dump} pour les path {$_u|var_dump} pour info de l'utilisateur loggé
+*}
+
+
+{if $add_cas_login_button.show_message}
+
+