From 054d4d2004160976deeb68f6513b6045261bf460 Mon Sep 17 00:00:00 2001 From: Angel Fernando Quiroz Campos Date: Tue, 5 Jan 2021 16:27:49 -0500 Subject: [PATCH] Minor - Format code - refs BT#18201 --- main/inc/lib/PortfolioController.php | 152 ++++++++++++++------------- 1 file changed, 79 insertions(+), 73 deletions(-) diff --git a/main/inc/lib/PortfolioController.php b/main/inc/lib/PortfolioController.php index 31b3730cbe..f1da18296d 100644 --- a/main/inc/lib/PortfolioController.php +++ b/main/inc/lib/PortfolioController.php @@ -122,6 +122,38 @@ class PortfolioController $this->renderView($content, get_lang('AddCategory'), $actions); } + /** + * @param string $content + * @param string $toolName + * @param array $actions + */ + private function renderView(string $content, string $toolName, array $actions = []) + { + global $this_section; + + $this_section = $this->course ? SECTION_COURSES : SECTION_SOCIAL; + + $view = new Template($toolName); + $view->assign('header', $toolName); + + $actionsStr = ''; + + if ($this->course) { + $actionsStr .= Display::return_introduction_section(TOOL_PORTFOLIO); + } + + if ($actions) { + $actions = implode(PHP_EOL, $actions); + + $actionsStr .= Display::toolbarAction('portfolio-toolbar', [$actions]); + } + + $view->assign('actions', $actionsStr); + + $view->assign('content', $content); + $view->display_one_col_template(); + } + /** * @param \Chamilo\CoreBundle\Entity\PortfolioCategory $category * @@ -140,7 +172,11 @@ class PortfolioController Display::return_message(get_lang('PortfolioCategoryFieldHelp'), 'info') ); - $form = new FormValidator('edit_category', 'post', $this->baseUrl."action=edit_category&id={$category->getId()}"); + $form = new FormValidator( + 'edit_category', + 'post', + $this->baseUrl."action=edit_category&id={$category->getId()}" + ); if (api_get_configuration_value('save_titles_as_html')) { $form->addHtmlEditor('title', get_lang('Title'), true, false, ['ToolbarSet' => 'TitleAsHtml']); @@ -151,10 +187,12 @@ class PortfolioController $form->addHtmlEditor('description', get_lang('Description'), false, false, ['ToolbarSet' => 'Minimal']); $form->addButtonUpdate(get_lang('Update')); - $form->setDefaults([ - 'title' => $category->getTitle(), - 'description' => $category->getDescription(), - ]); + $form->setDefaults( + [ + 'title' => $category->getTitle(), + 'description' => $category->getDescription(), + ] + ); if ($form->validate()) { $values = $form->exportValues(); @@ -190,6 +228,20 @@ class PortfolioController return $this->renderView($content, get_lang('EditCategory'), $actions); } + /** + * @param \Chamilo\CoreBundle\Entity\PortfolioCategory $category + * + * @return bool + */ + private function categoryBelongToOwner(PortfolioCategory $category): bool + { + if ($category->getUser()->getId() != $this->owner->getId()) { + return false; + } + + return true; + } + /** * @param \Chamilo\CoreBundle\Entity\PortfolioCategory $category * @@ -399,6 +451,28 @@ class PortfolioController $this->renderView($content, get_lang('EditPortfolioItem'), $actions); } + /** + * @param \Chamilo\CoreBundle\Entity\Portfolio $item + * + * @return bool + */ + private function itemBelongToOwner(Portfolio $item): bool + { + if ($this->session && $item->getSession()->getId() != $this->session->getId()) { + return false; + } + + if ($this->course && $item->getCourse()->getId() != $this->course->getId()) { + return false; + } + + if ($item->getUser()->getId() != $this->owner->getId()) { + return false; + } + + return true; + } + /** * @param \Chamilo\CoreBundle\Entity\Portfolio $item * @@ -538,72 +612,4 @@ class PortfolioController $this->renderView($content, get_lang('Portfolio'), $actions); } - - /** - * @param \Chamilo\CoreBundle\Entity\PortfolioCategory $category - * - * @return bool - */ - private function categoryBelongToOwner(PortfolioCategory $category): bool - { - if ($category->getUser()->getId() != $this->owner->getId()) { - return false; - } - - return true; - } - - /** - * @param \Chamilo\CoreBundle\Entity\Portfolio $item - * - * @return bool - */ - private function itemBelongToOwner(Portfolio $item): bool - { - if ($this->session && $item->getSession()->getId() != $this->session->getId()) { - return false; - } - - if ($this->course && $item->getCourse()->getId() != $this->course->getId()) { - return false; - } - - if ($item->getUser()->getId() != $this->owner->getId()) { - return false; - } - - return true; - } - - /** - * @param string $content - * @param string $toolName - * @param array $actions - */ - private function renderView(string $content, string $toolName, array $actions = []) - { - global $this_section; - - $this_section = $this->course ? SECTION_COURSES : SECTION_SOCIAL; - - $view = new Template($toolName); - $view->assign('header', $toolName); - - $actionsStr = ''; - - if ($this->course) { - $actionsStr .= Display::return_introduction_section(TOOL_PORTFOLIO); - } - - if ($actions) { - $actions = implode(PHP_EOL, $actions); - - $actionsStr .= Display::toolbarAction('portfolio-toolbar', [$actions]); - } - - $view->assign('actions', $actionsStr); - - $view->assign('content', $content); - $view->display_one_col_template(); - } }