Пример #1
0
print_category_edit(NULL, $displaylist, $parentlist);
echo '</table>';
echo '<div class="buttons">';
if (has_capability('moodle/course:create', $systemcontext)) {
    // print create course link to first category
    $options = array();
    $options = array('category' => $CFG->defaultrequestcategory);
    $form = html_form::make_button('edit.php', $options, get_string('addnewcourse'));
    $form->method = 'get';
    echo $OUTPUT->button($form);
}
// Print button for creating new categories
if (has_capability('moodle/category:manage', $systemcontext)) {
    $options = array();
    $options['parent'] = 0;
    $form = html_form::make_button('editcategory.php', $options, get_string('addnewcategory'));
    $form->method = 'get';
    echo $OUTPUT->button($form);
}
print_course_request_buttons($systemcontext);
echo '</div>';
echo $OUTPUT->footer();
function print_category_edit($category, $displaylist, $parentslist, $depth = -1, $up = false, $down = false)
{
    /// Recursive function to print all the categories ready for editing
    global $CFG, $USER, $OUTPUT;
    static $str = NULL;
    if (is_null($str)) {
        $str = new stdClass();
        $str->edit = get_string('edit');
        $str->delete = get_string('delete');
Пример #2
0
    } else {
        if ($edit == 0 and confirm_sesskey()) {
            $USER->gradeediting[$course->id] = 0;
        }
    }
    // page params for the turn editting on
    $options = $gpr->get_options();
    $options['sesskey'] = sesskey();
    if ($USER->gradeediting[$course->id]) {
        $options['edit'] = 0;
        $string = get_string('turneditingoff');
    } else {
        $options['edit'] = 1;
        $string = get_string('turneditingon');
    }
    $buttons = $OUTPUT->button(html_form::make_button('index.php', $options, $string, 'get'));
} else {
    $USER->gradeediting[$course->id] = 0;
    $buttons = '';
}
$gradeserror = array();
// Handle toggle change request
if (!is_null($toggle) && !empty($toggle_type)) {
    set_user_preferences(array('grade_report_show' . $toggle_type => $toggle));
}
//first make sure we have proper final grades - this must be done before constructing of the grade tree
grade_regrade_final_grades($courseid);
// Perform actions
if (!empty($target) && !empty($action) && confirm_sesskey()) {
    grade_report_grader::process_action($target, $action);
}
Пример #3
0
        echo $OUTPUT->footer();
        exit;
    } else {
        if ($confirmed == AUTH_CONFIRM_OK) {
            // The user has confirmed successfully, let's log them in
            if (!($user = get_complete_user_data('username', $username))) {
                print_error('cannotfinduser', '', '', $username);
            }
            complete_user_login($user);
            if (!empty($SESSION->wantsurl)) {
                // Send them where they were going
                $goto = $SESSION->wantsurl;
                unset($SESSION->wantsurl);
                redirect($goto);
            }
            print_header(get_string("confirmed"), get_string("confirmed"), array(), "");
            echo $OUTPUT->box_start('generalbox centerpara boxwidthnormal boxaligncenter');
            echo "<h3>" . get_string("thanks") . ", " . fullname($USER) . "</h3>\n";
            echo "<p>" . get_string("confirmed") . "</p>\n";
            echo $OUTPUT->button(html_form::make_button("{$CFG->wwwroot}/course/", null, get_string('courses')));
            echo $OUTPUT->box_end();
            echo $OUTPUT->footer();
            exit;
        } else {
            print_error('invalidconfirmdata');
        }
    }
} else {
    print_error("errorwhenconfirming");
}
redirect("{$CFG->wwwroot}/");
Пример #4
0
     $filtername = $filterpath;
 }
 if (substr($filterpath, 0, 4) == 'mod/') {
     $mod = basename($filterpath);
     $a = new stdClass();
     $a->filter = $filtername;
     $a->module = get_string('modulename', $mod);
     print_error('cannotdeletemodfilter', 'admin', $returnurl, $a);
 }
 // If not yet confirmed, display a confirmation message.
 if (!optional_param('confirm', '', PARAM_BOOL)) {
     $title = get_string('deletefilterareyousure', 'admin', $filtername);
     admin_externalpage_print_header();
     echo $OUTPUT->heading($title);
     $linkcontinue = new moodle_url($returnurl, array('action' => 'delete', 'filterpath' => $filterpath, 'confirm' => 1));
     $formcancel = html_form::make_button($returnurl, null, get_string('no'), 'get');
     echo $OUTPUT->confirm(get_string('deletefilterareyousuremessage', 'admin', $filtername), $linkcontinue, $formcancel);
     echo $OUTPUT->footer();
     exit;
 }
 // Do the deletion.
 $title = get_string('deletingfilter', 'admin', $filtername);
 admin_externalpage_print_header();
 echo $OUTPUT->heading($title);
 // Delete all data for this plugin.
 filter_delete_all_for_filter($filterpath);
 $a = new stdClass();
 $a->filter = $filtername;
 $a->directory = $filterpath;
 echo $OUTPUT->box(get_string('deletefilterfiles', 'admin', $a), 'generalbox', 'notice');
 echo $OUTPUT->continue_button($returnurl);
Пример #5
0
 function output_quiz_info_table($course, $cm, $quiz, $quizstats, $usingattemptsstring, $currentgroup, $groupstudents, $useallattempts, $download, $reporturl, $everything)
 {
     global $DB, $OUTPUT;
     // Print information on the number of existing attempts
     $quizinformationtablehtml = $OUTPUT->heading(get_string('quizinformation', 'quiz_statistics'), 2, 'main');
     $quizinformationtable = new html_table();
     $quizinformationtable->align = array('center', 'center');
     $quizinformationtable->width = '60%';
     $quizinformationtable->class = 'generaltable titlesleft';
     $quizinformationtable->data = array();
     $quizinformationtable->data[] = array(get_string('quizname', 'quiz_statistics'), $quiz->name);
     $quizinformationtable->data[] = array(get_string('coursename', 'quiz_statistics'), $course->fullname);
     if ($cm->idnumber) {
         $quizinformationtable->data[] = array(get_string('idnumbermod'), $cm->idnumber);
     }
     if ($quiz->timeopen) {
         $quizinformationtable->data[] = array(get_string('quizopen', 'quiz'), userdate($quiz->timeopen));
     }
     if ($quiz->timeclose) {
         $quizinformationtable->data[] = array(get_string('quizclose', 'quiz'), userdate($quiz->timeclose));
     }
     if ($quiz->timeopen && $quiz->timeclose) {
         $quizinformationtable->data[] = array(get_string('duration', 'quiz_statistics'), format_time($quiz->timeclose - $quiz->timeopen));
     }
     $format = array('firstattemptscount' => '', 'allattemptscount' => '', 'firstattemptsavg' => 'sumgrades_as_percentage', 'allattemptsavg' => 'sumgrades_as_percentage', 'median' => 'sumgrades_as_percentage', 'standarddeviation' => 'sumgrades_as_percentage', 'skewness' => '', 'kurtosis' => '', 'cic' => 'number_format', 'errorratio' => 'number_format', 'standarderror' => 'sumgrades_as_percentage');
     foreach ($quizstats as $property => $value) {
         if (!isset($format[$property])) {
             continue;
         }
         if (!is_null($value)) {
             switch ($format[$property]) {
                 case 'sumgrades_as_percentage':
                     $formattedvalue = quiz_report_scale_sumgrades_as_percentage($value, $quiz);
                     break;
                 case 'number_format':
                     $formattedvalue = quiz_format_grade($quiz, $value) . '%';
                     break;
                 default:
                     $formattedvalue = $value;
             }
             $quizinformationtable->data[] = array(get_string($property, 'quiz_statistics', $usingattemptsstring), $formattedvalue);
         }
     }
     if (!$this->table->is_downloading()) {
         if (isset($quizstats->timemodified)) {
             list($fromqa, $whereqa, $qaparams) = quiz_report_attempts_sql($quiz->id, $currentgroup, $groupstudents, $useallattempts);
             $sql = 'SELECT COUNT(1) ' . 'FROM ' . $fromqa . ' ' . 'WHERE ' . $whereqa . ' AND qa.timefinish > :time';
             $a = new object();
             $a->lastcalculated = format_time(time() - $quizstats->timemodified);
             if (!($a->count = $DB->count_records_sql($sql, array('time' => $quizstats->timemodified) + $qaparams))) {
                 $a->count = 0;
             }
             $quizinformationtablehtml .= $OUTPUT->box_start('boxaligncenter generalbox boxwidthnormal mdl-align');
             $quizinformationtablehtml .= get_string('lastcalculated', 'quiz_statistics', $a);
             $quizinformationtablehtml .= $OUTPUT->button(html_form::make_button($reporturl->out(true), $reporturl->params() + array('recalculate' => 1), get_string('recalculatenow', 'quiz_statistics')));
             $quizinformationtablehtml .= $OUTPUT->box_end();
         }
         $downloadoptions = $this->table->get_download_menu();
         $quizinformationtablehtml .= '<form action="' . $this->table->baseurl . '" method="post">';
         $quizinformationtablehtml .= '<div class="mdl-align">';
         $quizinformationtablehtml .= '<input type="hidden" name="everything" value="1"/>';
         $quizinformationtablehtml .= '<input type="submit" value="' . get_string('downloadeverything', 'quiz_statistics') . '"/>';
         $select = html_select::make($downloadoptions, 'download', $this->table->defaultdownloadformat, false);
         $select->nothingvalue = '';
         $quizinformationtablehtml .= $OUTPUT->select($select);
         $quizinformationtablehtml .= $OUTPUT->help_icon(moodle_help_icon::make('tableexportformats', get_string('tableexportformats', 'table')));
         $quizinformationtablehtml .= '</div></form>';
     }
     $quizinformationtablehtml .= $OUTPUT->table($quizinformationtable);
     if (!$this->table->is_downloading()) {
         echo $quizinformationtablehtml;
     } elseif ($everything) {
         $exportclass =& $this->table->export_class_instance();
         if ($download == 'xhtml') {
             echo $quizinformationtablehtml;
         } else {
             $exportclass->start_table(get_string('quizinformation', 'quiz_statistics'));
             $headers = array();
             $row = array();
             foreach ($quizinformationtable->data as $data) {
                 $headers[] = $data[0];
                 $row[] = $data[1];
             }
             $exportclass->output_headers($headers);
             $exportclass->add_data($row);
             $exportclass->finish_table();
         }
     }
 }
Пример #6
0
        print_error('invalidcourseid');
    }
    $group = new object();
    $group->courseid = $course->id;
}
require_login($course);
$context = get_context_instance(CONTEXT_COURSE, $course->id);
require_capability('moodle/course:managegroups', $context);
$returnurl = $CFG->wwwroot . '/group/index.php?id=' . $course->id . '&amp;group=' . $id;
if ($id and $delete) {
    if (!$confirm) {
        print_header(get_string('deleteselectedgroup', 'group'), get_string('deleteselectedgroup', 'group'));
        $optionsyes = array('id' => $id, 'delete' => 1, 'courseid' => $courseid, 'sesskey' => sesskey(), 'confirm' => 1);
        $optionsno = array('id' => $courseid);
        $formcontinue = html_form::make_button('group.php', $optionsyes, get_string('yes'), 'get');
        $formcancel = html_form::make_button($baseurl, $optionsno, get_string('no'), 'get');
        echo $OUTPUT->confirm(get_string('deletegroupconfirm', 'group', $group->name), $formcontinue, $formcancel);
        echo $OUTPUT->footer();
        die;
    } else {
        if (confirm_sesskey()) {
            if (groups_delete_group($id)) {
                redirect('index.php?id=' . $course->id);
            } else {
                print_error('erroreditgroup', 'group', $returnurl);
            }
        }
    }
}
/// First create the form
$editform = new group_form();
Пример #7
0
                }
                echo $ug2 . "\t";
                if (isset($option_text)) {
                    echo format_string($option_text, true);
                }
                echo "\n";
            }
        }
    }
    exit;
}
choice_show_results($choice, $course, $cm, $users, $format);
//show table with students responses.
//now give links for downloading spreadsheets.
if (!empty($users) && has_capability('mod/choice:downloadresponses', $context)) {
    echo "<br />\n";
    echo "<table class=\"downloadreport\"><tr>\n";
    echo "<td>";
    $options = array();
    $options["id"] = "{$cm->id}";
    $options["download"] = "ods";
    echo $OUTPUT->button(html_form::make_button("report.php", $options, get_string("downloadods")));
    echo "</td><td>";
    $options["download"] = "xls";
    echo $OUTPUT->button(html_form::make_button("report.php", $options, get_string("downloadexcel")));
    echo "</td><td>";
    $options["download"] = "txt";
    echo $OUTPUT->button(html_form::make_button("report.php", $options, get_string("downloadtext")));
    echo "</td></tr></table>";
}
echo $OUTPUT->footer();
Пример #8
0
    } else {
        $row[3] .= get_spacer();
    }
    // edit
    $row[3] .= get_action_icon($defineurl . '?action=edit&amp;roleid=' . $role->id, 'edit', $stredit, get_string('editxrole', 'role', $role->localname));
    // duplicate
    $row[3] .= get_action_icon($defineurl . '?action=duplicate&amp;roleid=' . $role->id, 'copy', $strduplicate, get_string('createrolebycopying', 'role', $role->localname));
    // delete
    if (isset($undeletableroles[$role->id])) {
        $row[3] .= get_spacer();
    } else {
        $row[3] .= get_action_icon($baseurl . '?action=delete&amp;roleid=' . $role->id, 'delete', $strdelete, get_string('deletexrole', 'role', $role->localname));
    }
    $table->data[] = $row;
}
echo $OUTPUT->table($table);
echo $OUTPUT->container_start('buttons');
echo $OUTPUT->button(html_form::make_button($defineurl, array('action' => 'add'), get_string('addrole', 'role'), 'get'));
echo $OUTPUT->container_end();
echo $OUTPUT->footer();
die;
function get_action_icon($url, $icon, $alt, $tooltip)
{
    global $OUTPUT;
    return '<a title="' . $tooltip . '" href="' . $url . '">' . '<img src="' . $OUTPUT->old_icon_url('t/' . $icon) . '" class="iconsmall" alt="' . $alt . '" /></a> ';
}
function get_spacer()
{
    global $OUTPUT;
    return '<img src="' . $OUTPUT->old_icon_url('spacer') . '" class="iconsmall" alt="" /> ';
}
Пример #9
0
require_once '../config.php';
require_once $CFG->libdir . '/adminlib.php';
admin_externalpage_setup('toinodb');
$confirm = optional_param('confirm', 0, PARAM_BOOL);
require_login();
require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
admin_externalpage_print_header();
echo $OUTPUT->heading('Convert all MySQL tables from MYISAM to InnoDB');
if ($DB->get_dbfamily() != 'mysql') {
    notice('This function is for MySQL databases only!', 'index.php');
}
if (data_submitted() and $confirm and confirm_sesskey()) {
    echo $OUTPUT->notification('Please be patient and wait for this to complete...', 'notifysuccess');
    if ($tables = $DB->get_tables()) {
        $DB->set_debug(true);
        foreach ($tables as $table) {
            $fulltable = $DB->get_prefix() . $table;
            $DB->change_database_structure("ALTER TABLE {$fulltable} TYPE=INNODB");
        }
        $DB->set_debug(false);
    }
    echo $OUTPUT->notification('... done.', 'notifysuccess');
    echo $OUTPUT->continue_button('index.php');
    echo $OUTPUT->footer();
} else {
    $optionsyes = array('confirm' => '1', 'sesskey' => sesskey());
    $formcontinue = html_form::make_button('innodb.php', $optionsyes, get_string('yes'));
    $formcancel = html_form::make_button('index.php', null, get_string('no'), 'get');
    echo $OUTPUT->confirm('Are you sure you want convert all your tables to the InnoDB format?', $formcontinue, $formcancel);
    echo $OUTPUT->footer();
}
Пример #10
0
/**
 * Returns a little popup menu for switching roles
 *
 * @global object
 * @global object
 * @uses CONTEXT_COURSE
 * @param int $courseid The course  to update by id as found in 'course' table
 * @return string
 */
function switchroles_form($courseid)
{
    global $CFG, $USER, $OUTPUT;
    if (!($context = get_context_instance(CONTEXT_COURSE, $courseid))) {
        return '';
    }
    if (!empty($USER->access['rsw'][$context->path])) {
        // Just a button to return to normal
        $options = array();
        $options['id'] = $courseid;
        $options['sesskey'] = sesskey();
        $options['switchrole'] = 0;
        return $OUTPUT->button(html_form::make_button($CFG->wwwroot . '/course/view.php', $options, get_string('switchrolereturn')));
    }
    if (has_capability('moodle/role:switchroles', $context)) {
        if (!($roles = get_switchable_roles($context))) {
            return '';
            // Nothing to show!
        }
        // unset default user role - it would not work
        unset($roles[$CFG->guestroleid]);
        $popupurl = $CFG->wwwroot . '/course/view.php?id=' . $courseid . '&sesskey=' . sesskey();
        $select = html_select::make_popup_form($popupurl, 'switchrole', $roles, 'switchrole', '');
        $select->nothinglabel = get_string('switchroleto');
        $select->set_help_icon('switchrole', get_string('switchroleto'));
        return $OUTPUT->select($select);
    }
    return '';
}
Пример #11
0
if (empty($SESSION->bulk_users)) {
    redirect($return);
}
admin_externalpage_print_header();
//TODO: add support for large number of users
if ($confirm and confirm_sesskey()) {
    $in = implode(',', $SESSION->bulk_users);
    if ($rs = $DB->get_recordset_select('user', "id IN ({$in})", null, '', 'id, username, secret, confirmed, auth, firstname, lastname')) {
        foreach ($rs as $user) {
            if ($user->confirmed) {
                continue;
            }
            $auth = get_auth_plugin($user->auth);
            $result = $auth->user_confirm($user->username, $user->secret);
            if ($result != AUTH_CONFIRM_OK && $result != AUTH_CONFIRM_ALREADY) {
                echo $OUTPUT->notification(get_string('usernotconfirmed', '', fullname($user, true)));
            }
        }
        $rs->close();
    }
    redirect($return, get_string('changessaved'));
} else {
    $in = implode(',', $SESSION->bulk_users);
    $userlist = $DB->get_records_select_menu('user', "id IN ({$in})", null, 'fullname', 'id,' . $DB->sql_fullname() . ' AS fullname');
    $usernames = implode(', ', $userlist);
    echo $OUTPUT->heading(get_string('confirmation', 'admin'));
    $formcontinue = html_form::make_button('user_bulk_confirm.php', array('confirm' => 1), get_string('yes'));
    $formcancel = html_form::make_button('user_bulk.php', $optionsno, get_string('no'), 'get');
    echo $OUTPUT->confirm(get_string('confirmcheckfull', '', $usernames), $formcontinue, $formcancel);
}
echo $OUTPUT->footer();
Пример #12
0
    if (count($table->data)) {
        echo $OUTPUT->table($table);
    } else {
        echo $OUTPUT->notification($strnofields);
    }
}
/// End of $categories foreach
echo '<hr />';
echo '<div class="profileeditor">';
/// Create a new field link
$options = profile_list_datatypes();
$popupurl = $CFG->wwwroot . '/user/profile/index.php?id=0&action=editfield';
echo $OUTPUT->select(html_select::make_popup_form($popupurl, 'datatype', $options, 'newfieldform', $strcreatefield));
/// Create a new category link
$options = array('action' => 'editcategory');
echo $OUTPUT->button(html_form::make_button('index.php', $options, get_string('profilecreatecategory', 'admin')));
echo '</div>';
echo $OUTPUT->footer();
die;
/***** Some functions relevant to this script *****/
/**
 * Create a string containing the editing icons for the user profile categories
 * @param   object   the category object
 * @return  string   the icon string
 */
function profile_category_icons($category)
{
    global $CFG, $USER, $DB, $OUTPUT;
    $strdelete = get_string('delete');
    $strmoveup = get_string('moveup');
    $strmovedown = get_string('movedown');
Пример #13
0
                 $unreadlink = '<span class="unread"><a href="view.php?f=' . $forum->id . '">' . $unread . '</a>';
                 $unreadlink .= '<a title="' . $strmarkallread . '" href="markposts.php?f=' . $forum->id . '&amp;mark=read"><img src="' . $OUTPUT->old_icon_url('t/clear') . '" alt="' . $strmarkallread . '" /></a></span>';
             } else {
                 $unreadlink = '<span class="read">0</span>';
             }
         }
         if ($forum->trackingtype == FORUM_TRACKING_ON) {
             $trackedlink = $stryes;
         } else {
             $options = array('id' => $forum->id);
             if (!isset($untracked[$forum->id])) {
                 $form = html_form::make_button($CFG->wwwroot . '/mod/forum/settracking.php', $options, $stryes);
                 $form->button->title = $strnotrackforum;
                 $trackedlink = $OUTPUT->button($form);
             } else {
                 $form = html_form::make_button($CFG->wwwroot . '/mod/forum/settracking.php', $options, $strno);
                 $form->button->title = $strtrackforum;
                 $trackedlink = $OUTPUT->button($form);
             }
         }
     }
 }
 $forum->intro = shorten_text(format_module_intro('forum', $forum, $cm->id), $CFG->forum_shortpost);
 if ($cm->sectionnum != $currentsection) {
     $printsection = $cm->sectionnum;
     if ($currentsection) {
         $learningtable->data[] = 'hr';
     }
     $currentsection = $cm->sectionnum;
 } else {
     $printsection = '';
            run_tests('filter_get_active_in_context', $contexts, $numcalls, $basetime);
        }
        break;
}
if ($issetup == count($requiredtables)) {
    echo '<p>Total of ' . $DB->count_records('context') . ' contexts, ' . $DB->count_records('filter_active') . ' filter_active and ' . $DB->count_records('filter_config') . ' filter_config rows in the database.</p>';
}
$DB = $realdb;
echo $OUTPUT->container_start();
$form = html_form::make_button($baseurl, array('action' => 'setup'), 'Set up test tables', 'get');
$form->button->disabled = $issetup > 0;
echo $OUTPUT->button($form);
$form = html_form::make_button($baseurl, array('action' => 'teardown'), 'Drop test tables', 'get');
$form->button->disabled = $issetup == 0;
echo $OUTPUT->button($form);
$form = html_form::make_button($baseurl, array('action' => 'test'), 'Run tests', 'get');
$form->button->disabled = $issetup != count($requiredtables);
echo $OUTPUT->button($form);
echo $OUTPUT->container_end();
echo $OUTPUT->footer();
function noop($context)
{
}
function simple_get_record_by_id($context)
{
    global $DB;
    $DB->get_record('context', array('id' => $context->id));
}
function run_tests($function, $contexts, $numcalls, $basetime)
{
    set_time_limit(120);
Пример #15
0
             <?php 
    }
    echo '</table>';
}
?>

        </td></tr>
        <tr>
        <td style="width:100%" colspan="2"  align="center">
            <?php 
$options['id'] = $cm->id;
$options['action'] = "add";
echo "<table border=\"0\"><tr><td align=\"right\">";
echo $OUTPUT->button(html_form::make_button("editcategories.php", $options, get_string("add") . " " . get_string("category", "glossary")));
echo "</td><td align=\"left\">";
unset($options['action']);
$options['mode'] = 'cat';
$options['hook'] = $hook;
echo $OUTPUT->button(html_form::make_button("view.php", $options, get_string("back", "glossary")));
echo "</td></tr>";
echo "</table>";
?>
        </td>
        </tr>
        </table>


</form>

<?php 
echo $OUTPUT->footer();
Пример #16
0
        print_error('invalidcourseid');
    }
    $grouping = new object();
    $grouping->courseid = $course->id;
}
require_login($course);
$context = get_context_instance(CONTEXT_COURSE, $course->id);
require_capability('moodle/course:managegroups', $context);
$returnurl = $CFG->wwwroot . '/group/groupings.php?id=' . $course->id;
if ($id and $delete) {
    if (!$confirm) {
        print_header(get_string('deletegrouping', 'group'), get_string('deletegrouping', 'group'));
        $optionsyes = array('id' => $id, 'delete' => 1, 'courseid' => $courseid, 'sesskey' => sesskey(), 'confirm' => 1);
        $optionsno = array('id' => $courseid);
        $formcontinue = html_form::make_button('grouping.php', $optionsyes, get_string('yes'), 'get');
        $formcancel = html_form::make_button('groupings.php', $optionsno, get_string('no'), 'get');
        echo $OUTPUT->confirm(get_string('deletegroupingconfirm', 'group', $grouping->name), $formcontinue, $formcancel);
        echo $OUTPUT->footer();
        die;
    } else {
        if (confirm_sesskey()) {
            if (groups_delete_grouping($id)) {
                redirect($returnurl);
            } else {
                print_error('erroreditgrouping', 'group', $returnurl);
            }
        }
    }
}
/// First create the form
$editform = new grouping_form();
Пример #17
0
 /**
  * The user submitted credit card form.
  *
  * @param object $form Form parameters
  * @param object $course Course info
  * @return string NULL if ok, error message otherwise.
  * @access private
  */
 private function cc_submit($form, $course)
 {
     global $CFG, $USER, $SESSION, $OUTPUT, $DB;
     prevent_double_paid($course);
     $useripno = getremoteaddr();
     $curcost = get_course_cost($course);
     $exp_date = sprintf("%02d", $form->ccexpiremm) . $form->ccexpireyyyy;
     // NEW CC ORDER
     $timenow = time();
     $order = new stdClass();
     $order->paymentmethod = AN_METHOD_CC;
     $order->refundinfo = substr($form->cc, -4);
     $order->ccname = $form->firstname . " " . $form->lastname;
     $order->courseid = $course->id;
     $order->userid = $USER->id;
     $order->status = AN_STATUS_NONE;
     // it will be changed...
     $order->settletime = 0;
     // cron changes this.
     $order->transid = 0;
     // Transaction Id
     $order->timecreated = $timenow;
     $order->amount = $curcost['cost'];
     $order->currency = $curcost['currency'];
     $order->id = $DB->insert_record("enrol_authorize", $order);
     if (!$order->id) {
         message_to_admin("Error while trying to insert new data", $order);
         return "Insert record error. Admin has been notified!";
     }
     $extra = new stdClass();
     $extra->x_card_num = $form->cc;
     $extra->x_card_code = $form->cvv;
     $extra->x_exp_date = $exp_date;
     $extra->x_currency_code = $curcost['currency'];
     $extra->x_amount = $curcost['cost'];
     $extra->x_first_name = $form->firstname;
     $extra->x_last_name = $form->lastname;
     $extra->x_country = $form->cccountry;
     $extra->x_address = $form->ccaddress;
     $extra->x_state = $form->ccstate;
     $extra->x_city = $form->cccity;
     $extra->x_zip = $form->cczip;
     $extra->x_invoice_num = $order->id;
     $extra->x_description = $course->shortname;
     $extra->x_cust_id = $USER->id;
     $extra->x_email = $USER->email;
     $extra->x_customer_ip = $useripno;
     $extra->x_email_customer = empty($CFG->enrol_mailstudents) ? 'FALSE' : 'TRUE';
     $extra->x_phone = '';
     $extra->x_fax = '';
     if (!empty($CFG->an_authcode) && !empty($form->ccauthcode)) {
         $action = AN_ACTION_CAPTURE_ONLY;
         $extra->x_auth_code = $form->ccauthcode;
     } elseif (!empty($CFG->an_review)) {
         $action = AN_ACTION_AUTH_ONLY;
     } else {
         $action = AN_ACTION_AUTH_CAPTURE;
     }
     $message = '';
     if (AN_APPROVED == AuthorizeNet::process($order, $message, $extra, $action, $form->cctype)) {
         $SESSION->ccpaid = 1;
         // security check: don't duplicate payment
         switch ($action) {
             // review enabled (authorize but capture: draw money but wait for settlement during 30 days)
             // the first step is to inform payment managers and to redirect the user to main page.
             // the next step is to accept/deny payment (AN_ACTION_PRIOR_AUTH_CAPTURE/VOID) within 30 days (payment management or scheduled-capture CRON)
             // unless you accept payment or enable auto-capture cron, the transaction is expired after 30 days and the user cannot enrol to the course during 30 days.
             // see also: admin/cron.php, $this->cron(), $CFG->an_capture_day...
             case AN_ACTION_AUTH_ONLY:
                 $a = new stdClass();
                 $a->url = "{$CFG->wwwroot}/enrol/authorize/index.php?order={$order->id}";
                 $a->orderid = $order->id;
                 $a->transid = $order->transid;
                 $a->amount = "{$order->currency} {$order->amount}";
                 $a->expireon = userdate(AuthorizeNet::getsettletime($timenow + 30 * 3600 * 24));
                 $a->captureon = userdate(AuthorizeNet::getsettletime($timenow + intval($CFG->an_capture_day) * 3600 * 24));
                 $a->course = $course->fullname;
                 $a->user = fullname($USER);
                 $a->acstatus = $CFG->an_capture_day > 0 ? get_string('yes') : get_string('no');
                 $emailmessage = get_string('adminneworder', 'enrol_authorize', $a);
                 $a = new stdClass();
                 $a->course = $course->shortname;
                 $a->orderid = $order->id;
                 $emailsubject = get_string('adminnewordersubject', 'enrol_authorize', $a);
                 $context = get_context_instance(CONTEXT_COURSE, $course->id);
                 if ($paymentmanagers = get_users_by_capability($context, 'enrol/authorize:managepayments')) {
                     foreach ($paymentmanagers as $paymentmanager) {
                         $eventdata = new object();
                         $eventdata->modulename = 'moodle';
                         $eventdata->userfrom = $USER;
                         $eventdata->userto = $paymentmanager;
                         $eventdata->subject = $emailsubject;
                         $eventdata->fullmessage = $emailmessage;
                         $eventdata->fullmessageformat = FORMAT_PLAIN;
                         $eventdata->fullmessagehtml = '';
                         $eventdata->smallmessage = '';
                         events_trigger('message_send', $eventdata);
                     }
                 }
                 redirect($CFG->wwwroot, get_string("reviewnotify", "enrol_authorize"), '30');
                 break;
             case AN_ACTION_CAPTURE_ONLY:
                 // auth code received via phone and the code accepted.
             // auth code received via phone and the code accepted.
             case AN_ACTION_AUTH_CAPTURE:
                 // Credit card captured, ENROL student now...
                 if (enrol_into_course($course, $USER, 'authorize')) {
                     if (!empty($CFG->enrol_mailstudents)) {
                         send_welcome_messages($order->id);
                     }
                     if (!empty($CFG->enrol_mailteachers)) {
                         $context = get_context_instance(CONTEXT_COURSE, $course->id);
                         $paymentmanagers = get_users_by_capability($context, 'enrol/authorize:managepayments', '', '', '0', '1');
                         $paymentmanager = array_shift($paymentmanagers);
                         $a = new stdClass();
                         $a->course = "{$course->fullname}";
                         $a->user = fullname($USER);
                         $eventdata = new object();
                         $eventdata->modulename = 'moodle';
                         $eventdata->userfrom = $USER;
                         $eventdata->userto = $paymentmanager;
                         $eventdata->subject = get_string("enrolmentnew", '', format_string($course->shortname));
                         $eventdata->fullmessage = get_string('enrolmentnewuser', '', $a);
                         $eventdata->fullmessageformat = FORMAT_PLAIN;
                         $eventdata->fullmessagehtml = '';
                         $eventdata->smallmessage = '';
                         events_trigger('message_send', $eventdata);
                     }
                     if (!empty($CFG->enrol_mailadmins)) {
                         $a = new stdClass();
                         $a->course = "{$course->fullname}";
                         $a->user = fullname($USER);
                         $admins = get_admins();
                         foreach ($admins as $admin) {
                             $eventdata = new object();
                             $eventdata->modulename = 'moodle';
                             $eventdata->userfrom = $USER;
                             $eventdata->userto = $admin;
                             $eventdata->subject = get_string("enrolmentnew", '', format_string($course->shortname));
                             $eventdata->fullmessage = get_string('enrolmentnewuser', '', $a);
                             $eventdata->fullmessageformat = FORMAT_PLAIN;
                             $eventdata->fullmessagehtml = '';
                             $eventdata->smallmessage = '';
                             events_trigger('message_send', $eventdata);
                         }
                     }
                 } else {
                     message_to_admin("Error while trying to enrol " . fullname($USER) . " in '{$course->fullname}'", $order);
                 }
                 load_all_capabilities();
                 echo $OUTPUT->box_start('generalbox notice');
                 echo '<p>' . get_string('paymentthanks', 'moodle', $course->fullname) . '</p>';
                 echo $OUTPUT->container_start('buttons');
                 echo $OUTPUT->button(html_form::make_button("{$CFG->wwwroot}/enrol/authorize/index.php", array('order' => $order->id), get_string('payments')));
                 echo $OUTPUT->button(html_form::make_button("{$CFG->wwwroot}/course/view.php", array('id' => $course->id), $course->fullname));
                 echo $OUTPUT->container_end();
                 echo $OUTPUT->box_end();
                 echo $OUTPUT->footer();
                 exit;
                 // break;
         }
         return NULL;
     } else {
         message_to_admin($message, $order);
         return $message;
     }
 }
Пример #18
0
            $select->add_action('change', 'submit_form_by_id', array('id' => 'movecourses'));
            echo $OUTPUT->select($select);
            echo '<input type="hidden" name="id" value="' . $category->id . '" />';
            echo '</td></tr>';
        }
        echo '</table>';
        echo '</div></form>';
        echo '<br />';
    }
}
echo '<div class="buttons">';
if (has_capability('moodle/category:manage', $context) and $numcourses > 1) {
    /// Print button to re-sort courses by name
    unset($options);
    $options['id'] = $category->id;
    $options['resort'] = 'name';
    $options['sesskey'] = sesskey();
    echo $OUTPUT->button(html_form::make_button('category.php', $options, get_string('resortcoursesbyname'), 'get'));
}
if (has_capability('moodle/course:create', $context)) {
    /// Print button to create a new course
    unset($options);
    $options['category'] = $category->id;
    echo $OUTPUT->button(html_form::make_button('edit.php', $options, get_string('addnewcourse'), 'get'));
}
if (!empty($CFG->enablecourserequests) && $category->id == $CFG->enablecourserequests) {
    print_course_request_buttons(get_context_instance(CONTEXT_SYSTEM));
}
echo '</div>';
print_course_search();
echo $OUTPUT->footer();
Пример #19
0
        if (file_exists($theme->dir . '/README.txt')) {
            $readmeurl = $CFG->themewww . '/' . $themename . '/README.txt';
        }
    }
    if ($readmeurl) {
        $link = html_link::make($readmeurl, get_string('info'));
        $link->add_action(new popup_action('click', $link->url, $themename));
        $infoitems['readme'] = $OUTPUT->link($link);
    }
    // Contents of the first screenshot/preview cell.
    if ($screenshotpath) {
        $row[] = '<object type="text/html" data="' . $CFG->themewww . '/' . $screenshotpath . '" height="200" width="400">' . $themename . '</object>';
    } else {
        $row[] = '<object type="text/html" data="preview.php?preview=' . $themename . '" height="200" width="400">' . $themename . '</object>';
    }
    // Contents of the second cell.
    $infocell = $OUTPUT->heading($themename, 3);
    if ($infoitems) {
        $infocell .= "<ul>\n<li>" . implode("</li>\n<li>", $infoitems) . "</li>\n</ul>\n";
    }
    if ($themename != $CFG->theme) {
        $infocell .= $OUTPUT->button(html_form::make_button('index.php', array('choose' => $themename, 'sesskey' => $sesskey), get_string('choose'), 'get'));
    }
    $row[] = $infocell;
    $table->data[$themename] = $row;
    if ($themename == $CFG->theme) {
        $table->rowclasses[$themename] = 'selectedtheme';
    }
}
echo $OUTPUT->table($table);
echo $OUTPUT->footer();
Пример #20
0
$key->courseid = $course->id;
require_login($course);
$context = get_context_instance(CONTEXT_COURSE, $course->id);
require_capability('moodle/grade:export', $context);
// extra security check
if (!empty($key->userid) and $USER->id != $key->userid) {
    print_error('notownerofkey');
}
$returnurl = $CFG->wwwroot . '/grade/export/keymanager.php?id=' . $course->id;
if ($id and $delete) {
    if (!$confirm) {
        print_header(get_string('deleteselectedkey'), get_string('deleteselectedkey'));
        $optionsyes = array('id' => $id, 'delete' => 1, 'courseid' => $courseid, 'sesskey' => sesskey(), 'confirm' => 1);
        $optionsno = array('id' => $courseid);
        $formcontinue = html_form::make_button('key.php', $optionsyes, get_string('yes'), 'get');
        $formcancel = html_form::make_button('keymanager.php', $optionsno, get_string('no'), 'get');
        echo $OUTPUT->confirm(get_string('deletekeyconfirm', 'userkey', $key->value), $formcontinue, $formcancel);
        echo $OUTPUT->footer();
        die;
    } else {
        if (confirm_sesskey()) {
            $DB->delete_records('user_private_key', array('id' => $id));
            redirect('keymanager.php?id=' . $course->id);
        }
    }
}
/// First create the form
$editform = new key_form();
$editform->set_data($key);
if ($editform->is_cancelled()) {
    redirect($returnurl);
Пример #21
0
    foreach ($groupings as $grouping) {
        $line = array();
        $line[0] = format_string($grouping->name);
        if ($groups = groups_get_all_groups($courseid, 0, $grouping->id)) {
            $groupnames = array();
            foreach ($groups as $group) {
                $groupnames[] = format_string($group->name);
            }
            $line[1] = implode(', ', $groupnames);
        } else {
            $line[1] = get_string('none');
        }
        $line[2] = $DB->count_records('course_modules', array('course' => $course->id, 'groupingid' => $grouping->id));
        $buttons = "<a title=\"{$stredit}\" href=\"grouping.php?id={$grouping->id}\"><img" . " src=\"" . $OUTPUT->old_icon_url('t/edit') . "\" class=\"iconsmall\" alt=\"{$stredit}\" /></a> ";
        $buttons .= "<a title=\"{$strdelete}\" href=\"grouping.php?id={$grouping->id}&amp;delete=1\"><img" . " src=\"" . $OUTPUT->old_icon_url('t/delete') . "\" class=\"iconsmall\" alt=\"{$strdelete}\" /></a> ";
        $buttons .= "<a title=\"{$strmanagegrping}\" href=\"assign.php?id={$grouping->id}\"><img" . " src=\"" . $OUTPUT->old_icon_url('i/group') . "\" class=\"icon\" alt=\"{$strmanagegrping}\" /></a> ";
        $line[3] = $buttons;
        $data[] = $line;
    }
}
$table = new html_table();
$table->head = array($strgrouping, $strgroups, $struses, $stredit);
$table->size = array('30%', '50%', '10%', '10%');
$table->align = array('left', 'left', 'center', 'center');
$table->width = '90%';
$table->data = $data;
echo $OUTPUT->table($table);
echo $OUTPUT->container_start('buttons');
echo $OUTPUT->button(html_form::make_button('grouping.php', array('courseid' => $courseid), $srtnewgrouping));
echo $OUTPUT->container_end();
echo $OUTPUT->footer();
Пример #22
0
                <tr>
                    <td align="left" colspan="2">
                        <?php 
        print_string('anonymous_entries', 'feedback');
        ?>
&nbsp;(<?php 
        echo $DB->count_records('feedback_completed', array('feedback' => $feedback->id, 'anonymous_response' => FEEDBACK_ANONYMOUS_YES));
        ?>
)
                    </td>
                    <td align="right">
                        <?php 
        $show_anon_button_link = 'show_entries_anonym.php';
        $show_anon_button_options = array('sesskey' => sesskey(), 'userid' => 0, 'do_show' => 'showoneentry', 'id' => $id);
        $show_anon_button_label = get_string('show_entries', 'feedback');
        echo $OUTPUT->button(html_form::make_button($show_anon_button_link, $show_anon_button_options, $show_anon_button_label));
        ?>
                    </td>
                </tr>
            </table>
    <?php 
        echo '</td></tr></table></div>';
        echo $OUTPUT->box_end();
    }
}
////////////////////////////////////////////////////////
/// Print the responses of the given user
////////////////////////////////////////////////////////
if ($do_show == 'showoneentry') {
    echo $OUTPUT->heading(format_text($feedback->name));
    //print the items
Пример #23
0
/**
 * Print header for admin page
 *
 * @param string $focus focus element
 */
function admin_externalpage_print_header($focus = '')
{
    global $CFG, $PAGE, $SITE, $THEME, $OUTPUT;
    if (!is_string($focus)) {
        $focus = '';
        // BC compatibility, there used to be adminroot parameter
    }
    if (empty($SITE->fullname) || empty($SITE->shortname)) {
        // During initial install.
        $strinstallation = get_string('installation', 'install');
        $strsettings = get_string('settings');
        $navigation = build_navigation(array(array('name' => $strsettings, 'link' => null, 'type' => 'misc')));
        print_header($strinstallation, $strinstallation, $navigation, "", "", false, "&nbsp;", "&nbsp;");
        return;
    }
    // Normal case.
    $adminroot = admin_get_root(false, false);
    //settings not required - only pages
    // fetch the path parameter
    $section = $PAGE->url->param('section');
    $current = $adminroot->locate($section, true);
    $visiblepathtosection = array_reverse($current->visiblepath);
    if ($PAGE->user_allowed_editing()) {
        $options = $PAGE->url->params();
        if ($PAGE->user_is_editing()) {
            $caption = get_string('blockseditoff');
            $options['adminedit'] = 'off';
        } else {
            $caption = get_string('blocksediton');
            $options['adminedit'] = 'on';
        }
        $buttons = $OUTPUT->button(html_form::make_button($PAGE->url->out(false), $options, $caption, 'get'));
    }
    $navlinks = array();
    foreach ($visiblepathtosection as $element) {
        $navlinks[] = array('name' => $element, 'link' => null, 'type' => 'misc');
    }
    $navigation = build_navigation($navlinks);
    print_header("{$SITE->shortname}: " . implode(": ", $visiblepathtosection), $SITE->fullname, $navigation, $focus, '', true, $buttons, '');
}
Пример #24
0
 // headers.  If not, processing stops.
 if (count($csv_data) != count($file_headers)) {
     echo $OUTPUT->box_start('generalbox importoutcomenofile');
     echo get_string('importoutcomenofile', 'grades', $line);
     echo $OUTPUT->button(html_form::make_button($CFG->wwwroot . '/grade/edit/outcome/index.php', array('id' => $courseid), get_string('back'), 'get'));
     echo $OUTPUT->box_end();
     $fatal_error = true;
     //echo $OUTPUT->box(var_export($csv_data, true) ."<br />". var_export($header, true));
     break;
 }
 // sanity check #3: all required fields must be present on the current line.
 foreach ($headers as $header => $position) {
     if ($csv_data[$imported_headers[$header]] == '') {
         echo $OUTPUT->box_start('generalbox importoutcomenofile');
         echo get_string('importoutcomenofile', 'grades', $line);
         echo $OUTPUT->button(html_form::make_button($CFG->wwwroot . '/grade/edit/outcome/index.php', array('id' => $courseid), get_string('back'), 'get'));
         echo $OUTPUT->box_end();
         $fatal_error = true;
         break;
     }
 }
 //var_dump($csv_data);
 // MDL-17273 errors in csv are not preventing import from happening. We break from the while loop here
 if ($fatal_error) {
     break;
 }
 $params = array($csv_data[$imported_headers['outcome_shortname']]);
 $wheresql = 'shortname = ? ';
 if ($local_scope) {
     $params[] = $courseid;
     $wheresql .= ' AND courseid = ?';
Пример #25
0
 $context = get_context_instance(CONTEXT_COURSE, $course->id);
 $modcontext = get_context_instance(CONTEXT_MODULE, $cm->id);
 require_capability('moodle/course:manageactivities', $context);
 $return = "{$CFG->wwwroot}/course/view.php?id={$cm->course}#section-{$cm->sectionnum}";
 if (!$confirm or !confirm_sesskey()) {
     $fullmodulename = get_string('modulename', $cm->modname);
     $optionsyes = array('confirm' => 1, 'delete' => $cm->id, 'sesskey' => sesskey());
     $optionsno = array('id' => $cm->course);
     $strdeletecheck = get_string('deletecheck', '', $fullmodulename);
     $strdeletecheckfull = get_string('deletecheckfull', '', "{$fullmodulename} '{$cm->name}'");
     $PAGE->set_pagetype('mod-' . $cm->modname . '-delete');
     print_header_simple($strdeletecheck, '', build_navigation(array(array('name' => $strdeletecheck, 'link' => '', 'type' => 'misc'))));
     // print_simple_box_start('center', '60%', '#FFAAAA', 20, 'noticebox');
     echo $OUTPUT->box_start('noticebox');
     $formcontinue = html_form::make_button('mod.php', $optionsyes, get_string('yes'));
     $formcancel = html_form::make_button($return, $optionsno, get_string('no'), 'get');
     echo $OUTPUT->confirm($strdeletecheckfull, $formcontinue, $formcancel);
     echo $OUTPUT->box_end();
     echo $OUTPUT->footer();
     exit;
 }
 $modlib = "{$CFG->dirroot}/mod/{$cm->modname}/lib.php";
 if (file_exists($modlib)) {
     require_once $modlib;
 } else {
     print_error('modulemissingcode', '', '', $modlib);
 }
 $deleteinstancefunction = $cm->modname . "_delete_instance";
 if (!$deleteinstancefunction($cm->instance)) {
     echo $OUTPUT->notification("Could not delete the {$cm->modname} (instance)");
 }
Пример #26
0
function hotpot_print_review_buttons(&$course, &$hotpot, &$attempt, $context)
{
    global $DB, $OUTPUT;
    print "\n" . '<table border="0" align="center" cellpadding="2" cellspacing="2" class="generaltable">';
    print "\n<tr>\n" . '<td align="center">';
    echo $OUTPUT->button(html_form::make_button("report.php?hp={$hotpot->id}", NULL, get_string('continue')));
    if (has_capability('mod/hotpot:viewreport', $context) && $DB->record_exists('hotpot_details', array('attempt' => $attempt->id))) {
        print "</td>\n" . '<td align="center">';
        echo $OUTPUT->button(html_form::make_button("review.php?hp={$hotpot->id}&attempt={$attempt->id}&action=showxmlsource", NULL, get_string('showxmlsource', 'hotpot')));
        print "</td>\n" . '<td align="center">';
        echo $OUTPUT->button(html_form::make_button("review.php?hp={$hotpot->id}&attempt={$attempt->id}&action=showxmltree", NULL, get_string('showxmltree', 'hotpot')));
        $colspan = 3;
    } else {
        $colspan = 1;
    }
    print "</td>\n</tr>\n";
    print '<tr><td colspan="' . $colspan . '">';
    $spacer = new html_image();
    $spacer->height = 4;
    $spacer->width = 1;
    echo $OUTPUT->spacer($spacer);
    print "</td></tr>\n";
    print "</table>\n";
}
Пример #27
0
require_login($course);
$context = get_context_instance(CONTEXT_COURSE, $id);
require_capability('moodle/grade:import', $context);
print_grade_page_head($course->id, 'import', 'keymanager', get_string('keymanager', 'grades'));
$stredit = get_string('edit');
$strdelete = get_string('delete');
$data = array();
$params = array($course->id, $USER->id);
if ($keys = $DB->get_records_select('user_private_key', "script='grade/import' AND instance=? AND userid=?", $params)) {
    foreach ($keys as $key) {
        $line = array();
        $line[0] = format_string($key->value);
        $line[1] = $key->iprestriction;
        $line[2] = empty($key->validuntil) ? get_string('always') : userdate($key->validuntil);
        $buttons = "<a title=\"{$stredit}\" href=\"key.php?id={$key->id}\"><img" . " src=\"" . $OUTPUT->old_icon_url('t/edit') . "\" class=\"iconsmall\" alt=\"{$stredit}\" /></a> ";
        $buttons .= "<a title=\"{$strdelete}\" href=\"key.php?id={$key->id}&amp;delete=1\"><img" . " src=\"" . $OUTPUT->old_icon_url('t/delete') . "\" class=\"iconsmall\" alt=\"{$strdelete}\" /></a> ";
        $line[3] = $buttons;
        $data[] = $line;
    }
}
$table = new html_table();
$table->head = array(get_string('keyvalue', 'userkey'), get_string('keyiprestriction', 'userkey'), get_string('keyvaliduntil', 'userkey'), $stredit);
$table->size = array('50%', '30%', '10%', '10%');
$table->align = array('left', 'left', 'left', 'center');
$table->width = '90%';
$table->data = $data;
echo $OUTPUT->table($table);
echo $OUTPUT->container_start('buttons');
echo $OUTPUT->button(html_form::make_button('key.php', array('courseid' => $course->id), get_string('newuserkey', 'userkey')));
echo $OUTPUT->container_end();
echo $OUTPUT->footer();
Пример #28
0
function message_print_search_results($frm)
{
    global $USER, $CFG, $DB, $OUTPUT;
    echo '<div class="mdl-align">';
    /// search for person
    if (!empty($frm->personsubmit) and !empty($frm->name)) {
        if (optional_param('mycourses', 0, PARAM_BOOL)) {
            $users = array();
            $mycourses = get_my_courses($USER->id);
            foreach ($mycourses as $mycourse) {
                if (is_array($susers = message_search_users($mycourse->id, $frm->name))) {
                    foreach ($susers as $suser) {
                        $users[$suser->id] = $suser;
                    }
                }
            }
        } else {
            $users = message_search_users(SITEID, $frm->name);
        }
        if (!empty($users)) {
            echo '<strong>' . get_string('userssearchresults', 'message', count($users)) . '</strong>';
            echo '<table class="message_users">';
            foreach ($users as $user) {
                if ($user->contactlistid) {
                    if ($user->blocked == 0) {
                        /// not blocked
                        $strcontact = message_contact_link($user->id, 'remove', true);
                        $strblock = message_contact_link($user->id, 'block', true);
                    } else {
                        // blocked
                        $strcontact = message_contact_link($user->id, 'add', true);
                        $strblock = message_contact_link($user->id, 'unblock', true);
                    }
                } else {
                    $strcontact = message_contact_link($user->id, 'add', true);
                    $strblock = message_contact_link($user->id, 'block', true);
                }
                $strhistory = message_history_link($user->id, 0, true, '', '', 'icon');
                echo '<tr><td class="pix">';
                $userpic = moodle_user_picture::make($user, SITEID);
                $userpic->size = 20;
                $userpic->link = true;
                echo $OUTPUT->user_picture($userpic);
                echo '</td>';
                echo '<td class="contact">';
                $popupoptions = array('height' => 500, 'width' => 500, 'menubar' => false, 'location' => false, 'status' => true, 'scrollbars' => true, 'resizable' => true);
                $link = html_link::make("/message/discussion.php?id={$user->id}", fullname($user));
                $link->add_action(new popup_action('click', $link->url, "message_{$user->id}", $popupoptions));
                $link->title = get_string('sendmessageto', 'message', fullname($user));
                echo $OUTPUT->link($link);
                echo '</td>';
                echo '<td class="link">' . $strcontact . '</td>';
                echo '<td class="link">' . $strblock . '</td>';
                echo '<td class="link">' . $strhistory . '</td>';
                echo '</tr>';
            }
            echo '</table>';
        } else {
            echo $OUTPUT->notification(get_string('nosearchresults', 'message'));
        }
        /// search messages for keywords
    } else {
        if (!empty($frm->keywordssubmit)) {
            $keywordstring = clean_text(trim($frm->keywords));
            if ($keywordstring) {
                $keywords = explode(' ', $keywordstring);
            } else {
                $keywords = array();
            }
            $tome = false;
            $fromme = false;
            $courseid = 'none';
            switch ($frm->keywordsoption) {
                case 'tome':
                    $tome = true;
                    break;
                case 'fromme':
                    $fromme = true;
                    break;
                case 'allmine':
                    $tome = true;
                    $fromme = true;
                    break;
                case 'allusers':
                    $courseid = SITEID;
                    break;
                case 'courseusers':
                    $courseid = $frm->courseid;
                    break;
                default:
                    $tome = true;
                    $fromme = true;
            }
            if (($messages = message_search($keywords, $fromme, $tome, $courseid)) !== false) {
                /// get a list of contacts
                if (($contacts = $DB->get_records('message_contacts', array('userid' => $USER->id), '', 'contactid, blocked')) === false) {
                    $contacts = array();
                }
                /// print heading with number of results
                echo '<p class="heading">' . get_string('keywordssearchresults', 'message', count($messages)) . ' ("' . s($keywordstring) . '")</p>';
                /// print table headings
                echo '<table class="searchresults" cellspacing="0">';
                echo '<tr>';
                echo '<td><strong>' . get_string('from') . '</strong></td>';
                echo '<td><strong>' . get_string('to') . '</strong></td>';
                echo '<td><strong>' . get_string('message', 'message') . '</strong></td>';
                echo '<td><strong>' . get_string('timesent', 'message') . '</strong></td>';
                echo "</tr>\n";
                $blockedcount = 0;
                $dateformat = get_string('strftimedatetimeshort');
                $strcontext = get_string('context', 'message');
                foreach ($messages as $message) {
                    /// ignore messages to and from blocked users unless $frm->includeblocked is set
                    if (!optional_param('includeblocked', 0, PARAM_BOOL) and (isset($contacts[$message->useridfrom]) and $contacts[$message->useridfrom]->blocked == 1 or isset($contacts[$message->useridto]) and $contacts[$message->useridto]->blocked == 1)) {
                        $blockedcount++;
                        continue;
                    }
                    /// load up user to record
                    if ($message->useridto !== $USER->id) {
                        $userto = $DB->get_record('user', array('id' => $message->useridto));
                        $tocontact = (array_key_exists($message->useridto, $contacts) and $contacts[$message->useridto]->blocked == 0);
                        $toblocked = (array_key_exists($message->useridto, $contacts) and $contacts[$message->useridto]->blocked == 1);
                    } else {
                        $userto = false;
                        $tocontact = false;
                        $toblocked = false;
                    }
                    /// load up user from record
                    if ($message->useridfrom !== $USER->id) {
                        $userfrom = $DB->get_record('user', array('id' => $message->useridfrom));
                        $fromcontact = (array_key_exists($message->useridfrom, $contacts) and $contacts[$message->useridfrom]->blocked == 0);
                        $fromblocked = (array_key_exists($message->useridfrom, $contacts) and $contacts[$message->useridfrom]->blocked == 1);
                    } else {
                        $userfrom = false;
                        $fromcontact = false;
                        $fromblocked = false;
                    }
                    /// find date string for this message
                    $date = usergetdate($message->timecreated);
                    $datestring = $date['year'] . $date['mon'] . $date['mday'];
                    /// print out message row
                    echo '<tr valign="top">';
                    echo '<td class="contact">';
                    message_print_user($userfrom, $fromcontact, $fromblocked);
                    echo '</td>';
                    echo '<td class="contact">';
                    message_print_user($userto, $tocontact, $toblocked);
                    echo '</td>';
                    echo '<td class="summary">' . message_get_fragment($message->fullmessage, $keywords);
                    echo '<br /><div class="link">';
                    message_history_link($message->useridto, $message->useridfrom, false, $keywordstring, 'm' . $message->id, $strcontext);
                    echo '</div>';
                    echo '</td>';
                    echo '<td class="date">' . userdate($message->timecreated, $dateformat) . '</td>';
                    echo "</tr>\n";
                }
                if ($blockedcount > 0) {
                    echo '<tr><td colspan="4" align="center">' . get_string('blockedmessages', 'message', $blockedcount) . '</td></tr>';
                }
                echo '</table>';
            } else {
                echo $OUTPUT->notification(get_string('nosearchresults', 'message'));
            }
            /// what the ????, probably an empty search string, duh!
        } else {
            echo $OUTPUT->notification(get_string('emptysearchstring', 'message'));
        }
    }
    echo '<br />';
    echo $OUTPUT->button(html_form::make_button('index.php', array('tab' => 'search'), get_string('newsearch', 'message')));
    echo '</div>';
}
Пример #29
0
?>
                          <input type="submit" name="save" value="<?php 
print_string('importfromthisfile', 'feedback');
?>
" />
                    </td>
                </tr>
          </table>
          <?php 
echo $OUTPUT->box_end();
?>
     </form>

     <?php 
echo $OUTPUT->container_start('mdl-align');
echo $OUTPUT->button(html_form::make_button('edit.php', array('id' => $id, 'do_show' => 'templates'), get_string('cancel')));
echo $OUTPUT->container_end();
echo $OUTPUT->footer();
function feedback_load_xml_data($filename)
{
    global $CFG;
    require_once $CFG->dirroot . '/lib/xmlize.php';
    $datei = file_get_contents($filename);
    if (!($datei = feedback_check_xml_utf8($datei))) {
        return false;
    }
    $data = xmlize($datei, 1, 'UTF-8');
    if (intval($data['FEEDBACK']['@']['VERSION']) != 200701) {
        return false;
    }
    $data = $data['FEEDBACK']['#']['ITEMS'][0]['#']['ITEM'];
Пример #30
0
 function view()
 {
     global $USER, $OUTPUT;
     $edit = optional_param('edit', 0, PARAM_BOOL);
     $saved = optional_param('saved', 0, PARAM_BOOL);
     $context = get_context_instance(CONTEXT_MODULE, $this->cm->id);
     require_capability('mod/assignment:view', $context);
     $submission = $this->get_submission();
     //Guest can not submit nor edit an assignment (bug: 4604)
     if (!has_capability('mod/assignment:submit', $context)) {
         $editable = null;
     } else {
         $editable = $this->isopen() && (!$submission || $this->assignment->resubmit || !$submission->timemarked);
     }
     $editmode = ($editable and $edit);
     if ($editmode) {
         //guest can not edit or submit assignment
         if (!has_capability('mod/assignment:submit', $context)) {
             print_error('guestnosubmit', 'assignment');
         }
     }
     add_to_log($this->course->id, "assignment", "view", "view.php?id={$this->cm->id}", $this->assignment->id, $this->cm->id);
     /// prepare form and process submitted data
     $mform = new mod_assignment_online_edit_form();
     $defaults = new object();
     $defaults->id = $this->cm->id;
     if (!empty($submission)) {
         if ($this->usehtmleditor) {
             $options = new object();
             $options->smiley = false;
             $options->filter = false;
             $defaults->text = format_text($submission->data1, $submission->data2, $options);
             $defaults->format = FORMAT_HTML;
         } else {
             $defaults->text = $submission->data1;
             $defaults->format = $submission->data2;
         }
     }
     $mform->set_data($defaults);
     if ($mform->is_cancelled()) {
         redirect('view.php?id=' . $this->cm->id);
     }
     if ($data = $mform->get_data()) {
         // No incoming data?
         if ($editable && $this->update_submission($data)) {
             //TODO fix log actions - needs db upgrade
             $submission = $this->get_submission();
             add_to_log($this->course->id, 'assignment', 'upload', 'view.php?a=' . $this->assignment->id, $this->assignment->id, $this->cm->id);
             $this->email_teachers($submission);
             //redirect to get updated submission date and word count
             redirect('view.php?id=' . $this->cm->id . '&saved=1');
         } else {
             // TODO: add better error message
             echo $OUTPUT->notification(get_string("error"));
             //submitting not allowed!
         }
     }
     /// print header, etc. and display form if needed
     if ($editmode) {
         $this->view_header(get_string('editmysubmission', 'assignment'));
     } else {
         $this->view_header();
     }
     $this->view_intro();
     $this->view_dates();
     if ($saved) {
         echo $OUTPUT->notification(get_string('submissionsaved', 'assignment'), 'notifysuccess');
     }
     if (has_capability('mod/assignment:submit', $context)) {
         if ($editmode) {
             echo $OUTPUT->box_start('generalbox', 'online');
             $mform->display();
         } else {
             echo $OUTPUT->box_start('generalbox boxwidthwide boxaligncenter', 'online');
             if ($submission && has_capability('mod/assignment:exportownsubmission', $this->context)) {
                 echo format_text($submission->data1, $submission->data2);
                 $button = new portfolio_add_button();
                 $button->set_callback_options('assignment_portfolio_caller', array('id' => $this->cm->id), '/mod/assignment/lib.php');
                 $button->render();
             } else {
                 if (!has_capability('mod/assignment:submit', $context)) {
                     //fix for #4604
                     echo '<div style="text-align:center">' . get_string('guestnosubmit', 'assignment') . '</div>';
                 } else {
                     if ($this->isopen()) {
                         //fix for #4206
                         echo '<div style="text-align:center">' . get_string('emptysubmission', 'assignment') . '</div>';
                     }
                 }
             }
         }
         echo $OUTPUT->box_end();
         if (!$editmode && $editable) {
             echo "<div style='text-align:center'>";
             echo $OUTPUT->button(html_form::make_button('view.php', array('id' => $this->cm->id, 'edit' => '1'), get_string('editmysubmission', 'assignment')));
             echo "</div>";
         }
     }
     $this->view_feedback();
     $this->view_footer();
 }