diff --git a/main/inc/lib/sessionmanager.lib.php b/main/inc/lib/sessionmanager.lib.php index fb2bea0b9a..081907f594 100755 --- a/main/inc/lib/sessionmanager.lib.php +++ b/main/inc/lib/sessionmanager.lib.php @@ -5442,10 +5442,10 @@ class SessionManager * Returns the list of session (name, short description, start date, end date) from category. * The short description is an extra field value * @param $categoryId + * @param $publicoObjetivo * @return mixed */ - public static function getSessionBriefListByCategory($categoryId) - { + public static function getSessionBriefListByCategory($categoryId, $publicoObjetivo) { $categoryId = (int) $categoryId; $sessionList = array(); if ($categoryId > 0) { @@ -5463,11 +5463,11 @@ class SessionManager ) ); $sessionFieldValueList = Database::select( - 'sfv.session_id AS id, sfv.field_value AS description', + 'sfv.session_id AS id, sfv.field_value AS description,', $joinTable, array( 'where' => array( - 'sf.field_variable = ?' => 'as_description' + 'sf.field_variable IN ( ? ) OR' => 'modalidad, duracion, cupos, horario, publico_objetivo', ) ) ); @@ -5475,9 +5475,20 @@ class SessionManager } foreach ($sessionList as $id => &$session) { - $session['description'] = isset($sessionFieldValueList[$id]) ? - $sessionFieldValueList[$id]['description'] : - ''; + if ($publicoObjetivo == $session['publico_objetivo']) { + $session['modalidad'] = isset($sessionFieldValueList[$id]) ? + $sessionFieldValueList[$id]['modalidad'] : + ''; + $session['duracion'] = isset($sessionFieldValueList[$id]) ? + $sessionFieldValueList[$id]['duracion'] : + ''; + $session['cupos'] = isset($sessionFieldValueList[$id]) ? + $sessionFieldValueList[$id]['cupos'] : + ''; + $session['horario'] = isset($sessionFieldValueList[$id]) ? + $sessionFieldValueList[$id]['horario'] : + ''; + } } return $sessionList; diff --git a/main/webservices/registration.soap.php b/main/webservices/registration.soap.php index 26f0497439..0937631d05 100755 --- a/main/webservices/registration.soap.php +++ b/main/webservices/registration.soap.php @@ -15,6 +15,7 @@ $debug = false; define('WS_ERROR_SECRET_KEY', 1); define('WS_ERROR_NOT_FOUND_RESULT', 2); define('WS_ERROR_INVALID_INPUT', 3); +define('WS_ERROR_SETTING', 4); function return_error($code) { @@ -22,13 +23,16 @@ function return_error($code) { switch ($code) { case WS_ERROR_SECRET_KEY: $fault = new soap_fault('Server', '', 'Secret key is not correct or params are not correctly set'); - break; + break; case WS_ERROR_NOT_FOUND_RESULT: $fault = new soap_fault('Server', '', 'Not found any result from the query'); - break; + break; case WS_ERROR_INVALID_INPUT: $fault = new soap_fault('Server', '', 'The input variables are invalid o are not correctly set'); - break; + break; + case WS_ERROR_SETTING: + $fault = new soap_fault('Server', '', 'Please check the configuration and installation for this webservice'); + break; } return $fault; } diff --git a/plugin/advancedsubscription/src/HookAdvancedSubscription.class.php b/plugin/advancedsubscription/src/HookAdvancedSubscription.class.php index a5a7f95bf8..693cbe0443 100644 --- a/plugin/advancedsubscription/src/HookAdvancedSubscription.class.php +++ b/plugin/advancedsubscription/src/HookAdvancedSubscription.class.php @@ -70,8 +70,12 @@ class HookAdvancedSubscription extends HookObserver implements array( 'name' => array('name' => 'name', 'type' => 'xsd:string'), //Course string code 'description' => array('name' => 'description', 'type' => 'xsd:string'), //Chamilo user_id + 'modality' => array('name' => 'start_date', 'type' => 'xsd:string'), 'date_start' => array('name' => 'start_date', 'type' => 'xsd:string'), 'date_end' => array('name' => 'end_date', 'type' => 'xsd:string'), + 'duration' => array('name' => 'date_end', 'type' => 'xsd:string'), + 'quota' => array('name' => 'quota', 'type' => 'xsd:string'), + 'schedule' => array('name' => 'schedule', 'type' => 'xsd:string'), ) ); @@ -97,8 +101,9 @@ class HookAdvancedSubscription extends HookObserver implements 'all', '', array( - 'id' => array('name' => 'id', 'type' => 'xsd:string'), //Course string code - 'name' => array('name' => 'name', 'type' => 'xsd:string'), //Chamilo user_id + 'id' => array('name' => 'id', 'type' => 'xsd:string'), // Course string code + 'name' => array('name' => 'name', 'type' => 'xsd:string'), // Chamilo user_id + 'target' => array('name' => 'target', 'type' => 'xsd:string'), // Publico objetivo 'secret_key' => array('name' => 'secret_key', 'type' => 'xsd:string') ) ); @@ -121,7 +126,7 @@ class HookAdvancedSubscription extends HookObserver implements 'urn:WSRegistration#WSAdvsubEncrypt', // soapaction 'rpc', // style 'encoded', // use - 'This service encrpyt data to be used later in urls' // documentation + 'This service encrypt data to be used later in urls' // documentation ); return $data; @@ -160,9 +165,14 @@ class HookAdvancedSubscription extends HookObserver implements // Get the session brief List by category - $sessionList = SessionManager::getSessionBriefListByCategory($sessionCategoryId); + $sessionList = SessionManager::getSessionBriefListByCategory($sessionCategoryId, $params['publico_objetivo']); - if (empty($sessionList)) { + $extraFieldSession = new ExtraFieldValue('session'); + $hasExtraField = $extraFieldSession->get_values_by_handler_and_field_variable(1, 'publico_objetivo'); + if ($hasExtraField != false) { + // Has session extra fields, Nothing to do + } else { + // No session extra fields return return_error(WS_ERROR_NOT_FOUND_RESULT); }