function print_section_dblistview($course, $section, $mods, $modnamesused, $absolute = false, $width = "100%")
{
    /// Prints a section full of activity modules
    global $CFG, $USER;
    static $initialised;
    static $groupbuttons;
    static $groupbuttonslink;
    static $isediting;
    static $ismoving;
    static $strmovehere;
    static $strmovefull;
    static $strunreadpostsone;
    static $usetracking;
    static $groupings;
    if (!isset($initialised)) {
        $groupbuttons = ($course->groupmode or !$course->groupmodeforce);
        $groupbuttonslink = !$course->groupmodeforce;
        $isediting = isediting($course->id);
        $ismoving = $isediting && ismoving($course->id);
        if ($ismoving) {
            $strmovehere = get_string("movehere");
            $strmovefull = strip_tags(get_string("movefull", "", "'{$USER->activitycopyname}'"));
        }
        include_once $CFG->dirroot . '/mod/forum/lib.php';
        if ($usetracking = forum_tp_can_track_forums()) {
            $strunreadpostsone = get_string('unreadpostsone', 'forum');
        }
        $initialised = true;
    }
    $labelformatoptions = new object();
    $labelformatoptions->noclean = true;
    /// Casting $course->modinfo to string prevents one notice when the field is null
    $modinfo = get_fast_modinfo($course);
    //Acccessibility: replace table with list <ul>, but don't output empty list.
    if (!empty($section->sequence)) {
        // Fix bug #5027, don't want style=\"width:$width\".
        echo "<ul class=\"section img-text\">\n";
        $sectionmods = explode(",", $section->sequence);
        foreach ($sectionmods as $modnumber) {
            if (empty($mods[$modnumber])) {
                continue;
            }
            $mod = $mods[$modnumber];
            if ($ismoving and $mod->id == $USER->activitycopy) {
                // do not display moving mod
                continue;
            }
            if (isset($modinfo->cms[$modnumber])) {
                if (!$modinfo->cms[$modnumber]->uservisible) {
                    // visibility shortcut
                    continue;
                }
            } else {
                if (!file_exists("{$CFG->dirroot}/mod/{$mod->modname}/lib.php")) {
                    // module not installed
                    continue;
                }
                if (!coursemodule_visible_for_user($mod)) {
                    // full visibility check
                    continue;
                }
            }
            // The magic! ... if indent == 1 then ... hide module
            //            if ($mod->indent == 1) {
            //                $hiddemodule = 'hidden';
            //            } else {
            //                $hiddemodule = '';
            //            }
            echo '<li class="activity ' . $mod->modname . ' ' . $hiddemodule . '" id="module-' . $modnumber . '">';
            // Unique ID
            if ($ismoving) {
                echo '<a title="' . $strmovefull . '"' . ' href="' . $CFG->wwwroot . '/course/mod.php?moveto=' . $mod->id . '&amp;sesskey=' . $USER->sesskey . '">' . '<img class="movetarget" src="' . $CFG->pixpath . '/movehere.gif" ' . ' alt="' . $strmovehere . '" /></a><br />
                     ';
            }
            if ($mod->indent) {
                print_spacer(12, 20 * $mod->indent, false);
            }
            $extra = '';
            if (!empty($modinfo->cms[$modnumber]->extra)) {
                $extra = $modinfo->cms[$modnumber]->extra;
            }
            if ($mod->modname == "label") {
                echo "<span class=\"";
                if (!$mod->visible) {
                    echo 'dimmed_text';
                } else {
                    echo 'label';
                }
                echo '">';
                echo format_text($extra, FORMAT_HTML, $labelformatoptions);
                echo "</span>";
                if (!empty($CFG->enablegroupings) && !empty($mod->groupingid) && has_capability('moodle/course:managegroups', get_context_instance(CONTEXT_COURSE, $course->id))) {
                    if (!isset($groupings)) {
                        $groupings = groups_get_all_groupings($course->id);
                    }
                    echo " <span class=\"groupinglabel\">(" . format_string($groupings[$mod->groupingid]->name) . ')</span>';
                }
            } else {
                // Normal activity
                $instancename = format_string($modinfo->cms[$modnumber]->name, true, $course->id);
                if (!empty($modinfo->cms[$modnumber]->icon)) {
                    $icon = "{$CFG->pixpath}/" . $modinfo->cms[$modnumber]->icon;
                } else {
                    $icon = "{$CFG->modpixpath}/{$mod->modname}/icon.gif";
                }
                //Accessibility: for files get description via icon.
                $altname = '';
                if ('resource' == $mod->modname) {
                    if (!empty($modinfo->cms[$modnumber]->icon)) {
                        $possaltname = $modinfo->cms[$modnumber]->icon;
                        $mimetype = mimeinfo_from_icon('type', $possaltname);
                        $altname = get_mimetype_description($mimetype);
                    } else {
                        $altname = $mod->modfullname;
                    }
                } else {
                    $altname = $mod->modfullname;
                }
                // Avoid unnecessary duplication.
                if (false !== stripos($instancename, $altname)) {
                    $altname = '';
                }
                // File type after name, for alphabetic lists (screen reader).
                if ($altname) {
                    $altname = get_accesshide(' ' . $altname);
                }
                $linkcss = $mod->visible ? "" : " class=\"dimmed\" ";
                if ($mod->modname != 'data') {
                    echo '<a ' . $linkcss . ' ' . $extra . ' href="' . $CFG->wwwroot . '/mod/' . $mod->modname . '/view.php?id=' . $mod->id . '">' . '<img src="' . $icon . '" class="activityicon" alt="" /> <span>' . $instancename . $altname . '</span></a>';
                }
                //echo " $mod->modname ";
                // Special DBLISTVIEW magic ... show summry from resource and blog's 200 chars from each post OUBlog (nadavkav)
                if ($mod->modname == 'resource') {
                    $article = get_record('resource', 'id', $mod->instance);
                    //print_r($article );
                    echo "{$article->summary}";
                }
                if ($mod->modname == 'data') {
                    require_once $CFG->dirroot . '/mod/data/lib.php';
                    if (!($data = get_record('data', 'id', $mod->instance))) {
                        //error('Course module is incorrect');
                    }
                    $sort = 0;
                    $what = ' DISTINCT r.id, r.approved, r.timecreated, r.timemodified, r.userid, u.firstname, u.lastname ';
                    $count = ' COUNT(DISTINCT c.recordid) ';
                    $tables = $CFG->prefix . 'data_content c,' . $CFG->prefix . 'data_records r,' . $CFG->prefix . 'data_content cs, ' . $CFG->prefix . 'user u ';
                    $where = 'WHERE c.recordid = r.id AND r.dataid = ' . $data->id . ' AND r.userid = u.id ';
                    $sortorder = ' ORDER BY r.id ASC ';
                    $searchselect = '';
                    // If requiredentries is not reached, only show current user's entries
                    //if (!$requiredentries_allowed) {
                    //    $where .= ' AND u.id = ' . $USER->id;
                    //}
                    /// To actually fetch the records
                    //$fromsql    = "FROM $tables $advtables $where $advwhere $groupselect $approveselect $searchselect $advsearchselect";
                    $fromsql = "FROM {$tables} {$where} ";
                    $sqlselect = "SELECT {$what} {$fromsql} {$sortorder}";
                    /// Get the actual records
                    if (!($records = get_records_sql($sqlselect))) {
                        // Nothing to show!
                    }
                    if (empty($data->listtemplate)) {
                        //notify(get_string('nolisttemplate','data'));
                        //data_generate_default_template($data, 'listtemplate', 0, false, false);
                    }
                    echo $data->listtemplateheader;
                    data_print_template('listtemplate', $records, $data);
                    echo $data->listtemplatefooter;
                    //print_r($article );
                    //echo "$article->summary";
                    echo '<hr/><a ' . $linkcss . ' ' . $extra . ' href="' . $CFG->wwwroot . '/mod/' . $mod->modname . '/view.php?id=' . $mod->id . '">' . '<img src="' . $icon . '" class="activityicon" alt="" /> <span>' . get_string('more', 'format_dblistview') . '</span></a>';
                    if (!empty($data->csstemplate)) {
                        echo '<style>' . $data->csstemplate . '</style>';
                    }
                }
                if (!empty($CFG->enablegroupings) && !empty($mod->groupingid) && has_capability('moodle/course:managegroups', get_context_instance(CONTEXT_COURSE, $course->id))) {
                    if (!isset($groupings)) {
                        $groupings = groups_get_all_groupings($course->id);
                    }
                    echo " <span class=\"groupinglabel\">(" . format_string($groupings[$mod->groupingid]->name) . ')</span>';
                }
            }
            if ($usetracking && $mod->modname == 'forum') {
                if ($unread = forum_tp_count_forum_unread_posts($mod, $course)) {
                    echo '<span class="unread"> <a href="' . $CFG->wwwroot . '/mod/forum/view.php?id=' . $mod->id . '">';
                    if ($unread == 1) {
                        echo $strunreadpostsone;
                    } else {
                        print_string('unreadpostsnumber', 'forum', $unread);
                    }
                    echo '</a></span>';
                }
            }
            if ($isediting) {
                // TODO: we must define this as mod property!
                if ($groupbuttons and $mod->modname != 'label' and $mod->modname != 'resource' and $mod->modname != 'glossary') {
                    if (!($mod->groupmodelink = $groupbuttonslink)) {
                        $mod->groupmode = $course->groupmode;
                    }
                } else {
                    $mod->groupmode = false;
                }
                echo '&nbsp;&nbsp;';
                echo make_editing_buttons($mod, $absolute, true, $mod->indent, $section->section);
            }
            echo "</li>\n";
        }
    } elseif ($ismoving) {
        echo "<ul class=\"section\">\n";
    }
    if ($ismoving) {
        echo '<li><a title="' . $strmovefull . '"' . ' href="' . $CFG->wwwroot . '/course/mod.php?movetosection=' . $section->id . '&amp;sesskey=' . $USER->sesskey . '">' . '<img class="movetarget" src="' . $CFG->pixpath . '/movehere.gif" ' . ' alt="' . $strmovehere . '" /></a></li>
             ';
    }
    if (!empty($section->sequence) || $ismoving) {
        echo "</ul><!--class='section'-->\n\n";
    }
}
Exemplo n.º 2
0
function hotpot_print_review_buttons(&$course, &$hotpot, &$attempt, $context)
{
    print "\n" . '<table border="0" align="center" cellpadding="2" cellspacing="2" class="generaltable">';
    print "\n<tr>\n" . '<td align="center">';
    print_single_button("report.php?hp={$hotpot->id}", NULL, get_string('continue'), 'post');
    if (has_capability('mod/hotpot:viewreport', $context) && record_exists('hotpot_details', 'attempt', $attempt->id)) {
        print "</td>\n" . '<td align="center">';
        print_single_button("review.php?hp={$hotpot->id}&attempt={$attempt->id}&action=showxmlsource", NULL, get_string('showxmlsource', 'hotpot'), 'post');
        print "</td>\n" . '<td align="center">';
        print_single_button("review.php?hp={$hotpot->id}&attempt={$attempt->id}&action=showxmltree", NULL, get_string('showxmltree', 'hotpot'), 'post');
        $colspan = 3;
    } else {
        $colspan = 1;
    }
    print "</td>\n</tr>\n";
    print '<tr><td colspan="' . $colspan . '">';
    print_spacer(4, 1, false);
    // height=4, width=1, no <br />
    print "</td></tr>\n";
    print "</table>\n";
}
 /**
  * Display the file resource
  *
  * Displays a file resource embedded, in a frame, or in a popup.
  * Output depends on type of file resource.
  *
  * @param    CFG     global object
  */
 function display()
 {
     global $CFG, $THEME, $USER;
     /// Set up generic stuff first, including checking for access
     parent::display();
     /// Set up some shorthand variables
     $cm = $this->cm;
     $course = $this->course;
     $resource = $this->resource;
     $this->set_parameters();
     // set the parameters array
     ///////////////////////////////////////////////
     /// Possible display modes are:
     /// File displayed in a frame in a normal window
     /// File displayed embedded in a normal page
     /// File displayed in a popup window
     /// File displayed emebedded in a popup window
     /// First, find out what sort of file we are dealing with.
     require_once $CFG->libdir . '/filelib.php';
     $querystring = '';
     $resourcetype = '';
     $embedded = false;
     $mimetype = mimeinfo("type", $resource->reference);
     $pagetitle = strip_tags($course->shortname . ': ' . format_string($resource->name));
     $formatoptions = new object();
     $formatoptions->noclean = true;
     if ($resource->options != "bogusoption_usedtobe_frame") {
         // TODO nicolasconnault 14-03-07: This option should be renamed "embed"
         if (in_array($mimetype, array('image/gif', 'image/jpeg', 'image/png'))) {
             // It's an image
             $resourcetype = "image";
             $embedded = true;
         } else {
             if ($mimetype == "audio/mp3") {
                 // It's an MP3 audio file
                 $resourcetype = "mp3";
                 $embedded = true;
             } else {
                 if ($mimetype == "video/x-flv") {
                     // It's a Flash video file
                     $resourcetype = "flv";
                     $embedded = true;
                 } else {
                     if (substr($mimetype, 0, 10) == "video/x-ms") {
                         // It's a Media Player file
                         $resourcetype = "mediaplayer";
                         $embedded = true;
                     } else {
                         if ($mimetype == "video/quicktime") {
                             // It's a Quicktime file
                             $resourcetype = "quicktime";
                             $embedded = true;
                         } else {
                             if ($mimetype == "application/x-shockwave-flash") {
                                 // It's a Flash file
                                 $resourcetype = "flash";
                                 $embedded = true;
                             } else {
                                 if ($mimetype == "video/mpeg") {
                                     // It's a Mpeg file
                                     $resourcetype = "mpeg";
                                     $embedded = true;
                                 } else {
                                     if ($mimetype == "text/html") {
                                         // It's a web page
                                         $resourcetype = "html";
                                     } else {
                                         if ($mimetype == "application/zip") {
                                             // It's a zip archive
                                             $resourcetype = "zip";
                                             $embedded = true;
                                         } else {
                                             if ($mimetype == 'application/pdf' || $mimetype == 'application/x-pdf') {
                                                 $resourcetype = "pdf";
                                                 $embedded = true;
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     $isteamspeak = stripos($resource->reference, 'teamspeak://') === 0;
     /// Form the parse string
     if (!empty($resource->alltext)) {
         $querys = array();
         $parray = explode(',', $resource->alltext);
         foreach ($parray as $fieldstring) {
             $field = explode('=', $fieldstring);
             $querys[] = urlencode($field[1]) . '=' . urlencode($this->parameters[$field[0]]['value']);
         }
         if ($isteamspeak) {
             $querystring = implode('?', $querys);
         } else {
             $querystring = implode('&amp;', $querys);
         }
     }
     /// Set up some variables
     $inpopup = optional_param('inpopup', 0, PARAM_BOOL);
     if (resource_is_url($resource->reference)) {
         $fullurl = $resource->reference;
         if (!empty($querystring)) {
             $urlpieces = parse_url($resource->reference);
             if (empty($urlpieces['query']) or $isteamspeak) {
                 $fullurl .= '?' . $querystring;
             } else {
                 $fullurl .= '&amp;' . $querystring;
             }
         }
     } else {
         if ($CFG->resource_allowlocalfiles and strpos($resource->reference, RESOURCE_LOCALPATH) === 0) {
             // Localpath
             $localpath = get_user_preferences('resource_localpath', 'D:');
             $relativeurl = str_replace(RESOURCE_LOCALPATH, $localpath, $resource->reference);
             if ($querystring) {
                 $relativeurl .= '?' . $querystring;
             }
             $relativeurl = str_replace('\\', '/', $relativeurl);
             $relativeurl = str_replace(' ', '%20', $relativeurl);
             $fullurl = 'file:///' . htmlentities($relativeurl);
             $localpath = true;
         } else {
             // Normal uploaded file
             if ($CFG->slasharguments) {
                 $relativeurl = "/file.php/{$course->id}/{$resource->reference}";
                 if ($querystring) {
                     $relativeurl .= '?' . $querystring;
                 }
             } else {
                 $relativeurl = "/file.php?file=/{$course->id}/{$resource->reference}";
                 if ($querystring) {
                     $relativeurl .= '&amp;' . $querystring;
                 }
             }
             $fullurl = "{$CFG->wwwroot}{$relativeurl}";
         }
     }
     /// Print a notice and redirect if we are trying to access a file on a local file system
     /// and the config setting has been disabled
     if (!$CFG->resource_allowlocalfiles and strpos($resource->reference, RESOURCE_LOCALPATH) === 0) {
         if ($inpopup) {
             print_header($pagetitle, $course->fullname);
         } else {
             $this->navlinks[] = array('name' => format_string($resource->name), 'link' => null, 'type' => 'misc');
             $this->navigation = build_navigation($this->navlinks);
             print_header($pagetitle, $course->fullname, $this->navigation, "", "", true, update_module_button($cm->id, $course->id, $this->strresource), navmenu($course, $cm));
         }
         notify(get_string('notallowedlocalfileaccess', 'resource', ''));
         if ($inpopup) {
             close_window_button();
         }
         print_footer('none');
         die;
     }
     /// Check whether this is supposed to be a popup, but was called directly
     if ($resource->popup and !$inpopup) {
         /// Make a page and a pop-up window
         $this->navlinks[] = array('name' => format_string($resource->name), 'link' => null, 'type' => 'misc');
         $this->navigation = build_navigation($this->navlinks);
         print_header($pagetitle, $course->fullname, $this->navigation, "", "", true, update_module_button($cm->id, $course->id, $this->strresource), navmenu($course, $cm));
         echo "\n<script type=\"text/javascript\">";
         echo "\n<!--\n";
         echo "openpopup('/mod/resource/view.php?inpopup=true&id={$cm->id}','resource{$resource->id}','{$resource->popup}');\n";
         echo "\n-->\n";
         echo '</script>';
         if (trim(strip_tags($resource->summary))) {
             print_simple_box(format_text($resource->summary, FORMAT_MOODLE, $formatoptions), "center");
         }
         $link = "<a href=\"{$CFG->wwwroot}/mod/resource/view.php?inpopup=true&amp;id={$cm->id}\" " . "onclick=\"this.target='resource{$resource->id}'; return openpopup('/mod/resource/view.php?inpopup=true&amp;id={$cm->id}', " . "'resource{$resource->id}','{$resource->popup}');\">" . format_string($resource->name, true) . "</a>";
         echo '<div class="popupnotice">';
         print_string('popupresource', 'resource');
         echo '<br />';
         print_string('popupresourcelink', 'resource', $link);
         echo '</div>';
         print_footer($course);
         exit;
     }
     /// Now check whether we need to display a frameset
     $frameset = optional_param('frameset', '', PARAM_ALPHA);
     if (empty($frameset) and !$embedded and !$inpopup and $resource->options == "frame" and empty($USER->screenreader)) {
         @header('Content-Type: text/html; charset=utf-8');
         echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Frameset//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd\">\n";
         echo "<html dir=\"ltr\">\n";
         echo '<head>';
         echo '<meta http-equiv="content-type" content="text/html; charset=utf-8" />';
         echo "<title>" . format_string($course->shortname) . ": " . strip_tags(format_string($resource->name, true)) . "</title></head>\n";
         echo "<frameset rows=\"{$CFG->resource_framesize},*\">";
         echo "<frame src=\"view.php?id={$cm->id}&amp;type={$resource->type}&amp;frameset=top\" title=\"" . get_string('modulename', 'resource') . "\"/>";
         if (!empty($localpath)) {
             // Show it like this so we interpose some HTML
             echo "<frame src=\"view.php?id={$cm->id}&amp;type={$resource->type}&amp;inpopup=true\" title=\"" . get_string('modulename', 'resource') . "\"/>";
         } else {
             echo "<frame src=\"{$fullurl}\" title=\"" . get_string('modulename', 'resource') . "\"/>";
         }
         echo "</frameset>";
         echo "</html>";
         exit;
     }
     /// We can only get here once per resource, so add an entry to the log
     add_to_log($course->id, "resource", "view", "view.php?id={$cm->id}", $resource->id, $cm->id);
     /// If we are in a frameset, just print the top of it
     if (!empty($frameset) and $frameset == "top") {
         $this->navlinks[] = array('name' => format_string($resource->name), 'link' => null, 'type' => 'misc');
         $this->navigation = build_navigation($this->navlinks);
         print_header($pagetitle, $course->fullname, $this->navigation, "", "", true, update_module_button($cm->id, $course->id, $this->strresource), navmenu($course, $cm, "parent"));
         $options = new object();
         $options->para = false;
         echo '<div class="summary">' . format_text($resource->summary, FORMAT_HTML, $options) . '</div>';
         if (!empty($localpath)) {
             // Show some help
             echo '<div align="right" class="helplink">';
             link_to_popup_window('/mod/resource/type/file/localpath.php', get_string('localfile', 'resource'), get_string('localfilehelp', 'resource'), 400, 500, get_string('localfilehelp', 'resource'));
             echo '</div>';
         }
         echo '</div></div></body></html>';
         exit;
     }
     /// Display the actual resource
     if ($embedded) {
         // Display resource embedded in page
         $strdirectlink = get_string("directlink", "resource");
         if ($inpopup) {
             print_header($pagetitle);
         } else {
             $this->navlinks[] = array('name' => format_string($resource->name, true), 'link' => $fullurl, 'type' => 'misc');
             $this->navigation = build_navigation($this->navlinks);
             print_header_simple($pagetitle, '', $this->navigation, "", "", true, update_module_button($cm->id, $course->id, $this->strresource), navmenu($course, $cm, "self"));
         }
         if ($resourcetype == "image") {
             echo '<div class="resourcecontent resourceimg">';
             echo "<img title=\"" . strip_tags(format_string($resource->name, true)) . "\" class=\"resourceimage\" src=\"{$fullurl}\" alt=\"\" />";
             echo '</div>';
         } else {
             if ($resourcetype == "mp3") {
                 if (!empty($THEME->resource_mp3player_colors)) {
                     $c = $THEME->resource_mp3player_colors;
                     // You can set this up in your theme/xxx/config.php
                 } else {
                     $c = 'bgColour=000000&btnColour=ffffff&btnBorderColour=cccccc&iconColour=000000&' . 'iconOverColour=00cc00&trackColour=cccccc&handleColour=ffffff&loaderColour=ffffff&' . 'font=Arial&fontColour=FF33FF&buffer=10&waitForPlay=no&autoPlay=yes';
                 }
                 $c .= '&volText=' . get_string('vol', 'resource') . '&panText=' . get_string('pan', 'resource');
                 $c = htmlentities($c);
                 $id = 'filter_mp3_' . time();
                 //we need something unique because it might be stored in text cache
                 $cleanurl = addslashes_js($fullurl);
                 // If we have Javascript, use UFO to embed the MP3 player, otherwise depend on plugins
                 echo '<div class="resourcecontent resourcemp3">';
                 echo '<span class="mediaplugin mediaplugin_mp3" id="' . $id . '"></span>' . '<script type="text/javascript">' . "\n" . '//<![CDATA[' . "\n" . 'var FO = { movie:"' . $CFG->wwwroot . '/lib/mp3player/mp3player.swf?src=' . $cleanurl . '",' . "\n" . 'width:"600", height:"70", majorversion:"6", build:"40", flashvars:"' . $c . '", quality: "high" };' . "\n" . 'UFO.create(FO, "' . $id . '");' . "\n" . '//]]>' . "\n" . '</script>' . "\n";
                 echo '<noscript>';
                 echo "<object type=\"audio/mpeg\" data=\"{$fullurl}\" width=\"600\" height=\"70\">";
                 echo "<param name=\"src\" value=\"{$fullurl}\" />";
                 echo '<param name="quality" value="high" />';
                 echo '<param name="autoplay" value="true" />';
                 echo '<param name="autostart" value="true" />';
                 echo '</object>';
                 echo '<p><a href="' . $fullurl . '">' . $fullurl . '</a></p>';
                 echo '</noscript>';
                 echo '</div>';
             } else {
                 if ($resourcetype == "flv") {
                     $id = 'filter_flv_' . time();
                     //we need something unique because it might be stored in text cache
                     $cleanurl = addslashes_js($fullurl);
                     // If we have Javascript, use UFO to embed the FLV player, otherwise depend on plugins
                     echo '<div class="resourcecontent resourceflv">';
                     echo '<span class="mediaplugin mediaplugin_flv" id="' . $id . '"></span>' . '<script type="text/javascript">' . "\n" . '//<![CDATA[' . "\n" . 'var FO = { movie:"' . $CFG->wwwroot . '/filter/mediaplugin/flvplayer.swf?file=' . $cleanurl . '",' . "\n" . 'width:"600", height:"400", majorversion:"6", build:"40", allowscriptaccess:"never", quality: "high" };' . "\n" . 'UFO.create(FO, "' . $id . '");' . "\n" . '//]]>' . "\n" . '</script>' . "\n";
                     echo '<noscript>';
                     echo "<object type=\"video/x-flv\" data=\"{$fullurl}\" width=\"600\" height=\"400\">";
                     echo "<param name=\"src\" value=\"{$fullurl}\" />";
                     echo '<param name="quality" value="high" />';
                     echo '<param name="autoplay" value="true" />';
                     echo '<param name="autostart" value="true" />';
                     echo '</object>';
                     echo '<p><a href="' . $fullurl . '">' . $fullurl . '</a></p>';
                     echo '</noscript>';
                     echo '</div>';
                 } else {
                     if ($resourcetype == "mediaplayer") {
                         echo '<div class="resourcecontent resourcewmv">';
                         echo '<object type="video/x-ms-wmv" data="' . $fullurl . '">';
                         echo '<param name="controller" value="true" />';
                         echo '<param name="autostart" value="true" />';
                         echo "<param name=\"src\" value=\"{$fullurl}\" />";
                         echo '<param name="scale" value="noScale" />';
                         echo "<a href=\"{$fullurl}\">{$fullurl}</a>";
                         echo '</object>';
                         echo '</div>';
                     } else {
                         if ($resourcetype == "mpeg") {
                             echo '<div class="resourcecontent resourcempeg">';
                             echo '<object classid="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95"
                           codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsm p2inf.cab#Version=5,1,52,701"
                           type="application/x-oleobject">';
                             echo "<param name=\"fileName\" value=\"{$fullurl}\" />";
                             echo '<param name="autoStart" value="true" />';
                             echo '<param name="animationatStart" value="true" />';
                             echo '<param name="transparentatStart" value="true" />';
                             echo '<param name="showControls" value="true" />';
                             echo '<param name="Volume" value="-450" />';
                             echo '<!--[if !IE]>-->';
                             echo '<object type="video/mpeg" data="' . $fullurl . '">';
                             echo '<param name="controller" value="true" />';
                             echo '<param name="autostart" value="true" />';
                             echo "<param name=\"src\" value=\"{$fullurl}\" />";
                             echo "<a href=\"{$fullurl}\">{$fullurl}</a>";
                             echo '<!--<![endif]-->';
                             echo '<a href="' . $fullurl . '">' . $fullurl . '</a>';
                             echo '<!--[if !IE]>-->';
                             echo '</object>';
                             echo '<!--<![endif]-->';
                             echo '</object>';
                             echo '</div>';
                         } else {
                             if ($resourcetype == "quicktime") {
                                 echo '<style type="text/css">';
                                 echo '/* class to hide nested objects in IE */';
                                 echo '/* hides the second object from all versions of IE */';
                                 echo '* html object.hiddenObjectForIE { display: none; }';
                                 echo '/* display the second object only for IE5 Mac */';
                                 echo '/* IE Mac \\*//*/';
                                 echo '* html object.hiddenObjectForIE { display: inline; }';
                                 echo '/**/';
                                 echo '</style>';
                                 echo '<div class="resourcecontent resourceqt">';
                                 echo '<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B"';
                                 echo '        codebase="http://www.apple.com/qtactivex/qtplugin.cab">';
                                 echo "<param name=\"src\" value=\"{$fullurl}\" />";
                                 echo '<param name="autoplay" value="true" />';
                                 echo '<param name="loop" value="true" />';
                                 echo '<param name="controller" value="true" />';
                                 echo '<param name="scale" value="aspect" />';
                                 echo "<object class=\"hiddenObjectForIE\" type=\"video/quicktime\" data=\"{$fullurl}\">";
                                 echo '<param name="controller" value="true" />';
                                 echo '<param name="autoplay" value="true" />';
                                 echo '<param name="loop" value="true" />';
                                 echo '<param name="scale" value="aspect" />';
                                 echo '</object>';
                                 echo '<a href="' . $fullurl . '">' . $fullurl . '</a>';
                                 echo '</object>';
                                 echo '</div>';
                             } else {
                                 if ($resourcetype == "flash") {
                                     echo '<div class="resourcecontent resourceswf">';
                                     echo '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000">';
                                     echo "<param name=\"movie\" value=\"{$fullurl}\" />";
                                     echo '<param name="autoplay" value="true" />';
                                     echo '<param name="loop" value="true" />';
                                     echo '<param name="controller" value="true" />';
                                     echo '<param name="scale" value="aspect" />';
                                     echo '<!--[if !IE]>-->';
                                     echo "<object type=\"application/x-shockwave-flash\" data=\"{$fullurl}\">";
                                     echo '<param name="controller" value="true" />';
                                     echo '<param name="autoplay" value="true" />';
                                     echo '<param name="loop" value="true" />';
                                     echo '<param name="scale" value="aspect" />';
                                     echo '<!--<![endif]-->';
                                     echo '<a href="' . $fullurl . '">' . $fullurl . '</a>';
                                     echo '<!--[if !IE]>-->';
                                     echo '</object>';
                                     echo '<!--<![endif]-->';
                                     echo '</object>';
                                     echo '</div>';
                                 } elseif ($resourcetype == 'zip') {
                                     echo '<div class="resourcepdf">';
                                     echo get_string('clicktoopen', 'resource') . '<a href="' . $fullurl . '">' . format_string($resource->name) . '</a>';
                                     echo '</div>';
                                 } elseif ($resourcetype == 'pdf') {
                                     echo '<div class="resourcepdf">';
                                     echo '<object data="' . $fullurl . '" type="application/pdf">';
                                     echo get_string('clicktoopen', 'resource') . '<a href="' . $fullurl . '">' . format_string($resource->name) . '</a>';
                                     echo '</object>';
                                     echo '</div>';
                                 }
                             }
                         }
                     }
                 }
             }
         }
         if (trim($resource->summary)) {
             print_simple_box(format_text($resource->summary, FORMAT_MOODLE, $formatoptions, $course->id), "center");
         }
         if ($inpopup) {
             echo "<div class=\"popupnotice\">(<a href=\"{$fullurl}\">{$strdirectlink}</a>)</div>";
         } else {
             print_spacer(20, 20);
             print_footer($course);
         }
     } else {
         // Display the resource on it's own
         if (!empty($localpath)) {
             // Show a link to help work around browser security
             echo '<div align="right" class="helplink">';
             link_to_popup_window('/mod/resource/type/file/localpath.php', get_string('localfile', 'resource'), get_string('localfilehelp', 'resource'), 400, 500, get_string('localfilehelp', 'resource'));
             echo '</div>';
             echo "<div class=\"popupnotice\">(<a href=\"{$fullurl}\">{$fullurl}</a>)</div>";
         }
         redirect($fullurl);
     }
 }
Exemplo n.º 4
0
function print_category_info($category, $depth, $showcourses = false)
{
    /// Prints the category info in indented fashion
    /// This function is only used by print_whole_category_list() above
    global $CFG;
    static $strallowguests, $strrequireskey, $strsummary;
    if (empty($strsummary)) {
        $strallowguests = get_string('allowguests');
        $strrequireskey = get_string('requireskey');
        $strsummary = get_string('summary');
    }
    $catlinkcss = $category->visible ? '' : ' class="dimmed" ';
    $coursecount = count_records('course') <= FRONTPAGECOURSELIMIT;
    if ($showcourses and $coursecount) {
        $catimage = '<img src="' . $CFG->pixpath . '/i/course.gif" alt="" />';
    } else {
        $catimage = "&nbsp;";
    }
    echo "\n\n" . '<table class="categorylist">';
    $courses = get_courses($category->id, 'c.sortorder ASC', 'c.id,c.sortorder,c.visible,c.fullname,c.shortname,c.password,c.summary,c.guest,c.cost,c.currency');
    if ($showcourses and $coursecount) {
        echo '<tr>';
        if ($depth) {
            $indent = $depth * 30;
            $rows = count($courses) + 1;
            echo '<td class="category indentation" rowspan="' . $rows . '" valign="top">';
            print_spacer(10, $indent);
            echo '</td>';
        }
        echo '<td valign="top" class="category image">' . $catimage . '</td>';
        echo '<td valign="top" class="category name">';
        echo '<a ' . $catlinkcss . ' href="' . $CFG->wwwroot . '/course/category.php?id=' . $category->id . '">' . format_string($category->name) . '</a>';
        echo '</td>';
        echo '<td class="category info">&nbsp;</td>';
        echo '</tr>';
        // does the depth exceed maxcategorydepth
        // maxcategorydepth == 0 or unset meant no limit
        $limit = !(isset($CFG->maxcategorydepth) && $depth >= $CFG->maxcategorydepth - 1);
        if ($courses && ($limit || $CFG->maxcategorydepth == 0)) {
            foreach ($courses as $course) {
                $linkcss = $course->visible ? '' : ' class="dimmed" ';
                echo '<tr><td valign="top">&nbsp;';
                echo '</td><td valign="top" class="course name">';
                echo '<a ' . $linkcss . ' href="' . $CFG->wwwroot . '/course/view.php?id=' . $course->id . '">' . format_string($course->fullname) . '</a>';
                echo '</td><td align="right" valign="top" class="course info">';
                if ($course->guest) {
                    echo '<a title="' . $strallowguests . '" href="' . $CFG->wwwroot . '/course/view.php?id=' . $course->id . '">';
                    echo '<img alt="' . $strallowguests . '" src="' . $CFG->pixpath . '/i/guest.gif" /></a>';
                } else {
                    echo '<img alt="" style="width:18px;height:16px;" src="' . $CFG->pixpath . '/spacer.gif" />';
                }
                if ($course->password) {
                    echo '<a title="' . $strrequireskey . '" href="' . $CFG->wwwroot . '/course/view.php?id=' . $course->id . '">';
                    echo '<img alt="' . $strrequireskey . '" src="' . $CFG->pixpath . '/i/key.gif" /></a>';
                } else {
                    echo '<img alt="" style="width:18px;height:16px;" src="' . $CFG->pixpath . '/spacer.gif" />';
                }
                if ($course->summary) {
                    link_to_popup_window('/course/info.php?id=' . $course->id, 'courseinfo', '<img alt="' . $strsummary . '" src="' . $CFG->pixpath . '/i/info.gif" />', 400, 500, $strsummary);
                } else {
                    echo '<img alt="" style="width:18px;height:16px;" src="' . $CFG->pixpath . '/spacer.gif" />';
                }
                echo '</td></tr>';
            }
        }
    } else {
        echo '<tr>';
        if ($depth) {
            $indent = $depth * 20;
            echo '<td class="category indentation" valign="top">';
            print_spacer(10, $indent);
            echo '</td>';
        }
        echo '<td valign="top" class="category name">';
        echo '<a ' . $catlinkcss . ' href="' . $CFG->wwwroot . '/course/category.php?id=' . $category->id . '">' . format_string($category->name) . '</a>';
        echo '</td>';
        echo '<td valign="top" class="category number">';
        if (count($courses)) {
            echo count($courses);
        }
        echo '</td></tr>';
    }
    echo '</table>';
}
Exemplo n.º 5
0
    $spacer = new html_image();
    $spacer->height = 20;
    echo $OUTPUT->spacer(clone $spacer) . '<br />';
    echo $OUTPUT->heading($solutionsstr);
    unset($admin_table->data);
    if (isset($errors['dir'])) {
        $admin_table->data[] = array($checkdirstr, $checkdiradvicestr);
    }
    if (isset($errors['db'])) {
        $admin_table->data[] = array($checkdbstr, $checkdbadvicestr);
    }
    $admin_table->data[] = array($runindexerteststr, '<a href="tests/index.php" target="_blank">tests/index.php</a>');
    $admin_table->data[] = array($runindexerstr, '<a href="indexersplash.php" target="_blank">indexersplash.php</a>');
    echo $OUTPUT->table($admin_table);
    echo $OUTPUT->spacer($spacer) . '<br />';
    print_spacer(20);
}
/// this is the standard summary table for normal users, shows document counts
$table = new html_table();
$table->tablealign = 'center';
$table->align = array('right', 'left');
$table->wrap = array('nowrap', 'nowrap');
$table->cellpadding = 5;
$table->cellspacing = 0;
$table->width = '500';
$table->data[] = array("<strong>{$databasestr}</strong>", "<em><strong>{$CFG->prefix}" . SEARCH_DATABASE_TABLE . '</strong></em>');
/// add extra fields if we're admin
if (has_capability('moodle/site:doanything', get_context_instance(CONTEXT_SYSTEM))) {
    //don't want to confuse users if the two totals don't match (hint: they should)
    $table->data[] = array($documentsinindexstr, $indexinfo->indexcount);
    //*cough* they should match if deletions were actually removed from the index,
Exemplo n.º 6
0
 function get_content()
 {
     global $USER, $CFG, $COURSE;
     // It need update?
     if (email_must_update($this->version)) {
         $this->content = get_string('mustupdate', 'block_email_list');
     }
     // Get course id
     if (!empty($COURSE)) {
         $this->courseid = $COURSE->id;
     }
     // If block have content, skip.
     if ($this->content !== NULL) {
         return $this->content;
     }
     $this->content = new stdClass();
     $this->content->items = array();
     $this->content->icons = array();
     if ($CFG->email_enable_ssl) {
         $wwwroot = str_replace('http:', 'https:', $CFG->wwwroot);
     } else {
         $wwwroot = $CFG->wwwroot;
     }
     // Get context
     $context = get_context_instance(CONTEXT_BLOCK, $this->instance->id);
     $emailicon = '<img src="' . $CFG->wwwroot . '/blocks/email_list/email/images/sobre.png" height="11" width="15" alt="' . get_string("course") . '" />';
     $composeicon = '<img src="' . $CFG->pixpath . '/i/edit.gif" alt="" />';
     // Only show all course in principal course, others, show it
     if ($this->instance->pageid == 1) {
         //Get the courses of the user
         $mycourses = get_my_courses($USER->id);
         $this->content->footer = '<br />' . $emailicon . print_spacer(1, 4, false, true) . '<a href="' . $CFG->wwwroot . '/blocks/email_list/email/">' . get_string('view_all', 'block_email_list') . '</a>';
     } else {
         if (!empty($CFG->mymoodleredirect) and $COURSE->id == 1) {
             //Get the courses of the user
             $mycourses = get_my_courses($USER->id);
             $this->content->footer = '<br />' . $emailicon . print_spacer(1, 4, false, true) . '<a href="' . $CFG->wwwroot . '/blocks/email_list/email/">' . get_string('view_all', 'block_email_list') . '</a>';
         } else {
             // Get this course
             $course = get_record('course', 'id', $this->instance->pageid);
             $mycourses[] = $course;
             $this->content->footer = '<br />' . $emailicon . print_spacer(1, 4, false, true) . '<a href="' . $CFG->wwwroot . '/blocks/email_list/email/index.php?id=' . $course->id . '">' . get_string('view_inbox', 'block_email_list') . '</a>';
             $this->content->footer .= '<br />' . $composeicon . print_spacer(1, 4, false, true) . '<a href="' . $wwwroot . '/blocks/email_list/email/sendmail.php?course=' . $course->id . '&amp;folderid=0&amp;filterid=0&amp;folderoldid=0&amp;action=newmail">' . get_string('compose', 'block_email_list') . '</a>';
         }
     }
     // Count my courses
     $countmycourses = count($mycourses);
     //Configure item and icon for this account
     $icon = '<img src="' . $CFG->wwwroot . '/blocks/email_list/email/images/openicon.gif" height="16" width="16" alt="' . get_string("course") . '" />';
     $number = 0;
     foreach ($mycourses as $mycourse) {
         ++$number;
         // increment for first course
         if ($number > $CFG->email_max_number_courses && !empty($CFG->email_max_number_courses)) {
             continue;
         }
         //Get the number of unread mails
         $numberunreadmails = email_count_unreaded_mails($USER->id, $mycourse->id);
         // Only show if has unreaded mails
         if ($numberunreadmails > 0) {
             $unreadmails = '<b>(' . $numberunreadmails . ')</b>';
             $this->content->items[] = '<a href="' . $CFG->wwwroot . '/blocks/email_list/email/index.php?id=' . $mycourse->id . '">' . $mycourse->fullname . ' ' . $unreadmails . '</a>';
             $this->content->icons[] = $icon;
         }
     }
     if (count($this->content->items) == 0) {
         $this->content->items[] = '<div align="center">' . get_string('emptymailbox', 'block_email_list') . '</div>';
     }
     return $this->content;
 }
Exemplo n.º 7
0
 print_paging_bar($totalcount, $page, $perpage, "search.php?search={$encodedsearch}&amp;perpage={$perpage}&amp;", 'page', $perpage == 99999);
 if ($perpage != 99999 && $totalcount > $perpage) {
     echo "<center><p>";
     echo "<a href=\"search.php?search={$encodedsearch}&perpage=99999\">" . get_string("showall", "", $totalcount) . "</a>";
     echo "</p></center>";
 }
 if (!has_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM))) {
     foreach ($courses as $course) {
         $course->fullname = highlight("{$search}", $course->fullname);
         $course->summary = highlight("{$search}", $course->summary);
         $course->summary .= "<br /><p class=\"category\">";
         $course->summary .= "{$strcategory}: <a href=\"category.php?id={$course->category}\">";
         $course->summary .= $displaylist[$course->category];
         $course->summary .= "</a></p>";
         print_course($course);
         print_spacer(5, 5);
     }
 } else {
     // slightly more sophisticated
     echo "<form id=\"movecourses\" action=\"search.php\" method=\"post\">\n";
     echo "<div><input type=\"hidden\" name=\"sesskey\" value=\"{$USER->sesskey}\" />\n";
     echo "<input type=\"hidden\" name=\"search\" value=\"" . s($search, true) . "\" />\n";
     echo "<input type=\"hidden\" name=\"page\" value=\"{$page}\" />\n";
     echo "<input type=\"hidden\" name=\"perpage\" value=\"{$perpage}\" /></div>\n";
     echo "<table border=\"0\" cellspacing=\"2\" cellpadding=\"4\" class=\"generalbox boxaligncenter\">\n<tr>\n";
     echo "<th scope=\"col\">{$strcourses}</th>\n";
     echo "<th scope=\"col\">{$strcategory}</th>\n";
     echo "<th scope=\"col\">{$strselect}</th>\n";
     echo "<th scope=\"col\">{$stredit}</th></tr>\n";
     foreach ($courses as $course) {
         if (isset($course->context)) {
 /**
 * Display the repository resource
 *
 * Displays a repository resource embedded, in a frame, or in a popup.
 * Output depends on type of file resource.
 *
 * @param    CFG     global object
 */
 function display()
 {
     global $CFG, $THEME, $SESSION;
     /// Set up generic stuff first, including checking for access
     parent::display();
     /// Set up some shorthand variables
     $cm = $this->cm;
     $course = $this->course;
     $resource = $this->resource;
     $this->set_parameters();
     // set the parameters array
     ///////////////////////////////////////////////
     /// Possible display modes are:
     /// File displayed in a frame in a normal window
     /// File displayed embedded in a normal page
     /// File displayed in a popup window
     /// File displayed emebedded in a popup window
     /// First, find out what sort of file we are dealing with.
     require_once $CFG->libdir . '/filelib.php';
     $querystring = '';
     $resourcetype = '';
     $embedded = false;
     $mimetype = mimeinfo("type", $resource->reference);
     $pagetitle = strip_tags($course->shortname . ': ' . format_string($resource->name));
     $formatoptions = new object();
     $formatoptions->noclean = true;
     if ($resource->options != "frame") {
         if (in_array($mimetype, array('image/gif', 'image/jpeg', 'image/png'))) {
             // It's an image
             $resourcetype = "image";
             $embedded = true;
         } else {
             if ($mimetype == "audio/mp3") {
                 // It's an MP3 audio file
                 $resourcetype = "mp3";
                 $embedded = true;
             } else {
                 if (substr($mimetype, 0, 10) == "video/x-ms") {
                     // It's a Media Player file
                     $resourcetype = "mediaplayer";
                     $embedded = true;
                 } else {
                     if ($mimetype == "video/quicktime") {
                         // It's a Quicktime file
                         $resourcetype = "quicktime";
                         $embedded = true;
                     } else {
                         if ($mimetype == "text/html") {
                             // It's a web page
                             $resourcetype = "html";
                         }
                     }
                 }
             }
         }
     }
     $navigation = build_navigation($this->navlinks, $cm);
     /// Form the parse string
     if (!empty($resource->alltext)) {
         $querys = array();
         $parray = explode(',', $resource->alltext);
         foreach ($parray as $fieldstring) {
             $field = explode('=', $fieldstring);
             $querys[] = urlencode($field[1]) . '=' . urlencode($this->parameters[$field[0]]['value']);
         }
         $querystring = implode('&amp;', $querys);
     }
     /// Set up some variables
     $inpopup = optional_param('inpopup', 0, PARAM_BOOL);
     $fullurl = $resource->reference . '&amp;HIVE_SESSION=' . $SESSION->HIVE_SESSION;
     if (!empty($querystring)) {
         $urlpieces = parse_url($resource->reference);
         if (empty($urlpieces['query'])) {
             $fullurl .= '?' . $querystring;
         } else {
             $fullurl .= '&amp;' . $querystring;
         }
     }
     /// MW check that the HIVE_SESSION is there
     if (empty($SESSION->HIVE_SESSION)) {
         if ($inpopup) {
             print_header($pagetitle, $course->fullname);
         } else {
             print_header($pagetitle, $course->fullname, $navigation, "", "", true, update_module_button($cm->id, $course->id, $this->strresource), navmenu($course, $cm));
         }
         notify('You do not have access to HarvestRoad Hive. This resource is unavailable.');
         if ($inpopup) {
             close_window_button();
         }
         print_footer('none');
         die;
     }
     /// MW END
     /// Check whether this is supposed to be a popup, but was called directly
     if ($resource->popup and !$inpopup) {
         /// Make a page and a pop-up window
         print_header($pagetitle, $course->fullname, $navigation, "", "", true, update_module_button($cm->id, $course->id, $this->strresource), navmenu($course, $cm));
         echo "\n<script type=\"text/javascript\">";
         echo "\n<!--\n";
         echo "openpopup('/mod/resource/view.php?inpopup=true&id={$cm->id}','resource{$resource->id}','{$resource->popup}');\n";
         echo "\n-->\n";
         echo '</script>';
         if (trim(strip_tags($resource->summary))) {
             $formatoptions->noclean = true;
             print_simple_box(format_text($resource->summary, FORMAT_MOODLE, $formatoptions), "center");
         }
         $link = "<a href=\"{$CFG->wwwroot}/mod/resource/view.php?inpopup=true&amp;id={$cm->id}\" target=\"resource{$resource->id}\" onclick=\"return openpopup('/mod/resource/view.php?inpopup=true&amp;id={$cm->id}', 'resource{$resource->id}','{$resource->popup}');\">" . format_string($resource->name, true) . "</a>";
         echo "<p>&nbsp;</p>";
         echo '<p align="center">';
         print_string('popupresource', 'resource');
         echo '<br />';
         print_string('popupresourcelink', 'resource', $link);
         echo "</p>";
         print_footer($course);
         exit;
     }
     /// Now check whether we need to display a frameset
     $frameset = optional_param('frameset', '', PARAM_ALPHA);
     if (empty($frameset) and !$embedded and !$inpopup and $resource->options == "frame" and empty($USER->screenreader)) {
         echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Frameset//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd\">\n";
         echo "<html dir=\"ltr\">\n";
         echo '<head>';
         echo '<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />';
         echo "<title>" . format_string($course->shortname) . ": " . strip_tags(format_string($resource->name, true)) . "</title></head>\n";
         echo "<frameset rows=\"{$CFG->resource_framesize},*\">";
         echo "<frame src=\"view.php?id={$cm->id}&amp;type={$resource->type}&amp;frameset=top\" title=\"" . get_string('modulename', 'resource') . "\"/>";
         echo "<frame src=\"{$fullurl}\" title=\"" . get_string('modulename', 'resource') . "\"/>";
         echo "</frameset>";
         echo "</html>";
         exit;
     }
     /// We can only get here once per resource, so add an entry to the log
     add_to_log($course->id, "resource", "view", "view.php?id={$cm->id}", $resource->id, $cm->id);
     /// If we are in a frameset, just print the top of it
     if (!empty($frameset) and $frameset == "top") {
         print_header($pagetitle, $course->fullname, $navigation, "", "", true, update_module_button($cm->id, $course->id, $this->strresource), navmenu($course, $cm, "parent"));
         echo '<div class="summary">' . format_text($resource->summary, FORMAT_HTML, $formatoptions) . '</div>';
         echo '</body></html>';
         exit;
     }
     /// Display the actual resource
     if ($embedded) {
         // Display resource embedded in page
         $strdirectlink = get_string("directlink", "resource");
         if ($inpopup) {
             print_header($pagetitle);
         } else {
             print_header($pagetitle, $course->fullname, $navigation, "", "", true, update_module_button($cm->id, $course->id, $this->strresource), navmenu($course, $cm, "self"));
         }
         if ($resourcetype == "image") {
             echo "<center><p>";
             echo "<img title=\"" . strip_tags(format_string($resource->name, true)) . "\" class=\"resourceimage\" src=\"{$fullurl}\" alt=\"\" />";
             echo "</p></center>";
         } else {
             if ($resourcetype == "mp3") {
                 if (!empty($THEME->resource_mp3player_colors)) {
                     $c = $THEME->resource_mp3player_colors;
                     // You can set this up in your theme/xxx/config.php
                 } else {
                     $c = 'bgColour=000000&btnColour=ffffff&btnBorderColour=cccccc&iconColour=000000&' . 'iconOverColour=00cc00&trackColour=cccccc&handleColour=ffffff&loaderColour=ffffff&' . 'font=Arial&fontColour=3333FF&buffer=10&waitForPlay=no&autoPlay=yes';
                 }
                 $c .= '&volText=' . get_string('vol', 'resource') . '&panText=' . get_string('pan', 'resource');
                 $c = htmlentities($c);
                 echo '<div class="mp3player" align="center">';
                 echo '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"';
                 echo '        codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" ';
                 echo '        width="600" height="70" id="mp3player" align="">';
                 echo '<param name="movie" value="' . $CFG->wwwroot . '/lib/mp3player/mp3player.swf?src=' . $fullurl . '">';
                 echo '<param name="quality" value="high">';
                 echo '<param name="bgcolor" value="#333333">';
                 echo '<param name="flashvars" value="' . $c . '&amp;" />';
                 echo '<embed src="' . $CFG->wwwroot . '/lib/mp3player/mp3player.swf?src=' . $fullurl . '" ';
                 echo ' quality="high" bgcolor="#333333" width="600" height="70" name="mp3player" ';
                 echo ' type="application/x-shockwave-flash" ';
                 echo ' flashvars="' . $c . '&amp;" ';
                 echo ' pluginspage="http://www.macromedia.com/go/getflashplayer">';
                 echo '</embed>';
                 echo '</object>';
                 echo '</div>';
             } else {
                 if ($resourcetype == "mediaplayer") {
                     echo "<center><p>";
                     echo '<object classid="CLSID:22D6f312-B0F6-11D0-94AB-0080C74C7E95"';
                     echo '        codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701" ';
                     echo '        standby="Loading Microsoft� Windows� Media Player components..." ';
                     echo '        id="msplayer" align="" type="application/x-oleobject">';
                     echo "<param name=\"Filename\" value=\"{$fullurl}\">";
                     echo '<param name="ShowControls" value="true" />';
                     echo '<param name="AutoRewind" value="true" />';
                     echo '<param name="AutoStart" value="true" />';
                     echo '<param name="Autosize" value="true" />';
                     echo '<param name="EnableContextMenu" value="true" />';
                     echo '<param name="TransparentAtStart" value="false" />';
                     echo '<param name="AnimationAtStart" value="false" />';
                     echo '<param name="ShowGotoBar" value="false" />';
                     echo '<param name="EnableFullScreenControls" value="true" />';
                     echo "\n<embed src=\"{$fullurl}\" name=\"msplayer\" type=\"{$mimetype}\" ";
                     echo ' ShowControls="1" AutoRewind="1" AutoStart="1" Autosize="0" EnableContextMenu="1"';
                     echo ' TransparentAtStart="0" AnimationAtStart="0" ShowGotoBar="0" EnableFullScreenControls="1"';
                     echo ' pluginspage="http://www.microsoft.com/Windows/Downloads/Contents/Products/MediaPlayer/">';
                     echo '</embed>';
                     echo '</object>';
                     echo "</p></center>";
                 } else {
                     if ($resourcetype == "quicktime") {
                         echo "<center><p>";
                         echo '<object classid="CLSID:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B"';
                         echo '        codebase="http://www.apple.com/qtactivex/qtplugin.cab" ';
                         echo '        height="450" width="600"';
                         echo '        id="quicktime" align="" type="application/x-oleobject">';
                         echo "<param name=\"src\" value=\"{$fullurl}\" />";
                         echo '<param name="autoplay" value="true" />';
                         echo '<param name="loop" value="true" />';
                         echo '<param name="controller" value="true" />';
                         echo '<param name="scale" value="aspect" />';
                         echo "\n<embed src=\"{$fullurl}\" name=\"quicktime\" type=\"{$mimetype}\" ";
                         echo ' height="450" width="600" scale="aspect"';
                         echo ' autoplay="true" controller="true" loop="true" ';
                         echo ' pluginspage="http://quicktime.apple.com/">';
                         echo '</embed>';
                         echo '</object>';
                         echo "</p></center>";
                     }
                 }
             }
         }
         if (trim($resource->summary)) {
             $formatoptions->noclean = true;
             print_simple_box(format_text($resource->summary, FORMAT_MOODLE, $formatoptions, $course->id), "center");
         }
         if ($inpopup) {
             echo "<center><p>(<a href=\"{$fullurl}\">{$strdirectlink}</a>)</p></center>";
         } else {
             print_spacer(20, 20);
             print_footer($course);
         }
     } else {
         // Display the resource on it's own
         redirect($fullurl);
     }
 }
 /**
  * Display the file resource
  *
  * Displays a file resource embedded, in a frame, or in a popup.
  * Output depends on type of file resource.
  *
  * @param    CFG     global object
  */
 function display()
 {
     global $CFG, $THEME, $USER;
     /// Set up generic stuff first, including checking for access
     parent::display();
     /// Set up some shorthand variables
     $cm = $this->cm;
     $course = $this->course;
     $resource = $this->resource;
     $this->set_parameters();
     // set the parameters array
     ///////////////////////////////////////////////
     /// Possible display modes are:
     /// File displayed embedded in a normal page
     /// File displayed in a popup window
     /// File displayed embedded in a popup window
     /// File not displayed at all, but downloaded
     /// First, find out what sort of file we are dealing with.
     require_once $CFG->libdir . '/filelib.php';
     $querystring = '';
     $resourcetype = '';
     $embedded = false;
     $mimetype = mimeinfo("type", $resource->reference);
     $pagetitle = strip_tags($course->shortname . ': ' . format_string($resource->name));
     $formatoptions = new object();
     $formatoptions->noclean = true;
     if ($resource->options != "forcedownload") {
         // TODO nicolasconnault 14-03-07: This option should be renamed "embed"
         if (in_array($mimetype, array('image/gif', 'image/jpeg', 'image/png'))) {
             // It's an image
             $resourcetype = "image";
             $embedded = true;
         } else {
             if ($mimetype == "audio/mp3") {
                 // It's an MP3 audio file
                 $resourcetype = "mp3";
                 $embedded = true;
             } else {
                 if ($mimetype == "video/x-flv") {
                     // It's a Flash video file
                     $resourcetype = "flv";
                     $embedded = true;
                 } else {
                     if (substr($mimetype, 0, 10) == "video/x-ms") {
                         // It's a Media Player file
                         $resourcetype = "mediaplayer";
                         $embedded = true;
                     } else {
                         if ($mimetype == "video/quicktime") {
                             // It's a Quicktime file
                             $resourcetype = "quicktime";
                             $embedded = true;
                         } else {
                             if ($mimetype == "application/x-shockwave-flash") {
                                 // It's a Flash file
                                 $resourcetype = "flash";
                                 $embedded = true;
                             } else {
                                 if ($mimetype == "video/mpeg") {
                                     // It's a Mpeg file
                                     $resourcetype = "mpeg";
                                     $embedded = true;
                                 } else {
                                     if ($mimetype == "text/html") {
                                         // It's a web page
                                         $resourcetype = "html";
                                     } else {
                                         if ($mimetype == "application/zip") {
                                             // It's a zip archive
                                             $resourcetype = "zip";
                                             $embedded = true;
                                         } else {
                                             if ($mimetype == 'application/pdf' || $mimetype == 'application/x-pdf') {
                                                 $resourcetype = "pdf";
                                                 //no need embedded, html file types behave like unknown file type
                                             } else {
                                                 if ($mimetype == "audio/x-pn-realaudio-plugin") {
                                                     // It's a realmedia file
                                                     $resourcetype = "rm";
                                                     $embedded = true;
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     $isteamspeak = stripos($resource->reference, 'teamspeak://') === 0;
     /// Form the parse string
     $querys = array();
     if (!empty($resource->alltext)) {
         $parray = explode(',', $resource->alltext);
         foreach ($parray as $fieldstring) {
             list($moodleparam, $urlname) = explode('=', $fieldstring);
             $value = urlencode($this->parameters[$moodleparam]['value']);
             $querys[urlencode($urlname)] = $value;
             $querysbits[] = urlencode($urlname) . '=' . $value;
         }
         if ($isteamspeak) {
             $querystring = implode('?', $querysbits);
         } else {
             $querystring = implode('&amp;', $querysbits);
         }
     }
     /// Set up some variables
     $inpopup = optional_param('inpopup', 0, PARAM_BOOL);
     if (resource_is_url($resource->reference)) {
         $fullurl = $resource->reference;
         if (!empty($querystring)) {
             $urlpieces = parse_url($resource->reference);
             if (empty($urlpieces['query']) or $isteamspeak) {
                 $fullurl .= '?' . $querystring;
             } else {
                 $fullurl .= '&amp;' . $querystring;
             }
         }
     } else {
         // Normal uploaded file
         $forcedownloadsep = '?';
         if ($resource->options == 'forcedownload') {
             $querys['forcedownload'] = '1';
         }
         $fullurl = get_file_url($course->id . '/' . $resource->reference, $querys);
     }
     /// Check whether this is supposed to be a popup, but was called directly
     if ($resource->popup and !$inpopup) {
         /// Make a page and a pop-up window
         $navigation = build_navigation($this->navlinks, $cm);
         print_header($pagetitle, $course->fullname, $navigation, "", "", true, update_module_button($cm->id, $course->id, $this->strresource), navmenu($course, $cm));
         echo "\n<script type=\"text/javascript\">";
         echo "\n<!--\n";
         echo "openpopup('/mod/resource/view.php?inpopup=true&id={$cm->id}','resource{$resource->id}','{$resource->popup}');\n";
         echo "\n-->\n";
         echo '</script>';
         if (trim(strip_tags($resource->summary))) {
             print_simple_box(format_text($resource->summary, FORMAT_MOODLE, $formatoptions), "center");
         }
         $link = "<a href=\"{$CFG->wwwroot}/mod/resource/view.php?inpopup=true&amp;id={$cm->id}\" " . "onclick=\"this.target='resource{$resource->id}'; return openpopup('/mod/resource/view.php?inpopup=true&amp;id={$cm->id}', " . "'resource{$resource->id}','{$resource->popup}');\">" . format_string($resource->name, true) . "</a>";
         echo '<div class="popupnotice">';
         print_string('popupresource', 'resource');
         echo '<br />';
         print_string('popupresourcelink', 'resource', $link);
         echo '</div>';
         print_footer($course);
         exit;
     }
     /// Now check whether we need to display a frameset
     $frameset = optional_param('frameset', '', PARAM_ALPHA);
     if (empty($frameset) and !$embedded and !$inpopup and $resource->options == "frame" || $resource->options == "objectframe" and empty($USER->screenreader)) {
         /// display the resource into a object tag
         if ($resource->options == "objectframe") {
             /// Yahoo javascript libaries for updating embedded object size
             require_js(array('yui_utilities'));
             require_js(array('yui_container'));
             require_js(array('yui_dom-event'));
             require_js(array('yui_dom'));
             /// Moodle Header and navigation bar
             $navigation = build_navigation($this->navlinks, $cm);
             print_header($pagetitle, $course->fullname, $navigation, "", "", true, update_module_button($cm->id, $course->id, $this->strresource), navmenu($course, $cm, "parent"));
             $options = new object();
             $options->para = false;
             echo '</div></div>';
             /// embedded file into iframe if the resource is on another domain
             ///
             /// This case is not XHTML strict but there is no alternative
             /// The object tag alternative is XHTML strict, however IE6-7 displays a blank object on accross domain by default,
             /// so we decided to use iframe for accross domain MDL-10021
             if (!stristr($fullurl, $CFG->wwwroot)) {
                 echo '<p><iframe id="embeddedhtml" src ="' . $fullurl . '" width="100%" height="600"></iframe></p>';
             } else {
                 /// embedded HTML file into an object tag
                 echo '<p><object id="embeddedhtml" data="' . $fullurl . '" type="' . $mimetype . '" width="800" height="600">
                         alt : <a href="' . $fullurl . '">' . $fullurl . '</a>
                       </object></p>';
             }
             /// add some javascript in order to fit this object tag into the browser window
             echo '<script type="text/javascript">
                          //<![CDATA[
                          function resizeEmbeddedHtml() {
                          //calculate new embedded html height size
                  ';
             if (!empty($resource->summary)) {
                 echo '    objectheight =  YAHOO.util.Dom.getViewportHeight() - 230;
                     ';
             } else {
                 echo '    objectheight =  YAHOO.util.Dom.getViewportHeight() - 120;
                      ';
             }
             echo '       //the object tag cannot be smaller than a human readable size
                          if (objectheight < 200) {
                              objectheight = 200;
                          }
                          //resize the embedded html object
                          YAHOO.util.Dom.setStyle("embeddedhtml", "height", objectheight+"px");
                          YAHOO.util.Dom.setStyle("embeddedhtml", "width", "100%");
                       }
                       resizeEmbeddedHtml();
                       YAHOO.widget.Overlay.windowResizeEvent.subscribe(resizeEmbeddedHtml);
                       //]]>
                    </script>
                 ';
             /// print the summary
             if (!empty($resource->summary)) {
                 print_simple_box(format_text($resource->summary, FORMAT_MOODLE, $formatoptions, $course->id), "center");
             }
             echo "</body></html>";
             add_to_log($course->id, "resource", "view", "view.php?id={$cm->id}", $resource->id, $cm->id);
             exit;
         } else {
             @header('Content-Type: text/html; charset=utf-8');
             echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Frameset//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd\">\n";
             echo "<html dir=\"ltr\">\n";
             echo '<head>';
             echo '<meta http-equiv="content-type" content="text/html; charset=utf-8" />';
             echo "<title>" . format_string($course->shortname) . ": " . strip_tags(format_string($resource->name, true)) . "</title></head>\n";
             echo "<frameset rows=\"{$CFG->resource_framesize},*\">";
             echo "<frame src=\"view.php?id={$cm->id}&amp;type={$resource->type}&amp;frameset=top\" title=\"" . get_string('modulename', 'resource') . "\"/>";
             echo "<frame src=\"{$fullurl}\" title=\"" . get_string('modulename', 'resource') . "\"/>";
             echo "</frameset>";
             echo "</html>";
             exit;
         }
     }
     /// We can only get here once per resource, so add an entry to the log
     add_to_log($course->id, "resource", "view", "view.php?id={$cm->id}", $resource->id, $cm->id);
     /// If we are in a frameset, just print the top of it
     if (!empty($frameset) and $frameset == "top") {
         // Force target atttributes on links.  Not Strict but we are already using frames anyway! MDL-20327
         $CFG->frametarget = ' target="' . $CFG->framename . '" ';
         $navigation = build_navigation($this->navlinks, $cm);
         print_header($pagetitle, $course->fullname, $navigation, "", "", true, update_module_button($cm->id, $course->id, $this->strresource), navmenu($course, $cm, "parent"));
         $options = new object();
         $options->para = false;
         echo '<div class="summary">' . format_text($resource->summary, FORMAT_HTML, $options) . '</div>';
         print_footer('empty');
         exit;
     }
     /// Display the actual resource
     if ($embedded) {
         // Display resource embedded in page
         $strdirectlink = get_string("directlink", "resource");
         if ($inpopup) {
             print_header($pagetitle);
         } else {
             $navigation = build_navigation($this->navlinks, $cm);
             print_header_simple($pagetitle, '', $navigation, "", "", true, update_module_button($cm->id, $course->id, $this->strresource), navmenu($course, $cm, "self"));
         }
         if ($resourcetype == "image") {
             echo '<div class="resourcecontent resourceimg">';
             echo "<img title=\"" . strip_tags(format_string($resource->name, true)) . "\" class=\"resourceimage\" src=\"{$fullurl}\" alt=\"\" />";
             echo '</div>';
         } else {
             if ($resourcetype == "mp3") {
                 if (!empty($THEME->resource_mp3player_colors)) {
                     $c = $THEME->resource_mp3player_colors;
                     // You can set this up in your theme/xxx/config.php
                 } else {
                     $c = 'bgColour=000000&btnColour=ffffff&btnBorderColour=cccccc&iconColour=000000&' . 'iconOverColour=00cc00&trackColour=cccccc&handleColour=ffffff&loaderColour=ffffff&' . 'font=Arial&fontColour=FF33FF&buffer=10&waitForPlay=no&autoPlay=yes';
                 }
                 $c .= '&volText=' . get_string('vol', 'resource') . '&panText=' . get_string('pan', 'resource');
                 $c = htmlentities($c);
                 $id = 'filter_mp3_' . time();
                 //we need something unique because it might be stored in text cache
                 $cleanurl = addslashes_js($fullurl);
                 // If we have Javascript, use UFO to embed the MP3 player, otherwise depend on plugins
                 echo '<div class="resourcecontent resourcemp3">';
                 echo '<span class="mediaplugin mediaplugin_mp3" id="' . $id . '"></span>' . '<script type="text/javascript">' . "\n" . '//<![CDATA[' . "\n" . 'var FO = { movie:"' . $CFG->wwwroot . '/lib/mp3player/mp3player.swf?src=' . $cleanurl . '",' . "\n" . 'width:"600", height:"70", majorversion:"6", build:"40", flashvars:"' . $c . '", quality: "high" };' . "\n" . 'UFO.create(FO, "' . $id . '");' . "\n" . '//]]>' . "\n" . '</script>' . "\n";
                 echo '<noscript>';
                 echo "<object type=\"audio/mpeg\" data=\"{$fullurl}\" width=\"600\" height=\"70\">";
                 echo "<param name=\"src\" value=\"{$fullurl}\" />";
                 echo '<param name="quality" value="high" />';
                 echo '<param name="autoplay" value="true" />';
                 echo '<param name="autostart" value="true" />';
                 echo '</object>';
                 echo '<p><a href="' . $fullurl . '">' . $fullurl . '</a></p>';
                 echo '</noscript>';
                 echo '</div>';
             } else {
                 if ($resourcetype == "flv") {
                     $id = 'filter_flv_' . time();
                     //we need something unique because it might be stored in text cache
                     $cleanurl = addslashes_js($fullurl);
                     // If we have Javascript, use UFO to embed the FLV player, otherwise depend on plugins
                     echo '<div class="resourcecontent resourceflv">';
                     echo '<span class="mediaplugin mediaplugin_flv" id="' . $id . '"></span>' . '<script type="text/javascript">' . "\n" . '//<![CDATA[' . "\n" . 'var FO = { movie:"' . $CFG->wwwroot . '/filter/mediaplugin/flvplayer.swf?file=' . $cleanurl . '",' . "\n" . 'width:"600", height:"400", majorversion:"6", build:"40", allowscriptaccess:"never", allowfullscreen:"true", quality: "high" };' . "\n" . 'UFO.create(FO, "' . $id . '");' . "\n" . '//]]>' . "\n" . '</script>' . "\n";
                     echo '<noscript>';
                     echo "<object type=\"video/x-flv\" data=\"{$fullurl}\" width=\"600\" height=\"400\">";
                     echo "<param name=\"src\" value=\"{$fullurl}\" />";
                     echo '<param name="quality" value="high" />';
                     echo '<param name="autoplay" value="true" />';
                     echo '<param name="autostart" value="true" />';
                     echo '</object>';
                     echo '<p><a href="' . $fullurl . '">' . $fullurl . '</a></p>';
                     echo '</noscript>';
                     echo '</div>';
                 } else {
                     if ($resourcetype == "mediaplayer") {
                         echo '<div class="resourcecontent resourcewmv">';
                         echo '<object type="video/x-ms-wmv" data="' . $fullurl . '">';
                         echo '<param name="controller" value="true" />';
                         echo '<param name="autostart" value="true" />';
                         echo "<param name=\"src\" value=\"{$fullurl}\" />";
                         echo '<param name="scale" value="noScale" />';
                         echo "<a href=\"{$fullurl}\">{$fullurl}</a>";
                         echo '</object>';
                         echo '</div>';
                     } else {
                         if ($resourcetype == "mpeg") {
                             echo '<div class="resourcecontent resourcempeg">';
                             echo '<object classid="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95"
                           codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsm p2inf.cab#Version=5,1,52,701"
                           type="application/x-oleobject">';
                             echo "<param name=\"fileName\" value=\"{$fullurl}\" />";
                             echo '<param name="autoStart" value="true" />';
                             echo '<param name="animationatStart" value="true" />';
                             echo '<param name="transparentatStart" value="true" />';
                             echo '<param name="showControls" value="true" />';
                             echo '<param name="Volume" value="-450" />';
                             echo '<!--[if !IE]>-->';
                             echo '<object type="video/mpeg" data="' . $fullurl . '">';
                             echo '<param name="controller" value="true" />';
                             echo '<param name="autostart" value="true" />';
                             echo "<param name=\"src\" value=\"{$fullurl}\" />";
                             echo "<a href=\"{$fullurl}\">{$fullurl}</a>";
                             echo '<!--<![endif]-->';
                             echo '<a href="' . $fullurl . '">' . $fullurl . '</a>';
                             echo '<!--[if !IE]>-->';
                             echo '</object>';
                             echo '<!--<![endif]-->';
                             echo '</object>';
                             echo '</div>';
                         } else {
                             if ($resourcetype == "rm") {
                                 echo '<div class="resourcecontent resourcerm">';
                                 echo '<object classid="clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA" width="320" height="240">';
                                 echo '<param name="src" value="' . $fullurl . '" />';
                                 echo '<param name="controls" value="All" />';
                                 echo '<!--[if !IE]>-->';
                                 echo '<object type="audio/x-pn-realaudio-plugin" data="' . $fullurl . '" width="320" height="240">';
                                 echo '<param name="controls" value="All" />';
                                 echo '<a href="' . $fullurl . '">' . $fullurl . '</a>';
                                 echo '</object>';
                                 echo '<!--<![endif]-->';
                                 echo '</object>';
                                 echo '</div>';
                             } else {
                                 if ($resourcetype == "quicktime") {
                                     echo '<div class="resourcecontent resourceqt">';
                                     echo '<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B"';
                                     echo '        codebase="http://www.apple.com/qtactivex/qtplugin.cab">';
                                     echo "<param name=\"src\" value=\"{$fullurl}\" />";
                                     echo '<param name="autoplay" value="true" />';
                                     echo '<param name="loop" value="true" />';
                                     echo '<param name="controller" value="true" />';
                                     echo '<param name="scale" value="aspect" />';
                                     echo '<!--[if !IE]>-->';
                                     echo "<object type=\"video/quicktime\" data=\"{$fullurl}\">";
                                     echo '<param name="controller" value="true" />';
                                     echo '<param name="autoplay" value="true" />';
                                     echo '<param name="loop" value="true" />';
                                     echo '<param name="scale" value="aspect" />';
                                     echo '<!--<![endif]-->';
                                     echo '<a href="' . $fullurl . '">' . $fullurl . '</a>';
                                     echo '<!--[if !IE]>-->';
                                     echo '</object>';
                                     echo '<!--<![endif]-->';
                                     echo '</object>';
                                     echo '</div>';
                                 } else {
                                     if ($resourcetype == "flash") {
                                         echo '<div class="resourcecontent resourceswf">';
                                         echo '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000">';
                                         echo "<param name=\"movie\" value=\"{$fullurl}\" />";
                                         echo '<param name="autoplay" value="true" />';
                                         echo '<param name="loop" value="true" />';
                                         echo '<param name="controller" value="true" />';
                                         echo '<param name="scale" value="aspect" />';
                                         echo '<param name="base" value="." />';
                                         echo '<!--[if !IE]>-->';
                                         echo "<object type=\"application/x-shockwave-flash\" data=\"{$fullurl}\">";
                                         echo '<param name="controller" value="true" />';
                                         echo '<param name="autoplay" value="true" />';
                                         echo '<param name="loop" value="true" />';
                                         echo '<param name="scale" value="aspect" />';
                                         echo '<param name="base" value="." />';
                                         echo '<!--<![endif]-->';
                                         echo '<a href="' . $fullurl . '">' . $fullurl . '</a>';
                                         echo '<!--[if !IE]>-->';
                                         echo '</object>';
                                         echo '<!--<![endif]-->';
                                         echo '</object>';
                                         echo '</div>';
                                     } elseif ($resourcetype == 'zip') {
                                         echo '<div class="resourcepdf">';
                                         echo get_string('clicktoopen', 'resource') . '<a href="' . $fullurl . '">' . format_string($resource->name) . '</a>';
                                         echo '</div>';
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
         if (trim($resource->summary)) {
             print_simple_box(format_text($resource->summary, FORMAT_MOODLE, $formatoptions, $course->id), "center");
         }
         if ($inpopup) {
             echo "<div class=\"popupnotice\">(<a href=\"{$fullurl}\">{$strdirectlink}</a>)</div>";
             print_footer($course);
             // MDL-12098
         } else {
             print_spacer(20, 20);
             print_footer($course);
         }
     } else {
         // Display the resource on it's own
         redirect($fullurl);
     }
 }
Exemplo n.º 10
0
/**
 * Prints blocks for a given position
 *
 * @param array $pageblocks An array of blocks organized by position
 * @param char $position Position that we are currently printing
 * @return void
 **/
function page_print_position($pageblocks, $position, $width)
{
    global $PAGE, $THEME;
    $editing = $PAGE->user_is_editing();
    if ($editing || blocks_have_content($pageblocks, $position)) {
        /// Figure out an appropriate ID
        switch ($position) {
            case BLOCK_POS_LEFT:
                $id = 'left';
                break;
            case BLOCK_POS_RIGHT:
                $id = 'right';
                break;
            case BLOCK_POS_CENTER:
                $id = 'middle';
                break;
            default:
                $id = $position;
                break;
        }
        /// Figure out the width - more for routine than being functional.  May want to impose a minimum width though
        $width = bounded_number($width, blocks_preferred_width($pageblocks[$position]), $width);
        /// Print it
        if (is_numeric($width)) {
            // default to px  MR-263
            $tdwidth = $width . 'px';
        } else {
            $tdwidth = $width;
        }
        echo "<td style=\"width: {$tdwidth}\" id=\"{$id}-column\">";
        if (is_numeric($width) or strpos($width, 'px')) {
            print_spacer(1, $width, false);
        }
        print_container_start();
        if ($position == BLOCK_POS_CENTER) {
            echo skip_main_destination();
            page_frontpage_settings();
        }
        page_blocks_print_group($pageblocks, $position);
        print_container_end();
        echo '</td>';
    } else {
        // Empty column - no class, style or width
        /// Figure out an appropriate ID
        switch ($position) {
            case BLOCK_POS_LEFT:
                $id = 'left';
                break;
            case BLOCK_POS_RIGHT:
                $id = 'right';
                break;
            case BLOCK_POS_CENTER:
                $id = 'middle';
                break;
            default:
                $id = $position;
                break;
        }
        // we still want to preserve values unles
        if ($width != '0') {
            if (is_numeric($width)) {
                // default to px  MR-263
                $tdwidth = $width . 'px';
            } else {
                $tdwidth = $width;
            }
            echo '<td style="width:' . $tdwidth . '" id="' . $id . '-column" > ';
            if ($width != '0' and is_numeric($width) or strpos($width, 'px')) {
                print_spacer(1, $width, false);
            }
            echo "</td>";
        } else {
            echo '<td></td>';
            // 0 means no column anyway
        }
    }
}
# This program is distributed under the terms and conditions of the GPL
# See the files README and LICENSE for details
# --------------------------------------------------------
# $Id: note_preview_page.php,v 1.12 2002/10/06 15:23:36 vboctor Exp $
# --------------------------------------------------------
require_once 'core' . DIRECTORY_SEPARATOR . 'api.php';
access_ensure_check_action(ACTION_NOTES_SUBMIT);
print_html_top();
print_head_top();
print_title($g_window_title);
print_css($g_css_inc_file);
theme_head();
print_head_bottom();
print_body_top();
print_header($g_page_title);
print_spacer();
$f_note_id = gpc_get_int('f_note_id');
$f_page_id = gpc_get_int('f_page_id');
$f_email = gpc_get_string('f_email');
$f_note = gpc_get_string('f_note');
$t_page_info = page_get_info(page_where_id_equals($f_page_id));
if (false === $t_page_info) {
    echo "page not found";
    exit;
}
$t_note['id'] = '0';
$t_note['email'] = string_prepare_note_for_viewing($f_email);
$t_note['date'] = time();
$t_note['note'] = string_prepare_note_for_viewing($f_note);
$t_page_data = array();
$t_page_data['id'] = 0;
 private static function render_diro(&$text, $depth, $name, $id, $path)
 {
     global $CFG;
     $text[] = str_repeat("\t", $depth + 1) . '<li class="r0">';
     $text[] = '<div title="' . htmlspecialchars(implode('/', $path)) . '" style="cursor:pointer;"' . ' onclick="return sharing_cart.toggle(this, ' . $id . ');">';
     $text[] = '<div class="column c0">';
     if ($depth) {
         $text[] = print_spacer(10, $depth * 10, false, true);
     }
     $text[] = '<img id="sharing_cart_' . $id . '_icon" src="' . $CFG->pixpath . '/i/open.gif" alt="" />' . '</div>';
     $text[] = '<div class="column c1">' . htmlspecialchars($name) . '</div>';
     $text[] = '</div>';
     $text[] = '<ul id="sharing_cart_' . $id . '_item" class="list">' . "\n";
 }
Exemplo n.º 13
0
function print_materials_selector($title, $variable1, $variable2)
{
    print_title($title);
    ?>
		<ul>
			<li ng-repeat="<?php 
    echo $variable1;
    ?>
 in dataModel.<?php 
    echo $variable1;
    ?>
">
				<?php 
    print_spacer();
    ?>
<span style="display:inline-block;width:6em;"><input type="checkbox" ng-model="<?php 
    echo $variable1;
    ?>
.value" ng-change="change()">{{<?php 
    echo $variable1;
    ?>
.text}}</input></span>
				<input type="checkbox" ng-model="<?php 
    echo $variable1;
    ?>
.surface" ng-change="change()">painting surface</input><br />
			</li>
		</ul>
		<?php 
    print_spacer();
    ?>
Other:
		<ul>
		<li ng-repeat="<?php 
    echo $variable2;
    ?>
 in dataModel.<?php 
    echo $variable2;
    ?>
">
<?php 
    print_remove($variable2);
    ?>
<input type="text" ng-model="<?php 
    echo $variable2;
    ?>
.text"
			  typeahead="label as label.display for label in suggestWikidata($viewValue, $index)"
   	    typeahead-min-length="1" typeahead-on-select="onSelectLine('<?php 
    echo $variable2;
    ?>
', $item)" size="65" />
	<input type="checkbox" ng-model="<?php 
    echo $variable2;
    ?>
.surface" ng-change="change()">painting surface</input><br ng-if="<?php 
    echo $variable2;
    ?>
.wikidata" />
	<small><span class="separator" style="width:30px;">&nbsp;</span><span ng-if="<?php 
    echo $variable2;
    ?>
.wikidata">{{<?php 
    echo $variable2;
    ?>
.description}}</span><span ng-if="<?php 
    echo $variable2;
    ?>
.wikidata"> &middot;
	<a href="https://www.wikidata.org/wiki/{{<?php 
    echo $variable2;
    ?>
.wikidata}}">{{<?php 
    echo $variable2;
    ?>
.wikidata}}</a></span></small>
		</li>
		</ul>
<?php 
    print_add_line($variable2);
}
Exemplo n.º 14
0
    function setup_elements(&$mform)
    {
        global $CFG;
        require_once $CFG->libdir . '/biblelib.php';
        //remove these so we have ui control of where name goes later
        $mform->removeElement('general');
        $mform->removeElement('name');
        /// sermon date
        $mform->addElement('html', '<table id="sermondetails-table" border="0" width="100%">
                                        <tr><td>');
        $mform->addElement('static', null, null, '<span class="sermon-delivery-title">' . get_string('sermonddeliverydate', 'resource') . '</span>');
        $mform->addElement('html', '<div id="datedelivered-picker"></div>' . '<script type="text/javascript">
                                jQuery(document).ready(function () {
                                    jQuery("#datedelivered-picker").datepicker({ dateFormat: "@", 
                                                                                 onSelect: function(dateText, inst){jQuery(".datedelivered").val(dateText)},
                                                                                 defaultDate: jQuery(".datedelivered").val()
                                    });

                                    
                                })
                            </script>' . print_spacer(0, 250, false, true) . '
                        </td><td>');
        $mform->addElement('hidden', 'datedelivered', 'testing', array('class' => 'datedelivered'));
        /// sermon info
        mform_partition_start($mform);
        $mform->addElement('text', 'name', get_string('name'), array('size' => '48'));
        if (!empty($CFG->formatstringstriptags)) {
            $mform->setType('name', PARAM_TEXT);
        } else {
            $mform->setType('name', PARAM_CLEAN);
        }
        $mform->addRule('name', null, 'required', null, 'client');
        $previousseries = get_recordset_sql("SELECT DISTINCT seriesname FROM {$CFG->prefix}resource_sermon ORDER BY seriesname DESC");
        $seriesoptions = array(0 => get_string('selectpreviousseries', 'resource'));
        while (($series = rs_fetch_next_record($previousseries)) !== false) {
            $seriesoptions[$series->seriesname] = $series->seriesname;
        }
        $mform->addElement('select', 'seriesname', get_string('series', 'resource'), $seriesoptions);
        mform_spacer($mform, null, get_string('or', 'resource'));
        $newseries = array();
        $newseries[] =& MoodleQuickForm::createelement('text', 'newseriesname', get_string('newseriesname', 'resource'));
        $newseries[] =& MoodleQuickForm::createelement('checkbox', 'newseries', get_string('newseries', 'resource'));
        $mform->addGroup($newseries, null, get_string('newseriesname', 'resource'));
        $mform->disabledIf('newseriesname', 'newseries', 'notchecked');
        $mform->disabledIf('seriesname', 'newseries', 'checked');
        mform_partition_end($mform);
        mform_partition_start($mform);
        /// link to sermon mp3
        $mform->addElement('html', '<span class="nowrap">');
        $mform->addElement('choosecoursefile', 'reference', get_string('sermonmp3', 'resource'), null, array('maxlength' => 255, 'size' => 18));
        $mform->addGroupRule('reference', array('value' => array(array(get_string('maximumchars', '', 255), 'maxlength', 255, 'server'))));
        $mform->addRule('reference', null, 'required', null, 'client');
        $mform->addElement('html', '</span>');
        /// link to sermon pdf
        $mform->addElement('html', '<span class="nowrap">');
        $mform->addElement('choosecoursefile', 'referencesermontext', get_string('sermontext', 'resource'), null, array('maxlength' => 255, 'size' => 18));
        $mform->addGroupRule('referencesermontext', array('value' => array(array(get_string('maximumchars', '', 255), 'maxlength', 255, 'client'))));
        $mform->addElement('html', '</span>');
        /// link to reference lesson
        $mform->addElement('html', '<span class="nowrap">');
        $mform->addElement('choosecoursefile', 'referencelesson', get_string('sermonlesson', 'resource'), null, array('maxlength' => 255, 'size' => 18));
        $mform->addGroupRule('referencelesson', array('value' => array(array(get_string('maximumchars', '', 255), 'maxlength', 255, 'client'))));
        $mform->addElement('html', '</span>');
        mform_partition_end($mform);
        /// add the bible place fields
        mform_partition_start($mform);
        $mform->addElement('html', '<span class="nowrap">');
        $biblebooks = array_merge(array('' => get_string('choosebook', 'resource')), biblebooks_array());
        $bibleplace = array();
        $bibleplace[] =& MoodleQuickForm::createElement('select', 'book', get_string('biblebook', 'resource'), $biblebooks);
        $bibleplace[] =& MoodleQuickForm::createElement('text', 'beginchapter', get_string('beginchapter', 'resource'), 'size="5"');
        $mform->addGroup($bibleplace, null, get_string('biblebook', 'resource'), get_string('biblechapter', 'resource'));
        $mform->addElement('html', '</span>');
        mform_partition_end($mform);
        /// speaker fields
        mform_partition_start($mform);
        //these are a list of members with the ones who have given sermons in the past at the top of the list
        $potentialspeakers = get_recordset_sql("SELECT DISTINCT u.* FROM {$CFG->prefix}user u \n                                                    LEFT JOIN {$CFG->prefix}resource_sermon rs ON u.id = rs.speakerid\n                                                    LEFT JOIN {$CFG->prefix}user u2 ON u2.id = rs.speakerid\n                                                WHERE u.username != 'guest'\n                                                ORDER BY u2.lastname ASC, u.lastname ASC");
        $speakeroptions = array(0 => get_string('selectfromexistinguser', 'resource'));
        while (($potentialspeaker = rs_fetch_next_record($potentialspeakers)) !== false) {
            $speakeroptions[$potentialspeaker->id] = $potentialspeaker->lastname . ', ' . $potentialspeaker->firstname;
        }
        $mform->addElement('select', 'speakerid', get_string('speakerbyid', 'resource'), $speakeroptions);
        mform_spacer($mform, null, get_string('or', 'resource'));
        $guestspeakergroup = array();
        $guestspeakergroup[] =& MoodleQuickForm::createElement('text', 'guestspeakername', get_string('guestspeakername', 'resource'));
        $guestspeakergroup[] =& MoodleQuickForm::createElement('checkbox', 'guestspeaker', null);
        $mform->addGroup($guestspeakergroup, null, get_string('guestspeakername', 'resource'));
        $mform->disabledIf('guestspeakername', 'guestspeaker', 'notchecked');
        $mform->disabledIf('speakerid', 'guestspeaker', 'checked');
        mform_partition_end($mform);
        /// searchable sermon text
        $mform->addElement('static', 'label', '<span class="searchsermontxt">' . get_string('searchablesermontext', 'resource') . '</span>');
        $mform->addElement('textarea', 'searchablesermontext', null, array('rows' => 10, 'cols' => 70));
        $mform->setType('searchablesermontext', PARAM_TEXT);
        $mform->addElement('html', '</td></tr></table>');
        // no need for description
        $mform->removeElement('summary');
    }
Exemplo n.º 15
0
                </td>
            </tr>
        </table>
    </td>
<?php 
print '<!-- End page content -->' . "\n";
// The right column
if (blocks_have_content($pageblocks, BLOCK_POS_RIGHT) || $editing) {
    echo '<td style="vertical-align: top; width: ' . $preferred_width_right . 'px;" id="right-column">';
    echo '<!-- Begin right side blocks -->' . "\n";
    blocks_print_group($PAGE, $pageblocks, BLOCK_POS_RIGHT);
    print_spacer(1, 120, true);
    echo '<!-- End right side blocks -->' . "\n";
    echo '</td>';
}
?>

    </tr>
</table>

<?php 
print_footer($course);
Exemplo n.º 16
0
function fn_print_mandatory_section(&$course, &$mods, &$modnamesused, &$sections)
{
    global $CFG, $USER, $THEME;
    $labeltext = '';
    $activitytext = '';
    /// Determine order using all sections.
    $orderedmods = array();
    foreach ($sections as $section) {
        $modseq = explode(",", $section->sequence);
        if (!empty($modseq)) {
            foreach ($modseq as $modnum) {
                if (!empty($mods[$modnum]) && $mods[$modnum]->mandatory && $mods[$modnum]->visible) {
                    $orderedmods[] = $mods[$modnum];
                }
            }
        }
    }
    $modinfo = unserialize($course->modinfo);
    foreach ($orderedmods as $mod) {
        if ($mod->mandatory && $mod->visible) {
            $instancename = urldecode($modinfo[$mod->id]->name);
            if (!empty($CFG->filterall)) {
                $instancename = filter_text("<nolink>{$instancename}</nolink>", $course->id);
            }
            if (!empty($modinfo[$mod->id]->extra)) {
                $extra = urldecode($modinfo[$mod->id]->extra);
            } else {
                $extra = "";
            }
            if (!empty($modinfo[$mod->id]->icon)) {
                $icon = "{$CFG->pixpath}/" . urldecode($modinfo[$mod->id]->icon);
            } else {
                $icon = "{$CFG->modpixpath}/{$mod->modname}/icon.gif";
            }
            if ($mod->indent) {
                print_spacer(12, 20 * $mod->indent, false);
            }
            if ($mod->modname == "label") {
                if (!$mod->visible) {
                    $labeltext .= "<span class=\"dimmed_text\">";
                }
                $labeltext .= format_text($extra, FORMAT_HTML);
                if (!$mod->visible) {
                    $labeltext .= "</span>";
                }
                $labeltext .= '<br />';
            } else {
                if ($mod->modname == "resource") {
                    $linkcss = $mod->visible ? "" : " class=\"dimmed\" ";
                    $alttext = isset($link_title[$mod->modname]) ? $link_title[$mod->modname] : $mod->modfullname;
                    $labeltext .= "<img src=\"{$icon}\"" . " height=16 width=16 alt=\"{$alttext}\">" . " <font size=2><a title=\"{$alttext}\" {$linkcss} {$extra}" . " href=\"{$CFG->wwwroot}/mod/{$mod->modname}/view.php?id={$mod->id}\">{$instancename}</a></font><br />";
                } else {
                    // Normal activity
                    $act_compl = is_activity_complete($mod, $USER->id);
                    if ($act_compl === false) {
                        $linkcss = $mod->visible ? "" : " class=\"dimmed\" ";
                        $alttext = isset($link_title[$mod->modname]) ? $link_title[$mod->modname] : $mod->modfullname;
                        $activitytext .= "<img src=\"{$icon}\"" . " height=16 width=16 alt=\"{$alttext}\">" . " <font size=2><a title=\"{$alttext}\" {$linkcss} {$extra}" . " href=\"{$CFG->wwwroot}/mod/{$mod->modname}/view.php?id={$mod->id}\">{$instancename}</a></font><br />";
                    }
                }
            }
        }
    }
    print_simple_box('<div align="right">' . $labeltext . '</div>', 'center', '100%');
    //    print_simple_box('<div align="left">'.$activitytext.'</div>', 'center', '100%');
}
Exemplo n.º 17
0
function email_convert_tree_to_html($tree, $row = 0)
{
    $str = "\n" . '<ul class="tabrow' . $row . '">' . "\n";
    $first = true;
    $count = count($tree);
    foreach ($tree as $tab) {
        $count--;
        // countdown to zero
        $liclass = '';
        if ($first && $count == 0) {
            // Just one in the row
            $liclass = 'first last';
            $first = false;
        } else {
            if ($first) {
                $liclass = 'first';
                $first = false;
            } else {
                if ($count == 0) {
                    $liclass = 'last';
                }
            }
        }
        if (empty($tab->subtree) && !empty($tab->selected)) {
            $liclass .= empty($liclass) ? 'onerow' : ' onerow';
        }
        if ($tab->inactive || $tab->active || $tab->selected && !$tab->linkedwhenselected) {
            if ($tab->selected) {
                $liclass .= empty($liclass) ? 'here selected' : ' here selected';
            } else {
                if ($tab->active) {
                    $liclass .= empty($liclass) ? 'here active' : ' here active';
                }
            }
        }
        $str .= !empty($liclass) ? '<li class="' . $liclass . '">' : '<li>';
        if ($tab->inactive || $tab->active || $tab->selected && !$tab->linkedwhenselected) {
            $str .= '<a href="#" title="' . $tab->title . '"><span>' . $tab->text . print_spacer(1, 4, false, true) . $tab->img . '</span></a>';
        } else {
            $str .= '<a href="' . $tab->link . '" title="' . $tab->title . '"><span>' . $tab->text . print_spacer(1, 4, false, true) . $tab->img . '</span></a>';
        }
        if (!empty($tab->subtree)) {
            $str .= convert_tree_to_html($tab->subtree, $row + 1);
        } else {
            if ($tab->selected) {
                $str .= '<div class="tabrow' . ($row + 1) . ' empty">&nbsp;</div>' . "\n";
            }
        }
        $str .= ' </li>' . "\n";
    }
    $str .= '</ul>' . "\n";
    return $str;
}
Exemplo n.º 18
0
if ($page == "correction.php") {
    $navigation = build_navigation(array(array('name' => $blended->name, 'link' => "../../mod/blended/view.php?a={$blended->id}", 'type' => 'misc'), array('name' => $strcorrectionpage, 'link' => "../../mod/blended/correction.php?a={$blended->id}", 'type' => 'misc'), array('name' => $strjobstatuspage, 'link' => null, 'type' => 'misc')));
    print_header("{$course->shortname}: {$blended->name}: {$strjobstatuspage}", "{$course->shortname}", $navigation, "", "", true, update_module_button($cm->id, $course->id, $blended->name, $strjobstatuspage), navmenu($course, $cm));
}
print_spacer(20);
print_box(format_text($strtable), 'generalbox', 'intro');
print_spacer(20);
// Print the main part of the page ----------------------------------
print_spacer(20);
if ($page == "scan.php") {
    print_heading(format_string(get_string('scan', 'blended')));
}
if ($page == "correction.php") {
    print_heading(format_string(get_string('correction', 'blended')));
}
print_box(format_text(get_string('jobstatusdesc', 'blended')), 'generalbox', 'intro');
print_spacer(20);
$message = get_status_message($jobid);
show_status_message($jobid, $message, $context, $blended, $page);
if ($page == "scan.php") {
    $volver = "{$CFG->wwwroot}/mod/blended/scan.php?a={$a}";
}
if ($page == "correction.php") {
    $volver = "{$CFG->wwwroot}/mod/blended/correction.php?a={$a}";
}
print_spacer(100);
print_continue($volver);
echo "<BR><BR><center>";
helpbutton($page = 'jobstatus', get_string('pagehelp', 'blended'), $module = 'blended', $image = true, $linktext = true, $text = '', $return = false, $imagetext = '');
echo "</center>";
print_footer($course);
Exemplo n.º 19
0
 function print_html_report(&$tables)
 {
     $count = count($tables);
     foreach ($tables as $i => $table) {
         $this->print_html_start($table);
         $this->print_html_head($table);
         $this->print_html_data($table);
         $this->print_html_stat($table);
         $this->print_html_foot($table);
         $this->print_html_finish($table);
         if ($i + 1 < $count) {
             print_spacer(30, 10, true);
         }
     }
 }
Exemplo n.º 20
0
    /**
     * This function return an HTML code for display this eMail
     */
    function get_html($courseid, $folderid, $urlpreviousmail, $urlnextmail, $baseurl, $override = false)
    {
        global $USER, $CFG;
        $html = '';
        $html .= '<table class="sitetopic" border="0" cellpadding="5" cellspacing="0" width="100%">';
        $html .= '<tr class="headermail">';
        $html .= '<td style="border-left: 1px solid black; border-top:1px solid black" width="7%" align="center">';
        // Get user picture
        $user = get_record('user', 'id', $this->userid);
        $html .= print_user_picture($this->userid, $this->course, $user->picture, 0, true, false);
        $html .= '</td>';
        $html .= '<td style="border-right: 1px solid black; border-top:1px solid black" align="left" colspan="2">';
        $html .= $this->subject;
        $html .= '</td>';
        $html .= '</tr>';
        $html .= '<tr>';
        $html .= '<td  style="border-left: 1px solid black; border-right: 1px solid black; border-top:1px solid black" align="left" colspan="3">';
        $html .= '&nbsp;&nbsp;&nbsp;';
        $html .= '<b> ' . get_string('from', 'block_email_list') . ':</b>&nbsp;';
        $html .= $this->get_fullname_writer($override);
        $html .= '</td>';
        $html .= '</tr>';
        $html .= '<tr>';
        $userstosendto = $this->get_users_send('to');
        $html .= '<td style="border-left: 1px solid black;" width="80%" align="left" colspan="2">';
        $html .= '&nbsp;&nbsp;&nbsp;';
        if ($userstosendto != '') {
            $html .= '<b> ' . get_string('for', 'block_email_list') . ':</b>&nbsp;';
            $html .= $this->get_users_send('to');
        }
        $html .= '</td>';
        $html .= '<td style="border-right: 1px solid black;" width="20%">';
        if ($urlnextmail or $urlpreviousmail) {
            $html .= "&nbsp;&nbsp;&nbsp;||&nbsp;&nbsp;&nbsp;";
        }
        if ($urlpreviousmail) {
            $html .= '<a href="view.php?' . $urlpreviousmail . '">' . get_string('previous', 'block_email_list') . '</a>';
        }
        if ($urlnextmail) {
            if ($urlpreviousmail) {
                $html .= '&nbsp;|&nbsp;';
            }
            $html .= '<a href="view.php?' . $urlnextmail . '">' . get_string('next', 'block_email_list') . '</a>';
        }
        $html .= '&nbsp;&nbsp;';
        $html .= '</td>';
        $html .= '</tr>';
        $userstosendcc = $this->get_users_send('cc');
        if ($userstosendcc != '') {
            $html .= '<tr>
	                    <td  style="border-left: 1px solid black; border-right: 1px solid black;" align="left" colspan="3">
	                        &nbsp;&nbsp;&nbsp;
	                        <b> ' . get_string('cc', 'block_email_list') . ':</b>&nbsp;' . $userstosendcc . '
	                    </td>
	                </tr>';
        }
        // Drop users sending by bcc if user isn't writer
        if ($userstosendbcc = $this->get_users_send('bcc') != '' and $USER->id != $this->userid) {
            $html .= '<tr>
	                    <td  style="border-left: 1px solid black; border-right: 1px solid black;" align="left" colspan="3">
	                        &nbsp;&nbsp;&nbsp;
	                        <b> ' . get_string('bcc', 'block_email_list') . ':</b>&nbsp;' . $userstosendbcc . '
	                    </td>
	                </tr>';
        }
        $html .= '<tr>';
        $html .= '<td style="border-left: thin solid black; border-right: 1px solid black" width="60%" align="left" colspan="3">';
        $html .= '&nbsp;&nbsp;&nbsp;';
        $html .= '<b> ' . get_string('date', 'block_email_list') . ':</b>&nbsp;';
        $html .= userdate($this->timecreated);
        $html .= '</td>';
        $html .= '</tr>';
        $html .= '<tr>';
        $html .= '<td style="border: 1px solid black" colspan="3" align="left">';
        $html .= '<br />';
        // Options for display body
        $options = new object();
        $options->filter = true;
        $html .= format_text($this->body, FORMAT_HTML, $options);
        if ($this->has_attachments()) {
            $html .= $this->_get_format_attachments();
        }
        $html .= '<br />';
        $html .= '<br />';
        $html .= '</td>';
        $html .= '</tr>';
        $html .= '<tr class="messagelinks">';
        $html .= '<td align="right" colspan="3">';
        $html .= '<a href="sendmail.php?' . $baseurl . '&amp;action=' . EMAIL_REPLY . '"><b>' . get_string('reply', 'block_email_list') . '</b></a>';
        $html .= ' | ';
        $html .= '<a href="sendmail.php?' . $baseurl . '&amp;action=' . EMAIL_REPLYALL . '"><b>' . get_string('replyall', 'block_email_list') . '</b></a>';
        $html .= ' | ';
        $html .= '<a href="sendmail.php?' . $baseurl . '&amp;action=' . EMAIL_FORWARD . '"><b>' . get_string('forward', 'block_email_list') . '</b></a>';
        $html .= ' | ';
        $html .= '<a href="index.php?id=' . $courseid . '&amp;mailid=' . $this->id . '&amp;folderid=' . $folderid . '&amp;action=removemail"><b>' . get_string('removemail', 'block_email_list') . '</b></a>';
        $html .= ' | ';
        $icon = '<img src="' . $CFG->wwwroot . '/blocks/email_list/email/images/printer.png" height="16" width="16" alt="' . get_string('print', 'block_email_list') . '" />';
        $html .= email_print_to_popup_window('link', '/blocks/email_list/email/print.php?courseid=' . $courseid . '&amp;mailids=' . $this->id, '<b>' . get_string('print', 'block_email_list') . '</b>' . print_spacer(1, 3, false, true) . $icon, get_string('print', 'block_email_list'), true);
        $html .= '</td>';
        $html .= '</tr>';
        $html .= '</table>';
        return $html;
    }
Exemplo n.º 21
0
/**
 * Prints blocks for a given position
 *
 * @param array $pageblocks An array of blocks organized by position
 * @param char $position Position that we are currently printing
 * @return void
 **/
function page_print_position($pageblocks, $position, $width)
{
    global $PAGE, $THEME;
    $editing = $PAGE->user_is_editing();
    /// Figure out an appropriate ID
    switch ($position) {
        case BLOCK_POS_LEFT:
            $id = 'left';
            break;
        case BLOCK_POS_RIGHT:
            $id = 'right';
            break;
        case BLOCK_POS_CENTER:
            $id = 'middle';
            break;
        default:
            $id = $position;
            break;
    }
    /// Figure out the width - more for routine than being functional.  May want to impose a minimum width though
    $width = bounded_number($width, blocks_preferred_width($pageblocks[$position]), $width);
    $widthstyle = "";
    if ($width > 1) {
        $widthstyle = 'style="width: ' . $width . 'px"';
    }
    if ($editing || blocks_have_content($pageblocks, $position)) {
        /// Print it
        echo "<td {$widthstyle} id=\"{$id}-column\">";
        print_spacer(1, $width, false);
        if (!empty($THEME->roundcorners)) {
            echo '<div class="bt"><div></div></div>';
            echo '<div class="i1"><div class="i2"><div class="i3">';
        }
        page_blocks_print_group($pageblocks, $position);
        if (!empty($THEME->roundcorners)) {
            echo '</div></div></div>';
            echo '<div class="bb"><div></div></div>';
        }
        echo '</td>';
    } else {
        // just print space to keep width consistent
        echo "<td {$widthstyle} id=\"{$id}-column\">";
        print_spacer(1, $width, false);
        echo "</td>";
    }
}
Exemplo n.º 22
0
/**
* hook to print extra stuff at the bottom of the user view page
*
* @param object $user user being viewed
* @param object $course course being viewed (often SITE)
*/
function local_user_view($user, $course)
{
    global $CFG, $USER, $MNET;
    if ($CFG->mnet_dispatcher_mode == 'strict') {
        require_once $CFG->dirroot . '/mnet/xmlrpc/client.php';
        //mnet client library
        /// Setup MNET environment
        if (empty($MNET)) {
            $MNET = new mnet_environment();
            $MNET->init();
        }
        /// Setup the server
        $host = get_record('mnet_host', 'name', 'localmahara');
        //we retrieve the server(host) from the 'mnet_host' table
        if (!empty($host)) {
            $users[] = $user->username;
            $mnet_peer = new mnet_peer();
            //we create a new mnet_peer (server/host)
            $mnet_peer->set_wwwroot($host->wwwroot);
            //we set this mnet_peer with the host http address
            //now call the method and get data
            $client = new mnet_xmlrpc_client();
            //create a new client
            $client->set_method('local/mahara/rpclib.php/get_user_ids');
            //tell it which method we're going to call
            $client->add_param($users);
            $client->send($mnet_peer);
            //Call the server
            //Receive the server response
            if (!empty($client->response[$user->username])) {
                $mahurl = $CFG->wwwroot . '/auth/mnet/jump.php?hostid=' . $host->id . '&wantsurl=user/view.php?id=' . $client->response[$user->username];
                echo '<p align=center><a href="' . $mahurl . '">' . get_string('viewmaharaprofile', 'local') . '</a></p>';
            }
        }
    }
    if ($USER->id != $user->id) {
        // include the add as friend button
        print_spacer(10);
        echo '<table width="80%" class="userinfobox" summary="">';
        echo '<tr>';
        echo '<td class="content">';
        $url = $CFG->wwwroot . '/local/user/friend.php';
        $options['userid'] = $user->id;
        $a->user = $user->firstname;
        if ($userfriend = get_record('user_friend', 'userid', $USER->id, 'friendid', $user->id)) {
            if ($userfriend->approved) {
                // already friend
                echo '<p align=center>' . get_string('arefriend', 'local', $a) . '</p>';
                $options['action'] = 'unfriend';
                $buttonstr = get_string('removefriend', 'local');
            } else {
                //waiting for approval.
                echo '<p align=center>' . get_string('friendapprovalneeded', 'local', $a) . '</p>';
                $options['action'] = 'unfriend';
                $buttonstr = get_string('removefriendrequest', 'local');
            }
        } else {
            $buttonstr = get_string('requestfriend', 'local');
        }
        echo '<div class="buttons">';
        print_single_button($url, $options, $buttonstr);
        echo '</div>';
        echo '</td>';
        echo '</tr>';
        echo '</table>';
        // include the assign user button
        print_spacer(10);
        echo '<table width="80%" class="userinfobox" summary="">';
        echo '<tr>';
        echo '<td class="content">';
        tao_can_assign_user($user, $course);
        echo '</td>';
        echo '</tr>';
        echo '</table>';
    }
    // include similar users
    /** HIDE THIS
        print_spacer(10);
        echo '<table width="80%" class="userinfobox" summary="">';
        echo '<tr>';
        echo '<td class="content">';
        echo $buttonstr = get_string('similarusers', 'local') . ':';
        tao_print_similar_users($user);
        echo '</td>';
        echo '</tr>';
        echo '</table>';
    **/
}
function print_section_newsroom($course, $section, $mods, $modnamesused, $absolute = false, $width = "100%")
{
    /// Prints a section full of activity modules
    global $CFG, $USER;
    static $initialised;
    static $groupbuttons;
    static $groupbuttonslink;
    static $isediting;
    static $ismoving;
    static $strmovehere;
    static $strmovefull;
    static $strunreadpostsone;
    static $usetracking;
    static $groupings;
    if (!isset($initialised)) {
        $groupbuttons = ($course->groupmode or !$course->groupmodeforce);
        $groupbuttonslink = !$course->groupmodeforce;
        $isediting = isediting($course->id);
        $ismoving = $isediting && ismoving($course->id);
        if ($ismoving) {
            $strmovehere = get_string("movehere");
            $strmovefull = strip_tags(get_string("movefull", "", "'{$USER->activitycopyname}'"));
        }
        include_once $CFG->dirroot . '/mod/forum/lib.php';
        if ($usetracking = forum_tp_can_track_forums()) {
            $strunreadpostsone = get_string('unreadpostsone', 'forum');
        }
        $initialised = true;
    }
    $labelformatoptions = new object();
    $labelformatoptions->noclean = true;
    /// Casting $course->modinfo to string prevents one notice when the field is null
    $modinfo = get_fast_modinfo($course);
    //Acccessibility: replace table with list <ul>, but don't output empty list.
    if (!empty($section->sequence)) {
        // Fix bug #5027, don't want style=\"width:$width\".
        echo "<ul class=\"section img-text\">\n";
        $sectionmods = explode(",", $section->sequence);
        foreach ($sectionmods as $modnumber) {
            if (empty($mods[$modnumber])) {
                continue;
            }
            $mod = $mods[$modnumber];
            if ($ismoving and $mod->id == $USER->activitycopy) {
                // do not display moving mod
                continue;
            }
            if (isset($modinfo->cms[$modnumber])) {
                if (!$modinfo->cms[$modnumber]->uservisible) {
                    // visibility shortcut
                    continue;
                }
            } else {
                if (!file_exists("{$CFG->dirroot}/mod/{$mod->modname}/lib.php")) {
                    // module not installed
                    continue;
                }
                if (!coursemodule_visible_for_user($mod)) {
                    // full visibility check
                    continue;
                }
            }
            // The magic! ... if indent == 1 then ... hide module
            if ($mod->indent == 1) {
                $hiddemodule = 'hidden';
            } else {
                $hiddemodule = '';
            }
            echo '<li class="activity ' . $mod->modname . ' ' . $hiddemodule . '" id="module-' . $modnumber . '">';
            // Unique ID
            if ($ismoving) {
                echo '<a title="' . $strmovefull . '"' . ' href="' . $CFG->wwwroot . '/course/mod.php?moveto=' . $mod->id . '&amp;sesskey=' . $USER->sesskey . '">' . '<img class="movetarget" src="' . $CFG->pixpath . '/movehere.gif" ' . ' alt="' . $strmovehere . '" /></a><br />
                     ';
            }
            if ($mod->indent) {
                print_spacer(12, 20 * $mod->indent, false);
            }
            $extra = '';
            if (!empty($modinfo->cms[$modnumber]->extra)) {
                $extra = $modinfo->cms[$modnumber]->extra;
            }
            if ($mod->modname == "label") {
                echo "<span class=\"";
                if (!$mod->visible) {
                    echo 'dimmed_text';
                } else {
                    echo 'label';
                }
                echo '">';
                echo format_text($extra, FORMAT_HTML, $labelformatoptions);
                echo "</span>";
                if (!empty($CFG->enablegroupings) && !empty($mod->groupingid) && has_capability('moodle/course:managegroups', get_context_instance(CONTEXT_COURSE, $course->id))) {
                    if (!isset($groupings)) {
                        $groupings = groups_get_all_groupings($course->id);
                    }
                    echo " <span class=\"groupinglabel\">(" . format_string($groupings[$mod->groupingid]->name) . ')</span>';
                }
            } else {
                // Normal activity
                $instancename = format_string($modinfo->cms[$modnumber]->name, true, $course->id);
                if (!empty($modinfo->cms[$modnumber]->icon)) {
                    $icon = "{$CFG->pixpath}/" . $modinfo->cms[$modnumber]->icon;
                } else {
                    $icon = "{$CFG->modpixpath}/{$mod->modname}/icon.gif";
                }
                //Accessibility: for files get description via icon.
                $altname = '';
                if ('resource' == $mod->modname) {
                    if (!empty($modinfo->cms[$modnumber]->icon)) {
                        $possaltname = $modinfo->cms[$modnumber]->icon;
                        $mimetype = mimeinfo_from_icon('type', $possaltname);
                        $altname = get_mimetype_description($mimetype);
                    } else {
                        $altname = $mod->modfullname;
                    }
                } else {
                    $altname = $mod->modfullname;
                }
                // Avoid unnecessary duplication.
                if (false !== stripos($instancename, $altname)) {
                    $altname = '';
                }
                // File type after name, for alphabetic lists (screen reader).
                if ($altname) {
                    $altname = get_accesshide(' ' . $altname);
                }
                $linkcss = $mod->visible ? "" : " class=\"dimmed\" ";
                echo '<a ' . $linkcss . ' ' . $extra . ' href="' . $CFG->wwwroot . '/mod/' . $mod->modname . '/view.php?id=' . $mod->id . '">' . '<img src="' . $icon . '" class="activityicon" alt="" /> <span>' . $instancename . $altname . '</span></a>';
                //echo " $mod->modname ";
                // Special NEWSPAPER magic ... show summry from resource and blog's 200 chars from each post OUBlog (nadavkav)
                if ($mod->modname == 'resource') {
                    $article = get_record('resource', 'id', $mod->instance);
                    //print_r($article );
                    echo "{$article->summary}";
                }
                if ($mod->modname == 'oublog') {
                    require_once $CFG->dirroot . '/mod/oublog/locallib.php';
                    $oublog = get_record('oublog', 'id', $mod->instance);
                    if (!($oublogcm = get_coursemodule_from_instance('oublog', $oublog->id))) {
                        //error("Course module ID was incorrect");
                    }
                    $oublogcontext = get_context_instance(CONTEXT_MODULE, $oublogcm->id);
                    //oublog_check_view_permissions($oublog, $oublogcontext, $oublogcm);
                    $currentgroup = oublog_get_activity_group($oublogcm, true);
                    echo '<br/>';
                    /// Get Posts
                    list($posts, $recordcount) = oublog_get_posts($oublog, $oublogcontext, 0, $oublogcm, $currentgroup);
                    //, -1, $oubloguser->id, $tag, $canaudit);
                    $i = 0;
                    foreach ($posts as $post) {
                        if ($i < 3) {
                            echo '<a href="' . $CFG->wwwroot . '/mod/oublog/viewpost.php?blog=' . $oublog->id . '&post=' . $post->id . '">' . $post->title . '</a><br/>';
                            $summaryformatoptions->noclean = false;
                            echo mb_substr(format_text($post->message, FORMAT_HTML, $summaryformatoptions), 1, 600) . "<hr/>";
                        }
                        if ($i > 2 and $i < 6) {
                            echo '<a href="' . $CFG->wwwroot . '/mod/oublog/viewpost.php?blog=' . $oublog->id . '&post=' . $post->id . '">' . $post->title . '</a><br/>';
                        }
                        $i++;
                    }
                    //print_r($article );
                    //echo "$article->summary";
                    echo '<br/><a ' . $linkcss . ' ' . $extra . ' href="' . $CFG->wwwroot . '/mod/' . $mod->modname . '/view.php?id=' . $mod->id . '">' . '<img src="' . $icon . '" class="activityicon" alt="" /> <span>' . get_string('more', 'format_newsroom') . '</span></a>';
                }
                if (!empty($CFG->enablegroupings) && !empty($mod->groupingid) && has_capability('moodle/course:managegroups', get_context_instance(CONTEXT_COURSE, $course->id))) {
                    if (!isset($groupings)) {
                        $groupings = groups_get_all_groupings($course->id);
                    }
                    echo " <span class=\"groupinglabel\">(" . format_string($groupings[$mod->groupingid]->name) . ')</span>';
                }
            }
            if ($usetracking && $mod->modname == 'forum') {
                if ($unread = forum_tp_count_forum_unread_posts($mod, $course)) {
                    echo '<span class="unread"> <a href="' . $CFG->wwwroot . '/mod/forum/view.php?id=' . $mod->id . '">';
                    if ($unread == 1) {
                        echo $strunreadpostsone;
                    } else {
                        print_string('unreadpostsnumber', 'forum', $unread);
                    }
                    echo '</a></span>';
                }
            }
            if ($isediting) {
                // TODO: we must define this as mod property!
                if ($groupbuttons and $mod->modname != 'label' and $mod->modname != 'resource' and $mod->modname != 'glossary') {
                    if (!($mod->groupmodelink = $groupbuttonslink)) {
                        $mod->groupmode = $course->groupmode;
                    }
                } else {
                    $mod->groupmode = false;
                }
                echo '&nbsp;&nbsp;';
                echo make_editing_buttons($mod, $absolute, true, $mod->indent, $section->section);
            }
            echo "</li>\n";
        }
    } elseif ($ismoving) {
        echo "<ul class=\"section\">\n";
    }
    if ($ismoving) {
        echo '<li><a title="' . $strmovefull . '"' . ' href="' . $CFG->wwwroot . '/course/mod.php?movetosection=' . $section->id . '&amp;sesskey=' . $USER->sesskey . '">' . '<img class="movetarget" src="' . $CFG->pixpath . '/movehere.gif" ' . ' alt="' . $strmovehere . '" /></a></li>
             ';
    }
    if (!empty($section->sequence) || $ismoving) {
        echo "</ul><!--class='section'-->\n\n";
    }
}
 /**
  * Specifies the user profile headers
  *
  * @uses none
  * @param none
  * @return array - header entires
  */
 function get_user_profile_header()
 {
     // Check for $this->up_headers
     if (!empty($this->up_headers) && is_array($this->up_headers)) {
         $up_headers = array();
         $count = 0;
         $init_label = get_string('filtered_by', 'rlreport_nonstarter');
         $chars = strlen(get_string('filtered_by', 'rlreport_nonstarter'));
         $next_label = print_spacer($chars, 10, false, true);
         foreach ($this->up_headers as $up_header) {
             $header_obj = new stdClass();
             if ($count == 0) {
                 $label = $init_label;
             } else {
                 // Pad the label with spaces
                 $label = $next_label;
             }
             $header_obj->label = $label;
             $header_obj->value = $up_header['value'];
             $header_obj->css_identifier = '';
             $up_headers[] = $header_obj;
             $count++;
         }
     }
     return $up_headers;
 }
Exemplo n.º 25
0
 function display()
 {
     global $CFG;
     /// Set up generic stuff first, including checking for access
     parent::display();
     /// Set up some shorthand variables
     $cm = $this->cm;
     $course = $this->course;
     $resource = $this->resource;
     require_once $CFG->libdir . '/filelib.php';
     $subdir = optional_param('subdir', '', PARAM_PATH);
     $resource->reference = clean_param($resource->reference, PARAM_PATH);
     $formatoptions = new object();
     $formatoptions->noclean = true;
     $formatoptions->para = false;
     // MDL-12061, <p> in html editor breaks xhtml strict
     add_to_log($course->id, "resource", "view", "view.php?id={$cm->id}", $resource->id, $cm->id);
     if ($resource->reference) {
         $relativepath = "{$course->id}/{$resource->reference}";
     } else {
         $relativepath = "{$course->id}";
     }
     if ($subdir) {
         $relativepath = "{$relativepath}{$subdir}";
         if (stripos($relativepath, 'backupdata') !== FALSE or stripos($relativepath, $CFG->moddata) !== FALSE) {
             error("Access not allowed!");
         }
         $subs = explode('/', $subdir);
         array_shift($subs);
         $countsubs = count($subs);
         $count = 0;
         $backsub = '';
         foreach ($subs as $sub) {
             $count++;
             if ($count < $countsubs) {
                 $backsub .= "/{$sub}";
                 $this->navlinks[] = array('name' => $sub, 'link' => "view.php?id={$cm->id}", 'type' => 'title');
             } else {
                 $this->navlinks[] = array('name' => $sub, 'link' => '', 'type' => 'title');
             }
         }
     }
     $pagetitle = strip_tags($course->shortname . ': ' . format_string($resource->name));
     $update = update_module_button($cm->id, $course->id, $this->strresource);
     if (has_capability('moodle/course:managefiles', get_context_instance(CONTEXT_COURSE, $course->id))) {
         $options = array('id' => $course->id, 'wdir' => '/' . $resource->reference . $subdir);
         $editfiles = print_single_button("{$CFG->wwwroot}/files/index.php", $options, get_string("editfiles"), 'get', '', true);
         $update = $editfiles . $update;
     }
     $navigation = build_navigation($this->navlinks, $cm);
     print_header($pagetitle, $course->fullname, $navigation, "", "", true, $update, navmenu($course, $cm));
     if (trim(strip_tags($resource->summary))) {
         print_simple_box(format_text($resource->summary, FORMAT_MOODLE, $formatoptions, $course->id), "center");
         print_spacer(10, 10);
     }
     $files = get_directory_list("{$CFG->dataroot}/{$relativepath}", array($CFG->moddata, 'backupdata'), false, true, true);
     if (!$files) {
         print_heading(get_string("nofilesyet"));
         print_footer($course);
         exit;
     }
     print_simple_box_start("center", "", "", '0');
     $strftime = get_string('strftimedatetime');
     $strname = get_string("name");
     $strsize = get_string("size");
     $strmodified = get_string("modified");
     $strfolder = get_string("folder");
     $strfile = get_string("file");
     echo '<table cellpadding="4" cellspacing="1" class="files" summary="">';
     echo "<tr><th class=\"header name\" scope=\"col\">{$strname}</th>" . "<th align=\"right\" colspan=\"2\" class=\"header size\" scope=\"col\">{$strsize}</th>" . "<th align=\"right\" class=\"header date\" scope=\"col\">{$strmodified}</th>" . "</tr>";
     foreach ($files as $file) {
         if (is_dir("{$CFG->dataroot}/{$relativepath}/{$file}")) {
             // Must be a directory
             $icon = "folder.gif";
             $relativeurl = "/view.php?blah";
             $filesize = display_size(get_directory_size("{$CFG->dataroot}/{$relativepath}/{$file}"));
         } else {
             $icon = mimeinfo("icon", $file);
             $relativeurl = get_file_url("{$relativepath}/{$file}");
             $filesize = display_size(filesize("{$CFG->dataroot}/{$relativepath}/{$file}"));
         }
         if ($icon == 'folder.gif') {
             echo '<tr class="folder">';
             echo '<td class="name">';
             echo "<a href=\"view.php?id={$cm->id}&amp;subdir={$subdir}/{$file}\">";
             echo "<img src=\"{$CFG->pixpath}/f/{$icon}\" class=\"icon\" alt=\"{$strfolder}\" />&nbsp;{$file}</a>";
         } else {
             echo '<tr class="file">';
             echo '<td class="name">';
             link_to_popup_window($relativeurl, "resourcedirectory{$resource->id}", "<img src=\"{$CFG->pixpath}/f/{$icon}\" class=\"icon\" alt=\"{$strfile}\" />&nbsp;{$file}", 450, 600, '');
         }
         echo '</td>';
         echo '<td>&nbsp;</td>';
         echo '<td align="right" class="size">';
         echo $filesize;
         echo '</td>';
         echo '<td align="right" class="date">';
         echo userdate(filemtime("{$CFG->dataroot}/{$relativepath}/{$file}"), $strftime);
         echo '</td>';
         echo '</tr>';
     }
     echo '</table>';
     print_simple_box_end();
     print_footer($course);
 }
 function view()
 {
     global $USER, $CFG;
     $context = get_context_instance(CONTEXT_MODULE, $this->cm->id);
     require_capability('mod/assignment:view', $context);
     $teacher = has_capability('mod/assignment:grade', $context);
     $criteriaList = get_records_list('assignment_criteria', 'assignment', $this->assignment->id, 'ordernumber');
     $numberOfCriteria = 0;
     if (is_array($criteriaList)) {
         $criteriaList = array_values($criteriaList);
         $numberOfCriteria = count($criteriaList);
     }
     if ($teacher && $numberOfCriteria == 0) {
         redirect($CFG->wwwroot . '/mod/assignment/type/peerreview/' . self::CRITERIA_FILE . '?id=' . $this->cm->id . '&a=' . $this->assignment->id, 0);
         return;
     }
     $submission = $this->get_submission();
     $reviewsAllocated = get_records_select('assignment_review', 'assignment=\'' . $this->assignment->id . '\' and reviewer=\'' . $USER->id . '\' ORDER BY id ASC');
     if (is_array($reviewsAllocated)) {
         $reviewsAllocated = array_values($reviewsAllocated);
         $numberOfReviewsAllocated = count($reviewsAllocated);
     } else {
         $numberOfReviewsAllocated = 0;
     }
     $numberOfReviewsDownloaded = count_records('assignment_review', 'assignment', $this->assignment->id, 'reviewer', $USER->id, 'downloaded', '1');
     $numberOfReviewsCompleted = count_records('assignment_review', 'assignment', $this->assignment->id, 'reviewer', $USER->id, 'complete', '1');
     add_to_log($this->course->id, "assignment", "view", "view.php?id={$this->cm->id}", $this->assignment->id, $this->cm->id);
     $this->view_header();
     require_once $CFG->dirroot . '/mod/assignment/type/peerreview/' . self::STYLES_FILE;
     //Determine what stage the student is up to and show progress
     if (!$teacher) {
         // Not yet submitted
         if (!$submission) {
             if ($this->isopen()) {
                 $this->print_progress_box('blueProgressBox', '1', get_string('submit', 'assignment_peerreview'), get_string('submitbelow', 'assignment_peerreview'));
             } else {
                 $this->print_progress_box('redProgressBox', '1', get_string('submit', 'assignment_peerreview'), get_string('closedpastdue', 'assignment_peerreview'));
             }
             $this->print_progress_box('greyProgressBox', '2', get_string('reviews', 'assignment_peerreview'), get_string('submitfirst', 'assignment_peerreview'));
             $this->print_progress_box('greyProgressBox', '3', get_string('feedback', 'assignment_peerreview'), get_string('notavailable', 'assignment_peerreview'));
         } else {
             $this->print_progress_box('greenProgressBox', '1', get_string('submit', 'assignment_peerreview'), get_string('submitted', 'assignment_peerreview'));
             // Completing Reviews
             if ($numberOfReviewsCompleted < 2) {
                 if ($numberOfReviewsCompleted == 1) {
                     $this->print_progress_box('blueProgressBox', '2', get_string('reviews', 'assignment_peerreview'), get_string('reviewsonemore', 'assignment_peerreview'));
                 } else {
                     if ($numberOfReviewsAllocated == 0) {
                         $this->print_progress_box('blueProgressBox', '2', get_string('reviews', 'assignment_peerreview'), get_string('reviewsnotallocated', 'assignment_peerreview'));
                     } else {
                         $this->print_progress_box('blueProgressBox', '2', get_string('reviews', 'assignment_peerreview'), get_string('completereviewsbelow', 'assignment_peerreview'));
                     }
                 }
                 $this->print_progress_box('greyProgressBox', '3', get_string('feedback', 'assignment_peerreview'), get_string('notavailable', 'assignment_peerreview'));
             } else {
                 $this->print_progress_box('greenProgressBox', '2', get_string('reviews', 'assignment_peerreview'), get_string('reviewscomplete', 'assignment_peerreview'));
                 if ($submission->timemarked == 0) {
                     $this->print_progress_box('blueProgressBox', '3', get_string('feedback', 'assignment_peerreview'), get_string('marknotassigned', 'assignment_peerreview'));
                 } else {
                     $this->print_progress_box('greenProgressBox', '3', get_string('feedback', 'assignment_peerreview'), get_string('markassigned', 'assignment_peerreview'));
                 }
             }
         }
     }
     // Completing Reviews
     if (!$teacher && $submission && $numberOfReviewsAllocated == 2 && $numberOfReviewsCompleted < 2) {
         print_box_start();
         // Allow review file to be downloaded
         if ($numberOfReviewsDownloaded == $numberOfReviewsCompleted) {
             print_heading(get_string('reviewnumber', 'assignment_peerreview', $numberOfReviewsCompleted + 1), $alignment);
             if (isset($this->assignment->var3) && $this->assignment->var3 == self::ONLINE_TEXT) {
                 print_heading(get_string('gettheonlinetext', 'assignment_peerreview'), $alignment, 3);
                 echo '<a onclick="setTimeout(\'document.getElementById(\\\'continueButton\\\').disabled=false;\',3000);return openpopup(\'/mod/assignment/type/peerreview/' . self::VIEW_ONLINE_TEXT . '?a=' . $this->assignment->id . '&id=' . $this->cm->id . '&view=peerreview\', \'window' . ($numberOfReviewsCompleted + 1) . '\', \'menubar=0,location=0,scrollbars,resizable,width=500,height=400\', 0);" target="window' . ($numberOfReviewsCompleted + 1) . '" href="' . $CFG->wwwroot . '/mod/assignment/type/peerreview/' . self::VIEW_ONLINE_TEXT . '?a=' . $this->assignment->id . '&id=' . $this->cm->id . '&view=peerreview">' . get_string('clicktoview', 'assignment_peerreview') . '</a>';
                 print_heading(get_string('continuetoreview', 'assignment_peerreview'), $alignment, 3);
             } else {
                 print_heading(get_string('getthedocument', 'assignment_peerreview'), $alignment, 3);
                 require_once $CFG->libdir . '/filelib.php';
                 echo '<a onclick="setTimeout(\'document.getElementById(\\\'continueButton\\\').disabled=false;\',3000);return true;" href="' . $CFG->wwwroot . '/mod/assignment/type/peerreview/' . self::DOWNLOAD_PEERREVIEW_FILE . '/' . self::FILE_PREFIX . ($numberOfReviewsCompleted + 1) . '.' . $this->assignment->fileextension . '?a=' . $this->assignment->id . '&id=' . $this->cm->id . '"><img class="icon" src="' . $CFG->pixpath . '/f/' . mimeinfo('icon', 'blah.' . $this->assignment->fileextension) . '" alt="' . get_string('clicktodownload', 'assignment_peerreview') . '" />' . get_string('clicktodownload', 'assignment_peerreview') . '</a>';
                 print_heading(get_string('continuetoreviewdocument', 'assignment_peerreview'), $alignment, 3);
             }
             echo '<noscript>';
             echo '<a href="view.php?id=' . $this->cm->id . '">' . get_string('continue', 'assignment_peerreview') . '</a>';
             echo '</noscript>';
             echo '<script>';
             echo 'document.write(\'<input type="button" disabled id="continueButton" onclick="document.location=\\\'view.php?id=' . $this->cm->id . '\\\'" value="' . get_string('continue', 'assignment_peerreview') . '" />\');';
             echo '</script>';
         } else {
             // Save review
             if ($comment = clean_param(htmlspecialchars(optional_param('comment', NULL, PARAM_RAW)), PARAM_CLEAN)) {
                 print_heading(get_string('reviewnumber', 'assignment_peerreview', $numberOfReviewsCompleted + 1));
                 notify(get_string('savingreview', 'assignment_peerreview'), 'notifysuccess');
                 for ($i = 0; $i < $numberOfCriteria; $i++) {
                     $criterionToSave = new Object();
                     $criterionToSave->review = $reviewsAllocated[$numberOfReviewsCompleted]->id;
                     $criterionToSave->criterion = $i;
                     $criterionToSave->checked = optional_param('criterion' . $i, 0, PARAM_BOOL);
                     insert_record('assignment_review_criterion', $criterionToSave);
                 }
                 $reviewToUpdate = get_record('assignment_review', 'id', $reviewsAllocated[$numberOfReviewsCompleted]->id);
                 $reviewToUpdate->reviewcomment = $comment;
                 $reviewToUpdate->complete = 1;
                 $reviewToUpdate->timemodified = time();
                 update_record('assignment_review', $reviewToUpdate);
                 // Send an email to student
                 $subject = get_string('peerreviewreceivedsubject', 'assignment_peerreview');
                 $linkToReview = $CFG->wwwroot . '/mod/assignment/view.php?id=' . $this->cm->id;
                 $message = get_string('peerreviewreceivedmessage', 'assignment_peerreview') . "\n\n" . get_string('assignmentname', 'assignment') . ': ' . $this->assignment->name . "\n" . get_string('course') . ': ' . $this->course->fullname . "\n\n";
                 $messageText = $message . $linkToReview;
                 $messageHTML = nl2br($message) . '<a href="' . $linkToReview . '" target="_blank">' . get_string('peerreviewreceivedlinktext', 'assignment_peerreview') . '</a>';
                 $this->email_from_teacher($this->course->id, $reviewToUpdate->reviewee, $subject, $messageText, $messageHTML);
                 redirect('view.php?id=' . $this->cm->id, get_string('reviewsaved', 'assignment_peerreview'), 1);
             } else {
                 if ($numberOfCriteria > 0) {
                     echo '<div style="position:relative;">';
                     print_heading(get_string('reviewnumber', 'assignment_peerreview', $numberOfReviewsCompleted + 1), 'left');
                     echo '<div style="text-align:right;position:absolute;top:0;right:0">';
                     if (isset($this->assignment->var3) && $this->assignment->var3 == self::ONLINE_TEXT) {
                         echo '<a onclick="setTimeout(\'document.getElementById(\\\'continueButton\\\').disabled=false;\',3000);return openpopup(\'/mod/assignment/type/peerreview/' . self::VIEW_ONLINE_TEXT . '?a=' . $this->assignment->id . '&id=' . $this->cm->id . '&view=peerreview\', \'window' . ($numberOfReviewsCompleted + 1) . '\', \'menubar=0,location=0,scrollbars,resizable,width=500,height=400\', 0);" target="window' . ($numberOfReviewsCompleted + 1) . '" href="' . $CFG->wwwroot . '/mod/assignment/type/peerreview/' . self::VIEW_ONLINE_TEXT . '?a=' . $this->assignment->id . '&id=' . $this->cm->id . '&view=peerreview">' . get_string('lostonlinetext', 'assignment_peerreview') . '</a>';
                     } else {
                         require_once $CFG->libdir . '/filelib.php';
                         echo '<a onclick="setTimeout(\'document.getElementById(\\\'continueButton\\\').disabled=false;\',3000);return true;" href="' . $CFG->wwwroot . '/mod/assignment/type/peerreview/' . self::DOWNLOAD_PEERREVIEW_FILE . '/' . self::FILE_PREFIX . ($numberOfReviewsCompleted + 1) . '.' . $this->assignment->fileextension . '?a=' . $this->assignment->id . '&id=' . $this->cm->id . '"><img class="icon" src="' . $CFG->pixpath . '/f/' . mimeinfo('icon', 'blah.' . $this->assignment->fileextension) . '" alt="' . get_string('lostfile', 'assignment_peerreview') . '" />' . get_string('lostfile', 'assignment_peerreview') . '</a>';
                     }
                     echo '</div>';
                     echo '<p id="showDescription"><a href="#null" onclick="document.getElementById(\'hiddenDescription\').style.display=\'block\';document.getElementById(\'showDescription\').style.display=\'none\';">' . get_string('showdescription', 'assignment_peerreview') . '</a></p>';
                     echo '<div id="hiddenDescription" style="display:none;">';
                     echo '<p><a href="#null" onclick="document.getElementById(\'hiddenDescription\').style.display=\'none\';document.getElementById(\'showDescription\').style.display=\'block\';">' . get_string('hidedescription', 'assignment_peerreview') . '</a></p>';
                     $this->view_intro();
                     echo '</div>';
                     echo '<form action="view.php" method="post">';
                     echo '<input type="hidden" name="id" value="' . $this->cm->id . '" />';
                     echo '<p>' . get_string('criteriainstructions', 'assignment_peerreview') . '</p>';
                     echo '<table style="width:99%;">';
                     $options = new object();
                     $options->para = false;
                     foreach ($criteriaList as $i => $criterion) {
                         echo '<tr' . ($i % 2 == 0 ? ' class="evenCriteriaRow"' : '') . '><td class="criteriaCheckboxColumn"><input type="checkbox" name="criterion' . $criterion->ordernumber . '" /></td><td class="criteriaTextColumn">' . format_text($criterion->textshownatreview != '' ? $criterion->textshownatreview : $criterion->textshownwithinstructions, FORMAT_MOODLE, $options) . '</td></tr>';
                     }
                     echo '</table>';
                     print_spacer(20);
                     echo '<p>' . get_string('commentinstructions', 'assignment_peerreview') . '</p>';
                     echo '<textarea name="comment" id="comment" rows="5" style="width:99%;"></textarea>';
                     echo '<input type="submit" value="' . get_string('savereview', 'assignment_peerreview') . '" onclick="if(document.getElementById(\'comment\').value==\'\'){alert(\'' . get_string('nocommentalert', 'assignment_peerreview') . '\');document.getElementById(\'comment\').focus();return false;}">';
                     echo '</form>';
                     echo '</div>';
                 } else {
                     notify(get_string('nocriteriaset', 'assignment_peerreview'));
                 }
             }
         }
         print_box_end();
     } else {
         if (!$teacher && $numberOfReviewsCompleted == 2) {
             print_box_start();
             // Find the reviews for this student
             $reviews = $this->get_reviews_of_student($USER->id);
             $numberOfReviewsOfThisStudent = 0;
             if (is_array($reviews)) {
                 $numberOfReviewsOfThisStudent = count($reviews);
             }
             $status = $this->get_status($reviews, $numberOfCriteria);
             // Table about student submission
             print_heading(get_string('yoursubmission', 'assignment_peerreview'), $alignment, 1);
             echo '<table cellpadding="3">';
             echo '<tr><td><strong>' . get_string('grade', 'assignment_peerreview') . ': </strong></td><td>' . ($submission->timemarked == 0 ? get_string('notavailable', 'assignment_peerreview') : $this->display_grade($submission->grade)) . '</td></tr>';
             echo '<tr><td><strong>' . get_string('status') . ': </strong></td><td>';
             switch ($status) {
                 case self::FLAGGED:
                 case self::CONFLICTING:
                 case self::FLAGGEDANDCONFLICTING:
                     echo get_string('waitingforteacher', 'assignment_peerreview', $this->course->teacher);
                     break;
                 case self::LESSTHANTWOREVIEWS:
                     echo get_string('waitingforpeers', 'assignment_peerreview');
                     break;
                 case self::CONCENSUS:
                     echo get_string('reviewconcensus', 'assignment_peerreview');
                     break;
                 case self::OVERRIDDEN:
                     echo get_string('reviewsoverridden', 'assignment_peerreview', $this->course->teacher);
                     break;
             }
             echo '</td></tr>';
             if (isset($this->assignment->var3) && $this->assignment->var3 == self::ONLINE_TEXT) {
                 echo '<tr><td><strong>' . get_string('submission', 'assignment_peerreview') . ': </strong></td><td>';
                 link_to_popup_window($CFG->wwwroot . '/mod/assignment/type/peerreview/' . self::VIEW_ONLINE_TEXT . '?id=' . $this->cm->id . '&a=' . $this->assignment->id . '&view=selfview');
                 echo '</td></tr>';
             } else {
                 require_once $CFG->libdir . '/filelib.php';
                 $filearea = $this->file_area_name($USER->id);
                 $files = get_directory_list($CFG->dataroot . '/' . $filearea, '', false);
                 echo '<tr><td><strong>' . get_string('submittedfile', 'assignment_peerreview') . ': </strong></td><td><a href="' . get_file_url($filearea . '/' . $files[0], array('forcedownload' => 1)) . '" ><img src="' . $CFG->pixpath . '/f/' . mimeinfo('icon', $files[0]) . '" class="icon" alt="icon" />' . $files[0] . '</a></td></tr>';
             }
             echo '<tr><td><strong>' . get_string('submittedtime', 'assignment_peerreview') . ': </strong></td><td>' . userdate($submission->timecreated, get_string('strftimedaydatetime')) . '</td></tr>';
             echo '</table>';
             print_spacer(10);
             echo '<p id="showDescription"><a href="#null" onclick="document.getElementById(\'hiddenDescription\').style.display=\'block\';document.getElementById(\'showDescription\').style.display=\'none\';">' . get_string('showdescription', 'assignment_peerreview') . '</a></p>';
             echo '<div id="hiddenDescription" style="display:none;">';
             echo '<p><a href="#null" onclick="document.getElementById(\'hiddenDescription\').style.display=\'none\';document.getElementById(\'showDescription\').style.display=\'block\';">' . get_string('hidedescription', 'assignment_peerreview') . '</a></p>';
             $this->view_intro();
             echo '</div>';
             // If reviews are available, show to student
             if ($reviews) {
                 print_heading(get_string('reviewsofyoursubmission', 'assignment_peerreview'), $alignment, 1);
                 echo '<table width="99%" cellpadding="0" cellspacing="0" border="0" style="border-collapse:collapse;">';
                 for ($i = 0; $i < $numberOfCriteria; $i++) {
                     echo '<tr class="criteriaDisplayRow">';
                     for ($j = 0; $j < $numberOfReviewsOfThisStudent; $j++) {
                         echo '<td class="criteriaCheckboxColumn" style="background:' . $this->REVIEW_COLOURS[$j % $this->NUMBER_OF_COLOURS] . '"><input type="checkbox" disabled' . ($reviews[$j]->{'checked' . $i} == 1 ? ' checked' : '') . ' /></td>';
                     }
                     $options = new object();
                     $options->para = false;
                     echo '<td class="criteriaDisplayColumn">' . format_text($criteriaList[$i]->textshownatreview != '' ? $criteriaList[$i]->textshownatreview : $criteriaList[$i]->textshownwithinstructions, FORMAT_MOODLE, $options) . '</td>';
                     echo '</tr>';
                 }
                 $studentCount = 1;
                 for ($i = 0; $i < $numberOfReviewsOfThisStudent; $i++) {
                     echo '<tr>';
                     for ($j = 0; $j < $numberOfReviewsOfThisStudent; $j++) {
                         echo '<td class="criteriaCheckboxColumn" style="background:' . ($j > $numberOfReviewsOfThisStudent - $i - 1 ? $this->REVIEW_COLOURS[($numberOfReviewsOfThisStudent - $i - 1) % $this->NUMBER_OF_COLOURS] : $this->REVIEW_COLOURS[$j % $this->NUMBER_OF_COLOURS]) . ';">&nbsp;</td>';
                     }
                     echo '<td class="reviewCommentRow" style="background:' . $this->REVIEW_COLOURS[($numberOfReviewsOfThisStudent - $i - 1) % $this->NUMBER_OF_COLOURS] . ';">';
                     echo '<table width="100%" cellpadding="0" cellspacing="0" border="0">';
                     echo '<tr class="reviewDetailsRow">';
                     echo '<td><em>' . get_string('conductedby', 'assignment_peerreview') . ': ' . ($reviews[$numberOfReviewsOfThisStudent - $i - 1]->teacherreview == 1 ? $reviews[$numberOfReviewsOfThisStudent - $i - 1]->firstname . ' ' . $reviews[$numberOfReviewsOfThisStudent - $i - 1]->lastname . ' (' . $this->course->teacher . ')' : $this->course->student . ' ' . $studentCount++) . '</em></td>';
                     echo '<td class="reviewDateColumn"><em>' . userdate($reviews[$numberOfReviewsOfThisStudent - $i - 1]->timemodified, get_string('strftimedatetime')) . '</em></td>';
                     echo '</tr>';
                     echo '<tr><td colspan="2"><pre class="commentTextBox" style="background:' . $this->REVIEW_COMMENT_COLOURS[($numberOfReviewsOfThisStudent - $i - 1) % count($this->REVIEW_COMMENT_COLOURS)] . ';">' . format_string(stripslashes($reviews[$numberOfReviewsOfThisStudent - $i - 1]->reviewcomment)) . '</pre></td></tr>';
                     if ($reviews[$numberOfReviewsOfThisStudent - $i - 1]->teacherreview != 1) {
                         echo '<tr class="reviewDetailsRow"><td colspan="2"><em>';
                         echo $reviews[$numberOfReviewsOfThisStudent - $i - 1]->flagged == 1 ? get_string('flagprompt1', 'assignment_peerreview', $this->course->teacher) . ' ' : get_string('flagprompt2', 'assignment_peerreview') . ' ';
                         $flagToggleURL = 'type/peerreview/' . self::TOGGLE_FLAG_FILE . '?id=' . $this->cm->id . '&a=' . $this->assignment->id . '&r=' . $reviews[$numberOfReviewsOfThisStudent - $i - 1]->review;
                         echo '<a href="' . $flagToggleURL . '" id="flag' . ($numberOfReviewsOfThisStudent - $i - 1) . '">';
                         echo $reviews[$numberOfReviewsOfThisStudent - $i - 1]->flagged == 1 ? get_string('flaglink1', 'assignment_peerreview') : get_string('flaglink2', 'assignment_peerreview');
                         echo '</a>';
                         echo '</em></td></tr>';
                     }
                     echo '</table>';
                     echo '</td>';
                     echo '</tr>';
                 }
                 echo '</table>';
             } else {
                 echo '<p>' . get_string('noreviews', 'assignment_peerreview');
             }
             print_box_end();
         } else {
             // Show description
             $this->view_intro();
             // Show criteria
             print_box_start();
             echo '<a name="criteria"></a>';
             print_heading(get_string('criteria', 'assignment_peerreview'), $alignment);
             if (has_capability('mod/assignment:grade', get_context_instance(CONTEXT_MODULE, $this->cm->id))) {
                 echo '<p><a href="type/peerreview/' . self::CRITERIA_FILE . '?id=' . $this->cm->id . '&a=' . $this->assignment->id . '">' . get_string('setcriteria', 'assignment_peerreview') . '</a></p>';
             }
             if ($numberOfCriteria > 0) {
                 echo '<table style="width:99%;">';
                 $options = new object();
                 $options->para = false;
                 foreach ($criteriaList as $i => $criterion) {
                     echo '<tr ' . ($i % 2 == 0 ? 'class="evenCriteriaRow"' : '') . '><td class="criteriaCheckboxColumn"><input type="checkbox" checked disabled /></td><td class="criteriaTextColumn">' . format_text($criterion->textshownwithinstructions, FORMAT_MOODLE, $options) . '</td></tr>';
                 }
                 echo '</table>';
             } else {
                 notify(get_string('nocriteriaset', 'assignment_peerreview'));
             }
             print_box_end();
             $this->view_dates();
             // With peer review teachers can grade but not submit (not here)
             if (has_capability('mod/assignment:submit', $context) && !$teacher && $this->isopen() && !$submission) {
                 $this->view_upload_form();
             } else {
                 if (!$this->isopen()) {
                     print_string("notopen", "assignment_peerreview");
                 }
             }
         }
     }
     $this->view_footer();
 }
Exemplo n.º 27
0
 foreach ($activities as $key => $activity) {
     if ($activity->type == 'section') {
         if ($param->sortby != 'default') {
             continue;
             // no section if ordering by date
         }
         if ($activity_count == $key + 1 or $activities[$key + 1]->type == 'section') {
             // peak at next activity.  If it's another section, don't print this one!
             // this means there are no activities in the current section
             continue;
         }
     }
     if ($activity->type == 'section' && $param->sortby == 'default') {
         if ($inbox) {
             print_simple_box_end();
             print_spacer(30);
         }
         print_simple_box_start('center', '90%');
         echo "<h2>{$activity->name}</h2>";
         $inbox = true;
     } else {
         if ($activity->type == 'activity') {
             if ($param->sortby == 'default') {
                 $cm = $modinfo->cms[$activity->cmid];
                 if ($cm->visible) {
                     $linkformat = '';
                 } else {
                     $linkformat = 'class="dimmed"';
                 }
                 $name = format_string($cm->name);
                 $modfullname = $modnames[$cm->modname];
Exemplo n.º 28
0
                $rolenames[$role->id] = strip_tags(role_get_name($role, $context));
                // Used in menus etc later on
            } else {
                $rolenames[$role->id] = strip_tags(format_string($role->name));
                // Used in menus etc later on
            }
        }
    }
    /// If there are multiple Roles in the course, then show a drop down menu for switching
    if (count($rolenames) > 1) {
        echo '<div class="rolesform">';
        echo get_string('currentrole', 'role') . ': ';
        $rolenames = array(0 => get_string('all')) + $rolenames;
        popup_form("{$wwwroot}/blocks/email_list/email/participants.php?id={$courseid}&amp;group={$selgroup}&amp;page={$page}&amp;perpage={$perpage}&amp;search={$search}&amp;fname={$firstinitial}&amp;lname={$lastinitial}&amp;contextid={$context->id}&amp;roleid=", $rolenames, 'rolesform', $roleid, '');
        echo '</div>';
    }
    // Prints group selector for users with a viewallgroups capability if course groupmode is separate
    echo '<br />';
    groups_print_course_menu($course, $wwwroot . '/blocks/email_list/email/participants.php?id=' . $course->id);
    echo '<br /><br />';
    echo '<div id="participants"></div>' . '<iframe id="idsearch" name="bssearch" src="get_users.php?id=' . $courseid . '&amp;roleid=' . $roleid . '&amp;group=' . $selgroup . '&amp;page=' . $page . '&amp;perpage=' . $perpage . '&amp;search=' . $search . '&amp;fname=' . $firstinitial . '&amp;lname=' . $lastinitial . '" style="display:none;"></iframe>' . "\n\n";
    print_spacer(1, 4, false);
    if ($perpage == '7') {
        echo '<div id="to_all_users" class="all_users"><img src="' . $CFG->wwwroot . '/blocks/email_list/email/images/add.png" height="16" width="16" alt="' . get_string("course") . '" /> <a href="' . $wwwroot . '/blocks/email_list/email/participants.php?id=' . $courseid . '&amp;group=' . $selgroup . '&amp;perpage=99999&amp;search=' . $search . '&amp;roleid=' . $roleid . '&amp;fname=' . $firstinitial . '&amp;lname=' . $lastinitial . '">' . get_string('showallusers') . '</a></div>';
    } else {
        echo '<div id="to_all_users" class="all_users"><img src="' . $CFG->wwwroot . '/blocks/email_list/email/images/delete.png" height="16" width="16" alt="' . get_string("course") . '" /> <a href="' . $wwwroot . '/blocks/email_list/email/participants.php?id=' . $courseid . '&amp;group=' . $selgroup . '&amp;perpage=7&amp;search=' . $search . '&amp;roleid=' . $roleid . '&amp;fname=' . $firstinitial . '&amp;lname=' . $lastinitial . '">' . get_string('showperpage', '', 7) . '</a></div>';
    }
}
// Print close button
close_window_button();
print_footer();
Exemplo n.º 29
0
function calendar_print_event($event)
{
    global $CFG, $USER;
    static $strftimetime;
    $event = calendar_add_event_metadata($event);
    echo '<a name="event_' . $event->id . '"></a><table class="event" cellspacing="0">';
    echo '<tr><td class="picture">';
    if (!empty($event->icon)) {
        echo $event->icon;
    } else {
        print_spacer(16, 16);
    }
    echo '</td>';
    echo '<td class="topic">';
    if (!empty($event->referer)) {
        echo '<div class="referer">' . $event->referer . '</div>';
    } else {
        echo '<div class="name">' . $event->name . "</div>";
    }
    if (!empty($event->courselink)) {
        echo '<div class="course">' . $event->courselink . ' </div>';
    }
    if (!empty($event->time)) {
        echo '<span class="date">' . $event->time . '</span>';
    } else {
        echo '<span class="date">' . calendar_time_representation($event->timestart) . '</span>';
    }
    echo '</td></tr>';
    echo '<tr><td class="side">&nbsp;</td>';
    if (isset($event->cssclass)) {
        echo '<td class="description ' . $event->cssclass . '">';
    } else {
        echo '<td class="description">';
    }
    echo format_text($event->description, FORMAT_HTML);
    if (calendar_edit_event_allowed($event)) {
        echo '<div class="commands">';
        $calendarcourseid = '';
        if (!empty($event->calendarcourseid)) {
            $calendarcourseid = '&amp;course=' . $event->calendarcourseid;
        }
        if (empty($event->cmid)) {
            $editlink = CALENDAR_URL . 'event.php?action=edit&amp;id=' . $event->id . $calendarcourseid;
            $deletelink = CALENDAR_URL . 'event.php?action=delete&amp;id=' . $event->id . $calendarcourseid;
        } else {
            $editlink = $CFG->wwwroot . '/course/mod.php?update=' . $event->cmid . '&amp;return=true&amp;sesskey=' . $USER->sesskey;
            $deletelink = '';
            // deleting activities directly from calendar is dangerous/confusing - see MDL-11843
        }
        echo ' <a href="' . $editlink . '"><img
                  src="' . $CFG->pixpath . '/t/edit.gif" alt="' . get_string('tt_editevent', 'calendar') . '"
                  title="' . get_string('tt_editevent', 'calendar') . '" /></a>';
        if ($deletelink) {
            echo ' <a href="' . $deletelink . '"><img
                      src="' . $CFG->pixpath . '/t/delete.gif" alt="' . get_string('tt_deleteevent', 'calendar') . '"
                      title="' . get_string('tt_deleteevent', 'calendar') . '" /></a>';
        }
        echo '</div>';
    }
    echo '</td></tr></table>';
}
Exemplo n.º 30
0
 /**
  * Mainline for showing all jobs currently set up for an existing
  * report
  *
  * @uses $CFG
  * @uses $USER
  */
 function action_listinstancejobs()
 {
     global $CFG, $USER;
     //report specified by URL
     $report = $this->required_param('report', PARAM_ALPHAEXT);
     //get the necessary data
     $recordset = block_php_report_get_report_jobs_recordset($report);
     //set up a job if none exist and a special parameter
     //is passed in to signal this functinality
     $createifnone = optional_param('createifnone', 0, PARAM_INT);
     if ($createifnone) {
         if (!$recordset or $recordset->_numOfRows == 0 or $recordset->EOF) {
             //set up a job for this report
             $this->action_default();
             return;
         }
     }
     //import necessary CSS
     $stylesheet_web_path = $CFG->wwwroot . '/blocks/php_report/styles.php';
     echo '<style>@import url("' . $stylesheet_web_path . '");</style>';
     if ($recordset = block_php_report_get_report_jobs_recordset($report) and $recordset->_numOfRows != 0 and !$recordset->EOF) {
         //we actually have scheduled instances for this report
         //display appropriate headers
         $this->render_listinstancejobs_header(true, NULL, php_report::EXECUTION_MODE_SCHEDULED);
         //set up our form
         echo '<form action="' . $this->get_url() . '" method="post">';
         //used by the "select all" functionality to identify a defining div
         echo '<div id="list_display">';
         echo '<input type="hidden" id="report" name="report" value="' . $report . '"/>';
         //table setup
         $table = new stdClass();
         //headers, with a "select all" checkbox in the first column
         require_js($CFG->wwwroot . '/blocks/php_report/lib.js');
         $checkbox = print_checkbox('selectall', '', false, get_string('listinstancejobs_header_select', 'block_php_report'), '', 'select_all()', true);
         $table->head = array($checkbox, get_string('listinstancejobs_header_label', 'block_php_report'), get_string('listinstancejobs_header_owner', 'block_php_report'), get_string('listinstancejobs_header_lastrun', 'block_php_report'), get_string('listinstancejobs_header_nextrun', 'block_php_report'), get_string('listinstancejobs_header_lastmodified', 'block_php_report'));
         //left align all columns
         $table->align = array();
         foreach ($table->head as $column_header) {
             $table->align[] = 'left';
         }
         $table->data = array();
         //run through available schedules
         while ($record = rs_fetch_next_record($recordset)) {
             $config_data = unserialize($record->config);
             $tz = $config_data['timezone'];
             //echo "action_listinstancejobs():: {$config_data['label']}: nextruntime = {$record->nextruntime}<br/>";
             //convert the last run time to the appropraite format
             if ($record->lastruntime == 0) {
                 //special case: never run before
                 $lastruntime = get_string('no_last_runtime', 'block_php_report');
             } else {
                 $lastruntime = userdate($record->lastruntime, '', $tz) . ' (' . usertimezone($tz) . ')';
                 debug_error_log("/blocks/php_report/lib/schedulelib.php::action_listinstancejobs(); {$config_data['label']}: record->lastruntime = {$record->lastruntime}, tz = {$tz}");
             }
             // convert 'will run next at' time to appropriate format
             $jobenddate = $config_data['schedule']['enddate'];
             debug_error_log("/blocks/php_report/lib/schedulelib.php::action_listinstancejobs(); {$config_data['label']}: nextruntime = {$record->nextruntime}, jobenddate = {$jobenddate}");
             if (!empty($record->nextruntime) && (empty($jobenddate) || $record->nextruntime < $jobenddate + DAYSECS)) {
                 $nextruntime = userdate($record->nextruntime, '', $tz) . ' (' . usertimezone($tz) . ')';
             } else {
                 $nextruntime = get_string('job_completed', 'block_php_report');
             }
             $checkbox = '<input type="checkbox" name="schedule_' . $record->scheduleid . '">';
             //link for editing this particular schedule instance
             $edit_schedule_params = array('id' => $record->scheduleid);
             $edit_schedule_link = '<a href="' . $this->get_url($edit_schedule_params) . '">' . $config_data['label'] . '</a>';
             //data row
             $table->data[] = array($checkbox, $edit_schedule_link, fullname($record), $lastruntime, $nextruntime, userdate($config_data['timemodified']));
         }
         print_table($table);
         print_spacer();
         //display the dropdown and button in an enabled state
         $this->render_listinstancejobs_actions_dropdown(true);
         echo '</div>';
         echo '</form>';
     } else {
         //display header info
         $this->render_listinstancejobs_header(false, NULL, php_report::EXECUTION_MODE_SCHEDULED);
         //display the dropdown and button in a disabled state
         $this->render_listinstancejobs_actions_dropdown(false);
         print_spacer();
     }
     //general footer
     $this->render_listinstancejobs_footer();
 }