Remove unused code, format code,

pull/2487/head
Julio 10 years ago
parent 7e3fb7badc
commit 55ce4a434d
  1. 3
      main/admin/resource_sequence.php
  2. 5
      main/blog/blog.php
  3. 5
      main/course_description/add.php
  4. 118
      main/forum/forumfunction.inc.php
  5. 70
      main/inc/lib/api.lib.php
  6. 16
      main/inc/lib/internationalization.lib.php
  7. 8
      main/link/link.php
  8. 31
      main/messages/new_message.php
  9. 29
      main/mySpace/myStudents.php
  10. 13
      main/newscorm/learnpath.class.php
  11. 163
      main/webservices/cm_webservice.php
  12. 37
      tests/main/forum/forumfunction.inc.test.php

@ -22,7 +22,7 @@ if (!empty($sessionListFromDatabase)) {
}
}
$formSequence = new FormValidator('sequence_form', 'post', api_get_self(),null,null,'inline');
$formSequence = new FormValidator('sequence_form', 'post', api_get_self(), null, null, 'inline');
$formSequence->addText('name', get_lang('Sequence'), true, ['cols-size' => [3, 8, 1]]);
$formSequence->addButtonCreate(get_lang('AddSequence'), 'submit_sequence', false, ['cols-size' => [3, 8, 1]]);
@ -78,7 +78,6 @@ $formSave = new FormValidator('');
$formSave->addHidden('sequence_type', 'session');
$formSave->addButton('save_resource', get_lang('SaveSettings'), 'floppy-o', 'success', null, null, ['cols-size' => [1, 10, 1]]);
$tpl->assign('create_sequence', $formSequence->returnForm());
$tpl->assign('select_sequence', $selectSequence->returnForm());
$tpl->assign('configure_sequence', $form->returnForm());

@ -13,8 +13,8 @@ if (empty($blog_id)) {
api_not_allowed(true);
}
$this_section = SECTION_COURSES;
$current_course_tool = TOOL_BLOGS;
$this_section = SECTION_COURSES;
$current_course_tool = TOOL_BLOGS;
/* ACCESS RIGHTS */
// notice for unauthorized people.
@ -72,7 +72,6 @@ if (!empty($_POST['new_comment_submit'])) {
}
if (!empty($_POST['new_task_submit'])) {
Blog:: create_task(
$blog_id,
$safe_task_name,

@ -54,10 +54,9 @@ $form = new FormValidator(
'POST',
'index.php?action=add&'.api_get_cidreq()
);
$form->addElement('header', '', $header);
$form->addElement('header', $header);
$form->addElement('hidden', 'description_type', $description_type);
$form->addElement('hidden', 'sec_token', $token);
$form->addText('title', get_lang('Title'), true, array('size'=>'width: 350px;'));
$form->addText('title', get_lang('Title'), true);
$form->applyFilter('title', 'html_filter');
$form->addHtmlEditor(
'contentDescription',

@ -3849,95 +3849,6 @@ function get_whats_new()
}
}
/**
* With this function we find the number of posts and topics in a given forum.
*
* @todo consider to call this function only once and let it return an array where the key is the forum id and the value is an array with number_of_topics and number of post
* as key of this array and the value as a value. This could reduce the number of queries needed (especially when there are more forums)
* @todo consider merging both in one query.
*
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
* @version february 2006, dokeos 1.8
*
* @deprecated the counting mechanism is now inside the function get_forums
*/
function get_post_topics_of_forum($forum_id)
{
$table_posts = Database :: get_course_table(TABLE_FORUM_POST);
$table_threads = Database :: get_course_table(TABLE_FORUM_THREAD);
$table_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY);
$course_id = api_get_course_int_id();
if (api_is_allowed_to_edit(null, true)) {
$sql = "SELECT count(*) as number_of_posts
FROM $table_posts posts, $table_threads threads, $table_item_property item_property
WHERE
posts.c_id = $course_id AND
item_property.c_id = $course_id AND
posts.forum_id='".Database::escape_string($forum_id)."'
AND posts.thread_id=threads.thread_id
AND item_property.ref=threads.thread_id
AND item_property.visibility<>2
AND item_property.tool='".TOOL_FORUM_THREAD."'
";
} else {
$sql = "SELECT count(*) as number_of_posts
FROM $table_posts posts, $table_threads threads, $table_item_property item_property
WHERE
posts.c_id = $course_id AND
item_property.c_id = $course_id AND
posts.forum_id='".Database::escape_string($forum_id)."'
AND posts.thread_id=threads.thread_id
AND item_property.ref=threads.thread_id
AND item_property.visibility=1
AND posts.visible=1
AND item_property.tool='".TOOL_FORUM_THREAD."'
";
}
$result = Database::query($sql);
$row = Database::fetch_array($result);
$number_of_posts = $row['number_of_posts'];
// We could loop through the result array and count the number of different group_ids, but I have chosen to use a second sql statement.
if (api_is_allowed_to_edit(null, true)) {
$sql = "SELECT count(*) as number_of_topics
FROM $table_threads threads, $table_item_property item_property
WHERE
threads.c_id = $course_id AND
item_property.c_id = $course_id AND
threads.forum_id='".Database::escape_string($forum_id)."'
AND item_property.ref=threads.thread_id
AND item_property.visibility<>2
AND item_property.tool='".TOOL_FORUM_THREAD."'
";
} else {
$sql = "SELECT count(*) as number_of_topics
FROM $table_threads threads, $table_item_property item_property
WHERE
threads.c_id = $course_id AND
item_property.c_id = $course_id AND
threads.forum_id='".Database::escape_string($forum_id)."'
AND item_property.ref=threads.thread_id
AND item_property.visibility=1
AND item_property.tool='".TOOL_FORUM_THREAD."'
";
}
$result = Database::query($sql);
$row = Database::fetch_array($result);
$number_of_topics = $row['number_of_topics'];
if ($number_of_topics == '') {
$number_of_topics = 0; // Due to the nature of the group by this can result in an empty string.
}
$return = array(
'number_of_topics' => $number_of_topics,
'number_of_posts' => $number_of_posts,
);
return $return;
}
/**
* This function approves a post = change
*
@ -5662,34 +5573,6 @@ function editAttachedFile($array, $id, $courseId = null) {
return 0;
}
/**
* Return a form to upload asynchronously attachments to forum post.
* @param int $forumId Forum ID from where the post are
* @param int $threadId Thread ID where forum post are
* @param int $postId Post ID to identify Post
* @deprecated this function seems to never been used
* @return string The Forum Attachment Ajax Form
*
*/
function getAttachmentAjaxForm($forumId, $threadId, $postId)
{
$forumId = intval($forumId);
$postId = intval($postId);
$threadId = !empty($threadId) ? intval($threadId) : isset($_REQUEST['thread']) ? intval($_REQUEST['thread']) : '';
if ($forumId === 0) {
// Forum Id must be defined
return '';
}
$url = api_get_path(WEB_AJAX_PATH).'forum.ajax.php?'.api_get_cidreq().'&forum=' . $forumId . '&thread=' . $threadId . '&postId=' . $postId . '&a=upload_file';
$multipleForm = new FormValidator('post');
$multipleForm->addMultipleUpload($url);
return $multipleForm->returnForm();
}
/**
* Return a table where the attachments will be set
* @param int $postId Forum Post ID
@ -5715,6 +5598,7 @@ function getAttachmentsAjaxTable($postId = null)
}
}
}
// Get data to fill into attachment files table
if (!empty($_SESSION['forum']['upload_file'][$courseId]) &&
is_array($_SESSION['forum']['upload_file'][$courseId])

@ -34,8 +34,7 @@ define('ANONYMOUS', 6);
/** global status of a user: low security, necessary for inserting data from
* the teacher through HTMLPurifier */
define('COURSEMANAGERLOWSECURITY', 10);
//Soft user status
// Soft user status
define('PLATFORM_ADMIN', 11);
define('SESSION_COURSE_COACH', 12);
define('SESSION_GENERAL_COACH', 13);
@ -273,7 +272,6 @@ define('REPEATED_SLASHES_PURIFIER', '/\/{2,}/'); // $path = p
define('VALID_WEB_PATH', '/https?:\/\/[^\/]*(\/.*)?/i'); // $is_valid_path = preg_match(VALID_WEB_PATH, $path);
define('VALID_WEB_SERVER_BASE', '/https?:\/\/[^\/]*/i'); // $new_path = preg_replace(VALID_WEB_SERVER_BASE, $new_base, $path);
// Constants for api_get_path() and api_get_path_type(), etc. - registered path types.
// basic (leaf elements)
define('REL_CODE_PATH', 'REL_CODE_PATH');
@ -970,25 +968,13 @@ function api_valid_url($url, $absolute = false) {
/**
* Checks whether a given string looks roughly like an email address.
* Tries to use PHP built-in validator in the filter extension (from PHP 5.2), falls back to a reasonably competent regex validator.
* Conforms approximately to RFC2822
* @link http://www.hexillion.com/samples/#Regex Original pattern found here
* This function is an adaptation from the method PHPMailer::ValidateAddress(), PHPMailer module.
* @link http://phpmailer.worxware.com
*
* @param string $address The e-mail address to be checked.
* @return mixed Returns the e-mail if it is valid, FALSE otherwise.
*/
function api_valid_email($address)
{
return filter_var($address, FILTER_VALIDATE_EMAIL);
/*
// disable for now because the results are incoherent - YW 20110926
if (function_exists('filter_var')) { // Introduced in PHP 5.2.
return filter_var($address, FILTER_VALIDATE_EMAIL);
} else {
return preg_match('/^(?:[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+\.)*[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+@(?:(?:(?:[a-zA-Z0-9_](?:[a-zA-Z0-9_\-](?!\.)){0,61}[a-zA-Z0-9_-]?\.)+[a-zA-Z0-9_](?:[a-zA-Z0-9_\-](?!$)){0,61}[a-zA-Z0-9_]?)|(?:\[(?:(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\.){3}(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\]))$/', $address) ? $address : false;
}*/
}
@ -1070,7 +1056,7 @@ function api_protect_course_script($print_headers = false, $allow_session_admins
}
}
//Check session visibility
// Check session visibility
$session_id = api_get_session_id();
if (!empty($session_id)) {
@ -2310,56 +2296,6 @@ function api_get_session_condition(
return $condition_session;
}
/**
* This function returns information about coaches from a course in session
* @param int optional, session id
* @param int $courseId
* @return array array containing user_id, lastname, firstname, username
* @deprecated use CourseManager::get_coaches_from_course
*/
function api_get_coachs_from_course($session_id = 0, $courseId = '')
{
if (!empty($session_id)) {
$session_id = intval($session_id);
} else {
$session_id = api_get_session_id();
}
if (!empty($courseId)) {
$courseId = intval($courseId);
} else {
$courseId = api_get_course_int_id();
}
$tbl_user = Database:: get_main_table(TABLE_MAIN_USER);
$tbl_session_course_user = Database:: get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
$coaches = array();
$sql = "SELECT
u.user_id,
u.lastname,
u.firstname,
u.username
FROM $tbl_user u, $tbl_session_course_user scu
WHERE
u.user_id = scu.user_id AND
scu.session_id = '$session_id' AND
scu.c_id = '$courseId' AND
scu.status = 2";
$rs = Database::query($sql);
if (Database::num_rows($rs) > 0) {
while ($row = Database::fetch_array($rs)) {
$coaches[] = $row;
}
return $coaches;
} else {
return false;
}
}
/**
* Returns the value of a setting from the web-adjustable admin config settings.
*

@ -57,15 +57,7 @@ define('PERSON_NAME_EMAIL_ADDRESS', PERSON_NAME_WESTERN_ORDER);
// For backward compatibility this format has been set to Eastern order.
define('PERSON_NAME_DATA_EXPORT', PERSON_NAME_EASTERN_ORDER);
// The following constants are used for tuning language detection functionality.
// We reduce the text for language detection to the given number of characters
// for increasing speed and to decrease memory consumption.
define('LANGUAGE_DETECT_MAX_LENGTH', 2000);
// Maximum allowed difference in so called delta-points for aborting certain language detection.
// The value 80000 is good enough for speed and detection accuracy.
// If you set the value of $max_delta too low, no language will be recognized.
// $max_delta = 400 * 350 = 140000 is the best detection with lowest speed.
define('LANGUAGE_DETECT_MAX_DELTA', 140000);
/**
* Returns a translated (localized) string, called by its identificator.
@ -275,7 +267,8 @@ function api_get_language_isocode($language = null, $default_code = 'en')
function api_get_platform_isocodes()
{
$iso_code = array();
$sql = "SELECT isocode FROM ".Database::get_main_table(TABLE_MAIN_LANGUAGE)." ORDER BY isocode ";
$sql = "SELECT isocode FROM ".Database::get_main_table(TABLE_MAIN_LANGUAGE)."
ORDER BY isocode ";
$sql_result = Database::query($sql);
if (Database::num_rows($sql_result)) {
while ($row = Database::fetch_array($sql_result)) {;
@ -976,9 +969,6 @@ function api_htmlentities($string, $quote_style = ENT_COMPAT, $encoding = 'UTF-8
}
return mb_convert_encoding($string, 'HTML-ENTITIES', 'UTF-8');
/*
return html_entity_decode($string, $quote_style, $encoding);
return mb_convert_encoding($string, 'HTML-ENTITIES', 'UTF-8');*/
}
/**

@ -16,17 +16,15 @@
* @author Patrick Cool
* @author René Haentjens, added CSV file import (October 2004)
* @package chamilo.link
*/
// Including libraries
require_once '../inc/global.inc.php';
$current_course_tool = TOOL_LINK;
$this_section = SECTION_COURSES;
api_protect_course_script();
api_protect_course_script(true);
$htmlHeadXtra[] = '<script type="text/javascript">
$htmlHeadXtra[] = '<script>
$(document).ready( function() {
for (i=0;i<$(".actions").length;i++) {
if ($(".actions:eq("+i+")").html()=="<table border=\"0\"></table>" || $(".actions:eq("+i+")").html()=="" || $(".actions:eq("+i+")").html()==null) {
@ -41,7 +39,7 @@ $htmlHeadXtra[] = '<script type="text/javascript">
$("#url_id_"+id).html(loading);
$("#url_id_"+id).load(url);
}
</script>';
</script>';
// @todo change the $_REQUEST into $_POST or $_GET
// @todo remove this code

@ -25,7 +25,7 @@ $nameTools = api_xml_http_response_encode(get_lang('Messages'));
/* Constants and variables */
$htmlHeadXtra[]='
<script language="javascript">
<script>
function validate(form, list) {
if(list.selectedIndex<0) {
alert("Please select someone to send the message to.")
@ -39,12 +39,6 @@ function validate(form, list) {
$htmlHeadXtra[] = '<script>
var counter_image = 1;
/*
function remove_image_form(id_elem1) {
var elem1 = document.getElementById(id_elem1);
elem1.parentNode.removeChild(elem1);
}
*/
function add_image_form() {
// Multiple filepaths for image form
var filepaths = document.getElementById("filepaths");
@ -68,7 +62,6 @@ function add_image_form() {
}
</script>';
$nameTools = get_lang('ComposeMessage');
/* FUNCTIONS */
/**
* Shows the compose area + a list of users to select from.
@ -184,18 +177,20 @@ function manage_form($default, $select_from_user_list = null, $sent_to = null)
}
if (empty($group_id)) {
$form->addElement('label', '', '<div id="filepaths" class="form-group">
<div id="filepath_1">
<label>'.get_lang('FilesAttachment').'</label>
<input type="file" name="attach_1"/>
<label>'.get_lang('Description').'</label>
<input id="file-descrtiption" type="text" name="legend[]" class="form-control"/>
</div>
</div>'
$form->addElement(
'label',
'',
'<div id="filepaths" class="form-group">
<div id="filepath_1">
<label>'.get_lang('FilesAttachment').'</label>
<input type="file" name="attach_1"/>
<label>'.get_lang('Description').'</label>
<input id="file-descrtiption" type="text" name="legend[]" />
</div>
</div>'
);
$form->addElement('label', '', '<span id="link-more-attach"><a href="javascript://" onclick="return add_image_form()">'.get_lang('AddOneMoreFile').'</a></span>&nbsp;('.sprintf(get_lang('MaximunFileSizeX'),format_file_size(api_get_setting('message_max_upload_filesize'))).')');
$form->addLabel('', '<span id="link-more-attach"><a href="javascript://" onclick="return add_image_form()">'.get_lang('AddOneMoreFile').'</a></span>&nbsp;('.sprintf(get_lang('MaximunFileSizeX'),format_file_size(api_get_setting('message_max_upload_filesize'))).')');
}
$form->addButtonSend(get_lang('SendMessage'), 'compose');

@ -435,29 +435,12 @@ if (!empty($student_id)) {
$coachs_name = '';
$session_name = '';
//$nb_login = Tracking :: count_login_per_student($user_info['user_id'], $courseInfo['real_id']);
//get coach and session_name if there is one and if session_mode is activated
/*if ($sessionId > 0) {
$session_info = api_get_session_info($sessionId);
$session_coach_id = $session_info['session_admin_id'];
$course_coachs = api_get_coachs_from_course($sessionId, $courseInfo['real_id']);
// $nb_login = '';
if (!empty($course_coachs)) {
$info_tutor_name = array();
foreach ($course_coachs as $course_coach) {
$info_tutor_name[] = api_get_person_name($course_coach['firstname'], $course_coach['lastname']);
}
$courseInfo['tutor_name'] = implode(",", $info_tutor_name);
} elseif ($session_coach_id != 0) {
$session_coach_id = intval($session_info['id_coach']);
$coach_info = api_get_user_info($session_coach_id);
$courseInfo['tutor_name'] = $coach_info['complete_name'];
}
$coachs_name = $courseInfo['tutor_name'];
$session_name = $session_info['name'];
} // end*/
$table_title = Display::return_icon('user.png', get_lang('User'), array(), ICON_SIZE_SMALL).$user_info['complete_name'];
$table_title = Display::return_icon(
'user.png',
get_lang('User'),
array(),
ICON_SIZE_SMALL
).$user_info['complete_name'];
echo Display::page_subheader($table_title);

@ -1545,18 +1545,7 @@ class learnpath
// TODO: Update the item object (can be ignored for now because refreshed).
return true;
}
/**
* Escapes a string with the available database escape function
* @param string String to escape
* @return string String escaped
* @deprecated use Database::escape_string
*/
public function escape_string($string)
{
return Database::escape_string($string);
}
/**
* Static admin function exporting a learnpath into a zip file
* @param string Export type (scorm, zip, cd)

@ -1,11 +1,14 @@
<?php
require_once(dirname(__FILE__).'/../inc/global.inc.php');
$libpath = api_get_path(LIBRARY_PATH);
/**
* Error returned by one of the methods of the web service. Contains an error code and an error message
*/
class WSCMError {
class WSCMError
{
/**
* Error handler. This needs to be a class that implements the interface WSErrorHandler
*
@ -33,7 +36,8 @@ class WSCMError {
* @param int Error code
* @param string Error message
*/
public function __construct($code, $message) {
public function __construct($code, $message)
{
$this->code = $code;
$this->message = $message;
}
@ -43,7 +47,8 @@ class WSCMError {
*
* @param WSErrorHandler Error handler
*/
public static function setErrorHandler($handler) {
public static function setErrorHandler($handler)
{
if($handler instanceof WSErrorHandler) {
self::$_handler = $handler;
}
@ -54,7 +59,8 @@ class WSCMError {
*
* @return WSErrorHandler Error handler
*/
public static function getErrorHandler() {
public static function getErrorHandler()
{
return self::$_handler;
}
@ -63,7 +69,8 @@ class WSCMError {
*
* @return array Associative array with code and message
*/
public function toArray() {
public function toArray()
{
return array('code' => $this->code, 'message' => $this->message);
}
}
@ -71,7 +78,8 @@ class WSCMError {
/**
* Interface that must be implemented by any error handler
*/
interface WSCMErrorHandler {
interface WSCMErrorHandler
{
/**
* Handle method
*
@ -83,7 +91,8 @@ interface WSCMErrorHandler {
/**
* Main class of the webservice. Webservice classes extend this class
*/
class WSCM {
class WSCM
{
/**
* Chamilo configuration
*
@ -94,7 +103,8 @@ class WSCM {
/**
* Constructor
*/
public function __construct() {
public function __construct()
{
$this->_configuration = $GLOBALS['_configuration'];
}
@ -104,7 +114,8 @@ class WSCM {
* @param string Secret key
* @return mixed WSError in case of failure, null in case of success
*/
protected function verifyKey($secret_key) {
protected function verifyKey($secret_key)
{
$ip = trim($_SERVER['REMOTE_ADDR']);
// if we are behind a reverse proxy, assume it will send the
// HTTP_X_FORWARDED_FOR header and use this IP instead
@ -121,73 +132,69 @@ class WSCM {
}
}
/**
* Verifies if the user is valid
*
* @param <String> $username of the user in chamilo
* @param <String> $pass of the same user (in MD5 of SHA)
*
* return "valid" if username e password are correct! Else, return a message error
*/
/**
* Verifies if the user is valid
*
* @param <String> $username of the user in chamilo
* @param <String> $pass of the same user (in MD5 of SHA)
*
* return "valid" if username e password are correct! Else, return a message error
*/
public function verifyUserPass($username, $pass) {
$login = $username;
$password = $pass;
public function verifyUserPass($username, $pass)
{
$login = $username;
$password = $pass;
//lookup the user in the main database
$user_table = Database::get_main_table(TABLE_MAIN_USER);
$sql = "SELECT user_id, username, password, auth_source, active, expiration_date
FROM $user_table
WHERE username = '".trim(addslashes($login))."'";
$result = Database::query($sql);
//lookup the user in the main database
$user_table = Database::get_main_table(TABLE_MAIN_USER);
$sql = "SELECT user_id, username, password, auth_source, active, expiration_date
FROM $user_table
WHERE username = '".trim(addslashes($login))."'";
$result = Database::query($sql);
if (Database::num_rows($result) > 0) {
$uData = Database::fetch_array($result);
if (Database::num_rows($result) > 0) {
$uData = Database::fetch_array($result);
if ($uData['auth_source'] == PLATFORM_AUTH_SOURCE) {
$password = trim(stripslashes($password));
// Check the user's password
if ($password == $uData['password'] AND (trim($login) == $uData['username'])) {
// Check if the account is active (not locked)
if ($uData['active']=='1') {
// Check if the expiration date has not been reached
if ($uData['expiration_date']>date('Y-m-d H:i:s') OR $uData['expiration_date']=='0000-00-00 00:00:00') {
return "valid";
}
else
return get_lang('AccountExpired');
}
else
return get_lang('AccountInactive');
if ($uData['auth_source'] == PLATFORM_AUTH_SOURCE) {
$password = trim(stripslashes($password));
// Check the user's password
if ($password == $uData['password'] AND (trim($login) == $uData['username'])) {
// Check if the account is active (not locked)
if ($uData['active'] == '1') {
// Check if the expiration date has not been reached
if ($uData['expiration_date'] > date(
'Y-m-d H:i:s'
) OR $uData['expiration_date'] == '0000-00-00 00:00:00'
) {
return "valid";
} else {
return get_lang('AccountExpired');
}
else
return get_lang('InvalidId');
} else {
return get_lang('AccountInactive');
}
else
return get_lang('AccountURLInactive');
} else {
return get_lang('InvalidId');
}
return get_lang('InvalidId');
} else {
return get_lang('AccountURLInactive');
}
}
return get_lang('InvalidId');
}
/**
* Return the encrypted pass
* @deprecated
* @param <String> $pass
* @return <String> $pass encrypted
*/
/*public function encryptPass($pass){
return api_get_encrypted_password($pass);
}*/
/**
* Gets the real user id based on the user id field name and value. Note that if the user id field name is "chamilo_user_id", it will use the user id
/**
* Gets the real user id based on the user id field name and value.
* Note that if the user id field name is "chamilo_user_id", it will use the user id
* in the system database
*
* @param string User id field name
* @param string User id value
* @return mixed System user id if the user was found, WSError otherwise
*/
protected function getUserId($user_id_field_name, $user_id_value) {
protected function getUserId($user_id_field_name, $user_id_value)
{
if($user_id_field_name == "chamilo_user_id") {
if(UserManager::is_user_id_valid(intval($user_id_value))) {
return intval($user_id_value);
@ -205,14 +212,16 @@ class WSCM {
}
/**
* Gets the real course id based on the course id field name and value. Note that if the course id field name is "chamilo_course_id", it will use the course id
* Gets the real course id based on the course id field name and value.
* Note that if the course id field name is "chamilo_course_id", it will use the course id
* in the system database
*
* @param string Course id field name
* @param string Course id value
* @return mixed System course id if the course was found, WSError otherwise
*/
protected function getCourseId($course_id_field_name, $course_id_value) {
protected function getCourseId($course_id_field_name, $course_id_value)
{
if($course_id_field_name == "chamilo_course_id") {
if(CourseManager::get_course_code_from_course_id(intval($course_id_value)) != null) {
return intval($course_id_value);
@ -230,7 +239,8 @@ class WSCM {
}
/**
* Gets the real session id based on the session id field name and value. Note that if the session id field name is "chamilo_session_id", it will use the session id
* Gets the real session id based on the session id field name and value.
* Note that if the session id field name is "chamilo_session_id", it will use the session id
* in the system database
*
* @param string Session id field name
@ -264,7 +274,8 @@ class WSCM {
*
* @param WSError Error
*/
protected function handleError($error) {
protected function handleError($error)
{
$handler = WSCMError::getErrorHandler();
$handler->handle($error);
}
@ -274,7 +285,8 @@ class WSCM {
*
* @return array Array with a code of 0 and a message 'Operation was successful'
*/
protected function getSuccessfulResult() {
protected function getSuccessfulResult()
{
return array('code' => 0, 'message' => 'Operation was successful');
}
@ -283,18 +295,19 @@ class WSCM {
*
* @return string Success
*/
public function test() {
public function test()
{
return "success";
}
/**
* *Strictly* reverts PHP's nl2br() effects (whether it was used in XHTML mode or not)
* @param <type> $string
* @return <type> $string
*/
public function nl2br_revert($string) {
return preg_replace('`<br(?: /)?>([\\n\\r])`', '$1', $string);
}
/**
* *Strictly* reverts PHP's nl2br() effects (whether it was used in XHTML mode or not)
* @param <type> $string
* @return <type> $string
*/
public function nl2br_revert($string) {
return preg_replace('`<br(?: /)?>([\\n\\r])`', '$1', $string);
}
}

@ -303,20 +303,6 @@ class TestForumFunction extends UnitTestCase {
//var_dump($res);
}
/**
* This function retrieves all the information of a given forum_id
* @param $forum_id integer that indicates the forum
* @return array returns
* @deprecated this functionality is now moved to get_forums($forum_id)
*/
/*
function testget_forum_information() {
$forum_id = 1;
$res = get_forum_information($forum_id);
$this->assertTrue(is_array($res));
//var_dump($res);
}*/
/**
* This function retrieves all the information of a given forumcategory id
* @param $forum_id integer that indicates the forum
@ -514,28 +500,7 @@ class TestForumFunction extends UnitTestCase {
}
//var_dump($res);
}
/**
* With this function we find the number of posts and topics in a given forum.
* @param int
* @return array
* @todo consider to call this function only once and let it return an array where the key is the forum id and the value is an array with number_of_topics and number of post
* as key of this array and the value as a value. This could reduce the number of queries needed (especially when there are more forums)
* @todo consider merging both in one query.
* @deprecated the counting mechanism is now inside the function get_forums
*/
/*
function testget_post_topics_of_forum() {
$forum_id = 1;
$res = get_post_topics_of_forum($forum_id);
if(!is_null($res)){
$this->assertTrue(is_array($res));
} else {
$this->assertTrue(is_null($res));
}
//var_dump($res);
}*/
/**
* Retrieve all posts of a given thread
* @param int $thread_id integer that indicates the forum

Loading…
Cancel
Save