-'.get_lang('UsersConnectedToMySessions').'';
@@ -110,7 +110,7 @@ if ((api_get_setting('showonline','world') == "true" AND !$_user['user_id']) OR
} else {
$number_online_in_course = 0;
}
-
+
echo "
";
// Display the who's online of the platform
if ((api_get_setting('showonline','world') == "true" AND !$_user['user_id']) OR (api_get_setting('showonline','users') == "true" AND $_user['user_id'])) {
@@ -148,7 +148,7 @@ if ( api_is_allowed_to_edit() ) {
' .$title. '' ."\n";
-
+
$list_body_blog[] = $list_name;
$list_body_blog[] = $info_log[1];
-
+
$visibility_icon=($info_log[2]==0) ? 'invisible' : 'visible';
$visibility_info=($info_log[2]==0) ? 'Visible' : 'Invisible';
$my_image.='';
@@ -2854,16 +2854,16 @@ class Blog {
$my_image.='';
$my_image.='';
$my_image.="\n";
-
+
$list_body_blog[]=$my_image;
$my_image='';
-
+
$list_content_blog[]=$list_body_blog;
$list_body_blog = array();
-
+
}
$parameters='';
- //$parameters=array('action'=>Security::remove_XSS($_GET['action']));
+ //$parameters=array('action'=>Security::remove_XSS($_GET['action']));
$table = new SortableTableFromArrayConfig($list_content_blog, 1,20,'project');
//$table->set_additional_parameters($parameters);
$table->set_header(0, get_lang('Title'));
@@ -2871,7 +2871,7 @@ class Blog {
$table->set_header(2, get_lang('Modify'));
$table->display();
}
-
+
/*$sql = "SELECT blog_id, blog_name, blog_subtitle, visibility FROM $tbl_blogs ORDER BY blog_name";
$result = api_sql_query($sql, __FILE__, __LINE__);
@@ -2905,35 +2905,35 @@ class Blog {
}
/**
- *
+ *
* END CLASS BLOG
- *
+ *
*/
/**
* Show a list with all the attachments according the parameter's
* @param the blog's id
- * @param the post's id
+ * @param the post's id
* @param the comment's id
- * @return array with the post info according the parameters
+ * @return array with the post info according the parameters
* @author Julio Montoya Dokeos
* @version avril 2008, dokeos 1.8.5
- */
+ */
function get_blog_attachment($blog_id, $post_id=null,$comment_id=null)
-{
+{
global $blog_table_attachment;
$blog_id = Database::escape_string($blog_id);
$comment_id = Database::escape_string($comment_id);
- $post_id = Database::escape_string($post_id);
-
+ $post_id = Database::escape_string($post_id);
+
$row=array();
$where='';
-
+
if (!empty ($post_id) && is_numeric($post_id))
{
$where.=' AND post_id ="'.$post_id.'" ';
}
-
+
if (!empty ($comment_id) && is_numeric($comment_id) )
{
if (!empty ($post_id) )
@@ -2941,42 +2941,42 @@ function get_blog_attachment($blog_id, $post_id=null,$comment_id=null)
$where.= ' AND ';
}
$where.=' comment_id ="'.$comment_id.'" ';
- }
-
+ }
+
$sql = 'SELECT path, filename, comment FROM '. $blog_table_attachment.' WHERE blog_id ="'.intval($blog_id).'" '.$where;
-
+
$result=api_sql_query($sql, __FILE__, __LINE__);
if (Database::num_rows($result)!=0)
{
$row=Database::fetch_array($result);
}
- return $row;
+ return $row;
}
/**
* Delete the all the attachments according the parameters.
* @param the blog's id
- * @param the post's id
+ * @param the post's id
* @param the comment's id
* @author Julio Montoya Dokeos
* @version avril 2008, dokeos 1.8.5
- */
+ */
function delete_all_blog_attachment($blog_id,$post_id=null,$comment_id=null)
-{
+{
global $blog_table_attachment;
global $_course;
-
+
$blog_id = Database::escape_string($blog_id);
$comment_id = Database::escape_string($comment_id);
- $post_id = Database::escape_string($post_id);
-
- // delete files in DB
+ $post_id = Database::escape_string($post_id);
+
+ // delete files in DB
if (!empty ($post_id) && is_numeric($post_id) )
{
$where.=' AND post_id ="'.$post_id.'" ';
}
-
+
if (!empty ($comment_id) && is_numeric($comment_id) )
{
if (!empty ($post_id) )
@@ -2985,44 +2985,44 @@ function delete_all_blog_attachment($blog_id,$post_id=null,$comment_id=null)
}
$where.=' comment_id ="'.$comment_id.'" ';
}
-
+
// delete all files in directory
$courseDir = $_course['path'].'/upload/blog';
- $sys_course_path = api_get_path(SYS_COURSE_PATH);
+ $sys_course_path = api_get_path(SYS_COURSE_PATH);
$updir = $sys_course_path.$courseDir;
-
- $sql= 'SELECT path FROM '.$blog_table_attachment.' WHERE blog_id ="'.intval($blog_id).'" '.$where;
+
+ $sql= 'SELECT path FROM '.$blog_table_attachment.' WHERE blog_id ="'.intval($blog_id).'" '.$where;
$result=api_sql_query($sql, __FILE__, __LINE__);
-
+
while ($row=Database::fetch_row($result))
{
- $file=$updir.'/'.$row[0];
+ $file=$updir.'/'.$row[0];
if (Security::check_abs_path($file,$updir) )
- {
+ {
@ unlink($file);
- }
- }
- $sql = 'DELETE FROM '. $blog_table_attachment.' WHERE blog_id ="'.intval($blog_id).'" '.$where;
+ }
+ }
+ $sql = 'DELETE FROM '. $blog_table_attachment.' WHERE blog_id ="'.intval($blog_id).'" '.$where;
api_sql_query($sql, __FILE__, __LINE__);
}
/**
* Gets all the post from a given user id
- * @param string db course name
+ * @param string db course name
* @param int user id
*/
function get_blog_post_from_user($course_db_name, $user_id) {
-
+
$tbl_blogs = Database::get_course_table(TABLE_BLOGS,$course_db_name);
$tbl_blog_post = Database::get_course_table(TABLE_BLOGS_POSTS,$course_db_name);
$sql = "SELECT DISTINCT blog.blog_id, post_id, title, full_text, post.date_creation
- FROM $tbl_blogs blog INNER JOIN $tbl_blog_post post
+ FROM $tbl_blogs blog INNER JOIN $tbl_blog_post post
ON (blog.blog_id = post.blog_id)
- WHERE author_id = $user_id AND visibility = 1
+ WHERE author_id = $user_id AND visibility = 1
ORDER BY post.date_creation DESC ";
$result = api_sql_query($sql, __FILE__, __LINE__);
$return_data = '';
//$my_course_info=explode('_',$course_db_name);
- $my_course_id=CourseManager::get_course_id_by_database_name($course_db_name);
+ $my_course_id=CourseManager::get_course_id_by_database_name($course_db_name);
if (Database::num_rows($result)!=0) {
while ($row=Database::fetch_array($result)) {
$return_data.= ' ';
@@ -3030,7 +3030,7 @@ function get_blog_post_from_user($course_db_name, $user_id) {
$return_data.= ' ';
//$return_data.= ''.$row['title'].''; echo ' ';
$return_data.= $row['full_text'];
- $return_data.= '
';
+ $return_data.= '
';
}
}
return $return_data;
@@ -3038,19 +3038,19 @@ function get_blog_post_from_user($course_db_name, $user_id) {
/**
* Gets all the post comments from a given user id
- * @param string db course name
+ * @param string db course name
* @param int user id
*/
function get_blog_comment_from_user($course_db_name, $user_id) {
-
+
$tbl_blogs = Database::get_course_table(TABLE_BLOGS,$course_db_name);
$tbl_blog_comment = Database::get_course_table(TABLE_BLOGS_COMMENTS,$course_db_name);
$user_id = Database::escape_string($user_id);
-
+
$sql = "SELECT DISTINCT blog.blog_id, comment_id, title, comment, comment.date_creation
- FROM $tbl_blogs blog INNER JOIN $tbl_blog_comment comment
+ FROM $tbl_blogs blog INNER JOIN $tbl_blog_comment comment
ON (blog.blog_id = comment.blog_id)
- WHERE author_id = $user_id AND visibility = 1
+ WHERE author_id = $user_id AND visibility = 1
ORDER BY blog_name";
$result = api_sql_query($sql, __FILE__, __LINE__);
$return_data = '';
@@ -3059,13 +3059,13 @@ function get_blog_comment_from_user($course_db_name, $user_id) {
while ($row=Database::fetch_array($result)) {
$return_data.= ' ';
$return_data.= '
';
- $return_data.= ' ';
+ $return_data.= ' ';
//$return_data.= ''.$row['title'].''; echo ' ';*/
$return_data.= $row['comment'];
$return_data.= ' ';
}
}
- return $return_data;
+ return $return_data;
}
?>
diff --git a/main/inc/lib/classmanager.lib.php b/main/inc/lib/classmanager.lib.php
index e71776496e..377c3d1756 100644
--- a/main/inc/lib/classmanager.lib.php
+++ b/main/inc/lib/classmanager.lib.php
@@ -1,32 +1,32 @@
';
echo 'LIBRARY_PATH :'.api_get_path(LIBRARY_PATH).' ';
echo 'CONFIGURATION_PATH :'.api_get_path(CONFIGURATION_PATH).' ';
-
+
}
diff --git a/main/inc/lib/document.lib.php b/main/inc/lib/document.lib.php
index 3812bc746c..0238fcae79 100644
--- a/main/inc/lib/document.lib.php
+++ b/main/inc/lib/document.lib.php
@@ -2,27 +2,27 @@
/*
==============================================================================
Dokeos - elearning and course management software
-
+
Copyright (c) 2004-2008 Dokeos SPRL
Copyright (c) 2003 Ghent University (UGent)
Copyright (c) Roan Embrechts, Vrije Universiteit Brussel
-
+
For a full list of contributors, see "credits.txt".
The full license can be read in "license.txt".
-
+
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
-
+
See the GNU General Public License for more details.
-
+
Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
Mail: info@dokeos.com
==============================================================================
*/
/**
-==============================================================================
+==============================================================================
* This is the document library for Dokeos.
* It is / will be used to provide a service layer to all document-using tools.
* and eliminate code duplication fro group documents, scorm documents, main documents.
@@ -30,20 +30,20 @@
*
* @version 1.1, January 2005
* @package dokeos.library
-==============================================================================
+==============================================================================
*/
/*
-==============================================================================
+==============================================================================
DOCUMENTATION
use the functions like this: DocumentManager::get_course_quota()
-==============================================================================
+==============================================================================
*/
/*
-==============================================================================
+==============================================================================
CONSTANTS
-==============================================================================
+==============================================================================
*/
define("DISK_QUOTA_FIELD", "disk_quota"); //name of the database field
@@ -51,9 +51,9 @@ define("DISK_QUOTA_FIELD", "disk_quota"); //name of the database field
define("DEFAULT_DOCUMENT_QUOTA", api_get_setting('default_document_quotum'));
/*
-==============================================================================
+==============================================================================
VARIABLES
-==============================================================================
+==============================================================================
*/
$sys_course_path = api_get_path(SYS_COURSE_PATH);
@@ -62,10 +62,10 @@ $baseServUrl = $_configuration['url_append']."/";
$baseWorkDir = $sys_course_path.(!empty($courseDir)?$courseDir:'');
/*
-==============================================================================
+==============================================================================
DocumentManager CLASS
the class and its functions
-==============================================================================
+==============================================================================
*/
/**
@@ -73,7 +73,7 @@ $baseWorkDir = $sys_course_path.(!empty($courseDir)?$courseDir:'');
*/
class DocumentManager {
private function __construct() {
-
+
}
/**
* @return the document folder quuta of the current course, in bytes
@@ -148,7 +148,7 @@ class DocumentManager {
"ez" => "application/andrew-inset",
"gif" => "image/gif",
"gtar" => "application/x-gtar",
- "gz" => "application/x-gzip",
+ "gz" => "application/x-gzip",
"hdf" => "application/x-hdf",
"hqx" => "application/mac-binhex40",
"htm" => "text/html",
@@ -259,8 +259,8 @@ class DocumentManager {
"wmlc" => "application/vnd.wap.wmlc",
"wmls" => "text/vnd.wap.wmlscript",
"wmlsc" => "application/vnd.wap.wmlscriptc",
- "wma" => "video/x-ms-wma",
- "wmv" => "audio/x-ms-wmv",
+ "wma" => "video/x-ms-wma",
+ "wmv" => "audio/x-ms-wmv",
"wrl" => "model/vrml",
"xbm" => "image/x-xbitmap",
"xht" => "application/xhtml+xml",
@@ -273,12 +273,12 @@ class DocumentManager {
"xyz" => "chemical/x-xyz",
"zip" => "application/zip"
);
-
- if ($filename === TRUE)
+
+ if ($filename === TRUE)
{
return $mime_types;
}
-
+
//get the extension of the file
$extension = explode('.', $filename);
@@ -317,7 +317,7 @@ class DocumentManager {
$tbl_item_property = $this_course.'item_property';
$doc_url = Database::escape_string($doc_url);
//$doc_url = addslashes($doc_url);
- $query = "SELECT 1 FROM $tbl_document AS docs,$tbl_item_property AS props
+ $query = "SELECT 1 FROM $tbl_document AS docs,$tbl_item_property AS props
WHERE props.tool = 'document' AND docs.id=props.ref AND props.visibility <> '1' AND docs.path = '$doc_url'";
//echo $query;
$result = api_sql_query($query, __FILE__, __LINE__);
@@ -479,7 +479,7 @@ class DocumentManager {
* @param int $to_group_id
* @param int $to_user_id
* @param boolean $can_see_invisible
- * @return array with all document data
+ * @return array with all document data
*/
public static function get_all_document_data ($_course, $path = '/', $to_group_id = 0, $to_user_id = NULL, $can_see_invisible = false) {
$TABLE_ITEMPROPERTY = Database::get_course_table(TABLE_ITEM_PROPERTY, $_course['dbName']);
@@ -520,9 +520,9 @@ class DocumentManager {
WHERE docs.id = last.ref
AND docs.path LIKE '".$path.$added_slash."%'
AND docs.path NOT LIKE '".$path.$added_slash."%/%'
- AND last.tool = '".TOOL_DOCUMENT."'
+ AND last.tool = '".TOOL_DOCUMENT."'
AND ".$to_field." = ".$to_value."
- AND last.visibility".$visibility_bit;
+ AND last.visibility".$visibility_bit;
$result = api_sql_query($sql);
@@ -531,13 +531,13 @@ class DocumentManager {
while ($row = Database::fetch_array($result,'ASSOC'))
//while ($row = Database::fetch_array($result,MYSQL_NUM))
{
-
+
if($row['filetype']=='file' && pathinfo($row['path'],PATHINFO_EXTENSION)=='html'){
-
+
//Templates management
$table_template = Database::get_main_table(TABLE_MAIN_TEMPLATES);
- $sql_is_template = "SELECT id FROM $table_template
- WHERE course_code='".$_course['id']."'
+ $sql_is_template = "SELECT id FROM $table_template
+ WHERE course_code='".$_course['id']."'
AND user_id='".api_get_user_id()."'
AND ref_doc='".$row['id']."'";
$template_result = api_sql_query($sql_is_template);
@@ -548,7 +548,7 @@ class DocumentManager {
$row['is_template'] = 0;
}
}
-
+
$document_data[$row['id']] = $row;
//$document_data[] = $row;
}
@@ -577,19 +577,19 @@ class DocumentManager {
} else {
$to_group_id = Database::escape_string($to_group_id);
}*/
-
+
if (!empty($to_group_id)) {
$to_group_id = intval($to_group_id);
}
-
+
if ($can_see_invisible)
{
$sql = "SELECT path
FROM ".$TABLE_ITEMPROPERTY." AS last, ".$TABLE_DOCUMENT." AS docs
WHERE docs.id = last.ref
- AND docs.filetype = 'folder'
- AND last.tool = '".TOOL_DOCUMENT."'
- AND last.to_group_id = ".$to_group_id."
+ AND docs.filetype = 'folder'
+ AND last.tool = '".TOOL_DOCUMENT."'
+ AND last.to_group_id = ".$to_group_id."
AND last.visibility <> 2";
$result = api_sql_query($sql, __FILE__, __LINE__);
@@ -619,9 +619,9 @@ class DocumentManager {
$visible_sql = "SELECT path
FROM ".$TABLE_ITEMPROPERTY." AS last, ".$TABLE_DOCUMENT." AS docs
WHERE docs.id = last.ref
- AND docs.filetype = 'folder'
- AND last.tool = '".TOOL_DOCUMENT."'
- AND last.to_group_id = ".$to_group_id."
+ AND docs.filetype = 'folder'
+ AND last.tool = '".TOOL_DOCUMENT."'
+ AND last.to_group_id = ".$to_group_id."
AND last.visibility = 1";
$visibleresult = api_sql_query($visible_sql, __FILE__, __LINE__);
while ($all_visible_folders = Database::fetch_array($visibleresult,'ASSOC'))
@@ -630,25 +630,25 @@ class DocumentManager {
//echo "visible folders: ".$all_visible_folders['path']." ";
}
//get invisible folders
- $invisible_sql = "SELECT path
+ $invisible_sql = "SELECT path
FROM ".$TABLE_ITEMPROPERTY." AS last, ".$TABLE_DOCUMENT." AS docs
WHERE docs.id = last.ref
- AND docs.filetype = 'folder'
- AND last.tool = '".TOOL_DOCUMENT."'
- AND last.to_group_id = ".$to_group_id."
+ AND docs.filetype = 'folder'
+ AND last.tool = '".TOOL_DOCUMENT."'
+ AND last.to_group_id = ".$to_group_id."
AND last.visibility = 0";
$invisibleresult = api_sql_query($invisible_sql, __FILE__, __LINE__);
while ($invisible_folders = Database::fetch_array($invisibleresult,'ASSOC'))
{
//get visible folders in the invisible ones -> they are invisible too
//echo "invisible folders: ".$invisible_folders['path']." ";
- $folder_in_invisible_sql = "SELECT path
+ $folder_in_invisible_sql = "SELECT path
FROM ".$TABLE_ITEMPROPERTY." AS last, ".$TABLE_DOCUMENT." AS docs
WHERE docs.id = last.ref
- AND docs.path LIKE '".Database::escape_string($invisible_folders['path'])."/%'
- AND docs.filetype = 'folder'
- AND last.tool = '".TOOL_DOCUMENT."'
- AND last.to_group_id = ".$to_group_id."
+ AND docs.path LIKE '".Database::escape_string($invisible_folders['path'])."/%'
+ AND docs.filetype = 'folder'
+ AND last.tool = '".TOOL_DOCUMENT."'
+ AND last.to_group_id = ".$to_group_id."
AND last.visibility = 1";
$folder_in_invisible_result = api_sql_query($folder_in_invisible_sql, __FILE__, __LINE__);
while ($folders_in_invisible_folder = Database::fetch_array($folder_in_invisible_result,'ASSOC'))
@@ -681,26 +681,26 @@ class DocumentManager {
return false;
}
}
- }
+ }
/**
* This check if a document has the readonly property checked, then see if the user
* is the owner of this file, if all this is true then return true.
- *
+ *
* @param array $_course
* @param int $user_id id of the current user
* @param string $file path stored in the database
* @param int $document_id in case you dont have the file path ,insert the id of the file here and leave $file in blank ''
- * @return boolean true/false
+ * @return boolean true/false
**/
public static function check_readonly ($_course,$user_id,$file,$document_id='',$to_delete=false) {
if(!(!empty($document_id) && is_numeric($document_id)))
- {
+ {
$document_id = self::get_document_id($_course, $file);
- }
-
+ }
+
$TABLE_PROPERTY = Database::get_course_table(TABLE_ITEM_PROPERTY, $_course['dbName']);
$TABLE_DOCUMENT = Database::get_course_table(TABLE_DOCUMENT, $_course['dbName']);
-
+
if ($to_delete)
{
if (self::is_folder($_course, $document_id))
@@ -708,83 +708,83 @@ class DocumentManager {
if (!empty($file))
{
$path = Database::escape_string($file);
- $what_to_check_sql = "SELECT td.id, readonly, tp.insert_user_id FROM ".$TABLE_DOCUMENT." td , $TABLE_PROPERTY tp
+ $what_to_check_sql = "SELECT td.id, readonly, tp.insert_user_id FROM ".$TABLE_DOCUMENT." td , $TABLE_PROPERTY tp
WHERE tp.ref= td.id and (path='".$path."' OR path LIKE BINARY '".$path."/%' ) ";
//get all id's of documents that are deleted
$what_to_check_result = api_sql_query($what_to_check_sql, __FILE__, __LINE__);
-
+
if ($what_to_check_result && Database::num_rows($what_to_check_result) != 0)
{
// file with readonly set to 1 exist?
$readonly_set=false;
while ($row = Database::fetch_array($what_to_check_result))
{
- //query to delete from item_property table
+ //query to delete from item_property table
//echo $row['id']; echo " ";
- if ($row['readonly']==1)
- {
+ if ($row['readonly']==1)
+ {
if (!($row['insert_user_id'] == $user_id))
- {
+ {
$readonly_set=true;
break;
- }
-
+ }
+
}
}
-
+
if ($readonly_set)
{
return true;
}
}
- }
- return false;
+ }
+ return false;
}
}
-
-
-
+
+
+
if (!empty($document_id))
- {
+ {
$sql= 'SELECT a.insert_user_id, b.readonly FROM '.$TABLE_PROPERTY.' a,'.$TABLE_DOCUMENT.' b
WHERE a.ref = b.id and a.ref='.$document_id.' LIMIT 1';
$resultans = api_sql_query($sql, __FILE__, __LINE__);
$doc_details = Database ::fetch_array($resultans,'ASSOC');
-
+
if($doc_details['readonly']==1)
- {
- if ( $doc_details['insert_user_id'] == $user_id || api_is_platform_admin() )
- {
- return false;
+ {
+ if ( $doc_details['insert_user_id'] == $user_id || api_is_platform_admin() )
+ {
+ return false;
}
else
- {
- return true;
- }
- }
+ {
+ return true;
+ }
+ }
}
return false;
}
-
+
/**
- * This check if a document is a folder or not
+ * This check if a document is a folder or not
* @param array $_course
* @param int $document_id of the item
- * @return boolean true/false
+ * @return boolean true/false
**/
- public static function is_folder ($_course, $document_id) {
+ public static function is_folder ($_course, $document_id) {
$TABLE_DOCUMENT = Database::get_course_table(TABLE_DOCUMENT, $_course['dbName']);
//if (!empty($document_id))
$document_id = Database::escape_string($document_id);
- $resultans = api_sql_query('SELECT filetype FROM '.$TABLE_DOCUMENT.' WHERE id='.$document_id.'', __FILE__, __LINE__);
+ $resultans = api_sql_query('SELECT filetype FROM '.$TABLE_DOCUMENT.' WHERE id='.$document_id.'', __FILE__, __LINE__);
$result= Database::fetch_array($resultans,'ASSOC');
if ($result['filetype']=='folder') {
- return true;
+ return true;
} else {
return false;
- }
+ }
}
-
+
/**
* This deletes a document by changing visibility to 2, renaming it to filename_DELETED_#id
* Files/folders that are inside a deleted folder get visibility 2
@@ -808,7 +808,7 @@ class DocumentManager {
$what_to_delete_sql = "SELECT id FROM ".$TABLE_DOCUMENT." WHERE path='".$path."' OR path LIKE BINARY '".$path."/%'";
//get all id's of documents that are deleted
$what_to_delete_result = api_sql_query($what_to_delete_sql, __FILE__, __LINE__);
-
+
if ($what_to_delete_result && Database::num_rows($what_to_delete_result) != 0)
{
//needed to deleted medadata
@@ -821,10 +821,10 @@ class DocumentManager {
{
//query to delete from item_property table
//avoid wrong behavior
-
+
//$remove_from_item_property_sql = "DELETE FROM ".$TABLE_ITEMPROPERTY." WHERE ref = ".$row['id']." AND tool='".TOOL_DOCUMENT."'";
api_item_property_update($_course, TOOL_DOCUMENT, $row['id'], 'delete', api_get_user_id());
-
+
//query to delete from document table
$remove_from_document_sql = "DELETE FROM ".$TABLE_DOCUMENT." WHERE id = ".$row['id']."";
self::unset_document_as_template($row['id'],$_course, api_get_user_id());
@@ -855,13 +855,13 @@ class DocumentManager {
else //set visibility to 2 and rename file/folder to qsdqsd_DELETED_#id
{
if (api_item_property_update($_course, TOOL_DOCUMENT, $document_id, 'delete', api_get_user_id()))
- {
+ {
//echo('item_property_update OK');
if (is_file($base_work_dir.$path) || is_dir($base_work_dir.$path) )
{
if(rename($base_work_dir.$path, $base_work_dir.$new_path))
{
- self::unset_document_as_template($document_id, api_get_course_id(), api_get_user_id());
+ self::unset_document_as_template($document_id, api_get_course_id(), api_get_user_id());
$sql = "UPDATE $TABLE_DOCUMENT set path='".$new_path."' WHERE id='".$document_id."'";
if (api_sql_query($sql, __FILE__, __LINE__))
{
@@ -875,7 +875,7 @@ class DocumentManager {
//echo('to delete also: id '.$deleted_items['id']);
api_item_property_update($_course, TOOL_DOCUMENT, $deleted_items['id'], 'delete', api_get_user_id());
//Change path of subfolders and documents in database
- $old_item_path = $deleted_items['path'];
+ $old_item_path = $deleted_items['path'];
$new_item_path = $new_path.substr($old_item_path, strlen($path));
/*/
* trying to fix this bug FS#2681
@@ -887,18 +887,18 @@ class DocumentManager {
*/
self::unset_document_as_template($deleted_items['id'], api_get_course_id(), api_get_user_id());
$sql = "UPDATE $TABLE_DOCUMENT set path = '".$new_item_path."' WHERE id = ".$deleted_items['id'];
-
- api_sql_query($sql, __FILE__, __LINE__);
+
+ api_sql_query($sql, __FILE__, __LINE__);
}
}
-
+
self::delete_document_from_search_engine(api_get_course_id(), $document_id);
return true;
}
}
else
{
- //Couldn't rename - file permissions problem?
+ //Couldn't rename - file permissions problem?
error_log(__FILE__.' '.__LINE__.': Error renaming '.$base_work_dir.$path.' to '.$base_work_dir.$new_path.'. This is probably due to file permissions',0);
}
}
@@ -914,13 +914,13 @@ class DocumentManager {
self::delete_document_from_search_engine(api_get_course_id(), $document_id);
- while ( $row = Database::fetch_array($res) )
+ while ( $row = Database::fetch_array($res) )
{
$sqlipd = "DELETE FROM $TABLE_ITEMPROPERTY WHERE ref = ".$row['id']." AND tool='".TOOL_DOCUMENT."'";
$resipd = Database::query($sqlipd,__FILE__,__LINE__);
self::unset_document_as_template($row['id'],api_get_course_id(), api_get_user_id());
$sqldd = "DELETE FROM $TABLE_DOCUMENT WHERE id = ".$row['id'];
- $resdd = Database::query($sqldd,__FILE__,__LINE__);
+ $resdd = Database::query($sqldd,__FILE__,__LINE__);
}
}
}
@@ -949,7 +949,7 @@ class DocumentManager {
require_once(api_get_path(LIBRARY_PATH) .'search/DokeosIndexer.class.php');
$di = new DokeosIndexer();
$di->remove_document((int)$row2['search_did']);
- }
+ }
$sql = 'DELETE FROM %s WHERE course_code=\'%s\' AND tool_id=\'%s\' AND ref_id_high_level=%s LIMIT 1';
$sql = sprintf($sql, $tbl_se_ref, $course_id, TOOL_DOCUMENT, $document_id);
api_sql_query($sql, __FILE__, __LINE__);
@@ -969,7 +969,7 @@ class DocumentManager {
*/
public static function get_document_id ($_course, $path) {
$TABLE_DOCUMENT = Database :: get_course_table(TABLE_DOCUMENT, $_course['dbName']);
- $path = Database::escape_string($path);
+ $path = Database::escape_string($path);
$sql = "SELECT id FROM $TABLE_DOCUMENT WHERE path LIKE BINARY '$path'";
$result = api_sql_query($sql, __FILE__, __LINE__);
if ($result && Database::num_rows($result) == 1) {
@@ -979,8 +979,8 @@ class DocumentManager {
return false;
}
}
-
-
+
+
/**
* Allow to set a specific document as a new template for FCKEditor for a particular user in a particular course
*
@@ -993,8 +993,8 @@ class DocumentManager {
public static function set_document_as_template ($title, $description, $document_id_for_template, $couse_code, $user_id, $image) {
// Database table definition
$table_template = Database::get_main_table(TABLE_MAIN_TEMPLATES);
-
- // creating the sql statement
+
+ // creating the sql statement
$sql = "INSERT INTO ".$table_template."
(title, description, course_code, user_id, ref_doc, image)
VALUES (
@@ -1003,13 +1003,13 @@ class DocumentManager {
'".Database::escape_string($couse_code)."',
'".Database::escape_string($user_id)."',
'".Database::escape_string($document_id_for_template)."',
- '".Database::escape_string($image)."')";
+ '".Database::escape_string($image)."')";
api_sql_query($sql);
-
+
return true;
}
-
-
+
+
/**
* Unset a document as template
*
@@ -1018,23 +1018,23 @@ class DocumentManager {
* @param int $user_id
*/
public static function unset_document_as_template ($document_id, $course_code, $user_id) {
-
+
$table_template = Database::get_main_table(TABLE_MAIN_TEMPLATES);
$course_code = Database::escape_string($course_code);
$user_id = Database::escape_string($user_id);
$document_id = Database::escape_string($document_id);
-
+
$sql = 'SELECT id FROM '.$table_template.' WHERE course_code="'.$course_code.'" AND user_id="'.$user_id.'" AND ref_doc="'.$document_id.'"';
$result = api_sql_query($sql);
$template_id = Database::result($result,0,0);
-
+
include_once(api_get_path(LIBRARY_PATH) . 'fileManage.lib.php');
my_delete(api_get_path(SYS_CODE_PATH).'upload/template_thumbnails/'.$template_id.'.jpg');
-
+
$sql = 'DELETE FROM '.$table_template.' WHERE course_code="'.$course_code.'" AND user_id="'.$user_id.'" AND ref_doc="'.$document_id.'"';
-
+
api_sql_query($sql);
-
+
}
/**
* return true if the documentpath have visibility=1 as item_property
@@ -1048,7 +1048,7 @@ class DocumentManager {
//note the extra / at the end of doc_path to match every path in the
// document table that is part of the document path
$doc_path = Database::escape_string($doc_path);
-
+
$sql = "SELECT path FROM $docTable d, $propTable ip " .
"where d.id=ip.ref AND ip.tool='".TOOL_DOCUMENT."' AND d.filetype='file' AND visibility=0 AND ".
"locate(concat(path,'/'),'".$doc_path."/')=1";
@@ -1058,10 +1058,10 @@ class DocumentManager {
//echo "$row[0] not visible";
return false;
}
-
+
//improved protection of documents viewable directly through the url: incorporates the same protections of the course at the url of documents: access allowed for the whole world Open, access allowed for users registered on the platform Private access, document accessible only to course members (see the Users list), Completely closed; the document is only accessible to the course admin and teaching assistants.
if ($_SESSION ['is_allowed_in_course'] || api_is_platform_admin())
- {
+ {
return true; // ok, document is visible
}
else
diff --git a/main/inc/lib/events.lib.inc.php b/main/inc/lib/events.lib.inc.php
index 19342d5207..0d175494bc 100644
--- a/main/inc/lib/events.lib.inc.php
+++ b/main/inc/lib/events.lib.inc.php
@@ -134,7 +134,7 @@ function event_access_course()
if(api_get_setting('use_session_mode')=='true' && isset($_SESSION['id_session']))
{
$id_session = intval($_SESSION['id_session']);
- }
+ }
else
{
$id_session = 0;
@@ -364,7 +364,7 @@ function event_link($link_id)
// anonymous
$user_id = "0";
}
-
+
$sql = "INSERT INTO ".$TABLETRACK_LINKS."
( links_user_id,
links_cours_id,
@@ -405,7 +405,7 @@ function update_event_exercice($exeid,$exo_id, $score, $weighting,$session_id,$l
exe_result = '".Database::escape_string($score)."',
exe_weighting = '".Database::escape_string($weighting)."',
session_id = '".Database::escape_string($session_id)."',
- orig_lp_id = '".Database::escape_string($learnpath_id)."',
+ orig_lp_id = '".Database::escape_string($learnpath_id)."',
orig_lp_item_id = '".Database::escape_string($learnpath_item_id)."',
exe_duration = '".Database::escape_string($duration)."',
exe_date= FROM_UNIXTIME(".$reallyNow."),status = '', data_tracking='',start_date =FROM_UNIXTIME(".Database::escape_string($_SESSION['exercice_start_date']).")
@@ -472,7 +472,7 @@ function exercise_attempt($score,$answer,$quesId,$exeId,$j)
$quesId = Database::escape_string($quesId);
$exeId = Database::escape_string($exeId);
$j = Database::escape_string($j);
-
+
global $_configuration, $_user, $_cid;
$TBL_TRACK_ATTEMPT = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
@@ -542,7 +542,7 @@ function exercise_attempt($score,$answer,$quesId,$exeId,$j)
* @param int Whether this answer is correct (1) or not (0)
* @param string Coordinates of this point (e.g. 123;324)
* @return boolean Result of the insert query
- * @uses Course code and user_id from global scope $_cid and $_user
+ * @uses Course code and user_id from global scope $_cid and $_user
*/
function exercise_attempt_hotspot($exe_id, $question_id, $answer_id, $correct, $coords)
{
@@ -581,14 +581,14 @@ function event_system($event_type, $event_value_type, $event_value, $timestamp =
global $_configuration;
global $_user;
global $TABLETRACK_DEFAULT;
-
+
$event_type = Database::escape_string($event_type);
$event_value_type = Database::escape_string($event_value_type);
$event_value = Database::escape_string($event_value);
$timestamp = Database::escape_string($timestamp);
$user_id = Database::escape_string($user_id);
$course_code = Database::escape_string($course_code);
-
+
// if tracking is disabled record nothing
if (!$_configuration['tracking_enabled'])
diff --git a/main/inc/lib/export.lib.inc.php b/main/inc/lib/export.lib.inc.php
index e250c6bbd7..7cad14c370 100644
--- a/main/inc/lib/export.lib.inc.php
+++ b/main/inc/lib/export.lib.inc.php
@@ -35,34 +35,34 @@
require_once ('document.lib.php');
class Export {
private function __construct() {
-
+
}
/**
* Export tabular data to CSV-file
* @param array $data
* @param string $filename
*/
- public static function export_table_csv ($data, $filename = 'export') {
+ public static function export_table_csv ($data, $filename = 'export') {
$file = api_get_path(SYS_ARCHIVE_PATH).uniqid('').'.csv';
- $handle = @fopen($file, 'a+');
-
+ $handle = @fopen($file, 'a+');
+
if(is_array($data))
{
foreach ($data as $index => $row)
{
$line='';
if(is_array($row))
- {
- foreach($row as $value)
- {
+ {
+ foreach($row as $value)
+ {
$line .= '"'.str_replace('"','""',$value).'";';
}
}
- @fwrite($handle, $line."\n");
+ @fwrite($handle, $line."\n");
}
}
- @fclose($handle);
- DocumentManager :: file_send_for_download($file, true, $filename.'.csv');
+ @fclose($handle);
+ DocumentManager :: file_send_for_download($file, true, $filename.'.csv');
exit();
}
/**
@@ -72,11 +72,11 @@ class Export {
*/
public static function export_table_xls ($data, $filename = 'export') {
$file = api_get_path(SYS_ARCHIVE_PATH).uniqid('').'.xls';
- $handle = @fopen($file, 'a+');
- foreach ($data as $index => $row)
- {
- @fwrite($handle, implode("\t", $row)."\n");
- }
+ $handle = @fopen($file, 'a+');
+ foreach ($data as $index => $row)
+ {
+ @fwrite($handle, implode("\t", $row)."\n");
+ }
@fclose($handle);
DocumentManager :: file_send_for_download($file, true, $filename.'.xls');
exit();
@@ -132,7 +132,7 @@ class Export {
$file = api_get_path(SYS_ARCHIVE_PATH).'/'.uniqid('').'.xml';
$handle = fopen($file, 'a+');
fwrite($handle, ''."\n");
-
+
if (!is_null($wrapper_tagname))
{
fwrite($handle, '<'.$wrapper_tagname.'>');
diff --git a/main/inc/lib/fileDisplay.lib.php b/main/inc/lib/fileDisplay.lib.php
index cd7b267c18..9fee9f052a 100644
--- a/main/inc/lib/fileDisplay.lib.php
+++ b/main/inc/lib/fileDisplay.lib.php
@@ -1,40 +1,40 @@
2' : '= 1');
$sql = <<
diff --git a/main/inc/lib/fileManage.lib.php b/main/inc/lib/fileManage.lib.php
index 3cb9d86592..c201caf81c 100644
--- a/main/inc/lib/fileManage.lib.php
+++ b/main/inc/lib/fileManage.lib.php
@@ -819,7 +819,7 @@ class FileManager
else
{
FileManager :: mkdirs(dirname($path), $mode);
- //mkdir($path, $mode);
+ //mkdir($path, $mode);
return true;
}
}
diff --git a/main/inc/lib/fileUpload.lib.php b/main/inc/lib/fileUpload.lib.php
index efbf3fb068..f14394aa7b 100644
--- a/main/inc/lib/fileUpload.lib.php
+++ b/main/inc/lib/fileUpload.lib.php
@@ -74,7 +74,7 @@ function api_replace_parameter($upload_path, $buffer, $param_name="src")
/**
* Replaces all accentuated characters by non-accentuated characters for filenames, as
* well as special HTML characters by their HTML entity's first letter.
- *
+ *
* Although this method is not absolute, it gives good results in general. It first
* transforms the string to HTML entities (ô, @oslash;, etc) then removes the
* HTML character part to result in simple characters (o, o, etc).
@@ -253,10 +253,10 @@ function handle_uploaded_document($_course,$uploaded_file,$base_work_dir,$upload
Display::display_error_message(get_lang('UplNotEnoughSpace'));
return false;
}
-
+
//if the want to unzip, check if the file has a .zip (or ZIP,Zip,ZiP,...) extension
if ($unzip == 1 && preg_match("/.zip$/", strtolower($uploaded_file['name'])) )
- {
+ {
return unzip_uploaded_document($uploaded_file, $upload_path, $base_work_dir, $maxFilledSpace, $output, $to_group_id);
//display_message("Unzipping file");
}
@@ -305,16 +305,16 @@ function handle_uploaded_document($_course,$uploaded_file,$base_work_dir,$upload
$document_name = get_document_title($uploaded_file['name']);
//size of the uploaded file (in bytes)
$file_size = $uploaded_file['size'];
-
+
$files_perm = api_get_setting('permissions_for_new_files');
$files_perm = octdec(!empty($files_perm)?$files_perm:'0770');
-
+
//what to do if the target file exists
switch ($what_if_file_exists)
{
//overwrite the file if it exists
case 'overwrite':
-
+
//check if the target file exists, so we can give another message
if (file_exists($store_path))
{
@@ -368,17 +368,17 @@ function handle_uploaded_document($_course,$uploaded_file,$base_work_dir,$upload
return false;
}
break;
-
+
//rename the file if it exists
case 'rename':
$new_name = unique_name($where_to_save, $clean_name);
$store_path = $where_to_save.$new_name;
$new_file_path = $upload_path.$new_name;
-
+
if (@move_uploaded_file($uploaded_file['tmp_name'], $store_path))
{
chmod($store_path,$files_perm);
-
+
//put the document data in the database
$document_id = add_document($_course,$new_file_path,'file',$file_size,$document_name);
if ($document_id)
@@ -400,7 +400,7 @@ function handle_uploaded_document($_course,$uploaded_file,$base_work_dir,$upload
return false;
}
break;
-
+
//only save the file if it doesn't exist or warn user if it does exist
default:
if (file_exists($store_path))
@@ -410,9 +410,9 @@ function handle_uploaded_document($_course,$uploaded_file,$base_work_dir,$upload
else
{
if (@move_uploaded_file($uploaded_file['tmp_name'], $store_path))
- {
+ {
chmod($store_path,$files_perm);
-
+
//put the document data in the database
$document_id = add_document($_course,$file_path,'file',$file_size,$document_name);
if ($document_id)
@@ -903,13 +903,13 @@ function unzip_uploaded_document($uploaded_file, $upload_path, $base_work_dir, $
global $_user;
global $to_user_id;
global $to_group_id;
-
+
$zip_file = new pclZip($uploaded_file['tmp_name']);
// Check the zip content (real size and file extension)
$zip_content_array = $zip_file->listContent();
-
+
foreach((array) $zip_content_array as $this_content)
{
$real_filesize += $this_content['size'];
@@ -935,7 +935,7 @@ function unzip_uploaded_document($uploaded_file, $upload_path, $base_work_dir, $
$save_dir = getcwd();
chdir($base_work_dir.$upload_path);
//we extract using a callback function that "cleans" the path
- $unzipping_state = $zip_file->extract(PCLZIP_CB_PRE_EXTRACT, 'clean_up_files_in_zip');
+ $unzipping_state = $zip_file->extract(PCLZIP_CB_PRE_EXTRACT, 'clean_up_files_in_zip');
// Add all documents in the unzipped folder to the database
add_all_documents_in_folder_to_database($_course,$_user['user_id'],$base_work_dir,$upload_path == '/' ? '' : $upload_path, $to_group_id);
//Display::display_normal_message(get_lang('UplZipExtractSuccess'));
@@ -1081,7 +1081,7 @@ function clean_up_path(&$path)
/**
* Check if the file is dangerous, based on extension and/or mimetype.
- * The list of extensions accepted/rejected can be found from
+ * The list of extensions accepted/rejected can be found from
* api_get_setting('upload_extensions_exclude') and api_get_setting('upload_extensions_include')
* @param string filename passed by reference. The filename will be modified if filter rules say so! (you can include path but the filename should look like 'abc.html')
* @return int 0 to skip file, 1 to keep file
@@ -1193,7 +1193,7 @@ function get_document_id() moved to document.lib.php
* @return boolean true /false
*/
function update_existing_document($_course,$document_id,$filesize,$readonly=0)
-{
+{
$document_table = Database::get_course_table(TABLE_DOCUMENT,$_course['dbName']);
$sql="UPDATE $document_table SET size = '$filesize' , readonly = '$readonly' WHERE id='$document_id'";
if(api_sql_query($sql,__FILE__,__LINE__))
@@ -1838,7 +1838,7 @@ function build_missing_files_form($missing_files,$upload_path,$file_name)
}
$form .= "\n"
.""
- .""
+ .""
."\n";
return $form;
}
@@ -1856,7 +1856,7 @@ function add_all_documents_in_folder_to_database($_course,$user_id,$base_work_di
{
$path = $base_work_dir.$current_path;
-
+
//open dir
$handle=opendir($path);
//run trough
@@ -1866,7 +1866,7 @@ function add_all_documents_in_folder_to_database($_course,$user_id,$base_work_di
$completepath="$path/$file";
//directory?
-
+
if (is_dir($completepath))
{
$title=get_document_title($file);
@@ -1889,7 +1889,7 @@ function add_all_documents_in_folder_to_database($_course,$user_id,$base_work_di
//rename
$safe_file=disable_dangerous_file(replace_dangerous_char($file));
@rename($base_work_dir.$current_path.'/'.$file,$base_work_dir.$current_path.'/'.$safe_file);
-
+
if(!DocumentManager::get_document_id($_course, $current_path.'/'.$safe_file))
{
$title=get_document_title($file);
diff --git a/main/inc/lib/groupmanager.lib.php b/main/inc/lib/groupmanager.lib.php
index 0a7758d806..2821a72267 100644
--- a/main/inc/lib/groupmanager.lib.php
+++ b/main/inc/lib/groupmanager.lib.php
@@ -90,7 +90,7 @@ class GroupManager {
* GROUP FUNCTIONS
==============================================================================*/
private function __construct() {
-
+
}
/**
* Get list of groups for current course.
@@ -118,7 +118,7 @@ class GroupManager {
$session_id=isset($_SESSION['id_session']) ? $_SESSION['id_session'] : 0;
$session_condition = intval($session_id)==0 ? '' : ' g.session_id = '.intval($session_id).' ';
$my_status_of_user_in_course=CourseManager::get_user_in_course_status($my_user_id,$my_course_code);
-
+
$is_student_in_session=false;
if (is_null($my_status_of_user_in_course) || $my_status_of_user_in_course=='') {//into session
if ($session_id>0) {
@@ -144,7 +144,7 @@ class GroupManager {
ON `ug`.`group_id` = `g`.`id` AND `ug`.`user_id` = '".$_user['user_id']."'
LEFT JOIN ".$table_group_user." `ug2`
ON `ug2`.`group_id` = `g`.`id`";
-
+
} elseif ($my_status_of_user_in_course==STUDENT || $is_student_in_session===true || $_SESSION['studentview'] == 'studentview') {
$sql = "SELECT g.id ,
g.name ,
@@ -163,7 +163,7 @@ class GroupManager {
LEFT JOIN ".$table_group_user." `ug2`
ON `ug2`.`group_id` = `g`.`id`";
}
-
+
if ($category != null){
$sql .= " WHERE g.category_id = '".Database::escape_string($category)."' ";
if(!empty($session_condition))
@@ -214,12 +214,12 @@ class GroupManager {
$table_group = Database :: get_course_table(TABLE_GROUP);
$table_forum = Database :: get_course_table(TABLE_FORUM);
$category = self :: get_category($category_id);
-
+
if (intval($places) == 0) //if the amount of users per group is not filled in, use the setting from the category
{
$places = $category['max_student'];
}
- $sql = "INSERT INTO ".$table_group." SET
+ $sql = "INSERT INTO ".$table_group." SET
category_id='".Database::escape_string($category_id)."', max_student = '".$places."', doc_state = '".$category['doc_state']."',
calendar_state = '".$category['calendar_state']."', work_state = '".$category['work_state']."', announcements_state = '".$category['announcements_state']."', forum_state = '".$category['forum_state']."', wiki_state = '".$category['wiki_state']."', self_registration_allowed = '".$category['self_reg_allowed']."', self_unregistration_allowed = '".$category['self_unreg_allowed']."', session_id='".Database::escape_string($my_id_session)."'";
api_sql_query($sql,__FILE__,__LINE__);
@@ -236,12 +236,12 @@ class GroupManager {
/* Stores the directory path into the group table */
$sql = "UPDATE ".$table_group." SET name = '".Database::escape_string($name)."', secret_directory = '".$dir_name."' WHERE id ='".$lastId."'";
api_sql_query($sql,__FILE__,__LINE__);
-
+
// create a forum if needed
if ($category['forum_state'] >= 0) {
include_once(api_get_path(SYS_CODE_PATH).'forum/forumconfig.inc.php');
include_once(api_get_path(SYS_CODE_PATH).'forum/forumfunction.inc.php');
-
+
$forum_categories = get_forum_categories();
$values['forum_title'] = $name;
$counter = 0;
@@ -262,7 +262,7 @@ class GroupManager {
$values['allow_attachments_group']['allow_attachments'] = 1;
$values['allow_new_threads_group']['allow_new_threads'] = 1;
$values['default_view_type_group']['default_view_type']=api_get_setting('default_forum_view');
- $values['group_forum'] = $lastId;
+ $values['group_forum'] = $lastId;
if ($category['forum_state'] == '1') {
$values['public_private_group_forum_group']['public_private_group_forum']='public';
} elseif ($category['forum_state'] == '2') {
@@ -382,7 +382,7 @@ class GroupManager {
{
$course = api_get_course_info();
}
-
+
// Database table definitions
$group_table = Database :: get_course_table(TABLE_GROUP, $course_db);
$group_user_table = Database :: get_course_table(TABLE_GROUP_USER, $course_db);
@@ -390,9 +390,9 @@ class GroupManager {
$forum_post_table = Database :: get_course_table(TABLE_FORUM_POST, $course_db);
//$forum_post_text_table = Database :: get_course_table(TOOL_FORUM_POST_TEXT_TABLE, $course_db);
$forum_topic_table = Database :: get_course_table(TABLE_FORUM_POST, $course_db);
-
+
$group_ids = is_array($group_ids) ? $group_ids : array ($group_ids);
-
+
if(api_is_course_coach())
{ //a coach can only delete courses from his session
for($i=0 ; $i 0)
{
$userToken[$this_user['user_id']] = $this_user['number_groups_left'];
@@ -874,7 +874,7 @@ class GroupManager {
$changed = true;
while ($changed)
{
-
+
$changed = false;
reset($group_available_place);
arsort($group_available_place);
@@ -886,7 +886,7 @@ class GroupManager {
{
if (self :: can_user_subscribe($user_id, $group_id))
{
-
+
self :: subscribe_users($user_id, $group_id);
$group_available_place[$group_id]--;
$userToken[$user_id]--;
@@ -941,7 +941,7 @@ class GroupManager {
$table_group = Database :: get_course_table(TABLE_GROUP);
$user_id = Database::escape_string($user_id);
$cat_id = Database::escape_string($cat_id);
-
+
$sql = 'SELECT COUNT(*) AS number_of_groups FROM '.$table_group_user.' gu, '.$table_group.' g WHERE gu.user_id = \''.$user_id.'\' AND g.id = gu.group_id AND g.category_id= \''.$cat_id.'\'';
$db_result = api_sql_query($sql,__FILE__,__LINE__);
$db_object = Database::fetch_object($db_result);
@@ -1066,7 +1066,7 @@ class GroupManager {
* (user_id, firstname, lastname, email)
*/
public static function get_subscribed_tutors ($group_id,$id_only=false) {
- $table_user = Database :: get_main_table(TABLE_MAIN_USER);
+ $table_user = Database :: get_main_table(TABLE_MAIN_USER);
$table_group_tutor = Database :: get_course_table(TABLE_GROUP_TUTOR);
$order_clause = api_sort_by_first_name() ? ' ORDER BY `u`.`firstname`, `u`.`lastname`' : ' ORDER BY `u`.`lastname`, `u`.`firstname`';
$group_id = Database::escape_string($group_id);
@@ -1129,7 +1129,7 @@ class GroupManager {
$table_group_tutor = Database :: get_course_table(TABLE_GROUP_TUTOR);
$user_id = Database::escape_string($user_id);
$group_id = Database::escape_string($group_id);
-
+
$sql = "INSERT INTO ".$table_group_tutor." (user_id, group_id) VALUES ('".$user_id."', '".$group_id."')";
$result &= api_sql_query($sql,__FILE__,__LINE__);
}
@@ -1157,7 +1157,7 @@ class GroupManager {
$group_ids = is_array($group_ids) ? $group_ids : array ($group_ids);
if( count($group_ids) > 0)
{
-
+
if(api_is_course_coach())
{
for($i=0 ; $i0)
@@ -1285,8 +1285,8 @@ class GroupManager {
public static function is_tutor ($user_id) {
global $_course;
$course_user_table = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
- $user_id = Database::escape_string($user_id);
-
+ $user_id = Database::escape_string($user_id);
+
$sql = "SELECT tutor_id FROM ".$course_user_table."
WHERE `user_id`='".$user_id."'
AND `course_code`='".$_course['sysCode']."'"."AND tutor_id=1";
@@ -1478,7 +1478,7 @@ class GroupManager {
break;
case GROUP_TOOL_WIKI :
$state_key = 'wiki_state';
- break;
+ break;
default:
return false;
}
@@ -1508,13 +1508,13 @@ class GroupManager {
* Get all groups where a specific user is subscribed
*/
public static function get_user_group_name ($user_id) {
-
+
$table_group_user=Database::get_course_table(TABLE_GROUP_USER);
$table_group=Database::get_course_table(TABLE_GROUP);
- $user_id = Database::escape_string($user_id);
+ $user_id = Database::escape_string($user_id);
$sql_groups = 'SELECT name FROM '.$table_group.' g,'.$table_group_user.' gu WHERE gu.user_id="'.$user_id.'" AND gu.group_id=g.id';
$res = api_sql_query($sql_groups,__FILE__,__LINE__);
-
+
$groups=array();
while($group = Database::fetch_array($res))
{
diff --git a/main/inc/lib/image.lib.php b/main/inc/lib/image.lib.php
index 1455683819..d286678bdf 100644
--- a/main/inc/lib/image.lib.php
+++ b/main/inc/lib/image.lib.php
@@ -9,20 +9,20 @@ class image {
var $bgx;
var $bgy;
var $fontfile='./verdana';
-
+
var $color;
function image($bgfile='') {
-
+
image::addbackground($bgfile);
-
+
}
function createimagefromtype($file,$handler) {
$size = @getimagesize(api_url_to_local_path($file));
$type=$size[2];
-
+
switch ($type) {
case 2 : $imhandler = @imagecreatefromjpeg($file);
break;
@@ -35,7 +35,7 @@ class image {
$xtmpstr=$handler.'x';
$ytmpstr=$handler.'y';
-
+
$this->$xtmpstr=$size[0];
$this->$ytmpstr=$size[1];
@@ -63,7 +63,7 @@ class image {
$scale = ($size[0] > 0 && $size[1] >0)?min($thumbw/$size[0], $thumbh/$size[1]):0;
$width = (int)($size[0]*$scale);
$height = (int)($size[1]*$scale);
-
+
$deltaw = 0;
$deltah = 0;
$dst_img = @ImageCreateTrueColor($width, $height);
@@ -81,8 +81,8 @@ class image {
}
function addbackground($bgfile) {
-
-
+
+
if ( !empty($bgfile) && file_exists($bgfile) ) { $this->bg = image::createimagefromtype($bgfile,'bg');
@imagealphablending( $this->bg ,TRUE );
}
@@ -115,7 +115,7 @@ class image {
putenv('GDFONTPATH=' . realpath('.'));
$this->fontfile='verdana';
$text= preg_replace('`(?fontfile, $text );
if ($x<0) {
$x=$this->bgx - max($box[2],$box[4]) + $x;
@@ -127,9 +127,9 @@ class image {
} else {
$y=max(-$box[7],-$box[5]) + $y;
}
-
+
@imagettftext($this->bg, $size, $angle, $x, $y, $this->color, $this->fontfile , $text );
-
+
}
function send_image($type,$file='',$compress=-1) {
@@ -154,7 +154,7 @@ class image {
break;
default: return 0;
}
-
+
// TODO: Occupied memory is not released, because the following fragment of code is actually dead.
@imagedestroy($this->bg);
@imagedestroy($this->logo);
diff --git a/main/inc/lib/import.lib.php b/main/inc/lib/import.lib.php
index 72a1b833a4..b478acfa3e 100644
--- a/main/inc/lib/import.lib.php
+++ b/main/inc/lib/import.lib.php
@@ -1,45 +1,45 @@
$value)
{
diff --git a/main/inc/lib/legal.lib.php b/main/inc/lib/legal.lib.php
index ff07dd966c..0aeed87ca0 100644
--- a/main/inc/lib/legal.lib.php
+++ b/main/inc/lib/legal.lib.php
@@ -7,7 +7,7 @@
* @package dokeos.legal
*
*/
-
+
class LegalManager {
private function __construct () {
//void
@@ -17,12 +17,12 @@ class LegalManager {
* @param int language id
* @param string the content
* @param int term and condition type (0 or 1)
- * @param string explain changes
+ * @param string explain changes
* @return boolean sucess
*/
public function add ($language, $content, $type, $changes) {
- $legal_table = Database::get_main_table(TABLE_MAIN_LEGAL);
- $last = self::get_last_condition($language);
+ $legal_table = Database::get_main_table(TABLE_MAIN_LEGAL);
+ $last = self::get_last_condition($language);
$language = Database::escape_string($language);
$content = Database::escape_string($content);
$type = intval($type);
@@ -50,7 +50,7 @@ class LegalManager {
date = '".$time."'
WHERE legal_id= $id ";
$result = Database::query($sql, __FILE__, __LINE__);
- return true;
+ return true;
} else {
return false;
}
@@ -63,13 +63,13 @@ class LegalManager {
$sql = "DELETE FROM $legal_table WHERE legal_id = '".$id."'";
*/
}
-
+
/**
* Gets the last version of a Term and condition by language
- * @param int the language id
- * @return array all the info of a Term and condition
- */
-
+ * @param int the language id
+ * @return array all the info of a Term and condition
+ */
+
public function get_last_condition_version ($language) {
$legal_conditions_table = Database::get_main_table(TABLE_MAIN_LEGAL);
$language= Database::escape_string($language);
@@ -77,16 +77,16 @@ class LegalManager {
$result = Database::query($sql, __FILE__, __LINE__);
$row = Database::fetch_array($result);
if (Database::num_rows($result)>0) {
- return $row['version'];
+ return $row['version'];
} else {
return 0;
}
}
/**
* Gets the data of a Term and condition by language
- * @param int the language id
- * @return array all the info of a Term and condition
- */
+ * @param int the language id
+ * @return array all the info of a Term and condition
+ */
public function get_last_condition ($language) {
$legal_conditions_table = Database::get_main_table(TABLE_MAIN_LEGAL);
$language= Database::escape_string($language);
@@ -94,11 +94,11 @@ class LegalManager {
$result = Database::query($sql, __FILE__, __LINE__);
return Database::fetch_array($result);
}
-
+
/**
* Gets the last version of a Term and condition by language
- * @param int the language id
- * @return boolean | int the version or false if does not exist
+ * @param int the language id
+ * @return boolean | int the version or false if does not exist
*/
public function get_last_version ($language) {
$legal_conditions_table = Database::get_main_table(TABLE_MAIN_LEGAL);
@@ -107,15 +107,15 @@ class LegalManager {
$result = Database::query($sql, __FILE__, __LINE__);
if (Database::num_rows($result)>0){
$version = Database::fetch_array($result);
- $version = explode(':',$version[0]);
+ $version = explode(':',$version[0]);
return $version[0];
- } else {
+ } else {
return false;
- }
+ }
}
-
+
/**
- * Show the last condition
+ * Show the last condition
* @param array with type and content i.e array('type'=>'1', 'content'=>'hola');
* @return string html preview
*/
@@ -144,15 +144,15 @@ class LegalManager {
'.get_lang('TermsAndConditions').'
- ';
+ ';
break;*/
// html
- case 0:
+ case 0:
$preview = '
'.$term_preview['content'].'
';
$preview .= ' '.get_lang('ByClickingRegisterYouAgreeTermsAndConditions');
break;
- // page link
- case 1:
+ // page link
+ case 1:
$preview ='';
break;
- default:
- break;
+ default:
+ break;
}
- return $preview;
+ return $preview;
}
-
+
/**
* Get the terms and condition table (only for maintenance)
- * @param int offset
+ * @param int offset
* @param int number of items
* @param int column
- * @return array
+ * @return array
*/
public function get_legal_data ($from, $number_of_items, $column) {
$legal_conditions_table = Database::get_main_table(TABLE_MAIN_LEGAL);
$lang_table = Database::get_main_table(TABLE_MAIN_LANGUAGE);
$from = intval($from);
- $number_of_items = intval($number_of_items);
+ $number_of_items = intval($number_of_items);
$column = intval($column);
-
- $sql = "SELECT version, original_name as language, content, changes, type, FROM_UNIXTIME(date)
- FROM $legal_conditions_table inner join $lang_table l on(language_id = l.id) ";
+
+ $sql = "SELECT version, original_name as language, content, changes, type, FROM_UNIXTIME(date)
+ FROM $legal_conditions_table inner join $lang_table l on(language_id = l.id) ";
$sql .= "ORDER BY language, version ASC ";
$sql .= "LIMIT $from,$number_of_items ";
-
- $result = Database::query($sql, __FILE__, __LINE__);
+
+ $result = Database::query($sql, __FILE__, __LINE__);
$legals = array ();
$versions = array ();
while ($legal = Database::fetch_array($result)) {
- // max 2000 chars
+ // max 2000 chars
//echo strlen($legal[1]); echo ' ';
$versions[]=$legal[0];
$languages[]=$legal[1];
if (strlen($legal[2])>2000)
- $legal[2]= substr($legal[2],0,2000).' ... ';
+ $legal[2]= substr($legal[2],0,2000).' ... ';
if ($legal[4]==0)
$legal[4]= get_lang('HTMLText');
elseif($legal[4]==1)
- $legal[4]=get_lang('PageLink');
+ $legal[4]=get_lang('PageLink');
$legals[] = $legal;
}
- return $legals;
+ return $legals;
}
-
+
/**
- * Gets the number of terms and conditions available
- * @return int
+ * Gets the number of terms and conditions available
+ * @return int
*/
public function count() {
$legal_conditions_table = Database::get_main_table(TABLE_MAIN_LEGAL);
$sql = "SELECT count(*) as count_result FROM $legal_conditions_table ORDER BY legal_id DESC ";
$result = Database::query($sql, __FILE__, __LINE__);
- $url = Database::fetch_array($result,'ASSOC');
- $result = $url['count_result'];
- return $result;
+ $url = Database::fetch_array($result,'ASSOC');
+ $result = $url['count_result'];
+ return $result;
}
-
+
/**
* Get type of terms and conditions
* @param int The legal id
@@ -230,8 +230,8 @@ class LegalManager {
*/
public function get_type_of_terms_and_conditions ($legal_id,$language_id) {
$legal_conditions_table = Database::get_main_table(TABLE_MAIN_LEGAL);
- $legal_id=Database::escape_string($legal_id);
- $language_id=Database::escape_string($language_id);
+ $legal_id=Database::escape_string($legal_id);
+ $language_id=Database::escape_string($language_id);
$sql='SELECT type FROM '.$legal_conditions_table.' WHERE legal_id="'.$legal_id.'" AND language_id="'.$language_id.'"';
$rs=Database::query($sql,__FILE__,__LINE__);
return Database::result($rs,0,'type');
diff --git a/main/inc/lib/mail.lib.inc.php b/main/inc/lib/mail.lib.inc.php
index 0d165cf8d9..c3cae3acfb 100644
--- a/main/inc/lib/mail.lib.inc.php
+++ b/main/inc/lib/mail.lib.inc.php
@@ -30,7 +30,7 @@ function api_mail($recipient_name, $recipient_email, $subject, $message, $sender
$mail->Mailer = $platform_email['SMTP_MAILER'];
$mail->Host = $platform_email['SMTP_HOST'];
$mail->Port = $platform_email['SMTP_PORT'];
- $mail->CharSet = $platform_email['SMTP_CHARSET'];
+ $mail->CharSet = $platform_email['SMTP_CHARSET'];
$mail->WordWrap = 200; // stay far below SMTP protocol 980 chars limit
if($platform_email['SMTP_AUTH'])
diff --git a/main/inc/lib/message.lib.php b/main/inc/lib/message.lib.php
index dad5032bb5..b8fcead97f 100644
--- a/main/inc/lib/message.lib.php
+++ b/main/inc/lib/message.lib.php
@@ -18,7 +18,7 @@
Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
Mail: info@dokeos.com
-
+
==============================================================================
*/
@@ -32,16 +32,16 @@ function inbox_display() {
echo ''.Display::return_icon('message_new.png',api_xml_http_response_encode(get_lang('ComposeMessage'))).api_xml_http_response_encode(get_lang('ComposeMessage')).'';
echo ''.api_convert_encoding(get_lang('Refresh'),'UTF-8',$charset).'';
echo '';
- echo '';
+ echo '';
$charset = api_get_setting('platform_charset');
- $table_message = Database::get_main_table(TABLE_MESSAGE);
+ $table_message = Database::get_main_table(TABLE_MESSAGE);
$request=api_is_xml_http_request();
if ($_SESSION['social_exist']===true) {
- $redirect="#remote-tab-2";
+ $redirect="#remote-tab-2";
if (api_get_setting('allow_social_tool')=='true' && api_get_setting('allow_message_tool')=='true') {
$success= get_lang('SelectedMessagesDeleted');
} else {
- $success= get_lang('SelectedMessagesDeleted');
+ $success= get_lang('SelectedMessagesDeleted');
}
} else {
$success= get_lang('SelectedMessagesDeleted');
@@ -82,7 +82,7 @@ function inbox_display() {
echo ''.api_xml_http_response_encode(get_lang('SelectAll')).' ';
echo ''.api_xml_http_response_encode(get_lang('UnSelectAll')).' ';
echo '';
-
+
}
} else {
$table->set_form_actions(array ('delete' => get_lang('DeleteSelectedMessages')));
@@ -95,23 +95,23 @@ function get_number_of_messages_mask() {
}
function get_message_data_mask($from, $number_of_items, $column, $direction) {
$column='3';
- $direction='desc';
- //non set by SortableTable ?
+ $direction='desc';
+ //non set by SortableTable ?
$number_of_items=get_number_of_messages_mask();
return MessageManager::get_message_data($from, $number_of_items, $column, $direction);
}
function outbox_display() {
- $table_message = Database::get_main_table(TABLE_MESSAGE);
+ $table_message = Database::get_main_table(TABLE_MESSAGE);
$request=api_is_xml_http_request();
global $charset;
if ($_SESSION['social_exist']===true) {
- $redirect="#remote-tab-3";
+ $redirect="#remote-tab-3";
if (api_get_setting('allow_social_tool')=='true' && api_get_setting('allow_message_tool')=='true') {
$success= get_lang('SelectedMessagesDeleted')."  ".get_lang('BackToOutbox')."";
}else {
- $success=get_lang('SelectedMessagesDeleted')."  ".get_lang('BackToOutbox')."";
+ $success=get_lang('SelectedMessagesDeleted')."  ".get_lang('BackToOutbox')."";
}
-
+
} else {
$success= get_lang('SelectedMessagesDeleted')." "." ".get_lang('BackToOutbox')."";
}
@@ -121,15 +121,15 @@ if (isset ($_REQUEST['action'])) {
$number_of_selected_messages = count($_POST['id']);
if ($number_of_selected_messages!=0) {
foreach ($_POST['id'] as $index => $message_id) {
- MessageManager::delete_message_by_user_receiver(api_get_user_id(), $message_id);
+ MessageManager::delete_message_by_user_receiver(api_get_user_id(), $message_id);
}
- }
+ }
Display::display_normal_message(api_xml_http_response_encode($success),false);
break;
case 'deleteone' :
MessageManager::delete_message_by_user_receiver(api_get_user_id(), $_GET['id']);
Display::display_confirmation_message(api_xml_http_response_encode($success),false);
- echo ' ';
+ echo ' ';
break;
}
}
@@ -168,7 +168,7 @@ function get_message_data_send_mask($from, $number_of_items, $column, $direction
$column='3';
$direction='desc';
//non set by SortableTable ?
- $number_of_items=get_number_of_messages_send_mask();
+ $number_of_items=get_number_of_messages_send_mask();
return MessageManager::get_message_data_sent($from, $number_of_items, $column, $direction);
}
?>
diff --git a/main/inc/lib/online.inc.php b/main/inc/lib/online.inc.php
index 543be82b44..724648de9b 100644
--- a/main/inc/lib/online.inc.php
+++ b/main/inc/lib/online.inc.php
@@ -1,27 +1,27 @@
0 && !empty($_course['id']))
@@ -59,7 +59,7 @@ function LoginCheck($uid)
}
else
{
- $query = "REPLACE INTO ".$online_table ." (login_id,login_user_id,login_date,login_ip) VALUES ($uid,$uid,'$login_date','$login_ip')";
+ $query = "REPLACE INTO ".$online_table ." (login_id,login_user_id,login_date,login_ip) VALUES ($uid,$uid,'$login_date','$login_ip')";
}
@api_sql_query($query,__FILE__,__LINE__);
@@ -90,19 +90,19 @@ function online_logout() {
if (Database::num_rows($q_last_connection)>0) {
$i_id_last_connection=Database::result($q_last_connection,0,"login_id");
}
-
+
if (!isset($_SESSION['login_as'])) {
$current_date=date('Y-m-d H:i:s',time());
$s_sql_update_logout_date="UPDATE $tbl_track_login SET logout_date='".$current_date."' WHERE login_id='$i_id_last_connection'";
api_sql_query($s_sql_update_logout_date);
}
LoginDelete($uid, $_configuration['statistics_database']); //from inc/lib/online.inc.php - removes the "online" status
-
+
//the following code enables the use of an external logout function.
//example: define a $extAuthSource['ldap']['logout']="file.php" in configuration.php
- // then a function called ldap_logout() inside that file
- // (using *authent_name*_logout as the function name) and the following code
- // will find and execute it
+ // then a function called ldap_logout() inside that file
+ // (using *authent_name*_logout as the function name) and the following code
+ // will find and execute it
$uinfo = api_get_user_info($uid);
if (($uinfo['auth_source'] != PLATFORM_AUTH_SOURCE) && is_array($extAuthSource)) {
if (is_array($extAuthSource[$uinfo['auth_source']])) {
@@ -133,7 +133,7 @@ function online_logout() {
*/
function LoginDelete($user_id)
{
- $online_table = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ONLINE);
+ $online_table = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ONLINE);
$user_id = (int) $user_id;
$query = "DELETE FROM ".$online_table ." WHERE login_user_id = '".Database::escape_string($user_id)."'";
@api_sql_query($query,__FILE__,__LINE__);
@@ -148,34 +148,34 @@ function LoginDelete($user_id)
* @todo remove parameter $statistics_database which is no longer necessary
*/
function WhoIsOnline($uid=0,$statistics_database='',$valid)
-{
+{
$valid = (int) $valid;
$current_date=date('Y-m-d H:i:s',time());
$track_online_table = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ONLINE);
$query = "SELECT login_user_id,login_date FROM ".$track_online_table ." WHERE DATE_ADD(login_date,INTERVAL $valid MINUTE) >= '".$current_date."' ";
-
- global $_configuration;
- if ($_configuration['multiple_access_urls']==true) {
- $tbl_user_rel_access_url= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
+
+ global $_configuration;
+ if ($_configuration['multiple_access_urls']==true) {
+ $tbl_user_rel_access_url= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$access_url_id = api_get_current_access_url_id();
if ($access_url_id != -1){
- $query = "SELECT login_user_id,login_date FROM ".$track_online_table ." track
+ $query = "SELECT login_user_id,login_date FROM ".$track_online_table ." track
INNER JOIN $tbl_user_rel_access_url user_rel_url
- ON (user_rel_url.user_id = track.login_user_id)
- WHERE access_url_id = $access_url_id AND DATE_ADD(login_date,INTERVAL $valid MINUTE) >= '".$current_date."' ";
+ ON (user_rel_url.user_id = track.login_user_id)
+ WHERE access_url_id = $access_url_id AND DATE_ADD(login_date,INTERVAL $valid MINUTE) >= '".$current_date."' ";
}
- }
-
- $result = @api_sql_query($query,__FILE__,__LINE__);
+ }
+
+ $result = @api_sql_query($query,__FILE__,__LINE__);
if (count($result)>0)
{
$rtime = time();
$rdate = date("Y-m-d H:i:s",$rtime);
$validtime = mktime(date("H"),date("i")-$valid,date("s"),date("m"),date("d"),date("Y"));
$rarray = array();
-
+
while(list($login_user_id,$login_date)= Database::fetch_row($result))
- {
+ {
$barray = array();
array_push($barray,$login_user_id);
array_push($barray,$login_date);
@@ -189,15 +189,15 @@ function WhoIsOnline($uid=0,$statistics_database='',$valid)
$year = substr($login_date,0,4);
// db timestamp
$dbtime = mktime($hour,$minute,$secund,$month,$day,$year);
-
+
if ($dbtime>$validtime)
{
array_push($rarray,$barray);
}
- }
+ }
return $rarray;
}
- else
+ else
{
return false;
}
@@ -234,7 +234,7 @@ function GetFullUserName($uid)
function chatcall() {
global $_user, $_cid;
-
+
if (!$_user['user_id'])
{
return (false);
@@ -270,10 +270,10 @@ function chatcall() {
. get_lang("No")
.""
."
";
-
+
return($message);
}
- else
+ else
{
return(false);
}
@@ -288,23 +288,23 @@ function chatcall() {
* @return array Each line gives a user id and a login time
*/
function who_is_online_in_this_course($uid, $valid, $coursecode=null)
-{
+{
if(empty($coursecode)) return false;
$track_online_table = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ONLINE);
$coursecode = Database::escape_string($coursecode);
$valid = Database::escape_string($valid);
-
- $query = "SELECT login_user_id,login_date FROM ".$track_online_table ." WHERE course='".$coursecode."' AND DATE_ADD(login_date,INTERVAL $valid MINUTE) >= NOW() ";
- $result = api_sql_query($query,__FILE__,__LINE__);
+
+ $query = "SELECT login_user_id,login_date FROM ".$track_online_table ." WHERE course='".$coursecode."' AND DATE_ADD(login_date,INTERVAL $valid MINUTE) >= NOW() ";
+ $result = api_sql_query($query,__FILE__,__LINE__);
if (count($result)>0)
{
$rtime = time();
$rdate = date("Y-m-d H:i:s",$rtime);
$validtime = mktime(date("H"),date("i")-$valid,date("s"),date("m"),date("d"),date("Y"));
$rarray = array();
-
+
while(list($login_user_id,$login_date)= mysql_fetch_row($result))
- {
+ {
$barray = array();
array_push($barray,$login_user_id);
array_push($barray,$login_date);
@@ -322,10 +322,10 @@ function who_is_online_in_this_course($uid, $valid, $coursecode=null)
{
array_push($rarray,$barray);
}
- }
+ }
return $rarray;
}
- else
+ else
{
return false;
}
diff --git a/main/inc/lib/security.lib.php b/main/inc/lib/security.lib.php
index 42acb86e41..2bd198a74c 100755
--- a/main/inc/lib/security.lib.php
+++ b/main/inc/lib/security.lib.php
@@ -1,23 +1,23 @@
filter($new_var,[more options])
- * and then using $secure->clean['var'] as a filtered equivalent, although
+ * a new Security object and using $secure->filter($new_var,[more options])
+ * and then using $secure->clean['var'] as a filtered equivalent, although
* this is *not* mandatory at all.
- *
+ *
* @author Yannick Warnier
*/
class Security {
public static $clean = array();
/**
- * Checks if the absolute path (directory) given is really under the
+ * Checks if the absolute path (directory) given is really under the
* checker path (directory)
* @param string Absolute path to be checked (with trailing slash)
* @param string Checker path under which the path should be (absolute path, with trailing slash, get it from api_get_path(SYS_COURSE_PATH))
@@ -62,9 +62,9 @@ class Security {
*/
public static function check_abs_path ($abs_path,$checker_path) {
if (empty($checker_path)) {return false;} //checker path must be set
-
+
$true_path=str_replace("\\", "/", realpath($abs_path));
-
+
$found = strpos($true_path.'/',$checker_path);
if ($found===0) {
return true;
@@ -72,7 +72,7 @@ class Security {
return false;
}
/**
- * Checks if the relative path (directory) given is really under the
+ * Checks if the relative path (directory) given is really under the
* checker path (directory)
* @param string Relative path to be checked (relative to the current directory) (with trailing slash)
* @param string Checker path under which the path should be (absolute path, with trailing slash, get it from api_get_path(SYS_COURSE_PATH))
@@ -119,7 +119,7 @@ class Security {
case 'post':
if (isset($_SESSION['sec_token']) && isset($_POST['sec_token']) && $_SESSION['sec_token'] === $_POST['sec_token']) {
return true;
- }
+ }
return false;
default:
if (isset($_SESSION['sec_token']) && isset($array) && $_SESSION['sec_token'] === $array) {
@@ -130,7 +130,7 @@ class Security {
return false; //just in case, don't let anything slip
}
/**
- * Checks the user agent of the client as recorder by get_ua() to prevent
+ * Checks the user agent of the client as recorder by get_ua() to prevent
* most session hijacking attacks.
* @return bool True if the user agent is the same, false otherwise
*/
@@ -186,7 +186,7 @@ class Security {
$_SESSION['sec_ua_seed'] = uniqid(rand(),TRUE);
$_SESSION['sec_ua'] = $_SERVER['HTTP_USER_AGENT'].$_SESSION['sec_ua_seed'];
}
- /**
+ /**
* This function filters a variable to the type given, with the options given
* @param mixed The variable to be filtered
* @param string The type of variable we expect (bool,int,float,string)
@@ -212,7 +212,7 @@ class Security {
$result = (float) $var;
break;
case 'string':
-
+
break;
case 'array':
//an array variable shouldn't be given to the filter
@@ -241,18 +241,18 @@ class Security {
* This function tackles the XSS injections.
* Filtering for XSS is very easily done by using the htmlentities() function.
* This kind of filtering prevents JavaScript snippets to be understood as such.
- * @param mixed The variable to filter for XSS, this params can be a string or an array (example : array(x,y))
+ * @param mixed The variable to filter for XSS, this params can be a string or an array (example : array(x,y))
* @param integer The user status,constant allowed(STUDENT,COURSEMANAGER,ANONYMOUS,COURSEMANAGERLOWSECURITY)
* @return mixed Filtered string or array
*/
public static function remove_XSS ($var,$user_status=ANONYMOUS) {
global $charset;
- $purifier = new HTMLPurifier(null,$user_status);
+ $purifier = new HTMLPurifier(null,$user_status);
if (is_array($var)) {
- return $purifier->purifyArray($var);
+ return $purifier->purifyArray($var);
} else {
- return $purifier->purify($var);
+ return $purifier->purify($var);
}
-
+
}
}
diff --git a/main/inc/lib/social.lib.php b/main/inc/lib/social.lib.php
index d18b99cfbd..c6032c5986 100755
--- a/main/inc/lib/social.lib.php
+++ b/main/inc/lib/social.lib.php
@@ -8,10 +8,10 @@ define(SOCIALGOODFRIEND,4);
define(SOCIALENEMY,5);
define(SOCIALDELETED,6);
-class UserFriend extends UserManager {
-
+class UserFriend extends UserManager {
+
private function __construct() {
-
+
}
/**
* Allow to register contact to social network
@@ -28,8 +28,8 @@ class UserFriend extends UserManager {
$result = Database::query($sql, __FILE__, __LINE__);
$row = Database :: fetch_array($result, 'ASSOC');
if ($row['count'] == 0) {
- $current_date=date('Y-m-d H:i:s');
- $sql_i = 'INSERT INTO ' . $tbl_my_friend . '(friend_user_id,user_id,relation_type,last_edit)values(' . ((int)$friend_id) . ','.((int)$my_user_id).','.((int)$relation_type).',"'.$current_date.'");';
+ $current_date=date('Y-m-d H:i:s');
+ $sql_i = 'INSERT INTO ' . $tbl_my_friend . '(friend_user_id,user_id,relation_type,last_edit)values(' . ((int)$friend_id) . ','.((int)$my_user_id).','.((int)$relation_type).',"'.$current_date.'");';
Database::query($sql_i, __FILE__, __LINE__);
} else {
$sql = 'SELECT COUNT(*) as count FROM ' . $tbl_my_friend . ' WHERE friend_user_id=' . ((int)$friend_id) . ' AND user_id='.((int)$my_user_id);
@@ -41,7 +41,7 @@ class UserFriend extends UserManager {
}
}
}
-
+
/**
* Allow to delete contact to social network
*@author isaac flores paz
@@ -61,11 +61,11 @@ class UserFriend extends UserManager {
$sql_j = 'UPDATE ' . $tbl_my_message . ' SET msg_status=7 WHERE user_receiver_id=' . ((int)$user_id).' AND user_sender_id='.((int)$friend_id);
//Delete user
$sql_ij = 'UPDATE ' . $tbl_my_friend . ' SET relation_type=6 WHERE user_id=' . ((int)$friend_id).' AND friend_user_id='.((int)$user_id);
- $sql_ji = 'UPDATE ' . $tbl_my_message . ' SET msg_status=7 WHERE user_receiver_id=' . ((int)$friend_id).' AND user_sender_id='.((int)$user_id);
+ $sql_ji = 'UPDATE ' . $tbl_my_message . ' SET msg_status=7 WHERE user_receiver_id=' . ((int)$friend_id).' AND user_sender_id='.((int)$user_id);
Database::query($sql_i, __FILE__, __LINE__);
Database::query($sql_j, __FILE__, __LINE__);
Database::query($sql_ij, __FILE__, __LINE__);
- Database::query($sql_ji, __FILE__, __LINE__);
+ Database::query($sql_ji, __FILE__, __LINE__);
}
}
/**
@@ -88,12 +88,12 @@ class UserFriend extends UserManager {
} else {
return $friend_relation_list;
}
-
+
}
/**
* Get relation type contact by name
* @author isaac flores paz
- * @param string names of the kind of relation
+ * @param string names of the kind of relation
* @return int
*/
public static function get_relation_type_by_name ($relation_type_name) {
@@ -103,7 +103,7 @@ class UserFriend extends UserManager {
if (strtolower($value_type_friend['title'])==$relation_type_name) {
return $value_type_friend['id'];
}
- }
+ }
}
/**
* Get the kind of relation between contacts
@@ -120,7 +120,7 @@ class UserFriend extends UserManager {
$res=Database::query($sql,__FILE__,__LINE__);
$row=Database::fetch_array($res,'ASSOC');
if (Database::num_rows($res)>0) {
- return $row['id'];
+ return $row['id'];
} else {
return USERUNKNOW;
}
@@ -136,7 +136,7 @@ class UserFriend extends UserManager {
public static function get_list_id_friends_by_user_id ($user_id,$id_group=null,$search_name=null) {
$list_ids_friends=array();
$tbl_my_friend = Database :: get_main_table(TABLE_MAIN_USER_FRIEND);
- $tbl_my_user = Database :: get_main_table(TABLE_MAIN_USER);
+ $tbl_my_user = Database :: get_main_table(TABLE_MAIN_USER);
$sql='SELECT friend_user_id FROM '.$tbl_my_friend.' WHERE relation_type<>6 AND friend_user_id<>'.((int)$user_id).' AND user_id='.((int)$user_id);
if (isset($id_group) && $id_group>0) {
$sql.=' AND relation_type='.$id_group;
@@ -156,13 +156,13 @@ class UserFriend extends UserManager {
* @param int user id
* @param int group id
* @param string name to search
- * @param array
+ * @param array
*/
public static function get_list_path_web_by_user_id ($user_id,$id_group=null,$search_name=null) {
$list_paths=array();
$list_path_friend=array();
$array_path_user=array();
- $combine_friend = array();
+ $combine_friend = array();
$list_ids = self::get_list_id_friends_by_user_id ($user_id,$id_group,$search_name);
if (is_array($list_ids)) {
foreach ($list_ids as $values_ids) {
@@ -186,7 +186,7 @@ class UserFriend extends UserManager {
$list_path_image_friend[] = UserManager::get_user_picture_path_by_id($values_ids['user_sender_id'],'web',false,true);
}
return $list_path_image_friend;
- }
+ }
/**
* allow to sent an invitation to my contacts
* @author isaac flores paz
@@ -206,21 +206,21 @@ class UserFriend extends UserManager {
if ($row_exist['count']==0) {
$sql='INSERT INTO '.$tbl_message.'(user_sender_id,user_receiver_id,msg_status,send_date,title,content) VALUES('.((int)$user_id).','.((int)$friend_id).','.((int)$status_invitation).',"'.$current_date.'","'.$message_title.'","'.$message_content.'")';
Database::query($sql,__FILE__,__LINE__);
- return true;
+ return true;
} elseif ($row_exist['count']==1) {
$sql_if_exist='SELECT COUNT(*) AS count FROM '.$tbl_message.' WHERE user_sender_id='.((int)$user_id).' AND user_receiver_id='.((int)$friend_id).' AND msg_status=7';
$res_if_exist=Database::query($sql_if_exist,__FILE__,__LINE__);
$row_if_exist=Database::fetch_array($res_if_exist,'ASSOC');
if ($row_if_exist['count']==1) {
- $sql_if_exist_up='UPDATE '.$tbl_message.'SET msg_status=5 WHERE user_sender_id='.((int)$user_id).' AND user_receiver_id='.((int)$friend_id).';';
+ $sql_if_exist_up='UPDATE '.$tbl_message.'SET msg_status=5 WHERE user_sender_id='.((int)$user_id).' AND user_receiver_id='.((int)$friend_id).';';
Database::query($sql_if_exist_up,__FILE__,__LINE__);
return true;
} else {
- return false;
+ return false;
}
} else {
- return false;
+ return false;
}
}
@@ -278,7 +278,7 @@ class UserFriend extends UserManager {
$tbl_message=Database::get_main_table(TABLE_MAIN_MESSAGE);
$msg_status=7;
$sql='UPDATE '.$tbl_message.' SET msg_status='.$msg_status.' WHERE user_sender_id='.((int)$user_send_id).' AND user_receiver_id='.((int)$user_receiver_id).';';
- Database::query($sql,__FILE__,__LINE__);
+ Database::query($sql,__FILE__,__LINE__);
}
/**
* allow attach to group
@@ -291,7 +291,7 @@ class UserFriend extends UserManager {
$tbl_user_friend=Database::get_main_table(TABLE_MAIN_USER_FRIEND);
$user_id=api_get_user_id();
$sql='UPDATE '.$tbl_user_friend.' SET relation_type='.((int)$type_qualify).' WHERE user_id='.((int)$user_id).' AND friend_user_id='.((int)$id_friend_qualify).';';
- Database::query($sql,__FILE__,__LINE__);
+ Database::query($sql,__FILE__,__LINE__);
}
/**
* Send invitation a your friends
@@ -305,11 +305,11 @@ class UserFriend extends UserManager {
$user_info=api_get_user_info($userfriend_id);
$succes=get_lang('MessageSentTo');
$succes.= ' : '.api_get_person_name($user_info['firstName'], $user_info['lastName']);
- if (isset($subject_message) && isset($content_message) && isset($userfriend_id)) {
+ if (isset($subject_message) && isset($content_message) && isset($userfriend_id)) {
$send_message = MessageManager::send_message(((int)$userfriend_id),Database::escape_string($subject_message), Database::escape_string($content_message));
if ($send_message) {
echo Display::display_confirmation_message($succes,true);
- } else {
+ } else {
echo Display::display_error_message($succes,true);
}
exit;
@@ -326,10 +326,10 @@ class UserFriend extends UserManager {
if ($count_is_true) {
echo Display::display_normal_message(get_lang('InvitationHasBeenSent'));
}else {
- echo Display::display_error_message(get_lang('InvitationHasBeenNotSent'));
+ echo Display::display_error_message(get_lang('InvitationHasBeenNotSent'));
}
-
+
}
}
- }
+ }
}
\ No newline at end of file
diff --git a/main/inc/lib/sortabletable.class.php b/main/inc/lib/sortabletable.class.php
index 8101497005..44658047af 100644
--- a/main/inc/lib/sortabletable.class.php
+++ b/main/inc/lib/sortabletable.class.php
@@ -107,7 +107,7 @@ class SortableTable extends HTML_Table {
* table
*/
public $other_tables;
-
+
/**
* Create a new SortableTable
@@ -128,19 +128,19 @@ class SortableTable extends HTML_Table {
$this->table_name = $table_name;
$this->additional_parameters = array ();
$this->param_prefix = $table_name.'_';
-
+
$this->page_nr = isset ($_SESSION[$this->param_prefix.'page_nr']) ? intval($_SESSION[$this->param_prefix.'page_nr']) : 1;
$this->page_nr = isset ($_GET[$this->param_prefix.'page_nr']) ? intval($_GET[$this->param_prefix.'page_nr']) : $this->page_nr;
$this->column = isset ($_SESSION[$this->param_prefix.'column']) ? intval($_SESSION[$this->param_prefix.'column']) : $default_column;
$this->column = isset ($_GET[$this->param_prefix.'column']) ? intval($_GET[$this->param_prefix.'column']) : $this->column;
-
+
//$this->direction = isset ($_SESSION[$this->param_prefix.'direction']) ? $_SESSION[$this->param_prefix.'direction'] : $default_order_direction;
-
-
+
+
if (isset($_SESSION[$this->param_prefix.'direction'])) {
$my_session_direction = $_SESSION[$this->param_prefix.'direction'];
if(!in_array($my_session_direction, array('ASC','DESC'))){
- $this->direction = 'ASC';
+ $this->direction = 'ASC';
} else {
if ($my_session_direction=='ASC') {
$this->direction = 'ASC';
@@ -148,12 +148,12 @@ class SortableTable extends HTML_Table {
$this->direction = 'DESC';
}
}
- }
-
+ }
+
if (isset($_GET[$this->param_prefix.'direction'])) {
- $my_get_direction = $_GET[$this->param_prefix.'direction'];
+ $my_get_direction = $_GET[$this->param_prefix.'direction'];
if(!in_array($my_get_direction, array('ASC','DESC'))){
- $this->direction = 'ASC';
+ $this->direction = 'ASC';
} else {
if ($my_get_direction=='ASC') {
$this->direction = 'ASC';
@@ -165,10 +165,10 @@ class SortableTable extends HTML_Table {
//allow to change paginate in multiples tabs
unset($_SESSION[$this->param_prefix.'per_page']);
-
+
$this->per_page = isset ($_SESSION[$this->param_prefix.'per_page']) ? intval($_SESSION[$this->param_prefix.'per_page']) : $default_items_per_page;
$this->per_page = isset ($_GET[$this->param_prefix.'per_page']) ? intval($_GET[$this->param_prefix.'per_page']) : $this->per_page;
-
+
$_SESSION[$this->param_prefix.'per_page'] = $this->per_page;
$_SESSION[$this->param_prefix.'direction'] = $this->direction ;
$_SESSION[$this->param_prefix.'page_nr'] = $this->page_nr;
@@ -237,7 +237,7 @@ class SortableTable extends HTML_Table {
$message_empty=get_lang('TheListIsEmpty');
}
$this->setCellContents(1, 0,$message_empty);
-
+
$empty_table = true;
}
$html='';
@@ -462,7 +462,7 @@ class SortableTable extends HTML_Table {
$param[$tablename.'_direction'] = 'ASC';
} else {
$param[$tablename.'_direction'] = $my_get_direction;
- }
+ }
}
if( isset($_GET[$tablename.'_page_nr']))
$param[$tablename.'_page_nr'] = intval($_GET[$tablename.'_page_nr']);
@@ -559,7 +559,7 @@ class SortableTable extends HTML_Table {
$row[0] .= '/>';
}
}
-
+
foreach ($row as $index => $value) {
if (strlen($row[$index]) == 0)
{
@@ -636,61 +636,61 @@ class SortableTableFromArray extends SortableTable {
/**
* Sortable table which can be used for data available in an array
- *
+ *
* Is a variation of SortableTableFromArray because we add 2 new arrays $column_show and $column_order
* $column_show is an array that lets us decide which are going to be the columns to show
- * $column_order is an array that lets us decide the ordering of the columns
+ * $column_order is an array that lets us decide the ordering of the columns
* i.e: $column_header=array('a','b','c','d','e'); $column_order=array(1,2,5,4,5);
- * These means that the 3th column (letter "c") will be sort like the order we use in the 5th column
+ * These means that the 3th column (letter "c") will be sort like the order we use in the 5th column
*/
-
-class SortableTableFromArrayConfig extends SortableTable {
+
+class SortableTableFromArrayConfig extends SortableTable {
/**
* The array containing the columns that will be show i.e $column_show=array('1','0','0'); we will show only the 1st column
*/
private $column_show;
-
+
/**
- *The array containing the real sort column $column_order=array('1''4','3','4'); The 2nd column will be order like the 4th column
+ *The array containing the real sort column $column_order=array('1''4','3','4'); The 2nd column will be order like the 4th column
*/
- private $column_order;
+ private $column_order;
/**
* The array containing all data for this table
*/
private $table_data;
-
+
/**
* Constructor
* @param array $table_data All the information of the table
- * @param int $default_column Default column that will be use in the sorts functions
+ * @param int $default_column Default column that will be use in the sorts functions
* @param int $default_items_per_page quantity of pages that we are going to see
* @param int $tablename Name of the table
- * @param array $column_show An array with binary values 1: we show the column 2: we don't show it
- * @param array $column_order An array of integers that let us decide how the columns are going to be sort.
- */
+ * @param array $column_show An array with binary values 1: we show the column 2: we don't show it
+ * @param array $column_order An array of integers that let us decide how the columns are going to be sort.
+ */
public function __construct ($table_data, $default_column = 1, $default_items_per_page = 20, $tablename = 'tablename',$column_show=null,$column_order=null,$direction='ASC') {
$this->column_show=$column_show;
$this->column_order=$column_order;
-
+
parent :: __construct ($tablename, null, null, $default_column, $default_items_per_page,$direction);
-
+
$this->table_data = $table_data;
}
/**
* Get table data to show on current page
* @see SortableTable#get_table_data
*/
- public function get_table_data($from = 1) {
+ public function get_table_data($from = 1) {
$content = TableSort :: sort_table_config($this->table_data, $this->column, $this->direction == 'ASC' ? SORT_ASC : SORT_DESC ,$this->column_show, $this->column_order);
return array_slice($content, $from, $this->per_page);
}
-
+
/**
* Get total number of items
* @see SortableTable#get_total_number_of_items
*/
public function get_total_number_of_items () {
return count($this->table_data);
- }
+ }
}
?>
diff --git a/main/inc/lib/specific_fields_manager.lib.php b/main/inc/lib/specific_fields_manager.lib.php
index bafb264c7e..3f6cc8c06e 100644
--- a/main/inc/lib/specific_fields_manager.lib.php
+++ b/main/inc/lib/specific_fields_manager.lib.php
@@ -45,7 +45,7 @@ function delete_specific_field($id) {
$sql = 'DELETE FROM %s WHERE id=%s LIMIT 1';
$sql = sprintf($sql, $table_sf, $id);
$result = api_sql_query($sql,__FILE__,__LINE__);
- //TODO also delete the corresponding values
+ //TODO also delete the corresponding values
}
/**
@@ -180,7 +180,7 @@ function delete_all_specific_field_value($course_id, $id_specific_field, $tool_i
}
/**
- * Delete all values from a specific item (course_id, tool_id and ref_id).
+ * Delete all values from a specific item (course_id, tool_id and ref_id).
* To be used when deleting such item from Dokeos
* @param string Course code
* @param string Tool ID
@@ -210,14 +210,14 @@ function get_specific_field_code_from_name($name) {
$code = strtoupper(substr($name,0,1));
//if no code exists in DB, return current one
if (Database::num_rows($res)<1) { return $code;}
-
+
$existing_list = array();
while ($row = Database::fetch_array($res)) {
$existing_list[] = $row['code'];
}
//if the current code doesn't exist in DB, return current one
if (!in_array($code,$existing_list)) { return $code;}
-
+
$idx = array_search($code,$list);
$c = count($list);
for ($i = $idx+1, $j=0 ; $j<$c ; $i++, $j++) {
diff --git a/main/inc/lib/stats.lib.inc.php b/main/inc/lib/stats.lib.inc.php
index 6ef03c0b29..9577735f02 100644
--- a/main/inc/lib/stats.lib.inc.php
+++ b/main/inc/lib/stats.lib.inc.php
@@ -1,43 +1,43 @@
-
@@ -91,11 +91,11 @@ $TABLESTATS_REFERERS = $_configuration['statistics_database']."`.`track_c_ref
information, to count occurences (for os, provider,...)
and to increment the number of occurrences of each
different element into the corresponding tables
- */
+ */
function decodeOpenInfos()
{
global $TABLETRACK_OPEN;
-
+
// record initial value of ignore_user_abort
$ignore = ignore_user_abort();
// prevent script from being stopped while executing, the following can be considered
@@ -103,7 +103,7 @@ function decodeOpenInfos()
ignore_user_abort(1) ;
// we take the last event id to prevent miss of some recorded event
// only processed record have to be cleaned
- $sql = "SELECT open_id
+ $sql = "SELECT open_id
FROM `$TABLETRACK_OPEN`
WHERE open_date <= NOW()
ORDER BY open_id DESC
@@ -117,30 +117,30 @@ function decodeOpenInfos()
$res = @mysql_fetch_array($query);
$processBegin = $res[0];
// process
-
+
//--Providers And Countries-------------------------------------------//
- $sql = "SELECT open_remote_host
- FROM `$TABLETRACK_OPEN`
+ $sql = "SELECT open_remote_host
+ FROM `$TABLETRACK_OPEN`
WHERE open_remote_host != ''
AND open_id <= '".$processBegin."' ";
$query = mysql_query( $sql );
if( mysql_num_rows($query) != 0 )
{
- // load list of countries
+ // load list of countries
$list_countries = loadCountries();
-
- while ($row = mysql_fetch_row ($query) )
+
+ while ($row = mysql_fetch_row ($query) )
{
$remote_host = $row[0];
/*****Provider*****/
- //extract provider
+ //extract provider
$provider = extractProvider( $remote_host );
// add or increment provider in the providers array
$providers_array = addProvider( $provider,$providers_array );
-
+
/*****Countries*****/
- // extract country
+ // extract country
$country = extractCountry( $remote_host, $list_countries );
// increment country in the countries table
$countries_array = addCountry( $country, $countries_array );
@@ -151,11 +151,11 @@ function decodeOpenInfos()
fillCountriesTable( $countries_array );
}
// provider and countries done
-
+
//--Browsers and OS---------------------------------------------------//
-
+
$sql = "SELECT open_agent
- FROM `$TABLETRACK_OPEN`
+ FROM `$TABLETRACK_OPEN`
WHERE open_remote_host != ''
AND open_id <= '".$processBegin."' ";
$query = mysql_query( $sql );
@@ -166,8 +166,8 @@ function decodeOpenInfos()
$list_browsers = loadBrowsers();
// of OS
$list_os = loadOs();
-
- while ( $row = mysql_fetch_row ($query) )
+
+ while ( $row = mysql_fetch_row ($query) )
{
$agent = $row[0];
/*****Browser and OS*****/
@@ -177,15 +177,15 @@ function decodeOpenInfos()
$browsers_array = addBrowser( $browser , $browsers_array );
$os_array = addOs( $os , $os_array );
}
-
+
fillBrowsersTable( $browsers_array );
fillOsTable( $os_array );
}
- // browsers and OS done
-
- //--Referers----------------------------------------------------------//
+ // browsers and OS done
+
+ //--Referers----------------------------------------------------------//
$sql = "SELECT open_referer
FROM `$TABLETRACK_OPEN`
@@ -197,22 +197,22 @@ function decodeOpenInfos()
{
$i=0;
- while ($row = mysql_fetch_row ($query) )
+ while ($row = mysql_fetch_row ($query) )
{
$ref = $row[0];
$referers_array = addReferer( $ref , $referers_array );
}
fillReferersTable( $referers_array );
}
-
- // referers done
-
+
+ // referers done
+
//-------------------------------------------------------------------//
-
+
// end of process
// cleaning of $TABLETRACK_OPEN table
cleanProcessedRecords($processBegin);
-
+
// reset to the initial value
ignore_user_abort($ignore);
}
@@ -230,23 +230,23 @@ function decodeOpenInfos()
* @author Sebastien Piraux
* @param limit : all records BEFORE $limit will be affected
* @desc this function will delete the remote_host, user_agent
- and referer rows from the track_open table recorded before
+ and referer rows from the track_open table recorded before
the date $limit. OPTIMIZE is called to get back the memory
espaces deleted
*/
function cleanProcessedRecords( $limit )
{
global $TABLETRACK_OPEN;
- $sql = "UPDATE `".$TABLETRACK_OPEN."`
+ $sql = "UPDATE `".$TABLETRACK_OPEN."`
SET open_remote_host = '',
open_agent = '',
open_referer =''
WHERE open_id <= '".$limit."'";
-
+
$query = mysql_query( $sql );
-
+
mysql_query("OPTIMIZE TABLE $TABLETRACK_OPEN");
-
+
}
@@ -261,41 +261,41 @@ function cleanProcessedRecords( $limit )
* @author Sebastien Piraux
* @param remhost : must be @getHostByAddr($_SERVER['REMOTE_ADDR']
- * @desc this function will extract the provider name from a given
- remote host and record this occurence in the corresponding
+ * @desc this function will extract the provider name from a given
+ remote host and record this occurence in the corresponding
table
*/
function extractProvider($remhost)
{
-
+
if($remhost == "Unknown")
return $remhost;
-
+
$explodedRemhost = explode(".", $remhost);
$provider = $explodedRemhost[sizeof( $explodedRemhost )-2]
."."
.$explodedRemhost[sizeof( $explodedRemhost )-1];
-
+
if($provider == "co.uk" || $provider == "co.jp")
return $explodedRemhost[sizeof( $explodedRemhost )-3].$provider;
else return $provider;
-
+
}
/**
* @author Sebastien Piraux
- * @param provider : name of the provider
+ * @param provider : name of the provider
* @param providers_array : list of providers and their counter
- * @desc this function will :
- - if the provider is already in the array it will increment
+ * @desc this function will :
+ - if the provider is already in the array it will increment
the corresponding value
- if the provider doesn't exist it will be added and set to 1
*/
function addProvider($provider,$providers_array)
{
- if( isset( $providers_array[$provider] ) )
+ if( isset( $providers_array[$provider] ) )
{
// add one unity to this provider occurrences
$providers_array[$provider] = $providers_array[$provider] + 1;
@@ -317,7 +317,7 @@ function addProvider($provider,$providers_array)
function fillProvidersTable($providers_array)
{
global $TABLESTATS_PROVIDERS;
-
+
if(is_array($providers_array))
{
foreach ( $providers_array as $prov=>$number )
@@ -326,7 +326,7 @@ function fillProvidersTable($providers_array)
FROM `".$TABLESTATS_PROVIDERS."`
WHERE `provider` = '".$prov."'";
$res = mysql_query($sql);
-
+
// if this provider already exists in the DB
if( $row = mysql_num_rows($res) )
{
@@ -338,13 +338,13 @@ function fillProvidersTable($providers_array)
else
{
// insert
- $sql2 = "INSERT INTO `".$TABLESTATS_PROVIDERS."`
- (`provider`,`counter`)
+ $sql2 = "INSERT INTO `".$TABLESTATS_PROVIDERS."`
+ (`provider`,`counter`)
VALUES ('".$prov."','".$number."')";
}
mysql_query($sql2);
- }
- }
+ }
+ }
}
/***************************************************************************
@@ -357,23 +357,23 @@ function fillProvidersTable($providers_array)
* @author Sebastien Piraux
* @return a 2D array filled with code and name of countries
- * @desc This function is used to build an array containing
+ * @desc This function is used to build an array containing
countries informations
*/
function loadCountries()
-{
+{
global $TABLESTATS_COUNTRIES;
-
+
$sql = "SELECT code, country
FROM `".$TABLESTATS_COUNTRIES."`";
-
+
$res = mysql_query( $sql );
-
+
$i = 0 ;
- while( $row = mysql_fetch_array( $res ) ) {
+ while( $row = mysql_fetch_array( $res ) ) {
$list_countries[$i][0] = $row["code"];
$list_countries[$i][1] = $row["country"];
- $i++;
+ $i++;
}
return $list_countries;
mysql_free_result($res);
@@ -384,7 +384,7 @@ function loadCountries()
* @author Sebastien Piraux
* @param remhost : must be @getHostByAddr($_SERVER['REMOTE_ADDR']
- * @param list_countries : list of countries -__-
+ * @param list_countries : list of countries -__-
* @return Name of the country or "Unknown" if not found
* @desc this function will extract the country from a given remote
host and increment the good value in the corresponding table
@@ -396,7 +396,7 @@ function extractCountry($remhost,$list_countries)
// country code is the last value of remote host
$explodedRemhost = explode(".",$remhost);
$countryCode = $explodedRemhost[sizeof( $explodedRemhost )-1];
-
+
for($i = 0 ; $i < sizeof( $list_countries );$i++)
{
if($list_countries[$i][0] == $countryCode)
@@ -408,15 +408,15 @@ function extractCountry($remhost,$list_countries)
/**
* @author Sebastien Piraux
- * @param country : name of the country or 'Unknown'
- * @param countries_array : list of countries and their
+ * @param country : name of the country or 'Unknown'
+ * @param countries_array : list of countries and their
number of occurence
- * @desc this function will increment number of occurrence
+ * @desc this function will increment number of occurrence
for $country in the countries' tables
*/
function addCountry($country,$countries_array)
{
- if( isset( $countries_array[$country] ) )
+ if( isset( $countries_array[$country] ) )
{
// add one unity to this provider occurrences
$countries_array[$country] = $countries_array[$country] + 1;
@@ -427,7 +427,7 @@ function addCountry($country,$countries_array)
$countries_array[$country] = 1;
}
return $countries_array;
-
+
}
@@ -440,7 +440,7 @@ function addCountry($country,$countries_array)
function fillCountriesTable($countries_array)
{
global $TABLESTATS_COUNTRIES;
- if(is_array($countries_array) )
+ if(is_array($countries_array) )
{
foreach ( $countries_array as $country=>$number )
{
@@ -451,7 +451,7 @@ function fillCountriesTable($countries_array)
WHERE `country` = '".$country."'";
mysql_query($sql);
- }
+ }
}
}
@@ -465,11 +465,11 @@ function fillCountriesTable($countries_array)
* @author Sebastien Piraux
* @return a 2D array filled with code and name of browsers
- * @desc This function is used to build an array containing
+ * @desc This function is used to build an array containing
browser informations
*/
function loadBrowsers()
-{
+{
$buffer = split ("#","Gecko|Gecko#Mozilla/3|Mozilla 3.x#Mozilla/4.0|Mozilla 4.0x#Mozilla/4.5|Mozilla 4.5x#Mozilla/4.6|Mozilla 4.6x#Mozilla/4.7|Mozilla 4.7x#Mozilla/5.0|Mozilla 5.0x#MSIE 1.2|MSIE 1.2#MSIE 3.01|MSIE 3.x#MSIE 3.02|MSIE 3.x#MSIE 4.0|MSIE 4.x#MSIE 4.01|MSIE 4.x#MSIE 4.5|MSIE 4.5#MSIE 5.0b1|MSIE 5.0x#MSIE 5.0b2|MSIE 5.0x#MSIE 5.0|MSIE 5.0x#MSIE 5.01|MSIE 5.0x#MSIE 5.1|MSIE 5.1#MSIE 5.1b1|MSIE 5.1#MSIE 5.5|MSIE 5.5#MSIE 5.5b1|MSIE 5.5#MSIE 5.5b2|MSIE 5.5#MSIE 6.0|MSIE 6#MSIE 6.0b|MSIE 6#MSIE 6.5a|MSIE 6.5#Lynx/2.8.0|Lynx 2#Lynx/2.8.1|Lynx 2#Lynx/2.8.2|Lynx 2#Lynx/2.8.3|Lynx 2#Lynx/2.8.4|Lynx 2#Lynx/2.8.5|Lynx 2#HTTrack 3.0x|HTTrack#OmniWeb/4.0.1|OmniWeb#Opera 3.60|Opera 3.60#Opera 4.0|Opera 4#Opera 4.01|Opera 4#Opera 4.02|Opera 4#Opera 5|Opera 5#Opera/3.60|Opera 3.60#Opera/4|Opera 4#Opera/5|Opera 5#Opera/6|Opera 6#Opera 6|Opera 6#Netscape6|NS 6#Netscape/6|NS 6#Netscape7|NS 7#Netscape/7|NS 7#Konqueror/2.0|Konqueror 2#Konqueror/2.0.1|Konqueror 2#Konqueror/2.1|Konqueror 2#Konqueror/2.1.1|Konqueror 2#Konqueror/2.1.2|Konqueror 2#Konqueror/2.2|Konqueror 2#Teleport Pro|Teleport Pro#WebStripper|WebStripper#WebZIP|WebZIP#Netcraft Web|NetCraft#Googlebot|Googlebot#WebCrawler|WebCrawler#InternetSeer|InternetSeer#ia_archiver|ia archiver");
@@ -487,11 +487,11 @@ function loadBrowsers()
* @author Sebastien Piraux
* @return a 2D array filled with code and name of OS
- * @desc This function is used to build an array containing
+ * @desc This function is used to build an array containing
OS informations
*/
function loadOs()
-{
+{
$buffer = split ("#","Windows 95|Win 95#Windows_95|Win 95#Windows 98|Win 98#Windows NT|Win NT#Windows NT 5.0|Win 2000#Windows NT 5.1|Win XP#Windows 2000|Win 2000#Windows XP|Win XP#Windows ME|Win Me#Win95|Win 95#Win98|Win 98#WinNT|Win NT#linux-2.2|Linux 2#Linux|Linux#Linux 2|Linux 2#Macintosh|Mac#Mac_PPC|Mac#Mac_PowerPC|Mac#SunOS 5|SunOS 5#SunOS 6|SunOS 6#FreeBSD|FreeBSD#beOS|beOS#InternetSeer|InternetSeer#Googlebot|Googlebot#Teleport Pro|Teleport Pro");
$i=0;
foreach( $buffer as $buffer1 ) {
@@ -506,9 +506,9 @@ function loadOs()
* @param remhost : must be $_SERVER['HTTP_USER_AGENT']
* @param list_browsers : browsers list :x
* @param list_os : os list :x
- * @return a string formatted like : browser|OS
+ * @return a string formatted like : browser|OS
browser and OS are the 'viewable' names
- * @desc this function will extract browser and OS from
+ * @desc this function will extract browser and OS from
$_SERVER['HTTP_USER_AGENT']
*/
function extractAgent( $user_agent, $list_browsers, $list_os )
@@ -516,44 +516,44 @@ function extractAgent( $user_agent, $list_browsers, $list_os )
// default values, if nothing corresponding found
$viewable_browser = "Unknown";
$viewable_os = "Unknown";
-
+
// search for corresponding pattern in $_SERVER['HTTP_USER_AGENT']
// for browser
for($i = 0; $i < count( $list_browsers ); $i++)
{
$pos = strpos( $user_agent, $list_browsers[$i][0] );
if( $pos !== false )
- {
+ {
$viewable_browser = $list_browsers[$i][1];
- }
+ }
}
-
+
// for os
for($i = 0; $i < count($list_os); $i++)
{
$pos = strpos( $user_agent, $list_os[$i][0] );
if( $pos !== false )
- {
+ {
$viewable_os = $list_os[$i][1];
}
}
return $viewable_browser."|".$viewable_os;
-
-}
+
+}
/**
* @author Sebastien Piraux
* @param browser : name of the browser or 'Unknown'
* @param browsers_array :
- * @desc this function will :
- - if the browser is already in the table it will increment
+ * @desc this function will :
+ - if the browser is already in the table it will increment
the corresponding value
- if the browser doesn't exist it will be added and set to 1
*/
function addBrowser($browser,$browsers_array)
{
- if( isset( $browsers_array[$browser] ) )
+ if( isset( $browsers_array[$browser] ) )
{
// add one unity to this provider occurrences
$browsers_array[$browser] = $browsers_array[$browser] + 1;
@@ -564,7 +564,7 @@ function addBrowser($browser,$browsers_array)
$browsers_array[$browser] = 1;
}
return $browsers_array;
-
+
}
/**
@@ -572,14 +572,14 @@ function addBrowser($browser,$browsers_array)
* @author Sebastien Piraux
* @param os : name of the OS or 'Unknown'
* @param os_array : list of os and number of occurences
- * @desc this function will :
- - if the os is already in the table it will increment
+ * @desc this function will :
+ - if the os is already in the table it will increment
the corresponding value
- if the os doesn't exist it will be added and set to 1
*/
function addOs($os,$os_array)
{
- if( isset( $os_array[$os] ) )
+ if( isset( $os_array[$os] ) )
{
// add one unity to this provider occurrences
$os_array[$os] = $os_array[$os] + 1;
@@ -590,7 +590,7 @@ function addOs($os,$os_array)
$os_array[$os] = 1;
}
return $os_array;
-
+
}
/**
@@ -602,7 +602,7 @@ function addOs($os,$os_array)
function fillBrowsersTable($browsers_array)
{
global $TABLESTATS_BROWSERS;
- if ( is_array($browsers_array ) )
+ if ( is_array($browsers_array ) )
{
foreach ( $browsers_array as $browser=>$number )
{
@@ -622,12 +622,12 @@ function fillBrowsersTable($browsers_array)
else
{
// insert
- $sql2 = "INSERT INTO `".$TABLESTATS_BROWSERS."`
- (`browser`,`counter`)
+ $sql2 = "INSERT INTO `".$TABLESTATS_BROWSERS."`
+ (`browser`,`counter`)
VALUES ('".$browser."','".$number."')";
}
mysql_query($sql2);
- }
+ }
}
}
@@ -660,12 +660,12 @@ function fillOsTable($os_array)
else
{
// insert
- $sql2 = "INSERT INTO `".$TABLESTATS_OS."`
- (`os`,`counter`)
+ $sql2 = "INSERT INTO `".$TABLESTATS_OS."`
+ (`os`,`counter`)
VALUES ('".$os."','".$number."')";
}
mysql_query($sql2);
- }
+ }
}
}
@@ -681,14 +681,14 @@ function fillOsTable($os_array)
* @author Sebastien Piraux
* @param referer : name of the referer
* @param referers_array : list of referer and number of occurences
- * @desc this function will :
- - if the referer is already in the table it will increment
+ * @desc this function will :
+ - if the referer is already in the table it will increment
the corresponding value
- if the referer doesn't exist it will be added and set to 1
*/
function addReferer($referer,$referers_array)
{
- if( isset( $referers_array[$referer] ) )
+ if( isset( $referers_array[$referer] ) )
{
// add one unity to this provider occurrences
$referers_array[$referer] = $referers_array[$referer] + 1;
@@ -699,9 +699,9 @@ function addReferer($referer,$referers_array)
$referers_array[$referer] = 1;
}
return $referers_array;
-
+
}
-
+
/**
@@ -712,7 +712,7 @@ function addReferer($referer,$referers_array)
function fillReferersTable($referers_array)
{
global $TABLESTATS_REFERERS;
- if (is_array($referers_array) )
+ if (is_array($referers_array) )
{
foreach ( $referers_array as $referer=>$number )
{
@@ -720,7 +720,7 @@ function fillReferersTable($referers_array)
FROM `".$TABLESTATS_REFERERS."`
WHERE `referer` = '".$referer."'";
$res = mysql_query($sql);
-
+
// if this provider already exists in the DB
if( $row = mysql_num_rows($res) )
{
@@ -732,8 +732,8 @@ function fillReferersTable($referers_array)
else
{
// insert
- $sql2 = "INSERT INTO `".$TABLESTATS_REFERERS."`
- (`referer`,`counter`)
+ $sql2 = "INSERT INTO `".$TABLESTATS_REFERERS."`
+ (`referer`,`counter`)
VALUES ('".$referer."','".$number."')";
}
mysql_query($sql2);
diff --git a/main/inc/lib/statsUtils.lib.inc.php b/main/inc/lib/statsUtils.lib.inc.php
index 9a7ecb3c67..373d73adff 100644
--- a/main/inc/lib/statsUtils.lib.inc.php
+++ b/main/inc/lib/statsUtils.lib.inc.php
@@ -1,39 +1,39 @@
* @param sql : a sql query (as a string)
- * @return hours_array
+ * @return hours_array
* @desc Return an assoc array. Keys are the hours, values are
the number of time this hours was found.
key 'total' return the sum of all number of time hours
@@ -187,7 +187,7 @@ function hoursTab($sql)
{
$hours_array = array('total' => 0);
$res = mysql_query($sql);
-
+
if (mysql_errno())
{
echo "\n\n";
@@ -212,7 +212,7 @@ function hoursTab($sql)
}
mysql_free_result($res);
}
-
+
return $hours_array;
}
@@ -255,7 +255,7 @@ function daysTab($sql)
}
mysql_free_result($res);
}
-
+
return $days_array;
}
@@ -263,7 +263,7 @@ function daysTab($sql)
* @author Sebastien Piraux
* @param sql : a sql query (as a string)
- * @return month_array
+ * @return month_array
* @desc Return an assoc array. Keys are the days, values are
the number of time this hours was found.
key "total" return the sum of all number of time days
@@ -274,7 +274,7 @@ function monthTab($sql)
$MonthsLong = array (get_lang('JanuaryLong'), get_lang('FebruaryLong'), get_lang('MarchLong'), get_lang('AprilLong'), get_lang('MayLong'), get_lang('JuneLong'), get_lang('JulyLong'), get_lang('AugustLong'), get_lang('SeptemberLong'), get_lang('OctoberLong'), get_lang('NovemberLong'), get_lang('DecemberLong'));
$month_array = array('total' => 0);
$res = mysql_query($sql);
-
+
if (mysql_errno())
{
echo "\n\n";
@@ -295,7 +295,7 @@ function monthTab($sql)
}
mysql_free_result($res);
}
-
+
return $month_array;
}
@@ -304,7 +304,7 @@ function monthTab($sql)
* @author Sebastien Piraux
* @param period_array : an array provided by hoursTab($sql) or daysTab($sql)
* @param periodTitle : title of the first column, type of period
- * @param linkOnPeriod :
+ * @param linkOnPeriod :
* @desc Display a 4 column array
Columns are : hour of day, graph, number of hits and %
First line are titles
@@ -334,7 +334,7 @@ function makeHitsTable($period_array, $periodTitle, $linkOnPeriod = '???')
$maxSize = $factor * 100; //pixels
while(list($periodPiece, $cpt) = each($period_array))
{
- if($periodPiece != 'total')
+ if($periodPiece != 'total')
{
$pourcent = round(100 * $cpt / $period_array['total']);
$barwidth = $factor * $pourcent ;
@@ -345,12 +345,12 @@ function makeHitsTable($period_array, $periodTitle, $linkOnPeriod = '???')
\n";
}
@@ -458,22 +458,22 @@ function buildTab2ColNoTitle($array_of_results)
* @param array_of_results : a 2 columns array
* @desc this function is used to display
integrity errors in the platform
- if array_of_results is not an array there is
+ if array_of_results is not an array there is
no error, else errors are displayed
*/
function buildTabDefcon($array_of_results)
{
echo "
\n";
-
+
if (is_array($array_of_results))
- {
- // there are some strange cases...
- echo '
';
+ {
+ // there are some strange cases...
+ echo '
\n";
@@ -491,7 +491,7 @@ function buildTabDefcon($array_of_results)
else
{
// all right
- echo '
';
+ echo '
';
echo '
'.get_lang('AllRight').'
';
echo "
\n";
}
diff --git a/main/inc/lib/surveymanager.lib.php b/main/inc/lib/surveymanager.lib.php
index dedccf172d..f1fc037b7c 100644
--- a/main/inc/lib/surveymanager.lib.php
+++ b/main/inc/lib/surveymanager.lib.php
@@ -32,7 +32,7 @@
*/
class SurveyManager {
private function __construct() {
-
+
}
/**
* Creates a new survey for the platform
@@ -82,8 +82,8 @@ class SurveyManager {
* Possible deprecated method
*/
function create_group($survey_id,$group_title,$introduction,$table_group)
- {
-
+ {
+
$sql_query = "SELECT * FROM $table_group WHERE groupname='".Database::escape_string($group_title)."' AND survey_id=".Database::escape_string($survey_id);
$res = api_sql_query($sql_query, __FILE__, __LINE__);
if(mysql_num_rows($res))
@@ -155,11 +155,11 @@ class SurveyManager {
/**
* Possible deprecated method
*/
- function insert_into_group ($survey_id,$group_title,$introduction,$tb) {
+ function insert_into_group ($survey_id,$group_title,$introduction,$tb) {
$survey_id = Database::escape_string($survey_id);
$group_title = Database::escape_string($group_title);
- $introduction = Database::escape_string($introduction);
-
+ $introduction = Database::escape_string($introduction);
+
$sql="INSERT INTO $tb (group_id,survey_id,group_title,introduction) values('','$survey_id','$group_title','$introduction')";
$result=api_sql_query($sql);
return mysql_insert_id();
@@ -453,7 +453,7 @@ class SurveyManager {
}
/**
* Possible deprecated method
- */
+ */
function get_surveyname_display($sid)
{
$sid = Database::escape_string($sid);
@@ -463,7 +463,7 @@ class SurveyManager {
$code=@mysql_result($res,0,'title');
return($code);
}
-
+
/*
function join_survey($question_type)
{
@@ -478,7 +478,7 @@ class SurveyManager {
*/
/**
* Possible deprecated method
- */
+ */
function import_questions($import_type, $ids)
{
//$groupname=surveymanager::get_groupname($gid_arr[$index]);
@@ -529,7 +529,7 @@ class SurveyManager {
$table_question = Database :: get_course_table(TABLE_MAIN_SURVEYQUESTION);
$survey_id = Database::escape_string($survey_id);
-
+
// Deleting the survey
$sql = "DELETE FROM $table_survey WHERE survey_id='".$survey_id."'";
api_sql_query($sql,__FILE__,__LINE__);
@@ -1771,100 +1771,100 @@ function getUserAnswersDetails($id_userAnswers, $params=''){
/**
- *
+ *
* Manage the "versioning" of a conditional survey
- *
+ *
* */
class SurveyTree {
- public $surveylist;
+ public $surveylist;
public $plainsurveylist;
public $numbersurveys;
-
+
/**
* Sets the surveylist and the plainsurveylist
*/
- public function __construct() {
+ public function __construct() {
// Database table definitions
$table_survey = Database :: get_course_table(TABLE_SURVEY);
$table_survey_question = Database :: get_course_table(TABLE_SURVEY_QUESTION);
$table_user = Database :: get_main_table(TABLE_MAIN_USER);
-
+
// searching
$search_restriction = SurveyUtil::survey_search_restriction();
if ($search_restriction) {
$search_restriction = ' AND '.$search_restriction;
}
-
+
$sql = "SELECT survey.survey_id , survey.parent_id, survey_version, survey.code as name
- FROM $table_survey survey
- LEFT JOIN $table_survey_question survey_question
- ON survey.survey_id = survey_question.survey_id , $table_user user
- WHERE survey.author = user.user_id
+ FROM $table_survey survey
+ LEFT JOIN $table_survey_question survey_question
+ ON survey.survey_id = survey_question.survey_id , $table_user user
+ WHERE survey.author = user.user_id
GROUP BY survey.survey_id";
-
+
$res = api_sql_query($sql, __FILE__, __LINE__);
- $surveys_parents = array ();
+ $surveys_parents = array ();
$refs = array();
$list = array();
- $last=array();
+ $last=array();
$plain_array=array();
-
+
while ($survey = Database::fetch_array($res,'ASSOC'))
{
$plain_array[$survey['survey_id']]=$survey;
- $surveys_parents[]=$survey['survey_version'];
- $thisref = &$refs[ $survey['survey_id'] ];
+ $surveys_parents[]=$survey['survey_version'];
+ $thisref = &$refs[ $survey['survey_id'] ];
$thisref['parent_id'] = $survey['parent_id'];
$thisref['name'] = $survey['name'];
$thisref['id'] = $survey['survey_id'];
- $thisref['survey_version'] = $survey['survey_version'];
- if ($survey['parent_id'] == 0)
+ $thisref['survey_version'] = $survey['survey_version'];
+ if ($survey['parent_id'] == 0)
{
- $list[ $survey['survey_id'] ] = &$thisref;
- }
- else
+ $list[ $survey['survey_id'] ] = &$thisref;
+ }
+ else
{
- $refs[ $survey['parent_id'] ]['children'][ $survey['survey_id'] ] = &$thisref;
- }
- }
+ $refs[ $survey['parent_id'] ]['children'][ $survey['survey_id'] ] = &$thisref;
+ }
+ }
$this->surveylist = $list;
- $this->plainsurveylist = $plain_array;
+ $this->plainsurveylist = $plain_array;
}
- /*
+ /*
function read_children($space=array(),$i=0)
- {
+ {
foreach ( $this->surveylist as $key=>$node)
{
if (is_array($node['children']))
- {
+ {
if (($node['parent_id']==0))
- {
- //echo '1 ';
+ {
+ //echo '1 ';
}
else
{
- $space[]='2>';
+ $space[]='2>';
}
-
- //if have children
+
+ //if have children
for ($j=0;$j';
}
//echo $node['name']; echo '3 ';
- read_children($node['children'],$space,$i);
+ read_children($node['children'],$space,$i);
}
else
- {
-
+ {
+
for ($j=0;$j';
- }
+ }
echo $node['name']; echo '5 ';
-
+
}
- }
+ }
}
*/
/*
@@ -1872,19 +1872,19 @@ class SurveyTree {
{
echo $node['name']; echo ' ';
//$node['children']=array();
- return $node['children'];
+ return $node['children'];
}
else
- {
+ {
if (is_array($node['children']))
- {
+ {
return SurveyTree::get_children($node['children'],$id);
}
else
{
//return SurveyTree::get_children($node, $id);
}
- }
+ }
*/
/**
@@ -1894,52 +1894,52 @@ class SurveyTree {
* @param id the id of the survey
* @return array the children of a given survey id
*
- * @author Julio Montoya , Dokeos
+ * @author Julio Montoya , Dokeos
* @version September 2008
*/
- public function get_children ($list,$id) {
+ public function get_children ($list,$id) {
$result=array();
foreach ($list as $key=>$node)
{
if ($key==$id)
{
- $result = $node['children'];
- break;
- }
+ $result = $node['children'];
+ break;
+ }
if (is_array($node['children']))
- {
- //echo $key; echo '-- ';
+ {
+ //echo $key; echo '-- ';
$re=self::get_children($node['children'],$id);
if (!empty($re))
{
$result=$re;
- }
+ }
}
else
- {
- //echo $key; echo '- ';
- }
+ {
+ //echo $key; echo '- ';
+ }
}
return $result;
}
-
+
/**
* This function gets the parent id of a survey
*
* @param int survey id
* @return int survey parent id
*
- * @author Julio Montoya , Dokeos
+ * @author Julio Montoya , Dokeos
* @version September 2008
*/
- public function getParentId ($id) {
+ public function getParentId ($id) {
$node = $this->plainsurveylist[$id];
if (is_array($node)&& !empty($node['parent_id']))
return $node['parent_id'];
else
- return -1;
+ return -1;
}
-
+
/**
* This function gets all the siblings of a given survey id
*
@@ -1947,91 +1947,91 @@ class SurveyTree {
* @param id the id of the survey
* @return array the children of a given survey id
*
- * @author Julio Montoya , Dokeos
+ * @author Julio Montoya , Dokeos
* @version September 2008
*/
public function nextSibling($id) {
$result=array();
- $parent_id = self::getParentId($id);
+ $parent_id = self::getParentId($id);
$siblings = self::get_children($this->surveylist ,$parent_id);
- //print_r($siblings);
- if (count($siblings) > 1)
- {
- // $key> $id means that the siblings are order 1 2 3 and we suppose that you can't change that order
+ //print_r($siblings);
+ if (count($siblings) > 1)
+ {
+ // $key> $id means that the siblings are order 1 2 3 and we suppose that you can't change that order
foreach ($siblings as $key=>$bro)
{
if ($key> $id && $key != $id)
{
$result[$key]=($bro);
- }
- }
+ }
+ }
}
- return $result;
+ return $result;
}
-
+
/**
- *
+ *
* This function shows the last sibling from a given list of surveys
* @param id of the survey
- * @author Julio Montoya , Dokeos
+ * @author Julio Montoya , Dokeos
* @version September 2008
- *
+ *
*/
- public function lastSibling($id) {
+ public function lastSibling($id) {
$result=array();
- $parent_id = self::getParentId($id);
+ $parent_id = self::getParentId($id);
$siblings = self::get_children($this->surveylist ,$parent_id);
- //print_r($siblings);
- if (count($siblings) > 1)
- {
+ //print_r($siblings);
+ if (count($siblings) > 1)
+ {
// $key> $id means that the siblings are order 1 2 3 and we suppose that you can't change that order
- $i=0;
+ $i=0;
foreach ($siblings as $key=>$bro)
{
if ($key> $id && $key != $id&& $i==count($siblings)-1)
{
$result[$key]=($bro);
- }
- $i++;
- }
+ }
+ $i++;
+ }
}
- return $result;
+ return $result;
}
-
-
+
+
/**
- *
- * This function shows the last children of a branch
+ *
+ * This function shows the last children of a branch
* @param list of nodes
* @return array of the lastest node
- * @author Julio Montoya , Dokeos
+ * @author Julio Montoya , Dokeos
* @version September 2008
- *
+ *
*/
- public function get_last_children_from_branch($list) {
- $result=array();
+ public function get_last_children_from_branch($list) {
+ $result=array();
foreach ($list as $key=>$node)
- {
+ {
//echo 'frist '; echo $key;
//print_r($node);
if ($node['parent_id']!=0)
- {
- $list_bros = self::lastSibling($key);
- //echo ' list_bro ';
+ {
+ $list_bros = self::lastSibling($key);
+ //echo ' list_bro ';
//print_r($list_bros);
- if (is_array($list_bros) && !empty($list_bros))
+ if (is_array($list_bros) && !empty($list_bros))
{
foreach ($list_bros as $bro)
- {
- //echo '0';
+ {
+ //echo '0';
if (is_array($bro['children']))
{
- //print_r($bro['children']);
+ //print_r($bro['children']);
return $result[]=self::get_last_children_from_branch($bro['children']);
}
else
- {
- //echo 'esl';
+ {
+ //echo 'esl';
$result=$bro;
//print_r($bro);
return $result;
@@ -2049,12 +2049,12 @@ class SurveyTree {
{
return $result[]=self::get_last_children_from_branch($node['children']);
}
- else
- {
- //return $result[]=SurveyTree::get_last_children_from_branch($node['children']);
- return $result[]=$node;
+ else
+ {
+ //return $result[]=SurveyTree::get_last_children_from_branch($node['children']);
+ return $result[]=$node;
}
-
+
}
}
else
@@ -2064,85 +2064,85 @@ class SurveyTree {
{
$result[]=self::get_last_children_from_branch($node['children']);
}
- else
+ else
{
- $result[]=$node;
+ $result[]=$node;
}
- }
+ }
}
return $result;
}
/*
*
- *
- * This function show the last children of list
+ *
+ * This function show the last children of list
* @param id
- * @param array
+ * @param array
* @return array of the lastest node
- * @author Julio Montoya , Dokeos
+ * @author Julio Montoya , Dokeos
* @version September 2008
- *
+ *
+
-
function get_last_children($id,$last)
- {
+ {
foreach ( $this->_list as $key=>$node)
{
if (($node['parent_id']==$id))
{
- $last=$node['name']; echo ' ';
+ $last=$node['name']; echo ' ';
}
else
{
if (is_array($node['children']))
{
- return $last = get_last_children($node['children'],$id);
- }
- }
+ return $last = get_last_children($node['children'],$id);
+ }
+ }
}
return $last;
}
*/
/**
- * This function creates a list of all surveys id
+ * This function creates a list of all surveys id
* @param list of nodes
- * @return array with the structure survey_id => survey_name
- * @author Julio Montoya , Dokeos
+ * @return array with the structure survey_id => survey_name
+ * @author Julio Montoya , Dokeos
* @version September 2008
- *
+ *
*/
public function createList ($list) {
- $result=array();
+ $result=array();
foreach ($list as $key=>$node)
- {
+ {
if (is_array($node['children']))
- {
+ {
//echo $key; echo '-- ';
//print_r($node);
//echo ' ';
- $result[$key]= $node['name'];
+ $result[$key]= $node['name'];
$re=self::createList($node['children']);
if (!empty($re))
- {
+ {
if (is_array($re))
foreach ($re as $key=>$r)
- {
+ {
$result[$key]=''.$r;
}
- else
+ else
{
$result[]=$re;
}
-
- }
+
+ }
}
else
- {
+ {
//echo $key; echo '- ';
- $result[$key]=$node['name'];
- }
- }
+ $result[$key]=$node['name'];
+ }
+ }
return $result;
- }
+ }
}
?>
diff --git a/main/inc/lib/system_announcements.lib.php b/main/inc/lib/system_announcements.lib.php
index b94d02e3e2..afa9456997 100644
--- a/main/inc/lib/system_announcements.lib.php
+++ b/main/inc/lib/system_announcements.lib.php
@@ -262,7 +262,7 @@ class SystemAnnouncementManager
if (!checkdate($date_start[1], $date_start[2], $date_start[0])) {
Display :: display_normal_message(get_lang('InvalidStartDate'));
return false;
- }
+ }
if (($date_end[1] || $date_end[2] || $date_end[0]) && !checkdate($date_end[1], $date_end[2], $date_end[0])) {
Display :: display_normal_message(get_lang('InvalidEndDate'));
return false;
@@ -278,9 +278,9 @@ class SystemAnnouncementManager
$lang = is_null($lang) ? 'NULL' : "'".Database::escape_string($lang)."'";
$sql = "INSERT INTO ".$db_table." (title,content,date_start,date_end,visible_teacher,visible_student,visible_guest, lang)
VALUES ('".$title."','".$content."','".$start."','".$end."','".$visible_teacher."','".$visible_student."','".$visible_guest."',".$lang.")";
- if ($send_mail==1) {
- SystemAnnouncementManager::send_system_announcement_by_email($title, $content,$visible_teacher, $visible_student);
- }
+ if ($send_mail==1) {
+ SystemAnnouncementManager::send_system_announcement_by_email($title, $content,$visible_teacher, $visible_student);
+ }
return api_sql_query($sql,__FILE__,__LINE__);
}
/**
@@ -324,9 +324,9 @@ class SystemAnnouncementManager
$id = intval($id);
$sql = "UPDATE ".$db_table." SET lang=$lang,title='".$title."',content='".$content."',date_start='".$start."',date_end='".$end."', ";
$sql .= " visible_teacher = '".$visible_teacher."', visible_student = '".$visible_student."', visible_guest = '".$visible_guest."' WHERE id='".$id."'";
-
+
if ($send_mail==1) {
- SystemAnnouncementManager::send_system_announcement_by_email($title, $content,$visible_teacher, $visible_student);
+ SystemAnnouncementManager::send_system_announcement_by_email($title, $content,$visible_teacher, $visible_student);
}
return api_sql_query($sql,__FILE__,__LINE__);
}
@@ -369,12 +369,12 @@ class SystemAnnouncementManager
$sql = "UPDATE ".$db_table." SET ".$field." = '".$visible."' WHERE id='".$announcement_id."'";
return api_sql_query($sql,__FILE__,__LINE__);
}
-
+
function send_system_announcement_by_email($title,$content,$teacher, $student)
{
- global $_user;
+ global $_user;
global $_setting;
- global $charset;
+ global $charset;
$user_table = Database :: get_main_table(TABLE_MAIN_USER);
if ($teacher<>0 AND $student == '0') {
$sql = "SELECT * FROM $user_table WHERE email<>'' AND status = '1'";
@@ -388,7 +388,7 @@ class SystemAnnouncementManager
if ($teacher == '0' AND $student == '0') {
return true;
}
-
+
$result = api_sql_query($sql,__FILE__,__LINE__);
while($row = Database::fetch_array($result,'ASSOC'))
{
diff --git a/main/inc/lib/tablesort.lib.php b/main/inc/lib/tablesort.lib.php
index 542ea9174f..35aff339fd 100644
--- a/main/inc/lib/tablesort.lib.php
+++ b/main/inc/lib/tablesort.lib.php
@@ -1,33 +1,33 @@
$row)
{
if(strlen(strip_tags($row[$column])) != 0 )
{
$check_date = strtotime(strip_tags($row[$column]));
- // strtotime Returns a timestamp on success, FALSE otherwise.
- // Previous to PHP 5.1.0, this function would return -1 on failure.
+ // strtotime Returns a timestamp on success, FALSE otherwise.
+ // Previous to PHP 5.1.0, this function would return -1 on failure.
$is_date &= ($check_date != -1 && $check_date != false);
}
else
{
- $is_date &= false;
+ $is_date &= false;
}
}
return $is_date;
@@ -165,39 +165,39 @@ class TableSort
}
return $is_image;
}
-
-
+
+
/**
* Sort 2-dimensional table. It is possile of change the columns that will be show and the way that the columns are sorted.
* @param array $data The data to be sorted.
* @param int $column The column on which the data should be sorted (default = 0)
* @param string $direction The direction to sort (SORT_ASC (default) orSORT_DESC)
- * @param array $column_show The columns that we will show in the table i.e: $column_show=array('1','0','1') we will show the 1st and the 3th column.
+ * @param array $column_show The columns that we will show in the table i.e: $column_show=array('1','0','1') we will show the 1st and the 3th column.
* @param array $column_order Changes how the columns will be sorted ie. $column_order=array('1','4','3','4') The 2nd column will be sorted like the 4 column
- * @param constant $type How should data be sorted (SORT_REGULAR, SORT_NUMERIC,SORT_STRING,SORT_DATE,SORT_IMAGE) *
+ * @param constant $type How should data be sorted (SORT_REGULAR, SORT_NUMERIC,SORT_STRING,SORT_DATE,SORT_IMAGE) *
* @return array The sorted dataset
* @author bart.mollet@hogent.be
*/
-
+
function sort_table_config($data, $column = 0, $direction = SORT_ASC, $column_show=null, $column_order=null,$type = SORT_REGULAR)
{
if(!is_array($data) or count($data)==0){return array();}
if($column != strval(intval($column))){return $data;} //probably an attack
if(!in_array($direction,array(SORT_ASC,SORT_DESC))){return $data;} // probably an attack
- $compare_function = '';
- // Change columns sort
+ $compare_function = '';
+ // Change columns sort
// Here we say that the real way of how the columns are going to be order is manage by the $column_order array
- if(is_array($column_order))
+ if(is_array($column_order))
{
for($i=0;$i 0';
break;
- }
-
+ }
+
$function_body = '$el1 = $a['.$column.']; ' .
'$el2 = $b['.$column.']; ' .
'return ('.$direction.' == SORT_ASC ? ('.$compare_function.') : !('.$compare_function.'));';
// Sort the content
usort($data, create_function('$a,$b', $function_body));
-
- // We show only the columns data that were set up on the $column_show array
+
+ // We show only the columns data that were set up on the $column_show array
$new_order_data=array();
-
+
if(is_array($column_show))
- {
-
+ {
+
for ($j=0;$j
diff --git a/main/inc/lib/text.lib.php b/main/inc/lib/text.lib.php
index 121f68aa7a..eea32b92f5 100644
--- a/main/inc/lib/text.lib.php
+++ b/main/inc/lib/text.lib.php
@@ -100,7 +100,7 @@ function format_locale_date($date_format, $time_stamp = -1, $language = null)
/**
* @desc this function does some parsing on the text that gets inputted. This parsing can be of any kind
* LaTeX notation, Word Censoring, Glossary Terminology (extension will available soon), Musical Notations, ...
-* The inspiration for this filter function came from Moodle an phpBB who both use a similar approach
+* The inspiration for this filter function came from Moodle an phpBB who both use a similar approach
* @param $input string. some text
* @return $output string. some text that contains the parsed elements.
* @example [tex]\sqrt(2)[/tex]
@@ -111,48 +111,48 @@ function text_filter($input, $filter=true)
{
//$input=stripslashes($input);
-
+
if ($filter==true)
{
// *** parse [tex]...[/tex] tags *** //
// which will return techexplorer or image html depending on the capabilities of the
// browser of the user (using some javascript that checks if the browser has the TechExplorer plugin installed or not)
$input=_text_parse_tex($input);
-
-
+
+
// *** parse [teximage]...[/teximage] tags *** //
// these force the gif rendering of LaTeX using the mimetex gif renderer
//$input=_text_parse_tex_image($input);
-
-
+
+
// *** parse [texexplorer]...[/texexplorer] tags *** //
// these force the texeplorer LaTeX notation
$input=_text_parse_texexplorer($input);
-
+
// *** Censor Words *** //
// censor words. This function removes certain words by [censored]
- // this can be usefull when the campus is open to the world.
+ // this can be usefull when the campus is open to the world.
// $input=text_censor_words($input);
-
+
// *** parse [?]...[/?] tags *** //
// for the glossary tool (see http://www.dokeos.com/extensions)
$input=_text_parse_glossary($input);
-
+
// parse [wiki]...[/wiki] tags
- // this is for the coolwiki plugin.
- // $input=text_parse_wiki($input);
-
+ // this is for the coolwiki plugin.
+ // $input=text_parse_wiki($input);
+
// parse [tool]...[/tool] tags
// this parse function adds a link to a certain tool
// $input=text_parse_tool($input);
-
+
// parse [user]...[/user] tags
-
+
// parse [email]...[/email] tags
-
+
// parse [code]...[/code] tags
}
-
+
return $input;
}
@@ -170,10 +170,10 @@ function _text_parse_tex($textext)
{
//$textext = str_replace(array ("[tex]", "[/tex]"), array ('[*****]', '[/*****]'), $textext);
//$textext=stripslashes($texttext);
-
+
$input_array=preg_split("/(\[tex]|\[\/tex])/",$textext,-1, PREG_SPLIT_DELIM_CAPTURE);
-
-
+
+
foreach ($input_array as $key=>$value)
{
if ($key>0 && $input_array[$key-1]=='[tex]' AND $input_array[$key+1]=='[/tex]')
@@ -184,7 +184,7 @@ function _text_parse_tex($textext)
//echo 'LaTeX: