Minor - format code.

pull/2487/head
jmontoyaa 7 years ago
parent 3c6edaacf8
commit 5d7750e0da
  1. 24
      main/webservices/access_url.php
  2. 3
      main/webservices/additional_webservices.php
  3. 4
      main/webservices/cm_soap_announcements.php
  4. 2
      main/webservices/cm_soap_inbox.php
  5. 125
      main/webservices/cm_webservice_course.php
  6. 20
      main/webservices/cm_webservice_forum.php
  7. 36
      main/webservices/cm_webservice_inbox.php
  8. 23
      main/webservices/cm_webservice_user.php
  9. 7
      main/webservices/courses_list.soap.php
  10. 4
      main/webservices/example_fill_users_fields.php
  11. 24
      main/webservices/http-auth.php
  12. 1
      main/webservices/lp.php
  13. 1
      main/webservices/soap_course.php
  14. 9
      main/webservices/user_info.soap.php
  15. 1
      main/webservices/webservice.php
  16. 4
      main/webservices/webservice_course.php
  17. 2
      main/webservices/webservice_report.php
  18. 1
      main/webservices/webservice_session.php

@ -25,16 +25,32 @@ function return_error($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;

@ -146,7 +146,6 @@ function pptConverterGetCommandBaseParams()
return $cmd;
}
$webPath = api_get_path(WEB_PATH);
$webCodePath = api_get_path(WEB_CODE_PATH);
$options = array(
@ -154,6 +153,6 @@ $options = array(
'location' => $webCodePath.'webservices/additional_webservices.php'
);
$soapServer = new SoapServer(NULL, $options);
$soapServer = new SoapServer(null, $options);
$soapServer->addFunction('wsConvertPpt');
$soapServer->handle();

@ -43,8 +43,4 @@ $s->register(
'',
'',
'Retorna o conteudo do campo informado de um anuncio de chave ID. Campos retornaveis: sender, date, title e content'
);

@ -93,7 +93,6 @@ $s->register(
'',
'',
'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(
@ -111,5 +110,4 @@ $s->register(
'',
'',
'Envia uma mensagem via rede social. Retorna o id da mensagem enviada.'
);

@ -139,7 +139,16 @@ class WSCMCourse extends WSCM
if ($wanted_code == '') {
$wanted_code = CourseManager::generate_course_code($title);
}
$result = create_course($wanted_code, $title, $tutor_name, $category_code, $language, $course_admin_id, $this->_configuration['db_prefix'], 0);
$result = create_course(
$wanted_code,
$title,
$tutor_name,
$category_code,
$language,
$course_admin_id,
$this->_configuration['db_prefix'],
0
);
if (!$result) {
return new WSError(202, 'There was an error creating the course');
} else {
@ -187,7 +196,18 @@ class WSCMCourse extends WSCM
if ($verifKey instanceof WSError) {
$this->handleError($verifKey);
} else {
$result = $this->createCourseHelper($title, $category_code, $wanted_code, $tutor_name, $course_admin_user_id_field_name, $course_admin_user_id_value, $language, $course_id_field_name, $course_id_value, $extras);
$result = $this->createCourseHelper(
$title,
$category_code,
$wanted_code,
$tutor_name,
$course_admin_user_id_field_name,
$course_admin_user_id_value,
$language,
$course_id_field_name,
$course_id_value,
$extras
);
if ($result instanceof WSError) {
$this->handleError($result);
} else {
@ -216,7 +236,18 @@ class WSCMCourse extends WSCM
//reinitialize variables just in case
$title = $category_code = $wanted_code = $tutor_name = $course_admin_user_id_field_name = $course_admin_user_id_value = $language = $course_id_field_name = $course_id_value = $extras = null;
extract($course);
$result = $this->createCourseHelper($title, $category_code, $wanted_code, $tutor_name, $course_admin_user_id_field_name, $course_admin_user_id_value, $language, $course_id_field_name, $course_id_value, $extras);
$result = $this->createCourseHelper(
$title,
$category_code,
$wanted_code,
$tutor_name,
$course_admin_user_id_field_name,
$course_admin_user_id_value,
$language,
$course_id_field_name,
$course_id_value,
$extras
);
if ($result instanceof WSCMError) {
$result_tmp['result'] = $result->toArray();
$result_tmp['course_id_value'] = $course_id_value;
@ -348,7 +379,20 @@ class WSCMCourse extends WSCM
if ($verifKey instanceof WSCMError) {
$this->handleError($verifKey);
} else {
$result = $this->editCourseHelper($course_id_field_name, $course_id_value, $title, $category_code, $department_name, $department_url, $language, $visibility, $subscribe, $unsubscribe, $visual_code, $extras);
$result = $this->editCourseHelper(
$course_id_field_name,
$course_id_value,
$title,
$category_code,
$department_name,
$department_url,
$language,
$visibility,
$subscribe,
$unsubscribe,
$visual_code,
$extras
);
if ($result instanceof WSCMError) {
$this->handleError($result);
}
@ -414,7 +458,14 @@ class WSCMCourse extends WSCM
* @param int Status (STUDENT or TEACHER) Used for subscription only
* @return mixed True if subscription or unsubscription was successful, false otherwise
*/
protected function changeUserSubscription($course_id_field_name, $course_id_value, $user_id_field_name, $user_id_value, $state, $status = STUDENT) {
protected function changeUserSubscription(
$course_id_field_name,
$course_id_value,
$user_id_field_name,
$user_id_value,
$state,
$status = STUDENT
) {
$course_id = $this->getCourseId($course_id_field_name, $course_id_value);
if ($course_id instanceof WSError) {
return $course_id;
@ -450,12 +501,26 @@ class WSCMCourse extends WSCM
* @param string User id value
* @param int Status (1 = Teacher, 5 = Student)
*/
public function SubscribeUserToCourse($secret_key, $course_id_field_name, $course_id_value, $user_id_field_name, $user_id_value, $status) {
public function SubscribeUserToCourse(
$secret_key,
$course_id_field_name,
$course_id_value,
$user_id_field_name,
$user_id_value,
$status
) {
$verifKey = $this->verifyKey($secret_key);
if ($verifKey instanceof WSError) {
$this->handleError($verifKey);
} else {
$result = $this->changeUserSubscription($course_id_field_name, $course_id_value, $user_id_field_name, $user_id_value, 1, $status);
$result = $this->changeUserSubscription(
$course_id_field_name,
$course_id_value,
$user_id_field_name,
$user_id_value,
1,
$status
);
if ($result instanceof WSError) {
$this->handleError($result);
}
@ -471,12 +536,24 @@ class WSCMCourse extends WSCM
* @param string User id field name. Use "chamilo_user_id" to use internal id
* @param string User id value
*/
public function UnsubscribeUserFromCourse($secret_key, $course_id_field_name, $course_id_value, $user_id_field_name, $user_id_value) {
public function UnsubscribeUserFromCourse(
$secret_key,
$course_id_field_name,
$course_id_value,
$user_id_field_name,
$user_id_value
) {
$verifKey = $this->verifyKey($secret_key);
if ($verifKey instanceof WSError) {
$this->handleError($verifKey);
} else {
$result = $this->changeUserSubscription($course_id_field_name, $course_id_value, $user_id_field_name, $user_id_value, 0);
$result = $this->changeUserSubscription(
$course_id_field_name,
$course_id_value,
$user_id_field_name,
$user_id_value,
0
);
if ($result instanceof WSError) {
$this->handleError($result);
}
@ -491,7 +568,11 @@ class WSCMCourse extends WSCM
* @param string Course id value
* @return array Returns an array with elements of the form ('course_desc_id' => 1, 'course_desc_title' => 'Title', 'course_desc_content' => 'Content')
*/
public function GetCourseDescriptions($secret_key, $course_id_field_name, $course_id_value) {
public function GetCourseDescriptions(
$secret_key,
$course_id_field_name,
$course_id_value
) {
$verifKey = $this->verifyKey($secret_key);
if ($verifKey instanceof WSError) {
$this->handleError($verifKey);
@ -524,7 +605,14 @@ class WSCMCourse extends WSCM
* @param string Description title
* @param string Course description content
*/
public function EditCourseDescription($secret_key, $course_id_field_name, $course_id_value, $course_desc_id, $course_desc_title, $course_desc_content) {
public function EditCourseDescription(
$secret_key,
$course_id_field_name,
$course_id_value,
$course_desc_id,
$course_desc_title,
$course_desc_content
) {
$verifKey = $this->verifyKey($secret_key);
if ($verifKey instanceof WSError) {
$this->handleError($verifKey);
@ -564,13 +652,14 @@ class WSCMCourse extends WSCM
}
public function unreadMessage($username, $password)
{
if ($this->verifyUserPass($username, $password) == "valid")
{
if ($this->verifyUserPass($username, $password) == "valid") {
$table_message = Database::get_main_table(TABLE_MESSAGE);
$user_id = UserManager::get_user_id_from_username($username);
$condition_msg_status = ' msg_status = 1 '; // define('MESSAGE_STATUS_UNREAD', '1');
$sql_query = "SELECT COUNT(*) as number_messages FROM $table_message WHERE $condition_msg_status AND user_receiver_id=".$user_id;
$sql_query = "SELECT COUNT(*) as number_messages
FROM $table_message
WHERE $condition_msg_status AND user_receiver_id=".$user_id;
$sql_result = Database::query($sql_query);
$result = Database::fetch_array($sql_result);
@ -581,18 +670,16 @@ class WSCMCourse extends WSCM
public function get_message_data($username, $password)
{
if ($this->verifyUserPass($username, $password) == "valid")
{
if ($this->verifyUserPass($username, $password) == "valid") {
$user_id = get_user_id_from_username($username);
}
}
public function nada($username, $password)
{
if ($this->verifyUserPass($username, $password) == "valid")
if ($this->verifyUserPass($username, $password) == "valid") {
return $username.$password;
}
return $username;
}

@ -72,10 +72,8 @@ class WSCMForum extends WSCM
if ($this->verifyUserPass($username, $password) == "valid") {
$threads_info = get_threads($forum_id);
$threads_id = '#';
foreach ($threads_info as $thread)
{
if (isset($thread['thread_id']))
{
foreach ($threads_info as $thread) {
if (isset($thread['thread_id'])) {
$threads_id .= $thread['thread_id']."#";
}
}
@ -214,10 +212,8 @@ class WSCMForum extends WSCM
$field
) {
if ($this->verifyUserPass($username, $password) == "valid") {
$course_db = api_get_course_info($course_code);
$table_posts = Database::get_course_table(TABLE_FORUM_POST, $course_db['db_name']);
$table_users = Database::get_main_table(TABLE_MAIN_USER);
$table_posts = Database::get_course_table(TABLE_FORUM_POST);
$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)."'";
@ -247,9 +243,10 @@ class WSCMForum extends WSCM
$htmlcode = true;
$field_table = "title";
}
return (htmlcode) ? html_entity_decode($post_info[$field_table]) : $post_info[$field_table];
} else
return ($htmlcode) ? html_entity_decode($post_info[$field_table]) : $post_info[$field_table];
} else {
return get_lang('InvalidId');
}
}
public function send_post(
@ -297,8 +294,9 @@ class WSCMForum extends WSCM
$em->flush();
return "Post enviado!";
} else
} else {
return get_lang('InvalidId');
}
}
}

@ -15,13 +15,14 @@ class WSCMInbox extends WSCM
{
public function unreadMessage($username, $password)
{
if ($this->verifyUserPass($username, $password) == "valid")
{
if ($this->verifyUserPass($username, $password) == "valid") {
$table_message = Database::get_main_table(TABLE_MESSAGE);
$user_id = UserManager::get_user_id_from_username($username);
$condition_msg_status = ' msg_status = 1 '; // define('MESSAGE_STATUS_UNREAD', '1');
$sql_query = "SELECT COUNT(*) as number_messages FROM $table_message WHERE $condition_msg_status AND user_receiver_id=".$user_id;
$sql_query = "SELECT COUNT(*) as number_messages
FROM $table_message
WHERE $condition_msg_status AND user_receiver_id=".$user_id;
$sql_result = Database::query($sql_query);
$result = Database::fetch_array($sql_result);
@ -30,7 +31,6 @@ class WSCMInbox extends WSCM
return "0";
}
public function get_message_id(
$username,
$password,
@ -57,7 +57,6 @@ class WSCMInbox extends WSCM
} else {
return get_lang('InvalidId');
}
}
public function get_message_data($username, $password, $message_id, $field)
@ -95,7 +94,7 @@ class WSCMInbox extends WSCM
$sql_result = Database::query($sql_query);
$result = Database::fetch_row($sql_result);
return (htmlcode) ? html_entity_decode($result[0]) : $result[0];
return $htmlcode ? html_entity_decode($result[0]) : $result[0];
} else {
return get_lang('InvalidId');
@ -112,10 +111,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 id FROM $table_message ".
"WHERE user_sender_id=".$user_id." AND msg_status=".MESSAGE_STATUS_OUTBOX." ".
"ORDER BY send_date LIMIT $from,$number_of_items";
$sql_query = "SELECT id FROM $table_message
WHERE user_sender_id=".$user_id." AND msg_status=".MESSAGE_STATUS_OUTBOX."
ORDER BY send_date LIMIT $from,$number_of_items";
$sql_result = Database::query($sql_query);
$message = "#";
@ -138,17 +136,17 @@ class WSCMInbox extends WSCM
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':
$htmlcode = true;
$field_table = "content";
break;
@ -163,10 +161,10 @@ class WSCMInbox extends WSCM
$sql_result = Database::query($sql_query);
$result = Database::fetch_row($sql_result);
return (htmlcode) ? html_entity_decode($result[0]) : $result[0];
} else
return $htmlcode ? html_entity_decode($result[0]) : $result[0];
} else {
return get_lang('InvalidId');
}
}
public function message_send(
@ -205,15 +203,13 @@ class WSCMInbox extends WSCM
} else {
return get_lang('InvalidId');
}
}
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);
Database::query($query);
}
}

@ -98,13 +98,22 @@ class WSCMUser extends WSCM
return "0";
}
public function send_invitation($username, $password, $userfriend_id, $content_message = '')
{
public function send_invitation(
$username,
$password,
$userfriend_id,
$content_message = ''
) {
global $charset;
if ($this->verifyUserPass($username, $password) == "valid") {
$user_id = UserManager::get_user_id_from_username($username);
$user_id = UserManager::get_user_id_from_username($username);
$message_title = get_lang('Invitation');
$count_is_true = SocialManager::send_invitation_friend($user_id, $userfriend_id, $message_title, $content_message);
$count_is_true = SocialManager::send_invitation_friend(
$user_id,
$userfriend_id,
$message_title,
$content_message
);
if ($count_is_true) {
return Display::return_message(
@ -135,7 +144,11 @@ class WSCMUser extends WSCM
{
if ($this->verifyUserPass($username, $password) == "valid") {
$user_id = UserManager::get_user_id_from_username($username);
UserManager::relate_users($userfriend_id, $user_id, USER_RELATION_TYPE_FRIEND);
UserManager::relate_users(
$userfriend_id,
$user_id,
USER_RELATION_TYPE_FRIEND
);
SocialManager::invitation_accepted($userfriend_id, $user_id);
return get_lang('AddedContactToList');

@ -56,7 +56,8 @@ $server->wsdl->addComplexType(
);
// Register the method to expose
$server->register('WSCourseList', // method name
$server->register(
'WSCourseList', // method name
array('username' => 'xsd:string',
'signature' => 'xsd:string',
'visibilities' => 'xsd:string'), // input parameters
@ -97,7 +98,9 @@ function WSCourseList($username, $signature, $visibilities = 'public')
$local_key = $username.$key;
if (!api_is_valid_secret_key($signature, $local_key) && !api_is_valid_secret_key($signature, $username.$_configuration['security_key'])) {
if (!api_is_valid_secret_key($signature, $local_key) &&
!api_is_valid_secret_key($signature, $username.$_configuration['security_key'])
) {
return -1; // The secret key is incorrect.
}
//public-registered = open

@ -22,7 +22,7 @@ $tuserfv = Database::get_main_table(TABLE_EXTRA_FIELD_VALUES);
$sql = "SELECT user_id, username FROM $tuser ORDER BY user_id";
$res = Database::query($sql);
while ($row = Database::fetch_array($res)) {
$sql2 = "INSERT INTO $tuserfv (item_id, field_id, value)
$sql2 = "INSERT INTO $tuserfv (item_id, field_id, value)
VALUES (".$row['user_id'].", 11,'".$row['username']."')";
$res2 = Database::query($sql2);
$res2 = Database::query($sql2);
}

@ -34,22 +34,24 @@ else {
}
// This function returns the digest string
function getDigest() {
function getDigest()
{
// mod_php
if (isset($_SERVER['PHP_AUTH_DIGEST'])) {
$digest = $_SERVER['PHP_AUTH_DIGEST'];
// most other servers
}
elseif (isset($_SERVER['HTTP_AUTHENTICATION'])) {
if (strpos(strtolower($_SERVER['HTTP_AUTHENTICATION']), 'digest') === 0)
$digest = substr($_SERVER['HTTP_AUTHORIZATION'], 7);
}
elseif (isset($_SERVER['HTTP_WWW_AUTHENTICATE'])) {
$digest = $_SERVER['HTTP_WWW_AUTHENTICATE'];
// most other servers
} elseif (isset($_SERVER['HTTP_AUTHENTICATION'])) {
if (strpos(
strtolower($_SERVER['HTTP_AUTHENTICATION']),
'digest'
) === 0) {
$digest = substr($_SERVER['HTTP_AUTHORIZATION'], 7);
}
} elseif (isset($_SERVER['HTTP_WWW_AUTHENTICATE'])) {
$digest = $_SERVER['HTTP_WWW_AUTHENTICATE'];
}
return $digest;
return $digest;
}
// This function forces a login prompt

@ -324,7 +324,6 @@ function WSGetLpList($params)
);
if (empty($sessionId)) {
if ($debug) error_log('Session not found');
return 'Session not found';
}

@ -262,4 +262,3 @@ $s->register(
'course_desc_content' => 'xsd:string'
)
);

@ -83,8 +83,6 @@ function WSCourseListOfUser($username, $signature)
if (empty($username) or empty($signature)) {
return -1;
}
global $_configuration;
$info = api_get_user_info_from_username($username);
$user_id = $info['user_id'];
$list = UserManager::get_api_keys($user_id, 'dokeos');
@ -106,9 +104,7 @@ function WSCourseListOfUser($username, $signature)
$courses_list[] = array(
'code' => $course['code'],
'title' => api_utf8_encode($course_info['title']),
'url' => api_get_path(
WEB_COURSE_PATH
).$course_info['directory'].'/',
'url' => api_get_path(WEB_COURSE_PATH).$course_info['directory'].'/',
'teacher' => api_utf8_encode($course_info['tutor_name']),
'language' => $course_info['course_language'],
);
@ -191,14 +187,13 @@ $server->register(
function WSEventsList($username, $signature, $datestart = 0, $dateend = 0) {
if (empty($username) or empty($signature)) { return -1; }
global $_configuration;
$info = api_get_user_info_from_username($username);
$user_id = $info['user_id'];
$list = UserManager::get_api_keys($user_id, 'dokeos');
$key = '';
foreach ($list as $key) {
break;
break;
}
$local_key = $username.$key;

@ -262,4 +262,3 @@ class WS
return "success";
}
}

@ -705,9 +705,7 @@ class WSCourse extends WS
$descriptions = CourseDescription::get_descriptions($course_id);
$exists = false;
foreach ($descriptions as $description) {
if ($description->get_description_type(
) == $course_desc_id
) {
if ($description->get_description_type() == $course_desc_id) {
$exists = true;
}
}

@ -11,7 +11,6 @@ require_once __DIR__.'/webservice.php';
*/
class WSReport extends WS
{
/**
* Gets the time spent on the platform by a given user
*
@ -333,7 +332,6 @@ class WSReport extends WS
}
}
public function test()
{
return 'Hello world!';

@ -755,5 +755,4 @@ class WSSession extends WS
}
}
}
}

Loading…
Cancel
Save