Format code, add docs, fix PHP warnings.

1.10.x
Julio Montoya 10 years ago
parent 65ee1ebf4d
commit ec07e3cb0c
  1. 21
      main/dropbox/dropbox_class.inc.php
  2. 65
      main/dropbox/dropbox_functions.inc.php
  3. 24
      main/dropbox/dropbox_init.inc.php
  4. 8
      main/dropbox/index.php
  5. 11
      main/dropbox/recover_dropbox_files.php
  6. 1
      main/forum/download.php
  7. 11
      main/forum/editpost.php
  8. 2
      main/forum/forumfunction.inc.php
  9. 1
      main/inc/lib/TeacherTimeReport.php
  10. 37
      main/inc/lib/dashboard.lib.php
  11. 1
      main/inc/lib/internationalization.lib.php
  12. 1
      main/inc/lib/legal.lib.php
  13. 2
      main/inc/lib/link.lib.php
  14. 107
      main/inc/lib/message.lib.php
  15. 144
      main/inc/lib/myspace.lib.php
  16. 8
      main/inc/lib/nanogong.lib.php
  17. 3
      main/inc/lib/online.inc.php
  18. 17
      main/inc/lib/security.lib.php
  19. 28
      main/inc/lib/statistics.lib.php
  20. 46
      main/inc/lib/sub_language.class.php
  21. 7
      main/inc/lib/system_announcements.lib.php
  22. 9
      main/inc/lib/thematic.lib.php
  23. 59
      main/inc/lib/tracking.lib.php
  24. 25
      main/inc/lib/usergroup.lib.php

@ -92,7 +92,6 @@ class Dropbox_Work
*/
public function _createNewWork($uploader_id, $title, $description, $author, $filename, $filesize)
{
$_user = api_get_user_info();
$dropbox_cnf = getDropboxConf();
// Fill in the properties
@ -190,7 +189,7 @@ class Dropbox_Work
// Get the data from DB
$sql = "SELECT uploader_id, filename, filesize, title, description, author, upload_date, last_upload_date, cat_id
FROM ".$dropbox_cnf['tbl_file']."
WHERE c_id = $course_id AND id = ".intval($id)."";
WHERE c_id = $course_id AND id = ".$id."";
$result = Database::query($sql);
$res = Database::fetch_array($result, 'ASSOC');
@ -275,7 +274,14 @@ class Dropbox_SentWork extends Dropbox_Work
$_course = api_get_course_info();
// Call constructor of Dropbox_Work object
$this->Dropbox_Work($uploader_id, $title, $description, $author, $filename, $filesize);
$this->Dropbox_Work(
$uploader_id,
$title,
$description,
$author,
$filename,
$filesize
);
$course_id = api_get_course_int_id();
@ -585,11 +591,14 @@ class Dropbox_Person
$course_id = api_get_course_int_id();
$id = intval($id);
$sql = "DELETE FROM ".$dropbox_cnf['tbl_file']." WHERE c_id = $course_id AND cat_id = '".$id."' ";
$sql = "DELETE FROM ".$dropbox_cnf['tbl_file']."
WHERE c_id = $course_id AND cat_id = '".$id."' ";
if (!Database::query($sql)) return false;
$sql = "DELETE FROM ".$dropbox_cnf['tbl_category']." WHERE c_id = $course_id AND cat_id = '".$id."' ";
$sql = "DELETE FROM ".$dropbox_cnf['tbl_category']."
WHERE c_id = $course_id AND cat_id = '".$id."' ";
if (!Database::query($sql)) return false;
$sql = "DELETE FROM ".$dropbox_cnf['tbl_post']." WHERE c_id = $course_id AND cat_id = '".$id."' ";
$sql = "DELETE FROM ".$dropbox_cnf['tbl_post']."
WHERE c_id = $course_id AND cat_id = '".$id."' ";
if (!Database::query($sql)) return false;
return true;
}

@ -115,7 +115,8 @@ function getDropboxConf()
/**
* This function deletes a dropbox category
*
* @todo give the user the possibility what needs to be done with the files in this category: move them to the root, download them as a zip, delete them
* @todo give the user the possibility what needs to be done with the files
* in this category: move them to the root, download them as a zip, delete them
*
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
* @version march 2006
@ -156,11 +157,13 @@ function delete_category($action, $id, $user_id = null)
}
// step 1: delete the category
$sql = "DELETE FROM ".$dropbox_cnf['tbl_category']." WHERE c_id = $course_id AND cat_id='".intval($id)."' AND $sentreceived='1'";
$sql = "DELETE FROM ".$dropbox_cnf['tbl_category']."
WHERE c_id = $course_id AND cat_id='".intval($id)."' AND $sentreceived='1'";
Database::query($sql);
// step 2: delete all the documents in this category
$sql = "SELECT * FROM ".$entries_table." WHERE c_id = $course_id AND cat_id='".intval($id)."'";
$sql = "SELECT * FROM ".$entries_table."
WHERE c_id = $course_id AND cat_id='".intval($id)."'";
$result = Database::query($sql);
while($row = Database::fetch_array($result)) {
@ -172,6 +175,7 @@ function delete_category($action, $id, $user_id = null)
$dropboxfile->deleteSentWork($row[$id_field]);
}
}
return $return_message;
}
@ -241,6 +245,7 @@ function store_move($id, $target, $part)
} else {
$return_message = get_lang('NotMovedError');
}
return $return_message;
}
@ -291,6 +296,7 @@ function display_file_checkbox($id, $part) {
$checked = 'checked';
}
$return_value = '<input type="checkbox" name="'.Security::remove_XSS($part).'_'.Security::remove_XSS($id).'" value="'.Security::remove_XSS($id).'" '.$checked.' />';
return $return_value;
}
@ -314,7 +320,8 @@ function get_dropbox_categories($filter = '')
$session_id = api_get_session_id();
$condition_session = api_get_session_condition($session_id);
$sql = "SELECT * FROM ".$dropbox_cnf['tbl_category']." WHERE c_id = $course_id AND user_id='".$_user['user_id']."' $condition_session";
$sql = "SELECT * FROM ".$dropbox_cnf['tbl_category']."
WHERE c_id = $course_id AND user_id='".$_user['user_id']."' $condition_session";
$result = Database::query($sql);
while ($row = Database::fetch_array($result)) {
@ -336,7 +343,8 @@ function get_dropbox_category($id)
$dropbox_cnf = getDropboxConf();
$course_id = api_get_course_int_id();
if (empty($id) or $id != intval($id)) { return array(); }
$sql = "SELECT * FROM ".$dropbox_cnf['tbl_category']." WHERE c_id = $course_id AND cat_id='".$id."'";
$sql = "SELECT * FROM ".$dropbox_cnf['tbl_category']."
WHERE c_id = $course_id AND cat_id='".$id."'";
$res = Database::query($sql);
if ($res === false) {
return array();
@ -524,7 +532,11 @@ function display_add_form($dropbox_unid, $viewReceivedCategory, $viewSentCategor
$origin = isset($_GET['origin']) ? $_GET['origin'] : null;
$token = Security::get_token();
$dropbox_person = new Dropbox_Person(api_get_user_id(), $is_courseAdmin, $is_courseTutor);
$dropbox_person = new Dropbox_Person(
api_get_user_id(),
$is_courseAdmin,
$is_courseTutor
);
$form = new FormValidator(
'sent_form',
@ -695,6 +707,7 @@ function getLoginFromId($id)
$result = Database::query($sql);
$res = Database::fetch_array($result);
if (!$res) return false;
return stripslashes($res['username']);
}
@ -707,6 +720,7 @@ function isCourseMember($user_id)
$_course = api_get_course_info();
$course_code = $_course['code'];
$is_course_member = CourseManager::is_user_subscribed_in_course($user_id, $course_code, true);
return $is_course_member;
}
@ -729,9 +743,11 @@ function removeUnusedFiles()
$result = Database::query($sql);
while ($res = Database::fetch_array($result)) {
//delete the selected files from the post and file tables
$sql = "DELETE FROM " . dropbox_cnf('tbl_post') . " WHERE c_id = $course_id AND file_id = '" . $res['id'] . "'";
$sql = "DELETE FROM " . dropbox_cnf('tbl_post') . "
WHERE c_id = $course_id AND file_id = '" . $res['id'] . "'";
Database::query($sql);
$sql = "DELETE FROM " . dropbox_cnf('tbl_file') . " WHERE c_id = $course_id AND id ='" . $res['id'] . "'";
$sql = "DELETE FROM " . dropbox_cnf('tbl_file') . "
WHERE c_id = $course_id AND id ='" . $res['id'] . "'";
Database::query($sql);
//delete file from server
@unlink( dropbox_cnf('sysPath') . '/' . $res['filename']);
@ -758,7 +774,8 @@ function getUserOwningThisMailing($mailingPseudoId, $owner = 0, $or_die = '')
$mailingPseudoId = intval($mailingPseudoId);
$sql = "SELECT f.uploader_id
FROM " . $dropbox_cnf['tbl_file'] . " f
LEFT JOIN " . $dropbox_cnf['tbl_post'] . " p ON (f.id = p.file_id AND f.c_id = $course_id AND p.c_id = $course_id)
LEFT JOIN " . $dropbox_cnf['tbl_post'] . " p
ON (f.id = p.file_id AND f.c_id = $course_id AND p.c_id = $course_id)
WHERE
p.dest_user_id = '" . $mailingPseudoId . "' AND
p.c_id = $course_id
@ -855,7 +872,8 @@ function store_add_dropbox()
}
// we are doing a just upload but an additional recipient is selected.
// note: why can't this be valid? It is like sending a document to yourself AND to a different person (I do this quite often with my e-mails)
// note: why can't this be valid? It is like sending a document to
// yourself AND to a different person (I do this quite often with my e-mails)
if ($thisIsJustUpload && (count($_POST['recipients']) != 1)) {
return get_lang('MailingJustUploadSelectNoOther');
}
@ -881,7 +899,8 @@ function store_add_dropbox()
// check if the filesize does not exceed the allowed size.
if ($dropbox_filesize <= 0 || $dropbox_filesize > $dropbox_cnf['maxFilesize']) {
return get_lang('DropboxFileTooBig'); // TODO: The "too big" message does not fit in the case of uploading zero-sized file.
return get_lang('DropboxFileTooBig');
// TODO: The "too big" message does not fit in the case of uploading zero-sized file.
}
// check if the file is actually uploaded
@ -914,7 +933,8 @@ function store_add_dropbox()
$_POST['authors'] = getUserNameFromId($_user['user_id']);
}
// note: I think we could better migrate everything from here on to separate functions: store_new_dropbox, store_new_mailing, store_just_upload
// note: I think we could better migrate everything from here on to
// separate functions: store_new_dropbox, store_new_mailing, store_just_upload
if ($dropbox_overwrite) {
$dropbox_person = new Dropbox_Person($_user['user_id'], api_is_course_admin(), api_is_course_tutor());
@ -995,7 +1015,15 @@ function store_add_dropbox()
}
}
new Dropbox_SentWork($_user['user_id'], $dropbox_title, $_POST['description'], strip_tags($_POST['authors']), $dropbox_filename, $dropbox_filesize, $new_work_recipients);
new Dropbox_SentWork(
$_user['user_id'],
$dropbox_title,
$_POST['description'],
strip_tags($_POST['authors']),
$dropbox_filename,
$dropbox_filesize,
$new_work_recipients
);
Security::clear_token();
return get_lang('FileUploadSucces');
@ -1059,7 +1087,8 @@ function feedback_form()
return $return;
}
function user_can_download_file($id, $user_id) {
function user_can_download_file($id, $user_id)
{
$dropbox_cnf = getDropboxConf();
$course_id = api_get_course_int_id();
$id = intval($id);
@ -1080,7 +1109,8 @@ function user_can_download_file($id, $user_id) {
// we now check if the other users have not delete this document yet.
// If this is the case then it is useless to see the
// add feedback since the other users will never get to see the feedback.
function check_if_file_exist($id) {
function check_if_file_exist($id)
{
$dropbox_cnf = getDropboxConf();
$id = intval($id);
$course_id = api_get_course_int_id();
@ -1096,8 +1126,6 @@ function check_if_file_exist($id) {
return $number_users_who_see_file > 0 || $count > 0;
}
/**
* @return a language string (depending on the success or failure.
*
@ -1276,7 +1304,8 @@ function generate_html_overview($files, $dont_show_columns = array(), $make_link
function get_total_number_feedback($file_id = '') {
$dropbox_cnf = getDropboxConf();
$course_id = api_get_course_int_id();
$sql = "SELECT COUNT(feedback_id) AS total, file_id FROM ".$dropbox_cnf['tbl_feedback']."
$sql = "SELECT COUNT(feedback_id) AS total, file_id
FROM ".$dropbox_cnf['tbl_feedback']."
WHERE c_id = $course_id GROUP BY file_id";
$result = Database::query($sql);
$return = array();

@ -1,7 +1,6 @@
<?php
/* For licensing terms, see /license.txt */
/**
* @desc The dropbox is a personal (peer to peer) file exchange module that allows
* you to send documents to a certain (group of) users.
@ -154,9 +153,18 @@ if (api_is_excluded_user_type()) {
}
if (empty($session_id)) {
$is_course_member = CourseManager::is_user_subscribed_in_course($user_id, $course_code, false);
$is_course_member = CourseManager::is_user_subscribed_in_course(
$user_id,
$course_code,
false
);
} else {
$is_course_member = CourseManager::is_user_subscribed_in_course($user_id, $course_code, true, $session_id);
$is_course_member = CourseManager::is_user_subscribed_in_course(
$user_id,
$course_code,
true,
$session_id
);
}
/* Object Initialisation */
@ -166,11 +174,14 @@ if (empty($session_id)) {
// @todo consider moving the javascripts in a function that displays the javascripts
// only when it is needed.
if ($action == 'add') {
$dropbox_person = new Dropbox_Person($_user['user_id'], $is_courseAdmin, $is_courseTutor);
$dropbox_person = new Dropbox_Person(
$_user['user_id'],
$is_courseAdmin,
$is_courseTutor
);
}
/* Create javascript and htmlHeaders */
$javascript = "<script type=\"text/javascript\">
function confirmsend ()
{
@ -210,7 +221,6 @@ if (dropbox_cnf('allowOverwrite')) {
//sentArray keeps list of all files still available in the sent files list
//of the user.
//This is used to show or hide the overwrite file-radio button of the upload form
$javascript .= "
var sentArray = new Array(";
if (isset($dropbox_person)) {
@ -287,7 +297,7 @@ $htmlHeadXtra[] = '<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="-1">';
$checked_files = false;
if (!$view OR $view == 'received') {
if (!$view || $view == 'received') {
$part = 'received';
} elseif ($view = 'sent') {
$part = 'sent';

@ -285,15 +285,15 @@ if ($action != 'add') {
?>
<ul class="nav nav-tabs">
<li <?php if (!$view || $view == 'sent') { echo 'class="active"'; } ?> >
<a href="index.php?<?php echo api_get_cidreq(); ?>&view=sent" ><?php echo get_lang('SentFiles'); ?></a></li>
<a href="index.php?<?php echo api_get_cidreq(); ?>&view=sent" ><?php echo get_lang('SentFiles'); ?></a>
</li>
<li <?php if ($view == 'received') { echo 'class="active"'; } ?> >
<a href="index.php?<?php echo api_get_cidreq(); ?>&view=received" ><?php echo get_lang('ReceivedFiles'); ?></a></li>
<a href="index.php?<?php echo api_get_cidreq(); ?>&view=received" ><?php echo get_lang('ReceivedFiles'); ?></a>
</li>
</ul>
<?php
}
/* RECEIVED FILES */
if ($view == 'received' || !$dropbox_cnf['sent_received_tabs']) {
// This is for the categories
if (isset($viewReceivedCategory) AND $viewReceivedCategory != '') {

@ -28,7 +28,8 @@ if (isset($_GET['recover_id']) && !empty($_GET['recover_id'])) {
}
}
$sql = "SELECT * FROM $file_tbl WHERE c_id = $course_id AND session_id = $session_id";
$sql = "SELECT * FROM $file_tbl
WHERE c_id = $course_id AND session_id = $session_id";
$result = Database::query($sql);
if (Database::num_rows($result)) {
@ -36,13 +37,17 @@ if (Database::num_rows($result)) {
$rows = array();
foreach ($files as $file) {
//Check if I have this file:
$sql = "SELECT * FROM $person_tbl WHERE c_id = $course_id AND user_id = $user_id AND file_id = {$file['id']}";
$sql = "SELECT * FROM $person_tbl
WHERE c_id = $course_id AND user_id = $user_id AND file_id = {$file['id']}";
$result_person = Database::query($sql);
if (Database::num_rows($result_person) == 0 ) {
$rows[] = array(
$file['filename'],
api_convert_and_format_date($file['upload_date']),
Display::url(get_lang('Recover'), api_get_self().'?recover_id='.$file['id'], array('class' => 'btn btn-default'))
Display::url(
get_lang('Recover'), api_get_self().'?recover_id='.$file['id'],
array('class' => 'btn btn-default')
)
);
}
}

@ -48,6 +48,7 @@ if (is_dir($full_file_name)) {
$document_explorer = api_get_path(WEB_COURSE_PATH).api_get_course_path();
//redirect
header('Location: '.$document_explorer);
exit;
}
$tbl_forum_attachment = Database::get_course_table(TABLE_FORUM_ATTACHMENT);

@ -71,7 +71,7 @@ if (!empty($gradebook) && $gradebook == 'view') {
if ($origin == 'group') {
$_clean['toolgroup'] = (int) $_SESSION['toolgroup'];
$group_properties = GroupManager::get_group_properties($_clean['toolgroup']);
$interbreadcrumb[] = array('url' => '../group/group.php', 'name' => get_lang('Groups'));
$interbreadcrumb[] = array('url' => '../group/group.php?'.api_get_cidreq(), 'name' => get_lang('Groups'));
$interbreadcrumb[] = array('url' => '../group/group_space.php?gidReq='.$_SESSION['toolgroup'], 'name' => get_lang('GroupSpace').' '.$group_properties['name']);
$interbreadcrumb[] = array('url' => 'viewforum.php?origin='.$origin.'&gidReq='.$_SESSION['toolgroup'].'&forum='.Security::remove_XSS($_GET['forum']), 'name' => prepare4display($current_forum['forum_title']));
$interbreadcrumb[] = array('url' => 'javascript: void (0);', 'name' => get_lang('EditPost'));
@ -178,11 +178,14 @@ if ($origin != 'learnpath') {
echo '<div class="actions">';
echo '<span style="float:right;">'.search_link().'</span>';
if ($origin == 'group') {
echo '<a href="../group/group_space.php?'.api_get_cidreq().'">'.Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('Groups'), '', ICON_SIZE_MEDIUM).'</a>';
echo '<a href="../group/group_space.php?'.api_get_cidreq().'">'.
Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('Groups'), '', ICON_SIZE_MEDIUM).'</a>';
} else {
echo '<a href="index.php?'.api_get_cidreq().'">'.Display::return_icon('back.png', get_lang('BackToForumOverview'), '', ICON_SIZE_MEDIUM).'</a>';
echo '<a href="index.php?'.api_get_cidreq().'">'.
Display::return_icon('back.png', get_lang('BackToForumOverview'), '', ICON_SIZE_MEDIUM).'</a>';
}
echo '<a href="viewforum.php?forum='.Security::remove_XSS($_GET['forum']).'&gidReq='.Security::remove_XSS($_GET['gidReq']).'&origin='.$origin.'">'.Display::return_icon('forum.png', get_lang('BackToForum'), '', ICON_SIZE_MEDIUM).'</a>';
echo '<a href="viewforum.php?forum='.Security::remove_XSS($_GET['forum']).'&gidReq='.Security::remove_XSS($_GET['gidReq']).'&origin='.$origin.'">'.
Display::return_icon('forum.png', get_lang('BackToForum'), '', ICON_SIZE_MEDIUM).'</a>';
echo '</div>';
}

@ -208,7 +208,7 @@ function show_add_forumcategory_form($inputvalues = array(), $lp_id)
$form->addElement('hidden', 'lp_id', $lp_id);
// Setting the form elements.
$form->addElement('header', '', get_lang('AddForumCategory'));
$form->addElement('header', get_lang('AddForumCategory'));
$form->addElement('text', 'forum_category_title', get_lang('Title'), array('autofocus'));
$form->addElement(
'html_editor',

@ -100,5 +100,4 @@ class TeacherTimeReport
return $dataToExport;
}
}

@ -107,7 +107,8 @@ class DashboardManager
/**
* display checkboxes for dashboard plugin list
* @param string plugin path
* @param string $plugin_path
*
* @return void
*/
public static function display_dashboard_plugin_checkboxes($plugin_path) {
@ -182,7 +183,7 @@ class DashboardManager
}
// update extra user blocks data
$upd_extra_field = self::store_user_blocks($user_id, $user_blocks_id, $columns);
self::store_user_blocks($user_id, $user_blocks_id, $columns);
}
// clean from block data
@ -239,9 +240,7 @@ class DashboardManager
$result = Database::query($ins);
$affected_rows = Database::affected_rows($result);
}
}
}
return $affected_rows;
@ -251,8 +250,8 @@ class DashboardManager
* Get all plugins path inside dashboard directory
* @return array name plugins directories
*/
public static function getPossibleDashboardPluginsPath() {
public static function getPossibleDashboardPluginsPath()
{
// get all plugins path inside plugin directory
/* We scan the plugin directory. Each folder is a potential plugin. */
$possiblePlugins = array();
@ -264,6 +263,7 @@ class DashboardManager
}
}
@closedir($handle);
return $possiblePlugins;
}
@ -271,8 +271,8 @@ class DashboardManager
* Get all blocks data without plugin directory
* @return array Block data
*/
public static function get_block_data_without_plugin() {
public static function get_block_data_without_plugin()
{
$tbl_block = Database :: get_main_table(TABLE_MAIN_BLOCK);
$possibleplugins = self::getPossibleDashboardPluginsPath();
@ -288,7 +288,8 @@ class DashboardManager
$active = 1;
}
// update active
$upd = "UPDATE $tbl_block SET active = '$active' WHERE path = '".$row['path']."'";
$upd = "UPDATE $tbl_block SET active = '$active'
WHERE path = '".$row['path']."'";
Database::query($upd);
}
}
@ -302,6 +303,7 @@ class DashboardManager
$block_data[] = $row_block;
}
}
return $block_data;
}
@ -409,7 +411,6 @@ class DashboardManager
}
}
/**
* display checkboxes for user dashboard list
* @param int User id
@ -451,7 +452,12 @@ class DashboardManager
foreach ($selected_blocks_id as $block_id) {
$fvalue[] = $block_id.':'.$columns[$block_id];
}
$upd_extra_field = UserManager::update_extra_field_value($user_id, $fname, $fvalue);
$upd_extra_field = UserManager::update_extra_field_value(
$user_id,
$fname,
$fvalue
);
return $upd_extra_field;
}
@ -461,8 +467,8 @@ class DashboardManager
* @param int User id
* @return array data (block_id,column)
*/
public static function get_user_block_data($user_id) {
public static function get_user_block_data($user_id)
{
$user_id = intval($user_id);
$field_variable = 'dashboard';
$extra_user_data = UserManager::get_extra_user_data_by_field($user_id, $field_variable);
@ -476,6 +482,7 @@ class DashboardManager
$data[$block_id] = array('block_id' => $block_id, 'column' => $column);
}
}
return $data;
}
@ -485,8 +492,8 @@ class DashboardManager
* @param string plugin path
* @return bool
*/
public static function close_user_block($user_id, $path) {
public static function close_user_block($user_id, $path)
{
$enabled_dashboard_blocks = self::get_enabled_dashboard_blocks($path);
$user_block_data = self::get_user_block_data($user_id);

@ -72,6 +72,7 @@ define('LANGUAGE_DETECT_MAX_DELTA', 140000);
* @param string $variable This is the identificator (name) of the translated string to be retrieved.
* @param string $reserved This parameter has been reserved for future use.
* @param string $language (optional) Language indentificator. If it is omited, the current interface language is assumed.
*
* @return string Returns the requested string in the correspondent language.
*
* @author Roan Embrechts

@ -13,7 +13,6 @@ class LegalManager
*/
public function __construct()
{
}
/**

@ -161,8 +161,6 @@ class Link extends Model
$session_id = api_get_session_id();
if ($type == 'link') {
$tbl_link = Database:: get_course_table(TABLE_LINK);
$title = Security:: remove_XSS(stripslashes($_POST['title']));
$urllink = Security:: remove_XSS($_POST['url']);
$description = Security:: remove_XSS($_POST['description']);

@ -103,7 +103,8 @@ class MessageManager
$condition_msg_status = ' msg_status IN('.MESSAGE_STATUS_NEW.','.MESSAGE_STATUS_UNREAD.') ';
}
$sql = "SELECT COUNT(*) as number_messages FROM $table_message
$sql = "SELECT COUNT(*) as number_messages
FROM $table_message
WHERE $condition_msg_status AND user_receiver_id=".api_get_user_id();
$sql_result = Database::query($sql);
$result = Database::fetch_array($sql_result);
@ -682,8 +683,11 @@ class MessageManager
return false;
}
$table_message = Database::get_main_table(TABLE_MESSAGE);
$sql = "UPDATE $table_message SET msg_status = '$type'
WHERE user_receiver_id=".intval($user_id)." AND id='".intval($message_id)."'";
$sql = "UPDATE $table_message SET
msg_status = '$type'
WHERE
user_receiver_id=".intval($user_id)." AND
id='".intval($message_id)."'";
Database::query($sql);
}
@ -716,12 +720,12 @@ class MessageManager
$table_message = Database::get_main_table(TABLE_MESSAGE);
$group_id = intval($group_id);
$query = "SELECT * FROM $table_message
$sql = "SELECT * FROM $table_message
WHERE
group_id= $group_id AND
msg_status NOT IN ('".MESSAGE_STATUS_OUTBOX."', '".MESSAGE_STATUS_DELETED."')
ORDER BY id";
$rs = Database::query($query);
$rs = Database::query($sql);
$data = array();
if (Database::num_rows($rs) > 0) {
while ($row = Database::fetch_array($rs, 'ASSOC')) {
@ -743,13 +747,13 @@ class MessageManager
return false;
$table_message = Database::get_main_table(TABLE_MESSAGE);
$group_id = intval($group_id);
$query = "SELECT * FROM $table_message
$sql = "SELECT * FROM $table_message
WHERE
group_id = $group_id AND
msg_status NOT IN ('".MESSAGE_STATUS_OUTBOX."', '".MESSAGE_STATUS_DELETED."')
ORDER BY id ";
$rs = Database::query($query);
$rs = Database::query($sql);
$data = array();
$parents = array();
if (Database::num_rows($rs) > 0) {
@ -792,16 +796,17 @@ class MessageManager
$condition_limit = " LIMIT $offset,$limit ";
}
$query = "SELECT * FROM $table_message
$sql = "SELECT * FROM $table_message
WHERE parent_id='$parent_id' AND msg_status <> ".MESSAGE_STATUS_OUTBOX." $condition_group_id
ORDER BY send_date DESC $condition_limit ";
$rs = Database::query($query);
$rs = Database::query($sql);
$data = array();
if (Database::num_rows($rs) > 0) {
while ($row = Database::fetch_array($rs)) {
$data[$row['id']] = $row;
}
}
return $data;
}
@ -1031,72 +1036,6 @@ class MessageManager
return $message_content;
}
/**
* display message box sent showing it into outbox
* @return void
*/
public static function show_message_box_sent()
{
$table_message = Database::get_main_table(TABLE_MESSAGE);
$message_id = '';
if (is_numeric($_GET['id_send'])) {
$query = "SELECT * FROM $table_message
WHERE
user_sender_id=".api_get_user_id()." AND
id=".intval($_GET['id_send'])." AND
msg_status = 4;";
$result = Database::query($query);
$message_id = intval($_GET['id_send']);
}
$path = 'outbox.php';
// get file attachments by message id
$files_attachments = self::get_links_message_attachment_files($message_id, 'outbox');
$row = Database::fetch_array($result);
$user_con = self::users_connected_by_id();
$band = 0;
$reply = '';
for ($i = 0; $i < count($user_con); $i++)
if ($row[1] == $user_con[$i])
$band = 1;
echo '<div class=actions>';
echo '<a onclick="close_and_open_outbox()" href="javascript:void(0)">'.Display::return_icon('folder_up.gif', api_xml_http_response_encode(get_lang('BackToOutbox'))).api_xml_http_response_encode(get_lang('BackToOutbox')).'</a>';
echo '<a onclick="delete_one_message_outbox('.$row[0].')" href="javascript:void(0)" >'.Display::return_icon('delete.png', api_xml_http_response_encode(get_lang('DeleteMessage'))).api_xml_http_response_encode(get_lang('DeleteMessage')).'</a>';
echo '</div><br />';
echo '
<table class="message_view_table" >
<TR>
<TD width=10>&nbsp; </TD>
<TD vAlign=top width="100%">
<TABLE>
<TR>
<TD width="100%">
<TR> <h1>'.str_replace("\\", "", api_xml_http_response_encode($row[5])).'</h1></TR>
</TD>
<TR>
<TD>'.api_xml_http_response_encode(get_lang('From').'&nbsp;<b>'.GetFullUserName($row[1]).'</b> '.api_strtolower(get_lang('To')).'&nbsp; <b>'.GetFullUserName($row[2])).'</b> </TD>
</TR>
<TR>
<TD >'.api_xml_http_response_encode(get_lang('Date').'&nbsp; '.$row[4]).'</TD>
</TR>
</TR>
</TABLE>
<br />
<TABLE height="209px" width="100%" bgColor=#ffffff>
<TBODY>
<TR>
<TD vAlign=top>'.str_replace("\\", "", api_xml_http_response_encode($row[6])).'</TD>
</TR>
</TBODY>
</TABLE>
<div id="message-attach">'.(!empty($files_attachments) ? implode('<br />', $files_attachments) : '').'</div>
<DIV class=HT style="PADDING-BOTTOM: 5px"> </DIV></TD>
<TD width=10>&nbsp;</TD>
</TR>
</TABLE>';
}
/**
* get user id by user email
* @param string $user_email
@ -1754,14 +1693,15 @@ class MessageManager
$messages = array();
$sql = "SELECT m.*, u.user_id, u.lastname, u.firstname "
. "FROM $messagesTable as m "
. "INNER JOIN $userTable as u "
. "ON m.user_sender_id = u.user_id "
. "WHERE m.user_receiver_id = $userId "
. "AND m.msg_status = " . MESSAGE_STATUS_UNREAD . " "
. "AND m.id > $lastId "
. "ORDER BY m.send_date DESC";
$sql = "SELECT m.*, u.user_id, u.lastname, u.firstname
FROM $messagesTable as m
INNER JOIN $userTable as u
ON m.user_sender_id = u.user_id
WHERE
m.user_receiver_id = $userId AND
m.msg_status = " . MESSAGE_STATUS_UNREAD . "
AND m.id > $lastId
ORDER BY m.send_date DESC";
$result = Database::query($sql);
@ -1805,5 +1745,4 @@ class MessageManager
return false;
}
}

@ -102,8 +102,10 @@ class MySpace
$courseId = intval($courseId);
$session_id = intval($session_id);
$sql = 'SELECT login_course_date, logout_course_date FROM ' . $tbl_track_course . '
WHERE user_id = '.$user_id.' AND
$sql = 'SELECT login_course_date, logout_course_date
FROM ' . $tbl_track_course . '
WHERE
user_id = '.$user_id.' AND
c_id = '.$courseId.' AND
session_id = '.$session_id.'
ORDER BY login_course_date ASC';
@ -115,6 +117,7 @@ class MySpace
$timestamp_logout_date = api_strtotime($row['logout_course_date'], 'UTC');
$connections[] = array('login' => $timestamp_login_date, 'logout' => $timestamp_logout_date);
}
return $connections;
}
@ -312,7 +315,12 @@ class MySpace
} else {
$order = array(0 => 'lastname', 1 => 'firstname', 2 => ($sort_by_first_name ? 'firstname' : 'lastname'), 3 => 'login_date', 4 => ($sort_by_first_name ? 'firstname' : 'lastname'), 5 => ($sort_by_first_name ? 'firstname' : 'lastname'));
}
$table = new SortableTable('tracking_list_coaches_myspace', array('MySpace', 'count_coaches'), null, ($is_western_name_order xor $sort_by_first_name) ? 1 : 0);
$table = new SortableTable(
'tracking_list_coaches_myspace',
array('MySpace', 'count_coaches'),
null,
($is_western_name_order xor $sort_by_first_name) ? 1 : 0
);
$parameters['view'] = 'admin';
$table->set_additional_parameters($parameters);
if ($is_western_name_order) {
@ -532,8 +540,7 @@ class MySpace
$lessons = LearnpathList::get_course_lessons($course['code'], $sessionId);
//create columns array
foreach ($lessons as $lesson_id => $lesson)
{
foreach ($lessons as $lesson_id => $lesson) {
$columns[] = $lesson['name'];
}
@ -543,17 +550,43 @@ class MySpace
* Column config
*/
$column_model = array(
array('name'=>'username', 'index'=>'username', 'align'=>'left', 'search' => 'true', 'wrap_cell' => "true"),
array('name'=>'firstname', 'index'=>'firstname', 'align'=>'left', 'search' => 'true'),
array('name'=>'lastname', 'index'=>'lastname', 'align'=>'left', 'search' => 'true'),
array(
'name' => 'username',
'index' => 'username',
'align' => 'left',
'search' => 'true',
'wrap_cell' => "true",
),
array(
'name' => 'firstname',
'index' => 'firstname',
'align' => 'left',
'search' => 'true',
),
array(
'name' => 'lastname',
'index' => 'lastname',
'align' => 'left',
'search' => 'true',
),
);
// Get dinamic column names
foreach ($lessons as $lesson_id => $lesson) {
$column_model[] = array(
'name' => $lesson['id'],
'index' => $lesson['id'],
'align' => 'left',
'search' => 'true',
);
//get dinamic column names
foreach ($lessons as $lesson_id => $lesson)
{
$column_model[] = array('name'=> $lesson['id'], 'index'=>$lesson['id'], 'align'=>'left', 'search' => 'true');
}
$column_model[] = array('name'=>'total', 'index'=>'total', 'align'=>'left', 'search' => 'true');
$column_model[] = array(
'name' => 'total',
'index' => 'total',
'align' => 'left',
'search' => 'true',
);
$action_links = '';
// jqgrid will use this URL to do the selects
@ -568,7 +601,16 @@ class MySpace
//height auto
$extra_params['height'] = 'auto';
$table = Display::grid_js($tableId, $url, $columns, $column_model, $extra_params, array(), $action_links, true);
$table = Display::grid_js(
$tableId,
$url,
$columns,
$column_model,
$extra_params,
array(),
$action_links,
true
);
$return = '<script>$(function() {'. $table .
'jQuery("#'.$tableId.'").jqGrid("navGrid","#'.$tableId.'_pager",{view:false, edit:false, add:false, del:false, search:false, excel:true});
@ -835,7 +877,16 @@ class MySpace
// height auto
$extra_params['height'] = 'auto';
$table = Display::grid_js($tableId, $url, $columns, $column_model, $extra_params, array(), $action_links, true);
$table = Display::grid_js(
$tableId,
$url,
$columns,
$column_model,
$extra_params,
array(),
$action_links,
true
);
$return = '<script>$(function() {'. $table .
'jQuery("#'.$tableId.'").jqGrid("navGrid","#'.$tableId.'_pager",{view:false, edit:false, add:false, del:false, search:false, excel:true});
@ -961,11 +1012,8 @@ class MySpace
//Autowidth
$extra_params['autowidth'] = 'true';
$extra_params['shrinkToFit'] = 'true';
$extra_params['headertitles'] = 'true';
$extra_params['groupHeaders'] = array(
'courses_detail' => array(
"startColumnName" => 'courses',
@ -1006,7 +1054,16 @@ class MySpace
//height auto
$extra_params['height'] = 'auto';
$table = Display::grid_js($tableId, $url, $columns, $column_model, $extra_params, array(), $action_links, true);
$table = Display::grid_js(
$tableId,
$url,
$columns,
$column_model,
$extra_params,
array(),
$action_links,
true
);
$return = '<script>$(function() {'. $table .
'jQuery("#'.$tableId.'").jqGrid("navGrid","#'.$tableId.'_pager",{view:false, edit:false, add:false, del:false, search:false, excel:true});
@ -1091,13 +1148,18 @@ class MySpace
*/
public static function display_user_overview_export_options()
{
$message = '';
// include the user manager and formvalidator library
if (isset($_GET['export']) && $_GET['export'] == 'options') {
// get all the defined extra fields
$extrafields = UserManager::get_extra_fields(0, 50, 5, 'ASC', false, 1);
// creating the form with all the defined extra fields
$form = new FormValidator('exportextrafields', 'post', api_get_self()."?view=".Security::remove_XSS($_GET['view']).'&display='.Security::remove_XSS($_GET['display']).'&export='.Security::remove_XSS($_GET['export']));
$form = new FormValidator(
'exportextrafields',
'post',
api_get_self()."?view=".Security::remove_XSS($_GET['view']).'&display='.Security::remove_XSS($_GET['display']).'&export='.Security::remove_XSS($_GET['export'])
);
if (is_array($extrafields) && count($extrafields) > 0) {
foreach ($extrafields as $key => $extra) {
@ -1144,7 +1206,6 @@ class MySpace
} else {
Display::display_confirmation_message(get_lang('NoAdditionalFieldsWillBeExported'), false);
}
$message = '';
} else {
$form->display();
}
@ -1159,7 +1220,6 @@ class MySpace
}
Display::display_normal_message(get_lang('FollowingFieldsWillAlsoBeExported').': <br /><ul>'.$message.'</ul>', false);
$message = '';
}
}
}
@ -1167,9 +1227,8 @@ class MySpace
/**
* Display a sortable table that contains an overview of all the reporting progress of all courses
*/
public static function display_tracking_course_overview() {
//MySpace::display_user_overview_export_options();
public static function display_tracking_course_overview()
{
$t_head = ' <table style="width: 100%;border:0;padding:0;border-collapse:collapse;table-layout: fixed">';
//$t_head .= ' <caption>'.get_lang('CourseInformation').'</caption>';
$t_head .= '<tr>';
@ -1208,6 +1267,7 @@ class MySpace
{
// database table definition
$main_course_table = Database :: get_main_table(TABLE_MAIN_COURSE);
return Database::count_rows($main_course_table);
}
@ -1503,8 +1563,6 @@ class MySpace
*/
public static function display_tracking_session_overview()
{
//MySpace::display_user_overview_export_options();
$t_head = ' <table style="width: 100%;border:0;padding:0;border-collapse:collapse;table-layout: fixed">';
//$t_head .= ' <caption>'.get_lang('CourseInformation').'</caption>';
$t_head .= '<tr>';
@ -1558,22 +1616,8 @@ class MySpace
*/
public static function get_session_data_tracking_overview($from, $number_of_items, $column, $direction)
{
//global $_configuration;
// database table definition
//$access_url_id = api_get_current_access_url_id();
//$tbl_url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$main_session_table = Database :: get_main_table(TABLE_MAIN_SESSION);
/*if ($_configuration['multiple_access_urls']) {
$condition_multi_url = ", $tbl_url_rel_user as url_user WHERE user.user_id=url_user.user_id AND access_url_id='$access_url_id'";
}
global $export_csv;
if ($export_csv) {
$is_western_name_order = api_is_western_name_order(PERSON_NAME_DATA_EXPORT);
} else {
$is_western_name_order = api_is_western_name_order();
}*/
$sql = "SELECT id AS col0, name AS col1 FROM $main_session_table";
$sql .= " ORDER BY col$column $direction ";
$sql .= " LIMIT $from,$number_of_items";
@ -2288,8 +2332,6 @@ class MySpace
*/
public static function make_username($firstname, $lastname, $username, $language = null, $encoding = null)
{
$table_user = Database::get_main_table(TABLE_MAIN_USER);
$tbl_session_rel_course_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
// if username exist
if (!UserManager::is_username_available($username) || empty($username)) {
$i = 0;
@ -2299,7 +2341,12 @@ class MySpace
} else {
$sufix = $i;
}
$desired_username = UserManager::create_username($firstname, $lastname, $language, $encoding);
$desired_username = UserManager::create_username(
$firstname,
$lastname,
$language,
$encoding
);
if (UserManager::is_username_available($desired_username.$sufix)) {
break;
} else {
@ -2434,7 +2481,6 @@ class MySpace
foreach ($users as $index => $user) {
// database table definition
$table_user = Database::get_main_table(TABLE_MAIN_USER);
$tbl_session_rel_course_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
$username = Database::escape_string($user['UserName']);
$sql = "SELECT creator_id FROM $table_user WHERE username='$username' ";
@ -2456,9 +2502,9 @@ class MySpace
* Validates imported data.
* @param list of users
*/
function validate_data($users, $id_session = null) {
function validate_data($users, $id_session = null)
{
$errors = array();
$usernames = array();
$new_users = array();
foreach ($users as $index => $user) {
// 1. Check whether mandatory fields are set.
@ -2634,9 +2680,7 @@ class MySpace
} else {
$i = 0;
foreach ($users as $index => $user) {
$userInfo = api_get_user_info($user['id']);
if (($user['added_at_platform'] == 1 && $user['added_at_session'] == 1) || $user['added_at_session'] == 1) {
if ($user['added_at_platform'] == 1) {
$addedto = get_lang('UserCreatedPlatform');
@ -2782,6 +2826,7 @@ function get_stats($user_id, $courseId, $start_date = null, $end_date = null)
$result = array('avg' => $foo_avg, 'total' => $foo_total, 'times' => $foo_times);
}
}
return $result;
}
@ -2947,7 +2992,6 @@ function grapher($sql_result, $start_date, $end_date, $type = "")
$myData->setAxisName(0, get_lang('Minutes'));
$myData->loadPalette(api_get_path(SYS_CODE_PATH) . 'palettes/pchart/default.color', true);
// Cache definition
$cachePath = api_get_path(SYS_ARCHIVE_PATH);
$myCache = new pCache(array('CacheFolder' => substr($cachePath, 0, strlen($cachePath) - 1)));

@ -2,13 +2,12 @@
/* For licensing terms, see /license.txt */
/**
* Class Nanogong
*
* Files are saved in the path:
*
* courses/XXX/exercises/(session_id)/(exercise_id)/(question_id)/(user_id)/
*
* The file name is composed with
*
* The file name is composed with:
* (course_id)/(session_id)/(user_id)/(exercise_id)/(question_id)/(exe_id).wav|mp3|ogg
*
*
@ -42,9 +41,6 @@ class Nanogong
return false;
}
//@todo use an array to create folders
$folders_to_create = array();
// Trying to create the courses/COURSE123/exercises/ dir just in case.
$directoryPermissions = api_get_permissions_for_new_directories();

@ -199,8 +199,10 @@ function user_is_online($user_id)
$result = Database::query($query);
if (Database::num_rows($result)) {
return true;
}
return false;
}
@ -464,7 +466,6 @@ function GetFullUserName($uid) {
$query = "SELECT firstname, lastname FROM ".$user_table." WHERE id=$uid";
$result = @Database::query($query);
if (count($result)>0) {
$str = '';
while(list($firstname,$lastname)= Database::fetch_array($result)) {
$str = str_replace(' ', '&nbsp;', api_get_person_name($firstname, $lastname));
return $str;

@ -123,21 +123,25 @@ class Security
if (isset($_SESSION['sec_token']) && isset($_REQUEST['sec_token']) && $_SESSION['sec_token'] === $_REQUEST['sec_token']) {
return true;
}
return false;
case 'get':
if (isset($_SESSION['sec_token']) && isset($_GET['sec_token']) && $_SESSION['sec_token'] === $_GET['sec_token']) {
return true;
}
return false;
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($request_type) && $_SESSION['sec_token'] === $request_type) {
return true;
}
return false;
}
return false; // Just in case, don't let anything slip.
@ -153,6 +157,7 @@ class Security
if (isset($_SESSION['sec_ua']) and $_SESSION['sec_ua'] === $_SERVER['HTTP_USER_AGENT'].$_SESSION['sec_ua_seed']) {
return true;
}
return false;
}
@ -180,6 +185,7 @@ class Security
$token = md5(uniqid(rand(), TRUE));
$string = '<input type="hidden" name="sec_token" value="'.$token.'" />';
$_SESSION['sec_token'] = $token;
return $string;
}
@ -194,8 +200,9 @@ class Security
*/
public static function get_token()
{
$token = md5(uniqid(rand(), TRUE));
$token = md5(uniqid(rand(), true));
$_SESSION['sec_token'] = $token;
return $token;
}
@ -205,8 +212,10 @@ class Security
public static function get_existing_token()
{
if (isset($_SESSION['sec_token']) && !empty($_SESSION['sec_token'])) {
return $_SESSION['sec_token'];
} else {
return self::get_token();
}
}
@ -218,7 +227,7 @@ class Security
*/
public static function get_ua()
{
$_SESSION['sec_ua_seed'] = uniqid(rand(), TRUE);
$_SESSION['sec_ua_seed'] = uniqid(rand(), true);
$_SESSION['sec_ua'] = $_SERVER['HTTP_USER_AGENT'].$_SESSION['sec_ua_seed'];
}
@ -263,6 +272,7 @@ class Security
if (!empty($option['save'])) {
self::$clean[$name] = $result;
}
return $result;
}
@ -277,7 +287,8 @@ class Security
if (isset(self::$clean[$varname])) {
return self::$clean[$varname];
}
return NULL;
return null;
}
/**

@ -39,13 +39,15 @@ class Statistics
$access_url_rel_course_table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
$current_url_id = api_get_current_access_url_id();
if (api_is_multiple_url_enabled()) {
$sql = "SELECT COUNT(*) AS number FROM ".$course_table." as c, ".$access_url_rel_course_table." as u
$sql = "SELECT COUNT(*) AS number
FROM ".$course_table." as c, ".$access_url_rel_course_table." as u
WHERE u.c_id = c.id AND access_url_id='".$current_url_id."'";
if (isset ($categoryCode)) {
$sql .= " AND category_code = '".Database::escape_string($categoryCode)."'";
}
} else {
$sql = "SELECT COUNT(*) AS number FROM ".$course_table." ";
$sql = "SELECT COUNT(*) AS number
FROM ".$course_table." ";
if (isset ($categoryCode)) {
$sql .= " WHERE category_code = '".Database::escape_string($categoryCode)."'";
}
@ -125,7 +127,8 @@ class Statistics
}
} else {
$sql = "SELECT COUNT(DISTINCT(user_id)) AS number
FROM $user_table WHERE 1=1 $status_filter $active_filter";
FROM $user_table
WHERE 1=1 $status_filter $active_filter";
if (isset ($categoryCode)) {
$status_filter = isset($status)?' AND status = '.intval($status):'';
$sql = "SELECT COUNT(DISTINCT(cu.user_id)) AS number
@ -155,13 +158,16 @@ class Statistics
$access_url_rel_session_table= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
if (api_is_multiple_url_enabled()) {
$current_url_id = api_get_current_access_url_id();
$sql = "SELECT COUNT(id) AS number FROM ".$session_table." as s, ".$access_url_rel_session_table." as u
$sql = "SELECT COUNT(id) AS number
FROM ".$session_table." as s, ".$access_url_rel_session_table." as u
WHERE u.session_id=s.id AND access_url_id='".$current_url_id."'";
} else {
$sql = "SELECT COUNT(id) AS number FROM ".$session_table." ";
$sql = "SELECT COUNT(id) AS number
FROM ".$session_table." ";
}
$res = Database::query($sql);
$obj = Database::fetch_object($res);
return $obj->number;
}
@ -179,7 +185,10 @@ class Statistics
if (api_is_multiple_url_enabled()) {
$sql = "SELECT count(default_id) AS total_number_of_items
FROM $track_e_default, $table_user user, $access_url_rel_user_table url
WHERE default_user_id = user.user_id AND user.user_id=url.user_id AND access_url_id='".$current_url_id."'";
WHERE
default_user_id = user.user_id AND
user.user_id=url.user_id AND
access_url_id='".$current_url_id."'";
} else {
$sql = "SELECT count(default_id) AS total_number_of_items
FROM $track_e_default, $table_user user
@ -306,8 +315,9 @@ class Statistics
*/
public static function getCourseCategories()
{
$category_table = Database :: get_main_table(TABLE_MAIN_CATEGORY);
$sql = "SELECT code, name FROM $category_table ORDER BY tree_pos";
$categoryTable = Database :: get_main_table(TABLE_MAIN_CATEGORY);
$sql = "SELECT code, name FROM $categoryTable
ORDER BY tree_pos";
$res = Database::query($sql);
$categories = array ();
while ($category = Database::fetch_object($res)) {
@ -709,10 +719,10 @@ class Statistics
HAVING c_id <> ''
AND DATEDIFF( '".date('Y-m-d h:i:s')."' , access_date ) <= ". $date_diff;
}
$res = Database::query($sql);
$sql .= ' ORDER BY '.$columns[$column].' '.$sql_order[$direction];
$from = ($page_nr -1) * $per_page;
$sql .= ' LIMIT '.$from.','.$per_page;
echo '<p>'.get_lang('LastAccess').' &gt;= '.$date_diff.' '.get_lang('Days').'</p>';
$res = Database::query($sql);
if (Database::num_rows($res) > 0) {

@ -38,6 +38,7 @@ class SubLanguageManager
}
}
closedir($dh);
return $content_dir;
}
}
@ -50,14 +51,15 @@ class SubLanguageManager
*/
public static function get_all_information_of_sub_language($parent_id, $sub_language_id)
{
$tbl_admin_languages = Database :: get_main_table(TABLE_MAIN_LANGUAGE);
$sql = 'SELECT * FROM ' . $tbl_admin_languages . '
$table = Database :: get_main_table(TABLE_MAIN_LANGUAGE);
$sql = 'SELECT * FROM ' . $table . '
WHERE parent_id= ' . intval($parent_id) . ' AND id= ' . intval($sub_language_id) . '';
$rs = Database::query($sql);
$all_information = array();
while ($row = Database::fetch_array($rs, 'ASSOC')) {
$all_information = $row;
}
return $all_information;
}
@ -68,8 +70,8 @@ class SubLanguageManager
*/
public static function get_all_information_of_language($parent_id)
{
$tbl_admin_languages = Database :: get_main_table(TABLE_MAIN_LANGUAGE);
$sql = 'SELECT * FROM ' . $tbl_admin_languages . ' WHERE id = "' . intval($parent_id) . '"';
$table = Database :: get_main_table(TABLE_MAIN_LANGUAGE);
$sql = 'SELECT * FROM ' . $table . ' WHERE id = "' . intval($parent_id) . '"';
$rs = Database::query($sql);
$all_information = array();
while ($row = Database::fetch_array($rs, 'ASSOC')) {
@ -116,6 +118,7 @@ class SubLanguageManager
public static function add_file_in_language_directory($system_path_file)
{
$return_value = @file_put_contents($system_path_file, '<?php' . PHP_EOL);
return $return_value;
}
@ -158,6 +161,7 @@ class SubLanguageManager
if (is_dir($dir)) {
return true;
} //even if the dir already exists, we reach the objective of having the directory there
return @mkdir($dir, api_get_permissions_for_new_directories());
}
@ -172,8 +176,8 @@ class SubLanguageManager
if (empty($parent_id) or (intval($parent_id) != $parent_id) or empty($sub_language_id) or (intval($sub_language_id) != $sub_language_id)) {
return false;
}
$tbl_admin_languages = Database :: get_main_table(TABLE_MAIN_LANGUAGE);
$sql = 'SELECT dokeos_folder FROM ' . $tbl_admin_languages . '
$table = Database :: get_main_table(TABLE_MAIN_LANGUAGE);
$sql = 'SELECT dokeos_folder FROM ' . $table . '
WHERE parent_id = ' . $parent_id . ' and id = ' . $sub_language_id;
$res = Database::query($sql);
if ($res === false or Database::num_rows($res) < 1) {
@ -184,7 +188,7 @@ class SubLanguageManager
if ($res === false) {
return false;
} //can't delete dir, so do not delete language record
$sql = 'DELETE FROM ' . $tbl_admin_languages . '
$sql = 'DELETE FROM ' . $table . '
WHERE id= ' . intval($sub_language_id) . ' ';
$res = Database::query($sql);
@ -225,9 +229,9 @@ class SubLanguageManager
*/
public static function check_if_exist_language_by_id($language_id)
{
$tbl_admin_languages = Database :: get_main_table(TABLE_MAIN_LANGUAGE);
$table = Database :: get_main_table(TABLE_MAIN_LANGUAGE);
$sql = 'SELECT count(*) as count
FROM ' . $tbl_admin_languages . '
FROM ' . $table . '
WHERE id="' . intval($language_id) . '"';
$rs = Database::query($sql);
if (Database::num_rows($rs) > 0) {
@ -248,9 +252,9 @@ class SubLanguageManager
*/
public static function get_name_of_language_by_id($language_id)
{
$tbl_admin_languages = Database :: get_main_table(TABLE_MAIN_LANGUAGE);
$table = Database :: get_main_table(TABLE_MAIN_LANGUAGE);
$sql = 'SELECT original_name
FROM ' . $tbl_admin_languages . '
FROM ' . $table . '
WHERE id= ' . intval($language_id) . '';
$rs = Database::query($sql);
if (Database::num_rows($rs) > 0) {
@ -262,13 +266,14 @@ class SubLanguageManager
/**
* Verified if language is sub-language
* @param Integer The language id
* @return Boolean
* @param int $language_id
*
* @return bool
*/
public static function check_if_language_is_sub_language($language_id)
{
$tbl_admin_languages = Database :: get_main_table(TABLE_MAIN_LANGUAGE);
$sql = 'SELECT count(*) AS count FROM ' . $tbl_admin_languages . '
$table = Database :: get_main_table(TABLE_MAIN_LANGUAGE);
$sql = 'SELECT count(*) AS count FROM ' . $table . '
WHERE id = ' . intval($language_id) . ' AND NOT ISNULL(parent_id)';
$rs = Database::query($sql);
@ -286,8 +291,8 @@ class SubLanguageManager
public static function check_if_language_is_used($language_id)
{
$language_info = self::get_all_information_of_language($language_id);
$user_table = Database :: get_main_table(TABLE_MAIN_USER);
$sql = 'SELECT count(*) AS count FROM ' . $user_table . '
$table = Database :: get_main_table(TABLE_MAIN_USER);
$sql = 'SELECT count(*) AS count FROM ' . $table . '
WHERE language ="' . Database::escape_string($language_info['english_name']).'"';
$rs = Database::query($sql);
if (Database::num_rows($rs) > 0 && Database::result($rs, '0', 'count') >= 1) {
@ -304,8 +309,8 @@ class SubLanguageManager
*/
public static function check_if_language_is_father($language_id)
{
$tbl_admin_languages = Database :: get_main_table(TABLE_MAIN_LANGUAGE);
$sql = 'SELECT count(*) AS count FROM ' . $tbl_admin_languages . '
$table = Database :: get_main_table(TABLE_MAIN_LANGUAGE);
$sql = 'SELECT count(*) AS count FROM ' . $table . '
WHERE parent_id= ' . intval($language_id) . ' AND NOT ISNULL(parent_id);';
$rs = Database::query($sql);
@ -327,6 +332,7 @@ class SubLanguageManager
$sql = "UPDATE $tbl_admin_languages SET available='0'
WHERE id = " . intval($language_id) . "";
$result = Database::query($sql);
return $result !== false; //only return false on sql error
}
@ -341,6 +347,7 @@ class SubLanguageManager
$sql = "UPDATE $tbl_admin_languages SET available='1'
WHERE id = " . intval($language_id) . "";
$result = Database::query($sql);
return $result !== false; //only return false on sql error
}
@ -386,6 +393,7 @@ class SubLanguageManager
return false;
}
$row = Database::fetch_array($res);
return $row['id'];
}

@ -235,7 +235,8 @@ class SystemAnnouncementManager
$visibility = api_is_allowed_to_create_course() ? self::VISIBLE_TEACHER : self::VISIBLE_STUDENT;
$user_selected_language = api_get_interface_language();
$db_table = Database :: get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS);
$sql = 'SELECT id FROM '.$db_table.' WHERE (lang="'.$user_selected_language.'" OR lang IS NULL) ';
$sql = 'SELECT id FROM '.$db_table.'
WHERE (lang="'.$user_selected_language.'" OR lang IS NULL) ';
if (isset($user_id)) {
switch ($visibility) {
case self::VISIBLE_GUEST :
@ -605,6 +606,7 @@ class SystemAnnouncementManager
$id = intval($id);
$sql = "SELECT * FROM ".$db_table." WHERE id = ".$id;
$announcement = Database::fetch_object(Database::query($sql));
return $announcement;
}
@ -630,9 +632,11 @@ class SystemAnnouncementManager
$sql = "UPDATE ".$db_table." SET ".$field." = '".$visible."'
WHERE id='".$announcement_id."'";
$res = Database::query($sql);
if ($res === false) {
return false;
}
return true;
}
@ -828,5 +832,4 @@ class SystemAnnouncementManager
return $template->fetch('default/announcement/view.tpl');
}
}

@ -51,6 +51,7 @@ class Thematic
WHERE c_id = $course_id AND active = 1 $condition_session ";
$res = Database::query($sql);
$obj = Database::fetch_object($res);
return $obj->total_number_of_items;
}
@ -82,7 +83,8 @@ class Thematic
$sql = "SELECT id AS col0, title AS col1, display_order AS col2, session_id
FROM $tbl_thematic
WHERE c_id = $course_id AND active = 1 $condition_session
ORDER BY col2 LIMIT $from,$number_of_items ";
ORDER BY col2
LIMIT $from,$number_of_items ";
$res = Database::query($sql);
$thematics = array ();
@ -165,7 +167,8 @@ class Thematic
$condition_session = '';
}
$course_id = api_get_course_int_id();
$sql = "SELECT MAX(display_order) FROM $tbl_thematic
$sql = "SELECT MAX(display_order)
FROM $tbl_thematic
WHERE c_id = $course_id AND active = 1 $condition_session";
$rs = Database::query($sql);
$row = Database::fetch_array($rs);
@ -571,6 +574,7 @@ class Thematic
}
}
}
return $data;
}
@ -1100,7 +1104,6 @@ class Thematic
$last_description_type = $row['max'];
if (isset($last_description_type)) {
$row = Database::fetch_array($rs);
$next_description_type = $last_description_type + 1;
} else {
$next_description_type = ADD_THEMATIC_PLAN;

@ -773,14 +773,6 @@ class Tracking
$output .= "<tr class='$oddclass'>";
}
/*if (($is_allowed_to_edit || api_is_drh()) && isset($_GET['lp_id']) && isset($course_code)) {
$lp = new learnpath($course_code, $_GET['lp_id'], api_get_user_id());
$lp->set_course_int_id($course_id);
$item_path_url = $lp->get_link('http', $my_id, false);
$item_path_url .= "&width=600";
$title = Display::url($title, $item_path_url, array('class' => 'ajax'));
}*/
$scoreItem = null;
if ($row['item_type'] == 'quiz') {
if (!$is_allowed_to_edit && $result_disabled_ext_all) {
@ -1394,14 +1386,20 @@ class Tracking
public static function get_first_connection_date($student_id)
{
$tbl_track_login = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
$sql = 'SELECT login_date FROM ' . $tbl_track_login . '
$sql = 'SELECT login_date
FROM ' . $tbl_track_login . '
WHERE login_user_id = ' . intval($student_id) . '
ORDER BY login_date ASC LIMIT 0,1';
ORDER BY login_date ASC
LIMIT 0,1';
$rs = Database::query($sql);
if (Database::num_rows($rs)>0) {
if ($first_login_date = Database::result($rs, 0, 0)) {
return api_convert_and_format_date($first_login_date, DATE_FORMAT_SHORT, date_default_timezone_get());
return api_convert_and_format_date(
$first_login_date,
DATE_FORMAT_SHORT,
date_default_timezone_get()
);
}
}
@ -1419,7 +1417,8 @@ class Tracking
public static function get_last_connection_date($student_id, $warning_message = false, $return_timestamp = false)
{
$table = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
$sql = 'SELECT login_date FROM ' . $table . '
$sql = 'SELECT login_date
FROM ' . $table . '
WHERE login_user_id = ' . intval($student_id) . '
ORDER BY login_date
DESC LIMIT 0,1';
@ -2286,10 +2285,12 @@ class Tracking
// database (and if no list was given, get them all)
if (empty($session_id)) {
$sql = "SELECT DISTINCT(id), use_max_score FROM $lp_table
WHERE c_id = $course_id AND session_id = 0 $condition_lp ";
$sql = "SELECT DISTINCT(id), use_max_score
FROM $lp_table
WHERE c_id = $course_id AND (session_id = 0 OR session_id IS NULL ) $condition_lp ";
} else {
$sql = "SELECT DISTINCT(id), use_max_score FROM $lp_table
$sql = "SELECT DISTINCT(id), use_max_score
FROM $lp_table
WHERE c_id = $course_id $condition_lp ";
}
@ -2680,9 +2681,8 @@ class Tracking
}
// Compose a filter based on optional session id
$condition_session = "";
$session_id = intval($session_id);
$condition_session = "";
if (isset($session_id)) {
$condition_session = " AND session_id = $session_id ";
}
@ -3586,7 +3586,11 @@ class Tracking
$rs = Database::query($sql);
if (Database::num_rows($rs) > 0) {
$row = Database::fetch_array($rs);
$date_time = api_convert_and_format_date($row['access_date'], null, date_default_timezone_get());
$date_time = api_convert_and_format_date(
$row['access_date'],
null,
date_default_timezone_get()
);
}
return $date_time;
}
@ -3605,10 +3609,10 @@ class Tracking
$session_id = intval($session_id);
// table definition
$tbl_stats_links = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LINKS);
$table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LINKS);
$sql = 'SELECT 1
FROM '.$tbl_stats_links.'
FROM '.$table.'
WHERE
links_user_id= '.$student_id.' AND
c_id = "'.$courseId.'" AND
@ -3632,14 +3636,15 @@ class Tracking
$session_id = intval($session_id);
// table definition
$tbl_stats_documents = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
$table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
$sql = 'SELECT 1
FROM ' . $tbl_stats_documents . '
FROM ' . $table . '
WHERE down_user_id = '.$student_id.'
AND c_id = "'.$courseId.'"
AND down_session_id = '.$session_id.' ';
$rs = Database::query($sql);
return Database::num_rows($rs);
}
@ -3714,8 +3719,9 @@ class Tracking
INNER JOIN '.$tableCourse.' c
ON (c.id = stats_login.c_id)
'.$inner.'
WHERE course_user.c_id = \''.$courseId.'\'
AND stats_login.login_course_date IS NULL
WHERE
course_user.c_id = \''.$courseId.'\' AND
stats_login.login_course_date IS NULL
GROUP BY course_user.user_id';
}
$rs = Database::query($sql);
@ -3739,10 +3745,10 @@ class Tracking
$student_id = intval($student_id);
$courseId = intval($courseId);
$session_id = intval($session_id);
$tbl_course_rel_user = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
$table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
$sql = 'SELECT '.$student_id.'
FROM ' . $tbl_course_rel_user . '
FROM ' . $table . '
WHERE
access_user_id=' . $student_id . ' AND
c_id="' . $courseId . '" AND
@ -3890,6 +3896,7 @@ class Tracking
if ($lp_with_quiz > 0) {
$avg_student_score = round(($average_data_sum / $lp_with_quiz * 100), 2);
}
return $avg_student_score;
}

@ -66,6 +66,8 @@ class UserGroup extends Model
}
/**
* @param int $type
*
* @return int
*/
public function get_count($type = -1)
@ -389,7 +391,14 @@ class UserGroup extends Model
{
if ($this->useMultipleUrl) {
$urlId = api_get_current_access_url_id();
$options = array('where' => array('c.course_id = ? AND access_url_id = ?' => array($course_id, $urlId)));
$options = array(
'where' => array(
'c.course_id = ? AND access_url_id = ?' => array(
$course_id,
$urlId,
),
),
);
$from = $this->usergroup_rel_course_table." as c INNER JOIN ".$this->access_url_rel_usergroup." a
ON c.usergroup_id = a.usergroup_id";
} else {
@ -463,7 +472,12 @@ class UserGroup extends Model
} else {
$conditions = array('where' => array('usergroup_id = ?' => $id));
}
$results = Database::select('user_id', $this->usergroup_rel_user_table, $conditions, true);
$results = Database::select(
'user_id',
$this->usergroup_rel_user_table,
$conditions,
true
);
$array = array();
if (!empty($results)) {
foreach ($results as $row) {
@ -482,7 +496,12 @@ class UserGroup extends Model
public function getUsersByUsergroupAndRelation($id, $relation = '')
{
$conditions = array('where' => array('usergroup_id = ? AND relation_type = ?' => [$id, $relation]));
$results = Database::select('user_id', $this->usergroup_rel_user_table, $conditions, true);
$results = Database::select(
'user_id',
$this->usergroup_rel_user_table,
$conditions,
true
);
$array = array();
if (!empty($results)) {
foreach ($results as $row) {

Loading…
Cancel
Save