First (unfinished) implementation view.php - redirect to manage.php
authorArtem Andreev <andreev.artem@gmail.com>
Sat, 23 Apr 2011 13:25:43 +0000 (17:25 +0400)
committerArtem Andreev <andreev.artem@gmail.com>
Sat, 23 Apr 2011 13:25:43 +0000 (17:25 +0400)
view.php [new file with mode: 0644]

diff --git a/view.php b/view.php
new file mode 100644 (file)
index 0000000..e6fbd79
--- /dev/null
+++ b/view.php
@@ -0,0 +1,56 @@
+<?php
+
+/**
+ * Prints attendance info for particular user
+ *
+ * @package    mod
+ * @subpackage attforblock
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+
+require_once(dirname(__FILE__).'/../../config.php');
+require_once(dirname(__FILE__).'/locallib.php');
+
+$id         = optional_param('id', 0, PARAM_INT);   // Course Module ID, or
+$a          = optional_param('a', 0, PARAM_INT);    // attforblock instance ID
+$studentid     = optional_param('student', 0, PARAM_INT);
+$printing      = optional_param('printing', 0, PARAM_INT);
+$mode          = optional_param('mode', 'thiscourse', PARAM_ALPHA);
+$view       = optional_param('view', NULL, PARAM_INT);        // which page to show
+$current       = optional_param('current', 0, PARAM_INT);
+
+if ($id) {
+    $cm             = get_coursemodule_from_id('attforblock', $id, 0, false, MUST_EXIST);
+    $course         = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
+    $attforblock    = $DB->get_record('attforblock', array('id' => $cm->instance), '*', MUST_EXIST);
+} else {
+    $attforblock    = $DB->get_record('attforblock', array('id' => $a), '*', MUST_EXIST);
+    $course         = $DB->get_record('course', array('id' => $workshop->course), '*', MUST_EXIST);
+    $cm             = get_coursemodule_from_instance('attforblock', $attforblock->id, $course->id, false, MUST_EXIST);
+}
+
+require_login($course, true, $cm);
+
+// Not specified studentid for displaying attendance?
+// Redirect to appropriate page if can
+if (!$studentid) {
+    if (has_capability('mod/attforblock:manageattendances', $PAGE->context) ||
+                    has_capability('mod/attforblock:takeattendances', $PAGE->context) ||
+                    has_capability('mod/attforblock:changeattendances', $PAGE->context)) {
+        redirect("manage.php?id=$cm->id");
+    }
+    elseif (has_capability('mod/attforblock:viewreports', $PAGE->context)) {
+        redirect("report.php?id=$cm->id");
+    }
+}
+
+if ($view)
+    set_current_view($course->id, $_GET['view']);
+else
+    $view = get_current_view($course->id, 'months');
+
+require_capability('mod/attforblock:view', $PAGE->context);
+
+
+?>