Minor, format code + fixing PHP warnings.

1.9.x
Julio Montoya 11 years ago
parent 321ef5d3a3
commit 3d6cb6fe5c
  1. 37
      main/newscorm/learnpath.class.php
  2. 35
      main/newscorm/lp_ajax_save_objectives.php

@ -8549,9 +8549,8 @@ class learnpath
</script>';
foreach ($a_forums as $forum) {
$return .= '<li class="lp_resource_element" data_id="'.$forum['forum_id'].'" data_type="'.TOOL_FORUM.'" title="'.$forum['forum_title'].'" >';
if (!empty($forum['forum_id'])) {
$return .= '<li class="lp_resource_element" data_id="'.$forum['forum_id'].'" data_type="'.TOOL_FORUM.'" title="'.$forum['forum_title'].'" >';
$return .= '<a class="moved" href="#">';
$return .= Display::return_icon('move_everywhere.png', get_lang('Move'), array(), ICON_SIZE_TINY);
$return .= ' </a>';
@ -8559,26 +8558,30 @@ class learnpath
$return .= '<a style="cursor:hand" onclick="javascript: toggle_forum(' . $forum['forum_id'] . ')" style="vertical-align:middle">
<img src="' . api_get_path(WEB_IMG_PATH) . 'add.gif" id="forum_' . $forum['forum_id'] . '_opener" align="absbottom" />
</a>
<a href="' . api_get_self() . '?'.api_get_cidreq().'&amp;action=add_item&amp;type=' . TOOL_FORUM . '&amp;forum_id=' . $forum['forum_id'] . '&amp;lp_id=' . $this->lp_id . '" style="vertical-align:middle">' . Security :: remove_XSS($forum['forum_title']) . '</a>';
}
$return .= '</li>';
<a href="' . api_get_self() . '?'.api_get_cidreq().'&amp;action=add_item&amp;type=' . TOOL_FORUM . '&amp;forum_id=' . $forum['forum_id'] . '&amp;lp_id=' . $this->lp_id . '" style="vertical-align:middle">' .
Security :: remove_XSS($forum['forum_title']) . '</a>';
$return .= '</li>';
$return .= '<div style="display:none" id="forum_' . $forum['forum_id'] . '_content">';
$a_threads = get_threads($forum['forum_id']);
if (is_array($a_threads)) {
foreach ($a_threads as $thread) {
$return .= '<li class="lp_resource_element" data_id="'.$thread['thread_id'].'" data_type="'.TOOL_THREAD.'" title="'.$thread['thread_title'].'" >';
$return .= '&nbsp;<a class="moved" href="#">';
$return .= Display::return_icon('move_everywhere.png', get_lang('Move'), array(), ICON_SIZE_TINY);
$return .= ' </a>';
$return .= Display::return_icon('forumthread.png', get_lang('Thread'), array(), ICON_SIZE_TINY);
$return .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&amp;action=add_item&amp;type=' . TOOL_THREAD . '&amp;thread_id=' . $thread['thread_id'] . '&amp;lp_id=' . $this->lp_id . '">' . Security :: remove_XSS($thread['thread_title']) . '</a>';
$return .= '</li>';
$return .= '<div style="display:none" id="forum_' . $forum['forum_id'] . '_content">';
$a_threads = get_threads($forum['forum_id']);
if (is_array($a_threads)) {
foreach ($a_threads as $thread) {
$return .= '<li class="lp_resource_element" data_id="'.$thread['thread_id'].'" data_type="'.TOOL_THREAD.'" title="'.$thread['thread_title'].'" >';
$return .= '&nbsp;<a class="moved" href="#">';
$return .= Display::return_icon('move_everywhere.png', get_lang('Move'), array(), ICON_SIZE_TINY);
$return .= ' </a>';
$return .= Display::return_icon('forumthread.png', get_lang('Thread'), array(), ICON_SIZE_TINY);
$return .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&amp;action=add_item&amp;type=' . TOOL_THREAD . '&amp;thread_id=' . $thread['thread_id'] . '&amp;lp_id=' . $this->lp_id . '">' .
Security :: remove_XSS($thread['thread_title']) . '</a>';
$return .= '</li>';
}
}
$return .= '</div>';
}
$return .= '</div>';
}
$return .= '</ul>';
return $return;
}

@ -7,9 +7,7 @@
* @package chamilo.learnpath
* @author Yannick Warnier <ywarnier@beeznest.org>
*/
/**
* Code
*/
// Flag to allow for anonymous user - needs to be set before global.inc.php.
$use_anonymous = true;
@ -26,12 +24,13 @@ require_once 'back_compat.inc.php';
* @param integer Item ID
* @param array Objectives array
*/
function save_objectives($lp_id, $user_id, $view_id, $item_id, $objectives = array()) {
global $_configuration;
function save_objectives($lp_id, $user_id, $view_id, $item_id, $objectives = array())
{
$debug = 0;
$return = '';
if ($debug > 0) { error_log('In xajax_save_objectives('.$lp_id.','.$user_id.','.$view_id.','.$item_id.',"'.(count($objectives) > 0 ? count($objectives) : '').'")', 0); }
//$objResponse = new xajaxResponse();
if ($debug > 0) {
error_log('In xajax_save_objectives('.$lp_id.','.$user_id.','.$view_id.','.$item_id.',"'.(count($objectives) > 0 ? count($objectives) : '').'")', 0);
}
require_once 'learnpath.class.php';
require_once 'scorm.class.php';
require_once 'aicc.class.php';
@ -40,26 +39,32 @@ function save_objectives($lp_id, $user_id, $view_id, $item_id, $objectives = arr
require_once 'aiccItem.class.php';
$mylp = learnpath::getLpFromSession(api_get_course_id(), $lp_id, $user_id);
$mylpi =& $mylp->items[$item_id];
//error_log(__FILE__.' '.__LINE__.' '.print_r($objectives,true), 0);
if(is_array($objectives) && count($objectives)>0){
foreach($objectives as $index=>$objective){
//error_log(__FILE__.' '.__LINE__.' '.$objectives[$index][0], 0);
if (is_array($objectives) && count($objectives)>0){
foreach ($objectives as $index=>$objective){
$mylpi->add_objective($index,$objectives[$index]);
}
$mylpi->write_objectives_to_db();
}
//return $objResponse;
return $return;
}
$objectives = array();
if (isset($_REQUEST['objectives'])) {
if (is_array($_REQUEST['objectives'])) {
foreach ($_REQUEST['objectives'] as $idx => $ob) {
$objectives[$idx] = split(',', substr($ob, 1, -1));
if (!isset($objectives[$idx][4])) { // Make sure there are 7 elements.
$objectives[$idx] = explode(',', substr($ob, 1, -1));
if (!isset($objectives[$idx][4])) {
// Make sure there are 7 elements.
$objectives[$idx][4] = '';
}
}
}
}
echo save_objectives($_REQUEST['lid'], $_REQUEST['uid'], $_REQUEST['vid'], $_REQUEST['iid'], $objectives);
echo save_objectives(
$_REQUEST['lid'],
$_REQUEST['uid'],
$_REQUEST['vid'],
$_REQUEST['iid'],
$objectives
);

Loading…
Cancel
Save