From a2dd7f1ff5fba1d57e72c19a805aa0793b6cefd7 Mon Sep 17 00:00:00 2001 From: Patrick Cool Date: Mon, 23 Nov 2009 15:47:56 +0100 Subject: [PATCH 01/22] bugfix: Administration -> Reporting -> Latest Access -> enter date -> change sorting => all results are gone bugfix: list did not display the last accesses but the accesses that were done prior to x days --- main/admin/statistics/statistics.lib.php | 65 ++++++++++++------------ 1 file changed, 32 insertions(+), 33 deletions(-) diff --git a/main/admin/statistics/statistics.lib.php b/main/admin/statistics/statistics.lib.php index 6dba3b4363..f9ca789c9f 100644 --- a/main/admin/statistics/statistics.lib.php +++ b/main/admin/statistics/statistics.lib.php @@ -413,45 +413,44 @@ class Statistics $form->add_textfield('date_diff',get_lang('Days'),true); $form->addRule('date_diff','InvalidNumber','numeric'); $form->addElement('submit','ok',get_lang('Ok')); - $defaults['date_diff'] = 60; + if (!isset($_GET['date_diff'])) { + $defaults['date_diff'] = 60; + } else { + $defaults['date_diff'] = Security::Remove_XSS($_GET['date_diff']); + } $form->setDefaults($defaults); - if($form->validate()) { - $form->display(); - $values = $form->exportValues(); - $date_diff = $values['date_diff']; - $table = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_LASTACCESS); - $sql = "SELECT * FROM $table GROUP BY access_cours_code HAVING access_cours_code <> '' AND DATEDIFF( NOW() , access_date ) >= ". $date_diff; - $res = Database::query($sql,__FILE__,__LINE__); - $number_of_courses = Database::num_rows($res); - $sql .= ' ORDER BY '.$columns[$column].' '.$sql_order[$direction]; - $from = ($page_nr -1) * $per_page; - $sql .= ' LIMIT '.$from.','.$per_page; - echo '

'.get_lang('LastAccess').' >= '.$date_diff.' '.get_lang('Days').'

'; - $res = Database::query($sql, __FILE__, __LINE__); - if (Database::num_rows($res) > 0) - { - $courses = array (); - while ($obj = Database::fetch_object($res)) - { - $course = array (); - $course[]= ''.$obj->access_cours_code.' '; - $course[] = $obj->access_date; - $courses[] = $course; - } - $parameters['action'] = 'courselastvisit'; - $parameters['date_diff'] = $date_diff; - $table_header[] = array ("Coursecode", true); - $table_header[] = array ("Last login", true); - Display :: display_sortable_table($table_header, $courses, array ('column'=>$column,'direction'=>$direction), array (), $parameters); - } - else + $form->display(); + $values = $form->exportValues(); + $date_diff = $values['date_diff']; + $table = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_LASTACCESS); + $sql = "SELECT * FROM $table GROUP BY access_cours_code HAVING access_cours_code <> '' AND DATEDIFF( NOW() , access_date ) <= ". $date_diff; + $res = Database::query($sql,__FILE__,__LINE__); + $number_of_courses = Database::num_rows($res); + $sql .= ' ORDER BY '.$columns[$column].' '.$sql_order[$direction]; + $from = ($page_nr -1) * $per_page; + $sql .= ' LIMIT '.$from.','.$per_page; + echo '

'.get_lang('LastAccess').' >= '.$date_diff.' '.get_lang('Days').'

'; + $res = Database::query($sql, __FILE__, __LINE__); + if (Database::num_rows($res) > 0) + { + $courses = array (); + while ($obj = Database::fetch_object($res)) { - echo get_lang('NoSearchResults'); + $course = array (); + $course[]= '
'.$obj->access_cours_code.' '; + $course[] = $obj->access_date; + $courses[] = $course; } + $parameters['action'] = 'courselastvisit'; + $parameters['date_diff'] = $date_diff; + $parameters['action'] = 'courselastvisit'; + $table_header[] = array ("Coursecode", true); + $table_header[] = array ("Last login", true); + Display :: display_sortable_table($table_header, $courses, array ('column'=>$column,'direction'=>$direction), array (), $parameters); } else { - $form->display(); + echo get_lang('NoSearchResults'); } } } From e158bc4fe50a44b205e77000a4f0d0a547c24b0d Mon Sep 17 00:00:00 2001 From: Cristian Fasanando Date: Mon, 23 Nov 2009 10:39:27 -0500 Subject: [PATCH 02/22] improved chat for group, log file is now save into group folder - partial DT#5496 --- main/chat/chat_chat.php | 42 +++++++++++++++++++++++--------------- main/chat/chat_hidden.php | 17 +++++++++++---- main/chat/chat_message.php | 41 ++++++++++++++++++++++--------------- 3 files changed, 64 insertions(+), 36 deletions(-) diff --git a/main/chat/chat_chat.php b/main/chat/chat_chat.php index 8c0580067d..eab3f09009 100755 --- a/main/chat/chat_chat.php +++ b/main/chat/chat_chat.php @@ -33,9 +33,10 @@ define('FRAME','chat'); $language_file = array ('chat'); -require('../inc/global.inc.php'); -include(api_get_path(LIBRARY_PATH).'document.lib.php'); -include (api_get_path(LIBRARY_PATH).'fileUpload.lib.php'); +require_once '../inc/global.inc.php'; +require_once api_get_path(LIBRARY_PATH).'document.lib.php'; +require_once api_get_path(LIBRARY_PATH).'fileUpload.lib.php'; +require_once api_get_path(LIBRARY_PATH).'groupmanager.lib.php'; //$course=api_get_course_id(); $course=$_GET['cidReq']; @@ -56,10 +57,17 @@ if (!empty($course)) $isMaster=$is_courseAdmin?true:false; - $dateNow=date('Y-m-d'); + $dateNow=date('Y-m-d'); + $basepath_chat = ''; + $documentPath=api_get_path(SYS_COURSE_PATH).$_course['path'].'/document'; + if (!empty($group_id)) { + $group_info = GroupManager :: get_group_properties($group_id); + $basepath_chat = $group_info['directory'].'/chat_files'; + } else { + $basepath_chat = '/chat_files'; + } + $chatPath=$documentPath.$basepath_chat.'/'; - $documentPath=api_get_path(SYS_COURSE_PATH).$_course['path'].'/document/'; - $chatPath=$documentPath.'chat_files/'; $TABLEITEMPROPERTY= Database::get_course_table(TABLE_ITEM_PROPERTY); if(!is_dir($chatPath)) @@ -74,11 +82,13 @@ if (!empty($course)) $perm = octdec(!empty($perm)?$perm:'0770'); @mkdir($chatPath,$perm); @chmod($chatPath,$perm); - - /* - $doc_id=add_document($_course,'/chat_files','folder',0,'chat_files'); - Database::query("INSERT INTO ".$TABLEITEMPROPERTY . " (tool,insert_user_id,insert_te,lastedit_date,ref,lastedit_type,lastedit_user_id,to_group_id,to_user_id,visibility) VALUES ('document',1,NOW(),NOW(),$doc_id,'DocumentAdded',1,0,NULL,0)"); - */ + // save chat files document for group into item property + if (!empty($group_id)) { + $doc_id=add_document($_course,$basepath_chat,'folder',0,'chat_files'); + $sql = "INSERT INTO $TABLEITEMPROPERTY (tool,insert_user_id,insert_date,lastedit_date,ref,lastedit_type,lastedit_user_id,to_group_id,to_user_id,visibility) + VALUES ('document',1,NOW(),NOW(),$doc_id,'FolderCreated',1,$group_id,NULL,0)"; + Database::query($sql,__FILE__,__LINE__); + } } } @@ -95,10 +105,10 @@ if (!empty($course)) { @fclose(fopen($chatPath.$filename_chat,'w')); if (!api_is_anonymous()) { - $doc_id=add_document($_course,'/chat_files/'.$filename_chat,'file',0,$filename_chat); + $doc_id=add_document($_course,$basepath_chat.'/'.$filename_chat,'file',0,$filename_chat); api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'DocumentAdded', $_user['user_id'],$group_id,null,null,null,$session_id); api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'invisible', $_user['user_id'],$group_id,null,null,null,$session_id); - item_property_update_on_folder($_course,'/chat_files', $_user['user_id']); + item_property_update_on_folder($_course,$basepath_chat, $_user['user_id']); } } @@ -124,13 +134,13 @@ if (!empty($course)) @fclose(fopen($chatPath.$basename_chat.'.log.html','w')); - $doc_id=add_document($_course,'/chat_files/'.$basename_chat.'-'.$i.'.log.html','file',filesize($chatPath.$basename_chat.'-'.$i.'.log.html'),$basename_chat.'-'.$i.'.log.html'); + $doc_id=add_document($_course,$basepath_chat.'/'.$basename_chat.'-'.$i.'.log.html','file',filesize($chatPath.$basename_chat.'-'.$i.'.log.html'),$basename_chat.'-'.$i.'.log.html'); api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'DocumentAdded', $_user['user_id'],$group_id,null,null,null,$session_id); api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'invisible', $_user['user_id'],$group_id,null,null,null,$session_id); - item_property_update_on_folder($_course,'/chat_files', $_user['user_id']); + item_property_update_on_folder($_course,$basepath_chat, $_user['user_id']); - $doc_id = DocumentManager::get_document_id($_course,'/chat_files/'.$basename_chat.'.log.html'); + $doc_id = DocumentManager::get_document_id($_course,$basepath_chat.'/'.$basename_chat.'.log.html'); update_existing_document($_course, $doc_id,0); } diff --git a/main/chat/chat_hidden.php b/main/chat/chat_hidden.php index 814a01f64b..9e80241348 100755 --- a/main/chat/chat_hidden.php +++ b/main/chat/chat_hidden.php @@ -34,8 +34,9 @@ define('FRAME','hidden'); $language_file = array ('chat'); -require('../inc/global.inc.php'); -include_once '../inc/lib/course.lib.php'; +require_once '../inc/global.inc.php'; +require_once api_get_path(LIBRARY_PATH).'course.lib.php'; +require_once api_get_path(LIBRARY_PATH).'groupmanager.lib.php'; require_once 'chat_functions.lib.php'; //$tbl_user=$mainDbName."`.`user"; //$tbl_chat_connected=$_course['dbNameGlu'].'chat_connected'; @@ -69,9 +70,17 @@ if (!empty($group_id)) { $extra_condition = $session_condition; } -$documentPath=api_get_path(SYS_COURSE_PATH).$_course['path'].'/document/'; -$chatPath=$documentPath.'chat_files/'; +// get chat path +$chatPath = ''; +$documentPath=api_get_path(SYS_COURSE_PATH).$_course['path'].'/document'; +if (!empty($group_id)) { + $group_info = GroupManager :: get_group_properties($group_id); + $chatPath=$documentPath.$group_info['directory'].'/chat_files/'; +} else { + $chatPath=$documentPath.'/chat_files/'; +} +// get chat file $basename_chat = ''; if (!empty($group_id)) { $basename_chat = 'messages-'.$dateNow.'_gid-'.$group_id; diff --git a/main/chat/chat_message.php b/main/chat/chat_message.php index 312b99d262..be8dee1d99 100755 --- a/main/chat/chat_message.php +++ b/main/chat/chat_message.php @@ -40,14 +40,14 @@ define('FRAME','message'); $language_file = array ('chat'); -require('../inc/global.inc.php'); - +require_once '../inc/global.inc.php'; +require_once api_get_path(LIBRARY_PATH).'groupmanager.lib.php'; $course=api_get_course_id(); $session_id = intval($_SESSION['id_session']); $group_id = intval($_SESSION['_gid']); ///// -// Juan Carlos Ra�a insert smileys and self-closing window +// Juan Carlos Raña insert smileys and self-closing window //// ?>