Skip to content

Commit 47761e8

Browse files
committed
Adição de bloco userexpire
Merge branch '8-notificacao-termino-curso' into MOODLE_32_STABLE
2 parents 73c69cf + c613887 commit 47761e8

File tree

6 files changed

+201
-0
lines changed

6 files changed

+201
-0
lines changed

blocks/userexpire/README

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// This file is part of Moodle - http://moodle.org/
2+
//
3+
// Moodle is free software: you can redistribute it and/or modify
4+
// it under the terms of the GNU General Public License as published by
5+
// the Free Software Foundation, either version 3 of the License, or
6+
// (at your option) any later version.
7+
//
8+
// Moodle is distributed in the hope that it will be useful,
9+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
10+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+
// GNU General Public License for more details.
12+
//
13+
// You should have received a copy of the GNU General Public License
14+
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
15+
16+
/**
17+
*
18+
* @package moodlecore
19+
* @subpackage block
20+
* @copyright 2012 Jeff Rader - Sunset Online
21+
* @author 2012 Jeff Rader <[email protected]>
22+
* @version 1.0
23+
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
24+
*/
25+
26+
Features:
27+
28+
This block intends to give the user a few links in order to navigate quickly
29+
through moodle. Besides it advices the user about unread messages and
30+
information about the last access to the LMS.
31+
32+
Installation:
33+
34+
1- Place the userexpire folder (if you have downloaded zipped then you have to unzip
35+
it) into the blocks folder under the root of your Moodle installation.
36+
2- Go to the notifications page and Moodle will automatically install this new
37+
block.
38+
3- Turn Editing on and add the block "User Expire block".
39+
4- That's it. Enjoy it!
40+

blocks/userexpire/README.md

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// This file is part of Moodle - http://moodle.org/
2+
//
3+
// Moodle is free software: you can redistribute it and/or modify
4+
// it under the terms of the GNU General Public License as published by
5+
// the Free Software Foundation, either version 3 of the License, or
6+
// (at your option) any later version.
7+
//
8+
// Moodle is distributed in the hope that it will be useful,
9+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
10+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+
// GNU General Public License for more details.
12+
//
13+
// You should have received a copy of the GNU General Public License
14+
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
15+
16+
/**
17+
*
18+
* @package moodlecore
19+
* @subpackage block
20+
* @copyright 2012 Jeff Rader - Sunset Online
21+
* @author 2012 Jeff Rader <[email protected]>
22+
* @version 1.0
23+
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
24+
*/
25+
26+
Features:
27+
28+
This block intends to give the user a few links in order to navigate quickly
29+
through moodle. Besides it advices the user about unread messages and
30+
information about the last access to the LMS.
31+
32+
Installation:
33+
34+
1- Place the userexpire folder (if you have downloaded zipped then you have to unzip
35+
it) into the blocks folder under the root of your Moodle installation.
36+
2- Go to the notifications page and Moodle will automatically install this new
37+
block.
38+
3- Turn Editing on and add the block "User Expire block".
39+
4- That's it. Enjoy it!
40+
+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
<?php //$Id: block_userexpire.php,v 1.0 2016-02-22 22:00:00 jrader Exp $
2+
3+
// This file is part of Moodle - http://moodle.org/
4+
//
5+
// Moodle is free software: you can redistribute it and/or modify
6+
// it under the terms of the GNU General Public License as published by
7+
// the Free Software Foundation, either version 3 of the License, or
8+
// (at your option) any later version.
9+
//
10+
// Moodle is distributed in the hope that it will be useful,
11+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
// GNU General Public License for more details.
14+
//
15+
// You should have received a copy of the GNU General Public License
16+
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
17+
18+
/**
19+
*
20+
* @package moodlecore
21+
* @subpackage block
22+
* @copyright 2012 Jeff Rader - Sunset Online
23+
* @author 2012 Jeff Rader <[email protected]>
24+
* @version 1.0
25+
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
26+
*/
27+
28+
class block_userexpire extends block_base {
29+
30+
function init() {
31+
$this->title = get_string('pluginname','block_userexpire');
32+
}
33+
34+
function get_content() {
35+
global $CFG, $OUTPUT, $USER, $course, $DB;
36+
37+
require_once($CFG->dirroot.'/message/lib.php');
38+
39+
if ($this->content !== NULL) {
40+
return $this->content;
41+
}
42+
43+
$this->content = new stdClass;
44+
$this->content->text = '';
45+
46+
if (isloggedin() && is_object($course)) {
47+
if ($course->id != SITEID) {
48+
$sql = 'SELECT ue.id, ue.timestart, ue.timeend
49+
FROM mdl_user_enrolments ue
50+
JOIN mdl_enrol e on ue.enrolid = e.id
51+
WHERE ue.userid = ? AND e.courseid = ?';
52+
53+
$records = $DB->get_records_sql($sql, array($USER->id, $course->id));
54+
$student = reset($records);
55+
if (isset($student->timeend) && $student->timeend>0) {
56+
$this->title = get_string('expiretitle', 'block_userexpire');
57+
$this->content->text .= get_string('expirelabel', 'block_userexpire').": ".date(get_string('strftimedate', 'block_userexpire'),$student->timeend);
58+
$this->content->text .= " (".floor(($student->timeend - time())/(24*60*60))." ".get_string('expireday', 'block_userexpire').", ".
59+
floor((($student->timeend - time())%(24*60*60))/3600)." ".get_string('expirehours', 'block_userexpire').")";
60+
} else {
61+
$this->title = get_string('enrolltitle', 'block_userexpire');
62+
$link = new moodle_url('/enrol/index.php', array('id' => $course->id));
63+
$this->content->text .= '<a href="'.$link->out().'">'.get_string('enrolltext', 'block_userexpire').'</a>';
64+
}
65+
}
66+
}
67+
68+
$this->content->footer = '';
69+
return $this->content;
70+
}
71+
72+
}
73+
?>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
$string['pluginname'] = 'User Expire block';
4+
$string['userinfo'] = 'User Expire Information';
5+
$string['strftimedate'] = 'F j, Y';//'l jS \of F j, Y h:i:s A';
6+
$string['expirelabel'] = 'Enrollment Expires';
7+
$string['expiretitle'] = 'Your Enrollment';
8+
$string['expireday'] = 'days';
9+
$string['expirehours'] = 'hours';
10+
$string['enrolltitle'] = "Enroll in this Course";
11+
$string['enrolltext'] = "Enroll me in this course";
12+
?>

blocks/userexpire/styles.css

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.block .content .userexpireblock{
2+
margin:auto;
3+
text-align: center;
4+
}

blocks/userexpire/version.php

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
// This file is part of Moodle - http://moodle.org/
4+
//
5+
// Moodle is free software: you can redistribute it and/or modify
6+
// it under the terms of the GNU General Public License as published by
7+
// the Free Software Foundation, either version 3 of the License, or
8+
// (at your option) any later version.
9+
//
10+
// Moodle is distributed in the hope that it will be useful,
11+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
// GNU General Public License for more details.
14+
//
15+
// You should have received a copy of the GNU General Public License
16+
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
17+
18+
/**
19+
*
20+
* @package moodlecore
21+
* @subpackage block
22+
* @copyright 2012 Jeff Rader - Sunset Online
23+
* @author 2012 Jeff Rader <[email protected]>
24+
* @version 1.0
25+
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
26+
*/
27+
28+
$plugin->version = 2015022200;
29+
$plugin->release = '1.0';
30+
$plugin->requires = 2011033010.00;
31+
$plugin->component = "block_userexpire";
32+
$plugin->maturity = MATURITY_STABLE;

0 commit comments

Comments
 (0)