From 20752ea5282617f09fa2820dbae16db48665a753 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Fri, 10 Jul 2020 08:32:23 +0200 Subject: [PATCH] Minor - flint fixes --- main/inc/ajax/course_home.ajax.php | 12 ++-- main/inc/introductionSection.inc.php | 13 ++-- main/inc/lib/course_home.lib.php | 10 +-- plugin/google_meet/lang/english.php | 2 - plugin/google_meet/lang/french.php | 2 - plugin/google_meet/lang/spanish.php | 2 - plugin/google_meet/meets.php | 10 +-- plugin/google_meet/plugin.php | 2 +- .../src/google_meet_plugin.class.php | 67 ++++++++++--------- plugin/google_meet/start.php | 3 - 10 files changed, 58 insertions(+), 65 deletions(-) diff --git a/main/inc/ajax/course_home.ajax.php b/main/inc/ajax/course_home.ajax.php index bd622a16f2..d88917401a 100755 --- a/main/inc/ajax/course_home.ajax.php +++ b/main/inc/ajax/course_home.ajax.php @@ -138,7 +138,7 @@ switch ($action) { } break; case 'set_visibility_for_all': - require_once __DIR__ . '/../global.inc.php'; + require_once __DIR__.'/../global.inc.php'; $course_id = api_get_course_int_id(); $sessionId = api_get_session_id(); $allowEditionInSession = api_get_configuration_value('allow_edit_tool_visibility_in_session'); @@ -151,7 +151,7 @@ switch ($action) { if (is_array($tools_ids) && count($tools_ids) != 0) { $total_tools = count($tools_ids); for ($i = 0; $i < $total_tools; $i++) { - $tool_id = (int)$tools_ids[$i]; + $tool_id = (int) $tools_ids[$i]; $criteria = [ 'cId' => $course_id, @@ -208,7 +208,7 @@ switch ($action) { $inactiveImage = str_replace('.gif', '_na.gif', $toolImage); } else { // Display::return_icon() also checks in the app/Resources/public/css/themes/{theme}/icons folder - $toolImage = (substr($toolImage, 0, strpos($toolImage, '.'))) . '.png'; + $toolImage = (substr($toolImage, 0, strpos($toolImage, '.'))).'.png'; $toolImage = Display::return_icon( $toolImage, get_lang(ucfirst($tool->getName())), @@ -221,8 +221,8 @@ switch ($action) { } if (isset($customIcon) && !empty($customIcon)) { - $toolImage = CourseHome::getCustomWebIconPath() . $customIcon; - $inactiveImage = CourseHome::getCustomWebIconPath() . CourseHome::getDisableIcon($customIcon); + $toolImage = CourseHome::getCustomWebIconPath().$customIcon; + $inactiveImage = CourseHome::getCustomWebIconPath().CourseHome::getDisableIcon($customIcon); } $requested_image = $visibility == 0 ? $toolImage : $inactiveImage; @@ -265,7 +265,7 @@ switch ($action) { 'message' => $requested_message, 'view' => $requested_view, 'fclass' => $requested_fa_class, - 'id'=>$tool_id, + 'id' => $tool_id, ]; } } diff --git a/main/inc/introductionSection.inc.php b/main/inc/introductionSection.inc.php index ed4f46c7c6..889d39d8bf 100755 --- a/main/inc/introductionSection.inc.php +++ b/main/inc/introductionSection.inc.php @@ -290,13 +290,12 @@ if (api_is_allowed_to_edit() && empty($session_id)) { api_get_path(WEB_CODE_PATH).'course_info/tools.php?'.api_get_cidreq(), ['class' => 'btn btn-default', 'title' => get_lang('CustomizeIcons')] ); - } /* Tool to show /hide all tools on course */ $toolAllShowHide = ''; if (api_is_allowed_to_edit() && empty($session_id)) { - $toolAllShowHide = ''; - $toolAllShowHide .= ''; + $toolAllShowHide = ''; + $toolAllShowHide .= ''; } $toolbar = ''; @@ -310,10 +309,10 @@ if ($intro_dispCommand) { $textIntro = ''; $textIntro .= ' '; $textIntro .= ""; - $toolbar .= $textIntro . $editIconButton.$toolAllShowHide; + $toolbar .= $textIntro.$editIconButton.$toolAllShowHide; } else { $toolbar .= ''.get_lang('AddIntro').''; - $toolbar .= $editIconButton . $toolAllShowHide; + $toolbar .= $editIconButton.$toolAllShowHide; } $toolbar .= ''; } else { @@ -324,7 +323,7 @@ if ($intro_dispCommand) { $toolbar .= ' '; - $toolbar .= $editIconButton . $toolAllShowHide; + $toolbar .= $editIconButton.$toolAllShowHide; $toolbar .= ""; @@ -333,7 +332,7 @@ if ($intro_dispCommand) { ' "'; - $toolbar .= $editIconButton . $toolAllShowHide; + $toolbar .= $editIconButton.$toolAllShowHide; $toolbar .= ""; diff --git a/main/inc/lib/course_home.lib.php b/main/inc/lib/course_home.lib.php index 10b5266d8b..8d02690f2b 100755 --- a/main/inc/lib/course_home.lib.php +++ b/main/inc/lib/course_home.lib.php @@ -896,7 +896,7 @@ class CourseHome ICON_SIZE_SMALL, false ); - $link['name']=''; + $link['name'] = ''; $link['cmd'] = 'hide=yes'; $lnk[] = $link; } @@ -908,7 +908,7 @@ class CourseHome ICON_SIZE_SMALL, false ); - $link['name']=''; + $link['name'] = ''; $link['cmd'] = 'restore=yes'; $lnk[] = $link; } @@ -937,7 +937,7 @@ class CourseHome ICON_SIZE_SMALL, false ); - $link['name']=''; + $link['name'] = ''; $link['cmd'] = 'restore=yes'; $lnk[] = $link; break; @@ -949,7 +949,7 @@ class CourseHome ICON_SIZE_SMALL, false ); - $link['name']=''; + $link['name'] = ''; $link['cmd'] = 'hide=yes'; $lnk[] = $link; break; @@ -962,7 +962,7 @@ class CourseHome ICON_SIZE_SMALL, false ); - $link['name']=''; + $link['name'] = ''; $link['cmd'] = 'hide=yes'; $lnk[] = $link; } diff --git a/plugin/google_meet/lang/english.php b/plugin/google_meet/lang/english.php index b9e295c181..42a17c6db4 100644 --- a/plugin/google_meet/lang/english.php +++ b/plugin/google_meet/lang/english.php @@ -20,5 +20,3 @@ $strings['MeetingDescription'] = 'Description'; $strings['MeetingDescriptionHelp'] = '(Optional) Add a short description for the meeting.'; $strings['MeetColor'] = 'Color of Meet'; $strings['MeetColorHelp'] = '(Optional)'; - - diff --git a/plugin/google_meet/lang/french.php b/plugin/google_meet/lang/french.php index 3469b95ddb..92b9143629 100644 --- a/plugin/google_meet/lang/french.php +++ b/plugin/google_meet/lang/french.php @@ -20,5 +20,3 @@ $strings['MeetingDescription'] = 'Description'; $strings['MeetingDescriptionHelp'] = '(Optionnel) Ajouter une brève description.'; $strings['MeetColor'] = 'Couleur de la réunion'; $strings['MeetColorHelp'] = '(Optionnel)'; - - diff --git a/plugin/google_meet/lang/spanish.php b/plugin/google_meet/lang/spanish.php index c178615d82..90d0f2e255 100644 --- a/plugin/google_meet/lang/spanish.php +++ b/plugin/google_meet/lang/spanish.php @@ -20,5 +20,3 @@ $strings['MeetingDescription'] = 'Descripción'; $strings['MeetingDescriptionHelp'] = '(Opcional) Añada una breve descripción sobre la reunión.'; $strings['MeetColor'] = 'Color de Meet'; $strings['MeetColorHelp'] = '(Opcional)'; - - diff --git a/plugin/google_meet/meets.php b/plugin/google_meet/meets.php index 8bc64a088b..6db29c589a 100644 --- a/plugin/google_meet/meets.php +++ b/plugin/google_meet/meets.php @@ -85,7 +85,7 @@ if ($enable) { $plugin->get_lang('MeetColorHelp'), ], [ - 'value' => '#1CC88A' + 'value' => '#1CC88A', ] ); } catch (HTML_QuickForm_Error $e) { @@ -135,7 +135,7 @@ if ($enable) { api_get_path(WEB_PLUGIN_PATH).'google_meet/start.php?'.api_get_cidreq() ); - $idMeet = isset($_GET['id_meet']) ? (int)$_GET['id_meet'] : 0; + $idMeet = isset($_GET['id_meet']) ? (int) $_GET['id_meet'] : 0; $dataMeet = $plugin->getMeet($idMeet); //create form @@ -175,7 +175,7 @@ if ($enable) { 'meet_color', [ $plugin->get_lang('MeetColor'), - $plugin->get_lang('MeetColorHelp') + $plugin->get_lang('MeetColorHelp'), ] ); $form->addHtmlEditor( @@ -204,13 +204,10 @@ if ($enable) { $url = api_get_path(WEB_PLUGIN_PATH).'google_meet/start.php?'.api_get_cidreq(); header('Location: '.$url); } - } $tpl->assign('form_room', $form->returnForm()); - - break; } } @@ -218,7 +215,6 @@ if ($enable) { } if ($isAdmin || $isTeacher) { - $tpl->assign( 'actions', Display::toolbarAction('toolbar', [$actionLinks]) diff --git a/plugin/google_meet/plugin.php b/plugin/google_meet/plugin.php index da7608d451..c1fac9daf3 100644 --- a/plugin/google_meet/plugin.php +++ b/plugin/google_meet/plugin.php @@ -1,4 +1,4 @@ get_info(); \ No newline at end of file +$plugin_info = GoogleMeetPlugin::create()->get_info(); diff --git a/plugin/google_meet/src/google_meet_plugin.class.php b/plugin/google_meet/src/google_meet_plugin.class.php index 3ef8b66d05..ac252f982e 100644 --- a/plugin/google_meet/src/google_meet_plugin.class.php +++ b/plugin/google_meet/src/google_meet_plugin.class.php @@ -1,12 +1,12 @@ */ - class GoogleMeetPlugin extends Plugin { const TABLE_MEET_LIST = 'plugin_google_meet_room'; @@ -54,7 +54,8 @@ class GoogleMeetPlugin extends Plugin } /** - * Create a plugin instance + * Create a plugin instance. + * * @return GoogleMeetPlugin */ public static function create() @@ -64,10 +65,9 @@ class GoogleMeetPlugin extends Plugin return $result ? $result : $result = new self(); } - /** * This method creates the tables required to this plugin and copies icons - * to the right places + * to the right places. */ public function install() { @@ -97,7 +97,7 @@ class GoogleMeetPlugin extends Plugin } /** - * This method drops the plugin tables and icons + * This method drops the plugin tables and icons. */ public function uninstall() { @@ -122,11 +122,11 @@ class GoogleMeetPlugin extends Plugin } $this->manageTab(false); - } /** - * {@inheritDoc} + * {@inheritdoc} + * * @return GoogleMeetPlugin */ public function performActionsAfterConfigure() @@ -146,18 +146,8 @@ class GoogleMeetPlugin extends Plugin return $this; } - /** - * Delete links to the tool from the c_tool table - */ - private function deleteCourseToolLinks() + public function saveMeet($values) { - Database::getManager() - ->createQuery('DELETE FROM ChamiloCourseBundle:CTool t WHERE t.category = :category AND t.link LIKE :link') - ->execute(['category' => 'plugin', 'link' => 'google_meet/start.php%']); - } - - - public function saveMeet($values){ if (!is_array($values) || empty($values['meet_name'])) { return false; } @@ -189,8 +179,8 @@ class GoogleMeetPlugin extends Plugin } } - public function listMeets($idCourse){ - + public function listMeets($idCourse) + { $list = []; $tableMeetList = Database::get_main_table(self::TABLE_MEET_LIST); @@ -200,8 +190,7 @@ class GoogleMeetPlugin extends Plugin if (Database::num_rows($result) > 0) { while ($row = Database::fetch_array($result)) { - - $action = Display::url( + $action = Display::url( Display::return_icon( 'delete.png', get_lang('Delete'), @@ -234,13 +223,14 @@ class GoogleMeetPlugin extends Plugin 'activate' => $active, 'actions' => $action, ]; - } } + return $list; } - public function getMeet($idMeet){ + public function getMeet($idMeet) + { if (empty($idMeet)) { return false; } @@ -267,10 +257,12 @@ class GoogleMeetPlugin extends Plugin ]; } } + return $meet; } - public function updateMeet($values){ + public function updateMeet($values) + { if (!is_array($values) || empty($values['meet_name'])) { return false; } @@ -309,8 +301,10 @@ class GoogleMeetPlugin extends Plugin } /** - * Delete a given meeting + * Delete a given meeting. + * * @param int $idMeet Chamilo's internal ID of the meeting + * * @return bool True on success, false on failure */ public function deleteMeet($idMeet) @@ -328,15 +322,27 @@ class GoogleMeetPlugin extends Plugin } return true; + } + /** + * Delete links to the tool from the c_tool table. + */ + private function deleteCourseToolLinks() + { + Database::getManager() + ->createQuery('DELETE FROM ChamiloCourseBundle:CTool t WHERE t.category = :category AND t.link LIKE :link') + ->execute(['category' => 'plugin', 'link' => 'google_meet/start.php%']); } /** - * Do a bit of prevention on the meeting URL format + * Do a bit of prevention on the meeting URL format. + * * @param string $url The URL received from the user + * * @return string Reformatted URL */ - private function filterUrl($url) { + private function filterUrl($url) + { if (!empty($url)) { if (preg_match('#^'.self::GOOGLE_MEET_URL.'#', $url)) { // The URL starts with the right Google Meet protocol and domain, do nothing @@ -352,6 +358,7 @@ class GoogleMeetPlugin extends Plugin $url = self::GOOGLE_MEET_URL.$url; } } + return $url; } } diff --git a/plugin/google_meet/start.php b/plugin/google_meet/start.php index 60978ac8a9..99b0db9a6a 100644 --- a/plugin/google_meet/start.php +++ b/plugin/google_meet/start.php @@ -28,12 +28,9 @@ $enable = $plugin->get('google_meet_enabled') == 'true'; $urlAddMeet = api_get_path(WEB_PLUGIN_PATH).'google_meet/meets.php?action=add&'.api_get_cidreq(); - if ($enable) { if ($isAdmin || $isTeacher || $isStudent) { - $meets = $plugin->listMeets($courseInfo['real_id']); - } }