Browse Source

Fix PHP warnings.

Julio Montoya 10 years ago
parent
commit
42d122a451

+ 6 - 2
main/inc/lib/message.lib.php

@@ -224,12 +224,16 @@ class MessageManager
 
         // Validating fields
         if (empty($subject) && empty($group_id)) {
-            return get_lang('YouShouldWriteASubject');
+            Display::addFlash(Display::return_message(get_lang('YouShouldWriteASubject'), 'warning'));
+            return false;
         } else if ($total_filesize > intval(api_get_setting('message_max_upload_filesize'))) {
-            return sprintf(
+            $warning = sprintf(
                 get_lang("FilesSizeExceedsX"),
                 format_file_size(api_get_setting('message_max_upload_filesize'))
             );
+
+            Display::addFlash(Display::return_message($warning , 'warning'));
+            return false;
         }
 
         $inbox_last_id = null;

+ 5 - 4
main/inc/lib/template.lib.php

@@ -451,11 +451,12 @@ class Template
 
         //Here we can add system parameters that can be use in any template
         $_s = array(
-            'software_name'  => $_configuration['software_name'],
+            'software_name' => $_configuration['software_name'],
             'system_version' => $_configuration['system_version'],
-            'site_name'      => api_get_setting('siteName'),
-            'institution'    => api_get_setting('Institution'),
-            'date'       => api_format_date('now', DATE_FORMAT_LONG),
+            'site_name' => api_get_setting('siteName'),
+            'institution' => api_get_setting('Institution'),
+            'date' => api_format_date('now', DATE_FORMAT_LONG),
+            'timezone' => _api_get_timezone()
         );
         $this->assign('_s', $_s);
     }

+ 12 - 4
main/inc/lib/tracking.lib.php

@@ -5670,14 +5670,18 @@ class TrackingCourseLog
                                 WHERE c_id = $course_id AND id = $ref";
     					$rs_document = Database::query($sql);
     					$obj_document = Database::fetch_object($rs_document);
-    					$row[5] = $obj_document->title;
+                        if ($obj_document) {
+                            $row[5] = $obj_document->title;
+                        }
     					break;
     				case 'glossary':
                         $sql = "SELECT name FROM $table_tool
     					        WHERE c_id = $course_id AND glossary_id = $ref";
     					$rs_document = Database::query($sql);
     					$obj_document = Database::fetch_object($rs_document);
-    					$row[5] = $obj_document->name;
+                        if ($obj_document) {
+                            $row[5] = $obj_document->name;
+                        }
     					break;
     				case 'lp':
                         $sql = "SELECT name
@@ -5691,14 +5695,18 @@ class TrackingCourseLog
                                 WHERE c_id = $course_id AND id = $ref";
     					$rs_document = Database::query($sql);
     					$obj_document = Database::fetch_object($rs_document);
-    					$row[5] = $obj_document->title;
+                        if ($obj_document) {
+                            $row[5] = $obj_document->title;
+                        }
     					break;
     				case 'course_description':
                         $sql = "SELECT title FROM $table_tool
                                 WHERE c_id = $course_id AND id = $ref";
     					$rs_document = Database::query($sql);
     					$obj_document = Database::fetch_object($rs_document);
-    					$row[5] = $obj_document->title;
+                        if ($obj_document) {
+                            $row[5] = $obj_document->title;
+                        }
     					break;
     				case 'thematic':
     					$rs = Database::query("SELECT title FROM $table_tool WHERE c_id = $course_id AND id = $ref");

+ 3 - 7
main/messages/new_message.php

@@ -254,11 +254,7 @@ function manage_form($default, $select_from_user_list = null, $sent_to = null)
 						$parent_id
 					);
 					if ($res) {
-						if (is_string($res)) {
-							$html .= Display::return_message($res, 'error');
-						} else {
-							$html .= MessageManager::display_success_message($user);
-						}
+						$html .= MessageManager::display_success_message($user);
 					}
 				}
 			} else {
@@ -384,8 +380,8 @@ if (api_get_setting('allow_social_tool') == 'true') {
     $tpl->display($social_layout);
 } else {
     $content = $social_right_content;
-    $tpl->assign('actions', $actions);
-    $tpl->assign('message', $show_message);
+    //$tpl->assign('actions', $actions);
+    //$tpl->assign('message', $show_message);
     $tpl->assign('content', $content);
     $tpl->display_one_col_template();
 }

+ 15 - 20
main/messages/outbox.php

@@ -27,9 +27,7 @@ if (api_get_setting('allow_message_tool')!='true'){
 //jquery thickbox already called from main/inc/header.inc.php
 
 $htmlHeadXtra[]='<script language="javascript">
-<!--
-function enviar(miforma)
-{
+function enviar(miforma) {
 	if(confirm("'.get_lang('SureYouWantToDeleteSelectedMessages', '').'"))
 		miforma.submit();
 }
@@ -55,7 +53,7 @@ function deselect_all(formita)
 /*
 		MAIN CODE
 */
-if ($_GET['f']=='social') {
+if (isset($_GET['f']) && $_GET['f']=='social') {
 	$this_section = SECTION_SOCIAL;
 	$interbreadcrumb[]= array ('url' => api_get_path(WEB_PATH).'main/social/home.php','name' => get_lang('Social'));
 	$interbreadcrumb[]= array ('url' => '#','name' => get_lang('Outbox'));
@@ -65,23 +63,20 @@ if ($_GET['f']=='social') {
 	$interbreadcrumb[]= array ('url' => '#','name' => get_lang('Outbox'));
 }
 
-if ($_GET['f']=='social') {
-
-} else {
-	if (api_get_setting('extended_profile') == 'true') {
-
-		if (api_get_setting('allow_social_tool') == 'true' && api_get_setting('allow_message_tool') == 'true') {
-			$actions .=  '<a href="'.api_get_path(WEB_PATH).'main/social/profile.php">'.Display::return_icon('shared_profile.png', get_lang('ViewSharedProfile')).'</a>';
-		}
-		if (api_get_setting('allow_message_tool') == 'true') {
-			//echo '<a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php">'.Display::return_icon('inbox.png').' '.get_lang('Messages').'</a>';
-			$actions .=  '<a href="'.api_get_path(WEB_PATH).'main/messages/new_message.php">'.Display::return_icon('message_new.png',get_lang('ComposeMessage')).'</a>';
-            $actions .=  '<a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php">'.Display::return_icon('inbox.png',get_lang('Inbox')).'</a>';
-            $actions .=  '<a href="'.api_get_path(WEB_PATH).'main/messages/outbox.php">'.Display::return_icon('outbox.png',get_lang('Outbox')).'</a>';
-		}
-	}
+$actions = '';
+if (api_get_setting('extended_profile') == 'true') {
+    if (api_get_setting('allow_social_tool') == 'true' && api_get_setting('allow_message_tool') == 'true') {
+        $actions .=  '<a href="'.api_get_path(WEB_PATH).'main/social/profile.php">'.Display::return_icon('shared_profile.png', get_lang('ViewSharedProfile')).'</a>';
+    }
+    if (api_get_setting('allow_message_tool') == 'true') {
+        //echo '<a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php">'.Display::return_icon('inbox.png').' '.get_lang('Messages').'</a>';
+        $actions .=  '<a href="'.api_get_path(WEB_PATH).'main/messages/new_message.php">'.Display::return_icon('message_new.png',get_lang('ComposeMessage')).'</a>';
+        $actions .=  '<a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php">'.Display::return_icon('inbox.png',get_lang('Inbox')).'</a>';
+        $actions .=  '<a href="'.api_get_path(WEB_PATH).'main/messages/outbox.php">'.Display::return_icon('outbox.png',get_lang('Outbox')).'</a>';
+    }
 }
 
+
 $info_delete_outbox =array();
 $info_delete_outbox = isset($_GET['form_delete_outbox']) ? explode(',',$_GET['form_delete_outbox']) : '';
 $count_delete_outbox = count($info_delete_outbox) - 1;
@@ -151,7 +146,7 @@ if (api_get_setting('allow_social_tool') == 'true') {
 } else {
     $content = $social_right_content;
     $tpl->assign('actions', $actions);
-    $tpl->assign('message', $show_message);
+    //$tpl->assign('message', $show_message);
     $tpl->assign('content', $content);
     $tpl->display_one_col_template();
 }

+ 1 - 1
main/tracking/course_log_resources.php

@@ -121,7 +121,7 @@ $table = new SortableTable(
 );
 
 $parameters = array(
-    'keyword' => Security::remove_XSS($_GET['keyword']),
+    //'keyword' => Security::remove_XSS($_GET['keyword']),
     'id_session' => $session_id,
     'cidReq' => api_get_course_id()
 );