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');
|
|
|
|
require_login();
|
|
|
|
|
|
|
|
$id = optional_param('id', 0, PARAM_INT); // course module id
|
|
|
|
$d = optional_param('d', 0, PARAM_INT); // database id
|
|
|
|
$search = optional_param('search','',PARAM_NOTAGS); //search string
|
|
|
|
$page = optional_param('page', 0, PARAM_INT); //offset of the current record
|
|
|
|
$rid = optional_param('rid', 0, PARAM_INT); //record id
|
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
|
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
|
|
|
$perpagemenu = optional_param('perpage1', 0, PARAM_INT); //value from drop down
|
2006-02-03 08:11:36 +00:00
|
|
|
$sort = optional_param('sort',0,PARAM_INT); //sort by field
|
|
|
|
$order = optional_param('order','ASC',PARAM_ALPHA); //sort order
|
2006-02-06 06:13:34 +00:00
|
|
|
$group = optional_param('group','0',PARAM_INT); //groupid
|
2006-02-03 08:11:36 +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');
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
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');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//set user preference if available
|
2006-03-26 05:03:10 +00:00
|
|
|
if (isset($_GET['updatepref'])){
|
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 (!$perpage = $perpagemenu){ //if menu not in use, use the text field
|
|
|
|
$perpage = (int)optional_param('perpage',10);
|
|
|
|
}
|
|
|
|
$perpage = ($perpage <= 0) ? 10 : $perpage ;
|
|
|
|
set_user_preference('data_perpage', $perpage);
|
|
|
|
}
|
|
|
|
|
|
|
|
$d = $data->id;//set this so tabs can work properly
|
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-03 08:06:50 +00:00
|
|
|
/// RSS meta
|
|
|
|
$rssmeta = '';
|
|
|
|
if (isset($CFG->enablerssfeeds) && isset($CFG->data_enablerssfeeds) && $data->rssarticles > 0) {
|
|
|
|
$rsspath = rss_get_url($course->id, $USER->id, 'data', $data->id);
|
|
|
|
$rssmeta = '<link rel="alternate" type="application/rss+xml" ';
|
|
|
|
$rssmeta .= 'title ="'.$course->shortname.': %fullname%" href="'.$rsspath.'" />';
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Print the page header
|
2006-03-03 08:30:36 +00:00
|
|
|
$PAGE->print_header($course->shortname.': %fullname%', '', $rssmeta);
|
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
|
|
|
echo '<table id="layout-table"><tr>';
|
|
|
|
|
|
|
|
if(!empty($CFG->showblocksonmodpages) && (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">';
|
|
|
|
|
|
|
|
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?
|
|
|
|
if (isset($CFG->enablerssfeeds) && isset($CFG->data_enablerssfeeds) && $data->rssarticles > 0) {
|
|
|
|
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-02-06 04:17:30 +00:00
|
|
|
if ($data->intro) {
|
|
|
|
print_simple_box(format_text($data->intro), 'center', '70%', '', 5, 'generalbox', 'intro');
|
|
|
|
echo '<br />';
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($currentgroup) {
|
2006-02-06 06:30:18 +00:00
|
|
|
$groupselect = " AND (r.groupid = '$currentgroup' OR r.groupid = 0)";
|
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
|
|
|
$groupparam = "&groupid=$currentgroup";
|
|
|
|
} else {
|
|
|
|
$groupselect = "";
|
|
|
|
$groupparam = "";
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Print the tabs
|
|
|
|
|
|
|
|
$currenttab = 'browse';
|
|
|
|
include('tabs.php');
|
|
|
|
|
2006-03-26 05:22:16 +00:00
|
|
|
$perpage = get_user_preferences('data_perpage', 10); //get default per page
|
|
|
|
|
2006-03-26 05:03:10 +00:00
|
|
|
/// Approve any requested records
|
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:03:10 +00:00
|
|
|
if ($approve && confirm_sesskey() && isteacher($course->id)) {
|
|
|
|
if ($record = get_record('data_records', 'id', $approve)) { // Need to check this is valid
|
|
|
|
if ($record->dataid == $data->id) { // Must be from this database
|
|
|
|
$newrecord->id = $record->id;
|
|
|
|
$newrecord->approved = 1;
|
|
|
|
if (update_record('data_records', $newrecord)) {
|
|
|
|
notify(get_string('recordapproved','data'), 'notifysuccess');
|
|
|
|
}
|
2006-03-26 05:22:16 +00:00
|
|
|
if ($perpage == 1) {
|
|
|
|
$rid = $approve;
|
|
|
|
}
|
2006-03-26 05:03:10 +00:00
|
|
|
}
|
|
|
|
}
|
2006-02-03 08:11:36 +00:00
|
|
|
}
|
2006-03-22 08:32:54 +00:00
|
|
|
|
2006-03-26 05:03:10 +00:00
|
|
|
/// Delete any requested records
|
|
|
|
|
|
|
|
if ($delete && confirm_sesskey()) {
|
2006-03-26 05:22:16 +00:00
|
|
|
if (isteacher($course->id) or data_isowner($delete)){
|
2006-03-22 14:31:32 +00:00
|
|
|
if ($confirm = optional_param('confirm',0,PARAM_INT)) {
|
|
|
|
if ($contents = get_records('data_content','recordid', $delete)) {
|
|
|
|
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-22 14:31:32 +00:00
|
|
|
}
|
|
|
|
delete_records('data_content','recordid',$delete);
|
|
|
|
delete_records('data_records','id',$delete);
|
2006-03-07 08:10:40 +00:00
|
|
|
|
2006-03-22 14:31:32 +00:00
|
|
|
add_to_log($course->id, 'data', 'record delete', "view.php?id=$cm->id", $data->id, $cm->id);
|
2006-03-07 08:10:40 +00:00
|
|
|
|
2006-03-26 05:22:16 +00:00
|
|
|
notify(get_string('recorddeleted','data'), 'notifysuccess');
|
|
|
|
|
|
|
|
if ($perpage == 1) {
|
|
|
|
$rid = $delete;
|
|
|
|
}
|
2006-03-22 14:31:32 +00:00
|
|
|
|
|
|
|
} else { // Print a confirmation page
|
|
|
|
notice_yesno(get_string('confirmdeleterecord','data'),
|
|
|
|
'view.php?d='.$data->id.'&delete='.$delete.'&confirm=1&sesskey='.sesskey(),
|
|
|
|
'view.php?d='.$data->id);
|
|
|
|
|
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-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-26 05:22:16 +00:00
|
|
|
if ($rid) { //set per page to 1, if looking for 1 specific record
|
2006-03-22 08:07:26 +00:00
|
|
|
set_user_preference('data_perpage', DATA_PERPAGE_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-10 09:08:59 +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
|
|
|
/*****************************
|
|
|
|
* Setting up page variables *
|
|
|
|
*****************************/
|
|
|
|
|
|
|
|
$perpage = get_user_preferences('data_perpage', 10); //get default per page
|
|
|
|
|
2006-02-06 06:13:34 +00:00
|
|
|
$baseurl = 'view.php?d='.$data->id.'&search='.s($search).'&sort='.s($sort).'&order='.s($order).'&group='.$currentgroup.'&';
|
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-02-03 08:11:36 +00:00
|
|
|
//if database requires approval, then we need to do some work
|
|
|
|
//and get those approved entries, or entries belongs to owner
|
|
|
|
if ((!isteacher($course->id)) && ($data->approval)){
|
|
|
|
$approvesql = ' AND (r.approved=1 OR r.userid='.$USER->id.') ';
|
|
|
|
} else {
|
|
|
|
$approvesql = '';
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($rid){ //only used for single mode, but rid should not appear in multi view anyway
|
|
|
|
$ridsql = 'AND r.id < '.$rid.' ';
|
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-02-03 08:11:36 +00:00
|
|
|
} else {
|
|
|
|
$ridsql = '';
|
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-02-03 08:11:36 +00:00
|
|
|
if ($sort) { //supports (sort and search)
|
|
|
|
//first find the field that we are sorting
|
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();
|
|
|
|
///SEARCH AND SORT SQL
|
|
|
|
$sql = 'SELECT DISTINCT c.recordid, c.recordid
|
|
|
|
FROM '.$CFG->prefix.'data_content c, '
|
|
|
|
.$CFG->prefix.'data_records r, '
|
|
|
|
.$CFG->prefix.'data_content c1
|
|
|
|
WHERE c.recordid = r.id
|
|
|
|
AND c1.recordid = r.id
|
|
|
|
AND r.dataid = '.$data->id.'
|
2006-02-06 06:13:34 +00:00
|
|
|
AND c.fieldid = '.$sort.' '.$groupselect.'
|
2006-02-03 08:11:36 +00:00
|
|
|
AND ((c1.content LIKE "%'.$search.'%") OR
|
|
|
|
(c1.content1 LIKE "%'.$search.'%") OR
|
|
|
|
(c1.content2 LIKE "%'.$search.'%") OR
|
|
|
|
(c1.content3 LIKE "%'.$search.'%") OR
|
|
|
|
(c1.content4 LIKE "%'.$search.'%")) '.$approvesql.'
|
|
|
|
ORDER BY c.'.$sortcontent.' '.$order.' ';
|
|
|
|
|
|
|
|
$sqlcount = 'SELECT COUNT(DISTINCT c.recordid)
|
|
|
|
FROM '.$CFG->prefix.'data_content c, '
|
|
|
|
.$CFG->prefix.'data_records r, '
|
|
|
|
.$CFG->prefix.'data_content c1
|
|
|
|
WHERE c.recordid = r.id
|
|
|
|
AND c1.recordid = r.id
|
|
|
|
AND r.dataid = '.$data->id.'
|
2006-02-06 06:13:34 +00:00
|
|
|
AND c.fieldid = '.$sort.' '.$groupselect.'
|
2006-02-03 08:11:36 +00:00
|
|
|
AND ((c1.content LIKE "%'.$search.'%") OR
|
|
|
|
(c1.content1 LIKE "%'.$search.'%") OR
|
|
|
|
(c1.content2 LIKE "%'.$search.'%") OR
|
|
|
|
(c1.content3 LIKE "%'.$search.'%") OR
|
|
|
|
(c1.content4 LIKE "%'.$search.'%")) '.$approvesql.'
|
|
|
|
ORDER BY c.'.$sortcontent.' '.$order.' ';
|
|
|
|
|
|
|
|
//sqlindex is used to find the number of entries smaller than the current rid
|
|
|
|
//useful for zooming into single view from multi view (so we can keep track
|
|
|
|
//of exact and relative position of records
|
|
|
|
$sqlindex = 'SELECT COUNT(DISTINCT c.recordid)
|
|
|
|
FROM '.$CFG->prefix.'data_content c, '
|
|
|
|
.$CFG->prefix.'data_records r, '
|
|
|
|
.$CFG->prefix.'data_content c1
|
|
|
|
WHERE c.recordid = r.id
|
|
|
|
AND c1.recordid = r.id
|
|
|
|
AND r.dataid = '.$data->id.'
|
2006-02-06 06:13:34 +00:00
|
|
|
AND c.fieldid = '.$sort.' '.$ridsql.' '.$groupselect.'
|
2006-02-03 08:11:36 +00:00
|
|
|
AND ((c1.content LIKE "%'.$search.'%") OR
|
|
|
|
(c1.content1 LIKE "%'.$search.'%") OR
|
|
|
|
(c1.content2 LIKE "%'.$search.'%") OR
|
|
|
|
(c1.content3 LIKE "%'.$search.'%") OR
|
|
|
|
(c1.content4 LIKE "%'.$search.'%")) '.$approvesql.'
|
|
|
|
ORDER BY c.'.$sortcontent.' '.$order.' ';
|
|
|
|
|
|
|
|
} else if ($search){ //search only, no sort. if in search mode, only search text fields
|
|
|
|
|
|
|
|
$sql = 'SELECT DISTINCT c.recordid, c.recordid
|
|
|
|
FROM '.$CFG->prefix.'data_content c, '
|
|
|
|
.$CFG->prefix.'data_fields f, '
|
|
|
|
.$CFG->prefix.'data_records r
|
2006-02-06 06:13:34 +00:00
|
|
|
WHERE c.recordid = r.id '.$groupselect.' '.$approvesql.' AND
|
2006-02-03 08:11:36 +00:00
|
|
|
c.fieldid = f.id AND f.dataid = '
|
2006-02-03 10:53:00 +00:00
|
|
|
.$data->id.' AND c.content LIKE "%'.$search.'%" ORDER BY r.id '.$order.' ';
|
2006-02-03 08:11:36 +00:00
|
|
|
|
|
|
|
$sqlcount = 'SELECT COUNT(DISTINCT c.recordid)
|
|
|
|
FROM '.$CFG->prefix.'data_content c, '
|
|
|
|
.$CFG->prefix.'data_fields f, '
|
|
|
|
.$CFG->prefix.'data_records r
|
2006-02-06 06:13:34 +00:00
|
|
|
WHERE c.recordid = r.id '.$groupselect.' '.$approvesql.' AND
|
2006-02-03 08:11:36 +00:00
|
|
|
c.fieldid = f.id AND f.dataid = '
|
2006-02-03 10:53:00 +00:00
|
|
|
.$data->id.' AND c.content LIKE "%'.$search.'%" ORDER BY r.id '.$order.' ';
|
2006-02-03 08:11:36 +00:00
|
|
|
|
|
|
|
$sqlindex = 'SELECT COUNT(DISTINCT c.recordid)
|
|
|
|
FROM '.$CFG->prefix.'data_content c, '
|
|
|
|
.$CFG->prefix.'data_fields f, '
|
|
|
|
.$CFG->prefix.'data_records r
|
2006-02-06 06:13:34 +00:00
|
|
|
WHERE c.recordid = r.id '.$groupselect.' '.$approvesql.' AND
|
2006-02-03 08:11:36 +00:00
|
|
|
c.fieldid = f.id AND f.dataid = '
|
2006-02-03 10:53:00 +00:00
|
|
|
.$data->id.' '.$ridsql.' AND c.content LIKE "%'.$search.'%" ORDER BY r.id '.$order.' ';
|
2006-02-03 08:11:36 +00:00
|
|
|
|
|
|
|
} else { //else get everything, no search, no sort
|
|
|
|
|
2006-02-06 06:13:34 +00:00
|
|
|
$sql = 'SELECT * FROM '.$CFG->prefix.'data_records r WHERE r.dataid ='.$data->id.' '.$groupselect.' '.$approvesql.' ORDER BY r.id '.$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
|
|
|
$sqlcount = 'SELECT COUNT(*) FROM '.$CFG->prefix
|
2006-02-06 06:13:34 +00:00
|
|
|
.'data_records r WHERE r.dataid ='.$data->id.' '.$groupselect.' '.$approvesql.'ORDER BY r.id '.$order.' ';
|
2006-02-03 08:11:36 +00:00
|
|
|
|
|
|
|
$sqlindex = 'SELECT COUNT(*) FROM '.$CFG->prefix
|
2006-02-06 06:13:34 +00:00
|
|
|
.'data_records r WHERE r.dataid ='.$data->id.' '.$groupselect.' '.$ridsql.' '.$approvesql .'ORDER BY r.id '.$order.' ';
|
2006-02-03 08:11:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ($rid) { //this is used in zooming
|
|
|
|
$page = count_records_sql($sqlindex);
|
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
|
|
|
}
|
|
|
|
|
|
|
|
$limit = $perpage > 1 ? sql_paging_limit($page * $perpage, $perpage)
|
2006-03-22 08:07:26 +00:00
|
|
|
: $limit = sql_paging_limit($page, DATA_PERPAGE_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
|
|
|
|
|
|
|
$sql = $sql . $limit;
|
2006-02-03 08:11:36 +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
|
|
|
$totalcount = count_records_sql($sqlcount);
|
|
|
|
|
|
|
|
if (!$records = get_records_sql($sql)){
|
|
|
|
if ($search){
|
|
|
|
notify(get_string('nomatch','data'));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
notify(get_string('norecords','data'));
|
|
|
|
}
|
|
|
|
|
|
|
|
data_print_preference_form($data, $perpage, $search);
|
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-02-03 08:11:36 +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
|
|
|
//print header for multi view
|
|
|
|
if ($perpage > 1){
|
|
|
|
|
|
|
|
echo $data->listtemplateheader;
|
|
|
|
$listmode = 'listtemplate';
|
|
|
|
if (empty($data->listtemplate)){
|
|
|
|
notify(get_string('nolisttemplate','data'));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$listmode = 'singletemplate';
|
|
|
|
if (empty($data->singletemplate)){
|
|
|
|
notify(get_string('nosingletemplate','data'));
|
|
|
|
}
|
|
|
|
}
|
2005-12-05 08:56:48 +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
|
|
|
print_paging_bar($totalcount, $page, $perpage, $baseurl, $pagevar='page');
|
|
|
|
|
|
|
|
//for each record we find, we do a string replacement for tags.
|
2006-02-06 06:13:34 +00:00
|
|
|
data_print_template($records, $data, $search, $listmode, $sort, $page, $rid, $order, $currentgroup);
|
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_paging_bar($totalcount, $page, $perpage, $baseurl, $pagevar='page');
|
|
|
|
|
|
|
|
if ($perpage > 1){
|
|
|
|
echo $data->listtemplatefooter; //print footer
|
|
|
|
}
|
|
|
|
|
2006-02-03 08:11:36 +00:00
|
|
|
data_print_preference_form($data, $perpage, $search, $sort, $order);
|
2006-02-20 02:15:45 +00:00
|
|
|
|
|
|
|
// Finish the page
|
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
|
|
|
echo '</td></tr></table>';
|
2006-02-20 02:15:45 +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
|
|
|
print_footer($course);
|
|
|
|
|
2006-03-22 08:07:26 +00:00
|
|
|
?>
|