NEW MODULE FROM MOODLE.COM - DATABASE !
Finally, we have an early version good enough for everyone to
start banging on to help us polish it up and find bugs.
Please take a look and file bugs in the bug tracker under "Database module".
We urgently need
- new icons for existing field types
- testing on PostgreSQL install
Coming soon (?):
- Many more field types: calculation, checkbox, relation, date, datetime,
time, email, group, list, user, number, richtext
(Please let us know if you are interested in developing any of these)
- A way to save and restore "presets", which are field/template sets
- Backup/Restore support
- Groups Support
- RSS support
Many thanks to Yu for all the hard work under my whip.
2005-12-02 07:50:26 +00:00
|
|
|
<?php // $Id$
|
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
// //
|
|
|
|
// NOTICE OF COPYRIGHT //
|
|
|
|
// //
|
|
|
|
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
|
|
|
|
// http://moodle.org //
|
|
|
|
// //
|
|
|
|
// Copyright (C) 2005 Martin Dougiamas http://dougiamas.com //
|
|
|
|
// //
|
|
|
|
// 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. //
|
|
|
|
// //
|
|
|
|
// This program is distributed in the hope that it will be useful, //
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
|
|
|
// GNU General Public License for more details: //
|
|
|
|
// //
|
|
|
|
// http://www.gnu.org/copyleft/gpl.html //
|
|
|
|
// //
|
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
require_once('../../config.php');
|
|
|
|
require_once('lib.php');
|
|
|
|
require_once($CFG->libdir.'/blocklib.php');
|
2006-02-13 07:57:54 +00:00
|
|
|
require_once("$CFG->libdir/rsslib.php");
|
NEW MODULE FROM MOODLE.COM - DATABASE !
Finally, we have an early version good enough for everyone to
start banging on to help us polish it up and find bugs.
Please take a look and file bugs in the bug tracker under "Database module".
We urgently need
- new icons for existing field types
- testing on PostgreSQL install
Coming soon (?):
- Many more field types: calculation, checkbox, relation, date, datetime,
time, email, group, list, user, number, richtext
(Please let us know if you are interested in developing any of these)
- A way to save and restore "presets", which are field/template sets
- Backup/Restore support
- Groups Support
- RSS support
Many thanks to Yu for all the hard work under my whip.
2005-12-02 07:50:26 +00:00
|
|
|
|
|
|
|
require_once('pagelib.php');
|
2006-03-27 04:13:32 +00:00
|
|
|
|
NEW MODULE FROM MOODLE.COM - DATABASE !
Finally, we have an early version good enough for everyone to
start banging on to help us polish it up and find bugs.
Please take a look and file bugs in the bug tracker under "Database module".
We urgently need
- new icons for existing field types
- testing on PostgreSQL install
Coming soon (?):
- Many more field types: calculation, checkbox, relation, date, datetime,
time, email, group, list, user, number, richtext
(Please let us know if you are interested in developing any of these)
- A way to save and restore "presets", which are field/template sets
- Backup/Restore support
- Groups Support
- RSS support
Many thanks to Yu for all the hard work under my whip.
2005-12-02 07:50:26 +00:00
|
|
|
|
2006-03-29 08:49:28 +00:00
|
|
|
/// One of these is necessary!
|
NEW MODULE FROM MOODLE.COM - DATABASE !
Finally, we have an early version good enough for everyone to
start banging on to help us polish it up and find bugs.
Please take a look and file bugs in the bug tracker under "Database module".
We urgently need
- new icons for existing field types
- testing on PostgreSQL install
Coming soon (?):
- Many more field types: calculation, checkbox, relation, date, datetime,
time, email, group, list, user, number, richtext
(Please let us know if you are interested in developing any of these)
- A way to save and restore "presets", which are field/template sets
- Backup/Restore support
- Groups Support
- RSS support
Many thanks to Yu for all the hard work under my whip.
2005-12-02 07:50:26 +00:00
|
|
|
$id = optional_param('id', 0, PARAM_INT); // course module id
|
|
|
|
$d = optional_param('d', 0, PARAM_INT); // database id
|
2006-03-29 08:49:28 +00:00
|
|
|
$rid = optional_param('rid', 0, PARAM_INT); //record id
|
|
|
|
|
|
|
|
$mode = optional_param('mode', '', PARAM_ALPHA); // Force the browse mode ('single')
|
|
|
|
|
|
|
|
|
|
|
|
/// These can be added to perform an action on a record
|
2006-03-26 05:03:10 +00:00
|
|
|
$approve = optional_param('approve', 0, PARAM_INT); //approval recordid
|
|
|
|
$delete = optional_param('delete', 0, PARAM_INT); //delete recordid
|
2006-03-29 08:49:28 +00:00
|
|
|
|
2006-01-31 03:58:42 +00:00
|
|
|
|
NEW MODULE FROM MOODLE.COM - DATABASE !
Finally, we have an early version good enough for everyone to
start banging on to help us polish it up and find bugs.
Please take a look and file bugs in the bug tracker under "Database module".
We urgently need
- new icons for existing field types
- testing on PostgreSQL install
Coming soon (?):
- Many more field types: calculation, checkbox, relation, date, datetime,
time, email, group, list, user, number, richtext
(Please let us know if you are interested in developing any of these)
- A way to save and restore "presets", which are field/template sets
- Backup/Restore support
- Groups Support
- RSS support
Many thanks to Yu for all the hard work under my whip.
2005-12-02 07:50:26 +00:00
|
|
|
if ($id) {
|
|
|
|
if (! $cm = get_record('course_modules', 'id', $id)) {
|
|
|
|
error('Course Module ID was incorrect');
|
|
|
|
}
|
|
|
|
if (! $course = get_record('course', 'id', $cm->course)) {
|
|
|
|
error('Course is misconfigured');
|
|
|
|
}
|
|
|
|
if (! $data = get_record('data', 'id', $cm->instance)) {
|
|
|
|
error('Course module is incorrect');
|
|
|
|
}
|
2006-03-29 08:49:28 +00:00
|
|
|
$record = NULL;
|
NEW MODULE FROM MOODLE.COM - DATABASE !
Finally, we have an early version good enough for everyone to
start banging on to help us polish it up and find bugs.
Please take a look and file bugs in the bug tracker under "Database module".
We urgently need
- new icons for existing field types
- testing on PostgreSQL install
Coming soon (?):
- Many more field types: calculation, checkbox, relation, date, datetime,
time, email, group, list, user, number, richtext
(Please let us know if you are interested in developing any of these)
- A way to save and restore "presets", which are field/template sets
- Backup/Restore support
- Groups Support
- RSS support
Many thanks to Yu for all the hard work under my whip.
2005-12-02 07:50:26 +00:00
|
|
|
|
2006-03-29 08:49:28 +00:00
|
|
|
} else if ($rid) {
|
|
|
|
if (! $record = get_record('data_records', 'id', $rid)) {
|
|
|
|
error('Record ID is incorrect');
|
|
|
|
}
|
|
|
|
if (! $data = get_record('data', 'id', $record->dataid)) {
|
|
|
|
error('Data ID is incorrect');
|
|
|
|
}
|
|
|
|
if (! $course = get_record('course', 'id', $data->course)) {
|
|
|
|
error('Course is misconfigured');
|
|
|
|
}
|
|
|
|
if (! $cm = get_coursemodule_from_instance('data', $data->id, $course->id)) {
|
|
|
|
error('Course Module ID was incorrect');
|
|
|
|
}
|
|
|
|
} else { // We must have $d
|
NEW MODULE FROM MOODLE.COM - DATABASE !
Finally, we have an early version good enough for everyone to
start banging on to help us polish it up and find bugs.
Please take a look and file bugs in the bug tracker under "Database module".
We urgently need
- new icons for existing field types
- testing on PostgreSQL install
Coming soon (?):
- Many more field types: calculation, checkbox, relation, date, datetime,
time, email, group, list, user, number, richtext
(Please let us know if you are interested in developing any of these)
- A way to save and restore "presets", which are field/template sets
- Backup/Restore support
- Groups Support
- RSS support
Many thanks to Yu for all the hard work under my whip.
2005-12-02 07:50:26 +00:00
|
|
|
if (! $data = get_record('data', 'id', $d)) {
|
|
|
|
error('Data ID is incorrect');
|
|
|
|
}
|
|
|
|
if (! $course = get_record('course', 'id', $data->course)) {
|
|
|
|
error('Course is misconfigured');
|
|
|
|
}
|
|
|
|
if (! $cm = get_coursemodule_from_instance('data', $data->id, $course->id)) {
|
|
|
|
error('Course Module ID was incorrect');
|
|
|
|
}
|
2006-03-29 08:49:28 +00:00
|
|
|
$record = NULL;
|
NEW MODULE FROM MOODLE.COM - DATABASE !
Finally, we have an early version good enough for everyone to
start banging on to help us polish it up and find bugs.
Please take a look and file bugs in the bug tracker under "Database module".
We urgently need
- new icons for existing field types
- testing on PostgreSQL install
Coming soon (?):
- Many more field types: calculation, checkbox, relation, date, datetime,
time, email, group, list, user, number, richtext
(Please let us know if you are interested in developing any of these)
- A way to save and restore "presets", which are field/template sets
- Backup/Restore support
- Groups Support
- RSS support
Many thanks to Yu for all the hard work under my whip.
2005-12-02 07:50:26 +00:00
|
|
|
}
|
|
|
|
|
2006-03-30 04:37:16 +00:00
|
|
|
|
2006-03-27 04:13:32 +00:00
|
|
|
require_course_login($course, true, $cm);
|
|
|
|
|
2006-03-30 04:37:16 +00:00
|
|
|
|
|
|
|
/// If it's hidden then it's don't show anything. :)
|
|
|
|
if (empty($cm->visible) and !isteacher($course->id)) {
|
2006-03-30 04:46:12 +00:00
|
|
|
$strdatabases = get_string("modulenameplural", "data");
|
|
|
|
$navigation = "<a href=\"index.php?id=$course->id\">$strdatabases</a> ->";
|
|
|
|
print_header_simple(format_string($data->name), "",
|
|
|
|
"$navigation ".format_string($data->name), "", "", true, '', navmenu($course, $cm));
|
2006-03-30 04:37:16 +00:00
|
|
|
notice(get_string("activityiscurrentlyhidden"));
|
|
|
|
}
|
|
|
|
|
2006-03-29 08:49:28 +00:00
|
|
|
/// If we have an empty Database then redirect because this page is useless without data
|
NEW MODULE FROM MOODLE.COM - DATABASE !
Finally, we have an early version good enough for everyone to
start banging on to help us polish it up and find bugs.
Please take a look and file bugs in the bug tracker under "Database module".
We urgently need
- new icons for existing field types
- testing on PostgreSQL install
Coming soon (?):
- Many more field types: calculation, checkbox, relation, date, datetime,
time, email, group, list, user, number, richtext
(Please let us know if you are interested in developing any of these)
- A way to save and restore "presets", which are field/template sets
- Backup/Restore support
- Groups Support
- RSS support
Many thanks to Yu for all the hard work under my whip.
2005-12-02 07:50:26 +00:00
|
|
|
if (isteacher($course->id)) {
|
2006-03-22 08:32:54 +00:00
|
|
|
if (!record_exists('data_fields','dataid',$data->id)) { // Brand new database!
|
2006-03-24 02:44:05 +00:00
|
|
|
redirect($CFG->wwwroot.'/mod/data/field.php?d='.$data->id); // Redirect to field entry
|
NEW MODULE FROM MOODLE.COM - DATABASE !
Finally, we have an early version good enough for everyone to
start banging on to help us polish it up and find bugs.
Please take a look and file bugs in the bug tracker under "Database module".
We urgently need
- new icons for existing field types
- testing on PostgreSQL install
Coming soon (?):
- Many more field types: calculation, checkbox, relation, date, datetime,
time, email, group, list, user, number, richtext
(Please let us know if you are interested in developing any of these)
- A way to save and restore "presets", which are field/template sets
- Backup/Restore support
- Groups Support
- RSS support
Many thanks to Yu for all the hard work under my whip.
2005-12-02 07:50:26 +00:00
|
|
|
}
|
|
|
|
}
|
2006-03-27 08:42:25 +00:00
|
|
|
|
2006-03-29 08:49:28 +00:00
|
|
|
|
|
|
|
/// Check further parameters that set browsing preferences
|
|
|
|
if (!isset($SESSION->dataprefs)) {
|
|
|
|
$SESSION->dataprefs = array();
|
2006-03-27 08:42:25 +00:00
|
|
|
}
|
2006-03-29 08:49:28 +00:00
|
|
|
if (!isset($SESSION->dataprefs[$data->id])) {
|
|
|
|
$SESSION->dataprefs[$data->id] = array();
|
|
|
|
$SESSION->dataprefs[$data->id]['search'] = '';
|
|
|
|
$SESSION->dataprefs[$data->id]['sort'] = $data->defaultsort;
|
|
|
|
$SESSION->dataprefs[$data->id]['order'] = ($data->defaultsortdir == 0) ? 'ASC' : 'DESC';
|
NEW MODULE FROM MOODLE.COM - DATABASE !
Finally, we have an early version good enough for everyone to
start banging on to help us polish it up and find bugs.
Please take a look and file bugs in the bug tracker under "Database module".
We urgently need
- new icons for existing field types
- testing on PostgreSQL install
Coming soon (?):
- Many more field types: calculation, checkbox, relation, date, datetime,
time, email, group, list, user, number, richtext
(Please let us know if you are interested in developing any of these)
- A way to save and restore "presets", which are field/template sets
- Backup/Restore support
- Groups Support
- RSS support
Many thanks to Yu for all the hard work under my whip.
2005-12-02 07:50:26 +00:00
|
|
|
}
|
2006-03-29 08:49:28 +00:00
|
|
|
$search = optional_param('search', $SESSION->dataprefs[$data->id]['search'], PARAM_NOTAGS);
|
|
|
|
$SESSION->dataprefs[$data->id]['search'] = $search; // Make it sticky
|
|
|
|
|
|
|
|
$sort = optional_param('sort', $SESSION->dataprefs[$data->id]['sort'], PARAM_INT);
|
|
|
|
$SESSION->dataprefs[$data->id]['sort'] = $sort; // Make it sticky
|
|
|
|
|
|
|
|
$order = (optional_param('order', $SESSION->dataprefs[$data->id]['order'], PARAM_ALPHA) == 'ASC') ? 'ASC': 'DESC';
|
|
|
|
$SESSION->dataprefs[$data->id]['order'] = $order; // Make it sticky
|
|
|
|
|
|
|
|
|
|
|
|
$oldperpage = get_user_preferences('data_perpage_'.$data->id, 10);
|
|
|
|
$perpage = optional_param('perpage', $oldperpage, PARAM_INT);
|
|
|
|
|
|
|
|
if ($perpage < 2) {
|
|
|
|
$perpage = 2;
|
|
|
|
}
|
|
|
|
if ($perpage != $oldperpage) {
|
|
|
|
set_user_preference('data_perpage_'.$data->id, $perpage);
|
|
|
|
}
|
|
|
|
|
|
|
|
$page = optional_param('page', 0, PARAM_INT);
|
2006-03-22 08:32:54 +00:00
|
|
|
|
NEW MODULE FROM MOODLE.COM - DATABASE !
Finally, we have an early version good enough for everyone to
start banging on to help us polish it up and find bugs.
Please take a look and file bugs in the bug tracker under "Database module".
We urgently need
- new icons for existing field types
- testing on PostgreSQL install
Coming soon (?):
- Many more field types: calculation, checkbox, relation, date, datetime,
time, email, group, list, user, number, richtext
(Please let us know if you are interested in developing any of these)
- A way to save and restore "presets", which are field/template sets
- Backup/Restore support
- Groups Support
- RSS support
Many thanks to Yu for all the hard work under my whip.
2005-12-02 07:50:26 +00:00
|
|
|
add_to_log($course->id, 'data', 'view', "view.php?id=$cm->id", $data->id, $cm->id);
|
|
|
|
|
|
|
|
|
|
|
|
// Initialize $PAGE, compute blocks
|
|
|
|
$PAGE = page_create_instance($data->id);
|
|
|
|
$pageblocks = blocks_setup($PAGE);
|
|
|
|
$blocks_preferred_width = bounded_number(180, blocks_preferred_width($pageblocks[BLOCK_POS_LEFT]), 210);
|
|
|
|
|
|
|
|
if (!empty($edit) && $PAGE->user_allowed_editing()) {
|
|
|
|
if ($edit == 'on') {
|
|
|
|
$USER->editing = true;
|
|
|
|
} else if ($edit == 'off') {
|
|
|
|
$USER->editing = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-03-29 18:29:16 +00:00
|
|
|
/// RSS and CSS meta
|
|
|
|
$meta = '';
|
2006-04-05 01:38:06 +00:00
|
|
|
if (!empty($CFG->enablerssfeeds) && !empty($CFG->data_enablerssfeeds) && $data->rssarticles > 0) {
|
2006-03-03 08:06:50 +00:00
|
|
|
$rsspath = rss_get_url($course->id, $USER->id, 'data', $data->id);
|
2006-03-29 18:29:16 +00:00
|
|
|
$meta .= '<link rel="alternate" type="application/rss+xml" ';
|
|
|
|
$meta .= 'title ="'.$course->shortname.': %fullname%" href="'.$rsspath.'" />';
|
|
|
|
}
|
|
|
|
if ($data->csstemplate) {
|
|
|
|
$meta .= '<link rel="stylesheet" type="text/css" href="'.$CFG->wwwroot.'/mod/data/css.php?d='.$data->id.'" /> ';
|
2006-03-03 08:06:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// Print the page header
|
2006-03-29 18:29:16 +00:00
|
|
|
$PAGE->print_header($course->shortname.': %fullname%', '', $meta);
|
2006-03-03 08:06:50 +00:00
|
|
|
|
NEW MODULE FROM MOODLE.COM - DATABASE !
Finally, we have an early version good enough for everyone to
start banging on to help us polish it up and find bugs.
Please take a look and file bugs in the bug tracker under "Database module".
We urgently need
- new icons for existing field types
- testing on PostgreSQL install
Coming soon (?):
- Many more field types: calculation, checkbox, relation, date, datetime,
time, email, group, list, user, number, richtext
(Please let us know if you are interested in developing any of these)
- A way to save and restore "presets", which are field/template sets
- Backup/Restore support
- Groups Support
- RSS support
Many thanks to Yu for all the hard work under my whip.
2005-12-02 07:50:26 +00:00
|
|
|
|
2006-04-05 08:19:09 +00:00
|
|
|
/// If we have blocks, then print the left side here
|
|
|
|
if (!empty($CFG->showblocksonmodpages)) {
|
|
|
|
echo '<table id="layout-table"><tr>';
|
|
|
|
if ((blocks_have_content($pageblocks, BLOCK_POS_LEFT) || $PAGE->user_is_editing())) {
|
|
|
|
echo '<td style="width: '.$blocks_preferred_width.'px;" id="left-column">';
|
|
|
|
blocks_print_group($PAGE, $pageblocks, BLOCK_POS_LEFT);
|
|
|
|
echo '</td>';
|
|
|
|
}
|
|
|
|
echo '<td id="middle-column">';
|
NEW MODULE FROM MOODLE.COM - DATABASE !
Finally, we have an early version good enough for everyone to
start banging on to help us polish it up and find bugs.
Please take a look and file bugs in the bug tracker under "Database module".
We urgently need
- new icons for existing field types
- testing on PostgreSQL install
Coming soon (?):
- Many more field types: calculation, checkbox, relation, date, datetime,
time, email, group, list, user, number, richtext
(Please let us know if you are interested in developing any of these)
- A way to save and restore "presets", which are field/template sets
- Backup/Restore support
- Groups Support
- RSS support
Many thanks to Yu for all the hard work under my whip.
2005-12-02 07:50:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
print_heading(format_string($data->name));
|
2006-02-13 07:57:54 +00:00
|
|
|
|
|
|
|
// Do we need to show a link to the RSS feed for the records?
|
2006-04-05 01:38:06 +00:00
|
|
|
if (!empty($CFG->enablerssfeeds) && !empty($CFG->data_enablerssfeeds) && $data->rssarticles > 0) {
|
2006-02-13 07:57:54 +00:00
|
|
|
echo '<div style="float:right;">';
|
2006-03-22 08:32:54 +00:00
|
|
|
rss_print_link($course->id, $USER->id, 'data', $data->id, get_string('rsstype'));
|
2006-02-13 07:57:54 +00:00
|
|
|
echo '</div>';
|
|
|
|
echo '<div style="clear:both;"></div>';
|
|
|
|
}
|
|
|
|
|
2006-04-05 01:38:06 +00:00
|
|
|
if ($data->intro and empty($page) and empty($record)) {
|
2006-02-06 04:17:30 +00:00
|
|
|
print_simple_box(format_text($data->intro), 'center', '70%', '', 5, 'generalbox', 'intro');
|
|
|
|
}
|
|
|
|
|
NEW MODULE FROM MOODLE.COM - DATABASE !
Finally, we have an early version good enough for everyone to
start banging on to help us polish it up and find bugs.
Please take a look and file bugs in the bug tracker under "Database module".
We urgently need
- new icons for existing field types
- testing on PostgreSQL install
Coming soon (?):
- Many more field types: calculation, checkbox, relation, date, datetime,
time, email, group, list, user, number, richtext
(Please let us know if you are interested in developing any of these)
- A way to save and restore "presets", which are field/template sets
- Backup/Restore support
- Groups Support
- RSS support
Many thanks to Yu for all the hard work under my whip.
2005-12-02 07:50:26 +00:00
|
|
|
/// Check to see if groups are being used here
|
|
|
|
if ($groupmode = groupmode($course, $cm)) { // Groups are being used
|
2006-03-22 08:32:54 +00:00
|
|
|
$currentgroup = setup_and_print_groups($course, $groupmode,
|
|
|
|
'view.php?d='.$data->id.'&search='.s($search).'&sort='.s($sort).
|
|
|
|
'&order='.s($order).'&');
|
NEW MODULE FROM MOODLE.COM - DATABASE !
Finally, we have an early version good enough for everyone to
start banging on to help us polish it up and find bugs.
Please take a look and file bugs in the bug tracker under "Database module".
We urgently need
- new icons for existing field types
- testing on PostgreSQL install
Coming soon (?):
- Many more field types: calculation, checkbox, relation, date, datetime,
time, email, group, list, user, number, richtext
(Please let us know if you are interested in developing any of these)
- A way to save and restore "presets", which are field/template sets
- Backup/Restore support
- Groups Support
- RSS support
Many thanks to Yu for all the hard work under my whip.
2005-12-02 07:50:26 +00:00
|
|
|
} else {
|
|
|
|
$currentgroup = 0;
|
|
|
|
}
|
|
|
|
|
2006-03-26 05:03:10 +00:00
|
|
|
/// Delete any requested records
|
|
|
|
|
2006-03-29 08:49:28 +00:00
|
|
|
if ($delete && confirm_sesskey() && (isteacher($course->id) or data_isowner($delete))) {
|
|
|
|
if ($confirm = optional_param('confirm',0,PARAM_INT)) {
|
|
|
|
if ($deleterecord = get_record('data_records', 'id', $delete)) { // Need to check this is valid
|
|
|
|
if ($deleterecord->dataid == $data->id) { // Must be from this database
|
|
|
|
if ($contents = get_records('data_content','recordid', $deleterecord->id)) {
|
|
|
|
foreach ($contents as $content) { // Delete files or whatever else this field allows
|
|
|
|
if ($field = data_get_field_from_id($content->fieldid, $data)) { // Might not be there
|
|
|
|
$field->delete_content($content->recordid);
|
|
|
|
}
|
NEW MODULE FROM MOODLE.COM - DATABASE !
Finally, we have an early version good enough for everyone to
start banging on to help us polish it up and find bugs.
Please take a look and file bugs in the bug tracker under "Database module".
We urgently need
- new icons for existing field types
- testing on PostgreSQL install
Coming soon (?):
- Many more field types: calculation, checkbox, relation, date, datetime,
time, email, group, list, user, number, richtext
(Please let us know if you are interested in developing any of these)
- A way to save and restore "presets", which are field/template sets
- Backup/Restore support
- Groups Support
- RSS support
Many thanks to Yu for all the hard work under my whip.
2005-12-02 07:50:26 +00:00
|
|
|
}
|
|
|
|
}
|
2006-03-29 08:49:28 +00:00
|
|
|
delete_records('data_content','recordid', $deleterecord->id);
|
|
|
|
delete_records('data_records','id', $deleterecord->id);
|
2006-03-22 14:31:32 +00:00
|
|
|
|
2006-03-29 08:49:28 +00:00
|
|
|
add_to_log($course->id, 'data', 'record delete', "view.php?id=$cm->id", $data->id, $cm->id);
|
2006-03-22 14:31:32 +00:00
|
|
|
|
2006-03-29 08:49:28 +00:00
|
|
|
notify(get_string('recorddeleted','data'), 'notifysuccess');
|
|
|
|
}
|
NEW MODULE FROM MOODLE.COM - DATABASE !
Finally, we have an early version good enough for everyone to
start banging on to help us polish it up and find bugs.
Please take a look and file bugs in the bug tracker under "Database module".
We urgently need
- new icons for existing field types
- testing on PostgreSQL install
Coming soon (?):
- Many more field types: calculation, checkbox, relation, date, datetime,
time, email, group, list, user, number, richtext
(Please let us know if you are interested in developing any of these)
- A way to save and restore "presets", which are field/template sets
- Backup/Restore support
- Groups Support
- RSS support
Many thanks to Yu for all the hard work under my whip.
2005-12-02 07:50:26 +00:00
|
|
|
}
|
2006-03-29 08:49:28 +00:00
|
|
|
|
|
|
|
} else { // Print a confirmation page
|
2006-04-05 01:38:06 +00:00
|
|
|
if ($deleterecord = get_record('data_records', 'id', $delete)) { // Need to check this is valid
|
|
|
|
if ($deleterecord->dataid == $data->id) { // Must be from this database
|
|
|
|
notice_yesno(get_string('confirmdeleterecord','data'),
|
|
|
|
'view.php?d='.$data->id.'&delete='.$delete.'&confirm=1&sesskey='.sesskey(),
|
|
|
|
'view.php?d='.$data->id);
|
2006-03-29 08:49:28 +00:00
|
|
|
|
2006-04-05 01:38:06 +00:00
|
|
|
$records[] = $deleterecord;
|
|
|
|
data_print_template('singletemplate', $records, $data);
|
|
|
|
|
|
|
|
print_footer($course);
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Print the tabs
|
|
|
|
|
|
|
|
if ($record or $mode == 'single') {
|
|
|
|
$currenttab = 'single';
|
|
|
|
} else {
|
|
|
|
$currenttab = 'list';
|
|
|
|
}
|
|
|
|
include('tabs.php');
|
|
|
|
|
|
|
|
|
|
|
|
/// Approve any requested records
|
|
|
|
|
|
|
|
if ($approve && confirm_sesskey() && isteacher($course->id)) {
|
|
|
|
if ($approverecord = get_record('data_records', 'id', $approve)) { // Need to check this is valid
|
|
|
|
if ($approverecord->dataid == $data->id) { // Must be from this database
|
|
|
|
$newrecord->id = $approverecord->id;
|
|
|
|
$newrecord->approved = 1;
|
|
|
|
if (update_record('data_records', $newrecord)) {
|
|
|
|
notify(get_string('recordapproved','data'), 'notifysuccess');
|
|
|
|
}
|
|
|
|
}
|
NEW MODULE FROM MOODLE.COM - DATABASE !
Finally, we have an early version good enough for everyone to
start banging on to help us polish it up and find bugs.
Please take a look and file bugs in the bug tracker under "Database module".
We urgently need
- new icons for existing field types
- testing on PostgreSQL install
Coming soon (?):
- Many more field types: calculation, checkbox, relation, date, datetime,
time, email, group, list, user, number, richtext
(Please let us know if you are interested in developing any of these)
- A way to save and restore "presets", which are field/template sets
- Backup/Restore support
- Groups Support
- RSS support
Many thanks to Yu for all the hard work under my whip.
2005-12-02 07:50:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-03-26 05:22:16 +00:00
|
|
|
// If not teacher, check whether user has sufficient records to view
|
|
|
|
if (!isteacher($course->id) and data_numentries($data) < $data->requiredentriestoview){
|
2006-03-23 05:38:53 +00:00
|
|
|
notify (($data->requiredentriestoview - data_numentries($data)).' '.get_string('insufficiententries','data'));
|
2006-02-20 02:15:45 +00:00
|
|
|
echo '</td></tr></table>';
|
NEW MODULE FROM MOODLE.COM - DATABASE !
Finally, we have an early version good enough for everyone to
start banging on to help us polish it up and find bugs.
Please take a look and file bugs in the bug tracker under "Database module".
We urgently need
- new icons for existing field types
- testing on PostgreSQL install
Coming soon (?):
- Many more field types: calculation, checkbox, relation, date, datetime,
time, email, group, list, user, number, richtext
(Please let us know if you are interested in developing any of these)
- A way to save and restore "presets", which are field/template sets
- Backup/Restore support
- Groups Support
- RSS support
Many thanks to Yu for all the hard work under my whip.
2005-12-02 07:50:26 +00:00
|
|
|
print_footer($course);
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-03-29 08:49:28 +00:00
|
|
|
/// We need to examine the whole dataset to produce the correct paging
|
2006-03-26 05:36:34 +00:00
|
|
|
|
2006-03-27 09:50:23 +00:00
|
|
|
if ((!isteacher($course->id)) && ($data->approval)) {
|
|
|
|
if (isloggedin()) {
|
2006-03-29 08:49:28 +00:00
|
|
|
$approveselect = ' AND (r.approved=1 OR r.userid='.$USER->id.') ';
|
2006-03-27 09:50:23 +00:00
|
|
|
} else {
|
2006-03-29 08:49:28 +00:00
|
|
|
$approveselect = ' AND r.approved=1 ';
|
2006-03-27 09:50:23 +00:00
|
|
|
}
|
2006-02-03 08:11:36 +00:00
|
|
|
} else {
|
2006-03-29 08:49:28 +00:00
|
|
|
$approveselect = ' ';
|
2006-02-03 08:11:36 +00:00
|
|
|
}
|
|
|
|
|
2006-03-29 08:49:28 +00:00
|
|
|
if ($currentgroup) {
|
|
|
|
$groupselect = " AND (r.groupid = '$currentgroup' OR r.groupid = 0)";
|
2006-02-03 08:11:36 +00:00
|
|
|
} else {
|
2006-03-29 08:49:28 +00:00
|
|
|
$groupselect = ' ';
|
NEW MODULE FROM MOODLE.COM - DATABASE !
Finally, we have an early version good enough for everyone to
start banging on to help us polish it up and find bugs.
Please take a look and file bugs in the bug tracker under "Database module".
We urgently need
- new icons for existing field types
- testing on PostgreSQL install
Coming soon (?):
- Many more field types: calculation, checkbox, relation, date, datetime,
time, email, group, list, user, number, richtext
(Please let us know if you are interested in developing any of these)
- A way to save and restore "presets", which are field/template sets
- Backup/Restore support
- Groups Support
- RSS support
Many thanks to Yu for all the hard work under my whip.
2005-12-02 07:50:26 +00:00
|
|
|
}
|
|
|
|
|
2006-03-29 08:49:28 +00:00
|
|
|
/// Find the field we are sorting on
|
|
|
|
if ($sort) {
|
2006-03-22 08:07:26 +00:00
|
|
|
$sortfield = data_get_field_from_id($sort, $data);
|
2006-02-03 08:11:36 +00:00
|
|
|
$sortcontent = $sortfield->get_sort_field();
|
2006-04-05 01:38:06 +00:00
|
|
|
$sortcontentfull = $sortfield->get_sort_sql('c.'.$sortcontent);
|
2006-03-29 08:49:28 +00:00
|
|
|
|
2006-04-05 01:38:06 +00:00
|
|
|
$what = ' DISTINCT r.id, r.approved, r.userid, u.firstname, u.lastname ';
|
2006-03-29 08:49:28 +00:00
|
|
|
$count = ' COUNT(DISTINCT c.recordid) ';
|
2006-04-05 01:38:06 +00:00
|
|
|
$tables = $CFG->prefix.'data_content c,'.$CFG->prefix.'data_records r,'.$CFG->prefix.'data_content c1, '.$CFG->prefix.'user u ';
|
2006-03-29 08:49:28 +00:00
|
|
|
$where = 'WHERE c.recordid = r.id
|
|
|
|
AND c.fieldid = '.$sort.'
|
|
|
|
AND r.dataid = '.$data->id.'
|
2006-04-05 01:38:06 +00:00
|
|
|
AND r.userid = u.id
|
2006-03-29 08:49:28 +00:00
|
|
|
AND c1.recordid = r.id ';
|
2006-04-05 01:38:06 +00:00
|
|
|
$sortorder = ' ORDER BY '.$sortcontentfull.' '.$order.' ';
|
|
|
|
if ($search) {
|
|
|
|
$searchselect = ' AND (c1.content LIKE "%'.$search.'%") ';
|
|
|
|
} else {
|
|
|
|
$searchselect = ' ';
|
|
|
|
}
|
2006-03-29 08:49:28 +00:00
|
|
|
|
|
|
|
} else if ($search) {
|
2006-04-05 01:38:06 +00:00
|
|
|
$what = ' DISTINCT r.id, r.approved, r.userid, u.firstname, u.lastname ';
|
2006-03-29 08:49:28 +00:00
|
|
|
$count = ' COUNT(DISTINCT c.recordid) ';
|
2006-04-05 01:38:06 +00:00
|
|
|
$tables = $CFG->prefix.'data_content c,'.$CFG->prefix.'data_records r, '.$CFG->prefix.'user u ';
|
2006-03-29 08:49:28 +00:00
|
|
|
$where = 'WHERE c.recordid = r.id
|
2006-04-05 01:38:06 +00:00
|
|
|
AND r.userid = u.id
|
2006-03-29 08:49:28 +00:00
|
|
|
AND r.dataid = '.$data->id;
|
|
|
|
$sortorder = ' ORDER BY r.id ';
|
2006-04-05 01:38:06 +00:00
|
|
|
$searchselect = ' AND (c.content LIKE "%'.$search.'%") ';
|
2006-03-29 08:49:28 +00:00
|
|
|
|
|
|
|
} else {
|
2006-04-05 01:38:06 +00:00
|
|
|
$what = ' DISTINCT r.id, r.approved, r.userid, u.firstname, u.lastname ';
|
2006-03-29 08:49:28 +00:00
|
|
|
$count = ' COUNT(r.id) ';
|
2006-04-05 01:38:06 +00:00
|
|
|
$tables = $CFG->prefix.'data_records r, '.$CFG->prefix.'user u ';
|
|
|
|
$where = 'WHERE r.dataid = '.$data->id. ' AND r.userid = u.id ';
|
|
|
|
$sortorder = ' ORDER BY r.timecreated '.$order. ' ';
|
2006-03-29 08:49:28 +00:00
|
|
|
$searchselect = ' ';
|
NEW MODULE FROM MOODLE.COM - DATABASE !
Finally, we have an early version good enough for everyone to
start banging on to help us polish it up and find bugs.
Please take a look and file bugs in the bug tracker under "Database module".
We urgently need
- new icons for existing field types
- testing on PostgreSQL install
Coming soon (?):
- Many more field types: calculation, checkbox, relation, date, datetime,
time, email, group, list, user, number, richtext
(Please let us know if you are interested in developing any of these)
- A way to save and restore "presets", which are field/template sets
- Backup/Restore support
- Groups Support
- RSS support
Many thanks to Yu for all the hard work under my whip.
2005-12-02 07:50:26 +00:00
|
|
|
}
|
|
|
|
|
2006-04-05 01:38:06 +00:00
|
|
|
|
2006-03-29 08:49:28 +00:00
|
|
|
/// To actually fetch the records
|
|
|
|
|
|
|
|
$fromsql = ' FROM '.$tables.$where.$groupselect.$approveselect.$searchselect;
|
|
|
|
|
|
|
|
$sqlselect = 'SELECT '.$what.$fromsql.$sortorder;
|
|
|
|
|
|
|
|
$sqlcount = 'SELECT '.$count.$fromsql; // Total number of records
|
|
|
|
|
|
|
|
/// Work out the paging numbers
|
|
|
|
|
NEW MODULE FROM MOODLE.COM - DATABASE !
Finally, we have an early version good enough for everyone to
start banging on to help us polish it up and find bugs.
Please take a look and file bugs in the bug tracker under "Database module".
We urgently need
- new icons for existing field types
- testing on PostgreSQL install
Coming soon (?):
- Many more field types: calculation, checkbox, relation, date, datetime,
time, email, group, list, user, number, richtext
(Please let us know if you are interested in developing any of these)
- A way to save and restore "presets", which are field/template sets
- Backup/Restore support
- Groups Support
- RSS support
Many thanks to Yu for all the hard work under my whip.
2005-12-02 07:50:26 +00:00
|
|
|
$totalcount = count_records_sql($sqlcount);
|
|
|
|
|
2006-03-29 08:49:28 +00:00
|
|
|
if ($record) { // We need to just show one, so where is it in context?
|
|
|
|
$nowperpage = 1;
|
|
|
|
$mode = 'single';
|
2006-04-05 01:38:06 +00:00
|
|
|
# if ($sort) { // We need to search by that field
|
|
|
|
# if ($content = get_field('data_content', 'content', 'recordid', $record->id, 'fieldid', $sort)) {
|
|
|
|
# $content = addslashes($content);
|
|
|
|
# if ($order == 'ASC') {
|
|
|
|
# $lessthan = " AND $sortcontentfull < '$content' ";
|
|
|
|
# } else {
|
|
|
|
# $lessthan = " AND $sortcontentfull > '$content' ";
|
|
|
|
# }
|
|
|
|
# } else { // Failed to find data (shouldn't happen), so fall back to something easy
|
|
|
|
# $lessthan = " r.id < '$record->id' ";
|
|
|
|
# }
|
|
|
|
# } else {
|
|
|
|
# $lessthan = " r.id < '$record->id' ";
|
|
|
|
# }
|
|
|
|
# $sqlindex = 'SELECT COUNT(DISTINCT c.recordid) '.$fromsql.$lessthan.$sortorder;
|
|
|
|
# $page = count_records_sql($sqlindex);
|
|
|
|
|
|
|
|
$allrecords = get_records_sql($sqlselect); // Kludgey but accurate at least!
|
|
|
|
$page = 0;
|
|
|
|
foreach ($allrecords as $key => $allrecord) {
|
|
|
|
if ($key == $record->id) {
|
|
|
|
break;
|
2006-03-29 08:49:28 +00:00
|
|
|
}
|
2006-04-05 01:38:06 +00:00
|
|
|
$page++;
|
2006-03-29 08:49:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} else if ($mode == 'single') { // We rely on ambient $page settings
|
|
|
|
$nowperpage = 1;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
$nowperpage = $perpage;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Get the actual records
|
|
|
|
|
|
|
|
$limit = sql_paging_limit($page * $nowperpage, $nowperpage);
|
|
|
|
$records = get_records_sql($sqlselect.$limit);
|
|
|
|
|
|
|
|
if (empty($records)) { // Nothing to show!
|
2006-04-08 16:33:16 +00:00
|
|
|
if ($record) { // Something was requested so try to show that at least (bug 5132)
|
|
|
|
if (isteacher($course->id) || empty($data->approval) ||
|
|
|
|
$record->approved || (isloggedin() && $record->userid == $USER->id)) {
|
|
|
|
if (!$currentgroup || $record->groupid == $currentgroup || $record->groupid == 0) {
|
|
|
|
$records[] = $record;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ($records) { // OK, we can show this one
|
|
|
|
data_print_template('singletemplate', $records, $data, $search, $page);
|
|
|
|
} else if ($search){
|
NEW MODULE FROM MOODLE.COM - DATABASE !
Finally, we have an early version good enough for everyone to
start banging on to help us polish it up and find bugs.
Please take a look and file bugs in the bug tracker under "Database module".
We urgently need
- new icons for existing field types
- testing on PostgreSQL install
Coming soon (?):
- Many more field types: calculation, checkbox, relation, date, datetime,
time, email, group, list, user, number, richtext
(Please let us know if you are interested in developing any of these)
- A way to save and restore "presets", which are field/template sets
- Backup/Restore support
- Groups Support
- RSS support
Many thanks to Yu for all the hard work under my whip.
2005-12-02 07:50:26 +00:00
|
|
|
notify(get_string('nomatch','data'));
|
2006-03-26 16:19:57 +00:00
|
|
|
} else {
|
NEW MODULE FROM MOODLE.COM - DATABASE !
Finally, we have an early version good enough for everyone to
start banging on to help us polish it up and find bugs.
Please take a look and file bugs in the bug tracker under "Database module".
We urgently need
- new icons for existing field types
- testing on PostgreSQL install
Coming soon (?):
- Many more field types: calculation, checkbox, relation, date, datetime,
time, email, group, list, user, number, richtext
(Please let us know if you are interested in developing any of these)
- A way to save and restore "presets", which are field/template sets
- Backup/Restore support
- Groups Support
- RSS support
Many thanks to Yu for all the hard work under my whip.
2005-12-02 07:50:26 +00:00
|
|
|
notify(get_string('norecords','data'));
|
|
|
|
}
|
2006-02-03 08:11:36 +00:00
|
|
|
|
2006-03-29 08:49:28 +00:00
|
|
|
} else { // We have some records to print
|
2005-12-05 08:56:48 +00:00
|
|
|
|
2006-03-29 08:49:28 +00:00
|
|
|
if ($mode == 'single') { // Single template
|
|
|
|
$baseurl = 'view.php?d='.$data->id.'&mode=single&';
|
NEW MODULE FROM MOODLE.COM - DATABASE !
Finally, we have an early version good enough for everyone to
start banging on to help us polish it up and find bugs.
Please take a look and file bugs in the bug tracker under "Database module".
We urgently need
- new icons for existing field types
- testing on PostgreSQL install
Coming soon (?):
- Many more field types: calculation, checkbox, relation, date, datetime,
time, email, group, list, user, number, richtext
(Please let us know if you are interested in developing any of these)
- A way to save and restore "presets", which are field/template sets
- Backup/Restore support
- Groups Support
- RSS support
Many thanks to Yu for all the hard work under my whip.
2005-12-02 07:50:26 +00:00
|
|
|
|
2006-03-29 08:49:28 +00:00
|
|
|
print_paging_bar($totalcount, $page, $nowperpage, $baseurl, $pagevar='page');
|
|
|
|
|
|
|
|
if (empty($data->singletemplate)){
|
|
|
|
notify(get_string('nosingletemplate','data'));
|
|
|
|
}
|
NEW MODULE FROM MOODLE.COM - DATABASE !
Finally, we have an early version good enough for everyone to
start banging on to help us polish it up and find bugs.
Please take a look and file bugs in the bug tracker under "Database module".
We urgently need
- new icons for existing field types
- testing on PostgreSQL install
Coming soon (?):
- Many more field types: calculation, checkbox, relation, date, datetime,
time, email, group, list, user, number, richtext
(Please let us know if you are interested in developing any of these)
- A way to save and restore "presets", which are field/template sets
- Backup/Restore support
- Groups Support
- RSS support
Many thanks to Yu for all the hard work under my whip.
2005-12-02 07:50:26 +00:00
|
|
|
|
2006-03-29 17:36:20 +00:00
|
|
|
data_print_template('singletemplate', $records, $data, $search, $page);
|
2006-03-29 08:49:28 +00:00
|
|
|
|
|
|
|
print_paging_bar($totalcount, $page, $nowperpage, $baseurl, $pagevar='page');
|
|
|
|
|
|
|
|
} else { // List template
|
|
|
|
$baseurl = 'view.php?d='.$data->id.'&';
|
|
|
|
|
|
|
|
print_paging_bar($totalcount, $page, $nowperpage, $baseurl, $pagevar='page');
|
|
|
|
|
|
|
|
if (empty($data->listtemplate)){
|
|
|
|
notify(get_string('nolisttemplate','data'));
|
|
|
|
}
|
|
|
|
echo $data->listtemplateheader;
|
2006-03-29 17:36:20 +00:00
|
|
|
data_print_template('listtemplate', $records, $data, $search, $page);
|
2006-03-29 08:49:28 +00:00
|
|
|
echo $data->listtemplatefooter;
|
|
|
|
|
|
|
|
print_paging_bar($totalcount, $page, $nowperpage, $baseurl, $pagevar='page');
|
|
|
|
}
|
2006-03-26 05:36:34 +00:00
|
|
|
|
2006-04-05 01:38:06 +00:00
|
|
|
data_print_preference_form($data, $perpage, $search, $sort, $order);
|
|
|
|
}
|
NEW MODULE FROM MOODLE.COM - DATABASE !
Finally, we have an early version good enough for everyone to
start banging on to help us polish it up and find bugs.
Please take a look and file bugs in the bug tracker under "Database module".
We urgently need
- new icons for existing field types
- testing on PostgreSQL install
Coming soon (?):
- Many more field types: calculation, checkbox, relation, date, datetime,
time, email, group, list, user, number, richtext
(Please let us know if you are interested in developing any of these)
- A way to save and restore "presets", which are field/template sets
- Backup/Restore support
- Groups Support
- RSS support
Many thanks to Yu for all the hard work under my whip.
2005-12-02 07:50:26 +00:00
|
|
|
|
2006-04-05 08:19:09 +00:00
|
|
|
/// If we have blocks, then print the left side here
|
|
|
|
if (!empty($CFG->showblocksonmodpages)) {
|
|
|
|
echo '</td>'; // Middle column
|
|
|
|
if ((blocks_have_content($pageblocks, BLOCK_POS_RIGHT) || $PAGE->user_is_editing())) {
|
|
|
|
echo '<td style="width: '.$blocks_preferred_width.'px;" id="right-column">';
|
|
|
|
blocks_print_group($PAGE, $pageblocks, BLOCK_POS_RIGHT);
|
|
|
|
echo '</td>';
|
|
|
|
}
|
|
|
|
echo '</table>';
|
|
|
|
}
|
|
|
|
|
2006-03-29 08:49:28 +00:00
|
|
|
print_footer($course);
|
2006-03-22 08:07:26 +00:00
|
|
|
?>
|