From 9544603c8ffc6cbcf744f404934cd71f295ce7ec Mon Sep 17 00:00:00 2001 From: jmontoyaa Date: Tue, 29 Aug 2017 14:12:32 +0200 Subject: [PATCH] Minor - format code. --- main/exercise/question.class.php | 3 +- main/webservices/registration.soap.php | 89 ++++++++++++++----- .../src/buy_course_plugin.class.php | 68 +++++++++----- plugin/buycourses/src/buycourses.ajax.php | 44 ++++++--- 4 files changed, 146 insertions(+), 58 deletions(-) diff --git a/main/exercise/question.class.php b/main/exercise/question.class.php index 5ff0620576..8bff85dcee 100755 --- a/main/exercise/question.class.php +++ b/main/exercise/question.class.php @@ -607,8 +607,7 @@ abstract class Question // if we really change the type if ($type != $this->type) { // if we don't change from "unique answer" to "multiple answers" (or conversely) - if ( - !in_array($this->type, array(UNIQUE_ANSWER, MULTIPLE_ANSWER)) || + if (!in_array($this->type, array(UNIQUE_ANSWER, MULTIPLE_ANSWER)) || !in_array($type, array(UNIQUE_ANSWER, MULTIPLE_ANSWER)) ) { // removes old answers diff --git a/main/webservices/registration.soap.php b/main/webservices/registration.soap.php index 5e09295d4d..66d761430d 100755 --- a/main/webservices/registration.soap.php +++ b/main/webservices/registration.soap.php @@ -26,16 +26,32 @@ function returnError($code) $fault = null; switch ($code) { case WS_ERROR_SECRET_KEY: - $fault = new soap_fault('Server', '', 'Secret key is not correct or params are not correctly set'); + $fault = new soap_fault( + 'Server', + '', + 'Secret key is not correct or params are not correctly set' + ); break; case WS_ERROR_NOT_FOUND_RESULT: - $fault = new soap_fault('Server', '', 'No result was found for this query'); + $fault = new soap_fault( + 'Server', + '', + 'No result was found for this query' + ); break; case WS_ERROR_INVALID_INPUT: - $fault = new soap_fault('Server', '', 'The input variables are invalid o are not correctly set'); + $fault = new soap_fault( + 'Server', + '', + 'The input variables are invalid o are not correctly set' + ); break; case WS_ERROR_SETTING: - $fault = new soap_fault('Server', '', 'Please check the configuration for this webservice'); + $fault = new soap_fault( + 'Server', + '', + 'Please check the configuration for this webservice' + ); break; } return $fault; @@ -215,7 +231,10 @@ $server->wsdl->addComplexType( 'SOAP-ENC:Array', array(), array( - array('ref' => 'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:result_createUsers[]') + array( + 'ref' => 'SOAP-ENC:arrayType', + 'wsdl:arrayType' => 'tns:result_createUsers[]' + ) ), 'tns:result_createUsers' ); @@ -358,7 +377,10 @@ function WSCreateUsers($params) if ($userId) { if (api_is_multiple_url_enabled()) { if (api_get_current_access_url_id() != -1) { - UrlManager::add_user_to_url($userId, api_get_current_access_url_id()); + UrlManager::add_user_to_url( + $userId, + api_get_current_access_url_id() + ); } else { UrlManager::add_user_to_url($userId, 1); } @@ -465,7 +487,7 @@ $server->register('WSCreateUser', // method name // Define the method WSCreateUser function WSCreateUser($params) { - global $_user, $_configuration, $debug; + global $_user, $debug; if (!WSHelperVerifyKey($params)) { return returnError(WS_ERROR_SECRET_KEY); @@ -674,7 +696,12 @@ $server->wsdl->addComplexType( '', 'SOAP-ENC:Array', array(), - array(array('ref' => 'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:createUsersPassEncryptParams[]')), + array( + array( + 'ref' => 'SOAP-ENC:arrayType', + 'wsdl:arrayType' => 'tns:createUsersPassEncryptParams[]' + ) + ), 'tns:createUsersPassEncryptParams' ); @@ -687,8 +714,11 @@ $server->wsdl->addComplexType( 'all', '', array( - 'users' => array('name' => 'users', 'type' => 'tns:createUsersPassEncryptParamsList'), - 'secret_key' => array('name' => 'secret_key', 'type' => 'xsd:string') + 'users' => array( + 'name' => 'users', + 'type' => 'tns:createUsersPassEncryptParamsList' + ), + 'secret_key' => array('name' => 'secret_key', 'type' => 'xsd:string') ) ); @@ -700,7 +730,10 @@ $server->wsdl->addComplexType( 'all', '', array( - 'original_user_id_value' => array('name' => 'original_user_id_value', 'type' => 'xsd:string'), + 'original_user_id_value' => array( + 'name' => 'original_user_id_value', + 'type' => 'xsd:string' + ), 'result' => array('name' => 'result', 'type' => 'xsd:string') ) ); @@ -712,7 +745,12 @@ $server->wsdl->addComplexType( '', 'SOAP-ENC:Array', array(), - array(array('ref' => 'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:result_createUsersPassEncrypt[]')), + array( + array( + 'ref' => 'SOAP-ENC:arrayType', + 'wsdl:arrayType' => 'tns:result_createUsersPassEncrypt[]' + ) + ), 'tns:result_createUsersPassEncrypt' ); @@ -823,7 +861,8 @@ function WSCreateUsersPasswordCrypted($params) $count_row = Database::num_rows($res); if ($count_row > 0) { // Check if user is not active. - $sql = "SELECT user_id FROM $table_user WHERE user_id ='".$row[1]."' AND active= '0'"; + $sql = "SELECT user_id FROM $table_user + WHERE user_id ='".$row[1]."' AND active= '0'"; $resu = Database::query($sql); $r_check_user = Database::fetch_row($resu); $count_check_user = Database::num_rows($resu); @@ -913,7 +952,10 @@ function WSCreateUsersPasswordCrypted($params) if (api_is_multiple_url_enabled()) { if (api_get_current_access_url_id() != -1) { - UrlManager::add_user_to_url($return, api_get_current_access_url_id()); + UrlManager::add_user_to_url( + $return, + api_get_current_access_url_id() + ); } else { UrlManager::add_user_to_url($return, 1); } @@ -1286,9 +1328,7 @@ function WSCreateUserPasswordCrypted($params) $r_check_user = Database::fetch_row($resu); $count_check_user = Database::num_rows($resu); if ($count_check_user > 0) { - if ($debug) error_log('User id: '.$user_id.' exists and is NOT active. Updating user and setting setting active = 1'); - $sql = "UPDATE $table_user SET lastname='".Database::escape_string($lastName)."', firstname='".Database::escape_string($firstName)."', @@ -1570,7 +1610,10 @@ $server->wsdl->addComplexType( 'all', '', array( - 'original_user_id_value' => array('name' => 'original_user_id_value', 'type' => 'xsd:string'), + 'original_user_id_value' => array( + 'name' => 'original_user_id_value', + 'type' => 'xsd:string' + ), 'result' => array('name' => 'result', 'type' => 'xsd:string') ) ); @@ -1582,7 +1625,12 @@ $server->wsdl->addComplexType( '', 'SOAP-ENC:Array', array(), - array(array('ref' => 'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:result_editUsers[]')), + array( + array( + 'ref' => 'SOAP-ENC:arrayType', + 'wsdl:arrayType' => 'tns:result_editUsers[]' + ) + ), 'tns:result_editUsers' ); @@ -1673,17 +1721,12 @@ function WSEditUsers($params) if (!empty($lastname)) { $user->setLastname($lastname); - //$sql .= " lastname='".Database::escape_string($lastname)."', "; } if (!empty($firstname)) { $user->setFirstname($firstname); - //$sql .= " firstname='".Database::escape_string($firstname)."', "; } $user->setUsername($username); - //$sql .= " username='".Database::escape_string($username)."',"; if (!is_null($password)) { - //$password = $_configuration['password_encryption'] ? api_get_encrypted_password($password) : $password; - //$sql .= " password='".Database::escape_string($password)."',"; $user->setPlainPassword($password); } if (!is_null($auth_source)) { diff --git a/plugin/buycourses/src/buy_course_plugin.class.php b/plugin/buycourses/src/buy_course_plugin.class.php index a1e301942f..9bcfecf6d9 100644 --- a/plugin/buycourses/src/buy_course_plugin.class.php +++ b/plugin/buycourses/src/buy_course_plugin.class.php @@ -433,7 +433,10 @@ class BuyCoursesPlugin extends Plugin $currency = $this->getSelectedCurrency(); foreach ($courses as $course) { - $configurationCourses[] = $this->getCourseForConfiguration($course, $currency); + $configurationCourses[] = $this->getCourseForConfiguration( + $course, + $currency + ); } return $configurationCourses; @@ -527,7 +530,10 @@ class BuyCoursesPlugin extends Plugin continue; } - $item = $this->getItemByProduct($session->getId(), self::PRODUCT_TYPE_SESSION); + $item = $this->getItemByProduct( + $session->getId(), + self::PRODUCT_TYPE_SESSION + ); if (empty($item)) { continue; @@ -535,7 +541,10 @@ class BuyCoursesPlugin extends Plugin $sessionData = $this->getSessionInfo($session->getId()); $sessionData['coach'] = $session->getGeneralCoach()->getCompleteName(); - $sessionData['enrolled'] = $this->getUserStatusForSession(api_get_user_id(), $session); + $sessionData['enrolled'] = $this->getUserStatusForSession( + api_get_user_id(), + $session + ); $sessionData['courses'] = array(); foreach ($sessionCourses as $sessionCourse) { @@ -580,7 +589,6 @@ class BuyCoursesPlugin extends Plugin $entityManager = Database::getManager(); $cuRepo = $entityManager->getRepository('ChamiloCoreBundle:CourseRelUser'); - $buySaleTable = Database::get_main_table(self::TABLE_SALE); // Check if user bought the course @@ -688,7 +696,10 @@ class BuyCoursesPlugin extends Plugin return []; } - $item = $this->getItemByProduct($course->getId(), self::PRODUCT_TYPE_COURSE); + $item = $this->getItemByProduct( + $course->getId(), + self::PRODUCT_TYPE_COURSE + ); if (empty($item)) { return []; @@ -737,7 +748,10 @@ class BuyCoursesPlugin extends Plugin return []; } - $item = $this->getItemByProduct($session->getId(), self::PRODUCT_TYPE_SESSION); + $item = $this->getItemByProduct( + $session->getId(), + self::PRODUCT_TYPE_SESSION + ); if (empty($item)) { return []; @@ -827,7 +841,6 @@ class BuyCoursesPlugin extends Plugin $paymentType, [self::PAYMENT_TYPE_PAYPAL, self::PAYMENT_TYPE_TRANSFER, self::PAYMENT_TYPE_CULQI]) ) { - return false; } @@ -972,7 +985,6 @@ class BuyCoursesPlugin extends Plugin } $saleIsCompleted = false; - switch ($sale['product_type']) { case self::PRODUCT_TYPE_COURSE: $course = api_get_course_info_by_id($sale['product_id']); @@ -1148,7 +1160,10 @@ class BuyCoursesPlugin extends Plugin $sessions = []; foreach ($sessionIds as $sessionId) { - $sessions[] = Database::getManager()->find('ChamiloCoreBundle:Session', $sessionId); + $sessions[] = Database::getManager()->find( + 'ChamiloCoreBundle:Session', + $sessionId + ); } return $sessions; @@ -1211,7 +1226,10 @@ class BuyCoursesPlugin extends Plugin $courses = []; foreach ($courseIds as $courseId) { - $courses[] = Database::getManager()->find('ChamiloCoreBundle:Course', $courseId); + $courses[] = Database::getManager()->find( + 'ChamiloCoreBundle:Course', + $courseId + ); } return $courses; @@ -1282,7 +1300,6 @@ class BuyCoursesPlugin extends Plugin $saleTable = Database::get_main_table(self::TABLE_SALE); $currencyTable = Database::get_main_table(self::TABLE_CURRENCY); $userTable = Database::get_main_table(TABLE_MAIN_USER); - $innerJoins = " INNER JOIN $currencyTable c ON s.currency_id = c.id INNER JOIN $userTable u ON s.user_id = u.id @@ -1583,8 +1600,11 @@ class BuyCoursesPlugin extends Plugin * @param int $userId * @return array */ - public function getPayouts($status = self::PAYOUT_STATUS_PENDING, $payoutId = false, $userId = false) - { + public function getPayouts( + $status = self::PAYOUT_STATUS_PENDING, + $payoutId = false, + $userId = false + ) { $condition = ($payoutId) ? 'AND p.id = '.intval($payoutId) : ''; $condition2 = ($userId) ? ' AND p.user_id = '.intval($userId) : ''; $typeResult = ($condition) ? 'first' : 'all'; @@ -1688,7 +1708,6 @@ class BuyCoursesPlugin extends Plugin 2 ); - $beneficiaries = $this->getBeneficiariesBySale($saleId); foreach ($beneficiaries as $beneficiary) { Database::insert( @@ -1780,8 +1799,8 @@ class BuyCoursesPlugin extends Plugin ] ); - if ($return && !empty($service['picture_crop_image_base_64']) - && !empty($service['picture_crop_result']) + if ($return && !empty($service['picture_crop_image_base_64']) && + !empty($service['picture_crop_result']) ) { $img = str_replace('data:image/png;base64,', '', $service['picture_crop_image_base_64']); $img = str_replace(' ', '+', $img); @@ -2096,7 +2115,10 @@ class BuyCoursesPlugin extends Plugin */ public function cancelServiceSale($serviceSaleId) { - $this->updateServiceSaleStatus($serviceSaleId, self::SERVICE_STATUS_CANCELLED); + $this->updateServiceSaleStatus( + $serviceSaleId, + self::SERVICE_STATUS_CANCELLED + ); return true; } @@ -2113,7 +2135,10 @@ class BuyCoursesPlugin extends Plugin return true; } - $this->updateServiceSaleStatus($serviceSaleId, self::SERVICE_STATUS_COMPLETED); + $this->updateServiceSaleStatus( + $serviceSaleId, + self::SERVICE_STATUS_COMPLETED + ); return true; } @@ -2189,8 +2214,10 @@ class BuyCoursesPlugin extends Plugin * @param int $newStatus The new status * @return boolean */ - private function updateServiceSaleStatus($serviceSaleId, $newStatus = self::SERVICE_STATUS_PENDING) - { + private function updateServiceSaleStatus( + $serviceSaleId, + $newStatus = self::SERVICE_STATUS_PENDING + ) { $serviceSaleTable = Database::get_main_table(self::TABLE_SERVICES_SALE); return Database::update( @@ -2214,7 +2241,6 @@ class BuyCoursesPlugin extends Plugin $paymentType, [self::PAYMENT_TYPE_PAYPAL, self::PAYMENT_TYPE_TRANSFER, self::PAYMENT_TYPE_CULQI]) ) { - return false; } diff --git a/plugin/buycourses/src/buycourses.ajax.php b/plugin/buycourses/src/buycourses.ajax.php index c8cb1837f6..d2d99d22aa 100644 --- a/plugin/buycourses/src/buycourses.ajax.php +++ b/plugin/buycourses/src/buycourses.ajax.php @@ -1,16 +1,16 @@ '.$plugin->get_lang('OrderPrice').': '.$sale['price'].''; $html .= '
  • '.$plugin->get_lang('CurrencyType').': '.$currency['iso_code'].'
  • '; $html .= '
  • '.$plugin->get_lang('ProductType').': '.$productType.'
  • '; - $html .= '
  • '.$plugin->get_lang('OrderDate').': '.api_format_date($sale['date'], - DATE_TIME_FORMAT_LONG_24H).'
  • '; + $html .= '
  • '.$plugin->get_lang('OrderDate').': '. + api_format_date( + $sale['date'], + DATE_TIME_FORMAT_LONG_24H + ).'
  • '; $html .= '
  • '.$plugin->get_lang('Buyer').': '.$userInfo['complete_name'].'
  • '; $html .= '
  • '.$plugin->get_lang('PaymentMethods').': '.$paymentType.'
  • '; $html .= ''; @@ -208,12 +211,19 @@ switch ($action) { $payouts = isset($_POST['payouts']) ? $_POST['payouts'] : ''; if (!$payouts) { - echo Display::return_message(get_plugin_lang("SelectOptionToProceed", "BuyCoursesPlugin"), 'error', false); + echo Display::return_message( + get_plugin_lang("SelectOptionToProceed", "BuyCoursesPlugin"), + 'error', + false + ); break; } foreach ($payouts as $index => $id) { - $allPayouts[] = $plugin->getPayouts(BuyCoursesPlugin::PAYOUT_STATUS_PENDING, $id); + $allPayouts[] = $plugin->getPayouts( + BuyCoursesPlugin::PAYOUT_STATUS_PENDING, + $id + ); } $currentCurrency = $plugin->getSelectedCurrency(); @@ -221,10 +231,17 @@ switch ($action) { $result = MassPayment($allPayouts, $isoCode); if ($result['ACK'] === 'Success') { foreach ($allPayouts as $payout) { - $plugin->setStatusPayouts($payout['id'], BuyCoursesPlugin::PAYOUT_STATUS_COMPLETED); + $plugin->setStatusPayouts( + $payout['id'], + BuyCoursesPlugin::PAYOUT_STATUS_COMPLETED + ); } - echo Display::return_message(get_plugin_lang("PayoutSuccess", "BuyCoursesPlugin"), 'success', false); + echo Display::return_message( + get_plugin_lang("PayoutSuccess", "BuyCoursesPlugin"), + 'success', + false + ); } else { echo Display::return_message( ''.$result['L_SEVERITYCODE0'].' '.$result['L_ERRORCODE0'].' - '.$result['L_SHORTMESSAGE0'] @@ -243,7 +260,10 @@ switch ($action) { // $payoutId only gets used in setStatusPayout(), where it is filtered $payoutId = isset($_POST['id']) ? $_POST['id'] : ''; - $plugin->setStatusPayouts($payoutId, BuyCoursesPlugin::PAYOUT_STATUS_CANCELED); + $plugin->setStatusPayouts( + $payoutId, + BuyCoursesPlugin::PAYOUT_STATUS_CANCELED + ); echo '';