From 2d27ed3ca283d4377efef53e9bfde8bf12e26323 Mon Sep 17 00:00:00 2001 From: jmontoyaa Date: Fri, 29 Dec 2017 09:08:50 +0100 Subject: [PATCH] Minor - format code --- main/inc/lib/add_course.lib.inc.php | 12 ++---- main/inc/lib/course.lib.php | 2 +- .../formvalidator/Element/DateTimePicker.php | 6 --- main/inc/lib/sortable_table.class.php | 19 +--------- main/lp/lp_view.lib.js | 13 ++++--- main/mySpace/slider.js | 24 ++++++------ .../src/AdvancedSubscriptionPlugin.php | 38 +++++++------------ src/Chamilo/CourseBundle/Entity/CDocument.php | 18 +++++++++ .../CourseBundle/Entity/CDropboxFile.php | 18 +++++++++ 9 files changed, 74 insertions(+), 76 deletions(-) diff --git a/main/inc/lib/add_course.lib.inc.php b/main/inc/lib/add_course.lib.inc.php index fbb585ef87..8d357be805 100755 --- a/main/inc/lib/add_course.lib.inc.php +++ b/main/inc/lib/add_course.lib.inc.php @@ -88,7 +88,7 @@ class AddCourse * @return int 0 * @assert (null,null) === false */ - public static function prepare_course_repository($course_repository, $course_code) + public static function prepare_course_repository($course_repository) { $perm = api_get_permissions_for_new_directories(); $perm_file = api_get_permissions_for_new_files(); @@ -369,15 +369,14 @@ class AddCourse /** * Sorts pictures by type (used?) * @param array List of files (sthg like array(0=>array('png'=>1))) - * @param string File type * @param string $type * @return array The received array without files not matching type * @assert (array(),null) === array() */ public static function sort_pictures($files, $type) { - $pictures = array(); - foreach ($files as $key => $value) { + $pictures = []; + foreach ($files as $value) { if (isset($value[$type]) && $value[$type] != '') { $pictures[][$type] = $value[$type]; } @@ -424,13 +423,8 @@ class AddCourse $TABLESETTING = Database::get_course_table(TABLE_COURSE_SETTING); $TABLEGRADEBOOK = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CATEGORY); $TABLEGRADEBOOKLINK = Database::get_main_table(TABLE_MAIN_GRADEBOOK_LINK); - - $visible_for_all = 1; $visible_for_course_admin = 0; - $visible_for_platform_admin = 2; - /* Course tools */ - Database::query( "INSERT INTO $tbl_course_homepage (c_id, id, name, link, image, visibility, admin, address, added_tool, target, category, session_id) VALUES ($course_id, 1, '".TOOL_COURSE_DESCRIPTION."','course_description/','info.gif','".self::string2binary( diff --git a/main/inc/lib/course.lib.php b/main/inc/lib/course.lib.php index 21d0675522..56fb20894c 100755 --- a/main/inc/lib/course.lib.php +++ b/main/inc/lib/course.lib.php @@ -6409,7 +6409,7 @@ class CourseManager { $authorId = empty($authorId) ? api_get_user_id() : (int) $authorId; - AddCourse::prepare_course_repository($courseInfo['directory'], $courseInfo['code']); + AddCourse::prepare_course_repository($courseInfo['directory']); AddCourse::fill_db_course( $courseInfo['real_id'], $courseInfo['directory'], diff --git a/main/inc/lib/formvalidator/Element/DateTimePicker.php b/main/inc/lib/formvalidator/Element/DateTimePicker.php index 70f99924c1..1b06e5b967 100755 --- a/main/inc/lib/formvalidator/Element/DateTimePicker.php +++ b/main/inc/lib/formvalidator/Element/DateTimePicker.php @@ -130,9 +130,7 @@ class DateTimePicker extends HTML_QuickForm_text public function getTemplate($layout) { $size = $this->getColumnsSize(); - $id = $this->getAttribute('id'); $value = $this->getValue(); - if (empty($size)) { $sizeTemp = $this->getInputSize(); if (empty($size)) { @@ -154,10 +152,6 @@ class DateTimePicker extends HTML_QuickForm_text } } - if (!empty($value)) { - $value = api_format_date($value, DATE_TIME_FORMAT_LONG_24H); - } - switch ($layout) { case FormValidator::LAYOUT_INLINE: return ' diff --git a/main/inc/lib/sortable_table.class.php b/main/inc/lib/sortable_table.class.php index b6236e2b74..efe96a9312 100755 --- a/main/inc/lib/sortable_table.class.php +++ b/main/inc/lib/sortable_table.class.php @@ -369,8 +369,6 @@ class SortableTable extends HTML_Table { $empty_table = false; if ($this->get_total_number_of_items() == 0) { - $cols = $this->getColCount(); - //$this->setCellAttributes(1, 0, 'style="font-style: italic;text-align:center;" colspan='.$cols); $message_empty = api_xml_http_response_encode(get_lang('TheListIsEmpty')); $this->setCellContents(1, 0, $message_empty); $empty_table = true; @@ -396,12 +394,9 @@ class SortableTable extends HTML_Table '; // @todo This also must be moved - // Show only navigations if there are more than 1 page $my_pager = $this->get_pager(); - $html .= '
'; - if ($my_pager->numPages() > 1) { $html .= '
'; $html .= '
'.$form.'
'; @@ -422,7 +417,6 @@ class SortableTable extends HTML_Table // Generation of style classes must be improved. Maybe we need a a table name to create style on the fly: // i.e: .whoisonline_table_grid_container instead of .grid_container // where whoisonline is the table's name like drupal's template engine - $html .= '
'; if (is_array($items) && count($items) > 0) { foreach ($items as & $row) { @@ -459,17 +453,12 @@ class SortableTable extends HTML_Table $grid_class = array() ) { $empty_table = false; - $total = $this->get_total_number_of_items(); - if ($this->get_total_number_of_items() == 0) { - $cols = $this->getColCount(); - //$this->setCellAttributes(1, 0, 'style="font-style: italic;text-align:center;" colspan='.$cols); $message_empty = api_xml_http_response_encode(get_lang('TheListIsEmpty')); $this->setCellContents(1, 0, $message_empty); $empty_table = true; } $html = ''; - if (!$empty_table) { // If we show the pagination if (!$hide_navigation) { @@ -640,9 +629,7 @@ class SortableTable extends HTML_Table $pager = $this->get_pager(); $offset = $pager->getOffsetByPageId(); $from = $offset[0] - 1; - $table_data = $this->get_table_data($from, null, null, null, $sort); - $new_table_data = array(); if (is_array($table_data)) { foreach ($table_data as $index => & $row) { @@ -740,6 +727,7 @@ class SortableTable extends HTML_Table $param['page_nr'] = $this->page_nr; $param['per_page'] = $this->per_page; $param['column'] = $column; + $link = $label; if ($sortable) { $link = '=0.1? 16 : 0; //extra height in px to add to iframe in FireFox 1.0+ browsers +var FFextraHeight = 32; +//parseFloat(getFFVersion)>=0.1? 16 : 0; //extra height in px to add to iframe in FireFox 1.0+ browsers function resizeIframe(frameid) { var currentfr=document.getElementById(frameid); @@ -54,8 +55,8 @@ function readjustIframe(loadevt) { } if (window.addEventListener) - window.addEventListener("load", resizeCaller, false); + window.addEventListener("load", resizeCaller, false); else if (window.attachEvent) - window.attachEvent("onload", resizeCaller); + window.attachEvent("onload", resizeCaller); else - window.onload=resizeCaller; \ No newline at end of file + window.onload = resizeCaller; \ No newline at end of file diff --git a/main/mySpace/slider.js b/main/mySpace/slider.js index 9ac1d83cb9..fb3c0879c9 100755 --- a/main/mySpace/slider.js +++ b/main/mySpace/slider.js @@ -1,17 +1,6 @@ // Set the initial height var sliderHeight = "80px"; -$(document).ready(function () { - // Show the slider content - $('.slider').show(); - $('.slider').each(function () { - var current = $(this); - current.attr("box_h", current.height()); - }); - - $(".slider").css("height", sliderHeight); -}); - // Set the initial slider state var slider_state = "close"; @@ -40,4 +29,15 @@ function sliderClose() { $(".slider").animate({"height": "0px"}, {duration: "fast" }); $(".slider").animate({"height": sliderHeight}, {duration: "fast" }); -} \ No newline at end of file +} + +$(document).ready(function () { + // Show the slider content + $('.slider').show(); + $('.slider').each(function () { + var current = $(this); + current.attr("box_h", current.height()); + }); + + $(".slider").css("height", sliderHeight); +}); \ No newline at end of file diff --git a/plugin/advanced_subscription/src/AdvancedSubscriptionPlugin.php b/plugin/advanced_subscription/src/AdvancedSubscriptionPlugin.php index 4746f03b81..f6451dc3cc 100644 --- a/plugin/advanced_subscription/src/AdvancedSubscriptionPlugin.php +++ b/plugin/advanced_subscription/src/AdvancedSubscriptionPlugin.php @@ -31,7 +31,6 @@ class AdvancedSubscriptionPlugin extends Plugin implements HookPluginInterface ); parent::__construct('1.0', 'Imanol Losada, Daniel Barreto', $parameters); - $this->errorMessages = array(); } @@ -80,7 +79,6 @@ class AdvancedSubscriptionPlugin extends Plugin implements HookPluginInterface { $extraField = new ExtraField('user'); $extraFieldHandler = $extraField->get_handler_field_info_by_field_variable('area'); - $areaExists = $extraFieldHandler !== false; if (!$areaExists) { @@ -127,7 +125,6 @@ class AdvancedSubscriptionPlugin extends Plugin implements HookPluginInterface { /* Drop plugin tables */ $advancedSubscriptionQueueTable = Database::get_main_table(TABLE_ADVANCED_SUBSCRIPTION_QUEUE); - $sql = "DROP TABLE IF EXISTS $advancedSubscriptionQueueTable; "; Database::query($sql); @@ -154,7 +151,7 @@ class AdvancedSubscriptionPlugin extends Plugin implements HookPluginInterface { $self = self::create(); $wsUrl = $self->get('ws_url'); - + $profileCompleted = 0; if (!empty($wsUrl)) { $client = new SoapClient( null, @@ -177,10 +174,7 @@ class AdvancedSubscriptionPlugin extends Plugin implements HookPluginInterface } } elseif (isset($params['profile_completed'])) { $profileCompleted = (float) $params['profile_completed']; - } else { - $profileCompleted = 0; } - $profileCompletedMin = (float) $self->get('min_profile_percentage'); if ($profileCompleted < $profileCompletedMin) { @@ -230,6 +224,7 @@ class AdvancedSubscriptionPlugin extends Plugin implements HookPluginInterface } $profileCompletedMin = (float) $plugin->get('min_profile_percentage'); + $profileCompleted = 0; if (is_string($wsUrl) && !empty($wsUrl)) { $options = array( @@ -245,8 +240,6 @@ class AdvancedSubscriptionPlugin extends Plugin implements HookPluginInterface } } elseif (isset($params['profile_completed'])) { $profileCompleted = (float) $params['profile_completed']; - } else { - $profileCompleted = 0; } if ($profileCompleted < $profileCompletedMin) { @@ -299,7 +292,6 @@ class AdvancedSubscriptionPlugin extends Plugin implements HookPluginInterface foreach ($sessions as $session) { $costField = $extra->get_values_by_handler_and_field_variable($session['id'], 'cost'); $userCost += $costField['value']; - $teachingHoursField = $extra->get_values_by_handler_and_field_variable($session['id'], 'teaching_hours'); $expendedTime += $teachingHoursField['value']; } @@ -433,7 +425,7 @@ class AdvancedSubscriptionPlugin extends Plugin implements HookPluginInterface */ public function startSubscription($userId, $sessionId, $params) { - $result = null; + $result = 'Params not found'; if (!empty($sessionId) && !empty($userId)) { $plugin = self::create(); try { @@ -445,10 +437,7 @@ class AdvancedSubscriptionPlugin extends Plugin implements HookPluginInterface } catch (Exception $e) { $result = $e->getMessage(); } - } else { - $result = 'Params not found'; } - return $result; } @@ -470,7 +459,7 @@ class AdvancedSubscriptionPlugin extends Plugin implements HookPluginInterface $content, $sessionId, $save = false, - $fileAttachments = array() + $fileAttachments = [] ) { if (!empty($fileAttachments) && is_array($fileAttachments) && @@ -547,8 +536,12 @@ class AdvancedSubscriptionPlugin extends Plugin implements HookPluginInterface * @param string $sessionFieldVariable * @return bool */ - public function isUserInTargetGroup($userId, $sessionId, $userFieldVariable = 'area', $sessionFieldVariable = 'target') - { + public function isUserInTargetGroup( + $userId, + $sessionId, + $userFieldVariable = 'area', + $sessionFieldVariable = 'target' + ) { $extraSessionFieldValue = new ExtraFieldValue('session'); $sessionTarget = $extraSessionFieldValue->get_values_by_handler_and_field_variable( $sessionId, @@ -582,6 +575,8 @@ class AdvancedSubscriptionPlugin extends Plugin implements HookPluginInterface public function updateQueueStatus($params, $newStatus) { $newStatus = intval($newStatus); + $res = false; + if (isset($params['queue']['id'])) { $where = array( 'id = ?' => intval($params['queue']['id']), @@ -605,8 +600,6 @@ class AdvancedSubscriptionPlugin extends Plugin implements HookPluginInterface ), $where ); - } else { - $res = false; } return $res; @@ -920,7 +913,6 @@ class AdvancedSubscriptionPlugin extends Plugin implements HookPluginInterface /** * This method will call the Hook management insertHook to add Hook observer from this plugin - * @return int */ public function installHook() { @@ -933,7 +925,6 @@ class AdvancedSubscriptionPlugin extends Plugin implements HookPluginInterface /** * This method will call the Hook management deleteHook to disable Hook observer from this plugin - * @return int */ public function uninstallHook() { @@ -1028,7 +1019,6 @@ class AdvancedSubscriptionPlugin extends Plugin implements HookPluginInterface 'brochure', 'banner', ); - $extraSession = new ExtraFieldValue('session'); $extraField = new ExtraField('session'); // Get session fields $fieldList = $extraField->get_all(array( @@ -1081,10 +1071,9 @@ class AdvancedSubscriptionPlugin extends Plugin implements HookPluginInterface { switch ($status) { case ADVANCED_SUBSCRIPTION_QUEUE_STATUS_NO_QUEUE: + $message = $this->get_lang('AdvancedSubscriptionNoQueue'); if ($isAble) { $message = $this->get_lang('AdvancedSubscriptionNoQueueIsAble'); - } else { - $message = $this->get_lang('AdvancedSubscriptionNoQueue'); } break; case ADVANCED_SUBSCRIPTION_QUEUE_STATUS_START: @@ -1486,5 +1475,4 @@ class AdvancedSubscriptionPlugin extends Plugin implements HookPluginInterface return $numberOfApproved; } - } diff --git a/src/Chamilo/CourseBundle/Entity/CDocument.php b/src/Chamilo/CourseBundle/Entity/CDocument.php index b2eee85298..4b22321335 100644 --- a/src/Chamilo/CourseBundle/Entity/CDocument.php +++ b/src/Chamilo/CourseBundle/Entity/CDocument.php @@ -296,4 +296,22 @@ class CDocument { return $this->cId; } + + /** + * @return int + */ + public function getIid() + { + return $this->iid; + } + + /** + * @param int $iid + * @return CDocument + */ + public function setIid($iid) + { + $this->iid = $iid; + return $this; + } } diff --git a/src/Chamilo/CourseBundle/Entity/CDropboxFile.php b/src/Chamilo/CourseBundle/Entity/CDropboxFile.php index 91f7b9cafb..bfb7869838 100644 --- a/src/Chamilo/CourseBundle/Entity/CDropboxFile.php +++ b/src/Chamilo/CourseBundle/Entity/CDropboxFile.php @@ -390,4 +390,22 @@ class CDropboxFile { return $this->cId; } + + /** + * @return int + */ + public function getIid() + { + return $this->iid; + } + + /** + * @param int $iid + * @return CDropboxFile + */ + public function setIid($iid) + { + $this->iid = $iid; + return $this; + } }