function serverCopySite($orig, $dest) { $sections = decode_array(db_get_value("sites", "sections", "name='{$orig}'")); $nsections = array(); foreach ($sections as $s) { $sa = db_get_line("sections", "id={$s}"); $squery = "insert into sections set addedby='" . addslashes($_SESSION['auser']) . "', addedtimestamp=NOW()"; $squery .= ",title='{$sa['title']}', active={$sa['active']}, type='{$sa['type']}', url='{$sa['url']}'"; $pages = decode_array($sa[pages]); $npages = array(); foreach ($pages as $p) { $pa = db_get_line("pages", "id={$p}"); $pquery = "insert into pages set addedby='" . addslashes($_SESSION['auser']) . "', addedtimestamp=NOW()"; $pquery .= ",ediscussion=1,archiveby='{$pa['archiveby']}',url='{$pa['url']}',type='{$pa['type']}',title='{$pa['title']}', showcreator={$pa['showcreator']}, showdate={$pa['showdate']}, locked={$pa['locked']}, active={$pa['active']}"; $stories = decode_array($pa[stories]); $nstories = array(); foreach ($stories as $st) { $sta = db_get_line("stories", "id={$st}"); $stquery = "insert into stories set addedby='" . addslashes($_SESSION['auser']) . "', addedtimestamp=NOW()"; $stquery .= ",type='{$sta['type']}',texttype='{$sta['texttype']}',category='{$sta['category']}',title='{$sta['title']}', discuss={$sta['discuss']}, discusspermissions='{$sta['discusspermissions']}', shorttext='{$sta['shorttext']}', longertext='{$sta['longertext']}', locked={$sta['locked']}, url='{$sa['url']}'"; db_query($stquery); // print "$stquery<br />"; $nstories[] = lastid(); } $stories = encode_array($nstories); $pquery .= ",stories='{$stories}'"; db_query($pquery); $npages[] = lastid(); // print "$pquery<br />"; } $pages = encode_array($npages); $squery .= ",pages='{$pages}'"; db_query($squery); $nsections[] = lastid(); // print "$squery<br />"; } $sections = encode_array($nsections); $query = "update sites set sections='{$sections}' where name='{$dest}'"; db_query($query); // print "$query<br />"; }
function print_options() { global $COURSE; $course_format = $COURSE->format; $move_to_section_string = ''; $move_to_section_string .= "<tr><td/><td colspan = 2><select name='section' onChange='this.form.submit()' format =\"{$course_format}\">\n"; $move_to_section_string .= "<option value=\"-1\">" . get_string('movetosection', 'block_massaction') . "</option>\n"; $select_section_string = "<tr><td/><td colspan = 2><select name='sel_section' onChange=\"select_section(this.options[this.selectedIndex].value)\">"; $select_section_string .= "<option value=\"-1\">" . get_string('selectsection', 'block_massaction') . "</option>\n"; $num_sections = get_field('course', 'numsections', 'id', $COURSE->id); $sections = get_records_select('course_sections', "course = {$COURSE->id} AND section <= {$num_sections}"); $weekdate = $COURSE->startdate; $weekdate += 7200; // Add two hours to avoid possible DST problems $weekofseconds = 604800; $monthft = "%B"; $dayft = "%d"; $print_counter = 0; foreach ($sections as $id => $record) { if ($course_format == 'weeks') { if ($record->section == 0) { $print_value = get_string('weekzero', 'block_massaction'); } else { $weekday = substr(userdate($weekdate, $monthft), 0, 3) . " " . userdate($weekdate, $dayft); $nextweekdate = $weekdate + $weekofseconds; $nextweekday = substr(userdate($nextweekdate, $monthft), 0, 3) . " " . userdate($nextweekdate, $dayft); $print_value = get_string('week', 'block_massaction') . " " . $record->section; $print_value .= ": {$weekday} - {$nextweekday}"; $weekdate = $nextweekdate; } } else { $print_value = get_string('topic', 'block_massaction') . " {$record->section}"; $print_counter++; } $value = array('id' => $record->id, 'name' => $print_value); $encoded_val = encode_array($value); $select_section_string .= "<option value=\"{$record->section}\">" . $print_value . "</option>\n"; $move_to_section_string .= "<option value=\"" . $encoded_val . "\">" . $print_value . "</option>\n"; } $select_section_string .= "</select></td></tr>"; $move_to_section_string .= "</select></td></tr>"; return array('select' => $select_section_string, 'move' => $move_to_section_string); }
$_SESSION[settings][permissions] = decode_array($_SESSION[settings][permissions]); if ($_SESSION[settings][edit] && ($_SESSION[settings][recursiveenable] || count($_SESSION[settings][copydownpermissions]))) { // recursively change the $active or $permissions field for all parts of the site $stories = decode_array(db_get_value("pages", "stories", "id='" . addslashes($_SESSION[settings][page]) . "'")); foreach ($stories as $s) { $sa = db_get_line("stories", "id='" . addslashes($s) . "'"); $chg = array(); if ($recursiveenable && permission($_SESSION['auser'], PAGE, EDIT, $p)) { $chg[] = "active='" . addslashes($_SESSION[settings][active]) . "'"; } if (count($_SESSION[settings][copydownpermissions]) && $_SESSION['auser'] == $_SESSION[settings][site_owner]) { $sp = decode_array($sa['permissions']); foreach ($_SESSION[settings][copydownpermissions] as $e) { $sp[$e] = $_SESSION[settings][permissions][$e]; } $sp = encode_array($sp); $chg[] = "permissions='" . addslashes($sp) . "'"; } $query = "update stories set " . implode(",", $chg) . " where id='" . addslashes($s) . "'"; print "--> " . $query . "<br />"; if (count($chg)) { db_query($query); } } } header("Location: index.php?{$sid}&action=viewsite&site=" . $thisSite->name . "§ion=" . $thisSection->id . ($_SESSION[pageObj]->getField("type") == 'page' ? "&page=" . $_SESSION[pageObj]->id : "")); exit; } else { $_SESSION[settings][step] = 1; } }
$theme = $_REQUEST['theme']; if (!preg_match('/^[a-z0-9_-]+$/i', $theme)) { die('Error: invalid theme name, "' . $theme . '"'); } $filename = "themes/{$theme}/themesettings.inc.php"; if (file_exists($filename)) { ob_start(); include $filename; $settings_form = ob_get_contents(); ob_end_clean(); } else { printc("<b>There are no additional options available for this theme.</b>"); } if ($_REQUEST['submitted']) { $onLoad = ' onload="'; $themesettings = encode_array($themesettings); if ($_REQUEST['updatemethod'] == 'javascript') { $onLoad .= 'update()'; } if ($_REQUEST['updatemethod'] == 'db') { $onLoad .= 'window.close()'; // update the database } $onLoad .= '"'; } else { // print out theme form printc("<form action='{$PHP_SELF}?{$sid}' method='post' name='settings'>"); printc("<input type='hidden' name='submitted' value='1' />"); printc("<input type='hidden' name='updatemethod' value='" . $_REQUEST['updatemethod'] . "' />"); printc("<input type='hidden' name='site' value='" . $_REQUEST['site'] . "' />"); printc("<input type='hidden' name='theme' value='{$theme}' />");
$section = -1; foreach ($_POST as $key => $val) { if (str_replace('massaction_check_', "", $key) == $val) { $modids[] = $val; } else { if (substr($key, 0, 4) == 'act_') { $action = substr($key, 4); } } } if ($encoded_modids = optional_param('modids', false)) { $modids = decode_array($encoded_modids); } // Turn arrays into strings that can easily be passed $encoded_post = encode_array($_POST); $encoded_mods = encode_array($modids); if (!isset($action) && isset($_POST['action'])) { $action = $_POST['action']; } if (optional_param('cancel', false)) { redirect($return_to); } if (!isset($action)) { redirect($return_to, "No action was specified"); } else { if (empty($modids)) { redirect($return_to, "No modules were selected"); } } if (!check_permission($instance_id)) { redirect($return_to, "You do not have permission to do that");