Code cleanups for excluding notices
authorArtem Andreev <andreev.artem@gmail.com>
Thu, 25 Nov 2010 14:36:50 +0000 (17:36 +0300)
committerArtem Andreev <andreev.artem@gmail.com>
Thu, 25 Nov 2010 14:36:50 +0000 (17:36 +0300)
locallib.php
manage.php
report.php

index f70e78e..ddc1ba9 100644 (file)
@@ -341,7 +341,7 @@ function print_user_attendaces($user, $cm, $attforblock,  $course = 0, $printing
 
 function print_filter_controls($url, $id, $studentid=0, $sort=NULL, $printselector=WITHOUT_SELECTOR) {
 
-    global $SESSION, $current, $view, $cm;
+    global $CFG, $SESSION, $current, $view, $cm;
 
     $date = usergetdate($current);
     $mday = $date['mday'];
@@ -349,7 +349,8 @@ function print_filter_controls($url, $id, $studentid=0, $sort=NULL, $printselect
     $mon = $date['mon'];
     $year = $date['year'];
 
-    $currentdatecontrols = '';
+    $curdatecontrols = '';
+    $curdatetxt = '';
     switch ($view) {
         case 'days':
             $format = get_string('strftimedm', 'attforblock');
@@ -387,6 +388,7 @@ function print_filter_controls($url, $id, $studentid=0, $sort=NULL, $printselect
 
     $link = $url . "?id=$id" . ($sort ? "&amp;sort=$sort" : "") . ($studentid ? "&amp;student=$studentid" : "");
 
+    $currentgroup = -1;
     if ($printselector === GROUP_SELECTOR) {
         $groupmode = groups_get_activity_groupmode($cm);
         $currentgroup = groups_get_activity_group($cm, true);
@@ -394,7 +396,7 @@ function print_filter_controls($url, $id, $studentid=0, $sort=NULL, $printselect
         $context = get_context_instance(CONTEXT_MODULE, $cm->id);
         if ($groupmode == VISIBLEGROUPS ||
                 ($groupmode && has_capability('moodle/site:accessallgroups', $context))) {
-            $groupselector = groups_print_activity_menu($cm, $link, true);
+            $groupselector = groups_print_activity_menu($cm, $CFG->wwwroot . '/mod/attforblock/' . $link, true);
         }
     } elseif ($printselector === SESSION_TYPE_SELECTOR and $groupmode = groups_get_activity_groupmode($cm)) {
         $context = get_context_instance(CONTEXT_MODULE, $cm->id);
@@ -433,12 +435,12 @@ function print_filter_controls($url, $id, $studentid=0, $sort=NULL, $printselect
         }
 
         $group = optional_param('group', -2, PARAM_INT);
+        if (!array_key_exists('attsessiontype', $SESSION)) {
+            $SESSION->attsessiontype = array();
+        }
         if ($group > -2) {
             $SESSION->attsessiontype[$cm->course] = $group;
         } elseif (!array_key_exists($cm->course, $SESSION->attsessiontype)) {
-                       if (!array_key_exists('attsessiontype', $SESSION)) {
-                               $SESSION->attsessiontype = array();
-                       }
             $SESSION->attsessiontype[$cm->course] = -1;
         }
         
index 84af654..d1d9e7a 100644 (file)
 function print_sessions_list($course) {
        global $CFG, $context, $cm, $current, $view, $id;
        
-                       $strhours = get_string('hours');
-                       $strmins = get_string('min');
-                               
-            if ($current == 0)
-                $current = get_current_date($course->id);
-            else
-                set_current_date ($course->id, $current);
+        $strhours = get_string('hours');
+        $strmins = get_string('min');
 
-            list($startdate, $enddate, $currentgroup) =
-                    print_filter_controls("manage.php", $id, 0, NULL, SESSION_TYPE_SELECTOR);
+        if ($current == 0)
+            $current = get_current_date($course->id);
+        else
+            set_current_date ($course->id, $current);
 
-            if ($startdate && $enddate) {
-                $where = "courseid={$course->id} AND sessdate >= $course->startdate AND sessdate >= $startdate AND sessdate < $enddate";
-            } else {
-                $where = "courseid={$course->id} AND sessdate >= $course->startdate";
-            }
+        list($startdate, $enddate, $currentgroup) =
+                print_filter_controls("manage.php", $id, 0, NULL, SESSION_TYPE_SELECTOR);
 
-            if ($currentgroup > -1) {
-                $where .= " AND groupid=$currentgroup";
-            }
+        if ($startdate && $enddate) {
+            $where = "courseid={$course->id} AND sessdate >= $course->startdate AND sessdate >= $startdate AND sessdate < $enddate";
+        } else {
+            $where = "courseid={$course->id} AND sessdate >= $course->startdate";
+        }
+
+        if ($currentgroup > -1) {
+            $where .= " AND groupid=$currentgroup";
+        }
 
-            $qry = get_records_select('attendance_sessions', $where/*"courseid = $course->id AND sessdate >= $course->startdate"*/, 'sessdate asc');
-                       $i = 0;
-                       $table->width = '100%';
-                       //$table->tablealign = 'center';
-                       $table->head = array('#', get_string('sessiontypeshort', 'attforblock'), get_string('date'), get_string('time'), get_string('duration', 'attforblock'), get_string('description','attforblock'), get_string('actions'), get_string('select'));
-                       $table->align = array('', '', '', 'right', 'left', 'center', 'center');
-                       $table->size = array('1px', '', '1px', '1px', '1px', '*', '1px', '1px');
+        $qry = get_records_select('attendance_sessions', $where, 'sessdate asc');
+        $i = 0;
+        $table->width = '100%';
+        //$table->tablealign = 'center';
+        $table->head = array('#', get_string('sessiontypeshort', 'attforblock'), get_string('date'), get_string('time'), get_string('duration', 'attforblock'), get_string('description','attforblock'), get_string('actions'), get_string('select'));
+        $table->align = array('', '', '', 'right', 'left', 'center', 'center');
+        $table->size = array('1px', '', '1px', '1px', '1px', '*', '1px', '1px');
 
-            $allowtake = has_capability('mod/attforblock:takeattendances', $context);
-            $allowchange = has_capability('mod/attforblock:changeattendances', $context);
-            $allowmanage = has_capability('mod/attforblock:manageattendances', $context);
-            $groups = groups_get_all_groups($course->id);
-                       foreach($qry as $key=>$sessdata)
-                       {
-                               $i++;
-                               $actions = '';
+        $allowtake = has_capability('mod/attforblock:takeattendances', $context);
+        $allowchange = has_capability('mod/attforblock:changeattendances', $context);
+        $allowmanage = has_capability('mod/attforblock:manageattendances', $context);
+        $groups = groups_get_all_groups($course->id);
+        if ($qry) {
+            foreach($qry as $key=>$sessdata)
+            {
+                $i++;
+                $actions = '';
 //                             if ($allowtake) {
-                                       if($sessdata->lasttaken > 0)    //attendance has taken
-                                       {
-                                               if ($allowchange) {
+                    if($sessdata->lasttaken > 0)       //attendance has taken
+                    {
+                        if ($allowchange) {
                             $desc = "<a href=\"attendances.php?id=$cm->id&amp;sessionid={$sessdata->id}&amp;grouptype={$sessdata->groupid}\">".
                                     ($sessdata->description ? $sessdata->description : get_string('nodescription', 'attforblock')).
                                     '</a>';
                         } else {
                             $desc = '<i>'.(empty($sessdata->description) ? get_string('nodescription', 'attforblock') : $sessdata->description).'</i>';
                         }
-                                       } else {
-                                               $desc = empty($sessdata->description) ? get_string('nodescription', 'attforblock') : $sessdata->description;
-                                               if ($allowtake) {
+                    } else {
+                        $desc = empty($sessdata->description) ? get_string('nodescription', 'attforblock') : $sessdata->description;
+                        if ($allowtake) {
                             $title = get_string('takeattendance','attforblock');
                             $actions = "<a title=\"$title\" href=\"attendances.php?id=$cm->id&amp;sessionid={$sessdata->id}&amp;grouptype={$sessdata->groupid}\">".
                                        "<img src=\"{$CFG->pixpath}/t/go.gif\" alt=\"$title\" /></a>&nbsp;";
                         }
-                                       }
+                    }
 //                             }
-                               if($allowmanage) {
-                                       $title = get_string('editsession','attforblock');
-                                       $actions .= "<a title=\"$title\" href=\"sessions.php?id=$cm->id&amp;sessionid={$sessdata->id}&amp;action=update\">".
-                                                               "<img src=\"{$CFG->pixpath}/t/edit.gif\" alt=\"$title\" /></a>&nbsp;";
-                                       $title = get_string('deletesession','attforblock');
-                                       $actions .= "<a title=\"$title\" href=\"sessions.php?id=$cm->id&amp;sessionid={$sessdata->id}&amp;action=delete\">".
-                                                               "<img src=\"{$CFG->pixpath}/t/delete.gif\" alt=\"$title\" /></a>&nbsp;";
-                               }
-                               
-                               $table->data[$sessdata->id][] = $i;
-                               $table->data[$sessdata->id][] = $sessdata->groupid ? $groups[$sessdata->groupid]->name : get_string('commonsession', 'attforblock');
-                               $table->data[$sessdata->id][] = userdate($sessdata->sessdate, get_string('strftimedmyw', 'attforblock'));
-                               $table->data[$sessdata->id][] = userdate($sessdata->sessdate, get_string('strftimehm', 'attforblock'));
+                if($allowmanage) {
+                    $title = get_string('editsession','attforblock');
+                    $actions .= "<a title=\"$title\" href=\"sessions.php?id=$cm->id&amp;sessionid={$sessdata->id}&amp;action=update\">".
+                                "<img src=\"{$CFG->pixpath}/t/edit.gif\" alt=\"$title\" /></a>&nbsp;";
+                    $title = get_string('deletesession','attforblock');
+                    $actions .= "<a title=\"$title\" href=\"sessions.php?id=$cm->id&amp;sessionid={$sessdata->id}&amp;action=delete\">".
+                                "<img src=\"{$CFG->pixpath}/t/delete.gif\" alt=\"$title\" /></a>&nbsp;";
+                }
+
+                $table->data[$sessdata->id][] = $i;
+                $table->data[$sessdata->id][] = $sessdata->groupid ? $groups[$sessdata->groupid]->name : get_string('commonsession', 'attforblock');
+                $table->data[$sessdata->id][] = userdate($sessdata->sessdate, get_string('strftimedmyw', 'attforblock'));
+                $table->data[$sessdata->id][] = userdate($sessdata->sessdate, get_string('strftimehm', 'attforblock'));
                 $hours = floor($sessdata->duration / HOURSECS);
                 $mins = floor(($sessdata->duration - $hours * HOURSECS) / MINSECS);
                 $mins = $mins < 10 ? "0$mins" : "$mins";
-                               $table->data[$sessdata->id][] = $hours ? "{$hours}&nbsp;{$strhours}&nbsp;{$mins}&nbsp;{$strmins}" : "{$mins}&nbsp;{$strmins}";
-                               $table->data[$sessdata->id][] = $desc;
-                               $table->data[$sessdata->id][] = $actions;
-                               $table->data[$sessdata->id][] = '<input type="checkbox" name="sessid['.$sessdata->id.']" />';
-                               unset($desc, $actions);
-                       }
+                $table->data[$sessdata->id][] = $hours ? "{$hours}&nbsp;{$strhours}&nbsp;{$mins}&nbsp;{$strmins}" : "{$mins}&nbsp;{$strmins}";
+                $table->data[$sessdata->id][] = $desc;
+                $table->data[$sessdata->id][] = $actions;
+                $table->data[$sessdata->id][] = '<input type="checkbox" name="sessid['.$sessdata->id.']" />';
+                unset($desc, $actions);
+            }
+        }
         echo '<div align="center"><div class="generalbox attwidth">';
         echo "<form method=\"post\" action=\"sessions.php?id={$cm->id}\">"; //&amp;sessionid={$sessdata->id}
                print_table($table);
index 9b755b2..3fb6820 100644 (file)
                                                        $table->data[$student->id][] = '<font color="red"><b>'.$allstatuses[$att->statusid]->acronym.'</b></font>';
                                                }
                                        } else {
-                        if ($sessdata->groupid && !$studgroups[$sessdata->groupid])
+                        if ($sessdata->groupid && !array_key_exists($sessdata->groupid, $studgroups))
                             $table->data[$student->id][] = '';
                         else
                             $table->data[$student->id][] = '?';