Minor - format code

pull/2487/head
jmontoyaa 8 years ago
parent d76c2ead15
commit acdda13b77
  1. 145
      main/webservices/cm_soap.php
  2. 56
      main/webservices/cm_soap_announcements.php
  3. 423
      main/webservices/cm_soap_course.php
  4. 50
      main/webservices/cm_soap_courses.php
  5. 218
      main/webservices/cm_soap_forum.php
  6. 158
      main/webservices/cm_soap_inbox.php
  7. 148
      main/webservices/cm_soap_user.php
  8. 1089
      main/webservices/cm_webservice_course.php
  9. 13
      main/webservices/cm_webservice_courses.php
  10. 138
      main/webservices/cm_webservice_forum.php
  11. 82
      main/webservices/cm_webservice_inbox.php
  12. 44
      main/webservices/cm_webservice_user.php
  13. 89
      main/webservices/courses_list.rest.php
  14. 74
      main/webservices/courses_list.soap.php

@ -10,101 +10,106 @@ $libpath = api_get_path(LIBRARY_PATH);
/**
* SOAP error handler. Handles an error sending a SOAP fault
*/
class WSCMSoapErrorHandler implements WSCMErrorHandler {
/**
* Handles the error by sending a SOAP fault through the server
*
* @param WSError Error to handle
*/
public function handle($error) {
$server = WSCMSoapServer::singleton();
$server->fault(strval($error->code), $error->message);
}
class WSCMSoapErrorHandler implements WSCMErrorHandler
{
/**
* Handles the error by sending a SOAP fault through the server
*
* @param WSError Error to handle
*/
public function handle($error)
{
$server = WSCMSoapServer::singleton();
$server->fault(strval($error->code), $error->message);
}
}
/**
* SOAP server wrapper implementing a Singleton
*/
class WSCMSoapServer {
/**
* SOAP server instance
*
* @var soap_server
*/
private static $_instance;
class WSCMSoapServer
{
/**
* SOAP server instance
*
* @var soap_server
*/
private static $_instance;
/**
* Private constructor
*/
private function __construct() {
}
/**
* Private constructor
*/
public function __construct()
{
}
/**
* Singleton method
*/
public static function singleton() {
if (!isset(self::$_instance)) {
self::$_instance = new soap_server();
// Set the error handler
WSCMError::setErrorHandler(new WSCMSoapErrorHandler());
// Configure the service
self::$_instance->configureWSDL('WSCMService', 'urn:WSCMService');
}
/**
* Singleton method
*/
public static function singleton()
{
if (!isset(self::$_instance)) {
self::$_instance = new soap_server();
// Set the error handler
WSCMError::setErrorHandler(new WSCMSoapErrorHandler());
// Configure the service
self::$_instance->configureWSDL('WSCMService', 'urn:WSCMService');
}
return self::$_instance;
}
return self::$_instance;
}
}
$s = WSCMSoapServer::singleton();
$s->wsdl->addComplexType(
'result',
'complexType',
'struct',
'all',
'',
array(
'code' => array('name' => 'code', 'type' => 'xsd:int'),
'message' => array('name' => 'message', 'type' => 'xsd:string')
)
'result',
'complexType',
'struct',
'all',
'',
array(
'code' => array('name' => 'code', 'type' => 'xsd:int'),
'message' => array('name' => 'message', 'type' => 'xsd:string')
)
);
$s->wsdl->addComplexType(
'extra_field',
'complexType',
'struct',
'all',
'',
array(
'field_name' => array('name' => 'field_name', 'type' => 'xsd:string'),
'field_value' => array('name' => 'field_value', 'type' => 'xsd:string')
)
'extra_field',
'complexType',
'struct',
'all',
'',
array(
'field_name' => array('name' => 'field_name', 'type' => 'xsd:string'),
'field_value' => array('name' => 'field_value', 'type' => 'xsd:string')
)
);
$s->register(
'WSCM.verifyUserPass',
array(
'username' => 'xsd:string',
'password' => 'xsd:string',
),
array('return' => 'xsd:string')
'WSCM.verifyUserPass',
array(
'username' => 'xsd:string',
'password' => 'xsd:string',
),
array('return' => 'xsd:string')
);
$s->register(
'WSCM.encryptPass',
array('password' => 'xsd:string'),
array('return' => 'xsd:string')
'WSCM.encryptPass',
array('password' => 'xsd:string'),
array('return' => 'xsd:string')
);
$s->register(
'WSCM.test',
array(),
array('return' => 'xsd:string'),
'urn:WSCMService',
'',
'',
'',
''
'WSCM.test',
array(),
array('return' => 'xsd:string'),
'urn:WSCMService',
'',
'',
'',
''
);
require_once __DIR__.'/cm_soap_inbox.php';

@ -12,39 +12,37 @@ require_once __DIR__.'/cm_soap.php';
*/
$s = WSCMSoapServer::singleton();
$s->register(
'WSCMAnnouncements.get_announcements_id',
array(
'username' => 'xsd:string',
'password' => 'xsd:string',
'course_code' => 'xsd:string'
),
array('return' => 'xsd:string'),
'urn:WSCMService',
'',
'',
'',
'Retorna o ID dos anuncios visiveis a um usuario de uma disciplina.'
'WSCMAnnouncements.get_announcements_id',
array(
'username' => 'xsd:string',
'password' => 'xsd:string',
'course_code' => 'xsd:string',
),
array('return' => 'xsd:string'),
'urn:WSCMService',
'',
'',
'',
'Retorna o ID dos anuncios visiveis a um usuario de uma disciplina.'
);
$s->register(
'WSCMAnnouncements.get_announcement_data',
array(
'username' => 'xsd:string',
'password' => 'xsd:string',
'course_code' => 'xsd:string',
'announcement_id' => 'xsd:string',
'field' => 'xsd:string'
),
array('return' => 'xsd:string'),
'urn:WSCMService',
'',
'',
'',
'Retorna o conteudo do campo informado de um anuncio de chave ID. Campos retornaveis: sender, date, title e content'
'WSCMAnnouncements.get_announcement_data',
array(
'username' => 'xsd:string',
'password' => 'xsd:string',
'course_code' => 'xsd:string',
'announcement_id' => 'xsd:string',
'field' => 'xsd:string',
),
array('return' => 'xsd:string'),
'urn:WSCMService',
'',
'',
'',
'Retorna o conteudo do campo informado de um anuncio de chave ID. Campos retornaveis: sender, date, title e content'
);

@ -13,283 +13,278 @@ require_once __DIR__.'/cm_soap.php';
$s = WSCMSoapServer::singleton();
$s->wsdl->addComplexType(
'course_id',
'complexType',
'struct',
'all',
'',
array(
'course_id_field_name' => array('name' => 'course_id_field_name', 'type' => 'xsd:string'),
'course_id_value' => array('name' => 'course_id_value', 'type' => 'xsd:string')
)
'course_id',
'complexType',
'struct',
'all',
'',
array(
'course_id_field_name' => array('name' => 'course_id_field_name', 'type' => 'xsd:string'),
'course_id_value' => array('name' => 'course_id_value', 'type' => 'xsd:string')
)
);
$s->wsdl->addComplexType(
'course_result',
'complexType',
'struct',
'all',
'',
array(
'course_id_value' => array('name' => 'course_id_value', 'type' => 'xsd:string'),
'result' => array('name' => 'result', 'type' => 'tns:result')
)
'course_result',
'complexType',
'struct',
'all',
'',
array(
'course_id_value' => array('name' => 'course_id_value', 'type' => 'xsd:string'),
'result' => array('name' => 'result', 'type' => 'tns:result')
)
);
$s->wsdl->addComplexType(
'course_result_array',
'complexType',
'array',
'',
'SOAP-ENC:Array',
array(),
array(array('ref'=>'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:course_result[]')),
'tns:course_result'
'course_result_array',
'complexType',
'array',
'',
'SOAP-ENC:Array',
array(),
array(array('ref'=>'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:course_result[]')),
'tns:course_result'
);
$s->register(
'WSCMCourse.DeleteCourse',
array('secret_key' => 'xsd:string', 'course_id_field_name' => 'xsd:string', 'course_id_value' => 'xsd:string')
'WSCMCourse.DeleteCourse',
array('secret_key' => 'xsd:string', 'course_id_field_name' => 'xsd:string', 'course_id_value' => 'xsd:string')
);
$s->register(
'WSCMCourse.DeleteCourses',
array('secret_key' => 'xsd:string', 'courses' => 'tns:course_id[]'),
array('return' => 'tns:course_result_array')
'WSCMCourse.DeleteCourses',
array('secret_key' => 'xsd:string', 'courses' => 'tns:course_id[]'),
array('return' => 'tns:course_result_array')
);
$s->register(
'WSCMCourse.CreateCourse',
array(
'secret_key' => 'xsd:string',
'title' => 'xsd:string',
'category_code' => 'xsd:string',
'wanted_code' => 'xsd:string',
'tutor_name' => 'xsd:string',
'course_admin_user_id_field_name' => 'xsd:string',
'course_admin_user_id_value' => 'xsd:string',
'language' => 'xsd:string',
'course_id_field_name' => 'xsd:string',
'course_id_value' => 'xsd:string',
'extras' => 'tns:extra_field[]'
),
array('return' => 'xsd:int')
'WSCMCourse.CreateCourse',
array(
'secret_key' => 'xsd:string',
'title' => 'xsd:string',
'category_code' => 'xsd:string',
'wanted_code' => 'xsd:string',
'tutor_name' => 'xsd:string',
'course_admin_user_id_field_name' => 'xsd:string',
'course_admin_user_id_value' => 'xsd:string',
'language' => 'xsd:string',
'course_id_field_name' => 'xsd:string',
'course_id_value' => 'xsd:string',
'extras' => 'tns:extra_field[]'
),
array('return' => 'xsd:int')
);
$s->wsdl->addComplexType(
'course_create',
'complexType',
'struct',
'all',
'',
array(
'title' => array('name' => 'title', 'type' => 'xsd:string'),
'category_code' => array('name' => 'category_code', 'type' => 'xsd:string'),
'wanted_code' => array('name' => 'wanted_code', 'type' => 'xsd:int'),
'tutor_name' => array('name' => 'tutor_name', 'type' => 'xsd:string'),
'course_admin_user_id_field_name' => array('name' => 'course_admin_user_id_field_name', 'type' => 'xsd:string'),
'course_admin_user_id_value' => array('name' => 'course_admin_user_id_value', 'type' => 'xsd:string'),
'language' => array('name' => 'language', 'type' => 'xsd:string'),
'course_id_field_name' => array('name' => 'course_id_field_name', 'type' => 'xsd:string'),
'course_id_value' => array('name' => 'course_id_value', 'type' => 'xsd:string'),
'extras' => array('name' => 'extras', 'type' => 'tns:extra_field[]')
)
'course_create',
'complexType',
'struct',
'all',
'',
array(
'title' => array('name' => 'title', 'type' => 'xsd:string'),
'category_code' => array('name' => 'category_code', 'type' => 'xsd:string'),
'wanted_code' => array('name' => 'wanted_code', 'type' => 'xsd:int'),
'tutor_name' => array('name' => 'tutor_name', 'type' => 'xsd:string'),
'course_admin_user_id_field_name' => array('name' => 'course_admin_user_id_field_name', 'type' => 'xsd:string'),
'course_admin_user_id_value' => array('name' => 'course_admin_user_id_value', 'type' => 'xsd:string'),
'language' => array('name' => 'language', 'type' => 'xsd:string'),
'course_id_field_name' => array('name' => 'course_id_field_name', 'type' => 'xsd:string'),
'course_id_value' => array('name' => 'course_id_value', 'type' => 'xsd:string'),
'extras' => array('name' => 'extras', 'type' => 'tns:extra_field[]')
)
);
$s->wsdl->addComplexType(
'course_create_result',
'complexType',
'struct',
'all',
'',
array(
'course_id_value' => array('name' => 'course_id_value', 'type' => 'xsd:string'),
'course_id_generated' => array('name' => 'course_id_generated', 'type' => 'xsd:int'),
'result' => array('name' => 'result', 'type' => 'tns:result')
)
'course_create_result',
'complexType',
'struct',
'all',
'',
array(
'course_id_value' => array('name' => 'course_id_value', 'type' => 'xsd:string'),
'course_id_generated' => array('name' => 'course_id_generated', 'type' => 'xsd:int'),
'result' => array('name' => 'result', 'type' => 'tns:result')
)
);
$s->wsdl->addComplexType(
'course_create_result_array',
'complexType',
'array',
'',
'SOAP-ENC:Array',
array(),
array(array('ref'=>'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:course_create_result[]')),
'tns:course_create_result'
'course_create_result_array',
'complexType',
'array',
'',
'SOAP-ENC:Array',
array(),
array(array('ref'=>'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:course_create_result[]')),
'tns:course_create_result'
);
$s->register(
'WSCMCourse.CreateCourses',
array(
'secret_key' => 'xsd:string',
'courses' => 'tns:course_create[]'
),
array('return' => 'tns:course_create_result_array')
'WSCMCourse.CreateCourses',
array(
'secret_key' => 'xsd:string',
'courses' => 'tns:course_create[]'
),
array('return' => 'tns:course_create_result_array')
);
$s->register(
'WSCMCourse.EditCourse',
array(
'secret_key' => 'xsd:string',
'course_id_field_name' => 'xsd:string',
'course_id_value' => 'xsd:string',
'title' => 'xsd:string',
'category_code' => 'xsd:string',
'department_name' => 'xsd:string',
'department_url' => 'xsd:string',
'language' => 'xsd:string',
'visibility' => 'xsd:int',
'subscribe' => 'xsd:int',
'unsubscribe' => 'xsd:int',
'visual_code' => 'xsd:string',
'extras' => 'tns:extra_field[]'
)
'WSCMCourse.EditCourse',
array(
'secret_key' => 'xsd:string',
'course_id_field_name' => 'xsd:string',
'course_id_value' => 'xsd:string',
'title' => 'xsd:string',
'category_code' => 'xsd:string',
'department_name' => 'xsd:string',
'department_url' => 'xsd:string',
'language' => 'xsd:string',
'visibility' => 'xsd:int',
'subscribe' => 'xsd:int',
'unsubscribe' => 'xsd:int',
'visual_code' => 'xsd:string',
'extras' => 'tns:extra_field[]'
)
);
$s->wsdl->addComplexType(
'course',
'complexType',
'struct',
'all',
'',
array(
'id' => array('name' => 'id', 'type' => 'xsd:int'),
'code' => array('name' => 'code', 'type' => 'xsd:string'),
'title' => array('name' => 'title', 'type' => 'xsd:string'),
'language' => array('name' => 'language', 'type' => 'xsd:string'),
'visibility' => array('name' => 'visibility', 'type' => 'xsd:int'),
'category_name' => array('name' => 'category_name', 'type' => 'xsd:string'),
'number_students' => array('name' => 'number_students', 'type' => 'xsd:int'),
'external_course_id' => array('name' => 'external_course_id', 'type' => 'xsd:string'),
)
'course',
'complexType',
'struct',
'all',
'',
array(
'id' => array('name' => 'id', 'type' => 'xsd:int'),
'code' => array('name' => 'code', 'type' => 'xsd:string'),
'title' => array('name' => 'title', 'type' => 'xsd:string'),
'language' => array('name' => 'language', 'type' => 'xsd:string'),
'visibility' => array('name' => 'visibility', 'type' => 'xsd:int'),
'category_name' => array('name' => 'category_name', 'type' => 'xsd:string'),
'number_students' => array('name' => 'number_students', 'type' => 'xsd:int'),
'external_course_id' => array('name' => 'external_course_id', 'type' => 'xsd:string'),
)
);
$s->wsdl->addComplexType(
'course_array',
'complexType',
'array',
'',
'SOAP-ENC:Array',
array(),
array(array('ref'=>'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:course[]')),
'tns:course'
'course_array',
'complexType',
'array',
'',
'SOAP-ENC:Array',
array(),
array(array('ref'=>'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:course[]')),
'tns:course'
);
$s->register(
'WSCMCourse.ListCourses',
array(
'secret_key' => 'xsd:string',
'course_id_field_name' => 'xsd:string'
),
array('return' => 'tns:course_array')
'WSCMCourse.ListCourses',
array(
'secret_key' => 'xsd:string',
'course_id_field_name' => 'xsd:string'
),
array('return' => 'tns:course_array')
);
$s->register(
'WSCMCourse.SubscribeUserToCourse',
array(
'secret_key' => 'xsd:string',
'course_id_field_name' => 'xsd:string',
'course_id_value' => 'xsd:string',
'user_id_field_name' => 'xsd:string',
'user_id_value' => 'xsd:string',
'status' => 'xsd:int'
)
'WSCMCourse.SubscribeUserToCourse',
array(
'secret_key' => 'xsd:string',
'course_id_field_name' => 'xsd:string',
'course_id_value' => 'xsd:string',
'user_id_field_name' => 'xsd:string',
'user_id_value' => 'xsd:string',
'status' => 'xsd:int'
)
);
$s->register(
'WSCMCourse.UnsubscribeUserFromCourse',
array(
'secret_key' => 'xsd:string',
'course_id_field_name' => 'xsd:string',
'course_id_value' => 'xsd:string',
'user_id_field_name' => 'xsd:string',
'user_id_value' => 'xsd:string'
)
'WSCMCourse.UnsubscribeUserFromCourse',
array(
'secret_key' => 'xsd:string',
'course_id_field_name' => 'xsd:string',
'course_id_value' => 'xsd:string',
'user_id_field_name' => 'xsd:string',
'user_id_value' => 'xsd:string'
)
);
$s->wsdl->addComplexType(
'course_description',
'complexType',
'struct',
'all',
'',
array(
'course_desc_id' => array('name' => 'course_desc_id', 'type' => 'xsd:int'),
'course_desc_title' => array('name' => 'course_desc_title', 'type' => 'xsd:string'),
'course_desc_content' => array('name' => 'course_desc_content', 'type' => 'xsd:string')
)
'course_description',
'complexType',
'struct',
'all',
'',
array(
'course_desc_id' => array('name' => 'course_desc_id', 'type' => 'xsd:int'),
'course_desc_title' => array('name' => 'course_desc_title', 'type' => 'xsd:string'),
'course_desc_content' => array('name' => 'course_desc_content', 'type' => 'xsd:string')
)
);
$s->wsdl->addComplexType(
'course_description_array',
'complexType',
'array',
'',
'SOAP-ENC:Array',
array(),
array(array('ref'=>'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:course_description[]')),
'tns:course_description'
'course_description_array',
'complexType',
'array',
'',
'SOAP-ENC:Array',
array(),
array(array('ref'=>'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:course_description[]')),
'tns:course_description'
);
$s->register(
'WSCMCourse.GetCourseDescriptions',
array(
'secret_key' => 'xsd:string',
'course_id_field_name' => 'xsd:string',
'course_id_value' => 'xsd:string'
),
array('return' => 'tns:course_description_array')
'WSCMCourse.GetCourseDescriptions',
array(
'secret_key' => 'xsd:string',
'course_id_field_name' => 'xsd:string',
'course_id_value' => 'xsd:string'
),
array('return' => 'tns:course_description_array')
);
$s->register(
'WSCMCourse.EditCourseDescription',
array(
'secret_key' => 'xsd:string',
'course_id_field_name' => 'xsd:string',
'course_id_value' => 'xsd:string',
'course_desc_id' => 'xsd:int',
'course_desc_title' => 'xsd:string',
'course_desc_content' => 'xsd:string'
)
'WSCMCourse.EditCourseDescription',
array(
'secret_key' => 'xsd:string',
'course_id_field_name' => 'xsd:string',
'course_id_value' => 'xsd:string',
'course_desc_id' => 'xsd:int',
'course_desc_title' => 'xsd:string',
'course_desc_content' => 'xsd:string'
)
);
$s->register(
'WSCMCourse.unreadMessage',
array(
'username' => 'xsd:string',
'password' => 'xsd:string',
),
array('return' => 'xsd:string'),
'urn:WSCMService',
'',
'',
'',
'Retorna a quantidade de mensagens nao lidas na caixa de entrada do usuario.'
'WSCMCourse.unreadMessage',
array(
'username' => 'xsd:string',
'password' => 'xsd:string',
),
array('return' => 'xsd:string'),
'urn:WSCMService',
'',
'',
'',
'Retorna a quantidade de mensagens nao lidas na caixa de entrada do usuario.'
);
$s->register(
'WSCMCourse.getIdMessage',
array(
'username' => 'xsd:string',
'password' => 'xsd:string',
),
array('return' => 'xsd:string'),
'urn:WSCMService',
'',
'',
'',
'Retorna o ID das mensagens.'
'WSCMCourse.getIdMessage',
array(
'username' => 'xsd:string',
'password' => 'xsd:string',
),
array('return' => 'xsd:string'),
'urn:WSCMService',
'',
'',
'',
'Retorna o ID das mensagens.'
);
$s->register(
'WSCMCourse.nada',
array('username' => 'xsd:string', 'password' => 'xsd:string'),
array('return' => 'xsd:string')
);
'WSCMCourse.nada',
array('username' => 'xsd:string', 'password' => 'xsd:string'),
array('return' => 'xsd:string')
);

@ -12,36 +12,34 @@ require_once __DIR__.'/cm_soap.php';
*/
$s = WSCMSoapServer::singleton();
$s->register(
'WSCMCourses.get_courses_code',
array(
'username' => 'xsd:string',
'password' => 'xsd:string'
),
array('return' => 'xsd:string'),
'urn:WSCMService',
'',
'',
'',
'Retorna o CODE dos cursos do username.'
'WSCMCourses.get_courses_code',
array(
'username' => 'xsd:string',
'password' => 'xsd:string',
),
array('return' => 'xsd:string'),
'urn:WSCMService',
'',
'',
'',
'Retorna o CODE dos cursos do username.'
);
$s->register(
'WSCMCourses.get_course_title',
array(
'username' => 'xsd:string',
'password' => 'xsd:string',
'course_code' => 'xsd:string',
),
array('return' => 'xsd:string'),
'urn:WSCMService',
'',
'',
'',
'Retorna o titulo/nome do curso de course_code informado'
'WSCMCourses.get_course_title',
array(
'username' => 'xsd:string',
'password' => 'xsd:string',
'course_code' => 'xsd:string',
),
array('return' => 'xsd:string'),
'urn:WSCMService',
'',
'',
'',
'Retorna o titulo/nome do curso de course_code informado'
);

@ -12,138 +12,136 @@ require_once __DIR__.'/cm_soap.php';
*/
$s = WSCMSoapServer::singleton();
$s->register(
'WSCMForum.get_foruns_id',
array(
'username' => 'xsd:string',
'password' => 'xsd:string',
'course_code' => 'xsd:string'
),
array('return' => 'xsd:string'),
'urn:WSCMService',
'',
'',
'',
'Retorna o ID dos foruns de uma disciplina.'
'WSCMForum.get_foruns_id',
array(
'username' => 'xsd:string',
'password' => 'xsd:string',
'course_code' => 'xsd:string',
),
array('return' => 'xsd:string'),
'urn:WSCMService',
'',
'',
'',
'Retorna o ID dos foruns de uma disciplina.'
);
$s->register(
'WSCMForum.get_forum_title',
array(
'username' => 'xsd:string',
'password' => 'xsd:string',
'course_code' => 'xsd:string',
'forum_id' => 'xsd:string'
),
array('return' => 'xsd:string'),
'urn:WSCMService',
'',
'',
'',
'Retorna o valor do titulo de um forum_id.'
'WSCMForum.get_forum_title',
array(
'username' => 'xsd:string',
'password' => 'xsd:string',
'course_code' => 'xsd:string',
'forum_id' => 'xsd:string',
),
array('return' => 'xsd:string'),
'urn:WSCMService',
'',
'',
'',
'Retorna o valor do titulo de um forum_id.'
);
$s->register(
'WSCMForum.get_forum_threads_id',
array(
'username' => 'xsd:string',
'password' => 'xsd:string',
'course_code' => 'xsd:string',
'forum_id' => 'xsd:string'
),
array('return' => 'xsd:string'),
'urn:WSCMService',
'',
'',
'',
'Retorna o ID das threads de um forum_id.'
'WSCMForum.get_forum_threads_id',
array(
'username' => 'xsd:string',
'password' => 'xsd:string',
'course_code' => 'xsd:string',
'forum_id' => 'xsd:string',
),
array('return' => 'xsd:string'),
'urn:WSCMService',
'',
'',
'',
'Retorna o ID das threads de um forum_id.'
);
$s->register(
'WSCMForum.get_forum_thread_data',
array(
'username' => 'xsd:string',
'password' => 'xsd:string',
'course_code' => 'xsd:string',
'thread_id' => 'xsd:string',
'field' => 'xsd:string'
),
array('return' => 'xsd:string'),
'urn:WSCMService',
'',
'',
'',
'Retorna o campo field de um thread_id. Campos possiveis: title, date, sender, sender_name.'
'WSCMForum.get_forum_thread_data',
array(
'username' => 'xsd:string',
'password' => 'xsd:string',
'course_code' => 'xsd:string',
'thread_id' => 'xsd:string',
'field' => 'xsd:string',
),
array('return' => 'xsd:string'),
'urn:WSCMService',
'',
'',
'',
'Retorna o campo field de um thread_id. Campos possiveis: title, date, sender, sender_name.'
);
$s->register(
'WSCMForum.get_forum_thread_title',
array(
'username' => 'xsd:string',
'password' => 'xsd:string',
'course_code' => 'xsd:string',
'thread_id' => 'xsd:string'
),
array('return' => 'xsd:string'),
'urn:WSCMService',
'',
'',
'',
'Retorna o campo title de uma thread_id.'
'WSCMForum.get_forum_thread_title',
array(
'username' => 'xsd:string',
'password' => 'xsd:string',
'course_code' => 'xsd:string',
'thread_id' => 'xsd:string',
),
array('return' => 'xsd:string'),
'urn:WSCMService',
'',
'',
'',
'Retorna o campo title de uma thread_id.'
);
$s->register(
'WSCMForum.get_posts_id',
array(
'username' => 'xsd:string',
'password' => 'xsd:string',
'course_code' => 'xsd:string',
'thread_id' => 'xsd:string'
),
array('return' => 'xsd:string'),
'urn:WSCMService',
'',
'',
'',
'Retorna o ID dos posts de uma thread.'
'WSCMForum.get_posts_id',
array(
'username' => 'xsd:string',
'password' => 'xsd:string',
'course_code' => 'xsd:string',
'thread_id' => 'xsd:string',
),
array('return' => 'xsd:string'),
'urn:WSCMService',
'',
'',
'',
'Retorna o ID dos posts de uma thread.'
);
$s->register(
'WSCMForum.get_post_data',
array(
'username' => 'xsd:string',
'password' => 'xsd:string',
'course_code' => 'xsd:string',
'post_id' => 'xsd:string',
'field' => 'xsd:string'
),
array('return' => 'xsd:string'),
'urn:WSCMService',
'',
'',
'',
'Retorna o campo field de um post_id. Campos possiveis: title, text, date, sender ou sender_name.'
'WSCMForum.get_post_data',
array(
'username' => 'xsd:string',
'password' => 'xsd:string',
'course_code' => 'xsd:string',
'post_id' => 'xsd:string',
'field' => 'xsd:string',
),
array('return' => 'xsd:string'),
'urn:WSCMService',
'',
'',
'',
'Retorna o campo field de um post_id. Campos possiveis: title, text, date, sender ou sender_name.'
);
$s->register(
'WSCMForum.send_post',
array(
'username' => 'xsd:string',
'password' => 'xsd:string',
'course_code' => 'xsd:string',
'forum_id' => 'xsd:string',
'thread_id' => 'xsd:string',
'title' => 'xsd:string',
'content' => 'xsd:string'
),
array('return' => 'xsd:string'),
'urn:WSCMService',
'',
'',
'',
'Envia um novo post ao forum_id.'
'WSCMForum.send_post',
array(
'username' => 'xsd:string',
'password' => 'xsd:string',
'course_code' => 'xsd:string',
'forum_id' => 'xsd:string',
'thread_id' => 'xsd:string',
'title' => 'xsd:string',
'content' => 'xsd:string',
),
array('return' => 'xsd:string'),
'urn:WSCMService',
'',
'',
'',
'Envia um novo post ao forum_id.'
);

@ -12,106 +12,104 @@ require_once __DIR__.'/cm_soap.php';
*/
$s = WSCMSoapServer::singleton();
$s->register(
'WSCMInbox.unreadMessage',
array(
'username' => 'xsd:string',
'password' => 'xsd:string',
),
array('return' => 'xsd:string'),
'urn:WSCMService',
'',
'',
'',
'Retorna a quantidade de mensagens nao lidas na caixa de entrada do usuario.'
'WSCMInbox.unreadMessage',
array(
'username' => 'xsd:string',
'password' => 'xsd:string',
),
array('return' => 'xsd:string'),
'urn:WSCMService',
'',
'',
'',
'Retorna a quantidade de mensagens nao lidas na caixa de entrada do usuario.'
);
$s->register(
'WSCMInbox.get_message_id',
array(
'username' => 'xsd:string',
'password' => 'xsd:string',
'from' => 'xsd:string',
'number_of_items' => 'xsd:string'
),
array('return' => 'xsd:string'),
'urn:WSCMService',
'',
'',
'',
'Retorna o ID das mensagens de entrada entre o intervalo de from até number_of_items.'
'WSCMInbox.get_message_id',
array(
'username' => 'xsd:string',
'password' => 'xsd:string',
'from' => 'xsd:string',
'number_of_items' => 'xsd:string',
),
array('return' => 'xsd:string'),
'urn:WSCMService',
'',
'',
'',
'Retorna o ID das mensagens de entrada entre o intervalo de from até number_of_items.'
);
$s->register(
'WSCMInbox.get_message_data',
array(
'username' => 'xsd:string',
'password' => 'xsd:string',
'id' => 'xsd:string',
'field' => 'xsd:string'
),
array('return' => 'xsd:string'),
'urn:WSCMService',
'',
'',
'',
'Retorna o conteudo do campo informado em field da mensagem de entrada id. Os campos retornados sao: sender, title, date, status e content.'
'WSCMInbox.get_message_data',
array(
'username' => 'xsd:string',
'password' => 'xsd:string',
'id' => 'xsd:string',
'field' => 'xsd:string',
),
array('return' => 'xsd:string'),
'urn:WSCMService',
'',
'',
'',
'Retorna o conteudo do campo informado em field da mensagem de entrada id. Os campos retornados sao: sender, title, date, status e content.'
);
$s->register(
'WSCMInbox.get_message_id_sent',
array(
'username' => 'xsd:string',
'password' => 'xsd:string',
'from' => 'xsd:string',
'number_of_items' => 'xsd:string'
),
array('return' => 'xsd:string'),
'urn:WSCMService',
'',
'',
'',
'Retorna o ID das mensagens de saida entre o intervalo de from até number_of_items.'
'WSCMInbox.get_message_id_sent',
array(
'username' => 'xsd:string',
'password' => 'xsd:string',
'from' => 'xsd:string',
'number_of_items' => 'xsd:string',
),
array('return' => 'xsd:string'),
'urn:WSCMService',
'',
'',
'',
'Retorna o ID das mensagens de saida entre o intervalo de from até number_of_items.'
);
$s->register(
'WSCMInbox.get_message_data_sent',
array(
'username' => 'xsd:string',
'password' => 'xsd:string',
'id' => 'xsd:string',
'field' => 'xsd:string'
),
array('return' => 'xsd:string'),
'urn:WSCMService',
'',
'',
'',
'Retorna o conteudo do campo informado em field da mensagem de saida id. Os campos retornados sao: sender, title, date, status e content.'
'WSCMInbox.get_message_data_sent',
array(
'username' => 'xsd:string',
'password' => 'xsd:string',
'id' => 'xsd:string',
'field' => 'xsd:string',
),
array('return' => 'xsd:string'),
'urn:WSCMService',
'',
'',
'',
'Retorna o conteudo do campo informado em field da mensagem de saida id. Os campos retornados sao: sender, title, date, status e content.'
);
$s->register(
'WSCMInbox.message_send',
array(
'username' => 'xsd:string',
'password' => 'xsd:string',
'receiver_user_id' => 'xsd:string',
'subject' => 'xsd:string',
'content' => 'xsd:string'
),
array('return' => 'xsd:string'),
'urn:WSCMService',
'',
'',
'',
'Envia uma mensagem via rede social. Retorna o id da mensagem enviada.'
'WSCMInbox.message_send',
array(
'username' => 'xsd:string',
'password' => 'xsd:string',
'receiver_user_id' => 'xsd:string',
'subject' => 'xsd:string',
'content' => 'xsd:string',
),
array('return' => 'xsd:string'),
'urn:WSCMService',
'',
'',
'',
'Envia uma mensagem via rede social. Retorna o id da mensagem enviada.'
);

@ -13,93 +13,93 @@ require_once __DIR__.'/cm_soap.php';
$s = WSCMSoapServer::singleton();
$s->register(
'WSCMUser.find_id_user',
array(
'username' => 'xsd:string',
'password' => 'xsd:string',
'name' => 'xsd:string',
),
array('return' => 'xsd:string'),
'urn:WSCMService',
'',
'',
'',
'Retorna o id de um usuario que contenha o parametro \'nome\' nos campos nome, sobrenome ou email (ordenado por nome).'
'WSCMUser.find_id_user',
array(
'username' => 'xsd:string',
'password' => 'xsd:string',
'name' => 'xsd:string',
),
array('return' => 'xsd:string'),
'urn:WSCMService',
'',
'',
'',
'Retorna o id de um usuario que contenha o parametro \'nome\' nos campos nome, sobrenome ou email (ordenado por nome).'
);
$s->register(
'WSCMUser.get_user_name',
array(
'username' => 'xsd:string',
'password' => 'xsd:string',
'id' => 'xsd:string',
'field' => 'xsd:string'
),
array('return' => 'xsd:string'),
'urn:WSCMService',
'',
'',
'',
'Retorna o primeiro, ultimo ou os dois nomes de um usuarios. No campo field deve ser informado firstname, lastname, bothfl (para fistname lastname) ou bothlf (para lastname firstname)'
'WSCMUser.get_user_name',
array(
'username' => 'xsd:string',
'password' => 'xsd:string',
'id' => 'xsd:string',
'field' => 'xsd:string',
),
array('return' => 'xsd:string'),
'urn:WSCMService',
'',
'',
'',
'Retorna o primeiro, ultimo ou os dois nomes de um usuarios. No campo field deve ser informado firstname, lastname, bothfl (para fistname lastname) ou bothlf (para lastname firstname)'
);
$s->register(
'WSCMUser.get_link_user_picture',
array(
'username' => 'xsd:string',
'password' => 'xsd:string',
'id' => 'xsd:string'
),
array('return' => 'xsd:string'),
'urn:WSCMService',
'',
'',
'',
'Retorna o link para a imagem do perfil do usuario.'
'WSCMUser.get_link_user_picture',
array(
'username' => 'xsd:string',
'password' => 'xsd:string',
'id' => 'xsd:string',
),
array('return' => 'xsd:string'),
'urn:WSCMService',
'',
'',
'',
'Retorna o link para a imagem do perfil do usuario.'
);
$s->register(
'WSCMUser.send_invitation',
array(
'username' => 'xsd:string',
'password' => 'xsd:string',
'userfriend_id' => 'xsd:string',
'content_message' => 'xsd:string'
),
array('return' => 'xsd:string'),
'urn:WSCMService',
'',
'',
'',
'Envia um convite para estabelecer amizado no portal. O campo userfriend_id o id do possivel amigo e o campo content_message e a mensagem de solicitacao.'
'WSCMUser.send_invitation',
array(
'username' => 'xsd:string',
'password' => 'xsd:string',
'userfriend_id' => 'xsd:string',
'content_message' => 'xsd:string',
),
array('return' => 'xsd:string'),
'urn:WSCMService',
'',
'',
'',
'Envia um convite para estabelecer amizado no portal. O campo userfriend_id o id do possivel amigo e o campo content_message e a mensagem de solicitacao.'
);
$s->register(
'WSCMUser.accept_friend',
array(
'username' => 'xsd:string',
'password' => 'xsd:string',
'userfriend_id' => 'xsd:string'
),
array('return' => 'xsd:string'),
'urn:WSCMService',
'',
'',
'',
'Aceita o convite realizado pelo userfriend_id.'
'WSCMUser.accept_friend',
array(
'username' => 'xsd:string',
'password' => 'xsd:string',
'userfriend_id' => 'xsd:string',
),
array('return' => 'xsd:string'),
'urn:WSCMService',
'',
'',
'',
'Aceita o convite realizado pelo userfriend_id.'
);
$s->register(
'WSCMUser.denied_invitation',
array(
'username' => 'xsd:string',
'password' => 'xsd:string',
'userfriend_id' => 'xsd:string'
),
array('return' => 'xsd:string'),
'urn:WSCMService',
'',
'',
'',
'Recusa o contive de amizade feito pelo usuario userfriend_id.'
'WSCMUser.denied_invitation',
array(
'username' => 'xsd:string',
'password' => 'xsd:string',
'userfriend_id' => 'xsd:string',
),
array('return' => 'xsd:string'),
'urn:WSCMService',
'',
'',
'',
'Recusa o contive de amizade feito pelo usuario userfriend_id.'
);

File diff suppressed because it is too large Load Diff

@ -16,8 +16,8 @@ require_once __DIR__.'/cm_webservice.php';
*/
class WSCMCourses extends WSCM
{
public function get_courses_code($username, $password) {
public function get_courses_code($username, $password)
{
if ($this->verifyUserPass($username, $password) == "valid") {
$user_id = UserManager::get_user_id_from_username($username);
$listOfCourses = UserManager::get_personal_session_course_list($user_id);
@ -34,15 +34,14 @@ class WSCMCourses extends WSCM
public function get_course_title($username, $password, $course_code)
{
if ($this->verifyUserPass($username, $password) == "valid")
{
if ($this->verifyUserPass($username, $password) == "valid") {
$course_info = CourseManager::get_course_information($course_code);
return $course_info['title'];
} else
} else {
return get_lang('InvalidId');
}
}
}
/*

@ -21,27 +21,29 @@ class WSCMForum extends WSCM
public function get_foruns_id($username, $password, $course_code)
{
if($this->verifyUserPass($username, $password) == "valid")
{
if ($this->verifyUserPass($username, $password) == "valid") {
$course_db = CourseManager::get_course_information($course_code);
$foruns_info = get_forums($id='', $course_db['code']);
$foruns_id = '#';
foreach ($foruns_info as $forum)
{
if( isset($forum['forum_id']))
{
foreach ($foruns_info as $forum) {
if (isset($forum['forum_id'])) {
$foruns_id .= $forum['forum_id']."#";
}
}
return $foruns_id;
} else
} else {
return get_lang('InvalidId');
}
}
public function get_forum_title($username, $password, $course_code, $forum_id)
{
if($this->verifyUserPass($username, $password) == "valid")
{
public function get_forum_title(
$username,
$password,
$course_code,
$forum_id
) {
if ($this->verifyUserPass($username, $password) == "valid") {
$course_db = CourseManager::get_course_information($course_code);
$table_forums = Database::get_course_table(TABLE_FORUM, $course_db['db_name']);
$table_item_property = Database::get_course_table(TABLE_ITEM_PROPERTY, $course_db['db_name']);
@ -56,13 +58,18 @@ class WSCMForum extends WSCM
$forum_title = utf8_decode($forum_info['forum_title']);
return $forum_title;
} else
} else {
return get_lang('InvalidId');
}
}
public function get_forum_threads_id($username, $password, $course_code, $forum_id)
{
if($this->verifyUserPass($username, $password) == "valid") {
public function get_forum_threads_id(
$username,
$password,
$course_code,
$forum_id
) {
if ($this->verifyUserPass($username, $password) == "valid") {
$threads_info = get_threads($forum_id);
$threads_id = '#';
foreach ($threads_info as $thread)
@ -75,14 +82,19 @@ class WSCMForum extends WSCM
return $threads_id;
} else
} else {
return get_lang('InvalidId');
}
}
public function get_forum_thread_data($username, $password, $course_code, $thread_id, $field)
{
if($this->verifyUserPass($username, $password) == "valid")
{
public function get_forum_thread_data(
$username,
$password,
$course_code,
$thread_id,
$field
) {
if ($this->verifyUserPass($username, $password) == "valid") {
$course_db = CourseManager::get_course_information($course_code);
$table_item_property = Database::get_course_table(TABLE_ITEM_PROPERTY, $course_db['db_name']);
$table_threads = Database::get_course_table(TABLE_FORUM_THREAD, $course_db['db_name']);
@ -94,21 +106,21 @@ class WSCMForum extends WSCM
$result=Database::query($sql);
$thread_info=Database::fetch_array($result);
switch ($field)
{
switch ($field) {
case 'title':
$htmlcode = true;
$field_table = "thread_title";
break;
case 'date' :
case 'date':
$field_table = "thread_date";
break;
case 'sender' :
case 'sender':
$field_table = "insert_user_id";
break;
case 'sender_name' :
case 'sender_name':
$user_id = $thread_info['insert_user_id'];
$user_info = api_get_user_info($user_id);
return $user_info['firstname'];
break;
default:
@ -117,14 +129,18 @@ class WSCMForum extends WSCM
return $thread_info[$field_table];
} else
} else {
return get_lang('InvalidId');
}
}
public function get_forum_thread_title($username, $password, $course_code, $thread_id)
{
if($this->verifyUserPass($username, $password) == "valid")
{
public function get_forum_thread_title(
$username,
$password,
$course_code,
$thread_id
) {
if ($this->verifyUserPass($username, $password) == "valid") {
$course_db = CourseManager::get_course_information($course_code);
$table_item_property = Database::get_course_table(TABLE_ITEM_PROPERTY, $course_db['db_name']);
$table_threads = Database::get_course_table(TABLE_FORUM_THREAD, $course_db['db_name']);
@ -141,15 +157,15 @@ class WSCMForum extends WSCM
return $thread_info[$field_table];
} else
} else {
return get_lang('InvalidId');
}
}
public function get_posts_id($username, $password, $course_code, $thread_id)
{
if($this->verifyUserPass($username, $password) == "valid")
{
if ($this->verifyUserPass($username, $password) == "valid") {
$course_db = CourseManager::get_course_information($course_code);
$table_users = Database::get_main_table(TABLE_MAIN_USER);
@ -178,49 +194,53 @@ class WSCMForum extends WSCM
$posts_id = '#';
foreach ($posts_info as $post)
{
if( isset($post['post_id']))
{
foreach ($posts_info as $post) {
if (isset($post['post_id'])) {
$posts_id .= $post['post_id']."#";
}
}
return $posts_id;
} else
} else {
return get_lang('InvalidId');
}
}
public function get_post_data($username, $password, $course_code, $post_id, $field)
{
if($this->verifyUserPass($username, $password) == "valid")
{
public function get_post_data(
$username,
$password,
$course_code,
$post_id,
$field
) {
if ($this->verifyUserPass($username, $password) == "valid") {
$course_db = CourseManager::get_course_information($course_code);
$table_posts = Database::get_course_table(TABLE_FORUM_POST, $course_db['db_name']);
$table_users = Database::get_main_table(TABLE_MAIN_USER);
$sql="SELECT * FROM ".$table_posts."posts, ".$table_users." users WHERE posts.poster_id=users.user_id AND posts.post_id='".Database::escape_string($post_id)."'";
$sql = "SELECT * FROM ".$table_posts."posts, ".$table_users." users
WHERE posts.poster_id=users.user_id AND posts.post_id='".Database::escape_string($post_id)."'";
$result=Database::query($sql);
$post_info =Database::fetch_array($result);
$htmlcode = false;
switch ($field)
{
switch ($field) {
case 'title':
$htmlcode = true;
$field_table = "post_title";
break;
case 'text' :
case 'text':
$htmlcode = true;
$field_table = "post_text";
break;
case 'date' :
case 'date':
$field_table = "post_date";
break;
case 'sender' :
case 'sender':
$field_table = "user_id";
break;
case 'sender_name' :
case 'sender_name':
$field_table = "firstname";
break;
default:
@ -232,10 +252,16 @@ class WSCMForum extends WSCM
return get_lang('InvalidId');
}
public function send_post($username, $password, $course_code, $forum_id, $thread_id, $title, $content)
{
if($this->verifyUserPass($username, $password) == "valid")
{
public function send_post(
$username,
$password,
$course_code,
$forum_id,
$thread_id,
$title,
$content
) {
if ($this->verifyUserPass($username, $password) == "valid") {
$em = Database::getManager();
$course_db = api_get_course_info($course_code);
@ -255,7 +281,6 @@ class WSCMForum extends WSCM
$content = htmlentities($content);
$postDate = new DateTime(api_get_utc_datetime(), new DateTimeZone('UTC'));
$post = new \Chamilo\CourseBundle\Entity\CForumPost();
$post
->setPostTitle($title)
@ -272,15 +297,10 @@ class WSCMForum extends WSCM
$em->flush();
return "Post enviado!";
//return $sql;
//send_notification_mails($thread_id, $values);
} else
return get_lang('InvalidId');
}
}
/*

@ -31,10 +31,13 @@ class WSCMInbox extends WSCM
}
public function get_message_id($username, $password, $from, $number_of_items)
{
if ($this->verifyUserPass($username, $password) == "valid")
{
public function get_message_id(
$username,
$password,
$from,
$number_of_items
) {
if ($this->verifyUserPass($username, $password) == "valid") {
$user_id = UserManager::get_user_id_from_username($username);
$table_message = Database::get_main_table(TABLE_MESSAGE);
@ -51,33 +54,32 @@ class WSCMInbox extends WSCM
return $message;
} else
} else {
return get_lang('InvalidId');
}
}
public function get_message_data($username, $password, $message_id, $field)
{
if ($this->verifyUserPass($username, $password) == "valid")
{
if ($this->verifyUserPass($username, $password) == "valid") {
$htmlcode = false;
$user_id = UserManager::get_user_id_from_username($username);
switch ($field)
{
switch ($field) {
case 'sender':
$field_table = "user_sender_id";
break;
case 'title' :
case 'title':
$htmlcode = true;
$field_table = "title";
break;
case 'date' :
case 'date':
$field_table = "send_date";
break;
case 'status' :
case 'status':
$field_table = "msg_status";
break;
case 'content' :
case 'content':
$this->set_message_as_read($user_id, $message_id);
$htmlcode = true;
$field_table = "content";
@ -95,16 +97,18 @@ class WSCMInbox extends WSCM
$result = Database::fetch_row($sql_result);
return (htmlcode) ? html_entity_decode($result[0]) : $result[0];
} else
} else {
return get_lang('InvalidId');
}
}
public function get_message_id_sent($username, $password, $from, $number_of_items)
{
if ($this->verifyUserPass($username, $password) == "valid")
{
public function get_message_id_sent(
$username,
$password,
$from,
$number_of_items
) {
if ($this->verifyUserPass($username, $password) == "valid") {
$user_id = UserManager::get_user_id_from_username($username);
$table_message = Database::get_main_table(TABLE_MESSAGE);
@ -121,19 +125,16 @@ class WSCMInbox extends WSCM
return $message;
} else
} else {
return get_lang('InvalidId');
}
}
public function get_message_data_sent($username, $password, $id, $field)
{
if ($this->verifyUserPass($username, $password) == "valid")
{
if ($this->verifyUserPass($username, $password) == "valid") {
$htmlcode = false;
switch ($field)
{
switch ($field) {
case 'sender':
$field_table = "user_sender_id";
break;
@ -156,12 +157,9 @@ class WSCMInbox extends WSCM
}
$user_id = UserManager::get_user_id_from_username($username);
$table_message = Database::get_main_table(TABLE_MESSAGE);
$sql_query = "SELECT ".$field_table." FROM $table_message ".
" WHERE user_sender_id=".$user_id." AND id=".$id;
" WHERE user_sender_id=".$user_id." AND id=".$id;
$sql_result = Database::query($sql_query);
$result = Database::fetch_row($sql_result);
@ -169,15 +167,17 @@ class WSCMInbox extends WSCM
} else
return get_lang('InvalidId');
}
public function message_send($username, $password, $receiver_user_id, $subject, $content)
{
public function message_send(
$username,
$password,
$receiver_user_id,
$subject,
$content
) {
//TODO: verificar data de envio. Esta divergindo de data!
if ($this->verifyUserPass($username, $password) == "valid")
{
if ($this->verifyUserPass($username, $password) == "valid") {
$group_id = intval(0);
$parent_id = intval(0);
$edit_message_id = intval(0);
@ -202,19 +202,19 @@ class WSCMInbox extends WSCM
return $inbox_last_id;
} else
} else {
return get_lang('InvalidId');
}
}
protected function set_message_as_read($user_id, $message_id) {
protected function set_message_as_read($user_id, $message_id)
{
$table_message = Database::get_main_table(TABLE_MESSAGE);
$query = "UPDATE $table_message SET msg_status = '".MESSAGE_STATUS_NEW."' WHERE user_receiver_id=".$user_id." AND id='".$message_id."';";
$result = Database::query($query);
}
}
/*

@ -11,39 +11,49 @@ require_once __DIR__.'/cm_webservice.php';
*
* @author marcosousa
*/
class WSCMUser extends WSCM {
class WSCMUser extends WSCM
{
public function find_id_user($username, $password, $name)
{
if ($this->verifyUserPass($username, $password) == "valid") {
if ($this->verifyUserPass($username, $password) == "valid") {
$listResult = "#";
$listArrayResult = Array();
$listArray = Array();
$listArrayResult = [];
$listArray = [];
$list = $this->get_user_list_like_start(array('firstname'=>$name), array('firstname'));
foreach ($list as $userData) {
$listArray[] = $userData['user_id'];
}
$list = $this->get_user_list_like_start(
array('firstname' => $name),
array('firstname')
);
foreach ($list as $userData) {
$listArray[] = $userData['user_id'];
}
$list = $this->get_user_list_like_start(array('lastname'=>$name), array('firstname'));
foreach ($list as $userData) {
$listArray[] = $userData['user_id'];
}
$list = $this->get_user_list_like_start(
array('lastname' => $name),
array('firstname')
);
foreach ($list as $userData) {
$listArray[] = $userData['user_id'];
}
$list = $this->get_user_list_like_start(array('email'=>$name), array('firstname'));
$list = $this->get_user_list_like_start(
array('email' => $name),
array('firstname')
);
foreach ($list as $userData) {
$listArray[] = $userData['user_id'];
}
$listArrayResult = array_unique($listArray);
$listArrayResult = array_unique($listArray);
foreach ($listArrayResult as $result) {
$listResult .= $result."#";
}
return $listResult;
}
return "0";
}
@ -140,10 +150,10 @@ class WSCMUser extends WSCM {
*@todo Use the UserManager class
* @todo security filter order by
*/
private static function get_user_list_like_start($conditions = array(), $order_by = array())
private static function get_user_list_like_start($conditions = [], $order_by = [])
{
$user_table = Database::get_main_table(TABLE_MAIN_USER);
$return_array = array();
$return_array = [];
$sql_query = "SELECT * FROM $user_table";
if (count($conditions) > 0) {
$sql_query .= ' WHERE ';

@ -20,34 +20,55 @@ require_once __DIR__.'/../inc/global.inc.php';
* @param mixed Array or string. Type of visibility of course (public, public-registered, private, closed)
* @return array Courses list (code=>[title=>'title',url='http://...',teacher=>'...',language=>''],code=>[...],...)
*/
function courses_list($security_key, $visibilities = 'public') {
function courses_list($security_key, $visibilities = 'public')
{
global $_configuration;
global $_configuration;
// Check if this script is launch by server and if security key is ok.
if ($security_key != $_configuration['security_key']) {
return array('error_msg' => 'Security check failed');
}
// Check if this script is launch by server and if security key is ok.
if ($security_key != $_configuration['security_key']) {
return array('error_msg' => 'Security check failed');
}
$vis = array(
'public' => '3',
'public-registered' => '2',
'private' => '1',
'closed' => '0',
);
$vis = array('public' => '3', 'public-registered' => '2', 'private' => '1', 'closed' => '0');
$courses_list = array();
$courses_list = array();
if (!is_array($visibilities)) {
$tmp = $visibilities;
$visibilities = array($tmp);
}
foreach ($visibilities as $visibility) {
if (!in_array($visibility, array_keys($vis))) {
return array('error_msg' => 'Security check failed');
}
$courses_list_tmp = CourseManager::get_courses_list(
null,
null,
null,
null,
$vis[$visibility]
);
foreach ($courses_list_tmp as $index => $course) {
$course_info = CourseManager::get_course_information(
$course['code']
);
$courses_list[$course['code']] = array(
'title' => api_utf8_encode(
$course_info['title']
),
'url' => api_get_path(WEB_COURSE_PATH).$course_info['directory'].'/',
'teacher' => api_utf8_encode($course_info['tutor_name']),
'language' => $course_info['course_language'],
);
}
}
if (!is_array($visibilities)) {
$tmp = $visibilities;
$visibilities = array($tmp);
}
foreach ($visibilities as $visibility) {
if (!in_array($visibility, array_keys($vis))) {
return array('error_msg' => 'Security check failed');
}
$courses_list_tmp = CourseManager::get_courses_list(null, null, null, null, $vis[$visibility]);
foreach ($courses_list_tmp as $index => $course) {
$course_info = CourseManager::get_course_information($course['code']);
$courses_list[$course['code']] = array('title' => api_utf8_encode($course_info['title']), 'url' => api_get_path(WEB_COURSE_PATH).$course_info['directory'].'/', 'teacher' => api_utf8_encode($course_info['tutor_name']), 'language' => $course_info['course_language']);
}
}
return $courses_list;
return $courses_list;
}
header('Content-Type: text/xml; charset=utf-8');
@ -55,17 +76,17 @@ echo '<?xml version="1.0"?>';
echo '<courseslist>';
if (empty($_POST['security-key']) || empty($_POST['visibility'])) {
echo '<errormsg>Invalid parameters, this script expects a security-key and a visibility parameters</errormsg>';
echo '<errormsg>Invalid parameters, this script expects a security-key and a visibility parameters</errormsg>';
} else {
$courses_list = courses_list($_POST['security-key'], $_POST['visibility']);
foreach ($courses_list as $code => $cd) {
echo '<course>';
echo '<code>' , $code , '</code>';
echo '<title>' , $cd['title'] , '</title>';
echo '<url>' , $cd['url'] , '</url>';
echo '<teacher>' , $cd['teacher'] , '</teacher>';
echo '<language>' , $cd['language'] , '</language>';
echo '</course>';
}
$courses_list = courses_list($_POST['security-key'], $_POST['visibility']);
foreach ($courses_list as $code => $cd) {
echo '<course>';
echo '<code>' , $code , '</code>';
echo '<title>' , $cd['title'] , '</title>';
echo '<url>' , $cd['url'] , '</url>';
echo '<teacher>' , $cd['teacher'] , '</teacher>';
echo '<language>' , $cd['language'] , '</language>';
echo '</course>';
}
}
echo '</courseslist>';

@ -22,18 +22,23 @@ $server->configureWSDL('WSCourseList', 'urn:WSCourseList');
// Register the data structures used by the service
$server->wsdl->addComplexType(
'courseDetails',
'complexType',
'struct',
'all',
'',
array(
'name'=>'code', 'type'=>'xsd:string',
'name'=>'title', 'type'=>'xsd:string',
'name'=>'url', 'type'=>'xsd:string',
'name'=>'teacher', 'type'=>'xsd:string',
'name'=>'language', 'type'=>'xsd:string',
)
'courseDetails',
'complexType',
'struct',
'all',
'',
array(
'name' => 'code',
'type' => 'xsd:string',
'name' => 'title',
'type' => 'xsd:string',
'name' => 'url',
'type' => 'xsd:string',
'name' => 'teacher',
'type' => 'xsd:string',
'name' => 'language',
'type' => 'xsd:string',
)
);
$server->wsdl->addComplexType(
@ -72,14 +77,17 @@ $server->register('WSCourseList', // method name
* @param mixed Array or string. Type of visibility of course (public, public-registered, private, closed)
* @return array Courses list (code=>[title=>'title',url='http://...',teacher=>'...',language=>''],code=>[...],...)
*/
function WSCourseList($username, $signature, $visibilities = 'public') {
function WSCourseList($username, $signature, $visibilities = 'public')
{
if (empty($username) or empty($signature)) { return -1; }
global $_configuration;
$info = api_get_user_info_from_username($username);
$user_id = $info['user_id'];
if (!UserManager::is_admin($user_id)) { return -1; }
if (!UserManager::is_admin($user_id)) {
return -1;
}
$list = UserManager::get_api_keys($user_id, 'dokeos');
$key = '';
@ -97,19 +105,31 @@ function WSCourseList($username, $signature, $visibilities = 'public') {
$courses_list = array();
if (!is_array($visibilities)) {
$visibilities = split(',', $visibilities);
}
foreach ($visibilities as $visibility) {
if (!in_array($visibility, array_keys($vis))) {
return array('error_msg' => 'Security check failed');
}
$courses_list_tmp = CourseManager::get_courses_list(null, null, null, null, $vis[$visibility]);
foreach ($courses_list_tmp as $index => $course) {
$course_info = CourseManager::get_course_information($course['code']);
$courses_list[] = array('code' => $course['code'], 'title' => api_utf8_encode($course_info['title']), 'url' => api_get_path(WEB_COURSE_PATH).$course_info['directory'].'/', 'teacher' => api_utf8_encode($course_info['tutor_name']), 'language' => $course_info['course_language']);
}
}
if (!is_array($visibilities)) {
$visibilities = split(',', $visibilities);
}
foreach ($visibilities as $visibility) {
if (!in_array($visibility, array_keys($vis))) {
return array('error_msg' => 'Security check failed');
}
$courses_list_tmp = CourseManager::get_courses_list(
null,
null,
null,
null,
$vis[$visibility]
);
foreach ($courses_list_tmp as $index => $course) {
$course_info = CourseManager::get_course_information($course['code']);
$courses_list[] = array(
'code' => $course['code'],
'title' => api_utf8_encode($course_info['title']),
'url' => api_get_path(WEB_COURSE_PATH).$course_info['directory'].'/',
'teacher' => api_utf8_encode($course_info['tutor_name']),
'language' => $course_info['course_language'],
);
}
}
return $courses_list;
}

Loading…
Cancel
Save