From de748f8c17db5d8ec99107707e123b42ecb20ae2 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Mon, 17 May 2010 12:26:59 +0200 Subject: [PATCH 02/63] Fixing commit fbc722cecf removing wrong Security::remove_XSS --- main/forum/reply.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/main/forum/reply.php b/main/forum/reply.php index 2764b35f0b..2a0e98dee8 100755 --- a/main/forum/reply.php +++ b/main/forum/reply.php @@ -165,7 +165,8 @@ echo ''; $my_action = isset($_GET['action']) ? Security::remove_XSS($_GET['action']) : ''; $my_post = isset($_GET['post']) ? Security::remove_XSS($_GET['post']) : ''; $my_elements = isset($_SESSION['formelements']) ? $_SESSION['formelements'] : ''; -$values = show_add_post_form(Security::remove_XSS($my_action,$my_post, $my_elements)); // note: this has to be cleaned first + +$values = show_add_post_form($my_action,$my_post, $my_elements); // note: this has to be cleaned first if (!empty($values) AND isset($_POST['SubmitPost'])) { store_reply($values); From fe6fd104fee758b284ada42cf103f1068e08485d Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Mon, 17 May 2010 13:06:15 +0200 Subject: [PATCH 03/63] Cleaning code --- main/forum/index.php | 140 +++++++++++++++---------------------------- 1 file changed, 47 insertions(+), 93 deletions(-) diff --git a/main/forum/index.php b/main/forum/index.php index 42cfd7b246..4667b24633 100755 --- a/main/forum/index.php +++ b/main/forum/index.php @@ -1,28 +1,5 @@ -'; $htmlHeadXtra[] = '"; } -if ( (! $is_allowed_to_edit) or ($isStudentView) ) -{ +if ( (! $is_allowed_to_edit) or ($isStudentView) ) { error_log('New LP - User not authorized in lp_add_item.php'); header('location:lp_controller.php?action=view&lp_id='.$learnpath_id); + exit; } //from here on, we are admin because of the previous condition, so don't check anymore @@ -202,14 +163,12 @@ $therow=Database::fetch_array($result); //$admin_output = ''; /* ------------------------------------------------------------ Course admin section - all the functions not available for students - always available in this case (page only shown to admin) ------------------------------------------------------------ */ -/*================================================== +/* SHOWING THE ADMIN TOOLS - ==================================================*/ + */ if (isset($_SESSION['gradebook'])){ $gradebook= $_SESSION['gradebook']; } @@ -224,7 +183,7 @@ if (!empty($gradebook) && $gradebook=='view') { $interbreadcrumb[]= array ("url"=>"lp_controller.php?action=list", "name"=> get_lang("_learning_path")); $interbreadcrumb[]= array ("url"=>api_get_self()."?action=build&lp_id=$learnpath_id", "name" => stripslashes("{$therow['name']}")); -switch($_GET['type']){ +switch($_GET['type']) { case 'chapter': $interbreadcrumb[]= array ("url"=>"#", "name" => get_lang("NewChapter")); break; @@ -270,19 +229,14 @@ function confirmation(name) //echo $admin_output; /* ------------------------------------------------------------ DISPLAY SECTION ------------------------------------------------------------ */ echo $_SESSION['oLP']->build_action_menu(); echo ''; - echo ''; - echo '' . "\n"; - $return .= "\t\t" . '' . "\n"; - $return .= "\t\t" . '' . "\n"; + $return .= ''; + $return .= ''; + $return .= ''; + $return .= ''; $return .= "\t\t\t" . '' . "\n"; $return .= "\t\t\t" . '
'; // show the template list - if (isset($_GET['type']) && $_GET['type']=='document' && !isset($_GET['file'])) - { + if (isset($_GET['type']) && $_GET['type']=='document' && !isset($_GET['file'])) { $count_items = count($_SESSION['oLP']->ordered_items); $style = ($count_items > 12)?' style="height:250px;width:230px;overflow-x : auto; overflow-y : scroll;" ':' class="lp_tree" '; echo '
'; @@ -300,146 +254,90 @@ echo ''; echo ''; } - echo ''; echo ''; - echo ''; - echo '
'; - if(isset($new_item_id) && is_numeric($new_item_id)) - { - switch($_GET['type']) - { - - case 'chapter': - echo $_SESSION['oLP']->display_manipulate($new_item_id, $_GET['type']); - Display::display_confirmation_message(get_lang('NewChapterCreated')); - break; - - case TOOL_LINK: - echo $_SESSION['oLP']->display_manipulate($new_item_id, $_GET['type']); - Display::display_confirmation_message(get_lang('NewLinksCreated')); - break; - - case TOOL_STUDENTPUBLICATION: - - echo $_SESSION['oLP']->display_manipulate($new_item_id, $_GET['type']); - Display::display_confirmation_message(get_lang('NewStudentPublicationCreated')); - break; - - case 'module': - - echo $_SESSION['oLP']->display_manipulate($new_item_id, $_GET['type']); - Display::display_confirmation_message(get_lang('NewModuleCreated')); - break; - - case TOOL_QUIZ: - - echo $_SESSION['oLP']->display_manipulate($new_item_id, $_GET['type']); - Display::display_confirmation_message(get_lang('NewExerciseCreated')); - break; - - - case TOOL_DOCUMENT: - Display::display_confirmation_message(get_lang('NewDocumentCreated')); - echo $_SESSION['oLP']->display_item($new_item_id, true, $msg); - break; - - - case TOOL_FORUM: - echo $_SESSION['oLP']->display_manipulate($new_item_id, $_GET['type']); - Display::display_confirmation_message(get_lang('NewForumCreated')); - break; - - - case 'thread': - echo $_SESSION['oLP']->display_manipulate($new_item_id, $_GET['type']); - Display::display_confirmation_message(get_lang('NewThreadCreated')); - break; - - } + if(isset($new_item_id) && is_numeric($new_item_id)) { + switch($_GET['type']) { + case 'chapter': + echo $_SESSION['oLP']->display_manipulate($new_item_id, $_GET['type']); + Display::display_confirmation_message(get_lang('NewChapterCreated')); + break; + case TOOL_LINK: + echo $_SESSION['oLP']->display_manipulate($new_item_id, $_GET['type']); + Display::display_confirmation_message(get_lang('NewLinksCreated')); + break; + case TOOL_STUDENTPUBLICATION: + echo $_SESSION['oLP']->display_manipulate($new_item_id, $_GET['type']); + Display::display_confirmation_message(get_lang('NewStudentPublicationCreated')); + break; + case 'module': + echo $_SESSION['oLP']->display_manipulate($new_item_id, $_GET['type']); + Display::display_confirmation_message(get_lang('NewModuleCreated')); + break; + case TOOL_QUIZ: + + echo $_SESSION['oLP']->display_manipulate($new_item_id, $_GET['type']); + Display::display_confirmation_message(get_lang('NewExerciseCreated')); + break; + + case TOOL_DOCUMENT: + Display::display_confirmation_message(get_lang('NewDocumentCreated')); + echo $_SESSION['oLP']->display_item($new_item_id, true, $msg); + break; + case TOOL_FORUM: + echo $_SESSION['oLP']->display_manipulate($new_item_id, $_GET['type']); + Display::display_confirmation_message(get_lang('NewForumCreated')); + break; + case 'thread': + echo $_SESSION['oLP']->display_manipulate($new_item_id, $_GET['type']); + Display::display_confirmation_message(get_lang('NewThreadCreated')); + break; } - else - { - switch($_GET['type']) - { - case 'chapter': - - echo $_SESSION['oLP']->display_item_form($_GET['type'], get_lang("EnterDataNewChapter")); - - break; - - case 'module': - - echo $_SESSION['oLP']->display_item_form($_GET['type'], get_lang("EnterDataNewModule")); - - break; - - case 'document': - - if(isset($_GET['file']) && is_numeric($_GET['file'])) - { - echo $_SESSION['oLP']->display_document_form('add', 0, $_GET['file']); - } - else - { - echo $_SESSION['oLP']->display_document_form('add', 0); - } - - break; - - case 'hotpotatoes': - - echo $_SESSION['oLP']->display_hotpotatoes_form('add', 0, $_GET['file']); - - break; - - case 'quiz': - - echo $_SESSION['oLP']->display_quiz_form('add', 0, $_GET['file']); - - break; - - case 'forum': - - echo $_SESSION['oLP']->display_forum_form('add', 0, $_GET['forum_id']); - - break; - - case 'thread': - - echo $_SESSION['oLP']->display_thread_form('add', 0, $_GET['thread_id']); - - break; - - case 'link': - - echo $_SESSION['oLP']->display_link_form('add', 0, $_GET['file']); - - break; - - case 'student_publication': - - echo $_SESSION['oLP']->display_student_publication_form('add', 0, $_GET['file']); - - break; - - case 'step': - - echo $_SESSION['oLP']->display_resources(); - - break; - } + } else { + switch($_GET['type']) { + case 'chapter': + echo $_SESSION['oLP']->display_item_form($_GET['type'], get_lang("EnterDataNewChapter")); + break; + case 'module': + echo $_SESSION['oLP']->display_item_form($_GET['type'], get_lang("EnterDataNewModule")); + break; + case 'document': + if(isset($_GET['file']) && is_numeric($_GET['file'])) { + echo $_SESSION['oLP']->display_document_form('add', 0, $_GET['file']); + } else { + echo $_SESSION['oLP']->display_document_form('add', 0); + } + break; + case 'hotpotatoes': + echo $_SESSION['oLP']->display_hotpotatoes_form('add', 0, $_GET['file']); + break; + case 'quiz': + echo $_SESSION['oLP']->display_quiz_form('add', 0, $_GET['file']); + break; + case 'forum': + echo $_SESSION['oLP']->display_forum_form('add', 0, $_GET['forum_id']); + break; + case 'thread': + echo $_SESSION['oLP']->display_thread_form('add', 0, $_GET['thread_id']); + break; + case 'link': + echo $_SESSION['oLP']->display_link_form('add', 0, $_GET['file']); + break; + case 'student_publication': + echo $_SESSION['oLP']->display_student_publication_form('add', 0, $_GET['file']); + break; + case 'step': + echo $_SESSION['oLP']->display_resources(); + break; } - + } echo '
'; /* -============================================================================== FOOTER -============================================================================== */ Display::display_footer(); ?> \ No newline at end of file From 70fd63cf0a5004a412da9ec52f48278e0b2f7188 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Tue, 18 May 2010 14:38:22 +0200 Subject: [PATCH 19/63] Prevents wrong parent selection for document CT#1251 --- main/newscorm/learnpath.class.php | 80 +++++++++++++++---------------- 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/main/newscorm/learnpath.class.php b/main/newscorm/learnpath.class.php index 4c31ce4acb..7c33eea476 100755 --- a/main/newscorm/learnpath.class.php +++ b/main/newscorm/learnpath.class.php @@ -4710,12 +4710,17 @@ class learnpath { if (is_numeric($item_id)) { $tbl_lp_item = Database :: get_course_table(TABLE_LP_ITEM); $tbl_doc = Database :: get_course_table(TABLE_DOCUMENT); - $sql = "SELECT lp.* - FROM " . $tbl_lp_item . " as lp - WHERE lp.id = " . Database :: escape_string($item_id); + $sql = "SELECT lp.* FROM " . $tbl_lp_item . " as lp + WHERE lp.id = " . Database :: escape_string($item_id); $result = Database::query($sql); - while ($row = Database :: fetch_array($result)) { + while ($row = Database :: fetch_array($result)) { $_SESSION['parent_item_id'] = ($row['item_type'] == 'dokeos_chapter' || $row['item_type'] == 'dokeos_module' || $row['item_type'] == 'dir') ? $item_id : 0; + + //Prevents wrong parent selection for document see Bug#1251 + if ($row['item_type'] != 'dokeos_chapter' || $row['item_type'] != 'dokeos_module') { + $_SESSION['parent_item_id'] = $row['parent_item_id']; + } + $return .= $this->display_manipulate($item_id, $row['item_type']); $return .= '
'; if ($msg != '') @@ -5032,10 +5037,10 @@ class learnpath { reset($arrLP); } - $return .= "\t\t\t\t" . ''; - $return .= "\t\t\t" . '
' . "\n"; @@ -5991,14 +5996,12 @@ class learnpath { $path_parts = pathinfo($extra_info['path']); $item_title = stripslashes($path_parts['filename']); } - } - elseif (is_numeric($extra_info)) { - $sql_doc = "SELECT path, title - FROM " . $tbl_doc . " - WHERE id = " . Database :: escape_string($extra_info); + } elseif (is_numeric($extra_info)) { + $sql_doc = "SELECT path, title FROM " . $tbl_doc . " + WHERE id = " . Database :: escape_string($extra_info); $result = Database::query($sql_doc); - $row = Database :: fetch_array($result); + $row = Database :: fetch_array($result); $explode = explode('.', $row['title']); @@ -6028,32 +6031,26 @@ class learnpath { else $parent = 0; - $sql = " - SELECT * - FROM " . $tbl_lp_item . " - WHERE - lp_id = " . $this->lp_id; - + $sql = "SELECT * FROM " . $tbl_lp_item . " + WHERE lp_id = " . $this->lp_id; $result = Database::query($sql); - $arrLP = array (); - while ($row = Database :: fetch_array($result)) { $arrLP[] = array ( - 'id' => $row['id'], - 'item_type' => $row['item_type'], - 'title' => $row['title'], - 'path' => $row['path'], - 'description' => $row['description'], - 'parent_item_id' => $row['parent_item_id'], - 'previous_item_id' => $row['previous_item_id'], - 'next_item_id' => $row['next_item_id'], - 'display_order' => $row['display_order'], - 'max_score' => $row['max_score'], - 'min_score' => $row['min_score'], - 'mastery_score' => $row['mastery_score'], - 'prerequisite' => $row['prerequisite'] - ); + 'id' => $row['id'], + 'item_type' => $row['item_type'], + 'title' => $row['title'], + 'path' => $row['path'], + 'description' => $row['description'], + 'parent_item_id' => $row['parent_item_id'], + 'previous_item_id' => $row['previous_item_id'], + 'next_item_id' => $row['next_item_id'], + 'display_order' => $row['display_order'], + 'max_score' => $row['max_score'], + 'min_score' => $row['min_score'], + 'mastery_score' => $row['mastery_score'], + 'prerequisite' => $row['prerequisite'] + ); } $this->tree_array($arrLP); @@ -6069,8 +6066,8 @@ class learnpath { $return .= get_lang("EditTheCurrentDocument") . "\n"; } - $return .= ' - '; + $return .= ' + '; if (isset ($_GET['edit']) && $_GET['edit'] == 'true') { $return .= Display :: return_warning_message('' . get_lang("Warning") . ' !
' . get_lang("WarningEditingDocument"), false); @@ -6112,6 +6109,7 @@ class learnpath { } } } + $parent_select = & $form->addElement('select', 'parent', get_lang('Parent'), '', 'class="learnpath_item_form" style="width:40%;" onchange="load_cbo(this.value);"'); $my_count=0; foreach ($arrHide as $key => $value) { @@ -6125,13 +6123,15 @@ class learnpath { } $my_count++; } - + if (!empty ($id)) { $parent_select->setSelected($parent); - } else { + } else { $parent_item_id = $_SESSION['parent_item_id']; $parent_select->setSelected($parent_item_id); } + + if (is_array($arrLP)) { reset($arrLP); From 8b5a33ad76c381a65372bfb3a8923adfb4f9126a Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Tue, 18 May 2010 14:46:19 +0200 Subject: [PATCH 20/63] Fixes user id variable definition see CT#1299 --- main/exercice/savescores.php | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/main/exercice/savescores.php b/main/exercice/savescores.php index 0b35e619a0..79d3c2131e 100755 --- a/main/exercice/savescores.php +++ b/main/exercice/savescores.php @@ -3,7 +3,7 @@ /** * Saving the scores. -* @package dokeos.exercise +* @package chamilo.exercise * @author * @version $Id: savescores.php 15602 2008-06-18 08:52:24Z pcool $ */ @@ -11,8 +11,7 @@ // name of the language file that needs to be included $language_file = 'learnpath'; -if($_GET['origin']=='learnpath') -{ +if($_GET['origin']=='learnpath') { require_once ('../newscorm/learnpath.class.php'); require_once ('../newscorm/learnpathItem.class.php'); require_once ('../newscorm/scorm.class.php'); @@ -21,18 +20,16 @@ if($_GET['origin']=='learnpath') require_once ('../newscorm/aiccItem.class.php'); } -include ('../inc/global.inc.php'); +require_once '../inc/global.inc.php'; $this_section=SECTION_COURSES; -include_once (api_get_path(LIBRARY_PATH).'fileManage.lib.php'); +require_once api_get_path(LIBRARY_PATH).'fileManage.lib.php'; $documentPath = api_get_path(SYS_COURSE_PATH).$_course['path']."/document"; $full_file_path = $documentPath.$test; my_delete($full_file_path.$_user['user_id'].".t.html"); - - $TABLETRACK_HOTPOTATOES = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_HOTPOTATOES); $tbl_learnpath_user = Database::get_course_table(TABLE_LEARNPATH_USER); $TABLE_LP_ITEM_VIEW = Database::get_course_table(TABLE_LP_ITEM_VIEW); @@ -62,17 +59,14 @@ function save_scores($file, $score) $reallyNow = time(); $date = date("Y-m-d H:i:s", $reallyNow); - if (!$_configuration['tracking_enabled']) - { + if (!$_configuration['tracking_enabled']) { return 0; } - if ($_user['user_id']) - { - $user_id = "'".$_user['user_id']."'"; - } - else // anonymous - { + if ($_user['user_id']) { + $user_id = $_user['user_id']; + } else { + // anonymous $user_id = "NULL"; } $sql = "INSERT INTO $TABLETRACK_HOTPOTATOES ". From 72813b674980c4718327ed350fc35951ce9c5f35 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Tue, 18 May 2010 14:47:04 +0200 Subject: [PATCH 21/63] Cleaning code --- main/exercice/savescores.php | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/main/exercice/savescores.php b/main/exercice/savescores.php index 79d3c2131e..cd900bed0b 100755 --- a/main/exercice/savescores.php +++ b/main/exercice/savescores.php @@ -49,8 +49,7 @@ $jscript2run = ''; * @param integer Score to save inside the tracking tables (HP and learnpath) * @return void */ -function save_scores($file, $score) -{ +function save_scores($file, $score) { global $_configuration, $origin, $_user, $_cid, $TABLETRACK_HOTPOTATOES; @@ -70,41 +69,36 @@ function save_scores($file, $score) $user_id = "NULL"; } $sql = "INSERT INTO $TABLETRACK_HOTPOTATOES ". - "(exe_name, exe_user_id, exe_date,exe_cours_id,exe_result,exe_weighting)" . - "VALUES" . - "( - '".Database::escape_string($file)."', - '".Database::escape_string($user_id)."', - '".Database::escape_string($date)."', - '".Database::escape_string($_cid)."', - '".Database::escape_string($score)."', - '".Database::escape_string($weighting)."')"; + "(exe_name, exe_user_id, exe_date,exe_cours_id,exe_result,exe_weighting)" . + "VALUES" . + "( + '".Database::escape_string($file)."', + '".Database::escape_string($user_id)."', + '".Database::escape_string($date)."', + '".Database::escape_string($_cid)."', + '".Database::escape_string($score)."', + '".Database::escape_string($weighting)."')"; $res = Database::query($sql); - if ($origin == 'learnpath') - { + if ($origin == 'learnpath') { //if we are in a learning path, save the score in the corresponding //table to get tracking in there as well global $jscript2run; //record the results in the learning path, using the SCORM interface (API) $jscript2run .= ''; } - } // Save the Scores save_scores($test, $score); // Back -if ($origin != 'learnpath') -{ +if ($origin != 'learnpath') { // $url = "Hpdownload.php?doc_url=".$test."&cid=".$cid; // back to the test $url = "exercice.php"; // back to exercices $jscript2run .= ''; echo $jscript2run; -} -else -{ +} else { ?> From e8984d22975a3710eab9101030d6d075e8e3f1f2 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Tue, 18 May 2010 15:08:12 +0200 Subject: [PATCH 22/63] Cleaning code --- main/calendar/agenda.php | 101 +++++++++++++++---------------------- main/calendar/calendar.php | 2 +- 2 files changed, 43 insertions(+), 60 deletions(-) diff --git a/main/calendar/agenda.php b/main/calendar/agenda.php index 7f7dbe76f9..59d24702a9 100755 --- a/main/calendar/agenda.php +++ b/main/calendar/agenda.php @@ -52,78 +52,65 @@ if (!empty($_GET['view'])) { } /* ------------------------------------------------------------ Libraries ------------------------------------------------------------ */ // containing the functions for the agenda tool -include "agenda.inc.php"; +require_once 'agenda.inc.php'; // some debug functions -include($includePath."/lib/debug.lib.inc.php"); +require_once $includePath."/lib/debug.lib.inc.php"; -/*============================================================================== +/* TREATING THE PARAMETERS 1. viewing month only or everything 2. sort ascending or descending 3. showing or hiding the send-to-specific-groups-or-users form 4. filter user or group - ============================================================================== */ +*/ // 1. show all or show current month? -if (!$_SESSION['show']) -{ +if (!$_SESSION['show']) { $_SESSION['show']="showall"; } -if (!empty($_GET['action']) and $_GET['action']=="showcurrent") -{ +if (!empty($_GET['action']) and $_GET['action']=="showcurrent") { $_SESSION['show']="showcurrent"; } -if (!empty($_GET['action']) and $_GET['action']=="showall") -{ +if (!empty($_GET['action']) and $_GET['action']=="showall") { $_SESSION['show']="showall"; } //echo $_SESSION['show']; // 2. sorting order (ASC or DESC) -if (empty($_GET['sort']) and empty($_SESSION['sort'])) -{ +if (empty($_GET['sort']) and empty($_SESSION['sort'])) { $_SESSION['sort']="DESC"; } -if (!empty($_GET['sort']) and $_GET['sort']=="asc") -{ +if (!empty($_GET['sort']) and $_GET['sort']=="asc") { $_SESSION['sort']="ASC"; } -if (!empty($_GET['sort']) and $_GET['sort']=="desc") -{ +if (!empty($_GET['sort']) and $_GET['sort']=="desc") { $_SESSION['sort']="DESC"; } // 3. showing or hiding the send-to-specific-groups-or-users form $setting_allow_individual_calendar=true; -if (empty($_POST['To']) and empty($_SESSION['allow_individual_calendar'])) -{ +if (empty($_POST['To']) and empty($_SESSION['allow_individual_calendar'])) { $_SESSION['allow_individual_calendar']="hide"; } $allow_individual_calendar_status=$_SESSION['allow_individual_calendar']; -if (!empty($_POST['To']) and ($allow_individual_calendar_status=="hide")) -{ +if (!empty($_POST['To']) and ($allow_individual_calendar_status=="hide")) { $_SESSION['allow_individual_calendar']="show"; } -if (!empty($_GET['sort']) and ($allow_individual_calendar_status=="show")) -{ +if (!empty($_GET['sort']) and ($allow_individual_calendar_status=="show")) { $_SESSION['allow_individual_calendar']="hide"; } // 4. filter user or group -if (!empty($_GET['user']) or !empty($_GET['group'])) -{ +if (!empty($_GET['user']) or !empty($_GET['group'])) { $_SESSION['user']=(int)$_GET['user']; $_SESSION['group']=(int)$_GET['group']; } -if ((!empty($_GET['user']) and $_GET['user']=="none") or (!empty($_GET['group']) and $_GET['group']=="none")) -{ +if ((!empty($_GET['user']) and $_GET['user']=="none") or (!empty($_GET['group']) and $_GET['group']=="none")) { api_session_unregister("user"); api_session_unregister("group"); - } +} if (!$is_courseAdmin){ if (!empty($_GET['toolgroup'])){ //$_SESSION['toolgroup']=$_GET['toolgroup']; @@ -132,8 +119,7 @@ if (!$is_courseAdmin){ } } //It comes from the group tools. If it's define it overwrites $_SESSION['group'] -if (!empty($_GET['isStudentView']) and $_GET['isStudentView']=="false") -{ +if (!empty($_GET['isStudentView']) and $_GET['isStudentView']=="false") { api_session_unregister("user"); api_session_unregister("group"); } @@ -314,8 +300,8 @@ if (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_ed } } -echo '' - . ''; +echo '
+ '; // THE LEFT PART if (empty($_GET['origin']) or $_GET['origin']!='learnpath') { @@ -323,8 +309,7 @@ if (empty($_GET['origin']) or $_GET['origin']!='learnpath') { // the small calendar $MonthName = $MonthsLong[$select_month -1]; $agenda_items=get_calendar_items($select_month,$select_year); - if (api_get_setting('display_mini_month_calendar') == 'true') - { + if (api_get_setting('display_mini_month_calendar') == 'true') { display_minimonthcalendar($agenda_items, $select_month,$select_year, $MonthName); } echo '
'; @@ -357,34 +342,34 @@ if (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_ed } break; case 'add' : + if ($_POST['submit_event']) { + display_agenda_items(); + } else { + show_add_form(); + } + break; + case 'edit' : + if ( !(api_is_course_coach() && !api_is_element_in_the_session(TOOL_AGENDA, intval($_REQUEST['id'])))) { if ($_POST['submit_event']) { display_agenda_items(); } else { - show_add_form(); + $id=(int)$_GET['id']; + show_add_form($id); } - break; - case 'edit' : - if ( !(api_is_course_coach() && !api_is_element_in_the_session(TOOL_AGENDA, intval($_REQUEST['id'])))) { - if ($_POST['submit_event']) { - display_agenda_items(); - } else { - $id=(int)$_GET['id']; - show_add_form($id); - } - } else { - display_agenda_items(); - } - break; - case 'delete': + } else { display_agenda_items(); - break; + } + break; + case 'delete': + display_agenda_items(); + break; case 'showhide': - if(!empty($_GET['agenda_id'])) { - display_one_agenda_item((int)$_GET['agenda_id']); - } else { - display_agenda_items(); - } - break; + if(!empty($_GET['agenda_id'])) { + display_one_agenda_item((int)$_GET['agenda_id']); + } else { + display_agenda_items(); + } + break; case 'announce': display_agenda_items(); break; @@ -413,9 +398,7 @@ if (!$_GET['action'] || $_GET['action']=="showall" || $_GET['action']=="showcur echo ' 
'; /* -============================================================================== FOOTER -============================================================================== */ // The footer is displayed only if we are not in the learnpath if ($_GET['origin'] != 'learnpath') diff --git a/main/calendar/calendar.php b/main/calendar/calendar.php index fa60b3634a..dce17214c3 100755 --- a/main/calendar/calendar.php +++ b/main/calendar/calendar.php @@ -1,4 +1,4 @@ - Date: Tue, 18 May 2010 16:30:01 +0200 Subject: [PATCH 23/63] Cleaning code --- main/calendar/myagenda.inc.php | 99 +++++++++++++++++----------------- 1 file changed, 48 insertions(+), 51 deletions(-) diff --git a/main/calendar/myagenda.inc.php b/main/calendar/myagenda.inc.php index 6d428c14e2..bfd3345b6e 100755 --- a/main/calendar/myagenda.inc.php +++ b/main/calendar/myagenda.inc.php @@ -123,7 +123,6 @@ function get_myagendaitems($courses_dbs, $month, $year) { $items[$agendaday][$item['start_date']] .= '
'."".$agenda_link." ".Security::remove_XSS($item['title'])."
"; $items[$agendaday][$item['start_date']] .= '
'; } - } // sorting by hour for every day $agendaitems = array (); @@ -136,6 +135,8 @@ function get_myagendaitems($courses_dbs, $month, $year) { $agendaitems[$agendaday] .= $val; } } + + //print_r($agendaitems); return $agendaitems; } @@ -162,19 +163,18 @@ function display_mymonthcalendar($agendaitems, $month, $year, $weekdaynames=arra $backwardsURL = api_get_self()."?coursePath=".urlencode($course_path)."&courseCode=".Security::remove_XSS($g_cc)."&action=view&view=month&month=". ($month == 1 ? 12 : $month -1)."&year=". ($month == 1 ? $year -1 : $year); $forewardsURL = api_get_self()."?coursePath=".urlencode($course_path)."&courseCode=".Security::remove_XSS($g_cc)."&action=view&view=month&month=". ($month == 12 ? 1 : $month +1)."&year=". ($month == 12 ? $year +1 : $year); - echo "\n", "\n", ""; - echo "\n", "", ""; + echo "
".Display::return_icon('action_prev.png',get_lang('Previous'))."", $monthName, " ", $year, "".Display::return_icon('action_next.png',get_lang('Next'))."
", "", ""; + echo "", "", ""; - echo "\n"; - for ($ii = 1; $ii < 8; $ii ++) - { - echo "\n"; + echo ""; + for ($ii = 1; $ii < 8; $ii ++) { + echo ""; } - echo "\n"; + echo ""; $curday = -1; $today = getdate(); while ($curday <= $numberofdays[$month]) { - echo "\n"; + echo ""; for ($ii = 0; $ii < 7; $ii ++) { if (($curday == -1) && ($ii == $startdayofweek)) { $curday = 1; @@ -183,22 +183,22 @@ function display_mymonthcalendar($agendaitems, $month, $year, $weekdaynames=arra $bgcolor = $ii < 5 ? $class = "class=\"days_week\" style=\"width:10%;\"" : $class = "class=\"days_weekend\" style=\"width:10%;\""; $dayheader = "$curday
"; if (($curday == $today['mday']) && ($year == $today['year']) && ($month == $today['mon'])) { - $dayheader = "$curday - ".get_lang("Today")."
"; + $dayheader = "$curday - ".get_lang('Today')."
"; $class = "class=\"days_today\" style=\"width:10%;\""; } echo "\n"; + echo ""; $curday ++; } else { - echo "\n"; + echo ""; } } - echo "\n"; + echo ""; } - echo "
".Display::return_icon('action_prev.png',get_lang('Previous'))."", $monthName, " ", $year, "".Display::return_icon('action_next.png',get_lang('Next'))."
", $DaysShort[$ii % 7], "
", $DaysShort[$ii % 7], "
", "".$dayheader; if (!empty($agendaitems[$curday])) { echo "".$agendaitems[$curday].""; } - echo "  
\n"; + echo "
"; } /** * Show the mini calender of the given month @@ -217,20 +217,20 @@ function display_myminimonthcalendar($agendaitems, $month, $year, $monthName) { $backwardsURL = api_get_self()."?coursePath=".urlencode($course_path)."&courseCode=".Security::remove_XSS($g_cc)."&month=". ($month == 1 ? 12 : $month -1)."&year=". ($month == 1 ? $year -1 : $year); $forewardsURL = api_get_self()."?coursePath=".urlencode($course_path)."&courseCode=".Security::remove_XSS($g_cc)."&month=". ($month == 12 ? 1 : $month +1)."&year=". ($month == 12 ? $year +1 : $year); - echo "\n", "\n", ""; - echo "\n", "", ""; + echo "
".Display::return_icon('action_prev.png',get_lang('Previous'))."", $monthName, " ", $year, "".Display::return_icon('action_next.png',get_lang('Next'))."
", "", ""; + echo "", "", ""; - echo "\n"; + echo ""; for ($ii = 1; $ii < 8; $ii ++) { - echo "\n"; + echo ""; } - echo "\n"; + echo ""; $curday = -1; $today = getdate(); while ($curday <= $numberofdays[$month]) { - echo "\n"; + echo ""; for ($ii = 0; $ii < 7; $ii ++) { if (($curday == -1) && ($ii == $startdayofweek)) { @@ -245,7 +245,7 @@ function display_myminimonthcalendar($agendaitems, $month, $year, $monthName) { $dayheader = "$curday"; $class = "class=\"days_today\""; } - echo "\t\n"; + // "a".$dayheader." ".$agendaitems[$curday].""; + echo ""; $curday ++; } else { - echo "\n"; + echo ""; } } - echo "\n"; + echo ""; } - echo "
".Display::return_icon('action_prev.png',get_lang('Previous'))."", $monthName, " ", $year, "".Display::return_icon('action_next.png',get_lang('Next'))."
", $DaysShort[$ii % 7], "", $DaysShort[$ii % 7], "
"; + echo ""; if (!empty($agendaitems[$curday])) { echo "".$dayheader.""; @@ -254,18 +254,18 @@ function display_myminimonthcalendar($agendaitems, $month, $year, $monthName) { { echo $dayheader; } - // "a".$dayheader." ".$agendaitems[$curday]."\n"; - echo "  
\n"; + echo ""; } /** @@ -612,12 +612,11 @@ function get_personal_agenda_items($agendaitems, $day = "", $month = "", $year = $root_url = $url['url']; } } - + $result = Database::query($sql); - while ($item = Database::fetch_array($result)) - { + while ($item = Database::fetch_array($result)) { // we break the date field in the database into a date and a time part - $agenda_db_date = explode(" ", $item[date]); + $agenda_db_date = explode(" ", $item['date']); $date = $agenda_db_date[0]; $time = $agenda_db_date[1]; // we divide the date part into a day, a month and a year @@ -631,31 +630,29 @@ function get_personal_agenda_items($agendaitems, $day = "", $month = "", $year = $minute = $agendatime[1]; $second = $agendatime[2]; // if the student has specified a course we a add a link to that course - if ($item['course'] <> "") - { + if ($item['course'] <> "") { $url = $root_url."main/calendar/agenda.php?cidReq=".urlencode($item['course'])."&day=$day&month=$month&year=$year#$day"; // RH //Patrick Cool: to highlight the relevant agenda item $course_link = "".$item['course'].""; - } - else - { + } else { $course_link = ""; } // Creating the array that will be returned. If we have week or month view we have an array with the date as the key // if we have a day_view we use a half hour as index => key 33 = 16h30 - if ($type !== "day_view") // This is the array construction for the WEEK or MONTH view - { + if ($type !== "day_view") { + // This is the array construction for the WEEK or MONTH view + //Display events in agenda $agendaitems[$day] .= "
$hour:$minute $course_link ".$item['title']."

"; - } - else // this is the array construction for the DAY view - { + + } else { + // this is the array construction for the DAY view $halfhour = 2 * $agendatime['0']; - if ($agendatime['1'] >= '30') - { + if ($agendatime['1'] >= '30') { $halfhour = $halfhour +1; } //Display events by list $agendaitems[$halfhour] .= "
$hour:$minute $course_link ".$item['title']."
"; + } } //print_r($agendaitems); @@ -711,7 +708,7 @@ function show_personal_agenda() { $export_icon_high = 'export_high_fade.png'; // starting the table output - echo "\n"; + echo "
"; if (Database::num_rows($result) > 0) { @@ -723,7 +720,7 @@ function show_personal_agenda() { if ($month_bar != date("m", strtotime($myrow["date"])).date("Y", strtotime($myrow["date"]))) { $month_bar = date("m", strtotime($myrow["date"])).date("Y", strtotime($myrow["date"])); - echo "\n"; + echo ""; } // highlight: if a date in the small calendar is clicked we highlight the relevant items $db_date = (int) date("d", strtotime($myrow["date"])).date("n", strtotime($myrow["date"])).date("Y", strtotime($myrow["date"])); @@ -740,7 +737,7 @@ function show_personal_agenda() { /*-------------------------------------------------- display: date and time --------------------------------------------------*/ - echo "\t\n\t\t"; + echo ""; echo '\n\t"; + //echo ""; echo ""; /*-------------------------------------------------- display: the title @@ -760,21 +757,21 @@ function show_personal_agenda() { echo ""; echo '\n\t"; - echo "\n"; + echo ""; + echo ""; /*-------------------------------------------------- display: the content --------------------------------------------------*/ $content = $myrow['text']; $content = make_clickable($content); $content = text_filter($content); - echo "\t\n\t\t"; /*-------------------------------------------------- display: the edit / delete icons --------------------------------------------------*/ - echo "\t\n\t\t"; @@ -784,7 +781,7 @@ function show_personal_agenda() { { echo ''; } - echo "
".$MonthsLong[date("n", strtotime($myrow["date"])) - 1]." ".date("Y", strtotime($myrow["date"]))."
".$MonthsLong[date("n", strtotime($myrow["date"])) - 1]." ".date("Y", strtotime($myrow["date"]))."
'; // adding an internal anchor echo ""; @@ -752,7 +749,7 @@ function show_personal_agenda() { //echo ''.Display::return_icon($export_icon_high, get_lang('ExportiCalConfidential')).''; //echo ''.Display::return_icon($export_icon_low, get_lang('ExportiCalPrivate')).''; //echo ''.Display::return_icon($export_icon, get_lang('ExportiCalPublic')).''; - //echo "\n\t\t
'; echo $myrow['title']; - echo "\n\t\t
"; + echo "
"; echo $content; echo "
"; + echo "
"; echo "".Display::return_icon('edit.gif', get_lang('Edit')).""; echo "".Display::return_icon('delete.gif', get_lang('Delete')).""; echo "
'.get_lang('NoAgendaItems').'
\n"; + echo ""; } /** From 206d0ccc18f43529890b7db6223fc145e1df8a39 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Tue, 18 May 2010 16:51:19 +0200 Subject: [PATCH 24/63] Cleaning code --- main/calendar/myagenda.php | 109 +++++++++++-------------------------- 1 file changed, 31 insertions(+), 78 deletions(-) diff --git a/main/calendar/myagenda.php b/main/calendar/myagenda.php index aad567e51f..320497a135 100755 --- a/main/calendar/myagenda.php +++ b/main/calendar/myagenda.php @@ -1,46 +1,5 @@ , Ghent University - @author: Toon Van Hoecke , Ghent University - @author: Eric Remy (initial version) - @version: 2.2 alpha - @description: this file generates a general agenda of all items of the - courses the user is registered for - - version info: - ------------- - -> version 2.3 : Yannick Warnier, yannick.warnier@dokeos.com 2008 - Added repeated events - -> version 2.2 : Patrick Cool, patrick.cool@ugent.be, november 2004 - Personal Agenda added. The user can add personal agenda items. The items - are stored in a chamilo_user database because it is not course or platform - based. A personal agenda view was also added. This lists all the personal - agenda items of that user. - - -> version 2.1 : Patrick Cool, patrick.cool@ugent.be, , oktober 2004 - This is the version that works with the Group based Agenda tool. - - -> version 2.0 (alpha): Patrick Cool, patrick.cool@ugent.be, , oktober 2004 - The 2.0 version introduces besides the month view also a week- and day view. - In the 2.5 (final) version it will be possible for the student to add his/her - own agenda items. The platform administrator can however decide if the students - are allowed to do this or not. - The alpha version only contains the three views. The personal agenda feature is - not yet completely finished. There are however already some parts of the code - for adding a personal agenda item present. - this code was not released in an official dokeos but was only used in the offical - server of the Ghent University where it underwent serious testing - - -> version 1.5: Toon Van Hoecke, toon.vanhoecke@ugent.be, december 2003 - - -> version 1.0: Eric Remy, eremy@rmwc.edu, 6 Oct 2003 - The tool was initially called master-calendar as it collects all the calendar - items of all the courses one is subscribed to. It was very soon integrated in - Dokeos as this was a really basic and very usefull tool. -**/ - -// HEADER // name of the language file that needs to be included $language_file = 'agenda'; @@ -76,11 +35,11 @@ Display::display_header(get_lang('MyAgenda')); // SETTING SOME VARIABLES // setting the database variables -$TABLECOURS = Database :: get_main_table(TABLE_MAIN_COURSE); -$TABLECOURSUSER = Database :: get_main_table(TABLE_MAIN_COURSE_USER); -$TABLEAGENDA = Database :: get_course_table(TABLE_AGENDA); +$TABLECOURS = Database :: get_main_table(TABLE_MAIN_COURSE); +$TABLECOURSUSER = Database :: get_main_table(TABLE_MAIN_COURSE_USER); +$TABLEAGENDA = Database :: get_course_table(TABLE_AGENDA); $TABLE_ITEMPROPERTY = Database :: get_course_table(TABLE_ITEM_PROPERTY); -$tbl_personal_agenda = Database :: get_user_personal_table(TABLE_PERSONAL_AGENDA); +$tbl_personal_agenda= Database :: get_user_personal_table(TABLE_PERSONAL_AGENDA); // the variables for the days and the months // Defining the shorts for the days @@ -91,17 +50,17 @@ $DaysLong = api_get_week_days_long(); $MonthsLong = api_get_months_long(); /* - TREATING THE URL PARAMETERS - 1. The default values - 2. storing it in the session - 3. possible view - 3.a Month view - 3.b Week view - 3.c day view - 3.d personal view (only the personal agenda items) - 4. add personal agenda - 5. edit personal agenda - 6. delete personal agenda + TREATING THE URL PARAMETERS + 1. The default values + 2. storing it in the session + 3. possible view + 3.a Month view + 3.b Week view + 3.c day view + 3.d personal view (only the personal agenda items) + 4. add personal agenda + 5. edit personal agenda + 6. delete personal agenda */ // 1. The default values. if there is no session yet, we have by default the month view @@ -118,51 +77,47 @@ if ($_SESSION['view']) { switch ($_SESSION['view']) { // 3.a Month view case "month" : - $process = "month_view"; + $process = 'month_view'; break; // 3.a Week view case "week" : - $process = "week_view"; + $process = 'week_view'; break; // 3.a Day view case "day" : - $process = "day_view"; + $process = 'day_view'; break; // 3.a Personal view case "personal" : - $process = "personal_view"; + $process = 'personal_view'; break; } } // 4. add personal agenda -if (!empty($_GET['action']) && $_GET['action'] == "add_personal_agenda_item" and !$_POST['Submit']) -{ +if (!empty($_GET['action']) && $_GET['action'] == 'add_personal_agenda_item' and !$_POST['Submit']) { $process = "add_personal_agenda_item"; } -if (!empty($_GET['action']) && $_GET['action'] == "add_personal_agenda_item" and $_POST['Submit']) -{ +if (!empty($_GET['action']) && $_GET['action'] == "add_personal_agenda_item" and $_POST['Submit']) { $process = "store_personal_agenda_item"; } // 5. edit personal agenda -if (!empty($_GET['action']) && $_GET['action'] == "edit_personal_agenda_item" and !$_POST['Submit']) -{ +if (!empty($_GET['action']) && $_GET['action'] == 'edit_personal_agenda_item' and !$_POST['Submit']) { $process = "edit_personal_agenda_item"; } -if (!empty($_GET['action']) && $_GET['action'] == "edit_personal_agenda_item" and $_POST['Submit']) -{ +if (!empty($_GET['action']) && $_GET['action'] == 'edit_personal_agenda_item' and $_POST['Submit']) { $process = "store_personal_agenda_item"; } // 6. delete personal agenda -if (!empty($_GET['action']) && $_GET['action'] == "delete" AND $_GET['id']) -{ +if (!empty($_GET['action']) && $_GET['action'] == "delete" AND $_GET['id']) { $process = "delete_personal_agenda_item"; } + // OUTPUT if (isset ($_user['user_id'])) { // getting all the courses that this user is subscribed to $courses_dbs = get_all_courses_of_user(); - if (!is_array($courses_dbs)) // this is for the special case if the user has no courses (otherwise you get an error) - { + if (!is_array($courses_dbs)) { + // this is for the special case if the user has no courses (otherwise you get an error) $courses_dbs = array (); } // setting and/or getting the year, month, day, week @@ -173,13 +128,11 @@ if (isset ($_user['user_id'])) { $year = $today['year']; } $month = (!empty($_GET['month'])? (int)$_GET['month']:NULL); - if ($month == NULL) - { + if ($month == NULL) { $month = $today['mon']; } $day = (!empty($_GET['day']) ? (int)$_GET['day']:NULL); - if ($day == NULL) - { + if ($day == NULL) { $day = $today['mday']; } $week = (!empty($_GET['week']) ?(int)$_GET['week']:NULL); @@ -207,8 +160,7 @@ if (isset ($_user['user_id'])) { echo ""; $agendaitems = get_myagendaitems($courses_dbs, $month, $year); $agendaitems = get_global_agenda_items($agendaitems, $day, $month, $year, $week, "month_view"); - if (api_get_setting('allow_personal_agenda') == 'true') - { + if (api_get_setting('allow_personal_agenda') == 'true') { $agendaitems = get_personal_agenda_items($agendaitems, $day, $month, $year, $week, "month_view"); } display_myminimonthcalendar($agendaitems, $month, $year, $monthName); @@ -224,6 +176,7 @@ if (isset ($_user['user_id'])) { case 'month_view' : $agendaitems = get_myagendaitems($courses_dbs, $month, $year); $agendaitems = get_global_agenda_items($agendaitems, $day, $month, $year, $week, "month_view"); + if (api_get_setting("allow_personal_agenda") == "true") { $agendaitems = get_personal_agenda_items($agendaitems, $day, $month, $year, $week, "month_view"); From 1a6a80ff9b616474733ca2dcbc7afbb79a7017fd Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Tue, 18 May 2010 16:52:33 +0200 Subject: [PATCH 25/63] Personal agenda events loaded in course agenda (partial) see CT#325 --- main/calendar/agenda.inc.php | 240 ++++++++++++++++------------------- 1 file changed, 111 insertions(+), 129 deletions(-) diff --git a/main/calendar/agenda.inc.php b/main/calendar/agenda.inc.php index 16be4d1c65..c48bbc3033 100755 --- a/main/calendar/agenda.inc.php +++ b/main/calendar/agenda.inc.php @@ -4,7 +4,7 @@ /** @author: Patrick Cool, patrick.cool@UGent.be - @author: Julio Montoya Lots of fixes + @author: Julio Montoya Lots of fixes - UI improvements @version: 1.1 @todo: synchronisation with the function in myagenda.php (for instance: using one function for the mini_calendar @@ -15,6 +15,8 @@ Reabability is also the reason why I use the if ($is_allowed_to_edit) check for each part of the code. I'm aware that is duplication, but it makes the code much easier to read. + + @todo this code should be clean as well as the myagenda.inc.php lots of function */ @@ -57,6 +59,7 @@ $(document).ready(function () { * @return array */ function get_calendar_items($month, $year) { + global $_user, $_course; global $is_allowed_to_edit; global $select_month, $select_year; @@ -78,9 +81,7 @@ function get_calendar_items($month, $year) { //$session_condition = intval($_SESSION['id_session'])==0 ? '' : ' AND agenda.session_id IN (0,'.intval($_SESSION['id_session']).') '; - - /* CONSTRUCT THE SQL STATEMENT - */ + /* CONSTRUCT THE SQL STATEMENT */ $start = 0; $stop = 0; @@ -240,13 +241,28 @@ function get_calendar_items($month, $year) { $result=Database::query($sql) or die(Database::error()); - ///////////////// $data=array(); - while ($row=Database::fetch_array($result)) - { - $datum_item=(int)substr($row["start_date"],8,2); + while ($row=Database::fetch_array($result, 'ASSOC')) { + $datum_item=(int)substr($row['start_date'],8,2); + $row['calendar_type'] = 'course'; $data[$datum_item][intval($datum_item)][] = $row; - } + } + + //Check my personal calendar items + if (api_get_setting('allow_personal_agenda') == 'true') { + $tbl_personal_agenda = Database :: get_user_personal_table(TABLE_PERSONAL_AGENDA); + // 1. creating the SQL statement for getting the personal agenda items in MONTH view + $sql = "SELECT id, title, text as content , date as start_date, enddate as end_date, parent_event_id FROM ".$tbl_personal_agenda." + WHERE user='".api_get_user_id()."' and MONTH(date)='".$month."' AND YEAR(date) = '".$year."' ORDER BY date ASC"; + $result = Database::query($sql); + while ($row = Database::fetch_array($result, 'ASSOC')) { + $datum_item=intval(substr($row["start_date"],8,2)); + $row['calendar_type'] = 'personal'; + $data[$datum_item][$datum_item][] = $row; + } + } + + return $data; } @@ -352,16 +368,14 @@ function display_minimonthcalendar($agendaitems, $month, $year, $monthName) * @param integer $year: the 4-digit year indication e.g. 2005 * @return html code */ -function display_monthcalendar($month, $year) -{ +function display_monthcalendar($month, $year) { global $MonthsLong; global $DaysShort; global $origin; - // grabbing all the calendar items for this year and storing it in a array + // Grabbing all the calendar items for this year and storing it in a array + my personal calendar events if exist and if enabled $data = get_calendar_items($month,$year); -// $data_global=get_global_calendar_items($month,$year); -// $data_global=get_global_agenda_items($agendaitems, $day, $month, $year, $week, $type); + //Handle leap year $numberofdays = array(0,31,28,31,30,31,30,31,31,30,31,30,31); if (($year%400 == 0) or ($year%4==0 and $year%100<>0)) $numberofdays[2] = 29; @@ -376,50 +390,55 @@ function display_monthcalendar($month, $year) $maand_array_maandnummer=$month-1; - echo "", - "", - "", - "", - "", - ""; + echo '
".Display::return_icon('action_prev.png',get_lang('Previous'))." ",$MonthsLong[$maand_array_maandnummer]," ",$year," ".Display::return_icon('action_next.png',get_lang('Next'))."
'; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; - echo ""; + echo ''; for ($ii=1;$ii<8; $ii++) { - echo ""; + echo ''; } - echo ""; + echo ''; $curday = -1; $today = getdate(); - echo '
';
-	//print_r($data);
+		
 	while ($curday <= $numberofdays[$month]) {
 		echo '
'; //week for ($ii=0; $ii<7; $ii++) { - if (($curday == -1)&&($ii==$startdayofweek)) { + if (($curday == -1) && ($ii==$startdayofweek)) { $curday = 1; } if (($curday>0)&&($curday<=$numberofdays[$month])) { - $bgcolor = $ii<5 ? "class=\"row_odd\"" : "class=\"row_even\""; + $bgcolor = $ii<5 ? 'class="row_odd"' : 'class="row_even"'; $dayheader = "$curday"; if (key_exists($curday, $data)) { - foreach ($data[$curday] as $key=>$agenda_item) { - foreach ($agenda_item as $key=>$value) { + foreach ($data[$curday] as $key=>$agenda_item) { + foreach ($agenda_item as $key=>$value) { $month_start_date = (int)substr($value['start_date'],5,2); $start_time = api_convert_and_format_date($value['start_date']); if ($month == $month_start_date) { $start_time = api_convert_and_format_date($value['start_date'], TIME_NO_SEC_FORMAT, date_default_timezone_get()); - $end_time = api_convert_and_format_date($value['end_date'], TIME_NO_SEC_FORMAT, date_default_timezone_get()); + $end_time = api_convert_and_format_date($value['end_date'], TIME_NO_SEC_FORMAT, date_default_timezone_get()); + + $personal_start = $personal_end = ''; - $dayheader="".$curday.""; + if ($value['calendar_type'] == 'personal') { + $personal_start = '
'; + $personal_end = '
'; + } + $dayheader = $personal_start; + $dayheader.="".$curday.""; - if ($value['end_date']=='0000-00-00 00:00:00'){ - + if ($value['end_date']=='0000-00-00 00:00:00') { $dayheader .= '
'.get_lang('Work').'
'; $dayheader .= $value['title']; $dayheader .= '
'; @@ -428,31 +447,31 @@ function display_monthcalendar($month, $year) $dayheader .= '
'; $dayheader .= $value['title']; $dayheader .= '
'; - } + } + $dayheader .= $personal_end; } else { //$dayheader=$curday; } - //$agendaitems = get_global_agenda_items($agendaitems, $curday, $month, $year, $startdayofweek, "month_view"); - //echo $agendaitems['title']; + //$agendaitems = get_global_agenda_items($agendaitems, $curday, $month, $year, $startdayofweek, "month_view"); + //echo $agendaitems['title']; } } } if (($curday==$today['mday']) && ($year ==$today['year'])&&($month == $today['mon'])) { - echo ""; + echo ''; $curday++; } else { - echo ""; + echo ''; } } - echo ""; + echo ''; } // end while - echo "
'.Display::return_icon('action_prev.png',get_lang('Previous')).''.$MonthsLong[$maand_array_maandnummer].$year.' '.Display::return_icon('action_next.png',get_lang('Next')).'
",$DaysShort[$ii%7],"'.$DaysShort[$ii%7].'
".$dayheader; + echo ''.$dayheader; } else { - echo "".$dayheader; - } - - echo "'.$dayheader; + } + echo '  
"; + echo ''; } @@ -1723,11 +1742,13 @@ function showhide_agenda_item($id) * Displays all the agenda items * @author Patrick Cool , Ghent University * @author Yannick Warnier - cleanup +* @author Julio Montoya - More cleanup */ -function display_agenda_items() -{ - global $TABLEAGENDA; - global $TABLE_ITEM_PROPERTY; +function display_agenda_items() { + + $TABLEAGENDA = Database::get_course_table(TABLE_AGENDA); + $TABLE_ITEM_PROPERTY = Database::get_course_table(TABLE_ITEM_PROPERTY); + global $select_month, $select_year; global $DaysShort, $DaysLong, $MonthsLong; global $is_courseAdmin; @@ -1739,32 +1760,26 @@ function display_agenda_items() // getting the name of the groups $group_names = get_course_groups(); - /*-------------------------------------------------- + /* CONSTRUCT THE SQL STATEMENT - --------------------------------------------------*/ + */ $start = 0; $stop = 0; // this is to make a difference between showing everything (all months) or only the current month) // $show_all_current is a part of the sql statement - if ($_SESSION['show']!=="showall") - { + if ($_SESSION['show']!=="showall") { $show_all_current=" AND MONTH(start_date)=$select_month AND year(start_date)=$select_year"; $start = mktime(0,0,0,$select_month,1,$select_year); $stop = 0; if(empty($select_year)){$select_year = date('Y');} if(empty($select_month)){$select_month = date('m');} - if($select_month==12) - { + if($select_month==12) { $stop = mktime(0,0,0,1,1,$select_year+1)-1; - } - else - { + } else { $stop = mktime(0,0,0,$select_month+1,1,$select_year)-1; } - } - else - { + } else { $show_all_current=""; $start = time(); $stop = mktime(0,0,0,1,1,2038);//by default, set year to maximum for mktime() @@ -1772,16 +1787,13 @@ function display_agenda_items() // by default we use the id of the current user. The course administrator can see the agenda of other users by using the user / group filter $user_id=$_user['user_id']; - if ($_SESSION['user']!==null) - { + if ($_SESSION['user']!==null) { $user_id=intval($_SESSION['user']); } - if ($_SESSION['group']!==null) - { + if ($_SESSION['group']!==null) { $group_id=intval($_SESSION['group']); } - if ($_SESSION['toolgroup']!==null) - { + if ($_SESSION['toolgroup']!==null) { $group_id=intval($_SESSION['toolgroup']); } @@ -1795,31 +1807,25 @@ function display_agenda_items() $session_id = api_get_session_id(); $session_condition = api_get_session_condition($session_id); - if (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_edit_agenda') && !api_is_anonymous())) - { + if (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_edit_agenda') && !api_is_anonymous())) { // A.1. you are a course admin with a USER filter // => see only the messages of this specific user + the messages of the group (s)he is member of. - if (!empty($_SESSION['user'])) - { + if (!empty($_SESSION['user'])) { $group_memberships=GroupManager::get_group_ids($_course['dbName'],$_SESSION['user']); $show_user =true; $new_group_memberships=array(); - foreach($group_memberships as $id) - { + foreach($group_memberships as $id) { // did i have access to the same $has_access = GroupManager::user_has_access(api_get_user_id(),$id,GROUP_TOOL_CALENDAR); $result = GroupManager::get_group_properties($id); - - if ($has_access && $result['calendar_state']!='0' ) - { + if ($has_access && $result['calendar_state']!='0' ) { $new_group_memberships[]=$id; } } $group_memberships = $new_group_memberships; - if (is_array($group_memberships) && count($group_memberships)>0) - { + if (is_array($group_memberships) && count($group_memberships)>0) { $sql="SELECT agenda.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.ref FROM ".$TABLEAGENDA." agenda, ".$TABLE_ITEM_PROPERTY." ip @@ -1829,9 +1835,7 @@ function display_agenda_items() AND ip.visibility='1' $session_condition ORDER BY start_date ".$_SESSION['sort']; - } - else - { + } else { $sql="SELECT agenda.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.ref FROM ".$TABLEAGENDA." agenda, ".$TABLE_ITEM_PROPERTY." ip @@ -1845,23 +1849,19 @@ function display_agenda_items() } // A.2. you are a course admin with a GROUP filter // => see only the messages of this specific group - elseif (!empty($_SESSION['group'])) - { - + elseif (!empty($_SESSION['group'])) { if (!empty($group_id)) { $result = GroupManager::get_group_properties($group_id); $has_access = GroupManager::user_has_access(api_get_user_id(),$group_id,GROUP_TOOL_CALENDAR); //echo '
';print_R($result);
 
 				// lastedit
-				if (!$has_access || $result['calendar_state']=='0' )
-				{
+				if (!$has_access || $result['calendar_state']=='0' ) {
 					$group_id=0;
 				}
 			}
 
-			$sql="SELECT
-				agenda.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.ref
+			$sql="SELECT agenda.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.ref
 				FROM ".$TABLEAGENDA." agenda, ".$TABLE_ITEM_PROPERTY." ip
 				WHERE agenda.id = ip.ref  ".$show_all_current."
 				AND ip.tool='".TOOL_CALENDAR_EVENT."'
@@ -1873,13 +1873,10 @@ function display_agenda_items()
 				//removed 	- > AND toolitemproperties.visibility='1'
 		}
 		// A.3 you are a course admin without any group or user filter
-		else
-		{
-
+		else {
 			// A.3.a you are a course admin without user or group filter but WITH studentview
 			// => see all the messages of all the users and groups without editing possibilities
-			if ($_GET['isStudentView']=='true')
-			{
+			if ($_GET['isStudentView']=='true') {
 				$sql="SELECT
 					agenda.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.ref
 					FROM ".$TABLEAGENDA." agenda, ".$TABLE_ITEM_PROPERTY." ip
@@ -1892,13 +1889,11 @@ function display_agenda_items()
 
 			}
 			// A.3.b you are a course admin or a student
-			else
-			{
+			else {
 				// A.3.b.1 you are a course admin without user or group filter and WITHOUT studentview (= the normal course admin view)
 				// 	=> see all the messages of all the users and groups with editing possibilities
 
-				 if (api_is_course_admin())
-				 {
+				 if (api_is_course_admin()) {
 					 $sql="SELECT
 						agenda.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.ref
 						FROM ".$TABLEAGENDA." agenda, ".$TABLE_ITEM_PROPERTY." ip
@@ -1908,9 +1903,7 @@ function display_agenda_items()
 						$session_condition
 						GROUP BY ip.ref
 						ORDER BY start_date ".$_SESSION['sort'];
-				 }
-				 else
-				 {
+				 } else {
 				 	// A.3.b.2 you are a student with no group filter possibly showall
 				 	//when showing all the events we do not show the group events
 				 	//todo showing ALL events including the groups events that are available
@@ -1924,7 +1917,6 @@ function display_agenda_items()
 						GROUP BY ip.ref
 						ORDER BY start_date ".$_SESSION['sort'];
 
-
 					/*
 				 	if (is_array($group_memberships) && count($group_memberships)>0)
 				 	{
@@ -1959,10 +1951,8 @@ function display_agenda_items()
 	} //if (is_allowed_to_edit() OR( api_get_course_setting('allow_user_edit_agenda') && !api_is_anonymous()))
 
 	// B. you are a student
-	else
-	{
-		if (is_array($group_memberships) and count($group_memberships)>0)
-		{
+	else {
+		if (is_array($group_memberships) and count($group_memberships)>0) {
 			$sql="SELECT
 				agenda.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.ref
 				FROM ".$TABLEAGENDA." agenda, ".$TABLE_ITEM_PROPERTY." ip
@@ -1972,11 +1962,8 @@ function display_agenda_items()
 				AND ip.visibility='1'
 				$session_condition
 				ORDER BY start_date ".$_SESSION['sort'];
-		}
-		else
-		{
-			if ($_user['user_id'])
-			{
+		} else {
+			if ($_user['user_id']) {
 				$sql="SELECT
 					agenda.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.ref
 					FROM ".$TABLEAGENDA." agenda, ".$TABLE_ITEM_PROPERTY." ip
@@ -1986,9 +1973,7 @@ function display_agenda_items()
 					AND ip.visibility='1'
 					$session_condition
 					ORDER BY start_date ".$_SESSION['sort'];
-			}
-			else
-			{
+			} else {
 				$sql="SELECT
 					agenda.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.ref
 					FROM ".$TABLEAGENDA." agenda, ".$TABLE_ITEM_PROPERTY." ip
@@ -2005,36 +1990,34 @@ function display_agenda_items()
 	//echo "
".$sql."
"; $result=Database::query($sql) or die(Database::error()); $number_items=Database::num_rows($result); - - /*-------------------------------------------------- + + /* DISPLAY: NO ITEMS - --------------------------------------------------*/ - if ($number_items==0) - { + */ + if ($number_items==0) { echo "
".get_lang("NoAgendaItems")."
"; } - /*-------------------------------------------------- + /* DISPLAY: THE ITEMS - --------------------------------------------------*/ + */ $month_bar=""; $event_list=""; $counter=0; - $export_icon = 'export.png'; - $export_icon_low = 'export_low_fade.png'; + $export_icon = 'export.png'; + $export_icon_low = 'export_low_fade.png'; $export_icon_high = 'export_high_fade.png'; while($myrow=Database::fetch_array($result)) { $is_repeated = !empty($myrow['parent_event_id']); echo ''; - /*-------------------------------------------------- + /* display: the month bar - --------------------------------------------------*/ + */ // Make the month bar appear only once. $myrow["start_date"] = api_get_local_time($myrow["start_date"], null, date_default_timezone_get()); - if ($month_bar != api_format_date($myrow["start_date"], "%m%Y")) - { + if ($month_bar != api_format_date($myrow["start_date"], "%m%Y")) { $month_bar = api_format_date($myrow["start_date"], "%m%Y"); echo ""; } - /*-------------------------------------------------- - display: the icon, title, destinees of the item - -------------------------------------------------*/ + /* display: the icon, title, destinees of the item */ echo ''; // highlight: if a date in the small calendar is clicked we highlight the relevant items $db_date = (int)api_format_date($myrow["start_date"], "%d").intval(api_format_date($myrow["start_date"], "%m")).api_format_date($myrow["start_date"], "%Y"); if ($_GET["day"].$_GET["month"].$_GET["year"] <>$db_date) { - if ($myrow['visibility']=='0') - { + if ($myrow['visibility']=='0') { $style="data_hidden"; $stylenotbold="datanotbold_hidden"; $text_style="text_hidden"; - } - else - { + } else { $style="data"; $stylenotbold="datanotbold"; $text_style="text"; } - - } - else - { + } else { $style="datanow"; $stylenotbold="datanotboldnow"; $text_style="textnow"; @@ -2060,8 +2041,7 @@ function display_agenda_items() { // we add the groups icon // 2do: if it is sent to groups we display the group icon, if it is sent to a user we show the user icon Display::display_icon('agenda.gif', get_lang('Agenda')); - if ($myrow['to_group_id']!=='0') - { + if ($myrow['to_group_id']!=='0') { echo Display::return_icon('group.gif', get_lang('ItemForUserSelection')); } echo $myrow['title']; @@ -2074,18 +2054,17 @@ function display_agenda_items() { echo $sent_to_form; echo ""; - if (!$is_repeated && (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_edit_agenda') && !api_is_anonymous()))) - { - if( ! (api_is_course_coach() && !api_is_element_in_the_session(TOOL_AGENDA, $myrow['id'] ) ) ) - { // a coach can only delete an element belonging to his session + if (!$is_repeated && (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_edit_agenda') && !api_is_anonymous()))) { + if( ! (api_is_course_coach() && !api_is_element_in_the_session(TOOL_AGENDA, $myrow['id'] ) ) ) { + // a coach can only delete an element belonging to his session echo ''; } } - /*-------------------------------------------------- + /* display: the title - --------------------------------------------------*/ + */ echo ""; echo "'; } - if (!$is_repeated && (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_edit_agenda') && !api_is_anonymous()))) { + if (!$is_repeated && (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_edit_agenda') && !api_is_anonymous())) && $myrow['calendar_type'] != 'personal' ) { if( ! (api_is_course_coach() && !api_is_element_in_the_session(TOOL_AGENDA, $myrow['id'] ) ) ) { // a coach can only delete an element belonging to his session echo ''; } + } else { + echo ''; } /* display: the title */ diff --git a/main/calendar/myagenda.inc.php b/main/calendar/myagenda.inc.php index d4e981008f..2438fe3225 100755 --- a/main/calendar/myagenda.inc.php +++ b/main/calendar/myagenda.inc.php @@ -688,19 +688,17 @@ function get_personal_agenda_item($id) { * these items in one list (ordered by date and grouped by month (the month_bar) */ function show_personal_agenda() { - global $MonthsLong, $charset; - global $_user; + global $MonthsLong, $charset; $tbl_personal_agenda = Database :: get_user_personal_table(TABLE_PERSONAL_AGENDA); // The SQL statement that retrieves all the personal agenda items of this user - $sql = "SELECT * FROM ".$tbl_personal_agenda." WHERE user='".$_user['user_id']."' ORDER BY date DESC"; + $sql = "SELECT * FROM ".$tbl_personal_agenda." WHERE user='".api_get_user_id()."' ORDER BY date DESC"; $result = Database::query($sql); // variable initialisation $month_bar = ""; // setting the default day, month and year - if (!$_GET['day'] AND !$_GET['month'] AND !$_GET['year']) - { + if (!$_GET['day'] AND !$_GET['month'] AND !$_GET['year']) { $today = getdate(); $year = $today['year']; $month = $today['mon']; @@ -711,32 +709,33 @@ function show_personal_agenda() { $export_icon_high = 'export_high_fade.png'; // starting the table output - echo "
". api_format_date($myrow["start_date"], "%B %Y"). @@ -2048,8 +2031,7 @@ function display_agenda_items() // highlight: if a date in the small calendar is clicked we highlight the relevant items $db_date = (int)api_format_date($myrow["start_date"], "%d").intval(api_format_date($myrow["start_date"], "%m")).api_format_date($myrow["start_date"], "%Y"); - if ($_GET["day"].$_GET["month"].$_GET["year"] <>$db_date) - { + if ($_GET["day"].$_GET["month"].$_GET["year"] <>$db_date) { if ($myrow['visibility']=='0') { $style="data_hidden"; @@ -4705,8 +4687,8 @@ function get_global_agenda_items($agendaitems, $day = "", $month = "", $year = " $sql = " SELECT * FROM ".$tbl_global_agenda." WHERE start_date>='".$start_filter."' AND start_date<='".$end_filter."'"; } $result = Database::query($sql); - while ($item = Database::fetch_array($result)) - { + + while ($item = Database::fetch_array($result)) { // we break the date field in the database into a date and a time part $agenda_db_date = explode(" ", $item['start_date']); $date = $agenda_db_date[0]; From 3994cc4814fdf9f451572ccaf4fa72ea601b04fd Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Tue, 18 May 2010 16:53:06 +0200 Subject: [PATCH 26/63] Cleaning code --- main/calendar/agenda.php | 13 +++++-------- main/calendar/myagenda.inc.php | 13 ++++++++----- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/main/calendar/agenda.php b/main/calendar/agenda.php index 59d24702a9..399a106301 100755 --- a/main/calendar/agenda.php +++ b/main/calendar/agenda.php @@ -198,16 +198,13 @@ echo ''; //setting the default year and month $select_year = ''; $select_month = ''; -if(!empty($_GET['year'])) -{ +if(!empty($_GET['year'])) { $select_year = (int)$_GET['year']; } -if(!empty($_GET['month'])) -{ +if(!empty($_GET['month'])) { $select_month = (int)$_GET['month']; } -if (empty($select_year) && empty($select_month)) -{ +if (empty($select_year) && empty($select_month)) { $today = getdate(); $select_year = $today['year']; $select_month = $today['mon']; @@ -384,7 +381,7 @@ if (!$_GET['action'] || $_GET['action']=="showall" || $_GET['action']=="showcur if ($_GET['origin'] != 'learnpath') { if (!$_SESSION['view'] || $_SESSION['view'] <> 'month') { if(!empty($_GET['agenda_id'])) { - display_one_agenda_item((int)$_GET['agenda_id']); + display_one_agenda_item($_GET['agenda_id']); } else { display_agenda_items(); } @@ -405,4 +402,4 @@ if ($_GET['origin'] != 'learnpath') { Display::display_footer(); } -?> +?> \ No newline at end of file diff --git a/main/calendar/myagenda.inc.php b/main/calendar/myagenda.inc.php index bfd3345b6e..d4e981008f 100755 --- a/main/calendar/myagenda.inc.php +++ b/main/calendar/myagenda.inc.php @@ -163,14 +163,17 @@ function display_mymonthcalendar($agendaitems, $month, $year, $weekdaynames=arra $backwardsURL = api_get_self()."?coursePath=".urlencode($course_path)."&courseCode=".Security::remove_XSS($g_cc)."&action=view&view=month&month=". ($month == 1 ? 12 : $month -1)."&year=". ($month == 1 ? $year -1 : $year); $forewardsURL = api_get_self()."?coursePath=".urlencode($course_path)."&courseCode=".Security::remove_XSS($g_cc)."&action=view&view=month&month=". ($month == 12 ? 1 : $month +1)."&year=". ($month == 12 ? $year +1 : $year); - echo "", "", ""; - echo "", "", ""; + echo '
".Display::return_icon('action_prev.png',get_lang('Previous'))."", $monthName, " ", $year, "".Display::return_icon('action_next.png',get_lang('Next'))."
'.''; + echo ''; + echo ''; + echo ''; + echo ''; - echo ""; + echo ''; for ($ii = 1; $ii < 8; $ii ++) { - echo ""; + echo ''; } - echo ""; + echo ''; $curday = -1; $today = getdate(); while ($curday <= $numberofdays[$month]) { From 9fc755e1d79fc8123bd830a18b6d28692537356d Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Tue, 18 May 2010 17:03:12 +0200 Subject: [PATCH 27/63] Updating CSS stylesheet --- main/css/academica/default.css | 35 +++ main/css/baby_orange/default.css | 35 +++ main/css/blue_lagoon/default.css | 17 +- main/css/chamilo/default.css | 19 +- main/css/chamilo_green/default.css | 17 +- main/css/chamilo_red/default.css | 17 +- main/css/cool_blue/default.css | 16 +- main/css/corporate/default.css | 36 +-- main/css/cosmic_campus/default.css | 33 +++ main/css/delicious_bordeaux/default.css | 17 +- main/css/dokeos_blue/default.css | 17 +- main/css/dokeos_classic/default.css | 18 +- main/css/dokeos_classic_2D/default.css | 39 ++-- main/css/empire_green/default.css | 17 +- main/css/fruity_orange/default.css | 17 +- main/css/medical/default.css | 17 +- main/css/public_admin/default.css | 17 +- main/css/royal_purple/default.css | 17 +- main/css/silver_line/default.css | 295 +++++++++++++++++------- main/css/sober_brown/default.css | 40 +--- main/css/steel_grey/default.css | 17 +- main/css/tasty_olive/default.css | 17 +- 22 files changed, 535 insertions(+), 235 deletions(-) diff --git a/main/css/academica/default.css b/main/css/academica/default.css index 87da2ee522..3cc0712d2b 100755 --- a/main/css/academica/default.css +++ b/main/css/academica/default.css @@ -643,6 +643,41 @@ form span.form_error { padding: 2px 10px; text-align: center; } +/* The cells for the days (1->31) */ +#agenda_list .days_week { + height: 40px; + width: 12%; + text-align: left; + vertical-align: top; + border: 1px solid #ccc; + border-collapse: collapse; + background-color: #f5f5f5; +} +#agenda_list .days_weekend { + height: 40px; + width: 12%; + text-align: left; + vertical-align: top; + border: 1px solid #ccc; + border-collapse: collapse; + background-color: #e6e6e6; +} +#agenda_list .days_today { + height: 40px; + width: 12%; + text-align: left; + vertical-align: top; + border: 1px solid #ccc; + border-collapse: collapse; + background-color: #FFFFC0; +} + +#agenda_list th { + background-color:#E5EDF9; + border:1px solid gray; + padding-right:12px; +} + /* text in the cells: display of agenda items (visible)*/ #agenda_list .data { background-color: #eee; diff --git a/main/css/baby_orange/default.css b/main/css/baby_orange/default.css index 6023f82366..0bb1a0b4fb 100755 --- a/main/css/baby_orange/default.css +++ b/main/css/baby_orange/default.css @@ -613,6 +613,41 @@ form span.form_error { text-align: center; border:1px solid #EE4C03; } +/* The cells for the days (1->31) */ +#agenda_list .days_week { + height: 40px; + width: 12%; + text-align: left; + vertical-align: top; + border: 1px solid #ccc; + border-collapse: collapse; + background-color: #f5f5f5; +} +#agenda_list .days_weekend { + height: 40px; + width: 12%; + text-align: left; + vertical-align: top; + border: 1px solid #ccc; + border-collapse: collapse; + background-color: #e6e6e6; +} +#agenda_list .days_today { + height: 40px; + width: 12%; + text-align: left; + vertical-align: top; + border: 1px solid #ccc; + border-collapse: collapse; + background-color: #FFFFC0; +} + +#agenda_list th { + background-color:#E5EDF9; + border:1px solid gray; + padding-right:12px; +} + /*The caption of the calendar (displays the month and the << and >> links*/ #agenda_list .title { background-color: #680157; diff --git a/main/css/blue_lagoon/default.css b/main/css/blue_lagoon/default.css index 958f5e161c..d59cf15a0c 100755 --- a/main/css/blue_lagoon/default.css +++ b/main/css/blue_lagoon/default.css @@ -701,7 +701,7 @@ input.liteoption { width: 12%; text-align: left; vertical-align: top; - border: 1px solid #264269; + border: 1px solid #ccc; border-collapse: collapse; background-color: #f5f5f5; } @@ -710,7 +710,7 @@ input.liteoption { width: 12%; text-align: left; vertical-align: top; - border: 1px solid #264269; + border: 1px solid #ccc; border-collapse: collapse; background-color: #e6e6e6; } @@ -719,12 +719,17 @@ input.liteoption { width: 12%; text-align: left; vertical-align: top; - border: 1px solid #264269; + border: 1px solid #ccc; border-collapse: collapse; - background-color: #FFCA8D; - color: #CC3300; - font-weight: bold; + background-color: #FFFFC0; } + +#agenda_list th { + background-color:#E5EDF9; + border:1px solid gray; + padding-right:12px; +} + /* text in the cells: display of agenda items (visible)*/ #agenda_list .data { background-color: #eee; diff --git a/main/css/chamilo/default.css b/main/css/chamilo/default.css index 407a1bc887..3e893087f6 100755 --- a/main/css/chamilo/default.css +++ b/main/css/chamilo/default.css @@ -1014,7 +1014,7 @@ input.liteoption { text-align: center; } /* The cells with the name of the days of the weeks (mon->sun)*/ -#agenda_list .weekdays { +#agenda_list .weekdays, .data_table .weekdays { background-color: #dcdcdc; text-align: center; font-weight: bold; @@ -1027,7 +1027,7 @@ input.liteoption { width: 12%; text-align: left; vertical-align: top; - border: 1px solid #264269; + border: 1px solid #ccc; border-collapse: collapse; background-color: #f5f5f5; } @@ -1036,7 +1036,7 @@ input.liteoption { width: 12%; text-align: left; vertical-align: top; - border: 1px solid #264269; + border: 1px solid #ccc; border-collapse: collapse; background-color: #e6e6e6; } @@ -1045,12 +1045,17 @@ input.liteoption { width: 12%; text-align: left; vertical-align: top; - border: 1px solid #264269; + border: 1px solid #ccc; border-collapse: collapse; - background-color: #FFCA8D; - color: #CC3300; - font-weight: bold; + background-color: #FFFFC0; } + +#agenda_list th { + background-color:#E5EDF9; + border:1px solid gray; + padding-right:12px; +} + /* text in the cells: display of agenda items (visible)*/ #agenda_list .data { background-color: #eee; diff --git a/main/css/chamilo_green/default.css b/main/css/chamilo_green/default.css index 9aa4baa29c..6746d7bf04 100755 --- a/main/css/chamilo_green/default.css +++ b/main/css/chamilo_green/default.css @@ -1031,7 +1031,7 @@ input.liteoption { width: 12%; text-align: left; vertical-align: top; - border: 1px solid #264269; + border: 1px solid #ccc; border-collapse: collapse; background-color: #f5f5f5; } @@ -1040,7 +1040,7 @@ input.liteoption { width: 12%; text-align: left; vertical-align: top; - border: 1px solid #264269; + border: 1px solid #ccc; border-collapse: collapse; background-color: #e6e6e6; } @@ -1049,12 +1049,17 @@ input.liteoption { width: 12%; text-align: left; vertical-align: top; - border: 1px solid #264269; + border: 1px solid #ccc; border-collapse: collapse; - background-color: #FFCA8D; - color: #CC3300; - font-weight: bold; + background-color: #FFFFC0; } + +#agenda_list th { + background-color:#E5EDF9; + border:1px solid gray; + padding-right:12px; +} + /* text in the cells: display of agenda items (visible)*/ #agenda_list .data { background-color: #eee; diff --git a/main/css/chamilo_red/default.css b/main/css/chamilo_red/default.css index d1fd6bee98..80483bbbc6 100755 --- a/main/css/chamilo_red/default.css +++ b/main/css/chamilo_red/default.css @@ -1025,7 +1025,7 @@ input.liteoption { width: 12%; text-align: left; vertical-align: top; - border: 1px solid #264269; + border: 1px solid #ccc; border-collapse: collapse; background-color: #f5f5f5; } @@ -1034,7 +1034,7 @@ input.liteoption { width: 12%; text-align: left; vertical-align: top; - border: 1px solid #264269; + border: 1px solid #ccc; border-collapse: collapse; background-color: #e6e6e6; } @@ -1043,12 +1043,17 @@ input.liteoption { width: 12%; text-align: left; vertical-align: top; - border: 1px solid #264269; + border: 1px solid #ccc; border-collapse: collapse; - background-color: #FFCA8D; - color: #CC3300; - font-weight: bold; + background-color: #FFFFC0; } + +#agenda_list th { + background-color:#E5EDF9; + border:1px solid gray; + padding-right:12px; +} + /* text in the cells: display of agenda items (visible)*/ #agenda_list .data { background-color: #eee; diff --git a/main/css/cool_blue/default.css b/main/css/cool_blue/default.css index b11a8b8df5..550a6f227e 100755 --- a/main/css/cool_blue/default.css +++ b/main/css/cool_blue/default.css @@ -680,7 +680,7 @@ input.liteoption { width: 12%; text-align: left; vertical-align: top; - border: 1px solid #264269; + border: 1px solid #ccc; border-collapse: collapse; background-color: #f5f5f5; } @@ -689,7 +689,7 @@ input.liteoption { width: 12%; text-align: left; vertical-align: top; - border: 1px solid #264269; + border: 1px solid #ccc; border-collapse: collapse; background-color: #e6e6e6; } @@ -698,11 +698,15 @@ input.liteoption { width: 12%; text-align: left; vertical-align: top; - border: 1px solid #264269; + border: 1px solid #ccc; border-collapse: collapse; - background-color: #FFCA8D; - color: #CC3300; - font-weight: bold; + background-color: #FFFFC0; +} + +#agenda_list th { + background-color:#E5EDF9; + border:1px solid gray; + padding-right:12px; } /* text in the cells: display of agenda items (visible)*/ #agenda_list .data { diff --git a/main/css/corporate/default.css b/main/css/corporate/default.css index 6c07e210b4..535b77333e 100755 --- a/main/css/corporate/default.css +++ b/main/css/corporate/default.css @@ -607,34 +607,40 @@ form span.form_error { border: 1px solid #CCCCCC; border-collapse: collapse; } + /* The cells for the days (1->31) */ -.days_week { +#agenda_list .days_week { height: 40px; width: 12%; - border: 1px solid #CCCCCC; + text-align: left; + vertical-align: top; + border: 1px solid #ccc; border-collapse: collapse; - background-color: #f9f9f9; + background-color: #f5f5f5; } -.days_weekend { +#agenda_list .days_weekend { height: 40px; width: 12%; - border: 1px solid #CCCCCC; + text-align: left; + vertical-align: top; + border: 1px solid #ccc; border-collapse: collapse; - background-color: #eaeaea; + background-color: #e6e6e6; } -.days_today { +#agenda_list .days_today { height: 40px; width: 12%; - border: 1px solid #CCCCCC; + text-align: left; + vertical-align: top; + border: 1px solid #ccc; border-collapse: collapse; - background-color: #FFCA8D; - color: #CC3300; - font-weight: bold; + background-color: #FFFFC0; } -.agenda_month_divider { - background-color: #666; - color: #fff; - text-align: center; + +#agenda_list th { + background-color:#E5EDF9; + border:1px solid gray; + padding-right:12px; } /*The caption of the calendar (displays the month and the << and >> links*/ #agenda_list .title { diff --git a/main/css/cosmic_campus/default.css b/main/css/cosmic_campus/default.css index 23bb73c43a..48d9c71564 100755 --- a/main/css/cosmic_campus/default.css +++ b/main/css/cosmic_campus/default.css @@ -692,6 +692,39 @@ form span.form_error { padding: 2px 10px; text-align: center; } +#agenda_list .days_week { + height: 40px; + width: 12%; + text-align: left; + vertical-align: top; + border: 1px solid #ccc; + border-collapse: collapse; + background-color: #f5f5f5; +} +#agenda_list .days_weekend { + height: 40px; + width: 12%; + text-align: left; + vertical-align: top; + border: 1px solid #ccc; + border-collapse: collapse; + background-color: #e6e6e6; +} +#agenda_list .days_today { + height: 40px; + width: 12%; + text-align: left; + vertical-align: top; + border: 1px solid #ccc; + border-collapse: collapse; + background-color: #FFFFC0; +} + +#agenda_list th { + background-color:#E5EDF9; + border:1px solid gray; + padding-right:12px; +} /* text in the cells: display of agenda items (visible)*/ #agenda_list .data { background-color: #eee; diff --git a/main/css/delicious_bordeaux/default.css b/main/css/delicious_bordeaux/default.css index ca46463de8..fb17a3a1c9 100755 --- a/main/css/delicious_bordeaux/default.css +++ b/main/css/delicious_bordeaux/default.css @@ -699,7 +699,7 @@ input.liteoption { width: 12%; text-align: left; vertical-align: top; - border: 1px solid #264269; + border: 1px solid #ccc; border-collapse: collapse; background-color: #f5f5f5; } @@ -708,7 +708,7 @@ input.liteoption { width: 12%; text-align: left; vertical-align: top; - border: 1px solid #264269; + border: 1px solid #ccc; border-collapse: collapse; background-color: #e6e6e6; } @@ -717,12 +717,17 @@ input.liteoption { width: 12%; text-align: left; vertical-align: top; - border: 1px solid #264269; + border: 1px solid #ccc; border-collapse: collapse; - background-color: #FFCA8D; - color: #CC3300; - font-weight: bold; + background-color: #FFFFC0; } + +#agenda_list th { + background-color:#E5EDF9; + border:1px solid gray; + padding-right:12px; +} + /* text in the cells: display of agenda items (visible)*/ #agenda_list .data { background-color: #eee; diff --git a/main/css/dokeos_blue/default.css b/main/css/dokeos_blue/default.css index 253250ba4a..6f89dc9386 100755 --- a/main/css/dokeos_blue/default.css +++ b/main/css/dokeos_blue/default.css @@ -685,7 +685,7 @@ input.liteoption { width: 12%; text-align: left; vertical-align: top; - border: 1px solid #264269; + border: 1px solid #ccc; border-collapse: collapse; background-color: #f5f5f5; } @@ -694,7 +694,7 @@ input.liteoption { width: 12%; text-align: left; vertical-align: top; - border: 1px solid #264269; + border: 1px solid #ccc; border-collapse: collapse; background-color: #e6e6e6; } @@ -703,12 +703,17 @@ input.liteoption { width: 12%; text-align: left; vertical-align: top; - border: 1px solid #264269; + border: 1px solid #ccc; border-collapse: collapse; - background-color: #FFCA8D; - color: #CC3300; - font-weight: bold; + background-color: #FFFFC0; } + +#agenda_list th { + background-color:#E5EDF9; + border:1px solid gray; + padding-right:12px; +} + /* text in the cells: display of agenda items (visible)*/ #agenda_list .data { background-color: #eee; diff --git a/main/css/dokeos_classic/default.css b/main/css/dokeos_classic/default.css index 4c11a63fe8..ae6a60abfe 100755 --- a/main/css/dokeos_classic/default.css +++ b/main/css/dokeos_classic/default.css @@ -743,13 +743,14 @@ input.liteoption { border: 1px solid #264269; border-collapse: collapse; } + /* The cells for the days (1->31) */ #agenda_list .days_week { height: 40px; width: 12%; text-align: left; vertical-align: top; - border: 1px solid #264269; + border: 1px solid #ccc; border-collapse: collapse; background-color: #f5f5f5; } @@ -758,7 +759,7 @@ input.liteoption { width: 12%; text-align: left; vertical-align: top; - border: 1px solid #264269; + border: 1px solid #ccc; border-collapse: collapse; background-color: #e6e6e6; } @@ -767,12 +768,17 @@ input.liteoption { width: 12%; text-align: left; vertical-align: top; - border: 1px solid #264269; + border: 1px solid #ccc; border-collapse: collapse; - background-color: #FFCA8D; - color: #CC3300; - font-weight: bold; + background-color: #FFFFC0; } + +#agenda_list th { + background-color:#E5EDF9; + border:1px solid gray; + padding-right:12px; +} + /* text in the cells: display of agenda items (visible)*/ #agenda_list .data { background-color: #eee; diff --git a/main/css/dokeos_classic_2D/default.css b/main/css/dokeos_classic_2D/default.css index baf6ff8dea..157c27dcb5 100755 --- a/main/css/dokeos_classic_2D/default.css +++ b/main/css/dokeos_classic_2D/default.css @@ -699,32 +699,41 @@ input.liteoption { font-weight: bold; text-align: center; } -#agenda_list .days_week, #agenda_list .days_weekend, #agenda_list .days_today { - border: 1px solid #264269; - border-collapse: collapse; +/* The cells for the days (1->31) */ +#agenda_list .days_week { height: 40px; + width: 12%; text-align: left; vertical-align: top; - width: 12%; -} -/* The cells for the days (1->31) */ -#agenda_list .days_week { + border: 1px solid #ccc; + border-collapse: collapse; background-color: #f5f5f5; } #agenda_list .days_weekend { + height: 40px; + width: 12%; + text-align: left; + vertical-align: top; + border: 1px solid #ccc; + border-collapse: collapse; background-color: #e6e6e6; } #agenda_list .days_today { - background-color: #FFCA8D; - color: #CC3300; - font-weight: bold; -} -#agenda_list .data, #agenda_list .datanotbold, #agenda_list .text, #agenda_list .data_hidden, #agenda_list .datanotbold_hidden, #agenda_list .text_hidden, #agenda_list .datanow, #agenda_list .datanotboldnow, #agenda_list .textnow { - border: 0px solid #4171B5; - border-collapse: collapse; - padding: 2px 10px; + height: 40px; + width: 12%; text-align: left; + vertical-align: top; + border: 1px solid #ccc; + border-collapse: collapse; + background-color: #FFFFC0; +} + +#agenda_list th { + background-color:#E5EDF9; + border:1px solid gray; + padding-right:12px; } + /* text in the cells: display of agenda items (visible)*/ #agenda_list .data { background-color: #eee; diff --git a/main/css/empire_green/default.css b/main/css/empire_green/default.css index 09bfe6d5cd..1c25405afa 100755 --- a/main/css/empire_green/default.css +++ b/main/css/empire_green/default.css @@ -696,7 +696,7 @@ input.liteoption { width: 12%; text-align: left; vertical-align: top; - border: 1px solid #264269; + border: 1px solid #ccc; border-collapse: collapse; background-color: #f5f5f5; } @@ -705,7 +705,7 @@ input.liteoption { width: 12%; text-align: left; vertical-align: top; - border: 1px solid #264269; + border: 1px solid #ccc; border-collapse: collapse; background-color: #e6e6e6; } @@ -714,12 +714,17 @@ input.liteoption { width: 12%; text-align: left; vertical-align: top; - border: 1px solid #264269; + border: 1px solid #ccc; border-collapse: collapse; - background-color: #FFCA8D; - color: #CC3300; - font-weight: bold; + background-color: #FFFFC0; } + +#agenda_list th { + background-color:#E5EDF9; + border:1px solid gray; + padding-right:12px; +} + /* text in the cells: display of agenda items (visible)*/ #agenda_list .data { background-color: #eee; diff --git a/main/css/fruity_orange/default.css b/main/css/fruity_orange/default.css index 96924df2a9..5be0fb7068 100755 --- a/main/css/fruity_orange/default.css +++ b/main/css/fruity_orange/default.css @@ -695,7 +695,7 @@ input.liteoption { width: 12%; text-align: left; vertical-align: top; - border: 1px solid #264269; + border: 1px solid #ccc; border-collapse: collapse; background-color: #f5f5f5; } @@ -704,7 +704,7 @@ input.liteoption { width: 12%; text-align: left; vertical-align: top; - border: 1px solid #264269; + border: 1px solid #ccc; border-collapse: collapse; background-color: #e6e6e6; } @@ -713,12 +713,17 @@ input.liteoption { width: 12%; text-align: left; vertical-align: top; - border: 1px solid #264269; + border: 1px solid #ccc; border-collapse: collapse; - background-color: #FFCA8D; - color: #CC3300; - font-weight: bold; + background-color: #FFFFC0; } + +#agenda_list th { + background-color:#E5EDF9; + border:1px solid gray; + padding-right:12px; +} + /* text in the cells: display of agenda items (visible)*/ #agenda_list .data { background-color: #eee; diff --git a/main/css/medical/default.css b/main/css/medical/default.css index 9abdbcd2e9..e352e86216 100755 --- a/main/css/medical/default.css +++ b/main/css/medical/default.css @@ -782,7 +782,7 @@ input.liteoption { width: 12%; text-align: left; vertical-align: top; - border: 1px solid #264269; + border: 1px solid #ccc; border-collapse: collapse; background-color: #f5f5f5; } @@ -791,7 +791,7 @@ input.liteoption { width: 12%; text-align: left; vertical-align: top; - border: 1px solid #264269; + border: 1px solid #ccc; border-collapse: collapse; background-color: #e6e6e6; } @@ -800,12 +800,17 @@ input.liteoption { width: 12%; text-align: left; vertical-align: top; - border: 1px solid #264269; + border: 1px solid #ccc; border-collapse: collapse; - background-color: #FFCA8D; - color: #CC3300; - font-weight: bold; + background-color: #FFFFC0; } + +#agenda_list th { + background-color:#E5EDF9; + border:1px solid gray; + padding-right:12px; +} + /* text in the cells: display of agenda items (visible)*/ #agenda_list .data { background-color: #eee; diff --git a/main/css/public_admin/default.css b/main/css/public_admin/default.css index 578f9bca72..155abe0d66 100755 --- a/main/css/public_admin/default.css +++ b/main/css/public_admin/default.css @@ -793,7 +793,7 @@ input.liteoption { width: 12%; text-align: left; vertical-align: top; - border: 1px solid #264269; + border: 1px solid #ccc; border-collapse: collapse; background-color: #f5f5f5; } @@ -802,7 +802,7 @@ input.liteoption { width: 12%; text-align: left; vertical-align: top; - border: 1px solid #264269; + border: 1px solid #ccc; border-collapse: collapse; background-color: #e6e6e6; } @@ -811,12 +811,17 @@ input.liteoption { width: 12%; text-align: left; vertical-align: top; - border: 1px solid #264269; + border: 1px solid #ccc; border-collapse: collapse; - background-color: #FFCA8D; - color: #CC3300; - font-weight: bold; + background-color: #FFFFC0; } + +#agenda_list th { + background-color:#E5EDF9; + border:1px solid gray; + padding-right:12px; +} + /* text in the cells: display of agenda items (visible)*/ #agenda_list .data { background-color: #eee; diff --git a/main/css/royal_purple/default.css b/main/css/royal_purple/default.css index eb652660d8..e2e8b9d74d 100755 --- a/main/css/royal_purple/default.css +++ b/main/css/royal_purple/default.css @@ -693,7 +693,7 @@ input.liteoption { width: 12%; text-align: left; vertical-align: top; - border: 1px solid #264269; + border: 1px solid #ccc; border-collapse: collapse; background-color: #f5f5f5; } @@ -702,7 +702,7 @@ input.liteoption { width: 12%; text-align: left; vertical-align: top; - border: 1px solid #264269; + border: 1px solid #ccc; border-collapse: collapse; background-color: #e6e6e6; } @@ -711,12 +711,17 @@ input.liteoption { width: 12%; text-align: left; vertical-align: top; - border: 1px solid #264269; + border: 1px solid #ccc; border-collapse: collapse; - background-color: #FFCA8D; - color: #CC3300; - font-weight: bold; + background-color: #FFFFC0; } + +#agenda_list th { + background-color:#E5EDF9; + border:1px solid gray; + padding-right:12px; +} + /* text in the cells: display of agenda items (visible)*/ #agenda_list .data { background-color: #eee; diff --git a/main/css/silver_line/default.css b/main/css/silver_line/default.css index 753ebf31d5..e658f8d8d0 100755 --- a/main/css/silver_line/default.css +++ b/main/css/silver_line/default.css @@ -830,124 +830,251 @@ div.row div.label { AGENDA ============================================================================== */ - -#agenda_list { +#agenda { + width: 100%; margin: 0 auto; - width: 95%; + border: 1px solid #bbb; + border-collapse: collapse; } -#agenda_list .datanow { - background: #ddd url('images/headertables.jpg') repeat-x top center; - border: 1px solid #ddd; - vertical-align: top; +.agenda_month_divider { + background-color: #dcdcdc; + font-weight: bold; + color: #666; + text-align: center; } -#agenda_list img { - margin-right: .8em; +#agenda .title a { + color: #fff; } -#agenda_list td.data img, #agenda_list td.datanow img { - margin-bottom: -.6em; - margin-top: -.3em; +#agenda .agendaitem { } -#agenda_list td.textnow { - border: 1px solid #bbb; - background-color: #eee; - padding: .5em; +#smallcalendar .title { + background-color: #dcdcdc; + font-weight: bold; + padding: 2px; + color: #666; + text-align: center; + font-size: 11px; } -#agenda_list tr, #agenda_list td { - width: auto; - border: none; +#smallcalendar .title a { + color: #666; } -#agenda_list tr.data, #agenda_list td.data, .data { - background: transparent url('images/headertables.jpg') repeat-x top center; - vertical-align: top; - border: 1px solid #ddd; +#agenda_select { + list-style: none; + border: 0px solid green; + margin: 30px 0 0 0; + padding: 0 0 0 10px; } -#agenda_list tr.text, #agenda_list td.text, .text { - border: 1px solid #ddd; +/* --------------------------------------------------- + styles for the agenda (day, week, month view) +-----------------------------------------------------*/ +#agenda_list { + width: 100%; + margin: 0 auto; + border: 1px solid #fff; + border-collapse: collapse; } -.agenda_month_divider { +/*The caption of the calendar (displays the month and the << and >> links*/ +#agenda_list .title { + background-color: #dcdcdc; + font-weight: bold; + color: #666; + text-align: left; + padding: 2px 10px; text-align: center; - background: #fff url("images/divider2.jpg") no-repeat 50% 1.3em; - height: 2.8em; + border: 1px solid #bbb; } -.agenda_month_divider, .title { - font: bold 1.2em Arial, sans-serif, sans; - color: #4170b4; +#agenda_list .title a:link, #agenda_list #title a:visited { + background-color: #dcdcdc; + font-weight: bold; + font-size: 11px; + color: #666; + padding: 2px 10px; text-align: center; } -#agenda_select img { - margin-right: .2em; +#agenda_list .title a:hover { + background-color: #dcdcdc; + font-weight: bold; + font-size: 11px; + color: #f3840d; + padding: 2px 10px; + text-align: center; } -#agenda_select li { - margin-bottom: .6em; - font: bold 1em Arial, sans-serif, sans; +/* The cells with the name of the days of the weeks (mon->sun)*/ +#agenda_list .weekdays { + background-color: #dcdcdc; + text-align: center; + font-weight: bold; + border: 1px solid #264269; + border-collapse: collapse; } -#agenda_select li a { - font: bold 1em Arial, sans-serif, sans; - text-decoration: none; +/* The cells for the days (1->31) */ +#agenda_list .days_week { + height: 40px; + width: 12%; + text-align: left; + vertical-align: top; + border: 1px solid #ccc; + border-collapse: collapse; + background-color: #f5f5f5; } -.alternativeBgLight { - background-color: #ccc; +#agenda_list .days_weekend { + height: 40px; + width: 12%; + text-align: left; + vertical-align: top; + border: 1px solid #ccc; + border-collapse: collapse; + background-color: #e6e6e6; } -.announcements_datum { - color: #888; - border: 1px solid #ddd; +#agenda_list .days_today { + height: 40px; + width: 12%; + text-align: left; + vertical-align: top; + border: 1px solid #ccc; + border-collapse: collapse; + background-color: #FFFFC0; +} + +#agenda_list th { + background-color:#E5EDF9; + border:1px solid gray; + padding-right:12px; +} + +/* text in the cells: display of agenda items (visible)*/ +#agenda_list .data { background-color: #eee; + text-align: left; + padding: 2px 10px; + font-weight: bold; + border: 0px solid #dcdcdc; + border-collapse: collapse; } -.data, .announcements_datum, .datanow { - font: bold 1em Arial, sans-serif, sans; +#agenda_list .datanotbold { + background-color: #eee; + text-align: left; + padding: 2px 10px; + font-weight: normal; + border: 0px solid #dcdcdc; + border-collapse: collapse; } -.datanotbold { +#agenda_list .text { + background-color: #fff; + text-align: left; + padding: 2px 10px; font-weight: normal; + border: 0px solid #dcdcdc; + border-collapse: collapse; } -span.agendaitem { - text-align: center; - display: block; - font-size: 95%; - width: 90%; - margin: 0 auto; - font-size: .9em; +/*text in the cells: display of agenda items (invisible)*/ +#agenda_list .data_hidden { + background-color: #eee; + text-align: left; + padding: 2px 10px; + font-weight: bold; + border: 0px solid #dcdcdc; + border-collapse: collapse; + color: #999999; } -span.agendaitem i { - font: bold 97% Arial, sans-serif, sans; - color: #a9a; +#agenda_list .datanotbold_hidden { + background-color: #eee; + text-align: left; + padding: 2px 10px; + font-weight: normal; + border: 0px solid #dcdcdc; + border-collapse: collapse; + color: #999999; } -/* Calendar */ -.days_today { - font: bold 1em Arial, sans-serif, sans; - text-decoration: none; - color: #667; +#agenda_list .text_hidden { + background-color: #fff; + text-align: left; + padding: 2px 10px; + font-weight: normal; + border: 0px solid #dcdcdc; + border-collapse: collapse; + color: #999999; } -.days_week { - background-color: #ccc; +/*text in the cells: display of agenda items (highlighted)*/ +#agenda_list .datanow { + background-color: #FFCC00; + text-align: left; + padding: 2px 10px; + font-weight: bold; + border: 0px solid #dcdcdc; + border-collapse: collapse; } -.days_week, .days_weekend, .days_today { - text-align: center; +#agenda_list .datanotboldnow { + background-color: #FFCC00; + text-align: left; + padding: 2px 10px; + font-weight: normal; + border: 0px solid #dcdcdc; + border-collapse: collapse; } -.days_week a, .days_weekend a { - font: bold 1em Arial, sans-serif, sans; +#agenda_list .textnow { + background-color: #fff; + text-align: left; + padding: 2px 10px; + font-weight: normal; + border: 0px solid #dcdcdc; + border-collapse: collapse; } -.days_weekend { - background-color: #aaa; +/* --------------------------------------------------- + styles for the mini agenda +-----------------------------------------------------*/ +#smallcalendar { + width: 100%; + margin: 0 auto; + border: 1px solid #fff; + border-collapse: collapse; } -.days_weekend .agendaitem i { - color: #444; +#smallcalendar .weekdays { + background-color: #dcdcdc; + text-align: center; + font-size: 11px; + font-weight: bold; + border: 1px solid #fff; + border-collapse: collapse; } -#newedit_form tr.title { - background:none; - text-align:left; +#smallcalendar .days_week { + background-color: #f5f5f5; + text-align: center; + font-size: 11px; + border-collapse: collapse; } -.title { - background: #ddd url('images/headertables.jpg') repeat-x top center; +#smallcalendar .days_weekend { + background-color: #e6e6e6; + text-align: center; + font-size: 11px; + border: 1px solid #fff; + border-collapse: collapse; } -.weekdays { - font: bold 1.1em Arial, sans-serif, sans; - color: #fff; - background-color: #667; +#smallcalendar .days_today { + width: 12%; text-align: center; + font-size: 11px; + border: 1px solid #FA8500; + border-collapse: collapse; + background-color: #FFCA8D; } -.ical_export { - float: right; - margin-top: 0.2em; +/* --------------------------------------------------- + styles for the personal agenda +-----------------------------------------------------*/ +.personal_agenda { + color: #008000; +} +.personal_agenda a:link, .personal_agenda a:visited { + color: #008000; +} +a.personal_agenda:link, a.personal_agenda:visited { + color: #008000; +} +.personal_agenda a:hover, .personal_agenda a:hover { + color: #666666; +} +a.personal_agenda:hover, a.personal_agenda:hover { + color: #666666; } /* ============================================================================== diff --git a/main/css/sober_brown/default.css b/main/css/sober_brown/default.css index 27c213f015..4e959d538a 100755 --- a/main/css/sober_brown/default.css +++ b/main/css/sober_brown/default.css @@ -766,7 +766,7 @@ input.liteoption { width: 12%; text-align: left; vertical-align: top; - border: 1px solid #264269; + border: 1px solid #ccc; border-collapse: collapse; background-color: #f5f5f5; } @@ -775,7 +775,7 @@ input.liteoption { width: 12%; text-align: left; vertical-align: top; - border: 1px solid #264269; + border: 1px solid #ccc; border-collapse: collapse; background-color: #e6e6e6; } @@ -784,37 +784,17 @@ input.liteoption { width: 12%; text-align: left; vertical-align: top; - border: 1px solid #264269; - border-collapse: collapse; - background-color: #FFCA8D; - color: #CC3300; - font-weight: bold; -} -/* text in the cells: display of agenda items (visible)*/ -#agenda_list .data { - background-color: #eee; - text-align: left; - padding: 2px 10px; - font-weight: bold; - border: 0px solid #dcdcdc; - border-collapse: collapse; -} -#agenda_list .datanotbold { - background-color: #eee; - text-align: left; - padding: 2px 10px; - font-weight: normal; - border: 0px solid #dcdcdc; + border: 1px solid #ccc; border-collapse: collapse; + background-color: #FFFFC0; } -#agenda_list .text { - background-color: #fff; - text-align: left; - padding: 2px 10px; - font-weight: normal; - border: 0px solid #dcdcdc; - border-collapse: collapse; + +#agenda_list th { + background-color:#E5EDF9; + border:1px solid gray; + padding-right:12px; } + /*text in the cells: display of agenda items (invisible)*/ #agenda_list .data_hidden { background-color: #eee; diff --git a/main/css/steel_grey/default.css b/main/css/steel_grey/default.css index 6fd1d14d29..08abb84f24 100755 --- a/main/css/steel_grey/default.css +++ b/main/css/steel_grey/default.css @@ -698,7 +698,7 @@ input.liteoption { width: 12%; text-align: left; vertical-align: top; - border: 1px solid #264269; + border: 1px solid #ccc; border-collapse: collapse; background-color: #f5f5f5; } @@ -707,7 +707,7 @@ input.liteoption { width: 12%; text-align: left; vertical-align: top; - border: 1px solid #264269; + border: 1px solid #ccc; border-collapse: collapse; background-color: #e6e6e6; } @@ -716,12 +716,17 @@ input.liteoption { width: 12%; text-align: left; vertical-align: top; - border: 1px solid #264269; + border: 1px solid #ccc; border-collapse: collapse; - background-color: #FFCA8D; - color: #CC3300; - font-weight: bold; + background-color: #FFFFC0; } + +#agenda_list th { + background-color:#E5EDF9; + border:1px solid gray; + padding-right:12px; +} + /* text in the cells: display of agenda items (visible)*/ #agenda_list .data { background-color: #eee; diff --git a/main/css/tasty_olive/default.css b/main/css/tasty_olive/default.css index 4da454f56d..5b0f8b330d 100755 --- a/main/css/tasty_olive/default.css +++ b/main/css/tasty_olive/default.css @@ -695,7 +695,7 @@ input.liteoption { width: 12%; text-align: left; vertical-align: top; - border: 1px solid #264269; + border: 1px solid #ccc; border-collapse: collapse; background-color: #f5f5f5; } @@ -704,7 +704,7 @@ input.liteoption { width: 12%; text-align: left; vertical-align: top; - border: 1px solid #264269; + border: 1px solid #ccc; border-collapse: collapse; background-color: #e6e6e6; } @@ -713,12 +713,17 @@ input.liteoption { width: 12%; text-align: left; vertical-align: top; - border: 1px solid #264269; + border: 1px solid #ccc; border-collapse: collapse; - background-color: #FFCA8D; - color: #CC3300; - font-weight: bold; + background-color: #FFFFC0; } + +#agenda_list th { + background-color:#E5EDF9; + border:1px solid gray; + padding-right:12px; +} + /* text in the cells: display of agenda items (visible)*/ #agenda_list .data { background-color: #eee; From 47f8118c47b2a0628b04e7ff1ec9174cadd9c4ff Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Tue, 18 May 2010 17:11:31 +0200 Subject: [PATCH 28/63] Minor - cleaning code --- main/inc/lib/groupmanager.lib.php | 36 +++++++++++++++---------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/main/inc/lib/groupmanager.lib.php b/main/inc/lib/groupmanager.lib.php index bddc3288bc..9d2b821075 100755 --- a/main/inc/lib/groupmanager.lib.php +++ b/main/inc/lib/groupmanager.lib.php @@ -1292,15 +1292,14 @@ class GroupManager { $user_id = Database::escape_string($user_id); $sql = "SELECT tutor_id FROM ".$course_user_table." - WHERE `user_id`='".$user_id."' - AND `course_code`='".$_course['sysCode']."'"."AND tutor_id=1"; + WHERE user_id='".$user_id."' AND course_code='".$_course['sysCode']."'"."AND tutor_id=1"; $db_result = Database::query($sql); $result = (Database::num_rows($db_result) > 0); return $result; } /** - * Get all group's from a given course in which a given user is ubscribed + * Get all group's from a given course in which a given user is unsubscribed * @author Patrick Cool * @param string $course_db: the database of the course you want to * retrieve the groups for @@ -1308,22 +1307,21 @@ class GroupManager { * group memberships */ public static function get_group_ids ($course_db,$user_id) { - $groups = array(); - $tbl_group = Database::get_course_table(TABLE_GROUP_USER,$course_db); - $user_id = Database::escape_string($user_id); - $sql = "SELECT group_id FROM $tbl_group WHERE user_id = '$user_id'"; - $groupres = Database::query($sql); - - // uncommenting causes a bug in Agenda AND announcements because there we check if the return value of this function is an array or not - //$groups=array(); - - if($groupres) - { - while ($myrow= Database::fetch_array($groupres)) - $groups[]=$myrow['group_id']; - } - - return $groups; + $groups = array(); + $tbl_group = Database::get_course_table(TABLE_GROUP_USER,$course_db); + $user_id = Database::escape_string($user_id); + $sql = "SELECT group_id FROM $tbl_group WHERE user_id = '$user_id'"; + $groupres = Database::query($sql); + + // uncommenting causes a bug in Agenda AND announcements because there we check if the return value of this function is an array or not + //$groups=array(); + + if($groupres) { + while ($myrow= Database::fetch_array($groupres)) + $groups[]=$myrow['group_id']; + } + + return $groups; } /* ----------------------------------------------------------- From f6388391d16bb0020484548fb0b5344754ee7774 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Tue, 18 May 2010 17:17:32 +0200 Subject: [PATCH 29/63] More cleaning code, removing global variables in some functions --- main/calendar/agenda.inc.php | 83 ++++++++++++++---------------------- main/calendar/agenda.php | 23 +++++----- 2 files changed, 42 insertions(+), 64 deletions(-) diff --git a/main/calendar/agenda.inc.php b/main/calendar/agenda.inc.php index c48bbc3033..9fe0bcdb91 100755 --- a/main/calendar/agenda.inc.php +++ b/main/calendar/agenda.inc.php @@ -1,5 +1,4 @@ - cleanup * @author Julio Montoya - More cleanup */ -function display_agenda_items() { - +function display_agenda_items($select_month, $select_year) { $TABLEAGENDA = Database::get_course_table(TABLE_AGENDA); $TABLE_ITEM_PROPERTY = Database::get_course_table(TABLE_ITEM_PROPERTY); - - global $select_month, $select_year; - global $DaysShort, $DaysLong, $MonthsLong; - global $is_courseAdmin; - global $dateFormatLong, $timeNoSecFormat,$charset, $_user, $_course; + //not used in the function + //global $DaysShort, $DaysLong, $MonthsLong; + //global $is_courseAdmin; + //global $dateFormatLong, $timeNoSecFormat,$charset, $_user, $_course; + global $charset, $_user, $_course; // getting the group memberships - $group_memberships = GroupManager::get_group_ids($_course['dbName'],$_user['user_id']); + $group_memberships = GroupManager::get_group_ids($_course['dbName'],api_get_user_id()); // getting the name of the groups $group_names = get_course_groups(); - - /* - CONSTRUCT THE SQL STATEMENT - */ + /* CONSTRUCT THE SQL STATEMENT */ $start = 0; $stop = 0; // this is to make a difference between showing everything (all months) or only the current month) // $show_all_current is a part of the sql statement - if ($_SESSION['show']!=="showall") { + if ($_SESSION['show']!=='showall') { $show_all_current=" AND MONTH(start_date)=$select_month AND year(start_date)=$select_year"; $start = mktime(0,0,0,$select_month,1,$select_year); $stop = 0; - if(empty($select_year)){$select_year = date('Y');} - if(empty($select_month)){$select_month = date('m');} - if($select_month==12) { + if (empty($select_year)) { $select_year = date('Y');} + if (empty($select_month)) { $select_month = date('m');} + if ($select_month==12) { $stop = mktime(0,0,0,1,1,$select_year+1)-1; } else { $stop = mktime(0,0,0,$select_month+1,1,$select_year)-1; @@ -1943,13 +1938,10 @@ function display_agenda_items() { ORDER BY start_date ".$_SESSION['sort']; } */ - } } } - } //if (is_allowed_to_edit() OR( api_get_course_setting('allow_user_edit_agenda') && !api_is_anonymous())) - // B. you are a student else { if (is_array($group_memberships) and count($group_memberships)>0) { @@ -1988,19 +1980,16 @@ function display_agenda_items() { } // you are a student //echo "
".$sql."
"; - $result=Database::query($sql) or die(Database::error()); - $number_items=Database::num_rows($result); + $result = Database::query($sql); + $number_items = Database::num_rows($result); - /* - DISPLAY: NO ITEMS - */ + /* DISPLAY: NO ITEMS */ + if ($number_items==0) { - echo "
'.Display::return_icon('action_prev.png',get_lang('Previous')).''.$monthName." ".$year.''.Display::return_icon('action_next.png',get_lang('Next')).'
", $DaysShort[$ii % 7], "'.$DaysShort[$ii % 7].'
".get_lang("NoAgendaItems")."
"; + echo "
".get_lang('NoAgendaItems')."
"; } - /* - DISPLAY: THE ITEMS - */ + /* DISPLAY: THE ITEMS */ $month_bar=""; $event_list=""; @@ -2024,30 +2013,22 @@ function display_agenda_items() { "
'.get_lang('Modify'); echo '
".get_lang("StartTimeWindow").": "; echo api_format_date($myrow['start_date']); @@ -2100,9 +2079,9 @@ function display_agenda_items() { // attachment list $attachment_list=get_attachment($myrow['id']); - /*-------------------------------------------------- + /* display: edit delete button (course admin only) - --------------------------------------------------*/ + */ if (!$is_repeated && (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_edit_agenda') && !api_is_anonymous()))) { diff --git a/main/calendar/agenda.php b/main/calendar/agenda.php index 399a106301..eabecc115f 100755 --- a/main/calendar/agenda.php +++ b/main/calendar/agenda.php @@ -332,15 +332,14 @@ if (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_ed display_ical_import_form(); break; } - display_agenda_items(); - } - else { + display_agenda_items($select_month, $select_year); + } else { display_ical_import_form(); } break; case 'add' : if ($_POST['submit_event']) { - display_agenda_items(); + display_agenda_items($select_month, $select_year); } else { show_add_form(); } @@ -348,42 +347,42 @@ if (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_ed case 'edit' : if ( !(api_is_course_coach() && !api_is_element_in_the_session(TOOL_AGENDA, intval($_REQUEST['id'])))) { if ($_POST['submit_event']) { - display_agenda_items(); + display_agenda_items($select_month, $select_year); } else { $id=(int)$_GET['id']; show_add_form($id); } } else { - display_agenda_items(); + display_agenda_items($select_month, $select_year); } break; case 'delete': - display_agenda_items(); + display_agenda_items($select_month, $select_year); break; case 'showhide': if(!empty($_GET['agenda_id'])) { display_one_agenda_item((int)$_GET['agenda_id']); } else { - display_agenda_items(); + display_agenda_items($select_month, $select_year); } break; case 'announce': - display_agenda_items(); + display_agenda_items($select_month, $select_year); break; case 'delete_attach': - display_agenda_items(); + display_agenda_items($select_month, $select_year); break; } } // this is for students and whenever the courseaministrator has not chosen any action. It is in fact the default behaviour -if (!$_GET['action'] || $_GET['action']=="showall" || $_GET['action']=="showcurrent" || $_GET['action']=="view") { +if (!$_GET['action'] || $_GET['action']=='showall' || $_GET['action']=='showcurrent' || $_GET['action']=="view") { if ($_GET['origin'] != 'learnpath') { if (!$_SESSION['view'] || $_SESSION['view'] <> 'month') { if(!empty($_GET['agenda_id'])) { display_one_agenda_item($_GET['agenda_id']); } else { - display_agenda_items(); + display_agenda_items($select_month, $select_year); } } else { display_monthcalendar($select_month, $select_year); From 2d8cc8f0894d6e32beff7e31d20aa97944837edd Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Tue, 18 May 2010 18:46:18 +0200 Subject: [PATCH 30/63] Minor - cleaning code --- main/calendar/agenda.inc.php | 209 +++++++++++++++++++---------------- 1 file changed, 112 insertions(+), 97 deletions(-) diff --git a/main/calendar/agenda.inc.php b/main/calendar/agenda.inc.php index 9fe0bcdb91..e5b696f4d5 100755 --- a/main/calendar/agenda.inc.php +++ b/main/calendar/agenda.inc.php @@ -392,7 +392,7 @@ function display_monthcalendar($month, $year) { echo ''; echo ''; echo ''; - echo ''; + echo ''; echo ''; echo ''; @@ -428,6 +428,7 @@ function display_monthcalendar($month, $year) { $start_time = api_convert_and_format_date($value['start_date'], TIME_NO_SEC_FORMAT, date_default_timezone_get()); $end_time = api_convert_and_format_date($value['end_date'], TIME_NO_SEC_FORMAT, date_default_timezone_get()); + //Setting a personal event to green $personal_start = $personal_end = ''; if ($value['calendar_type'] == 'personal') { @@ -1716,18 +1717,15 @@ function delete_agenda_item($id) * @author Patrick Cool , Ghent University * @param integer id the id of the agenda item we are changing the visibility of */ -function showhide_agenda_item($id) -{ +function showhide_agenda_item($id) { global $nameTools; - /*================================================== + /* SHOW / HIDE A CALENDAR ITEM - ==================================================*/ + */ // and $_GET['isStudentView']<>"false" is added to prevent that the visibility is changed after you do the following: // change visibility -> studentview -> course manager view - if ((api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_edit_agenda') && !api_is_anonymous())) and $_GET['isStudentView']<>"false") - { - if (isset($_GET['id']) && isset($_GET['action']) && $_GET['action']=="showhide") - { + if ((api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_edit_agenda') && !api_is_anonymous())) and $_GET['isStudentView']<>"false") { + if (isset($_GET['id']) && isset($_GET['action']) && $_GET['action']=="showhide") { $id=(int)addslashes($_GET['id']); if (isset($_GET['next_action']) && $_GET['next_action'] == strval(intval($_GET['next_action']))) { $visibility = $_GET['next_action']; @@ -1761,10 +1759,14 @@ function display_agenda_items($select_month, $select_year) { $start = 0; $stop = 0; + $select_month = intval($select_month); + $select_year = intval($select_year); // this is to make a difference between showing everything (all months) or only the current month) // $show_all_current is a part of the sql statement if ($_SESSION['show']!=='showall') { - $show_all_current=" AND MONTH(start_date)=$select_month AND year(start_date)=$select_year"; + $show_all_current =" AND MONTH(start_date)=$select_month AND year(start_date)=$select_year"; + $show_all_current_personal =" AND MONTH(date)=$select_month AND year(date)=$select_year"; + $start = mktime(0,0,0,$select_month,1,$select_year); $stop = 0; if (empty($select_year)) { $select_year = date('Y');} @@ -1775,7 +1777,8 @@ function display_agenda_items($select_month, $select_year) { $stop = mktime(0,0,0,$select_month+1,1,$select_year)-1; } } else { - $show_all_current=""; + $show_all_current=''; + $show_all_current_personal = ''; $start = time(); $stop = mktime(0,0,0,1,1,2038);//by default, set year to maximum for mktime() } @@ -1997,8 +2000,28 @@ function display_agenda_items($select_month, $select_year) { $export_icon = 'export.png'; $export_icon_low = 'export_low_fade.png'; $export_icon_high = 'export_high_fade.png'; + + $my_events = array(); + while($myrow = Database::fetch_array($result)) { + $myrow['calendar_type'] = 'course'; + $my_events[] = $myrow; + } - while($myrow=Database::fetch_array($result)) { + //Check my personal calendar items + if (api_get_setting('allow_personal_agenda') == 'true') { + $tbl_personal_agenda = Database :: get_user_personal_table(TABLE_PERSONAL_AGENDA); + // 1. creating the SQL statement for getting the personal agenda items in MONTH view + $sql = "SELECT id, title, text as content , date as start_date, enddate as end_date, parent_event_id FROM ".$tbl_personal_agenda." + WHERE user='".api_get_user_id()."' ".$show_all_current_personal." ORDER BY date ASC"; + $result = Database::query($sql); + while ($row = Database::fetch_array($result, 'ASSOC')) { + $row['calendar_type'] = 'personal'; + $my_events[] = $row; + } + } + + //while($myrow = Database::fetch_array($result)) { + foreach ($my_events as $myrow) { $is_repeated = !empty($myrow['parent_event_id']); echo '
'.Display::return_icon('action_prev.png',get_lang('Previous')).''.$MonthsLong[$maand_array_maandnummer].$year.''.$MonthsLong[$maand_array_maandnummer].' '.$year.' '.Display::return_icon('action_next.png',get_lang('Next')).'
'; /* @@ -2008,9 +2031,10 @@ function display_agenda_items($select_month, $select_year) { $myrow["start_date"] = api_get_local_time($myrow["start_date"], null, date_default_timezone_get()); if ($month_bar != api_format_date($myrow["start_date"], "%m%Y")) { $month_bar = api_format_date($myrow["start_date"], "%m%Y"); - echo ""; + //Showing month header + echo ''; } /* display: the icon, title, destinees of the item */ @@ -2040,20 +2064,31 @@ function display_agenda_items($select_month, $select_year) { // the icons. If the message is sent to one or more specific users/groups // we add the groups icon // 2do: if it is sent to groups we display the group icon, if it is sent to a user we show the user icon - Display::display_icon('agenda.gif', get_lang('Agenda')); - if ($myrow['to_group_id']!=='0') { - echo Display::return_icon('group.gif', get_lang('ItemForUserSelection')); - } - echo $myrow['title']; - echo ""; - - // the message has been sent to - echo ""; - + if ($myrow['calendar_type'] != 'personal') { + echo '
'; + Display::display_icon('agenda.gif', get_lang('Agenda')); + if ($myrow['to_group_id']!=='0') { + echo Display::return_icon('group.gif', get_lang('ItemForUserSelection')); + } + echo $myrow['title']; + echo '
'; + } else { + Display::display_icon('calendar_personal.gif', get_lang('Personal')); + echo $myrow['title']; + } + echo ''; + + if ($myrow['calendar_type'] != 'personal') { + // the message has been sent to + echo "'; + } else { + echo ''; + } + if (!$is_repeated && (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_edit_agenda') && !api_is_anonymous()))) { if( ! (api_is_course_coach() && !api_is_element_in_the_session(TOOL_AGENDA, $myrow['id'] ) ) ) { // a coach can only delete an element belonging to his session @@ -2062,35 +2097,30 @@ function display_agenda_items($select_month, $select_year) { } } - /* - display: the title - */ - echo ""; - echo "'; + echo '"; - echo "'; + echo '"; + echo ''; // attachment list - $attachment_list=get_attachment($myrow['id']); - - /* - display: edit delete button (course admin only) - */ + $attachment_list=get_attachment($myrow['id']); - - if (!$is_repeated && (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_edit_agenda') && !api_is_anonymous()))) { + /*Display: edit delete button (course admin only) */ + if (!$is_repeated && (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_edit_agenda') && !api_is_anonymous())) && $myrow['calendar_type'] != 'personal') { if( ! (api_is_course_coach() && !api_is_element_in_the_session(TOOL_AGENDA, $myrow['id'] ) ) ) { // a coach can only delete an element belonging to his session $mylink = api_get_self().'?'.api_get_cidreq().'&origin='.Security::remove_XSS($_GET['origin']).'&id='.$myrow['id'].'&'; echo ''; - echo ''; -} + if (!$is_repeated && (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_edit_agenda') && !api_is_anonymous()))) { + if( ! (api_is_course_coach() && !api_is_element_in_the_session(TOOL_AGENDA, $myrow['id'] ) ) ) { + // a coach can only delete an element belonging to his session + $td_colspan= ''; + } else { + echo ''; + } + echo ''; - /*-------------------------------------------------- - display: the content - --------------------------------------------------*/ + /* display: the content */ $content = $myrow['content']; $content = make_clickable($content); $content = text_filter($content); - echo ""; - echo "'; + echo ''; - - /*-------------------------------------------------- - display: the added resources - --------------------------------------------------*/ - if (check_added_resources("Agenda", $myrow["id"])) - { - + /* display: the added resources */ + if (check_added_resources("Agenda", $myrow["id"])) { echo ''; echo '"; - } - - + } $event_list.=$myrow['id'].','; - $counter++; - /*-------------------------------------------------- - display: jump-to-top icon - --------------------------------------------------*/ + /* display: jump-to-top icon */ echo ''; echo '"; echo "
". - api_format_date($myrow["start_date"], "%B %Y"). - "
'; + echo api_format_date($myrow["start_date"], "%B %Y"); + echo '
".get_lang("SentTo").": "; - $sent_to=sent_to(TOOL_CALENDAR_EVENT, $myrow["ref"]); - $sent_to_form=sent_to_form($sent_to); - echo $sent_to_form; - echo "".get_lang('SentTo').": "; + $sent_to=sent_to(TOOL_CALENDAR_EVENT, $myrow["ref"]); + $sent_to_form=sent_to_form($sent_to); + echo $sent_to_form; + echo ''.get_lang('Personal').'
".get_lang("StartTimeWindow").": "; + /* display: the title */ + echo '
'.get_lang('StartTimeWindow').': '; echo api_format_date($myrow['start_date']); - echo ""; - if ($myrow["end_date"]<>"0000-00-00 00:00:00") { - echo get_lang("EndTimeWindow").": "; + echo ''; + + if ($myrow['end_date']<>'0000-00-00 00:00:00') { + echo get_lang('EndTimeWindow').": "; echo api_convert_and_format_date($myrow['end_date'], null, date_default_timezone_get()); } - echo "'; - // edit + // edit echo ''; echo Display::return_icon('edit.gif', get_lang('ModifyCalendarItem')).""; @@ -2112,38 +2142,38 @@ function display_agenda_items($select_month, $select_year) { echo ''.Display::return_icon($image_visibility, $text_visibility),' '; } - if (!$is_repeated && (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_edit_agenda') && !api_is_anonymous()))) { - if( ! (api_is_course_coach() && !api_is_element_in_the_session(TOOL_AGENDA, $myrow['id'] ) ) ) - { // a coach can only delete an element belonging to his session - $td_colspan= ''; - } else { - $td_colspan= ''; - } - } else { - $td_colspan= ''; - } - $mylink = 'ical_export.php?'.api_get_cidreq().'&type=course&id='.$myrow['id']; - //echo ''.Display::return_icon($export_icon_high, get_lang('ExportiCalConfidential')).' '; - //echo ''.Display::return_icon($export_icon_low, get_lang('ExportiCalPrivate')).' '; - //echo ''.Display::return_icon($export_icon, get_lang('ExportiCalPublic')).' '; - echo ''.Display::return_icon('print.gif', get_lang('Print')).' '; - echo '
'; + } else { + $td_colspan= ''; + } + } else { + $td_colspan= ''; + } + $mylink = 'ical_export.php?'.api_get_cidreq().'&type=course&id='.$myrow['id']; + //echo ''.Display::return_icon($export_icon_high, get_lang('ExportiCalConfidential')).' '; + //echo ''.Display::return_icon($export_icon_low, get_lang('ExportiCalPrivate')).' '; + //echo ''.Display::return_icon($export_icon, get_lang('ExportiCalPublic')).' '; + echo ''.Display::return_icon('print.gif', get_lang('Print')).' '; + echo ''; + echo '
"; - + + echo '
'; echo $content; // show attachment list if (!empty($attachment_list)) { - $realname=$attachment_list['path']; $user_filename=$attachment_list['filename']; $full_file_name = 'download.php?file='.$realname; @@ -2154,52 +2184,37 @@ function display_agenda_items($select_month, $select_year) { if (api_is_allowed_to_edit()) { echo '  '.Display::return_icon('delete.gif',get_lang('Delete')).'
'; } - } - echo '
'; echo "".get_lang("AddedResources")."
"; - if ($myrow['visibility']==0) - { + if ($myrow['visibility']==0) { $addedresource_style="invisible"; } display_added_resources("Agenda", $myrow["id"], $addedresource_style); echo "
'; - if($is_repeated){echo get_lang('RepeatedEvent'),' ',get_lang('RepeatedEventViewOriginalEvent'),'';} + if ($is_repeated) { + echo get_lang('RepeatedEvent'),' ',get_lang('RepeatedEventViewOriginalEvent'),''; + } echo "".Display::return_icon('top.gif', get_lang('Top'))."


"; } // end while ($myrow=Database::fetch_array($result)) - if(!empty($event_list)) - { + if(!empty($event_list)) { $event_list=api_substr($event_list,0,-1); - } - else - { + } else { $event_list='0'; } - echo "
"; // closing the layout table From 539093eb0e00605882b2d34e4921fed4ea53d6af Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Tue, 18 May 2010 19:06:19 +0200 Subject: [PATCH 31/63] More code cleaning --- main/calendar/agenda.inc.php | 43 ++++++++++++++++-------------- main/calendar/myagenda.inc.php | 48 ++++++++++++++-------------------- 2 files changed, 43 insertions(+), 48 deletions(-) diff --git a/main/calendar/agenda.inc.php b/main/calendar/agenda.inc.php index e5b696f4d5..f98eaa4ab1 100755 --- a/main/calendar/agenda.inc.php +++ b/main/calendar/agenda.inc.php @@ -731,17 +731,16 @@ function plus_ical() { * @author: Patrick Cool , Ghent University * @return javascript code */ -function user_group_filter_javascript() -{ -return " -"; +function user_group_filter_javascript() { + return " + "; } @@ -1457,10 +1456,9 @@ function change_visibility($tool,$id,$visibility) function display_courseadmin_links() { //echo "".Display::return_icon('calendar_add.gif', get_lang('AgendaAdd'))." ".get_lang('AgendaAdd').""; echo "".Display::return_icon('calendar_add.gif', get_lang('AgendaAdd'))." ".get_lang('AgendaAdd').""; - if (empty ($_SESSION['toolgroup'])) - { + if (empty ($_SESSION['toolgroup'])) { echo get_lang('UserGroupFilter'); - echo "
"; + echo "  "; show_user_group_filter_form(); echo "
"; } @@ -2065,16 +2063,19 @@ function display_agenda_items($select_month, $select_year) { // we add the groups icon // 2do: if it is sent to groups we display the group icon, if it is sent to a user we show the user icon if ($myrow['calendar_type'] != 'personal') { - echo '
'; - Display::display_icon('agenda.gif', get_lang('Agenda')); + + Display::display_icon('agenda.gif', get_lang('Agenda')); if ($myrow['to_group_id']!=='0') { echo Display::return_icon('group.gif', get_lang('ItemForUserSelection')); } + echo ''; echo $myrow['title']; - echo '
'; + echo ''; } else { - Display::display_icon('calendar_personal.gif', get_lang('Personal')); - echo $myrow['title']; + Display::display_icon('calendar_personal.gif', get_lang('Personal')); + echo ''; + echo $myrow['title']; + echo ''; } echo ''; @@ -2089,12 +2090,14 @@ function display_agenda_items($select_month, $select_year) { echo '
'.get_lang('Personal').''.get_lang('Modify'); echo '
"; + echo '
'; - if (Database::num_rows($result) > 0) - { - while ($myrow = Database::fetch_array($result)) - { - /*-------------------------------------------------- - display: the month bar - --------------------------------------------------*/ - if ($month_bar != date("m", strtotime($myrow["date"])).date("Y", strtotime($myrow["date"]))) - { + if (Database::num_rows($result) > 0) { + while ($myrow = Database::fetch_array($result)) { + /* display: the month bar */ + if ($month_bar != date("m", strtotime($myrow["date"])).date("Y", strtotime($myrow["date"]))) { $month_bar = date("m", strtotime($myrow["date"])).date("Y", strtotime($myrow["date"])); echo ""; } // highlight: if a date in the small calendar is clicked we highlight the relevant items $db_date = (int) date("d", strtotime($myrow["date"])).date("n", strtotime($myrow["date"])).date("Y", strtotime($myrow["date"])); - if ($_GET["day"].$_GET["month"].$_GET["year"] <> $db_date) - { + if ($_GET["day"].$_GET["month"].$_GET["year"] <> $db_date) { $style = "data"; $text_style = "text"; - } - else - { + } else { $style = "datanow"; $text_style = "text"; } + + /* display: the title */ + + echo ""; + echo '"; + echo ""; + /*-------------------------------------------------- display: date and time --------------------------------------------------*/ @@ -754,14 +753,7 @@ function show_personal_agenda() { //echo ''.Display::return_icon($export_icon, get_lang('ExportiCalPublic')).''; //echo ""; echo ""; - /*-------------------------------------------------- - display: the title - --------------------------------------------------*/ - echo ""; - echo '"; - echo ""; + /*-------------------------------------------------- display: the content --------------------------------------------------*/ From c6918067d2a12af2c18aed562707bc3c1c3503a8 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Tue, 18 May 2010 19:28:58 +0200 Subject: [PATCH 32/63] Personal agenda events don't have end date --- main/calendar/agenda.inc.php | 48 ++++++++++++++++++++---------------- 1 file changed, 27 insertions(+), 21 deletions(-) diff --git a/main/calendar/agenda.inc.php b/main/calendar/agenda.inc.php index f98eaa4ab1..fbe74e3ba0 100755 --- a/main/calendar/agenda.inc.php +++ b/main/calendar/agenda.inc.php @@ -374,7 +374,7 @@ function display_monthcalendar($month, $year) { // Grabbing all the calendar items for this year and storing it in a array + my personal calendar events if exist and if enabled $data = get_calendar_items($month,$year); - + //Handle leap year $numberofdays = array(0,31,28,31,30,31,30,31,31,30,31,30,31); if (($year%400 == 0) or ($year%4==0 and $year%100<>0)) $numberofdays[2] = 29; @@ -387,7 +387,7 @@ function display_monthcalendar($month, $year) { $backwardsURL = api_get_self()."?".api_get_cidreq()."&origin=$origin&month=".($month==1 ? 12 : $month-1)."&year=".($month==1 ? $year-1 : $year); $forewardsURL = api_get_self()."?".api_get_cidreq()."&origin=$origin&month=".($month==12 ? 1 : $month+1)."&year=".($month==12 ? $year+1 : $year); - $maand_array_maandnummer=$month-1; + $maand_array_maandnummer=$month-1; echo '
".$MonthsLong[date("n", strtotime($myrow["date"])) - 1]." ".date("Y", strtotime($myrow["date"]))."
'; + echo $myrow['title']; + echo "
'; - echo $myrow['title']; - echo "
'; echo ''; @@ -418,32 +418,38 @@ function display_monthcalendar($month, $year) { $bgcolor = $ii<5 ? 'class="row_odd"' : 'class="row_even"'; $dayheader = "$curday"; - if (key_exists($curday, $data)) { - foreach ($data[$curday] as $key=>$agenda_item) { - foreach ($agenda_item as $key=>$value) { - $month_start_date = (int)substr($value['start_date'],5,2); - $start_time = api_convert_and_format_date($value['start_date']); + if (key_exists($curday, $data)) { + foreach ($data[$curday] as $key=>$agenda_item) { + $dayheader ="".$curday.""; + foreach ($agenda_item as $key=>$value) { + + $month_start_date = (int)substr($value['start_date'],5,2); + $start_time = api_convert_and_format_date($value['start_date']); + + if ($month == $month_start_date) { $start_time = api_convert_and_format_date($value['start_date'], TIME_NO_SEC_FORMAT, date_default_timezone_get()); $end_time = api_convert_and_format_date($value['end_date'], TIME_NO_SEC_FORMAT, date_default_timezone_get()); //Setting a personal event to green - $personal_start = $personal_end = ''; - + $personal_start = $personal_end = ''; if ($value['calendar_type'] == 'personal') { $personal_start = '
'; $personal_end = '
'; - } - $dayheader = $personal_start; - $dayheader.="".$curday.""; + } + $dayheader.= $personal_start; if ($value['end_date']=='0000-00-00 00:00:00') { $dayheader .= '
'.get_lang('Work').'
'; $dayheader .= $value['title']; $dayheader .= '
'; } else { - $dayheader .= '
'.get_lang('StartTimeWindow').' '.$start_time.' - '.get_lang('EndTimeWindow').' '.$end_time.' '; + if ($value['calendar_type'] == 'personal') { + $dayheader .= '
'.get_lang('StartTimeWindow').' '.$start_time.' '; + } else { + $dayheader .= '
'.get_lang('StartTimeWindow').' '.$start_time.' - '.get_lang('EndTimeWindow').' '.$end_time.' '; + } $dayheader .= '
'; $dayheader .= $value['title']; $dayheader .= '
'; @@ -452,11 +458,10 @@ function display_monthcalendar($month, $year) { } else { //$dayheader=$curday; } - //$agendaitems = get_global_agenda_items($agendaitems, $curday, $month, $year, $startdayofweek, "month_view"); - //echo $agendaitems['title']; - } + } } } + //var_dump($dayheader); if (($curday==$today['mday']) && ($year ==$today['year'])&&($month == $today['mon'])) { echo ''; echo ''; From 7538ea649ebfc96acf1e769c954148576a843827 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Tue, 18 May 2010 19:35:03 +0200 Subject: [PATCH 33/63] Fixing wrong user of the remove_XSS function. Adding database::escape_string function --- main/calendar/agenda.inc.php | 61 +++++++++++++++--------------------- 1 file changed, 26 insertions(+), 35 deletions(-) diff --git a/main/calendar/agenda.inc.php b/main/calendar/agenda.inc.php index fbe74e3ba0..3849d55cc5 100755 --- a/main/calendar/agenda.inc.php +++ b/main/calendar/agenda.inc.php @@ -993,21 +993,18 @@ function store_new_agenda_item() { $content=trim($_POST['content']); $start_date=(int)$_POST['fyear']."-".(int)$_POST['fmonth']."-".(int)$_POST['fday']." ".(int)$_POST['fhour'].":".(int)$_POST['fminute'].":00"; $end_date=(int)$_POST['end_fyear']."-".(int)$_POST['end_fmonth']."-".(int)$_POST['end_fday']." ".(int)$_POST['end_fhour'].":".(int)$_POST['end_fminute'].":00"; - - $content=stripslashes($content); - $title=Database::escape_string(Security::remove_XSS($title)); - $content = Database::escape_string(Security::remove_XSS($content,COURSEMANAGERLOWSECURITY)); - $start_date=Database::escape_string($start_date); - $end_date=Database::escape_string($end_date); + + $title = Database::escape_string($title); + $content = Database::escape_string($content); + $start_date = Database::escape_string($start_date); + $end_date = Database::escape_string($end_date); // store in the table calendar_event - $sql = "INSERT INTO ".$TABLEAGENDA." - (title,content, start_date, end_date) - VALUES - ('".$title."','".$content."', '".$start_date."','".$end_date."')"; - $result = Database::query($sql); - $last_id = Database::insert_id(); + $sql = "INSERT INTO ".$TABLEAGENDA." (title,content, start_date, end_date) + VALUES ('".$title."','".$content."', '".$start_date."','".$end_date."')"; + $result = Database::query($sql); + $last_id = Database::insert_id(); // store in last_tooledit (first the groups, then the users $to=$_POST['selectedform']; @@ -1077,26 +1074,23 @@ function store_agenda_item_as_announcement($item_id){ $sql_max = "SELECT MAX(display_order) FROM $table_ann"; $res_max = Database::query($sql_max); $row_max = Database::fetch_array($res_max); - $max = $row_max[0]+1; + $max = intval($row_max[0])+1; //build the announcement text $content = $row['start_date']." - ".$row['end_date']."\n".$row['content']; //insert announcement - $session_id = api_get_session_id(); + $session_id = api_get_session_id(); $sql_ins = "INSERT INTO $table_ann (title,content,end_date,display_order,session_id) " . - "VALUES ('".Security::remove_XSS($row['title'])."','".$content."','".$row['end_date']."','$max','$session_id')"; + "VALUES ('".Database::escape_string($row['title'])."','".Database::escape_string($content)."','".Database::escape_string($row['end_date'])."','$max','$session_id')"; $res_ins = Database::query($sql_ins); - if($res > 0) - { + if($res > 0) { $ann_id = Database::insert_id(); //Now also get the list of item_properties rows for this agenda_item (calendar_event) //and copy them into announcement item_properties $table_props = Database::get_course_table(TABLE_ITEM_PROPERTY); $sql_props = "SELECT * FROM $table_props WHERE tool = 'calendar_event' AND ref='$item_id'"; $res_props = Database::query($sql_props); - if(Database::num_rows($res_props)>0) - { - while($row_props = Database::fetch_array($res_props)) - { + if(Database::num_rows($res_props)>0) { + while($row_props = Database::fetch_array($res_props)) { //insert into announcement item_property $time = date("Y-m-d H:i:s", time()); $sql_ins_props = "INSERT INTO $table_props " . @@ -1111,14 +1105,14 @@ function store_agenda_item_as_announcement($item_id){ "'".$row_props['visibility']."','".$row_props['start_visible']."','".$row_props['end_visible']."')"; $res_ins_props = Database::query($sql_ins_props); if($res_ins_props <= 0){ - error_log('SQL Error in '.__FILE__.' at line '.__LINE__.': '.$sql_ins_props); - }else{ + return -1; + } else { //copy was a success return $ann_id; } } } - }else{ + } else { return -1; } } @@ -1132,8 +1126,7 @@ function store_agenda_item_as_announcement($item_id){ * @author: Patrick Cool , Ghent University * @return array */ -function separate_users_groups($to) -{ +function separate_users_groups($to) { $grouplist = array(); $userlist = array(); $send_to = null; @@ -1640,12 +1633,11 @@ function store_edited_agenda_item($id_attach,$file_comment) * This function stores the Agenda Item in the table calendar_event and updates the item_property table also (after an edit) * @author: Patrick Cool , Ghent University */ -function save_edit_agenda_item($id,$title,$content,$start_date,$end_date) -{ +function save_edit_agenda_item($id,$title,$content,$start_date,$end_date) { $TABLEAGENDA= Database::get_course_table(TABLE_AGENDA); $id = Database::escape_string($id); - $title = Database::escape_string(Security::remove_XSS($title)); - $content = Database::escape_string(Security::remove_XSS($content,COURSEMANAGERLOWSECURITY)); + $title = Database::escape_string($title); + $content = Database::escape_string($content); $start_date = Database::escape_string($start_date); $end_date = Database::escape_string($end_date); @@ -1669,8 +1661,7 @@ function save_edit_agenda_item($id,$title,$content,$start_date,$end_date) * @author Patrick Cool , Ghent University * @param integer the id of the agenda item wa are deleting */ -function delete_agenda_item($id) -{ +function delete_agenda_item($id) { global $_course; $id=Database::escape_string($id); if (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_edit_agenda') && !api_is_anonymous())) @@ -4262,12 +4253,12 @@ function agenda_add_item($course_info, $title, $content, $db_start_date, $db_end // database table definitions $t_agenda = Database::get_course_table(TABLE_AGENDA,$course_info['dbName']); $agenda_table_attachment = Database::get_course_table(TABLE_AGENDA_ATTACHMENT); - $item_property = Database::get_course_table(TABLE_ITEM_PROPERTY); + $item_property = Database::get_course_table(TABLE_ITEM_PROPERTY); // some filtering of the input data $content=stripslashes($content); - $title=Database::escape_string(Security::remove_XSS($title)); - $content = Database::escape_string(Security::remove_XSS($content,COURSEMANAGERLOWSECURITY)); + $title=Database::escape_string($title); + $content = Database::escape_string($content); $start_date = Database::escape_string($db_start_date); $end_date = Database::escape_string($db_end_date); isset($_SESSION['id_session'])?$id_session=intval($_SESSION['id_session']):$id_session=null; From 69733a2969b8dec6a2bca9a5fb681976985d7d10 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Tue, 18 May 2010 19:42:23 +0200 Subject: [PATCH 34/63] Removing execise use of remove_XSS . i.e: Database::escape_string(Security::remove_XSS()) --- main/link/linkfunctions.php | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/main/link/linkfunctions.php b/main/link/linkfunctions.php index 91d2635018..273c59fcb3 100755 --- a/main/link/linkfunctions.php +++ b/main/link/linkfunctions.php @@ -224,18 +224,18 @@ function deletelinkcategory($type) { } if ($type == 'category') { - global $id; + if (isset($_GET['id']) && !empty($_GET['id'])) { + // First we delete the category itself and afterwards all the links of this category. + $sql = "DELETE FROM ".$tbl_categories." WHERE id='".intval($_GET['id'])."'"; + Database::query($sql); + $sql = "DELETE FROM ".$tbl_link." WHERE category_id='".intval($_GET['id'])."'"; + $catlinkstatus = get_lang('CategoryDeleted'); + unset ($id); + Database::query($sql); - // First we delete the category itself and afterwards all the links of this category. - $sql = "DELETE FROM ".$tbl_categories." WHERE id='".Database::escape_string(Security::remove_XSS($_GET['id']))."'"; - Database::query($sql); - $sql = "DELETE FROM ".$tbl_link." WHERE category_id='".Database::escape_string(Security::remove_XSS($_GET['id']))."'"; - $catlinkstatus = get_lang('CategoryDeleted'); - unset ($id); - Database::query($sql); - - Display::display_confirmation_message(get_lang('CategoryDeleted')); + Display::display_confirmation_message(get_lang('CategoryDeleted')); + } } } @@ -328,7 +328,7 @@ function editlinkcategory($type) { } // Finding the old category_id - $sql = "SELECT * FROM ".$tbl_link." WHERE id='".Database::escape_string(Security::remove_XSS($_POST['id']))."'"; + $sql = "SELECT * FROM ".$tbl_link." WHERE id='".intval($_POST['id'])."'"; $result = Database::query($sql); $row = Database::fetch_array($result); $category_id = $row['category_id']; @@ -342,7 +342,14 @@ function editlinkcategory($type) { $max_display_order = $row['display_order']; } - $sql = "UPDATE ".$tbl_link." set url='".Database::escape_string(Security::remove_XSS($_POST['urllink']))."', title='".Database::escape_string(Security::remove_XSS($_POST['title']))."', description='".Database::escape_string(Security::remove_XSS($_POST['description']))."', category_id='".Database::escape_string(Security::remove_XSS($_POST['selectcategory']))."', display_order='".$max_display_order."', on_homepage='".Database::escape_string(Security::remove_XSS($onhomepage))." ' $mytarget WHERE id='".Database::escape_string(Security::remove_XSS($_POST['id']))."'"; + $sql = "UPDATE ".$tbl_link." SET " . + "url='".Database::escape_string($_POST['urllink'])."', " . + "title='".Database::escape_string($_POST['title'])."', " . + "description='".Database::escape_string($_POST['description'])."', " . + "category_id='".Database::escape_string($_POST['selectcategory'])."', " . + "display_order='".$max_display_order."', " . + "on_homepage='".Database::escape_string($onhomepage)." ' $mytarget " . + " WHERE id='".Database::escape_string($_POST['id'])."'"; Database::query($sql); // Update search enchine and its values table if enabled @@ -453,7 +460,7 @@ function editlinkcategory($type) { // This is used to put the modified info of the category-form into the database if ($submit_category) { - $sql = "UPDATE ".$tbl_categories." set category_title='".Database::escape_string(Security::remove_XSS($_POST['category_title']))."', description='".Database::escape_string(Security::remove_XSS($_POST['description']))."' WHERE id='".Database::escape_string(Security::remove_XSS($_POST['id']))."'"; + $sql = "UPDATE ".$tbl_categories." set category_title='".Database::escape_string($_POST['category_title'])."', description='".Database::escape_string($_POST['description'])."' WHERE id='".Database::escape_string($_POST['id'])."'"; Database::query($sql); Display::display_confirmation_message(get_lang('CategoryModded')); } From 03cefca1a0a266e2eaf94ddc8bcce6e5e5e2b9f4 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Tue, 18 May 2010 19:48:34 +0200 Subject: [PATCH 35/63] Removing execise use of remove_XSS . i.e: Database::escape_string(Security::remove_XSS()) --- main/survey/survey.lib.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/main/survey/survey.lib.php b/main/survey/survey.lib.php index e94d212dc6..19587cc1d8 100644 --- a/main/survey/survey.lib.php +++ b/main/survey/survey.lib.php @@ -217,16 +217,16 @@ class survey_manager { } $sql = "INSERT INTO $table_survey (code, title, subtitle, author, lang, avail_from, avail_till, is_shared, template, intro, surveythanks, creation_date, anonymous".$additional['columns'].", session_id) VALUES ( '".Database::escape_string(strtolower(generate_course_code(api_substr($values['survey_code'],0))))."', - '".Database::escape_string(Security::remove_XSS(stripslashes(api_html_entity_decode($values['survey_title'])), COURSEMANAGERLOWSECURITY))."', - '".Database::escape_string(Security::remove_XSS(stripslashes(api_html_entity_decode($values['survey_subtitle'])), COURSEMANAGERLOWSECURITY))."', + '".Database::escape_string($values['survey_title'])."', + '".Database::escape_string($values['survey_subtitle'])."', '".Database::escape_string($_user['user_id'])."', '".Database::escape_string($values['survey_language'])."', '".Database::escape_string($values['start_date'])."', '".Database::escape_string($values['end_date'])."', '".Database::escape_string($shared_survey_id)."', '".Database::escape_string('template')."', - '".Database::escape_string(Security::remove_XSS(stripslashes(api_html_entity_decode($values['survey_introduction'])), COURSEMANAGERLOWSECURITY))."', - '".Database::escape_string(Security::remove_XSS(stripslashes(api_html_entity_decode($values['survey_thanks'])), COURSEMANAGERLOWSECURITY))."', + '".Database::escape_string($values['survey_introduction'])."', + '".Database::escape_string($values['survey_thanks'])."', '".date('Y-m-d H:i:s')."', '".Database::escape_string($values['anonymous'])."'".$additional['values'].", ".intval($_SESSION['id_session'])." From 130f367a823d6e0c9352bc58fdd597b896a29d08 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Tue, 18 May 2010 19:53:01 +0200 Subject: [PATCH 36/63] Removing execise use of remove_XSS . i.e: Database::escape_string(Security::remove_XSS()) --- main/wiki/wiki.inc.php | 125 +++++++++++++++++++---------------------- 1 file changed, 59 insertions(+), 66 deletions(-) diff --git a/main/wiki/wiki.inc.php b/main/wiki/wiki.inc.php index 5d1657efe7..7271fc0970 100755 --- a/main/wiki/wiki.inc.php +++ b/main/wiki/wiki.inc.php @@ -270,16 +270,17 @@ function save_wiki() { // NOTE: visibility, visibility_disc and ratinglock_disc changes are not made here, but through the interce buttons // cleaning the variables - $_clean['page_id']=Database::escape_string($_POST['page_id']); - $_clean['reflink']=Database::escape_string(Security::remove_XSS($_POST['reflink'])); - $_clean['title']=Database::escape_string(Security::remove_XSS($_POST['title'])); - $_clean['content']= Database::escape_string(Security::remove_XSS(stripslashes(api_html_entity_decode($_POST['content'])),COURSEMANAGERLOWSECURITY)); - $_clean['user_id']=(int)Database::escape_string(api_get_user_id()); - $_clean['assignment']=Database::escape_string($_POST['assignment']); - $_clean['comment']=Database::escape_string(Security::remove_XSS($_POST['comment'])); - $_clean['progress']=Database::escape_string($_POST['progress']); - $_clean['version']=Database::escape_string($_POST['version'])+1; - $_clean['linksto'] = links_to($_clean['content']); //and check links content + $_clean['page_id'] = Database::escape_string($_POST['page_id']); + $_clean['reflink'] = Database::escape_string($_POST['reflink']); + $_clean['title'] = Database::escape_string($_POST['title']); + $_clean['content'] = Database::escape_string($_POST['content']); + $_clean['user_id'] = api_get_user_id(); + $_clean['assignment'] = Database::escape_string($_POST['assignment']); + $_clean['comment'] = Database::escape_string($_POST['comment']); + $_clean['progress'] = Database::escape_string($_POST['progress']); + $_clean['version'] = intval($_POST['version']) + 1 ; + $_clean['linksto'] = links_to($_clean['content']); //and check links content + $dtime = date( "Y-m-d H:i:s" ); $session_id = api_get_session_id(); @@ -296,56 +297,55 @@ function save_wiki() { if(!empty($_POST['task'])) { - $_clean['task']= Database::escape_string(Security::remove_XSS(stripslashes(api_html_entity_decode($_POST['task'])),COURSEMANAGERLOWSECURITY)); + $_clean['task']= Database::escape_string($_POST['task']); } - if(!empty($_POST['feedback1']) || !empty($_POST['feedback2']) || !empty($_POST['feedback3'])) - { - $_clean['feedback1']=Database::escape_string(Security::remove_XSS($_POST['feedback1'])); - $_clean['feedback2']=Database::escape_string(Security::remove_XSS($_POST['feedback2'])); - $_clean['feedback3']=Database::escape_string(Security::remove_XSS($_POST['feedback3'])); - $_clean['fprogress1']=Database::escape_string(Security::remove_XSS($_POST['fprogress1'])); - $_clean['fprogress2']=Database::escape_string(Security::remove_XSS($_POST['fprogress2'])); - $_clean['fprogress3']=Database::escape_string(Security::remove_XSS($_POST['fprogress3'])); + if(!empty($_POST['feedback1']) || !empty($_POST['feedback2']) || !empty($_POST['feedback3'])) { + $_clean['feedback1']=Database::escape_string($_POST['feedback1']); + $_clean['feedback2']=Database::escape_string($_POST['feedback2']); + $_clean['feedback3']=Database::escape_string($_POST['feedback3']); + $_clean['fprogress1']=Database::escape_string($_POST['fprogress1']); + $_clean['fprogress2']=Database::escape_string($_POST['fprogress2']); + $_clean['fprogress3']=Database::escape_string($_POST['fprogress3']); } if(Security::remove_XSS($_POST['initstartdate']==1)) { - $_clean['startdate_assig']=Database::escape_string(Security::remove_XSS(get_date_from_select('startdate_assig'))); + $_clean['startdate_assig']=Database::escape_string(get_date_from_select('startdate_assig')); } else { - $_clean['startdate_assig']=Database::escape_string(Security::remove_XSS($_POST['startdate_assig'])); + $_clean['startdate_assig']=Database::escape_string($_POST['startdate_assig']); } if(Security::remove_XSS($_POST['initenddate']==1)) { - $_clean['enddate_assig']=Database::escape_string(Security::remove_XSS(get_date_from_select('enddate_assig'))); + $_clean['enddate_assig']=Database::escape_string(get_date_from_select('enddate_assig')); } else { - $_clean['enddate_assig']=Database::escape_string(Security::remove_XSS($_POST['enddate_assig'])); + $_clean['enddate_assig']=Database::escape_string($_POST['enddate_assig']); } - $_clean['delayedsubmit']=Database::escape_string(Security::remove_XSS($_POST['delayedsubmit'])); + $_clean['delayedsubmit']=Database::escape_string($_POST['delayedsubmit']); if(!empty($_POST['max_text']) || !empty($_POST['max_version'])) { - $_clean['max_text']=Database::escape_string(Security::remove_XSS($_POST['max_text'])); - $_clean['max_version']=Database::escape_string(Security::remove_XSS($_POST['max_version'])); + $_clean['max_text'] =Database::escape_string($_POST['max_text']); + $_clean['max_version']=Database::escape_string($_POST['max_version']); } - $sql = "INSERT INTO ".$tbl_wiki." (page_id, reflink, title, content, user_id, group_id, dtime, assignment, comment, progress, version, linksto, user_ip, session_id) VALUES ('".$_clean['page_id']."','".$_clean['reflink']."','".$_clean['title']."','".$_clean['content']."','".$_clean['user_id']."','".$_clean['group_id']."','".$dtime."','".$_clean['assignment']."','".$_clean['comment']."','".$_clean['progress']."','".$_clean['version']."','".$_clean['linksto']."','".Database::escape_string($_SERVER['REMOTE_ADDR'])."', '".Database::escape_string($session_id)."')"; + $sql = "INSERT INTO ".$tbl_wiki." (page_id, reflink, title, content, user_id, group_id, dtime, assignment, comment, progress, version, linksto, user_ip, session_id) + VALUES ('".$_clean['page_id']."','".$_clean['reflink']."','".$_clean['title']."','".$_clean['content']."','".$_clean['user_id']."','".$_clean['group_id']."','".$dtime."','".$_clean['assignment']."','".$_clean['comment']."','".$_clean['progress']."','".$_clean['version']."','".$_clean['linksto']."','".Database::escape_string($_SERVER['REMOTE_ADDR'])."', '".Database::escape_string($session_id)."')"; - $result=Database::query($sql); - $Id = Database::insert_id(); + $result = Database::query($sql); + $Id = Database::insert_id(); if ($Id > 0) { //insert into item_property api_item_property_update(api_get_course_info(), TOOL_WIKI, $Id, 'WikiAdded', api_get_user_id(), $_clean['group_id']); } - if ($_clean['page_id'] ==0) - { + if ($_clean['page_id'] ==0) { $sql='UPDATE '.$tbl_wiki.' SET page_id="'.$Id.'" WHERE id="'.$Id.'"'; Database::query($sql); } @@ -354,7 +354,8 @@ function save_wiki() { if ($_clean['reflink']=='index' && $_clean['version']==1) { - $sql="INSERT INTO ".$tbl_wiki_conf." (page_id, task, feedback1, feedback2, feedback3, fprogress1, fprogress2, fprogress3, max_text, max_version, startdate_assig, enddate_assig, delayedsubmit) VALUES ('".$Id."','".$_clean['task']."','".$_clean['feedback1']."','".$_clean['feedback2']."','".$_clean['feedback3']."','".$_clean['fprogress1']."','".$_clean['fprogress2']."','".$_clean['fprogress3']."','".$_clean['max_text']."','".$_clean['max_version']."','".$_clean['startdate_assig']."','".$_clean['enddate_assig']."','".$_clean['delayedsubmit']."')"; + $sql="INSERT INTO ".$tbl_wiki_conf." (page_id, task, feedback1, feedback2, feedback3, fprogress1, fprogress2, fprogress3, max_text, max_version, startdate_assig, enddate_assig, delayedsubmit) + VALUES ('".$Id."','".$_clean['task']."','".$_clean['feedback1']."','".$_clean['feedback2']."','".$_clean['feedback3']."','".$_clean['fprogress1']."','".$_clean['fprogress2']."','".$_clean['fprogress3']."','".$_clean['max_text']."','".$_clean['max_version']."','".$_clean['startdate_assig']."','".$_clean['enddate_assig']."','".$_clean['delayedsubmit']."')"; } else { @@ -435,13 +436,13 @@ function save_new_wiki() { $session_id = api_get_session_id(); if($_clean['assignment']==2 || $_clean['assignment']==1) {// Unlike ordinary pages of pages of assignments. Allow create a ordinary page although there is a assignment with the same name - $_clean['reflink']=Database::escape_string(Security::remove_XSS(str_replace(' ','_',$_POST['title']."_uass".$assig_user_id))); + $_clean['reflink']=Database::escape_string(str_replace(' ','_',$_POST['title']."_uass".$assig_user_id)); } else { - $_clean['reflink']=Database::escape_string(Security::remove_XSS(str_replace(' ','_',$_POST['title']))); + $_clean['reflink']=Database::escape_string(str_replace(' ','_',$_POST['title'])); } - $_clean['title']=Database::escape_string(Security::remove_XSS($_POST['title'])); - $_clean['content']= Database::escape_string(Security::remove_XSS(stripslashes(api_html_entity_decode($_POST['content'])),COURSEMANAGERLOWSECURITY)); + $_clean['title']=Database::escape_string($_POST['title']); + $_clean['content']= Database::escape_string($_POST['content']); if($_clean['assignment']==2) {//config by default for individual assignment (students) @@ -452,7 +453,7 @@ function save_new_wiki() { $_clean['ratinglock_disc']=0; } else { - $_clean['user_id']=(int)Database::escape_string(api_get_user_id()); + $_clean['user_id']=api_get_user_id(); $_clean['visibility']=1; $_clean['visibility_disc']=1; @@ -460,7 +461,7 @@ function save_new_wiki() { } - $_clean['comment']=Database::escape_string(Security::remove_XSS($_POST['comment'])); + $_clean['comment']=Database::escape_string($_POST['comment']); $_clean['progress']=Database::escape_string($_POST['progress']); $_clean['version']=1; @@ -476,44 +477,36 @@ function save_new_wiki() { $_clean['linksto'] = links_to($_clean['content']); //check wikilinks //cleaning config variables - $_clean['task']= Database::escape_string(Security::remove_XSS(stripslashes(api_html_entity_decode($_POST['task'])),COURSEMANAGERLOWSECURITY)); - $_clean['feedback1']=Database::escape_string(Security::remove_XSS($_POST['feedback1'])); - $_clean['feedback2']=Database::escape_string(Security::remove_XSS($_POST['feedback2'])); - $_clean['feedback3']=Database::escape_string(Security::remove_XSS($_POST['feedback3'])); - $_clean['fprogress1']=Database::escape_string(Security::remove_XSS($_POST['fprogress1'])); - $_clean['fprogress2']=Database::escape_string(Security::remove_XSS($_POST['fprogress2'])); - $_clean['fprogress3']=Database::escape_string(Security::remove_XSS($_POST['fprogress3'])); - - if(Security::remove_XSS($_POST['initstartdate']==1)) - { - $_clean['startdate_assig']=Database::escape_string(Security::remove_XSS(get_date_from_select('startdate_assig'))); - } - else - { - $_clean['startdate_assig']=Database::escape_string(Security::remove_XSS($_POST['startdate_assig'])); + $_clean['task']= Database::escape_string($_POST['task']); + $_clean['feedback1']=Database::escape_string($_POST['feedback1']); + $_clean['feedback2']=Database::escape_string($_POST['feedback2']); + $_clean['feedback3']=Database::escape_string($_POST['feedback3']); + $_clean['fprogress1']=Database::escape_string($_POST['fprogress1']); + $_clean['fprogress2']=Database::escape_string($_POST['fprogress2']); + $_clean['fprogress3']=Database::escape_string($_POST['fprogress3']); + + if(Security::remove_XSS($_POST['initstartdate']==1)) { + $_clean['startdate_assig']=Database::escape_string(get_date_from_select('startdate_assig')); + } else { + $_clean['startdate_assig']=Database::escape_string($_POST['startdate_assig']); } - if(Security::remove_XSS($_POST['initenddate']==1)) - { - $_clean['enddate_assig']=Database::escape_string(Security::remove_XSS(get_date_from_select('enddate_assig'))); - } - else - { - $_clean['enddate_assig']=Database::escape_string(Security::remove_XSS($_POST['enddate_assig'])); + if(Security::remove_XSS($_POST['initenddate']==1)) { + $_clean['enddate_assig']=Database::escape_string(get_date_from_select('enddate_assig')); + } else { + $_clean['enddate_assig']=Database::escape_string($_POST['enddate_assig']); } - $_clean['delayedsubmit']=Database::escape_string(Security::remove_XSS($_POST['delayedsubmit'])); - $_clean['max_text']=Database::escape_string(Security::remove_XSS($_POST['max_text'])); - $_clean['max_version']=Database::escape_string(Security::remove_XSS($_POST['max_version'])); + $_clean['delayedsubmit']=Database::escape_string($_POST['delayedsubmit']); + $_clean['max_text']=Database::escape_string($_POST['max_text']); + $_clean['max_version']=Database::escape_string($_POST['max_version']); //filter no _uass if (api_eregi('_uass', $_POST['title']) || (api_strtoupper(trim($_POST['title'])) == 'INDEX' || api_strtoupper(trim(api_htmlentities($_POST['title'], ENT_QUOTES, $charset))) == api_strtoupper(api_htmlentities(get_lang('DefaultTitle'), ENT_QUOTES, $charset)))) { $message= get_lang('GoAndEditMainPage'); Display::display_warning_message($message,false); } else { - $var=$_clean['reflink']; - $group_id=Security::remove_XSS($_GET['group_id']); if(!checktitle($var)) { return get_lang('WikiPageTitleExist').''.$_POST['title'].''; @@ -2084,7 +2077,7 @@ function make_select($name,$values,$checked='') { * */ function get_date_from_select($prefix) { - return $_POST[$prefix.'_year'].'-'.two_digits($_POST[$prefix.'_month']).'-'.two_digits($_POST[$prefix.'_day']).' '.two_digits($_POST[$prefix.'_hour']).':'.two_digits($_POST[$prefix.'_minute']).':00'; + return $_POST[$prefix.'_year'].'-'.two_digits($_POST[$prefix.'_month']).'-'.two_digits($_POST[$prefix.'_day']).' '.two_digits($_POST[$prefix.'_hour']).':'.two_digits($_POST[$prefix.'_minute']).':00'; } /** From aa7cc3e9169216fa8d6fc8a6d27002876319d828 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Tue, 18 May 2010 19:53:59 +0200 Subject: [PATCH 37/63] Removing use of remove_XSS . i.e: Database::escape_string(Security::remove_XSS()) --- main/wiki/wiki.inc.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main/wiki/wiki.inc.php b/main/wiki/wiki.inc.php index 7271fc0970..91b2dcbb4c 100755 --- a/main/wiki/wiki.inc.php +++ b/main/wiki/wiki.inc.php @@ -485,13 +485,13 @@ function save_new_wiki() { $_clean['fprogress2']=Database::escape_string($_POST['fprogress2']); $_clean['fprogress3']=Database::escape_string($_POST['fprogress3']); - if(Security::remove_XSS($_POST['initstartdate']==1)) { + if($_POST['initstartdate']==1) { $_clean['startdate_assig']=Database::escape_string(get_date_from_select('startdate_assig')); } else { $_clean['startdate_assig']=Database::escape_string($_POST['startdate_assig']); } - if(Security::remove_XSS($_POST['initenddate']==1)) { + if($_POST['initenddate']==1) { $_clean['enddate_assig']=Database::escape_string(get_date_from_select('enddate_assig')); } else { $_clean['enddate_assig']=Database::escape_string($_POST['enddate_assig']); From 8d54ded29a09f0a0a3a3c5954f9c6e17658d1977 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Tue, 18 May 2010 20:00:12 +0200 Subject: [PATCH 38/63] Cleaning code --- main/wiki/index.php | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/main/wiki/index.php b/main/wiki/index.php index e4cd4984f0..941b882ac6 100755 --- a/main/wiki/index.php +++ b/main/wiki/index.php @@ -1843,18 +1843,14 @@ if ($_GET['action']=='history' or Security::remove_XSS($_POST['HistoryDifference //rss feed. TODO: // -if ($_GET['action']=='recentchanges') -{ +if ($_GET['action']=='recentchanges') { $_clean['group_id']=(int)$_SESSION['_gid']; if ( api_is_allowed_to_session_edit(false,true) ) { - if (check_notify_all()==1) - { + if (check_notify_all()==1) { $notify_all= ''.get_lang('FullNotifyByEmail').''.get_lang('NotNotifyChanges'); $lock_unlock_notify_all='unlocknotifyall'; - } - else - { + } else { $notify_all= ''.get_lang('FullCancelNotifyByEmail').''.get_lang('NotifyChanges'); $lock_unlock_notify_all='locknotifyall'; } @@ -1873,14 +1869,12 @@ if ($_GET['action']=='recentchanges') $sql='SELECT * FROM '.$tbl_wiki.', '.$tbl_wiki_conf.' WHERE '.$tbl_wiki_conf.'.page_id='.$tbl_wiki.'.page_id AND '.$tbl_wiki.'.'.$groupfilter.$condition_session.' ORDER BY dtime DESC'; // new version - } - else - { + } else { $sql='SELECT * FROM '.$tbl_wiki.' WHERE '.$groupfilter.$condition_session.' AND visibility=1 ORDER BY dtime DESC'; // old version TODO: Replace by the bottom line //$sql='SELECT * FROM '.$tbl_wiki.', '.$tbl_wiki_conf.' WHERE '.$tbl_wiki_conf.'.page_id='.$tbl_wiki.'.page_id AND visibility=1 AND '.$tbl_wiki.'.'.$groupfilter.' ORDER BY dtime DESC'; // new version } - + $allpages=Database::query($sql); //show table From d133ff9d3d9a751110b42d1c96d7cd4ea938cc84 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Tue, 18 May 2010 20:09:04 +0200 Subject: [PATCH 39/63] Minor changing Dxxxx to Chamilo --- main/inc/lib/security.lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) mode change 100644 => 100755 main/inc/lib/security.lib.php diff --git a/main/inc/lib/security.lib.php b/main/inc/lib/security.lib.php old mode 100644 new mode 100755 index 9c6106d1c1..0059e35a5d --- a/main/inc/lib/security.lib.php +++ b/main/inc/lib/security.lib.php @@ -1,12 +1,12 @@ Date: Tue, 18 May 2010 21:06:50 +0200 Subject: [PATCH 40/63] Cleaning code + adding securty::remove_XSS --- main/admin/access_url_edit_courses_to_url.php | 1 - .../admin/access_url_edit_sessions_to_url.php | 2 +- main/admin/calendar.lib.php | 89 ++++++++----------- main/admin/calendar.php | 51 +++-------- 4 files changed, 46 insertions(+), 97 deletions(-) diff --git a/main/admin/access_url_edit_courses_to_url.php b/main/admin/access_url_edit_courses_to_url.php index b646ace69f..5345ecf62c 100755 --- a/main/admin/access_url_edit_courses_to_url.php +++ b/main/admin/access_url_edit_courses_to_url.php @@ -17,7 +17,6 @@ require_once (api_get_path(LIBRARY_PATH).'urlmanager.lib.php'); require_once (api_get_path(LIBRARY_PATH).'access_url_edit_courses_to_url_functions.lib.php'); $xajax = new xajax(); -//$xajax->debugOn(); $xajax -> registerFunction (array('search_courses', 'Accessurleditcoursestourl', 'search_courses')); diff --git a/main/admin/access_url_edit_sessions_to_url.php b/main/admin/access_url_edit_sessions_to_url.php index c5fbac3397..776611444c 100755 --- a/main/admin/access_url_edit_sessions_to_url.php +++ b/main/admin/access_url_edit_sessions_to_url.php @@ -18,7 +18,7 @@ require_once api_get_path(LIBRARY_PATH).'urlmanager.lib.php'; require_once api_get_path(LIBRARY_PATH).'access_url_edit_sessions_to_url_functions.lib.php'; $xajax = new xajax(); -//$xajax->debugOn(); + $xajax -> registerFunction (array('search_sessions', 'Accessurleditsessionstourl', 'search_sessions')); diff --git a/main/admin/calendar.lib.php b/main/admin/calendar.lib.php index d890c52042..2d34c50a1b 100755 --- a/main/admin/calendar.lib.php +++ b/main/admin/calendar.lib.php @@ -4,6 +4,8 @@ * @package chamilo.admin * @author Carlos Vargas * This file is the calendar/agenda.inc.php +* +* @todo This file should not exist since redeclares many of the functions in calendar/agenda.inc.php J.M */ /* @@ -40,8 +42,7 @@ $MonthsLong = api_get_months_long(); * @return html code * @todo refactor this so that $monthName is no longer needed as a parameter */ -function display_minimonthcalendar($agendaitems, $month, $year, $monthName) -{ +function display_minimonthcalendar($agendaitems, $month, $year, $monthName) { global $DaysShort; //Handle leap year $numberofdays = array (0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); @@ -119,10 +120,9 @@ function display_minimonthcalendar($agendaitems, $month, $year, $monthName) * @author: Patrick Cool , Ghent University * @return javascript code */ -function to_javascript() -{ -$Send2All=get_lang("Send2All"); -return " -"; +function user_group_filter_javascript() { + return " + "; } -function display_monthcalendar($month, $year) -{ +function display_monthcalendar($month, $year) { global $MonthsLong; global $DaysShort; global $origin; @@ -333,16 +331,14 @@ function display_monthcalendar($month, $year) echo "\n"; - for ($ii=1;$ii<8; $ii++) - { - echo "\n"; - } + for ($ii=1;$ii<8; $ii++) { + echo "\n"; + } echo "\n"; $curday = -1; $today = getdate(); - while ($curday <=$numberofdays[$month]) - { + while ($curday <=$numberofdays[$month]) { echo "\n"; for ($ii=0; $ii<7; $ii++) { @@ -401,9 +397,7 @@ echo "
'.$dayheader; @@ -2062,8 +2067,7 @@ function display_agenda_items($select_month, $select_year) { // the icons. If the message is sent to one or more specific users/groups // we add the groups icon // 2do: if it is sent to groups we display the group icon, if it is sent to a user we show the user icon - if ($myrow['calendar_type'] != 'personal') { - + if ($myrow['calendar_type'] != 'personal') { Display::display_icon('agenda.gif', get_lang('Agenda')); if ($myrow['to_group_id']!=='0') { echo Display::return_icon('group.gif', get_lang('ItemForUserSelection')); @@ -2107,9 +2111,11 @@ function display_agenda_items($select_month, $select_year) { echo ''; - if ($myrow['end_date']<>'0000-00-00 00:00:00') { - echo get_lang('EndTimeWindow').": "; - echo api_convert_and_format_date($myrow['end_date'], null, date_default_timezone_get()); + if ($myrow['calendar_type'] != 'personal') { + if ($myrow['end_date']<>'0000-00-00 00:00:00') { + echo get_lang('EndTimeWindow').": "; + echo api_convert_and_format_date($myrow['end_date'], null, date_default_timezone_get()); + } } echo '
",$DaysShort[$ii%7],"",$DaysShort[$ii%7],"
"; * @author: Patrick Cool , Ghent University * @return integer the id of the last added agenda item */ -function store_new_agenda_item() -{ - global $_user /*, $_course*/; +function store_new_agenda_item() { $TABLEAGENDA = Database::get_main_table(TABLE_MAIN_SYSTEM_CALENDAR); //$t_agenda_repeat = Database::get_course_Table(TABLE_AGENDA_REPEAT); @@ -486,23 +480,16 @@ function display_courseadmin_links() { echo "".Display::return_icon('calendar_personal_add.gif', get_lang('AgendaAdd'))." ".get_lang('AgendaAdd').""; } -function display_student_links() -{ - global $show; - if ($_SESSION['sort'] == 'DESC') - { - echo "".Display::return_icon('calendar_up.gif',get_lang('AgendaSortChronologicallyUp')).' '.get_lang("AgendaSortChronologicallyUp").""; - } - else - { - echo "".Display::return_icon('calendar_down.gif',get_lang('AgendaSortChronologicallyDown')).' '.get_lang("AgendaSortChronologicallyDown").""; + +function display_student_links() { + if ($_SESSION['sort'] == 'DESC') { + echo "".Display::return_icon('calendar_up.gif',get_lang('AgendaSortChronologicallyUp')).' '.get_lang("AgendaSortChronologicallyUp").""; + } else { + echo "".Display::return_icon('calendar_down.gif',get_lang('AgendaSortChronologicallyDown')).' '.get_lang("AgendaSortChronologicallyDown").""; } - if ($_SESSION['view'] <> 'month') - { + if ($_SESSION['view'] <> 'month') { echo "\t\"".get_lang('MonthView')."\" ".get_lang('MonthView')."\n"; - } - else - { + } else { echo "\t\"".get_lang('ListView')."\" ".get_lang('ListView')."\n"; } } @@ -512,8 +499,7 @@ function display_student_links() * @param integer the id of the agenda item we are getting all the information of * @return an associative array that contains all the information of the agenda item. The keys are the database fields */ -function get_agenda_item($id) -{ +function get_agenda_item($id) { $TABLEAGENDA = Database::get_main_table(TABLE_MAIN_SYSTEM_CALENDAR); //$t_agenda_repeat = Database::get_course_table(TABLE_AGENDA_REPEAT); $item = array(); @@ -532,12 +518,9 @@ function get_agenda_item($id) $item['end_date'] = $entry_to_edit["end_date"]; $item['to'] == "everyone"; // if the item has been sent to everybody then we show the compact to form - if ($item['to']=="everyone") - { + if ($item['to']=="everyone") { $_SESSION['allow_individual_calendar']="hide"; - } - else - { + } else { $_SESSION['allow_individual_calendar']="show"; } @@ -550,8 +533,7 @@ function get_agenda_item($id) * 3. modify the attachments (if needed) * @author Patrick Cool , Ghent University */ -function store_edited_agenda_item() -{ +function store_edited_agenda_item() { // STEP 1: editing the calendar_event table // 1.a. some filtering of the input data @@ -626,8 +608,7 @@ function delete_agenda_item($id) * @author Patrick Cool , Ghent University * @param integer id the id of the agenda item we are changing the visibility of */ -function showhide_agenda_item($id) -{ +function showhide_agenda_item($id) { global $nameTools; /*================================================== SHOW / HIDE A CALENDAR ITEM diff --git a/main/admin/calendar.php b/main/admin/calendar.php index b00802c556..48b2e67491 100755 --- a/main/admin/calendar.php +++ b/main/admin/calendar.php @@ -23,14 +23,6 @@ api_protect_admin_script(true); // setting breadcrumbs $interbreadcrumb[] = array('url' => 'index.php', 'name' => get_lang('PlatformAdmin')); -//$interbreadcrumb[] = array('url' => 'session_list.php','name' => get_lang('SessionList')); - -// Database Table Definitions -// $tbl_session_rel_course_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER); -// $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION); -// $tbl_session_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_USER); -// $tbl_session_rel_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE); -// $tbl_course = Database::get_main_table(TABLE_MAIN_COURSE); // setting the name of the tool $tool_name= get_lang('SubscribeCoursesToSession'); @@ -47,23 +39,18 @@ if(!api_is_platform_admin()) } } /* ------------------------------------------------------------ Libraries ------------------------------------------------------------ */ // containing the functions for the agenda tool -include "calendar.lib.php"; -// some debug functions -include($includePath."/lib/debug.lib.inc.php"); - +require_once 'calendar.lib.php'; -/*============================================================================== +/* TREATING THE PARAMETERS 1. viewing month only or everything 2. sort ascending or descending 3. showing or hiding the send-to-specific-groups-or-users form 4. filter user or group - ============================================================================== */ + */ // 1. show all or show current month? if (!$_SESSION['show']) { @@ -133,9 +120,9 @@ else echo ""; }*/ -/* ============================================================================== +/* SETTING SOME VARIABLES -============================================================================== */ +*/ // Variable definitions // Defining the shorts for the days. We use camelcase because these are arrays of language variables $DaysShort = api_get_week_days_short(); @@ -151,29 +138,18 @@ $tbl_user = Database::get_main_table(TABLE_MAIN_USER); $tbl_courseUser = Database::get_main_table(TABLE_MAIN_COURSE_USER); $tbl_group = Database::get_course_table(TABLE_GROUP); $tbl_groupUser = Database::get_course_table(TABLE_GROUP_USER); -$tbl_session_course_user= Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER); - - -/* ============================================================================== +/* ACCESS RIGHTS -============================================================================== */ +*/ // permission stuff - also used by loading from global in agenda.inc.php $is_allowed_to_edit = is_allowed_to_edit() OR (api_get_course_setting('allow_user_edit_agenda') && !api_is_anonymous()); -// Displaying the title of the tool -// api_display_tool_title($nameTools); - -// tool introduction -//Display::display_introduction_section(TOOL_CALENDAR_EVENT); - // insert an anchor (top) so one can jump back to the top of the page echo ""; /* -============================================================================== MAIN SECTION -============================================================================== */ //setting the default year and month @@ -207,10 +183,8 @@ echo '

'; echo '' . ''; - // THE LEFT PART -if (empty($_GET['origin']) or $_GET['origin']!='learnpath') -{ +if (empty($_GET['origin']) or $_GET['origin']!='learnpath') { echo '
'; // the small calendar $MonthName = $MonthsLong[$select_month -1]; @@ -382,15 +356,10 @@ if (!$_GET['action'] OR $_GET['action']=="showall" OR $_GET['action']=="showcur echo " 
"; /* -============================================================================== FOOTER -============================================================================== */ // The footer is displayed only if we are not in the learnpath -if ($_GET['origin'] != 'learnpath') -{ - +if ($_GET['origin'] != 'learnpath') { Display::display_footer(); - } -?> +?> \ No newline at end of file From ce635f12420f7f197b9a00b3b03dd9321d5c403d Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Tue, 18 May 2010 21:13:22 +0200 Subject: [PATCH 41/63] Minor - Adding headers --- main/conference/api.php | 9 ++++----- main/conference/audiopost.php | 4 +++- main/conference/checksession.php | 2 +- main/conference/get_translation.lib.php | 2 +- main/conference/index.php | 9 ++++++--- main/conference/testpost.php | 2 ++ main/conference/videoconference.php | 2 +- 7 files changed, 18 insertions(+), 12 deletions(-) mode change 100644 => 100755 main/conference/api.php mode change 100644 => 100755 main/conference/audiopost.php mode change 100644 => 100755 main/conference/checksession.php mode change 100644 => 100755 main/conference/index.php mode change 100644 => 100755 main/conference/testpost.php mode change 100644 => 100755 main/conference/videoconference.php diff --git a/main/conference/api.php b/main/conference/api.php old mode 100644 new mode 100755 index bb7adb8ab9..3dede1f9a7 --- a/main/conference/api.php +++ b/main/conference/api.php @@ -1,14 +1,13 @@ diff --git a/main/conference/testpost.php b/main/conference/testpost.php old mode 100644 new mode 100755 index f4b7b8b966..c28ed5745f --- a/main/conference/testpost.php +++ b/main/conference/testpost.php @@ -1,4 +1,6 @@ + From 3064dfe27ac53bf2488089f8b57bc1294ddce4ca Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Thu, 20 May 2010 12:10:50 +0200 Subject: [PATCH 42/63] Fixing javascript error in LPs in ie8 see CT#827 --- main/newscorm/lp_view.php | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/main/newscorm/lp_view.php b/main/newscorm/lp_view.php index c9f9902c9d..beb097127d 100755 --- a/main/newscorm/lp_view.php +++ b/main/newscorm/lp_view.php @@ -391,6 +391,20 @@ window.onload = function() { document.body.style.overflow = 'hidden'; updateContentHeight(); viewportheight = window.innerHeight; + //Fixing IE compatibility of window.innerHeight + + var viewportheight = 0; + if( typeof( window.innerHeight ) == 'number' ) { + //Non-IE + viewportheight = window.innerHeight; + } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) { + //IE 6+ in 'standards compliant mode' + viewportheight = document.documentElement.clientHeight; + } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) { + //IE 4 compatible + viewportheight = document.body.clientHeight; + } + document.getElementById('toc_id').style.height = viewportheight - 200 + "px"; } @@ -584,7 +598,21 @@ window.onload = function() { rightZoneHeightOccupied = docHeight - initialRightZoneHeight; document.body.style.overflow = 'hidden'; updateContentHeight(); - viewportheight = window.innerHeight; + + //Fixing IE compatibility of window.innerHeight + + var viewportheight = 0; + if( typeof( window.innerHeight ) == 'number' ) { + //Non-IE + viewportheight = window.innerHeight; + } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) { + //IE 6+ in 'standards compliant mode' + viewportheight = document.documentElement.clientHeight; + } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) { + //IE 4 compatible + viewportheight = document.body.clientHeight; + } + document.getElementById('toc_id').style.height = viewportheight - 200 + "px"; @@ -633,4 +661,4 @@ window.onresize = updateContentHeight; //Display::display_footer(); } //restore global setting -$_setting['show_navigation_menu'] = $save_setting; \ No newline at end of file +$_setting['show_navigation_menu'] = $save_setting; From 9446154dd109ac237576bccd3382013b44afdb93 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Thu, 20 May 2010 14:14:11 +0200 Subject: [PATCH 43/63] Cleaning file removing \n and \t --- main/admin/calendar.lib.php | 182 ++++++++++++++++++------------------ 1 file changed, 90 insertions(+), 92 deletions(-) diff --git a/main/admin/calendar.lib.php b/main/admin/calendar.lib.php index 2d34c50a1b..bf8ae91c7c 100755 --- a/main/admin/calendar.lib.php +++ b/main/admin/calendar.lib.php @@ -55,22 +55,22 @@ function display_minimonthcalendar($agendaitems, $month, $year, $monthName) { $backwardsURL = api_get_self()."?".api_get_cidreq()."&coursePath=".(empty($_GET['coursePath'])?'':$_GET['coursePath'])."&courseCode=".(empty($_GET['courseCode'])?'':$_GET['courseCode'])."&month=". ($month == 1 ? 12 : $month -1)."&year=". ($month == 1 ? $year -1 : $year); $forewardsURL = api_get_self()."?".api_get_cidreq()."&coursePath=".(empty($_GET['coursePath'])?'':$_GET['coursePath'])."&courseCode=".(empty($_GET['courseCode'])?'':$_GET['courseCode'])."&month=". ($month == 12 ? 1 : $month +1)."&year=". ($month == 12 ? $year +1 : $year); - echo "\n", - "\n", - "\n", - "\n", - "\n", "\n"; - echo "\n"; + echo "
".Display::return_icon('action_prev.png',get_lang('Previous'))." ", $monthName, " ", $year, " ".Display::return_icon('action_next.png',get_lang('Next'))."
", + "", + "", + "", + "", ""; + echo ""; for ($ii = 1; $ii < 8; $ii ++) { - echo "\n"; + echo ""; } - echo "\n"; + echo ""; $curday = -1; $today = getdate(); while ($curday <= $numberofdays[$month]) { - echo "\n"; + echo ""; for ($ii = 0; $ii < 7; $ii ++) { if (($curday == -1) && ($ii == $startdayofweek)) @@ -86,7 +86,7 @@ function display_minimonthcalendar($agendaitems, $month, $year, $monthName) { $dayheader = "$curday"; $class = "class=\"days_today\""; } - echo "\t\n"; + // "a".$dayheader." ".$agendaitems[$curday].""; + echo ""; $curday ++; } else { - echo "\n"; + echo ""; } } - echo "\n"; + echo ""; } - echo "
".Display::return_icon('action_prev.png',get_lang('Previous'))." ", $monthName, " ", $year, " ".Display::return_icon('action_next.png',get_lang('Next'))."
", $DaysShort[$ii % 7], "", $DaysShort[$ii % 7], "
"; + echo ""; if (!empty($agendaitems[$curday])) { echo "".$dayheader.""; @@ -95,18 +95,18 @@ function display_minimonthcalendar($agendaitems, $month, $year, $monthName) { { echo $dayheader; } - // "a".$dayheader." ".$agendaitems[$curday]."\n"; - echo "  
\n"; + echo ""; } /** * show the calender of the given month @@ -322,24 +322,24 @@ function display_monthcalendar($month, $year) { $maand_array_maandnummer=$month-1; - echo "\n", - "\n", - "\n", - "\n", - "\n", - "\n"; + echo "
".Display::return_icon('action_prev.png',get_lang('Previous'))."",$MonthsLong[$maand_array_maandnummer]," ",$year," ".Display::return_icon('action_next.png',get_lang('Next'))."
", + "", + "", + "", + "", + ""; - echo "\n"; + echo ""; for ($ii=1;$ii<8; $ii++) { - echo "\n"; + echo ""; } - echo "\n"; + echo ""; $curday = -1; $today = getdate(); while ($curday <=$numberofdays[$month]) { - echo "\n"; + echo ""; for ($ii=0; $ii<7; $ii++) { if (($curday == -1)&&($ii==$startdayofweek)) @@ -367,13 +367,13 @@ function display_monthcalendar($month, $year) { if (($curday==$today['mday'])&&($year ==$today['year'])&&($month == $today['mon'])) { - echo "\n"; + echo ""; $curday++; } @@ -488,9 +488,9 @@ function display_student_links() { echo "".Display::return_icon('calendar_down.gif',get_lang('AgendaSortChronologicallyDown')).' '.get_lang("AgendaSortChronologicallyDown").""; } if ($_SESSION['view'] <> 'month') { - echo "\t\"".get_lang('MonthView')."\" ".get_lang('MonthView')."\n"; + echo "\"".get_lang('MonthView')."\" ".get_lang('MonthView').""; } else { - echo "\t\"".get_lang('ListView')."\" ".get_lang('ListView')."\n"; + echo "\"".get_lang('ListView')."\" ".get_lang('ListView').""; } } /** @@ -712,7 +712,7 @@ function display_agenda_items() while($myrow=Database::fetch_array($result)) { $is_repeated = !empty($myrow['parent_event_id']); - echo '
".Display::return_icon('action_prev.png',get_lang('Previous'))."",$MonthsLong[$maand_array_maandnummer]," ",$year," ".Display::return_icon('action_next.png',get_lang('Next'))."
",$DaysShort[$ii%7],"",$DaysShort[$ii%7],"
".$dayheader." \n"; + echo "".$dayheader." "; } else { - echo "".$dayheader." \n"; + echo "".$dayheader." "; } - echo "
',"\n"; + echo '
',""; /*-------------------------------------------------- display: the month bar --------------------------------------------------*/ @@ -721,9 +721,9 @@ function display_agenda_items() if ($month_bar != api_format_date($myrow["start_date"], "%m%Y")) { $month_bar = api_format_date($myrow["start_date"], "%m%Y"); - echo "\t\n\t\t\n\t\n"; + ""; } /*-------------------------------------------------- @@ -756,9 +756,9 @@ function display_agenda_items() $text_style="textnow"; } - echo "\t\t\n"; + echo " ".$myrow['title'].""; + echo ""; // the message has been sent to - echo "\t\t"; - echo "\t\t\n"; - echo "\t\t"; + echo "\n"; + echo ""; // attachment list //$attachment_list=get_attachment($myrow['id']); @@ -976,12 +976,12 @@ function display_one_agenda_item($agenda_id) /*-------------------------------------------------- DISPLAY: THE ITEMS --------------------------------------------------*/ - echo "
". + echo "
". api_format_date($myrow["start_date"], "%B %Y"). - "
\n"; + echo ""; // adding an internal anchor - echo "\t\t\t"; + echo ""; // the icons. If the message is sent to one or more specific users/groups // we add the groups icon // 2do: if it is sent to groups we display the group icon, if it is sent to a user we show the user icon @@ -767,11 +767,11 @@ function display_agenda_items() { echo Display::return_icon('group.gif', get_lang('AllUsersOfThePlatform')); } - echo " ".$myrow['title']."\n"; - echo "\t\t".get_lang("SentTo").": ".get_lang('AllUsersOfThePlatform'); + echo "".get_lang("SentTo").": ".get_lang('AllUsersOfThePlatform'); //$sent_to=sent_to(TOOL_CALENDAR_EVENT, $myrow["ref"]); //$sent_to_form=sent_to_form($sent_to); // echo $sent_to_form; @@ -790,16 +790,16 @@ function display_agenda_items() display: the title --------------------------------------------------*/ echo "
".get_lang("StartTimeWindow").": "; + echo "".get_lang("StartTimeWindow").": "; echo api_format_date($myrow["start_date"]); - echo ""; + echo ""; if ($myrow["end_date"]<>"0000-00-00 00:00:00") { echo get_lang("EndTimeWindow").": "; echo api_convert_and_format_date($myrow["end_date"], null, date_default_timezone_get()); } - echo "
\n"; + echo "
"; /*-------------------------------------------------- DISPLAY : the icon, title, destinees of the item --------------------------------------------------*/ - echo "\t\n"; + echo ""; // highlight: if a date in the small calendar is clicked we highlight the relevant items $myrow["start_date"] = api_get_local_time($myrow["start_date"], null, date_default_timezone_get()); @@ -1009,10 +1009,10 @@ function display_one_agenda_item($agenda_id) } - echo "\t\t\n"; + echo " ".$myrow['title'].""; + echo ""; // the message has been sent to - echo "\t\t\n\t\n"; + echo ""; /*-------------------------------------------------- DISPLAY: the title --------------------------------------------------*/ - echo "\t\n"; - echo "\t\t"; + echo "\n"; - echo "\t\t"; + echo "\n"; - echo "\n\t\n"; + echo ""; + echo ""; /*-------------------------------------------------- DISPLAY: the content @@ -1054,7 +1054,7 @@ function display_one_agenda_item($agenda_id) $content = $myrow['content']; $content = make_clickable($content); $content = text_filter($content); - //echo "\t\n\t\t"; echo ""; @@ -1162,32 +1162,32 @@ echo ""; function show_user_group_filter_form() { /** @todo this select missing to implement */ - echo "\n"; + echo ""; // Groups - echo "\n\t"; + echo ""; //$group_list=get_course_groups(); /* foreach($group_list as $this_group) { // echo ""; - echo "\n\t\t"; }*/ - echo "\n\t"; + echo ""; // Users - echo "\n\t"; + echo ""; //$user_list=get_course_users(); /* foreach($user_list as $this_user) { // echo ""; - echo "\n\t\t"; }*/ - echo "\n\t"; + echo ""; echo ""; } @@ -1313,14 +1313,13 @@ function show_add_form($id = '') @@ -1434,9 +1432,9 @@ function show_add_form($id = '') $value = ($i <= 9 ? '0'.$i : $i ); // the current day is indicated with [] around the date if ($value==$end_day) - { echo "\t\t\t\t \n";} + { echo " \n";} else - { echo "\t\t\t\t \n"; } + { echo " \n"; } }?> @@ -1448,9 +1446,9 @@ function show_add_form($id = '') // values have to have double digits $value = ($i <= 9 ? '0'.$i : $i ); if ($value==$end_month) - { echo "\t\t\t\t \n"; } + { echo " \n"; } else - { echo "\t\t\t\t \n"; } + { echo " \n"; } }?> 'vertical-align: middle;')); ?> @@ -1480,9 +1478,9 @@ function show_add_form($id = '') $value = ($i <= 9 ? '0'.$i : $i ); // the current hour is indicated with [] around the hour if ($end_hours==$value) - { echo "\t\t\t\t\n"; } + { echo "\n"; } else - { echo "\t\t\t\t\n"; } + { echo "\n"; } } ?> @@ -1494,7 +1492,7 @@ function show_add_form($id = '') { // values have to have double digits $value = ($i <= 9 ? '0'.$i : $i ); - echo "\t\t\t\t\n"; + echo "\n"; } ?>
@@ -1545,11 +1543,11 @@ function show_add_form($id = '') --> \n"; - echo "\t\t\n"; + echo "\n\t\n"; + echo "\n\n"; /* END ADDED BY UGENT, Patrick Cool, march 2004 */ if(empty($id)) //only show repeat fields when adding the first time { @@ -1785,7 +1783,7 @@ function display_daycalendar($agendaitems, $day, $month, $year, $weekdaynames, $ $class = "class=\"row_odd\""; } echo "\n"; - echo "\t"; + echo ""; if ($i % 2 == 0) { echo ("\n"); @@ -1794,7 +1792,7 @@ function display_daycalendar($agendaitems, $day, $month, $year, $weekdaynames, $ { echo ("\n"); } - echo "\t\n"; + echo "\n"; echo "\n"; } echo "
\n"; + echo ""; // adding an internal anchor - echo "\t\t\t"; + echo ""; // the icons. If the message is sent to one or more specific users/groups // we add the groups icon @@ -1022,27 +1022,27 @@ function display_one_agenda_item($agenda_id) { echo Display::return_icon('group.gif'); } - echo " ".$myrow['title']."\n"; - echo "\t\t".get_lang("SentTo").": ".get_lang('AllUsersOfThePlatform'); + echo "".get_lang("SentTo").": ".get_lang('AllUsersOfThePlatform'); //$sent_to = sent_to(TOOL_CALENDAR_EVENT, $myrow["ref"]); //sent_to_form=sent_to_form($sent_to); //echo $sent_to_form; - echo "
".get_lang("StartTime").": "; + echo "
".get_lang("StartTime").": "; echo api_format_date($myrow["start_date"]); - echo "".get_lang("EndTime").": "; + echo "".get_lang("EndTime").": "; echo api_convert_and_format_date($myrow["end_date"], null, date_default_timezone_get()); - echo "
"; + //echo "
"; //echo $content; //echo "
- + ".$MonthsLong[$i-1]."\n"; + echo " \n"; } else { - echo "\t\t\t\t \n"; + echo " \n"; } } ?> @@ -1370,7 +1368,7 @@ function show_add_form($id = '') for ($i=1; $i<=5; $i++) { $value=$year+$i; - echo "\t\t\t\t\n"; + echo "\n"; } ?> 'vertical-align: middle;')); ?> @@ -1390,11 +1388,11 @@ function show_add_form($id = '') // the current hour is indicated with [] around the hour if ($hours==$value) { - echo "\t\t\t\t\n"; + echo "\n"; } else { - echo "\t\t\t\t\n"; + echo "\n"; } } ?> @@ -1407,7 +1405,7 @@ function show_add_form($id = '') { // values have to have double digits $value = ($i <= 9 ? '0'.$i : $i ); - echo "\t\t\t\t\n"; + echo "\n"; } ?>
\n"; + echo "
\n"; //echo display_resources(0);//-------------------------------------------------------- $test=$_SESSION['addedresource']; - echo "\t\t
". (($i) / 2)." ".get_lang("HourShort")." 00". ((($i) / 2) - (1 / 2))." ".get_lang("HourShort")." 30\n"; + echo "\n"; if (is_array($agendaitems[$i])) { foreach ($agendaitems[$i] as $key => $value) @@ -1806,7 +1804,7 @@ function display_daycalendar($agendaitems, $day, $month, $year, $weekdaynames, $ { echo $agendaitems[$i]; } - echo "\t
\n"; @@ -1856,7 +1854,7 @@ function display_weekcalendar($agendaitems, $month, $year, $weekdaynames, $month for ($ii = 1; $ii < 8; $ii ++) { $is_today = ($ii == $thisday_of_the_week AND (!isset($_GET['week']) OR $_GET['week']==$thisweek_number)); - echo "\t"; + echo ""; if ($is_today) { echo ""; @@ -1890,7 +1888,7 @@ function display_weekcalendar($agendaitems, $month, $year, $weekdaynames, $month $class = "class=\"days_today\""; } - echo "\t"; + echo ""; echo "".$agendaitems[date('j', $value)]."  "; echo "\n"; $counter ++; From 04f3fe5330a8a398aea391829597c86263be50d0 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Thu, 20 May 2010 14:40:47 +0200 Subject: [PATCH 44/63] Adding global events in course agenda and personal agenda see CT#325 --- main/admin/calendar.lib.php | 14 +++--- main/admin/calendar.php | 58 +++++----------------- main/calendar/agenda.inc.php | 90 +++++++++++++++++++++++++---------- main/calendar/agenda.php | 1 - main/img/calendar_global.png | Bin 0 -> 946 bytes main/img/loading1.gif | Bin 0 -> 673 bytes 6 files changed, 85 insertions(+), 78 deletions(-) create mode 100644 main/img/calendar_global.png create mode 100644 main/img/loading1.gif diff --git a/main/admin/calendar.lib.php b/main/admin/calendar.lib.php index bf8ae91c7c..ba2bd8eea5 100755 --- a/main/admin/calendar.lib.php +++ b/main/admin/calendar.lib.php @@ -653,7 +653,7 @@ function display_agenda_items() $stop = 0; // this is to make a difference between showing everything (all months) or only the current month) // $show_all_current is a part of the sql statement - if ($_SESSION['show']!=="showall") + if ($_SESSION['show_all_admin']!=="showall") { $show_all_current=" AND MONTH(start_date)=$select_month AND year(start_date)=$select_year"; $start = mktime(0,0,0,$select_month,1,$select_year); @@ -762,11 +762,10 @@ function display_agenda_items() // the icons. If the message is sent to one or more specific users/groups // we add the groups icon // 2do: if it is sent to groups we display the group icon, if it is sent to a user we show the user icon - Display::display_icon('agenda.gif', get_lang('Agenda')); - if ($myrow['to_group_id']!=='0') - { + Display::display_icon('calendar_global.png', get_lang('Agenda')); + /*if ($myrow['to_group_id']!=='0') { echo Display::return_icon('group.gif', get_lang('AllUsersOfThePlatform')); - } + }*/ echo " ".$myrow['title'].""; echo ""; @@ -1666,9 +1665,8 @@ function get_agendaitems($month, $year) return $agendaitems; } -function display_upcoming_events() -{ - echo ''.get_lang('UpcomingEvent').'
'; +function display_upcoming_events() { + echo '
'.get_lang('UpcomingEvent').'
'; $number_of_items_to_show = (int)api_get_setting('number_of_upcoming_events'); //databases of the courses diff --git a/main/admin/calendar.php b/main/admin/calendar.php index 48b2e67491..bf48c1632a 100755 --- a/main/admin/calendar.php +++ b/main/admin/calendar.php @@ -52,19 +52,17 @@ require_once 'calendar.lib.php'; 4. filter user or group */ // 1. show all or show current month? -if (!$_SESSION['show']) -{ - $_SESSION['show']="showall"; +if (!$_SESSION['show_all_admin']) { + $_SESSION['show_all_admin']="showall"; } if (!empty($_GET['action']) and $_GET['action']=="showcurrent") { - $_SESSION['show']="showcurrent"; + $_SESSION['show_all_admin']='showcurrent'; } if (!empty($_GET['action']) and $_GET['action']=="showall") { - $_SESSION['show']="showall"; + $_SESSION['show_all_admin']='showall'; } -//echo $_SESSION['show']; // 2. sorting order (ASC or DESC) if (empty($_GET['sort']) and empty($_SESSION['sort'])) @@ -189,13 +187,12 @@ if (empty($_GET['origin']) or $_GET['origin']!='learnpath') { // the small calendar $MonthName = $MonthsLong[$select_month -1]; $agenda_items=get_calendar_items($select_month,$select_year); - if (api_get_setting('display_mini_month_calendar') == 'true') - { + if (api_get_setting('display_mini_month_calendar') == 'true') { display_minimonthcalendar($agenda_items, $select_month,$select_year, $MonthName); } - /*if (api_get_setting('display_upcoming_events') == 'true') { + if (api_get_setting('display_upcoming_events') == 'true') { display_upcoming_events(); - }*/ + } echo ''; echo ' '; } @@ -206,17 +203,13 @@ echo ''; echo '
'; echo '
'; -if (api_is_allowed_to_edit(false,true)) -{ +if (api_is_allowed_to_edit(false,true)) { switch ($_GET['action']) { case "add": if(!empty($_POST['ical_submit'])) { $course_info = api_get_course_info(); - agenda_import_ical($course_info,$_FILES['ical_import']); - if (api_get_setting('display_upcoming_events') == 'true') { - display_upcoming_events(); - } + agenda_import_ical($course_info,$_FILES['ical_import']); display_agenda_items(); } elseif ($_POST['submit_event']) { @@ -232,10 +225,7 @@ if (api_is_allowed_to_edit(false,true)) $end_d = intval($_POST['repeat_end_day']); $end = mktime(23, 59, 59, $end_m, $end_d, $end_y); $res = agenda_add_repeat_item($course_info,$id,$_POST['repeat_type'],$end,null,$_POST['file_comment']); - } - if (api_get_setting('display_upcoming_events') == 'true') { - display_upcoming_events(); - } + } display_agenda_items(); } else { show_add_form(); @@ -249,22 +239,12 @@ if (api_is_allowed_to_edit(false,true)) { $my_id_attach = (int)$_REQUEST['id_attach']; $my_file_comment = Database::escape_string($_REQUEST['file_comment']); store_edited_agenda_item($my_id_attach,$my_file_comment); - if (api_get_setting('display_upcoming_events') == 'true') { - display_upcoming_events(); - } display_agenda_items(); - } - else - { + } else { $id=(int)$_GET['id']; show_add_form($id); } - } - else - { - if (api_get_setting('display_upcoming_events') == 'true') { - display_upcoming_events(); - } + } else { display_agenda_items(); } break; @@ -282,10 +262,7 @@ if (api_is_allowed_to_edit(false,true)) } } } - if (api_get_setting('display_upcoming_events') == 'true') { - display_upcoming_events(); - } - display_agenda_items(); + display_agenda_items(); break; case "showhide": @@ -294,9 +271,6 @@ if (api_is_allowed_to_edit(false,true)) { // a coach can only delete an element belonging to his session showhide_agenda_item($id); } - if (api_get_setting('display_upcoming_events') == 'true') { - display_upcoming_events(); - } display_agenda_items(); break; case "announce": //copying the agenda item into an announcement @@ -308,9 +282,6 @@ if (api_is_allowed_to_edit(false,true)) echo '
'; Display::display_normal_message(get_lang('CopiedAsAnnouncement').''.get_lang('NewAnnouncement').'', false); } - if (api_get_setting('display_upcoming_events') == 'true') { - display_upcoming_events(); - } display_agenda_items(); break; case "delete_attach": //delete attachment file @@ -318,9 +289,6 @@ if (api_is_allowed_to_edit(false,true)) if (!empty($id_attach)) { delete_attachment_file($id_attach); } - if (api_get_setting('display_upcoming_events') == 'true') { - display_upcoming_events(); - } display_agenda_items(); break; diff --git a/main/calendar/agenda.inc.php b/main/calendar/agenda.inc.php index 3849d55cc5..04a69bbf40 100755 --- a/main/calendar/agenda.inc.php +++ b/main/calendar/agenda.inc.php @@ -86,7 +86,8 @@ function get_calendar_items($month, $year) { $stop = 0; // this is to make a difference between showing everything (all months) or only the current month) // $show_all_current is a part of the sql statement - if ($_SESSION['show']!=="showall") { + + if ($_SESSION['show']!=='showall') { $show_all_current=" AND MONTH(start_date)=$select_month AND year(start_date)=$select_year"; $start = mktime(0,0,0,$select_month,1,$select_year); $stop = 0; @@ -236,10 +237,8 @@ function get_calendar_items($month, $year) { } } } // you are a student - - - $result=Database::query($sql) or die(Database::error()); - + + $result=Database::query($sql); $data=array(); while ($row=Database::fetch_array($result, 'ASSOC')) { $datum_item=(int)substr($row['start_date'],8,2); @@ -247,7 +246,7 @@ function get_calendar_items($month, $year) { $data[$datum_item][intval($datum_item)][] = $row; } - //Check my personal calendar items + //Check my personal agenda events if (api_get_setting('allow_personal_agenda') == 'true') { $tbl_personal_agenda = Database :: get_user_personal_table(TABLE_PERSONAL_AGENDA); // 1. creating the SQL statement for getting the personal agenda items in MONTH view @@ -259,8 +258,21 @@ function get_calendar_items($month, $year) { $row['calendar_type'] = 'personal'; $data[$datum_item][$datum_item][] = $row; } - } - + } + /* + //Check global agenda events */ + $table_agenda_system = Database :: get_main_table(TABLE_MAIN_SYSTEM_CALENDAR); + $sql = "SELECT DISTINCT * FROM ".$table_agenda_system." + WHERE + MONTH(start_date)='".$month."' + AND YEAR(start_date)='".$year."' + ORDER BY start_date "; + $result=Database::query($sql); + while ($row = Database::fetch_array($result, 'ASSOC')) { + $datum_item=intval(substr($row['start_date'],8,2)); + $row['calendar_type'] = 'global'; + $data[$datum_item][$datum_item][] = $row; + } return $data; } @@ -276,8 +288,7 @@ function get_calendar_items($month, $year) { * @return html code * @todo refactor this so that $monthName is no longer needed as a parameter */ -function display_minimonthcalendar($agendaitems, $month, $year, $monthName) -{ +function display_minimonthcalendar($agendaitems, $month, $year, $monthName) { global $DaysShort; //Handle leap year $numberofdays = array (0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); @@ -420,14 +431,16 @@ function display_monthcalendar($month, $year) { if (key_exists($curday, $data)) { foreach ($data[$curday] as $key=>$agenda_item) { - $dayheader ="".$curday.""; + + $dayheader = "".$curday.""; + $some_content = false; foreach ($agenda_item as $key=>$value) { $month_start_date = (int)substr($value['start_date'],5,2); - $start_time = api_convert_and_format_date($value['start_date']); + $start_time = api_convert_and_format_date($value['start_date']); - if ($month == $month_start_date) { + $some_content = true; $start_time = api_convert_and_format_date($value['start_date'], TIME_NO_SEC_FORMAT, date_default_timezone_get()); $end_time = api_convert_and_format_date($value['end_date'], TIME_NO_SEC_FORMAT, date_default_timezone_get()); @@ -435,9 +448,12 @@ function display_monthcalendar($month, $year) { //Setting a personal event to green $personal_start = $personal_end = ''; if ($value['calendar_type'] == 'personal') { - $personal_start = '
'; + $personal_start = '
'.get_lang('MyAgenda'); + $personal_end = '
'; + } elseif ($value['calendar_type'] == 'global') { + $personal_start = '
'.get_lang('GlobalEvent'); $personal_end = '
'; - } + } $dayheader.= $personal_start; if ($value['end_date']=='0000-00-00 00:00:00') { @@ -458,7 +474,12 @@ function display_monthcalendar($month, $year) { } else { //$dayheader=$curday; } - } + } + //Do not show links with no content + if ($some_content == false) { + $dayheader = $curday; + } + } } //var_dump($dayheader); @@ -2014,6 +2035,20 @@ function display_agenda_items($select_month, $select_year) { } } + + + //Check global agenda events */ + $table_agenda_system = Database :: get_main_table(TABLE_MAIN_SYSTEM_CALENDAR); + $sql = "SELECT DISTINCT id, title, content , start_date, end_date FROM ".$table_agenda_system." + WHERE 1=1 ".$show_all_current." + ORDER BY start_date "; + $result=Database::query($sql); + while ($row = Database::fetch_array($result, 'ASSOC')) { + $row['calendar_type'] = 'global'; + $my_events[] = $row; + } + + //while($myrow = Database::fetch_array($result)) { foreach ($my_events as $myrow) { $is_repeated = !empty($myrow['parent_event_id']); @@ -2058,7 +2093,7 @@ function display_agenda_items($select_month, $select_year) { // the icons. If the message is sent to one or more specific users/groups // we add the groups icon // 2do: if it is sent to groups we display the group icon, if it is sent to a user we show the user icon - if ($myrow['calendar_type'] != 'personal') { + if ($myrow['calendar_type'] == 'course') { Display::display_icon('agenda.gif', get_lang('Agenda')); if ($myrow['to_group_id']!=='0') { echo Display::return_icon('group.gif', get_lang('ItemForUserSelection')); @@ -2066,26 +2101,33 @@ function display_agenda_items($select_month, $select_year) { echo ''; echo $myrow['title']; echo ''; - } else { + } elseif ($myrow['calendar_type'] == 'personal') { Display::display_icon('calendar_personal.gif', get_lang('Personal')); echo ''; echo $myrow['title']; echo ''; - } + } else { + Display::display_icon('calendar_global.png', get_lang('Personal')); + echo ''; + echo $myrow['title']; + echo ''; + } echo ''; - if ($myrow['calendar_type'] != 'personal') { + if ($myrow['calendar_type'] == 'course') { // the message has been sent to echo "".get_lang('SentTo').": "; $sent_to=sent_to(TOOL_CALENDAR_EVENT, $myrow["ref"]); $sent_to_form=sent_to_form($sent_to); echo $sent_to_form; echo ''; - } else { + } elseif ($myrow['calendar_type'] == 'personal') { echo ''.get_lang('Personal').''; + } elseif ($myrow['calendar_type'] == 'global') { + echo ''.get_lang('GlobalEvent').''; } - if (!$is_repeated && (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_edit_agenda') && !api_is_anonymous())) && $myrow['calendar_type'] != 'personal' ) { + if (!$is_repeated && (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_edit_agenda') && !api_is_anonymous())) && $myrow['calendar_type'] == 'course' ) { if( ! (api_is_course_coach() && !api_is_element_in_the_session(TOOL_AGENDA, $myrow['id'] ) ) ) { // a coach can only delete an element belonging to his session echo ''.get_lang('Modify'); @@ -2102,7 +2144,7 @@ function display_agenda_items($select_month, $select_year) { echo ''; echo ''; - if ($myrow['calendar_type'] != 'personal') { + if ($myrow['calendar_type'] == 'course') { if ($myrow['end_date']<>'0000-00-00 00:00:00') { echo get_lang('EndTimeWindow').": "; echo api_convert_and_format_date($myrow['end_date'], null, date_default_timezone_get()); @@ -2114,7 +2156,7 @@ function display_agenda_items($select_month, $select_year) { $attachment_list=get_attachment($myrow['id']); /*Display: edit delete button (course admin only) */ - if (!$is_repeated && (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_edit_agenda') && !api_is_anonymous())) && $myrow['calendar_type'] != 'personal') { + if (!$is_repeated && (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_edit_agenda') && !api_is_anonymous())) && $myrow['calendar_type'] == 'course') { if( ! (api_is_course_coach() && !api_is_element_in_the_session(TOOL_AGENDA, $myrow['id'] ) ) ) { // a coach can only delete an element belonging to his session $mylink = api_get_self().'?'.api_get_cidreq().'&origin='.Security::remove_XSS($_GET['origin']).'&id='.$myrow['id'].'&'; diff --git a/main/calendar/agenda.php b/main/calendar/agenda.php index eabecc115f..45e747183e 100755 --- a/main/calendar/agenda.php +++ b/main/calendar/agenda.php @@ -76,7 +76,6 @@ if (!empty($_GET['action']) and $_GET['action']=="showcurrent") { if (!empty($_GET['action']) and $_GET['action']=="showall") { $_SESSION['show']="showall"; } -//echo $_SESSION['show']; // 2. sorting order (ASC or DESC) if (empty($_GET['sort']) and empty($_SESSION['sort'])) { diff --git a/main/img/calendar_global.png b/main/img/calendar_global.png new file mode 100644 index 0000000000000000000000000000000000000000..74169fd4b9cb7a52fc325112f613527ffaf7f276 GIT binary patch literal 946 zcmV;j15NyiP)Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2igS` z3r311W96b4i!O?HO<*ttq=y8%*n5xK1r=y_DO#> z7di)VTrYMGjbqf>Ml8wxhkRcC`ts!@1gMqE{>$a%HH%qLJ>usq7Kwa5-VyIjU{Qzq9##fZG8mRpw=Qb zMy+X(hf=f1t3xUVbpkG~ABq!2u|bTjliD~Tsb7%JPpUQS-QQI29th>Pc^DZ%|0&d8 zRVA5%pel%@IYmWr;!sgU1!D}audkTbS2Ule`peIRKYjSXkMG{m-qDc|DxT+&LQ=aV zc~vEjgMxVS)7>Fw>MtE&rZEvKia6pO{gvdYNF z2vHQFiGSlbCRA0L@$~e>!NCFLav5U`rBaFc`FV1=97jh-oSmID2nGiSiK6IDeVDeD zwtI7P!_CbNQ&UqIV_02X<>cgq@$qr)@9&wJnPF^fjJCEmeBW<$mcnmUn8{>_qKJGx z&-3#$VHh$nFn}?JhldCD_V!p=Sz&W?lXAKIX5IjP8aU^uR;zS&b}~6R$<@^rJ3BiR z3I+Q6`>9kaSZi5WSYUa1nTv}Hj*pLN6%?iq^78V6a}MA4DHe-tY-}(zG{oH89G>UV z-QCUF+8Unc;hZCiBJS?)zH>!rt))__;GDzrJW8b!TU%RnbaYTC6gWRWr>CcfVzJ2f z_BIO(3#clkQi;*g(eGLgYqeTKwuo?ec*yPTExzxwzP^qzhUw{PW@l%)yu4(0cNgaz z6B82*4-YrInZn!O-`BprJ}Q+8%`e^z&+`a^pkeaVufFd$JekYoxW2xw+oqWyJ=BVH zRzVQF$+gB|5CmkiS*;84_&-opve~Q#LEw3di;KT6EiL`oYS90RAPD&U`STzD0@l^B UwGrI%Pyhe`07*qoM6N<$g884mqyPW_ literal 0 HcmV?d00001 diff --git a/main/img/loading1.gif b/main/img/loading1.gif new file mode 100644 index 0000000000000000000000000000000000000000..d0bce1542342e912da81a2c260562df172f30d73 GIT binary patch literal 673 zcmZ?wbhEHb6krfw_{6~Q|Nnmm28Kh24mmkF0U1e2Nli^nlO|14{Lk&@8WQa67~pE8 zXTZz|lvDgC+Z`3#dv5h=E26FfcG1 zbL_hF&)}42ws10s6^G;;cE1^EoUR)U5A70}d2pLv!jVIT7j&Z~EblI3x0K*v_sV|m z0kj3v921Z^em#l`(k(o@H$3ZdDRc@9NidXDNbqrumReCGv$gd8+e8WW28HVqkJ_9i zH>s*<31KtHjANIPvi2#*6BEu%3Dak5O_t&NBI)H?V$TxT}#l{vOTn5naXTfF^&~Hhq+NX@#Ccc>y7T?;vjI&jdhsDsPJyAw*m0Qz>i}K7# zL9w50Ng{fT}A5JUe8lRK1h7_Y2;BWJDd=c6f&i?Wv5(5q?6|P zQw{>maxZP<537OA37Uk}7@%_$4o$EWe_Zl>&#id|lE-BpDC#+Fn|msJ%_2h{Hg1vP z#N8WAzfWasG}yq|xqE)DrWaOofX=z|?*pgc%{ig5vl!pqDlC|q&~Z0$&Rvsft&VO- z4MZj+%-+Vx%W}v;V76hyp=;+R;x+~t^Q%*xuFTQAF2})fSfTHDAs>sO!OBw`)&)o$ c0!CNZt))x~rAZP^^P&YOFfdqy5)K#u0POD40{{R3 literal 0 HcmV?d00001 From d1c9dbc01995b143920337442d0b7e89f27e6c7c Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Thu, 20 May 2010 15:02:46 +0200 Subject: [PATCH 45/63] Cleaning code --- main/forum/viewthread_flat.inc.php | 34 +++++++++++++------------- main/forum/viewthread_nested.inc.php | 32 ++++++++++++------------ main/forum/viewthread_threaded.inc.php | 32 ++++++++++++------------ 3 files changed, 49 insertions(+), 49 deletions(-) diff --git a/main/forum/viewthread_flat.inc.php b/main/forum/viewthread_flat.inc.php index 6cdc649582..162888a480 100755 --- a/main/forum/viewthread_flat.inc.php +++ b/main/forum/viewthread_flat.inc.php @@ -14,7 +14,7 @@ if (isset($current_thread['thread_id'])){ $rows=get_posts($current_thread['thread_id']); $increment=0; foreach ($rows as $row) { - echo "\n"; + echo "
"; // the style depends on the status of the message: approved or not if ($row['visible']=='0') { $titleclass='forum_message_post_title_2_be_approved'; @@ -26,8 +26,8 @@ if (isset($current_thread['thread_id'])){ $leftclass='forum_message_left'; } - echo "\t\n"; - echo "\t\t"; + echo "\n"; + echo ""; // show the if (isset($whatsnew_post_info[$current_forum['forum_id']][$current_thread['thread_id']][$row['post_id']]) and !empty($whatsnew_post_info[$current_forum['forum_id']][$current_thread['thread_id']][$row['post_id']]) and !empty($whatsnew_post_info[$_GET['forum']][$row['thread_id']])) { $post_image=icon('../img/forumpostnew.gif'); @@ -108,13 +108,13 @@ if (isset($current_thread['thread_id'])){ $post_image.=icon('../img/forumnotification.gif',get_lang('YouWillBeNotified')); } // The post title - echo "\t\t\n"; - echo "\t\n"; + echo ""; + echo ""; // The post message - echo "\t\n"; - echo "\t\t\n"; - echo "\t\n"; + echo ""; + echo ""; + echo ""; // The check if there is an attachment diff --git a/main/forum/viewthread_nested.inc.php b/main/forum/viewthread_nested.inc.php index 4d706fb755..4de01b834a 100755 --- a/main/forum/viewthread_nested.inc.php +++ b/main/forum/viewthread_nested.inc.php @@ -40,8 +40,8 @@ foreach ($rows as $post) { $indent=$post['indent_cnt']*'20'; echo "
"; - echo "
"; + echo "
"; if ($row['user_id']=='0') { $name=prepare4display($row['poster_name']); } else { @@ -49,16 +49,16 @@ if (isset($current_thread['thread_id'])){ // The course admin him/herself can do this off course always if (($current_forum['allow_edit']==1 AND $row['user_id']==$_user['user_id']) or (api_is_allowed_to_edit(false,true) && !(api_is_course_coach() && $current_forum['session_id']!=$_SESSION['id_session']))) { if (api_is_allowed_to_session_edit(false,true)) - echo "".icon('../img/edit.gif',get_lang('Edit'))."\n"; + echo "".icon('../img/edit.gif',get_lang('Edit')).""; } if ($origin != 'learnpath') { if (api_is_allowed_to_edit(false,true) && !(api_is_course_coach() && $current_forum['session_id']!=$_SESSION['id_session'])) { - echo "".icon('../img/delete.gif',get_lang('Delete'))."\n"; + echo "".icon('../img/delete.gif',get_lang('Delete')).""; display_visible_invisible_icon('post', $row['post_id'], $row['visible'],array('forum'=>Security::remove_XSS($_GET['forum']),'thread'=>Security::remove_XSS($_GET['thread']), 'origin'=>$origin )); - echo "\n"; + echo ""; if ($increment>0) { - echo "".icon('../img/deplacer_fichier.gif',get_lang('MovePost'))."\n"; + echo "".icon('../img/deplacer_fichier.gif',get_lang('MovePost')).""; } } } @@ -70,11 +70,11 @@ if (isset($current_thread['thread_id'])){ if( isset($_GET['gradebook'])){ if ($increment>0 && $user_status!=1 ) { $info_thread=get_thread_information(Security::remove_XSS($_GET['thread'])); - echo "".icon('../img/new_test_small.gif',get_lang('Qualify'))."\n"; + echo "".icon('../img/new_test_small.gif',get_lang('Qualify')).""; } } else { if ($increment>0 && $user_status!=1 ) { - echo "".icon('../img/new_test_small.gif',get_lang('Qualify'))."\n"; + echo "".icon('../img/new_test_small.gif',get_lang('Qualify')).""; } } } @@ -82,8 +82,8 @@ if (isset($current_thread['thread_id'])){ if ($current_forum_category['locked']==0 AND $current_forum['locked']==0 AND $current_thread['locked']==0 OR api_is_allowed_to_edit(false,true)) { if ($_user['user_id'] OR ($current_forum['allow_anonymous']==1 AND !$_user['user_id'])) { if (!api_is_anonymous() && api_is_allowed_to_session_edit(false,true)) { - echo ''.Display :: return_icon('message_reply_forum.png', get_lang('ReplyToMessage'))."\n"; - echo ''.Display :: return_icon('quote.gif', get_lang('QuoteMessage'))."\n"; + echo ''.Display :: return_icon('message_reply_forum.png', get_lang('ReplyToMessage')).""; + echo ''.Display :: return_icon('quote.gif', get_lang('QuoteMessage')).""; } } } else { @@ -97,7 +97,7 @@ if (isset($current_thread['thread_id'])){ echo get_lang('ThreadLocked').'
'; } } - echo "
".prepare4display(Security::remove_XSS($row['post_title'], STUDENT))."
".prepare4display(Security::remove_XSS($row['post_title'], STUDENT))."
".prepare4display(Security::remove_XSS($row['post_text'], STUDENT))."
".prepare4display(Security::remove_XSS($row['post_text'], STUDENT))."
\n"; - echo "\t\n"; + echo "
"; + echo "\t"; echo "\t\t\n"; + echo ""; // note: this can be removed here because it will be displayed in the tree if (isset($whatsnew_post_info[$current_forum['forum_id']][$current_thread['thread_id']][$post['post_id']]) and !empty($whatsnew_post_info[$current_forum['forum_id']][$current_thread['thread_id']][$post['post_id']]) and !empty($whatsnew_post_info[$_GET['forum']][$post['thread_id']])) { $post_image=icon('../img/forumpostnew.gif'); @@ -108,13 +108,13 @@ foreach ($rows as $post) { $post_image.=icon('../img/forumnotification.gif',get_lang('YouWillBeNotified')); } // The post title - echo "\t\t\n"; - echo "\t\n"; + echo "\t\t"; + echo "\t"; // The post message - echo "\t\n"; - echo "\t\t\n"; - echo "\t\n"; + echo "\t"; + echo "\t\t"; + echo "\t"; // The check if there is an attachment @@ -139,7 +139,7 @@ foreach ($rows as $post) { // The post has been displayed => it can be removed from the what's new array unset($whatsnew_post_info[$current_forum['forum_id']][$current_thread['thread_id']][$row['post_id']]); unset($_SESSION['whatsnew_post_info'][$current_forum['forum_id']][$current_thread['thread_id']][$row['post_id']]); - echo "
"; if ($post['user_id']=='0') { $name=$post['poster_name']; @@ -59,14 +59,14 @@ foreach ($rows as $post) { // The user who posted it can edit his thread only if the course admin allowed this in the properties of the forum // The course admin him/herself can do this off course always if (($current_forum['allow_edit']==1 AND $post['user_id']==$_user['user_id']) or (api_is_allowed_to_edit(false,true) && !(api_is_course_coach() && $current_forum['session_id']!=$_SESSION['id_session']))) { - echo "".icon('../img/edit.gif',get_lang('Edit'))."\n"; + echo "".icon('../img/edit.gif',get_lang('Edit')).""; } if (api_is_allowed_to_edit(false,true) && !(api_is_course_coach() && $current_forum['session_id']!=$_SESSION['id_session'])) { - echo "".icon('../img/delete.gif',get_lang('Delete'))."\n"; + echo "".icon('../img/delete.gif',get_lang('Delete')).""; display_visible_invisible_icon('post', $post['post_id'], $post['visible'],array('forum'=>Security::remove_XSS($_GET['forum']),'thread'=>Security::remove_XSS($_GET['thread']) )); - echo "\n"; + echo ""; if ($count>0) { - echo "".icon('../img/deplacer_fichier.gif',get_lang('MovePost'))."\n"; + echo "".icon('../img/deplacer_fichier.gif',get_lang('MovePost')).""; } } $userinf=api_get_user_info($post['user_id']); @@ -74,7 +74,7 @@ foreach ($rows as $post) { if (api_is_allowed_to_edit(null,true)) { if ($count>0 && $user_status!=1) { $current_qualify_thread=show_qualify('1',$_GET['cidReq'],$_GET['forum'],$post['user_id'],$_GET['thread']); - echo "".icon('../img/new_test_small.gif',get_lang('Qualify'))."\n"; + echo "".icon('../img/new_test_small.gif',get_lang('Qualify')).""; } } //echo '

'; @@ -82,8 +82,8 @@ foreach ($rows as $post) { if ($current_forum_category['locked']==0 AND $current_forum['locked']==0 AND $current_thread['locked']==0 OR api_is_allowed_to_edit(false,true)) { if ($_user['user_id'] OR ($current_forum['allow_anonymous']==1 AND !$_user['user_id'])) { if (!api_is_anonymous() && api_is_allowed_to_session_edit(false,true)) { - echo ''.Display :: return_icon('message_reply_forum.png', get_lang('ReplyToMessage'))."\n"; - echo ''.Display :: return_icon('quote.gif', get_lang('QuoteMessage'))."\n"; + echo ''.Display :: return_icon('message_reply_forum.png', get_lang('ReplyToMessage')).""; + echo ''.Display :: return_icon('quote.gif', get_lang('QuoteMessage')).""; } } } else { @@ -97,7 +97,7 @@ foreach ($rows as $post) { echo get_lang('ThreadLocked').'
'; } } - echo "
".prepare4display(Security::remove_XSS($post['post_title'], STUDENT))."
".prepare4display(Security::remove_XSS($post['post_title'], STUDENT))."
".prepare4display(Security::remove_XSS($post['post_text'], STUDENT))."
".prepare4display(Security::remove_XSS($post['post_text'], STUDENT))."
\n"; + echo ""; echo "
"; $count++; } diff --git a/main/forum/viewthread_threaded.inc.php b/main/forum/viewthread_threaded.inc.php index 9fc6f03737..3317d00019 100755 --- a/main/forum/viewthread_threaded.inc.php +++ b/main/forum/viewthread_threaded.inc.php @@ -95,7 +95,7 @@ foreach ($rows as $post) { $class=''; } $count_loop=($count==0)?'&id=1' : ''; - $thread_structure.= "".prepare4display(Security::remove_XSS($post['post_title'],STUDENT))."\n"; + $thread_structure.= "".prepare4display(Security::remove_XSS($post['post_title'],STUDENT)).""; $prev_next_array[]=$post['post_id']; } $count++; @@ -180,8 +180,8 @@ else // we mark the image we are displaying as set unset($whatsnew_post_info[$current_forum['forum_id']][$current_thread['thread_id']][$rows[$display_post_id]['post_id']]); -echo "\n"; -echo "\t\n"; +echo "
"; +echo "\t"; echo "\t\t\n"; +echo ""; // note: this can be removed here because it will be displayed in the tree if (isset($whatsnew_post_info[$current_forum['forum_id']][$current_thread['thread_id']][$rows[$display_post_id]['post_id']]) and !empty($whatsnew_post_info[$current_forum['forum_id']][$current_thread['thread_id']][$rows[$display_post_id]['post_id']]) and !empty($whatsnew_post_info[$_GET['forum']][$rows[$display_post_id]['thread_id']])) { @@ -278,13 +278,13 @@ if ($rows[$display_post_id]['post_notification']=='1' AND $rows[$display_post_id $post_image.=icon('../img/forumnotification.gif',get_lang('YouWillBeNotified')); } // The post title -echo "\t\t\n"; -echo "\t\n"; +echo "\t\t"; +echo "\t"; // The post message -echo "\t\n"; -echo "\t\t\n"; -echo "\t\n"; +echo "\t"; +echo "\t\t"; +echo "\t"; // The check if there is an attachment $attachment_list = get_attachment($display_post_id); From 1c16873a469d806f52c82de410c12a1030b57cb0 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Thu, 20 May 2010 21:16:22 +0200 Subject: [PATCH 46/63] Fixing BT#961 Updating score when exercise is in a LP with an open question with multiple attempts. We always take the last attempt in the teacher view. --- main/exercice/exercice.php | 136 +++++++++++++++++++++++-------------- 1 file changed, 85 insertions(+), 51 deletions(-) diff --git a/main/exercice/exercice.php b/main/exercice/exercice.php index f7ed452465..44febe2e99 100755 --- a/main/exercice/exercice.php +++ b/main/exercice/exercice.php @@ -130,12 +130,12 @@ if ($_GET['delete'] == 'delete' && ($is_allowedToEdit || api_is_coach()) && !emp } if ($show == 'result' && $_REQUEST['comments'] == 'update' && ($is_allowedToEdit || $is_tutor) && $_GET['exeid']== strval(intval($_GET['exeid']))) { - $id = $_GET['exeid']; //filtered by post-condition - $emailid = $_GET['emailid']; - $test = $_GET['test']; - $from = $_SESSION['_user']['mail']; - $from_name = api_get_person_name($_SESSION['_user']['firstName'], $_SESSION['_user']['lastName'], null, PERSON_NAME_EMAIL_ADDRESS); - $url = api_get_path(WEB_CODE_PATH) . 'exercice/exercice.php?' . api_get_cidreq() . '&show=result'; + $id = $_GET['exeid']; //filtered by post-condition + $emailid = $_GET['emailid']; + $test = $_GET['test']; + $from = $_SESSION['_user']['mail']; + $from_name = api_get_person_name($_SESSION['_user']['firstName'], $_SESSION['_user']['lastName'], null, PERSON_NAME_EMAIL_ADDRESS); + $url = api_get_path(WEB_CODE_PATH) . 'exercice/exercice.php?' . api_get_cidreq() . '&show=result'; $TBL_RECORDING = Database :: get_statistic_table('track_e_attempt_recording'); $total_weighting = $_REQUEST['totalWeighting']; @@ -157,10 +157,12 @@ if ($show == 'result' && $_REQUEST['comments'] == 'update' && ($is_allowedToEdit } else { $array_content_id_exe=$post_content_id; } + for ($i=0;$i<$loop_in_track;$i++) { $my_marks=Database::escape_string($_POST['marks_'.$array_content_id_exe[$i]]); + $contain_comments=Database::escape_string($_POST['comments_'.$array_content_id_exe[$i]]); if (isset($contain_comments)) { @@ -168,38 +170,40 @@ if ($show == 'result' && $_REQUEST['comments'] == 'update' && ($is_allowedToEdit } else { $my_comments=''; } - $my_questionid=$array_content_id_exe[$i]; - $sql = "SELECT question from $TBL_QUESTIONS WHERE id = '$my_questionid'"; - $result =Database::query($sql); - $ques_name = Database::result($result,0,"question"); - - $query = "UPDATE $TBL_TRACK_ATTEMPT SET marks = '$my_marks',teacher_comment = '$my_comments' - WHERE question_id = '".$my_questionid."' - AND exe_id='".$id."'"; - Database::query($query); - - - $qry = 'SELECT sum(marks) as tot - FROM '.$TBL_TRACK_ATTEMPT.' WHERE exe_id = '.intval($id).' - GROUP BY question_id'; - - $res = Database::query($qry); - $tot = Database::result($res,0,'tot'); - //updating also the total weight - $totquery = "UPDATE $TBL_TRACK_EXERCICES SET exe_result = '".Database::escape_string($tot)."', exe_weighting = '".Database::escape_string($total_weighting)."' - WHERE exe_Id='".Database::escape_string($id)."'"; - Database::query($totquery); - $recording_changes = 'INSERT INTO '.$TBL_RECORDING.' ' . - '(exe_id, - question_id, - marks, - insert_date, - author, - teacher_comment) - VALUES - ('."'$id','".$my_questionid."','$my_marks','".date('Y-m-d H:i:s')."','".api_get_user_id()."'".',"'.$my_comments.'")'; - Database::query($recording_changes); + $my_questionid=$array_content_id_exe[$i]; + $sql = "SELECT question from $TBL_QUESTIONS WHERE id = '$my_questionid'"; + $result =Database::query($sql); + $ques_name = Database::result($result,0,"question"); + + $query = "UPDATE $TBL_TRACK_ATTEMPT SET marks = '$my_marks',teacher_comment = '$my_comments' + WHERE question_id = '".$my_questionid."' + AND exe_id='".$id."'"; + + Database::query($query); + + + $qry = 'SELECT sum(marks) as tot + FROM '.$TBL_TRACK_ATTEMPT.' WHERE exe_id = '.intval($id).' + GROUP BY question_id'; + + $res = Database::query($qry); + $tot = Database::result($res,0,'tot'); + //updating also the total weight + $totquery = "UPDATE $TBL_TRACK_EXERCICES SET exe_result = '".Database::escape_string($tot)."', exe_weighting = '".Database::escape_string($total_weighting)."' + WHERE exe_Id='".Database::escape_string($id)."'"; + Database::query($totquery); + $recording_changes = 'INSERT INTO '.$TBL_RECORDING.' ' . + '(exe_id, + question_id, + marks, + insert_date, + author, + teacher_comment) + VALUES + ('."'$id','".$my_questionid."','$my_marks','".date('Y-m-d H:i:s')."','".api_get_user_id()."'".',"'.$my_comments.'")'; + Database::query($recording_changes); } + $post_content_id=array(); $array_content_id_exe=array(); /*foreach ($_POST as $key => $v) { @@ -273,7 +277,7 @@ if ($show == 'result' && $_REQUEST['comments'] == 'update' && ($is_allowedToEdit //search items if (isset($_POST['my_exe_exo_id']) && isset($_POST['student_id'])) { $sql_lp='SELECT li.id as lp_item_id,li.lp_id,li.item_type,li.path,liv.id AS lp_view_id,liv.user_id,max(liv.view_count) AS view_count FROM '.$TBL_LP_ITEM.' li - INNER JOIN '.$TBL_LP_VIEW.' liv ON li.lp_id=liv.lp_id WHERE li.path="'.Database::escape_string(Security::remove_XSS($_POST['my_exe_exo_id'])).'" AND li.item_type="quiz" AND user_id="'.Database::escape_string(Security::remove_XSS($_POST['student_id'])).'" '; + INNER JOIN '.$TBL_LP_VIEW.' liv ON li.lp_id=liv.lp_id WHERE li.path="'.Database::escape_string(Security::remove_XSS($_POST['my_exe_exo_id'])).'" AND li.item_type="quiz" AND user_id="'.Database::escape_string($_POST['student_id']).'" '; $rs_lp=Database::query($sql_lp); if (!($rs_lp===false)) { $row_lp=Database::fetch_array($rs_lp); @@ -348,33 +352,63 @@ if ($show == 'result' && $_REQUEST['comments'] == 'update' && ($is_allowedToEdit $totalWeighting = $_POST['totalWeighting']; if ($lp_item_id == strval(intval($lp_item_id)) && $lp_item_view_id == strval(intval($lp_item_view_id)) && $student_id == strval(intval($student_id))) { - $score = Database :: escape_string($_POST['total_score']); + + $score = Database :: escape_string($_POST['total_score']); //This is the new note $total_time = Database :: escape_string($_POST['total_time']); + + //I need the lp_item_view_id in order to update the record + + //@todo add the lp_item_view_id in the track_exercise table in order to have a real match between the lp_item_view and the track_exercise + + //$my_real_lp_item_view_id = Database :: escape_string($_POST['real_lp_item_view_id']); + $lp_item_id = Database :: escape_string($lp_item_id); $lp_item_view_id = Database :: escape_string($lp_item_view_id); $student_id = Database :: escape_string($student_id); $totalWeighting = Database :: escape_string($totalWeighting); - // get max view_count from lp_item_view - /*$sql = "SELECT MAX(view_count) FROM $TBL_LP_ITEM_VIEW WHERE lp_item_id = '" . (int) $lp_item_view_id . "' - AND lp_view_id = (SELECT id from $TBL_LP_VIEW WHERE user_id = '" . (int) $student_id . "' and lp_id='" . (int) $lp_item_id . "')"; + + /* + $sql = "SELECT (view_count) FROM $TBL_LP_ITEM_VIEW + WHERE lp_item_id = '" . (int) $lp_item_view_id . "' AND lp_view_id = $my_real_lp_item_view_id ORDER BY id DESC LIMIT 1"; + $res_view_count = Database::query($sql); + $res_view_count = Database :: fetch_row($res_view_count); + $my_view_count = intval($res_view_count[0]); + */ + + //Checking if this is the lastest attempt + $sql = "SELECT exe_id FROM $TBL_TRACK_EXERCICES + WHERE exe_user_id = '" . Database :: escape_string($_POST['student_id']) . "' AND exe_cours_id = '" . api_get_course_id() . "' AND orig_lp_id = '$lp_item_id' AND orig_lp_item_id = '$lp_item_view_id' AND session_id = '" . api_get_session_id() . "' AND status = '' + ORDER BY exe_id DESC LIMIT 1 "; + $res_view_count = Database::query($sql); + $res_view_count = Database :: fetch_row($res_view_count); + $my_view_count = intval($res_view_count[0]); + + //Update lp_item_view if this attempts is the latest + $sql = "SELECT MAX(view_count) FROM $TBL_LP_ITEM_VIEW + WHERE lp_item_id = '" . (int) $lp_item_view_id . "' AND lp_view_id = (SELECT id from $TBL_LP_VIEW WHERE user_id = '" . (int) $student_id . "' and lp_id='" . (int) $lp_item_id . "')"; $res_max_view_count = Database::query($sql); $row_max_view_count = Database :: fetch_row($res_max_view_count); - $max_view_count = (int) $row_max_view_count[0]; - - // update score and total_time from last attempt when you qualify the exercise in Learning path detail - $sql_update_score = "UPDATE $TBL_LP_ITEM_VIEW SET score = '" . (float) $score . "',total_time = '" . (int) $total_time . "' WHERE lp_item_id = '" . (int) $lp_item_view_id . "' - AND lp_view_id = (SELECT id from $TBL_LP_VIEW WHERE user_id = '" . (int) $student_id . "' and lp_id='" . (int) $lp_item_id . "') AND view_count = '$max_view_count'"; - Database::query($sql_update_score); - + $max_view_count = intval($row_max_view_count[0]); + + //Only update if is the last attempt + if ($my_view_count == $_GET['exeid']) { + // update score and total_time from last attempt when you qualify the exercise in Learning path detail + $sql_update_score = "UPDATE $TBL_LP_ITEM_VIEW SET score = '" . intval($tot) . "', total_time = '" . (int) $total_time . "' WHERE lp_item_id = '" . (int) $lp_item_view_id . "' + AND lp_view_id = (SELECT id from $TBL_LP_VIEW WHERE user_id = '" . (int) $student_id . "' and lp_id='" . (int) $lp_item_id . "') AND view_count = '$max_view_count'"; + Database::query($sql_update_score); + } + + /* + /* // update score and total_time from last attempt when you qualify the exercise in Learning path detail $sql_update_score = "UPDATE $TBL_LP_ITEM_VIEW SET score = '" . (float) $score . "',total_time = '" . (int) $total_time . "' WHERE lp_item_id = '" . (int) $lp_item_view_id . "' AND lp_view_id = (SELECT id from $TBL_LP_VIEW WHERE user_id = '" . (int) $student_id . "' and lp_id='" . (int) $lp_item_id . "') AND view_count = '$max_view_count'"; Database::query($sql_update_score);*/ // update max_score from a exercise in lp - $sql_update_max_score = "UPDATE $TBL_LP_ITEM SET max_score = '" . (float) $totalWeighting . "' WHERE id = '" . (int) $lp_item_view_id . "'"; + //$sql_update_max_score = "UPDATE $TBL_LP_ITEM SET max_score = '" . (float) $totalWeighting . "' WHERE id = '" . (int) $lp_item_view_id . "'"; - Database::query($sql_update_max_score); + //Database::query($sql_update_max_score); } } From 79e4baad0a72401e09dc5f3201b89c14f907d608 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Fri, 21 May 2010 12:56:29 +0200 Subject: [PATCH 47/63] Cleaning code --- main/announcements/announcements.inc.php | 181 +++++++++++------------ main/announcements/announcements.php | 52 +++---- main/announcements/download.php | 31 +--- 3 files changed, 113 insertions(+), 151 deletions(-) diff --git a/main/announcements/announcements.inc.php b/main/announcements/announcements.inc.php index 1c13a7e918..3b9d2b0ba2 100755 --- a/main/announcements/announcements.inc.php +++ b/main/announcements/announcements.inc.php @@ -1,18 +1,13 @@ -\n"; - echo "\n"; - echo "\n"; - echo "\n"; + echo "
"; if ($rows[$display_post_id]['user_id']=='0') { $name=prepare4display($rows[$display_post_id]['poster_name']); @@ -200,13 +200,13 @@ $id_attach = !empty($attachment_list)?$attachment_list['id']:''; // The course admin him/herself can do this off course always if (($current_forum['allow_edit']==1 AND $rows[$display_post_id]['user_id']==$_user['user_id']) or (api_is_allowed_to_edit(false,true) && !(api_is_course_coach() && $current_forum['session_id']!=$_SESSION['id_session']))) { - echo "".icon('../img/edit.gif',get_lang('Edit'))."\n"; + echo "".icon('../img/edit.gif',get_lang('Edit')).""; } if (api_is_allowed_to_edit(false,true) && !(api_is_course_coach() && $current_forum['session_id']!=$_SESSION['id_session'])) { - echo "".icon('../img/delete.gif',get_lang('Delete'))."\n"; + echo "".icon('../img/delete.gif',get_lang('Delete')).""; display_visible_invisible_icon('post', $rows[$display_post_id]['post_id'], $rows[$display_post_id]['visible'],array('forum'=>Security::remove_XSS($_GET['forum']),'thread'=>Security::remove_XSS($_GET['thread']), 'post'=>Security::remove_XSS($_GET['post']) )); - echo "\n"; + echo ""; //verified the post minor $my_post=get_posts($_GET['thread']); $id_posts=array(); @@ -221,7 +221,7 @@ if (api_is_allowed_to_edit(false,true) && !(api_is_course_coach() && $current_f $post_minor=(int)$id_posts[0]; $post_id = isset($_GET['post'])?(int)$_GET['post']:0; if (!isset($_GET['id']) && $post_id>$post_minor) { - echo "".icon('../img/deplacer_fichier.gif',get_lang('MovePost'))."\n"; + echo "".icon('../img/deplacer_fichier.gif',get_lang('MovePost')).""; } } $userinf=api_get_user_info($rows[$display_post_id]['user_id']); @@ -232,7 +232,7 @@ if (api_is_allowed_to_edit(null,true)) { if($user_status!=1) { $current_qualify_thread=show_qualify('1',$_GET['cidReq'],$_GET['forum'],$rows[$display_post_id]['user_id'],$_GET['thread']); - echo "".icon('../img/new_test_small.gif',get_lang('Qualify'))."\n"; + echo "".icon('../img/new_test_small.gif',get_lang('Qualify')).""; } } } @@ -243,8 +243,8 @@ if ($current_forum_category['locked']==0 AND $current_forum['locked']==0 AND $cu if ($_user['user_id'] OR ($current_forum['allow_anonymous']==1 AND !$_user['user_id'])) { if (!api_is_anonymous() && api_is_allowed_to_session_edit(false,true)) { - echo ''.Display :: return_icon('message_reply_forum.png', get_lang('ReplyToMessage'))."\n"; - echo ''.Display :: return_icon('quote.gif', get_lang('QuoteMessage'))."\n"; + echo ''.Display :: return_icon('message_reply_forum.png', get_lang('ReplyToMessage')).""; + echo ''.Display :: return_icon('quote.gif', get_lang('QuoteMessage')).""; } } } @@ -263,7 +263,7 @@ else echo get_lang('ThreadLocked').'
'; } } -echo "
".prepare4display(Security::remove_XSS($rows[$display_post_id]['post_title'], STUDENT))."
".prepare4display(Security::remove_XSS($rows[$display_post_id]['post_title'], STUDENT))."
".prepare4display(Security::remove_XSS($rows[$display_post_id]['post_text'], STUDENT))."
".prepare4display(Security::remove_XSS($rows[$display_post_id]['post_text'], STUDENT))."
" . $title . "
" . get_lang('AnnouncementPublishedOn') . " : " . api_convert_and_format_date($last_post_datetime, null, date_default_timezone_get()) . "
$content
"; + echo ""; + echo ""; + echo ""; echo "
" . $title . "
" . get_lang('AnnouncementPublishedOn') . " : " . api_convert_and_format_date($last_post_datetime, null, date_default_timezone_get()) . "
$content
"; } -/*====================================== +/* SHOW_TO_FORM -======================================*/ +*/ /** * this function shows the form for sending a message to a specific group or user. */ -function show_to_form($to_already_selected) -{ +function show_to_form($to_already_selected) { $user_list=get_course_users(); $group_list=get_course_groups(); if ($to_already_selected == "") $to_already_selected = array(); - echo "\n\n"; - echo "\t\n"; + echo "
"; + echo "\t"; // the form containing all the groups and all the users of the course - echo "\t\t\n"; + echo ""; // the buttons for adding or removing groups/users - echo "\n\t\t"; + echo "\n"; - echo "\t\n"; + echo ""; + echo ""; echo "
\n"; + echo ""; echo "".get_lang('Users')."
"; construct_not_selected_select_form($group_list,$user_list,$to_already_selected); - echo "\t\t
\n"; - /*echo "\t\t"; + /*echo "> \">", - "\n\t\t

 

", + "

 

", - "\n\t\t";*/ @@ -108,28 +100,28 @@ function show_to_form($to_already_selected)

\n"; - echo "\n\t\t
\n"; + echo ""; // the form containing the selected groups and users echo "".get_lang('DestinationUsers')."
"; construct_selected_select_form($group_list,$user_list,$to_already_selected); - echo "\t\t
"; } -/*=========================================== +/* CONSTRUCT_NOT_SELECT_SELECT_FORM -===========================================*/ +*/ /** * this function shows the form for sending a message to a specific group or user. */ function construct_not_selected_select_form($group_list=null, $user_list=null,$to_already_selected) { - echo "\t\t"; // adding the groups to the select form if ($group_list) { @@ -139,14 +131,14 @@ function construct_not_selected_select_form($group_list=null, $user_list=null,$t { if (!in_array("GROUP:".$this_group['id'],$to_already_selected)) // $to_already_selected is the array containing the groups (and users) that are already selected { - echo "\t\t\n"; + ""; } } } // a divider - echo "\t\t\n"; + echo ""; } // adding the individual users to the select form if ($user_list) { @@ -155,21 +147,21 @@ function construct_not_selected_select_form($group_list=null, $user_list=null,$t if (is_array($to_already_selected)) { if (!in_array("USER:".$this_user['user_id'],$to_already_selected)) // $to_already_selected is the array containing the users (and groups) that are already selected { - echo "\t\t\n"; + ""; } } } } - echo "\t\t\n"; + echo ""; } -/*========================================== +/* CONSTRUCT_SELECTED_SELECT_FORM -==========================================*/ +*/ /** * this function shows the form for sending a message to a specific group or user. */ @@ -190,20 +182,20 @@ function construct_selected_select_form($group_list=null, $user_list=null,$to_al $ref_array_users=get_course_users(); // we construct the form of the already selected groups / users - echo "\t\t"; if (is_array($to_already_selected)) { foreach($to_already_selected as $groupuser) { list($type,$id)=explode(":",$groupuser); if ($type=="GROUP") { - echo "\t\t"; + echo ""; } else { foreach($ref_array_users as $key=>$value){ if($value['user_id']==$id){ - echo "\t\t"; + echo ""; break; } } @@ -219,9 +211,9 @@ function construct_selected_select_form($group_list=null, $user_list=null,$to_al //api_display_normal_message("group " . $thisGroup[id] . $thisGroup[name]); if (!is_array($to_already_selected) || !in_array("GROUP:".$this_group['id'],$to_already_selected)) // $to_already_selected is the array containing the groups (and users) that are already selected { - echo "\t\t\n"; + ""; } } } @@ -230,14 +222,14 @@ function construct_selected_select_form($group_list=null, $user_list=null,$to_al { if (!is_array($to_already_selected) || !in_array("USER:".$this_user['user_id'],$to_already_selected)) // $to_already_selected is the array containing the users (and groups) that are already selected { - echo "\t\t\n"; + ""; } } } } - echo "\n"; + echo ""; } @@ -247,29 +239,29 @@ function construct_selected_select_form($group_list=null, $user_list=null,$to_al function show_to_form_group($group_id) { - echo "\n\n"; - echo "\t\n"; + echo "
"; + echo ""; - echo "\t\t\n"; + echo ""; // the buttons for adding or removing groups/users - echo "\n\t\t"; + echo "\n"; - echo "\t\n"; + echo ""; + echo ""; echo "
\n"; + echo ""; - echo "\t\t"; $group_users = GroupManager::get_subscribed_users($group_id); foreach ($group_users as $user){ echo ''; } echo ''; - echo "\t\t\n"; - /*echo "\t\t"; + /*echo "> \">", - "\n\t\t

 

", + "

 

", - "\n\t\t";*/ @@ -278,22 +270,20 @@ function show_to_form_group($group_id)

\n"; - echo "\n\t\t
\n"; + echo ""; - echo "\t\t"; echo ''; - echo "\t\t
"; } /* -============================================================================== DATA FUNCTIONS -============================================================================== */ /** @@ -331,9 +321,10 @@ function get_course_groups() return $new_group_list; } -/*====================================== +/* + * LOAD_EDIT_USERS -======================================*/ +*/ /** * This tools loads all the users and all the groups who have received * a specific item (in this case an announcement item) @@ -371,9 +362,9 @@ function load_edit_users($tool, $id) -/*====================================== +/* USER_GROUP_FILTER_JAVASCRIPT -======================================*/ +*/ /** * returns the javascript for setting a filter * this goes into the $htmlHeadXtra[] array @@ -393,9 +384,9 @@ function user_group_filter_javascript() } -/*====================================== +/* TO_JAVASCRIPT -========================================*/ +*/ /** * returns all the javascript that is required for easily * setting the target people/groups @@ -552,9 +543,9 @@ function plus_attachment() { } -/*====================================== +/* SENT_TO_FORM -======================================*/ +*/ /** * constructs the form to display all the groups and users the message has been sent to * input: $sent_to_array is a 2 dimensional array containing the groups and the users @@ -593,14 +584,14 @@ function sent_to_form($sent_to_array) // starting the form if there is more than one user/group if ($total_numbers >1) { - $output=""; $output.=""; // outputting the name of the groups if (is_array($sent_to_array['groups'])) { foreach ($sent_to_array['groups'] as $group_id) { - $output.="\t\n"; + $output.=""; } } @@ -611,13 +602,13 @@ function sent_to_form($sent_to_array) foreach ($sent_to_array['users'] as $user_id) { $user_info = api_get_user_info($user_id); - $output.="\t\n"; + $output.=""; } } } // ending the form - $output.="\n"; + $output.=""; } else // there is only one user/group { @@ -643,9 +634,9 @@ function sent_to_form($sent_to_array) } -/*====================================== +/* SEPARATE_USERS_GROUPS - ======================================*/ +*/ /** * This function separates the users from the groups * users have a value USER:XXX (with XXX the dokeos id @@ -674,9 +665,9 @@ function separate_users_groups($to) -/*====================================== +/* SENT_TO() - ======================================*/ +*/ /** * Returns all the users and all the groups a specific announcement item * has been sent to @@ -776,8 +767,7 @@ function change_visibility_announcement($tool,$id) function store_advalvas_item($emailTitle, $newContent, $order, $to, $file = array(), $file_comment='') { global $_course; - global $nameTools; - global $_user; + global $nameTools; $tbl_announcement = Database::get_course_table(TABLE_ANNOUNCEMENT); $tbl_item_property = Database::get_course_table(TABLE_ITEM_PROPERTY); @@ -809,7 +799,7 @@ function store_advalvas_item($emailTitle, $newContent, $order, $to, $file = arra { foreach ($send_to['groups'] as $group) { - api_item_property_update($_course, TOOL_ANNOUNCEMENT, $last_id, "AnnouncementAdded", $_user['user_id'], $group); + api_item_property_update($_course, TOOL_ANNOUNCEMENT, $last_id, "AnnouncementAdded", api_get_user_id(), $group); } } @@ -818,23 +808,21 @@ function store_advalvas_item($emailTitle, $newContent, $order, $to, $file = arra { foreach ($send_to['users'] as $user) { - api_item_property_update($_course, TOOL_ANNOUNCEMENT, $last_id, "AnnouncementAdded", $_user['user_id'], '', $user); + api_item_property_update($_course, TOOL_ANNOUNCEMENT, $last_id, "AnnouncementAdded", api_get_user_id(), '', $user); } } } else // the message is sent to everyone, so we set the group to 0 { - api_item_property_update($_course, TOOL_ANNOUNCEMENT, $last_id, "AnnouncementAdded", $_user['user_id'], '0'); + api_item_property_update($_course, TOOL_ANNOUNCEMENT, $last_id, "AnnouncementAdded", api_get_user_id(), '0'); } return $last_id; } -function store_advalvas_group_item($emailTitle,$newContent, $order, $to, $to_users, $file = array(), $file_comment='') -{ +function store_advalvas_group_item($emailTitle,$newContent, $order, $to, $to_users, $file = array(), $file_comment='') { global $_course; global $nameTools; - global $_user; // database definitions $tbl_announcement = Database::get_course_table(TABLE_ANNOUNCEMENT); @@ -868,7 +856,7 @@ function store_advalvas_group_item($emailTitle,$newContent, $order, $to, $to_use { foreach ($send_to['groups'] as $group) { - api_item_property_update($_course, TOOL_ANNOUNCEMENT, $last_id, "AnnouncementAdded", $_user['user_id'], $group); + api_item_property_update($_course, TOOL_ANNOUNCEMENT, $last_id, "AnnouncementAdded", api_get_user_id(), $group); } } } @@ -879,7 +867,7 @@ function store_advalvas_group_item($emailTitle,$newContent, $order, $to, $to_use { foreach ($to_users as $user) { - api_item_property_update($_course, TOOL_ANNOUNCEMENT, $last_id, "AnnouncementAdded", $_user['user_id'], '', $user); + api_item_property_update($_course, TOOL_ANNOUNCEMENT, $last_id, "AnnouncementAdded", api_get_user_id(), '', $user); } } } @@ -901,8 +889,7 @@ function edit_advalvas_item($id,$emailTitle,$newContent,$to,$file = array(), $fi global $_course; global $nameTools; - global $_user; - + global $tbl_announcement; global $tbl_item_property; @@ -940,7 +927,7 @@ function edit_advalvas_item($id,$emailTitle,$newContent,$to,$file = array(), $fi { foreach ($send_to['groups'] as $group) { - api_item_property_update($_course, TOOL_ANNOUNCEMENT, $id, "AnnouncementUpdated", $_user['user_id'], $group); + api_item_property_update($_course, TOOL_ANNOUNCEMENT, $id, "AnnouncementUpdated", api_get_user_id(), $group); } } // storing the selected users @@ -948,21 +935,19 @@ function edit_advalvas_item($id,$emailTitle,$newContent,$to,$file = array(), $fi { foreach ($send_to['users'] as $user) { - api_item_property_update($_course, TOOL_ANNOUNCEMENT, $id, "AnnouncementUpdated", $_user['user_id'], 0, $user); + api_item_property_update($_course, TOOL_ANNOUNCEMENT, $id, "AnnouncementUpdated", api_get_user_id(), 0, $user); } } } else // the message is sent to everyone, so we set the group to 0 { - api_item_property_update($_course, TOOL_ANNOUNCEMENT, $id, "AnnouncementUpdated", $_user['user_id'], '0'); + api_item_property_update($_course, TOOL_ANNOUNCEMENT, $id, "AnnouncementUpdated", api_get_user_id(), '0'); } } /* -============================================================================== MAIL FUNCTIONS -============================================================================== */ /** diff --git a/main/announcements/announcements.php b/main/announcements/announcements.php index dcb27e71d5..634b63e0dd 100755 --- a/main/announcements/announcements.php +++ b/main/announcements/announcements.php @@ -893,8 +893,8 @@ if (!$surveyid) { if (empty($_GET['origin']) OR $_GET['origin'] !== 'learnpath') { echo "\n\n\n"; - echo "\t\n"; - echo "\t\t\n"; + echo "
\n"; + echo "
\n"; } /* @@ -902,12 +902,12 @@ if (empty($_GET['origin']) OR $_GET['origin'] !== 'learnpath') { */ if (!$surveyid) { if ($display_title_list == true) { - echo "\t\t\t\n"; + echo "
\n"; while ($myrow = Database::fetch_array($result)) { $title = $myrow['title']; $title = Security::remove_XSS($title); - echo "\t\t\t\t\n"; - echo "\t\t\t\t\t\n"; + echo "\n\t\t\t\t\n"; + echo Display::return_icon('lp_announcement.png', api_convert_and_format_date($myrow['end_date'], DATE_FORMAT_LONG), array('align' => 'absmiddle', 'Width' => '10', 'Height' => '10'))." " . api_trunc_str($title, $length) . "\n" . $session_img; + echo "\n\n"; } - echo "\t\t\t
\n"; + echo "
\n"; if ($myrow['visibility']==0) { $class="class=\"invisible\""; } else { @@ -916,18 +916,18 @@ if (!$surveyid) { //validation when belongs to a session $session_img = api_get_session_image($myrow['session_id'], $_user['status']); - echo "\t\t\t\t\t\t".Display::return_icon('lp_announcement.png', api_convert_and_format_date($myrow['end_date'], DATE_FORMAT_LONG), array('align' => 'absmiddle', 'Width' => '10', 'Height' => '10'))." " . api_trunc_str($title, $length) . "\n" . $session_img; - echo "\t\t\t\t\t
\n"; + echo "
\n"; } // end $display_title_list == true } if (empty($_GET['origin']) or $_GET['origin'] !== 'learnpath') { - echo "\t\t\n"; - echo "\t\t \n"; + echo "\n"; + echo " \n"; // START RIGHT PART - echo "\t\t\n"; + echo "\n"; } /* @@ -1310,7 +1310,7 @@ if ($display_announcement_list && !$surveyid) { $iterator = 1; $bottomAnnouncement = $announcement_number; - echo "\t\t\t\n"; + echo "
\n"; $displayed=array(); @@ -1339,46 +1339,46 @@ if ($display_announcement_list && !$surveyid) { $style = ''; } - echo "\t\t\t\t"; + echo ""; /* THE ICONS */ - echo "\t\t\t\t\t\n"; + echo "\n"; /* TITLE */ - echo "\t\t\t\t\t\n"; - echo "\t\t\t\t\t\n"; + echo "\n","\t\t\t\t\n"; - echo "\t\t\t\t\n\t\t\t\t\t"; + echo "\n\n\t\t\t\t\n"; + echo "\n\n"; /* CONTENT */ - echo "\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\n"; + echo "\n\n"; /* RESOURCES */ - echo "\n\n\n"; + echo ""; $iterator ++; } else { // end of is_allowed_to_edit diff --git a/main/announcements/download.php b/main/announcements/download.php index 921d53eb79..1ec5e3eb2d 100755 --- a/main/announcements/download.php +++ b/main/announcements/download.php @@ -1,48 +1,25 @@ - Date: Fri, 21 May 2010 13:06:54 +0200 Subject: [PATCH 48/63] More code cleaning, removing old global definitions, removing die() function, removing tags \t \n --- main/announcements/announcements.inc.php | 63 +++++++++--------------- main/announcements/announcements.php | 23 ++++----- 2 files changed, 32 insertions(+), 54 deletions(-) diff --git a/main/announcements/announcements.inc.php b/main/announcements/announcements.inc.php index 3b9d2b0ba2..27591735a7 100755 --- a/main/announcements/announcements.inc.php +++ b/main/announcements/announcements.inc.php @@ -10,26 +10,22 @@ $tbl_announcement_attachment = Database::get_course_table(TABLE_ANNOUNCEMENT_ATT DISPLAY FUNCTIONS */ /** -* displays one specific announcement +* Displays one specific announcement * @param $announcement_id, the id of the announcement you want to display -* @todo remove globals -* @todo more security checking */ -function display_announcement($announcement_id) { - global $_user, $dateFormatLong; +function display_announcement($announcement_id) { if ($announcement_id != strval(intval($announcement_id))) { return false; } // potencial sql injection $tbl_announcement = Database::get_course_table(TABLE_ANNOUNCEMENT); $tbl_item_property = Database::get_course_table(TABLE_ITEM_PROPERTY); - if ($_user['user_id']) - { + if (api_get_user_id() != 0) { $sql_query = " SELECT announcement.*, toolitemproperties.* FROM $tbl_announcement announcement, $tbl_item_property toolitemproperties WHERE announcement.id = toolitemproperties.ref AND announcement.id = '$announcement_id' AND toolitemproperties.tool='announcement' - AND (toolitemproperties.to_user_id='".intval($_user['user_id'])."' OR toolitemproperties.to_group_id='0') + AND (toolitemproperties.to_user_id='".api_get_user_id()."' OR toolitemproperties.to_group_id='0') AND toolitemproperties.visibility='1' ORDER BY display_order DESC"; @@ -43,7 +39,7 @@ function display_announcement($announcement_id) { AND toolitemproperties.visibility='1'"; } $sql_result = Database::query($sql_query); - $result = Database::fetch_array($sql_result); + $result = Database::fetch_array($sql_result); if ($result !== false) { // A sanity check. $title = $result['title']; @@ -62,7 +58,7 @@ function display_announcement($announcement_id) { } /* - SHOW_TO_FORM + SHOW_TO_FORM */ /** * this function shows the form for sending a message to a specific group or user. @@ -165,8 +161,7 @@ function construct_not_selected_select_form($group_list=null, $user_list=null,$t /** * this function shows the form for sending a message to a specific group or user. */ -function construct_selected_select_form($group_list=null, $user_list=null,$to_already_selected) -{ +function construct_selected_select_form($group_list=null, $user_list=null,$to_already_selected) { // we separate the $to_already_selected array (containing groups AND users into // two separate arrays $groupuser = array(); @@ -329,16 +324,14 @@ function get_course_groups() * This tools loads all the users and all the groups who have received * a specific item (in this case an announcement item) */ -function load_edit_users($tool, $id) -{ - global $_course; +function load_edit_users($tool, $id) { global $tbl_item_property; $tool = Database::escape_string($tool); $id = Database::escape_string($id); $sql = "SELECT * FROM $tbl_item_property WHERE tool='$tool' AND ref='$id'"; - $result = Database::query($sql) or die(Database::error()); + $result = Database::query($sql); while ($row = Database::fetch_array($result)) { $to_group=$row['to_group_id']; @@ -736,18 +729,15 @@ function change_visibility_announcement($tool,$id) $sql = "SELECT * FROM $tbl_item_property WHERE tool='$tool' AND ref='$id'"; - $result = Database::query($sql) or die(Database::error()); + $result = Database::query($sql); $row = Database::fetch_array($result); - if ($row['visibility']=='1') - { + if ($row['visibility']=='1') { $sql_visibility="UPDATE $tbl_item_property SET visibility='0' WHERE tool='$tool' AND ref='$id'"; - } - else - { + } else { $sql_visibility="UPDATE $tbl_item_property SET visibility='1' WHERE tool='$tool' AND ref='$id'"; } - $result=Database::query($sql_visibility); + $result = Database::query($sql_visibility); if ($result === false) { return false; } @@ -778,7 +768,7 @@ function store_advalvas_item($emailTitle, $newContent, $order, $to, $file = arra $order = intval($order); // store in the table announcement - $sql = "INSERT INTO $tbl_announcement SET content = '$newContent', title = '$emailTitle', end_date = NOW(), display_order ='$order', session_id=".intval($_SESSION['id_session']); + $sql = "INSERT INTO $tbl_announcement SET content = '$newContent', title = '$emailTitle', end_date = NOW(), display_order ='$order', session_id=".api_get_session_id(); $result = Database::query($sql); if ($result === false) { return false; @@ -834,8 +824,8 @@ function store_advalvas_group_item($emailTitle,$newContent, $order, $to, $to_use $order = intval($order); // store in the table announcement - $sql = "INSERT INTO $tbl_announcement SET content = '$newContent', title = '$emailTitle', end_date = NOW(), display_order ='$order', session_id=".intval($_SESSION['id_session']); - $result = Database::query($sql) or die(Database::error()); + $sql = "INSERT INTO $tbl_announcement SET content = '$newContent', title = '$emailTitle', end_date = NOW(), display_order ='$order', session_id=".api_get_session_id(); + $result = Database::query($sql); if ($result === false) { return false; } @@ -884,8 +874,7 @@ function store_advalvas_group_item($emailTitle,$newContent, $order, $to, $to_use * This function stores the announcement Item in the table announcement * and updates the item_property also */ -function edit_advalvas_item($id,$emailTitle,$newContent,$to,$file = array(), $file_comment='') -{ +function edit_advalvas_item($id,$emailTitle,$newContent,$to,$file = array(), $file_comment='') { global $_course; global $nameTools; @@ -900,7 +889,7 @@ function edit_advalvas_item($id,$emailTitle,$newContent,$to,$file = array(), $fi // store the modifications in the table announcement $sql = "UPDATE $tbl_announcement SET content='$newContent', title = '$emailTitle' WHERE id='$id'"; - $result = Database::query($sql) or die(Database::error()); + $result = Database::query($sql); // save attachment file $row_attach = get_attachment($id); @@ -916,7 +905,7 @@ function edit_advalvas_item($id,$emailTitle,$newContent,$to,$file = array(), $fi // we remove everything from item_property for this $sql_delete="DELETE FROM $tbl_item_property WHERE ref='$id' AND tool='announcement'"; - $result = Database::query($sql_delete) or die(Database::error()); + $result = Database::query($sql_delete); // store in item_property (first the groups, then the users if (!is_null($to)) // !is_null($to): when no user is selected we send it to everyone @@ -972,10 +961,8 @@ function send_announcement_email($user_list, $course_code, $_course, $mail_title } } -function update_mail_sent($insert_id) -{ - global $_course; - global $tbl_announcement; +function update_mail_sent($insert_id) { + $tbl_announcement = Database::get_course_table(TABLE_ANNOUNCEMENT); if ($insert_id != strval(intval($insert_id))) { return false; } $insert_id = Database::escape_string($insert_id); // store the modifications in the table tbl_annoucement @@ -989,8 +976,7 @@ function update_mail_sent($insert_id) * @param int user id * @return array html with the content and count of announcements or false otherwise */ -function get_all_annoucement_by_user_course($course_db, $user_id) -{ +function get_all_annoucement_by_user_course($course_db, $user_id) { if (empty($course_db) || empty($user_id)) { return false; } @@ -1031,9 +1017,7 @@ function get_all_annoucement_by_user_course($course_db, $user_id) } /* -============================================================================== ATTACHMENT FUNCTIONS -============================================================================== */ /** @@ -1155,7 +1139,6 @@ function edit_announcement_attachment_file($id_attach, $file, $file_comment) { * */ function delete_announcement_attachment_file($id) { - global $_course; $tbl_announcement_attachment = Database::get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT); $id=Database::escape_string($id); @@ -1163,4 +1146,4 @@ function delete_announcement_attachment_file($id) { $result=Database::query($sql); // update item_property //api_item_property_update($_course, 'announcement_attachment', $id,'AnnouncementAttachmentDeleted', api_get_user_id()); -} +} \ No newline at end of file diff --git a/main/announcements/announcements.php b/main/announcements/announcements.php index 634b63e0dd..0285b4132b 100755 --- a/main/announcements/announcements.php +++ b/main/announcements/announcements.php @@ -3,10 +3,11 @@ /** * @author Frederik Vermeire , UGent Internship * @author Patrick Cool , Ghent University: code cleaning + * @author Julio MMontoya , MORE code cleaning * @abstract The task of the internship was to integrate the 'send messages to specific users' with the * Announcements tool and also add the resource linker here. The database also needed refactoring * as there was no title field (the title was merged into the content field) - * @package dokeos.announcements + * @package chamilo.announcements * @todo make AWACS out of the configuration settings * @todo this file is 1200+ lines without any functions -> needs to be split into * multiple functions @@ -15,9 +16,7 @@ INIT SECTION */ // name of the language file that needs to be included -$language_file[] = 'announcements'; -$language_file[] = 'group'; -$language_file[] = 'survey'; +$language_file[] = array('announcements', 'group', 'survey'); // use anonymous mode when accessing this course tool $use_anonymous = true; @@ -25,10 +24,8 @@ $use_anonymous = true; // setting the global file that gets the general configuration, the databases, the languages, ... require_once '../inc/global.inc.php'; $this_section=SECTION_COURSES; - $nameTools = get_lang('ToolAnnouncement'); - //session if(isset($_GET['id_session'])) { $_SESSION['id_session'] = intval($_GET['id_session']); @@ -92,9 +89,7 @@ if (!empty($_POST['addresources'])) // When the "Add Resource" button is clicked { header("Location: ../resourcelinker/resourcelinker.php?source_id=7&action=$action&id=$id&originalresource=no&publish_survey=$surveyid&db_name=$db_name&cidReq=$cidReq"); exit; - } - else - { + } else { header("Location: ../resourcelinker/resourcelinker.php?source_id=7&action=$action&id=$id&originalresource=no"); exit; } @@ -500,7 +495,7 @@ if (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_ed if ($ctok == $_POST['sec_token']) { if (!$surveyid) { - $result = Database::query("SELECT MAX(display_order) FROM $tbl_announcement WHERE session_id=".intval($_SESSION['id_session'])." OR session_id=0"); + $result = Database::query("SELECT MAX(display_order) FROM $tbl_announcement WHERE session_id=".api_get_session_id()." OR session_id=0"); list($orderMax) = Database::fetch_row($result); $order = $orderMax + 1; $file = $_FILES['user_upload']; @@ -625,7 +620,7 @@ if (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_ed INNER JOIN $tbl_session_course_user ON $tbl_user.user_id = $tbl_session_course_user.id_user AND $tbl_session_course_user.course_code = '".$_course['id']."' - AND $tbl_session_course_user.id_session = ".intval($_SESSION['id_session']); + AND $tbl_session_course_user.id_session = ".api_get_session(); } } @@ -981,7 +976,7 @@ if ($display_form == true) { // we want to remind inactive users. The $_GET['since'] parameter determines which users have to be warned (i.e the users who have been inactive for x days or more $since = isset($_GET['since']) ? intval($_GET['since']) : 6; // getting the users who have to be reminded - $to = Tracking :: get_inactives_students_in_course($_course['id'],$since, $_SESSION['id_session']); + $to = Tracking :: get_inactives_students_in_course($_course['id'],$since, api_get_session_id()); // setting the variables for the form elements: the users who need to receive the message foreach($to as &$user) { $user = 'USER:'.$user; @@ -1272,7 +1267,7 @@ if ($display_announcement_list && !$surveyid) { $cond_user_id $condition_session AND ip.visibility='1' - AND announcement.session_id IN(0,".intval($_SESSION['id_session']).") + AND announcement.session_id IN(0,".api_get_session_id().") ORDER BY display_order DESC"; } else { @@ -1290,7 +1285,7 @@ if ($display_announcement_list && !$surveyid) { $cond_user_id $condition_session AND ip.visibility='1' - AND announcement.session_id IN(0,".intval($_SESSION['id_session']).")"; + AND announcement.session_id IN(0,".api_get_session_id().")"; } } From db356b9846f627c374dd21bffada7259d732e83c Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Fri, 21 May 2010 15:12:26 +0200 Subject: [PATCH 49/63] Cleaning code --- main/inc/lib/main_api.lib.php | 78 +++++++++++++++-------------------- 1 file changed, 34 insertions(+), 44 deletions(-) diff --git a/main/inc/lib/main_api.lib.php b/main/inc/lib/main_api.lib.php index cb17a2f322..a7b472f5b4 100755 --- a/main/inc/lib/main_api.lib.php +++ b/main/inc/lib/main_api.lib.php @@ -2319,19 +2319,20 @@ function api_get_item_visibility($_course, $tool, $id) { function api_item_property_update($_course, $tool, $item_id, $lastedit_type, $user_id, $to_group_id = 0, $to_user_id = null, $start_visible = 0, $end_visible = 0, $session_id = 0) { // Definition of variables - $tool = Database::escape_string($tool); - $item_id = Database::escape_string($item_id); - $lastedit_type = Database::escape_string($lastedit_type); - $user_id = Database::escape_string($user_id); - $to_group_id = Database::escape_string($to_group_id); - $to_user_id = Database::escape_string($to_user_id); - $start_visible = Database::escape_string($start_visible); - $end_visible = Database::escape_string($end_visible); - $start_visible = ($start_visible == 0) ? '0000-00-00 00:00:00' : $start_visible; - $end_visible = ($end_visible == 0) ? '0000-00-00 00:00:00' : $end_visible; - $to_filter = ''; - $time = time(); - $time = date('Y-m-d H:i:s', $time); + $tool = Database::escape_string($tool); + $item_id = Database::escape_string($item_id); + $lastedit_type = Database::escape_string($lastedit_type); + $user_id = Database::escape_string($user_id); + $to_group_id = Database::escape_string($to_group_id); + $to_user_id = Database::escape_string($to_user_id); + $start_visible = Database::escape_string($start_visible); + $end_visible = Database::escape_string($end_visible); + $start_visible = ($start_visible == 0) ? '0000-00-00 00:00:00' : $start_visible; + $end_visible = ($end_visible == 0) ? '0000-00-00 00:00:00' : $end_visible; + $to_filter = ''; + $time = time(); + $time = date('Y-m-d H:i:s', $time); + if (!empty($session_id)) { $session_id = intval($session_id); } else { @@ -2379,8 +2380,10 @@ function api_item_property_update($_course, $tool, $item_id, $lastedit_type, $us $to_filter = " AND to_group_id='$to_group_id' $condition_session"; // Set filter to intended group } } + // Update if possible $set_type = ''; + switch ($lastedit_type) { case 'delete' : // delete = make item only visible for the platform admin $visibility = '2'; @@ -2395,18 +2398,14 @@ function api_item_property_update($_course, $tool, $item_id, $lastedit_type, $us SET lastedit_type='".str_replace('_', '', ucwords($tool))."Deleted', lastedit_date='$time', lastedit_user_id='$user_id', visibility='$visibility', id_session = '$session_id' $set_type WHERE $filter"; } else { - - $sql = "INSERT INTO $TABLE_ITEMPROPERTY - (tool, ref, insert_date, insert_user_id, lastedit_date, lastedit_type, lastedit_user_id,$to_field, visibility, start_visible, end_visible, id_session) - VALUES ('$tool','$item_id','$time', '$user_id', '$time', '$lastedit_type','$user_id', '$to_value', '$visibility', '$start_visible','$end_visible', '$session_id')"; + $sql = "INSERT INTO $TABLE_ITEMPROPERTY (tool, ref, insert_date, insert_user_id, lastedit_date, lastedit_type, lastedit_user_id,$to_field, visibility, start_visible, end_visible, id_session) + VALUES ('$tool','$item_id','$time', '$user_id', '$time', '$lastedit_type','$user_id', '$to_value', '$visibility', '$start_visible','$end_visible', '$session_id')"; } } else { - $sql = "UPDATE $TABLE_ITEMPROPERTY - SET lastedit_type='".str_replace('_', '', ucwords($tool))."Deleted', lastedit_date='$time', lastedit_user_id='$user_id', visibility='$visibility' $set_type - WHERE $filter"; + $sql = "UPDATE $TABLE_ITEMPROPERTY SET lastedit_type='".str_replace('_', '', ucwords($tool))."Deleted', lastedit_date='$time', lastedit_user_id='$user_id', visibility='$visibility' $set_type + WHERE $filter"; } - break; case 'visible' : // Change item to visible $visibility = '1'; @@ -2421,18 +2420,14 @@ function api_item_property_update($_course, $tool, $item_id, $lastedit_type, $us SET lastedit_type='".str_replace('_', '', ucwords($tool))."Visible', lastedit_date='$time', lastedit_user_id='$user_id', visibility='$visibility', id_session = '$session_id' $set_type WHERE $filter"; } else { - - $sql = "INSERT INTO $TABLE_ITEMPROPERTY - (tool, ref, insert_date, insert_user_id, lastedit_date, lastedit_type, lastedit_user_id,$to_field, visibility, start_visible, end_visible, id_session) - VALUES ('$tool','$item_id','$time', '$user_id', '$time', '$lastedit_type','$user_id', '$to_value', '$visibility', '$start_visible','$end_visible', '$session_id')"; + $sql = "INSERT INTO $TABLE_ITEMPROPERTY (tool, ref, insert_date, insert_user_id, lastedit_date, lastedit_type, lastedit_user_id,$to_field, visibility, start_visible, end_visible, id_session) + VALUES ('$tool','$item_id','$time', '$user_id', '$time', '$lastedit_type','$user_id', '$to_value', '$visibility', '$start_visible','$end_visible', '$session_id')"; } - - } else { + } else { $sql = "UPDATE $TABLE_ITEMPROPERTY - SET lastedit_type='".str_replace('_', '', ucwords($tool))."Visible', lastedit_date='$time', lastedit_user_id='$user_id', visibility='$visibility' $set_type - WHERE $filter"; + SET lastedit_type='".str_replace('_', '', ucwords($tool))."Visible', lastedit_date='$time', lastedit_user_id='$user_id', visibility='$visibility' $set_type + WHERE $filter"; } - break; case 'invisible' : // Change item to invisible $visibility = '0'; @@ -2447,34 +2442,29 @@ function api_item_property_update($_course, $tool, $item_id, $lastedit_type, $us SET lastedit_type='".str_replace('_', '', ucwords($tool))."Invisible', lastedit_date='$time', lastedit_user_id='$user_id', visibility='$visibility', id_session = '$session_id' $set_type WHERE $filter"; } else { - - $sql = "INSERT INTO $TABLE_ITEMPROPERTY - (tool, ref, insert_date, insert_user_id, lastedit_date, lastedit_type, lastedit_user_id,$to_field, visibility, start_visible, end_visible, id_session) - VALUES ('$tool','$item_id','$time', '$user_id', '$time', '$lastedit_type','$user_id', '$to_value', '$visibility', '$start_visible','$end_visible', '$session_id')"; + $sql = "INSERT INTO $TABLE_ITEMPROPERTY (tool, ref, insert_date, insert_user_id, lastedit_date, lastedit_type, lastedit_user_id,$to_field, visibility, start_visible, end_visible, id_session) + VALUES ('$tool','$item_id','$time', '$user_id', '$time', '$lastedit_type','$user_id', '$to_value', '$visibility', '$start_visible','$end_visible', '$session_id')"; } } else { $sql = "UPDATE $TABLE_ITEMPROPERTY - SET lastedit_type='".str_replace('_', '', ucwords($tool))."Invisible', lastedit_date='$time', lastedit_user_id='$user_id', visibility='$visibility' $set_type - WHERE $filter"; + SET lastedit_type='".str_replace('_', '', ucwords($tool))."Invisible', lastedit_date='$time', lastedit_user_id='$user_id', visibility='$visibility' $set_type + WHERE $filter"; } - break; default : // The item will be added or updated $set_type = ", lastedit_type='$lastedit_type' "; $visibility = '1'; $filter .= $to_filter; $sql = "UPDATE $TABLE_ITEMPROPERTY - SET lastedit_date='$time', lastedit_user_id='$user_id' $set_type - WHERE $filter"; - } - + SET lastedit_date='$time', lastedit_user_id='$user_id' $set_type + WHERE $filter"; + } $res = Database::query($sql); // Insert if no entries are found (can only happen in case of $lastedit_type switch is 'default') if (Database::affected_rows() == 0) { - $sql = "INSERT INTO $TABLE_ITEMPROPERTY - (tool,ref,insert_date,insert_user_id,lastedit_date,lastedit_type, lastedit_user_id,$to_field, visibility, start_visible, end_visible, id_session) - VALUES ('$tool','$item_id','$time', '$user_id', '$time', '$lastedit_type','$user_id', '$to_value','$visibility','$start_visible','$end_visible', '$session_id')"; + $sql = "INSERT INTO $TABLE_ITEMPROPERTY (tool,ref,insert_date,insert_user_id,lastedit_date,lastedit_type, lastedit_user_id,$to_field, visibility, start_visible, end_visible, id_session) + VALUES ('$tool','$item_id','$time', '$user_id', '$time', '$lastedit_type','$user_id', '$to_value','$visibility','$start_visible','$end_visible', '$session_id')"; $res = Database::query($sql); if (!$res) { return false; From 73dba3b815d3c785668c7140276f273192f1b326 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Fri, 21 May 2010 15:25:53 +0200 Subject: [PATCH 50/63] More cleaning code --- main/announcements/announcements.inc.php | 630 +++++++++++------------ main/announcements/announcements.php | 24 +- 2 files changed, 303 insertions(+), 351 deletions(-) diff --git a/main/announcements/announcements.inc.php b/main/announcements/announcements.inc.php index 27591735a7..71d9b77f00 100755 --- a/main/announcements/announcements.inc.php +++ b/main/announcements/announcements.inc.php @@ -6,6 +6,268 @@ */ $tbl_announcement_attachment = Database::get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT); + +/** + * Store an announcement in the database (including its attached file if any) + * @param string Announcement title (pure text) + * @param string Content of the announcement (can be HTML) + * @param int Display order in the list of announcements + * @param array Array of users and groups to send the announcement to + * @param array uploaded file $_FILES + * @param string Comment describing the attachment + * @return int false on failure, ID of the announcement on success + */ +function store_advalvas_item($emailTitle, $newContent, $order, $to, $file = array(), $file_comment='') { + global $_course; + + $tbl_announcement = Database::get_course_table(TABLE_ANNOUNCEMENT); + $tbl_item_property = Database::get_course_table(TABLE_ITEM_PROPERTY); + + // filter data + $emailTitle = Database::escape_string($emailTitle); + $newContent = Database::escape_string($newContent); + $order = intval($order); + + // store in the table announcement + $sql = "INSERT INTO $tbl_announcement SET content = '$newContent', title = '$emailTitle', end_date = NOW(), display_order ='$order', session_id=".api_get_session_id(); + $result = Database::query($sql); + if ($result === false) { + return false; + } else { + //Store the attach file + $last_id = Database::insert_id(); + if (!empty($file)) { + $save_attachment = add_announcement_attachment_file($last_id, $file_comment, $_FILES['user_upload']); + } + + // store in item_property (first the groups, then the users + if (!is_null($to)) { + // !is_null($to): when no user is selected we send it to everyone + $send_to=separate_users_groups($to); + // storing the selected groups + if (is_array($send_to['groups'])) { + foreach ($send_to['groups'] as $group) { + api_item_property_update($_course, TOOL_ANNOUNCEMENT, $last_id, "AnnouncementAdded", api_get_user_id(), $group); + } + } + + // storing the selected users + if (is_array($send_to['users'])) { + foreach ($send_to['users'] as $user) { + api_item_property_update($_course, TOOL_ANNOUNCEMENT, $last_id, "AnnouncementAdded", api_get_user_id(), '', $user); + } + } + } else { + // the message is sent to everyone, so we set the group to 0 + api_item_property_update($_course, TOOL_ANNOUNCEMENT, $last_id, "AnnouncementAdded", api_get_user_id(), '0'); + } + return $last_id; + } +} + +/* + STORE ANNOUNCEMENT GROUP ITEM +*/ +function store_advalvas_group_item($emailTitle,$newContent, $order, $to, $to_users, $file = array(), $file_comment='') { + global $_course; + + // database definitions + $tbl_announcement = Database::get_course_table(TABLE_ANNOUNCEMENT); + $tbl_item_property = Database::get_course_table(TABLE_ITEM_PROPERTY); + + $newContent=stripslashes($newContent); + $emailTitle = Database::escape_string($emailTitle); + $newContent = Database::escape_string($newContent); + $order = intval($order); + + // store in the table announcement + $sql = "INSERT INTO $tbl_announcement SET content = '$newContent', title = '$emailTitle', end_date = NOW(), display_order ='$order', session_id=".api_get_session_id(); + $result = Database::query($sql); + if ($result === false) { + return false; + } + + //store the attach file + $last_id = Database::insert_id(); + if (empty($file)) { + $save_attachment = add_announcement_attachment_file($last_id, $file_comment, $file); + } + + + // store in item_property (first the groups, then the users + if (!isset($to_users)) // !isset($to): when no user is selected we send it to everyone + { + $send_to=separate_users_groups($to); + // storing the selected groups + if (is_array($send_to['groups'])) + { + foreach ($send_to['groups'] as $group) + { + api_item_property_update($_course, TOOL_ANNOUNCEMENT, $last_id, "AnnouncementAdded", api_get_user_id(), $group); + } + } + } + else // the message is sent to everyone, so we set the group to 0 + { + // storing the selected users + if (is_array($to_users)) + { + foreach ($to_users as $user) + { + api_item_property_update($_course, TOOL_ANNOUNCEMENT, $last_id, "AnnouncementAdded", api_get_user_id(), '', $user); + } + } + } + return $last_id; +} + + +/* + EDIT ANNOUNCEMENT +*/ +/** +* This function stores the announcement item in the announcement table +* and updates the item_property table +* +* @param int id of the announcement +* @param string email +* @param string content +* @param array users that will receive the announcement +* @param mixed attachment +* @param string file comment +* +*/ +function edit_advalvas_item($id, $emailTitle,$newContent,$to,$file = array(), $file_comment='') { + global $_course; + $tbl_item_property = Database::get_course_table(TABLE_ITEM_PROPERTY); + $tbl_announcement = Database::get_course_table(TABLE_ANNOUNCEMENT); + + $emailTitle = Database::escape_string($emailTitle); + $newContent = Database::escape_string($newContent); + $id = intval($id); + + // store the modifications in the table announcement + $sql = "UPDATE $tbl_announcement SET content='$newContent', title = '$emailTitle' WHERE id='$id'"; + $result = Database::query($sql); + + // save attachment file + $row_attach = get_attachment($id); + $id_attach = intval($row_attach['id']); + + if (!empty($file)) { + if (empty($id_attach)) { + add_announcement_attachment_file($id,$file_comment,$file); + } else { + edit_announcement_attachment_file($id_attach,$file,$file_comment); + } + } + + // we remove everything from item_property for this + $sql_delete="DELETE FROM $tbl_item_property WHERE ref='$id' AND tool='announcement'"; + $result = Database::query($sql_delete); + + // store in item_property (first the groups, then the users + if (!is_null($to)) { + // !is_null($to): when no user is selected we send it to everyone + + $send_to=separate_users_groups($to); + // storing the selected groups + if (is_array($send_to['groups'])) { + foreach ($send_to['groups'] as $group) { + api_item_property_update($_course, TOOL_ANNOUNCEMENT, $id, "AnnouncementUpdated", api_get_user_id(), $group); + } + } + // storing the selected users + if (is_array($send_to['users'])) { + foreach ($send_to['users'] as $user) { + api_item_property_update($_course, TOOL_ANNOUNCEMENT, $id, "AnnouncementUpdated", api_get_user_id(), 0, $user); + } + } + } else { + // the message is sent to everyone, so we set the group to 0 + api_item_property_update($_course, TOOL_ANNOUNCEMENT, $id, "AnnouncementUpdated", api_get_user_id(), '0'); + } +} + + +/* + MAIL FUNCTIONS +*/ + +/** +* Sends an announcement by email to a list of users. +* Emails are sent one by one to try to avoid antispam. +*/ +function send_announcement_email($user_list, $course_code, $_course, $mail_title, $mail_content) { + global $_user; + foreach ($user_list as $this_user) { + + $mail_subject = get_lang('professorMessage').' - '.$_course['official_code'].' - '.$mail_title; + $mail_body = '['.$_course['official_code'].'] - ['.$_course['name']."]\n"; + $mail_body .= api_get_person_name($this_user['firstname'], $this_user['lastname'], null, PERSON_NAME_EMAIL_ADDRESS).' <'.$this_user["email"]."> \n\n".stripslashes($mail_title)."\n\n".trim(stripslashes(api_html_entity_decode(strip_tags(str_replace(array('

','

','
'),array('',"\n","\n"),$mail_content)), ENT_QUOTES, api_get_system_encoding())))." \n\n-- \n"; + $mail_body .= api_get_person_name($_user['firstname'], $_user['lastname'], null, PERSON_NAME_EMAIL_ADDRESS).' '; + $mail_body .= '<'.$_user['mail'].">\n"; + $mail_body .= $_course['official_code'].' '.$_course['name']; + + @api_mail(api_get_person_name($this_user['firstname'], $this_user['lastname'], null, PERSON_NAME_EMAIL_ADDRESS), $this_user['email'], $mail_subject, $mail_body, api_get_person_name($_SESSION['_user']['firstname'], $_SESSION['_user']['lastname'], null, PERSON_NAME_EMAIL_ADDRESS), $_SESSION['_user']['mail']); + } +} + +function update_mail_sent($insert_id) { + $tbl_announcement = Database::get_course_table(TABLE_ANNOUNCEMENT); + if ($insert_id != strval(intval($insert_id))) { return false; } + $insert_id = Database::escape_string($insert_id); + // store the modifications in the table tbl_annoucement + $sql = "UPDATE $tbl_announcement SET email_sent='1' WHERE id='$insert_id'"; + Database::query($sql); +} + +/** + * Gets all announcements from a user by course + * @param string course db + * @param int user id + * @return array html with the content and count of announcements or false otherwise + */ +function get_all_annoucement_by_user_course($course_db, $user_id) { + if (empty($course_db) || empty($user_id)) { + return false; + } + $tbl_announcement = Database::get_course_table(TABLE_ANNOUNCEMENT, $course_db); + $tbl_item_property = Database::get_course_table(TABLE_ITEM_PROPERTY, $course_db); + if (!empty($user_id) && is_numeric($user_id)) { + $user_id = intval($user_id); + $sql="SELECT DISTINCT announcement.title, announcement.content + FROM $tbl_announcement announcement, $tbl_item_property toolitemproperties + WHERE announcement.id = toolitemproperties.ref + AND toolitemproperties.tool='announcement' + AND (toolitemproperties.insert_user_id='$user_id' AND (toolitemproperties.to_group_id='0' OR toolitemproperties.to_group_id is null)) + AND toolitemproperties.visibility='1' + AND announcement.session_id = 0 + ORDER BY display_order DESC"; + $rs = Database::query($sql); + $num_rows = Database::num_rows($rs); + $content = ''; + $i=0; + $result = array(); + if ($num_rows>0) { + while ($myrow = Database::fetch_array($rs)) { + //if ($i<=4) { + $content.= ''.$myrow['title'].'

'; + $content.= $myrow['content']; + /*} else { + break; + }*/ + $i++; + } + $result['content'] = $content; + $result['count'] = $i; + return $result; + } + return false; + } + return false; +} + /* DISPLAY FUNCTIONS */ @@ -231,14 +493,10 @@ function construct_selected_select_form($group_list=null, $user_list=null,$to_al /** * this function shows the form for sending a message to a specific group or user. */ -function show_to_form_group($group_id) -{ - +function show_to_form_group($group_id) { echo "
\n"; + echo "\n"; // anchoring echo "\n"; // User or group icon if ($myrow['to_group_id']!== '0' and $myrow['to_group_id']!== 'NULL') { - echo "\t\t\t\t\t\t".Display::return_icon('group.gif', get_lang('AnnounceSentToUserSelection'))."\n"; + echo Display::return_icon('group.gif', get_lang('AnnounceSentToUserSelection'))."\n"; } // the email icon if ($myrow['email_sent'] == '1') { - echo "\t\t\t\t\t\t".Display::return_icon('email.gif', get_lang('AnnounceSentByEmail'))."\n"; + echo Display::return_icon('email.gif', get_lang('AnnounceSentByEmail'))."\n"; } - echo "\t\t\t\t\t".Security::remove_XSS($title)."" . get_lang("SentTo") . " :   "; + echo "".Security::remove_XSS($title)."" . get_lang("SentTo") . " :   "; $sent_to=sent_to("announcement", $myrow['id']); $sent_to_form=sent_to_form($sent_to); $user_info=api_get_user_info($myrow['insert_user_id']); echo '   '.get_lang('By').' :  '.str_replace(' ', ' ', api_get_person_name($user_info['firstName'], $user_info['lastName'])); - echo "\t\t\t\t\t
"; + echo "
"; echo get_lang('AnnouncementPublishedOn')," : ", api_convert_and_format_date($last_post_datetime, DATE_FORMAT_LONG, date_default_timezone_get()); - echo "
\n"; - echo $content."\t\t\t\t\t
\n"; + echo $content."
\n"; + echo "
"; if (check_added_resources("Ad_Valvas", $myrow["id"])) { echo "".get_lang('AddedResources')."
"; @@ -1448,7 +1448,7 @@ if ($display_announcement_list && !$surveyid) { } - echo "
"; echo ""; - echo "
"; - echo "