本文整理匯總了PHP中print_progress函數的典型用法代碼示例。如果您正苦於以下問題:PHP print_progress函數的具體用法?PHP print_progress怎麽用?PHP print_progress使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了print_progress函數的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: unset
return;
}
$file = '../include/config.inc.php';
unset($errors);
unset($progress);
if (file_exists($file)) {
@chmod($file, 0666);
if (!is_writeable($file)) {
$errors[] = '<strong>' . $file . '</strong> is not writeable. Use <kbd>chmod a+rw ' . $file . '</kbd> to change permissions.';
} else {
$progress[] = '<strong>' . $file . '</strong> is writeable.';
}
} else {
$errors[] = '<strong>' . $file . '</strong> does not exist.';
}
print_progress($step);
echo '<form action="' . $_SERVER['PHP_SELF'] . '" method="post" name="form">';
if (isset($errors)) {
if (isset($progress)) {
print_feedback($progress);
}
print_errors($errors);
echo '<input type="hidden" name="step" value="' . $step . '" />';
unset($_POST['step']);
unset($_POST['action']);
unset($errors);
print_hidden($step);
echo '<p><strong>Note:</strong> To change permissions on Unix use <kbd>chmod a+rw</kbd> then the file name.</p>';
echo '<p align="center"><input type="submit" class="button" value=" Try Again " name="retry" />';
} else {
if (!copy('../../' . $_POST['step1']['old_path'] . '/include/config.inc.php', '../include/config.inc.php')) {
示例2: print_progress
$dcount++;
print_progress($dcount, $dtotal);
if ($discussion->course != $currcourse) {
/// Discussions are ordered by course, so we only need to get any course's users once.
$currcourse = $discussion->course;
$users = get_course_users($currcourse, '', '', 'u.id,u.confirmed');
}
/// If this course has users, and posts more than a day old, mark them for each user.
if ($users && ($posts = get_records_select('forum_posts', 'discussion = ' . $discussion->id . ' AND ' . $dateafter . ' < modified AND modified < ' . $onedayago, '', 'id,discussion,modified'))) {
foreach ($users as $user) {
/// If its a group discussion, make sure the user is in the group.
if ($discussion->groupid) {
if (!isset($groups[$discussion->groupid][$user->id])) {
$groups[$discussion->groupid][$user->id] = ismember($discussion->groupid, $user->id);
}
}
if (!$discussion->groupid || !empty($groups[$discussion->groupid][$user->id])) {
foreach ($posts as $post) {
print_progress($dcount, $dtotal);
forum_tp_mark_post_read($user->id, $post, $discussion->forum);
}
}
}
}
}
print_progress($dcount, $dtotal, 0);
}
delete_records('config', 'name', 'upgrade', 'value', 'forumread');
notify('Log upgrading was successful!', 'notifysuccess');
print_continue('index.php');
admin_externalpage_print_footer($adminroot);
示例3: moodle_install_roles
/**
* Installs the roles system.
* This function runs on a fresh install as well as on an upgrade from the old
* hard-coded student/teacher/admin etc. roles to the new roles system.
*/
function moodle_install_roles()
{
global $CFG, $db;
/// Create a system wide context for assignemnt.
$systemcontext = $context = get_context_instance(CONTEXT_SYSTEM);
/// Create default/legacy roles and capabilities.
/// (1 legacy capability per legacy role at system level).
$adminrole = create_role(addslashes(get_string('administrator')), 'admin', addslashes(get_string('administratordescription')), 'moodle/legacy:admin');
$coursecreatorrole = create_role(addslashes(get_string('coursecreators')), 'coursecreator', addslashes(get_string('coursecreatorsdescription')), 'moodle/legacy:coursecreator');
$editteacherrole = create_role(addslashes(get_string('defaultcourseteacher')), 'editingteacher', addslashes(get_string('defaultcourseteacherdescription')), 'moodle/legacy:editingteacher');
$noneditteacherrole = create_role(addslashes(get_string('noneditingteacher')), 'teacher', addslashes(get_string('noneditingteacherdescription')), 'moodle/legacy:teacher');
$studentrole = create_role(addslashes(get_string('defaultcoursestudent')), 'student', addslashes(get_string('defaultcoursestudentdescription')), 'moodle/legacy:student');
$guestrole = create_role(addslashes(get_string('guest')), 'guest', addslashes(get_string('guestdescription')), 'moodle/legacy:guest');
$userrole = create_role(addslashes(get_string('authenticateduser')), 'user', addslashes(get_string('authenticateduserdescription')), 'moodle/legacy:user');
/// Now is the correct moment to install capabilities - after creation of legacy roles, but before assigning of roles
if (!assign_capability('moodle/site:doanything', CAP_ALLOW, $adminrole, $systemcontext->id)) {
error('Could not assign moodle/site:doanything to the admin role');
}
if (!update_capabilities()) {
error('Had trouble upgrading the core capabilities for the Roles System');
}
/// Look inside user_admin, user_creator, user_teachers, user_students and
/// assign above new roles. If a user has both teacher and student role,
/// only teacher role is assigned. The assignment should be system level.
$dbtables = $db->MetaTables('TABLES');
/// Set up the progress bar
$usertables = array('user_admins', 'user_coursecreators', 'user_teachers', 'user_students');
$totalcount = $progresscount = 0;
foreach ($usertables as $usertable) {
if (in_array($CFG->prefix . $usertable, $dbtables)) {
$totalcount += count_records($usertable);
}
}
print_progress(0, $totalcount, 5, 1, 'Processing role assignments');
/// Upgrade the admins.
/// Sort using id ASC, first one is primary admin.
if (in_array($CFG->prefix . 'user_admins', $dbtables)) {
if ($rs = get_recordset_sql('SELECT * from ' . $CFG->prefix . 'user_admins ORDER BY ID ASC')) {
while ($admin = rs_fetch_next_record($rs)) {
role_assign($adminrole, $admin->userid, 0, $systemcontext->id);
$progresscount++;
print_progress($progresscount, $totalcount, 5, 1, 'Processing role assignments');
}
rs_close($rs);
}
} else {
// This is a fresh install.
}
/// Upgrade course creators.
if (in_array($CFG->prefix . 'user_coursecreators', $dbtables)) {
if ($rs = get_recordset('user_coursecreators')) {
while ($coursecreator = rs_fetch_next_record($rs)) {
role_assign($coursecreatorrole, $coursecreator->userid, 0, $systemcontext->id);
$progresscount++;
print_progress($progresscount, $totalcount, 5, 1, 'Processing role assignments');
}
rs_close($rs);
}
}
/// Upgrade editting teachers and non-editting teachers.
if (in_array($CFG->prefix . 'user_teachers', $dbtables)) {
if ($rs = get_recordset('user_teachers')) {
while ($teacher = rs_fetch_next_record($rs)) {
// removed code here to ignore site level assignments
// since the contexts are separated now
// populate the user_lastaccess table
$access = new object();
$access->timeaccess = $teacher->timeaccess;
$access->userid = $teacher->userid;
$access->courseid = $teacher->course;
insert_record('user_lastaccess', $access);
// assign the default student role
$coursecontext = get_context_instance(CONTEXT_COURSE, $teacher->course);
// needs cache
// hidden teacher
if ($teacher->authority == 0) {
$hiddenteacher = 1;
} else {
$hiddenteacher = 0;
}
if ($teacher->editall) {
// editting teacher
role_assign($editteacherrole, $teacher->userid, 0, $coursecontext->id, $teacher->timestart, $teacher->timeend, $hiddenteacher, $teacher->enrol, $teacher->timemodified);
} else {
role_assign($noneditteacherrole, $teacher->userid, 0, $coursecontext->id, $teacher->timestart, $teacher->timeend, $hiddenteacher, $teacher->enrol, $teacher->timemodified);
}
$progresscount++;
print_progress($progresscount, $totalcount, 5, 1, 'Processing role assignments');
}
rs_close($rs);
}
}
/// Upgrade students.
if (in_array($CFG->prefix . 'user_students', $dbtables)) {
if ($rs = get_recordset('user_students')) {
//.........這裏部分代碼省略.........
示例4: build_context_rel
/**
* rebuild context_rel table without deleting
*/
function build_context_rel()
{
global $db;
$savedb = $db->debug;
// total number of records
$total = count_records('context');
// processed records
$done = 0;
print_progress($done, $total, 10, 0, 'Processing context relations');
$db->debug = false;
if ($contexts = get_records('context')) {
foreach ($contexts as $context) {
// no need to delete because it's all empty
insert_context_rel($context, false, false);
$db->debug = true;
print_progress(++$done, $total, 10, 0, 'Processing context relations');
$db->debug = false;
}
}
$db->debug = $savedb;
}