Minor - Format code, remove unused code

pull/2487/head
jmontoyaa 9 years ago
parent a0bffd4f87
commit 66ea436b73
  1. 2
      main/inc/ajax/chat.ajax.php
  2. 29
      main/inc/ajax/course.ajax.php
  3. 14
      main/inc/ajax/course_home.ajax.php
  4. 1
      main/inc/ajax/lp.ajax.php
  5. 1
      main/inc/ajax/message.ajax.php
  6. 1
      main/inc/ajax/myspace.ajax.php
  7. 2
      main/inc/ajax/record_audio_wami.ajax.php
  8. 4
      main/inc/ajax/sequence.ajax.php
  9. 8
      main/inc/ajax/session.ajax.php
  10. 14
      main/inc/ajax/social.ajax.php
  11. 2
      main/inc/ajax/statistics.ajax.php
  12. 1
      main/inc/ajax/thematic.ajax.php
  13. 11
      main/inc/ajax/user_manager.ajax.php
  14. 2
      main/inc/lib/SequenceResourceManager.php
  15. 3
      main/inc/lib/TicketManager.php
  16. 2
      main/inc/lib/api.lib.php
  17. 33
      main/inc/lib/message.lib.php
  18. 8
      main/inc/lib/notebook.lib.php
  19. 3
      main/inc/lib/social.lib.php
  20. 45
      main/inc/lib/statistics.lib.php
  21. 183
      main/inc/lib/statsUtils.lib.inc.php
  22. 2
      main/inc/lib/table_sort.class.php
  23. 13
      main/inc/lib/tracking.lib.php
  24. 70
      main/inc/lib/urlmanager.lib.php
  25. 2
      main/inc/lib/usergroup.lib.php
  26. 4
      main/social/profile.php
  27. 38
      tests/main/inc/lib/statsUtils.lib.inc.test.php

@ -37,7 +37,7 @@ if (!isset($_SESSION['openChatBoxes'])) {
}
$chat = new Chat();
if (chat::disableChat()){
if (chat::disableChat()) {
exit;
}
if ($chat->is_chat_blocked_by_exercises()) {

@ -57,7 +57,6 @@ switch ($action) {
}
$list = [];
foreach ($categories as $item) {
$list['items'][] = [
'id' => $item['code'],
@ -173,9 +172,8 @@ switch ($action) {
break;
case 'search_user_by_course':
if (api_is_platform_admin()) {
$user = Database :: get_main_table(TABLE_MAIN_USER);
$session_course_user = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
$user = Database :: get_main_table(TABLE_MAIN_USER);
$session_course_user = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
$course = api_get_course_info_by_id($_GET['course_id']);
$json = [
@ -184,7 +182,8 @@ switch ($action) {
$sql = "SELECT u.user_id as id, u.username, u.lastname, u.firstname
FROM $user u
INNER JOIN $session_course_user r ON u.user_id = r.user_id
INNER JOIN $session_course_user r
ON u.user_id = r.user_id
WHERE session_id = %d AND c_id = '%s'
AND (u.firstname LIKE '%s' OR u.username LIKE '%s' OR u.lastname LIKE '%s')";
$needle = '%' . $_GET['q'] . '%';
@ -207,7 +206,14 @@ switch ($action) {
if (api_is_platform_admin()) {
$course = api_get_course_info_by_id($_GET['course_id']);
$session_id = (!empty($_GET['session_id'])) ? intval($_GET['session_id']) : 0 ;
$exercises = ExerciseLib::get_all_exercises($course, $session_id, false, $_GET['q'], true, 3);
$exercises = ExerciseLib::get_all_exercises(
$course,
$session_id,
false,
$_GET['q'],
true,
3
);
foreach ($exercises as $exercise) {
$data[] = array('id' => $exercise['id'], 'text' => html_entity_decode($exercise['title']) );
@ -255,7 +261,6 @@ switch ($action) {
case 'display_sessions_courses':
$sessionId = intval($_GET['session']);
$userTable = Database::get_main_table(TABLE_MAIN_USER);
$coursesData = SessionManager::get_course_list_by_session_id($sessionId);
$courses = array();
@ -273,11 +278,11 @@ switch ($action) {
$coachName = api_get_person_name($userResult['firstname'], $userResult['lastname']);
}
$courses[] = array(
'id' => $courseId,
'name' => $course['title'],
'coachName' => $coachName,
);
$courses[] = array(
'id' => $courseId,
'name' => $course['title'],
'coachName' => $coachName,
);
}
echo json_encode($courses);

@ -85,7 +85,7 @@ switch ($action) {
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;
}
@ -104,7 +104,6 @@ switch ($action) {
* @todo this functions need to belong to a class or a special
* wrapper to process the AJAX petitions from the jqgrid
*/
require_once __DIR__.'/../global.inc.php';
$now = time();
$page = intval($_REQUEST['page']); //page
@ -122,7 +121,7 @@ switch ($action) {
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) {
foreach ($new_session_list as $item) {
if (!empty($item['id_session']))
$my_session_list[] = $item['id_session'];
}
@ -208,7 +207,7 @@ switch ($action) {
$i =0;
$response = new stdClass();
foreach($temp as $key=>$row) {
foreach ($temp as $key=>$row) {
$row = $row['cell'];
if (!empty($row)) {
if ($key >= $start && $key < ($start + $limit)) {
@ -219,7 +218,7 @@ switch ($action) {
}
}
if($count > 0 && $limit > 0) {
if ($count > 0 && $limit > 0) {
$total_pages = ceil($count/$limit);
} else {
$total_pages = 0;
@ -254,9 +253,10 @@ switch ($action) {
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']))
foreach ($new_session_list as $item) {
if (!empty($item['id_session'])) {
$my_session_list[] = $item['id_session'];
}
}
if (!in_array($session_id, $my_session_list)) {
break;

@ -245,7 +245,6 @@ switch ($action) {
}
$forumThread = $lpItem->getForumThread($course_id, $sessionId);
if (empty($forumThread)) {
$lpItem->createForumThread($forumId);
$forumThread = $lpItem->getForumThread($course_id, $sessionId);

@ -1,5 +1,6 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Responses to AJAX calls
*/

@ -1,5 +1,6 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Responses to AJAX calls
*/

@ -58,7 +58,7 @@ if (!is_dir($saveDir)) {
//avoid duplicates
$waminame_to_save = $waminame;
$waminame_noex = basename($waminame, ".wav");
$waminame_noex = basename($waminame, ".wav");
if (file_exists($saveDir.'/'.$waminame_noex.'.'.$ext)) {
$i = 1;
while (file_exists($saveDir.'/'.$waminame_noex.'_'.$i.'.'.$ext)) {

@ -127,7 +127,6 @@ switch ($action) {
if ($sequenceResource->getSequence()->hasGraph()) {
$graph = $sequenceResource->getSequence()->getUnSerializeGraph();
if ($graph->hasVertex($vertexId)) {
$edgeIterator = $graph->getEdges()->getIterator();
$edgeToDelete = null;
foreach ($edgeIterator as $edge) {
@ -197,10 +196,7 @@ switch ($action) {
$em->remove($sequenceResource);
$em->remove($sequenceResourceToDelete);
}
}
}
}

@ -161,7 +161,11 @@ switch ($action) {
$sessionId = isset($_GET['session_id']) ? (int) $_GET['session_id'] : 0;
$courseList = [];
if (empty($sessionId)) {
$preCourseList = CourseManager::get_courses_list_by_user_id($userId, false, true);
$preCourseList = CourseManager::get_courses_list_by_user_id(
$userId,
false,
true
);
$courseList = array_column($preCourseList, 'real_id');
} else {
if ($isAdmin) {
@ -175,7 +179,7 @@ switch ($action) {
$courseListToSelect = [];
if (!empty($courseList)) {
//Course List
// Course List
foreach ($courseList as $courseId) {
$courseInfo = api_get_course_info_by_id($courseId);
$courseListToSelect[] = [

@ -83,8 +83,8 @@ switch ($action) {
if ($number_friends != 0) {
$number_loop = ($number_friends/$number_of_images);
$loop_friends = ceil($number_loop);
$j=0;
for ($k=0; $k<$loop_friends; $k++) {
$j = 0;
for ($k = 0; $k < $loop_friends; $k++) {
if ($j==$number_of_images) {
$number_of_images=$number_of_images*2;
}
@ -195,7 +195,7 @@ switch ($action) {
break;
}
break;
case 'listWallMessage':
case 'list_wall_message':
$start = isset($_REQUEST['start']) ? intval($_REQUEST['start']) - 1 : 0;
$length = isset($_REQUEST['length']) ? intval($_REQUEST['length']) : 10;
$userId = isset($_REQUEST['u']) ? intval($_REQUEST['u']) : api_get_user_id();
@ -204,7 +204,7 @@ switch ($action) {
if (!empty($array)) {
ksort($array);
$html = '';
for($i = 0; $i < count($array); $i++) {
for ($i = 0; $i < count($array); $i++) {
$post = $array[$i]['html'];
$comment = SocialManager::getWallMessagesHTML($userId, $friendId, $array[$i]['id']);
$html .= '<div class="panel panel-info"><div class="panel-body">'.$post.$comment.'</div></div>';
@ -212,7 +212,7 @@ switch ($action) {
$html .= Display::div(
Display::url(
get_lang('SeeMore'),
api_get_self() . '?u=' . $userId . '&a=listWallMessage&start=' .
api_get_self() . '?u=' . $userId . '&a=list_wall_message&start=' .
($start + $length + 1) . '&length=' . $length,
array(
'class' => 'nextPage',
@ -226,7 +226,7 @@ switch ($action) {
}
break;
// Read the Url using OpenGraph and returns the hyperlinks content
case 'readUrlWithOpenGraph':
case 'read_url_with_open_graph':
$url = isset($_POST['social_wall_new_msg_main']) ? $_POST['social_wall_new_msg_main'] : '';
$url = trim($url);
$html = '';
@ -237,8 +237,6 @@ switch ($action) {
}
echo $html;
break;
case 'voteMsg':
break;
default:
echo '';
}

@ -14,9 +14,7 @@ $action = isset($_REQUEST['a']) ? $_REQUEST['a'] : null;
switch ($action) {
case 'recentlogins':
header('Content-type: application/json');
$list = [];
$all = Statistics::getRecentLoginStats();
$distinct = Statistics::getRecentLoginStats(true);

@ -1,5 +1,6 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Responses to AJAX calls for thematic
*/

@ -66,12 +66,7 @@ switch ($action) {
});';
echo '</script>';
echo MessageManager::generate_message_form(
'send_message',
array(),
'block'
);
echo MessageManager::generate_message_form();
echo '
<div class="row">
<div class="col-sm-10 col-sm-offset-2">
@ -129,7 +124,9 @@ switch ($action) {
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."'";
$sql = "UPDATE $user_table
SET active='".$status."'
WHERE user_id='".$user_id."'";
$result = Database::query($sql);
//Send and email if account is active

@ -11,7 +11,6 @@ use \Chamilo\CoreBundle\Entity\SequenceResource;
*/
class SequenceResourceManager
{
/**
* Check if the ser has completed the requirements for the sequences
* @param array $sequences The sequences
@ -23,7 +22,6 @@ class SequenceResourceManager
public static function checkRequirementsForUser(array $sequences, $type, $userId = 0)
{
$sequenceList = [];
switch ($type) {
case SequenceResource::SESSION_TYPE:
$sequenceList = self::checkSessionRequirementsForUser($sequences, $userId);

@ -758,7 +758,8 @@ class TicketManager
$user_id = api_get_user_id();
$ticket_id = intval($ticket_id);
$new_file_name = add_ext_on_mime(
stripslashes($file_attach['name']), $file_attach['type']
stripslashes($file_attach['name']),
$file_attach['type']
);
$file_name = $file_attach['name'];
$table_support_message_attachments = Database::get_main_table(TABLE_TICKET_MESSAGE_ATTACHMENTS);

@ -558,7 +558,7 @@ define('TIMELINE_STATUS_ACTIVE', '1');
define('TIMELINE_STATUS_INACTIVE', '2');
// Event email template class
define('EVENT_EMAIL_TEMPLATE_ACTIVE', 1);
define('EVENT_EMAIL_TEMPLATE_ACTIVE', 1);
define('EVENT_EMAIL_TEMPLATE_INACTIVE', 0);
// Course home

@ -65,21 +65,6 @@ class MessageManager
return $row['count'];
}
/**
* Get the list of user_ids of users who are online.
*/
public static function users_connected_by_id()
{
$count = who_is_online_count();
$user_connect = who_is_online(0, $count, null, null, 30, true);
$user_id_list = array();
for ($i = 0; $i < count($user_connect); $i++) {
$user_id_list[$i] = $user_connect[$i][0];
}
return $user_id_list;
}
/**
* Gets the total number of messages, used for the inbox sortable table
*/
@ -496,8 +481,8 @@ class MessageManager
content='{$row_message['content']}' AND
group_id='{$row_message['group_id']}' AND
user_receiver_id='$receiver_user_id'";
$rs_msg_id = Database::query($sql);
$row = Database::fetch_array($rs_msg_id);
$result = Database::query($sql);
$row = Database::fetch_array($result);
// update parent_id for other user receiver
$sql = "UPDATE $table_message SET parent_id = " . $row['id'] . "
@ -526,8 +511,11 @@ class MessageManager
// delete attachment file
self::delete_message_attachment_file($id, $user_receiver_id);
// delete message
$query = "UPDATE $table_message SET msg_status=3
WHERE user_receiver_id=" . $user_receiver_id . " AND id=" . $id;
$query = "UPDATE $table_message
SET msg_status = 3
WHERE
user_receiver_id=" . $user_receiver_id . " AND
id = " . $id;
Database::query($query);
return true;
@ -1087,6 +1075,7 @@ class MessageManager
$message_content .= get_lang('From') . ':&nbsp;' . $name . '</b> ' . api_strtolower(get_lang('To')) . ' <b>' . get_lang('Me') . '</b>';
}
}
$message_content .= '
<br />
<hr style="color:#ddd" />
@ -1455,6 +1444,7 @@ class MessageManager
$html_items = Display::div($html_items, array('class' => '', 'style' => 'margin-left:' . $indent . 'px'));
$array_html_items[] = array($html_items);
}
// grids for items with paginations
$options = array('hide_navigation' => false, 'per_page' => $items_per_page);
$visibility = array(true, true, true, false);
@ -1592,11 +1582,10 @@ class MessageManager
}
/**
* @param $id
* @param array $params
*
* @return string
*/
public static function generate_message_form($id, $params = array())
public static function generate_message_form()
{
$form = new FormValidator('send_message');
$form->addText('subject', get_lang('Subject'), false, ['id' => 'subject_id']);

@ -81,7 +81,13 @@ class NotebookManager
Database::query($sql);
//insert into item_property
api_item_property_update($courseInfo, TOOL_NOTEBOOK, $id, 'NotebookAdded', $userId);
api_item_property_update(
$courseInfo,
TOOL_NOTEBOOK,
$id,
'NotebookAdded',
$userId
);
return $id;
}

@ -31,7 +31,8 @@ class SocialManager extends UserManager
$friend_relation_list = array();
$tbl_my_friend_relation_type = Database :: get_main_table(TABLE_MAIN_USER_FRIEND_RELATION_TYPE);
$sql = 'SELECT id,title FROM '.$tbl_my_friend_relation_type.'
WHERE id<>6 ORDER BY id ASC';
WHERE id<>6
ORDER BY id ASC';
$result = Database::query($sql);
while ($row = Database::fetch_array($result, 'ASSOC')) {
$friend_relation_list[] = $row;

@ -235,14 +235,14 @@ class Statistics
if (api_is_multiple_url_enabled()) {
$sql = "SELECT
default_event_type as col0,
default_value_type as col1,
default_value as col2,
c_id as col3,
session_id as col4,
user.username as col5,
user.user_id as col6,
default_date as col7
default_event_type as col0,
default_value_type as col1,
default_value as col2,
c_id as col3,
session_id as col4,
user.username as col5,
user.user_id as col6,
default_date as col7
FROM $track_e_default as track_default,
$table_user as user,
$access_url_rel_user_table as url
@ -252,14 +252,14 @@ class Statistics
access_url_id= $current_url_id ";
} else {
$sql = "SELECT
default_event_type as col0,
default_value_type as col1,
default_value as col2,
c_id as col3,
session_id as col4,
user.username as col5,
user.user_id as col6,
default_date as col7
default_event_type as col0,
default_value_type as col1,
default_value as col2,
c_id as col3,
session_id as col4,
user.username as col5,
user.user_id as col6,
default_date as col7
FROM $track_e_default track_default, $table_user user
WHERE track_default.default_user_id = user.user_id ";
}
@ -346,7 +346,8 @@ class Statistics
public static function getCourseCategories()
{
$categoryTable = Database :: get_main_table(TABLE_MAIN_CATEGORY);
$sql = "SELECT code, name FROM $categoryTable
$sql = "SELECT code, name
FROM $categoryTable
ORDER BY tree_pos";
$res = Database::query($sql);
$categories = array ();
@ -672,7 +673,7 @@ class Statistics
public static function printUserPicturesStats()
{
$user_table = Database :: get_main_table(TABLE_MAIN_USER);
$access_url_rel_user_table= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$access_url_rel_user_table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$current_url_id = api_get_current_access_url_id();
$url_condition = null;
$url_condition2 = null;
@ -692,6 +693,7 @@ class Statistics
// #users without picture
$result[get_lang('No')] = $count1->n - $count2->n;
$result[get_lang('Yes')] = $count2->n; // #users with picture
Statistics::printStats(get_lang('CountUsers').' ('.get_lang('UserPicture').')', $result, true);
}
@ -894,7 +896,7 @@ class Statistics
$sql = "SELECT lastname, firstname, username, COUNT(friend_user_id) AS count_friend
FROM $access_url_rel_user_table as url, $user_friend_table uf
LEFT JOIN $user_table u
ON uf.user_id = u.user_id
ON (uf.user_id = u.user_id)
WHERE
uf.relation_type <> '".USER_RELATION_TYPE_RRHH."' AND
uf.user_id = url.user_id AND
@ -904,7 +906,8 @@ class Statistics
} else {
$sql = "SELECT lastname, firstname, username, COUNT(friend_user_id) AS count_friend
FROM $user_friend_table uf
LEFT JOIN $user_table u ON uf.user_id = u.user_id
LEFT JOIN $user_table u
ON (uf.user_id = u.user_id)
WHERE uf.relation_type <> '".USER_RELATION_TYPE_RRHH."'
GROUP BY uf.user_id
ORDER BY count_friend DESC ";
@ -926,7 +929,7 @@ class Statistics
{
$totalLogin = array();
$table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
$access_url_rel_user_table= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$access_url_rel_user_table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$current_url_id = api_get_current_access_url_id();
$total = self::countUsers();
if (api_is_multiple_url_enabled()) {

@ -2,10 +2,11 @@
/* For licensing terms, see /license.txt */
/**
* This is the statistic utility functions library for Chamilo.
* Include/require it in your code to use its functionality.
* @package chamilo.library
*/
* This is the statistic utility functions library for Chamilo.
* Include/require it in your code to use its functionality.
* @package chamilo.library
* @deprecated
*/
class StatsUtils
{
/**
@ -106,178 +107,4 @@ class StatsUtils
}
return $resu;
}
/**
* @author Sebastien Piraux <piraux_seb@hotmail.com>
* @param sql : a sql query (as a string)
* @return hours_array
* @desc Return an assoc array. Keys are the hours, values are
* the number of time this hours was found.
* key 'total' return the sum of all number of time hours
* appear
*/
public static function hoursTab($sql)
{
$hours_array = array('total' => 0);
$res = Database::query($sql);
if ($res !== false) {
$last_hours = -1;
while ($row = Database::fetch_row($res)) {
$date_array = getdate($row[0]);
if ($date_array['hours'] == $last_hours) {
$hours_array[$date_array['hours']]++;
} else {
$hours_array[$date_array['hours']] = 1;
$last_hours = $date_array['hours'];
}
$hours_array['total']++;
}
Database::free_result($res);
}
return $hours_array;
}
/**
* @author Sebastien Piraux <piraux_seb@hotmail.com>
* @param sql : a sql query (as a string)
* @return days_array
* @desc Return an assoc array. Keys are the days, values are
* the number of time this hours was found.
* key "total" return the sum of all number of time days
* appear
*/
public static function daysTab($sql)
{
$MonthsShort = api_get_months_short();
$days_array = array('total' => 0);
$res = Database::query($sql);
if ($res !== false) {
$last_day = -1;
while ($row = Database::fetch_row($res)) {
$date_array = getdate($row[0]);
$display_date = $date_array['mday'] . ' ' . $MonthsShort[$date_array['mon'] - 1] . ' ' . $date_array['year'];
if ($date_array['mday'] == $last_day) {
$days_array[$display_date]++;
} else {
$days_array[$display_date] = 1;
$last_day = $display_date;
}
$days_array['total']++;
}
Database::free_result($res);
}
return $days_array;
}
/**
* @author Sebastien Piraux <piraux_seb@hotmail.com>
* @param sql : a sql query (as a string)
* @return month_array
* @desc Return an assoc array. Keys are the days, values are
* the number of time this hours was found.
* key "total" return the sum of all number of time days
* appear
*/
public static function monthTab($sql)
{
$MonthsLong = api_get_months_long();
$month_array = array('total' => 0);
$res = Database::query($sql);
if ($res !== false) {
// init tab with all months
for ($i = 0; $i < 12; $i++) {
$month_array[$MonthsLong[$i]] = 0;
}
while ($row = Database::fetch_row($res)) {
$date_array = getdate($row[0]);
$month_array[$MonthsLong[$date_array['mon'] - 1]]++;
$month_array['total']++;
}
Database::free_result($res);
}
return $month_array;
}
/**
* @author Sebastien Piraux <piraux_seb@hotmail.com>
* @param period_array : an array provided by hoursTab($sql) or daysTab($sql)
* @param periodTitle : title of the first column, type of period
* @param linkOnPeriod :
* @desc Display a 4 column array
* Columns are : hour of day, graph, number of hits and %
* First line are titles
* next are informations
* Last is total number of hits
*/
public static function makeHitsTable($period_array, $periodTitle, $linkOnPeriod = '???')
{
echo "<table width='100%' cellpadding='0' cellspacing='1' border='0' align=center class='minitext'>";
// titles
echo "<tr bgcolor='#E6E6E6' align='center'>
<td width='15%' >
<b>$periodTitle</b>
</td>
<td width='60%'>
&nbsp;
</td>
<td width='10%'>
<b>" . get_lang('Hits') . "</b>
</td>
<td width='15%'>
<b>%</b>
</td>
</tr>
";
$factor = 4;
$maxSize = $factor * 100; //pixels
while (list($periodPiece, $cpt) = each($period_array)) {
if ($periodPiece != 'total') {
$pourcent = round(100 * $cpt / $period_array['total']);
$barwidth = $factor * $pourcent;
echo "<tr>
<td align='center' width='15%'>";
echo $periodPiece;
echo "</td>
<td width='60%' style='padding-top: 3px;' align='center'>"
// display hitbar
. "<img src='".Display::returnIconPath('bar_1.gif')."' width='1' height='12' alt='$periodPiece : $cpt hits &ndash; $pourcent %' />";
if ($pourcent != 0) {
echo "<img src='".Display::returnIconPath('bar_1u.gif')."' width='$barwidth' height='12' alt='$periodPiece : $cpt hits &ndash; $pourcent %' />";
}
// display 100% bar
if ($pourcent != 100 && $pourcent != 0) {
echo "<img src='".Display::returnIconPath('bar_1m.gif')."' width='1' height='12' alt='$periodPiece : $cpt hits &ndash; $pourcent %' />";
}
if ($pourcent != 100) {
echo "<img src='".Display::returnIconPath('bar_1r.gif')."' width='" . ($maxSize - $barwidth) . "' height='12' alt='$periodPiece : $cpt hits &ndash; $pourcent %' />";
}
echo "<img src='".Display::returnIconPath('bar_1.gif')."' width='1' height='12' alt='$periodPiece : $cpt hits &ndash; $pourcent %' />
</td>
<td align='center' width='10%'>
$cpt
</td>
<td align='center' width='15%'>
$pourcent %
</td>
</tr>
";
}
}
echo "<tr bgcolor='#E6E6E6'>
<td width='15%' align='center'>
" . get_lang('Total') . "
</td>
<td align='right' width='60%'>
&nbsp;
</td>
<td align='center' width='10%'>
" . $period_array['total'] . "
</td>
<td width='15%'>
&nbsp;
</td>
</tr>
";
echo "</table>";
}
}

@ -71,7 +71,7 @@ class TableSort
usort($data, create_function('$a, $b', $compare_function));
return $data;
}
}
/**
* Sorts 2-dimensional table. It is possile changing the columns that will be shown and the way that the columns are to be sorted.

@ -47,10 +47,14 @@ class Tracking
$default_where = array('c_id = ? AND session_id = ? ' => array($course_id, $sessionId));
}
$result = Database::select($select, $table_group, array(
'limit' => " $start, $limit",
'where' => $default_where,
'order' => "$sidx $sord")
$result = Database::select(
$select,
$table_group,
array(
'limit' => " $start, $limit",
'where' => $default_where,
'order' => "$sidx $sord",
)
);
if ($type == 'count') {
@ -372,7 +376,6 @@ class Tracking
}
$attemptCount = 1;
do {
// Check if there are interactions below.
$extend_attempt_link = '';

@ -313,7 +313,7 @@ class UrlManager
$table_user_group = Database::get_main_table(TABLE_USERGROUP);
if (!empty($access_url_id)) {
$where ="WHERE $table_url_rel_usergroup.access_url_id = ".intval($access_url_id);
$where = " WHERE $table_url_rel_usergroup.access_url_id = ".intval($access_url_id);
}
$sql = "SELECT u.id, u.name, access_url_id
@ -362,7 +362,7 @@ class UrlManager
/**
* Sets the status of an URL 1 or 0
* @author Julio Montoya
* @param string lock || unlock
* @param string $status lock || unlock
* @param int url id
* */
public static function set_url_status($status, $url_id)
@ -451,7 +451,7 @@ class UrlManager
{
$table_url_rel_session= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
$session_id = intval($session_id);
$url_id = intval($url_id);
$url_id = intval($url_id);
$sql = "SELECT session_id FROM $table_url_rel_session
WHERE
access_url_id = ".intval($url_id)." AND
@ -477,7 +477,7 @@ class UrlManager
if (is_array($user_list) && is_array($url_list)) {
foreach ($url_list as $url_id) {
foreach ($user_list as $user_id) {
$count = UrlManager::relation_url_user_exist($user_id,$url_id);
$count = UrlManager::relation_url_user_exist($user_id, $url_id);
if ($count == 0) {
$sql = "INSERT INTO $table_url_rel_user
SET
@ -494,18 +494,18 @@ class UrlManager
}
}
return $result_array;
return $result_array;
}
/**
* Add a group of courses into a group of URLs
* @author Julio Montoya
* @param array of course ids
* @param array of url_ids
* @param array $course_list of course ids
* @param array $url_list of url_ids
* @return array
**/
public static function add_courses_to_urls($course_list,$url_list)
public static function add_courses_to_urls($course_list, $url_list)
{
$table_url_rel_course = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
$result_array = array();
@ -737,7 +737,7 @@ class UrlManager
/**
* Inserts a session to a URL (access_url_rel_session table)
* @param int Session ID
* @param int $session_id Session ID
* @param int URL ID
*
* @return bool True on success, false session already exists or insert failed
@ -750,7 +750,7 @@ class UrlManager
}
$result = false;
$count = UrlManager::relation_url_session_exist($session_id, $url_id);
$session_id = intval($session_id);
$session_id = intval($session_id);
if (empty($count) && !empty($session_id)) {
$url_id = intval($url_id);
$sql = "INSERT INTO $table_url_rel_session
@ -812,7 +812,7 @@ class UrlManager
* */
public static function delete_url_rel_course($courseId, $urlId)
{
$table_url_rel_course= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
$table_url_rel_course = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
$sql= "DELETE FROM $table_url_rel_course
WHERE c_id = '".intval($courseId)."' AND access_url_id=".intval($urlId)." ";
$result = Database::query($sql);
@ -871,7 +871,7 @@ class UrlManager
$table_url_rel_session = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
$sql= "DELETE FROM $table_url_rel_session
WHERE session_id = ".intval($session_id)." AND access_url_id=".intval($url_id)." ";
$result = Database::query($sql,'ASSOC');
$result = Database::query($sql, 'ASSOC');
return $result;
}
@ -929,7 +929,7 @@ class UrlManager
* Updates the access_url_rel_course table with a given user list
* @author Julio Montoya
* @param array $course_list
* @param int access_url_id
* @param int $access_url_id
* */
public static function update_urls_rel_course($course_list, $access_url_id)
{
@ -940,7 +940,7 @@ class UrlManager
$result = Database::query($sql);
$existing_courses = array();
while ($row = Database::fetch_array($result)){
while ($row = Database::fetch_array($result)) {
$existing_courses[] = $row['c_id'];
}
@ -969,11 +969,11 @@ class UrlManager
{
$table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USERGROUP);
$sql = "SELECT usergroup_id FROM $table WHERE access_url_id = ".intval($urlId);
$sql = "SELECT usergroup_id FROM $table
WHERE access_url_id = ".intval($urlId);
$result = Database::query($sql);
$existingItems = array();
while ($row = Database::fetch_array($result)){
while ($row = Database::fetch_array($result)) {
$existingItems[] = $row['usergroup_id'];
}
@ -1006,7 +1006,7 @@ class UrlManager
$result = Database::query($sql);
$existingItems = array();
while ($row = Database::fetch_array($result)){
while ($row = Database::fetch_array($result)) {
$existingItems[] = $row['course_category_id'];
}
@ -1046,9 +1046,10 @@ class UrlManager
* */
public static function update_urls_rel_session($session_list, $access_url_id)
{
$table_url_rel_session = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
$table_url_rel_session = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
$sql = "SELECT session_id FROM $table_url_rel_session WHERE access_url_id=".intval($access_url_id);
$sql = "SELECT session_id FROM $table_url_rel_session
WHERE access_url_id=".intval($access_url_id);
$result = Database::query($sql);
$existing_sessions = array();
@ -1084,11 +1085,13 @@ class UrlManager
{
$table_url_rel_user = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$table_url = Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
$sql = "SELECT url, access_url_id FROM $table_url_rel_user url_rel_user INNER JOIN $table_url u
$sql = "SELECT url, access_url_id
FROM $table_url_rel_user url_rel_user
INNER JOIN $table_url u
ON (url_rel_user.access_url_id = u.id)
WHERE user_id = ".intval($user_id);
$result = Database::query($sql);
$url_list = Database::store_result($result,'ASSOC');
$url_list = Database::store_result($result, 'ASSOC');
return $url_list;
}
@ -1099,14 +1102,16 @@ class UrlManager
*/
public static function get_access_url_from_course($courseId)
{
$table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
$table_url = Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
$sql = "SELECT url, access_url_id FROM $table c INNER JOIN $table_url u
$table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
$table_url = Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
$sql = "SELECT url, access_url_id FROM $table c
INNER JOIN $table_url u
ON (c.access_url_id = u.id)
WHERE c_id = ".intval($courseId);
$result = Database::query($sql);
$url_list = Database::store_result($result,'ASSOC');
$url_list = Database::store_result($result, 'ASSOC');
return $url_list;
}
@ -1118,7 +1123,8 @@ class UrlManager
{
$table_url_rel_session = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
$table_url = Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
$sql = "SELECT url, access_url_id FROM $table_url_rel_session url_rel_session INNER JOIN $table_url u
$sql = "SELECT url, access_url_id FROM $table_url_rel_session url_rel_session
INNER JOIN $table_url u
ON (url_rel_session.access_url_id = u.id)
WHERE session_id = ".intval($session_id);
$result = Database::query($sql);
@ -1134,7 +1140,8 @@ class UrlManager
public static function get_url_id($url)
{
$table_access_url= Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
$sql = "SELECT id FROM $table_access_url WHERE url = '".Database::escape_string($url)."'";
$sql = "SELECT id FROM $table_access_url
WHERE url = '".Database::escape_string($url)."'";
$result = Database::query($sql);
$access_url_id = Database::result($result, 0, 0);
@ -1157,8 +1164,11 @@ class UrlManager
$needle = api_convert_encoding($needle, $charset, 'utf-8');
$needle = Database::escape_string($needle);
// search courses where username or firstname or lastname begins likes $needle
$sql = 'SELECT id, name FROM '.Database::get_main_table(TABLE_MAIN_CATEGORY).' u
WHERE name LIKE "'.$needle.'%" AND (parent_id IS NULL or parent_id = 0)
$sql = 'SELECT id, name
FROM '.Database::get_main_table(TABLE_MAIN_CATEGORY).' u
WHERE
name LIKE "'.$needle.'%" AND
(parent_id IS NULL or parent_id = 0)
ORDER BY name
LIMIT 11';
$result = Database::query($sql);

@ -89,7 +89,6 @@ class UserGroup extends Model
return 0;
} else {
$typeCondition = '';
if ($type != -1) {
$type = intval($type);
@ -378,6 +377,7 @@ class UserGroup extends Model
$sql .= " LIMIT ".$limits[0].', '.$limits[1];
}
}
$result = Database::query($sql);
$array = Database::store_result($result, 'ASSOC');

@ -269,7 +269,7 @@ $social_post_wall_block = empty($posts) ? '<p>'.get_lang("NoPosts").'</p>' : $po
$socialAutoExtendLink = Display::url(
get_lang('SeeMore'),
$socialAjaxUrl . '?u='. $my_user_id . '&a=listWallMessage&start=10&length=5',
$socialAjaxUrl . '?u='. $my_user_id . '&a=list_wall_message&start=10&length=5',
array(
'class' => 'nextPage next',
)
@ -296,7 +296,7 @@ $(document).ready(function() {
'");
},
type: "POST",
url: "'. api_get_path(WEB_AJAX_PATH) .'social.ajax.php?a=readUrlWithOpenGraph",
url: "'. api_get_path(WEB_AJAX_PATH) .'social.ajax.php?a=read_url_with_open_graph",
data: "social_wall_new_msg_main=" + e.originalEvent.clipboardData.getData("text"),
success: function(response) {
$("[name=\'wall_post_button\']").prop( "disabled", false );

@ -7,16 +7,6 @@ class TestStatsUtils extends UnitTestCase
$this->UnitTestCase('Stats utilities library - main/inc/lib/statsUtil.lib.inc.test.php');
}
function testdaysTab() {
$sql='';
ob_start();
$days_array = array('total' => 0);
$res=StatsUtils::daysTab($sql);
ob_end_clean();
$this->assertTrue(is_array($days_array));
//var_dump($sql);
}
function testgetManyResults1Col() {
$sql='';
ob_start();
@ -62,32 +52,4 @@ class TestStatsUtils extends UnitTestCase
$this->assertTrue(is_string($sql));
//var_dump($sql);
}
function testhoursTab() {
$sql='';
ob_start();
$res=StatsUtils::hoursTab($sql);
ob_end_clean();
$this->assertTrue(is_string($sql));
//var_dump($sql);
}
function testmakeHitsTable() {
$period_array=array();
$periodTitle='';
ob_start();
$res=StatsUtils::makeHitsTable($period_array, $periodTitle, $linkOnPeriod = '???');
$this->assertTrue(is_null($res));
ob_end_clean();
//var_dump($res);
}
function testmonthTab() {
$sql='';
ob_start();
$res=StatsUtils::monthTab($sql);
ob_end_clean();
$this->assertTrue(is_array($res));
//var_dump($res);
}
}

Loading…
Cancel
Save