Browse Source

PHP warning/notices avoided

Julio Montoya 12 years ago
parent
commit
2115f0dfcc
4 changed files with 36 additions and 27 deletions
  1. 23 19
      main/inc/ajax/lp.ajax.php
  2. 9 5
      main/newscorm/learnpath.class.php
  3. 2 2
      plugin/bbb/lib/bbb.lib.php
  4. 2 1
      plugin/bbb/listing.php

+ 23 - 19
main/inc/ajax/lp.ajax.php

@@ -8,45 +8,49 @@ require_once '../global.inc.php';
 api_protect_course_script(true);
 $action = $_REQUEST['a'];
 
-$course_id = api_get_course_int_id(); 
-$tbl_lp_item = Database :: get_course_table(TABLE_LP_ITEM);        
+$course_id = api_get_course_int_id();
+$tbl_lp_item = Database :: get_course_table(TABLE_LP_ITEM);
 
-switch ($action) {    
+switch ($action) {
     case 'add_lp_item':
-        if (api_is_allowed_to_edit(null, true)) {            
+        if (api_is_allowed_to_edit(null, true)) {
             if ($_SESSION['oLP']) {
-                //Updating the lp.modified_on            
-                $_SESSION['oLP']->set_modified_on();                
-                echo $_SESSION['oLP']->add_item($_REQUEST['parent_id'], $_REQUEST['previous_id'], $_REQUEST['type'], $_REQUEST['id'], $_REQUEST['title'], null);                
+                //Updating the lp.modified_on
+                $_SESSION['oLP']->set_modified_on();
+                echo $_SESSION['oLP']->add_item($_REQUEST['parent_id'], $_REQUEST['previous_id'], $_REQUEST['type'], $_REQUEST['id'], $_REQUEST['title'], null);
             }
         }
-        break;   
+        break;
     case 'update_lp_item_order':
         if (api_is_allowed_to_edit(null, true)) {
             $new_order   = $_POST['new_order'];
-            $sections	= explode('^', $new_order);            
+            $sections	= explode('^', $new_order);
             $new_array = array();
             $i = 0;
+            
             foreach ($sections as $items) {
-            	list($id, $parent_id) = explode('|', $items);
-            	$new_array[$i]['id'] = intval($id);
-            	$new_array[$i]['parent_id'] = intval($parent_id);
-            	$i++;
-            }            
+                if (!empty($items)) {
+                    list($id, $parent_id) = explode('|', $items);
+                    $new_array[$i]['id'] = intval($id);
+                    $new_array[$i]['parent_id'] = intval($parent_id);
+                    $i++;
+                }
+            }
+
             $counter = 1;
             for ($i=0; $i < count($new_array); $i++) {
-            	$params = array();   
+            	$params = array();
             	$id = $new_array[$i]['id'];
             	if (empty($id)) {
             		continue;
             	}
             	$parent_id = isset($new_array[$i]['parent_id']) ? $new_array[$i]['parent_id'] : 0;
-            	$params['display_order'] 	= $counter;            	
+            	$params['display_order'] 	= $counter;
             	$params['previous_item_id']	= isset($new_array[$i-1]) &&  isset($new_array[$i-1]['id']) ? $new_array[$i-1]['id'] : 0;
-            	$params['next_item_id']		= isset($new_array[$i+1]) &&  isset($new_array[$i+1]['id']) ? $new_array[$i+1]['id'] : 0;            	
-            	$params['parent_item_id']	= $parent_id;            	
+            	$params['next_item_id']		= isset($new_array[$i+1]) &&  isset($new_array[$i+1]['id']) ? $new_array[$i+1]['id'] : 0;
+            	$params['parent_item_id']	= $parent_id;
             	Database::update($tbl_lp_item, $params, array('id = ? AND c_id = ? '=> array(intval($id), $course_id)));
-                $counter ++;                
+                $counter ++;
             }
             Display::display_confirmation_message(get_lang('Saved'));
         }

+ 9 - 5
main/newscorm/learnpath.class.php

@@ -1608,7 +1608,7 @@ class learnpath {
             }
             $this->last     = $this->current;
             // current is
-            $this->current  = $this->ordered_items[$index];
+            $this->current  = isset($this->ordered_items[$index]) ? $this->ordered_items[$index] : null;
             $this->index    = $index;
             if ($this->debug > 2) {
                 error_log('$index ' . $index);
@@ -5030,6 +5030,8 @@ class learnpath {
         $this->tree_array($arrLP);
         $arrLP = $this->arrMenu;
         unset ($this->arrMenu);
+        $default_data = null;
+        $default_content = null;
 
         $elements = array();
         for ($i = 0; $i < count($arrLP); $i++) {
@@ -6618,7 +6620,9 @@ class learnpath {
         }
 
         $this->tree_array($arrLP);
-        $arrLP = $this->arrMenu;
+
+        $arrLP = isset($this->arrMenu) ? $this->arrMenu : null;
+
         unset ($this->arrMenu);
 
         $gradebook = isset($_GET['gradebook']) ? Security :: remove_XSS($_GET['gradebook']) : null;
@@ -7914,7 +7918,7 @@ class learnpath {
             $return .= '</a> ';
 
             $return .= '<img src="../img/hotpotatoes_s.png" style="margin-right:5px;" title="" width="16px" />';
-            $return .= '<a href="' . api_get_self() . '?cidReq=' . Security :: remove_XSS($_GET['cidReq']).'&amp;action=add_item&amp;type=' . TOOL_HOTPOTATOES . '&amp;file=' . $row_hot['id'] . '&amp;lp_id=' . $this->lp_id . '">'.
+            $return .= '<a href="' . api_get_self() . '?' . api_get_cidreq().'&amp;action=add_item&amp;type=' . TOOL_HOTPOTATOES . '&amp;file=' . $row_hot['id'] . '&amp;lp_id=' . $this->lp_id . '">'.
                         ((!empty ($row_hot['comment'])) ? $row_hot['comment'] : Security :: remove_XSS($row_hot['title'])) . '</a>';
             $return .= '</li>';
         }
@@ -7927,7 +7931,7 @@ class learnpath {
             $return .= '</a> ';
 
             $return .= '<img alt="" src="../img/quizz_small.gif" style="margin-right:5px;" title="" />';
-            $return .= '<a href="' . api_get_self() . '?cidReq=' . Security :: remove_XSS($_GET['cidReq']) . '&amp;action=add_item&amp;type=' . TOOL_QUIZ . '&amp;file=' . $row_quiz['id'] . '&amp;lp_id=' . $this->lp_id . '">' .
+            $return .= '<a href="' . api_get_self() . '?'.api_get_cidreq().'&amp;action=add_item&amp;type=' . TOOL_QUIZ . '&amp;file=' . $row_quiz['id'] . '&amp;lp_id=' . $this->lp_id . '">' .
                         Security :: remove_XSS(cut($row_quiz['title'], 80)).
                         '</a>';
             $return .= '</li>';
@@ -7987,7 +7991,7 @@ class learnpath {
         $return = '<div class="lp_resource" >';
         $return .= '<div class="lp_resource_element">';
         $return .= '<img align="left" alt="" src="../img/works_small.gif" style="margin-right:5px;" title="" />';
-        $return .= '<a href="' . api_get_self() . '?cidReq=' . Security :: remove_XSS($_GET['cidReq']) . '&amp;action=add_item&amp;type=' . TOOL_STUDENTPUBLICATION . '&amp;lp_id=' . $this->lp_id . '">' . get_lang('AddAssignmentPage') . '</a>';
+        $return .= '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&amp;action=add_item&amp;type=' . TOOL_STUDENTPUBLICATION . '&amp;lp_id=' . $this->lp_id . '">' . get_lang('AddAssignmentPage') . '</a>';
         $return .= '</div>';
         $return .= '</div>';
         return $return;

+ 2 - 2
plugin/bbb/lib/bbb.lib.php

@@ -41,8 +41,8 @@ class bbb {
             }
 
             // Setting BBB api
-            define(CONFIG_SECURITY_SALT, $this->salt);
-            define(CONFIG_SERVER_BASE_URL, $this->url);
+            define('CONFIG_SECURITY_SALT', $this->salt);
+            define('CONFIG_SERVER_BASE_URL', $this->url);
 
             $this->api = new BigBlueButtonBN();
             $this->plugin_enabled = true;

+ 2 - 1
plugin/bbb/listing.php

@@ -18,6 +18,7 @@ $action = isset($_GET['action']) ? $_GET['action'] : null;
 $teacher = api_is_course_admin() || api_is_coach() || api_is_platform_admin();
 
 api_protect_course_script(true);
+$message = null;
 
 if ($teacher) {
     switch ($action) {
@@ -80,7 +81,7 @@ $tpl->assign('conference_url', $conference_url);
 $tpl->assign('users_online', $users_online);
 $tpl->assign('bbb_status', $status);
 
-$tpl->assign('actions', $actions);
+//$tpl->assign('actions', $actions);
 $tpl->assign('message', $message);
 $listing_tpl = 'bbb/listing.tpl';
 $content = $tpl->fetch($listing_tpl);