Minor - format code, fix php notices

pull/3382/head
Julio Montoya 5 years ago
parent 581505442a
commit 79fd1765a6
  1. 51
      main/gradebook/lib/GradebookUtils.php
  2. 32
      main/wiki/wiki.inc.php

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
/**
@ -260,7 +261,7 @@ class GradebookUtils
if (api_is_allowed_to_edit(null, true)) {
// Locking button
if (api_get_setting('gradebook_locking_enabled') == 'true') {
if (api_get_setting('gradebook_locking_enabled') === 'true') {
if ($cat->is_locked()) {
if (api_is_platform_admin()) {
$modify_icons .= '&nbsp;<a onclick="javascript:if (!confirm(\''.addslashes(get_lang('ConfirmToUnlockElement')).'\')) return false;" href="'.api_get_self().'?'.api_get_cidreq().'&category_id='.$cat->get_id().'&action=unlock">'.
@ -444,7 +445,6 @@ class GradebookUtils
$cat = new Category();
$message_link = $cat->show_message_resource_delete($link->get_course_code());
$is_locked = $link->is_locked();
$modify_icons = null;
if (!api_is_allowed_to_edit(null, true)) {
@ -513,7 +513,10 @@ class GradebookUtils
ICON_SIZE_SMALL
);
} else {
$modify_icons .= '&nbsp;<a href="'.api_get_self().'?deletelink='.$link->get_id().'&selectcat='.$selectcat.' &'.$courseParams.'" onclick="return confirmation();">'.
$modify_icons .= '&nbsp;
<a
href="'.api_get_self().'?deletelink='.$link->get_id().'&selectcat='.$selectcat.' &'.$courseParams.'"
onclick="return confirmation();">'.
Display::return_icon(
'delete.png',
get_lang('Delete'),
@ -759,34 +762,6 @@ class GradebookUtils
return $list_users;
}
public static function getTotalCertificates($urlId)
{
$urlId = (int) $urlId;
$table_certificate = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CERTIFICATE);
$table_user = Database::get_main_table(TABLE_MAIN_USER);
$sql = 'SELECT DISTINCT u.user_id, u.lastname, u.firstname, u.username
FROM '.$table_user.' u
INNER JOIN '.$table_certificate.' gc
ON u.user_id=gc.user_id ';
if (!is_null($cat_id) && $cat_id > 0) {
$sql .= ' WHERE cat_id='.intval($cat_id);
}
if (!empty($userList)) {
$userList = array_map('intval', $userList);
$userListCondition = implode("','", $userList);
$sql .= " AND u.user_id IN ('$userListCondition')";
}
$sql .= ' ORDER BY '.(api_sort_by_first_name() ? 'u.firstname' : 'u.lastname');
$rs = Database::query($sql);
$list_users = [];
while ($row = Database::fetch_array($rs)) {
$list_users[] = $row;
}
return $list_users;
}
/**
* Gets the certificate list by user id.
*
@ -932,7 +907,6 @@ class GradebookUtils
$cat->set_weight($default_weight);
$cat->set_grade_model_id($gradebook_model_id);
$cat->set_certificate_min_score(75);
$cat->set_visible(0);
$cat->add();
$category_id = $cat->get_id();
@ -980,7 +954,6 @@ class GradebookUtils
$grade_model_id = $my_cat->get_grade_model_id();
if (empty($grade_model_id)) {
if ($my_cat->get_parent_id() == 0) {
//$default_weight = $my_cat->get_weight();
$select_gradebook->addOption(get_lang('Default'), $my_cat->get_id());
$cats_added[] = $my_cat->get_id();
} else {
@ -1059,9 +1032,11 @@ class GradebookUtils
if ($use_grade_model) {
if ($parent_id == 0) {
$title = api_strtoupper(get_lang('Average')).'<br />'.get_lang('Detailed');
$title = api_strtoupper(get_lang('Average')).
'<br />'.get_lang('Detailed');
} else {
$title = api_strtoupper(get_lang('Average')).'<br />'.$cat[0]->get_description().' - ('.$cat[0]->get_name().')';
$title = api_strtoupper(get_lang('Average')).
'<br />'.$cat[0]->get_description().' - ('.$cat[0]->get_name().')';
}
} else {
if ($parent_id == 0) {
@ -1332,9 +1307,8 @@ class GradebookUtils
}
$result = Database::query($sql);
$users = Database::store_result($result);
return $users;
return Database::store_result($result);
}
/**
@ -1672,9 +1646,6 @@ class GradebookUtils
if ($saveToHtmlFile) {
return $result;
file_put_contents($file, $result);
return $file;
}
return $file;

@ -1,7 +1,7 @@
<?php
/* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Component\Filesystem\Data;
use ChamiloSession as Session;
/**
@ -11,8 +11,6 @@ use ChamiloSession as Session;
* @author Juan Carlos Raña <herodoto@telefonica.net>
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University, Belgium
* @author Julio Montoya <gugli100@gmail.com> using the pdf.lib.php library
*
* @package chamilo.wiki
*/
class Wiki
{
@ -86,10 +84,9 @@ class Wiki
// the value has not been found and is this available
if ($num == 0) {
return true;
} else {
// the value has been found
return false;
}
return false;
}
/**
@ -131,9 +128,8 @@ class Wiki
).' ';
}
}
$output = implode($all_links);
return $output;
return implode($all_links);
}
/**
@ -145,9 +141,8 @@ class Wiki
{
$exlink = 'href=';
$exlinkStyle = 'class="wiki_link_ext" href=';
$output = str_replace($exlink, $exlinkStyle, $input);
return $output;
return str_replace($exlink, $exlinkStyle, $input);
}
/**
@ -1041,7 +1036,10 @@ class Wiki
$result = Database::query($sql);
$row = Database::fetch_array($result, 'ASSOC');
$KeyVisibility = $row['visibility'];
$KeyVisibility = null;
if ($KeyVisibility) {
$KeyVisibility = $row['visibility'];
}
// second, show the last version
$sql = 'SELECT * FROM '.$tbl_wiki.' w
@ -1063,7 +1061,7 @@ class Wiki
Event::addEvent(LOG_WIKI_ACCESS, LOG_WIKI_PAGE_ID, $row['page_id']);
}
//update visits
if ($row['id']) {
if ($row && $row['id']) {
$sql = 'UPDATE '.$tbl_wiki.' SET hits=(hits+1)
WHERE c_id = '.$course_id.' AND id='.$row['id'].'';
Database::query($sql);
@ -1511,7 +1509,10 @@ class Wiki
$result = Database::query($sql);
$row = Database::fetch_array($result);
$status_addlock = $row['addlock'];
$status_addlock = null;
if ($row) {
$status_addlock = $row['addlock'];
}
// Change status
if (api_is_allowed_to_edit(false, true) ||
@ -1536,9 +1537,12 @@ class Wiki
ORDER BY id ASC';
$result = Database::query($sql);
$row = Database::fetch_array($result);
if ($row) {
return $row['addlock'];
}
}
return $row['addlock'];
return null;
}
/**

Loading…
Cancel
Save