Browse Source

Cleaning files, declaring variables, avoiding notices

Julio Montoya 13 years ago
parent
commit
5dccfd22a6

+ 1 - 1
index.php

@@ -236,7 +236,7 @@ if (!api_is_anonymous()) {
     }
     $img_array = UserManager::get_picture_user(api_get_user_id(), $img_array['file'], 50, USER_IMAGE_SIZE_MEDIUM, ' width="90" height="90" ');
     
-    $profile_content .='<div id="social_widget">';
+    $profile_content ='<div id="social_widget">';
     
     $profile_content .= '<div id="social_widget_image">';
     if (api_get_setting('allow_social_tool') == 'true') {

+ 7 - 4
main/document/document.inc.php

@@ -137,6 +137,8 @@ function create_document_link($document_data, $show_as_icon = false, $counter =
     }
 
     $target = '_self';
+    $is_browser_viewable_file = false; 
+    
     if ($filetype == 'file') {
         // Check the extension
         $ext = explode('.', $path);
@@ -144,6 +146,7 @@ function create_document_link($document_data, $show_as_icon = false, $counter =
 
         // HTML-files an some other types are shown in a frameset by default.
         $is_browser_viewable_file = is_browser_viewable($ext);
+        
         if ($is_browser_viewable_file) {
             //$url = 'showinframes.php?'.api_get_cidreq().'&amp;file='.$url_path.$req_gid;
             $url = 'showinframes.php?'.api_get_cidreq().'&id='.$document_data['id'].$req_gid;
@@ -195,13 +198,13 @@ function create_document_link($document_data, $show_as_icon = false, $counter =
     } elseif($path == '/images/gallery') {
         $tooltip_title_alt = get_lang('DefaultCourseImages');
     }
-    $current_session_id=api_get_session_id();
-    
+    $current_session_id = api_get_session_id();
+    $copy_to_myfiles = $open_in_new_window_link = null;
     if (!$show_as_icon) {
         if ($filetype == 'folder') {
             if (api_is_allowed_to_edit() || api_is_platform_admin() || api_get_setting('students_download_folders') == 'true') {
                 //filter when I am into shared folder, I can show for donwload only my shared folder
-                if (is_shared_folder($_GET['curdirpath'],$current_session_id)) {
+                if (isset($_GET['curdirpath']) && is_shared_folder($_GET['curdirpath'], $current_session_id)) {
                     if (preg_match('/shared_folder\/sf_user_'.api_get_user_id().'$/', urldecode($forcedownload_link))|| preg_match('/shared_folder_session_'.$current_session_id.'\/sf_user_'.api_get_user_id().'$/', urldecode($forcedownload_link)) || api_is_allowed_to_edit() || api_is_platform_admin()) {
                         $force_download_html = ($size == 0) ? '' : '<a href="'.$forcedownload_link.'" style="float:right"'.$prevent_multiple_click.'>'.Display::return_icon($forcedownload_icon, get_lang('Download'), array(),22).'</a>';
                     }
@@ -218,7 +221,7 @@ function create_document_link($document_data, $show_as_icon = false, $counter =
             $copy_myfiles_link = ($filetype == 'file') ? api_get_self().'?'.api_get_cidreq().'&curdirpath='.Security::remove_XSS($_GET['curdirpath']).'&amp;action=copytomyfiles&amp;id='.$url_path.$req_gid :api_get_self().'?'.api_get_cidreq();
 
             if ($filetype == 'file') {
-                $copy_to_myfiles='<a href="'.$copy_myfiles_link.'" style="float:right"'.$prevent_multiple_click.'>'.Display::return_icon('briefcase.png', get_lang('CopyToMyFiles'), array(),22).'&nbsp;&nbsp;</a>';
+                $copy_to_myfiles = '<a href="'.$copy_myfiles_link.'" style="float:right"'.$prevent_multiple_click.'>'.Display::return_icon('briefcase.png', get_lang('CopyToMyFiles'), array(),22).'&nbsp;&nbsp;</a>';
             }
         }
         

+ 8 - 4
main/document/document.php

@@ -509,8 +509,9 @@ if (isset($_GET['action']) && $_GET['action'] == 'copytomyfiles' && api_get_sett
 /*	MOVE FILE OR DIRECTORY */
 //Only teacher and all users into their group and each user into his/her shared folder
 if ($is_allowed_to_edit || $group_member_with_upload_rights || is_my_shared_folder(api_get_user_id(), $curdirpath, $current_session_id) || is_my_shared_folder(api_get_user_id(), Security::remove_XSS($_POST['move_to']), $current_session_id)) {
-    $my_get_move = intval($_REQUEST['move']);
+    
     if (isset($_GET['move']) && $_GET['move'] != '') {
+        $my_get_move = intval($_REQUEST['move']);
 
         if (api_is_coach()) {
             if (!DocumentManager::is_visible_by_id($my_get_move, api_get_course_info(), api_get_session_id())) {                    
@@ -896,6 +897,8 @@ if ($is_certificate_mode && $curdirpath != '/certificates') {
 <?php
 }
 $table_footer = '';
+$total_size = 0;
+
 if (isset($docs_and_folders) && is_array($docs_and_folders)) {
     //echo('<pre>');
     //print_r($docs_and_folders);
@@ -966,7 +969,7 @@ if (isset($docs_and_folders) && is_array($docs_and_folders)) {
         $row[] = create_document_link($document_data,  true, $count);
         $path_info = pathinfo($document_data['path']);
                 
-        if (in_array($path_info['extension'], array('ogg', 'mp3','wav'))) {
+        if (isset($path_info['extension']) && in_array($path_info['extension'], array('ogg', 'mp3','wav'))) {
             $count ++;
         }
 
@@ -987,9 +990,10 @@ if (isset($docs_and_folders) && is_array($docs_and_folders)) {
         $display_date = date_to_str_ago($last_edit_date);
         $row[] = $invisibility_span_open.$display_date.$invisibility_span_close;
         // Admins get an edit column
+        
         if ($is_allowed_to_edit || $group_member_with_upload_rights || is_my_shared_folder(api_get_user_id(), $curdirpath, $current_session_id)) {
-            $is_template = isset($document_data['is_template']) ? $document_data['is_template'] : false;
-            // If readonly, check if it the owner of the file or if the user is an admin
+            $is_template = isset($document_data['is_template']) ? $document_data['is_template'] : false;            
+            // If readonly, check if it the owner of the file or if the user is an admin            
             if ($document_data['insert_user_id'] == api_get_user_id() || api_is_platform_admin()) {                
                 $edit_icons = build_edit_icons($document_data, $key, $is_template, 0);
             } else {          

+ 5 - 2
main/inc/lib/course_home.lib.php

@@ -647,6 +647,7 @@ class CourseHome {
                         $link['cmd'] = 'restore=yes';
                         $lnk[] = $link;
                     }
+                    $item['extra'] = null;
                     if (!empty($tool['adminlink'])) {
                         $item['extra'] = '<a href="'.$tool['adminlink'].'">'.Display::return_icon('edit.gif', get_lang('Edit')).'</a>';
                     }
@@ -658,8 +659,10 @@ class CourseHome {
                         $link['cmd'] = 'hide=yes';
                     }
                 }
-
-                if (isset($lnk) && is_array($lnk)) {
+                
+                $item['visibility'] = null;
+                
+                if (isset($lnk) && is_array($lnk)) {                    
                     foreach ($lnk as $this_link) {
                         if (empty($tool['adminlink'])) {
                             $item['visibility'] .=  '<a class="make_visible_and_invisible"  href="'.api_get_self().'?'.api_get_cidreq().'&amp;id='.$tool['id'].'&amp;'.$this_link['cmd'].'">'.$this_link['name'].'</a>';

+ 2 - 5
main/inc/lib/document.lib.php

@@ -512,14 +512,14 @@ return 'application/octet-stream';
 
         //condition for search (get ALL folders and documents)
         if ($search) {
-            $sql = "SELECT docs.id, docs.filetype, docs.path, docs.title, docs.comment, docs.size, docs.readonly, docs.session_id, last.id_session item_property_session_id, last.lastedit_date, last.visibility
+            $sql = "SELECT docs.id, docs.filetype, docs.path, docs.title, docs.comment, docs.size, docs.readonly, docs.session_id, last.id_session item_property_session_id, last.lastedit_date, last.visibility, last.insert_user_id
                         FROM  ".$TABLE_ITEMPROPERTY."  AS last, ".$TABLE_DOCUMENT."  AS docs
                         WHERE docs.id = last.ref
                         AND last.tool = '".TOOL_DOCUMENT."'
                         AND ".$to_field." = ".$to_value."
                         AND last.visibility".$visibility_bit . $condition_session;
         } else {
-            $sql = "SELECT docs.id, docs.filetype, docs.path, docs.title, docs.comment, docs.size, docs.readonly, docs.session_id, last.id_session item_property_session_id, last.lastedit_date, last.visibility
+            $sql = "SELECT docs.id, docs.filetype, docs.path, docs.title, docs.comment, docs.size, docs.readonly, docs.session_id, last.id_session item_property_session_id, last.lastedit_date, last.visibility, last.insert_user_id
                         FROM  ".$TABLE_ITEMPROPERTY."  AS last, ".$TABLE_DOCUMENT."  AS docs
                         WHERE docs.id = last.ref
                         AND docs.path LIKE '".$path.$added_slash."%'
@@ -620,9 +620,6 @@ return 'application/octet-stream';
                     }
                 }
             }
-
-
-
             return $document_data;
         } else {
             //display_error("Error getting document info from database (".Database::error().")!");

+ 11 - 8
main/inc/lib/main_api.lib.php

@@ -856,14 +856,17 @@ function _api_format_user($user) {
     } else {
         $result['mail'] = $user['mail'];
     }
-    $result['picture_uri'] = $user['picture_uri'];
-    $result['user_id'] = intval($user['user_id']);
-    $result['official_code'] = $user['official_code'];
-    $result['status'] = $user['status'];
-    $result['auth_source'] = $user['auth_source'];
-    $result['username'] = $user['username'];
-    $result['theme'] = $user['theme'];
-    $result['language'] = $user['language'];
+    
+    $result['picture_uri']      = $user['picture_uri'];
+    $result['user_id']          = intval($user['user_id']);
+    $result['official_code']    = $user['official_code'];
+    $result['status']           = $user['status'];
+    $result['auth_source']      = $user['auth_source'];
+    if (isset($user['username'])) {
+        $result['username']         = $user['username'];
+    }
+    $result['theme']            = $user['theme'];
+    $result['language']         = $user['language'];
     if (!isset($user['lastLogin']) && !isset($user['last_login'])) {
         require_once api_get_path(LIBRARY_PATH).'tracking.lib.php';
         $timestamp = Tracking::get_last_connection_date($result['user_id'], false, true);

+ 1 - 1
main/inc/lib/social.lib.php

@@ -522,7 +522,7 @@ class SocialManager extends UserManager {
 					}
 					$active = ($date_start <= $now && $date_end >= $now)?true:false;
 				}
-			}
+			}			
 			$output = array ($my_course['user_course_cat'], $result, $my_course['id_session'], $session, 'active'=>$active);
 		} else {
 			$output = array ($my_course['user_course_cat'], $result);