From f423cdd15691792433001c0039878bcee94dce73 Mon Sep 17 00:00:00 2001 From: jmontoyaa Date: Wed, 2 Aug 2017 10:59:28 +0200 Subject: [PATCH] Minor - format code, set namespace at the beginning of file. --- main/exercise/unique_answer.class.php | 3 +- main/inc/lib/CourseChatUtils.php | 3 +- main/inc/lib/add_course.lib.inc.php | 8 ++- main/inc/lib/extra_field.lib.php | 6 +- main/inc/lib/pear/HTML/QuickForm.php | 13 +--- main/inc/lib/plugin.class.php | 92 ++++++++++++++------------- main/inc/lib/webservices/Rest.php | 6 +- 7 files changed, 66 insertions(+), 65 deletions(-) diff --git a/main/exercise/unique_answer.class.php b/main/exercise/unique_answer.class.php index 5d0391072d..bde962d8f9 100755 --- a/main/exercise/unique_answer.class.php +++ b/main/exercise/unique_answer.class.php @@ -2,6 +2,7 @@ /* For licensing terms, see /license.txt */ use ChamiloSession as Session; +use Chamilo\CourseBundle\Entity\CQuizAnswer; /** * Class UniqueAnswer @@ -463,7 +464,7 @@ class UniqueAnswer extends Question $position = $row_max->max_position + 1; // Insert a new answer - $quizAnswer = new \Chamilo\CourseBundle\Entity\CQuizAnswer(); + $quizAnswer = new CQuizAnswer(); $quizAnswer ->setCId($course_id) ->setId($id) diff --git a/main/inc/lib/CourseChatUtils.php b/main/inc/lib/CourseChatUtils.php index f4ca3336d3..cd561e013a 100644 --- a/main/inc/lib/CourseChatUtils.php +++ b/main/inc/lib/CourseChatUtils.php @@ -3,6 +3,7 @@ use Michelf\MarkdownExtra; use Doctrine\Common\Collections\Criteria; +use Chamilo\CourseBundle\Entity\CChatConnected; /** * Class CourseChat @@ -319,7 +320,7 @@ class CourseChatUtils return; } - $connection = new \Chamilo\CourseBundle\Entity\CChatConnected(); + $connection = new CChatConnected(); $connection ->setCId($this->courseId) ->setUserId($this->userId) diff --git a/main/inc/lib/add_course.lib.inc.php b/main/inc/lib/add_course.lib.inc.php index e728023d64..1172d7f543 100755 --- a/main/inc/lib/add_course.lib.inc.php +++ b/main/inc/lib/add_course.lib.inc.php @@ -1,6 +1,8 @@ ' . get_lang('IntroductionText').'

'; - $toolIntro = new Chamilo\CourseBundle\Entity\CToolIntro(); + $toolIntro = new CToolIntro(); $toolIntro ->setCId($course_id) ->setId(TOOL_COURSE_HOMEPAGE) @@ -964,7 +966,7 @@ class AddCourse ->setIntroText($intro_text); $manager->persist($toolIntro); - $toolIntro = new Chamilo\CourseBundle\Entity\CToolIntro(); + $toolIntro = new CToolIntro(); $toolIntro ->setCId($course_id) ->setId(TOOL_STUDENTPUBLICATION) @@ -972,7 +974,7 @@ class AddCourse ->setIntroText(get_lang('IntroductionTwo')); $manager->persist($toolIntro); - $toolIntro = new Chamilo\CourseBundle\Entity\CToolIntro(); + $toolIntro = new CToolIntro(); $toolIntro ->setCId($course_id) ->setId(TOOL_WIKI) diff --git a/main/inc/lib/extra_field.lib.php b/main/inc/lib/extra_field.lib.php index 3864e081a8..24ea2fa3ea 100755 --- a/main/inc/lib/extra_field.lib.php +++ b/main/inc/lib/extra_field.lib.php @@ -1184,7 +1184,10 @@ class ExtraField extends Model 'extra_'.$field_details['variable'], $field_details['display_text'], $options, - array('multiple' => 'multiple', 'id' => 'extra_'.$field_details['variable']) + array( + 'multiple' => 'multiple', + 'id' => 'extra_'.$field_details['variable'] + ) ); if ($freezeElement) { $form->freeze('extra_'.$field_details['variable']); @@ -2634,7 +2637,6 @@ JAVASCRIPT; continue; } if (strpos($rule->field, '_second') === false) { - } else { $my_field = str_replace('_second', '', $rule->field); $double_select[$my_field] = $rule->data; diff --git a/main/inc/lib/pear/HTML/QuickForm.php b/main/inc/lib/pear/HTML/QuickForm.php index 08b7b0384d..6e866c1c93 100755 --- a/main/inc/lib/pear/HTML/QuickForm.php +++ b/main/inc/lib/pear/HTML/QuickForm.php @@ -1,6 +1,4 @@ createLinkToCourseTool($plugin_name, $courseId); } + /** + * Delete the fields added to the course settings page and the link to the + * tool on the course's homepage + * @param int $courseId + * + * @return false|null + */ + public function uninstall_course_fields($courseId) + { + $courseId = intval($courseId); + + if (empty($courseId)) { + return false; + } + $plugin_name = $this->get_name(); + + $t_course = Database::get_course_table(TABLE_COURSE_SETTING); + $t_tool = Database::get_course_table(TABLE_TOOL_LIST); + + if (!empty($this->course_settings)) { + foreach ($this->course_settings as $setting) { + $variable = Database::escape_string($setting['name']); + if (!empty($setting['group'])) { + $variable = Database::escape_string($setting['group']); + } + if (empty($variable)) { + continue; + } + $sql = "DELETE FROM $t_course + WHERE c_id = $courseId AND variable = '$variable'"; + Database::query($sql); + } + } + + $plugin_name = Database::escape_string($plugin_name); + $sql = "DELETE FROM $t_tool + WHERE c_id = $courseId AND name = '$plugin_name'"; + Database::query($sql); + } + /** * Add an link for a course tool * @param string $name The tool name * @param int $courseId The course ID * @param string $iconName Optional. Icon file name * @param string $link Optional. Link URL - * @return \Chamilo\CourseBundle\Entity\CTool|null - */ - protected function createLinkToCourseTool($name, $courseId, $iconName = null, $link = null) - { + * @return CTool|null + */ + protected function createLinkToCourseTool( + $name, + $courseId, + $iconName = null, + $link = null + ) { if (!$this->addCourseTool) { return null; } @@ -559,46 +603,6 @@ class Plugin return $tool; } - /** - * Delete the fields added to the course settings page and the link to the - * tool on the course's homepage - * @param int $courseId - * - * @return false|null - */ - public function uninstall_course_fields($courseId) - { - $courseId = intval($courseId); - - if (empty($courseId)) { - return false; - } - $plugin_name = $this->get_name(); - - $t_course = Database::get_course_table(TABLE_COURSE_SETTING); - $t_tool = Database::get_course_table(TABLE_TOOL_LIST); - - if (!empty($this->course_settings)) { - foreach ($this->course_settings as $setting) { - $variable = Database::escape_string($setting['name']); - if (!empty($setting['group'])) { - $variable = Database::escape_string($setting['group']); - } - if (empty($variable)) { - continue; - } - $sql = "DELETE FROM $t_course - WHERE c_id = $courseId AND variable = '$variable'"; - Database::query($sql); - } - } - - $plugin_name = Database::escape_string($plugin_name); - $sql = "DELETE FROM $t_tool - WHERE c_id = $courseId AND name = '$plugin_name'"; - Database::query($sql); - } - /** * Install the course fields and tool link of this plugin in all courses * @param boolean $add_tool_link Whether we want to add a plugin link on the course homepage diff --git a/main/inc/lib/webservices/Rest.php b/main/inc/lib/webservices/Rest.php index 0941d756c8..b931aacd18 100644 --- a/main/inc/lib/webservices/Rest.php +++ b/main/inc/lib/webservices/Rest.php @@ -8,6 +8,7 @@ use Chamilo\CourseBundle\Entity\Repository\CNotebookRepository; use Chamilo\CourseBundle\Entity\CLpCategory; use Chamilo\CoreBundle\Entity\Session; use Chamilo\UserBundle\Entity\User; +use Chamilo\CourseBundle\Entity\CNotebook; /** * Class RestApi @@ -482,7 +483,7 @@ class Rest extends WebService $notebooks = $notebooksRepo->findByUser($this->user, $this->course, $this->session); return array_map( - function(\Chamilo\CourseBundle\Entity\CNotebook $notebook) { + function (CNotebook $notebook) { return [ 'id' => $notebook->getIid(), 'title' => $notebook->getTitle(), @@ -687,13 +688,12 @@ class Rest extends WebService $sessionId = $this->session ? $this->session->getId() : 0; $categoriesTempList = learnpath::getCategories($this->course->getId()); - $categoryNone = new \Chamilo\CourseBundle\Entity\CLpCategory(); + $categoryNone = new CLpCategory(); $categoryNone->setId(0); $categoryNone->setName(get_lang('WithOutCategory')); $categoryNone->setPosition(0); $categories = array_merge([$categoryNone], $categoriesTempList); - $categoryData = array(); /** @var CLpCategory $category */