Minor - Format code

pull/2487/head
jmontoyaa 9 years ago
parent 94c592a9d7
commit 2b02a1bc7f
  1. 2
      main/inc/lib/CourseChatUtils.php
  2. 1
      main/inc/lib/CoursesAndSessionsCatalog.class.php
  3. 1
      main/inc/lib/GamificationUtils.php
  4. 2
      main/inc/lib/VideoChat.php
  5. 7
      main/inc/lib/fileUpload.lib.php
  6. 3
      main/inc/lib/internationalization.lib.php
  7. 130
      main/inc/lib/social.lib.php
  8. 56
      main/inc/lib/statistics.lib.php
  9. 24
      main/inc/lib/thematic.lib.php
  10. 16
      main/inc/lib/urlmanager.lib.php
  11. 72
      main/inc/lib/usergroup.lib.php

@ -43,7 +43,7 @@ class CourseChatUtils
$course = $em->find('ChamiloCoreBundle:Course', $this->courseId); $course = $em->find('ChamiloCoreBundle:Course', $this->courseId);
if ($this->sessionId) { if ($this->sessionId) {
$criteria = Criteria::create()->where(Criteria::expr()->eq("course", $course)); $criteria = Criteria::create()->where(Criteria::expr()->eq('course', $course));
return $em return $em
->find('ChamiloCoreBundle:Session', $this->sessionId) ->find('ChamiloCoreBundle:Session', $this->sessionId)

@ -6,7 +6,6 @@
*/ */
class CoursesAndSessionsCatalog class CoursesAndSessionsCatalog
{ {
/** /**
* Check the configuration for the courses and sessions catalog * Check the configuration for the courses and sessions catalog
* @global array $_configuration Configuration * @global array $_configuration Configuration

@ -25,7 +25,6 @@ class GamificationUtils
); );
if (empty($sessions)) { if (empty($sessions)) {
return 0; return 0;
} }

@ -10,7 +10,6 @@
*/ */
class VideoChat class VideoChat
{ {
/** /**
* Get the video chat info by its users * Get the video chat info by its users
* @param int $user1 User id * @param int $user1 User id
@ -89,5 +88,4 @@ class VideoChat
return false; return false;
} }
} }

@ -2077,7 +2077,12 @@ function add_all_documents_in_folder_to_database(
if ($folderExists === true) { if ($folderExists === true) {
$documentId = DocumentManager::get_document_id($courseInfo, $completePath, $sessionId); $documentId = DocumentManager::get_document_id($courseInfo, $completePath, $sessionId);
if ($documentId) { if ($documentId) {
$newFolderData = DocumentManager::get_document_data_by_id($documentId, $courseInfo, false, $sessionId); $newFolderData = DocumentManager::get_document_data_by_id(
$documentId,
$courseInfo,
false,
$sessionId
);
} }
} else { } else {
$newFolderData = create_unexisting_directory( $newFolderData = create_unexisting_directory(

@ -458,8 +458,6 @@ function api_get_local_time(
$from_timezone = 'UTC'; $from_timezone = 'UTC';
} }
try { try {
$date = new DateTime($time, new DateTimezone($from_timezone)); $date = new DateTime($time, new DateTimezone($from_timezone));
$date->setTimezone(new DateTimeZone($to_timezone)); $date->setTimezone(new DateTimeZone($to_timezone));
@ -664,7 +662,6 @@ function api_format_date($time, $format = null, $language = null)
function date_to_str_ago($date, $timeZone = 'UTC') function date_to_str_ago($date, $timeZone = 'UTC')
{ {
if ($date === '0000-00-00 00:00:00') { if ($date === '0000-00-00 00:00:00') {
return ''; return '';
} }

@ -504,8 +504,11 @@ class SocialManager extends UserManager
$image = $my_course['course_info']['course_image']; $image = $my_course['course_info']['course_image'];
$imageCourse = Display::img($image, $course_title, array('class'=>'img-course')); $imageCourse = Display::img($image, $course_title, array('class'=>'img-course'));
} else { } else {
$imageCourse = Display::return_icon('session_default_small.png', $course_title, array('class' => 'img-course')); $imageCourse = Display::return_icon(
'session_default_small.png',
$course_title,
array('class' => 'img-course')
);
} }
} else { } else {
$imageCourse = Display::return_icon('course.png', get_lang('Course'), array('class' => 'img-default')); $imageCourse = Display::return_icon('course.png', get_lang('Course'), array('class' => 'img-default'));
@ -525,7 +528,7 @@ class SocialManager extends UserManager
) { ) {
$result .= '<span class="title">' . $course_title . '<span>'; $result .= '<span class="title">' . $course_title . '<span>';
} else { } else {
$result .= $course_title." "." ".get_lang('CourseClosed').""; $result .= $course_title." ".get_lang('CourseClosed');
} }
$result .= '</li>'; $result .= '</li>';
@ -563,7 +566,7 @@ class SocialManager extends UserManager
$my_course['user_course_cat'], $my_course['user_course_cat'],
$result, $result,
$my_course['id_session'], $my_course['id_session'],
$session, $session
); );
return $output; return $output;
@ -572,7 +575,7 @@ class SocialManager extends UserManager
/** /**
* Shows the avatar block in social pages * Shows the avatar block in social pages
* *
* @param string highlight link possible values: * @param string $show highlight link possible values:
* group_add, * group_add,
* home, * home,
* messages, * messages,
@ -583,8 +586,8 @@ class SocialManager extends UserManager
* shared_profile, * shared_profile,
* friends, * friends,
* groups search * groups search
* @param int group id * @param int $group_id
* @param int user id * @param int $user_id
* *
*/ */
public static function show_social_avatar_block($show = '', $group_id = 0, $user_id = 0) public static function show_social_avatar_block($show = '', $group_id = 0, $user_id = 0)
@ -644,14 +647,13 @@ class SocialManager extends UserManager
'normal' => UserManager::getUserPicture( 'normal' => UserManager::getUserPicture(
$user_id, $user_id,
USER_IMAGE_SIZE_MEDIUM USER_IMAGE_SIZE_MEDIUM
), )
] ]
); );
} }
$skillBlock = $template->get_template('social/avatar_block.tpl'); $skillBlock = $template->get_template('social/avatar_block.tpl');
return $template->fetch($skillBlock); return $template->fetch($skillBlock);
} }
@ -685,18 +687,8 @@ class SocialManager extends UserManager
if (empty($user_id)) { if (empty($user_id)) {
$user_id = api_get_user_id(); $user_id = api_get_user_id();
} }
$usergroup = new UserGroup();
$user_info = api_get_user_info($user_id, true);
$current_user_id = api_get_user_id();
$current_user_info = api_get_user_info($current_user_id, true);
if ($current_user_id == $user_id) {
$user_friend_relation = null;
} else {
$user_friend_relation = SocialManager::get_relation_between_contacts($current_user_id, $user_id);
}
$usergroup = new UserGroup();
$show_groups = array( $show_groups = array(
'groups', 'groups',
'group_messages', 'group_messages',
@ -810,17 +802,16 @@ class SocialManager extends UserManager
$myFiles = ''; $myFiles = '';
} }
$links .= $myFiles; $links .= $myFiles;
$links .='</ul>'; $links .='</ul>';
$html .= Display::panelCollapse( $html .= Display::panelCollapse(
get_lang('SocialNetwork'), get_lang('SocialNetwork'),
$links, $links,
'social-network-menu', 'social-network-menu',
null, null,
'sn-sidebar', 'sn-sidebar',
'sn-sidebar-collapse' 'sn-sidebar-collapse'
); );
} }
if (in_array($show, $show_groups) && !empty($group_id)) { if (in_array($show, $show_groups) && !empty($group_id)) {
@ -971,7 +962,10 @@ class SocialManager extends UserManager
); );
if (!empty($content)) { if (!empty($content)) {
$url = Display::url(Display::return_icon('announcement.png', get_lang('Announcements')).$course_info['name'].' ('.$content['count'].')', api_get_path(WEB_CODE_PATH).'announcements/announcements.php?cidReq='.$course['code']); $url = Display::url(
Display::return_icon('announcement.png', get_lang('Announcements')).$course_info['name'].' ('.$content['count'].')',
api_get_path(WEB_CODE_PATH).'announcements/announcements.php?cidReq='.$course['code']
);
$announcements[] = Display::tag('li', $url); $announcements[] = Display::tag('li', $url);
} }
} }
@ -1027,11 +1021,8 @@ class SocialManager extends UserManager
if (api_is_anonymous()) { if (api_is_anonymous()) {
$add_row = true; $add_row = true;
} }
$extra_params = array();
$course_url = ''; $course_url = '';
if (isset($_GET['cidReq']) && strlen($_GET['cidReq']) > 0) { if (isset($_GET['cidReq']) && strlen($_GET['cidReq']) > 0) {
$extra_params['cidReq'] = Security::remove_XSS($_GET['cidReq']);
$course_url = '&amp;cidReq='.Security::remove_XSS($_GET['cidReq']); $course_url = '&amp;cidReq='.Security::remove_XSS($_GET['cidReq']);
} }
@ -1061,7 +1052,7 @@ class SocialManager extends UserManager
$url = null; $url = null;
// Anonymous users can't have access to the profile // Anonymous users can't have access to the profile
if (!api_is_anonymous()) { if (!api_is_anonymous()) {
if (api_get_setting('allow_social_tool') == 'true') { if (api_get_setting('allow_social_tool') === 'true') {
$url = api_get_path(WEB_CODE_PATH).'social/profile.php?u='.$uid.$course_url; $url = api_get_path(WEB_CODE_PATH).'social/profile.php?u='.$uid.$course_url;
} else { } else {
$url = '?id='.$uid.$course_url; $url = '?id='.$uid.$course_url;
@ -1361,22 +1352,25 @@ class SocialManager extends UserManager
$start = Database::escape_string($start); $start = Database::escape_string($start);
$limit = intval($limit); $limit = intval($limit);
$sql = " $sql = "SELECT
SELECT id,
id, user_sender_id,
user_sender_id, user_receiver_id,
user_receiver_id, send_date,
send_date, content,
content, parent_id,
parent_id, (
(SELECT ma.path FROM $tblMessageAttachment ma SELECT ma.path FROM $tblMessageAttachment ma
WHERE ma.message_id = tm.id ) as path, WHERE ma.message_id = tm.id
(SELECT ma.filename FROM $tblMessageAttachment ma ) as path,
WHERE ma.message_id = tm.id ) as filename (
FROM $tblMessage tm SELECT ma.filename FROM $tblMessageAttachment ma
WHERE WHERE ma.message_id = tm.id
user_receiver_id = $userId AND ) as filename
send_date > '$start' FROM $tblMessage tm
WHERE
user_receiver_id = $userId AND
send_date > '$start'
"; ";
$sql .= (empty($messageStatus) || is_null($messageStatus)) ? '' : " AND msg_status = '$messageStatus' "; $sql .= (empty($messageStatus) || is_null($messageStatus)) ? '' : " AND msg_status = '$messageStatus' ";
@ -1646,33 +1640,6 @@ class SocialManager extends UserManager
} }
} }
/**
* Get full image path from a path and a size
* @param string $path
* @return string
*/
private static function getImagePath($path, $size = '')
{
$name = '';
$array = preg_split('#\/#', $path);
if (isset($array[2]) && !empty($array[2])) {
if ($size == IMAGE_WALL_SMALL) {
$name = IMAGE_WALL_SMALL. '_' . $array[2];
}else if($size == IMAGE_WALL_MEDIUM){
$name = IMAGE_WALL_MEDIUM. '_' . $array[2];
}else if($size == IMAGE_WALL_BIG){
$name = IMAGE_WALL_BIG. '_' . $array[2];
}else {
$name = IMAGE_WALL_SMALL. '_' . $array[2];
}
$lessImage = str_replace($array[2], '', $path);
$name = $lessImage . $name;
}
return $name;
}
/** /**
* Delete messages delete logic * Delete messages delete logic
* @param int $id id message to delete. * @param int $id id message to delete.
@ -1698,8 +1665,13 @@ class SocialManager extends UserManager
* @param int $groupId Optional. Group ID * @param int $groupId Optional. Group ID
* @return string The HTML code with the social block * @return string The HTML code with the social block
*/ */
public static function setSocialUserBlock(Template $template, $userId, $groupBlock = '', $groupId = 0, $show_full_profile = true) public static function setSocialUserBlock(
{ Template $template,
$userId,
$groupBlock = '',
$groupId = 0,
$show_full_profile = true
) {
if (api_get_setting('allow_social_tool') != 'true') { if (api_get_setting('allow_social_tool') != 'true') {
return ''; return '';
} }
@ -1937,7 +1909,6 @@ class SocialManager extends UserManager
foreach ($messages as $message) { foreach ($messages as $message) {
$post = $message['html']; $post = $message['html'];
$comment = SocialManager::getWallMessagesHTML($userId, $friendId, $message['id']); $comment = SocialManager::getWallMessagesHTML($userId, $friendId, $message['id']);
$html .= Display::panel($post.$comment, ''); $html .= Display::panel($post.$comment, '');
} }
@ -1956,7 +1927,6 @@ class SocialManager extends UserManager
} }
$skill = new Skill(); $skill = new Skill();
$ranking = $skill->get_user_skill_ranking($userId); $ranking = $skill->get_user_skill_ranking($userId);
$skills = $skill->get_user_skills($userId, true); $skills = $skill->get_user_skills($userId, true);

@ -304,7 +304,6 @@ class Statistics
} }
if (!empty($row[5])) { if (!empty($row[5])) {
//course //course
if (!empty($row[3])) { if (!empty($row[3])) {
$row[3] = Display::url($row[3], api_get_path(WEB_CODE_PATH).'admin/course_edit.php?id='.$row[3]); $row[3] = Display::url($row[3], api_get_path(WEB_CODE_PATH).'admin/course_edit.php?id='.$row[3]);
@ -314,7 +313,10 @@ class Statistics
// session // session
if (!empty($row[4])) { if (!empty($row[4])) {
$row[4] = Display::url($row[4], api_get_path(WEB_CODE_PATH).'session/resume_session.php?id_session='.$row[4]); $row[4] = Display::url(
$row[4],
api_get_path(WEB_CODE_PATH).'session/resume_session.php?id_session='.$row[4]
);
} else { } else {
$row[4] = '-'; $row[4] = '-';
} }
@ -571,7 +573,10 @@ class Statistics
if ($distinct) { if ($distinct) {
$field = 'DISTINCT(login_user_id)'; $field = 'DISTINCT(login_user_id)';
} }
$sql = "SELECT count($field) AS number, date(login_date) as login_date FROM $table $table_url WHERE DATE_ADD(login_date, INTERVAL 15 DAY) >= '$now' $where_url GROUP BY date(login_date)"; $sql = "SELECT count($field) AS number, date(login_date) as login_date
FROM $table $table_url
WHERE DATE_ADD(login_date, INTERVAL 15 DAY) >= '$now' $where_url
GROUP BY date(login_date)";
$res = Database::query($sql); $res = Database::query($sql);
while ($row = Database::fetch_array($res,'ASSOC')){ while ($row = Database::fetch_array($res,'ASSOC')){
@ -847,16 +852,18 @@ class Statistics
$field = 'user_receiver_id'; $field = 'user_receiver_id';
break; break;
} }
if (api_is_multiple_url_enabled()) { if (api_is_multiple_url_enabled()) {
$sql = "SELECT lastname, firstname, username, COUNT($field) AS count_message $sql = "SELECT lastname, firstname, username, COUNT($field) AS count_message
FROM ".$access_url_rel_user_table." as url, ".$message_table." m FROM $access_url_rel_user_table as url, $message_table m
LEFT JOIN ".$user_table." u ON m.$field = u.user_id LEFT JOIN $user_table u ON m.$field = u.user_id
WHERE url.user_id = m.$field AND access_url_id='".$current_url_id."' WHERE url.user_id = m.$field AND access_url_id='".$current_url_id."'
GROUP BY m.$field ORDER BY count_message DESC "; GROUP BY m.$field
ORDER BY count_message DESC ";
} else { } else {
$sql = "SELECT lastname, firstname, username, COUNT($field) AS count_message $sql = "SELECT lastname, firstname, username, COUNT($field) AS count_message
FROM ".$message_table." m FROM $message_table m
LEFT JOIN ".$user_table." u ON m.$field = u.user_id LEFT JOIN $user_table u ON m.$field = u.user_id
GROUP BY m.$field ORDER BY count_message DESC "; GROUP BY m.$field ORDER BY count_message DESC ";
} }
$res = Database::query($sql); $res = Database::query($sql);
@ -885,17 +892,23 @@ class Statistics
$current_url_id = api_get_current_access_url_id(); $current_url_id = api_get_current_access_url_id();
if (api_is_multiple_url_enabled()) { if (api_is_multiple_url_enabled()) {
$sql = "SELECT lastname, firstname, username, COUNT(friend_user_id) AS count_friend ". $sql = "SELECT lastname, firstname, username, COUNT(friend_user_id) AS count_friend
"FROM ".$access_url_rel_user_table." as url, ".$user_friend_table." uf ". FROM $access_url_rel_user_table as url, $user_friend_table uf
"LEFT JOIN ".$user_table." u ON uf.user_id = u.user_id ". LEFT JOIN $user_table u
"WHERE uf.relation_type <> '".USER_RELATION_TYPE_RRHH."' AND uf.user_id = url.user_id AND access_url_id='".$current_url_id."' ". ON uf.user_id = u.user_id
"GROUP BY uf.user_id ORDER BY count_friend DESC "; WHERE
uf.relation_type <> '".USER_RELATION_TYPE_RRHH."' AND
uf.user_id = url.user_id AND
access_url_id = '".$current_url_id."'
GROUP BY uf.user_id
ORDER BY count_friend DESC ";
} else { } else {
$sql = "SELECT lastname, firstname, username, COUNT(friend_user_id) AS count_friend ". $sql = "SELECT lastname, firstname, username, COUNT(friend_user_id) AS count_friend
"FROM ".$user_friend_table." uf ". 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."' ". WHERE uf.relation_type <> '".USER_RELATION_TYPE_RRHH."'
"GROUP BY uf.user_id ORDER BY count_friend DESC "; GROUP BY uf.user_id
ORDER BY count_friend DESC ";
} }
$res = Database::query($sql); $res = Database::query($sql);
$list_friends = array(); $list_friends = array();
@ -903,6 +916,7 @@ class Statistics
$users = api_get_person_name($friends['firstname'], $friends['lastname']).'<br />('.$friends['username'].')'; $users = api_get_person_name($friends['firstname'], $friends['lastname']).'<br />('.$friends['username'].')';
$list_friends[$users] = $friends['count_friend']; $list_friends[$users] = $friends['count_friend'];
} }
return $list_friends; return $list_friends;
} }
@ -924,11 +938,11 @@ class Statistics
$where_url=''; $where_url='';
} }
$now = api_get_utc_datetime(); $now = api_get_utc_datetime();
$sql[get_lang('ThisDay')] = $sql[get_lang('ThisDay')] =
"SELECT count(distinct(login_user_id)) AS number ". "SELECT count(distinct(login_user_id)) AS number ".
" FROM $table $table_url ". " FROM $table $table_url ".
" WHERE DATE_ADD(login_date, INTERVAL 1 DAY) >= '$now' $where_url"; " WHERE DATE_ADD(login_date, INTERVAL 1 DAY) >= '$now' $where_url";
$sql[get_lang('Last7days')] = $sql[get_lang('Last7days')] =
"SELECT count(distinct(login_user_id)) AS number ". "SELECT count(distinct(login_user_id)) AS number ".
" FROM $table $table_url ". " FROM $table $table_url ".
" WHERE DATE_ADD(login_date, INTERVAL 7 DAY) >= '$now' $where_url"; " WHERE DATE_ADD(login_date, INTERVAL 7 DAY) >= '$now' $where_url";
@ -940,7 +954,7 @@ class Statistics
"SELECT count(distinct(login_user_id)) AS number ". "SELECT count(distinct(login_user_id)) AS number ".
" FROM $table $table_url ". " FROM $table $table_url ".
" WHERE DATE_ADD(login_date, INTERVAL 6 MONTH) >= '$now' $where_url"; " WHERE DATE_ADD(login_date, INTERVAL 6 MONTH) >= '$now' $where_url";
$sql[get_lang('NeverConnected')] = $sql[get_lang('NeverConnected')] =
"SELECT count(distinct(login_user_id)) AS number ". "SELECT count(distinct(login_user_id)) AS number ".
" FROM $table $table_url WHERE 1=1 $where_url"; " FROM $table $table_url WHERE 1=1 $where_url";
foreach ($sql as $index => $query) { foreach ($sql as $index => $query) {

@ -278,9 +278,9 @@ class Thematic
$res = Database::query($sql); $res = Database::query($sql);
if (Database::num_rows($res) > 0) { if (Database::num_rows($res) > 0) {
if (!empty($thematic_id)) { if (!empty($thematic_id)) {
$data = Database::fetch_array($res,'ASSOC'); $data = Database::fetch_array($res, 'ASSOC');
} else { } else {
while ($row = Database::fetch_array($res,'ASSOC')) { while ($row = Database::fetch_array($res, 'ASSOC')) {
$data[$row['id']] = $row; $data[$row['id']] = $row;
} }
} }
@ -469,7 +469,8 @@ class Thematic
$tbl_thematic_advance = Database :: get_course_table(TABLE_THEMATIC_ADVANCE); $tbl_thematic_advance = Database :: get_course_table(TABLE_THEMATIC_ADVANCE);
$course_id = api_get_course_int_id(); $course_id = api_get_course_int_id();
$sql = "SELECT COUNT(id) AS total_number_of_items FROM $tbl_thematic_advance $sql = "SELECT COUNT(id) AS total_number_of_items
FROM $tbl_thematic_advance
WHERE c_id = $course_id AND thematic_id = $thematic_id "; WHERE c_id = $course_id AND thematic_id = $thematic_id ";
$res = Database::query($sql); $res = Database::query($sql);
$obj = Database::fetch_object($res); $obj = Database::fetch_object($res);
@ -821,7 +822,7 @@ class Thematic
$_course, $_course,
'thematic_advance', 'thematic_advance',
$thematic_advance_id, $thematic_advance_id,
"ThematicAdvanceDeleted", 'ThematicAdvanceDeleted',
$user_id $user_id
); );
} }
@ -885,7 +886,8 @@ class Thematic
$sql = "SELECT $sql = "SELECT
tp.id, thematic_id, tp.title, description, description_type, t.session_id tp.id, thematic_id, tp.title, description, description_type, t.session_id
FROM $tbl_thematic_plan tp FROM $tbl_thematic_plan tp
INNER JOIN $tbl_thematic t ON (t.id=tp.thematic_id) INNER JOIN $tbl_thematic t
ON (t.id=tp.thematic_id)
WHERE WHERE
t.c_id = $course_id AND t.c_id = $course_id AND
tp.c_id = $course_id tp.c_id = $course_id
@ -1071,7 +1073,7 @@ class Thematic
$_course, $_course,
'thematic_plan', 'thematic_plan',
$thematic_plan_id, $thematic_plan_id,
"ThematicPlanDeleted", 'ThematicPlanDeleted',
$user_id $user_id
); );
} }
@ -1097,7 +1099,7 @@ class Thematic
WHERE WHERE
c_id = $course_id AND c_id = $course_id AND
thematic_id = $thematic_id AND thematic_id = $thematic_id AND
description_type >= ".ADD_THEMATIC_PLAN." "; description_type >= ".ADD_THEMATIC_PLAN;
$rs = Database::query($sql); $rs = Database::query($sql);
$row = Database::fetch_array($rs); $row = Database::fetch_array($rs);
$last_description_type = $row['max']; $last_description_type = $row['max'];
@ -1220,6 +1222,7 @@ class Thematic
} }
} }
} }
return $affected_rows; return $affected_rows;
} }
@ -1292,8 +1295,8 @@ class Thematic
/** /**
* Get total average of thematic advances * Get total average of thematic advances
* @param string Course code (optional) * @param string $course_code (optional)
* @param int Session id (optional) * @param int $session_id (optional)
* @return float Average of thematic advances * @return float Average of thematic advances
*/ */
public function get_total_average_of_thematic_advances($course_code = null, $session_id = null) public function get_total_average_of_thematic_advances($course_code = null, $session_id = null)
@ -1332,7 +1335,7 @@ class Thematic
$score = array_sum($a_average_of_advances_by_thematic); $score = array_sum($a_average_of_advances_by_thematic);
$total_average = round(($score * 100) / ($count_tematics * 100)); $total_average = round(($score * 100) / ($count_tematics * 100));
} }
return $total_average; return $total_average;
} }
@ -1362,7 +1365,6 @@ class Thematic
} }
return $average; return $average;
} }
/** /**

@ -510,7 +510,7 @@ class UrlManager
$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);
$result_array = array(); $result_array = array();
if (is_array($course_list) && is_array($url_list)){ if (is_array($course_list) && is_array($url_list)) {
foreach ($url_list as $url_id) { foreach ($url_list as $url_id) {
foreach ($course_list as $course_code) { foreach ($course_list as $course_code) {
$courseInfo = api_get_course_info($course_code); $courseInfo = api_get_course_info($course_code);
@ -531,7 +531,7 @@ class UrlManager
} }
} }
return $result_array; return $result_array;
} }
/** /**
@ -560,7 +560,7 @@ class UrlManager
} }
} }
return $resultArray; return $resultArray;
} }
/** /**
@ -589,7 +589,7 @@ class UrlManager
} }
} }
return $resultArray; return $resultArray;
} }
/** /**
@ -625,6 +625,7 @@ class UrlManager
usergroup_id = '".intval($userGroupId)."', usergroup_id = '".intval($userGroupId)."',
access_url_id = ".intval($urlId); access_url_id = ".intval($urlId);
Database::query($sql); Database::query($sql);
return Database::insert_id(); return Database::insert_id();
} }
@ -832,7 +833,7 @@ class UrlManager
$table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USERGROUP); $table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USERGROUP);
$sql= "DELETE FROM $table $sql= "DELETE FROM $table
WHERE usergroup_id = '".intval($userGroupId)."' AND WHERE usergroup_id = '".intval($userGroupId)."' AND
access_url_id=".intval($urlId)." "; access_url_id = ".intval($urlId);
$result = Database::query($sql); $result = Database::query($sql);
return $result; return $result;
@ -884,7 +885,9 @@ class UrlManager
public static function update_urls_rel_user($user_list, $access_url_id) public static function update_urls_rel_user($user_list, $access_url_id)
{ {
$table_url_rel_user = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); $table_url_rel_user = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$sql = "SELECT user_id FROM $table_url_rel_user WHERE access_url_id = ".intval($access_url_id); $sql = "SELECT user_id
FROM $table_url_rel_user
WHERE access_url_id = ".intval($access_url_id);
$result = Database::query($sql); $result = Database::query($sql);
$existing_users = array(); $existing_users = array();
@ -1008,7 +1011,6 @@ class UrlManager
} }
// Adding // Adding
foreach ($list as $id) { foreach ($list as $id) {
UrlManager::addCourseCategoryToUrl($id, $urlId); UrlManager::addCourseCategoryToUrl($id, $urlId);
$categoryInfo = CourseCategory::getCategoryById($id); $categoryInfo = CourseCategory::getCategoryById($id);

@ -801,7 +801,8 @@ class UserGroup extends Model
if ($this->useMultipleUrl) { if ($this->useMultipleUrl) {
$urlId = api_get_current_access_url_id(); $urlId = api_get_current_access_url_id();
$sql = "SELECT * FROM $this->table u $sql = "SELECT * FROM $this->table u
INNER JOIN {$this->access_url_rel_usergroup} a ON (a.usergroup_id = u.id) INNER JOIN {$this->access_url_rel_usergroup} a
ON (a.usergroup_id = u.id)
WHERE name = '".Database::escape_string($name)."' AND access_url_id = $urlId"; WHERE name = '".Database::escape_string($name)."' AND access_url_id = $urlId";
} else { } else {
$sql = "SELECT * FROM $this->table WHERE name = '".Database::escape_string($name)."'"; $sql = "SELECT * FROM $this->table WHERE name = '".Database::escape_string($name)."'";
@ -954,7 +955,6 @@ class UserGroup extends Model
$groupExists = $this->usergroup_exists(trim($params['name'])); $groupExists = $this->usergroup_exists(trim($params['name']));
if ($groupExists == false) { if ($groupExists == false) {
$id = parent::save($params, $show_query); $id = parent::save($params, $show_query);
if ($id) { if ($id) {
if ($this->useMultipleUrl) { if ($this->useMultipleUrl) {
@ -1318,7 +1318,6 @@ class UserGroup extends Model
$form->applyFilter('description', 'trim'); $form->applyFilter('description', 'trim');
if ($this->showGroupTypeSetting) { if ($this->showGroupTypeSetting) {
$form->addElement( $form->addElement(
'checkbox', 'checkbox',
'group_type', 'group_type',
@ -1356,7 +1355,7 @@ class UserGroup extends Model
$form->addElement('checkbox', 'allow_members_leave_group', '', get_lang('AllowMemberLeaveGroup')); $form->addElement('checkbox', 'allow_members_leave_group', '', get_lang('AllowMemberLeaveGroup'));
// Setting the form elements // Setting the form elements
if ($type == 'add') { if ($type === 'add') {
$form->addButtonCreate($header); $form->addButtonCreate($header);
} else { } else {
$form->addButtonUpdate($header); $form->addButtonUpdate($header);
@ -1376,7 +1375,7 @@ class UserGroup extends Model
{ {
$picture = array(); $picture = array();
//$picture['style'] = $style; //$picture['style'] = $style;
if ($picture_file == 'unknown.jpg') { if ($picture_file === 'unknown.jpg') {
$picture['file'] = Display::returnIconPath($picture_file); $picture['file'] = Display::returnIconPath($picture_file);
return $picture; return $picture;
} }
@ -1485,7 +1484,7 @@ class UserGroup extends Model
*/ */
public function getAllowedPictureExtensions() public function getAllowedPictureExtensions()
{ {
return $allowed_picture_types = array ('jpg', 'jpeg', 'png', 'gif'); return ['jpg', 'jpeg', 'png', 'gif'];
} }
/** /**
@ -1828,8 +1827,8 @@ class UserGroup extends Model
} }
/** Gets the last groups created /** Gets the last groups created
* @param int quantity of records * @param int $num quantity of records
* @param bool show groups with image or not * @param bool $with_image show groups with image or not
* @return array with group content * @return array with group content
* @author Julio Montoya * @author Julio Montoya
* */ * */
@ -1992,7 +1991,6 @@ class UserGroup extends Model
$my_group_role = self::get_user_group_role($user_id, $group_id); $my_group_role = self::get_user_group_role($user_id, $group_id);
// Loading group permission // Loading group permission
$links = ''; $links = '';
switch ($my_group_role) { switch ($my_group_role) {
case GROUP_USER_PERMISSION_READER: case GROUP_USER_PERMISSION_READER:
@ -2088,16 +2086,19 @@ class UserGroup extends Model
* @param bool $with_image * @param bool $with_image
* @return int * @return int
*/ */
public function get_groups_by_user_count($user_id = '', $relation_type = GROUP_USER_PERMISSION_READER, $with_image = false) public function get_groups_by_user_count(
{ $user_id = '',
$table_group_rel_user = $this->usergroup_rel_user_table; $relation_type = GROUP_USER_PERMISSION_READER,
$tbl_group = $this->table; $with_image = false
$user_id = intval($user_id); ) {
$table_group_rel_user = $this->usergroup_rel_user_table;
$tbl_group = $this->table;
$user_id = intval($user_id);
if ($relation_type == 0) { if ($relation_type == 0) {
$where_relation_condition = ''; $where_relation_condition = '';
} else { } else {
$relation_type = intval($relation_type); $relation_type = intval($relation_type);
$where_relation_condition = "AND gu.relation_type = $relation_type "; $where_relation_condition = "AND gu.relation_type = $relation_type ";
} }
@ -2125,39 +2126,11 @@ class UserGroup extends Model
public function get_all_group_tags($tag, $from = 0, $number_of_items = 10, $getCount = false) public function get_all_group_tags($tag, $from = 0, $number_of_items = 10, $getCount = false)
{ {
$group_table = $this->table; $group_table = $this->table;
$table_tag = Database::get_main_table(TABLE_MAIN_TAG);
//$table_group_tag_values = Database::get_main_table(TABLE_USERGROUP_REL_TAG);
$field_id = 5;
$tag = Database::escape_string($tag); $tag = Database::escape_string($tag);
$from = intval($from); $from = intval($from);
$number_of_items = intval($number_of_items); $number_of_items = intval($number_of_items);
$return = array(); $return = array();
// all the information of the field
/*$select = "SELECT g.id, g.name, g.description, g.picture";
$sql = "$select
FROM $table_tag t
INNER JOIN $table_group_tag_values tv
ON (tv.tag_id=t.id)
INNER JOIN $group_table g
ON (tv.usergroup_id =g.id)
WHERE
tag LIKE '$tag%' AND
field_id= $field_id
ORDER BY tag";
$sql .= " LIMIT $from, $number_of_items";
$result = Database::query($sql);
if (Database::num_rows($result)> 0) {
while ($row = Database::fetch_array($result,'ASSOC')) {
$return[$row['id']] = $row;
}
}*/
$keyword = $tag; $keyword = $tag;
$sql = "SELECT g.id, g.name, g.description, g.url, g.picture $sql = "SELECT g.id, g.name, g.description, g.url, g.picture
FROM $group_table g"; FROM $group_table g";
@ -2243,9 +2216,7 @@ class UserGroup extends Model
$includeSubgroupsUsers = true $includeSubgroupsUsers = true
) { ) {
$userId = intval($userId); $userId = intval($userId);
$groups = $this->get_groups_by_user($userId, $relationType); $groups = $this->get_groups_by_user($userId, $relationType);
$groupsId = array_keys($groups); $groupsId = array_keys($groups);
$subgroupsId = []; $subgroupsId = [];
$userIdList = []; $userIdList = [];
@ -2304,9 +2275,7 @@ class UserGroup extends Model
for ($i = 1; $i <= $levels; $i++) { for ($i = 1; $i <= $levels; $i++) {
$tableIndexNumber = $i; $tableIndexNumber = $i;
$tableIndexJoinNumber = $i - 1; $tableIndexJoinNumber = $i - 1;
$select .= "g$i.id as id_$i "; $select .= "g$i.id as id_$i ";
$select .= ($i != $levels ? ", " : null); $select .= ($i != $levels ? ", " : null);
if ($i == 1) { if ($i == 1) {
@ -2322,9 +2291,9 @@ class UserGroup extends Model
$result = Database::query("$select $from"); $result = Database::query("$select $from");
while ($item = Database::fetch_assoc($result)) { while ($item = Database::fetch_assoc($result)) {
foreach ($item as $groupId) { foreach ($item as $myGroupId) {
if (!empty($groupId)) { if (!empty($myGroupId)) {
$groups[] = $groupId; $groups[] = $myGroupId;
} }
} }
} }
@ -2362,6 +2331,7 @@ class UserGroup extends Model
} }
} }
$res = Database::query($sql); $res = Database::query($sql);
return $res; return $res;
} }
@ -2411,6 +2381,4 @@ class UserGroup extends Model
{ {
return $groupInfo['allow_members_leave_group'] == 1 ? true : false; return $groupInfo['allow_members_leave_group'] == 1 ? true : false;
} }
} }

Loading…
Cancel
Save