Browse Source

Add from and too see BT#10927

Julio 9 years ago
parent
commit
767d99cf54
2 changed files with 16 additions and 4 deletions
  1. 7 1
      main/inc/lib/sessionmanager.lib.php
  2. 9 3
      main/webservices/registration.soap.php

+ 7 - 1
main/inc/lib/sessionmanager.lib.php

@@ -2609,7 +2609,7 @@ class SessionManager
      * @return array An array with all sessions of the platform.
      * @todo   optional course code parameter, optional sorting parameters...
      */
-    public static function get_sessions_list($conditions = array(), $order_by = array())
+    public static function get_sessions_list($conditions = array(), $order_by = array(), $from = null, $to = null)
     {
         $session_table = Database::get_main_table(TABLE_MAIN_SESSION);
         $session_category_table = Database::get_main_table(TABLE_MAIN_SESSION_CATEGORY);
@@ -2679,6 +2679,12 @@ class SessionManager
             }
         }
 
+        if (!is_null($from) && !is_null($to)) {
+            $to = intval($to);
+            $from = intval($from);
+            $sql_query .= "LIMIT $from, $to";
+        }
+
         $sql_result = Database::query($sql_query);
         if (Database::num_rows($sql_result) > 0) {
             while ($result = Database::fetch_array($sql_result)) {

+ 9 - 3
main/webservices/registration.soap.php

@@ -5992,6 +5992,8 @@ $server->wsdl->addComplexType(
     'all',
     '',
     array(
+        'from'  => array('name' => 'from',  'type' => 'xsd:int'),
+        'to'    => array('name' => 'to',    'type' => 'xsd:int'),
         'date_start'  => array('name' => 'date_start',  'type' => 'xsd:string'),
         'date_end'    => array('name' => 'date_end',    'type' => 'xsd:string'),
         'secret_key'  => array('name' => 'secret_key',  'type' => 'xsd:string')
@@ -6048,8 +6050,9 @@ $server->register('WSListSessions',           // method name
  * @param array List of parameters (security key, date_start and date_end)
  * @return array Sessions list (id=>[title=>'title',url='http://...',date_start=>'...',date_end=>''])
  */
-function WSListSessions($params) {
-    if(!WSHelperVerifyKey($params)) {
+function WSListSessions($params)
+{
+    if (!WSHelperVerifyKey($params)) {
         return returnError(WS_ERROR_SECRET_KEY);
     }
     $sql_params = array();
@@ -6060,7 +6063,10 @@ function WSListSessions($params) {
     if (!empty($params['date_end'])) {
         $sql_params['s.access_end_date'] = array('operator' => '<=', 'value' => $params['date_end']);
     }
-    $sessions_list = SessionManager::get_sessions_list($sql_params);
+    $from = isset($params['from']) ? $params['from'] : null;
+    $to = isset($params['to']) ? $params['to'] : null;
+
+    $sessions_list = SessionManager::get_sessions_list($sql_params, null, $from, $to);
     $return_list = array();
     foreach ($sessions_list as $session) {
         $return_list[] = array(