Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

removed

  • Loading branch information...
commit fc9c255cb8681fd4c2c8d4bf6c290b34fbfa417b 1 parent 66a00a0
jpuntd authored
124 blocks/glossary_random/block_glossary_random.php
... ... @@ -1,124 +0,0 @@
1   -<?PHP
2   -define("RANDOMLY", "0");
3   -define("LASTMODIFIED", "1");
4   -define("NEXTONE","2");
5   -
6   -class CourseBlock_glossary_random extends MoodleBlock {
7   - function CourseBlock_glossary_random ($course) {
8   -
9   - $this->title = get_string('blockname','block_glossary_random');
10   - $this->content_type = BLOCK_TYPE_TEXT;
11   - $this->course = $course;
12   - $this->version = 2004100700;
13   - if(!empty($course)) {
14   - if ($prefs=get_record("block_glossary_random","course",$course->id)) {
15   - $this->title = $prefs->title;
16   - }
17   - }
18   - }
19   - function get_content() {
20   - global $USER, $CFG, $THEME;
21   -
22   - if($this->content !== NULL) {
23   - return $this->content;
24   - }
25   -
26   -
27   - $this->content = New object;
28   - $this->content->text = '';
29   - $this->content->footer = '';
30   -
31   - if ($prefs=get_record("block_glossary_random","course",$this->course->id)) {
32   -
33   - $glossaryid = $prefs->glossary;
34   - $glossary=get_record("glossary", "id", $glossaryid);
35   - $studentcanpost = $glossary->studentcanpost; //needed to decide on which footer
36   -
37   - //check if it's time to put a new entry in cache
38   - if (time() > $prefs->nexttime)
39   - {
40   - // place glossary concept and definition in $pref->cache
41   - $numberofentries = count_records("glossary_entries","glossaryid",$glossaryid,"approved",1)-1;
42   - switch ($prefs->type) {
43   - case RANDOMLY:
44   - $i = rand(0,$numberofentries);
45   - break;
46   - case NEXTONE:
47   - $i = 1 + $prefs->previous;
48   - if ($i < $numberofentries) {
49   - break;
50   - }
51   - //otherwise fall through
52   - case LASTMODIFIED:
53   - $i=$numberofentries;
54   - break;
55   -
56   - }
57   -
58   - if ($entries = get_records_sql("SELECT concept, definition, format
59   - FROM {$CFG->prefix}glossary_entries
60   - WHERE glossaryid = {$glossaryid} and approved = 1
61   - ORDER BY timemodified LIMIT {$i},1")) {
62   -
63   - foreach ($entries as $entry) { //normally only on entry
64   - $text = "<b> $entry->concept</b><br>";
65   - $text .= clean_text($entry->definition, $entry->format);
66   - }
67   -
68   -
69   - $prefs->nexttime = usergetmidnight(time())+60*60*24*$prefs->refresh;
70   - $prefs->cache = addslashes($text);
71   - $prefs->previous = $i;
72   - if (!(update_record("block_glossary_random", $prefs))) {
73   - error("Could not update the database");
74   - }
75   - } else {
76   - $text = get_string('notyetconfigured','block_glossary_random');
77   - }
78   - }
79   -
80   - //otherwise just return the cached text
81   - $this->content->text = stripslashes($prefs->cache);
82   -
83   - // place link to glossary in the footer if the glossary is visible
84   -
85   - //Create a temp valid module structure (course,id)
86   - $tempmod->course = $this->course->id;
87   - $tempmod->id = $glossaryid;
88   -
89   - //Obtain the visible property from the instance
90   - if (instance_is_visible('glossary', $tempmod)) {
91   -
92   - $cm = get_coursemodule_from_instance('glossary',$glossaryid, $this->course->id) ;
93   - if ($studentcanpost) {
94   - $footertext = $prefs->addentry;
95   - } else {
96   - $footertext = $prefs->viewglossary;
97   - }
98   - $this->content->footer = '<a href="'.$CFG->wwwroot.'/mod/glossary/'
99   - .(($studentcanpost == 1)?'edit':'view').'.php?id='.$cm->id
100   - .'" title="'.$footertext.'">'.$footertext.'</a>';
101   -
102   - // otherwise just place some text, no link
103   - } else {
104   - $this->content->footer = $prefs->invisible;
105   - }
106   -
107   -
108   - } else { //nothing in the database, this block needs configuration
109   - $this->content->text = get_string("notyetconfigured","block_glossary_random");
110   - }
111   -
112   - if (isteacheredit($this->course->id)) { //add the option to configure this block
113   - $this->content->footer .= '<br><a href="'
114   - .$CFG->wwwroot."/blocks/glossary_random/prefs.php?id="
115   - .$this->course->id."\">"
116   - .get_string("configureblock","block_glossary_random")."</a>";
117   - }
118   -
119   - return $this->content;
120   - }
121   -
122   -
123   - }
124   -?>
33 blocks/glossary_random/db/mysql.php
... ... @@ -1,33 +0,0 @@
1   -<?PHP
2   -//
3   -// This file keeps track of upgrades to Moodle's
4   -// blocks system.
5   -//
6   -// Sometimes, changes between versions involve
7   -// alterations to database structures and other
8   -// major things that may break installations.
9   -//
10   -// The upgrade function in this file will attempt
11   -// to perform all the necessary actions to upgrade
12   -// your older installtion to the current version.
13   -//
14   -// If there's something it cannot do itself, it
15   -// will tell you what you need to do.
16   -//
17   -// Versions are defined by backup_version.php
18   -//
19   -// This file is tailored to MySQL
20   -
21   -function glossary_random_upgrade($oldversion=0) {
22   -
23   - global $CFG;
24   -
25   - $result = true;
26   -
27   - if ($oldversion < 2004041000 and $result) {
28   - $result = true; //Nothing to do
29   - }
30   -
31   - //Finally, return result
32   - return $result;
33   -}
20 blocks/glossary_random/db/mysql.sql
... ... @@ -1,20 +0,0 @@
1   -#
2   -# Table structure for table `block_glossary_random`
3   -#
4   -
5   -CREATE TABLE prefix_block_glossary_random (
6   - id int(10) unsigned NOT NULL auto_increment,
7   - course int(10) unsigned NOT NULL default '0',
8   - title varchar(50) default NULL,
9   - glossary int(10) unsigned NOT NULL default '0',
10   - previous int(10) unsigned NOT NULL default '0',
11   - type tinyint(4) NOT NULL default '0',
12   - addentry varchar(255) default NULL,
13   - viewglossary varchar(255) default NULL,
14   - invisible varchar(255) default NULL,
15   - cache text NOT NULL,
16   - refresh int(10) unsigned NOT NULL default'0',
17   - nexttime int(10) unsigned NOT NULL default '0',
18   - PRIMARY KEY (id),
19   - UNIQUE KEY id (id)
20   -) TYPE=MyISAM;
45 blocks/glossary_random/prefs.html
... ... @@ -1,45 +0,0 @@
1   -<table cellpadding="20" width=75% align="center"> <tr> <td bgcolor="<?php p($THEME->cellcontent2) ?>" class="generalbox">
2   -
3   -<form action="prefs.php" method="post" name="form" id="form">
4   -<p><b><?php print_string("intro","block_glossary_random") ?>:</b></p>
5   -
6   -<table>
7   -<tr valign=top>
8   -<td align=right><p><?php print_string("title","block_glossary_random") ?>:</p></td>
9   -<td><input type="text" name="title" size="50" value="<?php p($prefs->title) ?>" /></td>
10   -</tr>
11   -
12   -<tr valign=top>
13   -<td align=right><p><?php print_string("select_glossary","block_glossary_random") ?>:</p></td>
14   -<td><?php choose_from_menu($glossaries,"glossary",$prefs->glossary) ?></td>
15   -</tr>
16   -
17   -<tr valign=top>
18   -<td align=right><p><?php print_string("refresh","block_glossary_random") ?>:</p></td>
19   -<td><input type="text" name="refresh" size="5" value="<?php p($prefs->refresh) ?>" /></td>
20   -</tr>
21   -
22   -<tr valign=top>
23   -<td align=right><p><?php print_string("type","block_glossary_random") ?>:</p></td>
24   -<td><?php
25   - choose_from_menu($type, "type", $prefs->type, "");
26   - helpbutton("",get_string("type","block_glossary_random"),"moodle",true,false,get_string("typehelp","block_glossary_random"));
27   - ?></td>
28   -</tr>
29   -</table>
30   -
31   - <p><b><?php print_string("aboutfooter","block_glossary_random") ?>:</b></p>
32   - <p><?php print_string("askaddentry", "block_glossary_random") ?></p>
33   - <input type="text" name="addentry" size="80" value="<?php p($prefs->addentry) ?>" /><br />
34   -<p><?php print_string("askviewglossary", "block_glossary_random") ?></p>
35   - <input type="text" name="viewglossary" size="80" value="<?php p($prefs->viewglossary) ?>" /><br />
36   - <p><?php print_string("askinvisible", "block_glossary_random") ?></p>
37   - <input type="text" name="invisible" size="80" value="<?php p($prefs->invisible) ?>" /><br />
38   -
39   -<input type="hidden" name=course value="<?php p($course) ?>">
40   -<input type="hidden" name=id value="<?php p($prefs->id) ?>">
41   -
42   -<br /><center><input type="submit" value="<?php print_string("savechanges") ?>"></center>
43   -</form>
44   -
45   -</td></tr></table>
71 blocks/glossary_random/prefs.php
... ... @@ -1,71 +0,0 @@
1   -<?PHP
2   -
3   - require_once("../../config.php");
4   - require_variable($id);
5   - $course = $id;// is there another way of getting the course id?
6   - require_login($course);
7   - if (!(isteacheredit($course))) {
8   - error("You're not allowed to edit this course");
9   - }
10   -
11   - // process data
12   -
13   - if ($prefs = data_submitted()) {
14   - validate_form($prefs, $err); //might add this later
15   - if (count((array)$err) == 0) {
16   - $prefs->nexttime = usergetmidnight(time())+24*60*60*$prefs->refresh;
17   - if (!(update_record("block_glossary_random", $prefs))) {
18   - error("Could not update record in the database.");
19   - }
20   - redirect("$CFG->wwwroot/course/view.php?id=$prefs->course");
21   - }
22   - }
23   -
24   - // print form
25   -
26   - if (!empty($err)) {
27   - $focus = "form.".array_shift(array_flip(get_object_vars($err)));
28   - } else {
29   - $focus = "";
30   - }
31   -
32   - $prefs = get_record("block_glossary_random", "course", $course);
33   - if (!$prefs) {
34   - $prefs->course = $course;
35   - $prefs->title = get_string('blockname','block_glossary_random');
36   - $prefs->refresh = 0;
37   - $prefs->text= get_string("notyetconfigured","block_glossary_random");
38   - $prefs->addentry=get_string("addentry", "block_glossary_random");
39   - $prefs->viewglossary=get_string("viewglossary", "block_glossary_random");
40   - $prefs->invisible=get_string("invisible", "block_glossary_random");
41   -
42   - if (!(insert_record("block_glossary_random",$prefs))) {
43   - error("Could not insert new record in database");
44   - }
45   - }
46   -
47   - // select glossaries to put in dropdown box ...
48   -
49   - $glossaries = get_records_select_menu("glossary", "course= $course","name","id,name");
50   - // and quotetypes to put in dropdown box
51   -
52   - $type[0] = get_string("random","block_glossary_random");
53   - $type[1] = get_string("lastmodified","block_glossary_random");
54   - $type[2] = get_string("nextone","block_glossary_random");
55   -
56   - print_header(get_string("blockname","block_glossary_random"),
57   - get_string("change_configuration","block_glossary_random"));
58   - include("prefs.html");
59   - print_footer();
60   -
61   -/******************************************************************************
62   - * FUNCTIONS
63   - *****************************************************************************/
64   -
65   -function validate_form($user, &$err) {
66   - //we might add a check for glossary selected
67   - return;
68   -}
69   -
70   -
71   -?>

0 comments on commit fc9c255

Please sign in to comment.
Something went wrong with that request. Please try again.