Exemplo n.º 1
0
function copysub($items, $parent, &$addtoarr)
{
    global $itemcnt, $toexport;
    global $checked;
    foreach ($items as $k => $item) {
        if (is_array($item)) {
            if (array_search($parent . '-' . ($k + 1), $checked) !== FALSE) {
                //copy block
                $newblock = array();
                $newblock['name'] = $item['name'];
                $newblock['avail'] = $item['avail'];
                $newblock['startdate'] = $item['startdate'];
                $newblock['enddate'] = $item['enddate'];
                $newblock['SH'] = $item['SH'];
                $newblock['colors'] = $item['colors'];
                $newblock['public'] = $item['public'];
                $newblock['fixedheight'] = $item['fixedheight'];
                $newblock['items'] = array();
                copysub($item['items'], $parent . '-' . ($k + 1), $newblock['items']);
                $addtoarr[] = $newblock;
            } else {
                copysub($item['items'], $parent . '-' . ($k + 1), $addtoarr);
            }
        } else {
            if (array_search($item, $checked) !== FALSE) {
                $toexport[$itemcnt] = $item;
                $addtoarr[] = $itemcnt;
                $itemcnt++;
            }
        }
    }
}
Exemplo n.º 2
0
 $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
     }
     array_splice($sub, count($sub), 0, $newitems);
Exemplo n.º 3
0
function copysub($items, $parent, &$addtoarr)
{
    global $checked, $blockcnt, $item, $questions, $qset;
    foreach ($items as $k => $anitem) {
        if (is_array($anitem)) {
            if (array_search($parent . '-' . ($k + 1), $checked) !== FALSE) {
                //copy block
                $newblock = array();
                $newblock['name'] = $anitem['name'];
                $newblock['id'] = $blockcnt;
                $blockcnt++;
                $newblock['startdate'] = $anitem['startdate'];
                $newblock['enddate'] = $anitem['enddate'];
                $newblock['avail'] = $anitem['avail'];
                $newblock['SH'] = $anitem['SH'];
                $newblock['colors'] = $anitem['colors'];
                $newblock['public'] = $anitem['public'];
                $newblock['fixedheight'] = $anitem['fixedheight'];
                $newblock['items'] = array();
                copysub($anitem['items'], $parent . '-' . ($k + 1), $newblock['items']);
                $addtoarr[] = $newblock;
            } else {
                copysub($anitem['items'], $parent . '-' . ($k + 1), $addtoarr);
            }
        } else {
            if (array_search($anitem, $checked) !== FALSE) {
                $addtoarr[] = additem($anitem, $item, $questions, $qset);
            }
        }
    }
}
Exemplo n.º 4
0
function copysub($items, $parent, &$addtoarr, $gbcats, $sethidden = false)
{
    global $checked, $blockcnt;
    foreach ($items as $k => $item) {
        if (is_array($item)) {
            if (array_search($parent . '-' . ($k + 1), $checked) !== FALSE) {
                //copy block
                $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) {
                    copysub($item['items'], $parent . '-' . ($k + 1), $newblock['items'], $gbcats, $sethidden);
                }
                $addtoarr[] = $newblock;
            } else {
                if (count($item['items']) > 0) {
                    copysub($item['items'], $parent . '-' . ($k + 1), $addtoarr, $gbcats, $sethidden);
                }
            }
        } else {
            if (array_search($item, $checked) !== FALSE) {
                $addtoarr[] = copyitem($item, $gbcats, $sethidden);
            }
        }
    }
}