Update from 1.11.x, fix queries, use iid, fix PHP warnings

pull/3741/head
Julio Montoya 5 years ago
parent 2ffef0ae53
commit 3ba91c46fc
  1. 2
      public/main/forum/viewforum.php
  2. 8
      public/main/lp/learnpathItem.class.php
  3. 10
      public/main/lp/lp_report.php
  4. 11
      public/main/lp/lp_subscribe_users.php
  5. 2
      public/main/survey/survey.lib.php
  6. 3
      public/main/survey/surveyUtil.class.php
  7. 16
      public/main/survey/survey_list.php
  8. 2
      public/main/work/edit.php

@ -420,7 +420,7 @@ if (is_array($threads)) {
ICON_SIZE_SMALL
).' '.$thread->getThreadReplies().' '.get_lang('Views').'<br>';
$html .= '</div>';
$last_post = null;
if ($thread->getThreadLastPost()) {
$post_date = api_convert_and_format_date($thread->getThreadLastPost()->getPostDate()->format('Y-m-d H:i:s'));
$last_post = $post_date.'<br>'.get_lang('By').' '.displayUserLink(

@ -4373,9 +4373,9 @@ class learnpathItem
public function dissociateForumThread($threadIid)
{
$threadIid = (int) $threadIid;
$em = Database::getManager();
$forumThread = $em->find('ChamiloCourseBundle:CForumThread', $threadIid);
$repo = Container::getForumThreadRepository();
$forumThread = $repo->find($threadIid);
if (!$forumThread) {
return false;
@ -4383,9 +4383,7 @@ class learnpathItem
$forumThread->setThreadTitle("{$this->get_title()} - {$this->db_id}");
$forumThread->setLpItemId(0);
$em->persist($forumThread);
$em->flush();
$repo->update($forumThread);
return true;
}

@ -2,6 +2,8 @@
/* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Framework\Container;
use Chamilo\CourseBundle\Entity\CLp;
use Chamilo\CourseBundle\Entity\CLpCategory;
/**
@ -36,9 +38,9 @@ if (!empty($groupFilterParts) && isset($groupFilterParts[1])) {
$export = isset($_REQUEST['export']);
$reset = isset($_REQUEST['reset']) ? $_REQUEST['reset'] : '';
$lpRepo = \Chamilo\CoreBundle\Framework\Container::getLpRepository();
/** @var \Chamilo\CourseBundle\Entity\CLp $entity */
$entity = $lpRepo->find($lpId);
$repo = Container::getLpRepository();
/** @var CLp $entity */
$entity = $repo->find($lpId);
$lp = new learnpath($entity, $courseInfo, api_get_user_id());
if (empty($lp)) {
@ -109,7 +111,7 @@ if ('1' === $lp->getSubscribeUsers()) {
$users = [];
if (!empty($categoryId)) {
/** @var CLpCategory $category */
$category = $em->getRepository('ChamiloCourseBundle:CLpCategory')->find($categoryId);
$category = $em->getRepository(CLpCategory::class)->find($categoryId);
$subscribedUsersInCategory = $category->getUsers();
if (!empty($subscribedUsersInCategory)) {
foreach ($subscribedUsersInCategory as $item) {

@ -5,7 +5,9 @@
use Chamilo\CoreBundle\Entity\Session;
use Chamilo\CoreBundle\Entity\SessionRelCourseRelUser;
use Chamilo\CoreBundle\Entity\User;
use Chamilo\CoreBundle\Framework\Container;
use Chamilo\CoreBundle\Repository\Node\CourseRepository;
use Chamilo\CourseBundle\Entity\CLp;
require_once __DIR__.'/../inc/global.inc.php';
@ -29,8 +31,10 @@ if (empty($lpId)) {
$allowUserGroups = api_get_configuration_value('allow_lp_subscription_to_usergroups');
$currentUser = api_get_user_entity(api_get_user_id());
$oLP = new learnpath(api_get_course_id(), $lpId, api_get_user_id());
$repo = Container::getLpRepository();
/** @var CLp $entity */
$entity = $repo->find($lpId);
$oLP = new learnpath($entity, api_get_course_info(), api_get_user_id());
$interbreadcrumb[] = [
'url' => 'lp_controller.php?action=list&'.api_get_cidreq(),
@ -49,8 +53,7 @@ $sessionId = api_get_session_id();
$url = api_get_self().'?'.api_get_cidreq().'&lp_id='.$lpId;
$lp = new learnpath($courseCode, $lpId, api_get_user_id());
$em = Database::getManager();
/** @var CourseRepository $courseRepo */
$courseRepo = $em->getRepository('ChamiloCoreBundle:Course');
$courseRepo = Container::getCourseRepository();
/** @var Session $session */
$session = null;

@ -859,7 +859,7 @@ class SurveyManager
Database::query($sql);
$sql = 'UPDATE '.$table_survey.' SET invited=0, answered=0
WHERE c_id = '.$courseId.' AND survey_id='.$surveyId;
WHERE c_id = '.$courseId.' AND iid ='.$surveyId;
Database::query($sql);
Event::addEvent(

@ -775,7 +775,7 @@ class SurveyUtil
if ($absolute_number != 0) {
echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/reporting.php?action='.$action
.'&survey_id='.$surveyId.'&question='.$offset.'&viewoption='
.$value['question_option_id'].'">'.$absolute_number.'</a>';
.$value['iid'].'">'.$absolute_number.'</a>';
} else {
echo '0';
}
@ -3410,6 +3410,7 @@ class SurveyUtil
ORDER BY col$column $direction
LIMIT $from,$number_of_items
";
$res = Database::query($sql);
$surveys = [];
$array = [];

@ -69,7 +69,7 @@ Session::erase('answer_count');
Session::erase('answer_list');
$tool_name = get_lang('Survey list');
// Database table definitions
if (isset($_GET['search']) && 'advanced' == $_GET['search']) {
if (isset($_GET['search']) && 'advanced' === $_GET['search']) {
$interbreadcrumb[] = [
'url' => api_get_path(WEB_CODE_PATH).'survey/survey_list.php',
'name' => get_lang('Survey list'),
@ -555,24 +555,28 @@ Display::display_header($tool_name, 'Survey');
Display::display_introduction_section('survey', 'left');
// Action handling: searching
if (isset($_GET['search']) && 'advanced' == $_GET['search']) {
if (isset($_GET['search']) && 'advanced' === $_GET['search']) {
SurveyUtil::display_survey_search_form();
}
echo '<div class="actions">';
if (!api_is_session_general_coach() || 'true' == $extend_rights_for_coachs) {
if (!api_is_session_general_coach() || 'true' === $extend_rights_for_coachs) {
// Action links
echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/create_new_survey.php?'.api_get_cidreq().'&amp;action=add">'.
echo '<a
href="'.api_get_path(WEB_CODE_PATH).'survey/create_new_survey.php?'.api_get_cidreq().'&amp;action=add">'.
Display::return_icon('new_survey.png', get_lang('Create survey'), '', ICON_SIZE_MEDIUM).'</a> ';
$url = api_get_path(WEB_CODE_PATH).'survey/create_meeting.php?'.api_get_cidreq();
echo Display::url(Display::return_icon('add_doodle.png', get_lang('Create surveyDoodle'), '', ICON_SIZE_MEDIUM), $url);
echo Display::url(
Display::return_icon('add_doodle.png', get_lang('Create surveyDoodle'), '', ICON_SIZE_MEDIUM),
$url
);
}
echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&amp;search=advanced">'.
Display::return_icon('search.png', get_lang('Search'), '', ICON_SIZE_MEDIUM).'</a>';
echo '</div>';
// Load main content
if (api_is_session_general_coach() && 'false' == $extend_rights_for_coachs) {
if (api_is_session_general_coach() && 'false' === $extend_rights_for_coachs) {
SurveyUtil::display_survey_list_for_coach();
} else {
SurveyUtil::display_survey_list();

@ -81,7 +81,7 @@ if (!api_is_allowed_to_edit()) {
}
if (!empty($my_folder_data)) {
$homework = get_work_assignment_by_id($my_folder_data['id']);
$homework = get_work_assignment_by_id($my_folder_data['iid']);
if (!empty($homework['expires_on']) || !empty($homework['ends_on'])) {
$time_now = time();

Loading…
Cancel
Save