Exemple #1
0
 if (isset($_POST['checked']) || $_POST['whattocopy'] == 'all') {
     $checked = $_POST['checked'];
     $query = "SELECT blockcnt FROM imas_courses WHERE id='{$cid}'";
     $result = mysql_query($query) or die("Query failed : {$query}" . mysql_error());
     $blockcnt = mysql_result($result, 0, 0);
     $query = "SELECT itemorder FROM imas_courses WHERE id='{$_POST['ctc']}'";
     $result = mysql_query($query) or die("Query failed : {$query}" . mysql_error());
     $items = unserialize(mysql_result($result, 0, 0));
     $newitems = array();
     if (isset($_POST['copystickyposts'])) {
         $copystickyposts = true;
     } else {
         $copystickyposts = false;
     }
     if ($_POST['whattocopy'] == 'all') {
         copyallsub($items, '0', $newitems, $gbcats);
     } else {
         copysub($items, '0', $newitems, $gbcats, isset($_POST['copyhidden']));
     }
     doaftercopy($_POST['ctc']);
     $query = "SELECT itemorder FROM imas_courses WHERE id='{$cid}'";
     $result = mysql_query($query) or die("Query failed : {$query}" . mysql_error());
     $items = unserialize(mysql_result($result, 0, 0));
     if ($_POST['addto'] == "none") {
         array_splice($items, count($items), 0, $newitems);
     } else {
         $blocktree = explode('-', $_POST['addto']);
         $sub =& $items;
         for ($i = 1; $i < count($blocktree); $i++) {
             $sub =& $sub[$blocktree[$i] - 1]['items'];
             //-1 to adjust for 1-indexing
Exemple #2
0
function copyallsub($items, $parent, &$addtoarr, $gbcats, $sethidden = false)
{
    global $blockcnt, $reqscoretrack, $assessnewid;
    if (strlen($_POST['append']) > 0 && $_POST['append'][0] != ' ') {
        $_POST['append'] = ' ' . $_POST['append'];
    }
    foreach ($items as $k => $item) {
        if (is_array($item)) {
            $newblock = array();
            $newblock['name'] = $item['name'] . stripslashes($_POST['append']);
            $newblock['id'] = $blockcnt;
            $blockcnt++;
            $newblock['startdate'] = $item['startdate'];
            $newblock['enddate'] = $item['enddate'];
            $newblock['avail'] = $sethidden ? 0 : $item['avail'];
            $newblock['SH'] = $item['SH'];
            $newblock['colors'] = $item['colors'];
            $newblock['public'] = $item['public'];
            $newblock['fixedheight'] = $item['fixedheight'];
            $newblock['grouplimit'] = $item['grouplimit'];
            $newblock['items'] = array();
            if (count($item['items']) > 0) {
                copyallsub($item['items'], $parent . '-' . ($k + 1), $newblock['items'], $gbcats, $sethidden);
            }
            $addtoarr[] = $newblock;
        } else {
            if ($item != null && $item != 0) {
                $addtoarr[] = copyitem($item, $gbcats, $sethidden);
            }
        }
    }
}