Fix PHP warnings

pull/3768/head
Julio Montoya 5 years ago
parent 134412e2cb
commit 471d948d15
  1. 3
      public/main/admin/gradebook_list.php
  2. 5
      public/main/admin/questions.php
  3. 26
      public/main/forum/forumfunction.inc.php
  4. 2
      public/main/survey/pending.php
  5. 6
      public/main/survey/survey.lib.php
  6. 3
      public/main/survey/surveyUtil.class.php
  7. 14
      src/CoreBundle/Entity/CourseRelUser.php
  8. 20
      src/CoreBundle/Traits/ResourceControllerTrait.php

@ -3,6 +3,7 @@
/* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Entity\GradebookCategory;
use Chamilo\CoreBundle\Framework\Container;
use Doctrine\Common\Collections\Criteria;
use Knp\Component\Pager\Paginator;
@ -266,7 +267,7 @@ switch ($action) {
break;
case 'list':
default:
$paginator = new Paginator();
$paginator = new Paginator(Container::$container->get('event_dispatcher'));
$pagination = $paginator->paginate(
$gradeBookList,
$page,

@ -1,6 +1,7 @@
<?php
/* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Framework\Container;
use Chamilo\CourseBundle\Entity\CQuiz;
use Chamilo\CourseBundle\Entity\CQuizQuestion;
use ChamiloSession as Session;
@ -76,14 +77,14 @@ if ($formSent) {
$questionCount = count($questions);
$paginator = new Paginator();
$paginator = new Paginator(Container::$container->get('event_dispatcher'));
$pagination = $paginator->paginate($questions, $page, $length);
$pagination->setItemNumberPerPage($length);
$pagination->setCurrentPageNumber($page);
$pagination->renderer = function ($data) use ($url) {
$render = '<ul class="pagination">';
for ($i = 1; $i <= $data['pageCount']; $i++) {
$page = (int) $i;
$page = $i;
$pageContent = '<li><a href="'.$url.'&page='.$page.'">'.$page.'</a></li>';
if ($data['current'] == $page) {
$pageContent = '<li class="active"><a href="#" >'.$page.'</a></li>';

@ -4621,7 +4621,7 @@ function forum_search()
*/
function display_forum_search_results($search_term)
{
$table_threads = Database::get_course_table(TABLE_FORUM_THREAD);
/*$table_threads = Database::get_course_table(TABLE_FORUM_THREAD);
$table_posts = Database::get_course_table(TABLE_FORUM_POST);
$table_item_property = Database::get_course_table(TABLE_ITEM_PROPERTY);
$session_id = api_get_session_id();
@ -4679,13 +4679,13 @@ function display_forum_search_results($search_term)
$forumData = get_forums($forumId);
$category = isset($forum_categories_list[$forumData['forum_category']]) ? $forum_categories_list[$forumData['forum_category']] : null;
$display_result = false;
/*
We only show it when
1. forum category is visible
2. forum is visible
3. thread is visible (to do)
4. post is visible
*/
// We only show it when
// 1. forum category is visible
// 2. forum is visible
// 3. thread is visible (to do)
// 4. post is visible
if (!api_is_allowed_to_edit(null, true)) {
if (!empty($category)) {
if ('1' == $category['visibility'] && '1' == $forumData['visibility']) {
@ -4723,7 +4723,7 @@ function display_forum_search_results($search_term)
if ($search_results) {
echo implode($search_results);
}
echo '</ol>';
echo '</ol>';*/
}
/**
@ -4868,6 +4868,8 @@ function add_forum_attachment_file($file_comment, CForumPost $post)
*/
function edit_forum_attachment_file($file_comment, $post_id, $id_attach)
{
throw new Exception('edit_forum_attachment_file');
/*
$_course = api_get_course_info();
$table_forum_attachment = Database::get_course_table(TABLE_FORUM_ATTACHMENT);
$course_id = api_get_course_int_id();
@ -4934,16 +4936,16 @@ function edit_forum_attachment_file($file_comment, $post_id, $id_attach)
size ='".$attachment['size']."'
WHERE c_id = $course_id AND id = '$safe_id_attach'";
Database::query($sql);
/*api_item_property_update(
api_item_property_update(
$_course,
TOOL_FORUM_ATTACH,
$safe_id_attach,
'ForumAttachmentUpdated',
api_get_user_id()
);*/
);
}
}
}
}*/
}
/**

@ -31,7 +31,7 @@ foreach ($pending as $i => $item) {
$course = api_get_course_entity($survey->getCId());
$session = api_get_session_entity($survey->getSessionId());
$course = $course ? ['id' => $course->getId(), 'title' => $course->getTitle(), 'code' => $course->getCode()] : null;
//$course = $course ? ['id' => $course->getId(), 'title' => $course->getTitle(), 'code' => $course->getCode()] : null;
$session = $session ? ['id' => $session->getId(), 'name' => $session->getName()] : null;
$courseInfo = api_get_course_info_by_id($course->getId());
$surveysData[$survey->getIid()] = [

@ -321,7 +321,7 @@ class SurveyManager
}
} else {
$row = Database::fetch_array($rs, 'ASSOC');
$pos = api_strpos($row['survey_version']);
$pos = api_strpos($row['survey_version'], '.');
if (false === $pos) {
$row['survey_version'] = $row['survey_version'] + 1;
$versionValue = $row['survey_version'];
@ -1347,7 +1347,7 @@ class SurveyManager
*
* @todo editing of a shared question
*/
public function save_shared_question($form_content, $survey_data)
public static function save_shared_question($form_content, $survey_data)
{
$_course = api_get_course_info();
@ -1719,7 +1719,7 @@ class SurveyManager
*
* @todo writing the update statement when editing a question
*/
public function save_shared_question_options($form_content, $survey_data)
public static function save_shared_question_options($form_content, $survey_data)
{
if (is_array($form_content) && is_array($form_content['answers'])) {
// Table definition

@ -3878,7 +3878,8 @@ class SurveyUtil
public static function drawChart($chartData, $hasSerie = false, $chartContainerId = 'chartContainer', $loadLibs = true)
{
$htmlChart = '';
if (api_browser_support('svg')) {
//if (api_browser_support('svg')) {
if (true) {
$serie = [];
$order = [];
$data = '';

@ -65,7 +65,7 @@ class CourseRelUser
/**
* @var int
*
* @Groups({"user:read", "course:read"})
* @Groups({"course:read", "user:read"})
* @ORM\Column(name="relation_type", type="integer", nullable=false, unique=false)
*/
protected $relationType;
@ -114,10 +114,7 @@ class CourseRelUser
$this->userCourseCat = 0;
}
/**
* @return string
*/
public function __toString()
public function __toString(): string
{
return (string) $this->getCourse()->getCode();
}
@ -137,12 +134,7 @@ class CourseRelUser
return $this;
}
/**
* Get Course.
*
* @return Course
*/
public function getCourse()
public function getCourse(): Course
{
return $this->course;
}

@ -92,7 +92,7 @@ trait ResourceControllerTrait
if ($this->hasCourse()) {
$parentResourceNode = $this->getCourse()->getResourceNode();
} else {
if ($this->isGranted('IS_AUTHENTICATED_REMEMBERED')) {
if ($this->container->get('security.authorization_checker')->isGranted('IS_AUTHENTICATED_REMEMBERED')) {
/** @var User $user */
$parentResourceNode = $this->getUser()->getResourceNode();
}
@ -109,6 +109,24 @@ trait ResourceControllerTrait
return $parentResourceNode;
}
protected function getUser()
{
if (!$this->container->has('security.token_storage')) {
throw new \LogicException('The SecurityBundle is not registered in your application. Try running "composer require symfony/security-bundle".');
}
if (null === $token = $this->container->get('security.token_storage')->getToken()) {
return null;
}
if (!\is_object($user = $token->getUser())) {
// e.g. anonymous authentication
return null;
}
return $user;
}
private function setBreadCrumb(Request $request, ResourceNode $resourceNode)
{
return false;

Loading…
Cancel
Save