Przeglądaj źródła

Removing PHP warnings

Julio Montoya 12 lat temu
rodzic
commit
308a29ffac

+ 6 - 7
main/inc/lib/auth.lib.php

@@ -395,15 +395,14 @@ class Auth {
         }
 
         $sql = "SELECT * FROM $tbl_course WHERE category_code" . (empty($category_code) ? " IS NULL" : "='" . $category_code . "'") . $without_special_courses;
-        // Showing only the courses of the current Dokeos access_url_id.
-        global $_configuration;
-        if ($_configuration['multiple_access_urls']) {
+
+        if (api_is_multiple_url_enabled()) {
             $url_access_id = api_get_current_access_url_id();
             if ($url_access_id != -1) {
                 $tbl_url_rel_course = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
                 $sql = "SELECT * FROM $tbl_course as course INNER JOIN $tbl_url_rel_course as url_rel_course
-                                        ON (url_rel_course.course_code=course.code)
-                                        WHERE access_url_id = $url_access_id AND category_code" . (empty($category_code) ? " IS NULL" : "='" . $category_code . "'") . $without_special_courses;
+                        ON (url_rel_course.course_code=course.code)
+                        WHERE access_url_id = $url_access_id AND category_code" . (empty($category_code) ? " IS NULL" : "='" . $category_code . "'") . $without_special_courses;
             }
         }
         return Database::num_rows(Database::query($sql));
@@ -466,7 +465,7 @@ class Auth {
             $result = Database::query($sql);
             list($num_records) = Database::fetch_row($result);
 
-            if ($_configuration['multiple_access_urls']) {
+            if (api_is_multiple_url_enabled()) {
 
                 $url_access_id = api_get_current_access_url_id();
                 $tbl_url_rel_course = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
@@ -500,7 +499,7 @@ class Auth {
             $sql = "SELECT * FROM $tbl_course WHERE category_code='$category_code' $without_special_courses ORDER BY title ";
 
             //showing only the courses of the current Chamilo access_url_id
-            if ($_configuration['multiple_access_urls']) {
+            if (api_is_multiple_url_enabled()) {
                 $url_access_id = api_get_current_access_url_id();
                 $tbl_url_rel_course = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
                 $sql = "SELECT * FROM $tbl_course as course INNER JOIN $tbl_url_rel_course as url_rel_course

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

@@ -1185,7 +1185,7 @@ class CourseManager {
         $session_id     = intval($session_id);
         $course_code    = Database::escape_string($course_code);
 
-        $sql .= 'SELECT DISTINCT count(*) as count  FROM '.Database::get_main_table(TABLE_MAIN_USER).' as user ';
+        $sql = 'SELECT DISTINCT count(*) as count  FROM '.Database::get_main_table(TABLE_MAIN_USER).' as user ';
         $where = array();
         if (!empty($session_id)) {
             $sql .= ' LEFT JOIN '.Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER).' as session_course_user

+ 2 - 2
main/template/default/auth/courses_categories.php

@@ -29,7 +29,7 @@ $stok = Security::get_token();
     });
 </script>
 
-<?php if (intval($_GET['hidden_links']) != 1) { ?>
+<?php if (!isset($_GET['hidden_links']) || ($_GET['hidden_links']) != 1) { ?>
 
 <div class="actions">
     <form class="form-search" method="post" action="<?php echo api_get_self(); ?>?action=subscribe&amp;hidden_links=0">
@@ -143,7 +143,7 @@ $stok = Security::get_token();
                 }
 
                 $rating = Display::return_rating_system('star_'.$course['real_id'], $ajax_url.'&amp;course_id='.$course['real_id'], $course['point_info']);
-
+                $icon_title = null;
                 echo '<div class="well_border"><div class="row">';
                     echo '<div class="span2">';
                         echo '<div class="thumbnail">';

+ 38 - 36
main/template/default/auth/courses_list.php

@@ -20,32 +20,32 @@ $courses_without_category = $courses_in_category[0];
 	&nbsp;<a href="<?php echo api_get_self(); ?>?action=createcoursecategory"><?php echo Display::return_icon('new_folder.png', get_lang('CreateCourseCategory'),'','32'); ?></a>
     <?php } ?>
 </div>
-    
-<?php 
+
+<?php
 if (!empty($message)) {
-    Display::display_confirmation_message($message, false); 
-}   
-        
+    Display::display_confirmation_message($message, false);
+}
+
 // COURSES WITH CATEGORIES
 if (!empty($user_course_categories)) {
        foreach ($user_course_categories as $row) {
            echo Display::page_subheader($row['title']);
            echo '<a name="category'.$row['id'].'"></a>';
-           
+
            if (isset($_GET['categoryid']) && $_GET['categoryid'] == $row['id']) { ?>
-            <!-- We display the edit form for the category -->            
-            
+            <!-- We display the edit form for the category -->
+
             <form name="edit_course_category" method="post" action="courses.php?action=<?php echo $action; ?>">
                 <input type="hidden" name="edit_course_category" value="<?php echo $row['id']; ?>" />
                 <input type="hidden" name="sec_token" value="<?php echo $stok; ?>">
                 <input type="text" name="title_course_category" value="<?php echo $row['title']; ?>" />
                 <button class="save" type="submit" name="submit_edit_course_category"><?php echo get_lang('Ok'); ?></button>
-            </form>            
+            </form>
             <?php } ?>
-            
-            
+
+
             <!-- display category icons -->
-            <?php 
+            <?php
             $max_category_key = count($user_course_categories);
             if ($action != 'unsubscribe') { ?>
                 <a href="courses.php?action=sortmycourses&amp;categoryid=<?php echo $row['id']; ?>&amp;sec_token=<?php echo $stok; ?>#category<?php echo $row['id']; ?>">
@@ -57,7 +57,7 @@ if (!empty($user_course_categories)) {
                         <?php echo Display::return_icon('up.png', get_lang('Up'),'',22); ?>
                         </a>
                 <?php } else { ?>
-                    <?php echo Display::return_icon('up_na.png', get_lang('Up'),'',22); ?> 
+                    <?php echo Display::return_icon('up_na.png', get_lang('Up'),'',22); ?>
                <?php } ?>
 
                 <?php if ($row['id'] != $user_course_categories[$max_category_key - 1]['id']) { ?>
@@ -69,13 +69,15 @@ if (!empty($user_course_categories)) {
                 <?php } ?>
                 <a href="courses.php?action=deletecoursecategory&amp;id=<?php echo $row['id']; ?>&amp;sec_token=<?php echo $stok; ?>">
                 <?php echo Display::display_icon('delete.png', get_lang('Delete'), array('onclick' => "javascript: if (!confirm('".addslashes(api_htmlentities(get_lang("CourseCategoryAbout2bedeleted"), ENT_QUOTES, api_get_system_encoding()))."')) return false;"),22) ?>
-                </a>	                   
+                </a>
             <?php }
             echo '<br /><br />';
-            // Show the courses inside this category            
+            // Show the courses inside this category
             echo '<table class="data_table">';
-            
-            $number_of_courses = count($courses_in_category[$row['id']]);
+            $number_of_courses = 0;
+            if (isset($courses_in_category[$row['id']])) {
+                $number_of_courses = count($courses_in_category[$row['id']]);
+            }
             $key = 0;
             if (!empty($courses_in_category[$row['id']])) {
                 foreach ($courses_in_category[$row['id']] as $course) {
@@ -108,7 +110,7 @@ if (!empty($user_course_categories)) {
                                     </form>
                         <?php }  ?>
 
-                        <div style="float:left;width:110px;"> 
+                        <div style="float:left;width:110px;">
                         <?php if (api_get_setting('show_courses_descriptions_in_catalog') == 'true') {
                                 $icon_title = get_lang('CourseDetails') . ' - ' . $course['title'];
                         ?>
@@ -116,12 +118,12 @@ if (!empty($user_course_categories)) {
                            <?php } ?>	                            	</a>
 
                         <?php if (isset($_GET['edit']) && $course['code'] == $_GET['edit']) { ?>
-                              <?php echo Display::display_icon('edit_na.png', get_lang('Edit'),'',22); ?>   
-                        <?php } else { ?>	                            
+                              <?php echo Display::display_icon('edit_na.png', get_lang('Edit'),'',22); ?>
+                        <?php } else { ?>
                             <a href="courses.php?action=<?php echo $action; ?>&amp;edit=<?php echo $course['code']; ?>&amp;sec_token=<?php echo $stok; ?>">
                                 <?php echo Display::display_icon('edit.png', get_lang('Edit'),'',22); ?>
                                 </a>
-                        <?php } ?>	                                    
+                        <?php } ?>
 
                         <?php if ($key > 0) { ?>
                             <a href="courses.php?action=<?php echo $action; ?>&amp;move=up&amp;course=<?php echo $course['code']; ?>&amp;category=<?php echo $course['user_course_cat']; ?>&amp;sec_token=<?php echo $stok; ?>">
@@ -135,9 +137,9 @@ if (!empty($user_course_categories)) {
                                 <a href="courses.php?action=<?php echo $action; ?>&amp;move=down&amp;course=<?php echo $course['code']; ?>&amp;category=<?php echo $course['user_course_cat']; ?>&amp;sec_token=<?php echo $stok; ?>">
                                 <?php echo Display::display_icon('down.png', get_lang('Down'),'',22); ?>
                                 </a>
-                        <?php } else { ?>	
+                        <?php } else { ?>
                             <?php echo Display::display_icon('down_na.png', get_lang('Down'),'',22); ?>
-                        <?php } ?>  
+                        <?php } ?>
 
                       </div>
                       <div style="float:left; margin-right:10px;">
@@ -147,7 +149,7 @@ if (!empty($user_course_categories)) {
 
                             <form action="<?php echo api_get_self(); ?>" method="post" onsubmit="javascript: if (!confirm('<?php echo addslashes(api_htmlentities(get_lang("ConfirmUnsubscribeFromCourse"), ENT_QUOTES, api_get_system_encoding()))?>')) return false">
                                 <input type="hidden" name="sec_token" value="<?php echo $stok; ?>">
-                                <input type="hidden" name="unsubscribe" value="<?php echo $course['code']; ?>" />                                    	
+                                <input type="hidden" name="unsubscribe" value="<?php echo $course['code']; ?>" />
                                  <button class="btn" value="<?php echo get_lang('Unsubscribe'); ?>" name="unsub">
                                 <?php echo get_lang('Unsubscribe'); ?>
                                 </button>
@@ -170,13 +172,13 @@ if (!empty($courses_without_category)) {
     $number_of_courses = count($courses_without_category);
     $key = 0;
 
-    foreach ($courses_without_category as $course) { 
+    foreach ($courses_without_category as $course) {
         echo '<tr>';
         ?>
 
         <td>
             <a name="course<?php echo $course['code']; ?>"></a>
-            <strong><?php echo $course['title']; ?></strong><br />                
+            <strong><?php echo $course['title']; ?></strong><br />
             <?php
             if (api_get_setting('display_coursecode_in_courselist') == 'true') { echo $course['visual_code']; }
             if (api_get_setting('display_coursecode_in_courselist') == 'true' && api_get_setting('display_teacher_in_courselist') == 'true') { echo " - "; }
@@ -190,7 +192,7 @@ if (!empty($courses_without_category)) {
             <!-- the edit icon OR the edit dropdown list -->
             <?php if (isset($_GET['edit']) && $course['code'] == $_GET['edit']) {
                 $edit_course = Security::remove_XSS($_GET['edit']);
-            ?>                
+            ?>
             <div style="float:left;">
             <form name="edit_course_category" method="post" action="courses.php?action=<?php echo $action; ?>">
                 <input type="hidden" name="sec_token" value="<?php echo $stok; ?>">
@@ -203,7 +205,7 @@ if (!empty($courses_without_category)) {
                 </select>
                 <button class="save" type="submit" name="submit_change_course_category"><?php echo get_lang('Ok') ?></button>
             </form><br />
-            </div>                
+            </div>
             <?php } ?>
 
             <div style="float:left; width:110px">
@@ -216,22 +218,22 @@ if (!empty($courses_without_category)) {
             </a>
             <?php } ?>
 
-             <?php if (isset($_GET['edit']) && $course['code'] == $_GET['edit']) {   ?>               
+             <?php if (isset($_GET['edit']) && $course['code'] == $_GET['edit']) {   ?>
                     <?php echo Display::display_icon('edit_na.png', get_lang('Edit'),'',22); ?>
-                  <?php } else { ?>                                                    
+                  <?php } else { ?>
                     <a href="courses.php?action=<?php echo $action; ?>&amp;edit=<?php echo $course['code']; ?>&amp;sec_token=<?php echo $stok; ?>">
                     <?php echo Display::display_icon('edit.png', get_lang('Edit'),'',22); ?>
-                    </a>                        
-             <?php } ?>       
+                    </a>
+             <?php } ?>
 
-            <!-- up /down icons-->                
+            <!-- up /down icons-->
             <?php if ($key > 0) { ?>
                     <a href="courses.php?action=<?php echo $action; ?>&amp;move=up&amp;course=<?php echo $course['code']; ?>&amp;category=<?php echo $course['user_course_cat']; ?>&amp;sec_token=<?php echo $stok; ?>">
                     <?php echo Display::display_icon('up.png', get_lang('Up'),'',22) ?>
                     </a>
             <?php } else {
                     echo Display::display_icon('up_na.png', get_lang('Up'),'',22);
-                  } 
+                  }
 
                   if ($key < $number_of_courses - 1) { ?>
                     <a href="courses.php?action=<?php echo $action; ?>&amp;move=down&amp;course=<?php echo $course['code']; ?>&amp;category=<?php echo $course['user_course_cat']; ?>&amp;sec_token=<?php echo $stok; ?>">
@@ -246,7 +248,7 @@ if (!empty($courses_without_category)) {
             <?php if ($course['status'] != 1) {
                     if ($course['unsubscr'] == 1) {
             ?>
-                        <!-- changed link to submit to avoid action by the search tool indexer -->                           
+                        <!-- changed link to submit to avoid action by the search tool indexer -->
                         <form action="<?php echo api_get_self(); ?>" method="post" onsubmit="javascript: if (!confirm('<?php echo addslashes(api_htmlentities(get_lang("ConfirmUnsubscribeFromCourse"), ENT_QUOTES, api_get_system_encoding())) ?>')) return false;">
                             <input type="hidden" name="sec_token" value="<?php echo $stok; ?>">
                             <input type="hidden" name="unsubscribe" value="<?php echo $course['code']; ?>" />
@@ -260,7 +262,7 @@ if (!empty($courses_without_category)) {
               ?>
             </td>
             </tr>
-            <?php 
+            <?php
             $key++;
         }
     }