Minor -format code.

1.9.x
Julio Montoya 12 years ago
parent ceb227d97d
commit e561374eba
  1. 372
      main/inc/ajax/course_home.ajax.php
  2. 8
      main/inc/ajax/events.ajax.php
  3. 19
      main/inc/ajax/exercise.ajax.php
  4. 1
      main/inc/ajax/form.ajax.php
  5. 2
      main/inc/ajax/glossary.ajax.php
  6. 8
      main/inc/ajax/gradebook.ajax.php
  7. 92
      main/inc/ajax/install.ajax.php
  8. 25
      main/inc/ajax/link.ajax.php
  9. 21
      main/inc/ajax/myspace.ajax.php
  10. 16
      main/inc/ajax/online.ajax.php
  11. 5
      main/inc/ajax/timeline.ajax.php
  12. 134
      main/inc/ajax/user_manager.ajax.php

@ -9,32 +9,32 @@ $now = time();
switch ($action) {
case 'set_visibility':
require_once '../global.inc.php';
require_once '../global.inc.php';
$course_id = api_get_course_int_id();
if (api_is_allowed_to_edit(null,true)) {
$tool_table = Database::get_course_table(TABLE_TOOL_LIST);
$tool_info = api_get_tool_information($_GET["id"]);
$tool_visibility = $tool_info['visibility'];
$tool_image = $tool_info['image'];
if (api_get_setting('homepage_view') != 'activity_big') {
if (api_is_allowed_to_edit(null,true)) {
$tool_table = Database::get_course_table(TABLE_TOOL_LIST);
$tool_info = api_get_tool_information($_GET["id"]);
$tool_visibility = $tool_info['visibility'];
$tool_image = $tool_info['image'];
if (api_get_setting('homepage_view') != 'activity_big') {
$new_image = Display::return_icon(str_replace('.gif','_na.gif',$tool_image), null, null, null, null, true);
$tool_image = Display::return_icon($tool_image, null, null, null, null, true);
} else {
$tool_image = $tool_info['image'];
$tool_image = (substr($tool_info['image'], 0, strpos($tool_info['image'], '.'))).'.png';
$new_image = str_replace('.png','_na.png',$tool_image);
} else {
$tool_image = $tool_info['image'];
$tool_image = (substr($tool_info['image'], 0, strpos($tool_info['image'], '.'))).'.png';
$new_image = str_replace('.png','_na.png',$tool_image);
$new_image = api_get_path(WEB_IMG_PATH).'icons/64/'.$new_image;
$tool_image = api_get_path(WEB_IMG_PATH).'icons/64/'.$tool_image;
}
$requested_image = ($tool_visibility == 0 ) ? $tool_image : $new_image;
$requested_clase = ($tool_visibility == 0 ) ? 'visible' : 'invisible';
$requested_message = ($tool_visibility == 0 ) ? 'is_active' : 'is_inactive';
$requested_view = ($tool_visibility == 0 ) ? 'visible.gif' : 'invisible.gif';
$requested_visible = ($tool_visibility == 0 ) ? 1 : 0;
$requested_view = ($tool_visibility == 0 ) ? 'visible.gif' : 'invisible.gif';
$requested_visible = ($tool_visibility == 0 ) ? 1 : 0;
$tool_image = api_get_path(WEB_IMG_PATH).'icons/64/'.$tool_image;
}
$requested_image = ($tool_visibility == 0 ) ? $tool_image : $new_image;
$requested_clase = ($tool_visibility == 0 ) ? 'visible' : 'invisible';
$requested_message = ($tool_visibility == 0 ) ? 'is_active' : 'is_inactive';
$requested_view = ($tool_visibility == 0 ) ? 'visible.gif' : 'invisible.gif';
$requested_visible = ($tool_visibility == 0 ) ? 1 : 0;
$requested_view = ($tool_visibility == 0 ) ? 'visible.gif' : 'invisible.gif';
$requested_visible = ($tool_visibility == 0 ) ? 1 : 0;
//HIDE AND REACTIVATE TOOL
if ($_GET["id"]==strval(intval($_GET["id"]))) {
@ -56,7 +56,7 @@ switch ($action) {
$sql="UPDATE $tool_table SET visibility=$requested_visible WHERE c_id = $course_id AND id='".intval($_GET['id'])."'";
Database::query($sql);
}
}
$response_data = array(
'image' => $requested_image,
'tclass' => $requested_clase,
@ -66,74 +66,74 @@ switch ($action) {
echo json_encode($response_data);
}
break;
case 'show_course_information' :
$language_file = array('course_description');
require_once '../global.inc.php';
// Get the name of the database course.
// Get the name of the database course.
$tbl_course_description = Database::get_course_table(TABLE_COURSE_DESCRIPTION);
$course_info = api_get_course_info($_GET['code']);
if ($course_info['visibility'] != COURSE_VISIBILITY_OPEN_WORLD) {
if (api_is_anonymous()) {
exit;
}
}
}
}
echo Display::tag('h2', $course_info['name']);
echo '<br />';
$sql = "SELECT * FROM $tbl_course_description WHERE c_id = ".$course_info['real_id']." AND session_id = 0 ORDER BY id";
$result = Database::query($sql);
if (Database::num_rows($result) > 0 ) {
if (Database::num_rows($result) > 0 ) {
while ($description = Database::fetch_object($result)) {
$descriptions[$description->id] = $description;
}
}
// Function that displays the details of the course description in html.
echo CourseManager::get_details_course_description_html($descriptions, api_get_system_encoding(), false);
} else {
echo get_lang('NoDescription');
}
break;
/**
}
break;
/**
* @todo this functions need to belong to a class or a special wrapper to process the AJAX petitions from the jqgrid
*/
case 'session_courses_lp_default':
require_once '../global.inc.php';
require_once api_get_path(SYS_CODE_PATH).'newscorm/learnpathList.class.php';
case 'session_courses_lp_default':
require_once '../global.inc.php';
require_once api_get_path(SYS_CODE_PATH).'newscorm/learnpathList.class.php';
$page = intval($_REQUEST['page']); //page
$limit = intval($_REQUEST['rows']); // quantity of rows
$sidx = $_REQUEST['sidx']; //index to filter
$sidx = $_REQUEST['sidx']; //index to filter
$sord = $_REQUEST['sord']; //asc or desc
if (!in_array($sord, array('asc','desc'))) {
$sord = 'desc';
}
}
$session_id = intval($_REQUEST['session_id']);
$course_id = intval($_REQUEST['course_id']);
//Filter users that does not belong to the session
if (!api_is_platform_admin()) {
$new_session_list = UserManager::get_personal_session_course_list(api_get_user_id());
$my_session_list = array();
foreach($new_session_list as $item) {
if (!empty($item['id_session']))
if (!empty($item['id_session']))
$my_session_list[] = $item['id_session'];
}
}
if (!in_array($session_id, $my_session_list)) {
break;
}
}
}
if(!$sidx) $sidx = 1;
$start = $limit*$page - $limit;
$course_list = SessionManager::get_course_list_by_session_id($session_id);
$start = $limit*$page - $limit;
$course_list = SessionManager::get_course_list_by_session_id($session_id);
$count = 0;
foreach ($course_list as $item) {
if (isset($course_id) && !empty($course_id)) {
if ($course_id != $item['id']) {
@ -141,13 +141,13 @@ switch ($action) {
}
}
$list = new LearnpathList(api_get_user_id(), $item['code'], $session_id);
$flat_list = $list->get_flat_list();
$flat_list = $list->get_flat_list();
$lps[$item['code']] = $flat_list;
$course_url = api_get_path(WEB_COURSE_PATH).$item['directory'].'/?id_session='.$session_id;
$item['title'] = Display::url($item['title'], $course_url, array('target'=>SESSION_LINK_TARGET));
foreach($flat_list as $lp_id => $lp_item) {
$temp[$count]['id']= $lp_id;
foreach($flat_list as $lp_id => $lp_item) {
$temp[$count]['id']= $lp_id;
$lp_url = api_get_path(WEB_CODE_PATH).'newscorm/lp_controller.php?cidReq='.$item['code'].'&id_session='.$session_id.'&lp_id='.$lp_id.'&action=view';
$last_date = Tracking::get_last_connection_date_on_the_course(api_get_user_id(),$item['code'], $session_id, false);
if ($lp_item['modified_on'] == '0000-00-00 00:00:00' || empty($lp_item['modified_on'])) {
@ -160,117 +160,117 @@ switch ($action) {
$label = get_lang('LearnpathUpdated');
}
if (strtotime($last_date) < strtotime($lp_date)) {
$icons = Display::return_icon($image, get_lang('TitleNotification').': '.$label.' - '.$lp_date);
$icons = Display::return_icon($image, get_lang('TitleNotification').': '.$label.' - '.$lp_date);
}
if (!empty($lp_item['publicated_on'])) {
$date = substr($lp_item['publicated_on'], 0, 10);
} else {
$date = '-';
}
//Checking LP publicated and expired_on dates
if (!empty($lp_item['publicated_on']) && $lp_item['publicated_on'] != '0000-00-00 00:00:00') {
if ($now < api_strtotime($lp_item['publicated_on'], 'UTC')) {
if (!empty($lp_item['publicated_on']) && $lp_item['publicated_on'] != '0000-00-00 00:00:00') {
if ($now < api_strtotime($lp_item['publicated_on'], 'UTC')) {
continue;
}
}
if (!empty($lp_item['expired_on']) && $lp_item['expired_on'] != '0000-00-00 00:00:00') {
if ($now > api_strtotime($lp_item['expired_on'], 'UTC')) {
continue;
}
}
$temp[$count]['cell']=array($date, $item['title'], Display::url($icons.' '.$lp_item['lp_name'], $lp_url, array('target'=>SESSION_LINK_TARGET)));
$temp[$count]['course'] = strip_tags($item['title']);
$temp[$count]['lp'] = $lp_item['lp_name'];
$temp[$count]['date'] = $lp_item['publicated_on'];
$count++;
}
}
$count++;
}
}
$temp = msort($temp, $sidx, $sord);
$i =0;
$response = new stdClass();
$response = new stdClass();
foreach($temp as $key=>$row) {
$row = $row['cell'];
if (!empty($row)) {
if ($key >= $start && $key < ($start + $limit)) {
if (!empty($row)) {
if ($key >= $start && $key < ($start + $limit)) {
$response->rows[$i]['id']= $key;
$response->rows[$i]['cell']=array($row[0], $row[1], $row[2]);
$i++;
$i++;
}
}
}
if($count > 0 && $limit > 0) {
$total_pages = ceil($count/$limit);
} else {
$total_pages = 0;
}
$response->total = $total_pages;
if ($page > $total_pages) {
}
if($count > 0 && $limit > 0) {
$total_pages = ceil($count/$limit);
} else {
$total_pages = 0;
}
$response->total = $total_pages;
if ($page > $total_pages) {
$response->page= $total_pages;
} else {
$response->page = $page;
}
$response->records = $count;
echo json_encode($response);
$response->page = $page;
}
$response->records = $count;
echo json_encode($response);
break;
case 'session_courses_lp_by_week':
require_once '../global.inc.php';
require_once api_get_path(SYS_CODE_PATH).'newscorm/learnpathList.class.php';
require_once '../global.inc.php';
require_once api_get_path(SYS_CODE_PATH).'newscorm/learnpathList.class.php';
$page = intval($_REQUEST['page']); //page
$limit = intval($_REQUEST['rows']); // quantity of rows
$sidx = $_REQUEST['sidx']; //index to filter
$sidx = $_REQUEST['sidx']; //index to filter
if (empty($sidx)) $sidx = 'course';
$sord = $_REQUEST['sord']; //asc or desc
if (!in_array($sord, array('asc','desc'))) {
$sord = 'desc';
}
$session_id = intval($_REQUEST['session_id']);
$course_id = intval($_REQUEST['course_id']);
//Filter users that does not belong to the session
if (!api_is_platform_admin()) {
$new_session_list = UserManager::get_personal_session_course_list(api_get_user_id());
$my_session_list = array();
foreach($new_session_list as $item) {
if (!empty($item['id_session']))
if (!empty($item['id_session']))
$my_session_list[] = $item['id_session'];
}
}
if (!in_array($session_id, $my_session_list)) {
break;
}
}
$start = $limit*$page - $limit;
}
$start = $limit*$page - $limit;
$course_list = SessionManager::get_course_list_by_session_id($session_id);
$count = 0;
$temp = array();
foreach ($course_list as $item) {
foreach ($course_list as $item) {
if (isset($course_id) && !empty($course_id)) {
if ($course_id != $item['id']) {
continue;
}
}
$list = new LearnpathList(api_get_user_id(),$item['code'], $session_id, 'publicated_on DESC');
$flat_list = $list->get_flat_list();
$flat_list = $list->get_flat_list();
$lps[$item['code']] = $flat_list;
$item['title'] = Display::url($item['title'],api_get_path(WEB_COURSE_PATH).$item['directory'].'/?id_session='.$session_id,array('target'=>SESSION_LINK_TARGET));
foreach($flat_list as $lp_id => $lp_item) {
$temp[$count]['id']= $lp_id;
$lp_url = api_get_path(WEB_CODE_PATH).'newscorm/lp_controller.php?cidReq='.$item['code'].'&id_session='.$session_id.'&lp_id='.$lp_id.'&action=view';
$last_date = Tracking::get_last_connection_date_on_the_course(api_get_user_id(),$item['code'], $session_id, false);
if ($lp_item['modified_on'] == '0000-00-00 00:00:00' || empty($lp_item['modified_on'])) {
$lp_date = api_get_local_time($lp_item['created_on']);
@ -282,118 +282,118 @@ switch ($action) {
$label = get_lang('LearnpathUpdated');
}
if (strtotime($last_date) < strtotime($lp_date)) {
$icons = Display::return_icon($image, get_lang('TitleNotification').': '.$label.' - '.$lp_date);
$icons = Display::return_icon($image, get_lang('TitleNotification').': '.$label.' - '.$lp_date);
}
if (!empty($lp_item['publicated_on'])) {
$date = substr($lp_item['publicated_on'], 0, 10);
} else {
$date = '-';
}
//Checking LP publicated and expired_on dates
if (!empty($lp_item['publicated_on']) && $lp_item['publicated_on'] != '0000-00-00 00:00:00') {
$week_data = date('Y', api_strtotime($lp_item['publicated_on'], 'UTC')).' - '.get_week_from_day($lp_item['publicated_on']);
if ($now < api_strtotime($lp_item['publicated_on'], 'UTC')) {
$week_data = date('Y', api_strtotime($lp_item['publicated_on'], 'UTC')).' - '.get_week_from_day($lp_item['publicated_on']);
if ($now < api_strtotime($lp_item['publicated_on'], 'UTC')) {
continue;
}
} else {
$week_data = '';
}
if (!empty($lp_item['expired_on']) && $lp_item['expired_on'] != '0000-00-00 00:00:00') {
if ($now > api_strtotime($lp_item['expired_on'], 'UTC')) {
continue;
}
}
$temp[$count]['cell'] = array($week_data, $date, $item['title'], Display::url($icons.' '.$lp_item['lp_name'], $lp_url, array('target'=>SESSION_LINK_TARGET)));
$temp[$count]['course'] = strip_tags($item['title']);
$temp[$count]['lp'] = $lp_item['lp_name'];
$count++;
}
$count++;
}
}
$temp = msort($temp, $sidx, $sord);
$response = new stdClass();
$i =0;
foreach($temp as $key=>$row) {
$row = $row['cell'];
if (!empty($row)) {
if ($key >= $start && $key < ($start + $limit)) {
$response = new stdClass();
$i =0;
foreach($temp as $key=>$row) {
$row = $row['cell'];
if (!empty($row)) {
if ($key >= $start && $key < ($start + $limit)) {
$response->rows[$i]['id']= $key;
$response->rows[$i]['cell']=array($row[0], $row[1], $row[2],$row[3]);
$i++;
$i++;
}
}
}
if($count > 0 && $limit > 0) {
$total_pages = ceil($count/$limit);
} else {
$total_pages = 0;
}
$response->total = $total_pages;
if ($page > $total_pages) {
if($count > 0 && $limit > 0) {
$total_pages = ceil($count/$limit);
} else {
$total_pages = 0;
}
$response->total = $total_pages;
if ($page > $total_pages) {
$response->page = $total_pages;
} else {
$response->page = $page;
}
$response->records = $count;
echo json_encode($response);
$response->page = $page;
}
$response->records = $count;
echo json_encode($response);
break;
case 'session_courses_lp_by_course':
require_once '../global.inc.php';
require_once api_get_path(SYS_CODE_PATH).'newscorm/learnpathList.class.php';
require_once '../global.inc.php';
require_once api_get_path(SYS_CODE_PATH).'newscorm/learnpathList.class.php';
$page = intval($_REQUEST['page']); //page
$limit = intval($_REQUEST['rows']); // quantity of rows
$sidx = $_REQUEST['sidx']; //index to filter
$sidx = $_REQUEST['sidx']; //index to filter
$sord = $_REQUEST['sord']; //asc or desc
if (!in_array($sord, array('asc','desc'))) {
$sord = 'desc';
}
}
$session_id = intval($_REQUEST['session_id']);
$course_id = intval($_REQUEST['course_id']);
//Filter users that does not belong to the session
if (!api_is_platform_admin()) {
$new_session_list = UserManager::get_personal_session_course_list(api_get_user_id());
$my_session_list = array();
foreach($new_session_list as $item) {
if (!empty($item['id_session']))
if (!empty($item['id_session']))
$my_session_list[] = $item['id_session'];
}
}
if (!in_array($session_id, $my_session_list)) {
break;
}
}
if(!$sidx) $sidx =1;
$start = $limit*$page - $limit;
$start = $limit*$page - $limit;
$course_list = SessionManager::get_course_list_by_session_id($session_id);
$count = 0;
foreach ($course_list as $item) {
foreach ($course_list as $item) {
if (isset($course_id) && !empty($course_id)) {
if ($course_id != $item['id']) {
continue;
}
}
$list = new LearnpathList(api_get_user_id(),$item['code'],$session_id);
$flat_list = $list->get_flat_list();
$flat_list = $list->get_flat_list();
$lps[$item['code']] = $flat_list;
$item['title'] = Display::url($item['title'],api_get_path(WEB_COURSE_PATH).$item['directory'].'/?id_session='.$session_id, array('target'=>SESSION_LINK_TARGET));
foreach($flat_list as $lp_id => $lp_item) {
foreach($flat_list as $lp_id => $lp_item) {
$temp[$count]['id']= $lp_id;
$lp_url = api_get_path(WEB_CODE_PATH).'newscorm/lp_controller.php?cidReq='.$item['code'].'&id_session='.$session_id.'&lp_id='.$lp_id.'&action=view';
$last_date = Tracking::get_last_connection_date_on_the_course(api_get_user_id(),$item['code'], $session_id, false);
@ -407,63 +407,63 @@ switch ($action) {
$label = get_lang('LearnpathUpdated');
}
if (strtotime($last_date) < strtotime($lp_date)) {
$icons = Display::return_icon($image, get_lang('TitleNotification').': '.$label.' - '.$lp_date);
$icons = Display::return_icon($image, get_lang('TitleNotification').': '.$label.' - '.$lp_date);
}
if (!empty($lp_item['publicated_on'])) {
$date = substr($lp_item['publicated_on'], 0, 10);
} else {
$date = '-';
}
//Checking LP publicated and expired_on dates
if (!empty($lp_item['publicated_on']) && $lp_item['publicated_on'] != '0000-00-00 00:00:00') {
if ($now < api_strtotime($lp_item['publicated_on'], 'UTC')) {
if (!empty($lp_item['publicated_on']) && $lp_item['publicated_on'] != '0000-00-00 00:00:00') {
if ($now < api_strtotime($lp_item['publicated_on'], 'UTC')) {
continue;
}
}
}
if (!empty($lp_item['expired_on']) && $lp_item['expired_on'] != '0000-00-00 00:00:00') {
if ($now > api_strtotime($lp_item['expired_on'], 'UTC')) {
continue;
}
}
}
$temp[$count]['cell'] = array($date, $item['title'], Display::url($icons.' '.$lp_item['lp_name'], $lp_url, array('target'=>SESSION_LINK_TARGET)));
$temp[$count]['course'] = strip_tags($item['title']);
$temp[$count]['lp'] = $lp_item['lp_name'];
$temp[$count]['date'] = $lp_item['publicated_on'];
$count++;
}
$count++;
}
}
$temp = msort($temp, $sidx, $sord);
$response = new stdClass();
$response = new stdClass();
$i =0;
foreach($temp as $key=>$row) {
$row = $row['cell'];
if (!empty($row)) {
if ($key >= $start && $key < ($start + $limit)) {
foreach($temp as $key=>$row) {
$row = $row['cell'];
if (!empty($row)) {
if ($key >= $start && $key < ($start + $limit)) {
$response->rows[$i]['id']= $key;
$response->rows[$i]['cell']=array($row[0], $row[1], $row[2],$row[3]);
$i++;
$i++;
}
}
}
if($count > 0 && $limit > 0) {
$total_pages = ceil($count/$limit);
} else {
$total_pages = 0;
}
$response->total = $total_pages;
if ($page > $total_pages) {
if($count > 0 && $limit > 0) {
$total_pages = ceil($count/$limit);
} else {
$total_pages = 0;
}
$response->total = $total_pages;
if ($page > $total_pages) {
$response->page= $total_pages;
} else {
$response->page = $page;
}
$response->records = $count;
echo json_encode($response);
$response->page = $page;
}
$response->records = $count;
echo json_encode($response);
break;
default:
echo '';

@ -1,5 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
require_once '../global.inc.php';
$id = isset($_REQUEST['id']) ? $_REQUEST['id'] : null;
@ -9,7 +9,7 @@ $event_name = isset($_REQUEST['eventName']) ? $_REQUEST['eventName'] : null;
api_protect_admin_script();
switch ($action) {
case 'getEventTypes':
case 'getEventTypes':
$events = get_all_event_types();
print json_encode($events);
break;
@ -17,9 +17,9 @@ switch ($action) {
$users = UserManager::get_user_list();
print json_encode($users);
break;
case 'get_event_users' :
case 'get_event_users':
$users = get_event_users($event_name);
print json_encode($users);
break;
}
exit;
exit;

@ -71,7 +71,7 @@ switch ($action) {
}
$start = $limit * $page - $limit;
if ($start < 0 ) {
if ($start < 0) {
$start = 0;
}
@ -101,7 +101,7 @@ switch ($action) {
$result = Database::query($sql);
$results = array();
while ($row = Database::fetch_array($result, 'ASSOC')){
while ($row = Database::fetch_array($result, 'ASSOC')) {
$results[] = $row;
}
@ -115,7 +115,7 @@ switch ($action) {
$i=0;
if (!empty($results)) {
foreach($results as $row) {
foreach ($results as $row) {
$sql = "SELECT SUM(count_question_id) as count_question_id FROM (
SELECT 1 as count_question_id FROM $track_attempt a
WHERE user_id = {$row['exe_user_id']} and exe_id = {$row['exe_id']}
@ -132,12 +132,13 @@ switch ($action) {
$h = floor($remaining/3600);
$m = floor(($remaining - ($h*3600))/60);
$s = ($remaining - ($h*3600) - ($m*60));
$array = array( $row['firstname'],
$row['lastname'],
api_format_date($row['start_date'], DATE_TIME_FORMAT_LONG).' ['.($h>0?$h.':':'').sprintf("%02d",$m).':'.sprintf("%02d",$s).']',
$row['count_questions'],
round($row['score']*100).'%'
);
$array = array(
$row['firstname'],
$row['lastname'],
api_format_date($row['start_date'], DATE_TIME_FORMAT_LONG).' ['.($h>0?$h.':':'').sprintf("%02d",$m).':'.sprintf("%02d",$s).']',
$row['count_questions'],
round($row['score']*100).'%'
);
$response->rows[$i]['cell'] = $array;
$i++;
}

@ -1,6 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
require_once '../global.inc.php';
$action = isset($_REQUEST['a']) ? $_REQUEST['a'] : null;

@ -1,5 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
namespace Glossary;
require_once '../global.inc.php';

@ -13,11 +13,11 @@ api_protect_course_script(true);
$action = $_REQUEST['a'];
switch ($action) {
switch ($action) {
case 'get_gradebook_weight':
if (api_is_allowed_to_edit(null, true)) {
$cat_id = $_GET['cat_id'];
$cat = Category :: load($cat_id);
$cat = Category :: load($cat_id);
if ($cat && isset($cat[0])) {
echo $cat[0]->get_weight();
} else {
@ -27,5 +27,5 @@ switch ($action) {
break;
default:
echo '';
}
exit;
}
exit;

@ -10,59 +10,59 @@ $action = $_GET['a'];
switch ($action) {
case 'send_contact_information':
if (!empty($_POST)) {
// get params from contact form
$person_name = $_POST['person_name'];
$person_email = $_POST['person_email'];
$person_role = $_POST['person_role'];
$financial_decision = $_POST['financial_decision'];
$contact_language = $_POST['language'];
$company_name = $_POST['company_name'];
$company_activity = $_POST['company_activity'];
$company_country = $_POST['company_country'];
$company_city = $_POST['company_city'];
if (!empty($_POST)) {
// get params from contact form
$person_name = $_POST['person_name'];
$person_email = $_POST['person_email'];
$person_role = $_POST['person_role'];
$financial_decision = $_POST['financial_decision'];
$contact_language = $_POST['language'];
$company_name = $_POST['company_name'];
$company_activity = $_POST['company_activity'];
$company_country = $_POST['company_country'];
$company_city = $_POST['company_city'];
// validating required fields
$a_required_fields = array($person_name, $person_role, $company_name, $company_activity, $company_country);
$required_field_error = false;
foreach($a_required_fields as $required_file) {
if (trim($required_file) === '') {
$required_field_error = true;
break;
}
}
// validating required fields
$a_required_fields = array($person_name, $person_role, $company_name, $company_activity, $company_country);
$required_field_error = false;
foreach ($a_required_fields as $required_file) {
if (trim($required_file) === '') {
$required_field_error = true;
break;
}
}
if ($required_field_error) {
echo 'required_field_error';
} else {
if ($required_field_error) {
echo 'required_field_error';
} else {
// save contact information with web service
require_once '../lib/nusoap/nusoap.php';
// save contact information with web service
require_once '../lib/nusoap/nusoap.php';
// create a client
$client = new nusoap_client('http://version.chamilo.org/contact.php?wsdl', true);
// create a client
$client = new nusoap_client('http://version.chamilo.org/contact.php?wsdl', true);
// call method ws_add_contact_information
$contact_params = array(
'person_name' => $person_name,
'person_email' => $person_email,
'person_role' => $person_role,
'financial_decision' => $financial_decision,
'contact_language' => $contact_language,
'company_name' => $company_name,
'company_activity' => $company_activity,
'company_country' => $company_country,
'company_city' => $company_city
);
// call method ws_add_contact_information
$contact_params = array(
'person_name' => $person_name,
'person_email' => $person_email,
'person_role' => $person_role,
'financial_decision' => $financial_decision,
'contact_language' => $contact_language,
'company_name' => $company_name,
'company_activity' => $company_activity,
'company_country' => $company_country,
'company_city' => $company_city
);
$result = $client->call('ws_add_contact_information', array('contact_params' => $contact_params));
echo $result;
}
$result = $client->call('ws_add_contact_information', array('contact_params' => $contact_params));
}
break;
echo $result;
}
}
break;
default:
echo '';
}
exit;
exit;

@ -10,36 +10,35 @@ api_protect_course_script(true);
$action = $_REQUEST['a'];
switch ($action) {
switch ($action) {
case 'check_url':
if (api_is_allowed_to_edit(null, true)) {
$url = $_REQUEST['url'];
//Check if curl is available
if (!in_array('curl', get_loaded_extensions())) {
// Check if curl is available.
if (!in_array('curl', get_loaded_extensions())) {
echo '';
exit;
}
// set URL and other appropriate options
// set URL and other appropriate options
$defaults = array(
CURLOPT_URL => $url,
CURLOPT_FOLLOWLOCATION => true, // follow redirects accept youtube.com
CURLOPT_FOLLOWLOCATION => true, // follow redirects accept youtube.com
CURLOPT_HEADER => 0,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 4
);
//create a new cURL resource
$ch = curl_init();
curl_setopt_array($ch, $defaults);
curl_setopt_array($ch, $defaults);
// grab URL and pass it to the browser
$result = curl_exec($ch);
$result = curl_exec($ch);
// close cURL resource, and free up system resources
curl_close($ch);
if ($result) {
echo Display::return_icon('accept.png', get_lang('Ok'));
} else {

@ -18,29 +18,29 @@ switch ($action) {
$course_code = Security::remove_XSS($_REQUEST['course']);
$type = Security::remove_XSS($_REQUEST['type']);
$range = Security::remove_XSS($_REQUEST['range']);
if ($range == 1){
if ($range == 1) {
$start_date = Security::remove_XSS($_REQUEST['sd']);
$end_date = Security::remove_XSS($_REQUEST['ed']);
$sql_result = get_connections_to_course_by_date($user_id, $course_code, $start_date, $end_date);
} else {
$sql_result = MySpace::get_connections_to_course($user_id, $course_code);
}
}
$foo_print = grapher($sql_result, $start_date, $end_date, $type);
echo $foo_print;
break;
case 'access_detail_by_date':
$db = array('is_empty'=>true);
$start_date = isset($_REQUEST['startDate'])?$_REQUEST['startDate']:"";
$end_date = isset($_REQUEST['endDate'])?$_REQUEST['endDate']:"";
$user_id = isset($_REQUEST['student'])?$_REQUEST['student']:"";
$course_code = isset($_REQUEST['course'])?$_REQUEST['course']:"";
$sql_result = get_connections_to_course_by_date($user_id, $course_code, $start_date, $end_date);
if (is_array($sql_result) && count($sql_result) > 0) {
$db['is_empty'] = false;
$db['result'] = convert_to_string($sql_result);
@ -54,10 +54,9 @@ switch ($action) {
$db['result'] = Display::return_message(get_lang('NoDataAvailable'), 'warning');
$db['graph_result'] = Display::return_message(get_lang('NoDataAvailable'), 'warning');
$db['stats'] = Display::return_message(get_lang('NoDataAvailable'), 'warning');
}
}
header('Cache-Control: no-cache');
echo json_encode($db); // requires: PHP >= 5.2.0, PECL json >= 1.2.0
break;
break;
}
exit;

@ -1,5 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
@ -16,17 +16,17 @@ switch($action) {
$_SESSION['who_is_online_counter'] = 2;
}
$images_to_show = 9;
$page = intval($_REQUEST['online_page_nr']);
$page = intval($_REQUEST['online_page_nr']);
$max_page = round(who_is_online_count()/$images_to_show);
$page_rows = ($page-1)*9 + 1;
if (!empty($max_page) && $page <= $max_page) {
if (isset($_GET['cidReq']) && strlen($_GET['cidReq']) > 0) {
$user_list = who_is_online_in_this_course($page_rows, $images_to_show, api_get_user_id(), api_get_setting('time_limit_whosonline'), $_GET['cidReq']);
} else {
$user_list = who_is_online($page_rows, $images_to_show);
}
} else {
$user_list = who_is_online($page_rows, $images_to_show);
}
if (!empty($user_list)) {
echo SocialManager::display_user_list($user_list);
exit;
@ -36,4 +36,4 @@ switch($action) {
break;
default:
break;
}
}

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
require_once '../global.inc.php';
require_once api_get_path(LIBRARY_PATH).'timeline.lib.php';
@ -6,10 +7,10 @@ $timeline = new Timeline();
$action = $_GET['a'];
switch ($action) {
switch ($action) {
case 'get_timeline_content':
$items = $timeline->get_timeline_content($_GET['id']);
echo json_encode($items);
echo json_encode($items);
/*echo '<pre>';
echo json_encode($items);
echo '</pre>';

@ -1,25 +1,24 @@
<?php
/* For licensing terms, see /chamilo_license.txt */
/**
* Responses to AJAX calls
* Responses to AJAX calls
*/
$language_file = array('admin', 'registration', 'userInfo');
require_once '../global.inc.php';
$action = $_GET['a'];
switch ($action) {
case 'get_user_popup':
switch ($action) {
case 'get_user_popup':
$user_info = api_get_user_info($_REQUEST['user_id']);
//var_dump($user_info);
echo '<div class="well">';
echo '<div class="row">';
echo '<div class="span2">';
echo '<div class="thumbnail">';
echo '<div class="thumbnail">';
echo '<img src="'.$user_info['avatar'].'" /> ';
echo '</div>';
echo '</div>';
echo '<div class="span3">';
echo '<div class="span3">';
if (api_get_setting('show_email_addresses') == 'false') {
$user_info['mail'] = ' ';
} else {
@ -33,80 +32,81 @@ switch ($action) {
break;
case 'user_id_exists':
if (api_is_anonymous()) {
echo '';
} else {
echo '';
} else {
if (UserManager::is_user_id_valid($_GET['user_id'])) {
echo 1;
} else {
echo 0;
}
}
break;
break;
case 'search_tags':
if (api_is_anonymous()) {
echo '';
} else {
if (isset($_GET['tag']) && isset($_GET['field_id'])) {
echo UserManager::get_tags($_GET['tag'], $_GET['field_id'],'json','10');
echo '';
} else {
if (isset($_GET['tag']) && isset($_GET['field_id'])) {
echo UserManager::get_tags($_GET['tag'], $_GET['field_id'], 'json', '10');
}
}
}
break;
case 'generate_api_key':
if (api_is_anonymous()) {
echo '';
} else {
$array_list_key = array();
$user_id = api_get_user_id();
$api_service = 'dokeos';
$num = UserManager::update_api_key($user_id, $api_service);
$array_list_key = UserManager::get_api_keys($user_id, $api_service);
?>
<div class="row">
<div class="label"><?php echo get_lang('MyApiKey'); ?></div>
<div class="formw">
<input type="text" name="api_key_generate" id="id_api_key_generate" size="40" value="<?php echo $array_list_key[$num]; ?>"/>
</div>
</div>
<?php
}
if (api_is_anonymous()) {
echo '';
} else {
$array_list_key = array();
$user_id = api_get_user_id();
$api_service = 'dokeos';
$num = UserManager::update_api_key($user_id, $api_service);
$array_list_key = UserManager::get_api_keys($user_id, $api_service);
?>
<div class="row">
<div class="label"><?php echo get_lang('MyApiKey'); ?></div>
<div class="formw">
<input type="text" name="api_key_generate" id="id_api_key_generate" size="40" value="<?php echo $array_list_key[$num]; ?>"/>
</div>
</div>
<?php
}
break;
case 'active_user':
if (api_is_platform_admin() && api_global_admin_can_edit_admin($_GET['user_id'])) {
$user_id = intval($_GET['user_id']);
$status = intval($_GET['status']);
if (!empty($user_id)) {
$user_table = Database :: get_main_table(TABLE_MAIN_USER);
$sql="UPDATE $user_table SET active='".$status."' WHERE user_id='".$user_id."'";
$result = Database::query($sql);
//Send and email if account is active
if ($status == 1) {
$user_info = api_get_user_info($user_id);
$recipient_name = api_get_person_name($user_info['firstname'], $user_info['lastname'], null, PERSON_NAME_EMAIL_ADDRESS);
$emailsubject = '['.api_get_setting('siteName').'] '.get_lang('YourReg').' '.api_get_setting('siteName');
$email_admin = api_get_setting('emailAdministrator');
$sender_name = api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'), null, PERSON_NAME_EMAIL_ADDRESS);
$emailbody=get_lang('Dear')." ".stripslashes($recipient_name).",\n\n";
$emailbody.=sprintf(get_lang('YourAccountOnXHasJustBeenApprovedByOneOfOurAdministrators'), api_get_setting('siteName'))."\n";
$emailbody.=sprintf(get_lang('YouCanNowLoginAtXUsingTheLoginAndThePasswordYouHaveProvided'), api_get_path(WEB_PATH)).",\n\n";
$emailbody.=get_lang('HaveFun')."\n\n";
//$emailbody.=get_lang('Problem'). "\n\n". get_lang('Formula');
$emailbody.=api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'))."\n". get_lang('Manager'). " ".api_get_setting('siteName')."\nT. ".api_get_setting('administratorTelephone')."\n" .get_lang('Email') ." : ".api_get_setting('emailAdministrator');
$result = api_mail($recipient_name, $user_info['mail'], $emailsubject, $emailbody, $sender_name, $email_admin);
event_system(LOG_USER_ENABLE, LOG_USER_ID, $user_id);
} else {
event_system(LOG_USER_DISABLE, LOG_USER_ID, $user_id);
}
if (api_is_platform_admin() && api_global_admin_can_edit_admin($_GET['user_id'])) {
$user_id = intval($_GET['user_id']);
$status = intval($_GET['status']);
if (!empty($user_id)) {
$user_table = Database :: get_main_table(TABLE_MAIN_USER);
$sql="UPDATE $user_table SET active='".$status."' WHERE user_id='".$user_id."'";
$result = Database::query($sql);
//Send and email if account is active
if ($status == 1) {
$user_info = api_get_user_info($user_id);
$recipient_name = api_get_person_name($user_info['firstname'], $user_info['lastname'], null, PERSON_NAME_EMAIL_ADDRESS);
$emailsubject = '['.api_get_setting('siteName').'] '.get_lang('YourReg').' '.api_get_setting('siteName');
$email_admin = api_get_setting('emailAdministrator');
$sender_name = api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'), null, PERSON_NAME_EMAIL_ADDRESS);
$emailbody=get_lang('Dear')." ".stripslashes($recipient_name).",\n\n";
$emailbody.=sprintf(get_lang('YourAccountOnXHasJustBeenApprovedByOneOfOurAdministrators'), api_get_setting('siteName'))."\n";
$emailbody.=sprintf(get_lang('YouCanNowLoginAtXUsingTheLoginAndThePasswordYouHaveProvided'), api_get_path(WEB_PATH)).",\n\n";
$emailbody.=get_lang('HaveFun')."\n\n";
//$emailbody.=get_lang('Problem'). "\n\n". get_lang('Formula');
$emailbody.=api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'))."\n". get_lang('Manager'). " ".api_get_setting('siteName')."\nT. ".api_get_setting('administratorTelephone')."\n" .get_lang('Email') ." : ".api_get_setting('emailAdministrator');
$result = api_mail($recipient_name, $user_info['mail'], $emailsubject, $emailbody, $sender_name, $email_admin);
event_system(LOG_USER_ENABLE, LOG_USER_ID, $user_id);
} else {
event_system(LOG_USER_DISABLE, LOG_USER_ID, $user_id);
}
echo $status;
}
} else {
echo '-1';
}
}
} else {
echo '-1';
}
break;
default:
echo '';
default:
echo '';
}
exit;

Loading…
Cancel
Save