Ejemplo n.º 1
0
function m4a_filter_callback($link)
{
    global $CFG;
    $ret = '';
    static $count = 0;
    $count++;
    if ($count === 1) {
        $ret .= '<script type="text/javascript" src="' . $CFG->wwwroot . '/filter/m4a/flowplayer-3.1.4.min.js"></script>';
    }
    $id = 'filter_flv_' . time() . $count;
    //we need something unique because it might be stored in text cache
    $url = addslashes_js($link[1]);
    $ret .= '   <a href="#" style="display:block;width:400px;height:20px" id="' . $id . '"></a>
                <script>
                    flowplayer("' . $id . '", "' . $CFG->wwwroot . '/filter/m4a/flowplayer-3.1.5.swf", {
                        clip: {
                            url: "' . $url . '",
                            autoBuffering: true,
                            autoPlay: false
                        },
                        plugins: {
                            controls: {
                                fullscreen: false,
                                height: 20
                            }
                        }
                    });
                </script>';
    return $ret;
}
Ejemplo n.º 2
0
function print_textarea($usehtmleditor, $rows, $cols, $width, $height, $name, $value = '', $courseid = 0, $return = false, $id = '')
{
    global $CFG, $COURSE, $HTTPSPAGEREQUIRED;
    $str = '';
    if ($id === '') {
        $id = 'edit-' . $name;
    }
    if (empty($courseid)) {
        $courseid = $COURSE->id;
    }
    if ($usehtmleditor) {
        $str .= '<textarea class="form-textarea" id="' . $id . '" name="' . $name . '" rows="' . $rows . '" cols="' . $cols . '">';
        $str .= htmlspecialchars($value);
        $str .= '</textarea><br />' . "\n";
        $toggle_ed = '<img width="50" height="17" src="' . $CFG->wwwroot . '/lib/editor/tinymce/images/toggle.gif" alt="' . get_string('toggleeditor', 'editor') . '" title="' . get_string('toggleeditor', 'editor') . '" />';
        $str .= "<a href=\"javascript:toggleEditor('" . $id . "');\">" . $toggle_ed . "</a> ";
        $str .= '<script type="text/javascript">
            document.write(\'' . addslashes_js(editorshortcutshelpbutton()) . '\');
        </script>';
    } else {
        $str .= '<textarea class="alltext" id="' . $id . '" name="' . $name . '" rows="' . $rows . '" cols="' . $cols . '">';
        $str .= s($value);
        $str .= '</textarea>' . "\n";
    }
    if ($return) {
        return $str;
    }
    echo $str;
}
function block_exabis_eportfolio_print_extern_item($item, $access)
{
    global $CFG;
    print_heading(format_string($item->name));
    $box_content = '';
    if ($item->type == 'link') {
        $link = clean_param($item->url, PARAM_URL);
        $link_js = str_replace('http://', '', $link);
        if ($link) {
            $box_content .= '<p><a href="#" onclick="window.open(\'http://' . addslashes_js($link_js) . '\',\'validate\',\'width=620,height=450,scrollbars=yes,status=yes,resizable=yes,menubar=yes,location=yes\');return true;">' . $link . '</a></p>';
        }
    } elseif ($item->type == 'file') {
        if ($item->attachment) {
            $type = mimeinfo("type", $item->attachment);
            $ffurl = "{$CFG->wwwroot}/blocks/exabis_eportfolio/portfoliofile.php?access=" . $access . "&itemid=" . $item->id;
            if (in_array($type, array('image/gif', 'image/jpeg', 'image/png'))) {
                // Image attachments don't get printed as links
                $box_content .= "<img width=\"100%\" src=\"{$ffurl}\" alt=\"" . format_string($item->name) . "\" /><br/>";
            } else {
                $box_content .= "<p>" . link_to_popup_window("{$ffurl}", 'popup', "{$ffurl}", $height = 400, $width = 500, format_string($item->name), 'none', true) . "</p>";
            }
        }
    }
    $box_content .= format_text($item->intro, FORMAT_HTML);
    print_box($box_content);
}
function question_plugin_filter_callback($link)
{
    global $CFG;
    static $count = 0;
    $count++;
    $id = 'filter_question_' . time() . $count;
    //we need something unique because it might be stored in text cache
    $url = addslashes_js($link[1]);
    return $link[0] . '<iframe id=' . $id . ' src="' . $url . '" width="60%"></iframe>';
}
Ejemplo n.º 5
0
function print_js_data($typename, $datarow, $number)
{
    echo $typename . 's[' . ($number - 1) . '] = new ' . $typename . '(';
    $firstitem = false;
    foreach ($datarow as $name => $value) {
        if ($firstitem) {
            echo ', ';
        }
        $firstitem = true;
        echo "'" . addslashes_js($value) . "'";
    }
    echo ");\n";
}
Ejemplo n.º 6
0
function scorm_get_resources($blocks) {
    $resources = array();
    foreach ($blocks as $block) {
        if ($block['name'] == 'RESOURCES' && isset($block['children'])) {
            foreach ($block['children'] as $resource) {
                if ($resource['name'] == 'RESOURCE') {
                    $resources[addslashes_js($resource['attrs']['IDENTIFIER'])] = $resource['attrs'];
                }
            }
        }
    }
    return $resources;
}
Ejemplo n.º 7
0
    function toHtml()
    {
        if ($this->_flagFrozen) {
            return $this->getFrozenHtml();
        } else {
            $id = $this->getAttribute('id');
            $unmask = get_string('unmaskpassword', 'form');
            $unmaskjs = '<script type="text/javascript">
//<![CDATA[
document.write(\'<div class="unmask"><input id="' . $id . 'unmask" value="1" type="checkbox" onclick="unmaskPassword(\\\'' . $id . '\\\')"/><label for="' . $id . 'unmask">' . addslashes_js($unmask) . '<\\/label><\\/div>\');
//]]>
</script>';
            return $this->_getTabs() . '<input' . $this->_getAttrString($this->_attributes) . ' />' . $unmaskjs;
        }
    }
Ejemplo n.º 8
0
 function wrap_html_start()
 {
     if (!$this->is_downloading()) {
         if ($this->candelete) {
             // Start form
             $strreallydel = addslashes_js(get_string('deleteattemptcheck', 'quiz'));
             echo '<div id="tablecontainer">';
             echo '<form id="attemptsform" method="post" action="' . $this->reporturl->out(true) . '" onsubmit="confirm(\'' . $strreallydel . '\');">';
             echo '<div style="display: none;">';
             echo $this->reporturl->hidden_params_out(array(), 0, $this->displayoptions);
             echo '</div>';
             echo '<div>';
         }
     }
 }
Ejemplo n.º 9
0
    function toHtml()
    {
        if ($this->_flagFrozen) {
            return $this->getFrozenHtml();
        } else {
            $id = $this->getAttribute('id');
            $reveal = get_string('revealpassword', 'form');
            $revealjs = '<script type="text/javascript">
//<![CDATA[
document.write(\'<div class="reveal"><input id="' . $id . 'reveal" value="1" type="checkbox" onclick="revealPassword(\\\'' . $id . '\\\')"/><label for="' . $id . 'reveal">' . addslashes_js($reveal) . '<\\/label><\\/div>\');
document.getElementById("' . $this->getAttribute('id') . '").setAttribute("autocomplete", "off");
//]]>
</script>';
            return $this->_getTabs() . '<input' . $this->_getAttrString($this->_attributes) . ' />' . $revealjs;
        }
    }
Ejemplo n.º 10
0
 function wrap_html_start()
 {
     if (!$this->is_downloading()) {
         if ($this->candelete) {
             // Start form
             $displayurl = new moodle_url($this->reporturl, $this->displayoptions);
             $strreallydel = addslashes_js(get_string('deleteattemptcheck', 'quiz'));
             echo '<div id="tablecontainer">';
             echo '<form id="attemptsform" method="post" action="' . $displayurl->out_omit_querystring() . '" onsubmit="confirm(\'' . $strreallydel . '\');">';
             echo '<div style="display: none;">';
             echo html_writer::input_hidden_params($displayurl);
             echo html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'sesskey', 'value' => sesskey())) . "\n";
             echo '</div>';
             echo '<div>';
         }
     }
 }
Ejemplo n.º 11
0
 function wrap_html_finish()
 {
     if (!$this->is_downloading()) {
         // Print "Select all" etc.
         if ($this->candelete) {
             $strreallydel = addslashes_js(get_string('deleteattemptcheck', 'quiz'));
             echo '<div id="commands">';
             echo '<a href="javascript:select_all_in(\'DIV\',null,\'tablecontainer\');">' . get_string('selectall', 'quiz') . '</a> / ';
             echo '<a href="javascript:deselect_all_in(\'DIV\',null,\'tablecontainer\');">' . get_string('selectnone', 'quiz') . '</a> ';
             echo '&nbsp;&nbsp;';
             echo '<input type="submit" onclick="return confirm(\'' . $strreallydel . '\');" name="delete" value="' . get_string('deleteselected', 'quiz_overview') . '"/>';
             echo '</div>';
             // Close form
             echo '</div>';
             echo '</form></div>';
         }
     }
 }
Ejemplo n.º 12
0
    function toHtml()
    {
        if ($this->_flagFrozen) {
            return $this->getFrozenHtml();
        } else {
            $id = $this->getAttribute('id');
            $unmask = get_string('unmaskpassword', 'form');
            $unmaskjs = '<script type="text/javascript">
//<![CDATA[

var is_ie = (navigator.userAgent.toLowerCase().indexOf("msie") != -1);

document.getElementById("' . $id . '").setAttribute("autocomplete", "off");

var unmaskdiv = document.getElementById("' . $id . 'unmaskdiv");

var unmaskchb = document.createElement("input");
unmaskchb.setAttribute("type", "checkbox");
unmaskchb.setAttribute("id", "' . $id . 'unmask");
unmaskchb.onchange = function() {unmaskPassword("' . $id . '");};
unmaskdiv.appendChild(unmaskchb);

var unmasklbl = document.createElement("label");
unmasklbl.innerHTML = "' . addslashes_js($unmask) . '";
if (is_ie) {
  unmasklbl.setAttribute("htmlFor", "' . $id . 'unmask");
} else {
  unmasklbl.setAttribute("for", "' . $id . 'unmask");
}
unmaskdiv.appendChild(unmasklbl);

if (is_ie) {
  // ugly hack to work around the famous onchange IE bug
  unmaskchb.onclick = function() {this.blur();};
  unmaskdiv.onclick = function() {this.blur();};
}
//]]>
</script>';
            return $this->_getTabs() . '<input' . $this->_getAttrString($this->_attributes) . ' /><div class="unmask" id="' . $id . 'unmaskdiv"></div>' . $unmaskjs;
        }
    }
Ejemplo n.º 13
0
 }
 $postbit_obj->cachable = $post_cachable;
 $post['postcount'] = ++$postcount;
 $post['attachments'] = $postattach['byattachment'];
 $post['allattachments'] = $postattach['bycontent'][$post['postid']];
 $parsed_postcache = array('text' => '', 'images' => 1);
 $bgclass = 'alt2';
 if ($threadedmode == 2) {
     $postbits .= $postbit_obj->construct_postbit($post);
 } else {
     $postbit = $postbit_obj->construct_postbit($post);
     if ($curpostid == $post['postid']) {
         $curpostdateline = $post['dateline'];
         $curpostbit = $postbit;
     }
     $postbit = preg_replace('#</script>#i', "<\\/scr' + 'ipt>", addslashes_js($postbit));
     $jspostbits .= "pd[{$post['postid']}] = '{$postbit}';\n";
 }
 // end threaded mode
 if ($post_cachable and $post['pagetext_html'] == '') {
     if (!empty($saveparsed)) {
         $saveparsed .= ',';
     }
     $saveparsed .= "({$post['postid']}, " . intval($thread['lastpost']) . ', ' . intval($postbit_obj->post_cache['has_images']) . ", '" . $db->escape_string($postbit_obj->post_cache['text']) . "'," . intval(STYLEID) . ", " . intval(LANGUAGEID) . ")";
 }
 if ($sigs_cachable and !empty($postbit_obj->sig_cache) and $post['userid']) {
     if (!empty($save_parsed_sigs)) {
         $save_parsed_sigs .= ',';
     }
     $save_parsed_sigs .= "({$post['userid']}, " . intval(STYLEID) . ", " . intval(LANGUAGEID) . ", '" . $db->escape_string($postbit_obj->sig_cache['text']) . "', " . intval($postbit_obj->sig_cache['has_images']) . ")";
 }
Ejemplo n.º 14
0
    $userdata->score_raw = '';
}
$userdata->student_id = addslashes_js($USER->username);
$userdata->student_name = addslashes_js($USER->lastname .', '. $USER->firstname);
$userdata->mode = 'normal';
if (!empty($mode)) {
    $userdata->mode = $mode;
}
if ($userdata->mode == 'normal') {
    $userdata->credit = 'credit';
} else {
    $userdata->credit = 'no-credit';
}
if ($scodatas = scorm_get_sco($scoid, SCO_DATA)) {
    foreach ($scodatas as $key => $value) {
        $userdata->$key = addslashes_js($value);
    }
} else {
    print_error('cannotfindsco', 'scorm');
}
if (!$sco = scorm_get_sco($scoid)) {
    print_error('cannotfindsco', 'scorm');
}
if (scorm_version_check($scorm->version, SCORM_13)) {
    $objectives = $DB->get_records('scorm_seq_objective', array('scoid' => $scoid));
    $index = 0;
    foreach ($objectives as $objective) {
        if (!empty($objective->minnormalizedmeasure)) {
            $userdata->{'cmi.scaled_passing_score'} = $objective->minnormalizedmeasure;
        }
        if (!empty($objective->objectiveid)) {
Ejemplo n.º 15
0
    /**
     * Returns XHTML for the field
     * Writes Javascript into the HTML below right before the last div
     *
     * @todo Make javascript available through newer methods if possible
     * @param string $data Value for the field
     * @param string $query Passed as final argument for format_admin_setting
     * @return string XHTML field
     */
    public function output_html($data, $query = '')
    {
        $id = $this->get_id();
        $unmask = get_string('unmaskpassword', 'form');
        $unmaskjs = '<script type="text/javascript">
//<![CDATA[
var is_ie = (navigator.userAgent.toLowerCase().indexOf("msie") != -1);

document.getElementById("' . $id . '").setAttribute("autocomplete", "off");

var unmaskdiv = document.getElementById("' . $id . 'unmaskdiv");

var unmaskchb = document.createElement("input");
unmaskchb.setAttribute("type", "checkbox");
unmaskchb.setAttribute("id", "' . $id . 'unmask");
unmaskchb.onchange = function() {unmaskPassword("' . $id . '");};
unmaskdiv.appendChild(unmaskchb);

var unmasklbl = document.createElement("label");
unmasklbl.innerHTML = "' . addslashes_js($unmask) . '";
if (is_ie) {
  unmasklbl.setAttribute("htmlFor", "' . $id . 'unmask");
} else {
  unmasklbl.setAttribute("for", "' . $id . 'unmask");
}
unmaskdiv.appendChild(unmasklbl);

if (is_ie) {
  // ugly hack to work around the famous onchange IE bug
  unmaskchb.onclick = function() {this.blur();};
  unmaskdiv.onclick = function() {this.blur();};
}
//]]>
</script>';
        return format_admin_setting($this, $this->visiblename, '<div class="form-password"><input type="password" size="' . $this->size . '" id="' . $id . '" name="' . $this->get_full_name() . '" value="' . s($data) . '" /><div class="unmask" id="' . $id . 'unmaskdiv"></div>' . $unmaskjs . '</div>', $this->description, true, '', NULL, $query);
    }
Ejemplo n.º 16
0
    /**
     * Helper method updating the listing on the main script from popup using javascript
     *
     * @global object
     * @global object
     * @param $submission object The submission whose data is to be updated on the main page
     */
    function update_main_listing($submission) {
        global $SESSION, $CFG, $OUTPUT;

        $output = '';

        $perpage = get_user_preferences('assignment_perpage', 10);

        $quickgrade = get_user_preferences('assignment_quickgrade', 0);

        /// Run some Javascript to try and update the parent page
        $output .= '<script type="text/javascript">'."\n<!--\n";
        if (empty($SESSION->flextable['mod-assignment-submissions']->collapse['submissioncomment'])) {
            if ($quickgrade){
                $output.= 'opener.document.getElementById("submissioncomment'.$submission->userid.'").value="'
                .trim($submission->submissioncomment).'";'."\n";
             } else {
                $output.= 'opener.document.getElementById("com'.$submission->userid.
                '").innerHTML="'.shorten_text(trim(strip_tags($submission->submissioncomment)), 15)."\";\n";
            }
        }

        if (empty($SESSION->flextable['mod-assignment-submissions']->collapse['grade'])) {
            //echo optional_param('menuindex');
            if ($quickgrade){
                $output.= 'opener.document.getElementById("menumenu'.$submission->userid.
                '").selectedIndex="'.optional_param('menuindex', 0, PARAM_INT).'";'."\n";
            } else {
                $output.= 'opener.document.getElementById("g'.$submission->userid.'").innerHTML="'.
                $this->display_grade($submission->grade)."\";\n";
            }
        }
        //need to add student's assignments in there too.
        if (empty($SESSION->flextable['mod-assignment-submissions']->collapse['timemodified']) &&
            $submission->timemodified) {
            $output.= 'opener.document.getElementById("ts'.$submission->userid.
                 '").innerHTML="'.addslashes_js($this->print_student_answer($submission->userid)).userdate($submission->timemodified)."\";\n";
        }

        if (empty($SESSION->flextable['mod-assignment-submissions']->collapse['timemarked']) &&
            $submission->timemarked) {
            $output.= 'opener.document.getElementById("tt'.$submission->userid.
                 '").innerHTML="'.userdate($submission->timemarked)."\";\n";
        }

        if (empty($SESSION->flextable['mod-assignment-submissions']->collapse['status'])) {
            $output.= 'opener.document.getElementById("up'.$submission->userid.'").className="s1";';
            $buttontext = get_string('update');
            $url = new moodle_url('/mod/assignment/submissions.php', array(
                    'id' => $this->cm->id,
                    'userid' => $submission->userid,
                    'mode' => 'single',
                    'offset' => (optional_param('offset', '', PARAM_INT)-1)));
            $button = $OUTPUT->action_link($url, $buttontext, new popup_action('click', $url, 'grade'.$submission->userid, array('height' => 450, 'width' => 700)), array('ttile'=>$buttontext));

            $output .= 'opener.document.getElementById("up'.$submission->userid.'").innerHTML="'.addslashes_js($button).'";';
        }

        $grading_info = grade_get_grades($this->course->id, 'mod', 'assignment', $this->assignment->id, $submission->userid);

        if (empty($SESSION->flextable['mod-assignment-submissions']->collapse['finalgrade'])) {
            $output.= 'opener.document.getElementById("finalgrade_'.$submission->userid.
            '").innerHTML="'.$grading_info->items[0]->grades[$submission->userid]->str_grade.'";'."\n";
        }

        if (!empty($CFG->enableoutcomes) and empty($SESSION->flextable['mod-assignment-submissions']->collapse['outcome'])) {

            if (!empty($grading_info->outcomes)) {
                foreach($grading_info->outcomes as $n=>$outcome) {
                    if ($outcome->grades[$submission->userid]->locked) {
                        continue;
                    }

                    if ($quickgrade){
                        $output.= 'opener.document.getElementById("outcome_'.$n.'_'.$submission->userid.
                        '").selectedIndex="'.$outcome->grades[$submission->userid]->grade.'";'."\n";

                    } else {
                        $options = make_grades_menu(-$outcome->scaleid);
                        $options[0] = get_string('nooutcome', 'grades');
                        $output.= 'opener.document.getElementById("outcome_'.$n.'_'.$submission->userid.'").innerHTML="'.$options[$outcome->grades[$submission->userid]->grade]."\";\n";
                    }

                }
            }
        }

        $output .= "\n-->\n</script>";
        return $output;
    }
Ejemplo n.º 17
0
/**
* Converts the newpost_attachmentbit template for use with javascript/construct_phrase
*
* @return	string
*/
function prepare_newpost_attachmentbit()
{
    // do not globalize $session or $attach!
    $attach = array('imgpath' => '%1$s', 'attachmentid' => '%3$s', 'dateline' => '%4$s', 'filename' => '%5$s', 'filesize' => '%6$s');
    $session['sessionurl'] = '%2$s';
    eval('$template = "' . fetch_template('newpost_attachmentbit') . '";');
    return addslashes_js($template, "'");
}
Ejemplo n.º 18
0
 $refreshusers = false;
 $us = array();
 if ($chatlasttime != $chatnewlasttime and $messages) {
     $beep = false;
     $refreshusers = false;
     foreach ($messages as $message) {
         $chatlastrow = ($chatlastrow + 1) % 2;
         $formatmessage = chat_format_message($message, $chatuser->course, $USER, $chatlastrow);
         if ($formatmessage->beep) {
             $beep = true;
         }
         if ($formatmessage->refreshusers) {
             $refreshusers = true;
         }
         $us[$message->userid] = $timenow - $message->timestamp;
         echo "parent.msg.document.write('" . addslashes_js($formatmessage->html) . "\\n');\n";
     }
     // From the last message printed.
     // A strange case where lack of closures is useful!
     $chatlasttime = $message->timestamp;
     $chatlastid = $message->id;
 }
 if ($refreshusers) {
     echo "if (parent.users.document.anchors[0] != null) {" . "parent.users.location.href = parent.users.document.anchors[0].href;}\n";
 } else {
     foreach ($us as $uid => $lastping) {
         $min = (int) ($lastping / 60);
         $sec = $lastping - $min * 60;
         $min = $min < 10 ? '0' . $min : $min;
         $sec = $sec < 10 ? '0' . $sec : $sec;
         $idle = $min . ':' . $sec;
Ejemplo n.º 19
0
 require_once DIR . '/includes/class_postbit.php';
 require_once DIR . '/includes/functions_bigthree.php';
 $vbulletin->input->clean_gpc('r', 'pmid', TYPE_UINT);
 ($hook = vBulletinHook::fetch_hook('private_showpm_start')) ? eval($hook) : false;
 $pm = $db->query_first_slave("\n\t\tSELECT\n\t\t\tpm.*, pmtext.*,\n\t\t\t" . iif($vbulletin->options['privallowicons'], "icon.title AS icontitle, icon.iconpath,") . "\n\t\t\tIF(ISNULL(pmreceipt.pmid), 0, 1) AS receipt, pmreceipt.readtime, pmreceipt.denied,\n\t\t\tsigpic.userid AS sigpic, sigpic.dateline AS sigpicdateline, sigpic.width AS sigpicwidth, sigpic.height AS sigpicheight\n\t\tFROM " . TABLE_PREFIX . "pm AS pm\n\t\tLEFT JOIN " . TABLE_PREFIX . "pmtext AS pmtext ON(pmtext.pmtextid = pm.pmtextid)\n\t\t" . iif($vbulletin->options['privallowicons'], "LEFT JOIN " . TABLE_PREFIX . "icon AS icon ON(icon.iconid = pmtext.iconid)") . "\n\t\tLEFT JOIN " . TABLE_PREFIX . "pmreceipt AS pmreceipt ON(pmreceipt.pmid = pm.pmid)\n\t\tLEFT JOIN " . TABLE_PREFIX . "sigpic AS sigpic ON(sigpic.userid = pmtext.fromuserid)\n\t\tWHERE pm.userid=" . $vbulletin->userinfo['userid'] . " AND pm.pmid=" . $vbulletin->GPC['pmid'] . "\n\t");
 if (!$pm) {
     eval(standard_error(fetch_error('invalidid', $vbphrase['private_message'], $vbulletin->options['contactuslink'])));
 }
 $folderjump = construct_folder_jump(0, $pm['folderid']);
 // do read receipt
 $show['receiptprompt'] = $show['receiptpopup'] = false;
 if ($pm['receipt'] == 1 and $pm['readtime'] == 0 and $pm['denied'] == 0) {
     if ($permissions['pmpermissions'] & $vbulletin->bf_ugp_pmpermissions['candenypmreceipts']) {
         // set it to denied just now as some people might have ad blocking that stops the popup appearing
         $show['receiptprompt'] = $show['receiptpopup'] = true;
         $receipt_question_js = addslashes_js(construct_phrase($vbphrase['x_has_requested_a_read_receipt'], unhtmlspecialchars($pm['fromusername'])), '"');
         $db->shutdown_query("UPDATE " . TABLE_PREFIX . "pmreceipt SET denied = 1 WHERE pmid = {$pm['pmid']}");
     } else {
         // they can't deny pm receipts so do not show a popup or prompt
         $db->shutdown_query("UPDATE " . TABLE_PREFIX . "pmreceipt SET readtime = " . TIMENOW . " WHERE pmid = {$pm['pmid']}");
     }
 } else {
     if ($pm['receipt'] == 1 and $pm['denied'] == 1) {
         $show['receiptprompt'] = true;
     }
 }
 $postbit_factory =& new vB_Postbit_Factory();
 $postbit_factory->registry =& $vbulletin;
 $postbit_factory->cache = array();
 $postbit_factory->bbcode_parser =& new vB_BbCodeParser($vbulletin, fetch_tag_list());
 $postbit_obj =& $postbit_factory->fetch_postbit('pm');
Ejemplo n.º 20
0
 /**
  * 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);
     }
 }
Ejemplo n.º 21
0
/**
 * Print url info and link.
 * @param object $url
 * @param object $cm
 * @param object $course
 * @return does not return
 */
function url_print_workaround($url, $cm, $course)
{
    global $OUTPUT;
    url_print_header($url, $cm, $course);
    url_print_heading($url, $cm, $course, true);
    url_print_intro($url, $cm, $course, true);
    $fullurl = url_get_full_url($url, $cm, $course);
    $display = url_get_final_display_type($url);
    if ($display == RESOURCELIB_DISPLAY_POPUP) {
        $jsfullurl = addslashes_js($fullurl);
        $options = empty($url->displayoptions) ? array() : unserialize($url->displayoptions);
        $width = empty($options['popupwidth']) ? 620 : $options['popupwidth'];
        $height = empty($options['popupheight']) ? 450 : $options['popupheight'];
        $wh = "width={$width},height={$height},toolbar=no,location=no,menubar=no,copyhistory=no,status=no,directories=no,scrollbars=yes,resizable=yes";
        $extra = "onclick=\"window.open('{$jsfullurl}', '', '{$wh}'); return false;\"";
    } else {
        if ($display == RESOURCELIB_DISPLAY_NEW) {
            $extra = "onclick=\"this.target='_blank';\"";
        } else {
            $extra = '';
        }
    }
    echo '<div class="urlworkaround">';
    print_string('clicktoopen', 'url', "<a href=\"{$fullurl}\" {$extra}>{$fullurl}</a>");
    echo '</div>';
    echo $OUTPUT->footer();
    die;
}
Ejemplo n.º 22
0
echo '  parent.messages.document.write("<meta http-equiv=\\"content-type\\" content=\\"text/html; charset=utf-8\\" />");' . "\n";
echo '  parent.messages.document.write("<base target=\\"_blank\\" />");' . "\n";
echo '  parent.messages.document.write("' . addslashes_js($stylesheetshtml) . '");' . "\n";
echo '  parent.messages.document.write("<\\/head><body class=\\"message course-1\\" id=\\"message-messages\\"><div style=\\"display: none\\" id=\\"messagestarted\\">&nbsp;<\\/div>");' . "\n";
echo '}' . "\n";
@ob_implicit_flush(true);
@ob_end_flush();
if ($messages = get_records_select('message', "useridto = '{$USER->id}' AND useridfrom = '{$userid}'", 'timecreated')) {
    foreach ($messages as $message) {
        $time = userdate($message->timecreated, get_string('strftimedatetimeshort'));
        $options = new object();
        $options->para = false;
        $options->newlines = true;
        $printmessage = format_text($message->message, $message->format, $options);
        $printmessage = '<div class="message other"><span class="author">' . s($userfullname) . '</span> ' . '<span class="time">[' . $time . ']</span>: ' . '<span class="content">' . $printmessage . '</span></div>';
        $printmessage = addslashes_js($printmessage);
        // So Javascript can write it
        echo "parent.messages.document.write('" . $printmessage . "');\n";
        /// Move the entry to the other table
        $message->timeread = time();
        $message = addslashes_object($message);
        $messageid = $message->id;
        unset($message->id);
        if (insert_record('message_read', $message)) {
            delete_records('message', 'id', $messageid);
        }
    }
    if (get_user_preferences('message_beepnewmessage', 0)) {
        $playbeep = true;
    }
    echo 'parent.messages.scroll(1,5000000);' . "\n";
Ejemplo n.º 23
0
     $smcache["{$smilie['category']}"][] = $smilie;
 }
 $popup_smiliesbits = '';
 $bits = array();
 exec_switch_bg();
 foreach ($smcache as $category => $smilies) {
     if (sizeof($bits) == 1) {
         eval('$smiliecells = "' . fetch_template('smiliepopup_straggler') . '";');
         eval('$smiliebits .= "' . fetch_template('smiliepopup_row') . '";');
     }
     ($hook = vBulletinHook::fetch_hook('misc_smiliespopup_category')) ? eval($hook) : false;
     eval('$smiliebits .= "' . fetch_template('smiliepopup_category') . '";');
     $bits = array();
     foreach ($smilies as $smilie) {
         ($hook = vBulletinHook::fetch_hook('misc_smiliespopup_smilie')) ? eval($hook) : false;
         $smilie['js'] = addslashes_js($smilie['text']);
         $smiliehtml = "<img src=\"{$smilie['path']}\" id=\"smilie_{$smilie['smilieid']}\" alt=\"" . htmlspecialchars_uni($smilie['text']) . "\" title=\"" . htmlspecialchars_uni($smilie['title']) . "\" />";
         eval('$bits[] = "' . fetch_template('smiliepopup_smilie') . '";');
         if (sizeof($bits) == 2) {
             exec_switch_bg();
             $smiliecells = implode('', $bits);
             eval('$smiliebits .= "' . fetch_template('smiliepopup_row') . '";');
             $bits = array();
         }
     }
 }
 if (sizeof($bits) == 1) {
     eval('$smiliecells = "' . fetch_template('smiliepopup_straggler') . '";');
     eval('$smiliebits .= "' . fetch_template('smiliepopup_row') . '";');
 }
 ($hook = vBulletinHook::fetch_hook('misc_smiliespopup_complete')) ? eval($hook) : false;
Ejemplo n.º 24
0
/**
 * @global object
 * @param object $choicegroup
 * @param object $course
 * @param object $coursemodule
 * @param array $allresponses
 *  * @param bool $allresponses
 * @return object
 */
function prepare_choicegroup_show_results($choicegroup, $course, $cm, $allresponses, $forcepublish = false)
{
    global $CFG, $FULLSCRIPT, $PAGE, $OUTPUT;
    $display = clone $choicegroup;
    $display->coursemoduleid = $cm->id;
    $display->courseid = $course->id;
    //debugging('<pre>'.print_r($choicegroup->option, true).'</pre>', DEBUG_DEVELOPER);
    //debugging('<pre>'.print_r($allresponses, true).'</pre>', DEBUG_DEVELOPER);
    //overwrite options value;
    $display->options = array();
    $totaluser = 0;
    foreach ($choicegroup->option as $optionid => $groupid) {
        $display->options[$optionid] = new stdClass();
        $display->options[$optionid]->groupid = $groupid;
        $display->options[$optionid]->maxanswer = $choicegroup->maxanswers[$optionid];
        if (array_key_exists($groupid, $allresponses)) {
            $display->options[$optionid]->user = $allresponses[$groupid];
            $totaluser += count($allresponses[$groupid]);
        }
    }
    if ($choicegroup->showunanswered) {
        $display->options[0]->user = $allresponses[0];
    }
    unset($display->option);
    unset($display->maxanswers);
    $display->numberofuser = $totaluser;
    $context = context_module::instance($cm->id);
    $display->viewresponsecapability = has_capability('mod/choicegroup:readresponses', $context);
    $display->deleterepsonsecapability = has_capability('mod/choicegroup:deleteresponses', $context);
    $display->fullnamecapability = has_capability('moodle/site:viewfullnames', $context);
    if (empty($allresponses)) {
        echo $OUTPUT->heading(get_string("nousersyet"));
        return false;
    }
    $totalresponsecount = 0;
    foreach ($allresponses as $optionid => $userlist) {
        if ($choicegroup->showunanswered || $optionid) {
            $totalresponsecount += count($userlist);
        }
    }
    $context = context_module::instance($cm->id);
    $hascapfullnames = has_capability('moodle/site:viewfullnames', $context);
    $viewresponses = has_capability('mod/choicegroup:readresponses', $context);
    switch ($forcepublish) {
        case CHOICEGROUP_PUBLISH_NAMES:
            echo '<div id="tablecontainer">';
            if ($viewresponses) {
                echo '<form id="attemptsform" method="post" action="' . $FULLSCRIPT . '" onsubmit="var menu = document.getElementById(\'menuaction\'); return (menu.options[menu.selectedIndex].value == \'delete\' ? \'' . addslashes_js(get_string('deleteattemptcheck', 'quiz')) . '\' : true);">';
                echo '<div>';
                echo '<input type="hidden" name="id" value="' . $cm->id . '" />';
                echo '<input type="hidden" name="sesskey" value="' . sesskey() . '" />';
                echo '<input type="hidden" name="mode" value="overview" />';
            }
            echo "<table cellpadding=\"5\" cellspacing=\"10\" class=\"results names\">";
            echo "<tr>";
            $columncount = array();
            // number of votes in each column
            if ($choicegroup->showunanswered) {
                $columncount[0] = 0;
                echo "<th class=\"col0 header\" scope=\"col\">";
                print_string('notanswered', 'choicegroup');
                echo "</th>";
            }
            $count = 1;
            foreach ($choicegroup->option as $optionid => $optiontext) {
                $columncount[$optionid] = 0;
                // init counters
                echo "<th class=\"col{$count} header\" scope=\"col\">";
                echo format_string($optiontext);
                echo "</th>";
                $count++;
            }
            echo "</tr><tr>";
            if ($choicegroup->showunanswered) {
                echo "<td class=\"col{$count} data\" >";
                // added empty row so that when the next iteration is empty,
                // we do not get <table></table> error from w3c validator
                // MDL-7861
                echo "<table class=\"choicegroupresponse\"><tr><td></td></tr>";
                if (!empty($allresponses[0])) {
                    foreach ($allresponses[0] as $user) {
                        echo "<tr>";
                        echo "<td class=\"picture\">";
                        echo $OUTPUT->user_picture($user, array('courseid' => $course->id));
                        echo "</td><td class=\"fullname\">";
                        echo "<a href=\"{$CFG->wwwroot}/user/view.php?id={$user->id}&amp;course={$course->id}\">";
                        echo fullname($user, $hascapfullnames);
                        echo "</a>";
                        echo "</td></tr>";
                    }
                }
                echo "</table></td>";
            }
            $count = 1;
            foreach ($choicegroup->option as $optionid => $optiontext) {
                echo '<td class="col' . $count . ' data" >';
                // added empty row so that when the next iteration is empty,
                // we do not get <table></table> error from w3c validator
                // MDL-7861
                echo '<table class="choicegroupresponse"><tr><td></td></tr>';
                if (isset($allresponses[$optionid])) {
                    foreach ($allresponses[$optionid] as $user) {
                        $columncount[$optionid] += 1;
                        echo '<tr><td class="attemptcell">';
                        if ($viewresponses and has_capability('mod/choicegroup:deleteresponses', $context)) {
                            echo '<input type="checkbox" name="userid[]" value="' . $user->id . '" />';
                        }
                        echo '</td><td class="picture">';
                        echo $OUTPUT->user_picture($user, array('courseid' => $course->id));
                        echo '</td><td class="fullname">';
                        echo "<a href=\"{$CFG->wwwroot}/user/view.php?id={$user->id}&amp;course={$course->id}\">";
                        echo fullname($user, $hascapfullnames);
                        echo '</a>';
                        echo '</td></tr>';
                    }
                }
                $count++;
                echo '</table></td>';
            }
            echo "</tr><tr>";
            $count = 1;
            if ($choicegroup->showunanswered) {
                echo "<td></td>";
            }
            foreach ($choicegroup->option as $optionid => $optiontext) {
                echo "<td align=\"center\" class=\"col{$count} count\">";
                if ($choicegroup->limitanswers) {
                    echo get_string("taken", "choicegroup") . ":";
                    echo $columncount[$optionid];
                    echo "<br/>";
                    echo get_string("limit", "choicegroup") . ":";
                    echo $choicegroup->maxanswers[$optionid];
                } else {
                    if (isset($columncount[$optionid])) {
                        echo $columncount[$optionid];
                    }
                }
                echo "</td>";
                $count++;
            }
            echo "</tr>";
            /// Print "Select all" etc.
            if ($viewresponses and has_capability('mod/choicegroup:deleteresponses', $context)) {
                echo '<tr><td></td><td>';
                echo '<a href="javascript:select_all_in(\'DIV\',null,\'tablecontainer\');">' . get_string('selectall') . '</a> / ';
                echo '<a href="javascript:deselect_all_in(\'DIV\',null,\'tablecontainer\');">' . get_string('deselectall') . '</a> ';
                echo '&nbsp;&nbsp;';
                echo html_writer::label(get_string('withselected', 'choicegroup'), 'menuaction');
                echo html_writer::select(array('delete' => get_string('delete')), 'action', '', array('' => get_string('withselectedusers')), array('id' => 'menuaction'));
                $PAGE->requires->js_init_call('M.util.init_select_autosubmit', array('attemptsform', 'menuaction', ''));
                echo '<noscript id="noscriptmenuaction" style="display:inline">';
                echo '<div>';
                echo '<input type="submit" value="' . get_string('go') . '" /></div></noscript>';
                echo '</td><td></td></tr>';
            }
            echo "</table></div>";
            if ($viewresponses) {
                echo "</form></div>";
            }
            break;
    }
    return $display;
}
Ejemplo n.º 25
0
/**
 * Replace flv links with flow player.
 *
 * @param  $link
 * @return string
 */
function filter_mediaplugin_flv_callback($link)
{
    static $count = 0;
    if (filter_mediaplugin_ignore($link[0])) {
        return $link[0];
    }
    $count++;
    $id = 'filter_flv_' . time() . '_' . $count;
    //we need something unique because it might be stored in text cache
    list($urls, $width, $height) = filter_mediaplugin_parse_alternatives($link[1], 0, 0);
    $autosize = false;
    if (!$width and !$height) {
        $width = FILTER_MEDIAPLUGIN_VIDEO_WIDTH;
        $height = FILTER_MEDIAPLUGIN_VIDEO_HEIGHT;
        $autosize = true;
    }
    $flashurl = null;
    $sources = array();
    foreach ($urls as $url) {
        $mimetype = filter_mediaplugin_get_mimetype($url);
        if (strpos($mimetype, 'video/') !== 0) {
            continue;
        }
        $source = html_writer::tag('source', '', array('src' => $url, 'type' => $mimetype));
        if ($mimetype === 'video/mp4') {
            // better add m4v as first source, it might be a bit more compatible with problematic browsers
            array_unshift($sources, $source);
        } else {
            $sources[] = $source;
        }
        if ($flashurl === null) {
            $flashurl = $url;
        }
    }
    if (!$sources) {
        return $link[0];
    }
    $info = trim($link[4]);
    if (empty($info) or strpos($info, 'http') === 0) {
        $info = get_string('fallbackvideo', 'filter_mediaplugin');
    }
    $printlink = html_writer::link($flashurl . '#', $info, array('class' => 'mediafallbacklink'));
    // the '#' prevents the QT filter
    $title = s($info);
    if (count($sources) > 1) {
        $sources = implode("\n", $sources);
        // html 5 fallback
        $printlink = <<<OET
<video controls="true" width="{$width}" height="{$height}" preload="metadata" title="{$title}">
{$sources}
{$printlink}
</video>
<noscript><br />
{$printlink}
</noscript>
OET;
    }
    // note: no need to print "this is flv link" because it is printed automatically if JS or Flash not available
    $output = html_writer::tag('span', $printlink, array('id' => $id, 'class' => 'mediaplugin mediaplugin_flv'));
    $output .= html_writer::script(js_writer::function_call('M.util.add_video_player', array($id, addslashes_js($flashurl), $width, $height, $autosize)));
    // we can not use standard JS init because this may be cached
    return $output;
}
Ejemplo n.º 26
0
/**
 * Does proper javascript quoting.
 *
 * Do not use addslashes anymore, because it does not work when magic_quotes_sybase is enabled.
 *
 * @param mixed $var String, Array, or Object to add slashes to
 * @return mixed quoted result
 */
function addslashes_js($var)
{
    if (is_string($var)) {
        $var = str_replace('\\', '\\\\', $var);
        $var = str_replace(array('\'', '"', "\n", "\r", ""), array('\\\'', '\\"', '\\n', '\\r', '\\0'), $var);
        $var = str_replace('</', '<\\/', $var);
        // XHTML compliance
    } else {
        if (is_array($var)) {
            $var = array_map('addslashes_js', $var);
        } else {
            if (is_object($var)) {
                $a = get_object_vars($var);
                foreach ($a as $key => $value) {
                    $a[$key] = addslashes_js($value);
                }
                $var = (object) $a;
            }
        }
    }
    return $var;
}
Ejemplo n.º 27
0
function scorm_insert_track($userid, $scormid, $scoid, $attempt, $element, $value)
{
    $id = null;
    if ($track = get_record_select('scorm_scoes_track', "userid='{$userid}' AND scormid='{$scormid}' AND scoid='{$scoid}' AND attempt='{$attempt}' AND element='{$element}'")) {
        $track->value = addslashes_js($value);
        $track->timemodified = time();
        $id = update_record('scorm_scoes_track', $track);
    } else {
        $track->userid = $userid;
        $track->scormid = $scormid;
        $track->scoid = $scoid;
        $track->attempt = $attempt;
        $track->element = $element;
        $track->value = addslashes_js($value);
        $track->timemodified = time();
        $id = insert_record('scorm_scoes_track', $track);
    }
    if (strstr($element, '.score.raw') || ($element == 'cmi.core.lesson_status' || $element == 'cmi.completion_status') && ($track->value == 'completed' || $track->value == 'passed')) {
        $scorm = get_record('scorm', 'id', $scormid);
        $grademethod = $scorm->grademethod % 10;
        include_once 'lib.php';
        scorm_update_grades($scorm, $userid);
    }
    return $id;
}
Ejemplo n.º 28
0
        $parentlist = $style['parentlist'];
    }
    // all browsers now support the enhanced template editor
    if (true) {
        define('FORMTYPE', 1);
        $SHOWTEMPLATE = 'construct_template_option';
    } else {
        define('FORMTYPE', 0);
        $SHOWTEMPLATE = 'construct_template_link';
    }
    if ($vbulletin->debug) {
        $JS_STYLETITLES[] = "\"0\" : \"" . $vbphrase['master_style'] . "\"";
        $prepend = '--';
    }
    foreach ($stylecache as $style) {
        $JS_STYLETITLES[] = "\"{$style['styleid']}\" : \"" . addslashes_js($style['title'], '"') . "\"";
        $JS_STYLEPARENTS[] = "\"{$style['styleid']}\" : \"{$style['parentid']}\"";
    }
    $JS_MONTHS = array();
    $i = 0;
    $months = array('january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december');
    foreach ($months as $month) {
        $JS_MONTHS[] = "\"{$i}\" : \"" . $vbphrase["{$month}"] . "\"";
        $i++;
    }
    foreach (array('click_the_expand_collapse_button', 'this_template_has_been_customized_in_a_parent_style', 'this_template_has_not_been_customized', 'this_template_has_been_customized_in_this_style', 'template_last_edited_js', 'x_templates') as $phrasename) {
        $JS_PHRASES[] = "\"{$phrasename}\" : \"" . fetch_js_safe_string($vbphrase["{$phrasename}"]) . "\"";
    }
    ?>

<script type="text/javascript">
Ejemplo n.º 29
0
 /**
  * Return edit icon for give element
  *
  * @param array  $element An array representing an element in the grade_tree
  * @param object $gpr A grade_plugin_return object
  *
  * @return string
  */
 public function get_edit_icon($element, $gpr)
 {
     global $CFG, $OUTPUT;
     if (!has_capability('moodle/grade:manage', $this->context)) {
         if ($element['type'] == 'grade' and has_capability('moodle/grade:edit', $this->context)) {
             // oki - let them override grade
         } else {
             return '';
         }
     }
     static $strfeedback = null;
     static $streditgrade = null;
     if (is_null($streditgrade)) {
         $streditgrade = get_string('editgrade', 'grades');
         $strfeedback = get_string('feedback');
     }
     $strparams = $this->get_params_for_iconstr($element);
     $object = $element['object'];
     switch ($element['type']) {
         case 'item':
         case 'categoryitem':
         case 'courseitem':
             $stredit = get_string('editverbose', 'grades', $strparams);
             if (empty($object->outcomeid) || empty($CFG->enableoutcomes)) {
                 $url = new moodle_url('/grade/edit/tree/item.php', array('courseid' => $this->courseid, 'id' => $object->id));
             } else {
                 $url = new moodle_url('/grade/edit/tree/outcomeitem.php', array('courseid' => $this->courseid, 'id' => $object->id));
             }
             break;
         case 'category':
             $stredit = get_string('editverbose', 'grades', $strparams);
             $url = new moodle_url('/grade/edit/tree/category.php', array('courseid' => $this->courseid, 'id' => $object->id));
             break;
         case 'grade':
             $stredit = $streditgrade;
             if (empty($object->id)) {
                 $url = new moodle_url('/grade/edit/tree/grade.php', array('courseid' => $this->courseid, 'itemid' => $object->itemid, 'userid' => $object->userid));
             } else {
                 $url = new moodle_url('/grade/edit/tree/grade.php', array('courseid' => $this->courseid, 'id' => $object->id));
             }
             if (!empty($object->feedback)) {
                 $feedback = addslashes_js(trim(format_string($object->feedback, $object->feedbackformat)));
             }
             break;
         default:
             $url = null;
     }
     if ($url) {
         return $OUTPUT->action_icon($gpr->add_url_params($url), new pix_icon('t/edit', $stredit));
     } else {
         return '';
     }
 }
Ejemplo n.º 30
0
					document.cpform.submit();
					return;
				case 'productdelete': page = "plugin.php?do=productdelete&productid="; break;
				default: return;
			}
			document.cpform.reset();
			jumptopage = page + sid + "&s=<?php 
    echo $vbulletin->session->vars['sessionhash'];
    ?>
";
			window.location = jumptopage;
		}
		else
		{
			alert('<?php 
    echo addslashes_js($vbphrase['invalid_action_specified']);
    ?>
');
		}
	}
	</script>
	<?php 
    print_form_header('plugin', 'productexport', false, true, 'cpform', '90%', 'download');
    construct_hidden_code('productid', '');
    print_table_header($vbphrase['installed_products'], 4);
    # Phrase me
    print_cells_row(array($vbphrase['title'], $vbphrase['version'], $vbphrase['description'], $vbphrase['controls']), 1);
    print_cells_row(array('<strong>vBulletin</strong>', $vbulletin->options['templateversion'], '', ''), false, '', -2);
    // used for <select> id attribute
    $i = 0;
    $products = $db->query_read("\r\n\t\tSELECT *\r\n\t\tFROM " . TABLE_PREFIX . "product\r\n\t\tORDER BY title\r\n\t");